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_FGAS_LAYOUT_FGAS_RTFBREAK_H_ | 7 #ifndef XFA_FGAS_LAYOUT_FGAS_RTFBREAK_H_ |
8 #define XFA_FGAS_LAYOUT_FGAS_RTFBREAK_H_ | 8 #define XFA_FGAS_LAYOUT_FGAS_RTFBREAK_H_ |
9 | 9 |
10 #include "core/fxcrt/include/fx_basic.h" | 10 #include "core/fxcrt/include/fx_basic.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 (FX_RTFLINEALIGNMENT_Left | FX_RTFLINEALIGNMENT_Distributed) | 58 (FX_RTFLINEALIGNMENT_Left | FX_RTFLINEALIGNMENT_Distributed) |
59 #define FX_RTFLINEALIGNMENT_DistributedCenter \ | 59 #define FX_RTFLINEALIGNMENT_DistributedCenter \ |
60 (FX_RTFLINEALIGNMENT_Center | FX_RTFLINEALIGNMENT_Distributed) | 60 (FX_RTFLINEALIGNMENT_Center | FX_RTFLINEALIGNMENT_Distributed) |
61 #define FX_RTFLINEALIGNMENT_DistributedRight \ | 61 #define FX_RTFLINEALIGNMENT_DistributedRight \ |
62 (FX_RTFLINEALIGNMENT_Right | FX_RTFLINEALIGNMENT_Distributed) | 62 (FX_RTFLINEALIGNMENT_Right | FX_RTFLINEALIGNMENT_Distributed) |
63 #define FX_RTFLINEALIGNMENT_LowerMask 0x03 | 63 #define FX_RTFLINEALIGNMENT_LowerMask 0x03 |
64 #define FX_RTFLINEALIGNMENT_HigherMask 0x0C | 64 #define FX_RTFLINEALIGNMENT_HigherMask 0x0C |
65 | 65 |
66 struct FX_RTFTEXTOBJ { | 66 struct FX_RTFTEXTOBJ { |
67 FX_RTFTEXTOBJ() { | 67 FX_RTFTEXTOBJ() { |
68 pStr = NULL; | 68 pStr = nullptr; |
69 pWidths = NULL; | 69 pWidths = nullptr; |
70 iLength = 0; | 70 iLength = 0; |
71 pFont = NULL; | 71 pFont = nullptr; |
72 fFontSize = 12.0f; | 72 fFontSize = 12.0f; |
73 dwLayoutStyles = 0; | 73 dwLayoutStyles = 0; |
74 iCharRotation = 0; | 74 iCharRotation = 0; |
75 iBidiLevel = 0; | 75 iBidiLevel = 0; |
76 pRect = NULL; | 76 pRect = nullptr; |
77 wLineBreakChar = L'\n'; | 77 wLineBreakChar = L'\n'; |
78 iHorizontalScale = 100; | 78 iHorizontalScale = 100; |
79 iVerticalScale = 100; | 79 iVerticalScale = 100; |
80 } | 80 } |
81 | 81 |
82 const FX_WCHAR* pStr; | 82 const FX_WCHAR* pStr; |
83 int32_t* pWidths; | 83 int32_t* pWidths; |
84 int32_t iLength; | 84 int32_t iLength; |
85 IFGAS_Font* pFont; | 85 IFGAS_Font* pFont; |
86 FX_FLOAT fFontSize; | 86 FX_FLOAT fFontSize; |
(...skipping 15 matching lines...) Expand all Loading... |
102 m_iStartChar(0), | 102 m_iStartChar(0), |
103 m_iChars(0), | 103 m_iChars(0), |
104 m_iBidiLevel(0), | 104 m_iBidiLevel(0), |
105 m_iBidiPos(0), | 105 m_iBidiPos(0), |
106 m_iFontSize(0), | 106 m_iFontSize(0), |
107 m_iFontHeight(0), | 107 m_iFontHeight(0), |
108 m_iHorizontalScale(100), | 108 m_iHorizontalScale(100), |
109 m_iVerticalScale(100), | 109 m_iVerticalScale(100), |
110 m_dwLayoutStyles(0), | 110 m_dwLayoutStyles(0), |
111 m_dwIdentity(0), | 111 m_dwIdentity(0), |
112 m_pChars(NULL), | 112 m_pChars(nullptr), |
113 m_pUserData(NULL) {} | 113 m_pUserData(nullptr) {} |
114 ~CFX_RTFPiece() { Reset(); } | 114 ~CFX_RTFPiece() { Reset(); } |
115 void AppendChar(const CFX_RTFChar& tc) { | 115 void AppendChar(const CFX_RTFChar& tc) { |
116 ASSERT(m_pChars != NULL); | |
117 m_pChars->Add(tc); | 116 m_pChars->Add(tc); |
118 if (m_iWidth < 0) { | 117 if (m_iWidth < 0) { |
119 m_iWidth = tc.m_iCharWidth; | 118 m_iWidth = tc.m_iCharWidth; |
120 } else { | 119 } else { |
121 m_iWidth += tc.m_iCharWidth; | 120 m_iWidth += tc.m_iCharWidth; |
122 } | 121 } |
123 m_iChars++; | 122 m_iChars++; |
124 } | 123 } |
125 int32_t GetEndPos() const { | 124 int32_t GetEndPos() const { |
126 return m_iWidth < 0 ? m_iStartPos : m_iStartPos + m_iWidth; | 125 return m_iWidth < 0 ? m_iStartPos : m_iStartPos + m_iWidth; |
127 } | 126 } |
128 int32_t GetLength() const { return m_iChars; } | 127 int32_t GetLength() const { return m_iChars; } |
129 int32_t GetEndChar() const { return m_iStartChar + m_iChars; } | 128 int32_t GetEndChar() const { return m_iStartChar + m_iChars; } |
130 CFX_RTFChar& GetChar(int32_t index) { | 129 CFX_RTFChar& GetChar(int32_t index) { |
131 ASSERT(index > -1 && index < m_iChars && m_pChars != NULL); | 130 ASSERT(index > -1 && index < m_iChars && m_pChars); |
132 return *m_pChars->GetDataPtr(m_iStartChar + index); | 131 return *m_pChars->GetDataPtr(m_iStartChar + index); |
133 } | 132 } |
134 CFX_RTFChar* GetCharPtr(int32_t index) const { | 133 CFX_RTFChar* GetCharPtr(int32_t index) const { |
135 ASSERT(index > -1 && index < m_iChars && m_pChars != NULL); | 134 ASSERT(index > -1 && index < m_iChars && m_pChars); |
136 return m_pChars->GetDataPtr(m_iStartChar + index); | 135 return m_pChars->GetDataPtr(m_iStartChar + index); |
137 } | 136 } |
138 void GetString(FX_WCHAR* pText) const { | 137 void GetString(FX_WCHAR* pText) const { |
139 ASSERT(pText != NULL); | 138 ASSERT(pText); |
140 int32_t iEndChar = m_iStartChar + m_iChars; | 139 int32_t iEndChar = m_iStartChar + m_iChars; |
141 CFX_RTFChar* pChar; | 140 CFX_RTFChar* pChar; |
142 for (int32_t i = m_iStartChar; i < iEndChar; i++) { | 141 for (int32_t i = m_iStartChar; i < iEndChar; i++) { |
143 pChar = m_pChars->GetDataPtr(i); | 142 pChar = m_pChars->GetDataPtr(i); |
144 *pText++ = (FX_WCHAR)pChar->m_wCharCode; | 143 *pText++ = (FX_WCHAR)pChar->m_wCharCode; |
145 } | 144 } |
146 } | 145 } |
147 void GetString(CFX_WideString& wsText) const { | 146 void GetString(CFX_WideString& wsText) const { |
148 FX_WCHAR* pText = wsText.GetBuffer(m_iChars); | 147 FX_WCHAR* pText = wsText.GetBuffer(m_iChars); |
149 GetString(pText); | 148 GetString(pText); |
150 wsText.ReleaseBuffer(m_iChars); | 149 wsText.ReleaseBuffer(m_iChars); |
151 } | 150 } |
152 void GetWidths(int32_t* pWidths) const { | 151 void GetWidths(int32_t* pWidths) const { |
153 ASSERT(pWidths != NULL); | 152 ASSERT(pWidths); |
154 int32_t iEndChar = m_iStartChar + m_iChars; | 153 int32_t iEndChar = m_iStartChar + m_iChars; |
155 CFX_RTFChar* pChar; | 154 CFX_RTFChar* pChar; |
156 for (int32_t i = m_iStartChar; i < iEndChar; i++) { | 155 for (int32_t i = m_iStartChar; i < iEndChar; i++) { |
157 pChar = m_pChars->GetDataPtr(i); | 156 pChar = m_pChars->GetDataPtr(i); |
158 *pWidths++ = pChar->m_iCharWidth; | 157 *pWidths++ = pChar->m_iCharWidth; |
159 } | 158 } |
160 } | 159 } |
161 void Reset() { | 160 void Reset() { |
162 m_dwStatus = FX_RTFBREAK_PieceBreak; | 161 m_dwStatus = FX_RTFBREAK_PieceBreak; |
163 if (m_iWidth > -1) { | 162 if (m_iWidth > -1) { |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 ASSERT(index > -1 && index < m_LinePieces.GetSize()); | 211 ASSERT(index > -1 && index < m_LinePieces.GetSize()); |
213 return m_LinePieces.GetAt(index); | 212 return m_LinePieces.GetAt(index); |
214 } | 213 } |
215 CFX_RTFPiece* GetPiecePtr(int32_t index) const { | 214 CFX_RTFPiece* GetPiecePtr(int32_t index) const { |
216 ASSERT(index > -1 && index < m_LinePieces.GetSize()); | 215 ASSERT(index > -1 && index < m_LinePieces.GetSize()); |
217 return m_LinePieces.GetPtrAt(index); | 216 return m_LinePieces.GetPtrAt(index); |
218 } | 217 } |
219 int32_t GetLineEnd() const { return m_iStart + m_iWidth; } | 218 int32_t GetLineEnd() const { return m_iStart + m_iWidth; } |
220 void RemoveAll(FX_BOOL bLeaveMemory = FALSE) { | 219 void RemoveAll(FX_BOOL bLeaveMemory = FALSE) { |
221 CFX_RTFChar* pChar; | 220 CFX_RTFChar* pChar; |
222 IFX_Retainable* pUnknown; | |
223 int32_t iCount = m_LineChars.GetSize(); | 221 int32_t iCount = m_LineChars.GetSize(); |
224 for (int32_t i = 0; i < iCount; i++) { | 222 for (int32_t i = 0; i < iCount; i++) { |
225 pChar = m_LineChars.GetDataPtr(i); | 223 pChar = m_LineChars.GetDataPtr(i); |
226 if ((pUnknown = pChar->m_pUserData) != NULL) { | 224 if (pChar->m_pUserData) |
227 pUnknown->Release(); | 225 pChar->m_pUserData->Release(); |
228 } | |
229 } | 226 } |
230 m_LineChars.RemoveAll(); | 227 m_LineChars.RemoveAll(); |
231 m_LinePieces.RemoveAll(bLeaveMemory); | 228 m_LinePieces.RemoveAll(bLeaveMemory); |
232 m_iWidth = 0; | 229 m_iWidth = 0; |
233 m_iArabicChars = 0; | 230 m_iArabicChars = 0; |
234 m_iMBCSChars = 0; | 231 m_iMBCSChars = 0; |
235 } | 232 } |
236 CFX_RTFCharArray m_LineChars; | 233 CFX_RTFCharArray m_LineChars; |
237 CFX_RTFPieceArray m_LinePieces; | 234 CFX_RTFPieceArray m_LinePieces; |
238 int32_t m_iStart; | 235 int32_t m_iStart; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 uint32_t AppendChar(FX_WCHAR wch); | 267 uint32_t AppendChar(FX_WCHAR wch); |
271 uint32_t EndBreak(uint32_t dwStatus = FX_RTFBREAK_PieceBreak); | 268 uint32_t EndBreak(uint32_t dwStatus = FX_RTFBREAK_PieceBreak); |
272 int32_t CountBreakPieces() const; | 269 int32_t CountBreakPieces() const; |
273 const CFX_RTFPiece* GetBreakPiece(int32_t index) const; | 270 const CFX_RTFPiece* GetBreakPiece(int32_t index) const; |
274 void GetLineRect(CFX_RectF& rect) const; | 271 void GetLineRect(CFX_RectF& rect) const; |
275 void ClearBreakPieces(); | 272 void ClearBreakPieces(); |
276 void Reset(); | 273 void Reset(); |
277 int32_t GetDisplayPos(const FX_RTFTEXTOBJ* pText, | 274 int32_t GetDisplayPos(const FX_RTFTEXTOBJ* pText, |
278 FXTEXT_CHARPOS* pCharPos, | 275 FXTEXT_CHARPOS* pCharPos, |
279 FX_BOOL bCharCode = FALSE, | 276 FX_BOOL bCharCode = FALSE, |
280 CFX_WideString* pWSForms = NULL, | 277 CFX_WideString* pWSForms = nullptr, |
281 FX_AdjustCharDisplayPos pAdjustPos = NULL) const; | 278 FX_AdjustCharDisplayPos pAdjustPos = nullptr) const; |
282 int32_t GetCharRects(const FX_RTFTEXTOBJ* pText, | 279 int32_t GetCharRects(const FX_RTFTEXTOBJ* pText, |
283 CFX_RectFArray& rtArray, | 280 CFX_RectFArray& rtArray, |
284 FX_BOOL bCharBBox = FALSE) const; | 281 FX_BOOL bCharBBox = FALSE) const; |
285 uint32_t AppendChar_CharCode(FX_WCHAR wch); | 282 uint32_t AppendChar_CharCode(FX_WCHAR wch); |
286 uint32_t AppendChar_Combination(CFX_RTFChar* pCurChar, int32_t iRotation); | 283 uint32_t AppendChar_Combination(CFX_RTFChar* pCurChar, int32_t iRotation); |
287 uint32_t AppendChar_Tab(CFX_RTFChar* pCurChar, int32_t iRotation); | 284 uint32_t AppendChar_Tab(CFX_RTFChar* pCurChar, int32_t iRotation); |
288 uint32_t AppendChar_Control(CFX_RTFChar* pCurChar, int32_t iRotation); | 285 uint32_t AppendChar_Control(CFX_RTFChar* pCurChar, int32_t iRotation); |
289 uint32_t AppendChar_Arabic(CFX_RTFChar* pCurChar, int32_t iRotation); | 286 uint32_t AppendChar_Arabic(CFX_RTFChar* pCurChar, int32_t iRotation); |
290 uint32_t AppendChar_Others(CFX_RTFChar* pCurChar, int32_t iRotation); | 287 uint32_t AppendChar_Others(CFX_RTFChar* pCurChar, int32_t iRotation); |
291 | 288 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 FX_BOOL EndBreak_SplitLine(CFX_RTFLine* pNextLine, | 340 FX_BOOL EndBreak_SplitLine(CFX_RTFLine* pNextLine, |
344 FX_BOOL bAllChars, | 341 FX_BOOL bAllChars, |
345 uint32_t dwStatus); | 342 uint32_t dwStatus); |
346 void EndBreak_BidiLine(CFX_TPOArray& tpos, uint32_t dwStatus); | 343 void EndBreak_BidiLine(CFX_TPOArray& tpos, uint32_t dwStatus); |
347 void EndBreak_Alignment(CFX_TPOArray& tpos, | 344 void EndBreak_Alignment(CFX_TPOArray& tpos, |
348 FX_BOOL bAllChars, | 345 FX_BOOL bAllChars, |
349 uint32_t dwStatus); | 346 uint32_t dwStatus); |
350 }; | 347 }; |
351 | 348 |
352 #endif // XFA_FGAS_LAYOUT_FGAS_RTFBREAK_H_ | 349 #endif // XFA_FGAS_LAYOUT_FGAS_RTFBREAK_H_ |
OLD | NEW |