Home | History | Annotate | Download | only in common
      1 // Copyright 2014 PDFium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
      6 
      7 #ifndef _XFA_OBJECT_H_
      8 #define _XFA_OBJECT_H_
      9 class CXFA_Document;
     10 class IXFA_ObjFactory;
     11 class IXFA_Notify;
     12 class CXFA_Object;
     13 class CXFA_OrdinaryObject;
     14 class CXFA_Node;
     15 class CXFA_NodeList;
     16 class CXFA_ArrayNodeList;
     17 class CXFA_AttachNodeList;
     18 enum XFA_OBJECTTYPE {
     19   XFA_OBJECTTYPE_OrdinaryObject = 0x0,
     20   XFA_OBJECTTYPE_OrdinaryList = 0x1,
     21   XFA_OBJECTTYPE_NodeList = 0x2,
     22   XFA_OBJECTTYPE_Node = 0x4,
     23   XFA_OBJECTTYPE_NodeC = 0x5,
     24   XFA_OBJECTTYPE_NodeV = 0x6,
     25   XFA_OBJECTTYPE_ModelNode = 0x8,
     26   XFA_OBJECTTYPE_TextNode = 0x9,
     27   XFA_OBJECTTYPE_ContainerNode = 0xA,
     28   XFA_OBJECTTYPE_ContentNode = 0xB,
     29   XFA_OBJECTTYPE_VariablesThis = 0xC,
     30   XFA_OBJECTTYPEMASK = 0xF,
     31   XFA_NODEFLAG_Initialized = 0x00020,
     32   XFA_NODEFLAG_HasRemoved = 0x00200,
     33   XFA_NODEFLAG_NeedsInitApp = 0x00400,
     34   XFA_NODEFLAG_BindFormItems = 0x00800,
     35   XFA_NODEFLAG_UserInteractive = 0x01000,
     36   XFA_NODEFLAG_SkipDataBinding = 0x02000,
     37   XFA_NODEFLAG_OwnXMLNode = 0x04000,
     38   XFA_NODEFLAG_UnusedNode = 0x08000,
     39   XFA_NODEFLAG_LayoutGeneratedNode = 0x10000,
     40 };
     41 class CXFA_Object {
     42  public:
     43   CXFA_Object(CXFA_Document* pDocument, FX_DWORD uFlags);
     44   inline CXFA_Document* GetDocument() const { return m_pDocument; }
     45   inline FX_DWORD GetFlag() const { return m_uFlags; }
     46   inline XFA_OBJECTTYPE GetObjectType() const {
     47     return (XFA_OBJECTTYPE)(m_uFlags & XFA_OBJECTTYPEMASK);
     48   }
     49   inline FX_BOOL IsNode() const {
     50     return (m_uFlags & XFA_OBJECTTYPEMASK) >= XFA_OBJECTTYPE_Node;
     51   }
     52   inline FX_BOOL IsOrdinaryObject() const {
     53     return (m_uFlags & XFA_OBJECTTYPEMASK) == XFA_OBJECTTYPE_OrdinaryObject;
     54   }
     55   inline FX_BOOL IsNodeList() const {
     56     return (m_uFlags & XFA_OBJECTTYPEMASK) == XFA_OBJECTTYPE_NodeList;
     57   }
     58   inline FX_BOOL IsOrdinaryList() const {
     59     return (m_uFlags & XFA_OBJECTTYPEMASK) == XFA_OBJECTTYPE_OrdinaryList;
     60   }
     61   FX_BOOL IsContentNode() const {
     62     return (m_uFlags & XFA_OBJECTTYPEMASK) == XFA_OBJECTTYPE_ContentNode;
     63   }
     64   FX_BOOL IsContainerNode() const {
     65     return (m_uFlags & XFA_OBJECTTYPEMASK) == XFA_OBJECTTYPE_ContainerNode;
     66   }
     67   XFA_ELEMENT GetClassID() const;
     68   void GetClassName(CFX_WideStringC& wsName) const;
     69   uint32_t GetClassHashCode() const;
     70   void Script_ObjectClass_ClassName(FXJSE_HVALUE hValue,
     71                                     FX_BOOL bSetting,
     72                                     XFA_ATTRIBUTE eAttribute);
     73   void ThrowScriptErrorMessage(int32_t iStringID, ...);
     74 
     75  protected:
     76   CXFA_Document* m_pDocument;
     77   FX_DWORD m_uFlags;
     78 };
     79 #define XFA_NODEFILTER_Children 0x01
     80 #define XFA_NODEFILTER_Properties 0x02
     81 #define XFA_NODEFILTER_OneOfProperty 0x04
     82 #define XFA_CLONEFLAG_Content 0x01
     83 enum XFA_NODEITEM {
     84   XFA_NODEITEM_Parent,
     85   XFA_NODEITEM_FirstChild,
     86   XFA_NODEITEM_NextSibling,
     87   XFA_NODEITEM_PrevSibling,
     88 };
     89 enum XFA_SOM_MESSAGETYPE {
     90   XFA_SOM_ValidationMessage,
     91   XFA_SOM_FormatMessage,
     92   XFA_SOM_MandatoryMessage
     93 };
     94 typedef CFX_StackTemplate<CXFA_Node*> CXFA_NodeStack;
     95 typedef CXFA_PtrSetTemplate<CXFA_Node*> CXFA_NodeSet;
     96 typedef void (*PD_CALLBACK_DUPLICATEDATA)(void*& pData);
     97 typedef struct _XFA_MAPDATABLOCKCALLBACKINFO {
     98   PD_CALLBACK_FREEDATA pFree;
     99   PD_CALLBACK_DUPLICATEDATA pCopy;
    100 } XFA_MAPDATABLOCKCALLBACKINFO;
    101 typedef struct _XFA_MAPDATABLOCK {
    102   uint8_t* GetData() const {
    103     return (uint8_t*)this + sizeof(_XFA_MAPDATABLOCK);
    104   }
    105   XFA_MAPDATABLOCKCALLBACKINFO* pCallbackInfo;
    106   int32_t iBytes;
    107 } XFA_MAPDATABLOCK, *XFA_LPMAPDATABLOCK;
    108 typedef struct _XFA_MAPMODULEDATA {
    109   CFX_MapPtrToPtr m_ValueMap;
    110   CFX_MapPtrTemplate<void*, XFA_LPMAPDATABLOCK> m_BufferMap;
    111 } XFA_MAPMODULEDATA, *XFA_LPMAPMODULEDATA;
    112 #define XFA_CalcRefCount (void*)(uintptr_t) FXBSTR_ID('X', 'F', 'A', 'R')
    113 #define XFA_CalcData (void*)(uintptr_t) FXBSTR_ID('X', 'F', 'A', 'C')
    114 #define XFA_LAYOUTITEMKEY (void*)(uintptr_t) FXBSTR_ID('L', 'Y', 'I', 'M')
    115 class CXFA_Node : public CXFA_Object {
    116  public:
    117   XFA_ELEMENT GetClassID() const { return (XFA_ELEMENT)m_eNodeClass; }
    118   FX_DWORD GetPacketID() const { return m_ePacket; }
    119   FX_BOOL HasFlag(FX_DWORD dwFlag) const;
    120   void SetFlag(FX_DWORD dwFlag, FX_BOOL bOn = TRUE, FX_BOOL bNotify = TRUE);
    121   FX_BOOL IsAttributeInXML();
    122   FX_BOOL IsFormContainer() {
    123     return m_ePacket == XFA_XDPPACKET_Form && IsContainerNode();
    124   }
    125   void SetXMLMappingNode(IFDE_XMLNode* pXMLNode) { m_pXMLNode = pXMLNode; }
    126   IFDE_XMLNode* GetXMLMappingNode() const { return m_pXMLNode; }
    127   IFDE_XMLNode* CreateXMLMappingNode();
    128   FX_BOOL IsNeedSavingXMLNode();
    129   inline FX_DWORD GetNameHash() const { return m_dwNameHash; }
    130   inline FX_BOOL IsUnnamed() const { return m_dwNameHash == 0; }
    131   CXFA_Node* GetModelNode();
    132   void UpdateNameHash();
    133   FX_BOOL HasAttribute(XFA_ATTRIBUTE eAttr, FX_BOOL bCanInherit = FALSE);
    134   FX_BOOL SetAttribute(XFA_ATTRIBUTE eAttr,
    135                        const CFX_WideStringC& wsValue,
    136                        FX_BOOL bNotify = FALSE);
    137   FX_BOOL GetAttribute(XFA_ATTRIBUTE eAttr,
    138                        CFX_WideString& wsValue,
    139                        FX_BOOL bUseDefault = TRUE);
    140   FX_BOOL SetAttribute(const CFX_WideStringC& wsAttr,
    141                        const CFX_WideStringC& wsValue,
    142                        FX_BOOL bNotify = FALSE);
    143   FX_BOOL GetAttribute(const CFX_WideStringC& wsAttr,
    144                        CFX_WideString& wsValue,
    145                        FX_BOOL bUseDefault = TRUE);
    146   FX_BOOL RemoveAttribute(const CFX_WideStringC& wsAttr);
    147   FX_BOOL SetContent(const CFX_WideString& wsContent,
    148                      const CFX_WideString& wsXMLValue,
    149                      FX_BOOL bNotify = FALSE,
    150                      FX_BOOL bScriptModify = FALSE,
    151                      FX_BOOL bSyncData = TRUE);
    152   FX_BOOL TryContent(CFX_WideString& wsContent,
    153                      FX_BOOL bScriptModify = FALSE,
    154                      FX_BOOL bProto = TRUE);
    155   CFX_WideString GetContent();
    156 
    157   FX_BOOL TryNamespace(CFX_WideString& wsNamespace);
    158 
    159   FX_BOOL SetBoolean(XFA_ATTRIBUTE eAttr,
    160                      FX_BOOL bValue,
    161                      FX_BOOL bNotify = FALSE) {
    162     return SetValue(eAttr, XFA_ATTRIBUTETYPE_Boolean, (void*)(uintptr_t)bValue,
    163                     bNotify);
    164   }
    165   FX_BOOL TryBoolean(XFA_ATTRIBUTE eAttr,
    166                      FX_BOOL& bValue,
    167                      FX_BOOL bUseDefault = TRUE);
    168   FX_BOOL GetBoolean(XFA_ATTRIBUTE eAttr) {
    169     FX_BOOL bValue;
    170     return TryBoolean(eAttr, bValue, TRUE) ? bValue : FALSE;
    171   }
    172   FX_BOOL SetInteger(XFA_ATTRIBUTE eAttr,
    173                      int32_t iValue,
    174                      FX_BOOL bNotify = FALSE) {
    175     return SetValue(eAttr, XFA_ATTRIBUTETYPE_Integer, (void*)(uintptr_t)iValue,
    176                     bNotify);
    177   }
    178   FX_BOOL TryInteger(XFA_ATTRIBUTE eAttr,
    179                      int32_t& iValue,
    180                      FX_BOOL bUseDefault = TRUE);
    181   int32_t GetInteger(XFA_ATTRIBUTE eAttr) {
    182     int32_t iValue;
    183     return TryInteger(eAttr, iValue, TRUE) ? iValue : 0;
    184   }
    185   FX_BOOL SetEnum(XFA_ATTRIBUTE eAttr,
    186                   XFA_ATTRIBUTEENUM eValue,
    187                   FX_BOOL bNotify = FALSE) {
    188     return SetValue(eAttr, XFA_ATTRIBUTETYPE_Enum, (void*)(uintptr_t)eValue,
    189                     bNotify);
    190   }
    191   FX_BOOL TryEnum(XFA_ATTRIBUTE eAttr,
    192                   XFA_ATTRIBUTEENUM& eValue,
    193                   FX_BOOL bUseDefault = TRUE);
    194   XFA_ATTRIBUTEENUM GetEnum(XFA_ATTRIBUTE eAttr) {
    195     XFA_ATTRIBUTEENUM eValue;
    196     return TryEnum(eAttr, eValue, TRUE) ? eValue : XFA_ATTRIBUTEENUM_Unknown;
    197   }
    198   FX_BOOL SetCData(XFA_ATTRIBUTE eAttr,
    199                    const CFX_WideString& wsValue,
    200                    FX_BOOL bNotify = FALSE,
    201                    FX_BOOL bScriptModify = FALSE);
    202   FX_BOOL SetAttributeValue(const CFX_WideString& wsValue,
    203                             const CFX_WideString& wsXMLValue,
    204                             FX_BOOL bNotify = FALSE,
    205                             FX_BOOL bScriptModify = FALSE);
    206   FX_BOOL TryCData(XFA_ATTRIBUTE eAttr,
    207                    CFX_WideString& wsValue,
    208                    FX_BOOL bUseDefault = TRUE,
    209                    FX_BOOL bProto = TRUE);
    210   FX_BOOL TryCData(XFA_ATTRIBUTE eAttr,
    211                    CFX_WideStringC& wsValue,
    212                    FX_BOOL bUseDefault = TRUE,
    213                    FX_BOOL bProto = TRUE);
    214   CFX_WideStringC GetCData(XFA_ATTRIBUTE eAttr) {
    215     CFX_WideStringC wsValue;
    216     return TryCData(eAttr, wsValue) ? wsValue : CFX_WideStringC();
    217   }
    218   FX_BOOL SetMeasure(XFA_ATTRIBUTE eAttr,
    219                      CXFA_Measurement mValue,
    220                      FX_BOOL bNotify = FALSE);
    221   FX_BOOL TryMeasure(XFA_ATTRIBUTE eAttr,
    222                      CXFA_Measurement& mValue,
    223                      FX_BOOL bUseDefault = TRUE);
    224   CXFA_Measurement GetMeasure(XFA_ATTRIBUTE eAttr) {
    225     CXFA_Measurement mValue;
    226     return TryMeasure(eAttr, mValue, TRUE) ? mValue : CXFA_Measurement();
    227   }
    228   FX_BOOL SetObject(XFA_ATTRIBUTE eAttr,
    229                     void* pData,
    230                     XFA_MAPDATABLOCKCALLBACKINFO* pCallbackInfo = NULL);
    231   FX_BOOL TryObject(XFA_ATTRIBUTE eAttr, void*& pData);
    232   void* GetObject(XFA_ATTRIBUTE eAttr) {
    233     void* pData;
    234     return TryObject(eAttr, pData) ? pData : NULL;
    235   }
    236   FX_BOOL SetUserData(void* pKey,
    237                       void* pData,
    238                       XFA_MAPDATABLOCKCALLBACKINFO* pCallbackInfo = NULL);
    239   FX_BOOL TryUserData(void* pKey, void*& pData, FX_BOOL bProtoAlso = FALSE);
    240   void* GetUserData(void* pKey, FX_BOOL bProtoAlso = FALSE) {
    241     void* pData;
    242     return TryUserData(pKey, pData, bProtoAlso) ? pData : NULL;
    243   }
    244   CXFA_Node* GetProperty(int32_t index,
    245                          XFA_ELEMENT eProperty,
    246                          FX_BOOL bCreateProperty = TRUE);
    247   int32_t CountChildren(XFA_ELEMENT eElement, FX_BOOL bOnlyChild = FALSE);
    248   CXFA_Node* GetChild(int32_t index,
    249                       XFA_ELEMENT eElement,
    250                       FX_BOOL bOnlyChild = FALSE);
    251   int32_t InsertChild(int32_t index, CXFA_Node* pNode);
    252   FX_BOOL InsertChild(CXFA_Node* pNode, CXFA_Node* pBeforeNode = NULL);
    253   FX_BOOL RemoveChild(CXFA_Node* pNode, FX_BOOL bNotify = TRUE);
    254   CXFA_Node* Clone(FX_BOOL bRecursive);
    255   CXFA_Node* GetNodeItem(XFA_NODEITEM eItem) const;
    256   CXFA_Node* GetNodeItem(XFA_NODEITEM eItem, XFA_OBJECTTYPE eType) const;
    257   int32_t GetNodeList(CXFA_NodeArray& nodes,
    258                       FX_DWORD dwTypeFilter = XFA_NODEFILTER_Children |
    259                                               XFA_NODEFILTER_Properties,
    260                       XFA_ELEMENT eElementFilter = XFA_ELEMENT_UNKNOWN,
    261                       int32_t iLevel = 1);
    262   CXFA_Node* CreateSamePacketNode(XFA_ELEMENT eElement,
    263                                   FX_DWORD dwFlags = XFA_NODEFLAG_Initialized);
    264   CXFA_Node* CloneTemplateToForm(FX_BOOL bRecursive);
    265   CXFA_Node* GetTemplateNode();
    266   void SetTemplateNode(CXFA_Node* pTemplateNode);
    267   CXFA_Node* GetDataDescriptionNode();
    268   void SetDataDescriptionNode(CXFA_Node* pDataDescriptionNode);
    269   CXFA_Node* GetBindData();
    270   int32_t GetBindItems(CXFA_NodeArray& formItems);
    271   int32_t AddBindItem(CXFA_Node* pFormNode);
    272   int32_t RemoveBindItem(CXFA_Node* pFormNode);
    273   FX_BOOL HasBindItem();
    274   CXFA_WidgetData* GetWidgetData();
    275   CXFA_WidgetData* GetContainerWidgetData();
    276   FX_BOOL GetLocaleName(CFX_WideString& wsLocaleName);
    277   XFA_ATTRIBUTEENUM GetIntact();
    278   CXFA_Node* GetFirstChildByName(const CFX_WideStringC& wsNodeName) const;
    279   CXFA_Node* GetFirstChildByName(FX_DWORD dwNodeNameHash) const;
    280   CXFA_Node* GetFirstChildByClass(XFA_ELEMENT eNodeClass) const;
    281   CXFA_Node* GetNextSameNameSibling(FX_DWORD dwNodeNameHash) const;
    282   CXFA_Node* GetNextSameNameSibling(const CFX_WideStringC& wsNodeName) const;
    283   CXFA_Node* GetNextSameClassSibling(XFA_ELEMENT eNodeClass) const;
    284   int32_t GetNodeSameNameIndex() const;
    285   int32_t GetNodeSameClassIndex() const;
    286   void GetSOMExpression(CFX_WideString& wsSOMExpression);
    287   CXFA_Node* GetInstanceMgrOfSubform();
    288 
    289   CXFA_Node* GetOccurNode();
    290   void Script_TreeClass_ResolveNode(CFXJSE_Arguments* pArguments);
    291   void Script_TreeClass_ResolveNodes(CFXJSE_Arguments* pArguments);
    292   void Script_Som_ResolveNodeList(FXJSE_HVALUE hValue,
    293                                   CFX_WideString wsExpression,
    294                                   FX_DWORD dwFlag,
    295                                   CXFA_Node* refNode = NULL);
    296   void Script_TreeClass_All(FXJSE_HVALUE hValue,
    297                             FX_BOOL bSetting,
    298                             XFA_ATTRIBUTE eAttribute);
    299   void Script_TreeClass_Nodes(FXJSE_HVALUE hValue,
    300                               FX_BOOL bSetting,
    301                               XFA_ATTRIBUTE eAttribute);
    302   void Script_TreeClass_ClassAll(FXJSE_HVALUE hValue,
    303                                  FX_BOOL bSetting,
    304                                  XFA_ATTRIBUTE eAttribute);
    305   void Script_TreeClass_Parent(FXJSE_HVALUE hValue,
    306                                FX_BOOL bSetting,
    307                                XFA_ATTRIBUTE eAttribute);
    308   void Script_TreeClass_Index(FXJSE_HVALUE hValue,
    309                               FX_BOOL bSetting,
    310                               XFA_ATTRIBUTE eAttribute);
    311   void Script_TreeClass_ClassIndex(FXJSE_HVALUE hValue,
    312                                    FX_BOOL bSetting,
    313                                    XFA_ATTRIBUTE eAttribute);
    314   void Script_TreeClass_SomExpression(FXJSE_HVALUE hValue,
    315                                       FX_BOOL bSetting,
    316                                       XFA_ATTRIBUTE eAttribute);
    317   void Script_NodeClass_ApplyXSL(CFXJSE_Arguments* pArguments);
    318   void Script_NodeClass_AssignNode(CFXJSE_Arguments* pArguments);
    319   void Script_NodeClass_Clone(CFXJSE_Arguments* pArguments);
    320   void Script_NodeClass_GetAttribute(CFXJSE_Arguments* pArguments);
    321   void Script_NodeClass_GetElement(CFXJSE_Arguments* pArguments);
    322   void Script_NodeClass_IsPropertySpecified(CFXJSE_Arguments* pArguments);
    323   void Script_NodeClass_LoadXML(CFXJSE_Arguments* pArguments);
    324   void Script_NodeClass_SaveFilteredXML(CFXJSE_Arguments* pArguments);
    325   void Script_NodeClass_SaveXML(CFXJSE_Arguments* pArguments);
    326   void Script_NodeClass_SetAttribute(CFXJSE_Arguments* pArguments);
    327   void Script_NodeClass_SetElement(CFXJSE_Arguments* pArguments);
    328   void Script_NodeClass_Ns(FXJSE_HVALUE hValue,
    329                            FX_BOOL bSetting,
    330                            XFA_ATTRIBUTE eAttribute);
    331   void Script_NodeClass_Model(FXJSE_HVALUE hValue,
    332                               FX_BOOL bSetting,
    333                               XFA_ATTRIBUTE eAttribute);
    334   void Script_NodeClass_IsContainer(FXJSE_HVALUE hValue,
    335                                     FX_BOOL bSetting,
    336                                     XFA_ATTRIBUTE eAttribute);
    337   void Script_NodeClass_IsNull(FXJSE_HVALUE hValue,
    338                                FX_BOOL bSetting,
    339                                XFA_ATTRIBUTE eAttribute);
    340   void Script_NodeClass_OneOfChild(FXJSE_HVALUE hValue,
    341                                    FX_BOOL bSetting,
    342                                    XFA_ATTRIBUTE eAttribute);
    343   void Script_ContainerClass_GetDelta(CFXJSE_Arguments* pArguments);
    344   void Script_ContainerClass_GetDeltas(CFXJSE_Arguments* pArguments);
    345   void Script_ModelClass_ClearErrorList(CFXJSE_Arguments* pArguments);
    346   void Script_ModelClass_CreateNode(CFXJSE_Arguments* pArguments);
    347   void Script_ModelClass_IsCompatibleNS(CFXJSE_Arguments* pArguments);
    348   void Script_ModelClass_Context(FXJSE_HVALUE hValue,
    349                                  FX_BOOL bSetting,
    350                                  XFA_ATTRIBUTE eAttribute);
    351   void Script_ModelClass_AliasNode(FXJSE_HVALUE hValue,
    352                                    FX_BOOL bSetting,
    353                                    XFA_ATTRIBUTE eAttribute);
    354   void Script_WsdlConnection_Execute(CFXJSE_Arguments* pArguments);
    355   void Script_Delta_Restore(CFXJSE_Arguments* pArguments);
    356   void Script_Delta_CurrentValue(FXJSE_HVALUE hValue,
    357                                  FX_BOOL bSetting,
    358                                  XFA_ATTRIBUTE eAttribute);
    359   void Script_Delta_SavedValue(FXJSE_HVALUE hValue,
    360                                FX_BOOL bSetting,
    361                                XFA_ATTRIBUTE eAttribute);
    362   void Script_Delta_Target(FXJSE_HVALUE hValue,
    363                            FX_BOOL bSetting,
    364                            XFA_ATTRIBUTE eAttribute);
    365   void Script_Attribute_SendAttributeChangeMessage(void* eAttribute,
    366                                                    void* eValue,
    367                                                    FX_BOOL bScriptModify);
    368   void Script_Attribute_Integer(FXJSE_HVALUE hValue,
    369                                 FX_BOOL bSetting,
    370                                 XFA_ATTRIBUTE eAttribute);
    371   void Script_Attribute_IntegerRead(FXJSE_HVALUE hValue,
    372                                     FX_BOOL bSetting,
    373                                     XFA_ATTRIBUTE eAttribute);
    374   void Script_Attribute_BOOL(FXJSE_HVALUE hValue,
    375                              FX_BOOL bSetting,
    376                              XFA_ATTRIBUTE eAttribute);
    377   void Script_Attribute_BOOLRead(FXJSE_HVALUE hValue,
    378                                  FX_BOOL bSetting,
    379                                  XFA_ATTRIBUTE eAttribute);
    380   void Script_Attribute_String(FXJSE_HVALUE hValue,
    381                                FX_BOOL bSetting,
    382                                XFA_ATTRIBUTE eAttribute);
    383   void Script_Attribute_StringRead(FXJSE_HVALUE hValue,
    384                                    FX_BOOL bSetting,
    385                                    XFA_ATTRIBUTE eAttribute);
    386   void Script_Som_ValidationMessage(FXJSE_HVALUE hValue,
    387                                     FX_BOOL bSetting,
    388                                     XFA_ATTRIBUTE eAttribute);
    389   void Script_Field_Length(FXJSE_HVALUE hValue,
    390                            FX_BOOL bSetting,
    391                            XFA_ATTRIBUTE eAttribute);
    392   void Script_Som_DefaultValue(FXJSE_HVALUE hValue,
    393                                FX_BOOL bSetting,
    394                                XFA_ATTRIBUTE eAttribute);
    395   void Script_Som_DefaultValue_Read(FXJSE_HVALUE hValue,
    396                                     FX_BOOL bSetting,
    397                                     XFA_ATTRIBUTE eAttribute);
    398   void Script_Boolean_Value(FXJSE_HVALUE hValue,
    399                             FX_BOOL bSetting,
    400                             XFA_ATTRIBUTE eAttribute);
    401   void Script_Som_Message(FXJSE_HVALUE hValue,
    402                           FX_BOOL bSetting,
    403                           XFA_SOM_MESSAGETYPE iMessageType);
    404   void Script_Som_BorderColor(FXJSE_HVALUE hValue,
    405                               FX_BOOL bSetting,
    406                               XFA_ATTRIBUTE eAttribute);
    407   void Script_Som_BorderWidth(FXJSE_HVALUE hValue,
    408                               FX_BOOL bSetting,
    409                               XFA_ATTRIBUTE eAttribute);
    410   void Script_Som_FillColor(FXJSE_HVALUE hValue,
    411                             FX_BOOL bSetting,
    412                             XFA_ATTRIBUTE eAttribute);
    413   void Script_Som_DataNode(FXJSE_HVALUE hValue,
    414                            FX_BOOL bSetting,
    415                            XFA_ATTRIBUTE eAttribute);
    416   void Script_Som_FontColor(FXJSE_HVALUE hValue,
    417                             FX_BOOL bSetting,
    418                             XFA_ATTRIBUTE eAttribute);
    419   void Script_Som_Mandatory(FXJSE_HVALUE hValue,
    420                             FX_BOOL bSetting,
    421                             XFA_ATTRIBUTE eAttribute);
    422   void Script_Som_MandatoryMessage(FXJSE_HVALUE hValue,
    423                                    FX_BOOL bSetting,
    424                                    XFA_ATTRIBUTE eAttribute);
    425   void Script_Som_InstanceIndex(FXJSE_HVALUE hValue,
    426                                 FX_BOOL bSetting,
    427                                 XFA_ATTRIBUTE eAttribute);
    428   void Script_Draw_DefaultValue(FXJSE_HVALUE hValue,
    429                                 FX_BOOL bSetting,
    430                                 XFA_ATTRIBUTE eAttribute);
    431   void Script_Field_DefaultValue(FXJSE_HVALUE hValue,
    432                                  FX_BOOL bSetting,
    433                                  XFA_ATTRIBUTE eAttribute);
    434   void Script_Field_EditValue(FXJSE_HVALUE hValue,
    435                               FX_BOOL bSetting,
    436                               XFA_ATTRIBUTE eAttribute);
    437   void Script_Field_FormatMessage(FXJSE_HVALUE hValue,
    438                                   FX_BOOL bSetting,
    439                                   XFA_ATTRIBUTE eAttribute);
    440   void Script_Field_FormattedValue(FXJSE_HVALUE hValue,
    441                                    FX_BOOL bSetting,
    442                                    XFA_ATTRIBUTE eAttribute);
    443   void Script_Field_ParentSubform(FXJSE_HVALUE hValue,
    444                                   FX_BOOL bSetting,
    445                                   XFA_ATTRIBUTE eAttribute);
    446   void Script_Field_SelectedIndex(FXJSE_HVALUE hValue,
    447                                   FX_BOOL bSetting,
    448                                   XFA_ATTRIBUTE eAttribute);
    449   void Script_Field_ClearItems(CFXJSE_Arguments* pArguments);
    450   void Script_Field_ExecEvent(CFXJSE_Arguments* pArguments);
    451   void Script_Field_ExecInitialize(CFXJSE_Arguments* pArguments);
    452   void Script_Field_DeleteItem(CFXJSE_Arguments* pArguments);
    453   void Script_Field_GetSaveItem(CFXJSE_Arguments* pArguments);
    454   void Script_Field_BoundItem(CFXJSE_Arguments* pArguments);
    455   void Script_Field_GetItemState(CFXJSE_Arguments* pArguments);
    456   void Script_Field_ExecCalculate(CFXJSE_Arguments* pArguments);
    457   void Script_Field_SetItems(CFXJSE_Arguments* pArguments);
    458   void Script_Field_GetDisplayItem(CFXJSE_Arguments* pArguments);
    459   void Script_Field_SetItemState(CFXJSE_Arguments* pArguments);
    460   void Script_Field_AddItem(CFXJSE_Arguments* pArguments);
    461   void Script_Field_ExecValidate(CFXJSE_Arguments* pArguments);
    462   void Script_ExclGroup_DefaultAndRawValue(FXJSE_HVALUE hValue,
    463                                            FX_BOOL bSetting,
    464                                            XFA_ATTRIBUTE eAttribute);
    465   void Script_ExclGroup_ErrorText(FXJSE_HVALUE hValue,
    466                                   FX_BOOL bSetting,
    467                                   XFA_ATTRIBUTE eAttribute);
    468   void Script_ExclGroup_Transient(FXJSE_HVALUE hValue,
    469                                   FX_BOOL bSetting,
    470                                   XFA_ATTRIBUTE eAttribute);
    471   void Script_ExclGroup_ExecEvent(CFXJSE_Arguments* pArguments);
    472   void Script_ExclGroup_SelectedMember(CFXJSE_Arguments* pArguments);
    473   void Script_ExclGroup_ExecInitialize(CFXJSE_Arguments* pArguments);
    474   void Script_ExclGroup_ExecCalculate(CFXJSE_Arguments* pArguments);
    475   void Script_ExclGroup_ExecValidate(CFXJSE_Arguments* pArguments);
    476   void Script_Subform_InstanceManager(FXJSE_HVALUE hValue,
    477                                       FX_BOOL bSetting,
    478                                       XFA_ATTRIBUTE eAttribute);
    479   void Script_Subform_Locale(FXJSE_HVALUE hValue,
    480                              FX_BOOL bSetting,
    481                              XFA_ATTRIBUTE eAttribute);
    482   void Script_Subform_ExecEvent(CFXJSE_Arguments* pArguments);
    483   void Script_Subform_ExecInitialize(CFXJSE_Arguments* pArguments);
    484   void Script_Subform_ExecCalculate(CFXJSE_Arguments* pArguments);
    485   void Script_Subform_ExecValidate(CFXJSE_Arguments* pArguments);
    486   void Script_Subform_GetInvalidObjects(CFXJSE_Arguments* pArguments);
    487 
    488   int32_t Subform_and_SubformSet_InstanceIndex();
    489   void Script_Template_FormNodes(CFXJSE_Arguments* pArguments);
    490   void Script_Template_Remerge(CFXJSE_Arguments* pArguments);
    491   void Script_Template_ExecInitialize(CFXJSE_Arguments* pArguments);
    492   void Script_Template_CreateNode(CFXJSE_Arguments* pArguments);
    493   void Script_Template_Recalculate(CFXJSE_Arguments* pArguments);
    494   void Script_Template_ExecCalculate(CFXJSE_Arguments* pArguments);
    495   void Script_Template_ExecValidate(CFXJSE_Arguments* pArguments);
    496   void Script_Manifest_Evaluate(CFXJSE_Arguments* pArguments);
    497   void Script_InstanceManager_Count(FXJSE_HVALUE hValue,
    498                                     FX_BOOL bSetting,
    499                                     XFA_ATTRIBUTE eAttribute);
    500   void Script_InstanceManager_Max(FXJSE_HVALUE hValue,
    501                                   FX_BOOL bSetting,
    502                                   XFA_ATTRIBUTE eAttribute);
    503   void Script_InstanceManager_Min(FXJSE_HVALUE hValue,
    504                                   FX_BOOL bSetting,
    505                                   XFA_ATTRIBUTE eAttribute);
    506   void Script_InstanceManager_MoveInstance(CFXJSE_Arguments* pArguments);
    507   void Script_InstanceManager_RemoveInstance(CFXJSE_Arguments* pArguments);
    508   void Script_InstanceManager_SetInstances(CFXJSE_Arguments* pArguments);
    509   void Script_InstanceManager_AddInstance(CFXJSE_Arguments* pArguments);
    510   void Script_InstanceManager_InsertInstance(CFXJSE_Arguments* pArguments);
    511   int32_t InstanceManager_SetInstances(int32_t iCount);
    512   int32_t InstanceManager_MoveInstance(int32_t iTo, int32_t iFrom);
    513   void Script_Occur_Max(FXJSE_HVALUE hValue,
    514                         FX_BOOL bSetting,
    515                         XFA_ATTRIBUTE eAttribute);
    516   void Script_Occur_Min(FXJSE_HVALUE hValue,
    517                         FX_BOOL bSetting,
    518                         XFA_ATTRIBUTE eAttribute);
    519   void Script_Desc_Metadata(CFXJSE_Arguments* pArguments);
    520   void Script_Form_FormNodes(CFXJSE_Arguments* pArguments);
    521   void Script_Form_Remerge(CFXJSE_Arguments* pArguments);
    522   void Script_Form_ExecInitialize(CFXJSE_Arguments* pArguments);
    523   void Script_Form_Recalculate(CFXJSE_Arguments* pArguments);
    524   void Script_Form_ExecCalculate(CFXJSE_Arguments* pArguments);
    525   void Script_Form_ExecValidate(CFXJSE_Arguments* pArguments);
    526   void Script_Form_Checksum(FXJSE_HVALUE hValue,
    527                             FX_BOOL bSetting,
    528                             XFA_ATTRIBUTE eAttribute);
    529   void Script_Packet_GetAttribute(CFXJSE_Arguments* pArguments);
    530   void Script_Packet_SetAttribute(CFXJSE_Arguments* pArguments);
    531   void Script_Packet_RemoveAttribute(CFXJSE_Arguments* pArguments);
    532   void Script_Packet_Content(FXJSE_HVALUE hValue,
    533                              FX_BOOL bSetting,
    534                              XFA_ATTRIBUTE eAttribute);
    535   void Script_Source_Next(CFXJSE_Arguments* pArguments);
    536   void Script_Source_CancelBatch(CFXJSE_Arguments* pArguments);
    537   void Script_Source_First(CFXJSE_Arguments* pArguments);
    538   void Script_Source_UpdateBatch(CFXJSE_Arguments* pArguments);
    539   void Script_Source_Previous(CFXJSE_Arguments* pArguments);
    540   void Script_Source_IsBOF(CFXJSE_Arguments* pArguments);
    541   void Script_Source_IsEOF(CFXJSE_Arguments* pArguments);
    542   void Script_Source_Cancel(CFXJSE_Arguments* pArguments);
    543   void Script_Source_Update(CFXJSE_Arguments* pArguments);
    544   void Script_Source_Open(CFXJSE_Arguments* pArguments);
    545   void Script_Source_Delete(CFXJSE_Arguments* pArguments);
    546   void Script_Source_AddNew(CFXJSE_Arguments* pArguments);
    547   void Script_Source_Requery(CFXJSE_Arguments* pArguments);
    548   void Script_Source_Resync(CFXJSE_Arguments* pArguments);
    549   void Script_Source_Close(CFXJSE_Arguments* pArguments);
    550   void Script_Source_Last(CFXJSE_Arguments* pArguments);
    551   void Script_Source_HasDataChanged(CFXJSE_Arguments* pArguments);
    552   void Script_Source_Db(FXJSE_HVALUE hValue,
    553                         FX_BOOL bSetting,
    554                         XFA_ATTRIBUTE eAttribute);
    555   void Script_Xfa_This(FXJSE_HVALUE hValue,
    556                        FX_BOOL bSetting,
    557                        XFA_ATTRIBUTE eAttribute);
    558   void Script_Handler_Version(FXJSE_HVALUE hValue,
    559                               FX_BOOL bSetting,
    560                               XFA_ATTRIBUTE eAttribute);
    561   void Script_SubmitFormat_Mode(FXJSE_HVALUE hValue,
    562                                 FX_BOOL bSetting,
    563                                 XFA_ATTRIBUTE eAttribute);
    564   void Script_Extras_Type(FXJSE_HVALUE hValue,
    565                           FX_BOOL bSetting,
    566                           XFA_ATTRIBUTE eAttribute);
    567   void Script_Encrypt_Format(FXJSE_HVALUE hValue,
    568                              FX_BOOL bSetting,
    569                              XFA_ATTRIBUTE eAttribute);
    570   void Script_Script_Stateless(FXJSE_HVALUE hValue,
    571                                FX_BOOL bSetting,
    572                                XFA_ATTRIBUTE eAttribute);
    573 
    574  protected:
    575   CXFA_Node(CXFA_Document* pDoc, FX_WORD ePacket, XFA_ELEMENT eElement);
    576   ~CXFA_Node();
    577   friend class CXFA_Document;
    578   CXFA_Node* Deprecated_GetPrevSibling();
    579   FX_BOOL SetValue(XFA_ATTRIBUTE eAttr,
    580                    XFA_ATTRIBUTETYPE eType,
    581                    void* pValue,
    582                    FX_BOOL bNotify);
    583   FX_BOOL GetValue(XFA_ATTRIBUTE eAttr,
    584                    XFA_ATTRIBUTETYPE eType,
    585                    FX_BOOL bUseDefault,
    586                    void*& pValue);
    587   void OnRemoved(CXFA_Node* pParent, CXFA_Node* pRemoved, FX_BOOL bNotify);
    588   void OnChanging(XFA_ATTRIBUTE eAttr, void* pNewValue, FX_BOOL bNotify);
    589   void OnChanged(XFA_ATTRIBUTE eAttr,
    590                  void* pNewValue,
    591                  FX_BOOL bNotify,
    592                  FX_BOOL bScriptModify = FALSE);
    593   int32_t execSingleEventByName(const CFX_WideStringC& wsEventName,
    594                                 XFA_ELEMENT eElementType);
    595   FX_BOOL SetScriptContent(const CFX_WideString& wsContent,
    596                            const CFX_WideString& wsXMLValue,
    597                            FX_BOOL bNotify = TRUE,
    598                            FX_BOOL bScriptModify = FALSE,
    599                            FX_BOOL bSyncData = TRUE);
    600   CFX_WideString GetScriptContent(FX_BOOL bScriptModify = FALSE);
    601   XFA_LPMAPMODULEDATA GetMapModuleData(FX_BOOL bCreateNew);
    602   void SetMapModuleValue(void* pKey, void* pValue);
    603   FX_BOOL GetMapModuleValue(void* pKey, void*& pValue);
    604   void SetMapModuleString(void* pKey, const CFX_WideStringC& wsValue);
    605   FX_BOOL GetMapModuleString(void* pKey, CFX_WideStringC& wsValue);
    606   void SetMapModuleBuffer(void* pKey,
    607                           void* pValue,
    608                           int32_t iBytes,
    609                           XFA_MAPDATABLOCKCALLBACKINFO* pCallbackInfo = NULL);
    610   FX_BOOL GetMapModuleBuffer(void* pKey,
    611                              void*& pValue,
    612                              int32_t& iBytes,
    613                              FX_BOOL bProtoAlso = TRUE);
    614   FX_BOOL HasMapModuleKey(void* pKey, FX_BOOL bProtoAlso = FALSE);
    615   void RemoveMapModuleKey(void* pKey = NULL);
    616   void MergeAllData(void* pDstModule, FX_BOOL bUseSrcAttr = TRUE);
    617   void MoveBufferMapData(CXFA_Node* pDstModule, void* pKey);
    618   void MoveBufferMapData(CXFA_Node* pSrcModule,
    619                          CXFA_Node* pDstModule,
    620                          void* pKey,
    621                          FX_BOOL bRecursive = FALSE);
    622 
    623   CXFA_Node* m_pNext;
    624   CXFA_Node* m_pChild;
    625   CXFA_Node* m_pLastChild;
    626   CXFA_Node* m_pParent;
    627   IFDE_XMLNode* m_pXMLNode;
    628   XFA_ELEMENT m_eNodeClass;
    629   FX_WORD m_ePacket;
    630   FX_DWORD m_dwNameHash;
    631   CXFA_Node* m_pAuxNode;
    632   XFA_LPMAPMODULEDATA m_pMapModuleData;
    633 };
    634 class CXFA_OrdinaryObject : public CXFA_Object {
    635  public:
    636   CXFA_OrdinaryObject(CXFA_Document* pDocument, XFA_ELEMENT eElement)
    637       : CXFA_Object(pDocument, XFA_OBJECTTYPE_OrdinaryObject),
    638         m_uScriptHash(0) {
    639     m_eNodeClass = eElement;
    640   }
    641   XFA_ELEMENT GetClassID() const { return (XFA_ELEMENT)m_eNodeClass; }
    642   uint32_t GetScriptObjHash() { return m_uScriptHash; }
    643 
    644  protected:
    645   XFA_ELEMENT m_eNodeClass;
    646   uint32_t m_uScriptHash;
    647 };
    648 class CXFA_ThisProxy : public CXFA_Object {
    649  public:
    650   CXFA_ThisProxy(CXFA_Node* pThisNode, CXFA_Node* pScriptNode)
    651       : CXFA_Object(pThisNode->GetDocument(), XFA_OBJECTTYPE_VariablesThis),
    652         m_pThisNode(NULL),
    653         m_pScriptNode(NULL) {
    654     m_pThisNode = pThisNode;
    655     m_pScriptNode = pScriptNode;
    656   }
    657   virtual ~CXFA_ThisProxy() {}
    658   CXFA_Node* GetThisNode() { return m_pThisNode; }
    659   CXFA_Node* GetScriptNode() { return m_pScriptNode; }
    660 
    661  private:
    662   CXFA_Node* m_pThisNode;
    663   CXFA_Node* m_pScriptNode;
    664 };
    665 class CXFA_NodeList : public CXFA_Object {
    666  public:
    667   CXFA_NodeList(CXFA_Document* pDocument);
    668   virtual ~CXFA_NodeList() {}
    669   XFA_ELEMENT GetClassID() const { return XFA_ELEMENT_NodeList; }
    670   CXFA_Node* NamedItem(const CFX_WideStringC& wsName);
    671   virtual int32_t GetLength() = 0;
    672   virtual FX_BOOL Append(CXFA_Node* pNode) = 0;
    673   virtual FX_BOOL Insert(CXFA_Node* pNewNode, CXFA_Node* pBeforeNode) = 0;
    674   virtual FX_BOOL Remove(CXFA_Node* pNode) = 0;
    675   virtual CXFA_Node* Item(int32_t iIndex) = 0;
    676 
    677   void Script_ListClass_Append(CFXJSE_Arguments* pArguments);
    678   void Script_ListClass_Insert(CFXJSE_Arguments* pArguments);
    679   void Script_ListClass_Remove(CFXJSE_Arguments* pArguments);
    680   void Script_ListClass_Item(CFXJSE_Arguments* pArguments);
    681 
    682   void Script_TreelistClass_NamedItem(CFXJSE_Arguments* pArguments);
    683   void Script_ListClass_Length(FXJSE_HVALUE hValue,
    684                                FX_BOOL bSetting,
    685                                XFA_ATTRIBUTE eAttribute);
    686 };
    687 class CXFA_ArrayNodeList : public CXFA_NodeList {
    688  public:
    689   CXFA_ArrayNodeList(CXFA_Document* pDocument);
    690   void SetArrayNodeList(const CXFA_NodeArray& srcArray);
    691   virtual int32_t GetLength();
    692   virtual FX_BOOL Append(CXFA_Node* pNode);
    693   virtual FX_BOOL Insert(CXFA_Node* pNewNode, CXFA_Node* pBeforeNode);
    694   virtual FX_BOOL Remove(CXFA_Node* pNode);
    695   virtual CXFA_Node* Item(int32_t iIndex);
    696 
    697  protected:
    698   CXFA_NodeArray m_array;
    699 };
    700 class CXFA_AttachNodeList : public CXFA_NodeList {
    701  public:
    702   CXFA_AttachNodeList(CXFA_Document* pDocument, CXFA_Node* pAttachNode);
    703 
    704   virtual int32_t GetLength();
    705   virtual FX_BOOL Append(CXFA_Node* pNode);
    706   virtual FX_BOOL Insert(CXFA_Node* pNewNode, CXFA_Node* pBeforeNode);
    707   virtual FX_BOOL Remove(CXFA_Node* pNode);
    708   virtual CXFA_Node* Item(int32_t iIndex);
    709 
    710  protected:
    711   CXFA_Node* m_pAttachNode;
    712 };
    713 class CXFA_TraverseStrategy_XFAContainerNode {
    714  public:
    715   static CXFA_Node* GetFirstChild(CXFA_Node* pTemplateNode,
    716                                   void* pUserData = NULL) {
    717     return pTemplateNode->GetNodeItem(XFA_NODEITEM_FirstChild,
    718                                       XFA_OBJECTTYPE_ContainerNode);
    719   }
    720   static CXFA_Node* GetNextSibling(CXFA_Node* pTemplateNode,
    721                                    void* pUserData = NULL) {
    722     return pTemplateNode->GetNodeItem(XFA_NODEITEM_NextSibling,
    723                                       XFA_OBJECTTYPE_ContainerNode);
    724   }
    725   static CXFA_Node* GetParent(CXFA_Node* pTemplateNode,
    726                               void* pUserData = NULL) {
    727     return pTemplateNode->GetNodeItem(XFA_NODEITEM_Parent,
    728                                       XFA_OBJECTTYPE_ContainerNode);
    729   }
    730 };
    731 typedef CXFA_NodeIteratorTemplate<CXFA_Node,
    732                                   CXFA_TraverseStrategy_XFAContainerNode>
    733     CXFA_ContainerIterator;
    734 class CXFA_TraverseStrategy_XFANode {
    735  public:
    736   static inline CXFA_Node* GetFirstChild(CXFA_Node* pTemplateNode) {
    737     return pTemplateNode->GetNodeItem(XFA_NODEITEM_FirstChild);
    738   }
    739   static inline CXFA_Node* GetNextSibling(CXFA_Node* pTemplateNode) {
    740     return pTemplateNode->GetNodeItem(XFA_NODEITEM_NextSibling);
    741   }
    742   static inline CXFA_Node* GetParent(CXFA_Node* pTemplateNode) {
    743     return pTemplateNode->GetNodeItem(XFA_NODEITEM_Parent);
    744   }
    745 };
    746 typedef CXFA_NodeIteratorTemplate<CXFA_Node, CXFA_TraverseStrategy_XFANode>
    747     CXFA_NodeIterator;
    748 #endif
    749