Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(523)

Side by Side Diff: xfa/src/fgas/layout/fgas_textbreak.h

Issue 1803723002: Move xfa/src up to xfa/. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Rebase to master Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « xfa/src/fgas/layout/fgas_rtfbreak.cpp ('k') | xfa/src/fgas/layout/fgas_textbreak.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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 XFA_SRC_FGAS_LAYOUT_FGAS_TEXTBREAK_H_
8 #define XFA_SRC_FGAS_LAYOUT_FGAS_TEXTBREAK_H_
9
10 #include "core/include/fxcrt/fx_ucd.h"
11 #include "core/include/fxge/fx_ge.h"
12 #include "xfa/src/fgas/crt/fgas_utils.h"
13 #include "xfa/src/fgas/layout/fgas_unicode.h"
14
15 class IFX_Font;
16 class CFX_Char;
17 class IFX_TxtAccess;
18 class CFX_TxtChar;
19 class CFX_TxtPiece;
20 class IFX_TxtBreak;
21
22 #define FX_TXTBREAKPOLICY_None 0x00
23 #define FX_TXTBREAKPOLICY_Pagination 0x01
24 #define FX_TXTBREAKPOLICY_SpaceBreak 0x02
25 #define FX_TXTBREAKPOLICY_NumberBreak 0x04
26 #define FX_TXTBREAK_None 0x00
27 #define FX_TXTBREAK_PieceBreak 0x01
28 #define FX_TXTBREAK_LineBreak 0x02
29 #define FX_TXTBREAK_ParagraphBreak 0x03
30 #define FX_TXTBREAK_PageBreak 0x04
31 #define FX_TXTBREAK_ControlChar 0x10
32 #define FX_TXTBREAK_BreakChar 0x20
33 #define FX_TXTBREAK_UnknownChar 0x40
34 #define FX_TXTBREAK_RemoveChar 0x80
35 #define FX_TXTLAYOUTSTYLE_MutipleFormat 0x0001
36 #define FX_TXTLAYOUTSTYLE_VerticalLayout 0x0002
37 #define FX_TXTLAYOUTSTYLE_VerticalChars 0x0004
38 #define FX_TXTLAYOUTSTYLE_ReverseLine 0x0008
39 #define FX_TXTLAYOUTSTYLE_ArabicContext 0x0010
40 #define FX_TXTLAYOUTSTYLE_ArabicShapes 0x0020
41 #define FX_TXTLAYOUTSTYLE_RTLReadingOrder 0x0040
42 #define FX_TXTLAYOUTSTYLE_ExpandTab 0x0100
43 #define FX_TXTLAYOUTSTYLE_SingleLine 0x0200
44 #define FX_TXTLAYOUTSTYLE_CombText 0x0400
45 #define FX_TXTCHARSTYLE_Alignment 0x000F
46 #define FX_TXTCHARSTYLE_ArabicNumber 0x0010
47 #define FX_TXTCHARSTYLE_ArabicShadda 0x0020
48 #define FX_TXTCHARSTYLE_OddBidiLevel 0x0040
49 #define FX_TXTCHARSTYLE_RTLReadingOrder 0x0080
50 #define FX_TXTCHARSTYLE_ArabicContext 0x0300
51 #define FX_TXTCHARSTYLE_ArabicIndic 0x0400
52 #define FX_TXTCHARSTYLE_ArabicComma 0x0800
53 #define FX_TXTLINEALIGNMENT_Left 0
54 #define FX_TXTLINEALIGNMENT_Center 1
55 #define FX_TXTLINEALIGNMENT_Right 2
56 #define FX_TXTLINEALIGNMENT_Justified (1 << 2)
57 #define FX_TXTLINEALIGNMENT_Distributed (2 << 2)
58 #define FX_TXTLINEALIGNMENT_JustifiedLeft \
59 (FX_TXTLINEALIGNMENT_Left | FX_TXTLINEALIGNMENT_Justified)
60 #define FX_TXTLINEALIGNMENT_JustifiedCenter \
61 (FX_TXTLINEALIGNMENT_Center | FX_TXTLINEALIGNMENT_Justified)
62 #define FX_TXTLINEALIGNMENT_JustifiedRight \
63 (FX_TXTLINEALIGNMENT_Right | FX_TXTLINEALIGNMENT_Justified)
64 #define FX_TXTLINEALIGNMENT_DistributedLeft \
65 (FX_TXTLINEALIGNMENT_Left | FX_TXTLINEALIGNMENT_Distributed)
66 #define FX_TXTLINEALIGNMENT_DistributedCenter \
67 (FX_TXTLINEALIGNMENT_Center | FX_TXTLINEALIGNMENT_Distributed)
68 #define FX_TXTLINEALIGNMENT_DistributedRight \
69 (FX_TXTLINEALIGNMENT_Right | FX_TXTLINEALIGNMENT_Distributed)
70 #define FX_TXTLINEALIGNMENT_LowerMask 0x03
71 #define FX_TXTLINEALIGNMENT_HigherMask 0x0C
72 #define FX_TXTBREAK_MinimumTabWidth 160000
73
74 class IFX_TxtAccess {
75 public:
76 virtual ~IFX_TxtAccess() {}
77 virtual FX_WCHAR GetChar(void* pIdentity, int32_t index) const = 0;
78 virtual int32_t GetWidth(void* pIdentity, int32_t index) const = 0;
79 };
80
81 struct FX_TXTRUN {
82 FX_TXTRUN() {
83 pAccess = NULL;
84 pIdentity = NULL;
85 pStr = NULL;
86 pWidths = NULL;
87 iLength = 0;
88 pFont = NULL;
89 fFontSize = 12;
90 dwStyles = 0;
91 iHorizontalScale = 100;
92 iVerticalScale = 100;
93 iCharRotation = 0;
94 dwCharStyles = 0;
95 pRect = NULL;
96 wLineBreakChar = L'\n';
97 bSkipSpace = TRUE;
98 }
99
100 IFX_TxtAccess* pAccess;
101 void* pIdentity;
102 const FX_WCHAR* pStr;
103 int32_t* pWidths;
104 int32_t iLength;
105 IFX_Font* pFont;
106 FX_FLOAT fFontSize;
107 FX_DWORD dwStyles;
108 int32_t iHorizontalScale;
109 int32_t iVerticalScale;
110 int32_t iCharRotation;
111 FX_DWORD dwCharStyles;
112 const CFX_RectF* pRect;
113 FX_WCHAR wLineBreakChar;
114 FX_BOOL bSkipSpace;
115 };
116
117 class CFX_TxtPiece : public CFX_Target {
118 public:
119 CFX_TxtPiece()
120 : m_dwStatus(FX_TXTBREAK_PieceBreak),
121 m_iStartPos(0),
122 m_iWidth(-1),
123 m_iStartChar(0),
124 m_iChars(0),
125 m_iBidiLevel(0),
126 m_iBidiPos(0),
127 m_iHorizontalScale(100),
128 m_iVerticalScale(100),
129 m_dwCharStyles(0),
130 m_pChars(NULL),
131 m_pUserData(NULL) {}
132 int32_t GetEndPos() const {
133 return m_iWidth < 0 ? m_iStartPos : m_iStartPos + m_iWidth;
134 }
135 int32_t GetLength() const { return m_iChars; }
136 int32_t GetEndChar() const { return m_iStartChar + m_iChars; }
137 CFX_TxtChar* GetCharPtr(int32_t index) const {
138 FXSYS_assert(index > -1 && index < m_iChars && m_pChars != NULL);
139 return m_pChars->GetDataPtr(m_iStartChar + index);
140 }
141 void GetString(FX_WCHAR* pText) const {
142 FXSYS_assert(pText != NULL);
143 int32_t iEndChar = m_iStartChar + m_iChars;
144 CFX_Char* pChar;
145 for (int32_t i = m_iStartChar; i < iEndChar; i++) {
146 pChar = m_pChars->GetDataPtr(i);
147 *pText++ = (FX_WCHAR)pChar->m_wCharCode;
148 }
149 }
150
151 void GetString(CFX_WideString& wsText) const {
152 FX_WCHAR* pText = wsText.GetBuffer(m_iChars);
153 GetString(pText);
154 wsText.ReleaseBuffer(m_iChars);
155 }
156 void GetWidths(int32_t* pWidths) const {
157 FXSYS_assert(pWidths != NULL);
158 int32_t iEndChar = m_iStartChar + m_iChars;
159 CFX_Char* pChar;
160 for (int32_t i = m_iStartChar; i < iEndChar; i++) {
161 pChar = m_pChars->GetDataPtr(i);
162 *pWidths++ = pChar->m_iCharWidth;
163 }
164 }
165 FX_DWORD m_dwStatus;
166 int32_t m_iStartPos;
167 int32_t m_iWidth;
168 int32_t m_iStartChar;
169 int32_t m_iChars;
170 int32_t m_iBidiLevel;
171 int32_t m_iBidiPos;
172 int32_t m_iHorizontalScale;
173 int32_t m_iVerticalScale;
174 FX_DWORD m_dwCharStyles;
175 CFX_TxtCharArray* m_pChars;
176 void* m_pUserData;
177 };
178 typedef CFX_BaseArrayTemplate<CFX_TxtPiece> CFX_TxtPieceArray;
179
180 class IFX_TxtBreak {
181 public:
182 static IFX_TxtBreak* Create(FX_DWORD dwPolicies);
183 virtual ~IFX_TxtBreak() {}
184 virtual void Release() = 0;
185 virtual void SetLineWidth(FX_FLOAT fLineWidth) = 0;
186 virtual void SetLinePos(FX_FLOAT fLinePos) = 0;
187 virtual FX_DWORD GetLayoutStyles() const = 0;
188 virtual void SetLayoutStyles(FX_DWORD dwLayoutStyles) = 0;
189 virtual void SetFont(IFX_Font* pFont) = 0;
190 virtual void SetFontSize(FX_FLOAT fFontSize) = 0;
191 virtual void SetTabWidth(FX_FLOAT fTabWidth, FX_BOOL bEquidistant) = 0;
192 virtual void SetDefaultChar(FX_WCHAR wch) = 0;
193 virtual void SetParagraphBreakChar(FX_WCHAR wch) = 0;
194 virtual void SetLineBreakTolerance(FX_FLOAT fTolerance) = 0;
195 virtual void SetHorizontalScale(int32_t iScale) = 0;
196 virtual void SetVerticalScale(int32_t iScale) = 0;
197 virtual void SetCharRotation(int32_t iCharRotation) = 0;
198 virtual void SetCharSpace(FX_FLOAT fCharSpace) = 0;
199 virtual void SetAlignment(int32_t iAlignment) = 0;
200 virtual FX_DWORD GetContextCharStyles() const = 0;
201 virtual void SetContextCharStyles(FX_DWORD dwCharStyles) = 0;
202 virtual void SetCombWidth(FX_FLOAT fCombWidth) = 0;
203 virtual void SetUserData(void* pUserData) = 0;
204 virtual FX_DWORD AppendChar(FX_WCHAR wch) = 0;
205 virtual FX_DWORD EndBreak(FX_DWORD dwStatus = FX_TXTBREAK_PieceBreak) = 0;
206 virtual int32_t CountBreakChars() const = 0;
207 virtual int32_t CountBreakPieces() const = 0;
208 virtual const CFX_TxtPiece* GetBreakPiece(int32_t index) const = 0;
209 virtual void ClearBreakPieces() = 0;
210 virtual void Reset() = 0;
211 virtual int32_t GetDisplayPos(
212 const FX_TXTRUN* pTxtRun,
213 FXTEXT_CHARPOS* pCharPos,
214 FX_BOOL bCharCode = FALSE,
215 CFX_WideString* pWSForms = NULL,
216 FX_AdjustCharDisplayPos pAdjustPos = NULL) const = 0;
217 virtual int32_t GetCharRects(const FX_TXTRUN* pTxtRun,
218 CFX_RectFArray& rtArray,
219 FX_BOOL bCharBBox = FALSE) const = 0;
220 };
221
222 #endif // XFA_SRC_FGAS_LAYOUT_FGAS_TEXTBREAK_H_
OLDNEW
« no previous file with comments | « xfa/src/fgas/layout/fgas_rtfbreak.cpp ('k') | xfa/src/fgas/layout/fgas_textbreak.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698