diff options
author | dsinclair <dsinclair@chromium.org> | 2016-07-11 08:42:33 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-07-11 08:42:33 -0700 |
commit | 34f86b0c7816289d2a0b402d1909572f4e95613b (patch) | |
tree | f4cc3d2442311723fd01d03689964fa0693bb5b1 /xfa/fxfa/parser/cxfa_document_parser.cpp | |
parent | a1b0772321e9b839073b9b312bac22143f2d4011 (diff) | |
download | pdfium-34f86b0c7816289d2a0b402d1909572f4e95613b.tar.xz |
Break xfa_parser_imp apart
This CL splits the three parsers into individual files to make working with
the code easier.
Review-Url: https://codereview.chromium.org/2129963002
Diffstat (limited to 'xfa/fxfa/parser/cxfa_document_parser.cpp')
-rw-r--r-- | xfa/fxfa/parser/cxfa_document_parser.cpp | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/xfa/fxfa/parser/cxfa_document_parser.cpp b/xfa/fxfa/parser/cxfa_document_parser.cpp new file mode 100644 index 0000000000..565916ba93 --- /dev/null +++ b/xfa/fxfa/parser/cxfa_document_parser.cpp @@ -0,0 +1,54 @@ +// Copyright 2016 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#include "xfa/fxfa/parser/cxfa_document_parser.h" + +#include "xfa/fxfa/include/fxfa.h" +#include "xfa/fxfa/parser/xfa_document.h" + +CXFA_DocumentParser::CXFA_DocumentParser(CXFA_FFNotify* pNotify) + : m_nodeParser(nullptr, TRUE), m_pNotify(pNotify) {} + +CXFA_DocumentParser::~CXFA_DocumentParser() { + CloseParser(); +} + +int32_t CXFA_DocumentParser::StartParse(IFX_FileRead* pStream, + XFA_XDPPACKET ePacketID) { + CloseParser(); + int32_t nRetStatus = m_nodeParser.StartParse(pStream, ePacketID); + if (nRetStatus == XFA_PARSESTATUS_Ready) { + m_pDocument.reset(new CXFA_Document(this)); + m_nodeParser.SetFactory(m_pDocument.get()); + } + return nRetStatus; +} + +int32_t CXFA_DocumentParser::DoParse(IFX_Pause* pPause) { + int32_t nRetStatus = m_nodeParser.DoParse(pPause); + if (nRetStatus >= XFA_PARSESTATUS_Done) { + ASSERT(m_pDocument); + m_pDocument->SetRoot(m_nodeParser.GetRootNode()); + } + return nRetStatus; +} + +CFDE_XMLDoc* CXFA_DocumentParser::GetXMLDoc() const { + return m_nodeParser.GetXMLDoc(); +} + +CXFA_FFNotify* CXFA_DocumentParser::GetNotify() const { + return m_pNotify; +} + +CXFA_Document* CXFA_DocumentParser::GetDocument() const { + return m_pDocument.get(); +} + +void CXFA_DocumentParser::CloseParser() { + m_pDocument.reset(); + m_nodeParser.CloseParser(); +} |