1 // Copyright 2016 PDFium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 6 7 #include "xfa/fxfa/parser/cxfa_document_parser.h" 8 9 #include "core/fxcrt/xml/cfx_xmldoc.h" 10 #include "third_party/base/ptr_util.h" 11 #include "xfa/fxfa/fxfa.h" 12 #include "xfa/fxfa/parser/cxfa_document.h" 13 CXFA_DocumentParser(CXFA_FFNotify * pNotify)14CXFA_DocumentParser::CXFA_DocumentParser(CXFA_FFNotify* pNotify) 15 : m_pNotify(pNotify) {} 16 ~CXFA_DocumentParser()17CXFA_DocumentParser::~CXFA_DocumentParser() { 18 } 19 StartParse(const RetainPtr<IFX_SeekableStream> & pStream,XFA_PacketType ePacketID)20int32_t CXFA_DocumentParser::StartParse( 21 const RetainPtr<IFX_SeekableStream>& pStream, 22 XFA_PacketType ePacketID) { 23 m_pDocument.reset(); 24 m_nodeParser.CloseParser(); 25 26 int32_t nRetStatus = m_nodeParser.StartParse(pStream, ePacketID); 27 if (nRetStatus == XFA_PARSESTATUS_Ready) { 28 m_pDocument = pdfium::MakeUnique<CXFA_Document>(this); 29 m_nodeParser.SetFactory(m_pDocument.get()); 30 } 31 return nRetStatus; 32 } 33 DoParse()34int32_t CXFA_DocumentParser::DoParse() { 35 int32_t nRetStatus = m_nodeParser.DoParse(); 36 if (nRetStatus >= XFA_PARSESTATUS_Done) { 37 ASSERT(m_pDocument); 38 m_pDocument->SetRoot(m_nodeParser.GetRootNode()); 39 } 40 return nRetStatus; 41 } 42 GetXMLDoc() const43CFX_XMLDoc* CXFA_DocumentParser::GetXMLDoc() const { 44 return m_nodeParser.GetXMLDoc(); 45 } 46 GetNotify() const47CXFA_FFNotify* CXFA_DocumentParser::GetNotify() const { 48 return m_pNotify.Get(); 49 } 50 GetDocument() const51CXFA_Document* CXFA_DocumentParser::GetDocument() const { 52 return m_pDocument.get(); 53 } 54