diff options
-rw-r--r-- | xfa/fxfa/cxfa_ffdoc.cpp | 2 | ||||
-rw-r--r-- | xfa/fxfa/fxfa_basic.h | 2 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_dataimporter.cpp | 4 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_document_parser.cpp | 2 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_document_parser.h | 2 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_node.cpp | 4 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_node.h | 2 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_node_statics.cpp | 3 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_simple_parser.cpp | 49 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_simple_parser.h | 7 | ||||
-rw-r--r-- | xfa/fxfa/parser/xfa_basic_data_packets.cpp | 30 |
11 files changed, 52 insertions, 55 deletions
diff --git a/xfa/fxfa/cxfa_ffdoc.cpp b/xfa/fxfa/cxfa_ffdoc.cpp index 02f852f0d8..bf8168d4cc 100644 --- a/xfa/fxfa/cxfa_ffdoc.cpp +++ b/xfa/fxfa/cxfa_ffdoc.cpp @@ -169,7 +169,7 @@ CXFA_FFDoc::~CXFA_FFDoc() { int32_t CXFA_FFDoc::StartLoad() { m_pNotify = pdfium::MakeUnique<CXFA_FFNotify>(this); m_pDocumentParser = pdfium::MakeUnique<CXFA_DocumentParser>(m_pNotify.get()); - return m_pDocumentParser->StartParse(m_pStream, XFA_XDPPACKET_XDP); + return m_pDocumentParser->StartParse(m_pStream, XFA_PacketType::Xdp); } bool XFA_GetPDFContentsFromPDFXML(CFX_XMLNode* pPDFElement, diff --git a/xfa/fxfa/fxfa_basic.h b/xfa/fxfa/fxfa_basic.h index f4d3383ae8..6094512995 100644 --- a/xfa/fxfa/fxfa_basic.h +++ b/xfa/fxfa/fxfa_basic.h @@ -100,7 +100,7 @@ enum XFA_XDPPACKET_FLAGS { struct XFA_PACKETINFO { uint32_t uHash; const wchar_t* pName; - XFA_XDPPACKET eName; + XFA_PacketType eName; const wchar_t* pURI; uint32_t eFlags; }; diff --git a/xfa/fxfa/parser/cxfa_dataimporter.cpp b/xfa/fxfa/parser/cxfa_dataimporter.cpp index 61daff3698..28d0a8ce2a 100644 --- a/xfa/fxfa/parser/cxfa_dataimporter.cpp +++ b/xfa/fxfa/parser/cxfa_dataimporter.cpp @@ -28,8 +28,8 @@ bool CXFA_DataImporter::ImportData( const RetainPtr<IFX_SeekableStream>& pDataDocument) { auto pDataDocumentParser = pdfium::MakeUnique<CXFA_SimpleParser>(m_pDocument.Get(), false); - if (pDataDocumentParser->StartParse(pDataDocument, XFA_XDPPACKET_Datasets) != - XFA_PARSESTATUS_Ready) { + if (pDataDocumentParser->StartParse( + pDataDocument, XFA_PacketType::Datasets) != XFA_PARSESTATUS_Ready) { return false; } if (pDataDocumentParser->DoParse() < XFA_PARSESTATUS_Done) diff --git a/xfa/fxfa/parser/cxfa_document_parser.cpp b/xfa/fxfa/parser/cxfa_document_parser.cpp index b8ff8f860c..0cc03b94d0 100644 --- a/xfa/fxfa/parser/cxfa_document_parser.cpp +++ b/xfa/fxfa/parser/cxfa_document_parser.cpp @@ -19,7 +19,7 @@ CXFA_DocumentParser::~CXFA_DocumentParser() { int32_t CXFA_DocumentParser::StartParse( const RetainPtr<IFX_SeekableStream>& pStream, - XFA_XDPPACKET ePacketID) { + XFA_PacketType ePacketID) { m_pDocument.reset(); m_nodeParser.CloseParser(); diff --git a/xfa/fxfa/parser/cxfa_document_parser.h b/xfa/fxfa/parser/cxfa_document_parser.h index e788480751..a3c2365b7b 100644 --- a/xfa/fxfa/parser/cxfa_document_parser.h +++ b/xfa/fxfa/parser/cxfa_document_parser.h @@ -23,7 +23,7 @@ class CXFA_DocumentParser { ~CXFA_DocumentParser(); int32_t StartParse(const RetainPtr<IFX_SeekableStream>& pStream, - XFA_XDPPACKET ePacketID); + XFA_PacketType ePacketID); int32_t DoParse(); CFX_XMLDoc* GetXMLDoc() const; diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp index ff0a60172f..3207010fcb 100644 --- a/xfa/fxfa/parser/cxfa_node.cpp +++ b/xfa/fxfa/parser/cxfa_node.cpp @@ -261,8 +261,8 @@ CXFA_Node* CXFA_Node::GetNodeItem(XFA_NODEITEM eItem) const { return nullptr; } -bool CXFA_Node::IsValidInPacket(XFA_XDPPACKET packet) const { - return !!(m_ValidPackets & packet); +bool CXFA_Node::IsValidInPacket(XFA_PacketType packet) const { + return !!(m_ValidPackets & (1 << static_cast<uint8_t>(packet))); } const CXFA_Node::PropertyData* CXFA_Node::GetPropertyData( diff --git a/xfa/fxfa/parser/cxfa_node.h b/xfa/fxfa/parser/cxfa_node.h index 066be5e8fe..4a2a2777a5 100644 --- a/xfa/fxfa/parser/cxfa_node.h +++ b/xfa/fxfa/parser/cxfa_node.h @@ -74,7 +74,7 @@ class CXFA_Node : public CXFA_Object { ~CXFA_Node() override; - bool IsValidInPacket(XFA_XDPPACKET packet) const; + bool IsValidInPacket(XFA_PacketType packet) const; bool HasProperty(XFA_Element property) const; bool HasPropertyFlags(XFA_Element property, uint8_t flags) const; diff --git a/xfa/fxfa/parser/cxfa_node_statics.cpp b/xfa/fxfa/parser/cxfa_node_statics.cpp index 64b70ee88b..2508890ff8 100644 --- a/xfa/fxfa/parser/cxfa_node_statics.cpp +++ b/xfa/fxfa/parser/cxfa_node_statics.cpp @@ -1864,8 +1864,7 @@ std::unique_ptr<CXFA_Node> CXFA_Node::Create(CXFA_Document* doc, NOTREACHED(); return nullptr; } - if (!node || !node->IsValidInPacket(static_cast<XFA_XDPPACKET>( - 1 << static_cast<uint8_t>(packet)))) + if (!node || !node->IsValidInPacket(packet)) return nullptr; return node; } 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); } diff --git a/xfa/fxfa/parser/cxfa_simple_parser.h b/xfa/fxfa/parser/cxfa_simple_parser.h index f7465b64d6..5ae9b43be3 100644 --- a/xfa/fxfa/parser/cxfa_simple_parser.h +++ b/xfa/fxfa/parser/cxfa_simple_parser.h @@ -26,7 +26,7 @@ class CXFA_SimpleParser { ~CXFA_SimpleParser(); int32_t StartParse(const RetainPtr<IFX_SeekableStream>& pStream, - XFA_XDPPACKET ePacketID); + XFA_PacketType ePacketID); int32_t DoParse(); CFX_XMLNode* ParseXMLData(const ByteString& wsXML); void ConstructXFANode(CXFA_Node* pXFANode, CFX_XMLNode* pXMLNode); @@ -38,7 +38,7 @@ class CXFA_SimpleParser { private: CXFA_Node* ParseAsXDPPacket(CFX_XMLNode* pXMLDocumentNode, - XFA_XDPPACKET ePacketID); + XFA_PacketType ePacketID); CXFA_Node* ParseAsXDPPacket_XDP(CFX_XMLNode* pXMLDocumentNode); CXFA_Node* ParseAsXDPPacket_Config(CFX_XMLNode* pXMLDocumentNode, XFA_PacketType ePacketID); @@ -77,7 +77,8 @@ class CXFA_SimpleParser { RetainPtr<IFX_SeekableStream> m_pFileRead; CXFA_Document* m_pFactory; CXFA_Node* m_pRootNode; - XFA_XDPPACKET m_ePacketID; + XFA_PacketType m_ePacketID; + bool m_bParseStarted; bool m_bDocumentParser; }; diff --git a/xfa/fxfa/parser/xfa_basic_data_packets.cpp b/xfa/fxfa/parser/xfa_basic_data_packets.cpp index 39a09dabd0..91e2d3cc6e 100644 --- a/xfa/fxfa/parser/xfa_basic_data_packets.cpp +++ b/xfa/fxfa/parser/xfa_basic_data_packets.cpp @@ -9,44 +9,44 @@ #include "xfa/fxfa/fxfa_basic.h" const XFA_PACKETINFO g_XFAPacketData[] = { - {0x0, nullptr, XFA_XDPPACKET_USER, nullptr, + {0x0, nullptr, XFA_PacketType::User, nullptr, XFA_XDPPACKET_FLAGS_NOMATCH | XFA_XDPPACKET_FLAGS_SUPPORTMANY}, - {0x811929d, L"sourceSet", XFA_XDPPACKET_SourceSet, + {0x811929d, L"sourceSet", XFA_PacketType::SourceSet, L"http://www.xfa.org/schema/xfa-source-set/", XFA_XDPPACKET_FLAGS_NOMATCH | XFA_XDPPACKET_FLAGS_SUPPORTONE}, - {0xb843dba, L"pdf", XFA_XDPPACKET_Pdf, L"http://ns.adobe.com/xdp/pdf/", + {0xb843dba, L"pdf", XFA_PacketType::Pdf, L"http://ns.adobe.com/xdp/pdf/", XFA_XDPPACKET_FLAGS_COMPLETEMATCH | XFA_XDPPACKET_FLAGS_SUPPORTONE}, - {0xc56afbf, L"xdc", XFA_XDPPACKET_Xdc, L"http://www.xfa.org/schema/xdc/", + {0xc56afbf, L"xdc", XFA_PacketType::Xdc, L"http://www.xfa.org/schema/xdc/", XFA_XDPPACKET_FLAGS_NOMATCH | XFA_XDPPACKET_FLAGS_SUPPORTONE}, - {0xc56afcc, L"xdp", XFA_XDPPACKET_XDP, L"http://ns.adobe.com/xdp/", + {0xc56afcc, L"xdp", XFA_PacketType::Xdp, L"http://ns.adobe.com/xdp/", XFA_XDPPACKET_FLAGS_COMPLETEMATCH | XFA_XDPPACKET_FLAGS_SUPPORTONE}, - {0x132a8fbc, L"xmpmeta", XFA_XDPPACKET_Xmpmeta, + {0x132a8fbc, L"xmpmeta", XFA_PacketType::Xmpmeta, L"http://ns.adobe.com/xmpmeta/", XFA_XDPPACKET_FLAGS_NOMATCH | XFA_XDPPACKET_FLAGS_SUPPORTMANY}, - {0x48d004a8, L"xfdf", XFA_XDPPACKET_Xfdf, L"http://ns.adobe.com/xfdf/", + {0x48d004a8, L"xfdf", XFA_PacketType::Xfdf, L"http://ns.adobe.com/xfdf/", XFA_XDPPACKET_FLAGS_NOMATCH | XFA_XDPPACKET_FLAGS_SUPPORTONE}, - {0x4e1e39b6, L"config", XFA_XDPPACKET_Config, + {0x4e1e39b6, L"config", XFA_PacketType::Config, L"http://www.xfa.org/schema/xci/", XFA_XDPPACKET_FLAGS_NOMATCH | XFA_XDPPACKET_FLAGS_SUPPORTONE}, - {0x5473b6dc, L"localeSet", XFA_XDPPACKET_LocaleSet, + {0x5473b6dc, L"localeSet", XFA_PacketType::LocaleSet, L"http://www.xfa.org/schema/xfa-locale-set/", XFA_XDPPACKET_FLAGS_NOMATCH | XFA_XDPPACKET_FLAGS_SUPPORTONE}, - {0x6038580a, L"stylesheet", XFA_XDPPACKET_Stylesheet, + {0x6038580a, L"stylesheet", XFA_PacketType::Stylesheet, L"http://www.w3.org/1999/XSL/Transform", XFA_XDPPACKET_FLAGS_NOMATCH | XFA_XDPPACKET_FLAGS_SUPPORTMANY}, - {0x803550fc, L"template", XFA_XDPPACKET_Template, + {0x803550fc, L"template", XFA_PacketType::Template, L"http://www.xfa.org/schema/xfa-template/", XFA_XDPPACKET_FLAGS_NOMATCH | XFA_XDPPACKET_FLAGS_SUPPORTONE}, - {0x8b036f32, L"signature", XFA_XDPPACKET_Signature, + {0x8b036f32, L"signature", XFA_PacketType::Signature, L"http://www.w3.org/2000/09/xmldsig#", XFA_XDPPACKET_FLAGS_NOMATCH | XFA_XDPPACKET_FLAGS_SUPPORTONE}, - {0x99b95079, L"datasets", XFA_XDPPACKET_Datasets, + {0x99b95079, L"datasets", XFA_PacketType::Datasets, L"http://www.xfa.org/schema/xfa-data/", XFA_XDPPACKET_FLAGS_PREFIXMATCH | XFA_XDPPACKET_FLAGS_SUPPORTONE}, - {0xcd309ff4, L"form", XFA_XDPPACKET_Form, + {0xcd309ff4, L"form", XFA_PacketType::Form, L"http://www.xfa.org/schema/xfa-form/", XFA_XDPPACKET_FLAGS_NOMATCH | XFA_XDPPACKET_FLAGS_SUPPORTONE}, - {0xe14c801c, L"connectionSet", XFA_XDPPACKET_ConnectionSet, + {0xe14c801c, L"connectionSet", XFA_PacketType::ConnectionSet, L"http://www.xfa.org/schema/xfa-connection-set/", XFA_XDPPACKET_FLAGS_NOMATCH | XFA_XDPPACKET_FLAGS_SUPPORTONE}, }; |