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 29 matching lines...) Expand all Loading... |
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 Loading... |
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 Loading... |
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 Loading... |
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 28 matching lines...) Expand all Loading... |
843 if (pPropertyInfo && | 843 if (pPropertyInfo && |
844 ((pPropertyInfo->uFlags & | 844 ((pPropertyInfo->uFlags & |
845 (XFA_PROPERTYFLAG_OneOf | XFA_PROPERTYFLAG_DefaultOneOf)) != 0)) { | 845 (XFA_PROPERTYFLAG_OneOf | XFA_PROPERTYFLAG_DefaultOneOf)) != 0)) { |
846 if (bOneOfPropertyFound) { | 846 if (bOneOfPropertyFound) { |
847 break; | 847 break; |
848 } | 848 } |
849 bOneOfPropertyFound = TRUE; | 849 bOneOfPropertyFound = TRUE; |
850 } | 850 } |
851 CXFA_Node* pXFAChild = | 851 CXFA_Node* pXFAChild = |
852 m_pFactory->CreateNode(ePacketID, pElemInfo->eName); | 852 m_pFactory->CreateNode(ePacketID, pElemInfo->eName); |
853 if (pXFAChild == NULL) { | 853 if (!pXFAChild) { |
854 return NULL; | 854 return nullptr; |
855 } | 855 } |
856 if (ePacketID == XFA_XDPPACKET_Config) { | 856 if (ePacketID == XFA_XDPPACKET_Config) { |
857 pXFAChild->SetAttribute(XFA_ATTRIBUTE_Name, wsTagName.AsStringC()); | 857 pXFAChild->SetAttribute(XFA_ATTRIBUTE_Name, wsTagName.AsStringC()); |
858 } | 858 } |
859 FX_BOOL IsNeedValue = TRUE; | 859 FX_BOOL IsNeedValue = TRUE; |
860 for (int32_t i = 0, count = pXMLElement->CountAttributes(); i < count; | 860 for (int32_t i = 0, count = pXMLElement->CountAttributes(); i < count; |
861 i++) { | 861 i++) { |
862 CFX_WideString wsAttrQualifiedName; | 862 CFX_WideString wsAttrQualifiedName; |
863 CFX_WideString wsAttrName; | 863 CFX_WideString wsAttrName; |
864 CFX_WideString wsAttrValue; | 864 CFX_WideString wsAttrValue; |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1098 break; | 1098 break; |
1099 } | 1099 } |
1100 } | 1100 } |
1101 } | 1101 } |
1102 } | 1102 } |
1103 if (eNodeType == XFA_Element::DataModel) { | 1103 if (eNodeType == XFA_Element::DataModel) { |
1104 eNodeType = XFA_Element::DataValue; | 1104 eNodeType = XFA_Element::DataValue; |
1105 } | 1105 } |
1106 CXFA_Node* pXFAChild = | 1106 CXFA_Node* pXFAChild = |
1107 m_pFactory->CreateNode(XFA_XDPPACKET_Datasets, eNodeType); | 1107 m_pFactory->CreateNode(XFA_XDPPACKET_Datasets, eNodeType); |
1108 if (pXFAChild == NULL) { | 1108 if (!pXFAChild) { |
1109 return; | 1109 return; |
1110 } | 1110 } |
1111 CFX_WideString wsNodeName; | 1111 CFX_WideString wsNodeName; |
1112 pXMLElement->GetLocalTagName(wsNodeName); | 1112 pXMLElement->GetLocalTagName(wsNodeName); |
1113 pXFAChild->SetCData(XFA_ATTRIBUTE_Name, wsNodeName); | 1113 pXFAChild->SetCData(XFA_ATTRIBUTE_Name, wsNodeName); |
1114 FX_BOOL bNeedValue = TRUE; | 1114 FX_BOOL bNeedValue = TRUE; |
1115 if (1) { | 1115 if (1) { |
1116 for (int32_t i = 0, count = pXMLElement->CountAttributes(); i < count; | 1116 for (int32_t i = 0, count = pXMLElement->CountAttributes(); i < count; |
1117 i++) { | 1117 i++) { |
1118 CFX_WideString wsAttrQualifiedName; | 1118 CFX_WideString wsAttrQualifiedName; |
(...skipping 19 matching lines...) Expand all Loading... |
1138 FX_WSTRC(L"http://www.w3.org/2001/XMLSchema-instance") || | 1138 FX_WSTRC(L"http://www.w3.org/2001/XMLSchema-instance") || |
1139 wsAttrNamespaceURI == | 1139 wsAttrNamespaceURI == |
1140 FX_WSTRC(L"http://www.xfa.org/schema/xfa-data/1.0/")) { | 1140 FX_WSTRC(L"http://www.xfa.org/schema/xfa-data/1.0/")) { |
1141 continue; | 1141 continue; |
1142 } | 1142 } |
1143 if (0) { | 1143 if (0) { |
1144 continue; | 1144 continue; |
1145 } | 1145 } |
1146 CXFA_Node* pXFAMetaData = m_pFactory->CreateNode( | 1146 CXFA_Node* pXFAMetaData = m_pFactory->CreateNode( |
1147 XFA_XDPPACKET_Datasets, XFA_Element::DataValue); | 1147 XFA_XDPPACKET_Datasets, XFA_Element::DataValue); |
1148 if (pXFAMetaData == NULL) { | 1148 if (!pXFAMetaData) { |
1149 return; | 1149 return; |
1150 } | 1150 } |
1151 pXFAMetaData->SetCData(XFA_ATTRIBUTE_Name, wsAttrName); | 1151 pXFAMetaData->SetCData(XFA_ATTRIBUTE_Name, wsAttrName); |
1152 pXFAMetaData->SetCData(XFA_ATTRIBUTE_QualifiedName, | 1152 pXFAMetaData->SetCData(XFA_ATTRIBUTE_QualifiedName, |
1153 wsAttrQualifiedName); | 1153 wsAttrQualifiedName); |
1154 pXFAMetaData->SetCData(XFA_ATTRIBUTE_Value, wsAttrValue); | 1154 pXFAMetaData->SetCData(XFA_ATTRIBUTE_Value, wsAttrValue); |
1155 pXFAMetaData->SetEnum(XFA_ATTRIBUTE_Contains, | 1155 pXFAMetaData->SetEnum(XFA_ATTRIBUTE_Contains, |
1156 XFA_ATTRIBUTEENUM_MetaData); | 1156 XFA_ATTRIBUTEENUM_MetaData); |
1157 pXFAChild->InsertChild(pXFAMetaData); | 1157 pXFAChild->InsertChild(pXFAMetaData); |
1158 pXFAMetaData->SetXMLMappingNode(pXMLElement); | 1158 pXFAMetaData->SetXMLMappingNode(pXMLElement); |
(...skipping 19 matching lines...) Expand all Loading... |
1178 case FDE_XMLNODE_CharData: { | 1178 case FDE_XMLNODE_CharData: { |
1179 CFDE_XMLCharData* pXMLCharData = | 1179 CFDE_XMLCharData* pXMLCharData = |
1180 static_cast<CFDE_XMLCharData*>(pXMLChild); | 1180 static_cast<CFDE_XMLCharData*>(pXMLChild); |
1181 CFX_WideString wsCharData; | 1181 CFX_WideString wsCharData; |
1182 pXMLCharData->GetCharData(wsCharData); | 1182 pXMLCharData->GetCharData(wsCharData); |
1183 if (XFA_FDEExtension_IsStringAllWhitespace(wsCharData)) { | 1183 if (XFA_FDEExtension_IsStringAllWhitespace(wsCharData)) { |
1184 continue; | 1184 continue; |
1185 } | 1185 } |
1186 CXFA_Node* pXFAChild = m_pFactory->CreateNode(XFA_XDPPACKET_Datasets, | 1186 CXFA_Node* pXFAChild = m_pFactory->CreateNode(XFA_XDPPACKET_Datasets, |
1187 XFA_Element::DataValue); | 1187 XFA_Element::DataValue); |
1188 if (pXFAChild == NULL) { | 1188 if (!pXFAChild) { |
1189 return; | 1189 return; |
1190 } | 1190 } |
1191 pXFAChild->SetCData(XFA_ATTRIBUTE_Value, wsCharData); | 1191 pXFAChild->SetCData(XFA_ATTRIBUTE_Value, wsCharData); |
1192 pXFANode->InsertChild(pXFAChild); | 1192 pXFANode->InsertChild(pXFAChild); |
1193 pXFAChild->SetXMLMappingNode(pXMLCharData); | 1193 pXFAChild->SetXMLMappingNode(pXMLCharData); |
1194 pXFAChild->SetFlag(XFA_NodeFlag_Initialized, false); | 1194 pXFAChild->SetFlag(XFA_NodeFlag_Initialized, false); |
1195 } | 1195 } |
1196 continue; | 1196 continue; |
1197 case FDE_XMLNODE_Text: { | 1197 case FDE_XMLNODE_Text: { |
1198 CFDE_XMLText* pXMLText = static_cast<CFDE_XMLText*>(pXMLChild); | 1198 CFDE_XMLText* pXMLText = static_cast<CFDE_XMLText*>(pXMLChild); |
1199 CFX_WideString wsText; | 1199 CFX_WideString wsText; |
1200 pXMLText->GetText(wsText); | 1200 pXMLText->GetText(wsText); |
1201 if (XFA_FDEExtension_IsStringAllWhitespace(wsText)) { | 1201 if (XFA_FDEExtension_IsStringAllWhitespace(wsText)) { |
1202 continue; | 1202 continue; |
1203 } | 1203 } |
1204 CXFA_Node* pXFAChild = m_pFactory->CreateNode(XFA_XDPPACKET_Datasets, | 1204 CXFA_Node* pXFAChild = m_pFactory->CreateNode(XFA_XDPPACKET_Datasets, |
1205 XFA_Element::DataValue); | 1205 XFA_Element::DataValue); |
1206 if (pXFAChild == NULL) { | 1206 if (!pXFAChild) { |
1207 return; | 1207 return; |
1208 } | 1208 } |
1209 pXFAChild->SetCData(XFA_ATTRIBUTE_Value, wsText); | 1209 pXFAChild->SetCData(XFA_ATTRIBUTE_Value, wsText); |
1210 pXFANode->InsertChild(pXFAChild); | 1210 pXFANode->InsertChild(pXFAChild); |
1211 pXFAChild->SetXMLMappingNode(pXMLText); | 1211 pXFAChild->SetXMLMappingNode(pXMLText); |
1212 pXFAChild->SetFlag(XFA_NodeFlag_Initialized, false); | 1212 pXFAChild->SetFlag(XFA_NodeFlag_Initialized, false); |
1213 } | 1213 } |
1214 continue; | 1214 continue; |
1215 case FDE_XMLNODE_Instruction: | 1215 case FDE_XMLNODE_Instruction: |
1216 continue; | 1216 continue; |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1342 if (pXMLInstruction->GetData(1, wsData) && | 1342 if (pXMLInstruction->GetData(1, wsData) && |
1343 wsData == FX_WSTRC(L"strictScoping")) { | 1343 wsData == FX_WSTRC(L"strictScoping")) { |
1344 pXFANode->GetDocument()->SetFlag(XFA_DOCFLAG_StrictScoping, TRUE); | 1344 pXFANode->GetDocument()->SetFlag(XFA_DOCFLAG_StrictScoping, TRUE); |
1345 } | 1345 } |
1346 } | 1346 } |
1347 } | 1347 } |
1348 } | 1348 } |
1349 void CXFA_SimpleParser::CloseParser() { | 1349 void CXFA_SimpleParser::CloseParser() { |
1350 if (m_pXMLDoc) { | 1350 if (m_pXMLDoc) { |
1351 m_pXMLDoc->Release(); | 1351 m_pXMLDoc->Release(); |
1352 m_pXMLDoc = NULL; | 1352 m_pXMLDoc = nullptr; |
1353 } | 1353 } |
1354 if (m_pStream) { | 1354 if (m_pStream) { |
1355 m_pStream->Release(); | 1355 m_pStream->Release(); |
1356 m_pStream = NULL; | 1356 m_pStream = nullptr; |
1357 } | 1357 } |
1358 } | 1358 } |
1359 | 1359 |
1360 CXFA_DocumentParser::CXFA_DocumentParser(CXFA_FFNotify* pNotify) | 1360 CXFA_DocumentParser::CXFA_DocumentParser(CXFA_FFNotify* pNotify) |
1361 : m_nodeParser(NULL, TRUE), m_pNotify(pNotify), m_pDocument(NULL) {} | 1361 : m_nodeParser(nullptr, TRUE), m_pNotify(pNotify), m_pDocument(nullptr) {} |
1362 CXFA_DocumentParser::~CXFA_DocumentParser() { | 1362 CXFA_DocumentParser::~CXFA_DocumentParser() { |
1363 CloseParser(); | 1363 CloseParser(); |
1364 } | 1364 } |
1365 | 1365 |
1366 void CXFA_DocumentParser::Release() { | 1366 void CXFA_DocumentParser::Release() { |
1367 delete this; | 1367 delete this; |
1368 } | 1368 } |
1369 int32_t CXFA_DocumentParser::StartParse(IFX_FileRead* pStream, | 1369 int32_t CXFA_DocumentParser::StartParse(IFX_FileRead* pStream, |
1370 XFA_XDPPACKET ePacketID) { | 1370 XFA_XDPPACKET ePacketID) { |
1371 CloseParser(); | 1371 CloseParser(); |
1372 int32_t nRetStatus = m_nodeParser.StartParse(pStream, ePacketID); | 1372 int32_t nRetStatus = m_nodeParser.StartParse(pStream, ePacketID); |
1373 if (nRetStatus == XFA_PARSESTATUS_Ready) { | 1373 if (nRetStatus == XFA_PARSESTATUS_Ready) { |
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 int32_t CXFA_DocumentParser::DoParse(IFX_Pause* pPause) { | 1379 int32_t CXFA_DocumentParser::DoParse(IFX_Pause* pPause) { |
1380 int32_t nRetStatus = m_nodeParser.DoParse(pPause); | 1380 int32_t nRetStatus = m_nodeParser.DoParse(pPause); |
1381 if (nRetStatus >= XFA_PARSESTATUS_Done) { | 1381 if (nRetStatus >= XFA_PARSESTATUS_Done) { |
1382 ASSERT(m_pDocument); | 1382 ASSERT(m_pDocument); |
1383 m_pDocument->SetRoot(m_nodeParser.GetRootNode()); | 1383 m_pDocument->SetRoot(m_nodeParser.GetRootNode()); |
1384 } | 1384 } |
1385 return nRetStatus; | 1385 return nRetStatus; |
1386 } | 1386 } |
1387 int32_t CXFA_DocumentParser::ParseXMLData(const CFX_WideString& wsXML, | 1387 int32_t CXFA_DocumentParser::ParseXMLData(const CFX_WideString& wsXML, |
1388 CFDE_XMLNode*& pXMLNode, | 1388 CFDE_XMLNode*& pXMLNode, |
1389 IFX_Pause* pPause) { | 1389 IFX_Pause* pPause) { |
1390 CloseParser(); | 1390 CloseParser(); |
1391 int32_t nRetStatus = m_nodeParser.ParseXMLData(wsXML, pXMLNode, NULL); | 1391 int32_t nRetStatus = m_nodeParser.ParseXMLData(wsXML, pXMLNode, nullptr); |
1392 if (nRetStatus == XFA_PARSESTATUS_Done && pXMLNode) { | 1392 if (nRetStatus == XFA_PARSESTATUS_Done && pXMLNode) { |
1393 m_pDocument = new CXFA_Document(this); | 1393 m_pDocument = new CXFA_Document(this); |
1394 m_nodeParser.SetFactory(m_pDocument); | 1394 m_nodeParser.SetFactory(m_pDocument); |
1395 } | 1395 } |
1396 return nRetStatus; | 1396 return nRetStatus; |
1397 } | 1397 } |
1398 void CXFA_DocumentParser::ConstructXFANode(CXFA_Node* pXFANode, | 1398 void CXFA_DocumentParser::ConstructXFANode(CXFA_Node* pXFANode, |
1399 CFDE_XMLNode* pXMLNode) { | 1399 CFDE_XMLNode* pXMLNode) { |
1400 if (!pXFANode || !pXMLNode) { | 1400 if (!pXFANode || !pXMLNode) { |
1401 return; | 1401 return; |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1517 m_pChild = m_pParent; | 1517 m_pChild = m_pParent; |
1518 iCount++; | 1518 iCount++; |
1519 break; | 1519 break; |
1520 case FDE_XmlSyntaxResult::TargetName: | 1520 case FDE_XmlSyntaxResult::TargetName: |
1521 m_pParser->GetTargetName(m_ws1); | 1521 m_pParser->GetTargetName(m_ws1); |
1522 if (m_ws1 == FX_WSTRC(L"originalXFAVersion") || | 1522 if (m_ws1 == FX_WSTRC(L"originalXFAVersion") || |
1523 m_ws1 == FX_WSTRC(L"acrobat")) { | 1523 m_ws1 == FX_WSTRC(L"acrobat")) { |
1524 m_pChild = new CFDE_XMLInstruction(m_ws1); | 1524 m_pChild = new CFDE_XMLInstruction(m_ws1); |
1525 m_pParent->InsertChildNode(m_pChild); | 1525 m_pParent->InsertChildNode(m_pChild); |
1526 } else { | 1526 } else { |
1527 m_pChild = NULL; | 1527 m_pChild = nullptr; |
1528 } | 1528 } |
1529 m_ws1.clear(); | 1529 m_ws1.clear(); |
1530 break; | 1530 break; |
1531 case FDE_XmlSyntaxResult::TagName: | 1531 case FDE_XmlSyntaxResult::TagName: |
1532 m_pParser->GetTagName(m_ws1); | 1532 m_pParser->GetTagName(m_ws1); |
1533 m_pChild = new CFDE_XMLElement(m_ws1); | 1533 m_pChild = new CFDE_XMLElement(m_ws1); |
1534 m_pParent->InsertChildNode(m_pChild); | 1534 m_pParent->InsertChildNode(m_pChild); |
1535 m_NodeStack.Push(m_pChild); | 1535 m_NodeStack.Push(m_pChild); |
1536 m_pParent = m_pChild; | 1536 m_pParent = m_pChild; |
1537 | 1537 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1598 } | 1598 } |
1599 if (pPause && iCount > 500 && pPause->NeedToPauseNow()) { | 1599 if (pPause && iCount > 500 && pPause->NeedToPauseNow()) { |
1600 break; | 1600 break; |
1601 } | 1601 } |
1602 } | 1602 } |
1603 return (m_syntaxParserResult == FDE_XmlSyntaxResult::Error || | 1603 return (m_syntaxParserResult == FDE_XmlSyntaxResult::Error || |
1604 m_NodeStack.GetSize() != 1) | 1604 m_NodeStack.GetSize() != 1) |
1605 ? -1 | 1605 ? -1 |
1606 : m_pParser->GetStatus(); | 1606 : m_pParser->GetStatus(); |
1607 } | 1607 } |
OLD | NEW |