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 #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 26 matching lines...) Expand all Loading... |
37 CXFA_SimpleParser::~CXFA_SimpleParser() { | 37 CXFA_SimpleParser::~CXFA_SimpleParser() { |
38 CloseParser(); | 38 CloseParser(); |
39 } | 39 } |
40 void CXFA_SimpleParser::SetFactory(CXFA_Document* pFactory) { | 40 void CXFA_SimpleParser::SetFactory(CXFA_Document* pFactory) { |
41 m_pFactory = pFactory; | 41 m_pFactory = pFactory; |
42 } | 42 } |
43 static CFDE_XMLNode* XFA_FDEExtension_GetDocumentNode( | 43 static CFDE_XMLNode* XFA_FDEExtension_GetDocumentNode( |
44 CFDE_XMLDoc* pXMLDoc, | 44 CFDE_XMLDoc* pXMLDoc, |
45 FX_BOOL bVerifyWellFormness = FALSE) { | 45 FX_BOOL bVerifyWellFormness = FALSE) { |
46 if (!pXMLDoc) { | 46 if (!pXMLDoc) { |
47 return NULL; | 47 return nullptr; |
48 } | 48 } |
49 CFDE_XMLNode* pXMLFakeRoot = pXMLDoc->GetRoot(); | 49 CFDE_XMLNode* pXMLFakeRoot = pXMLDoc->GetRoot(); |
50 for (CFDE_XMLNode* pXMLNode = | 50 for (CFDE_XMLNode* pXMLNode = |
51 pXMLFakeRoot->GetNodeItem(CFDE_XMLNode::FirstChild); | 51 pXMLFakeRoot->GetNodeItem(CFDE_XMLNode::FirstChild); |
52 pXMLNode; pXMLNode = pXMLNode->GetNodeItem(CFDE_XMLNode::NextSibling)) { | 52 pXMLNode; pXMLNode = pXMLNode->GetNodeItem(CFDE_XMLNode::NextSibling)) { |
53 if (pXMLNode->GetType() == FDE_XMLNODE_Element) { | 53 if (pXMLNode->GetType() == FDE_XMLNODE_Element) { |
54 if (bVerifyWellFormness) { | 54 if (bVerifyWellFormness) { |
55 for (CFDE_XMLNode* pNextNode = | 55 for (CFDE_XMLNode* pNextNode = |
56 pXMLNode->GetNodeItem(CFDE_XMLNode::NextSibling); | 56 pXMLNode->GetNodeItem(CFDE_XMLNode::NextSibling); |
57 pNextNode; | 57 pNextNode; |
58 pNextNode = pNextNode->GetNodeItem(CFDE_XMLNode::NextSibling)) { | 58 pNextNode = pNextNode->GetNodeItem(CFDE_XMLNode::NextSibling)) { |
59 if (pNextNode->GetType() == FDE_XMLNODE_Element) { | 59 if (pNextNode->GetType() == FDE_XMLNODE_Element) { |
60 return FALSE; | 60 return FALSE; |
61 } | 61 } |
62 } | 62 } |
63 } | 63 } |
64 return pXMLNode; | 64 return pXMLNode; |
65 } | 65 } |
66 } | 66 } |
67 return NULL; | 67 return nullptr; |
68 } | 68 } |
69 int32_t CXFA_SimpleParser::StartParse(IFX_FileRead* pStream, | 69 int32_t CXFA_SimpleParser::StartParse(IFX_FileRead* pStream, |
70 XFA_XDPPACKET ePacketID) { | 70 XFA_XDPPACKET ePacketID) { |
71 CloseParser(); | 71 CloseParser(); |
72 m_pFileRead = pStream; | 72 m_pFileRead = pStream; |
73 m_pStream = IFX_Stream::CreateStream( | 73 m_pStream = IFX_Stream::CreateStream( |
74 pStream, FX_STREAMACCESS_Read | FX_STREAMACCESS_Text); | 74 pStream, FX_STREAMACCESS_Read | FX_STREAMACCESS_Text); |
75 if (m_pStream == NULL) { | 75 if (!m_pStream) |
76 return XFA_PARSESTATUS_StreamErr; | 76 return XFA_PARSESTATUS_StreamErr; |
77 } | 77 |
78 uint16_t wCodePage = m_pStream->GetCodePage(); | 78 uint16_t wCodePage = m_pStream->GetCodePage(); |
79 if (wCodePage != FX_CODEPAGE_UTF16LE && wCodePage != FX_CODEPAGE_UTF16BE && | 79 if (wCodePage != FX_CODEPAGE_UTF16LE && wCodePage != FX_CODEPAGE_UTF16BE && |
80 wCodePage != FX_CODEPAGE_UTF8) { | 80 wCodePage != FX_CODEPAGE_UTF8) { |
81 m_pStream->SetCodePage(FX_CODEPAGE_UTF8); | 81 m_pStream->SetCodePage(FX_CODEPAGE_UTF8); |
82 } | 82 } |
83 m_pXMLDoc = new CFDE_XMLDoc; | 83 m_pXMLDoc = new CFDE_XMLDoc; |
84 m_pXMLParser = new CXFA_XMLParser(m_pXMLDoc->GetRoot(), m_pStream); | 84 m_pXMLParser = new CXFA_XMLParser(m_pXMLDoc->GetRoot(), m_pStream); |
85 if (!m_pXMLDoc->LoadXML(m_pXMLParser)) { | 85 if (!m_pXMLDoc->LoadXML(m_pXMLParser)) { |
86 return XFA_PARSESTATUS_StatusErr; | 86 return XFA_PARSESTATUS_StatusErr; |
87 } | 87 } |
88 m_ePacketID = ePacketID; | 88 m_ePacketID = ePacketID; |
89 return XFA_PARSESTATUS_Ready; | 89 return XFA_PARSESTATUS_Ready; |
90 } | 90 } |
91 int32_t CXFA_SimpleParser::DoParse(IFX_Pause* pPause) { | 91 int32_t CXFA_SimpleParser::DoParse(IFX_Pause* pPause) { |
92 if (m_pXMLDoc == NULL || m_ePacketID == XFA_XDPPACKET_UNKNOWN) { | 92 if (!m_pXMLDoc || m_ePacketID == XFA_XDPPACKET_UNKNOWN) |
93 return XFA_PARSESTATUS_StatusErr; | 93 return XFA_PARSESTATUS_StatusErr; |
94 } | 94 |
95 int32_t iRet = m_pXMLDoc->DoLoad(pPause); | 95 int32_t iRet = m_pXMLDoc->DoLoad(pPause); |
96 if (iRet < 0) { | 96 if (iRet < 0) { |
97 return XFA_PARSESTATUS_SyntaxErr; | 97 return XFA_PARSESTATUS_SyntaxErr; |
98 } | 98 } |
99 if (iRet < 100) { | 99 if (iRet < 100) { |
100 return iRet / 2; | 100 return iRet / 2; |
101 } | 101 } |
102 m_pRootNode = ParseAsXDPPacket(XFA_FDEExtension_GetDocumentNode(m_pXMLDoc), | 102 m_pRootNode = ParseAsXDPPacket(XFA_FDEExtension_GetDocumentNode(m_pXMLDoc), |
103 m_ePacketID); | 103 m_ePacketID); |
104 m_pXMLDoc->CloseXML(); | 104 m_pXMLDoc->CloseXML(); |
105 if (m_pStream) { | 105 if (m_pStream) { |
106 m_pStream->Release(); | 106 m_pStream->Release(); |
107 m_pStream = NULL; | 107 m_pStream = nullptr; |
108 } | 108 } |
109 if (!m_pRootNode) { | 109 if (!m_pRootNode) { |
110 return XFA_PARSESTATUS_StatusErr; | 110 return XFA_PARSESTATUS_StatusErr; |
111 } | 111 } |
112 return XFA_PARSESTATUS_Done; | 112 return XFA_PARSESTATUS_Done; |
113 } | 113 } |
114 int32_t CXFA_SimpleParser::ParseXMLData(const CFX_WideString& wsXML, | 114 int32_t CXFA_SimpleParser::ParseXMLData(const CFX_WideString& wsXML, |
115 CFDE_XMLNode*& pXMLNode, | 115 CFDE_XMLNode*& pXMLNode, |
116 IFX_Pause* pPause) { | 116 IFX_Pause* pPause) { |
117 CloseParser(); | 117 CloseParser(); |
118 pXMLNode = NULL; | 118 pXMLNode = nullptr; |
119 IFX_Stream* pStream = XFA_CreateWideTextRead(wsXML); | 119 IFX_Stream* pStream = XFA_CreateWideTextRead(wsXML); |
120 if (!pStream) { | 120 if (!pStream) { |
121 return XFA_PARSESTATUS_StreamErr; | 121 return XFA_PARSESTATUS_StreamErr; |
122 } | 122 } |
123 m_pStream = pStream; | 123 m_pStream = pStream; |
124 m_pXMLDoc = new CFDE_XMLDoc; | 124 m_pXMLDoc = new CFDE_XMLDoc; |
125 CXFA_XMLParser* pParser = new CXFA_XMLParser(m_pXMLDoc->GetRoot(), m_pStream); | 125 CXFA_XMLParser* pParser = new CXFA_XMLParser(m_pXMLDoc->GetRoot(), m_pStream); |
126 pParser->m_dwCheckStatus = 0x03; | 126 pParser->m_dwCheckStatus = 0x03; |
127 if (!m_pXMLDoc->LoadXML(pParser)) { | 127 if (!m_pXMLDoc->LoadXML(pParser)) { |
128 return XFA_PARSESTATUS_StatusErr; | 128 return XFA_PARSESTATUS_StatusErr; |
129 } | 129 } |
130 int32_t iRet = m_pXMLDoc->DoLoad(pPause); | 130 int32_t iRet = m_pXMLDoc->DoLoad(pPause); |
131 if (iRet < 0 || iRet >= 100) { | 131 if (iRet < 0 || iRet >= 100) { |
132 m_pXMLDoc->CloseXML(); | 132 m_pXMLDoc->CloseXML(); |
133 } | 133 } |
134 if (iRet < 0) { | 134 if (iRet < 0) { |
135 return XFA_PARSESTATUS_SyntaxErr; | 135 return XFA_PARSESTATUS_SyntaxErr; |
136 } | 136 } |
137 if (iRet < 100) { | 137 if (iRet < 100) { |
138 return iRet / 2; | 138 return iRet / 2; |
139 } | 139 } |
140 if (m_pStream) { | 140 if (m_pStream) { |
141 m_pStream->Release(); | 141 m_pStream->Release(); |
142 m_pStream = NULL; | 142 m_pStream = nullptr; |
143 } | 143 } |
144 pXMLNode = XFA_FDEExtension_GetDocumentNode(m_pXMLDoc); | 144 pXMLNode = XFA_FDEExtension_GetDocumentNode(m_pXMLDoc); |
145 return XFA_PARSESTATUS_Done; | 145 return XFA_PARSESTATUS_Done; |
146 } | 146 } |
147 | 147 |
148 void CXFA_SimpleParser::ConstructXFANode(CXFA_Node* pXFANode, | 148 void CXFA_SimpleParser::ConstructXFANode(CXFA_Node* pXFANode, |
149 CFDE_XMLNode* pXMLNode) { | 149 CFDE_XMLNode* pXMLNode) { |
150 XFA_XDPPACKET ePacketID = (XFA_XDPPACKET)pXFANode->GetPacketID(); | 150 XFA_XDPPACKET ePacketID = (XFA_XDPPACKET)pXFANode->GetPacketID(); |
151 if (ePacketID == XFA_XDPPACKET_Datasets) { | 151 if (ePacketID == XFA_XDPPACKET_Datasets) { |
152 if (pXFANode->GetClassID() == XFA_ELEMENT_DataValue) { | 152 if (pXFANode->GetClassID() == XFA_ELEMENT_DataValue) { |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 } | 334 } |
335 wsValue = wsAttrValue; | 335 wsValue = wsAttrValue; |
336 return TRUE; | 336 return TRUE; |
337 } | 337 } |
338 return FALSE; | 338 return FALSE; |
339 } | 339 } |
340 CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket(CFDE_XMLNode* pXMLDocumentNode, | 340 CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket(CFDE_XMLNode* pXMLDocumentNode, |
341 XFA_XDPPACKET ePacketID) { | 341 XFA_XDPPACKET ePacketID) { |
342 switch (ePacketID) { | 342 switch (ePacketID) { |
343 case XFA_XDPPACKET_UNKNOWN: | 343 case XFA_XDPPACKET_UNKNOWN: |
344 return NULL; | 344 return nullptr; |
345 case XFA_XDPPACKET_XDP: | 345 case XFA_XDPPACKET_XDP: |
346 return ParseAsXDPPacket_XDP(pXMLDocumentNode, ePacketID); | 346 return ParseAsXDPPacket_XDP(pXMLDocumentNode, ePacketID); |
347 case XFA_XDPPACKET_Config: | 347 case XFA_XDPPACKET_Config: |
348 return ParseAsXDPPacket_Config(pXMLDocumentNode, ePacketID); | 348 return ParseAsXDPPacket_Config(pXMLDocumentNode, ePacketID); |
349 case XFA_XDPPACKET_Template: | 349 case XFA_XDPPACKET_Template: |
350 case XFA_XDPPACKET_Form: | 350 case XFA_XDPPACKET_Form: |
351 return ParseAsXDPPacket_TemplateForm(pXMLDocumentNode, ePacketID); | 351 return ParseAsXDPPacket_TemplateForm(pXMLDocumentNode, ePacketID); |
352 case XFA_XDPPACKET_Datasets: | 352 case XFA_XDPPACKET_Datasets: |
353 return ParseAsXDPPacket_Data(pXMLDocumentNode, ePacketID); | 353 return ParseAsXDPPacket_Data(pXMLDocumentNode, ePacketID); |
354 case XFA_XDPPACKET_Xdc: | 354 case XFA_XDPPACKET_Xdc: |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 pPacketInfo->pURI, | 404 pPacketInfo->pURI, |
405 pPacketInfo->eFlags)) { | 405 pPacketInfo->eFlags)) { |
406 continue; | 406 continue; |
407 } | 407 } |
408 if (pXFARootNode->GetFirstChildByName(pPacketInfo->uHash)) { | 408 if (pXFARootNode->GetFirstChildByName(pPacketInfo->uHash)) { |
409 return nullptr; | 409 return nullptr; |
410 } | 410 } |
411 pXMLConfigDOMRoot = pChildItem; | 411 pXMLConfigDOMRoot = pChildItem; |
412 pXFAConfigDOMRoot = | 412 pXFAConfigDOMRoot = |
413 ParseAsXDPPacket_Config(pXMLConfigDOMRoot, XFA_XDPPACKET_Config); | 413 ParseAsXDPPacket_Config(pXMLConfigDOMRoot, XFA_XDPPACKET_Config); |
414 pXFARootNode->InsertChild(pXFAConfigDOMRoot, NULL); | 414 pXFARootNode->InsertChild(pXFAConfigDOMRoot, nullptr); |
415 } | 415 } |
416 } | 416 } |
417 CFDE_XMLNode* pXMLDatasetsDOMRoot = nullptr; | 417 CFDE_XMLNode* pXMLDatasetsDOMRoot = nullptr; |
418 CFDE_XMLNode* pXMLFormDOMRoot = nullptr; | 418 CFDE_XMLNode* pXMLFormDOMRoot = nullptr; |
419 CFDE_XMLNode* pXMLTemplateDOMRoot = nullptr; | 419 CFDE_XMLNode* pXMLTemplateDOMRoot = nullptr; |
420 { | 420 { |
421 for (CFDE_XMLNode* pChildItem = | 421 for (CFDE_XMLNode* pChildItem = |
422 pXMLDocumentNode->GetNodeItem(CFDE_XMLNode::FirstChild); | 422 pXMLDocumentNode->GetNodeItem(CFDE_XMLNode::FirstChild); |
423 pChildItem; | 423 pChildItem; |
424 pChildItem = pChildItem->GetNodeItem(CFDE_XMLNode::NextSibling)) { | 424 pChildItem = pChildItem->GetNodeItem(CFDE_XMLNode::NextSibling)) { |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
500 pXFARootNode->SetXMLMappingNode(pXMLDocumentNode); | 500 pXFARootNode->SetXMLMappingNode(pXMLDocumentNode); |
501 return pXFARootNode; | 501 return pXFARootNode; |
502 } | 502 } |
503 CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_Config( | 503 CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_Config( |
504 CFDE_XMLNode* pXMLDocumentNode, | 504 CFDE_XMLNode* pXMLDocumentNode, |
505 XFA_XDPPACKET ePacketID) { | 505 XFA_XDPPACKET ePacketID) { |
506 if (!XFA_FDEExtension_MatchNodeName( | 506 if (!XFA_FDEExtension_MatchNodeName( |
507 pXMLDocumentNode, XFA_GetPacketByIndex(XFA_PACKET_Config)->pName, | 507 pXMLDocumentNode, XFA_GetPacketByIndex(XFA_PACKET_Config)->pName, |
508 XFA_GetPacketByIndex(XFA_PACKET_Config)->pURI, | 508 XFA_GetPacketByIndex(XFA_PACKET_Config)->pURI, |
509 XFA_GetPacketByIndex(XFA_PACKET_Config)->eFlags)) { | 509 XFA_GetPacketByIndex(XFA_PACKET_Config)->eFlags)) { |
510 return NULL; | 510 return nullptr; |
511 } | 511 } |
512 CXFA_Node* pNode = | 512 CXFA_Node* pNode = |
513 m_pFactory->CreateNode(XFA_XDPPACKET_Config, XFA_ELEMENT_Config); | 513 m_pFactory->CreateNode(XFA_XDPPACKET_Config, XFA_ELEMENT_Config); |
514 if (!pNode) { | 514 if (!pNode) { |
515 return NULL; | 515 return nullptr; |
516 } | 516 } |
517 pNode->SetCData(XFA_ATTRIBUTE_Name, | 517 pNode->SetCData(XFA_ATTRIBUTE_Name, |
518 XFA_GetPacketByIndex(XFA_PACKET_Config)->pName); | 518 XFA_GetPacketByIndex(XFA_PACKET_Config)->pName); |
519 if (!NormalLoader(pNode, pXMLDocumentNode, ePacketID)) { | 519 if (!NormalLoader(pNode, pXMLDocumentNode, ePacketID)) { |
520 return NULL; | 520 return nullptr; |
521 } | 521 } |
522 pNode->SetXMLMappingNode(pXMLDocumentNode); | 522 pNode->SetXMLMappingNode(pXMLDocumentNode); |
523 return pNode; | 523 return pNode; |
524 } | 524 } |
525 CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_TemplateForm( | 525 CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_TemplateForm( |
526 CFDE_XMLNode* pXMLDocumentNode, | 526 CFDE_XMLNode* pXMLDocumentNode, |
527 XFA_XDPPACKET ePacketID) { | 527 XFA_XDPPACKET ePacketID) { |
528 CXFA_Node* pNode = NULL; | 528 CXFA_Node* pNode = nullptr; |
529 if (ePacketID == XFA_XDPPACKET_Template) { | 529 if (ePacketID == XFA_XDPPACKET_Template) { |
530 if (XFA_FDEExtension_MatchNodeName( | 530 if (XFA_FDEExtension_MatchNodeName( |
531 pXMLDocumentNode, XFA_GetPacketByIndex(XFA_PACKET_Template)->pName, | 531 pXMLDocumentNode, XFA_GetPacketByIndex(XFA_PACKET_Template)->pName, |
532 XFA_GetPacketByIndex(XFA_PACKET_Template)->pURI, | 532 XFA_GetPacketByIndex(XFA_PACKET_Template)->pURI, |
533 XFA_GetPacketByIndex(XFA_PACKET_Template)->eFlags)) { | 533 XFA_GetPacketByIndex(XFA_PACKET_Template)->eFlags)) { |
534 pNode = | 534 pNode = |
535 m_pFactory->CreateNode(XFA_XDPPACKET_Template, XFA_ELEMENT_Template); | 535 m_pFactory->CreateNode(XFA_XDPPACKET_Template, XFA_ELEMENT_Template); |
536 if (!pNode) { | 536 if (!pNode) { |
537 return NULL; | 537 return nullptr; |
538 } | 538 } |
539 pNode->SetCData(XFA_ATTRIBUTE_Name, | 539 pNode->SetCData(XFA_ATTRIBUTE_Name, |
540 XFA_GetPacketByIndex(XFA_PACKET_Template)->pName); | 540 XFA_GetPacketByIndex(XFA_PACKET_Template)->pName); |
541 if (m_bDocumentParser) { | 541 if (m_bDocumentParser) { |
542 CFX_WideString wsNamespaceURI; | 542 CFX_WideString wsNamespaceURI; |
543 CFDE_XMLElement* pXMLDocumentElement = | 543 CFDE_XMLElement* pXMLDocumentElement = |
544 static_cast<CFDE_XMLElement*>(pXMLDocumentNode); | 544 static_cast<CFDE_XMLElement*>(pXMLDocumentNode); |
545 pXMLDocumentElement->GetNamespaceURI(wsNamespaceURI); | 545 pXMLDocumentElement->GetNamespaceURI(wsNamespaceURI); |
546 if (wsNamespaceURI.IsEmpty()) { | 546 if (wsNamespaceURI.IsEmpty()) { |
547 pXMLDocumentElement->GetString(L"xmlns:xfa", wsNamespaceURI); | 547 pXMLDocumentElement->GetString(L"xmlns:xfa", wsNamespaceURI); |
548 } | 548 } |
549 pNode->GetDocument()->RecognizeXFAVersionNumber(wsNamespaceURI); | 549 pNode->GetDocument()->RecognizeXFAVersionNumber(wsNamespaceURI); |
550 } | 550 } |
551 if (!NormalLoader(pNode, pXMLDocumentNode, ePacketID)) { | 551 if (!NormalLoader(pNode, pXMLDocumentNode, ePacketID)) { |
552 return NULL; | 552 return nullptr; |
553 } | 553 } |
554 } | 554 } |
555 } else if (ePacketID == XFA_XDPPACKET_Form) { | 555 } else if (ePacketID == XFA_XDPPACKET_Form) { |
556 if (XFA_FDEExtension_MatchNodeName( | 556 if (XFA_FDEExtension_MatchNodeName( |
557 pXMLDocumentNode, XFA_GetPacketByIndex(XFA_PACKET_Form)->pName, | 557 pXMLDocumentNode, XFA_GetPacketByIndex(XFA_PACKET_Form)->pName, |
558 XFA_GetPacketByIndex(XFA_PACKET_Form)->pURI, | 558 XFA_GetPacketByIndex(XFA_PACKET_Form)->pURI, |
559 XFA_GetPacketByIndex(XFA_PACKET_Form)->eFlags)) { | 559 XFA_GetPacketByIndex(XFA_PACKET_Form)->eFlags)) { |
560 CFDE_XMLElement* pXMLDocumentElement = | 560 CFDE_XMLElement* pXMLDocumentElement = |
561 static_cast<CFDE_XMLElement*>(pXMLDocumentNode); | 561 static_cast<CFDE_XMLElement*>(pXMLDocumentNode); |
562 CFX_WideString wsChecksum; | 562 CFX_WideString wsChecksum; |
563 pXMLDocumentElement->GetString(L"checksum", wsChecksum); | 563 pXMLDocumentElement->GetString(L"checksum", wsChecksum); |
564 if (wsChecksum.GetLength() != 28 || | 564 if (wsChecksum.GetLength() != 28 || |
565 m_pXMLParser->m_dwCheckStatus != 0x03) { | 565 m_pXMLParser->m_dwCheckStatus != 0x03) { |
566 return NULL; | 566 return nullptr; |
567 } | 567 } |
568 std::unique_ptr<CXFA_ChecksumContext> pChecksum(new CXFA_ChecksumContext); | 568 std::unique_ptr<CXFA_ChecksumContext> pChecksum(new CXFA_ChecksumContext); |
569 pChecksum->StartChecksum(); | 569 pChecksum->StartChecksum(); |
570 pChecksum->UpdateChecksum(m_pFileRead, m_pXMLParser->m_nStart[0], | 570 pChecksum->UpdateChecksum(m_pFileRead, m_pXMLParser->m_nStart[0], |
571 m_pXMLParser->m_nSize[0]); | 571 m_pXMLParser->m_nSize[0]); |
572 pChecksum->UpdateChecksum(m_pFileRead, m_pXMLParser->m_nStart[1], | 572 pChecksum->UpdateChecksum(m_pFileRead, m_pXMLParser->m_nStart[1], |
573 m_pXMLParser->m_nSize[1]); | 573 m_pXMLParser->m_nSize[1]); |
574 pChecksum->FinishChecksum(); | 574 pChecksum->FinishChecksum(); |
575 CFX_ByteString bsCheck = pChecksum->GetChecksum(); | 575 CFX_ByteString bsCheck = pChecksum->GetChecksum(); |
576 if (bsCheck != wsChecksum.UTF8Encode()) | 576 if (bsCheck != wsChecksum.UTF8Encode()) |
577 return nullptr; | 577 return nullptr; |
578 | 578 |
579 pNode = m_pFactory->CreateNode(XFA_XDPPACKET_Form, XFA_ELEMENT_Form); | 579 pNode = m_pFactory->CreateNode(XFA_XDPPACKET_Form, XFA_ELEMENT_Form); |
580 if (!pNode) | 580 if (!pNode) |
581 return nullptr; | 581 return nullptr; |
582 | 582 |
583 pNode->SetCData(XFA_ATTRIBUTE_Name, | 583 pNode->SetCData(XFA_ATTRIBUTE_Name, |
584 XFA_GetPacketByIndex(XFA_PACKET_Form)->pName); | 584 XFA_GetPacketByIndex(XFA_PACKET_Form)->pName); |
585 pNode->SetAttribute(XFA_ATTRIBUTE_Checksum, wsChecksum.AsStringC()); | 585 pNode->SetAttribute(XFA_ATTRIBUTE_Checksum, wsChecksum.AsStringC()); |
586 CXFA_Node* pTemplateRoot = | 586 CXFA_Node* pTemplateRoot = |
587 m_pRootNode->GetFirstChildByClass(XFA_ELEMENT_Template); | 587 m_pRootNode->GetFirstChildByClass(XFA_ELEMENT_Template); |
588 CXFA_Node* pTemplateChosen = | 588 CXFA_Node* pTemplateChosen = |
589 pTemplateRoot | 589 pTemplateRoot |
590 ? pTemplateRoot->GetFirstChildByClass(XFA_ELEMENT_Subform) | 590 ? pTemplateRoot->GetFirstChildByClass(XFA_ELEMENT_Subform) |
591 : NULL; | 591 : nullptr; |
592 FX_BOOL bUseAttribute = TRUE; | 592 FX_BOOL bUseAttribute = TRUE; |
593 if (pTemplateChosen && | 593 if (pTemplateChosen && |
594 pTemplateChosen->GetEnum(XFA_ATTRIBUTE_RestoreState) != | 594 pTemplateChosen->GetEnum(XFA_ATTRIBUTE_RestoreState) != |
595 XFA_ATTRIBUTEENUM_Auto) { | 595 XFA_ATTRIBUTEENUM_Auto) { |
596 bUseAttribute = FALSE; | 596 bUseAttribute = FALSE; |
597 } | 597 } |
598 if (!NormalLoader(pNode, pXMLDocumentNode, ePacketID, bUseAttribute)) { | 598 if (!NormalLoader(pNode, pXMLDocumentNode, ePacketID, bUseAttribute)) { |
599 return NULL; | 599 return nullptr; |
600 } | 600 } |
601 } | 601 } |
602 } | 602 } |
603 if (pNode) { | 603 if (pNode) { |
604 pNode->SetXMLMappingNode(pXMLDocumentNode); | 604 pNode->SetXMLMappingNode(pXMLDocumentNode); |
605 } | 605 } |
606 return pNode; | 606 return pNode; |
607 } | 607 } |
608 static CFDE_XMLNode* XFA_GetDataSetsFromXDP(CFDE_XMLNode* pXMLDocumentNode) { | 608 static CFDE_XMLNode* XFA_GetDataSetsFromXDP(CFDE_XMLNode* pXMLDocumentNode) { |
609 if (XFA_FDEExtension_MatchNodeName( | 609 if (XFA_FDEExtension_MatchNodeName( |
610 pXMLDocumentNode, XFA_GetPacketByIndex(XFA_PACKET_Datasets)->pName, | 610 pXMLDocumentNode, XFA_GetPacketByIndex(XFA_PACKET_Datasets)->pName, |
611 XFA_GetPacketByIndex(XFA_PACKET_Datasets)->pURI, | 611 XFA_GetPacketByIndex(XFA_PACKET_Datasets)->pURI, |
612 XFA_GetPacketByIndex(XFA_PACKET_Datasets)->eFlags)) { | 612 XFA_GetPacketByIndex(XFA_PACKET_Datasets)->eFlags)) { |
613 return pXMLDocumentNode; | 613 return pXMLDocumentNode; |
614 } | 614 } |
615 if (!XFA_FDEExtension_MatchNodeName( | 615 if (!XFA_FDEExtension_MatchNodeName( |
616 pXMLDocumentNode, XFA_GetPacketByIndex(XFA_PACKET_XDP)->pName, | 616 pXMLDocumentNode, XFA_GetPacketByIndex(XFA_PACKET_XDP)->pName, |
617 XFA_GetPacketByIndex(XFA_PACKET_XDP)->pURI, | 617 XFA_GetPacketByIndex(XFA_PACKET_XDP)->pURI, |
618 XFA_GetPacketByIndex(XFA_PACKET_XDP)->eFlags)) { | 618 XFA_GetPacketByIndex(XFA_PACKET_XDP)->eFlags)) { |
619 return NULL; | 619 return nullptr; |
620 } | 620 } |
621 for (CFDE_XMLNode* pDatasetsNode = | 621 for (CFDE_XMLNode* pDatasetsNode = |
622 pXMLDocumentNode->GetNodeItem(CFDE_XMLNode::FirstChild); | 622 pXMLDocumentNode->GetNodeItem(CFDE_XMLNode::FirstChild); |
623 pDatasetsNode; | 623 pDatasetsNode; |
624 pDatasetsNode = pDatasetsNode->GetNodeItem(CFDE_XMLNode::NextSibling)) { | 624 pDatasetsNode = pDatasetsNode->GetNodeItem(CFDE_XMLNode::NextSibling)) { |
625 if (!XFA_FDEExtension_MatchNodeName( | 625 if (!XFA_FDEExtension_MatchNodeName( |
626 pDatasetsNode, XFA_GetPacketByIndex(XFA_PACKET_Datasets)->pName, | 626 pDatasetsNode, XFA_GetPacketByIndex(XFA_PACKET_Datasets)->pName, |
627 XFA_GetPacketByIndex(XFA_PACKET_Datasets)->pURI, | 627 XFA_GetPacketByIndex(XFA_PACKET_Datasets)->pURI, |
628 XFA_GetPacketByIndex(XFA_PACKET_Datasets)->eFlags)) { | 628 XFA_GetPacketByIndex(XFA_PACKET_Datasets)->eFlags)) { |
629 continue; | 629 continue; |
630 } | 630 } |
631 return pDatasetsNode; | 631 return pDatasetsNode; |
632 } | 632 } |
633 return NULL; | 633 return nullptr; |
634 } | 634 } |
635 CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_Data( | 635 CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_Data( |
636 CFDE_XMLNode* pXMLDocumentNode, | 636 CFDE_XMLNode* pXMLDocumentNode, |
637 XFA_XDPPACKET ePacketID) { | 637 XFA_XDPPACKET ePacketID) { |
638 CFDE_XMLNode* pDatasetsXMLNode = XFA_GetDataSetsFromXDP(pXMLDocumentNode); | 638 CFDE_XMLNode* pDatasetsXMLNode = XFA_GetDataSetsFromXDP(pXMLDocumentNode); |
639 if (pDatasetsXMLNode) { | 639 if (pDatasetsXMLNode) { |
640 CXFA_Node* pNode = | 640 CXFA_Node* pNode = |
641 m_pFactory->CreateNode(XFA_XDPPACKET_Datasets, XFA_ELEMENT_DataModel); | 641 m_pFactory->CreateNode(XFA_XDPPACKET_Datasets, XFA_ELEMENT_DataModel); |
642 if (!pNode) { | 642 if (!pNode) { |
643 return NULL; | 643 return nullptr; |
644 } | 644 } |
645 pNode->SetCData(XFA_ATTRIBUTE_Name, | 645 pNode->SetCData(XFA_ATTRIBUTE_Name, |
646 XFA_GetPacketByIndex(XFA_PACKET_Datasets)->pName); | 646 XFA_GetPacketByIndex(XFA_PACKET_Datasets)->pName); |
647 if (!DataLoader(pNode, pDatasetsXMLNode, FALSE)) { | 647 if (!DataLoader(pNode, pDatasetsXMLNode, FALSE)) { |
648 return NULL; | 648 return nullptr; |
649 } | 649 } |
650 pNode->SetXMLMappingNode(pDatasetsXMLNode); | 650 pNode->SetXMLMappingNode(pDatasetsXMLNode); |
651 return pNode; | 651 return pNode; |
652 } | 652 } |
653 CFDE_XMLNode* pDataXMLNode = NULL; | 653 CFDE_XMLNode* pDataXMLNode = nullptr; |
654 if (XFA_FDEExtension_MatchNodeName( | 654 if (XFA_FDEExtension_MatchNodeName( |
655 pXMLDocumentNode, FX_WSTRC(L"data"), | 655 pXMLDocumentNode, FX_WSTRC(L"data"), |
656 XFA_GetPacketByIndex(XFA_PACKET_Datasets)->pURI, | 656 XFA_GetPacketByIndex(XFA_PACKET_Datasets)->pURI, |
657 XFA_GetPacketByIndex(XFA_PACKET_Datasets)->eFlags)) { | 657 XFA_GetPacketByIndex(XFA_PACKET_Datasets)->eFlags)) { |
658 static_cast<CFDE_XMLElement*>(pXMLDocumentNode) | 658 static_cast<CFDE_XMLElement*>(pXMLDocumentNode) |
659 ->RemoveAttribute(L"xmlns:xfa"); | 659 ->RemoveAttribute(L"xmlns:xfa"); |
660 pDataXMLNode = pXMLDocumentNode; | 660 pDataXMLNode = pXMLDocumentNode; |
661 } else { | 661 } else { |
662 CFDE_XMLElement* pDataElement = new CFDE_XMLElement(L"xfa:data"); | 662 CFDE_XMLElement* pDataElement = new CFDE_XMLElement(L"xfa:data"); |
663 CFDE_XMLNode* pParentXMLNode = | 663 CFDE_XMLNode* pParentXMLNode = |
664 pXMLDocumentNode->GetNodeItem(CFDE_XMLNode::Parent); | 664 pXMLDocumentNode->GetNodeItem(CFDE_XMLNode::Parent); |
665 if (pParentXMLNode) { | 665 if (pParentXMLNode) { |
666 pParentXMLNode->RemoveChildNode(pXMLDocumentNode); | 666 pParentXMLNode->RemoveChildNode(pXMLDocumentNode); |
667 } | 667 } |
668 ASSERT(pXMLDocumentNode->GetType() == FDE_XMLNODE_Element); | 668 ASSERT(pXMLDocumentNode->GetType() == FDE_XMLNODE_Element); |
669 if (pXMLDocumentNode->GetType() == FDE_XMLNODE_Element) { | 669 if (pXMLDocumentNode->GetType() == FDE_XMLNODE_Element) { |
670 static_cast<CFDE_XMLElement*>(pXMLDocumentNode) | 670 static_cast<CFDE_XMLElement*>(pXMLDocumentNode) |
671 ->RemoveAttribute(L"xmlns:xfa"); | 671 ->RemoveAttribute(L"xmlns:xfa"); |
672 } | 672 } |
673 pDataElement->InsertChildNode(pXMLDocumentNode); | 673 pDataElement->InsertChildNode(pXMLDocumentNode); |
674 pDataXMLNode = pDataElement; | 674 pDataXMLNode = pDataElement; |
675 } | 675 } |
676 if (pDataXMLNode) { | 676 if (pDataXMLNode) { |
677 CXFA_Node* pNode = | 677 CXFA_Node* pNode = |
678 m_pFactory->CreateNode(XFA_XDPPACKET_Datasets, XFA_ELEMENT_DataGroup); | 678 m_pFactory->CreateNode(XFA_XDPPACKET_Datasets, XFA_ELEMENT_DataGroup); |
679 if (!pNode) { | 679 if (!pNode) { |
680 if (pDataXMLNode != pXMLDocumentNode) { | 680 if (pDataXMLNode != pXMLDocumentNode) { |
681 pDataXMLNode->Release(); | 681 pDataXMLNode->Release(); |
682 } | 682 } |
683 return NULL; | 683 return nullptr; |
684 } | 684 } |
685 CFX_WideString wsLocalName; | 685 CFX_WideString wsLocalName; |
686 static_cast<CFDE_XMLElement*>(pDataXMLNode)->GetLocalTagName(wsLocalName); | 686 static_cast<CFDE_XMLElement*>(pDataXMLNode)->GetLocalTagName(wsLocalName); |
687 pNode->SetCData(XFA_ATTRIBUTE_Name, wsLocalName); | 687 pNode->SetCData(XFA_ATTRIBUTE_Name, wsLocalName); |
688 if (!DataLoader(pNode, pDataXMLNode, TRUE)) { | 688 if (!DataLoader(pNode, pDataXMLNode, TRUE)) { |
689 return NULL; | 689 return nullptr; |
690 } | 690 } |
691 pNode->SetXMLMappingNode(pDataXMLNode); | 691 pNode->SetXMLMappingNode(pDataXMLNode); |
692 if (pDataXMLNode != pXMLDocumentNode) { | 692 if (pDataXMLNode != pXMLDocumentNode) { |
693 pNode->SetFlag(XFA_NODEFLAG_OwnXMLNode, false); | 693 pNode->SetFlag(XFA_NODEFLAG_OwnXMLNode, false); |
694 } | 694 } |
695 return pNode; | 695 return pNode; |
696 } | 696 } |
697 return NULL; | 697 return nullptr; |
698 } | 698 } |
699 CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_LocaleConnectionSourceSet( | 699 CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_LocaleConnectionSourceSet( |
700 CFDE_XMLNode* pXMLDocumentNode, | 700 CFDE_XMLNode* pXMLDocumentNode, |
701 XFA_XDPPACKET ePacketID) { | 701 XFA_XDPPACKET ePacketID) { |
702 CXFA_Node* pNode = NULL; | 702 CXFA_Node* pNode = nullptr; |
703 if (ePacketID == XFA_XDPPACKET_LocaleSet) { | 703 if (ePacketID == XFA_XDPPACKET_LocaleSet) { |
704 if (XFA_FDEExtension_MatchNodeName( | 704 if (XFA_FDEExtension_MatchNodeName( |
705 pXMLDocumentNode, XFA_GetPacketByIndex(XFA_PACKET_LocaleSet)->pName, | 705 pXMLDocumentNode, XFA_GetPacketByIndex(XFA_PACKET_LocaleSet)->pName, |
706 XFA_GetPacketByIndex(XFA_PACKET_LocaleSet)->pURI, | 706 XFA_GetPacketByIndex(XFA_PACKET_LocaleSet)->pURI, |
707 XFA_GetPacketByIndex(XFA_PACKET_LocaleSet)->eFlags)) { | 707 XFA_GetPacketByIndex(XFA_PACKET_LocaleSet)->eFlags)) { |
708 pNode = m_pFactory->CreateNode(XFA_XDPPACKET_LocaleSet, | 708 pNode = m_pFactory->CreateNode(XFA_XDPPACKET_LocaleSet, |
709 XFA_ELEMENT_LocaleSet); | 709 XFA_ELEMENT_LocaleSet); |
710 if (!pNode) { | 710 if (!pNode) { |
711 return NULL; | 711 return nullptr; |
712 } | 712 } |
713 pNode->SetCData(XFA_ATTRIBUTE_Name, | 713 pNode->SetCData(XFA_ATTRIBUTE_Name, |
714 XFA_GetPacketByIndex(XFA_PACKET_LocaleSet)->pName); | 714 XFA_GetPacketByIndex(XFA_PACKET_LocaleSet)->pName); |
715 if (!NormalLoader(pNode, pXMLDocumentNode, ePacketID)) { | 715 if (!NormalLoader(pNode, pXMLDocumentNode, ePacketID)) { |
716 return NULL; | 716 return nullptr; |
717 } | 717 } |
718 } | 718 } |
719 } else if (ePacketID == XFA_XDPPACKET_ConnectionSet) { | 719 } else if (ePacketID == XFA_XDPPACKET_ConnectionSet) { |
720 if (XFA_FDEExtension_MatchNodeName( | 720 if (XFA_FDEExtension_MatchNodeName( |
721 pXMLDocumentNode, | 721 pXMLDocumentNode, |
722 XFA_GetPacketByIndex(XFA_PACKET_ConnectionSet)->pName, | 722 XFA_GetPacketByIndex(XFA_PACKET_ConnectionSet)->pName, |
723 XFA_GetPacketByIndex(XFA_PACKET_ConnectionSet)->pURI, | 723 XFA_GetPacketByIndex(XFA_PACKET_ConnectionSet)->pURI, |
724 XFA_GetPacketByIndex(XFA_PACKET_ConnectionSet)->eFlags)) { | 724 XFA_GetPacketByIndex(XFA_PACKET_ConnectionSet)->eFlags)) { |
725 pNode = m_pFactory->CreateNode(XFA_XDPPACKET_ConnectionSet, | 725 pNode = m_pFactory->CreateNode(XFA_XDPPACKET_ConnectionSet, |
726 XFA_ELEMENT_ConnectionSet); | 726 XFA_ELEMENT_ConnectionSet); |
727 if (!pNode) { | 727 if (!pNode) { |
728 return NULL; | 728 return nullptr; |
729 } | 729 } |
730 pNode->SetCData(XFA_ATTRIBUTE_Name, | 730 pNode->SetCData(XFA_ATTRIBUTE_Name, |
731 XFA_GetPacketByIndex(XFA_PACKET_ConnectionSet)->pName); | 731 XFA_GetPacketByIndex(XFA_PACKET_ConnectionSet)->pName); |
732 if (!NormalLoader(pNode, pXMLDocumentNode, ePacketID)) { | 732 if (!NormalLoader(pNode, pXMLDocumentNode, ePacketID)) { |
733 return NULL; | 733 return nullptr; |
734 } | 734 } |
735 } | 735 } |
736 } else if (ePacketID == XFA_XDPPACKET_SourceSet) { | 736 } else if (ePacketID == XFA_XDPPACKET_SourceSet) { |
737 if (XFA_FDEExtension_MatchNodeName( | 737 if (XFA_FDEExtension_MatchNodeName( |
738 pXMLDocumentNode, XFA_GetPacketByIndex(XFA_PACKET_SourceSet)->pName, | 738 pXMLDocumentNode, XFA_GetPacketByIndex(XFA_PACKET_SourceSet)->pName, |
739 XFA_GetPacketByIndex(XFA_PACKET_SourceSet)->pURI, | 739 XFA_GetPacketByIndex(XFA_PACKET_SourceSet)->pURI, |
740 XFA_GetPacketByIndex(XFA_PACKET_SourceSet)->eFlags)) { | 740 XFA_GetPacketByIndex(XFA_PACKET_SourceSet)->eFlags)) { |
741 pNode = m_pFactory->CreateNode(XFA_XDPPACKET_SourceSet, | 741 pNode = m_pFactory->CreateNode(XFA_XDPPACKET_SourceSet, |
742 XFA_ELEMENT_SourceSet); | 742 XFA_ELEMENT_SourceSet); |
743 if (!pNode) { | 743 if (!pNode) { |
744 return NULL; | 744 return nullptr; |
745 } | 745 } |
746 pNode->SetCData(XFA_ATTRIBUTE_Name, | 746 pNode->SetCData(XFA_ATTRIBUTE_Name, |
747 XFA_GetPacketByIndex(XFA_PACKET_SourceSet)->pName); | 747 XFA_GetPacketByIndex(XFA_PACKET_SourceSet)->pName); |
748 if (!NormalLoader(pNode, pXMLDocumentNode, ePacketID)) { | 748 if (!NormalLoader(pNode, pXMLDocumentNode, ePacketID)) { |
749 return NULL; | 749 return nullptr; |
750 } | 750 } |
751 } | 751 } |
752 } | 752 } |
753 if (pNode) { | 753 if (pNode) { |
754 pNode->SetXMLMappingNode(pXMLDocumentNode); | 754 pNode->SetXMLMappingNode(pXMLDocumentNode); |
755 } | 755 } |
756 return pNode; | 756 return pNode; |
757 } | 757 } |
758 CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_Xdc( | 758 CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_Xdc( |
759 CFDE_XMLNode* pXMLDocumentNode, | 759 CFDE_XMLNode* pXMLDocumentNode, |
760 XFA_XDPPACKET ePacketID) { | 760 XFA_XDPPACKET ePacketID) { |
761 if (XFA_FDEExtension_MatchNodeName( | 761 if (XFA_FDEExtension_MatchNodeName( |
762 pXMLDocumentNode, XFA_GetPacketByIndex(XFA_PACKET_Xdc)->pName, | 762 pXMLDocumentNode, XFA_GetPacketByIndex(XFA_PACKET_Xdc)->pName, |
763 XFA_GetPacketByIndex(XFA_PACKET_Xdc)->pURI, | 763 XFA_GetPacketByIndex(XFA_PACKET_Xdc)->pURI, |
764 XFA_GetPacketByIndex(XFA_PACKET_Xdc)->eFlags)) { | 764 XFA_GetPacketByIndex(XFA_PACKET_Xdc)->eFlags)) { |
765 CXFA_Node* pNode = | 765 CXFA_Node* pNode = |
766 m_pFactory->CreateNode(XFA_XDPPACKET_Xdc, XFA_ELEMENT_Xdc); | 766 m_pFactory->CreateNode(XFA_XDPPACKET_Xdc, XFA_ELEMENT_Xdc); |
767 if (!pNode) { | 767 if (!pNode) { |
768 return NULL; | 768 return nullptr; |
769 } | 769 } |
770 pNode->SetCData(XFA_ATTRIBUTE_Name, | 770 pNode->SetCData(XFA_ATTRIBUTE_Name, |
771 XFA_GetPacketByIndex(XFA_PACKET_Xdc)->pName); | 771 XFA_GetPacketByIndex(XFA_PACKET_Xdc)->pName); |
772 pNode->SetXMLMappingNode(pXMLDocumentNode); | 772 pNode->SetXMLMappingNode(pXMLDocumentNode); |
773 return pNode; | 773 return pNode; |
774 } | 774 } |
775 return NULL; | 775 return nullptr; |
776 } | 776 } |
777 CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_User( | 777 CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_User( |
778 CFDE_XMLNode* pXMLDocumentNode, | 778 CFDE_XMLNode* pXMLDocumentNode, |
779 XFA_XDPPACKET ePacketID) { | 779 XFA_XDPPACKET ePacketID) { |
780 CXFA_Node* pNode = | 780 CXFA_Node* pNode = |
781 m_pFactory->CreateNode(XFA_XDPPACKET_XDP, XFA_ELEMENT_Packet); | 781 m_pFactory->CreateNode(XFA_XDPPACKET_XDP, XFA_ELEMENT_Packet); |
782 if (!pNode) { | 782 if (!pNode) { |
783 return NULL; | 783 return nullptr; |
784 } | 784 } |
785 CFX_WideString wsName; | 785 CFX_WideString wsName; |
786 static_cast<CFDE_XMLElement*>(pXMLDocumentNode)->GetLocalTagName(wsName); | 786 static_cast<CFDE_XMLElement*>(pXMLDocumentNode)->GetLocalTagName(wsName); |
787 pNode->SetCData(XFA_ATTRIBUTE_Name, wsName); | 787 pNode->SetCData(XFA_ATTRIBUTE_Name, wsName); |
788 if (!UserPacketLoader(pNode, pXMLDocumentNode)) { | 788 if (!UserPacketLoader(pNode, pXMLDocumentNode)) { |
789 return NULL; | 789 return nullptr; |
790 } | 790 } |
791 pNode->SetXMLMappingNode(pXMLDocumentNode); | 791 pNode->SetXMLMappingNode(pXMLDocumentNode); |
792 return pNode; | 792 return pNode; |
793 } | 793 } |
794 CXFA_Node* CXFA_SimpleParser::UserPacketLoader(CXFA_Node* pXFANode, | 794 CXFA_Node* CXFA_SimpleParser::UserPacketLoader(CXFA_Node* pXFANode, |
795 CFDE_XMLNode* pXMLDoc) { | 795 CFDE_XMLNode* pXMLDoc) { |
796 return pXFANode; | 796 return pXFANode; |
797 } | 797 } |
798 static FX_BOOL XFA_FDEExtension_IsStringAllWhitespace(CFX_WideString wsText) { | 798 static FX_BOOL XFA_FDEExtension_IsStringAllWhitespace(CFX_WideString wsText) { |
799 wsText.TrimRight(L"\x20\x9\xD\xA"); | 799 wsText.TrimRight(L"\x20\x9\xD\xA"); |
(...skipping 28 matching lines...) Expand all Loading... |
828 if (pPropertyInfo && | 828 if (pPropertyInfo && |
829 ((pPropertyInfo->uFlags & | 829 ((pPropertyInfo->uFlags & |
830 (XFA_PROPERTYFLAG_OneOf | XFA_PROPERTYFLAG_DefaultOneOf)) != 0)) { | 830 (XFA_PROPERTYFLAG_OneOf | XFA_PROPERTYFLAG_DefaultOneOf)) != 0)) { |
831 if (bOneOfPropertyFound) { | 831 if (bOneOfPropertyFound) { |
832 break; | 832 break; |
833 } | 833 } |
834 bOneOfPropertyFound = TRUE; | 834 bOneOfPropertyFound = TRUE; |
835 } | 835 } |
836 CXFA_Node* pXFAChild = | 836 CXFA_Node* pXFAChild = |
837 m_pFactory->CreateNode(ePacketID, pElemInfo->eName); | 837 m_pFactory->CreateNode(ePacketID, pElemInfo->eName); |
838 if (pXFAChild == NULL) { | 838 if (!pXFAChild) |
839 return NULL; | 839 return nullptr; |
840 } | 840 |
841 if (ePacketID == XFA_XDPPACKET_Config) { | 841 if (ePacketID == XFA_XDPPACKET_Config) { |
842 pXFAChild->SetAttribute(XFA_ATTRIBUTE_Name, wsTagName.AsStringC()); | 842 pXFAChild->SetAttribute(XFA_ATTRIBUTE_Name, wsTagName.AsStringC()); |
843 } | 843 } |
844 FX_BOOL IsNeedValue = TRUE; | 844 FX_BOOL IsNeedValue = TRUE; |
845 for (int32_t i = 0, count = pXMLElement->CountAttributes(); i < count; | 845 for (int32_t i = 0, count = pXMLElement->CountAttributes(); i < count; |
846 i++) { | 846 i++) { |
847 CFX_WideString wsAttrQualifiedName; | 847 CFX_WideString wsAttrQualifiedName; |
848 CFX_WideString wsAttrName; | 848 CFX_WideString wsAttrName; |
849 CFX_WideString wsAttrValue; | 849 CFX_WideString wsAttrValue; |
850 pXMLElement->GetAttribute(i, wsAttrQualifiedName, wsAttrValue); | 850 pXMLElement->GetAttribute(i, wsAttrQualifiedName, wsAttrValue); |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1083 break; | 1083 break; |
1084 } | 1084 } |
1085 } | 1085 } |
1086 } | 1086 } |
1087 } | 1087 } |
1088 if (eNodeType == XFA_ELEMENT_DataModel) { | 1088 if (eNodeType == XFA_ELEMENT_DataModel) { |
1089 eNodeType = XFA_ELEMENT_DataValue; | 1089 eNodeType = XFA_ELEMENT_DataValue; |
1090 } | 1090 } |
1091 CXFA_Node* pXFAChild = | 1091 CXFA_Node* pXFAChild = |
1092 m_pFactory->CreateNode(XFA_XDPPACKET_Datasets, eNodeType); | 1092 m_pFactory->CreateNode(XFA_XDPPACKET_Datasets, eNodeType); |
1093 if (pXFAChild == NULL) { | 1093 if (!pXFAChild) |
1094 return; | 1094 return; |
1095 } | 1095 |
1096 CFX_WideString wsNodeName; | 1096 CFX_WideString wsNodeName; |
1097 pXMLElement->GetLocalTagName(wsNodeName); | 1097 pXMLElement->GetLocalTagName(wsNodeName); |
1098 pXFAChild->SetCData(XFA_ATTRIBUTE_Name, wsNodeName); | 1098 pXFAChild->SetCData(XFA_ATTRIBUTE_Name, wsNodeName); |
1099 FX_BOOL bNeedValue = TRUE; | 1099 FX_BOOL bNeedValue = TRUE; |
1100 if (1) { | 1100 if (1) { |
1101 for (int32_t i = 0, count = pXMLElement->CountAttributes(); i < count; | 1101 for (int32_t i = 0, count = pXMLElement->CountAttributes(); i < count; |
1102 i++) { | 1102 i++) { |
1103 CFX_WideString wsAttrQualifiedName; | 1103 CFX_WideString wsAttrQualifiedName; |
1104 CFX_WideString wsAttrValue; | 1104 CFX_WideString wsAttrValue; |
1105 CFX_WideString wsAttrName; | 1105 CFX_WideString wsAttrName; |
(...skipping 17 matching lines...) Expand all Loading... |
1123 FX_WSTRC(L"http://www.w3.org/2001/XMLSchema-instance") || | 1123 FX_WSTRC(L"http://www.w3.org/2001/XMLSchema-instance") || |
1124 wsAttrNamespaceURI == | 1124 wsAttrNamespaceURI == |
1125 FX_WSTRC(L"http://www.xfa.org/schema/xfa-data/1.0/")) { | 1125 FX_WSTRC(L"http://www.xfa.org/schema/xfa-data/1.0/")) { |
1126 continue; | 1126 continue; |
1127 } | 1127 } |
1128 if (0) { | 1128 if (0) { |
1129 continue; | 1129 continue; |
1130 } | 1130 } |
1131 CXFA_Node* pXFAMetaData = m_pFactory->CreateNode( | 1131 CXFA_Node* pXFAMetaData = m_pFactory->CreateNode( |
1132 XFA_XDPPACKET_Datasets, XFA_ELEMENT_DataValue); | 1132 XFA_XDPPACKET_Datasets, XFA_ELEMENT_DataValue); |
1133 if (pXFAMetaData == NULL) { | 1133 if (!pXFAMetaData) |
1134 return; | 1134 return; |
1135 } | 1135 |
1136 pXFAMetaData->SetCData(XFA_ATTRIBUTE_Name, wsAttrName); | 1136 pXFAMetaData->SetCData(XFA_ATTRIBUTE_Name, wsAttrName); |
1137 pXFAMetaData->SetCData(XFA_ATTRIBUTE_QualifiedName, | 1137 pXFAMetaData->SetCData(XFA_ATTRIBUTE_QualifiedName, |
1138 wsAttrQualifiedName); | 1138 wsAttrQualifiedName); |
1139 pXFAMetaData->SetCData(XFA_ATTRIBUTE_Value, wsAttrValue); | 1139 pXFAMetaData->SetCData(XFA_ATTRIBUTE_Value, wsAttrValue); |
1140 pXFAMetaData->SetEnum(XFA_ATTRIBUTE_Contains, | 1140 pXFAMetaData->SetEnum(XFA_ATTRIBUTE_Contains, |
1141 XFA_ATTRIBUTEENUM_MetaData); | 1141 XFA_ATTRIBUTEENUM_MetaData); |
1142 pXFAChild->InsertChild(pXFAMetaData); | 1142 pXFAChild->InsertChild(pXFAMetaData); |
1143 pXFAMetaData->SetXMLMappingNode(pXMLElement); | 1143 pXFAMetaData->SetXMLMappingNode(pXMLElement); |
1144 pXFAMetaData->SetFlag(XFA_NODEFLAG_Initialized, false); | 1144 pXFAMetaData->SetFlag(XFA_NODEFLAG_Initialized, false); |
1145 } | 1145 } |
(...skipping 17 matching lines...) Expand all Loading... |
1163 case FDE_XMLNODE_CharData: { | 1163 case FDE_XMLNODE_CharData: { |
1164 CFDE_XMLCharData* pXMLCharData = | 1164 CFDE_XMLCharData* pXMLCharData = |
1165 static_cast<CFDE_XMLCharData*>(pXMLChild); | 1165 static_cast<CFDE_XMLCharData*>(pXMLChild); |
1166 CFX_WideString wsCharData; | 1166 CFX_WideString wsCharData; |
1167 pXMLCharData->GetCharData(wsCharData); | 1167 pXMLCharData->GetCharData(wsCharData); |
1168 if (XFA_FDEExtension_IsStringAllWhitespace(wsCharData)) { | 1168 if (XFA_FDEExtension_IsStringAllWhitespace(wsCharData)) { |
1169 continue; | 1169 continue; |
1170 } | 1170 } |
1171 CXFA_Node* pXFAChild = m_pFactory->CreateNode(XFA_XDPPACKET_Datasets, | 1171 CXFA_Node* pXFAChild = m_pFactory->CreateNode(XFA_XDPPACKET_Datasets, |
1172 XFA_ELEMENT_DataValue); | 1172 XFA_ELEMENT_DataValue); |
1173 if (pXFAChild == NULL) { | 1173 if (!pXFAChild) |
1174 return; | 1174 return; |
1175 } | 1175 |
1176 pXFAChild->SetCData(XFA_ATTRIBUTE_Value, wsCharData); | 1176 pXFAChild->SetCData(XFA_ATTRIBUTE_Value, wsCharData); |
1177 pXFANode->InsertChild(pXFAChild); | 1177 pXFANode->InsertChild(pXFAChild); |
1178 pXFAChild->SetXMLMappingNode(pXMLCharData); | 1178 pXFAChild->SetXMLMappingNode(pXMLCharData); |
1179 pXFAChild->SetFlag(XFA_NODEFLAG_Initialized, false); | 1179 pXFAChild->SetFlag(XFA_NODEFLAG_Initialized, false); |
1180 } | 1180 } |
1181 continue; | 1181 continue; |
1182 case FDE_XMLNODE_Text: { | 1182 case FDE_XMLNODE_Text: { |
1183 CFDE_XMLText* pXMLText = static_cast<CFDE_XMLText*>(pXMLChild); | 1183 CFDE_XMLText* pXMLText = static_cast<CFDE_XMLText*>(pXMLChild); |
1184 CFX_WideString wsText; | 1184 CFX_WideString wsText; |
1185 pXMLText->GetText(wsText); | 1185 pXMLText->GetText(wsText); |
1186 if (XFA_FDEExtension_IsStringAllWhitespace(wsText)) { | 1186 if (XFA_FDEExtension_IsStringAllWhitespace(wsText)) { |
1187 continue; | 1187 continue; |
1188 } | 1188 } |
1189 CXFA_Node* pXFAChild = m_pFactory->CreateNode(XFA_XDPPACKET_Datasets, | 1189 CXFA_Node* pXFAChild = m_pFactory->CreateNode(XFA_XDPPACKET_Datasets, |
1190 XFA_ELEMENT_DataValue); | 1190 XFA_ELEMENT_DataValue); |
1191 if (pXFAChild == NULL) { | 1191 if (!pXFAChild) |
1192 return; | 1192 return; |
1193 } | 1193 |
1194 pXFAChild->SetCData(XFA_ATTRIBUTE_Value, wsText); | 1194 pXFAChild->SetCData(XFA_ATTRIBUTE_Value, wsText); |
1195 pXFANode->InsertChild(pXFAChild); | 1195 pXFANode->InsertChild(pXFAChild); |
1196 pXFAChild->SetXMLMappingNode(pXMLText); | 1196 pXFAChild->SetXMLMappingNode(pXMLText); |
1197 pXFAChild->SetFlag(XFA_NODEFLAG_Initialized, false); | 1197 pXFAChild->SetFlag(XFA_NODEFLAG_Initialized, false); |
1198 } | 1198 } |
1199 continue; | 1199 continue; |
1200 case FDE_XMLNODE_Instruction: | 1200 case FDE_XMLNODE_Instruction: |
1201 continue; | 1201 continue; |
1202 default: | 1202 default: |
1203 continue; | 1203 continue; |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1327 if (pXMLInstruction->GetData(1, wsData) && | 1327 if (pXMLInstruction->GetData(1, wsData) && |
1328 wsData == FX_WSTRC(L"strictScoping")) { | 1328 wsData == FX_WSTRC(L"strictScoping")) { |
1329 pXFANode->GetDocument()->SetFlag(XFA_DOCFLAG_StrictScoping, TRUE); | 1329 pXFANode->GetDocument()->SetFlag(XFA_DOCFLAG_StrictScoping, TRUE); |
1330 } | 1330 } |
1331 } | 1331 } |
1332 } | 1332 } |
1333 } | 1333 } |
1334 void CXFA_SimpleParser::CloseParser() { | 1334 void CXFA_SimpleParser::CloseParser() { |
1335 if (m_pXMLDoc) { | 1335 if (m_pXMLDoc) { |
1336 m_pXMLDoc->Release(); | 1336 m_pXMLDoc->Release(); |
1337 m_pXMLDoc = NULL; | 1337 m_pXMLDoc = nullptr; |
1338 } | 1338 } |
1339 if (m_pStream) { | 1339 if (m_pStream) { |
1340 m_pStream->Release(); | 1340 m_pStream->Release(); |
1341 m_pStream = NULL; | 1341 m_pStream = nullptr; |
1342 } | 1342 } |
1343 } | 1343 } |
1344 | 1344 |
1345 CXFA_DocumentParser::CXFA_DocumentParser(CXFA_FFNotify* pNotify) | 1345 CXFA_DocumentParser::CXFA_DocumentParser(CXFA_FFNotify* pNotify) |
1346 : m_nodeParser(NULL, TRUE), m_pNotify(pNotify), m_pDocument(NULL) {} | 1346 : m_nodeParser(nullptr, TRUE), m_pNotify(pNotify), m_pDocument(nullptr) {} |
1347 CXFA_DocumentParser::~CXFA_DocumentParser() { | 1347 CXFA_DocumentParser::~CXFA_DocumentParser() { |
1348 CloseParser(); | 1348 CloseParser(); |
1349 } | 1349 } |
1350 int32_t CXFA_DocumentParser::StartParse(IFX_FileRead* pStream, | 1350 int32_t CXFA_DocumentParser::StartParse(IFX_FileRead* pStream, |
1351 XFA_XDPPACKET ePacketID) { | 1351 XFA_XDPPACKET ePacketID) { |
1352 CloseParser(); | 1352 CloseParser(); |
1353 int32_t nRetStatus = m_nodeParser.StartParse(pStream, ePacketID); | 1353 int32_t nRetStatus = m_nodeParser.StartParse(pStream, ePacketID); |
1354 if (nRetStatus == XFA_PARSESTATUS_Ready) { | 1354 if (nRetStatus == XFA_PARSESTATUS_Ready) { |
1355 m_pDocument = new CXFA_Document(this); | 1355 m_pDocument = new CXFA_Document(this); |
1356 m_nodeParser.SetFactory(m_pDocument); | 1356 m_nodeParser.SetFactory(m_pDocument); |
1357 } | 1357 } |
1358 return nRetStatus; | 1358 return nRetStatus; |
1359 } | 1359 } |
1360 int32_t CXFA_DocumentParser::DoParse(IFX_Pause* pPause) { | 1360 int32_t CXFA_DocumentParser::DoParse(IFX_Pause* pPause) { |
1361 int32_t nRetStatus = m_nodeParser.DoParse(pPause); | 1361 int32_t nRetStatus = m_nodeParser.DoParse(pPause); |
1362 if (nRetStatus >= XFA_PARSESTATUS_Done) { | 1362 if (nRetStatus >= XFA_PARSESTATUS_Done) { |
1363 ASSERT(m_pDocument); | 1363 ASSERT(m_pDocument); |
1364 m_pDocument->SetRoot(m_nodeParser.GetRootNode()); | 1364 m_pDocument->SetRoot(m_nodeParser.GetRootNode()); |
1365 } | 1365 } |
1366 return nRetStatus; | 1366 return nRetStatus; |
1367 } | 1367 } |
1368 int32_t CXFA_DocumentParser::ParseXMLData(const CFX_WideString& wsXML, | 1368 int32_t CXFA_DocumentParser::ParseXMLData(const CFX_WideString& wsXML, |
1369 CFDE_XMLNode*& pXMLNode, | 1369 CFDE_XMLNode*& pXMLNode, |
1370 IFX_Pause* pPause) { | 1370 IFX_Pause* pPause) { |
1371 CloseParser(); | 1371 CloseParser(); |
1372 int32_t nRetStatus = m_nodeParser.ParseXMLData(wsXML, pXMLNode, NULL); | 1372 int32_t nRetStatus = m_nodeParser.ParseXMLData(wsXML, pXMLNode, nullptr); |
1373 if (nRetStatus == XFA_PARSESTATUS_Done && pXMLNode) { | 1373 if (nRetStatus == XFA_PARSESTATUS_Done && pXMLNode) { |
1374 m_pDocument = new CXFA_Document(this); | 1374 m_pDocument = new CXFA_Document(this); |
1375 m_nodeParser.SetFactory(m_pDocument); | 1375 m_nodeParser.SetFactory(m_pDocument); |
1376 } | 1376 } |
1377 return nRetStatus; | 1377 return nRetStatus; |
1378 } | 1378 } |
1379 void CXFA_DocumentParser::ConstructXFANode(CXFA_Node* pXFANode, | 1379 void CXFA_DocumentParser::ConstructXFANode(CXFA_Node* pXFANode, |
1380 CFDE_XMLNode* pXMLNode) { | 1380 CFDE_XMLNode* pXMLNode) { |
1381 if (!pXFANode || !pXMLNode) { | 1381 if (!pXFANode || !pXMLNode) { |
1382 return; | 1382 return; |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1472 m_pChild = m_pParent; | 1472 m_pChild = m_pParent; |
1473 iCount++; | 1473 iCount++; |
1474 break; | 1474 break; |
1475 case FDE_XmlSyntaxResult::TargetName: | 1475 case FDE_XmlSyntaxResult::TargetName: |
1476 m_pParser->GetTargetName(m_ws1); | 1476 m_pParser->GetTargetName(m_ws1); |
1477 if (m_ws1 == FX_WSTRC(L"originalXFAVersion") || | 1477 if (m_ws1 == FX_WSTRC(L"originalXFAVersion") || |
1478 m_ws1 == FX_WSTRC(L"acrobat")) { | 1478 m_ws1 == FX_WSTRC(L"acrobat")) { |
1479 m_pChild = new CFDE_XMLInstruction(m_ws1); | 1479 m_pChild = new CFDE_XMLInstruction(m_ws1); |
1480 m_pParent->InsertChildNode(m_pChild); | 1480 m_pParent->InsertChildNode(m_pChild); |
1481 } else { | 1481 } else { |
1482 m_pChild = NULL; | 1482 m_pChild = nullptr; |
1483 } | 1483 } |
1484 m_ws1.clear(); | 1484 m_ws1.clear(); |
1485 break; | 1485 break; |
1486 case FDE_XmlSyntaxResult::TagName: | 1486 case FDE_XmlSyntaxResult::TagName: |
1487 m_pParser->GetTagName(m_ws1); | 1487 m_pParser->GetTagName(m_ws1); |
1488 m_pChild = new CFDE_XMLElement(m_ws1); | 1488 m_pChild = new CFDE_XMLElement(m_ws1); |
1489 m_pParent->InsertChildNode(m_pChild); | 1489 m_pParent->InsertChildNode(m_pChild); |
1490 m_NodeStack.Push(m_pChild); | 1490 m_NodeStack.Push(m_pChild); |
1491 m_pParent = m_pChild; | 1491 m_pParent = m_pChild; |
1492 | 1492 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1553 } | 1553 } |
1554 if (pPause && iCount > 500 && pPause->NeedToPauseNow()) { | 1554 if (pPause && iCount > 500 && pPause->NeedToPauseNow()) { |
1555 break; | 1555 break; |
1556 } | 1556 } |
1557 } | 1557 } |
1558 return (m_syntaxParserResult == FDE_XmlSyntaxResult::Error || | 1558 return (m_syntaxParserResult == FDE_XmlSyntaxResult::Error || |
1559 m_NodeStack.GetSize() != 1) | 1559 m_NodeStack.GetSize() != 1) |
1560 ? -1 | 1560 ? -1 |
1561 : m_pParser->GetStatus(); | 1561 : m_pParser->GetStatus(); |
1562 } | 1562 } |
OLD | NEW |