// Copyright 2016 PDFium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com #ifndef CORE_FPDFTEXT_CPDF_TEXTPAGEFIND_H_ #define CORE_FPDFTEXT_CPDF_TEXTPAGEFIND_H_ #include #include #include "core/fxcrt/fx_coordinates.h" #include "core/fxcrt/fx_string.h" #include "core/fxcrt/fx_system.h" #include "core/fxcrt/unowned_ptr.h" #include "third_party/base/optional.h" class CPDF_TextPage; class CPDF_TextPageFind { public: struct Options { bool bMatchCase = false; bool bMatchWholeWord = false; bool bConsecutive = false; }; static std::unique_ptr Create( const CPDF_TextPage* pTextPage, const WideString& findwhat, const Options& options, Optional startPos); ~CPDF_TextPageFind(); bool FindNext(); bool FindPrev(); int GetCurOrder() const; int GetMatchedCount() const; private: CPDF_TextPageFind(const CPDF_TextPage* pTextPage, const std::vector& findwhat_array, const Options& options, Optional startPos); // Should be called immediately after construction. bool FindFirst(); int GetCharIndex(int index) const; UnownedPtr const m_pTextPage; const WideString m_strText; const std::vector m_csFindWhatArray; Optional m_findNextStart; Optional m_findPreStart; int m_resStart = 0; int m_resEnd = -1; const Options m_options; }; #endif // CORE_FPDFTEXT_CPDF_TEXTPAGEFIND_H_