• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2017 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 XFA_FGAS_LAYOUT_CFX_BREAK_H_
8 #define XFA_FGAS_LAYOUT_CFX_BREAK_H_
9 
10 #include <stdint.h>
11 
12 #include "core/fxcrt/retain_ptr.h"
13 #include "xfa/fgas/layout/cfx_breakline.h"
14 
15 class CFGAS_GEFont;
16 
17 struct FX_TPO {
18   bool operator<(const FX_TPO& that) const { return pos < that.pos; }
19 
20   int32_t index;
21   int32_t pos;
22 };
23 
24 enum FX_LAYOUTSTYLE {
25   FX_LAYOUTSTYLE_None = 0,
26   FX_LAYOUTSTYLE_Pagination = 0x01,
27   FX_LAYOUTSTYLE_ExpandTab = 0x10,
28   FX_LAYOUTSTYLE_SingleLine = 0x200,
29   FX_LAYOUTSTYLE_CombText = 0x400
30 };
31 
32 class CFX_Break {
33  public:
34   virtual ~CFX_Break();
35 
36   void Reset();
37 
38   void SetLayoutStyles(uint32_t dwLayoutStyles);
GetLayoutStyles()39   uint32_t GetLayoutStyles() const { return m_dwLayoutStyles; }
40 
41   void SetFont(const RetainPtr<CFGAS_GEFont>& pFont);
42   void SetFontSize(float fFontSize);
43   void SetTabWidth(float fTabWidth);
GetTabWidth()44   int32_t GetTabWidth() const { return m_iTabWidth; }
45 
46   void SetHorizontalScale(int32_t iScale);
47   void SetVerticalScale(int32_t iScale);
48   void SetLineBreakTolerance(float fTolerance);
49   void SetLineBoundary(float fLineStart, float fLineEnd);
50 
51   void SetCharSpace(float fCharSpace);
52   void SetParagraphBreakChar(wchar_t wch);
53   void SetDefaultChar(wchar_t wch);
54 
55   int32_t CountBreakPieces() const;
56   const CFX_BreakPiece* GetBreakPieceUnstable(int32_t index) const;
57   void ClearBreakPieces();
58 
59   CFX_Char* GetLastChar(int32_t index, bool bOmitChar, bool bRichText) const;
60 
61  protected:
62   explicit CFX_Break(uint32_t dwLayoutStyles);
63 
64   void SetBreakStatus();
HasLine()65   bool HasLine() const { return m_iReadyLineIndex >= 0; }
66   FX_CHARTYPE GetUnifiedCharType(FX_CHARTYPE dwType) const;
67 
68   FX_CHARTYPE m_eCharType;
69   bool m_bSingleLine;
70   bool m_bCombText;
71   uint32_t m_dwIdentity;
72   uint32_t m_dwLayoutStyles;
73   int32_t m_iLineStart;
74   int32_t m_iLineWidth;
75   wchar_t m_wParagraphBreakChar;
76   int32_t m_iFontSize;
77   int32_t m_iTabWidth;
78   int32_t m_iHorizontalScale;
79   int32_t m_iVerticalScale;
80   int32_t m_iTolerance;
81   int32_t m_iCharSpace;
82   int32_t m_iDefChar;
83   wchar_t m_wDefChar;
84   RetainPtr<CFGAS_GEFont> m_pFont;
85   CFX_BreakLine m_Line[2];
86   CFX_BreakLine* m_pCurLine;
87   int8_t m_iReadyLineIndex;
88 
89  private:
90   void FontChanged();
91 };
92 
93 #endif  // XFA_FGAS_LAYOUT_CFX_BREAK_H_
94