• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2016 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 
7 #ifndef CORE_FPDFTEXT_CPDF_TEXTPAGEFIND_H_
8 #define CORE_FPDFTEXT_CPDF_TEXTPAGEFIND_H_
9 
10 #include <vector>
11 
12 #include "core/fxcrt/fx_coordinates.h"
13 #include "core/fxcrt/fx_string.h"
14 #include "core/fxcrt/fx_system.h"
15 #include "core/fxcrt/unowned_ptr.h"
16 #include "third_party/base/optional.h"
17 
18 class CPDF_TextPage;
19 
20 class CPDF_TextPageFind {
21  public:
22   explicit CPDF_TextPageFind(const CPDF_TextPage* pTextPage);
23   ~CPDF_TextPageFind();
24 
25   bool FindFirst(const WideString& findwhat,
26                  int flags,
27                  Optional<size_t> startPos);
28   bool FindNext();
29   bool FindPrev();
30   int GetCurOrder() const;
31   int GetMatchedCount() const;
32 
33  protected:
34   void ExtractFindWhat(const WideString& findwhat);
35   bool IsMatchWholeWord(const WideString& csPageText,
36                         size_t startPos,
37                         size_t endPos);
38   Optional<WideString> ExtractSubString(const wchar_t* lpszFullString,
39                                         int iSubString,
40                                         wchar_t chSep);
41   int GetCharIndex(int index) const;
42 
43  private:
44   std::vector<uint16_t> m_CharIndex;
45   UnownedPtr<const CPDF_TextPage> m_pTextPage;
46   WideString m_strText;
47   WideString m_findWhat;
48   int m_flags;
49   std::vector<WideString> m_csFindWhatArray;
50   Optional<size_t> m_findNextStart;
51   Optional<size_t> m_findPreStart;
52   bool m_bMatchCase;
53   bool m_bMatchWholeWord;
54   int m_resStart;
55   int m_resEnd;
56   std::vector<CFX_FloatRect> m_resArray;
57   bool m_IsFind;
58 };
59 
60 #endif  // CORE_FPDFTEXT_CPDF_TEXTPAGEFIND_H_
61