• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_FXFA_PARSER_CXFA_DOCUMENT_H_
8 #define XFA_FXFA_PARSER_CXFA_DOCUMENT_H_
9 
10 #include <map>
11 
12 #include "xfa/fxfa/fxfa.h"
13 #include "xfa/fxfa/parser/xfa_localemgr.h"
14 #include "xfa/fxfa/parser/xfa_object.h"
15 
16 enum XFA_VERSION {
17   XFA_VERSION_UNKNOWN = 0,
18   XFA_VERSION_200 = 200,
19   XFA_VERSION_202 = 202,
20   XFA_VERSION_204 = 204,
21   XFA_VERSION_205 = 205,
22   XFA_VERSION_206 = 206,
23   XFA_VERSION_207 = 207,
24   XFA_VERSION_208 = 208,
25   XFA_VERSION_300 = 300,
26   XFA_VERSION_301 = 301,
27   XFA_VERSION_303 = 303,
28   XFA_VERSION_306 = 306,
29   XFA_VERSION_DEFAULT = XFA_VERSION_303,
30   XFA_VERSION_MIN = 200,
31   XFA_VERSION_MAX = 400,
32 };
33 
34 enum XFA_DocFlag {
35   XFA_DOCFLAG_StrictScoping = 0x0001,
36   XFA_DOCFLAG_HasInteractive = 0x0002,
37   XFA_DOCFLAG_Interactive = 0x0004,
38   XFA_DOCFLAG_Scripting = 0x0008
39 };
40 
41 class CFDE_XMLDoc;
42 class CScript_DataWindow;
43 class CScript_EventPseudoModel;
44 class CScript_HostPseudoModel;
45 class CScript_LogPseudoModel;
46 class CScript_LayoutPseudoModel;
47 class CScript_SignaturePseudoModel;
48 class CXFA_Document;
49 class CXFA_LayoutItem;
50 class CXFA_LayoutProcessor;
51 class CXFA_Node;
52 class CXFA_LayoutProcessor;
53 class CXFA_DocumentParser;
54 class CXFA_ContainerLayoutItem;
55 class CXFA_FFNotify;
56 class CXFA_ScriptContext;
57 
58 class CXFA_Document {
59  public:
60   explicit CXFA_Document(CXFA_DocumentParser* pParser);
61   ~CXFA_Document();
62 
63   CXFA_ScriptContext* InitScriptContext(v8::Isolate* pIsolate);
64 
GetRoot()65   CXFA_Node* GetRoot() const { return m_pRootNode; }
66 
67   CFDE_XMLDoc* GetXMLDoc() const;
68   CXFA_FFNotify* GetNotify() const;
69   CXFA_LocaleMgr* GetLocalMgr();
70   CXFA_Object* GetXFAObject(XFA_HashCode wsNodeNameHash);
71   CXFA_Node* GetNodeByID(CXFA_Node* pRoot, const CFX_WideStringC& wsID);
72   CXFA_Node* GetNotBindNode(CXFA_ObjArray& arrayNodes);
73   CXFA_LayoutProcessor* GetLayoutProcessor();
74   CXFA_LayoutProcessor* GetDocLayout();
75   CXFA_ScriptContext* GetScriptContext();
76 
77   void SetRoot(CXFA_Node* pNewRoot);
78 
79   void AddPurgeNode(CXFA_Node* pNode);
80   bool RemovePurgeNode(CXFA_Node* pNode);
81   void PurgeNodes();
82 
HasFlag(uint32_t dwFlag)83   bool HasFlag(uint32_t dwFlag) { return (m_dwDocFlags & dwFlag) == dwFlag; }
84   void SetFlag(uint32_t dwFlag, bool bOn);
85 
86   bool IsInteractive();
GetCurVersionMode()87   XFA_VERSION GetCurVersionMode() { return m_eCurVersionMode; }
88   XFA_VERSION RecognizeXFAVersionNumber(CFX_WideString& wsTemplateNS);
89 
90   CXFA_Node* CreateNode(uint32_t dwPacket, XFA_Element eElement);
91   CXFA_Node* CreateNode(const XFA_PACKETINFO* pPacket, XFA_Element eElement);
92 
93   void DoProtoMerge();
94   void DoDataMerge();
95   void DoDataRemerge(bool bDoDataMerge);
96   CXFA_Node* DataMerge_CopyContainer(CXFA_Node* pTemplateNode,
97                                      CXFA_Node* pFormNode,
98                                      CXFA_Node* pDataScope,
99                                      bool bOneInstance,
100                                      bool bDataMerge,
101                                      bool bUpLevel);
102   void DataMerge_UpdateBindingRelations(CXFA_Node* pFormUpdateRoot);
103 
104   void ClearLayoutData();
105 
106   std::map<uint32_t, CXFA_Node*> m_rgGlobalBinding;
107   CXFA_NodeArray m_pPendingPageSet;
108 
109  protected:
110   CXFA_DocumentParser* m_pParser;
111   CXFA_ScriptContext* m_pScriptContext;
112   CXFA_LayoutProcessor* m_pLayoutProcessor;
113   CXFA_Node* m_pRootNode;
114   CXFA_LocaleMgr* m_pLocalMgr;
115   CScript_DataWindow* m_pScriptDataWindow;
116   CScript_EventPseudoModel* m_pScriptEvent;
117   CScript_HostPseudoModel* m_pScriptHost;
118   CScript_LogPseudoModel* m_pScriptLog;
119   CScript_LayoutPseudoModel* m_pScriptLayout;
120   CScript_SignaturePseudoModel* m_pScriptSignature;
121   CXFA_NodeSet m_PurgeNodes;
122   XFA_VERSION m_eCurVersionMode;
123   uint32_t m_dwDocFlags;
124 };
125 
126 #endif  // XFA_FXFA_PARSER_CXFA_DOCUMENT_H_
127