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_FXFA_APP_XFA_TEXTLAYOUT_H_ | 7 #ifndef XFA_FXFA_APP_XFA_TEXTLAYOUT_H_ |
8 #define XFA_FXFA_APP_XFA_TEXTLAYOUT_H_ | 8 #define XFA_FXFA_APP_XFA_TEXTLAYOUT_H_ |
9 | 9 |
10 #include <map> | 10 #include <map> |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 CFX_WideString& wsValue); | 123 CFX_WideString& wsValue); |
124 CXFA_TextParseContext* GetParseContextFromMap(CFDE_XMLNode* pXMLNode); | 124 CXFA_TextParseContext* GetParseContextFromMap(CFDE_XMLNode* pXMLNode); |
125 | 125 |
126 private: | 126 private: |
127 void InitCSSData(CXFA_TextProvider* pTextProvider); | 127 void InitCSSData(CXFA_TextProvider* pTextProvider); |
128 void ParseRichText(CFDE_XMLNode* pXMLNode, | 128 void ParseRichText(CFDE_XMLNode* pXMLNode, |
129 IFDE_CSSComputedStyle* pParentStyle); | 129 IFDE_CSSComputedStyle* pParentStyle); |
130 void ParseTagInfo(CFDE_XMLNode* pXMLNode, CXFA_CSSTagProvider& tagProvider); | 130 void ParseTagInfo(CFDE_XMLNode* pXMLNode, CXFA_CSSTagProvider& tagProvider); |
131 IFDE_CSSStyleSheet* LoadDefaultSheetStyle(); | 131 IFDE_CSSStyleSheet* LoadDefaultSheetStyle(); |
132 IFDE_CSSComputedStyle* CreateStyle(IFDE_CSSComputedStyle* pParentStyle); | 132 IFDE_CSSComputedStyle* CreateStyle(IFDE_CSSComputedStyle* pParentStyle); |
133 IFX_MEMAllocator* m_pAllocator; | 133 IFX_MemoryAllocator* m_pAllocator; |
134 CFDE_CSSStyleSelector* m_pSelector; | 134 CFDE_CSSStyleSelector* m_pSelector; |
135 IFDE_CSSStyleSheet* m_pUASheet; | 135 IFDE_CSSStyleSheet* m_pUASheet; |
136 CFX_MapPtrTemplate<CFDE_XMLNode*, CXFA_TextParseContext*> | 136 CFX_MapPtrTemplate<CFDE_XMLNode*, CXFA_TextParseContext*> |
137 m_mapXMLNodeToParseContext; | 137 m_mapXMLNodeToParseContext; |
138 }; | 138 }; |
139 | 139 |
140 class CXFA_LoaderContext { | 140 class CXFA_LoaderContext { |
141 public: | 141 public: |
142 CXFA_LoaderContext() | 142 CXFA_LoaderContext() |
143 : m_bSaveLineHeight(FALSE), | 143 : m_bSaveLineHeight(FALSE), |
(...skipping 18 matching lines...) Expand all Loading... |
162 CFDE_XMLNode* m_pXMLNode; | 162 CFDE_XMLNode* m_pXMLNode; |
163 CXFA_Node* m_pNode; | 163 CXFA_Node* m_pNode; |
164 IFDE_CSSComputedStyle* m_pParentStyle; | 164 IFDE_CSSComputedStyle* m_pParentStyle; |
165 CFX_ArrayTemplate<FX_FLOAT> m_lineHeights; | 165 CFX_ArrayTemplate<FX_FLOAT> m_lineHeights; |
166 uint32_t m_dwFlags; | 166 uint32_t m_dwFlags; |
167 CFX_FloatArray m_BlocksHeight; | 167 CFX_FloatArray m_BlocksHeight; |
168 }; | 168 }; |
169 | 169 |
170 class CXFA_LinkUserData : public IFX_Unknown, public CFX_Target { | 170 class CXFA_LinkUserData : public IFX_Unknown, public CFX_Target { |
171 public: | 171 public: |
172 CXFA_LinkUserData(IFX_MEMAllocator* pAllocator, FX_WCHAR* pszText) | 172 CXFA_LinkUserData(IFX_MemoryAllocator* pAllocator, FX_WCHAR* pszText) |
173 : m_pAllocator(pAllocator), m_dwRefCount(1) { | 173 : m_pAllocator(pAllocator), m_dwRefCount(1) { |
174 m_pszURLContent = pszText; | 174 m_pszURLContent = pszText; |
175 } | 175 } |
176 ~CXFA_LinkUserData() {} | 176 ~CXFA_LinkUserData() {} |
177 virtual uint32_t Release() { | 177 virtual uint32_t Release() { |
178 uint32_t dwRefCount = --m_dwRefCount; | 178 uint32_t dwRefCount = --m_dwRefCount; |
179 if (dwRefCount <= 0) { | 179 if (dwRefCount <= 0) { |
180 FXTARGET_DeleteWith(CXFA_LinkUserData, m_pAllocator, this); | 180 FXTARGET_DeleteWith(CXFA_LinkUserData, m_pAllocator, this); |
181 } | 181 } |
182 return dwRefCount; | 182 return dwRefCount; |
183 } | 183 } |
184 virtual uint32_t AddRef() { return ++m_dwRefCount; } | 184 virtual uint32_t AddRef() { return ++m_dwRefCount; } |
185 | 185 |
186 const FX_WCHAR* GetLinkURL() { return m_pszURLContent.c_str(); } | 186 const FX_WCHAR* GetLinkURL() { return m_pszURLContent.c_str(); } |
187 | 187 |
188 protected: | 188 protected: |
189 IFX_MEMAllocator* m_pAllocator; | 189 IFX_MemoryAllocator* m_pAllocator; |
190 uint32_t m_dwRefCount; | 190 uint32_t m_dwRefCount; |
191 CFX_WideString m_pszURLContent; | 191 CFX_WideString m_pszURLContent; |
192 }; | 192 }; |
193 | 193 |
194 class CXFA_TextUserData : public IFX_Unknown, public CFX_Target { | 194 class CXFA_TextUserData : public IFX_Unknown, public CFX_Target { |
195 public: | 195 public: |
196 CXFA_TextUserData(IFX_MEMAllocator* pAllocator, IFDE_CSSComputedStyle* pStyle) | 196 CXFA_TextUserData(IFX_MemoryAllocator* pAllocator, |
| 197 IFDE_CSSComputedStyle* pStyle) |
197 : m_pStyle(pStyle), | 198 : m_pStyle(pStyle), |
198 m_pLinkData(nullptr), | 199 m_pLinkData(nullptr), |
199 m_pAllocator(pAllocator), | 200 m_pAllocator(pAllocator), |
200 m_dwRefCount(0) { | 201 m_dwRefCount(0) { |
201 ASSERT(m_pAllocator); | 202 ASSERT(m_pAllocator); |
202 if (m_pStyle) | 203 if (m_pStyle) |
203 m_pStyle->AddRef(); | 204 m_pStyle->AddRef(); |
204 } | 205 } |
205 CXFA_TextUserData(IFX_MEMAllocator* pAllocator, | 206 CXFA_TextUserData(IFX_MemoryAllocator* pAllocator, |
206 IFDE_CSSComputedStyle* pStyle, | 207 IFDE_CSSComputedStyle* pStyle, |
207 CXFA_LinkUserData* pLinkData) | 208 CXFA_LinkUserData* pLinkData) |
208 : m_pStyle(pStyle), | 209 : m_pStyle(pStyle), |
209 m_pLinkData(pLinkData), | 210 m_pLinkData(pLinkData), |
210 m_pAllocator(pAllocator), | 211 m_pAllocator(pAllocator), |
211 m_dwRefCount(0) { | 212 m_dwRefCount(0) { |
212 ASSERT(m_pAllocator); | 213 ASSERT(m_pAllocator); |
213 if (m_pStyle) | 214 if (m_pStyle) |
214 m_pStyle->AddRef(); | 215 m_pStyle->AddRef(); |
215 } | 216 } |
216 ~CXFA_TextUserData() { | 217 ~CXFA_TextUserData() { |
217 if (m_pStyle) | 218 if (m_pStyle) |
218 m_pStyle->Release(); | 219 m_pStyle->Release(); |
219 if (m_pLinkData) | 220 if (m_pLinkData) |
220 m_pLinkData->Release(); | 221 m_pLinkData->Release(); |
221 } | 222 } |
222 virtual uint32_t Release() { | 223 virtual uint32_t Release() { |
223 uint32_t dwRefCount = --m_dwRefCount; | 224 uint32_t dwRefCount = --m_dwRefCount; |
224 if (dwRefCount == 0) { | 225 if (dwRefCount == 0) { |
225 FXTARGET_DeleteWith(CXFA_TextUserData, m_pAllocator, this); | 226 FXTARGET_DeleteWith(CXFA_TextUserData, m_pAllocator, this); |
226 } | 227 } |
227 return dwRefCount; | 228 return dwRefCount; |
228 } | 229 } |
229 virtual uint32_t AddRef() { return ++m_dwRefCount; } | 230 virtual uint32_t AddRef() { return ++m_dwRefCount; } |
230 | 231 |
231 IFDE_CSSComputedStyle* m_pStyle; | 232 IFDE_CSSComputedStyle* m_pStyle; |
232 CXFA_LinkUserData* m_pLinkData; | 233 CXFA_LinkUserData* m_pLinkData; |
233 | 234 |
234 protected: | 235 protected: |
235 IFX_MEMAllocator* m_pAllocator; | 236 IFX_MemoryAllocator* m_pAllocator; |
236 uint32_t m_dwRefCount; | 237 uint32_t m_dwRefCount; |
237 }; | 238 }; |
238 | 239 |
239 class XFA_TextPiece : public CFX_Target { | 240 class XFA_TextPiece : public CFX_Target { |
240 public: | 241 public: |
241 XFA_TextPiece() : pszText(nullptr), pFont(nullptr), pLinkData(nullptr) {} | 242 XFA_TextPiece() : pszText(nullptr), pFont(nullptr), pLinkData(nullptr) {} |
242 ~XFA_TextPiece() { | 243 ~XFA_TextPiece() { |
243 if (pLinkData) | 244 if (pLinkData) |
244 pLinkData->Release(); | 245 pLinkData->Release(); |
245 } | 246 } |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 FXTEXT_CHARPOS* pCharPos, | 398 FXTEXT_CHARPOS* pCharPos, |
398 FX_BOOL bCharCode = FALSE); | 399 FX_BOOL bCharCode = FALSE); |
399 FX_BOOL ToRun(const XFA_TextPiece* pPiece, FX_RTFTEXTOBJ& tr); | 400 FX_BOOL ToRun(const XFA_TextPiece* pPiece, FX_RTFTEXTOBJ& tr); |
400 void DoTabstops(IFDE_CSSComputedStyle* pStyle, CXFA_PieceLine* pPieceLine); | 401 void DoTabstops(IFDE_CSSComputedStyle* pStyle, CXFA_PieceLine* pPieceLine); |
401 FX_BOOL Layout(int32_t iBlock); | 402 FX_BOOL Layout(int32_t iBlock); |
402 int32_t CountBlocks() const; | 403 int32_t CountBlocks() const; |
403 | 404 |
404 CXFA_TextProvider* m_pTextProvider; | 405 CXFA_TextProvider* m_pTextProvider; |
405 CXFA_Node* m_pTextDataNode; | 406 CXFA_Node* m_pTextDataNode; |
406 FX_BOOL m_bRichText; | 407 FX_BOOL m_bRichText; |
407 IFX_MEMAllocator* m_pAllocator; | 408 IFX_MemoryAllocator* m_pAllocator; |
408 CFX_RTFBreak* m_pBreak; | 409 CFX_RTFBreak* m_pBreak; |
409 CXFA_LoaderContext* m_pLoader; | 410 CXFA_LoaderContext* m_pLoader; |
410 int32_t m_iLines; | 411 int32_t m_iLines; |
411 FX_FLOAT m_fMaxWidth; | 412 FX_FLOAT m_fMaxWidth; |
412 CXFA_TextParser m_textParser; | 413 CXFA_TextParser m_textParser; |
413 CXFA_PieceLineArray m_pieceLines; | 414 CXFA_PieceLineArray m_pieceLines; |
414 CXFA_TextTabstopsContext* m_pTabstopContext; | 415 CXFA_TextTabstopsContext* m_pTabstopContext; |
415 FX_BOOL m_bBlockContinue; | 416 FX_BOOL m_bBlockContinue; |
416 }; | 417 }; |
417 | 418 |
418 #endif // XFA_FXFA_APP_XFA_TEXTLAYOUT_H_ | 419 #endif // XFA_FXFA_APP_XFA_TEXTLAYOUT_H_ |
OLD | NEW |