dsinclair | 34f86b0 | 2016-07-11 08:42:33 -0700 | [diff] [blame] | 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 "xfa/fxfa/include/fxfa.h" |
dsinclair | 1628024 | 2016-07-21 12:03:47 -0700 | [diff] [blame^] | 10 | #include "xfa/fxfa/parser/cxfa_document.h" |
dsinclair | 34f86b0 | 2016-07-11 08:42:33 -0700 | [diff] [blame] | 11 | |
| 12 | CXFA_DocumentParser::CXFA_DocumentParser(CXFA_FFNotify* pNotify) |
| 13 | : m_nodeParser(nullptr, TRUE), m_pNotify(pNotify) {} |
| 14 | |
| 15 | CXFA_DocumentParser::~CXFA_DocumentParser() { |
dsinclair | 34f86b0 | 2016-07-11 08:42:33 -0700 | [diff] [blame] | 16 | } |
| 17 | |
| 18 | int32_t CXFA_DocumentParser::StartParse(IFX_FileRead* pStream, |
| 19 | XFA_XDPPACKET ePacketID) { |
dsinclair | bb95c50 | 2016-07-11 08:55:08 -0700 | [diff] [blame] | 20 | m_pDocument.reset(); |
| 21 | m_nodeParser.CloseParser(); |
| 22 | |
dsinclair | 34f86b0 | 2016-07-11 08:42:33 -0700 | [diff] [blame] | 23 | int32_t nRetStatus = m_nodeParser.StartParse(pStream, ePacketID); |
| 24 | if (nRetStatus == XFA_PARSESTATUS_Ready) { |
| 25 | m_pDocument.reset(new CXFA_Document(this)); |
| 26 | m_nodeParser.SetFactory(m_pDocument.get()); |
| 27 | } |
| 28 | return nRetStatus; |
| 29 | } |
| 30 | |
| 31 | int32_t CXFA_DocumentParser::DoParse(IFX_Pause* pPause) { |
| 32 | int32_t nRetStatus = m_nodeParser.DoParse(pPause); |
| 33 | if (nRetStatus >= XFA_PARSESTATUS_Done) { |
| 34 | ASSERT(m_pDocument); |
| 35 | m_pDocument->SetRoot(m_nodeParser.GetRootNode()); |
| 36 | } |
| 37 | return nRetStatus; |
| 38 | } |
| 39 | |
| 40 | CFDE_XMLDoc* CXFA_DocumentParser::GetXMLDoc() const { |
| 41 | return m_nodeParser.GetXMLDoc(); |
| 42 | } |
| 43 | |
| 44 | CXFA_FFNotify* CXFA_DocumentParser::GetNotify() const { |
| 45 | return m_pNotify; |
| 46 | } |
| 47 | |
| 48 | CXFA_Document* CXFA_DocumentParser::GetDocument() const { |
| 49 | return m_pDocument.get(); |
| 50 | } |