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