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

Side by Side Diff: xfa/fxfa/parser/xfa_parser_imp.cpp

Issue 2095653002: Remove NULL in xfa/ (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Rebase to master Created 4 years, 6 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/parser/xfa_parser_imp.h ('k') | xfa/fxfa/parser/xfa_script.h » ('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/parser/xfa_parser_imp.h" 7 #include "xfa/fxfa/parser/xfa_parser_imp.h"
8 8
9 #include <memory> 9 #include <memory>
10 10
(...skipping 29 matching lines...) Expand all
40 void CXFA_SimpleParser::Release() { 40 void CXFA_SimpleParser::Release() {
41 delete this; 41 delete this;
42 } 42 }
43 void CXFA_SimpleParser::SetFactory(CXFA_Document* pFactory) { 43 void CXFA_SimpleParser::SetFactory(CXFA_Document* pFactory) {
44 m_pFactory = pFactory; 44 m_pFactory = pFactory;
45 } 45 }
46 static CFDE_XMLNode* XFA_FDEExtension_GetDocumentNode( 46 static CFDE_XMLNode* XFA_FDEExtension_GetDocumentNode(
47 CFDE_XMLDoc* pXMLDoc, 47 CFDE_XMLDoc* pXMLDoc,
48 FX_BOOL bVerifyWellFormness = FALSE) { 48 FX_BOOL bVerifyWellFormness = FALSE) {
49 if (!pXMLDoc) { 49 if (!pXMLDoc) {
50 return NULL; 50 return nullptr;
51 } 51 }
52 CFDE_XMLNode* pXMLFakeRoot = pXMLDoc->GetRoot(); 52 CFDE_XMLNode* pXMLFakeRoot = pXMLDoc->GetRoot();
53 for (CFDE_XMLNode* pXMLNode = 53 for (CFDE_XMLNode* pXMLNode =
54 pXMLFakeRoot->GetNodeItem(CFDE_XMLNode::FirstChild); 54 pXMLFakeRoot->GetNodeItem(CFDE_XMLNode::FirstChild);
55 pXMLNode; pXMLNode = pXMLNode->GetNodeItem(CFDE_XMLNode::NextSibling)) { 55 pXMLNode; pXMLNode = pXMLNode->GetNodeItem(CFDE_XMLNode::NextSibling)) {
56 if (pXMLNode->GetType() == FDE_XMLNODE_Element) { 56 if (pXMLNode->GetType() == FDE_XMLNODE_Element) {
57 if (bVerifyWellFormness) { 57 if (bVerifyWellFormness) {
58 for (CFDE_XMLNode* pNextNode = 58 for (CFDE_XMLNode* pNextNode =
59 pXMLNode->GetNodeItem(CFDE_XMLNode::NextSibling); 59 pXMLNode->GetNodeItem(CFDE_XMLNode::NextSibling);
60 pNextNode; 60 pNextNode;
61 pNextNode = pNextNode->GetNodeItem(CFDE_XMLNode::NextSibling)) { 61 pNextNode = pNextNode->GetNodeItem(CFDE_XMLNode::NextSibling)) {
62 if (pNextNode->GetType() == FDE_XMLNODE_Element) { 62 if (pNextNode->GetType() == FDE_XMLNODE_Element) {
63 return FALSE; 63 return FALSE;
64 } 64 }
65 } 65 }
66 } 66 }
67 return pXMLNode; 67 return pXMLNode;
68 } 68 }
69 } 69 }
70 return NULL; 70 return nullptr;
71 } 71 }
72 int32_t CXFA_SimpleParser::StartParse(IFX_FileRead* pStream, 72 int32_t CXFA_SimpleParser::StartParse(IFX_FileRead* pStream,
73 XFA_XDPPACKET ePacketID) { 73 XFA_XDPPACKET ePacketID) {
74 CloseParser(); 74 CloseParser();
75 m_pFileRead = pStream; 75 m_pFileRead = pStream;
76 m_pStream = IFX_Stream::CreateStream( 76 m_pStream = IFX_Stream::CreateStream(
77 pStream, FX_STREAMACCESS_Read | FX_STREAMACCESS_Text); 77 pStream, FX_STREAMACCESS_Read | FX_STREAMACCESS_Text);
78 if (m_pStream == NULL) { 78 if (!m_pStream) {
79 return XFA_PARSESTATUS_StreamErr; 79 return XFA_PARSESTATUS_StreamErr;
80 } 80 }
81 uint16_t wCodePage = m_pStream->GetCodePage(); 81 uint16_t wCodePage = m_pStream->GetCodePage();
82 if (wCodePage != FX_CODEPAGE_UTF16LE && wCodePage != FX_CODEPAGE_UTF16BE && 82 if (wCodePage != FX_CODEPAGE_UTF16LE && wCodePage != FX_CODEPAGE_UTF16BE &&
83 wCodePage != FX_CODEPAGE_UTF8) { 83 wCodePage != FX_CODEPAGE_UTF8) {
84 m_pStream->SetCodePage(FX_CODEPAGE_UTF8); 84 m_pStream->SetCodePage(FX_CODEPAGE_UTF8);
85 } 85 }
86 m_pXMLDoc = new CFDE_XMLDoc; 86 m_pXMLDoc = new CFDE_XMLDoc;
87 m_pXMLParser = new CXFA_XMLParser(m_pXMLDoc->GetRoot(), m_pStream); 87 m_pXMLParser = new CXFA_XMLParser(m_pXMLDoc->GetRoot(), m_pStream);
88 if (!m_pXMLDoc->LoadXML(m_pXMLParser)) { 88 if (!m_pXMLDoc->LoadXML(m_pXMLParser)) {
89 return XFA_PARSESTATUS_StatusErr; 89 return XFA_PARSESTATUS_StatusErr;
90 } 90 }
91 m_ePacketID = ePacketID; 91 m_ePacketID = ePacketID;
92 return XFA_PARSESTATUS_Ready; 92 return XFA_PARSESTATUS_Ready;
93 } 93 }
94 int32_t CXFA_SimpleParser::DoParse(IFX_Pause* pPause) { 94 int32_t CXFA_SimpleParser::DoParse(IFX_Pause* pPause) {
95 if (m_pXMLDoc == NULL || m_ePacketID == XFA_XDPPACKET_UNKNOWN) { 95 if (!m_pXMLDoc || m_ePacketID == XFA_XDPPACKET_UNKNOWN) {
96 return XFA_PARSESTATUS_StatusErr; 96 return XFA_PARSESTATUS_StatusErr;
97 } 97 }
98 int32_t iRet = m_pXMLDoc->DoLoad(pPause); 98 int32_t iRet = m_pXMLDoc->DoLoad(pPause);
99 if (iRet < 0) { 99 if (iRet < 0) {
100 return XFA_PARSESTATUS_SyntaxErr; 100 return XFA_PARSESTATUS_SyntaxErr;
101 } 101 }
102 if (iRet < 100) { 102 if (iRet < 100) {
103 return iRet / 2; 103 return iRet / 2;
104 } 104 }
105 m_pRootNode = ParseAsXDPPacket(XFA_FDEExtension_GetDocumentNode(m_pXMLDoc), 105 m_pRootNode = ParseAsXDPPacket(XFA_FDEExtension_GetDocumentNode(m_pXMLDoc),
106 m_ePacketID); 106 m_ePacketID);
107 m_pXMLDoc->CloseXML(); 107 m_pXMLDoc->CloseXML();
108 if (m_pStream) { 108 if (m_pStream) {
109 m_pStream->Release(); 109 m_pStream->Release();
110 m_pStream = NULL; 110 m_pStream = nullptr;
111 } 111 }
112 if (!m_pRootNode) { 112 if (!m_pRootNode) {
113 return XFA_PARSESTATUS_StatusErr; 113 return XFA_PARSESTATUS_StatusErr;
114 } 114 }
115 return XFA_PARSESTATUS_Done; 115 return XFA_PARSESTATUS_Done;
116 } 116 }
117 int32_t CXFA_SimpleParser::ParseXMLData(const CFX_WideString& wsXML, 117 int32_t CXFA_SimpleParser::ParseXMLData(const CFX_WideString& wsXML,
118 CFDE_XMLNode*& pXMLNode, 118 CFDE_XMLNode*& pXMLNode,
119 IFX_Pause* pPause) { 119 IFX_Pause* pPause) {
120 CloseParser(); 120 CloseParser();
121 pXMLNode = NULL; 121 pXMLNode = nullptr;
122 IFX_Stream* pStream = XFA_CreateWideTextRead(wsXML); 122 IFX_Stream* pStream = XFA_CreateWideTextRead(wsXML);
123 if (!pStream) { 123 if (!pStream) {
124 return XFA_PARSESTATUS_StreamErr; 124 return XFA_PARSESTATUS_StreamErr;
125 } 125 }
126 m_pStream = pStream; 126 m_pStream = pStream;
127 m_pXMLDoc = new CFDE_XMLDoc; 127 m_pXMLDoc = new CFDE_XMLDoc;
128 CXFA_XMLParser* pParser = new CXFA_XMLParser(m_pXMLDoc->GetRoot(), m_pStream); 128 CXFA_XMLParser* pParser = new CXFA_XMLParser(m_pXMLDoc->GetRoot(), m_pStream);
129 pParser->m_dwCheckStatus = 0x03; 129 pParser->m_dwCheckStatus = 0x03;
130 if (!m_pXMLDoc->LoadXML(pParser)) { 130 if (!m_pXMLDoc->LoadXML(pParser)) {
131 return XFA_PARSESTATUS_StatusErr; 131 return XFA_PARSESTATUS_StatusErr;
132 } 132 }
133 int32_t iRet = m_pXMLDoc->DoLoad(pPause); 133 int32_t iRet = m_pXMLDoc->DoLoad(pPause);
134 if (iRet < 0 || iRet >= 100) { 134 if (iRet < 0 || iRet >= 100) {
135 m_pXMLDoc->CloseXML(); 135 m_pXMLDoc->CloseXML();
136 } 136 }
137 if (iRet < 0) { 137 if (iRet < 0) {
138 return XFA_PARSESTATUS_SyntaxErr; 138 return XFA_PARSESTATUS_SyntaxErr;
139 } 139 }
140 if (iRet < 100) { 140 if (iRet < 100) {
141 return iRet / 2; 141 return iRet / 2;
142 } 142 }
143 if (m_pStream) { 143 if (m_pStream) {
144 m_pStream->Release(); 144 m_pStream->Release();
145 m_pStream = NULL; 145 m_pStream = nullptr;
146 } 146 }
147 pXMLNode = XFA_FDEExtension_GetDocumentNode(m_pXMLDoc); 147 pXMLNode = XFA_FDEExtension_GetDocumentNode(m_pXMLDoc);
148 return XFA_PARSESTATUS_Done; 148 return XFA_PARSESTATUS_Done;
149 } 149 }
150 150
151 void CXFA_SimpleParser::ConstructXFANode(CXFA_Node* pXFANode, 151 void CXFA_SimpleParser::ConstructXFANode(CXFA_Node* pXFANode,
152 CFDE_XMLNode* pXMLNode) { 152 CFDE_XMLNode* pXMLNode) {
153 XFA_XDPPACKET ePacketID = (XFA_XDPPACKET)pXFANode->GetPacketID(); 153 XFA_XDPPACKET ePacketID = (XFA_XDPPACKET)pXFANode->GetPacketID();
154 if (ePacketID == XFA_XDPPACKET_Datasets) { 154 if (ePacketID == XFA_XDPPACKET_Datasets) {
155 if (pXFANode->GetElementType() == XFA_Element::DataValue) { 155 if (pXFANode->GetElementType() == XFA_Element::DataValue) {
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 } 349 }
350 wsValue = wsAttrValue; 350 wsValue = wsAttrValue;
351 return TRUE; 351 return TRUE;
352 } 352 }
353 return FALSE; 353 return FALSE;
354 } 354 }
355 CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket(CFDE_XMLNode* pXMLDocumentNode, 355 CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket(CFDE_XMLNode* pXMLDocumentNode,
356 XFA_XDPPACKET ePacketID) { 356 XFA_XDPPACKET ePacketID) {
357 switch (ePacketID) { 357 switch (ePacketID) {
358 case XFA_XDPPACKET_UNKNOWN: 358 case XFA_XDPPACKET_UNKNOWN:
359 return NULL; 359 return nullptr;
360 case XFA_XDPPACKET_XDP: 360 case XFA_XDPPACKET_XDP:
361 return ParseAsXDPPacket_XDP(pXMLDocumentNode, ePacketID); 361 return ParseAsXDPPacket_XDP(pXMLDocumentNode, ePacketID);
362 case XFA_XDPPACKET_Config: 362 case XFA_XDPPACKET_Config:
363 return ParseAsXDPPacket_Config(pXMLDocumentNode, ePacketID); 363 return ParseAsXDPPacket_Config(pXMLDocumentNode, ePacketID);
364 case XFA_XDPPACKET_Template: 364 case XFA_XDPPACKET_Template:
365 case XFA_XDPPACKET_Form: 365 case XFA_XDPPACKET_Form:
366 return ParseAsXDPPacket_TemplateForm(pXMLDocumentNode, ePacketID); 366 return ParseAsXDPPacket_TemplateForm(pXMLDocumentNode, ePacketID);
367 case XFA_XDPPACKET_Datasets: 367 case XFA_XDPPACKET_Datasets:
368 return ParseAsXDPPacket_Data(pXMLDocumentNode, ePacketID); 368 return ParseAsXDPPacket_Data(pXMLDocumentNode, ePacketID);
369 case XFA_XDPPACKET_Xdc: 369 case XFA_XDPPACKET_Xdc:
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 pPacketInfo->pURI, 419 pPacketInfo->pURI,
420 pPacketInfo->eFlags)) { 420 pPacketInfo->eFlags)) {
421 continue; 421 continue;
422 } 422 }
423 if (pXFARootNode->GetFirstChildByName(pPacketInfo->uHash)) { 423 if (pXFARootNode->GetFirstChildByName(pPacketInfo->uHash)) {
424 return nullptr; 424 return nullptr;
425 } 425 }
426 pXMLConfigDOMRoot = pChildItem; 426 pXMLConfigDOMRoot = pChildItem;
427 pXFAConfigDOMRoot = 427 pXFAConfigDOMRoot =
428 ParseAsXDPPacket_Config(pXMLConfigDOMRoot, XFA_XDPPACKET_Config); 428 ParseAsXDPPacket_Config(pXMLConfigDOMRoot, XFA_XDPPACKET_Config);
429 pXFARootNode->InsertChild(pXFAConfigDOMRoot, NULL); 429 pXFARootNode->InsertChild(pXFAConfigDOMRoot, nullptr);
430 } 430 }
431 } 431 }
432 CFDE_XMLNode* pXMLDatasetsDOMRoot = nullptr; 432 CFDE_XMLNode* pXMLDatasetsDOMRoot = nullptr;
433 CFDE_XMLNode* pXMLFormDOMRoot = nullptr; 433 CFDE_XMLNode* pXMLFormDOMRoot = nullptr;
434 CFDE_XMLNode* pXMLTemplateDOMRoot = nullptr; 434 CFDE_XMLNode* pXMLTemplateDOMRoot = nullptr;
435 { 435 {
436 for (CFDE_XMLNode* pChildItem = 436 for (CFDE_XMLNode* pChildItem =
437 pXMLDocumentNode->GetNodeItem(CFDE_XMLNode::FirstChild); 437 pXMLDocumentNode->GetNodeItem(CFDE_XMLNode::FirstChild);
438 pChildItem; 438 pChildItem;
439 pChildItem = pChildItem->GetNodeItem(CFDE_XMLNode::NextSibling)) { 439 pChildItem = pChildItem->GetNodeItem(CFDE_XMLNode::NextSibling)) {
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 pXFARootNode->SetXMLMappingNode(pXMLDocumentNode); 515 pXFARootNode->SetXMLMappingNode(pXMLDocumentNode);
516 return pXFARootNode; 516 return pXFARootNode;
517 } 517 }
518 CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_Config( 518 CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_Config(
519 CFDE_XMLNode* pXMLDocumentNode, 519 CFDE_XMLNode* pXMLDocumentNode,
520 XFA_XDPPACKET ePacketID) { 520 XFA_XDPPACKET ePacketID) {
521 if (!XFA_FDEExtension_MatchNodeName( 521 if (!XFA_FDEExtension_MatchNodeName(
522 pXMLDocumentNode, XFA_GetPacketByIndex(XFA_PACKET_Config)->pName, 522 pXMLDocumentNode, XFA_GetPacketByIndex(XFA_PACKET_Config)->pName,
523 XFA_GetPacketByIndex(XFA_PACKET_Config)->pURI, 523 XFA_GetPacketByIndex(XFA_PACKET_Config)->pURI,
524 XFA_GetPacketByIndex(XFA_PACKET_Config)->eFlags)) { 524 XFA_GetPacketByIndex(XFA_PACKET_Config)->eFlags)) {
525 return NULL; 525 return nullptr;
526 } 526 }
527 CXFA_Node* pNode = 527 CXFA_Node* pNode =
528 m_pFactory->CreateNode(XFA_XDPPACKET_Config, XFA_Element::Config); 528 m_pFactory->CreateNode(XFA_XDPPACKET_Config, XFA_Element::Config);
529 if (!pNode) { 529 if (!pNode) {
530 return NULL; 530 return nullptr;
531 } 531 }
532 pNode->SetCData(XFA_ATTRIBUTE_Name, 532 pNode->SetCData(XFA_ATTRIBUTE_Name,
533 XFA_GetPacketByIndex(XFA_PACKET_Config)->pName); 533 XFA_GetPacketByIndex(XFA_PACKET_Config)->pName);
534 if (!NormalLoader(pNode, pXMLDocumentNode, ePacketID)) { 534 if (!NormalLoader(pNode, pXMLDocumentNode, ePacketID)) {
535 return NULL; 535 return nullptr;
536 } 536 }
537 pNode->SetXMLMappingNode(pXMLDocumentNode); 537 pNode->SetXMLMappingNode(pXMLDocumentNode);
538 return pNode; 538 return pNode;
539 } 539 }
540 CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_TemplateForm( 540 CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_TemplateForm(
541 CFDE_XMLNode* pXMLDocumentNode, 541 CFDE_XMLNode* pXMLDocumentNode,
542 XFA_XDPPACKET ePacketID) { 542 XFA_XDPPACKET ePacketID) {
543 CXFA_Node* pNode = NULL; 543 CXFA_Node* pNode = nullptr;
544 if (ePacketID == XFA_XDPPACKET_Template) { 544 if (ePacketID == XFA_XDPPACKET_Template) {
545 if (XFA_FDEExtension_MatchNodeName( 545 if (XFA_FDEExtension_MatchNodeName(
546 pXMLDocumentNode, XFA_GetPacketByIndex(XFA_PACKET_Template)->pName, 546 pXMLDocumentNode, XFA_GetPacketByIndex(XFA_PACKET_Template)->pName,
547 XFA_GetPacketByIndex(XFA_PACKET_Template)->pURI, 547 XFA_GetPacketByIndex(XFA_PACKET_Template)->pURI,
548 XFA_GetPacketByIndex(XFA_PACKET_Template)->eFlags)) { 548 XFA_GetPacketByIndex(XFA_PACKET_Template)->eFlags)) {
549 pNode = 549 pNode =
550 m_pFactory->CreateNode(XFA_XDPPACKET_Template, XFA_Element::Template); 550 m_pFactory->CreateNode(XFA_XDPPACKET_Template, XFA_Element::Template);
551 if (!pNode) { 551 if (!pNode) {
552 return NULL; 552 return nullptr;
553 } 553 }
554 pNode->SetCData(XFA_ATTRIBUTE_Name, 554 pNode->SetCData(XFA_ATTRIBUTE_Name,
555 XFA_GetPacketByIndex(XFA_PACKET_Template)->pName); 555 XFA_GetPacketByIndex(XFA_PACKET_Template)->pName);
556 if (m_bDocumentParser) { 556 if (m_bDocumentParser) {
557 CFX_WideString wsNamespaceURI; 557 CFX_WideString wsNamespaceURI;
558 CFDE_XMLElement* pXMLDocumentElement = 558 CFDE_XMLElement* pXMLDocumentElement =
559 static_cast<CFDE_XMLElement*>(pXMLDocumentNode); 559 static_cast<CFDE_XMLElement*>(pXMLDocumentNode);
560 pXMLDocumentElement->GetNamespaceURI(wsNamespaceURI); 560 pXMLDocumentElement->GetNamespaceURI(wsNamespaceURI);
561 if (wsNamespaceURI.IsEmpty()) { 561 if (wsNamespaceURI.IsEmpty()) {
562 pXMLDocumentElement->GetString(L"xmlns:xfa", wsNamespaceURI); 562 pXMLDocumentElement->GetString(L"xmlns:xfa", wsNamespaceURI);
563 } 563 }
564 pNode->GetDocument()->RecognizeXFAVersionNumber(wsNamespaceURI); 564 pNode->GetDocument()->RecognizeXFAVersionNumber(wsNamespaceURI);
565 } 565 }
566 if (!NormalLoader(pNode, pXMLDocumentNode, ePacketID)) { 566 if (!NormalLoader(pNode, pXMLDocumentNode, ePacketID)) {
567 return NULL; 567 return nullptr;
568 } 568 }
569 } 569 }
570 } else if (ePacketID == XFA_XDPPACKET_Form) { 570 } else if (ePacketID == XFA_XDPPACKET_Form) {
571 if (XFA_FDEExtension_MatchNodeName( 571 if (XFA_FDEExtension_MatchNodeName(
572 pXMLDocumentNode, XFA_GetPacketByIndex(XFA_PACKET_Form)->pName, 572 pXMLDocumentNode, XFA_GetPacketByIndex(XFA_PACKET_Form)->pName,
573 XFA_GetPacketByIndex(XFA_PACKET_Form)->pURI, 573 XFA_GetPacketByIndex(XFA_PACKET_Form)->pURI,
574 XFA_GetPacketByIndex(XFA_PACKET_Form)->eFlags)) { 574 XFA_GetPacketByIndex(XFA_PACKET_Form)->eFlags)) {
575 CFDE_XMLElement* pXMLDocumentElement = 575 CFDE_XMLElement* pXMLDocumentElement =
576 static_cast<CFDE_XMLElement*>(pXMLDocumentNode); 576 static_cast<CFDE_XMLElement*>(pXMLDocumentNode);
577 CFX_WideString wsChecksum; 577 CFX_WideString wsChecksum;
578 pXMLDocumentElement->GetString(L"checksum", wsChecksum); 578 pXMLDocumentElement->GetString(L"checksum", wsChecksum);
579 if (wsChecksum.GetLength() != 28 || 579 if (wsChecksum.GetLength() != 28 ||
580 m_pXMLParser->m_dwCheckStatus != 0x03) { 580 m_pXMLParser->m_dwCheckStatus != 0x03) {
581 return NULL; 581 return nullptr;
582 } 582 }
583 std::unique_ptr<CXFA_ChecksumContext> pChecksum(new CXFA_ChecksumContext); 583 std::unique_ptr<CXFA_ChecksumContext> pChecksum(new CXFA_ChecksumContext);
584 pChecksum->StartChecksum(); 584 pChecksum->StartChecksum();
585 pChecksum->UpdateChecksum(m_pFileRead, m_pXMLParser->m_nStart[0], 585 pChecksum->UpdateChecksum(m_pFileRead, m_pXMLParser->m_nStart[0],
586 m_pXMLParser->m_nSize[0]); 586 m_pXMLParser->m_nSize[0]);
587 pChecksum->UpdateChecksum(m_pFileRead, m_pXMLParser->m_nStart[1], 587 pChecksum->UpdateChecksum(m_pFileRead, m_pXMLParser->m_nStart[1],
588 m_pXMLParser->m_nSize[1]); 588 m_pXMLParser->m_nSize[1]);
589 pChecksum->FinishChecksum(); 589 pChecksum->FinishChecksum();
590 CFX_ByteString bsCheck = pChecksum->GetChecksum(); 590 CFX_ByteString bsCheck = pChecksum->GetChecksum();
591 if (bsCheck != wsChecksum.UTF8Encode()) 591 if (bsCheck != wsChecksum.UTF8Encode())
592 return nullptr; 592 return nullptr;
593 593
594 pNode = m_pFactory->CreateNode(XFA_XDPPACKET_Form, XFA_Element::Form); 594 pNode = m_pFactory->CreateNode(XFA_XDPPACKET_Form, XFA_Element::Form);
595 if (!pNode) 595 if (!pNode)
596 return nullptr; 596 return nullptr;
597 597
598 pNode->SetCData(XFA_ATTRIBUTE_Name, 598 pNode->SetCData(XFA_ATTRIBUTE_Name,
599 XFA_GetPacketByIndex(XFA_PACKET_Form)->pName); 599 XFA_GetPacketByIndex(XFA_PACKET_Form)->pName);
600 pNode->SetAttribute(XFA_ATTRIBUTE_Checksum, wsChecksum.AsStringC()); 600 pNode->SetAttribute(XFA_ATTRIBUTE_Checksum, wsChecksum.AsStringC());
601 CXFA_Node* pTemplateRoot = 601 CXFA_Node* pTemplateRoot =
602 m_pRootNode->GetFirstChildByClass(XFA_Element::Template); 602 m_pRootNode->GetFirstChildByClass(XFA_Element::Template);
603 CXFA_Node* pTemplateChosen = 603 CXFA_Node* pTemplateChosen =
604 pTemplateRoot 604 pTemplateRoot
605 ? pTemplateRoot->GetFirstChildByClass(XFA_Element::Subform) 605 ? pTemplateRoot->GetFirstChildByClass(XFA_Element::Subform)
606 : NULL; 606 : nullptr;
607 FX_BOOL bUseAttribute = TRUE; 607 FX_BOOL bUseAttribute = TRUE;
608 if (pTemplateChosen && 608 if (pTemplateChosen &&
609 pTemplateChosen->GetEnum(XFA_ATTRIBUTE_RestoreState) != 609 pTemplateChosen->GetEnum(XFA_ATTRIBUTE_RestoreState) !=
610 XFA_ATTRIBUTEENUM_Auto) { 610 XFA_ATTRIBUTEENUM_Auto) {
611 bUseAttribute = FALSE; 611 bUseAttribute = FALSE;
612 } 612 }
613 if (!NormalLoader(pNode, pXMLDocumentNode, ePacketID, bUseAttribute)) { 613 if (!NormalLoader(pNode, pXMLDocumentNode, ePacketID, bUseAttribute)) {
614 return NULL; 614 return nullptr;
615 } 615 }
616 } 616 }
617 } 617 }
618 if (pNode) { 618 if (pNode) {
619 pNode->SetXMLMappingNode(pXMLDocumentNode); 619 pNode->SetXMLMappingNode(pXMLDocumentNode);
620 } 620 }
621 return pNode; 621 return pNode;
622 } 622 }
623 static CFDE_XMLNode* XFA_GetDataSetsFromXDP(CFDE_XMLNode* pXMLDocumentNode) { 623 static CFDE_XMLNode* XFA_GetDataSetsFromXDP(CFDE_XMLNode* pXMLDocumentNode) {
624 if (XFA_FDEExtension_MatchNodeName( 624 if (XFA_FDEExtension_MatchNodeName(
625 pXMLDocumentNode, XFA_GetPacketByIndex(XFA_PACKET_Datasets)->pName, 625 pXMLDocumentNode, XFA_GetPacketByIndex(XFA_PACKET_Datasets)->pName,
626 XFA_GetPacketByIndex(XFA_PACKET_Datasets)->pURI, 626 XFA_GetPacketByIndex(XFA_PACKET_Datasets)->pURI,
627 XFA_GetPacketByIndex(XFA_PACKET_Datasets)->eFlags)) { 627 XFA_GetPacketByIndex(XFA_PACKET_Datasets)->eFlags)) {
628 return pXMLDocumentNode; 628 return pXMLDocumentNode;
629 } 629 }
630 if (!XFA_FDEExtension_MatchNodeName( 630 if (!XFA_FDEExtension_MatchNodeName(
631 pXMLDocumentNode, XFA_GetPacketByIndex(XFA_PACKET_XDP)->pName, 631 pXMLDocumentNode, XFA_GetPacketByIndex(XFA_PACKET_XDP)->pName,
632 XFA_GetPacketByIndex(XFA_PACKET_XDP)->pURI, 632 XFA_GetPacketByIndex(XFA_PACKET_XDP)->pURI,
633 XFA_GetPacketByIndex(XFA_PACKET_XDP)->eFlags)) { 633 XFA_GetPacketByIndex(XFA_PACKET_XDP)->eFlags)) {
634 return NULL; 634 return nullptr;
635 } 635 }
636 for (CFDE_XMLNode* pDatasetsNode = 636 for (CFDE_XMLNode* pDatasetsNode =
637 pXMLDocumentNode->GetNodeItem(CFDE_XMLNode::FirstChild); 637 pXMLDocumentNode->GetNodeItem(CFDE_XMLNode::FirstChild);
638 pDatasetsNode; 638 pDatasetsNode;
639 pDatasetsNode = pDatasetsNode->GetNodeItem(CFDE_XMLNode::NextSibling)) { 639 pDatasetsNode = pDatasetsNode->GetNodeItem(CFDE_XMLNode::NextSibling)) {
640 if (!XFA_FDEExtension_MatchNodeName( 640 if (!XFA_FDEExtension_MatchNodeName(
641 pDatasetsNode, XFA_GetPacketByIndex(XFA_PACKET_Datasets)->pName, 641 pDatasetsNode, XFA_GetPacketByIndex(XFA_PACKET_Datasets)->pName,
642 XFA_GetPacketByIndex(XFA_PACKET_Datasets)->pURI, 642 XFA_GetPacketByIndex(XFA_PACKET_Datasets)->pURI,
643 XFA_GetPacketByIndex(XFA_PACKET_Datasets)->eFlags)) { 643 XFA_GetPacketByIndex(XFA_PACKET_Datasets)->eFlags)) {
644 continue; 644 continue;
645 } 645 }
646 return pDatasetsNode; 646 return pDatasetsNode;
647 } 647 }
648 return NULL; 648 return nullptr;
649 } 649 }
650 CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_Data( 650 CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_Data(
651 CFDE_XMLNode* pXMLDocumentNode, 651 CFDE_XMLNode* pXMLDocumentNode,
652 XFA_XDPPACKET ePacketID) { 652 XFA_XDPPACKET ePacketID) {
653 CFDE_XMLNode* pDatasetsXMLNode = XFA_GetDataSetsFromXDP(pXMLDocumentNode); 653 CFDE_XMLNode* pDatasetsXMLNode = XFA_GetDataSetsFromXDP(pXMLDocumentNode);
654 if (pDatasetsXMLNode) { 654 if (pDatasetsXMLNode) {
655 CXFA_Node* pNode = 655 CXFA_Node* pNode =
656 m_pFactory->CreateNode(XFA_XDPPACKET_Datasets, XFA_Element::DataModel); 656 m_pFactory->CreateNode(XFA_XDPPACKET_Datasets, XFA_Element::DataModel);
657 if (!pNode) { 657 if (!pNode) {
658 return NULL; 658 return nullptr;
659 } 659 }
660 pNode->SetCData(XFA_ATTRIBUTE_Name, 660 pNode->SetCData(XFA_ATTRIBUTE_Name,
661 XFA_GetPacketByIndex(XFA_PACKET_Datasets)->pName); 661 XFA_GetPacketByIndex(XFA_PACKET_Datasets)->pName);
662 if (!DataLoader(pNode, pDatasetsXMLNode, FALSE)) { 662 if (!DataLoader(pNode, pDatasetsXMLNode, FALSE)) {
663 return NULL; 663 return nullptr;
664 } 664 }
665 pNode->SetXMLMappingNode(pDatasetsXMLNode); 665 pNode->SetXMLMappingNode(pDatasetsXMLNode);
666 return pNode; 666 return pNode;
667 } 667 }
668 CFDE_XMLNode* pDataXMLNode = NULL; 668 CFDE_XMLNode* pDataXMLNode = nullptr;
669 if (XFA_FDEExtension_MatchNodeName( 669 if (XFA_FDEExtension_MatchNodeName(
670 pXMLDocumentNode, FX_WSTRC(L"data"), 670 pXMLDocumentNode, FX_WSTRC(L"data"),
671 XFA_GetPacketByIndex(XFA_PACKET_Datasets)->pURI, 671 XFA_GetPacketByIndex(XFA_PACKET_Datasets)->pURI,
672 XFA_GetPacketByIndex(XFA_PACKET_Datasets)->eFlags)) { 672 XFA_GetPacketByIndex(XFA_PACKET_Datasets)->eFlags)) {
673 static_cast<CFDE_XMLElement*>(pXMLDocumentNode) 673 static_cast<CFDE_XMLElement*>(pXMLDocumentNode)
674 ->RemoveAttribute(L"xmlns:xfa"); 674 ->RemoveAttribute(L"xmlns:xfa");
675 pDataXMLNode = pXMLDocumentNode; 675 pDataXMLNode = pXMLDocumentNode;
676 } else { 676 } else {
677 CFDE_XMLElement* pDataElement = new CFDE_XMLElement(L"xfa:data"); 677 CFDE_XMLElement* pDataElement = new CFDE_XMLElement(L"xfa:data");
678 CFDE_XMLNode* pParentXMLNode = 678 CFDE_XMLNode* pParentXMLNode =
679 pXMLDocumentNode->GetNodeItem(CFDE_XMLNode::Parent); 679 pXMLDocumentNode->GetNodeItem(CFDE_XMLNode::Parent);
680 if (pParentXMLNode) { 680 if (pParentXMLNode) {
681 pParentXMLNode->RemoveChildNode(pXMLDocumentNode); 681 pParentXMLNode->RemoveChildNode(pXMLDocumentNode);
682 } 682 }
683 ASSERT(pXMLDocumentNode->GetType() == FDE_XMLNODE_Element); 683 ASSERT(pXMLDocumentNode->GetType() == FDE_XMLNODE_Element);
684 if (pXMLDocumentNode->GetType() == FDE_XMLNODE_Element) { 684 if (pXMLDocumentNode->GetType() == FDE_XMLNODE_Element) {
685 static_cast<CFDE_XMLElement*>(pXMLDocumentNode) 685 static_cast<CFDE_XMLElement*>(pXMLDocumentNode)
686 ->RemoveAttribute(L"xmlns:xfa"); 686 ->RemoveAttribute(L"xmlns:xfa");
687 } 687 }
688 pDataElement->InsertChildNode(pXMLDocumentNode); 688 pDataElement->InsertChildNode(pXMLDocumentNode);
689 pDataXMLNode = pDataElement; 689 pDataXMLNode = pDataElement;
690 } 690 }
691 if (pDataXMLNode) { 691 if (pDataXMLNode) {
692 CXFA_Node* pNode = 692 CXFA_Node* pNode =
693 m_pFactory->CreateNode(XFA_XDPPACKET_Datasets, XFA_Element::DataGroup); 693 m_pFactory->CreateNode(XFA_XDPPACKET_Datasets, XFA_Element::DataGroup);
694 if (!pNode) { 694 if (!pNode) {
695 if (pDataXMLNode != pXMLDocumentNode) { 695 if (pDataXMLNode != pXMLDocumentNode) {
696 pDataXMLNode->Release(); 696 pDataXMLNode->Release();
697 } 697 }
698 return NULL; 698 return nullptr;
699 } 699 }
700 CFX_WideString wsLocalName; 700 CFX_WideString wsLocalName;
701 static_cast<CFDE_XMLElement*>(pDataXMLNode)->GetLocalTagName(wsLocalName); 701 static_cast<CFDE_XMLElement*>(pDataXMLNode)->GetLocalTagName(wsLocalName);
702 pNode->SetCData(XFA_ATTRIBUTE_Name, wsLocalName); 702 pNode->SetCData(XFA_ATTRIBUTE_Name, wsLocalName);
703 if (!DataLoader(pNode, pDataXMLNode, TRUE)) { 703 if (!DataLoader(pNode, pDataXMLNode, TRUE)) {
704 return NULL; 704 return nullptr;
705 } 705 }
706 pNode->SetXMLMappingNode(pDataXMLNode); 706 pNode->SetXMLMappingNode(pDataXMLNode);
707 if (pDataXMLNode != pXMLDocumentNode) { 707 if (pDataXMLNode != pXMLDocumentNode) {
708 pNode->SetFlag(XFA_NodeFlag_OwnXMLNode, false); 708 pNode->SetFlag(XFA_NodeFlag_OwnXMLNode, false);
709 } 709 }
710 return pNode; 710 return pNode;
711 } 711 }
712 return NULL; 712 return nullptr;
713 } 713 }
714 CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_LocaleConnectionSourceSet( 714 CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_LocaleConnectionSourceSet(
715 CFDE_XMLNode* pXMLDocumentNode, 715 CFDE_XMLNode* pXMLDocumentNode,
716 XFA_XDPPACKET ePacketID) { 716 XFA_XDPPACKET ePacketID) {
717 CXFA_Node* pNode = NULL; 717 CXFA_Node* pNode = nullptr;
718 if (ePacketID == XFA_XDPPACKET_LocaleSet) { 718 if (ePacketID == XFA_XDPPACKET_LocaleSet) {
719 if (XFA_FDEExtension_MatchNodeName( 719 if (XFA_FDEExtension_MatchNodeName(
720 pXMLDocumentNode, XFA_GetPacketByIndex(XFA_PACKET_LocaleSet)->pName, 720 pXMLDocumentNode, XFA_GetPacketByIndex(XFA_PACKET_LocaleSet)->pName,
721 XFA_GetPacketByIndex(XFA_PACKET_LocaleSet)->pURI, 721 XFA_GetPacketByIndex(XFA_PACKET_LocaleSet)->pURI,
722 XFA_GetPacketByIndex(XFA_PACKET_LocaleSet)->eFlags)) { 722 XFA_GetPacketByIndex(XFA_PACKET_LocaleSet)->eFlags)) {
723 pNode = m_pFactory->CreateNode(XFA_XDPPACKET_LocaleSet, 723 pNode = m_pFactory->CreateNode(XFA_XDPPACKET_LocaleSet,
724 XFA_Element::LocaleSet); 724 XFA_Element::LocaleSet);
725 if (!pNode) { 725 if (!pNode) {
726 return NULL; 726 return nullptr;
727 } 727 }
728 pNode->SetCData(XFA_ATTRIBUTE_Name, 728 pNode->SetCData(XFA_ATTRIBUTE_Name,
729 XFA_GetPacketByIndex(XFA_PACKET_LocaleSet)->pName); 729 XFA_GetPacketByIndex(XFA_PACKET_LocaleSet)->pName);
730 if (!NormalLoader(pNode, pXMLDocumentNode, ePacketID)) { 730 if (!NormalLoader(pNode, pXMLDocumentNode, ePacketID)) {
731 return NULL; 731 return nullptr;
732 } 732 }
733 } 733 }
734 } else if (ePacketID == XFA_XDPPACKET_ConnectionSet) { 734 } else if (ePacketID == XFA_XDPPACKET_ConnectionSet) {
735 if (XFA_FDEExtension_MatchNodeName( 735 if (XFA_FDEExtension_MatchNodeName(
736 pXMLDocumentNode, 736 pXMLDocumentNode,
737 XFA_GetPacketByIndex(XFA_PACKET_ConnectionSet)->pName, 737 XFA_GetPacketByIndex(XFA_PACKET_ConnectionSet)->pName,
738 XFA_GetPacketByIndex(XFA_PACKET_ConnectionSet)->pURI, 738 XFA_GetPacketByIndex(XFA_PACKET_ConnectionSet)->pURI,
739 XFA_GetPacketByIndex(XFA_PACKET_ConnectionSet)->eFlags)) { 739 XFA_GetPacketByIndex(XFA_PACKET_ConnectionSet)->eFlags)) {
740 pNode = m_pFactory->CreateNode(XFA_XDPPACKET_ConnectionSet, 740 pNode = m_pFactory->CreateNode(XFA_XDPPACKET_ConnectionSet,
741 XFA_Element::ConnectionSet); 741 XFA_Element::ConnectionSet);
742 if (!pNode) { 742 if (!pNode) {
743 return NULL; 743 return nullptr;
744 } 744 }
745 pNode->SetCData(XFA_ATTRIBUTE_Name, 745 pNode->SetCData(XFA_ATTRIBUTE_Name,
746 XFA_GetPacketByIndex(XFA_PACKET_ConnectionSet)->pName); 746 XFA_GetPacketByIndex(XFA_PACKET_ConnectionSet)->pName);
747 if (!NormalLoader(pNode, pXMLDocumentNode, ePacketID)) { 747 if (!NormalLoader(pNode, pXMLDocumentNode, ePacketID)) {
748 return NULL; 748 return nullptr;
749 } 749 }
750 } 750 }
751 } else if (ePacketID == XFA_XDPPACKET_SourceSet) { 751 } else if (ePacketID == XFA_XDPPACKET_SourceSet) {
752 if (XFA_FDEExtension_MatchNodeName( 752 if (XFA_FDEExtension_MatchNodeName(
753 pXMLDocumentNode, XFA_GetPacketByIndex(XFA_PACKET_SourceSet)->pName, 753 pXMLDocumentNode, XFA_GetPacketByIndex(XFA_PACKET_SourceSet)->pName,
754 XFA_GetPacketByIndex(XFA_PACKET_SourceSet)->pURI, 754 XFA_GetPacketByIndex(XFA_PACKET_SourceSet)->pURI,
755 XFA_GetPacketByIndex(XFA_PACKET_SourceSet)->eFlags)) { 755 XFA_GetPacketByIndex(XFA_PACKET_SourceSet)->eFlags)) {
756 pNode = m_pFactory->CreateNode(XFA_XDPPACKET_SourceSet, 756 pNode = m_pFactory->CreateNode(XFA_XDPPACKET_SourceSet,
757 XFA_Element::SourceSet); 757 XFA_Element::SourceSet);
758 if (!pNode) { 758 if (!pNode) {
759 return NULL; 759 return nullptr;
760 } 760 }
761 pNode->SetCData(XFA_ATTRIBUTE_Name, 761 pNode->SetCData(XFA_ATTRIBUTE_Name,
762 XFA_GetPacketByIndex(XFA_PACKET_SourceSet)->pName); 762 XFA_GetPacketByIndex(XFA_PACKET_SourceSet)->pName);
763 if (!NormalLoader(pNode, pXMLDocumentNode, ePacketID)) { 763 if (!NormalLoader(pNode, pXMLDocumentNode, ePacketID)) {
764 return NULL; 764 return nullptr;
765 } 765 }
766 } 766 }
767 } 767 }
768 if (pNode) { 768 if (pNode) {
769 pNode->SetXMLMappingNode(pXMLDocumentNode); 769 pNode->SetXMLMappingNode(pXMLDocumentNode);
770 } 770 }
771 return pNode; 771 return pNode;
772 } 772 }
773 CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_Xdc( 773 CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_Xdc(
774 CFDE_XMLNode* pXMLDocumentNode, 774 CFDE_XMLNode* pXMLDocumentNode,
775 XFA_XDPPACKET ePacketID) { 775 XFA_XDPPACKET ePacketID) {
776 if (XFA_FDEExtension_MatchNodeName( 776 if (XFA_FDEExtension_MatchNodeName(
777 pXMLDocumentNode, XFA_GetPacketByIndex(XFA_PACKET_Xdc)->pName, 777 pXMLDocumentNode, XFA_GetPacketByIndex(XFA_PACKET_Xdc)->pName,
778 XFA_GetPacketByIndex(XFA_PACKET_Xdc)->pURI, 778 XFA_GetPacketByIndex(XFA_PACKET_Xdc)->pURI,
779 XFA_GetPacketByIndex(XFA_PACKET_Xdc)->eFlags)) { 779 XFA_GetPacketByIndex(XFA_PACKET_Xdc)->eFlags)) {
780 CXFA_Node* pNode = 780 CXFA_Node* pNode =
781 m_pFactory->CreateNode(XFA_XDPPACKET_Xdc, XFA_Element::Xdc); 781 m_pFactory->CreateNode(XFA_XDPPACKET_Xdc, XFA_Element::Xdc);
782 if (!pNode) { 782 if (!pNode) {
783 return NULL; 783 return nullptr;
784 } 784 }
785 pNode->SetCData(XFA_ATTRIBUTE_Name, 785 pNode->SetCData(XFA_ATTRIBUTE_Name,
786 XFA_GetPacketByIndex(XFA_PACKET_Xdc)->pName); 786 XFA_GetPacketByIndex(XFA_PACKET_Xdc)->pName);
787 pNode->SetXMLMappingNode(pXMLDocumentNode); 787 pNode->SetXMLMappingNode(pXMLDocumentNode);
788 return pNode; 788 return pNode;
789 } 789 }
790 return NULL; 790 return nullptr;
791 } 791 }
792 CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_User( 792 CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_User(
793 CFDE_XMLNode* pXMLDocumentNode, 793 CFDE_XMLNode* pXMLDocumentNode,
794 XFA_XDPPACKET ePacketID) { 794 XFA_XDPPACKET ePacketID) {
795 CXFA_Node* pNode = 795 CXFA_Node* pNode =
796 m_pFactory->CreateNode(XFA_XDPPACKET_XDP, XFA_Element::Packet); 796 m_pFactory->CreateNode(XFA_XDPPACKET_XDP, XFA_Element::Packet);
797 if (!pNode) { 797 if (!pNode) {
798 return NULL; 798 return nullptr;
799 } 799 }
800 CFX_WideString wsName; 800 CFX_WideString wsName;
801 static_cast<CFDE_XMLElement*>(pXMLDocumentNode)->GetLocalTagName(wsName); 801 static_cast<CFDE_XMLElement*>(pXMLDocumentNode)->GetLocalTagName(wsName);
802 pNode->SetCData(XFA_ATTRIBUTE_Name, wsName); 802 pNode->SetCData(XFA_ATTRIBUTE_Name, wsName);
803 if (!UserPacketLoader(pNode, pXMLDocumentNode)) { 803 if (!UserPacketLoader(pNode, pXMLDocumentNode)) {
804 return NULL; 804 return nullptr;
805 } 805 }
806 pNode->SetXMLMappingNode(pXMLDocumentNode); 806 pNode->SetXMLMappingNode(pXMLDocumentNode);
807 return pNode; 807 return pNode;
808 } 808 }
809 CXFA_Node* CXFA_SimpleParser::UserPacketLoader(CXFA_Node* pXFANode, 809 CXFA_Node* CXFA_SimpleParser::UserPacketLoader(CXFA_Node* pXFANode,
810 CFDE_XMLNode* pXMLDoc) { 810 CFDE_XMLNode* pXMLDoc) {
811 return pXFANode; 811 return pXFANode;
812 } 812 }
813 static FX_BOOL XFA_FDEExtension_IsStringAllWhitespace(CFX_WideString wsText) { 813 static FX_BOOL XFA_FDEExtension_IsStringAllWhitespace(CFX_WideString wsText) {
814 wsText.TrimRight(L"\x20\x9\xD\xA"); 814 wsText.TrimRight(L"\x20\x9\xD\xA");
(...skipping 26 matching lines...) Expand all
841 pXFANode->GetElementType(), eType, ePacketID); 841 pXFANode->GetElementType(), eType, ePacketID);
842 if (pPropertyInfo && 842 if (pPropertyInfo &&
843 ((pPropertyInfo->uFlags & 843 ((pPropertyInfo->uFlags &
844 (XFA_PROPERTYFLAG_OneOf | XFA_PROPERTYFLAG_DefaultOneOf)) != 0)) { 844 (XFA_PROPERTYFLAG_OneOf | XFA_PROPERTYFLAG_DefaultOneOf)) != 0)) {
845 if (bOneOfPropertyFound) { 845 if (bOneOfPropertyFound) {
846 break; 846 break;
847 } 847 }
848 bOneOfPropertyFound = TRUE; 848 bOneOfPropertyFound = TRUE;
849 } 849 }
850 CXFA_Node* pXFAChild = m_pFactory->CreateNode(ePacketID, eType); 850 CXFA_Node* pXFAChild = m_pFactory->CreateNode(ePacketID, eType);
851 if (pXFAChild == NULL) { 851 if (!pXFAChild)
852 return NULL; 852 return nullptr;
853 } 853 if (ePacketID == XFA_XDPPACKET_Config)
854 if (ePacketID == XFA_XDPPACKET_Config) {
855 pXFAChild->SetAttribute(XFA_ATTRIBUTE_Name, wsTagName.AsStringC()); 854 pXFAChild->SetAttribute(XFA_ATTRIBUTE_Name, wsTagName.AsStringC());
856 } 855
857 FX_BOOL IsNeedValue = TRUE; 856 FX_BOOL IsNeedValue = TRUE;
858 for (int32_t i = 0, count = pXMLElement->CountAttributes(); i < count; 857 for (int32_t i = 0, count = pXMLElement->CountAttributes(); i < count;
859 i++) { 858 i++) {
860 CFX_WideString wsAttrQualifiedName; 859 CFX_WideString wsAttrQualifiedName;
861 CFX_WideString wsAttrName; 860 CFX_WideString wsAttrName;
862 CFX_WideString wsAttrValue; 861 CFX_WideString wsAttrValue;
863 pXMLElement->GetAttribute(i, wsAttrQualifiedName, wsAttrValue); 862 pXMLElement->GetAttribute(i, wsAttrQualifiedName, wsAttrValue);
864 XFA_FDEExtension_GetAttributeLocalName( 863 XFA_FDEExtension_GetAttributeLocalName(
865 wsAttrQualifiedName.AsStringC(), wsAttrName); 864 wsAttrQualifiedName.AsStringC(), wsAttrName);
866 if (wsAttrName == FX_WSTRC(L"nil") && 865 if (wsAttrName == FX_WSTRC(L"nil") &&
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
1095 break; 1094 break;
1096 } 1095 }
1097 } 1096 }
1098 } 1097 }
1099 } 1098 }
1100 if (eNodeType == XFA_Element::DataModel) { 1099 if (eNodeType == XFA_Element::DataModel) {
1101 eNodeType = XFA_Element::DataValue; 1100 eNodeType = XFA_Element::DataValue;
1102 } 1101 }
1103 CXFA_Node* pXFAChild = 1102 CXFA_Node* pXFAChild =
1104 m_pFactory->CreateNode(XFA_XDPPACKET_Datasets, eNodeType); 1103 m_pFactory->CreateNode(XFA_XDPPACKET_Datasets, eNodeType);
1105 if (pXFAChild == NULL) { 1104 if (!pXFAChild) {
1106 return; 1105 return;
1107 } 1106 }
1108 CFX_WideString wsNodeName; 1107 CFX_WideString wsNodeName;
1109 pXMLElement->GetLocalTagName(wsNodeName); 1108 pXMLElement->GetLocalTagName(wsNodeName);
1110 pXFAChild->SetCData(XFA_ATTRIBUTE_Name, wsNodeName); 1109 pXFAChild->SetCData(XFA_ATTRIBUTE_Name, wsNodeName);
1111 FX_BOOL bNeedValue = TRUE; 1110 FX_BOOL bNeedValue = TRUE;
1112 if (1) { 1111 if (1) {
1113 for (int32_t i = 0, count = pXMLElement->CountAttributes(); i < count; 1112 for (int32_t i = 0, count = pXMLElement->CountAttributes(); i < count;
1114 i++) { 1113 i++) {
1115 CFX_WideString wsAttrQualifiedName; 1114 CFX_WideString wsAttrQualifiedName;
(...skipping 19 matching lines...) Expand all
1135 FX_WSTRC(L"http://www.w3.org/2001/XMLSchema-instance") || 1134 FX_WSTRC(L"http://www.w3.org/2001/XMLSchema-instance") ||
1136 wsAttrNamespaceURI == 1135 wsAttrNamespaceURI ==
1137 FX_WSTRC(L"http://www.xfa.org/schema/xfa-data/1.0/")) { 1136 FX_WSTRC(L"http://www.xfa.org/schema/xfa-data/1.0/")) {
1138 continue; 1137 continue;
1139 } 1138 }
1140 if (0) { 1139 if (0) {
1141 continue; 1140 continue;
1142 } 1141 }
1143 CXFA_Node* pXFAMetaData = m_pFactory->CreateNode( 1142 CXFA_Node* pXFAMetaData = m_pFactory->CreateNode(
1144 XFA_XDPPACKET_Datasets, XFA_Element::DataValue); 1143 XFA_XDPPACKET_Datasets, XFA_Element::DataValue);
1145 if (pXFAMetaData == NULL) { 1144 if (!pXFAMetaData) {
1146 return; 1145 return;
1147 } 1146 }
1148 pXFAMetaData->SetCData(XFA_ATTRIBUTE_Name, wsAttrName); 1147 pXFAMetaData->SetCData(XFA_ATTRIBUTE_Name, wsAttrName);
1149 pXFAMetaData->SetCData(XFA_ATTRIBUTE_QualifiedName, 1148 pXFAMetaData->SetCData(XFA_ATTRIBUTE_QualifiedName,
1150 wsAttrQualifiedName); 1149 wsAttrQualifiedName);
1151 pXFAMetaData->SetCData(XFA_ATTRIBUTE_Value, wsAttrValue); 1150 pXFAMetaData->SetCData(XFA_ATTRIBUTE_Value, wsAttrValue);
1152 pXFAMetaData->SetEnum(XFA_ATTRIBUTE_Contains, 1151 pXFAMetaData->SetEnum(XFA_ATTRIBUTE_Contains,
1153 XFA_ATTRIBUTEENUM_MetaData); 1152 XFA_ATTRIBUTEENUM_MetaData);
1154 pXFAChild->InsertChild(pXFAMetaData); 1153 pXFAChild->InsertChild(pXFAMetaData);
1155 pXFAMetaData->SetXMLMappingNode(pXMLElement); 1154 pXFAMetaData->SetXMLMappingNode(pXMLElement);
(...skipping 19 matching lines...) Expand all
1175 case FDE_XMLNODE_CharData: { 1174 case FDE_XMLNODE_CharData: {
1176 CFDE_XMLCharData* pXMLCharData = 1175 CFDE_XMLCharData* pXMLCharData =
1177 static_cast<CFDE_XMLCharData*>(pXMLChild); 1176 static_cast<CFDE_XMLCharData*>(pXMLChild);
1178 CFX_WideString wsCharData; 1177 CFX_WideString wsCharData;
1179 pXMLCharData->GetCharData(wsCharData); 1178 pXMLCharData->GetCharData(wsCharData);
1180 if (XFA_FDEExtension_IsStringAllWhitespace(wsCharData)) { 1179 if (XFA_FDEExtension_IsStringAllWhitespace(wsCharData)) {
1181 continue; 1180 continue;
1182 } 1181 }
1183 CXFA_Node* pXFAChild = m_pFactory->CreateNode(XFA_XDPPACKET_Datasets, 1182 CXFA_Node* pXFAChild = m_pFactory->CreateNode(XFA_XDPPACKET_Datasets,
1184 XFA_Element::DataValue); 1183 XFA_Element::DataValue);
1185 if (pXFAChild == NULL) { 1184 if (!pXFAChild) {
1186 return; 1185 return;
1187 } 1186 }
1188 pXFAChild->SetCData(XFA_ATTRIBUTE_Value, wsCharData); 1187 pXFAChild->SetCData(XFA_ATTRIBUTE_Value, wsCharData);
1189 pXFANode->InsertChild(pXFAChild); 1188 pXFANode->InsertChild(pXFAChild);
1190 pXFAChild->SetXMLMappingNode(pXMLCharData); 1189 pXFAChild->SetXMLMappingNode(pXMLCharData);
1191 pXFAChild->SetFlag(XFA_NodeFlag_Initialized, false); 1190 pXFAChild->SetFlag(XFA_NodeFlag_Initialized, false);
1192 } 1191 }
1193 continue; 1192 continue;
1194 case FDE_XMLNODE_Text: { 1193 case FDE_XMLNODE_Text: {
1195 CFDE_XMLText* pXMLText = static_cast<CFDE_XMLText*>(pXMLChild); 1194 CFDE_XMLText* pXMLText = static_cast<CFDE_XMLText*>(pXMLChild);
1196 CFX_WideString wsText; 1195 CFX_WideString wsText;
1197 pXMLText->GetText(wsText); 1196 pXMLText->GetText(wsText);
1198 if (XFA_FDEExtension_IsStringAllWhitespace(wsText)) { 1197 if (XFA_FDEExtension_IsStringAllWhitespace(wsText)) {
1199 continue; 1198 continue;
1200 } 1199 }
1201 CXFA_Node* pXFAChild = m_pFactory->CreateNode(XFA_XDPPACKET_Datasets, 1200 CXFA_Node* pXFAChild = m_pFactory->CreateNode(XFA_XDPPACKET_Datasets,
1202 XFA_Element::DataValue); 1201 XFA_Element::DataValue);
1203 if (pXFAChild == NULL) { 1202 if (!pXFAChild) {
1204 return; 1203 return;
1205 } 1204 }
1206 pXFAChild->SetCData(XFA_ATTRIBUTE_Value, wsText); 1205 pXFAChild->SetCData(XFA_ATTRIBUTE_Value, wsText);
1207 pXFANode->InsertChild(pXFAChild); 1206 pXFANode->InsertChild(pXFAChild);
1208 pXFAChild->SetXMLMappingNode(pXMLText); 1207 pXFAChild->SetXMLMappingNode(pXMLText);
1209 pXFAChild->SetFlag(XFA_NodeFlag_Initialized, false); 1208 pXFAChild->SetFlag(XFA_NodeFlag_Initialized, false);
1210 } 1209 }
1211 continue; 1210 continue;
1212 case FDE_XMLNODE_Instruction: 1211 case FDE_XMLNODE_Instruction:
1213 continue; 1212 continue;
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
1339 if (pXMLInstruction->GetData(1, wsData) && 1338 if (pXMLInstruction->GetData(1, wsData) &&
1340 wsData == FX_WSTRC(L"strictScoping")) { 1339 wsData == FX_WSTRC(L"strictScoping")) {
1341 pXFANode->GetDocument()->SetFlag(XFA_DOCFLAG_StrictScoping, TRUE); 1340 pXFANode->GetDocument()->SetFlag(XFA_DOCFLAG_StrictScoping, TRUE);
1342 } 1341 }
1343 } 1342 }
1344 } 1343 }
1345 } 1344 }
1346 void CXFA_SimpleParser::CloseParser() { 1345 void CXFA_SimpleParser::CloseParser() {
1347 if (m_pXMLDoc) { 1346 if (m_pXMLDoc) {
1348 m_pXMLDoc->Release(); 1347 m_pXMLDoc->Release();
1349 m_pXMLDoc = NULL; 1348 m_pXMLDoc = nullptr;
1350 } 1349 }
1351 if (m_pStream) { 1350 if (m_pStream) {
1352 m_pStream->Release(); 1351 m_pStream->Release();
1353 m_pStream = NULL; 1352 m_pStream = nullptr;
1354 } 1353 }
1355 } 1354 }
1356 1355
1357 CXFA_DocumentParser::CXFA_DocumentParser(CXFA_FFNotify* pNotify) 1356 CXFA_DocumentParser::CXFA_DocumentParser(CXFA_FFNotify* pNotify)
1358 : m_nodeParser(NULL, TRUE), m_pNotify(pNotify), m_pDocument(NULL) {} 1357 : m_nodeParser(nullptr, TRUE), m_pNotify(pNotify), m_pDocument(nullptr) {}
1359 CXFA_DocumentParser::~CXFA_DocumentParser() { 1358 CXFA_DocumentParser::~CXFA_DocumentParser() {
1360 CloseParser(); 1359 CloseParser();
1361 } 1360 }
1362 1361
1363 void CXFA_DocumentParser::Release() { 1362 void CXFA_DocumentParser::Release() {
1364 delete this; 1363 delete this;
1365 } 1364 }
1366 int32_t CXFA_DocumentParser::StartParse(IFX_FileRead* pStream, 1365 int32_t CXFA_DocumentParser::StartParse(IFX_FileRead* pStream,
1367 XFA_XDPPACKET ePacketID) { 1366 XFA_XDPPACKET ePacketID) {
1368 CloseParser(); 1367 CloseParser();
1369 int32_t nRetStatus = m_nodeParser.StartParse(pStream, ePacketID); 1368 int32_t nRetStatus = m_nodeParser.StartParse(pStream, ePacketID);
1370 if (nRetStatus == XFA_PARSESTATUS_Ready) { 1369 if (nRetStatus == XFA_PARSESTATUS_Ready) {
1371 m_pDocument = new CXFA_Document(this); 1370 m_pDocument = new CXFA_Document(this);
1372 m_nodeParser.SetFactory(m_pDocument); 1371 m_nodeParser.SetFactory(m_pDocument);
1373 } 1372 }
1374 return nRetStatus; 1373 return nRetStatus;
1375 } 1374 }
1376 int32_t CXFA_DocumentParser::DoParse(IFX_Pause* pPause) { 1375 int32_t CXFA_DocumentParser::DoParse(IFX_Pause* pPause) {
1377 int32_t nRetStatus = m_nodeParser.DoParse(pPause); 1376 int32_t nRetStatus = m_nodeParser.DoParse(pPause);
1378 if (nRetStatus >= XFA_PARSESTATUS_Done) { 1377 if (nRetStatus >= XFA_PARSESTATUS_Done) {
1379 ASSERT(m_pDocument); 1378 ASSERT(m_pDocument);
1380 m_pDocument->SetRoot(m_nodeParser.GetRootNode()); 1379 m_pDocument->SetRoot(m_nodeParser.GetRootNode());
1381 } 1380 }
1382 return nRetStatus; 1381 return nRetStatus;
1383 } 1382 }
1384 int32_t CXFA_DocumentParser::ParseXMLData(const CFX_WideString& wsXML, 1383 int32_t CXFA_DocumentParser::ParseXMLData(const CFX_WideString& wsXML,
1385 CFDE_XMLNode*& pXMLNode, 1384 CFDE_XMLNode*& pXMLNode,
1386 IFX_Pause* pPause) { 1385 IFX_Pause* pPause) {
1387 CloseParser(); 1386 CloseParser();
1388 int32_t nRetStatus = m_nodeParser.ParseXMLData(wsXML, pXMLNode, NULL); 1387 int32_t nRetStatus = m_nodeParser.ParseXMLData(wsXML, pXMLNode, nullptr);
1389 if (nRetStatus == XFA_PARSESTATUS_Done && pXMLNode) { 1388 if (nRetStatus == XFA_PARSESTATUS_Done && pXMLNode) {
1390 m_pDocument = new CXFA_Document(this); 1389 m_pDocument = new CXFA_Document(this);
1391 m_nodeParser.SetFactory(m_pDocument); 1390 m_nodeParser.SetFactory(m_pDocument);
1392 } 1391 }
1393 return nRetStatus; 1392 return nRetStatus;
1394 } 1393 }
1395 void CXFA_DocumentParser::ConstructXFANode(CXFA_Node* pXFANode, 1394 void CXFA_DocumentParser::ConstructXFANode(CXFA_Node* pXFANode,
1396 CFDE_XMLNode* pXMLNode) { 1395 CFDE_XMLNode* pXMLNode) {
1397 if (!pXFANode || !pXMLNode) { 1396 if (!pXFANode || !pXMLNode) {
1398 return; 1397 return;
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
1514 m_pChild = m_pParent; 1513 m_pChild = m_pParent;
1515 iCount++; 1514 iCount++;
1516 break; 1515 break;
1517 case FDE_XmlSyntaxResult::TargetName: 1516 case FDE_XmlSyntaxResult::TargetName:
1518 m_pParser->GetTargetName(m_ws1); 1517 m_pParser->GetTargetName(m_ws1);
1519 if (m_ws1 == FX_WSTRC(L"originalXFAVersion") || 1518 if (m_ws1 == FX_WSTRC(L"originalXFAVersion") ||
1520 m_ws1 == FX_WSTRC(L"acrobat")) { 1519 m_ws1 == FX_WSTRC(L"acrobat")) {
1521 m_pChild = new CFDE_XMLInstruction(m_ws1); 1520 m_pChild = new CFDE_XMLInstruction(m_ws1);
1522 m_pParent->InsertChildNode(m_pChild); 1521 m_pParent->InsertChildNode(m_pChild);
1523 } else { 1522 } else {
1524 m_pChild = NULL; 1523 m_pChild = nullptr;
1525 } 1524 }
1526 m_ws1.clear(); 1525 m_ws1.clear();
1527 break; 1526 break;
1528 case FDE_XmlSyntaxResult::TagName: 1527 case FDE_XmlSyntaxResult::TagName:
1529 m_pParser->GetTagName(m_ws1); 1528 m_pParser->GetTagName(m_ws1);
1530 m_pChild = new CFDE_XMLElement(m_ws1); 1529 m_pChild = new CFDE_XMLElement(m_ws1);
1531 m_pParent->InsertChildNode(m_pChild); 1530 m_pParent->InsertChildNode(m_pChild);
1532 m_NodeStack.Push(m_pChild); 1531 m_NodeStack.Push(m_pChild);
1533 m_pParent = m_pChild; 1532 m_pParent = m_pChild;
1534 1533
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
1595 } 1594 }
1596 if (pPause && iCount > 500 && pPause->NeedToPauseNow()) { 1595 if (pPause && iCount > 500 && pPause->NeedToPauseNow()) {
1597 break; 1596 break;
1598 } 1597 }
1599 } 1598 }
1600 return (m_syntaxParserResult == FDE_XmlSyntaxResult::Error || 1599 return (m_syntaxParserResult == FDE_XmlSyntaxResult::Error ||
1601 m_NodeStack.GetSize() != 1) 1600 m_NodeStack.GetSize() != 1)
1602 ? -1 1601 ? -1
1603 : m_pParser->GetStatus(); 1602 : m_pParser->GetStatus();
1604 } 1603 }
OLDNEW
« no previous file with comments | « xfa/fxfa/parser/xfa_parser_imp.h ('k') | xfa/fxfa/parser/xfa_script.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698