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