Merge to XFA: Kill CFX_Object.
[pdfium.git] / xfa / src / fxfa / src / parser / xfa_script_imp.h
1 // Copyright 2014 PDFium Authors. All rights reserved.\r
2 // Use of this source code is governed by a BSD-style license that can be\r
3 // found in the LICENSE file.\r
4 \r
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com\r
6 \r
7 #ifndef _FXFA_SCRIPT_IMP_H\r
8 #define _FXFA_SCRIPT_IMP_H\r
9 #define XFA_RESOLVENODE_TagName                         0x0002\r
10 #define XFA_JSBUILTIN_Initialized                       0x0001\r
11 #define XFA_JSBUILTIN_HasCount                          0x0002\r
12 class CXFA_ResolveProcessor;\r
13 class CXFA_ScriptContext : public IXFA_ScriptContext\r
14 {\r
15 public:\r
16     CXFA_ScriptContext(CXFA_Document* pDocument);\r
17     ~CXFA_ScriptContext();\r
18     virtual void                        Release();\r
19     virtual void                        Initialize(FXJSE_HRUNTIME hRuntime);\r
20     virtual void                                SetEventParam(CXFA_EventParam* pEventParam)\r
21     {\r
22         m_pEventParam = pEventParam;\r
23     }\r
24     virtual CXFA_EventParam*    GetEventParam()\r
25     {\r
26         return m_pEventParam;\r
27     }\r
28     virtual FX_BOOL                     RunScript(XFA_SCRIPTLANGTYPE eScriptType, FX_WSTR wsScript, FXJSE_HVALUE hRetValue, CXFA_Object* pThisObject = NULL);\r
29 \r
30     virtual FX_INT32            ResolveObjects(CXFA_Object* refNode, FX_WSTR wsExpression, XFA_RESOLVENODE_RS& resolveNodeRS,  FX_DWORD dwStyles = XFA_RESOLVENODE_Children, CXFA_Node* bindNode = NULL);\r
31     virtual FXJSE_HVALUE        GetJSValueFromMap(CXFA_Object* pObject);\r
32     virtual void                        CacheList(CXFA_NodeList* pList)\r
33     {\r
34         m_CacheListArray.Add(pList);\r
35     }\r
36     virtual CXFA_Object*        GetThisObject() const\r
37     {\r
38         return m_pThisObject;\r
39     }\r
40     virtual FXJSE_HRUNTIME      GetRuntime() const\r
41     {\r
42         return m_hJsRuntime;\r
43     }\r
44 \r
45     virtual FX_INT32            GetIndexByName(CXFA_Node* refNode);\r
46     virtual FX_INT32            GetIndexByClassName(CXFA_Node* refNode);\r
47     virtual void                        GetSomExpression(CXFA_Node* refNode, CFX_WideString &wsExpression);\r
48 \r
49     virtual void                        SetNodesOfRunScript(CXFA_NodeArray *pArray);\r
50     virtual void                        AddNodesOfRunScript(const CXFA_NodeArray& nodes);\r
51     virtual void                        AddNodesOfRunScript(CXFA_Node* pNode);\r
52     virtual FXJSE_HCLASS        GetJseNormalClass();\r
53 \r
54     virtual     void                    AddJSBuiltinObject(XFA_LPCJSBUILTININFO pBuitinObject);\r
55     virtual     void                    SetRunAtType(XFA_ATTRIBUTEENUM eRunAt)\r
56     {\r
57         m_eRunAtType = eRunAt;\r
58     }\r
59     virtual FX_BOOL                     IsRunAtClient()\r
60     {\r
61         return m_eRunAtType != XFA_ATTRIBUTEENUM_Server;\r
62     }\r
63     FX_BOOL                                     QueryNodeByFlag(CXFA_Node* refNode, FX_WSTR propname, FXJSE_HVALUE hValue, FX_DWORD dwFlag, FX_BOOL bSetting);\r
64     FX_BOOL                                     QueryVariableHValue(CXFA_Node* pScriptNode, FX_BSTR szPropName, FXJSE_HVALUE hValue, FX_BOOL bGetter);\r
65     FX_BOOL                                     QueryBuiltinHValue(FX_BSTR szPropName, FXJSE_HVALUE hValue);\r
66     static void                         GlobalPropertyGetter(FXJSE_HOBJECT hObject, FX_BSTR szPropName, FXJSE_HVALUE hValue);\r
67     static void                         GlobalPropertySetter(FXJSE_HOBJECT hObject, FX_BSTR szPropName, FXJSE_HVALUE hValue);\r
68     static void                         NormalPropertyGetter(FXJSE_HOBJECT hObject, FX_BSTR szPropName, FXJSE_HVALUE hValue);\r
69     static void                         NormalPropertySetter(FXJSE_HOBJECT hObject, FX_BSTR szPropName, FXJSE_HVALUE hValue);\r
70     static void                         NormalMethodCall(FXJSE_HOBJECT hThis, FX_BSTR szFuncName, CFXJSE_Arguments &args);\r
71     static FX_INT32                     NormalPropTypeGetter(FXJSE_HOBJECT hObject, FX_BSTR szPropName, FX_BOOL bQueryIn);\r
72     static FX_INT32                     GlobalPropTypeGetter(FXJSE_HOBJECT hObject, FX_BSTR szPropName, FX_BOOL bQueryIn);\r
73     FX_BOOL                                     RunVariablesScript(CXFA_Node* pScriptNode);\r
74     CXFA_Object*                        GetVariablesThis(CXFA_Object* pObject, FX_BOOL bScriptNode = FALSE);\r
75     void                                        ReleaseVariablesMap();\r
76     FX_BOOL                                     IsStrictScopeInJavaScript();\r
77     XFA_SCRIPTLANGTYPE          GetType();\r
78     CXFA_NodeArray&                     GetUpObjectArray()\r
79     {\r
80         return m_upObjectArray;\r
81     }\r
82     CXFA_Document*                      GetDocument() const\r
83     {\r
84         return m_pDocument;\r
85     }\r
86 protected:\r
87     void                                        DefineJsContext();\r
88     FXJSE_HCONTEXT                      CreateVariablesContext(CXFA_Node* pScriptNode, CXFA_Node* pSubform);\r
89 \r
90     void                                        DefineJsClass();\r
91     CXFA_Document*                                                                      m_pDocument;\r
92     FXJSE_HCONTEXT                                                                      m_hJsContext;\r
93     FXJSE_HRUNTIME                                                                      m_hJsRuntime;\r
94     FXJSE_HCLASS                                                                        m_hJsClass;\r
95     XFA_SCRIPTLANGTYPE                                                          m_eScriptType;\r
96     FXJSE_CLASS                                                                         m_JsGlobalClass;\r
97     FXJSE_CLASS                                                                         m_JsNormalClass;\r
98     CFX_MapPtrTemplate<CXFA_Object*, FXJSE_HVALUE>  m_mapXFAToHValue;\r
99 \r
100     FXJSE_CLASS                                                                         m_JsGlobalVariablesClass;\r
101     CFX_MapPtrTemplate<CXFA_Object*, FXJSE_HCONTEXT> m_mapVariableToHValue;\r
102     CXFA_EventParam*                                                            m_pEventParam;\r
103     CXFA_NodeArray                                                                      m_upObjectArray;\r
104     CFX_PtrArray                                                                        m_CacheListArray;\r
105     CXFA_NodeArray*                                                                     m_pScriptNodeArray;\r
106     CXFA_ResolveProcessor*                                                      m_pResolveProcessor;\r
107     XFA_HFM2JSCONTEXT                                                           m_hFM2JSContext;\r
108     CXFA_Object*                                                                        m_pThisObject;\r
109     CFX_CMapByteStringToPtr                                                     m_JSBuiltInObjects;\r
110     FX_DWORD                                                                            m_dwBuiltInInFlags;\r
111     XFA_ATTRIBUTEENUM                                                           m_eRunAtType;\r
112 };\r
113 #endif\r