summaryrefslogtreecommitdiff
path: root/xfa/src/fxfa/src/common/xfa_document.h
blob: 9e985e2155663c69a871a445e791b4b3a577bca3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
// Copyright 2014 PDFium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com

#ifndef _XFA_DOCUMENT_H
#define _XFA_DOCUMENT_H
class IXFA_DocParser;
class CXFA_LayoutProcessor;
class IXFA_DocLayout;
class IXFA_LayoutPage;
class CXFA_LayoutItem;
class IXFA_PageContent;
class IXFA_ScriptContext;
class CXFA_Node;
class IXFA_Notify;
class IXFA_ObjFactory;
class CXFA_Document;
enum XFA_VERSION {
    XFA_VERSION_UNKNOWN = 0,
    XFA_VERSION_200 = 200,
    XFA_VERSION_202 = 202,
    XFA_VERSION_204 = 204,
    XFA_VERSION_205 = 205,
    XFA_VERSION_206 = 206,
    XFA_VERSION_207 = 207,
    XFA_VERSION_208 = 208,
    XFA_VERSION_300 = 300,
    XFA_VERSION_301 = 301,
    XFA_VERSION_303 = 303,
    XFA_VERSION_306 = 306,
    XFA_VERSION_DEFAULT = XFA_VERSION_303,
    XFA_VERSION_MIN     = 200,
    XFA_VERSION_MAX     = 400,
};
#define XFA_LAYOUTSTATUS_Visible	0x0001
#define XFA_LAYOUTSTATUS_Viewable	0x0010
#define XFA_LAYOUTSTATUS_Printable	0x0020
enum XFA_NODEEVENT {
    XFA_NODEEVENT_Ready,
    XFA_NODEEVENT_ValueChanging,
    XFA_NODEEVENT_ValueChanged,
    XFA_NODEEVENT_ChildAdded,
    XFA_NODEEVENT_ChildRemoved,
};
enum XFA_PAGEEVENT {
    XFA_PAGEEVENT_PageAdded,
    XFA_PAGEEVENT_PageRemoved,
};
enum XFA_LAYOUTEVENT {
    XFA_LAYOUTEVENT_ItemAdded,
    XFA_LAYOUTEVENT_ItemRemoving,
    XFA_LAYOUTEVENT_RectChanged,
    XFA_LAYOUTEVENT_StatusChanged,
};
enum XFA_LAYOUTRESULT {
    XFA_LAYOUTRESULT_Continue,
    XFA_LAYOUTRESULT_Done,
    XFA_LAYOUTRESULT_NextContent,
};
#define XFA_LAYOUTNOTIFY_StrictHeight	0x0001
#define XFA_LAYOUTNOTIFY_NoParentBreak	0x0002
class IXFA_Notify
{
public:
    virtual void				OnPageEvent(IXFA_LayoutPage *pSender, XFA_PAGEEVENT eEvent, FX_LPVOID pParam = NULL) = 0;

    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;
    virtual void		        OnWidgetDataEvent(CXFA_WidgetData* pSender, FX_DWORD dwEvent, FX_LPVOID pParam = NULL, FX_LPVOID pAdditional = NULL, FX_LPVOID pAdditional2 = NULL) = 0;

