From f473672fd6305fe97c749bde3b92e3c9c90e88d0 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Mon, 27 Nov 2017 18:10:47 +0000 Subject: Generate XFA node classes This CL adds concrete classes for each of the XFA Node types. Change-Id: Ieac8e2fcd5d13c61daa27fc63e3d80abb7aa7a29 Reviewed-on: https://pdfium-review.googlesource.com/18271 Reviewed-by: Tom Sepez Commit-Queue: dsinclair --- xfa/fxfa/parser/cxfa_node.h | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) (limited to 'xfa/fxfa/parser/cxfa_node.h') diff --git a/xfa/fxfa/parser/cxfa_node.h b/xfa/fxfa/parser/cxfa_node.h index dc4710a9c6..7b7086ecb5 100644 --- a/xfa/fxfa/parser/cxfa_node.h +++ b/xfa/fxfa/parser/cxfa_node.h @@ -9,6 +9,7 @@ #include #include +#include #include #include "core/fxcrt/fx_string.h" @@ -46,12 +47,28 @@ const XFA_ATTRIBUTEENUMINFO* GetAttributeEnumByID(XFA_ATTRIBUTEENUM eName); class CXFA_Node : public CXFA_Object { public: + struct PropertyData { + XFA_Element property; + uint8_t occurance_count; + uint8_t flags; + }; + + static XFA_Element NameToElement(const WideString& name); static std::unique_ptr Create(CXFA_Document* doc, - XFA_XDPPACKET packet, - const XFA_ELEMENTINFO* pElement); + XFA_Element element, + XFA_XDPPACKET packet); ~CXFA_Node() override; + bool IsValidInPacket(XFA_XDPPACKET packet) const; + + bool HasProperty(XFA_Element property) const; + bool HasPropertyFlags(XFA_Element property, uint8_t flags) const; + uint8_t PropertyOccuranceCount(XFA_Element property) const; + + bool HasAttribute(XFA_Attribute attr) const; + XFA_Attribute GetAttribute(size_t i) const; + uint32_t GetPacketID() const { return m_ePacket; } void SetFlag(uint32_t dwFlag, bool bNotify); @@ -148,18 +165,26 @@ class CXFA_Node : public CXFA_Object { pdfium::Optional GetDefaultCData(XFA_Attribute attr) const; pdfium::Optional GetDefaultEnum(XFA_Attribute attr) const; - private: + protected: CXFA_Node(CXFA_Document* pDoc, uint16_t ePacket, + uint32_t validPackets, XFA_ObjectType oType, XFA_Element eType, + const PropertyData* properties, + const XFA_Attribute* attributes, const WideStringView& elementName); + private: bool HasFlag(XFA_NodeFlag dwFlag) const; CXFA_Node* Deprecated_GetPrevSibling(); - + const PropertyData* GetPropertyData(XFA_Element property) const; + pdfium::Optional GetFirstPropertyWithFlag(uint8_t flag); void OnRemoved(bool bNotify); + const PropertyData* m_Properties; + const XFA_Attribute* m_Attributes; + uint32_t m_ValidPackets; CXFA_Node* m_pNext; CXFA_Node* m_pChild; CXFA_Node* m_pLastChild; -- cgit v1.2.3