OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #ifndef XFA_FXFA_PARSER_XFA_OBJECT_H_ | 7 #ifndef XFA_FXFA_PARSER_XFA_OBJECT_H_ |
8 #define XFA_FXFA_PARSER_XFA_OBJECT_H_ | 8 #define XFA_FXFA_PARSER_XFA_OBJECT_H_ |
9 | 9 |
10 #include <unordered_set> | 10 #include <unordered_set> |
11 | 11 |
12 #include "fxjse/include/cfxjse_arguments.h" | 12 #include "fxjse/include/cfxjse_arguments.h" |
13 #include "xfa/fde/xml/fde_xml.h" | 13 #include "xfa/fde/xml/fde_xml.h" |
14 #include "xfa/fxfa/parser/xfa_utils.h" | 14 #include "xfa/fxfa/parser/xfa_utils.h" |
15 | 15 |
16 class CXFA_Document; | 16 class CXFA_Document; |
17 class CXFA_Node; | 17 class CXFA_Node; |
18 class CXFA_NodeList; | 18 class CXFA_NodeList; |
19 class CXFA_OrdinaryObject; | |
20 | 19 |
21 enum class XFA_ObjectType { | 20 enum class XFA_ObjectType { |
22 OrdinaryObject, | 21 Object, |
23 OrdinaryList, | 22 OrdinaryList, |
24 NodeList, | 23 NodeList, |
25 Node, | 24 Node, |
26 NodeC, | 25 NodeC, |
27 NodeV, | 26 NodeV, |
28 ModelNode, | 27 ModelNode, |
29 TextNode, | 28 TextNode, |
30 ContainerNode, | 29 ContainerNode, |
31 ContentNode, | 30 ContentNode, |
32 VariablesThis | 31 VariablesThis |
(...skipping 25 matching lines...) Expand all Loading... |
58 bool IsNode() const { | 57 bool IsNode() const { |
59 return m_objectType == XFA_ObjectType::Node || | 58 return m_objectType == XFA_ObjectType::Node || |
60 m_objectType == XFA_ObjectType::NodeC || | 59 m_objectType == XFA_ObjectType::NodeC || |
61 m_objectType == XFA_ObjectType::NodeV || | 60 m_objectType == XFA_ObjectType::NodeV || |
62 m_objectType == XFA_ObjectType::ModelNode || | 61 m_objectType == XFA_ObjectType::ModelNode || |
63 m_objectType == XFA_ObjectType::TextNode || | 62 m_objectType == XFA_ObjectType::TextNode || |
64 m_objectType == XFA_ObjectType::ContainerNode || | 63 m_objectType == XFA_ObjectType::ContainerNode || |
65 m_objectType == XFA_ObjectType::ContentNode || | 64 m_objectType == XFA_ObjectType::ContentNode || |
66 m_objectType == XFA_ObjectType::VariablesThis; | 65 m_objectType == XFA_ObjectType::VariablesThis; |
67 } | 66 } |
68 bool IsOrdinaryObject() const { | |
69 return m_objectType == XFA_ObjectType::OrdinaryObject; | |
70 } | |
71 bool IsNodeList() const { return m_objectType == XFA_ObjectType::NodeList; } | 67 bool IsNodeList() const { return m_objectType == XFA_ObjectType::NodeList; } |
72 bool IsOrdinaryList() const { | 68 bool IsOrdinaryList() const { |
73 return m_objectType == XFA_ObjectType::OrdinaryList; | 69 return m_objectType == XFA_ObjectType::OrdinaryList; |
74 } | 70 } |
75 bool IsContentNode() const { | 71 bool IsContentNode() const { |
76 return m_objectType == XFA_ObjectType::ContentNode; | 72 return m_objectType == XFA_ObjectType::ContentNode; |
77 } | 73 } |
78 bool IsContainerNode() const { | 74 bool IsContainerNode() const { |
79 return m_objectType == XFA_ObjectType::ContainerNode; | 75 return m_objectType == XFA_ObjectType::ContainerNode; |
80 } | 76 } |
81 bool IsModelNode() const { return m_objectType == XFA_ObjectType::ModelNode; } | 77 bool IsModelNode() const { return m_objectType == XFA_ObjectType::ModelNode; } |
82 bool IsNodeV() const { return m_objectType == XFA_ObjectType::NodeV; } | 78 bool IsNodeV() const { return m_objectType == XFA_ObjectType::NodeV; } |
83 bool IsVariablesThis() const { | 79 bool IsVariablesThis() const { |
84 return m_objectType == XFA_ObjectType::VariablesThis; | 80 return m_objectType == XFA_ObjectType::VariablesThis; |
85 } | 81 } |
86 | 82 |
87 CXFA_Node* AsNode(); | 83 CXFA_Node* AsNode(); |
88 CXFA_OrdinaryObject* AsOrdinaryObject(); | |
89 CXFA_NodeList* AsNodeList(); | 84 CXFA_NodeList* AsNodeList(); |
90 | 85 |
91 const CXFA_Node* AsNode() const; | 86 const CXFA_Node* AsNode() const; |
92 const CXFA_OrdinaryObject* AsOrdinaryObject() const; | |
93 const CXFA_NodeList* AsNodeList() const; | 87 const CXFA_NodeList* AsNodeList() const; |
94 | 88 |
95 XFA_Element GetElementType() const; | 89 XFA_Element GetElementType() const; |
96 void GetClassName(CFX_WideStringC& wsName) const; | 90 void GetClassName(CFX_WideStringC& wsName) const; |
97 uint32_t GetClassHashCode() const; | 91 uint32_t GetClassHashCode() const; |
98 void Script_ObjectClass_ClassName(CFXJSE_Value* pValue, | 92 void Script_ObjectClass_ClassName(CFXJSE_Value* pValue, |
99 FX_BOOL bSetting, | 93 FX_BOOL bSetting, |
100 XFA_ATTRIBUTE eAttribute); | 94 XFA_ATTRIBUTE eAttribute); |
101 void ThrowException(int32_t iStringID, ...); | 95 void ThrowException(int32_t iStringID, ...); |
102 | 96 |
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
677 CXFA_Node* m_pLastChild; | 671 CXFA_Node* m_pLastChild; |
678 CXFA_Node* m_pParent; | 672 CXFA_Node* m_pParent; |
679 CFDE_XMLNode* m_pXMLNode; | 673 CFDE_XMLNode* m_pXMLNode; |
680 uint16_t m_ePacket; | 674 uint16_t m_ePacket; |
681 uint16_t m_uNodeFlags; | 675 uint16_t m_uNodeFlags; |
682 uint32_t m_dwNameHash; | 676 uint32_t m_dwNameHash; |
683 CXFA_Node* m_pAuxNode; | 677 CXFA_Node* m_pAuxNode; |
684 XFA_MAPMODULEDATA* m_pMapModuleData; | 678 XFA_MAPMODULEDATA* m_pMapModuleData; |
685 }; | 679 }; |
686 | 680 |
687 class CXFA_OrdinaryObject : public CXFA_Object { | |
688 public: | |
689 CXFA_OrdinaryObject(CXFA_Document* pDocument, XFA_Element eElement); | |
690 ~CXFA_OrdinaryObject() override; | |
691 }; | |
692 | |
693 class CXFA_ThisProxy : public CXFA_Object { | 681 class CXFA_ThisProxy : public CXFA_Object { |
694 public: | 682 public: |
695 CXFA_ThisProxy(CXFA_Node* pThisNode, CXFA_Node* pScriptNode); | 683 CXFA_ThisProxy(CXFA_Node* pThisNode, CXFA_Node* pScriptNode); |
696 ~CXFA_ThisProxy() override; | 684 ~CXFA_ThisProxy() override; |
697 | 685 |
698 CXFA_Node* GetThisNode() const; | 686 CXFA_Node* GetThisNode() const; |
699 CXFA_Node* GetScriptNode() const; | 687 CXFA_Node* GetScriptNode() const; |
700 | 688 |
701 private: | 689 private: |
702 CXFA_Node* m_pThisNode; | 690 CXFA_Node* m_pThisNode; |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
790 static inline CXFA_Node* GetParent(CXFA_Node* pTemplateNode) { | 778 static inline CXFA_Node* GetParent(CXFA_Node* pTemplateNode) { |
791 return pTemplateNode->GetNodeItem(XFA_NODEITEM_Parent); | 779 return pTemplateNode->GetNodeItem(XFA_NODEITEM_Parent); |
792 } | 780 } |
793 }; | 781 }; |
794 typedef CXFA_NodeIteratorTemplate<CXFA_Node, CXFA_TraverseStrategy_XFANode> | 782 typedef CXFA_NodeIteratorTemplate<CXFA_Node, CXFA_TraverseStrategy_XFANode> |
795 CXFA_NodeIterator; | 783 CXFA_NodeIterator; |
796 | 784 |
797 inline CXFA_Node* CXFA_Object::AsNode() { | 785 inline CXFA_Node* CXFA_Object::AsNode() { |
798 return IsNode() ? static_cast<CXFA_Node*>(this) : nullptr; | 786 return IsNode() ? static_cast<CXFA_Node*>(this) : nullptr; |
799 } | 787 } |
800 inline CXFA_OrdinaryObject* CXFA_Object::AsOrdinaryObject() { | 788 |
801 return IsOrdinaryObject() ? static_cast<CXFA_OrdinaryObject*>(this) : nullptr; | |
802 } | |
803 inline CXFA_NodeList* CXFA_Object::AsNodeList() { | 789 inline CXFA_NodeList* CXFA_Object::AsNodeList() { |
804 return IsNodeList() ? static_cast<CXFA_NodeList*>(this) : nullptr; | 790 return IsNodeList() ? static_cast<CXFA_NodeList*>(this) : nullptr; |
805 } | 791 } |
806 | 792 |
807 inline const CXFA_Node* CXFA_Object::AsNode() const { | 793 inline const CXFA_Node* CXFA_Object::AsNode() const { |
808 return IsNode() ? static_cast<const CXFA_Node*>(this) : nullptr; | 794 return IsNode() ? static_cast<const CXFA_Node*>(this) : nullptr; |
809 } | 795 } |
810 inline const CXFA_OrdinaryObject* CXFA_Object::AsOrdinaryObject() const { | 796 |
811 return IsOrdinaryObject() ? static_cast<const CXFA_OrdinaryObject*>(this) | |
812 : nullptr; | |
813 } | |
814 inline const CXFA_NodeList* CXFA_Object::AsNodeList() const { | 797 inline const CXFA_NodeList* CXFA_Object::AsNodeList() const { |
815 return IsNodeList() ? static_cast<const CXFA_NodeList*>(this) : nullptr; | 798 return IsNodeList() ? static_cast<const CXFA_NodeList*>(this) : nullptr; |
816 } | 799 } |
817 | 800 |
818 inline CXFA_Node* ToNode(CXFA_Object* pObj) { | 801 inline CXFA_Node* ToNode(CXFA_Object* pObj) { |
819 return pObj ? pObj->AsNode() : nullptr; | 802 return pObj ? pObj->AsNode() : nullptr; |
820 } | 803 } |
821 | 804 |
822 inline const CXFA_Node* ToNode(const CXFA_Object* pObj) { | 805 inline const CXFA_Node* ToNode(const CXFA_Object* pObj) { |
823 return pObj ? pObj->AsNode() : nullptr; | 806 return pObj ? pObj->AsNode() : nullptr; |
824 } | 807 } |
825 | 808 |
826 #endif // XFA_FXFA_PARSER_XFA_OBJECT_H_ | 809 #endif // XFA_FXFA_PARSER_XFA_OBJECT_H_ |
OLD | NEW |