OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #include "core/fxcrt/include/fx_ext.h" | 7 #include "core/fxcrt/include/fx_ext.h" |
| 8 #include "xfa/fxfa/app/xfa_ffnotify.h" |
8 #include "xfa/fxfa/fm2js/xfa_fm2jsapi.h" | 9 #include "xfa/fxfa/fm2js/xfa_fm2jsapi.h" |
9 #include "xfa/fxfa/parser/xfa_basic_imp.h" | 10 #include "xfa/fxfa/parser/xfa_basic_imp.h" |
10 #include "xfa/fxfa/parser/xfa_docdata.h" | 11 #include "xfa/fxfa/parser/xfa_docdata.h" |
11 #include "xfa/fxfa/parser/xfa_doclayout.h" | 12 #include "xfa/fxfa/parser/xfa_doclayout.h" |
12 #include "xfa/fxfa/parser/xfa_document.h" | 13 #include "xfa/fxfa/parser/xfa_document.h" |
13 #include "xfa/fxfa/parser/xfa_document_layout_imp.h" | 14 #include "xfa/fxfa/parser/xfa_document_layout_imp.h" |
14 #include "xfa/fxfa/parser/xfa_localemgr.h" | 15 #include "xfa/fxfa/parser/xfa_localemgr.h" |
15 #include "xfa/fxfa/parser/xfa_object.h" | 16 #include "xfa/fxfa/parser/xfa_object.h" |
16 #include "xfa/fxfa/parser/xfa_parser.h" | 17 #include "xfa/fxfa/parser/xfa_parser.h" |
| 18 #include "xfa/fxfa/parser/xfa_parser_imp.h" |
17 #include "xfa/fxfa/parser/xfa_script.h" | 19 #include "xfa/fxfa/parser/xfa_script.h" |
18 #include "xfa/fxfa/parser/xfa_script_datawindow.h" | 20 #include "xfa/fxfa/parser/xfa_script_datawindow.h" |
19 #include "xfa/fxfa/parser/xfa_script_eventpseudomodel.h" | 21 #include "xfa/fxfa/parser/xfa_script_eventpseudomodel.h" |
20 #include "xfa/fxfa/parser/xfa_script_hostpseudomodel.h" | 22 #include "xfa/fxfa/parser/xfa_script_hostpseudomodel.h" |
| 23 #include "xfa/fxfa/parser/xfa_script_imp.h" |
21 #include "xfa/fxfa/parser/xfa_script_layoutpseudomodel.h" | 24 #include "xfa/fxfa/parser/xfa_script_layoutpseudomodel.h" |
22 #include "xfa/fxfa/parser/xfa_script_logpseudomodel.h" | 25 #include "xfa/fxfa/parser/xfa_script_logpseudomodel.h" |
23 #include "xfa/fxfa/parser/xfa_script_signaturepseudomodel.h" | 26 #include "xfa/fxfa/parser/xfa_script_signaturepseudomodel.h" |
24 #include "xfa/fxfa/parser/xfa_utils.h" | 27 #include "xfa/fxfa/parser/xfa_utils.h" |
25 | 28 |
26 CXFA_Document::CXFA_Document(IXFA_DocParser* pParser) | 29 CXFA_Document::CXFA_Document(CXFA_DocumentParser* pParser) |
27 : m_pParser(pParser), | 30 : m_pParser(pParser), |
28 m_pScriptContext(nullptr), | 31 m_pScriptContext(nullptr), |
29 m_pLayoutProcessor(nullptr), | 32 m_pLayoutProcessor(nullptr), |
30 m_pRootNode(nullptr), | 33 m_pRootNode(nullptr), |
31 m_pLocalMgr(nullptr), | 34 m_pLocalMgr(nullptr), |
32 m_pScriptDataWindow(nullptr), | 35 m_pScriptDataWindow(nullptr), |
33 m_pScriptEvent(nullptr), | 36 m_pScriptEvent(nullptr), |
34 m_pScriptHost(nullptr), | 37 m_pScriptHost(nullptr), |
35 m_pScriptLog(nullptr), | 38 m_pScriptLog(nullptr), |
36 m_pScriptLayout(nullptr), | 39 m_pScriptLayout(nullptr), |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 m_pScriptSignature = NULL; | 84 m_pScriptSignature = NULL; |
82 } | 85 } |
83 } | 86 } |
84 void CXFA_Document::SetRoot(CXFA_Node* pNewRoot) { | 87 void CXFA_Document::SetRoot(CXFA_Node* pNewRoot) { |
85 if (m_pRootNode) { | 88 if (m_pRootNode) { |
86 AddPurgeNode(m_pRootNode); | 89 AddPurgeNode(m_pRootNode); |
87 } | 90 } |
88 m_pRootNode = pNewRoot; | 91 m_pRootNode = pNewRoot; |
89 RemovePurgeNode(pNewRoot); | 92 RemovePurgeNode(pNewRoot); |
90 } | 93 } |
91 IXFA_Notify* CXFA_Document::GetNotify() const { | 94 CXFA_FFNotify* CXFA_Document::GetNotify() const { |
92 return m_pParser->GetNotify(); | 95 return m_pParser->GetNotify(); |
93 } | 96 } |
94 CXFA_Object* CXFA_Document::GetXFAObject(const CFX_WideStringC& wsNodeName) { | 97 CXFA_Object* CXFA_Document::GetXFAObject(const CFX_WideStringC& wsNodeName) { |
95 return GetXFAObject( | 98 return GetXFAObject( |
96 FX_HashCode_String_GetW(wsNodeName.GetPtr(), wsNodeName.GetLength())); | 99 FX_HashCode_String_GetW(wsNodeName.GetPtr(), wsNodeName.GetLength())); |
97 } | 100 } |
98 CXFA_Object* CXFA_Document::GetXFAObject(uint32_t dwNodeNameHash) { | 101 CXFA_Object* CXFA_Document::GetXFAObject(uint32_t dwNodeNameHash) { |
99 switch (dwNodeNameHash) { | 102 switch (dwNodeNameHash) { |
100 case XFA_HASHCODE_Data: { | 103 case XFA_HASHCODE_Data: { |
101 CXFA_Node* pDatasetsNode = ToNode(GetXFAObject(XFA_HASHCODE_Datasets)); | 104 CXFA_Node* pDatasetsNode = ToNode(GetXFAObject(XFA_HASHCODE_Datasets)); |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 } | 241 } |
239 CXFA_LocaleMgr* CXFA_Document::GetLocalMgr() { | 242 CXFA_LocaleMgr* CXFA_Document::GetLocalMgr() { |
240 if (!m_pLocalMgr) { | 243 if (!m_pLocalMgr) { |
241 CFX_WideString wsLanguage; | 244 CFX_WideString wsLanguage; |
242 GetParser()->GetNotify()->GetAppProvider()->GetLanguage(wsLanguage); | 245 GetParser()->GetNotify()->GetAppProvider()->GetLanguage(wsLanguage); |
243 m_pLocalMgr = new CXFA_LocaleMgr( | 246 m_pLocalMgr = new CXFA_LocaleMgr( |
244 ToNode(GetXFAObject(XFA_HASHCODE_LocaleSet)), wsLanguage); | 247 ToNode(GetXFAObject(XFA_HASHCODE_LocaleSet)), wsLanguage); |
245 } | 248 } |
246 return m_pLocalMgr; | 249 return m_pLocalMgr; |
247 } | 250 } |
248 IXFA_ScriptContext* CXFA_Document::InitScriptContext(FXJSE_HRUNTIME hRuntime) { | 251 CXFA_ScriptContext* CXFA_Document::InitScriptContext(FXJSE_HRUNTIME hRuntime) { |
249 if (!m_pScriptContext) { | 252 if (!m_pScriptContext) |
250 m_pScriptContext = XFA_ScriptContext_Create(this); | 253 m_pScriptContext = new CXFA_ScriptContext(this); |
251 } | |
252 m_pScriptContext->Initialize(hRuntime); | 254 m_pScriptContext->Initialize(hRuntime); |
253 return m_pScriptContext; | 255 return m_pScriptContext; |
254 } | 256 } |
255 IXFA_ScriptContext* CXFA_Document::GetScriptContext() { | 257 CXFA_ScriptContext* CXFA_Document::GetScriptContext() { |
256 if (!m_pScriptContext) { | 258 if (!m_pScriptContext) |
257 m_pScriptContext = XFA_ScriptContext_Create(this); | 259 m_pScriptContext = new CXFA_ScriptContext(this); |
258 } | |
259 return m_pScriptContext; | 260 return m_pScriptContext; |
260 } | 261 } |
261 XFA_VERSION CXFA_Document::RecognizeXFAVersionNumber( | 262 XFA_VERSION CXFA_Document::RecognizeXFAVersionNumber( |
262 CFX_WideString& wsTemplateNS) { | 263 CFX_WideString& wsTemplateNS) { |
263 CFX_WideStringC wsTemplateURIPrefix = | 264 CFX_WideStringC wsTemplateURIPrefix = |
264 XFA_GetPacketByIndex(XFA_PACKET_Template)->pURI; | 265 XFA_GetPacketByIndex(XFA_PACKET_Template)->pURI; |
265 FX_STRSIZE nPrefixLength = wsTemplateURIPrefix.GetLength(); | 266 FX_STRSIZE nPrefixLength = wsTemplateURIPrefix.GetLength(); |
266 if (CFX_WideStringC(wsTemplateNS, wsTemplateNS.GetLength()) != | 267 if (CFX_WideStringC(wsTemplateNS, wsTemplateNS.GetLength()) != |
267 wsTemplateURIPrefix) { | 268 wsTemplateURIPrefix) { |
268 return XFA_VERSION_UNKNOWN; | 269 return XFA_VERSION_UNKNOWN; |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
432 pProtoNode)) { | 433 pProtoNode)) { |
433 continue; | 434 continue; |
434 } | 435 } |
435 } | 436 } |
436 if (!pProtoNode) { | 437 if (!pProtoNode) { |
437 continue; | 438 continue; |
438 } | 439 } |
439 XFA_ProtoMerge_MergeNode(this, pUseHrefNode, pProtoNode); | 440 XFA_ProtoMerge_MergeNode(this, pUseHrefNode, pProtoNode); |
440 } | 441 } |
441 } | 442 } |
OLD | NEW |