OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #ifndef XFA_FEE_FX_WORDBREAK_FX_WORDBREAK_H_ | 7 #ifndef XFA_FEE_FX_WORDBREAK_FX_WORDBREAK_H_ |
8 #define XFA_FEE_FX_WORDBREAK_FX_WORDBREAK_H_ | 8 #define XFA_FEE_FX_WORDBREAK_FX_WORDBREAK_H_ |
9 | 9 |
| 10 #include <memory> |
| 11 |
10 #include "core/fxcrt/include/fx_string.h" | 12 #include "core/fxcrt/include/fx_string.h" |
11 #include "core/fxcrt/include/fx_system.h" | 13 #include "core/fxcrt/include/fx_system.h" |
12 #include "xfa/fee/ifde_txtedtengine.h" | 14 #include "xfa/fee/ifde_txtedtengine.h" |
13 | 15 |
14 class CFX_CharIter : public IFX_CharIter { | 16 class CFX_CharIter : public IFX_CharIter { |
15 public: | 17 public: |
16 CFX_CharIter(const CFX_WideString& wsText); | 18 explicit CFX_CharIter(const CFX_WideString& wsText); |
17 virtual void Release(); | 19 ~CFX_CharIter() override; |
18 virtual FX_BOOL Next(FX_BOOL bPrev = FALSE); | |
19 virtual FX_WCHAR GetChar(); | |
20 virtual void SetAt(int32_t nIndex); | |
21 virtual int32_t GetAt() const; | |
22 virtual FX_BOOL IsEOF(FX_BOOL bTail = TRUE) const; | |
23 virtual IFX_CharIter* Clone(); | |
24 | 20 |
25 protected: | 21 FX_BOOL Next(FX_BOOL bPrev = FALSE) override; |
26 ~CFX_CharIter(); | 22 FX_WCHAR GetChar() override; |
| 23 void SetAt(int32_t nIndex) override; |
| 24 int32_t GetAt() const override; |
| 25 FX_BOOL IsEOF(FX_BOOL bTail = TRUE) const override; |
| 26 IFX_CharIter* Clone() override; |
27 | 27 |
28 private: | 28 private: |
29 const CFX_WideString& m_wsText; | 29 const CFX_WideString& m_wsText; |
30 int32_t m_nIndex; | 30 int32_t m_nIndex; |
31 }; | 31 }; |
| 32 |
32 class CFX_WordBreak { | 33 class CFX_WordBreak { |
33 public: | 34 public: |
34 CFX_WordBreak(); | 35 CFX_WordBreak(); |
| 36 ~CFX_WordBreak(); |
35 | 37 |
36 void Release(); | |
37 void Attach(IFX_CharIter* pIter); | 38 void Attach(IFX_CharIter* pIter); |
38 void Attach(const CFX_WideString& wsText); | 39 void Attach(const CFX_WideString& wsText); |
39 FX_BOOL Next(FX_BOOL bPrev); | 40 FX_BOOL Next(FX_BOOL bPrev); |
40 void SetAt(int32_t nIndex); | 41 void SetAt(int32_t nIndex); |
41 int32_t GetWordPos() const; | 42 int32_t GetWordPos() const; |
42 int32_t GetWordLength() const; | 43 int32_t GetWordLength() const; |
43 void GetWord(CFX_WideString& wsWord) const; | 44 void GetWord(CFX_WideString& wsWord) const; |
44 FX_BOOL IsEOF(FX_BOOL bTail) const; | 45 FX_BOOL IsEOF(FX_BOOL bTail) const; |
45 | 46 |
46 protected: | 47 protected: |
47 ~CFX_WordBreak(); | |
48 FX_BOOL FindNextBreakPos(IFX_CharIter* pIter, | 48 FX_BOOL FindNextBreakPos(IFX_CharIter* pIter, |
49 FX_BOOL bPrev, | 49 FX_BOOL bPrev, |
50 FX_BOOL bFromNext = TRUE); | 50 FX_BOOL bFromNext = TRUE); |
51 | 51 |
52 private: | 52 private: |
53 IFX_CharIter* m_pPreIter; | 53 std::unique_ptr<IFX_CharIter> m_pPreIter; |
54 IFX_CharIter* m_pCurIter; | 54 std::unique_ptr<IFX_CharIter> m_pCurIter; |
55 }; | 55 }; |
56 | 56 |
57 #endif // XFA_FEE_FX_WORDBREAK_FX_WORDBREAK_H_ | 57 #endif // XFA_FEE_FX_WORDBREAK_FX_WORDBREAK_H_ |
OLD | NEW |