| 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 "core/fxcrt/include/fx_ucd.h" | 10 #include "core/fxcrt/include/fx_ucd.h" |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 class IFX_TxtAccess { | 75 class IFX_TxtAccess { |
| 76 public: | 76 public: |
| 77 virtual ~IFX_TxtAccess() {} | 77 virtual ~IFX_TxtAccess() {} |
| 78 virtual FX_WCHAR GetChar(const FDE_TEXTEDITPIECE* pIdentity, | 78 virtual FX_WCHAR GetChar(const FDE_TEXTEDITPIECE* pIdentity, |
| 79 int32_t index) const = 0; | 79 int32_t index) const = 0; |
| 80 virtual int32_t GetWidth(const FDE_TEXTEDITPIECE* pIdentity, | 80 virtual int32_t GetWidth(const FDE_TEXTEDITPIECE* pIdentity, |
| 81 int32_t index) const = 0; | 81 int32_t index) const = 0; |
| 82 }; | 82 }; |
| 83 | 83 |
| 84 struct FX_TXTRUN { | 84 struct FX_TXTRUN { |
| 85 FX_TXTRUN() | 85 FX_TXTRUN(); |
| 86 : pAccess(nullptr), | 86 FX_TXTRUN(const FX_TXTRUN& other); |
| 87 pIdentity(nullptr), | 87 ~FX_TXTRUN(); |
| 88 pWidths(nullptr), | |
| 89 iLength(0), | |
| 90 pFont(nullptr), | |
| 91 fFontSize(12), | |
| 92 dwStyles(0), | |
| 93 iHorizontalScale(100), | |
| 94 iVerticalScale(100), | |
| 95 iCharRotation(0), | |
| 96 dwCharStyles(0), | |
| 97 pRect(nullptr), | |
| 98 wLineBreakChar(L'\n'), | |
| 99 bSkipSpace(TRUE) {} | |
| 100 | 88 |
| 101 IFX_TxtAccess* pAccess; | 89 IFX_TxtAccess* pAccess; |
| 102 const FDE_TEXTEDITPIECE* pIdentity; | 90 const FDE_TEXTEDITPIECE* pIdentity; |
| 103 CFX_WideString wsStr; | 91 CFX_WideString wsStr; |
| 104 int32_t* pWidths; | 92 int32_t* pWidths; |
| 105 int32_t iLength; | 93 int32_t iLength; |
| 106 CFGAS_GEFont* pFont; | 94 CFGAS_GEFont* pFont; |
| 107 FX_FLOAT fFontSize; | 95 FX_FLOAT fFontSize; |
| 108 uint32_t dwStyles; | 96 uint32_t dwStyles; |
| 109 int32_t iHorizontalScale; | 97 int32_t iHorizontalScale; |
| 110 int32_t iVerticalScale; | 98 int32_t iVerticalScale; |
| 111 int32_t iCharRotation; | 99 int32_t iCharRotation; |
| 112 uint32_t dwCharStyles; | 100 uint32_t dwCharStyles; |
| 113 const CFX_RectF* pRect; | 101 const CFX_RectF* pRect; |
| 114 FX_WCHAR wLineBreakChar; | 102 FX_WCHAR wLineBreakChar; |
| 115 FX_BOOL bSkipSpace; | 103 FX_BOOL bSkipSpace; |
| 116 }; | 104 }; |
| 117 | 105 |
| 118 class CFX_TxtPiece : public CFX_Target { | 106 class CFX_TxtPiece : public CFX_Target { |
| 119 public: | 107 public: |
| 120 CFX_TxtPiece() | 108 CFX_TxtPiece(); |
| 121 : m_dwStatus(FX_TXTBREAK_PieceBreak), | 109 |
| 122 m_iStartPos(0), | |
| 123 m_iWidth(-1), | |
| 124 m_iStartChar(0), | |
| 125 m_iChars(0), | |
| 126 m_iBidiLevel(0), | |
| 127 m_iBidiPos(0), | |
| 128 m_iHorizontalScale(100), | |
| 129 m_iVerticalScale(100), | |
| 130 m_dwCharStyles(0), | |
| 131 m_pChars(NULL), | |
| 132 m_pUserData(NULL) {} | |
| 133 int32_t GetEndPos() const { | 110 int32_t GetEndPos() const { |
| 134 return m_iWidth < 0 ? m_iStartPos : m_iStartPos + m_iWidth; | 111 return m_iWidth < 0 ? m_iStartPos : m_iStartPos + m_iWidth; |
| 135 } | 112 } |
| 136 int32_t GetLength() const { return m_iChars; } | 113 int32_t GetLength() const { return m_iChars; } |
| 137 int32_t GetEndChar() const { return m_iStartChar + m_iChars; } | 114 int32_t GetEndChar() const { return m_iStartChar + m_iChars; } |
| 138 CFX_TxtChar* GetCharPtr(int32_t index) const { | 115 CFX_TxtChar* GetCharPtr(int32_t index) const { |
| 139 ASSERT(index > -1 && index < m_iChars && m_pChars != NULL); | 116 ASSERT(index > -1 && index < m_iChars && m_pChars != NULL); |
| 140 return m_pChars->GetDataPtr(m_iStartChar + index); | 117 return m_pChars->GetDataPtr(m_iStartChar + index); |
| 141 } | 118 } |
| 142 void GetString(FX_WCHAR* pText) const { | 119 void GetString(FX_WCHAR* pText) const { |
| 143 ASSERT(pText != NULL); | 120 ASSERT(pText != NULL); |
| 144 int32_t iEndChar = m_iStartChar + m_iChars; | 121 int32_t iEndChar = m_iStartChar + m_iChars; |
| 145 CFX_Char* pChar; | 122 CFX_Char* pChar; |
| 146 for (int32_t i = m_iStartChar; i < iEndChar; i++) { | 123 for (int32_t i = m_iStartChar; i < iEndChar; i++) { |
| 147 pChar = m_pChars->GetDataPtr(i); | 124 pChar = m_pChars->GetDataPtr(i); |
| 148 *pText++ = (FX_WCHAR)pChar->m_wCharCode; | 125 *pText++ = (FX_WCHAR)pChar->m_wCharCode; |
| 149 } | 126 } |
| 150 } | 127 } |
| 151 | |
| 152 void GetString(CFX_WideString& wsText) const { | 128 void GetString(CFX_WideString& wsText) const { |
| 153 FX_WCHAR* pText = wsText.GetBuffer(m_iChars); | 129 FX_WCHAR* pText = wsText.GetBuffer(m_iChars); |
| 154 GetString(pText); | 130 GetString(pText); |
| 155 wsText.ReleaseBuffer(m_iChars); | 131 wsText.ReleaseBuffer(m_iChars); |
| 156 } | 132 } |
| 157 void GetWidths(int32_t* pWidths) const { | 133 void GetWidths(int32_t* pWidths) const { |
| 158 ASSERT(pWidths != NULL); | 134 ASSERT(pWidths != NULL); |
| 159 int32_t iEndChar = m_iStartChar + m_iChars; | 135 int32_t iEndChar = m_iStartChar + m_iChars; |
| 160 CFX_Char* pChar; | 136 CFX_Char* pChar; |
| 161 for (int32_t i = m_iStartChar; i < iEndChar; i++) { | 137 for (int32_t i = m_iStartChar; i < iEndChar; i++) { |
| 162 pChar = m_pChars->GetDataPtr(i); | 138 pChar = m_pChars->GetDataPtr(i); |
| 163 *pWidths++ = pChar->m_iCharWidth; | 139 *pWidths++ = pChar->m_iCharWidth; |
| 164 } | 140 } |
| 165 } | 141 } |
| 142 |
| 166 uint32_t m_dwStatus; | 143 uint32_t m_dwStatus; |
| 167 int32_t m_iStartPos; | 144 int32_t m_iStartPos; |
| 168 int32_t m_iWidth; | 145 int32_t m_iWidth; |
| 169 int32_t m_iStartChar; | 146 int32_t m_iStartChar; |
| 170 int32_t m_iChars; | 147 int32_t m_iChars; |
| 171 int32_t m_iBidiLevel; | 148 int32_t m_iBidiLevel; |
| 172 int32_t m_iBidiPos; | 149 int32_t m_iBidiPos; |
| 173 int32_t m_iHorizontalScale; | 150 int32_t m_iHorizontalScale; |
| 174 int32_t m_iVerticalScale; | 151 int32_t m_iVerticalScale; |
| 175 uint32_t m_dwCharStyles; | 152 uint32_t m_dwCharStyles; |
| 176 CFX_TxtCharArray* m_pChars; | 153 CFX_TxtCharArray* m_pChars; |
| 177 void* m_pUserData; | 154 void* m_pUserData; |
| 178 }; | 155 }; |
| 156 |
| 179 typedef CFX_BaseArrayTemplate<CFX_TxtPiece> CFX_TxtPieceArray; | 157 typedef CFX_BaseArrayTemplate<CFX_TxtPiece> CFX_TxtPieceArray; |
| 180 | 158 |
| 181 class CFX_TxtLine { | 159 class CFX_TxtLine { |
| 182 public: | 160 public: |
| 183 CFX_TxtLine(int32_t iBlockSize) | 161 CFX_TxtLine(int32_t iBlockSize); |
| 184 : m_iStart(0), m_iWidth(0), m_iArabicChars(0) { | 162 ~CFX_TxtLine(); |
| 185 m_pLineChars = new CFX_TxtCharArray; | 163 |
| 186 m_pLinePieces = new CFX_TxtPieceArray(16); | |
| 187 } | |
| 188 ~CFX_TxtLine() { | |
| 189 RemoveAll(); | |
| 190 delete m_pLineChars; | |
| 191 delete m_pLinePieces; | |
| 192 } | |
| 193 int32_t CountChars() const { return m_pLineChars->GetSize(); } | 164 int32_t CountChars() const { return m_pLineChars->GetSize(); } |
| 194 CFX_TxtChar* GetCharPtr(int32_t index) const { | 165 CFX_TxtChar* GetCharPtr(int32_t index) const { |
| 195 ASSERT(index > -1 && index < m_pLineChars->GetSize()); | 166 ASSERT(index > -1 && index < m_pLineChars->GetSize()); |
| 196 return m_pLineChars->GetDataPtr(index); | 167 return m_pLineChars->GetDataPtr(index); |
| 197 } | 168 } |
| 198 int32_t CountPieces() const { return m_pLinePieces->GetSize(); } | 169 int32_t CountPieces() const { return m_pLinePieces->GetSize(); } |
| 199 CFX_TxtPiece* GetPiecePtr(int32_t index) const { | 170 CFX_TxtPiece* GetPiecePtr(int32_t index) const { |
| 200 ASSERT(index > -1 && index < m_pLinePieces->GetSize()); | 171 ASSERT(index > -1 && index < m_pLinePieces->GetSize()); |
| 201 return m_pLinePieces->GetPtrAt(index); | 172 return m_pLinePieces->GetPtrAt(index); |
| 202 } | 173 } |
| 203 void GetString(CFX_WideString& wsStr) const { | 174 void GetString(CFX_WideString& wsStr) const { |
| 204 int32_t iCount = m_pLineChars->GetSize(); | 175 int32_t iCount = m_pLineChars->GetSize(); |
| 205 FX_WCHAR* pBuf = wsStr.GetBuffer(iCount); | 176 FX_WCHAR* pBuf = wsStr.GetBuffer(iCount); |
| 206 CFX_Char* pChar; | 177 CFX_Char* pChar; |
| 207 for (int32_t i = 0; i < iCount; i++) { | 178 for (int32_t i = 0; i < iCount; i++) { |
| 208 pChar = m_pLineChars->GetDataPtr(i); | 179 pChar = m_pLineChars->GetDataPtr(i); |
| 209 *pBuf++ = (FX_WCHAR)pChar->m_wCharCode; | 180 *pBuf++ = (FX_WCHAR)pChar->m_wCharCode; |
| 210 } | 181 } |
| 211 wsStr.ReleaseBuffer(iCount); | 182 wsStr.ReleaseBuffer(iCount); |
| 212 } | 183 } |
| 213 void RemoveAll(FX_BOOL bLeaveMemory = FALSE) { | 184 void RemoveAll(FX_BOOL bLeaveMemory = FALSE) { |
| 214 m_pLineChars->RemoveAll(); | 185 m_pLineChars->RemoveAll(); |
| 215 m_pLinePieces->RemoveAll(bLeaveMemory); | 186 m_pLinePieces->RemoveAll(bLeaveMemory); |
| 216 m_iWidth = 0; | 187 m_iWidth = 0; |
| 217 m_iArabicChars = 0; | 188 m_iArabicChars = 0; |
| 218 } | 189 } |
| 190 |
| 219 CFX_TxtCharArray* m_pLineChars; | 191 CFX_TxtCharArray* m_pLineChars; |
| 220 CFX_TxtPieceArray* m_pLinePieces; | 192 CFX_TxtPieceArray* m_pLinePieces; |
| 221 int32_t m_iStart; | 193 int32_t m_iStart; |
| 222 int32_t m_iWidth; | 194 int32_t m_iWidth; |
| 223 int32_t m_iArabicChars; | 195 int32_t m_iArabicChars; |
| 224 }; | 196 }; |
| 225 | 197 |
| 226 class CFX_TxtBreak { | 198 class CFX_TxtBreak { |
| 227 public: | 199 public: |
| 228 CFX_TxtBreak(uint32_t dwPolicies); | 200 CFX_TxtBreak(uint32_t dwPolicies); |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 CFX_TxtLine* m_pTxtLine2; | 301 CFX_TxtLine* m_pTxtLine2; |
| 330 CFX_TxtLine* m_pCurLine; | 302 CFX_TxtLine* m_pCurLine; |
| 331 int32_t m_iReady; | 303 int32_t m_iReady; |
| 332 int32_t m_iTolerance; | 304 int32_t m_iTolerance; |
| 333 int32_t m_iHorScale; | 305 int32_t m_iHorScale; |
| 334 int32_t m_iVerScale; | 306 int32_t m_iVerScale; |
| 335 int32_t m_iCharSpace; | 307 int32_t m_iCharSpace; |
| 336 }; | 308 }; |
| 337 | 309 |
| 338 #endif // XFA_FGAS_LAYOUT_FGAS_TEXTBREAK_H_ | 310 #endif // XFA_FGAS_LAYOUT_FGAS_TEXTBREAK_H_ |
| OLD | NEW |