summaryrefslogtreecommitdiff
path: root/xfa/fxfa/parser/cxfa_simple_parser.cpp
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-11-30 21:48:20 +0000
committerChromium commit bot <commit-bot@chromium.org>2017-11-30 21:48:20 +0000
commite06c542ffdc7325cb3c430e59bd0d9df4ddb7776 (patch)
tree3ca7f1e31c4b103920b6cc14e966b347cc4a8905 /xfa/fxfa/parser/cxfa_simple_parser.cpp
parentc40c5aa2d7f1753dd382c35955deafdaca660020 (diff)
downloadpdfium-e06c542ffdc7325cb3c430e59bd0d9df4ddb7776.tar.xz
Make parsers work off XFA_PacketType enum
This CL changes the various parsers to use XFA_PacketType instead of XFA_XDPPACKET. This just leaves XFA_XDPPACKET for determining if a given node can be created in a given packet. Change-Id: I6fd23480c0c780a131d23b64b7c7e9d8684b0220 Reviewed-on: https://pdfium-review.googlesource.com/20013 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'xfa/fxfa/parser/cxfa_simple_parser.cpp')
-rw-r--r--xfa/fxfa/parser/cxfa_simple_parser.cpp49
1 files changed, 23 insertions, 26 deletions
diff --git a/xfa/fxfa/parser/cxfa_simple_parser.cpp b/xfa/fxfa/parser/cxfa_simple_parser.cpp
index e5f3f688fe..67d6f80b6d 100644
--- a/xfa/fxfa/parser/cxfa_simple_parser.cpp
+++ b/xfa/fxfa/parser/cxfa_simple_parser.cpp
@@ -238,12 +238,10 @@ bool XFA_RecognizeRichText(CFX_XMLElement* pRichTextXMLNode) {
CXFA_SimpleParser::CXFA_SimpleParser(CXFA_Document* pFactory,
bool bDocumentParser)
: m_pXMLParser(nullptr),
- m_pXMLDoc(nullptr),
- m_pStream(nullptr),
- m_pFileRead(nullptr),
m_pFactory(pFactory),
m_pRootNode(nullptr),
- m_ePacketID(XFA_XDPPACKET_UNKNOWN),
+ m_ePacketID(XFA_PacketType::User),
+ m_bParseStarted(false),
m_bDocumentParser(bDocumentParser) {}
CXFA_SimpleParser::~CXFA_SimpleParser() {}
@@ -254,7 +252,7 @@ void CXFA_SimpleParser::SetFactory(CXFA_Document* pFactory) {
int32_t CXFA_SimpleParser::StartParse(
const RetainPtr<IFX_SeekableStream>& pStream,
- XFA_XDPPACKET ePacketID) {
+ XFA_PacketType ePacketID) {
CloseParser();
m_pFileRead = pStream;
m_pStream = pdfium::MakeRetain<CFX_SeekableStreamProxy>(pStream, false);
@@ -270,12 +268,13 @@ int32_t CXFA_SimpleParser::StartParse(
if (!m_pXMLDoc->LoadXML(std::move(pNewParser)))
return XFA_PARSESTATUS_StatusErr;
+ m_bParseStarted = true;
m_ePacketID = ePacketID;
return XFA_PARSESTATUS_Ready;
}
int32_t CXFA_SimpleParser::DoParse() {
- if (!m_pXMLDoc || m_ePacketID == XFA_XDPPACKET_UNKNOWN)
+ if (!m_pXMLDoc || !m_bParseStarted)
return XFA_PARSESTATUS_StatusErr;
int32_t iRet = m_pXMLDoc->DoLoad();
@@ -398,31 +397,29 @@ bool XFA_FDEExtension_ResolveNamespaceQualifier(CFX_XMLElement* pNode,
}
CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket(CFX_XMLNode* pXMLDocumentNode,
- XFA_XDPPACKET ePacketID) {
+ XFA_PacketType ePacketID) {
switch (ePacketID) {
- case XFA_XDPPACKET_UNKNOWN:
- return nullptr;
- case XFA_XDPPACKET_XDP:
+ case XFA_PacketType::Xdp:
return ParseAsXDPPacket_XDP(pXMLDocumentNode);
- case XFA_XDPPACKET_Config:
+ case XFA_PacketType::Config:
return ParseAsXDPPacket_Config(pXMLDocumentNode, XFA_PacketType::Config);
- case XFA_XDPPACKET_Template:
+ case XFA_PacketType::Template:
return ParseAsXDPPacket_TemplateForm(pXMLDocumentNode,
XFA_PacketType::Template);
- case XFA_XDPPACKET_Form:
+ case XFA_PacketType::Form:
return ParseAsXDPPacket_TemplateForm(pXMLDocumentNode,
XFA_PacketType::Form);
- case XFA_XDPPACKET_Datasets:
+ case XFA_PacketType::Datasets:
return ParseAsXDPPacket_Data(pXMLDocumentNode);
- case XFA_XDPPACKET_Xdc:
+ case XFA_PacketType::Xdc:
return ParseAsXDPPacket_Xdc(pXMLDocumentNode);
- case XFA_XDPPACKET_LocaleSet:
+ case XFA_PacketType::LocaleSet:
return ParseAsXDPPacket_LocaleConnectionSourceSet(
pXMLDocumentNode, XFA_PacketType::LocaleSet);
- case XFA_XDPPACKET_ConnectionSet:
+ case XFA_PacketType::ConnectionSet:
return ParseAsXDPPacket_LocaleConnectionSourceSet(
pXMLDocumentNode, XFA_PacketType::ConnectionSet);
- case XFA_XDPPACKET_SourceSet:
+ case XFA_PacketType::SourceSet:
return ParseAsXDPPacket_LocaleConnectionSourceSet(
pXMLDocumentNode, XFA_PacketType::SourceSet);
default:
@@ -501,21 +498,21 @@ CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_XDP(
pPacketInfo = nullptr;
}
}
- XFA_XDPPACKET ePacket =
- pPacketInfo ? pPacketInfo->eName : XFA_XDPPACKET_USER;
- if (ePacket == XFA_XDPPACKET_XDP)
+ XFA_PacketType ePacket =
+ pPacketInfo ? pPacketInfo->eName : XFA_PacketType::User;
+ if (ePacket == XFA_PacketType::Xdp)
continue;
- if (ePacket == XFA_XDPPACKET_Datasets) {
+ if (ePacket == XFA_PacketType::Datasets) {
if (pXMLDatasetsDOMRoot)
return nullptr;
pXMLDatasetsDOMRoot = pElement;
- } else if (ePacket == XFA_XDPPACKET_Form) {
+ } else if (ePacket == XFA_PacketType::Form) {
if (pXMLFormDOMRoot)
return nullptr;
pXMLFormDOMRoot = pElement;
- } else if (ePacket == XFA_XDPPACKET_Template) {
+ } else if (ePacket == XFA_PacketType::Template) {
// Found a duplicate template packet.
if (pXMLTemplateDOMRoot)
return nullptr;
@@ -544,13 +541,13 @@ CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_XDP(
if (pXMLDatasetsDOMRoot) {
CXFA_Node* pPacketNode =
- ParseAsXDPPacket(pXMLDatasetsDOMRoot, XFA_XDPPACKET_Datasets);
+ ParseAsXDPPacket(pXMLDatasetsDOMRoot, XFA_PacketType::Datasets);
if (pPacketNode)
pXFARootNode->InsertChild(pPacketNode, nullptr);
}
if (pXMLFormDOMRoot) {
CXFA_Node* pPacketNode =
- ParseAsXDPPacket(pXMLFormDOMRoot, XFA_XDPPACKET_Form);
+ ParseAsXDPPacket(pXMLFormDOMRoot, XFA_PacketType::Form);
if (pPacketNode)
pXFARootNode->InsertChild(pPacketNode, nullptr);
}