From d936d2931d86eb029feadd8aefbd3c7e51264a64 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Mon, 9 Apr 2018 17:27:55 +0000 Subject: Move the CFX_XMLParser out of CXFA_SimpleParser This CL removes the CFX_XMLParser from CXFA_SimpleParser and constructs it in the CFX_XMLDoc. Change-Id: Id69b396f091892170a4c4654ac1d0fd65d1efbb6 Reviewed-on: https://pdfium-review.googlesource.com/29970 Reviewed-by: Henrique Nakashima Commit-Queue: dsinclair --- xfa/fxfa/parser/cxfa_simple_parser.cpp | 28 ++++++++++------------------ xfa/fxfa/parser/cxfa_simple_parser.h | 2 -- 2 files changed, 10 insertions(+), 20 deletions(-) (limited to 'xfa/fxfa/parser') diff --git a/xfa/fxfa/parser/cxfa_simple_parser.cpp b/xfa/fxfa/parser/cxfa_simple_parser.cpp index f30ab6b631..de9f74f291 100644 --- a/xfa/fxfa/parser/cxfa_simple_parser.cpp +++ b/xfa/fxfa/parser/cxfa_simple_parser.cpp @@ -350,12 +350,8 @@ int32_t CXFA_SimpleParser::StartParse( wCodePage != FX_CODEPAGE_UTF8) { m_pStream->SetCodePage(FX_CODEPAGE_UTF8); } - m_pXMLDoc = pdfium::MakeUnique(); - auto pNewParser = - pdfium::MakeUnique(m_pXMLDoc->GetRoot(), m_pStream); - m_pXMLParser = pNewParser.get(); - if (!m_pXMLDoc->LoadXML(std::move(pNewParser))) - return XFA_PARSESTATUS_StatusErr; + + m_pXMLDoc = pdfium::MakeUnique(m_pStream); m_bParseStarted = true; m_ePacketID = ePacketID; @@ -373,7 +369,6 @@ int32_t CXFA_SimpleParser::DoParse() { return iRet / 2; m_pRootNode = ParseAsXDPPacket(GetDocumentNode(m_pXMLDoc.get()), m_ePacketID); - m_pXMLParser.Release(); m_pXMLDoc->CloseXML(); m_pStream.Reset(); @@ -385,15 +380,11 @@ int32_t CXFA_SimpleParser::DoParse() { CFX_XMLNode* CXFA_SimpleParser::ParseXMLData(const ByteString& wsXML) { CloseParser(); - m_pXMLDoc = pdfium::MakeUnique(); auto pStream = pdfium::MakeRetain( const_cast(wsXML.raw_str()), wsXML.GetLength()); - auto pParser = - pdfium::MakeUnique(m_pXMLDoc->GetRoot(), pStream); - pParser->m_dwCheckStatus = 0x03; - if (!m_pXMLDoc->LoadXML(std::move(pParser))) - return nullptr; + m_pXMLDoc = pdfium::MakeUnique(pStream); + m_pXMLDoc->GetParser()->m_dwCheckStatus = 0x03; int32_t iRet = m_pXMLDoc->DoLoad(); if (iRet < 0 || iRet >= 100) @@ -662,16 +653,17 @@ CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_Form( CFX_XMLElement* pXMLDocumentElement = static_cast(pXMLDocumentNode); WideString wsChecksum = pXMLDocumentElement->GetString(L"checksum"); - if (wsChecksum.GetLength() != 28 || m_pXMLParser->m_dwCheckStatus != 0x03) { + if (wsChecksum.GetLength() != 28 || + m_pXMLDoc->GetParser()->m_dwCheckStatus != 0x03) { return nullptr; } auto pChecksum = pdfium::MakeUnique(); pChecksum->StartChecksum(); - pChecksum->UpdateChecksum(m_pFileRead, m_pXMLParser->m_nStart[0], - m_pXMLParser->m_nSize[0]); - pChecksum->UpdateChecksum(m_pFileRead, m_pXMLParser->m_nStart[1], - m_pXMLParser->m_nSize[1]); + pChecksum->UpdateChecksum(m_pFileRead, m_pXMLDoc->GetParser()->m_nStart[0], + m_pXMLDoc->GetParser()->m_nSize[0]); + pChecksum->UpdateChecksum(m_pFileRead, m_pXMLDoc->GetParser()->m_nStart[1], + m_pXMLDoc->GetParser()->m_nSize[1]); pChecksum->FinishChecksum(); ByteString bsCheck = pChecksum->GetChecksum(); if (bsCheck != wsChecksum.UTF8Encode()) diff --git a/xfa/fxfa/parser/cxfa_simple_parser.h b/xfa/fxfa/parser/cxfa_simple_parser.h index c1015469c9..1300a8c4f2 100644 --- a/xfa/fxfa/parser/cxfa_simple_parser.h +++ b/xfa/fxfa/parser/cxfa_simple_parser.h @@ -16,7 +16,6 @@ class CXFA_Node; class CFX_XMLDoc; class CFX_XMLInstruction; class CFX_XMLNode; -class CFX_XMLParser; class IFX_SeekableStream; class CFX_SeekableStreamProxy; @@ -73,7 +72,6 @@ class CXFA_SimpleParser { XFA_PacketType ePacketID); std::unique_ptr m_pXMLDoc; - UnownedPtr m_pXMLParser; // Owned by |m_pXMLDoc| RetainPtr m_pStream; RetainPtr m_pFileRead; UnownedPtr m_pFactory; -- cgit v1.2.3