    virtual CXFA_LayoutItem*	OnCreateLayoutItem(CXFA_Node *pNode) = 0;
    virtual void				OnLayoutEvent(IXFA_DocLayout *pLayout, CXFA_LayoutItem *pSender, XFA_LAYOUTEVENT eEvent, FX_LPVOID pParam = NULL, FX_LPVOID pParam2 = NULL) = 0;
    virtual void				StartFieldDrawLayout(CXFA_Node *pItem, FX_FLOAT &fCalcWidth, FX_FLOAT &fCalcHeight) = 0;
    virtual FX_BOOL				FindSplitPos(CXFA_Node *pItem, FX_INT32 iBlockIndex, FX_FLOAT &fCalcHeightPos) = 0;
    virtual FX_BOOL				RunScript(CXFA_Node* pScript, CXFA_Node* pFormItem) = 0;
    virtual	FX_INT32			ExecEventByDeepFirst(CXFA_Node* pFormNode, XFA_EVENTTYPE eEventType, FX_BOOL bIsFormReady = FALSE, FX_BOOL bRecursive = TRUE, CXFA_WidgetAcc* pExclude = NULL) = 0;
    virtual void				AddCalcValidate(CXFA_Node* pNode) = 0;
    virtual IXFA_Doc*			GetHDOC() = 0;
    virtual IXFA_DocProvider*	GetDocProvider() = 0;
    virtual IXFA_AppProvider*	GetAppProvider() = 0;
    virtual IXFA_WidgetHandler*	GetWidgetHandler() = 0;
    virtual XFA_HWIDGET			GetHWidget(CXFA_LayoutItem* pLayoutItem) = 0;
    virtual void				OpenDropDownList(XFA_HWIDGET hWidget) = 0;
    virtual CFX_WideString		GetCurrentDateTime() = 0;
    virtual void				ResetData(CXFA_WidgetData* pWidgetData = NULL) = 0;
    virtual FX_INT32			GetLayoutStatus() = 0;
    virtual void				RunNodeInitialize(CXFA_Node* pNode) = 0;
    virtual void				RunSubformIndexChange(CXFA_Node* pSubformNode) = 0;
    virtual CXFA_Node*			GetFocusWidgetNode() = 0;
    virtual void				SetFocusWidgetNode(CXFA_Node* pNode) = 0;
};
class IXFA_ObjFactory
{
public:
    virtual CXFA_Node*			CreateNode(FX_DWORD dwPacket, XFA_ELEMENT eElement) = 0;
    virtual CXFA_Node*			CreateNode(XFA_LPCPACKETINFO pPacket, XFA_ELEMENT eElement) = 0;
};
#define XFA_DOCFLAG_StrictScoping	0x0001
#define XFA_DOCFLAG_HasInteractive	0x0002
#define XFA_DOCFLAG_Interactive		0x0004
#define XFA_DOCFLAG_Scripting		0x0008
class CScript_DataWindow;
class CScript_EventPseudoModel;
class CScript_HostPseudoModel;
class CScript_LogPseudoModel;
class CScript_LayoutPseudoModel;
class CScript_SignaturePseudoModel;
class CXFA_Document : public IXFA_ObjFactory
{
public:
    CXFA_Document(IXFA_DocParser *pParser);
    ~CXFA_Document();
    CXFA_Node*					GetRoot() const
    {
        return m_pRootNode;
    }
    IXFA_DocParser*				GetParser() const
    {
        return m_pParser;
    }
    IXFA_Notify*				GetNotify() const;
    void						SetRoot(CXFA_Node* pNewRoot);
    CXFA_Object*				GetXFANode(FX_WSTR wsNodeName);
    CXFA_Object*				GetXFANode(FX_DWORD wsNodeNameHash);
    void						AddPurgeNode(CXFA_Node *pNode);
    FX_BOOL						RemovePurgeNode(CXFA_Node *pNode);
    void						PurgeNodes();
    FX_BOOL						HasFlag(FX_DWORD dwFlag)
    {
        return (m_dwDocFlags & dwFlag) == dwFlag;
    }
    void						SetFlag(FX_DWORD dwFlag, FX_BOOL bOn = TRUE);
    FX_BOOL						IsInteractive();
    XFA_VERSION					GetCurVersionMode()
    {
        return m_eCurVersionMode;
    }
    XFA_VERSION					RecognizeXFAVersionNumber(CFX_WideString& wsTemplateNS);
    CXFA_LocaleMgr*				GetLocalMgr();
    virtual CXFA_Node*			CreateNode(FX_DWORD dwPacket, XFA_ELEMENT eElement);
    virtual CXFA_Node*			CreateNode(XFA_LPCPACKETINFO pPacket, XFA_ELEMENT eElement);
    void						DoProtoMerge();
    CXFA_Node*					GetNodeByID(CXFA_Node* pRoot, FX_WSTR wsID);

    void						DoDataMerge();
    void						DoDataRemerge(FX_BOOL bDoDataMerge);
    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);
    void						DataMerge_UpdateBindingRelations(CXFA_Node* pFormUpdateRoot);
    CXFA_Node*					GetNotBindNode(CXFA_ObjArray& arrayNodes);
    CXFA_LayoutProcessor*		GetLayoutProcessor();
    IXFA_DocLayout*				GetDocLayout();
    IXFA_ScriptContext*			InitScriptContext(FXJSE_HRUNTIME hRuntime);
    IXFA_ScriptContext*			GetScriptContext();
    void						ClearLayoutData();
public:
    CFX_MapPtrTemplate<FX_DWORD, CXFA_Node*> m_rgGlobalBinding;
    CXFA_NodeArray				 m_pPendingPageSet;
protected:
    IXFA_DocParser*				m_pParser;
    IXFA_ScriptContext*			m_pScriptContext;
    CXFA_LayoutProcessor*		m_pLayoutProcessor;
    CXFA_Node*					m_pRootNode;

    CXFA_LocaleMgr*				m_pLocalMgr;
    CScript_DataWindow*					m_pScriptDataWindow;
    CScript_EventPseudoModel*			m_pScriptEvent;
    CScript_HostPseudoModel*			m_pScriptHost;
    CScript_LogPseudoModel*				m_pScriptLog;
    CScript_LayoutPseudoModel*			m_pScriptLayout;
    CScript_SignaturePseudoModel*		m_pScriptSignature;
    CXFA_NodeSet						m_rgPurgeNodes;
    XFA_VERSION							m_eCurVersionMode;
    FX_DWORD							m_dwDocFlags;
    friend class CXFA_SimpleParser;
};
#endif