| 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> |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 int32_t iLength; | 95 int32_t iLength; |
| 96 CFGAS_GEFont* pFont; | 96 CFGAS_GEFont* pFont; |
| 97 FX_FLOAT fFontSize; | 97 FX_FLOAT fFontSize; |
| 98 uint32_t dwStyles; | 98 uint32_t dwStyles; |
| 99 int32_t iHorizontalScale; | 99 int32_t iHorizontalScale; |
| 100 int32_t iVerticalScale; | 100 int32_t iVerticalScale; |
| 101 int32_t iCharRotation; | 101 int32_t iCharRotation; |
| 102 uint32_t dwCharStyles; | 102 uint32_t dwCharStyles; |
| 103 const CFX_RectF* pRect; | 103 const CFX_RectF* pRect; |
| 104 FX_WCHAR wLineBreakChar; | 104 FX_WCHAR wLineBreakChar; |
| 105 FX_BOOL bSkipSpace; | 105 bool bSkipSpace; |
| 106 }; | 106 }; |
| 107 | 107 |
| 108 class CFX_TxtPiece : public CFX_Target { | 108 class CFX_TxtPiece : public CFX_Target { |
| 109 public: | 109 public: |
| 110 CFX_TxtPiece(); | 110 CFX_TxtPiece(); |
| 111 | 111 |
| 112 int32_t GetEndPos() const { | 112 int32_t GetEndPos() const { |
| 113 return m_iWidth < 0 ? m_iStartPos : m_iStartPos + m_iWidth; | 113 return m_iWidth < 0 ? m_iStartPos : m_iStartPos + m_iWidth; |
| 114 } | 114 } |
| 115 int32_t GetLength() const { return m_iChars; } | 115 int32_t GetLength() const { return m_iChars; } |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 void GetString(CFX_WideString& wsStr) const { | 176 void GetString(CFX_WideString& wsStr) const { |
| 177 int32_t iCount = m_pLineChars->GetSize(); | 177 int32_t iCount = m_pLineChars->GetSize(); |
| 178 FX_WCHAR* pBuf = wsStr.GetBuffer(iCount); | 178 FX_WCHAR* pBuf = wsStr.GetBuffer(iCount); |
| 179 CFX_Char* pChar; | 179 CFX_Char* pChar; |
| 180 for (int32_t i = 0; i < iCount; i++) { | 180 for (int32_t i = 0; i < iCount; i++) { |
| 181 pChar = m_pLineChars->GetDataPtr(i); | 181 pChar = m_pLineChars->GetDataPtr(i); |
| 182 *pBuf++ = (FX_WCHAR)pChar->m_wCharCode; | 182 *pBuf++ = (FX_WCHAR)pChar->m_wCharCode; |
| 183 } | 183 } |
| 184 wsStr.ReleaseBuffer(iCount); | 184 wsStr.ReleaseBuffer(iCount); |
| 185 } | 185 } |
| 186 void RemoveAll(FX_BOOL bLeaveMemory = FALSE) { | 186 void RemoveAll(bool bLeaveMemory = false) { |
| 187 m_pLineChars->RemoveAll(); | 187 m_pLineChars->RemoveAll(); |
| 188 m_pLinePieces->RemoveAll(bLeaveMemory); | 188 m_pLinePieces->RemoveAll(bLeaveMemory); |
| 189 m_iWidth = 0; | 189 m_iWidth = 0; |
| 190 m_iArabicChars = 0; | 190 m_iArabicChars = 0; |
| 191 } | 191 } |
| 192 | 192 |
| 193 std::unique_ptr<CFX_TxtCharArray> m_pLineChars; | 193 std::unique_ptr<CFX_TxtCharArray> m_pLineChars; |
| 194 std::unique_ptr<CFX_TxtPieceArray> m_pLinePieces; | 194 std::unique_ptr<CFX_TxtPieceArray> m_pLinePieces; |
| 195 int32_t m_iStart; | 195 int32_t m_iStart; |
| 196 int32_t m_iWidth; | 196 int32_t m_iWidth; |
| 197 int32_t m_iArabicChars; | 197 int32_t m_iArabicChars; |
| 198 }; | 198 }; |
| 199 | 199 |
| 200 class CFX_TxtBreak { | 200 class CFX_TxtBreak { |
| 201 public: | 201 public: |
| 202 CFX_TxtBreak(uint32_t dwPolicies); | 202 CFX_TxtBreak(uint32_t dwPolicies); |
| 203 ~CFX_TxtBreak(); | 203 ~CFX_TxtBreak(); |
| 204 | 204 |
| 205 void SetLineWidth(FX_FLOAT fLineWidth); | 205 void SetLineWidth(FX_FLOAT fLineWidth); |
| 206 void SetLinePos(FX_FLOAT fLinePos); | 206 void SetLinePos(FX_FLOAT fLinePos); |
| 207 uint32_t GetLayoutStyles() const { return m_dwLayoutStyles; } | 207 uint32_t GetLayoutStyles() const { return m_dwLayoutStyles; } |
| 208 void SetLayoutStyles(uint32_t dwLayoutStyles); | 208 void SetLayoutStyles(uint32_t dwLayoutStyles); |
| 209 void SetFont(CFGAS_GEFont* pFont); | 209 void SetFont(CFGAS_GEFont* pFont); |
| 210 void SetFontSize(FX_FLOAT fFontSize); | 210 void SetFontSize(FX_FLOAT fFontSize); |
| 211 void SetTabWidth(FX_FLOAT fTabWidth, FX_BOOL bEquidistant); | 211 void SetTabWidth(FX_FLOAT fTabWidth, bool bEquidistant); |
| 212 void SetDefaultChar(FX_WCHAR wch); | 212 void SetDefaultChar(FX_WCHAR wch); |
| 213 void SetParagraphBreakChar(FX_WCHAR wch); | 213 void SetParagraphBreakChar(FX_WCHAR wch); |
| 214 void SetLineBreakTolerance(FX_FLOAT fTolerance); | 214 void SetLineBreakTolerance(FX_FLOAT fTolerance); |
| 215 void SetHorizontalScale(int32_t iScale); | 215 void SetHorizontalScale(int32_t iScale); |
| 216 void SetVerticalScale(int32_t iScale); | 216 void SetVerticalScale(int32_t iScale); |
| 217 void SetCharRotation(int32_t iCharRotation); | 217 void SetCharRotation(int32_t iCharRotation); |
| 218 void SetCharSpace(FX_FLOAT fCharSpace); | 218 void SetCharSpace(FX_FLOAT fCharSpace); |
| 219 void SetAlignment(int32_t iAlignment); | 219 void SetAlignment(int32_t iAlignment); |
| 220 uint32_t GetContextCharStyles() const; | 220 uint32_t GetContextCharStyles() const; |
| 221 void SetContextCharStyles(uint32_t dwCharStyles); | 221 void SetContextCharStyles(uint32_t dwCharStyles); |
| 222 void SetCombWidth(FX_FLOAT fCombWidth); | 222 void SetCombWidth(FX_FLOAT fCombWidth); |
| 223 void SetUserData(void* pUserData); | 223 void SetUserData(void* pUserData); |
| 224 uint32_t AppendChar(FX_WCHAR wch); | 224 uint32_t AppendChar(FX_WCHAR wch); |
| 225 uint32_t EndBreak(uint32_t dwStatus = FX_TXTBREAK_PieceBreak); | 225 uint32_t EndBreak(uint32_t dwStatus = FX_TXTBREAK_PieceBreak); |
| 226 int32_t CountBreakChars() const; | 226 int32_t CountBreakChars() const; |
| 227 int32_t CountBreakPieces() const; | 227 int32_t CountBreakPieces() const; |
| 228 const CFX_TxtPiece* GetBreakPiece(int32_t index) const; | 228 const CFX_TxtPiece* GetBreakPiece(int32_t index) const; |
| 229 void ClearBreakPieces(); | 229 void ClearBreakPieces(); |
| 230 void Reset(); | 230 void Reset(); |
| 231 int32_t GetDisplayPos(const FX_TXTRUN* pTxtRun, | 231 int32_t GetDisplayPos(const FX_TXTRUN* pTxtRun, |
| 232 FXTEXT_CHARPOS* pCharPos, | 232 FXTEXT_CHARPOS* pCharPos, |
| 233 FX_BOOL bCharCode = FALSE, | 233 bool bCharCode = false, |
| 234 CFX_WideString* pWSForms = nullptr, | 234 CFX_WideString* pWSForms = nullptr, |
| 235 FX_AdjustCharDisplayPos pAdjustPos = nullptr) const; | 235 FX_AdjustCharDisplayPos pAdjustPos = nullptr) const; |
| 236 int32_t GetCharRects(const FX_TXTRUN* pTxtRun, | 236 int32_t GetCharRects(const FX_TXTRUN* pTxtRun, |
| 237 CFX_RectFArray& rtArray, | 237 CFX_RectFArray& rtArray, |
| 238 FX_BOOL bCharBBox = FALSE) const; | 238 bool bCharBBox = false) const; |
| 239 void AppendChar_PageLoad(CFX_TxtChar* pCurChar, uint32_t dwProps); | 239 void AppendChar_PageLoad(CFX_TxtChar* pCurChar, uint32_t dwProps); |
| 240 uint32_t AppendChar_Combination(CFX_TxtChar* pCurChar, int32_t iRotation); | 240 uint32_t AppendChar_Combination(CFX_TxtChar* pCurChar, int32_t iRotation); |
| 241 uint32_t AppendChar_Tab(CFX_TxtChar* pCurChar, int32_t iRotation); | 241 uint32_t AppendChar_Tab(CFX_TxtChar* pCurChar, int32_t iRotation); |
| 242 uint32_t AppendChar_Control(CFX_TxtChar* pCurChar, int32_t iRotation); | 242 uint32_t AppendChar_Control(CFX_TxtChar* pCurChar, int32_t iRotation); |
| 243 uint32_t AppendChar_Arabic(CFX_TxtChar* pCurChar, int32_t iRotation); | 243 uint32_t AppendChar_Arabic(CFX_TxtChar* pCurChar, int32_t iRotation); |
| 244 uint32_t AppendChar_Others(CFX_TxtChar* pCurChar, int32_t iRotation); | 244 uint32_t AppendChar_Others(CFX_TxtChar* pCurChar, int32_t iRotation); |
| 245 | 245 |
| 246 private: | 246 private: |
| 247 void SetBreakStatus(); | 247 void SetBreakStatus(); |
| 248 int32_t GetLineRotation(uint32_t dwStyles) const; | 248 int32_t GetLineRotation(uint32_t dwStyles) const; |
| 249 CFX_TxtChar* GetLastChar(int32_t index, FX_BOOL bOmitChar = TRUE) const; | 249 CFX_TxtChar* GetLastChar(int32_t index, bool bOmitChar = true) const; |
| 250 CFX_TxtLine* GetTxtLine(FX_BOOL bReady) const; | 250 CFX_TxtLine* GetTxtLine(bool bReady) const; |
| 251 CFX_TxtPieceArray* GetTxtPieces(FX_BOOL bReady) const; | 251 CFX_TxtPieceArray* GetTxtPieces(bool bReady) const; |
| 252 FX_CHARTYPE GetUnifiedCharType(FX_CHARTYPE dwType) const; | 252 FX_CHARTYPE GetUnifiedCharType(FX_CHARTYPE dwType) const; |
| 253 void ResetArabicContext(); | 253 void ResetArabicContext(); |
| 254 void ResetContextCharStyles(); | 254 void ResetContextCharStyles(); |
| 255 void EndBreak_UpdateArabicShapes(); | 255 void EndBreak_UpdateArabicShapes(); |
| 256 FX_BOOL EndBreak_SplitLine(CFX_TxtLine* pNextLine, | 256 bool EndBreak_SplitLine(CFX_TxtLine* pNextLine, |
| 257 FX_BOOL bAllChars, | 257 bool bAllChars, |
| 258 uint32_t dwStatus); | 258 uint32_t dwStatus); |
| 259 void EndBreak_BidiLine(CFX_TPOArray& tpos, uint32_t dwStatus); | 259 void EndBreak_BidiLine(CFX_TPOArray& tpos, uint32_t dwStatus); |
| 260 void EndBreak_Alignment(CFX_TPOArray& tpos, | 260 void EndBreak_Alignment(CFX_TPOArray& tpos, |
| 261 FX_BOOL bAllChars, | 261 bool bAllChars, |
| 262 uint32_t dwStatus); | 262 uint32_t dwStatus); |
| 263 int32_t GetBreakPos(CFX_TxtCharArray& ca, | 263 int32_t GetBreakPos(CFX_TxtCharArray& ca, |
| 264 int32_t& iEndPos, | 264 int32_t& iEndPos, |
| 265 FX_BOOL bAllChars = FALSE, | 265 bool bAllChars = false, |
| 266 FX_BOOL bOnlyBrk = FALSE); | 266 bool bOnlyBrk = false); |
| 267 void SplitTextLine(CFX_TxtLine* pCurLine, | 267 void SplitTextLine(CFX_TxtLine* pCurLine, |
| 268 CFX_TxtLine* pNextLine, | 268 CFX_TxtLine* pNextLine, |
| 269 FX_BOOL bAllChars = FALSE); | 269 bool bAllChars = false); |
| 270 | 270 |
| 271 uint32_t m_dwPolicies; | 271 uint32_t m_dwPolicies; |
| 272 FX_BOOL m_bPagination; | 272 bool m_bPagination; |
| 273 int32_t m_iLineWidth; | 273 int32_t m_iLineWidth; |
| 274 uint32_t m_dwLayoutStyles; | 274 uint32_t m_dwLayoutStyles; |
| 275 FX_BOOL m_bVertical; | 275 bool m_bVertical; |
| 276 FX_BOOL m_bArabicContext; | 276 bool m_bArabicContext; |
| 277 FX_BOOL m_bArabicShapes; | 277 bool m_bArabicShapes; |
| 278 FX_BOOL m_bRTL; | 278 bool m_bRTL; |
| 279 FX_BOOL m_bSingleLine; | 279 bool m_bSingleLine; |
| 280 FX_BOOL m_bCombText; | 280 bool m_bCombText; |
| 281 int32_t m_iArabicContext; | 281 int32_t m_iArabicContext; |
| 282 int32_t m_iCurArabicContext; | 282 int32_t m_iCurArabicContext; |
| 283 CFGAS_GEFont* m_pFont; | 283 CFGAS_GEFont* m_pFont; |
| 284 int32_t m_iFontSize; | 284 int32_t m_iFontSize; |
| 285 FX_BOOL m_bEquidistant; | 285 bool m_bEquidistant; |
| 286 int32_t m_iTabWidth; | 286 int32_t m_iTabWidth; |
| 287 FX_WCHAR m_wDefChar; | 287 FX_WCHAR m_wDefChar; |
| 288 FX_WCHAR m_wParagBreakChar; | 288 FX_WCHAR m_wParagBreakChar; |
| 289 int32_t m_iDefChar; | 289 int32_t m_iDefChar; |
| 290 int32_t m_iLineRotation; | 290 int32_t m_iLineRotation; |
| 291 int32_t m_iCharRotation; | 291 int32_t m_iCharRotation; |
| 292 int32_t m_iRotation; | 292 int32_t m_iRotation; |
| 293 int32_t m_iAlignment; | 293 int32_t m_iAlignment; |
| 294 uint32_t m_dwContextCharStyles; | 294 uint32_t m_dwContextCharStyles; |
| 295 int32_t m_iCombWidth; | 295 int32_t m_iCombWidth; |
| 296 void* m_pUserData; | 296 void* m_pUserData; |
| 297 FX_CHARTYPE m_eCharType; | 297 FX_CHARTYPE m_eCharType; |
| 298 FX_BOOL m_bCurRTL; | 298 bool m_bCurRTL; |
| 299 int32_t m_iCurAlignment; | 299 int32_t m_iCurAlignment; |
| 300 FX_BOOL m_bArabicNumber; | 300 bool m_bArabicNumber; |
| 301 FX_BOOL m_bArabicComma; | 301 bool m_bArabicComma; |
| 302 std::unique_ptr<CFX_TxtLine> m_pTxtLine1; | 302 std::unique_ptr<CFX_TxtLine> m_pTxtLine1; |
| 303 std::unique_ptr<CFX_TxtLine> m_pTxtLine2; | 303 std::unique_ptr<CFX_TxtLine> m_pTxtLine2; |
| 304 CFX_TxtLine* m_pCurLine; | 304 CFX_TxtLine* m_pCurLine; |
| 305 int32_t m_iReady; | 305 int32_t m_iReady; |
| 306 int32_t m_iTolerance; | 306 int32_t m_iTolerance; |
| 307 int32_t m_iHorScale; | 307 int32_t m_iHorScale; |
| 308 int32_t m_iVerScale; | 308 int32_t m_iVerScale; |
| 309 int32_t m_iCharSpace; | 309 int32_t m_iCharSpace; |
| 310 }; | 310 }; |
| 311 | 311 |
| 312 #endif // XFA_FGAS_LAYOUT_FGAS_TEXTBREAK_H_ | 312 #endif // XFA_FGAS_LAYOUT_FGAS_TEXTBREAK_H_ |
| OLD | NEW |