| Index: xfa/fxfa/parser/cxfa_simple_parser.cpp
|
| diff --git a/xfa/fxfa/parser/xfa_parser_imp.cpp b/xfa/fxfa/parser/cxfa_simple_parser.cpp
|
| similarity index 86%
|
| rename from xfa/fxfa/parser/xfa_parser_imp.cpp
|
| rename to xfa/fxfa/parser/cxfa_simple_parser.cpp
|
| index e4387a78380c51eb7d3b5507bb5aed8ba94831e6..c9edf2daff8293d40884038329bee3f6436d3ae4 100644
|
| --- a/xfa/fxfa/parser/xfa_parser_imp.cpp
|
| +++ b/xfa/fxfa/parser/cxfa_simple_parser.cpp
|
| @@ -1,23 +1,16 @@
|
| -// Copyright 2014 PDFium Authors. All rights reserved.
|
| +// 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/xfa_parser_imp.h"
|
| +#include "xfa/fxfa/parser/cxfa_simple_parser.h"
|
|
|
| -#include <memory>
|
| -
|
| -#include "xfa/fde/xml/fde_xml_imp.h"
|
| #include "xfa/fgas/crt/fgas_codepage.h"
|
| +#include "xfa/fxfa/include/fxfa.h"
|
| #include "xfa/fxfa/include/xfa_checksum.h"
|
| -#include "xfa/fxfa/parser/xfa_basic_imp.h"
|
| -#include "xfa/fxfa/parser/xfa_doclayout.h"
|
| +#include "xfa/fxfa/parser/cxfa_xml_parser.h"
|
| #include "xfa/fxfa/parser/xfa_document.h"
|
| -#include "xfa/fxfa/parser/xfa_localemgr.h"
|
| -#include "xfa/fxfa/parser/xfa_object.h"
|
| -#include "xfa/fxfa/parser/xfa_script.h"
|
| -#include "xfa/fxfa/parser/xfa_utils.h"
|
|
|
| CXFA_SimpleParser::CXFA_SimpleParser(CXFA_Document* pFactory,
|
| bool bDocumentParser)
|
| @@ -1323,220 +1316,3 @@ void CXFA_SimpleParser::CloseParser() {
|
| m_pStream = nullptr;
|
| }
|
| }
|
| -
|
| -CXFA_DocumentParser::CXFA_DocumentParser(CXFA_FFNotify* pNotify)
|
| - : m_nodeParser(nullptr, TRUE), m_pNotify(pNotify), m_pDocument(nullptr) {}
|
| -
|
| -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();
|
| -}
|
| -
|
| -CXFA_XMLParser::CXFA_XMLParser(CFDE_XMLNode* pRoot, IFX_Stream* pStream)
|
| - : m_nElementStart(0),
|
| - m_dwCheckStatus(0),
|
| - m_dwCurrentCheckStatus(0),
|
| - m_pRoot(pRoot),
|
| - m_pStream(pStream),
|
| - m_pParser(nullptr),
|
| - m_pParent(pRoot),
|
| - m_pChild(nullptr),
|
| - m_NodeStack(16),
|
| - m_syntaxParserResult(FDE_XmlSyntaxResult::None) {
|
| - ASSERT(m_pParent && m_pStream);
|
| - m_NodeStack.Push(m_pParent);
|
| - m_pParser = new CFDE_XMLSyntaxParser;
|
| - m_pParser->Init(m_pStream, 32 * 1024, 1024 * 1024);
|
| -}
|
| -
|
| -CXFA_XMLParser::~CXFA_XMLParser() {
|
| - if (m_pParser) {
|
| - m_pParser->Release();
|
| - }
|
| - m_NodeStack.RemoveAll();
|
| - m_ws1.clear();
|
| - m_ws2.clear();
|
| -}
|
| -
|
| -void CXFA_XMLParser::Release() {
|
| - delete this;
|
| -}
|
| -
|
| -int32_t CXFA_XMLParser::DoParser(IFX_Pause* pPause) {
|
| - if (m_syntaxParserResult == FDE_XmlSyntaxResult::Error)
|
| - return -1;
|
| - if (m_syntaxParserResult == FDE_XmlSyntaxResult::EndOfString)
|
| - return 100;
|
| -
|
| - int32_t iCount = 0;
|
| - while (TRUE) {
|
| - m_syntaxParserResult = m_pParser->DoSyntaxParse();
|
| - switch (m_syntaxParserResult) {
|
| - case FDE_XmlSyntaxResult::InstructionOpen:
|
| - break;
|
| - case FDE_XmlSyntaxResult::InstructionClose:
|
| - if (m_pChild) {
|
| - if (m_pChild->GetType() != FDE_XMLNODE_Instruction) {
|
| - m_syntaxParserResult = FDE_XmlSyntaxResult::Error;
|
| - break;
|
| - }
|
| - }
|
| - m_pChild = m_pParent;
|
| - break;
|
| - case FDE_XmlSyntaxResult::ElementOpen:
|
| - if (m_dwCheckStatus != 0x03 && m_NodeStack.GetSize() == 2) {
|
| - m_nElementStart = m_pParser->GetCurrentPos() - 1;
|
| - }
|
| - break;
|
| - case FDE_XmlSyntaxResult::ElementBreak:
|
| - break;
|
| - case FDE_XmlSyntaxResult::ElementClose:
|
| - if (m_pChild->GetType() != FDE_XMLNODE_Element) {
|
| - m_syntaxParserResult = FDE_XmlSyntaxResult::Error;
|
| - break;
|
| - }
|
| - m_pParser->GetTagName(m_ws1);
|
| - static_cast<CFDE_XMLElement*>(m_pChild)->GetTagName(m_ws2);
|
| - if (m_ws1.GetLength() > 0 && m_ws1 != m_ws2) {
|
| - m_syntaxParserResult = FDE_XmlSyntaxResult::Error;
|
| - break;
|
| - }
|
| - m_NodeStack.Pop();
|
| - if (m_NodeStack.GetSize() < 1) {
|
| - m_syntaxParserResult = FDE_XmlSyntaxResult::Error;
|
| - break;
|
| - } else if (m_dwCurrentCheckStatus != 0 && m_NodeStack.GetSize() == 2) {
|
| - m_nSize[m_dwCurrentCheckStatus - 1] =
|
| - m_pParser->GetCurrentBinaryPos() -
|
| - m_nStart[m_dwCurrentCheckStatus - 1];
|
| - m_dwCurrentCheckStatus = 0;
|
| - }
|
| -
|
| - m_pParent = static_cast<CFDE_XMLNode*>(*m_NodeStack.GetTopElement());
|
| - m_pChild = m_pParent;
|
| - iCount++;
|
| - break;
|
| - case FDE_XmlSyntaxResult::TargetName:
|
| - m_pParser->GetTargetName(m_ws1);
|
| - if (m_ws1 == FX_WSTRC(L"originalXFAVersion") ||
|
| - m_ws1 == FX_WSTRC(L"acrobat")) {
|
| - m_pChild = new CFDE_XMLInstruction(m_ws1);
|
| - m_pParent->InsertChildNode(m_pChild);
|
| - } else {
|
| - m_pChild = nullptr;
|
| - }
|
| - m_ws1.clear();
|
| - break;
|
| - case FDE_XmlSyntaxResult::TagName:
|
| - m_pParser->GetTagName(m_ws1);
|
| - m_pChild = new CFDE_XMLElement(m_ws1);
|
| - m_pParent->InsertChildNode(m_pChild);
|
| - m_NodeStack.Push(m_pChild);
|
| - m_pParent = m_pChild;
|
| -
|
| - if (m_dwCheckStatus != 0x03 && m_NodeStack.GetSize() == 3) {
|
| - CFX_WideString wsTag;
|
| - static_cast<CFDE_XMLElement*>(m_pChild)->GetLocalTagName(wsTag);
|
| - if (wsTag == FX_WSTRC(L"template")) {
|
| - m_dwCheckStatus |= 0x01;
|
| - m_dwCurrentCheckStatus = 0x01;
|
| - m_nStart[0] = m_pParser->GetCurrentBinaryPos() -
|
| - (m_pParser->GetCurrentPos() - m_nElementStart);
|
| - } else if (wsTag == FX_WSTRC(L"datasets")) {
|
| - m_dwCheckStatus |= 0x02;
|
| - m_dwCurrentCheckStatus = 0x02;
|
| - m_nStart[1] = m_pParser->GetCurrentBinaryPos() -
|
| - (m_pParser->GetCurrentPos() - m_nElementStart);
|
| - }
|
| - }
|
| - break;
|
| - case FDE_XmlSyntaxResult::AttriName:
|
| - m_pParser->GetAttributeName(m_ws1);
|
| - break;
|
| - case FDE_XmlSyntaxResult::AttriValue:
|
| - if (m_pChild) {
|
| - m_pParser->GetAttributeName(m_ws2);
|
| - if (m_pChild->GetType() == FDE_XMLNODE_Element) {
|
| - static_cast<CFDE_XMLElement*>(m_pChild)->SetString(m_ws1, m_ws2);
|
| - }
|
| - }
|
| - m_ws1.clear();
|
| - break;
|
| - case FDE_XmlSyntaxResult::Text:
|
| - m_pParser->GetTextData(m_ws1);
|
| - m_pChild = new CFDE_XMLText(m_ws1);
|
| - m_pParent->InsertChildNode(m_pChild);
|
| - m_pChild = m_pParent;
|
| - break;
|
| - case FDE_XmlSyntaxResult::CData:
|
| - m_pParser->GetTextData(m_ws1);
|
| - m_pChild = new CFDE_XMLCharData(m_ws1);
|
| - m_pParent->InsertChildNode(m_pChild);
|
| - m_pChild = m_pParent;
|
| - break;
|
| - case FDE_XmlSyntaxResult::TargetData:
|
| - if (m_pChild) {
|
| - if (m_pChild->GetType() != FDE_XMLNODE_Instruction) {
|
| - m_syntaxParserResult = FDE_XmlSyntaxResult::Error;
|
| - break;
|
| - }
|
| - if (!m_ws1.IsEmpty()) {
|
| - static_cast<CFDE_XMLInstruction*>(m_pChild)->AppendData(m_ws1);
|
| - }
|
| - m_pParser->GetTargetData(m_ws1);
|
| - static_cast<CFDE_XMLInstruction*>(m_pChild)->AppendData(m_ws1);
|
| - }
|
| - m_ws1.clear();
|
| - break;
|
| - default:
|
| - break;
|
| - }
|
| - if (m_syntaxParserResult == FDE_XmlSyntaxResult::Error ||
|
| - m_syntaxParserResult == FDE_XmlSyntaxResult::EndOfString) {
|
| - break;
|
| - }
|
| - if (pPause && iCount > 500 && pPause->NeedToPauseNow()) {
|
| - break;
|
| - }
|
| - }
|
| - return (m_syntaxParserResult == FDE_XmlSyntaxResult::Error ||
|
| - m_NodeStack.GetSize() != 1)
|
| - ? -1
|
| - : m_pParser->GetStatus();
|
| -}
|
|
|