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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 int32_t iHorizontalScale; | 79 int32_t iHorizontalScale; |
80 int32_t iVerticalScale; | 80 int32_t iVerticalScale; |
81 }; | 81 }; |
82 | 82 |
83 class CFX_RTFPiece : public CFX_Target { | 83 class CFX_RTFPiece : public CFX_Target { |
84 public: | 84 public: |
85 CFX_RTFPiece(); | 85 CFX_RTFPiece(); |
86 ~CFX_RTFPiece() override; | 86 ~CFX_RTFPiece() override; |
87 | 87 |
88 void AppendChar(const CFX_RTFChar& tc) { | 88 void AppendChar(const CFX_RTFChar& tc) { |
89 ASSERT(m_pChars != NULL); | 89 ASSERT(m_pChars); |
90 m_pChars->Add(tc); | 90 m_pChars->Add(tc); |
91 if (m_iWidth < 0) { | 91 if (m_iWidth < 0) { |
92 m_iWidth = tc.m_iCharWidth; | 92 m_iWidth = tc.m_iCharWidth; |
93 } else { | 93 } else { |
94 m_iWidth += tc.m_iCharWidth; | 94 m_iWidth += tc.m_iCharWidth; |
95 } | 95 } |
96 m_iChars++; | 96 m_iChars++; |
97 } | 97 } |
98 int32_t GetEndPos() const { | 98 int32_t GetEndPos() const { |
99 return m_iWidth < 0 ? m_iStartPos : m_iStartPos + m_iWidth; | 99 return m_iWidth < 0 ? m_iStartPos : m_iStartPos + m_iWidth; |
100 } | 100 } |
101 int32_t GetLength() const { return m_iChars; } | 101 int32_t GetLength() const { return m_iChars; } |
102 int32_t GetEndChar() const { return m_iStartChar + m_iChars; } | 102 int32_t GetEndChar() const { return m_iStartChar + m_iChars; } |
103 CFX_RTFChar& GetChar(int32_t index) { | 103 CFX_RTFChar& GetChar(int32_t index) { |
104 ASSERT(index > -1 && index < m_iChars && m_pChars != NULL); | 104 ASSERT(index > -1 && index < m_iChars && m_pChars); |
105 return *m_pChars->GetDataPtr(m_iStartChar + index); | 105 return *m_pChars->GetDataPtr(m_iStartChar + index); |
106 } | 106 } |
107 CFX_RTFChar* GetCharPtr(int32_t index) const { | 107 CFX_RTFChar* GetCharPtr(int32_t index) const { |
108 ASSERT(index > -1 && index < m_iChars && m_pChars != NULL); | 108 ASSERT(index > -1 && index < m_iChars && m_pChars); |
109 return m_pChars->GetDataPtr(m_iStartChar + index); | 109 return m_pChars->GetDataPtr(m_iStartChar + index); |
110 } | 110 } |
111 void GetString(FX_WCHAR* pText) const { | 111 void GetString(FX_WCHAR* pText) const { |
112 ASSERT(pText != NULL); | 112 ASSERT(pText); |
113 int32_t iEndChar = m_iStartChar + m_iChars; | 113 int32_t iEndChar = m_iStartChar + m_iChars; |
114 CFX_RTFChar* pChar; | 114 CFX_RTFChar* pChar; |
115 for (int32_t i = m_iStartChar; i < iEndChar; i++) { | 115 for (int32_t i = m_iStartChar; i < iEndChar; i++) { |
116 pChar = m_pChars->GetDataPtr(i); | 116 pChar = m_pChars->GetDataPtr(i); |
117 *pText++ = (FX_WCHAR)pChar->m_wCharCode; | 117 *pText++ = (FX_WCHAR)pChar->m_wCharCode; |
118 } | 118 } |
119 } | 119 } |
120 void GetString(CFX_WideString& wsText) const { | 120 void GetString(CFX_WideString& wsText) const { |
121 FX_WCHAR* pText = wsText.GetBuffer(m_iChars); | 121 FX_WCHAR* pText = wsText.GetBuffer(m_iChars); |
122 GetString(pText); | 122 GetString(pText); |
123 wsText.ReleaseBuffer(m_iChars); | 123 wsText.ReleaseBuffer(m_iChars); |
124 } | 124 } |
125 void GetWidths(int32_t* pWidths) const { | 125 void GetWidths(int32_t* pWidths) const { |
126 ASSERT(pWidths != NULL); | 126 ASSERT(pWidths); |
127 int32_t iEndChar = m_iStartChar + m_iChars; | 127 int32_t iEndChar = m_iStartChar + m_iChars; |
128 CFX_RTFChar* pChar; | 128 CFX_RTFChar* pChar; |
129 for (int32_t i = m_iStartChar; i < iEndChar; i++) { | 129 for (int32_t i = m_iStartChar; i < iEndChar; i++) { |
130 pChar = m_pChars->GetDataPtr(i); | 130 pChar = m_pChars->GetDataPtr(i); |
131 *pWidths++ = pChar->m_iCharWidth; | 131 *pWidths++ = pChar->m_iCharWidth; |
132 } | 132 } |
133 } | 133 } |
134 void Reset() { | 134 void Reset() { |
135 m_dwStatus = FX_RTFBREAK_PieceBreak; | 135 m_dwStatus = FX_RTFBREAK_PieceBreak; |
136 if (m_iWidth > -1) { | 136 if (m_iWidth > -1) { |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 ASSERT(index > -1 && index < m_LinePieces.GetSize()); | 183 ASSERT(index > -1 && index < m_LinePieces.GetSize()); |
184 return m_LinePieces.GetAt(index); | 184 return m_LinePieces.GetAt(index); |
185 } | 185 } |
186 CFX_RTFPiece* GetPiecePtr(int32_t index) const { | 186 CFX_RTFPiece* GetPiecePtr(int32_t index) const { |
187 ASSERT(index > -1 && index < m_LinePieces.GetSize()); | 187 ASSERT(index > -1 && index < m_LinePieces.GetSize()); |
188 return m_LinePieces.GetPtrAt(index); | 188 return m_LinePieces.GetPtrAt(index); |
189 } | 189 } |
190 int32_t GetLineEnd() const { return m_iStart + m_iWidth; } | 190 int32_t GetLineEnd() const { return m_iStart + m_iWidth; } |
191 void RemoveAll(FX_BOOL bLeaveMemory = FALSE) { | 191 void RemoveAll(FX_BOOL bLeaveMemory = FALSE) { |
192 CFX_RTFChar* pChar; | 192 CFX_RTFChar* pChar; |
193 IFX_Retainable* pUnknown; | |
194 int32_t iCount = m_LineChars.GetSize(); | 193 int32_t iCount = m_LineChars.GetSize(); |
195 for (int32_t i = 0; i < iCount; i++) { | 194 for (int32_t i = 0; i < iCount; i++) { |
196 pChar = m_LineChars.GetDataPtr(i); | 195 pChar = m_LineChars.GetDataPtr(i); |
197 if ((pUnknown = pChar->m_pUserData) != NULL) { | 196 if (pChar->m_pUserData) |
198 pUnknown->Release(); | 197 pChar->m_pUserData->Release(); |
199 } | |
200 } | 198 } |
201 m_LineChars.RemoveAll(); | 199 m_LineChars.RemoveAll(); |
202 m_LinePieces.RemoveAll(bLeaveMemory); | 200 m_LinePieces.RemoveAll(bLeaveMemory); |
203 m_iWidth = 0; | 201 m_iWidth = 0; |
204 m_iArabicChars = 0; | 202 m_iArabicChars = 0; |
205 m_iMBCSChars = 0; | 203 m_iMBCSChars = 0; |
206 } | 204 } |
207 | 205 |
208 CFX_RTFCharArray m_LineChars; | 206 CFX_RTFCharArray m_LineChars; |
209 CFX_RTFPieceArray m_LinePieces; | 207 CFX_RTFPieceArray m_LinePieces; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 uint32_t AppendChar(FX_WCHAR wch); | 240 uint32_t AppendChar(FX_WCHAR wch); |
243 uint32_t EndBreak(uint32_t dwStatus = FX_RTFBREAK_PieceBreak); | 241 uint32_t EndBreak(uint32_t dwStatus = FX_RTFBREAK_PieceBreak); |
244 int32_t CountBreakPieces() const; | 242 int32_t CountBreakPieces() const; |
245 const CFX_RTFPiece* GetBreakPiece(int32_t index) const; | 243 const CFX_RTFPiece* GetBreakPiece(int32_t index) const; |
246 void GetLineRect(CFX_RectF& rect) const; | 244 void GetLineRect(CFX_RectF& rect) const; |
247 void ClearBreakPieces(); | 245 void ClearBreakPieces(); |
248 void Reset(); | 246 void Reset(); |
249 int32_t GetDisplayPos(const FX_RTFTEXTOBJ* pText, | 247 int32_t GetDisplayPos(const FX_RTFTEXTOBJ* pText, |
250 FXTEXT_CHARPOS* pCharPos, | 248 FXTEXT_CHARPOS* pCharPos, |
251 FX_BOOL bCharCode = FALSE, | 249 FX_BOOL bCharCode = FALSE, |
252 CFX_WideString* pWSForms = NULL, | 250 CFX_WideString* pWSForms = nullptr, |
253 FX_AdjustCharDisplayPos pAdjustPos = NULL) const; | 251 FX_AdjustCharDisplayPos pAdjustPos = nullptr) const; |
254 int32_t GetCharRects(const FX_RTFTEXTOBJ* pText, | 252 int32_t GetCharRects(const FX_RTFTEXTOBJ* pText, |
255 CFX_RectFArray& rtArray, | 253 CFX_RectFArray& rtArray, |
256 FX_BOOL bCharBBox = FALSE) const; | 254 FX_BOOL bCharBBox = FALSE) const; |
257 uint32_t AppendChar_CharCode(FX_WCHAR wch); | 255 uint32_t AppendChar_CharCode(FX_WCHAR wch); |
258 uint32_t AppendChar_Combination(CFX_RTFChar* pCurChar, int32_t iRotation); | 256 uint32_t AppendChar_Combination(CFX_RTFChar* pCurChar, int32_t iRotation); |
259 uint32_t AppendChar_Tab(CFX_RTFChar* pCurChar, int32_t iRotation); | 257 uint32_t AppendChar_Tab(CFX_RTFChar* pCurChar, int32_t iRotation); |
260 uint32_t AppendChar_Control(CFX_RTFChar* pCurChar, int32_t iRotation); | 258 uint32_t AppendChar_Control(CFX_RTFChar* pCurChar, int32_t iRotation); |
261 uint32_t AppendChar_Arabic(CFX_RTFChar* pCurChar, int32_t iRotation); | 259 uint32_t AppendChar_Arabic(CFX_RTFChar* pCurChar, int32_t iRotation); |
262 uint32_t AppendChar_Others(CFX_RTFChar* pCurChar, int32_t iRotation); | 260 uint32_t AppendChar_Others(CFX_RTFChar* pCurChar, int32_t iRotation); |
263 | 261 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 FX_CHARTYPE m_eCharType; | 315 FX_CHARTYPE m_eCharType; |
318 uint32_t m_dwIdentity; | 316 uint32_t m_dwIdentity; |
319 CFX_RTFLine m_RTFLine1; | 317 CFX_RTFLine m_RTFLine1; |
320 CFX_RTFLine m_RTFLine2; | 318 CFX_RTFLine m_RTFLine2; |
321 CFX_RTFLine* m_pCurLine; | 319 CFX_RTFLine* m_pCurLine; |
322 int32_t m_iReady; | 320 int32_t m_iReady; |
323 int32_t m_iTolerance; | 321 int32_t m_iTolerance; |
324 }; | 322 }; |
325 | 323 |
326 #endif // XFA_FGAS_LAYOUT_FGAS_RTFBREAK_H_ | 324 #endif // XFA_FGAS_LAYOUT_FGAS_RTFBREAK_H_ |
OLD | NEW |