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 "xfa/fxfa/app/xfa_ffdochandler.h" | 7 #include "xfa/include/fxfa/xfa_ffdochandler.h" |
8 | 8 |
9 #include "xfa/fxfa/app/xfa_ffdoc.h" | 9 #include "xfa/include/fxfa/xfa_ffdoc.h" |
10 #include "xfa/fxfa/parser/xfa_script.h" | 10 #include "xfa/fxfa/parser/xfa_script.h" |
11 #include "xfa/include/fxfa/xfa_checksum.h" | |
12 #include "xfa/fxfa/parser/xfa_script_imp.h" | |
11 | 13 |
12 CXFA_FFDocHandler::CXFA_FFDocHandler() {} | 14 CXFA_FFDocHandler::CXFA_FFDocHandler() {} |
15 | |
13 CXFA_FFDocHandler::~CXFA_FFDocHandler() {} | 16 CXFA_FFDocHandler::~CXFA_FFDocHandler() {} |
14 void CXFA_FFDocHandler::ReleaseDoc(IXFA_Doc* hDoc) { | 17 |
18 void CXFA_FFDocHandler::ReleaseDoc(CXFA_FFDoc* hDoc) { | |
15 delete hDoc; // virtual dtor. | 19 delete hDoc; // virtual dtor. |
16 } | 20 } |
17 IXFA_DocProvider* CXFA_FFDocHandler::GetDocProvider(IXFA_Doc* hDoc) { | 21 IXFA_DocProvider* CXFA_FFDocHandler::GetDocProvider(CXFA_FFDoc* hDoc) { |
18 return static_cast<CXFA_FFDoc*>(hDoc)->GetDocProvider(); | 22 return static_cast<CXFA_FFDoc*>(hDoc)->GetDocProvider(); |
19 } | 23 } |
20 uint32_t CXFA_FFDocHandler::GetDocType(IXFA_Doc* hDoc) { | 24 uint32_t CXFA_FFDocHandler::GetDocType(CXFA_FFDoc* hDoc) { |
21 return static_cast<CXFA_FFDoc*>(hDoc)->GetDocType(); | 25 return static_cast<CXFA_FFDoc*>(hDoc)->GetDocType(); |
22 } | 26 } |
23 int32_t CXFA_FFDocHandler::StartLoad(IXFA_Doc* hDoc) { | 27 int32_t CXFA_FFDocHandler::StartLoad(CXFA_FFDoc* hDoc) { |
24 return static_cast<CXFA_FFDoc*>(hDoc)->StartLoad(); | 28 return static_cast<CXFA_FFDoc*>(hDoc)->StartLoad(); |
25 } | 29 } |
26 int32_t CXFA_FFDocHandler::DoLoad(IXFA_Doc* hDoc, IFX_Pause* pPause) { | 30 int32_t CXFA_FFDocHandler::DoLoad(CXFA_FFDoc* hDoc, IFX_Pause* pPause) { |
27 return static_cast<CXFA_FFDoc*>(hDoc)->DoLoad(pPause); | 31 return static_cast<CXFA_FFDoc*>(hDoc)->DoLoad(pPause); |
28 } | 32 } |
29 void CXFA_FFDocHandler::StopLoad(IXFA_Doc* hDoc) { | 33 void CXFA_FFDocHandler::StopLoad(CXFA_FFDoc* hDoc) { |
30 static_cast<CXFA_FFDoc*>(hDoc)->StopLoad(); | 34 static_cast<CXFA_FFDoc*>(hDoc)->StopLoad(); |
31 } | 35 } |
32 | 36 |
33 IXFA_DocView* CXFA_FFDocHandler::CreateDocView(IXFA_Doc* hDoc, | 37 CXFA_FFDocView* CXFA_FFDocHandler::CreateDocView(CXFA_FFDoc* hDoc, |
34 uint32_t dwView) { | 38 uint32_t dwView) { |
35 return static_cast<CXFA_FFDoc*>(hDoc)->CreateDocView(dwView); | 39 return static_cast<CXFA_FFDoc*>(hDoc)->CreateDocView(dwView); |
36 } | 40 } |
37 int32_t CXFA_FFDocHandler::CountPackages(IXFA_Doc* hDoc) { | 41 int32_t CXFA_FFDocHandler::CountPackages(CXFA_FFDoc* hDoc) { |
38 return 0; | 42 return 0; |
39 } | 43 } |
40 void CXFA_FFDocHandler::GetPackageName(IXFA_Doc* hDoc, | 44 void CXFA_FFDocHandler::GetPackageName(CXFA_FFDoc* hDoc, |
41 int32_t iPackage, | 45 int32_t iPackage, |
42 CFX_WideStringC& wsPackage) {} | 46 CFX_WideStringC& wsPackage) {} |
43 CFDE_XMLElement* CXFA_FFDocHandler::GetPackageData( | 47 CFDE_XMLElement* CXFA_FFDocHandler::GetPackageData( |
44 IXFA_Doc* hDoc, | 48 CXFA_FFDoc* hDoc, |
45 const CFX_WideStringC& wsPackage) { | 49 const CFX_WideStringC& wsPackage) { |
46 return static_cast<CXFA_FFDoc*>(hDoc)->GetPackageData(wsPackage); | 50 return static_cast<CXFA_FFDoc*>(hDoc)->GetPackageData(wsPackage); |
47 } | 51 } |
48 FX_BOOL CXFA_FFDocHandler::SavePackage(IXFA_Doc* hDoc, | 52 FX_BOOL CXFA_FFDocHandler::SavePackage(CXFA_FFDoc* hDoc, |
49 const CFX_WideStringC& wsPackage, | 53 const CFX_WideStringC& wsPackage, |
50 IFX_FileWrite* pFile, | 54 IFX_FileWrite* pFile, |
51 IXFA_ChecksumContext* pCSContext) { | 55 CXFA_ChecksumContext* pCSContext) { |
52 return static_cast<CXFA_FFDoc*>(hDoc) | 56 return static_cast<CXFA_FFDoc*>(hDoc) |
53 ->SavePackage(wsPackage, pFile, pCSContext); | 57 ->SavePackage(wsPackage, pFile, pCSContext); |
54 } | 58 } |
55 FX_BOOL CXFA_FFDocHandler::CloseDoc(IXFA_Doc* hDoc) { | 59 FX_BOOL CXFA_FFDocHandler::CloseDoc(CXFA_FFDoc* hDoc) { |
56 return static_cast<CXFA_FFDoc*>(hDoc)->CloseDoc(); | 60 return static_cast<CXFA_FFDoc*>(hDoc)->CloseDoc(); |
57 } | 61 } |
58 | 62 |
59 FX_BOOL CXFA_FFDocHandler::ImportData(IXFA_Doc* hDoc, | 63 FX_BOOL CXFA_FFDocHandler::ImportData(CXFA_FFDoc* hDoc, |
60 IFX_FileRead* pStream, | 64 IFX_FileRead* pStream, |
61 FX_BOOL bXDP) { | 65 FX_BOOL bXDP) { |
62 return static_cast<CXFA_FFDoc*>(hDoc)->ImportData(pStream, bXDP); | 66 return static_cast<CXFA_FFDoc*>(hDoc)->ImportData(pStream, bXDP); |
63 } | 67 } |
64 void CXFA_FFDocHandler::SetJSERuntime(IXFA_Doc* hDoc, FXJSE_HRUNTIME hRuntime) { | 68 void CXFA_FFDocHandler::SetJSERuntime(CXFA_FFDoc* hDoc, |
Tom Sepez
2016/03/31 17:01:57
nit: funny, this used to fin in 80 cols.
dsinclair
2016/03/31 19:52:26
CXFA_FFDoc is longer then IXFA_Doc. At some point
Tom Sepez
2016/03/31 21:49:27
I didn't notice the FF. FF probably mean form fil
| |
69 FXJSE_HRUNTIME hRuntime) { | |
65 static_cast<CXFA_FFDoc*>(hDoc)->GetXFADoc()->InitScriptContext(hRuntime); | 70 static_cast<CXFA_FFDoc*>(hDoc)->GetXFADoc()->InitScriptContext(hRuntime); |
66 } | 71 } |
67 FXJSE_HVALUE CXFA_FFDocHandler::GetXFAScriptObject(IXFA_Doc* hDoc) { | 72 FXJSE_HVALUE CXFA_FFDocHandler::GetXFAScriptObject(CXFA_FFDoc* hDoc) { |
68 CXFA_Document* pXFADoc = static_cast<CXFA_FFDoc*>(hDoc)->GetXFADoc(); | 73 CXFA_Document* pXFADoc = static_cast<CXFA_FFDoc*>(hDoc)->GetXFADoc(); |
69 if (!pXFADoc) { | 74 if (!pXFADoc) { |
70 return NULL; | 75 return NULL; |
71 } | 76 } |
72 IXFA_ScriptContext* pScriptContext = pXFADoc->GetScriptContext(); | 77 CXFA_ScriptContext* pScriptContext = pXFADoc->GetScriptContext(); |
73 if (!pScriptContext) { | 78 if (!pScriptContext) { |
74 return NULL; | 79 return NULL; |
75 } | 80 } |
76 return pScriptContext->GetJSValueFromMap(pXFADoc->GetRoot()); | 81 return pScriptContext->GetJSValueFromMap(pXFADoc->GetRoot()); |
77 } | 82 } |
78 XFA_ATTRIBUTEENUM CXFA_FFDocHandler::GetRestoreState(IXFA_Doc* hDoc) { | 83 XFA_ATTRIBUTEENUM CXFA_FFDocHandler::GetRestoreState(CXFA_FFDoc* hDoc) { |
79 CXFA_Document* pXFADoc = static_cast<CXFA_FFDoc*>(hDoc)->GetXFADoc(); | 84 CXFA_Document* pXFADoc = static_cast<CXFA_FFDoc*>(hDoc)->GetXFADoc(); |
80 if (!pXFADoc) { | 85 if (!pXFADoc) { |
81 return XFA_ATTRIBUTEENUM_Unknown; | 86 return XFA_ATTRIBUTEENUM_Unknown; |
82 } | 87 } |
83 CXFA_Node* pForm = ToNode(pXFADoc->GetXFAObject(XFA_HASHCODE_Form)); | 88 CXFA_Node* pForm = ToNode(pXFADoc->GetXFAObject(XFA_HASHCODE_Form)); |
84 if (!pForm) { | 89 if (!pForm) { |
85 return XFA_ATTRIBUTEENUM_Unknown; | 90 return XFA_ATTRIBUTEENUM_Unknown; |
86 } | 91 } |
87 CXFA_Node* pSubForm = pForm->GetFirstChildByClass(XFA_ELEMENT_Subform); | 92 CXFA_Node* pSubForm = pForm->GetFirstChildByClass(XFA_ELEMENT_Subform); |
88 if (!pSubForm) { | 93 if (!pSubForm) { |
89 return XFA_ATTRIBUTEENUM_Unknown; | 94 return XFA_ATTRIBUTEENUM_Unknown; |
90 } | 95 } |
91 return pSubForm->GetEnum(XFA_ATTRIBUTE_RestoreState); | 96 return pSubForm->GetEnum(XFA_ATTRIBUTE_RestoreState); |
92 } | 97 } |
93 FX_BOOL CXFA_FFDocHandler::RunDocScript(IXFA_Doc* hDoc, | 98 FX_BOOL CXFA_FFDocHandler::RunDocScript(CXFA_FFDoc* hDoc, |
94 XFA_SCRIPTTYPE eScriptType, | 99 XFA_SCRIPTTYPE eScriptType, |
95 const CFX_WideStringC& wsScript, | 100 const CFX_WideStringC& wsScript, |
96 FXJSE_HVALUE hRetValue, | 101 FXJSE_HVALUE hRetValue, |
97 FXJSE_HVALUE hThisObject) { | 102 FXJSE_HVALUE hThisObject) { |
98 CXFA_Document* pXFADoc = static_cast<CXFA_FFDoc*>(hDoc)->GetXFADoc(); | 103 CXFA_Document* pXFADoc = static_cast<CXFA_FFDoc*>(hDoc)->GetXFADoc(); |
99 if (!pXFADoc) { | 104 if (!pXFADoc) { |
100 return FALSE; | 105 return FALSE; |
101 } | 106 } |
102 IXFA_ScriptContext* pScriptContext = pXFADoc->GetScriptContext(); | 107 CXFA_ScriptContext* pScriptContext = pXFADoc->GetScriptContext(); |
103 if (!pScriptContext) { | 108 if (!pScriptContext) { |
104 return FALSE; | 109 return FALSE; |
105 } | 110 } |
106 return pScriptContext->RunScript( | 111 return pScriptContext->RunScript( |
107 (XFA_SCRIPTLANGTYPE)eScriptType, wsScript, hRetValue, | 112 (XFA_SCRIPTLANGTYPE)eScriptType, wsScript, hRetValue, |
108 hThisObject ? (CXFA_Object*)FXJSE_Value_ToObject(hThisObject, NULL) | 113 hThisObject ? (CXFA_Object*)FXJSE_Value_ToObject(hThisObject, NULL) |
109 : NULL); | 114 : NULL); |
110 } | 115 } |
OLD | NEW |