Replace XFA_HWIDGET with IXFA_Widget*
[pdfium.git] / xfa / src / fxfa / src / common / xfa_document.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 _XFA_DOCUMENT_H\r
8 #define _XFA_DOCUMENT_H\r
9 class IXFA_DocParser;\r
10 class CXFA_LayoutProcessor;\r
11 class IXFA_DocLayout;\r
12 class IXFA_LayoutPage;\r
13 class CXFA_LayoutItem;\r
14 class IXFA_PageContent;\r
15 class IXFA_ScriptContext;\r
16 class CXFA_Node;\r
17 class IXFA_Notify;\r
18 class IXFA_ObjFactory;\r
19 class CXFA_Document;\r
20 enum XFA_VERSION {\r
21     XFA_VERSION_UNKNOWN = 0,\r
22     XFA_VERSION_200 = 200,\r
23     XFA_VERSION_202 = 202,\r
24     XFA_VERSION_204 = 204,\r
25     XFA_VERSION_205 = 205,\r
26     XFA_VERSION_206 = 206,\r
27     XFA_VERSION_207 = 207,\r
28     XFA_VERSION_208 = 208,\r
29     XFA_VERSION_300 = 300,\r
30     XFA_VERSION_301 = 301,\r
31     XFA_VERSION_303 = 303,\r
32     XFA_VERSION_306 = 306,\r
33     XFA_VERSION_DEFAULT = XFA_VERSION_303,\r
34     XFA_VERSION_MIN     = 200,\r
35     XFA_VERSION_MAX     = 400,\r
36 };\r
37 #define XFA_LAYOUTSTATUS_Visible        0x0001\r
38 #define XFA_LAYOUTSTATUS_Viewable       0x0010\r
39 #define XFA_LAYOUTSTATUS_Printable      0x0020\r
40 enum XFA_NODEEVENT {\r
41     XFA_NODEEVENT_Ready,\r
42     XFA_NODEEVENT_ValueChanging,\r
43     XFA_NODEEVENT_ValueChanged,\r
44     XFA_NODEEVENT_ChildAdded,\r
45     XFA_NODEEVENT_ChildRemoved,\r
46 };\r
47 enum XFA_PAGEEVENT {\r
48     XFA_PAGEEVENT_PageAdded,\r
49     XFA_PAGEEVENT_PageRemoved,\r
50 };\r
51 enum XFA_LAYOUTEVENT {\r
52     XFA_LAYOUTEVENT_ItemAdded,\r
53     XFA_LAYOUTEVENT_ItemRemoving,\r
54     XFA_LAYOUTEVENT_RectChanged,\r
55     XFA_LAYOUTEVENT_StatusChanged,\r
56 };\r
57 enum XFA_LAYOUTRESULT {\r
58     XFA_LAYOUTRESULT_Continue,\r
59     XFA_LAYOUTRESULT_Done,\r
60     XFA_LAYOUTRESULT_NextContent,\r
61 };\r
62 #define XFA_LAYOUTNOTIFY_StrictHeight   0x0001\r
63 #define XFA_LAYOUTNOTIFY_NoParentBreak  0x0002\r
64 class IXFA_Notify\r
65 {\r
66 public:\r
67     virtual void                                OnPageEvent(IXFA_LayoutPage *pSender, XFA_PAGEEVENT eEvent, FX_LPVOID pParam = NULL) = 0;\r
68 \r
69     virtual void                                OnNodeEvent(CXFA_Node *pSender, XFA_NODEEVENT eEvent, FX_LPVOID pParam = NULL, FX_LPVOID pParam2 = NULL, FX_LPVOID pParam3 = NULL, FX_LPVOID pParam4 = NULL) = 0;\r
70     virtual void                        OnWidgetDataEvent(CXFA_WidgetData* pSender, FX_DWORD dwEvent, FX_LPVOID pParam = NULL, FX_LPVOID pAdditional = NULL, FX_LPVOID pAdditional2 = NULL) = 0;\r
71 \r
72     virtual CXFA_LayoutItem*    OnCreateLayoutItem(CXFA_Node *pNode) = 0;\r
73     virtual void                                OnLayoutEvent(IXFA_DocLayout *pLayout, CXFA_LayoutItem *pSender, XFA_LAYOUTEVENT eEvent, FX_LPVOID pParam = NULL, FX_LPVOID pParam2 = NULL) = 0;\r
74     virtual void                                StartFieldDrawLayout(CXFA_Node *pItem, FX_FLOAT &fCalcWidth, FX_FLOAT &fCalcHeight) = 0;\r
75     virtual FX_BOOL                             FindSplitPos(CXFA_Node *pItem, FX_INT32 iBlockIndex, FX_FLOAT &fCalcHeightPos) = 0;\r
76     virtual FX_BOOL                             RunScript(CXFA_Node* pScript, CXFA_Node* pFormItem) = 0;\r
77     virtual     FX_INT32                        ExecEventByDeepFirst(CXFA_Node* pFormNode, XFA_EVENTTYPE eEventType, FX_BOOL bIsFormReady = FALSE, FX_BOOL bRecursive = TRUE, CXFA_WidgetAcc* pExclude = NULL) = 0;\r
78     virtual void                                AddCalcValidate(CXFA_Node* pNode) = 0;\r
79     virtual IXFA_Doc*                   GetHDOC() = 0;\r
80     virtual IXFA_DocProvider*   GetDocProvider() = 0;\r
81     virtual IXFA_AppProvider*   GetAppProvider() = 0;\r
82     virtual IXFA_WidgetHandler* GetWidgetHandler() = 0;\r
83     virtual IXFA_Widget*                GetHWidget(CXFA_LayoutItem* pLayoutItem) = 0;\r
84     virtual void                                OpenDropDownList(IXFA_Widget* hWidget) = 0;\r
85     virtual CFX_WideString              GetCurrentDateTime() = 0;\r
86     virtual void                                ResetData(CXFA_WidgetData* pWidgetData = NULL) = 0;\r
87     virtual FX_INT32                    GetLayoutStatus() = 0;\r
88     virtual void                                RunNodeInitialize(CXFA_Node* pNode) = 0;\r
89     virtual void                                RunSubformIndexChange(CXFA_Node* pSubformNode) = 0;\r
90     virtual CXFA_Node*                  GetFocusWidgetNode() = 0;\r
91     virtual void                                SetFocusWidgetNode(CXFA_Node* pNode) = 0;\r
92 };\r
93 class IXFA_ObjFactory\r
94 {\r
95 public:\r
96     virtual CXFA_Node*                  CreateNode(FX_DWORD dwPacket, XFA_ELEMENT eElement) = 0;\r
97     virtual CXFA_Node*                  CreateNode(XFA_LPCPACKETINFO pPacket, XFA_ELEMENT eElement) = 0;\r
98 };\r
99 #define XFA_DOCFLAG_StrictScoping       0x0001\r
100 #define XFA_DOCFLAG_HasInteractive      0x0002\r
101 #define XFA_DOCFLAG_Interactive         0x0004\r
102 #define XFA_DOCFLAG_Scripting           0x0008\r
103 class CScript_DataWindow;\r
104 class CScript_EventPseudoModel;\r
105 class CScript_HostPseudoModel;\r
106 class CScript_LogPseudoModel;\r
107 class CScript_LayoutPseudoModel;\r
108 class CScript_SignaturePseudoModel;\r
109 class CXFA_Document : public IXFA_ObjFactory\r
110 {\r
111 public:\r
112     CXFA_Document(IXFA_DocParser *pParser);\r
113     ~CXFA_Document();\r
114     CXFA_Node*                                  GetRoot() const\r
115     {\r
116         return m_pRootNode;\r
117     }\r
118     IXFA_DocParser*                             GetParser() const\r
119     {\r
120         return m_pParser;\r
121     }\r
122     IXFA_Notify*                                GetNotify() const;\r
123     void                                                SetRoot(CXFA_Node* pNewRoot);\r
124     CXFA_Object*                                GetXFANode(FX_WSTR wsNodeName);\r
125     CXFA_Object*                                GetXFANode(FX_DWORD wsNodeNameHash);\r
126     void                                                AddPurgeNode(CXFA_Node *pNode);\r
127     FX_BOOL                                             RemovePurgeNode(CXFA_Node *pNode);\r
128     void                                                PurgeNodes();\r
129     FX_BOOL                                             HasFlag(FX_DWORD dwFlag)\r
130     {\r
131         return (m_dwDocFlags & dwFlag) == dwFlag;\r
132     }\r
133     void                                                SetFlag(FX_DWORD dwFlag, FX_BOOL bOn = TRUE);\r
134     FX_BOOL                                             IsInteractive();\r
135     XFA_VERSION                                 GetCurVersionMode()\r
136     {\r
137         return m_eCurVersionMode;\r
138     }\r
139     XFA_VERSION                                 RecognizeXFAVersionNumber(CFX_WideString& wsTemplateNS);\r
140     CXFA_LocaleMgr*                             GetLocalMgr();\r
141     virtual CXFA_Node*                  CreateNode(FX_DWORD dwPacket, XFA_ELEMENT eElement);\r
142     virtual CXFA_Node*                  CreateNode(XFA_LPCPACKETINFO pPacket, XFA_ELEMENT eElement);\r
143     void                                                DoProtoMerge();\r
144     CXFA_Node*                                  GetNodeByID(CXFA_Node* pRoot, FX_WSTR wsID);\r
145 \r
146     void                                                DoDataMerge();\r
147     void                                                DoDataRemerge(FX_BOOL bDoDataMerge);\r
148     CXFA_Node*                                  DataMerge_CopyContainer(CXFA_Node* pTemplateNode, CXFA_Node* pFormNode, CXFA_Node* pDataScope, FX_BOOL bOneInstance = FALSE, FX_BOOL bDataMerge = TRUE, FX_BOOL bUpLevel = TRUE);\r
149     void                                                DataMerge_UpdateBindingRelations(CXFA_Node* pFormUpdateRoot);\r
150     CXFA_Node*                                  GetNotBindNode(CXFA_ObjArray& arrayNodes);\r
151     CXFA_LayoutProcessor*               GetLayoutProcessor();\r
152     IXFA_DocLayout*                             GetDocLayout();\r
153     IXFA_ScriptContext*                 InitScriptContext(FXJSE_HRUNTIME hRuntime);\r
154     IXFA_ScriptContext*                 GetScriptContext();\r
155     void                                                ClearLayoutData();\r
156 public:\r
157     CFX_MapPtrTemplate<FX_DWORD, CXFA_Node*> m_rgGlobalBinding;\r
158     CXFA_NodeArray                               m_pPendingPageSet;\r
159 protected:\r
160     IXFA_DocParser*                             m_pParser;\r
161     IXFA_ScriptContext*                 m_pScriptContext;\r
162     CXFA_LayoutProcessor*               m_pLayoutProcessor;\r
163     CXFA_Node*                                  m_pRootNode;\r
164 \r
165     CXFA_LocaleMgr*                             m_pLocalMgr;\r
166     CScript_DataWindow*                                 m_pScriptDataWindow;\r
167     CScript_EventPseudoModel*                   m_pScriptEvent;\r
168     CScript_HostPseudoModel*                    m_pScriptHost;\r
169     CScript_LogPseudoModel*                             m_pScriptLog;\r
170     CScript_LayoutPseudoModel*                  m_pScriptLayout;\r
171     CScript_SignaturePseudoModel*               m_pScriptSignature;\r
172     CXFA_NodeSet                                                m_rgPurgeNodes;\r
173     XFA_VERSION                                                 m_eCurVersionMode;\r
174     FX_DWORD                                                    m_dwDocFlags;\r
175     friend class CXFA_SimpleParser;\r
176 };\r
177 #endif\r