summaryrefslogtreecommitdiff
path: root/xfa/fxfa
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2018-04-12 13:41:09 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-04-12 13:41:09 +0000
commite7d5c7f48ead8f5554105da9637fd9de1c093d67 (patch)
treed2d680785cd6c64799530b650b61b81253a7a095 /xfa/fxfa
parent62110c9ce5e0d74319e25f0f41fd241f4aeeac42 (diff)
downloadpdfium-e7d5c7f48ead8f5554105da9637fd9de1c093d67.tar.xz
Remove CFX_XMLDoc and call the parser directly
This CL removes the CFX_XMLDoc and calls the CFX_XMLParser directly from CXFA_DocumentParser. Change-Id: I4d715cca90cd15b5e1d79827e0bb2781e873e371 Reviewed-on: https://pdfium-review.googlesource.com/30251 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'xfa/fxfa')
-rw-r--r--xfa/fxfa/parser/cxfa_dataexporter.cpp1
-rw-r--r--xfa/fxfa/parser/cxfa_document_parser.cpp22
-rw-r--r--xfa/fxfa/parser/cxfa_document_parser.h3
3 files changed, 17 insertions, 9 deletions
diff --git a/xfa/fxfa/parser/cxfa_dataexporter.cpp b/xfa/fxfa/parser/cxfa_dataexporter.cpp
index 7773aeb190..1418d030b5 100644
--- a/xfa/fxfa/parser/cxfa_dataexporter.cpp
+++ b/xfa/fxfa/parser/cxfa_dataexporter.cpp
@@ -7,7 +7,6 @@
#include "xfa/fxfa/parser/cxfa_dataexporter.h"
#include "core/fxcrt/fx_codepage.h"
-#include "core/fxcrt/xml/cfx_xmldoc.h"
#include "core/fxcrt/xml/cfx_xmlelement.h"
#include "core/fxcrt/xml/cfx_xmlnode.h"
#include "third_party/base/stl_util.h"
diff --git a/xfa/fxfa/parser/cxfa_document_parser.cpp b/xfa/fxfa/parser/cxfa_document_parser.cpp
index 707dfc11d5..c2cc1deb88 100644
--- a/xfa/fxfa/parser/cxfa_document_parser.cpp
+++ b/xfa/fxfa/parser/cxfa_document_parser.cpp
@@ -14,7 +14,6 @@
#include "core/fxcrt/fx_codepage.h"
#include "core/fxcrt/fx_extension.h"
#include "core/fxcrt/xml/cfx_xmlchardata.h"
-#include "core/fxcrt/xml/cfx_xmldoc.h"
#include "core/fxcrt/xml/cfx_xmlelement.h"
#include "core/fxcrt/xml/cfx_xmlinstruction.h"
#include "core/fxcrt/xml/cfx_xmlnode.h"
@@ -345,11 +344,10 @@ bool CXFA_DocumentParser::Parse(const RetainPtr<IFX_SeekableStream>& pStream,
pStreamProxy->SetCodePage(FX_CODEPAGE_UTF8);
}
- CFX_XMLDoc doc;
- if (!doc.Load(pStreamProxy))
+ m_pNodeTree = LoadXML(pStreamProxy);
+ if (!m_pNodeTree)
return false;
- m_pNodeTree = doc.GetTree();
m_pRootNode = ParseAsXDPPacket(GetDocumentNode(m_pNodeTree.get()), ePacketID);
return !!m_pRootNode;
}
@@ -357,13 +355,21 @@ bool CXFA_DocumentParser::Parse(const RetainPtr<IFX_SeekableStream>& pStream,
CFX_XMLNode* CXFA_DocumentParser::ParseXMLData(const ByteString& wsXML) {
auto pStream = pdfium::MakeRetain<CFX_SeekableStreamProxy>(
const_cast<uint8_t*>(wsXML.raw_str()), wsXML.GetLength());
- CFX_XMLDoc doc;
- if (doc.Load(pStream))
- m_pNodeTree = doc.GetTree();
-
+ m_pNodeTree = LoadXML(pStream);
return m_pNodeTree ? GetDocumentNode(m_pNodeTree.get()) : nullptr;
}
+std::unique_ptr<CFX_XMLNode> CXFA_DocumentParser::LoadXML(
+ const RetainPtr<CFX_SeekableStreamProxy>& pStream) {
+ ASSERT(pStream);
+
+ auto root = pdfium::MakeUnique<CFX_XMLNode>();
+ root->AppendChild(new CFX_XMLInstruction(L"xml"));
+
+ CFX_XMLParser parser(root.get(), pStream);
+ return parser.Parse() ? std::move(root) : nullptr;
+}
+
void CXFA_DocumentParser::ConstructXFANode(CXFA_Node* pXFANode,
CFX_XMLNode* pXMLNode) {
XFA_PacketType ePacketID = pXFANode->GetPacketType();
diff --git a/xfa/fxfa/parser/cxfa_document_parser.h b/xfa/fxfa/parser/cxfa_document_parser.h
index e41bf7bf07..8899494c79 100644
--- a/xfa/fxfa/parser/cxfa_document_parser.h
+++ b/xfa/fxfa/parser/cxfa_document_parser.h
@@ -39,6 +39,9 @@ class CXFA_DocumentParser {
void SetFactory(CXFA_Document* pFactory);
private:
+ std::unique_ptr<CFX_XMLNode> LoadXML(
+ const RetainPtr<CFX_SeekableStreamProxy>& pStream);
+
CXFA_Node* ParseAsXDPPacket(CFX_XMLNode* pXMLDocumentNode,
XFA_PacketType ePacketID);
CXFA_Node* ParseAsXDPPacket_XDP(CFX_XMLNode* pXMLDocumentNode);