summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2018-04-12 13:54:39 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-04-12 13:54:39 +0000
commit7023b8877475dda639a15d623b5a552f88a6812f (patch)
tree419e9359df5e36941e61ee18b3a470666253d379
parentbabeeb69b1744e414b46d77de03689682742d99d (diff)
downloadpdfium-7023b8877475dda639a15d623b5a552f88a6812f.tar.xz
Remove CXFA_DocumentParser::m_bDocumentParser flag
This CL removes the import data behaviour as it was never called and cleans up the m_bDocumentParser flag as it will always be used in the true case. Change-Id: If90a0a55cc76f406e9987aa71580e90edeaa01ba Reviewed-on: https://pdfium-review.googlesource.com/30292 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
-rw-r--r--BUILD.gn2
-rw-r--r--xfa/fxfa/cxfa_ffdoc.cpp12
-rw-r--r--xfa/fxfa/cxfa_ffdoc.h2
-rw-r--r--xfa/fxfa/parser/cxfa_dataimporter.cpp60
-rw-r--r--xfa/fxfa/parser/cxfa_dataimporter.h28
-rw-r--r--xfa/fxfa/parser/cxfa_document_parser.cpp30
-rw-r--r--xfa/fxfa/parser/cxfa_document_parser.h5
7 files changed, 11 insertions, 128 deletions
diff --git a/BUILD.gn b/BUILD.gn
index 87de013c89..2f74e43bf3 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -2271,8 +2271,6 @@ if (pdf_enable_xfa) {
"xfa/fxfa/parser/cxfa_dataexporter.h",
"xfa/fxfa/parser/cxfa_datagroup.cpp",
"xfa/fxfa/parser/cxfa_datagroup.h",
- "xfa/fxfa/parser/cxfa_dataimporter.cpp",
- "xfa/fxfa/parser/cxfa_dataimporter.h",
"xfa/fxfa/parser/cxfa_datamodel.cpp",
"xfa/fxfa/parser/cxfa_datamodel.h",
"xfa/fxfa/parser/cxfa_datavalue.cpp",
diff --git a/xfa/fxfa/cxfa_ffdoc.cpp b/xfa/fxfa/cxfa_ffdoc.cpp
index 24a8a04c03..9dc58adb9a 100644
--- a/xfa/fxfa/cxfa_ffdoc.cpp
+++ b/xfa/fxfa/cxfa_ffdoc.cpp
@@ -31,7 +31,6 @@
#include "xfa/fxfa/parser/cxfa_acrobat.h"
#include "xfa/fxfa/parser/cxfa_acrobat7.h"
#include "xfa/fxfa/parser/cxfa_dataexporter.h"
-#include "xfa/fxfa/parser/cxfa_dataimporter.h"
#include "xfa/fxfa/parser/cxfa_document.h"
#include "xfa/fxfa/parser/cxfa_document_parser.h"
#include "xfa/fxfa/parser/cxfa_dynamicrender.h"
@@ -181,10 +180,7 @@ bool CXFA_FFDoc::ParseDoc(CPDF_Object* pElementXFA) {
auto stream = pdfium::MakeRetain<CFX_SeekableMultiStream>(xfaStreams);
- // Note, we don't pass the document into the constructor as currently that
- // triggers different behaviour in the parser.
- CXFA_DocumentParser parser;
- parser.SetFactory(m_pDocument.get());
+ CXFA_DocumentParser parser(m_pDocument.get());
if (!parser.Parse(stream, XFA_PacketType::Xdp))
return false;
@@ -406,9 +402,3 @@ bool CXFA_FFDoc::SavePackage(CXFA_Node* pNode,
CXFA_DataExporter exporter;
return exporter.Export(pFile, pNode ? pNode : GetXFADoc()->GetRoot());
}
-
-bool CXFA_FFDoc::ImportData(const RetainPtr<IFX_SeekableStream>& pStream,
- bool bXDP) {
- auto importer = pdfium::MakeUnique<CXFA_DataImporter>(m_pDocument.get());
- return importer->ImportData(pStream);
-}
diff --git a/xfa/fxfa/cxfa_ffdoc.h b/xfa/fxfa/cxfa_ffdoc.h
index dc656253ef..dacc246378 100644
--- a/xfa/fxfa/cxfa_ffdoc.h
+++ b/xfa/fxfa/cxfa_ffdoc.h
@@ -78,8 +78,6 @@ class CXFA_FFDoc {
bool SavePackage(CXFA_Node* pNode,
const RetainPtr<IFX_SeekableStream>& pFile);
- bool ImportData(const RetainPtr<IFX_SeekableStream>& pStream,
- bool bXDP = true);
private:
bool ParseDoc(CPDF_Object* pElementXFA);
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_