Merge to XFA: Use stdint.h types throughout PDFium.
[pdfium.git] / xfa / src / fgas / src / layout / fx_textbreak.h
1 // Copyright 2014 PDFium Authors. All rights reserved.\r
2 // Use of this source code is governed by a BSD-style license that can be\r
3 // found in the LICENSE file.\r
4 \r
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com\r
6 \r
7 #ifndef _FX_TEXTBREAK_IMP\r
8 #define _FX_TEXTBREAK_IMP\r
9 class CFX_TxtLine;\r
10 class CFX_Txtbreak;\r
11 class CFX_TxtLine\r
12 {\r
13 public:\r
14     CFX_TxtLine(int32_t iBlockSize) : m_iStart(0)\r
15         , m_iWidth(0)\r
16         , m_iArabicChars(0)\r
17     {\r
18         m_pLineChars = FX_NEW CFX_TxtCharArray;\r
19         m_pLinePieces = FXTARGET_New CFX_TxtPieceArray(16);\r
20     }\r
21     ~CFX_TxtLine()\r
22     {\r
23         RemoveAll();\r
24         delete m_pLineChars;\r
25         FXTARGET_Delete m_pLinePieces;\r
26     }\r
27     int32_t CountChars() const\r
28     {\r
29         return m_pLineChars->GetSize();\r
30     }\r
31     CFX_TxtChar* GetCharPtr(int32_t index) const\r
32     {\r
33         FXSYS_assert(index > -1 && index < m_pLineChars->GetSize());\r
34         return m_pLineChars->GetDataPtr(index);\r
35     }\r
36     int32_t CountPieces() const\r
37     {\r
38         return m_pLinePieces->GetSize();\r
39     }\r
40     CFX_TxtPiece* GetPiecePtr(int32_t index) const\r
41     {\r
42         FXSYS_assert(index > -1 && index < m_pLinePieces->GetSize());\r
43         return m_pLinePieces->GetPtrAt(index);\r
44     }\r
45     void GetString(CFX_WideString &wsStr) const\r
46     {\r
47         int32_t iCount = m_pLineChars->GetSize();\r
48         FX_LPWSTR pBuf = wsStr.GetBuffer(iCount);\r
49         CFX_Char *pChar;\r
50         for (int32_t i = 0; i < iCount; i ++) {\r
51             pChar = m_pLineChars->GetDataPtr(i);\r
52             *pBuf ++ = (FX_WCHAR)pChar->m_wCharCode;\r
53         }\r
54         wsStr.ReleaseBuffer(iCount);\r
55     }\r
56     void RemoveAll(FX_BOOL bLeaveMemory = FALSE)\r
57     {\r
58         m_pLineChars->RemoveAll();\r
59         m_pLinePieces->RemoveAll(bLeaveMemory);\r
60         m_iWidth = 0;\r
61         m_iArabicChars = 0;\r
62     }\r
63     CFX_TxtCharArray    *m_pLineChars;\r
64     CFX_TxtPieceArray   *m_pLinePieces;\r
65     int32_t                     m_iStart;\r
66     int32_t                     m_iWidth;\r
67     int32_t                     m_iArabicChars;\r
68 };\r
69 class CFX_TxtBreak : public IFX_TxtBreak\r
70 {\r
71 public:\r
72     CFX_TxtBreak(FX_DWORD dwPolicies);\r
73     ~CFX_TxtBreak();\r
74     virtual void                        Release()\r
75     {\r
76         delete this;\r
77     }\r
78     virtual void                        SetLineWidth(FX_FLOAT fLineWidth);\r
79     virtual void                        SetLinePos(FX_FLOAT fLinePos);\r
80     virtual FX_DWORD            GetLayoutStyles() const\r
81     {\r
82         return m_dwLayoutStyles;\r
83     }\r
84     virtual void                        SetLayoutStyles(FX_DWORD dwLayoutStyles);\r
85     virtual void                        SetFont(IFX_Font *pFont);\r
86     virtual void                        SetFontSize(FX_FLOAT fFontSize);\r
87     virtual void                        SetTabWidth(FX_FLOAT fTabWidth, FX_BOOL bEquidistant);\r
88     virtual void                        SetDefaultChar(FX_WCHAR wch);\r
89     virtual void                        SetParagraphBreakChar(FX_WCHAR wch);\r
90     virtual void                        SetLineBreakTolerance(FX_FLOAT fTolerance);\r
91     virtual void                        SetHorizontalScale(int32_t iScale);\r
92     virtual void                        SetVerticalScale(int32_t iScale);\r
93     virtual void                        SetCharRotation(int32_t iCharRotation);\r
94     virtual void                        SetCharSpace(FX_FLOAT fCharSpace);\r
95     virtual void                        SetAlignment(int32_t iAlignment);\r
96     virtual FX_DWORD            GetContextCharStyles() const;\r
97     virtual void                        SetContextCharStyles(FX_DWORD dwCharStyles);\r
98     virtual void                        SetCombWidth(FX_FLOAT fCombWidth);\r
99     virtual void                        SetUserData(FX_LPVOID pUserData);\r
100     virtual FX_DWORD                            AppendChar(FX_WCHAR wch);\r
101     virtual FX_DWORD                            EndBreak(FX_DWORD dwStatus = FX_TXTBREAK_PieceBreak);\r
102     virtual int32_t                             CountBreakChars() const;\r
103     virtual int32_t                             CountBreakPieces() const;\r
104     virtual const CFX_TxtPiece*         GetBreakPiece(int32_t index) const;\r
105     virtual void                                        ClearBreakPieces();\r
106     virtual void                        Reset();\r
107     virtual int32_t             GetDisplayPos(FX_LPCTXTRUN pTxtRun, FXTEXT_CHARPOS *pCharPos, FX_BOOL bCharCode = FALSE, CFX_WideString *pWSForms = NULL, FX_AdjustCharDisplayPos pAdjustPos = NULL) const;\r
108     virtual int32_t             GetCharRects(FX_LPCTXTRUN pTxtRun, CFX_RectFArray &rtArray, FX_BOOL bCharBBox = FALSE) const;\r
109     void                                AppendChar_PageLoad(CFX_Char *pCurChar, FX_DWORD dwProps);\r
110     FX_DWORD                    AppendChar_Combination(CFX_Char *pCurChar, int32_t iRotation);\r
111     FX_DWORD                    AppendChar_Tab(CFX_Char *pCurChar, int32_t iRotation);\r
112     FX_DWORD                    AppendChar_Control(CFX_Char *pCurChar, int32_t iRotation);\r
113     FX_DWORD                    AppendChar_Arabic(CFX_Char *pCurChar, int32_t iRotation);\r
114     FX_DWORD                    AppendChar_Others(CFX_Char *pCurChar, int32_t iRotation);\r
115 protected:\r
116     FX_DWORD                    m_dwPolicies;\r
117     FX_BOOL                             m_bPagination;\r
118     IFX_ArabicChar              *m_pArabicChar;\r
119     int32_t                     m_iLineWidth;\r
120     FX_DWORD                    m_dwLayoutStyles;\r
121     FX_BOOL                             m_bVertical;\r
122     FX_BOOL                             m_bArabicContext;\r
123     FX_BOOL                             m_bArabicShapes;\r
124     FX_BOOL                             m_bRTL;\r
125     FX_BOOL                             m_bSingleLine;\r
126     FX_BOOL                             m_bCombText;\r
127     int32_t                     m_iArabicContext;\r
128     int32_t                     m_iCurArabicContext;\r
129     IFX_Font                    *m_pFont;\r
130     int32_t                     m_iFontSize;\r
131     FX_BOOL                             m_bEquidistant;\r
132     int32_t                     m_iTabWidth;\r
133     FX_WCHAR                    m_wDefChar;\r
134     FX_WCHAR                    m_wParagBreakChar;\r
135     int32_t                     m_iDefChar;\r
136     int32_t                     m_iLineRotation;\r
137     int32_t                     m_iCharRotation;\r
138     int32_t                     m_iRotation;\r
139     int32_t                     m_iAlignment;\r
140     FX_DWORD                    m_dwContextCharStyles;\r
141     int32_t                     m_iCombWidth;\r
142     FX_LPVOID                   m_pUserData;\r
143     FX_DWORD                    m_dwCharType;\r
144     FX_BOOL                             m_bCurRTL;\r
145     int32_t                     m_iCurAlignment;\r
146     FX_BOOL                             m_bArabicNumber;\r
147     FX_BOOL                             m_bArabicComma;\r
148     CFX_TxtLine                 *m_pTxtLine1;\r
149     CFX_TxtLine                 *m_pTxtLine2;\r
150     CFX_TxtLine                 *m_pCurLine;\r
151     int32_t                     m_iReady;\r
152     int32_t                     m_iTolerance;\r
153     int32_t                     m_iHorScale;\r
154     int32_t                     m_iVerScale;\r
155     int32_t                     m_iCharSpace;\r
156     void                                SetBreakStatus();\r
157     int32_t                     GetLineRotation(FX_DWORD dwStyles) const;\r
158     CFX_TxtChar*                GetLastChar(int32_t index, FX_BOOL bOmitChar = TRUE) const;\r
159     CFX_TxtLine*                GetTxtLine(FX_BOOL bReady) const;\r
160     CFX_TxtPieceArray*  GetTxtPieces(FX_BOOL bReady) const;\r
161     FX_DWORD                    GetUnifiedCharType(FX_DWORD dwType) const;\r
162     void                                ResetArabicContext();\r
163     void                                ResetContextCharStyles();\r
164     void                                EndBreak_UpdateArabicShapes();\r
165     FX_BOOL                             EndBreak_SplitLine(CFX_TxtLine *pNextLine, FX_BOOL bAllChars, FX_DWORD dwStatus);\r
166     void                                EndBreak_BidiLine(CFX_TPOArray &tpos, FX_DWORD dwStatus);\r
167     void                                EndBreak_Alignment(CFX_TPOArray &tpos, FX_BOOL bAllChars, FX_DWORD dwStatus);\r
168     int32_t                     GetBreakPos(CFX_TxtCharArray &ca, int32_t &iEndPos, FX_BOOL bAllChars = FALSE, FX_BOOL bOnlyBrk = FALSE);\r
169     void                                SplitTextLine(CFX_TxtLine *pCurLine, CFX_TxtLine *pNextLine, FX_BOOL bAllChars = FALSE);\r
170 };\r
171 #endif\r