| OLD | NEW |
| 1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 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/cxfa_document_parser.h" | 7 #include "xfa/fxfa/parser/cxfa_document_parser.h" |
| 8 | 8 |
| 9 #include "xfa/fxfa/include/fxfa.h" | 9 #include "xfa/fxfa/include/fxfa.h" |
| 10 #include "xfa/fxfa/parser/xfa_document.h" | 10 #include "xfa/fxfa/parser/xfa_document.h" |
| 11 | 11 |
| 12 CXFA_DocumentParser::CXFA_DocumentParser(CXFA_FFNotify* pNotify) | 12 CXFA_DocumentParser::CXFA_DocumentParser(CXFA_FFNotify* pNotify) |
| 13 : m_nodeParser(nullptr, TRUE), m_pNotify(pNotify) {} | 13 : m_nodeParser(nullptr, TRUE), m_pNotify(pNotify) {} |
| 14 | 14 |
| 15 CXFA_DocumentParser::~CXFA_DocumentParser() { | 15 CXFA_DocumentParser::~CXFA_DocumentParser() { |
| 16 CloseParser(); | |
| 17 } | 16 } |
| 18 | 17 |
| 19 int32_t CXFA_DocumentParser::StartParse(IFX_FileRead* pStream, | 18 int32_t CXFA_DocumentParser::StartParse(IFX_FileRead* pStream, |
| 20 XFA_XDPPACKET ePacketID) { | 19 XFA_XDPPACKET ePacketID) { |
| 21 CloseParser(); | 20 m_pDocument.reset(); |
| 21 m_nodeParser.CloseParser(); |
| 22 |
| 22 int32_t nRetStatus = m_nodeParser.StartParse(pStream, ePacketID); | 23 int32_t nRetStatus = m_nodeParser.StartParse(pStream, ePacketID); |
| 23 if (nRetStatus == XFA_PARSESTATUS_Ready) { | 24 if (nRetStatus == XFA_PARSESTATUS_Ready) { |
| 24 m_pDocument.reset(new CXFA_Document(this)); | 25 m_pDocument.reset(new CXFA_Document(this)); |
| 25 m_nodeParser.SetFactory(m_pDocument.get()); | 26 m_nodeParser.SetFactory(m_pDocument.get()); |
| 26 } | 27 } |
| 27 return nRetStatus; | 28 return nRetStatus; |
| 28 } | 29 } |
| 29 | 30 |
| 30 int32_t CXFA_DocumentParser::DoParse(IFX_Pause* pPause) { | 31 int32_t CXFA_DocumentParser::DoParse(IFX_Pause* pPause) { |
| 31 int32_t nRetStatus = m_nodeParser.DoParse(pPause); | 32 int32_t nRetStatus = m_nodeParser.DoParse(pPause); |
| 32 if (nRetStatus >= XFA_PARSESTATUS_Done) { | 33 if (nRetStatus >= XFA_PARSESTATUS_Done) { |
| 33 ASSERT(m_pDocument); | 34 ASSERT(m_pDocument); |
| 34 m_pDocument->SetRoot(m_nodeParser.GetRootNode()); | 35 m_pDocument->SetRoot(m_nodeParser.GetRootNode()); |
| 35 } | 36 } |
| 36 return nRetStatus; | 37 return nRetStatus; |
| 37 } | 38 } |
| 38 | 39 |
| 39 CFDE_XMLDoc* CXFA_DocumentParser::GetXMLDoc() const { | 40 CFDE_XMLDoc* CXFA_DocumentParser::GetXMLDoc() const { |
| 40 return m_nodeParser.GetXMLDoc(); | 41 return m_nodeParser.GetXMLDoc(); |
| 41 } | 42 } |
| 42 | 43 |
| 43 CXFA_FFNotify* CXFA_DocumentParser::GetNotify() const { | 44 CXFA_FFNotify* CXFA_DocumentParser::GetNotify() const { |
| 44 return m_pNotify; | 45 return m_pNotify; |
| 45 } | 46 } |
| 46 | 47 |
| 47 CXFA_Document* CXFA_DocumentParser::GetDocument() const { | 48 CXFA_Document* CXFA_DocumentParser::GetDocument() const { |
| 48 return m_pDocument.get(); | 49 return m_pDocument.get(); |
| 49 } | 50 } |
| 50 | |
| 51 void CXFA_DocumentParser::CloseParser() { | |
| 52 m_pDocument.reset(); | |
| 53 m_nodeParser.CloseParser(); | |
| 54 } | |
| OLD | NEW |