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
16class CPDF_TextPage;
17
18class CPDF_TextPageFind {
19 public:
20  explicit CPDF_TextPageFind(const CPDF_TextPage* pTextPage);
21  ~CPDF_TextPageFind();
22
23  bool FindFirst(const CFX_WideString& findwhat, int flags, int startPos = 0);
24  bool FindNext();
25  bool FindPrev();
26  int GetCurOrder() const;
27  int GetMatchedCount() const;
28
29 protected:
30  void ExtractFindWhat(const CFX_WideString& findwhat);
31  bool IsMatchWholeWord(const CFX_WideString& csPageText,
32                        int startPos,
33                        int endPos);
34  bool ExtractSubString(CFX_WideString& rString,
35                        const FX_WCHAR* lpszFullString,
36                        int iSubString,
37                        FX_WCHAR chSep);
38  CFX_WideString MakeReverse(const CFX_WideString& str);
39  int GetCharIndex(int index) const;
40
41 private:
42  std::vector<uint16_t> m_CharIndex;
43  const CPDF_TextPage* m_pTextPage;
44  CFX_WideString m_strText;
45  CFX_WideString m_findWhat;
46  int m_flags;
47  std::vector<CFX_WideString> m_csFindWhatArray;
48  int m_findNextStart;
49  int m_findPreStart;
50  bool m_bMatchCase;
51  bool m_bMatchWholeWord;
52  int m_resStart;
53  int m_resEnd;
54  std::vector<CFX_FloatRect> m_resArray;
55  bool m_IsFind;
56};
57
58#endif  // CORE_FPDFTEXT_CPDF_TEXTPAGEFIND_H_
59