diff options
Diffstat (limited to 'xfa/fxfa/parser')
-rw-r--r-- | xfa/fxfa/parser/cxfa_dataimporter.cpp | 60 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_dataimporter.h | 28 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_document_parser.cpp | 30 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_document_parser.h | 5 |
4 files changed, 10 insertions, 113 deletions
diff --git a/xfa/fxfa/parser/cxfa_dataimporter.cpp b/xfa/fxfa/parser/cxfa_dataimporter.cpp deleted file mode 100644 index 481f946fe0..0000000000 --- a/xfa/fxfa/parser/cxfa_dataimporter.cpp +++ /dev/null @@ -1,60 +0,0 @@ -// 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_dataimporter.h" - -#include <memory> - -#include "core/fxcrt/fx_stream.h" -#include "core/fxcrt/xml/cfx_xmlnode.h" -#include "third_party/base/ptr_util.h" -#include "xfa/fxfa/fxfa.h" -#include "xfa/fxfa/fxfa_basic.h" -#include "xfa/fxfa/parser/cxfa_document.h" -#include "xfa/fxfa/parser/cxfa_document_parser.h" -#include "xfa/fxfa/parser/cxfa_node.h" - -CXFA_DataImporter::CXFA_DataImporter(CXFA_Document* pDocument) - : m_pDocument(pDocument) { - ASSERT(m_pDocument); -} - -CXFA_DataImporter::~CXFA_DataImporter() {} - -bool CXFA_DataImporter::ImportData( - const RetainPtr<IFX_SeekableStream>& pDataDocument) { - CXFA_DocumentParser parser(m_pDocument.Get()); - if (!parser.Parse(pDataDocument, XFA_PacketType::Datasets)) - return false; - - CXFA_Node* pImportDataRoot = parser.GetRootNode(); - if (!pImportDataRoot) - return false; - - CXFA_Node* pDataModel = - ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Datasets)); - if (!pDataModel) - return false; - - CXFA_Node* pDataNode = ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Data)); - if (pDataNode) - pDataModel->RemoveChild(pDataNode, true); - - if (pImportDataRoot->GetElementType() == XFA_Element::DataModel) { - while (CXFA_Node* pChildNode = pImportDataRoot->GetFirstChild()) { - pImportDataRoot->RemoveChild(pChildNode, true); - pDataModel->InsertChild(pChildNode, nullptr); - } - } else { - CFX_XMLNode* pXMLNode = pImportDataRoot->GetXMLMappingNode(); - CFX_XMLNode* pParentXMLNode = pXMLNode->GetParent(); - if (pParentXMLNode) - pParentXMLNode->RemoveChildNode(pXMLNode); - pDataModel->InsertChild(pImportDataRoot, nullptr); - } - m_pDocument->DoDataRemerge(false); - return true; -} diff --git a/xfa/fxfa/parser/cxfa_dataimporter.h b/xfa/fxfa/parser/cxfa_dataimporter.h deleted file mode 100644 index ca5896eb55..0000000000 --- a/xfa/fxfa/parser/cxfa_dataimporter.h +++ /dev/null @@ -1,28 +0,0 @@ -// 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 - -#ifndef XFA_FXFA_PARSER_CXFA_DATAIMPORTER_H_ -#define XFA_FXFA_PARSER_CXFA_DATAIMPORTER_H_ - -#include "core/fxcrt/fx_system.h" -#include "core/fxcrt/retain_ptr.h" -#include "core/fxcrt/unowned_ptr.h" - -class CXFA_Document; -class IFX_SeekableStream; - -class CXFA_DataImporter { - public: - explicit CXFA_DataImporter(CXFA_Document* pDocument); - ~CXFA_DataImporter(); - - bool ImportData(const RetainPtr<IFX_SeekableStream>& pDataDocument); - - private: - UnownedPtr<CXFA_Document> const m_pDocument; -}; - -#endif // XFA_FXFA_PARSER_CXFA_DATAIMPORTER_H_ diff --git a/xfa/fxfa/parser/cxfa_document_parser.cpp b/xfa/fxfa/parser/cxfa_document_parser.cpp index c2cc1deb88..97f34b6472 100644 --- a/xfa/fxfa/parser/cxfa_document_parser.cpp +++ b/xfa/fxfa/parser/cxfa_document_parser.cpp @@ -322,18 +322,11 @@ bool XFA_RecognizeRichText(CFX_XMLElement* pRichTextXMLNode) { L"http://www.w3.org/1999/xhtml"; } -CXFA_DocumentParser::CXFA_DocumentParser() : m_bDocumentParser(true) {} - CXFA_DocumentParser::CXFA_DocumentParser(CXFA_Document* pFactory) - : m_pFactory(pFactory), m_bDocumentParser(false) {} + : m_pFactory(pFactory) {} CXFA_DocumentParser::~CXFA_DocumentParser() {} -void CXFA_DocumentParser::SetFactory(CXFA_Document* pFactory) { - ASSERT(m_bDocumentParser); - m_pFactory = pFactory; -} - bool CXFA_DocumentParser::Parse(const RetainPtr<IFX_SeekableStream>& pStream, XFA_PacketType ePacketID) { auto pStreamProxy = @@ -604,15 +597,15 @@ CXFA_Node* CXFA_DocumentParser::ParseAsXDPPacket_Template( return nullptr; pNode->JSObject()->SetCData(XFA_Attribute::Name, packet->name, false, false); - if (m_bDocumentParser) { - CFX_XMLElement* pXMLDocumentElement = - static_cast<CFX_XMLElement*>(pXMLDocumentNode); - WideString wsNamespaceURI = pXMLDocumentElement->GetNamespaceURI(); - if (wsNamespaceURI.IsEmpty()) - wsNamespaceURI = pXMLDocumentElement->GetString(L"xmlns:xfa"); - - pNode->GetDocument()->RecognizeXFAVersionNumber(wsNamespaceURI); - } + + CFX_XMLElement* pXMLDocumentElement = + static_cast<CFX_XMLElement*>(pXMLDocumentNode); + WideString wsNamespaceURI = pXMLDocumentElement->GetNamespaceURI(); + if (wsNamespaceURI.IsEmpty()) + wsNamespaceURI = pXMLDocumentElement->GetString(L"xmlns:xfa"); + + pNode->GetDocument()->RecognizeXFAVersionNumber(wsNamespaceURI); + if (!NormalLoader(pNode, pXMLDocumentNode, XFA_PacketType::Template, true)) return nullptr; @@ -1148,9 +1141,6 @@ void CXFA_DocumentParser::ParseDataValue(CXFA_Node* pXFANode, void CXFA_DocumentParser::ParseInstruction(CXFA_Node* pXFANode, CFX_XMLInstruction* pXMLInstruction, XFA_PacketType ePacketID) { - if (!m_bDocumentParser) - return; - WideString wsTargetName = pXMLInstruction->GetName(); const std::vector<WideString>& target_data = pXMLInstruction->GetTargetData(); if (wsTargetName == L"originalXFAVersion") { diff --git a/xfa/fxfa/parser/cxfa_document_parser.h b/xfa/fxfa/parser/cxfa_document_parser.h index 8899494c79..acd27e6238 100644 --- a/xfa/fxfa/parser/cxfa_document_parser.h +++ b/xfa/fxfa/parser/cxfa_document_parser.h @@ -22,7 +22,6 @@ class CFX_SeekableStreamProxy; class CXFA_DocumentParser { public: - CXFA_DocumentParser(); explicit CXFA_DocumentParser(CXFA_Document* pFactory); ~CXFA_DocumentParser(); @@ -35,9 +34,6 @@ class CXFA_DocumentParser { std::unique_ptr<CFX_XMLNode> GetXMLRoot() { return std::move(m_pNodeTree); } CXFA_Node* GetRootNode() const; - // Called later for the ctor with no parameters. - void SetFactory(CXFA_Document* pFactory); - private: std::unique_ptr<CFX_XMLNode> LoadXML( const RetainPtr<CFX_SeekableStreamProxy>& pStream); @@ -80,7 +76,6 @@ class CXFA_DocumentParser { std::unique_ptr<CFX_XMLNode> m_pNodeTree; // TODO(dsinclair): Figure out who owns this. CXFA_Node* m_pRootNode = nullptr; - const bool m_bDocumentParser; }; #endif // XFA_FXFA_PARSER_CXFA_DOCUMENT_PARSER_H_ |