diff options
Diffstat (limited to 'xfa')
-rw-r--r-- | xfa/fxfa/parser/cxfa_document.cpp | 15 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_node.cpp | 8 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_node.h | 7 |
3 files changed, 20 insertions, 10 deletions
diff --git a/xfa/fxfa/parser/cxfa_document.cpp b/xfa/fxfa/parser/cxfa_document.cpp index c80dec979a..c374b762ba 100644 --- a/xfa/fxfa/parser/cxfa_document.cpp +++ b/xfa/fxfa/parser/cxfa_document.cpp @@ -214,15 +214,14 @@ CXFA_Node* CXFA_Document::CreateNode(const XFA_PACKETINFO* pPacket, return nullptr; const XFA_ELEMENTINFO* pElement = XFA_GetElementByID(eElement); - if (pElement && (pElement->dwPackets & pPacket->eName)) { - CXFA_Node* pNode = - new CXFA_Node(this, pPacket->eName, pElement->eObjectType, - pElement->eName, pElement->pName); - AddPurgeNode(pNode); - return pNode; - } + if (!pElement || !(pElement->dwPackets & pPacket->eName)) + return nullptr; - return nullptr; + std::unique_ptr<CXFA_Node> pNode = + CXFA_Node::Create(this, pPacket->eName, pElement); + // TODO(dsinclair): AddPrugeNode should take ownership of the pointer. + AddPurgeNode(pNode.get()); + return pNode.release(); } void CXFA_Document::AddPurgeNode(CXFA_Node* pNode) { diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp index a91b87766d..2ab0b18cf5 100644 --- a/xfa/fxfa/parser/cxfa_node.cpp +++ b/xfa/fxfa/parser/cxfa_node.cpp @@ -143,6 +143,14 @@ const XFA_ATTRIBUTEENUMINFO* GetAttributeEnumByID(XFA_ATTRIBUTEENUM eName) { return g_XFAEnumData + eName; } +// static +std::unique_ptr<CXFA_Node> CXFA_Node::Create(CXFA_Document* doc, + XFA_XDPPACKET packet, + const XFA_ELEMENTINFO* pElement) { + return std::unique_ptr<CXFA_Node>(new CXFA_Node( + doc, packet, pElement->eObjectType, pElement->eName, pElement->pName)); +} + CXFA_Node::CXFA_Node(CXFA_Document* pDoc, uint16_t ePacket, XFA_ObjectType oType, diff --git a/xfa/fxfa/parser/cxfa_node.h b/xfa/fxfa/parser/cxfa_node.h index 47be027d28..073fd5261f 100644 --- a/xfa/fxfa/parser/cxfa_node.h +++ b/xfa/fxfa/parser/cxfa_node.h @@ -8,6 +8,7 @@ #define XFA_FXFA_PARSER_CXFA_NODE_H_ #include <map> +#include <memory> #include <vector> #include "core/fxcrt/fx_string.h" @@ -45,6 +46,10 @@ const XFA_ATTRIBUTEENUMINFO* GetAttributeEnumByID(XFA_ATTRIBUTEENUM eName); class CXFA_Node : public CXFA_Object { public: + static std::unique_ptr<CXFA_Node> Create(CXFA_Document* doc, + XFA_XDPPACKET packet, + const XFA_ELEMENTINFO* pElement); + ~CXFA_Node() override; uint32_t GetPacketID() const { return m_ePacket; } @@ -136,8 +141,6 @@ class CXFA_Node : public CXFA_Object { CXFA_Node* GetOccurNode(); private: - friend class CXFA_Document; - CXFA_Node(CXFA_Document* pDoc, uint16_t ePacket, XFA_ObjectType oType, |