Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(71)

Side by Side Diff: xfa/fxfa/app/xfa_ffdochandler.cpp

Issue 1857893002: Cleanup the FF Handler proxy methods. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « xfa/fxfa/app/xfa_ffdoc.cpp ('k') | xfa/fxfa/app/xfa_ffdocview.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/include/fxfa/xfa_ffdochandler.h" 7 #include "xfa/include/fxfa/xfa_ffdochandler.h"
8 8
9 #include "xfa/fxfa/parser/xfa_script.h" 9 #include "xfa/fxfa/parser/xfa_script.h"
10 #include "xfa/fxfa/parser/xfa_script_imp.h" 10 #include "xfa/fxfa/parser/xfa_script_imp.h"
11 #include "xfa/include/fxfa/xfa_checksum.h" 11 #include "xfa/include/fxfa/xfa_checksum.h"
12 #include "xfa/include/fxfa/xfa_ffdoc.h" 12 #include "xfa/include/fxfa/xfa_ffdoc.h"
13 13
14 CXFA_FFDocHandler::CXFA_FFDocHandler() {} 14 CXFA_FFDocHandler::CXFA_FFDocHandler() {}
15 15
16 CXFA_FFDocHandler::~CXFA_FFDocHandler() {} 16 CXFA_FFDocHandler::~CXFA_FFDocHandler() {}
17 17
18 void CXFA_FFDocHandler::ReleaseDoc(CXFA_FFDoc* hDoc) { 18 FXJSE_HVALUE CXFA_FFDocHandler::GetXFAScriptObject(CXFA_FFDoc* hDoc) {
19 delete hDoc; // virtual dtor. 19 CXFA_Document* pXFADoc = hDoc->GetXFADoc();
20 } 20 if (!pXFADoc)
21 IXFA_DocProvider* CXFA_FFDocHandler::GetDocProvider(CXFA_FFDoc* hDoc) { 21 return nullptr;
22 return hDoc->GetDocProvider(); 22
23 } 23 CXFA_ScriptContext* pScriptContext = pXFADoc->GetScriptContext();
24 uint32_t CXFA_FFDocHandler::GetDocType(CXFA_FFDoc* hDoc) { 24 if (!pScriptContext)
25 return hDoc->GetDocType(); 25 return nullptr;
26 } 26 return pScriptContext->GetJSValueFromMap(pXFADoc->GetRoot());
27 int32_t CXFA_FFDocHandler::StartLoad(CXFA_FFDoc* hDoc) {
28 return hDoc->StartLoad();
29 }
30 int32_t CXFA_FFDocHandler::DoLoad(CXFA_FFDoc* hDoc, IFX_Pause* pPause) {
31 return hDoc->DoLoad(pPause);
32 }
33 void CXFA_FFDocHandler::StopLoad(CXFA_FFDoc* hDoc) {
34 hDoc->StopLoad();
35 } 27 }
36 28
37 CXFA_FFDocView* CXFA_FFDocHandler::CreateDocView(CXFA_FFDoc* hDoc, 29 XFA_ATTRIBUTEENUM CXFA_FFDocHandler::GetRestoreState(CXFA_FFDoc* hDoc) {
38 uint32_t dwView) { 30 CXFA_Document* pXFADoc = hDoc->GetXFADoc();
39 return hDoc->CreateDocView(dwView); 31 if (!pXFADoc)
40 } 32 return XFA_ATTRIBUTEENUM_Unknown;
41 int32_t CXFA_FFDocHandler::CountPackages(CXFA_FFDoc* hDoc) { 33
42 return 0; 34 CXFA_Node* pForm = ToNode(pXFADoc->GetXFAObject(XFA_HASHCODE_Form));
43 } 35 if (!pForm)
44 void CXFA_FFDocHandler::GetPackageName(CXFA_FFDoc* hDoc, 36 return XFA_ATTRIBUTEENUM_Unknown;
45 int32_t iPackage, 37
46 CFX_WideStringC& wsPackage) {} 38 CXFA_Node* pSubForm = pForm->GetFirstChildByClass(XFA_ELEMENT_Subform);
47 CFDE_XMLElement* CXFA_FFDocHandler::GetPackageData( 39 if (!pSubForm)
48 CXFA_FFDoc* hDoc, 40 return XFA_ATTRIBUTEENUM_Unknown;
49 const CFX_WideStringC& wsPackage) { 41 return pSubForm->GetEnum(XFA_ATTRIBUTE_RestoreState);
50 return hDoc->GetPackageData(wsPackage);
51 }
52 FX_BOOL CXFA_FFDocHandler::SavePackage(CXFA_FFDoc* hDoc,
53 const CFX_WideStringC& wsPackage,
54 IFX_FileWrite* pFile,
55 CXFA_ChecksumContext* pCSContext) {
56 return hDoc->SavePackage(wsPackage, pFile, pCSContext);
57 }
58 FX_BOOL CXFA_FFDocHandler::CloseDoc(CXFA_FFDoc* hDoc) {
59 return hDoc->CloseDoc();
60 } 42 }
61 43
62 FX_BOOL CXFA_FFDocHandler::ImportData(CXFA_FFDoc* hDoc,
63 IFX_FileRead* pStream,
64 FX_BOOL bXDP) {
65 return hDoc->ImportData(pStream, bXDP);
66 }
67 void CXFA_FFDocHandler::SetJSERuntime(CXFA_FFDoc* hDoc,
68 FXJSE_HRUNTIME hRuntime) {
69 hDoc->GetXFADoc()->InitScriptContext(hRuntime);
70 }
71 FXJSE_HVALUE CXFA_FFDocHandler::GetXFAScriptObject(CXFA_FFDoc* hDoc) {
72 CXFA_Document* pXFADoc = hDoc->GetXFADoc();
73 if (!pXFADoc) {
74 return NULL;
75 }
76 CXFA_ScriptContext* pScriptContext = pXFADoc->GetScriptContext();
77 if (!pScriptContext) {
78 return NULL;
79 }
80 return pScriptContext->GetJSValueFromMap(pXFADoc->GetRoot());
81 }
82 XFA_ATTRIBUTEENUM CXFA_FFDocHandler::GetRestoreState(CXFA_FFDoc* hDoc) {
83 CXFA_Document* pXFADoc = hDoc->GetXFADoc();
84 if (!pXFADoc) {
85 return XFA_ATTRIBUTEENUM_Unknown;
86 }
87 CXFA_Node* pForm = ToNode(pXFADoc->GetXFAObject(XFA_HASHCODE_Form));
88 if (!pForm) {
89 return XFA_ATTRIBUTEENUM_Unknown;
90 }
91 CXFA_Node* pSubForm = pForm->GetFirstChildByClass(XFA_ELEMENT_Subform);
92 if (!pSubForm) {
93 return XFA_ATTRIBUTEENUM_Unknown;
94 }
95 return pSubForm->GetEnum(XFA_ATTRIBUTE_RestoreState);
96 }
97 FX_BOOL CXFA_FFDocHandler::RunDocScript(CXFA_FFDoc* hDoc, 44 FX_BOOL CXFA_FFDocHandler::RunDocScript(CXFA_FFDoc* hDoc,
98 XFA_SCRIPTTYPE eScriptType, 45 XFA_SCRIPTTYPE eScriptType,
99 const CFX_WideStringC& wsScript, 46 const CFX_WideStringC& wsScript,
100 FXJSE_HVALUE hRetValue, 47 FXJSE_HVALUE hRetValue,
101 FXJSE_HVALUE hThisObject) { 48 FXJSE_HVALUE hThisObject) {
102 CXFA_Document* pXFADoc = hDoc->GetXFADoc(); 49 CXFA_Document* pXFADoc = hDoc->GetXFADoc();
103 if (!pXFADoc) { 50 if (!pXFADoc)
104 return FALSE; 51 return FALSE;
105 } 52
106 CXFA_ScriptContext* pScriptContext = pXFADoc->GetScriptContext(); 53 CXFA_ScriptContext* pScriptContext = pXFADoc->GetScriptContext();
107 if (!pScriptContext) { 54 if (!pScriptContext)
108 return FALSE; 55 return FALSE;
109 } 56
110 return pScriptContext->RunScript( 57 return pScriptContext->RunScript(
111 (XFA_SCRIPTLANGTYPE)eScriptType, wsScript, hRetValue, 58 (XFA_SCRIPTLANGTYPE)eScriptType, wsScript, hRetValue,
112 hThisObject ? (CXFA_Object*)FXJSE_Value_ToObject(hThisObject, NULL) 59 hThisObject ? (CXFA_Object*)FXJSE_Value_ToObject(hThisObject, nullptr)
113 : NULL); 60 : nullptr);
114 } 61 }
OLDNEW
« no previous file with comments | « xfa/fxfa/app/xfa_ffdoc.cpp ('k') | xfa/fxfa/app/xfa_ffdocview.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698