Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(879)

Side by Side Diff: xfa/fxfa/app/xfa_textlayout.cpp

Issue 1836353002: Remove IFDE_XML* classes. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « xfa/fxfa/app/xfa_textlayout.h ('k') | xfa/fxfa/parser/xfa_document_datamerger_imp.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "xfa/fxfa/app/xfa_textlayout.h" 7 #include "xfa/fxfa/app/xfa_textlayout.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
11 #include "core/fxcrt/include/fx_ext.h" 11 #include "core/fxcrt/include/fx_ext.h"
12 #include "xfa/fde/fde_pen.h" 12 #include "xfa/fde/fde_pen.h"
13 #include "xfa/fde/xml/fde_xml_imp.h"
13 #include "xfa/fgas/crt/fgas_algorithm.h" 14 #include "xfa/fgas/crt/fgas_algorithm.h"
14 #include "xfa/fgas/crt/fgas_codepage.h" 15 #include "xfa/fgas/crt/fgas_codepage.h"
15 #include "xfa/fxfa/app/xfa_ffapp.h" 16 #include "xfa/fxfa/app/xfa_ffapp.h"
16 #include "xfa/fxfa/app/xfa_ffdoc.h" 17 #include "xfa/fxfa/app/xfa_ffdoc.h"
17 #include "xfa/fxfa/app/xfa_fontmgr.h" 18 #include "xfa/fxfa/app/xfa_fontmgr.h"
18 19
19 CXFA_CSSTagProvider::~CXFA_CSSTagProvider() { 20 CXFA_CSSTagProvider::~CXFA_CSSTagProvider() {
20 FX_POSITION pos = m_Attributes.GetStartPosition(); 21 FX_POSITION pos = m_Attributes.GetStartPosition();
21 while (pos) { 22 while (pos) {
22 CFX_WideString *pName = NULL, *pValue = NULL; 23 CFX_WideString *pName = NULL, *pValue = NULL;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 } 58 }
58 CXFA_TextParser::~CXFA_TextParser() { 59 CXFA_TextParser::~CXFA_TextParser() {
59 if (m_pUASheet) 60 if (m_pUASheet)
60 m_pUASheet->Release(); 61 m_pUASheet->Release();
61 if (m_pSelector) 62 if (m_pSelector)
62 m_pSelector->Release(); 63 m_pSelector->Release();
63 if (m_pAllocator) 64 if (m_pAllocator)
64 m_pAllocator->Release(); 65 m_pAllocator->Release();
65 FX_POSITION ps = m_mapXMLNodeToParseContext.GetStartPosition(); 66 FX_POSITION ps = m_mapXMLNodeToParseContext.GetStartPosition();
66 while (ps) { 67 while (ps) {
67 IFDE_XMLNode* pXMLNode; 68 CFDE_XMLNode* pXMLNode;
68 CXFA_TextParseContext* pParseContext; 69 CXFA_TextParseContext* pParseContext;
69 m_mapXMLNodeToParseContext.GetNextAssoc(ps, pXMLNode, pParseContext); 70 m_mapXMLNodeToParseContext.GetNextAssoc(ps, pXMLNode, pParseContext);
70 if (pParseContext) 71 if (pParseContext)
71 FXTARGET_DeleteWith(CXFA_TextParseContext, m_pAllocator, pParseContext); 72 FXTARGET_DeleteWith(CXFA_TextParseContext, m_pAllocator, pParseContext);
72 } 73 }
73 m_mapXMLNodeToParseContext.RemoveAll(); 74 m_mapXMLNodeToParseContext.RemoveAll();
74 } 75 }
75 void CXFA_TextParser::Reset() { 76 void CXFA_TextParser::Reset() {
76 FX_POSITION ps = m_mapXMLNodeToParseContext.GetStartPosition(); 77 FX_POSITION ps = m_mapXMLNodeToParseContext.GetStartPosition();
77 while (ps) { 78 while (ps) {
78 IFDE_XMLNode* pXMLNode; 79 CFDE_XMLNode* pXMLNode;
79 CXFA_TextParseContext* pParseContext; 80 CXFA_TextParseContext* pParseContext;
80 m_mapXMLNodeToParseContext.GetNextAssoc(ps, pXMLNode, pParseContext); 81 m_mapXMLNodeToParseContext.GetNextAssoc(ps, pXMLNode, pParseContext);
81 if (pParseContext) 82 if (pParseContext)
82 FXTARGET_DeleteWith(CXFA_TextParseContext, m_pAllocator, pParseContext); 83 FXTARGET_DeleteWith(CXFA_TextParseContext, m_pAllocator, pParseContext);
83 } 84 }
84 m_mapXMLNodeToParseContext.RemoveAll(); 85 m_mapXMLNodeToParseContext.RemoveAll();
85 if (m_pAllocator) { 86 if (m_pAllocator) {
86 m_pAllocator->Release(); 87 m_pAllocator->Release();
87 m_pAllocator = NULL; 88 m_pAllocator = NULL;
88 } 89 }
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 IFDE_CSSBoundaryStyle* pBoundarytyle = pParentStyle->GetBoundaryStyles(); 204 IFDE_CSSBoundaryStyle* pBoundarytyle = pParentStyle->GetBoundaryStyles();
204 const FDE_CSSRECT* pRect = pBoundarytyle->GetMarginWidth(); 205 const FDE_CSSRECT* pRect = pBoundarytyle->GetMarginWidth();
205 if (pRect) { 206 if (pRect) {
206 pBoundarytyle = pNewStyle->GetBoundaryStyles(); 207 pBoundarytyle = pNewStyle->GetBoundaryStyles();
207 pBoundarytyle->SetMarginWidth(*pRect); 208 pBoundarytyle->SetMarginWidth(*pRect);
208 } 209 }
209 } 210 }
210 return pNewStyle; 211 return pNewStyle;
211 } 212 }
212 IFDE_CSSComputedStyle* CXFA_TextParser::ComputeStyle( 213 IFDE_CSSComputedStyle* CXFA_TextParser::ComputeStyle(
213 IFDE_XMLNode* pXMLNode, 214 CFDE_XMLNode* pXMLNode,
214 IFDE_CSSComputedStyle* pParentStyle) { 215 IFDE_CSSComputedStyle* pParentStyle) {
215 CXFA_TextParseContext* pContext = static_cast<CXFA_TextParseContext*>( 216 CXFA_TextParseContext* pContext = static_cast<CXFA_TextParseContext*>(
216 m_mapXMLNodeToParseContext.GetValueAt(pXMLNode)); 217 m_mapXMLNodeToParseContext.GetValueAt(pXMLNode));
217 if (!pContext) 218 if (!pContext)
218 return nullptr; 219 return nullptr;
219 pContext->m_pParentStyle = pParentStyle; 220 pContext->m_pParentStyle = pParentStyle;
220 pParentStyle->AddRef(); 221 pParentStyle->AddRef();
221 CXFA_CSSTagProvider tagProvider; 222 CXFA_CSSTagProvider tagProvider;
222 ParseTagInfo(pXMLNode, tagProvider); 223 ParseTagInfo(pXMLNode, tagProvider);
223 if (tagProvider.m_bContent) 224 if (tagProvider.m_bContent)
224 return nullptr; 225 return nullptr;
225 IFDE_CSSComputedStyle* pStyle = CreateStyle(pParentStyle); 226 IFDE_CSSComputedStyle* pStyle = CreateStyle(pParentStyle);
226 IFDE_CSSAccelerator* pCSSAccel = m_pSelector->InitAccelerator(); 227 IFDE_CSSAccelerator* pCSSAccel = m_pSelector->InitAccelerator();
227 pCSSAccel->OnEnterTag(&tagProvider); 228 pCSSAccel->OnEnterTag(&tagProvider);
228 m_pSelector->ComputeStyle(&tagProvider, pContext->GetDecls(), 229 m_pSelector->ComputeStyle(&tagProvider, pContext->GetDecls(),
229 pContext->CountDecls(), pStyle); 230 pContext->CountDecls(), pStyle);
230 pCSSAccel->OnLeaveTag(&tagProvider); 231 pCSSAccel->OnLeaveTag(&tagProvider);
231 return pStyle; 232 return pStyle;
232 } 233 }
233 void CXFA_TextParser::DoParse(IFDE_XMLNode* pXMLContainer, 234 void CXFA_TextParser::DoParse(CFDE_XMLNode* pXMLContainer,
234 IXFA_TextProvider* pTextProvider) { 235 IXFA_TextProvider* pTextProvider) {
235 if (pXMLContainer == NULL || pTextProvider == NULL || m_pAllocator) { 236 if (pXMLContainer == NULL || pTextProvider == NULL || m_pAllocator) {
236 return; 237 return;
237 } 238 }
238 m_pAllocator = 239 m_pAllocator =
239 FX_CreateAllocator(FX_ALLOCTYPE_Fixed, 32, sizeof(CXFA_CSSTagProvider)); 240 FX_CreateAllocator(FX_ALLOCTYPE_Fixed, 32, sizeof(CXFA_CSSTagProvider));
240 InitCSSData(pTextProvider); 241 InitCSSData(pTextProvider);
241 IFDE_CSSComputedStyle* pRootStyle = CreateRootStyle(pTextProvider); 242 IFDE_CSSComputedStyle* pRootStyle = CreateRootStyle(pTextProvider);
242 ParseRichText(pXMLContainer, pRootStyle); 243 ParseRichText(pXMLContainer, pRootStyle);
243 pRootStyle->Release(); 244 pRootStyle->Release();
244 } 245 }
245 void CXFA_TextParser::ParseRichText(IFDE_XMLNode* pXMLNode, 246 void CXFA_TextParser::ParseRichText(CFDE_XMLNode* pXMLNode,
246 IFDE_CSSComputedStyle* pParentStyle) { 247 IFDE_CSSComputedStyle* pParentStyle) {
247 if (pXMLNode == NULL) { 248 if (pXMLNode == NULL) {
248 return; 249 return;
249 } 250 }
250 CXFA_CSSTagProvider tagProvider; 251 CXFA_CSSTagProvider tagProvider;
251 ParseTagInfo(pXMLNode, tagProvider); 252 ParseTagInfo(pXMLNode, tagProvider);
252 if (!tagProvider.m_bTagAviliable) { 253 if (!tagProvider.m_bTagAviliable) {
253 return; 254 return;
254 } 255 }
255 IFDE_CSSComputedStyle* pNewStyle = NULL; 256 IFDE_CSSComputedStyle* pNewStyle = NULL;
(...skipping 15 matching lines...) Expand all
271 pNewStyle); 272 pNewStyle);
272 pCSSAccel->OnLeaveTag(&tagProvider); 273 pCSSAccel->OnLeaveTag(&tagProvider);
273 if (iMatchedDecls > 0) { 274 if (iMatchedDecls > 0) {
274 pTextContext->SetDecls(ppMatchDecls, iMatchedDecls); 275 pTextContext->SetDecls(ppMatchDecls, iMatchedDecls);
275 } 276 }
276 eDisplay = pNewStyle->GetPositionStyles()->GetDisplay(); 277 eDisplay = pNewStyle->GetPositionStyles()->GetDisplay();
277 } 278 }
278 pTextContext->SetDisplay(eDisplay); 279 pTextContext->SetDisplay(eDisplay);
279 m_mapXMLNodeToParseContext.SetAt(pXMLNode, pTextContext); 280 m_mapXMLNodeToParseContext.SetAt(pXMLNode, pTextContext);
280 } 281 }
281 for (IFDE_XMLNode* pXMLChild = 282 for (CFDE_XMLNode* pXMLChild =
282 pXMLNode->GetNodeItem(IFDE_XMLNode::FirstChild); 283 pXMLNode->GetNodeItem(CFDE_XMLNode::FirstChild);
283 pXMLChild; 284 pXMLChild;
284 pXMLChild = pXMLChild->GetNodeItem(IFDE_XMLNode::NextSibling)) { 285 pXMLChild = pXMLChild->GetNodeItem(CFDE_XMLNode::NextSibling)) {
285 ParseRichText(pXMLChild, pNewStyle); 286 ParseRichText(pXMLChild, pNewStyle);
286 } 287 }
287 if (pNewStyle) 288 if (pNewStyle)
288 pNewStyle->Release(); 289 pNewStyle->Release();
289 } 290 }
290 void CXFA_TextParser::ParseTagInfo(IFDE_XMLNode* pXMLNode, 291 void CXFA_TextParser::ParseTagInfo(CFDE_XMLNode* pXMLNode,
291 CXFA_CSSTagProvider& tagProvider) { 292 CXFA_CSSTagProvider& tagProvider) {
292 static const uint32_t s_XFATagName[] = { 293 static const uint32_t s_XFATagName[] = {
293 0x61, 0x62, 0x69, 0x70, 0x0001f714, 294 0x61, 0x62, 0x69, 0x70, 0x0001f714,
294 0x00022a55, 0x000239bb, 0x00025881, 0x0bd37faa, 0x0bd37fb8, 295 0x00022a55, 0x000239bb, 0x00025881, 0x0bd37faa, 0x0bd37fb8,
295 0xa73e3af2, 0xb182eaae, 0xdb8ac455, 296 0xa73e3af2, 0xb182eaae, 0xdb8ac455,
296 }; 297 };
297 CFX_WideString wsName; 298 CFX_WideString wsName;
298 if (pXMLNode->GetType() == FDE_XMLNODE_Element) { 299 if (pXMLNode->GetType() == FDE_XMLNODE_Element) {
299 IFDE_XMLElement* pXMLElement = (IFDE_XMLElement*)pXMLNode; 300 CFDE_XMLElement* pXMLElement = static_cast<CFDE_XMLElement*>(pXMLNode);
300 pXMLElement->GetLocalTagName(wsName); 301 pXMLElement->GetLocalTagName(wsName);
301 tagProvider.SetTagNameObj(wsName); 302 tagProvider.SetTagNameObj(wsName);
302 uint32_t dwHashCode = 303 uint32_t dwHashCode =
303 FX_HashCode_String_GetW(wsName, wsName.GetLength(), TRUE); 304 FX_HashCode_String_GetW(wsName, wsName.GetLength(), TRUE);
304 static const int32_t s_iCount = sizeof(s_XFATagName) / sizeof(uint32_t); 305 static const int32_t s_iCount = sizeof(s_XFATagName) / sizeof(uint32_t);
305 CFX_DSPATemplate<uint32_t> lookup; 306 CFX_DSPATemplate<uint32_t> lookup;
306 tagProvider.m_bTagAviliable = 307 tagProvider.m_bTagAviliable =
307 lookup.Lookup(dwHashCode, s_XFATagName, s_iCount) > -1; 308 lookup.Lookup(dwHashCode, s_XFATagName, s_iCount) > -1;
308 CFX_WideString wsValue; 309 CFX_WideString wsValue;
309 pXMLElement->GetString(FX_WSTRC(L"style").GetPtr(), wsValue); 310 pXMLElement->GetString(FX_WSTRC(L"style").GetPtr(), wsValue);
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 return pStyle->GetFontStyles()->GetFontSize(); 385 return pStyle->GetFontStyles()->GetFontSize();
385 386
386 CXFA_Font font = pTextProvider->GetFontNode(); 387 CXFA_Font font = pTextProvider->GetFontNode();
387 if (font) { 388 if (font) {
388 return font.GetFontSize(); 389 return font.GetFontSize();
389 } 390 }
390 return 10; 391 return 10;
391 } 392 }
392 int32_t CXFA_TextParser::GetHorScale(IXFA_TextProvider* pTextProvider, 393 int32_t CXFA_TextParser::GetHorScale(IXFA_TextProvider* pTextProvider,
393 IFDE_CSSComputedStyle* pStyle, 394 IFDE_CSSComputedStyle* pStyle,
394 IFDE_XMLNode* pXMLNode) const { 395 CFDE_XMLNode* pXMLNode) const {
395 if (pStyle) { 396 if (pStyle) {
396 CFX_WideString wsValue; 397 CFX_WideString wsValue;
397 if (pStyle->GetCustomStyle(FX_WSTRC(L"xfa-font-horizontal-scale"), 398 if (pStyle->GetCustomStyle(FX_WSTRC(L"xfa-font-horizontal-scale"),
398 wsValue)) { 399 wsValue)) {
399 return wsValue.GetInteger(); 400 return wsValue.GetInteger();
400 } 401 }
401 while (pXMLNode) { 402 while (pXMLNode) {
402 CXFA_TextParseContext* pContext = static_cast<CXFA_TextParseContext*>( 403 CXFA_TextParseContext* pContext = static_cast<CXFA_TextParseContext*>(
403 m_mapXMLNodeToParseContext.GetValueAt(pXMLNode)); 404 m_mapXMLNodeToParseContext.GetValueAt(pXMLNode));
404 if (pContext && pContext->m_pParentStyle && 405 if (pContext && pContext->m_pParentStyle &&
405 pContext->m_pParentStyle->GetCustomStyle( 406 pContext->m_pParentStyle->GetCustomStyle(
406 FX_WSTRC(L"xfa-font-horizontal-scale"), wsValue)) { 407 FX_WSTRC(L"xfa-font-horizontal-scale"), wsValue)) {
407 return wsValue.GetInteger(); 408 return wsValue.GetInteger();
408 } 409 }
409 pXMLNode = pXMLNode->GetNodeItem(IFDE_XMLNode::Parent); 410 pXMLNode = pXMLNode->GetNodeItem(CFDE_XMLNode::Parent);
410 } 411 }
411 } 412 }
412 if (CXFA_Font font = pTextProvider->GetFontNode()) { 413 if (CXFA_Font font = pTextProvider->GetFontNode()) {
413 return static_cast<int32_t>(font.GetHorizontalScale()); 414 return static_cast<int32_t>(font.GetHorizontalScale());
414 } 415 }
415 return 100; 416 return 100;
416 } 417 }
417 int32_t CXFA_TextParser::GetVerScale(IXFA_TextProvider* pTextProvider, 418 int32_t CXFA_TextParser::GetVerScale(IXFA_TextProvider* pTextProvider,
418 IFDE_CSSComputedStyle* pStyle) const { 419 IFDE_CSSComputedStyle* pStyle) const {
419 if (pStyle) { 420 if (pStyle) {
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 } else { 509 } else {
509 fLineHeight = std::min(fLineHeight, fFontSize); 510 fLineHeight = std::min(fLineHeight, fFontSize);
510 } 511 }
511 } else if (fLineHeight < 0.1f) { 512 } else if (fLineHeight < 0.1f) {
512 fLineHeight = GetFontSize(pTextProvider, pStyle) * 1.2f; 513 fLineHeight = GetFontSize(pTextProvider, pStyle) * 1.2f;
513 } 514 }
514 fLineHeight *= fVerScale; 515 fLineHeight *= fVerScale;
515 return fLineHeight; 516 return fLineHeight;
516 } 517 }
517 FX_BOOL CXFA_TextParser::GetEmbbedObj(IXFA_TextProvider* pTextProvider, 518 FX_BOOL CXFA_TextParser::GetEmbbedObj(IXFA_TextProvider* pTextProvider,
518 IFDE_XMLNode* pXMLNode, 519 CFDE_XMLNode* pXMLNode,
519 CFX_WideString& wsValue) { 520 CFX_WideString& wsValue) {
520 wsValue.Empty(); 521 wsValue.Empty();
521 if (pXMLNode == NULL) { 522 if (pXMLNode == NULL) {
522 return FALSE; 523 return FALSE;
523 } 524 }
524 FX_BOOL bRet = FALSE; 525 FX_BOOL bRet = FALSE;
525 if (pXMLNode->GetType() == FDE_XMLNODE_Element) { 526 if (pXMLNode->GetType() == FDE_XMLNODE_Element) {
526 IFDE_XMLElement* pElement = (IFDE_XMLElement*)pXMLNode; 527 CFDE_XMLElement* pElement = static_cast<CFDE_XMLElement*>(pXMLNode);
527 CFX_WideString wsAttr; 528 CFX_WideString wsAttr;
528 pElement->GetString(FX_WSTRC(L"xfa:embed").GetPtr(), wsAttr); 529 pElement->GetString(FX_WSTRC(L"xfa:embed").GetPtr(), wsAttr);
529 if (wsAttr.IsEmpty()) { 530 if (wsAttr.IsEmpty()) {
530 return FALSE; 531 return FALSE;
531 } 532 }
532 if (wsAttr.GetAt(0) == L'#') { 533 if (wsAttr.GetAt(0) == L'#') {
533 wsAttr.Delete(0); 534 wsAttr.Delete(0);
534 } 535 }
535 CFX_WideString ws; 536 CFX_WideString ws;
536 pElement->GetString(FX_WSTRC(L"xfa:embedType").GetPtr(), ws); 537 pElement->GetString(FX_WSTRC(L"xfa:embedType").GetPtr(), ws);
(...skipping 15 matching lines...) Expand all
552 } 553 }
553 FX_BOOL bRaw = (ws == FX_WSTRC(L"raw")); 554 FX_BOOL bRaw = (ws == FX_WSTRC(L"raw"));
554 if (!bRaw && ws != FX_WSTRC(L"formatted")) { 555 if (!bRaw && ws != FX_WSTRC(L"formatted")) {
555 return FALSE; 556 return FALSE;
556 } 557 }
557 bRet = pTextProvider->GetEmbbedObj(bURI, bRaw, wsAttr, wsValue); 558 bRet = pTextProvider->GetEmbbedObj(bURI, bRaw, wsAttr, wsValue);
558 } 559 }
559 return bRet; 560 return bRet;
560 } 561 }
561 CXFA_TextParseContext* CXFA_TextParser::GetParseContextFromMap( 562 CXFA_TextParseContext* CXFA_TextParser::GetParseContextFromMap(
562 IFDE_XMLNode* pXMLNode) { 563 CFDE_XMLNode* pXMLNode) {
563 return (CXFA_TextParseContext*)m_mapXMLNodeToParseContext.GetValueAt( 564 return (CXFA_TextParseContext*)m_mapXMLNodeToParseContext.GetValueAt(
564 pXMLNode); 565 pXMLNode);
565 } 566 }
566 enum XFA_TABSTOPSSTATUS { 567 enum XFA_TABSTOPSSTATUS {
567 XFA_TABSTOPSSTATUS_Error, 568 XFA_TABSTOPSSTATUS_Error,
568 XFA_TABSTOPSSTATUS_EOS, 569 XFA_TABSTOPSSTATUS_EOS,
569 XFA_TABSTOPSSTATUS_None, 570 XFA_TABSTOPSSTATUS_None,
570 XFA_TABSTOPSSTATUS_Alignment, 571 XFA_TABSTOPSSTATUS_Alignment,
571 XFA_TABSTOPSSTATUS_StartLeader, 572 XFA_TABSTOPSSTATUS_StartLeader,
572 XFA_TABSTOPSSTATUS_Leader, 573 XFA_TABSTOPSSTATUS_Leader,
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
705 void CXFA_TextLayout::GetTextDataNode() { 706 void CXFA_TextLayout::GetTextDataNode() {
706 if (m_pTextProvider == NULL) { 707 if (m_pTextProvider == NULL) {
707 return; 708 return;
708 } 709 }
709 CXFA_Node* pNode = m_pTextProvider->GetTextNode(m_bRichText); 710 CXFA_Node* pNode = m_pTextProvider->GetTextNode(m_bRichText);
710 if (pNode && m_bRichText) { 711 if (pNode && m_bRichText) {
711 m_textParser.Reset(); 712 m_textParser.Reset();
712 } 713 }
713 m_pTextDataNode = pNode; 714 m_pTextDataNode = pNode;
714 } 715 }
715 IFDE_XMLNode* CXFA_TextLayout::GetXMLContainerNode() { 716 CFDE_XMLNode* CXFA_TextLayout::GetXMLContainerNode() {
716 IFDE_XMLNode* pXMLContainer = NULL; 717 CFDE_XMLNode* pXMLContainer = NULL;
717 if (m_bRichText) { 718 if (m_bRichText) {
718 IFDE_XMLNode* pXMLRoot = m_pTextDataNode->GetXMLMappingNode(); 719 CFDE_XMLNode* pXMLRoot = m_pTextDataNode->GetXMLMappingNode();
719 if (!pXMLRoot) { 720 if (!pXMLRoot) {
720 return pXMLContainer; 721 return pXMLContainer;
721 } 722 }
722 for (IFDE_XMLNode* pXMLChild = 723 for (CFDE_XMLNode* pXMLChild =
723 pXMLRoot->GetNodeItem(IFDE_XMLNode::FirstChild); 724 pXMLRoot->GetNodeItem(CFDE_XMLNode::FirstChild);
724 pXMLChild; 725 pXMLChild;
725 pXMLChild = pXMLChild->GetNodeItem(IFDE_XMLNode::NextSibling)) { 726 pXMLChild = pXMLChild->GetNodeItem(CFDE_XMLNode::NextSibling)) {
726 if (pXMLChild->GetType() == FDE_XMLNODE_Element) { 727 if (pXMLChild->GetType() == FDE_XMLNODE_Element) {
727 IFDE_XMLElement* pXMLElement = (IFDE_XMLElement*)pXMLChild; 728 CFDE_XMLElement* pXMLElement = static_cast<CFDE_XMLElement*>(pXMLChild);
728 CFX_WideString wsTag; 729 CFX_WideString wsTag;
729 pXMLElement->GetLocalTagName(wsTag); 730 pXMLElement->GetLocalTagName(wsTag);
730 if (wsTag.Equal(FX_WSTRC(L"body")) || wsTag.Equal(FX_WSTRC(L"html"))) { 731 if (wsTag.Equal(FX_WSTRC(L"body")) || wsTag.Equal(FX_WSTRC(L"html"))) {
731 pXMLContainer = pXMLChild; 732 pXMLContainer = pXMLChild;
732 break; 733 break;
733 } 734 }
734 } 735 }
735 } 736 }
736 } 737 }
737 return pXMLContainer; 738 return pXMLContainer;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
796 m_pBreak->SetCharSpace(font.GetLetterSpacing()); 797 m_pBreak->SetCharSpace(font.GetLetterSpacing());
797 } 798 }
798 FX_FLOAT fFontSize = m_textParser.GetFontSize(m_pTextProvider, NULL); 799 FX_FLOAT fFontSize = m_textParser.GetFontSize(m_pTextProvider, NULL);
799 m_pBreak->SetFontSize(fFontSize); 800 m_pBreak->SetFontSize(fFontSize);
800 m_pBreak->SetFont(m_textParser.GetFont(m_pTextProvider, NULL)); 801 m_pBreak->SetFont(m_textParser.GetFont(m_pTextProvider, NULL));
801 m_pBreak->SetLineBreakTolerance(fFontSize * 0.2f); 802 m_pBreak->SetLineBreakTolerance(fFontSize * 0.2f);
802 } 803 }
803 void CXFA_TextLayout::InitBreak(IFDE_CSSComputedStyle* pStyle, 804 void CXFA_TextLayout::InitBreak(IFDE_CSSComputedStyle* pStyle,
804 FDE_CSSDISPLAY eDisplay, 805 FDE_CSSDISPLAY eDisplay,
805 FX_FLOAT fLineWidth, 806 FX_FLOAT fLineWidth,
806 IFDE_XMLNode* pXMLNode, 807 CFDE_XMLNode* pXMLNode,
807 IFDE_CSSComputedStyle* pParentStyle) { 808 IFDE_CSSComputedStyle* pParentStyle) {
808 if (pStyle == NULL) { 809 if (pStyle == NULL) {
809 InitBreak(fLineWidth); 810 InitBreak(fLineWidth);
810 return; 811 return;
811 } 812 }
812 IFDE_CSSParagraphStyle* pParaStyle = pStyle->GetParagraphStyles(); 813 IFDE_CSSParagraphStyle* pParaStyle = pStyle->GetParagraphStyles();
813 if (eDisplay == FDE_CSSDISPLAY_Block || eDisplay == FDE_CSSDISPLAY_ListItem) { 814 if (eDisplay == FDE_CSSDISPLAY_Block || eDisplay == FDE_CSSDISPLAY_ListItem) {
814 int32_t iAlign = FX_RTFLINEALIGNMENT_Left; 815 int32_t iAlign = FX_RTFLINEALIGNMENT_Left;
815 switch (pParaStyle->GetTextAlign()) { 816 switch (pParaStyle->GetTextAlign()) {
816 case FDE_CSSTEXTALIGN_Right: 817 case FDE_CSSTEXTALIGN_Right:
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
1106 if (iCount == 0 && m_pLoader->m_fStartLineOffset < 0.1f) { 1107 if (iCount == 0 && m_pLoader->m_fStartLineOffset < 0.1f) {
1107 UpdateAlign(szText.y, fLinePos); 1108 UpdateAlign(szText.y, fLinePos);
1108 } 1109 }
1109 } else if (m_pTextDataNode) { 1110 } else if (m_pTextDataNode) {
1110 iBlock *= 2; 1111 iBlock *= 2;
1111 if (iBlock < iCount - 2) { 1112 if (iBlock < iCount - 2) {
1112 m_pLoader->m_iTotalLines = m_Blocks.ElementAt(iBlock + 1); 1113 m_pLoader->m_iTotalLines = m_Blocks.ElementAt(iBlock + 1);
1113 } 1114 }
1114 m_pBreak->Reset(); 1115 m_pBreak->Reset();
1115 if (m_bRichText) { 1116 if (m_bRichText) {
1116 IFDE_XMLNode* pContainerNode = GetXMLContainerNode(); 1117 CFDE_XMLNode* pContainerNode = GetXMLContainerNode();
1117 if (!pContainerNode) { 1118 if (!pContainerNode) {
1118 return TRUE; 1119 return TRUE;
1119 } 1120 }
1120 IFDE_XMLNode* pXMLNode = m_pLoader->m_pXMLNode; 1121 CFDE_XMLNode* pXMLNode = m_pLoader->m_pXMLNode;
1121 if (pXMLNode == NULL) { 1122 if (pXMLNode == NULL) {
1122 return TRUE; 1123 return TRUE;
1123 } 1124 }
1124 IFDE_XMLNode* pSaveXMLNode = m_pLoader->m_pXMLNode; 1125 CFDE_XMLNode* pSaveXMLNode = m_pLoader->m_pXMLNode;
1125 for (; pXMLNode; 1126 for (; pXMLNode;
1126 pXMLNode = pXMLNode->GetNodeItem(IFDE_XMLNode::NextSibling)) { 1127 pXMLNode = pXMLNode->GetNodeItem(CFDE_XMLNode::NextSibling)) {
1127 FX_BOOL bFlag = LoadRichText(pXMLNode, szText, fLinePos, 1128 FX_BOOL bFlag = LoadRichText(pXMLNode, szText, fLinePos,
1128 m_pLoader->m_pParentStyle, TRUE); 1129 m_pLoader->m_pParentStyle, TRUE);
1129 if (!bFlag) { 1130 if (!bFlag) {
1130 break; 1131 break;
1131 } 1132 }
1132 } 1133 }
1133 while (pXMLNode == NULL) { 1134 while (pXMLNode == NULL) {
1134 pXMLNode = pSaveXMLNode->GetNodeItem(IFDE_XMLNode::Parent); 1135 pXMLNode = pSaveXMLNode->GetNodeItem(CFDE_XMLNode::Parent);
1135 if (pXMLNode == pContainerNode) { 1136 if (pXMLNode == pContainerNode) {
1136 break; 1137 break;
1137 } 1138 }
1138 FX_BOOL bFlag = 1139 FX_BOOL bFlag =
1139 LoadRichText(pXMLNode, szText, fLinePos, m_pLoader->m_pParentStyle, 1140 LoadRichText(pXMLNode, szText, fLinePos, m_pLoader->m_pParentStyle,
1140 TRUE, NULL, FALSE); 1141 TRUE, NULL, FALSE);
1141 if (!bFlag) { 1142 if (!bFlag) {
1142 break; 1143 break;
1143 } 1144 }
1144 pSaveXMLNode = pXMLNode; 1145 pSaveXMLNode = pXMLNode;
1145 pXMLNode = pXMLNode->GetNodeItem(IFDE_XMLNode::NextSibling); 1146 pXMLNode = pXMLNode->GetNodeItem(CFDE_XMLNode::NextSibling);
1146 if (!pXMLNode) { 1147 if (!pXMLNode) {
1147 continue; 1148 continue;
1148 } 1149 }
1149 for (; pXMLNode; 1150 for (; pXMLNode;
1150 pXMLNode = pXMLNode->GetNodeItem(IFDE_XMLNode::NextSibling)) { 1151 pXMLNode = pXMLNode->GetNodeItem(CFDE_XMLNode::NextSibling)) {
1151 FX_BOOL bFlag = LoadRichText(pXMLNode, szText, fLinePos, 1152 FX_BOOL bFlag = LoadRichText(pXMLNode, szText, fLinePos,
1152 m_pLoader->m_pParentStyle, TRUE); 1153 m_pLoader->m_pParentStyle, TRUE);
1153 if (!bFlag) { 1154 if (!bFlag) {
1154 break; 1155 break;
1155 } 1156 }
1156 } 1157 }
1157 } 1158 }
1158 } else { 1159 } else {
1159 pNode = m_pLoader->m_pNode; 1160 pNode = m_pLoader->m_pNode;
1160 if (pNode == NULL) { 1161 if (pNode == NULL) {
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
1306 FX_FLOAT& fLinePos, 1307 FX_FLOAT& fLinePos,
1307 FX_BOOL bSavePieces) { 1308 FX_BOOL bSavePieces) {
1308 if (m_pAllocator == NULL) { 1309 if (m_pAllocator == NULL) {
1309 m_pAllocator = FX_CreateAllocator(FX_ALLOCTYPE_Static, 256, 0); 1310 m_pAllocator = FX_CreateAllocator(FX_ALLOCTYPE_Static, 256, 0);
1310 } 1311 }
1311 GetTextDataNode(); 1312 GetTextDataNode();
1312 if (m_pTextDataNode == NULL) { 1313 if (m_pTextDataNode == NULL) {
1313 return TRUE; 1314 return TRUE;
1314 } 1315 }
1315 if (m_bRichText) { 1316 if (m_bRichText) {
1316 IFDE_XMLNode* pXMLContainer = GetXMLContainerNode(); 1317 CFDE_XMLNode* pXMLContainer = GetXMLContainerNode();
1317 if (pXMLContainer) { 1318 if (pXMLContainer) {
1318 if (!m_textParser.IsParsed()) { 1319 if (!m_textParser.IsParsed()) {
1319 m_textParser.DoParse(pXMLContainer, m_pTextProvider); 1320 m_textParser.DoParse(pXMLContainer, m_pTextProvider);
1320 } 1321 }
1321 IFDE_CSSComputedStyle* pRootStyle = 1322 IFDE_CSSComputedStyle* pRootStyle =
1322 m_textParser.CreateRootStyle(m_pTextProvider); 1323 m_textParser.CreateRootStyle(m_pTextProvider);
1323 LoadRichText(pXMLContainer, szText, fLinePos, pRootStyle, bSavePieces); 1324 LoadRichText(pXMLContainer, szText, fLinePos, pRootStyle, bSavePieces);
1324 pRootStyle->Release(); 1325 pRootStyle->Release();
1325 } 1326 }
1326 } else { 1327 } else {
(...skipping 25 matching lines...) Expand all
1352 } 1353 }
1353 CFX_WideString wsText = pNode->GetContent(); 1354 CFX_WideString wsText = pNode->GetContent();
1354 wsText.TrimRight(L" "); 1355 wsText.TrimRight(L" ");
1355 FX_BOOL bRet = AppendChar(wsText, fLinePos, fSpaceAbove, bSavePieces); 1356 FX_BOOL bRet = AppendChar(wsText, fLinePos, fSpaceAbove, bSavePieces);
1356 if (bRet && m_pLoader) { 1357 if (bRet && m_pLoader) {
1357 m_pLoader->m_pNode = pNode; 1358 m_pLoader->m_pNode = pNode;
1358 } else { 1359 } else {
1359 EndBreak(FX_RTFBREAK_ParagraphBreak, fLinePos, bSavePieces); 1360 EndBreak(FX_RTFBREAK_ParagraphBreak, fLinePos, bSavePieces);
1360 } 1361 }
1361 } 1362 }
1362 FX_BOOL CXFA_TextLayout::LoadRichText(IFDE_XMLNode* pXMLNode, 1363 FX_BOOL CXFA_TextLayout::LoadRichText(CFDE_XMLNode* pXMLNode,
1363 const CFX_SizeF& szText, 1364 const CFX_SizeF& szText,
1364 FX_FLOAT& fLinePos, 1365 FX_FLOAT& fLinePos,
1365 IFDE_CSSComputedStyle* pParentStyle, 1366 IFDE_CSSComputedStyle* pParentStyle,
1366 FX_BOOL bSavePieces, 1367 FX_BOOL bSavePieces,
1367 CXFA_LinkUserData* pLinkData, 1368 CXFA_LinkUserData* pLinkData,
1368 FX_BOOL bEndBreak, 1369 FX_BOOL bEndBreak,
1369 FX_BOOL bIsOl, 1370 FX_BOOL bIsOl,
1370 int32_t iLiCount) { 1371 int32_t iLiCount) {
1371 if (pXMLNode == NULL) { 1372 if (pXMLNode == NULL) {
1372 return FALSE; 1373 return FALSE;
1373 } 1374 }
1374 CXFA_TextParseContext* pContext = 1375 CXFA_TextParseContext* pContext =
1375 m_textParser.GetParseContextFromMap(pXMLNode); 1376 m_textParser.GetParseContextFromMap(pXMLNode);
1376 FDE_CSSDISPLAY eDisplay = FDE_CSSDISPLAY_None; 1377 FDE_CSSDISPLAY eDisplay = FDE_CSSDISPLAY_None;
1377 FX_BOOL bContentNode = FALSE; 1378 FX_BOOL bContentNode = FALSE;
1378 FX_FLOAT fSpaceBelow = 0; 1379 FX_FLOAT fSpaceBelow = 0;
1379 IFDE_CSSComputedStyle* pStyle = NULL; 1380 IFDE_CSSComputedStyle* pStyle = NULL;
1380 CFX_WideString wsName; 1381 CFX_WideString wsName;
1381 if (bEndBreak) { 1382 if (bEndBreak) {
1382 FX_BOOL bCurOl = FALSE; 1383 FX_BOOL bCurOl = FALSE;
1383 FX_BOOL bCurLi = FALSE; 1384 FX_BOOL bCurLi = FALSE;
1384 IFDE_XMLElement* pElement = NULL; 1385 CFDE_XMLElement* pElement = NULL;
1385 if (pContext) { 1386 if (pContext) {
1386 if (m_bBlockContinue || 1387 if (m_bBlockContinue ||
1387 (m_pLoader && pXMLNode == m_pLoader->m_pXMLNode)) { 1388 (m_pLoader && pXMLNode == m_pLoader->m_pXMLNode)) {
1388 m_bBlockContinue = TRUE; 1389 m_bBlockContinue = TRUE;
1389 } 1390 }
1390 if (pXMLNode->GetType() == FDE_XMLNODE_Text) { 1391 if (pXMLNode->GetType() == FDE_XMLNODE_Text) {
1391 bContentNode = TRUE; 1392 bContentNode = TRUE;
1392 } else if (pXMLNode->GetType() == FDE_XMLNODE_Element) { 1393 } else if (pXMLNode->GetType() == FDE_XMLNODE_Element) {
1393 pElement = (IFDE_XMLElement*)pXMLNode; 1394 pElement = static_cast<CFDE_XMLElement*>(pXMLNode);
1394 pElement->GetLocalTagName(wsName); 1395 pElement->GetLocalTagName(wsName);
1395 } 1396 }
1396 if (wsName == FX_WSTRC(L"ol")) { 1397 if (wsName == FX_WSTRC(L"ol")) {
1397 bIsOl = TRUE; 1398 bIsOl = TRUE;
1398 bCurOl = TRUE; 1399 bCurOl = TRUE;
1399 } 1400 }
1400 if (m_bBlockContinue || bContentNode == FALSE) { 1401 if (m_bBlockContinue || bContentNode == FALSE) {
1401 eDisplay = pContext->GetDisplay(); 1402 eDisplay = pContext->GetDisplay();
1402 if (eDisplay != FDE_CSSDISPLAY_Block && 1403 if (eDisplay != FDE_CSSDISPLAY_Block &&
1403 eDisplay != FDE_CSSDISPLAY_Inline && 1404 eDisplay != FDE_CSSDISPLAY_Inline &&
(...skipping 26 matching lines...) Expand all
1430 wsLinkContent.GetBuffer(wsLinkContent.GetLength())); 1431 wsLinkContent.GetBuffer(wsLinkContent.GetLength()));
1431 wsLinkContent.ReleaseBuffer(wsLinkContent.GetLength()); 1432 wsLinkContent.ReleaseBuffer(wsLinkContent.GetLength());
1432 } 1433 }
1433 } 1434 }
1434 int32_t iTabCount = 1435 int32_t iTabCount =
1435 m_textParser.CountTabs(bContentNode ? pParentStyle : pStyle); 1436 m_textParser.CountTabs(bContentNode ? pParentStyle : pStyle);
1436 FX_BOOL bSpaceRun = 1437 FX_BOOL bSpaceRun =
1437 m_textParser.IsSpaceRun(bContentNode ? pParentStyle : pStyle); 1438 m_textParser.IsSpaceRun(bContentNode ? pParentStyle : pStyle);
1438 CFX_WideString wsText; 1439 CFX_WideString wsText;
1439 if (bContentNode && iTabCount == 0) { 1440 if (bContentNode && iTabCount == 0) {
1440 ((IFDE_XMLText*)pXMLNode)->GetText(wsText); 1441 static_cast<CFDE_XMLText*>(pXMLNode)->GetText(wsText);
1441 } else if (wsName == FX_WSTRC(L"br")) { 1442 } else if (wsName == FX_WSTRC(L"br")) {
1442 wsText = L'\n'; 1443 wsText = L'\n';
1443 } else if (wsName == FX_WSTRC(L"li")) { 1444 } else if (wsName == FX_WSTRC(L"li")) {
1444 bCurLi = TRUE; 1445 bCurLi = TRUE;
1445 if (bIsOl) { 1446 if (bIsOl) {
1446 wsText.Format(L"%d. ", iLiCount); 1447 wsText.Format(L"%d. ", iLiCount);
1447 } else { 1448 } else {
1448 wsText = 0x00B7 + FX_WSTRC(L" "); 1449 wsText = 0x00B7 + FX_WSTRC(L" ");
1449 } 1450 }
1450 } else if (!bContentNode) { 1451 } else if (!bContentNode) {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1499 if (pStyle) 1500 if (pStyle)
1500 pStyle->Release(); 1501 pStyle->Release();
1501 return FALSE; 1502 return FALSE;
1502 } 1503 }
1503 return TRUE; 1504 return TRUE;
1504 } 1505 }
1505 } 1506 }
1506 } 1507 }
1507 } 1508 }
1508 FX_BOOL ret = TRUE; 1509 FX_BOOL ret = TRUE;
1509 for (IFDE_XMLNode* pChildNode = 1510 for (CFDE_XMLNode* pChildNode =
1510 pXMLNode->GetNodeItem(IFDE_XMLNode::FirstChild); 1511 pXMLNode->GetNodeItem(CFDE_XMLNode::FirstChild);
1511 pChildNode; 1512 pChildNode;
1512 pChildNode = pChildNode->GetNodeItem(IFDE_XMLNode::NextSibling)) { 1513 pChildNode = pChildNode->GetNodeItem(CFDE_XMLNode::NextSibling)) {
1513 if (bCurOl) { 1514 if (bCurOl) {
1514 iLiCount++; 1515 iLiCount++;
1515 } 1516 }
1516 ret = LoadRichText(pChildNode, szText, fLinePos, 1517 ret = LoadRichText(pChildNode, szText, fLinePos,
1517 pContext ? pStyle : pParentStyle, bSavePieces, 1518 pContext ? pStyle : pParentStyle, bSavePieces,
1518 pLinkData, TRUE, bIsOl, iLiCount); 1519 pLinkData, TRUE, bIsOl, iLiCount);
1519 if (ret == FALSE) { 1520 if (ret == FALSE) {
1520 return FALSE; 1521 return FALSE;
1521 } 1522 }
1522 } 1523 }
(...skipping 27 matching lines...) Expand all
1550 pLinkData->Release(); 1551 pLinkData->Release();
1551 pLinkData = nullptr; 1552 pLinkData = nullptr;
1552 } 1553 }
1553 } 1554 }
1554 if (IsEnd(bSavePieces)) { 1555 if (IsEnd(bSavePieces)) {
1555 if (pStyle) { 1556 if (pStyle) {
1556 pStyle->Release(); 1557 pStyle->Release();
1557 } 1558 }
1558 if (m_pLoader && m_pLoader->m_iTotalLines > -1) { 1559 if (m_pLoader && m_pLoader->m_iTotalLines > -1) {
1559 m_pLoader->m_pXMLNode = 1560 m_pLoader->m_pXMLNode =
1560 pXMLNode->GetNodeItem(IFDE_XMLNode::NextSibling); 1561 pXMLNode->GetNodeItem(CFDE_XMLNode::NextSibling);
1561 m_pLoader->m_pParentStyle = pParentStyle; 1562 m_pLoader->m_pParentStyle = pParentStyle;
1562 } 1563 }
1563 return FALSE; 1564 return FALSE;
1564 } 1565 }
1565 } 1566 }
1566 } 1567 }
1567 if (pStyle) 1568 if (pStyle)
1568 pStyle->Release(); 1569 pStyle->Release();
1569 return TRUE; 1570 return TRUE;
1570 } 1571 }
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
1992 tr.iLength = iLength; 1993 tr.iLength = iLength;
1993 tr.fFontSize = pPiece->fFontSize; 1994 tr.fFontSize = pPiece->fFontSize;
1994 tr.iBidiLevel = pPiece->iBidiLevel; 1995 tr.iBidiLevel = pPiece->iBidiLevel;
1995 tr.iCharRotation = 0; 1996 tr.iCharRotation = 0;
1996 tr.wLineBreakChar = L'\n'; 1997 tr.wLineBreakChar = L'\n';
1997 tr.iVerticalScale = pPiece->iVerScale; 1998 tr.iVerticalScale = pPiece->iVerScale;
1998 tr.dwLayoutStyles = FX_RTFLAYOUTSTYLE_ExpandTab; 1999 tr.dwLayoutStyles = FX_RTFLAYOUTSTYLE_ExpandTab;
1999 tr.iHorizontalScale = pPiece->iHorScale; 2000 tr.iHorizontalScale = pPiece->iHorScale;
2000 return TRUE; 2001 return TRUE;
2001 } 2002 }
OLDNEW
« no previous file with comments | « xfa/fxfa/app/xfa_textlayout.h ('k') | xfa/fxfa/parser/xfa_document_datamerger_imp.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698