• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2014 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 _FX_WORDBREAK_IMPL_H
8 #define _FX_WORDBREAK_IMPL_H
9 extern const FX_WORD gs_FX_WordBreak_Table[16];
10 extern const uint8_t gs_FX_WordBreak_CodePointProperties[(0xFFFF - 1) / 2 + 1];
11 enum FX_WordBreakProp {
12   FX_WordBreakProp_None = 0,
13   FX_WordBreakProp_CR,
14   FX_WordBreakProp_LF,
15   FX_WordBreakProp_NewLine,
16   FX_WordBreakProp_Extend,
17   FX_WordBreakProp_Format,
18   FX_WordBreakProp_KataKana,
19   FX_WordBreakProp_ALetter,
20   FX_WordBreakProp_MidLetter,
21   FX_WordBreakProp_MidNum,
22   FX_WordBreakProp_MidNumLet,
23   FX_WordBreakProp_Numberic,
24   FX_WordBreakProp_ExtendNumLet,
25 };
26 FX_WordBreakProp FX_GetWordBreakProperty(FX_WCHAR wcCodePoint);
27 class CFX_CharIter : public IFX_CharIter {
28  public:
29   CFX_CharIter(const CFX_WideString& wsText);
30   virtual void Release();
31   virtual FX_BOOL Next(FX_BOOL bPrev = FALSE);
32   virtual FX_WCHAR GetChar();
33   virtual void SetAt(int32_t nIndex);
34   virtual int32_t GetAt() const;
35   virtual FX_BOOL IsEOF(FX_BOOL bTail = TRUE) const;
36   virtual IFX_CharIter* Clone();
37 
38  protected:
39   ~CFX_CharIter();
40 
41  private:
42   const CFX_WideString& m_wsText;
43   int32_t m_nIndex;
44 };
45 class CFX_WordBreak : public IFX_WordBreak {
46  public:
47   CFX_WordBreak();
48   virtual void Release();
49   virtual void Attach(IFX_CharIter* pIter);
50   virtual void Attach(const CFX_WideString& wsText);
51   virtual FX_BOOL Next(FX_BOOL bPrev);
52   virtual void SetAt(int32_t nIndex);
53   virtual int32_t GetWordPos() const;
54   virtual int32_t GetWordLength() const;
55   virtual void GetWord(CFX_WideString& wsWord) const;
56   virtual FX_BOOL IsEOF(FX_BOOL bTail) const;
57 
58  protected:
59   ~CFX_WordBreak();
60   FX_BOOL FindNextBreakPos(IFX_CharIter* pIter,
61                            FX_BOOL bPrev,
62                            FX_BOOL bFromNext = TRUE);
63 
64  private:
65   IFX_CharIter* m_pPreIter;
66   IFX_CharIter* m_pCurIter;
67 };
68 #endif
69