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_TEXTBREAK_H_ | 7 #ifndef XFA_FGAS_LAYOUT_FGAS_TEXTBREAK_H_ |
8 #define XFA_FGAS_LAYOUT_FGAS_TEXTBREAK_H_ | 8 #define XFA_FGAS_LAYOUT_FGAS_TEXTBREAK_H_ |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
11 #include <vector> | |
11 | 12 |
12 #include "core/fxcrt/fx_ucd.h" | 13 #include "core/fxcrt/fx_ucd.h" |
13 #include "core/fxge/cfx_renderdevice.h" | 14 #include "core/fxge/cfx_renderdevice.h" |
15 #include "third_party/base/stl_util.h" | |
14 #include "xfa/fgas/crt/fgas_utils.h" | 16 #include "xfa/fgas/crt/fgas_utils.h" |
15 #include "xfa/fgas/layout/fgas_unicode.h" | 17 #include "xfa/fgas/layout/fgas_unicode.h" |
16 | 18 |
17 class CFX_Char; | 19 class CFX_Char; |
18 class CFGAS_GEFont; | 20 class CFGAS_GEFont; |
19 class CFX_TxtChar; | 21 class CFX_TxtChar; |
20 class CFX_TxtPiece; | 22 class CFX_TxtPiece; |
21 class IFX_TxtAccess; | 23 class IFX_TxtAccess; |
22 | 24 |
23 #define FX_TXTBREAKPOLICY_None 0x00 | 25 #define FX_TXTBREAKPOLICY_None 0x00 |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
109 public: | 111 public: |
110 CFX_TxtPiece(); | 112 CFX_TxtPiece(); |
111 | 113 |
112 int32_t GetEndPos() const { | 114 int32_t GetEndPos() const { |
113 return m_iWidth < 0 ? m_iStartPos : m_iStartPos + m_iWidth; | 115 return m_iWidth < 0 ? m_iStartPos : m_iStartPos + m_iWidth; |
114 } | 116 } |
115 int32_t GetLength() const { return m_iChars; } | 117 int32_t GetLength() const { return m_iChars; } |
116 int32_t GetEndChar() const { return m_iStartChar + m_iChars; } | 118 int32_t GetEndChar() const { return m_iStartChar + m_iChars; } |
117 CFX_TxtChar* GetCharPtr(int32_t index) const { | 119 CFX_TxtChar* GetCharPtr(int32_t index) const { |
118 ASSERT(index > -1 && index < m_iChars && m_pChars); | 120 ASSERT(index > -1 && index < m_iChars && m_pChars); |
119 return m_pChars->GetDataPtr(m_iStartChar + index); | 121 return &(*m_pChars)[m_iStartChar + index]; |
120 } | 122 } |
121 void GetString(FX_WCHAR* pText) const { | 123 void GetString(FX_WCHAR* pText) const { |
122 ASSERT(pText); | 124 ASSERT(pText); |
123 int32_t iEndChar = m_iStartChar + m_iChars; | 125 int32_t iEndChar = m_iStartChar + m_iChars; |
124 CFX_Char* pChar; | |
125 for (int32_t i = m_iStartChar; i < iEndChar; i++) { | 126 for (int32_t i = m_iStartChar; i < iEndChar; i++) { |
126 pChar = m_pChars->GetDataPtr(i); | 127 CFX_Char* pChar = &(*m_pChars)[i]; |
127 *pText++ = (FX_WCHAR)pChar->m_wCharCode; | 128 *pText++ = (FX_WCHAR)pChar->m_wCharCode; |
dsinclair
2017/01/24 18:43:59
This seems overly complicated why not something li
Tom Sepez
2017/01/24 19:16:12
Done.
| |
128 } | 129 } |
129 } | 130 } |
130 void GetString(CFX_WideString& wsText) const { | 131 void GetString(CFX_WideString& wsText) const { |
131 FX_WCHAR* pText = wsText.GetBuffer(m_iChars); | 132 FX_WCHAR* pText = wsText.GetBuffer(m_iChars); |
132 GetString(pText); | 133 GetString(pText); |
133 wsText.ReleaseBuffer(m_iChars); | 134 wsText.ReleaseBuffer(m_iChars); |
134 } | 135 } |
135 void GetWidths(int32_t* pWidths) const { | 136 void GetWidths(int32_t* pWidths) const { |
136 ASSERT(pWidths); | 137 ASSERT(pWidths); |
137 int32_t iEndChar = m_iStartChar + m_iChars; | 138 int32_t iEndChar = m_iStartChar + m_iChars; |
138 CFX_Char* pChar; | |
139 for (int32_t i = m_iStartChar; i < iEndChar; i++) { | 139 for (int32_t i = m_iStartChar; i < iEndChar; i++) { |
140 pChar = m_pChars->GetDataPtr(i); | 140 CFX_Char* pChar = &(*m_pChars)[i]; |
141 *pWidths++ = pChar->m_iCharWidth; | 141 *pWidths++ = pChar->m_iCharWidth; |
142 } | 142 } |
143 } | 143 } |
144 | 144 |
145 uint32_t m_dwStatus; | 145 uint32_t m_dwStatus; |
146 int32_t m_iStartPos; | 146 int32_t m_iStartPos; |
147 int32_t m_iWidth; | 147 int32_t m_iWidth; |
148 int32_t m_iStartChar; | 148 int32_t m_iStartChar; |
149 int32_t m_iChars; | 149 int32_t m_iChars; |
150 int32_t m_iBidiLevel; | 150 int32_t m_iBidiLevel; |
151 int32_t m_iBidiPos; | 151 int32_t m_iBidiPos; |
152 int32_t m_iHorizontalScale; | 152 int32_t m_iHorizontalScale; |
153 int32_t m_iVerticalScale; | 153 int32_t m_iVerticalScale; |
154 uint32_t m_dwCharStyles; | 154 uint32_t m_dwCharStyles; |
155 CFX_TxtCharArray* m_pChars; | 155 std::vector<CFX_TxtChar>* m_pChars; |
156 void* m_pUserData; | 156 void* m_pUserData; |
157 }; | 157 }; |
158 | 158 |
159 typedef CFX_BaseArrayTemplate<CFX_TxtPiece> CFX_TxtPieceArray; | 159 typedef CFX_BaseArrayTemplate<CFX_TxtPiece> CFX_TxtPieceArray; |
160 | 160 |
161 class CFX_TxtLine { | 161 class CFX_TxtLine { |
162 public: | 162 public: |
163 explicit CFX_TxtLine(int32_t iBlockSize); | 163 explicit CFX_TxtLine(int32_t iBlockSize); |
164 ~CFX_TxtLine(); | 164 ~CFX_TxtLine(); |
165 | 165 |
166 int32_t CountChars() const { return m_pLineChars->GetSize(); } | 166 int32_t CountChars() const { |
167 return pdfium::CollectionSize<int32_t>(*m_pLineChars); | |
168 } | |
167 CFX_TxtChar* GetCharPtr(int32_t index) const { | 169 CFX_TxtChar* GetCharPtr(int32_t index) const { |
168 ASSERT(index > -1 && index < m_pLineChars->GetSize()); | 170 ASSERT(index >= 0 && |
169 return m_pLineChars->GetDataPtr(index); | 171 index < pdfium::CollectionSize<int32_t>(*m_pLineChars)); |
172 return &(*m_pLineChars)[index]; | |
170 } | 173 } |
171 int32_t CountPieces() const { return m_pLinePieces->GetSize(); } | 174 int32_t CountPieces() const { return m_pLinePieces->GetSize(); } |
172 CFX_TxtPiece* GetPiecePtr(int32_t index) const { | 175 CFX_TxtPiece* GetPiecePtr(int32_t index) const { |
173 ASSERT(index > -1 && index < m_pLinePieces->GetSize()); | 176 ASSERT(index > -1 && index < m_pLinePieces->GetSize()); |
174 return m_pLinePieces->GetPtrAt(index); | 177 return m_pLinePieces->GetPtrAt(index); |
175 } | 178 } |
176 void GetString(CFX_WideString& wsStr) const { | 179 void GetString(CFX_WideString& wsStr) const { |
177 int32_t iCount = m_pLineChars->GetSize(); | 180 int32_t iCount = pdfium::CollectionSize<int32_t>(*m_pLineChars); |
178 FX_WCHAR* pBuf = wsStr.GetBuffer(iCount); | 181 FX_WCHAR* pBuf = wsStr.GetBuffer(iCount); |
179 CFX_Char* pChar; | |
180 for (int32_t i = 0; i < iCount; i++) { | 182 for (int32_t i = 0; i < iCount; i++) { |
181 pChar = m_pLineChars->GetDataPtr(i); | 183 CFX_Char* pChar = &(*m_pLineChars)[i]; |
182 *pBuf++ = (FX_WCHAR)pChar->m_wCharCode; | 184 *pBuf++ = (FX_WCHAR)pChar->m_wCharCode; |
183 } | 185 } |
184 wsStr.ReleaseBuffer(iCount); | 186 wsStr.ReleaseBuffer(iCount); |
185 } | 187 } |
186 void RemoveAll(bool bLeaveMemory = false) { | 188 void RemoveAll(bool bLeaveMemory = false) { |
187 m_pLineChars->RemoveAll(); | 189 m_pLineChars->clear(); |
188 m_pLinePieces->RemoveAll(bLeaveMemory); | 190 m_pLinePieces->RemoveAll(bLeaveMemory); |
189 m_iWidth = 0; | 191 m_iWidth = 0; |
190 m_iArabicChars = 0; | 192 m_iArabicChars = 0; |
191 } | 193 } |
192 | 194 |
193 std::unique_ptr<CFX_TxtCharArray> m_pLineChars; | 195 std::unique_ptr<std::vector<CFX_TxtChar>> m_pLineChars; |
194 std::unique_ptr<CFX_TxtPieceArray> m_pLinePieces; | 196 std::unique_ptr<CFX_TxtPieceArray> m_pLinePieces; |
195 int32_t m_iStart; | 197 int32_t m_iStart; |
196 int32_t m_iWidth; | 198 int32_t m_iWidth; |
197 int32_t m_iArabicChars; | 199 int32_t m_iArabicChars; |
198 }; | 200 }; |
199 | 201 |
200 class CFX_TxtBreak { | 202 class CFX_TxtBreak { |
201 public: | 203 public: |
202 explicit CFX_TxtBreak(uint32_t dwPolicies); | 204 explicit CFX_TxtBreak(uint32_t dwPolicies); |
203 ~CFX_TxtBreak(); | 205 ~CFX_TxtBreak(); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
253 void ResetArabicContext(); | 255 void ResetArabicContext(); |
254 void ResetContextCharStyles(); | 256 void ResetContextCharStyles(); |
255 void EndBreak_UpdateArabicShapes(); | 257 void EndBreak_UpdateArabicShapes(); |
256 bool EndBreak_SplitLine(CFX_TxtLine* pNextLine, | 258 bool EndBreak_SplitLine(CFX_TxtLine* pNextLine, |
257 bool bAllChars, | 259 bool bAllChars, |
258 uint32_t dwStatus); | 260 uint32_t dwStatus); |
259 void EndBreak_BidiLine(CFX_TPOArray& tpos, uint32_t dwStatus); | 261 void EndBreak_BidiLine(CFX_TPOArray& tpos, uint32_t dwStatus); |
260 void EndBreak_Alignment(CFX_TPOArray& tpos, | 262 void EndBreak_Alignment(CFX_TPOArray& tpos, |
261 bool bAllChars, | 263 bool bAllChars, |
262 uint32_t dwStatus); | 264 uint32_t dwStatus); |
263 int32_t GetBreakPos(CFX_TxtCharArray& ca, | 265 int32_t GetBreakPos(std::vector<CFX_TxtChar>& ca, |
264 int32_t& iEndPos, | 266 int32_t& iEndPos, |
265 bool bAllChars = false, | 267 bool bAllChars = false, |
266 bool bOnlyBrk = false); | 268 bool bOnlyBrk = false); |
267 void SplitTextLine(CFX_TxtLine* pCurLine, | 269 void SplitTextLine(CFX_TxtLine* pCurLine, |
268 CFX_TxtLine* pNextLine, | 270 CFX_TxtLine* pNextLine, |
269 bool bAllChars = false); | 271 bool bAllChars = false); |
270 | 272 |
271 uint32_t m_dwPolicies; | 273 uint32_t m_dwPolicies; |
272 bool m_bPagination; | 274 bool m_bPagination; |
273 int32_t m_iLineWidth; | 275 int32_t m_iLineWidth; |
(...skipping 29 matching lines...) Expand all Loading... | |
303 std::unique_ptr<CFX_TxtLine> m_pTxtLine2; | 305 std::unique_ptr<CFX_TxtLine> m_pTxtLine2; |
304 CFX_TxtLine* m_pCurLine; | 306 CFX_TxtLine* m_pCurLine; |
305 int32_t m_iReady; | 307 int32_t m_iReady; |
306 int32_t m_iTolerance; | 308 int32_t m_iTolerance; |
307 int32_t m_iHorScale; | 309 int32_t m_iHorScale; |
308 int32_t m_iVerScale; | 310 int32_t m_iVerScale; |
309 int32_t m_iCharSpace; | 311 int32_t m_iCharSpace; |
310 }; | 312 }; |
311 | 313 |
312 #endif // XFA_FGAS_LAYOUT_FGAS_TEXTBREAK_H_ | 314 #endif // XFA_FGAS_LAYOUT_FGAS_TEXTBREAK_H_ |
OLD | NEW |