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

Side by Side Diff: fpdfsdk/fsdk_actionhandler.cpp

Issue 2453683011: Remove FX_BOOL from fpdfsdk. (Closed)
Patch Set: Regenerate patch after rebase. Created 4 years, 1 month 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 | « fpdfsdk/fsdk_actionhandler.h ('k') | fpdfsdk/fsdk_define.h » ('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 "fpdfsdk/fsdk_actionhandler.h" 7 #include "fpdfsdk/fsdk_actionhandler.h"
8 8
9 #include <set> 9 #include <set>
10 10
11 #include "core/fpdfapi/parser/cpdf_array.h" 11 #include "core/fpdfapi/parser/cpdf_array.h"
12 #include "core/fpdfdoc/cpdf_formfield.h" 12 #include "core/fpdfdoc/cpdf_formfield.h"
13 #include "core/fpdfdoc/cpdf_interform.h" 13 #include "core/fpdfdoc/cpdf_interform.h"
14 #include "fpdfsdk/cpdfsdk_formfillenvironment.h" 14 #include "fpdfsdk/cpdfsdk_formfillenvironment.h"
15 #include "fpdfsdk/cpdfsdk_interform.h" 15 #include "fpdfsdk/cpdfsdk_interform.h"
16 #include "fpdfsdk/fsdk_define.h" 16 #include "fpdfsdk/fsdk_define.h"
17 #include "fpdfsdk/javascript/ijs_context.h" 17 #include "fpdfsdk/javascript/ijs_context.h"
18 #include "fpdfsdk/javascript/ijs_runtime.h" 18 #include "fpdfsdk/javascript/ijs_runtime.h"
19 #include "third_party/base/stl_util.h" 19 #include "third_party/base/stl_util.h"
20 20
21 FX_BOOL CPDFSDK_ActionHandler::DoAction_DocOpen( 21 bool CPDFSDK_ActionHandler::DoAction_DocOpen(
22 const CPDF_Action& action, 22 const CPDF_Action& action,
23 CPDFSDK_FormFillEnvironment* pFormFillEnv) { 23 CPDFSDK_FormFillEnvironment* pFormFillEnv) {
24 std::set<CPDF_Dictionary*> visited; 24 std::set<CPDF_Dictionary*> visited;
25 return ExecuteDocumentOpenAction(action, pFormFillEnv, &visited); 25 return ExecuteDocumentOpenAction(action, pFormFillEnv, &visited);
26 } 26 }
27 27
28 FX_BOOL CPDFSDK_ActionHandler::DoAction_JavaScript( 28 bool CPDFSDK_ActionHandler::DoAction_JavaScript(
29 const CPDF_Action& JsAction, 29 const CPDF_Action& JsAction,
30 CFX_WideString csJSName, 30 CFX_WideString csJSName,
31 CPDFSDK_FormFillEnvironment* pFormFillEnv) { 31 CPDFSDK_FormFillEnvironment* pFormFillEnv) {
32 if (JsAction.GetType() == CPDF_Action::JavaScript) { 32 if (JsAction.GetType() == CPDF_Action::JavaScript) {
33 CFX_WideString swJS = JsAction.GetJavaScript(); 33 CFX_WideString swJS = JsAction.GetJavaScript();
34 if (!swJS.IsEmpty()) { 34 if (!swJS.IsEmpty()) {
35 RunDocumentOpenJavaScript(pFormFillEnv, csJSName, swJS); 35 RunDocumentOpenJavaScript(pFormFillEnv, csJSName, swJS);
36 return TRUE; 36 return true;
37 } 37 }
38 } 38 }
39 39
40 return FALSE; 40 return false;
41 } 41 }
42 42
43 FX_BOOL CPDFSDK_ActionHandler::DoAction_FieldJavaScript( 43 bool CPDFSDK_ActionHandler::DoAction_FieldJavaScript(
44 const CPDF_Action& JsAction, 44 const CPDF_Action& JsAction,
45 CPDF_AAction::AActionType type, 45 CPDF_AAction::AActionType type,
46 CPDFSDK_FormFillEnvironment* pFormFillEnv, 46 CPDFSDK_FormFillEnvironment* pFormFillEnv,
47 CPDF_FormField* pFormField, 47 CPDF_FormField* pFormField,
48 PDFSDK_FieldAction& data) { 48 PDFSDK_FieldAction& data) {
49 ASSERT(pFormFillEnv); 49 ASSERT(pFormFillEnv);
50 if (pFormFillEnv->IsJSInitiated() && 50 if (pFormFillEnv->IsJSInitiated() &&
51 JsAction.GetType() == CPDF_Action::JavaScript) { 51 JsAction.GetType() == CPDF_Action::JavaScript) {
52 CFX_WideString swJS = JsAction.GetJavaScript(); 52 CFX_WideString swJS = JsAction.GetJavaScript();
53 if (!swJS.IsEmpty()) { 53 if (!swJS.IsEmpty()) {
54 RunFieldJavaScript(pFormFillEnv, pFormField, type, data, swJS); 54 RunFieldJavaScript(pFormFillEnv, pFormField, type, data, swJS);
55 return TRUE; 55 return true;
56 } 56 }
57 } 57 }
58 return FALSE; 58 return false;
59 } 59 }
60 60
61 FX_BOOL CPDFSDK_ActionHandler::DoAction_Page( 61 bool CPDFSDK_ActionHandler::DoAction_Page(
62 const CPDF_Action& action, 62 const CPDF_Action& action,
63 enum CPDF_AAction::AActionType eType, 63 enum CPDF_AAction::AActionType eType,
64 CPDFSDK_FormFillEnvironment* pFormFillEnv) { 64 CPDFSDK_FormFillEnvironment* pFormFillEnv) {
65 std::set<CPDF_Dictionary*> visited; 65 std::set<CPDF_Dictionary*> visited;
66 return ExecuteDocumentPageAction(action, eType, pFormFillEnv, &visited); 66 return ExecuteDocumentPageAction(action, eType, pFormFillEnv, &visited);
67 } 67 }
68 68
69 FX_BOOL CPDFSDK_ActionHandler::DoAction_Document( 69 bool CPDFSDK_ActionHandler::DoAction_Document(
70 const CPDF_Action& action, 70 const CPDF_Action& action,
71 enum CPDF_AAction::AActionType eType, 71 enum CPDF_AAction::AActionType eType,
72 CPDFSDK_FormFillEnvironment* pFormFillEnv) { 72 CPDFSDK_FormFillEnvironment* pFormFillEnv) {
73 std::set<CPDF_Dictionary*> visited; 73 std::set<CPDF_Dictionary*> visited;
74 return ExecuteDocumentPageAction(action, eType, pFormFillEnv, &visited); 74 return ExecuteDocumentPageAction(action, eType, pFormFillEnv, &visited);
75 } 75 }
76 76
77 FX_BOOL CPDFSDK_ActionHandler::DoAction_BookMark( 77 bool CPDFSDK_ActionHandler::DoAction_BookMark(
78 CPDF_Bookmark* pBookMark, 78 CPDF_Bookmark* pBookMark,
79 const CPDF_Action& action, 79 const CPDF_Action& action,
80 CPDF_AAction::AActionType type, 80 CPDF_AAction::AActionType type,
81 CPDFSDK_FormFillEnvironment* pFormFillEnv) { 81 CPDFSDK_FormFillEnvironment* pFormFillEnv) {
82 std::set<CPDF_Dictionary*> visited; 82 std::set<CPDF_Dictionary*> visited;
83 return ExecuteBookMark(action, pFormFillEnv, pBookMark, &visited); 83 return ExecuteBookMark(action, pFormFillEnv, pBookMark, &visited);
84 } 84 }
85 85
86 FX_BOOL CPDFSDK_ActionHandler::DoAction_Screen( 86 bool CPDFSDK_ActionHandler::DoAction_Screen(
87 const CPDF_Action& action, 87 const CPDF_Action& action,
88 CPDF_AAction::AActionType type, 88 CPDF_AAction::AActionType type,
89 CPDFSDK_FormFillEnvironment* pFormFillEnv, 89 CPDFSDK_FormFillEnvironment* pFormFillEnv,
90 CPDFSDK_Annot* pScreen) { 90 CPDFSDK_Annot* pScreen) {
91 std::set<CPDF_Dictionary*> visited; 91 std::set<CPDF_Dictionary*> visited;
92 return ExecuteScreenAction(action, type, pFormFillEnv, pScreen, &visited); 92 return ExecuteScreenAction(action, type, pFormFillEnv, pScreen, &visited);
93 } 93 }
94 94
95 FX_BOOL CPDFSDK_ActionHandler::DoAction_Link( 95 bool CPDFSDK_ActionHandler::DoAction_Link(
96 const CPDF_Action& action, 96 const CPDF_Action& action,
97 CPDFSDK_FormFillEnvironment* pFormFillEnv) { 97 CPDFSDK_FormFillEnvironment* pFormFillEnv) {
98 std::set<CPDF_Dictionary*> visited; 98 std::set<CPDF_Dictionary*> visited;
99 return ExecuteLinkAction(action, pFormFillEnv, &visited); 99 return ExecuteLinkAction(action, pFormFillEnv, &visited);
100 } 100 }
101 101
102 FX_BOOL CPDFSDK_ActionHandler::DoAction_Field( 102 bool CPDFSDK_ActionHandler::DoAction_Field(
103 const CPDF_Action& action, 103 const CPDF_Action& action,
104 CPDF_AAction::AActionType type, 104 CPDF_AAction::AActionType type,
105 CPDFSDK_FormFillEnvironment* pFormFillEnv, 105 CPDFSDK_FormFillEnvironment* pFormFillEnv,
106 CPDF_FormField* pFormField, 106 CPDF_FormField* pFormField,
107 PDFSDK_FieldAction& data) { 107 PDFSDK_FieldAction& data) {
108 std::set<CPDF_Dictionary*> visited; 108 std::set<CPDF_Dictionary*> visited;
109 return ExecuteFieldAction(action, type, pFormFillEnv, pFormField, data, 109 return ExecuteFieldAction(action, type, pFormFillEnv, pFormField, data,
110 &visited); 110 &visited);
111 } 111 }
112 112
113 FX_BOOL CPDFSDK_ActionHandler::ExecuteDocumentOpenAction( 113 bool CPDFSDK_ActionHandler::ExecuteDocumentOpenAction(
114 const CPDF_Action& action, 114 const CPDF_Action& action,
115 CPDFSDK_FormFillEnvironment* pFormFillEnv, 115 CPDFSDK_FormFillEnvironment* pFormFillEnv,
116 std::set<CPDF_Dictionary*>* visited) { 116 std::set<CPDF_Dictionary*>* visited) {
117 CPDF_Dictionary* pDict = action.GetDict(); 117 CPDF_Dictionary* pDict = action.GetDict();
118 if (pdfium::ContainsKey(*visited, pDict)) 118 if (pdfium::ContainsKey(*visited, pDict))
119 return FALSE; 119 return false;
120 120
121 visited->insert(pDict); 121 visited->insert(pDict);
122 122
123 ASSERT(pFormFillEnv); 123 ASSERT(pFormFillEnv);
124 if (action.GetType() == CPDF_Action::JavaScript) { 124 if (action.GetType() == CPDF_Action::JavaScript) {
125 if (pFormFillEnv->IsJSInitiated()) { 125 if (pFormFillEnv->IsJSInitiated()) {
126 CFX_WideString swJS = action.GetJavaScript(); 126 CFX_WideString swJS = action.GetJavaScript();
127 if (!swJS.IsEmpty()) { 127 if (!swJS.IsEmpty()) {
128 RunDocumentOpenJavaScript(pFormFillEnv, L"", swJS); 128 RunDocumentOpenJavaScript(pFormFillEnv, L"", swJS);
129 } 129 }
130 } 130 }
131 } else { 131 } else {
132 DoAction_NoJs(action, pFormFillEnv); 132 DoAction_NoJs(action, pFormFillEnv);
133 } 133 }
134 134
135 for (int32_t i = 0, sz = action.GetSubActionsCount(); i < sz; i++) { 135 for (int32_t i = 0, sz = action.GetSubActionsCount(); i < sz; i++) {
136 CPDF_Action subaction = action.GetSubAction(i); 136 CPDF_Action subaction = action.GetSubAction(i);
137 if (!ExecuteDocumentOpenAction(subaction, pFormFillEnv, visited)) 137 if (!ExecuteDocumentOpenAction(subaction, pFormFillEnv, visited))
138 return FALSE; 138 return false;
139 } 139 }
140 140
141 return TRUE; 141 return true;
142 } 142 }
143 143
144 FX_BOOL CPDFSDK_ActionHandler::ExecuteLinkAction( 144 bool CPDFSDK_ActionHandler::ExecuteLinkAction(
145 const CPDF_Action& action, 145 const CPDF_Action& action,
146 CPDFSDK_FormFillEnvironment* pFormFillEnv, 146 CPDFSDK_FormFillEnvironment* pFormFillEnv,
147 std::set<CPDF_Dictionary*>* visited) { 147 std::set<CPDF_Dictionary*>* visited) {
148 CPDF_Dictionary* pDict = action.GetDict(); 148 CPDF_Dictionary* pDict = action.GetDict();
149 if (pdfium::ContainsKey(*visited, pDict)) 149 if (pdfium::ContainsKey(*visited, pDict))
150 return FALSE; 150 return false;
151 151
152 visited->insert(pDict); 152 visited->insert(pDict);
153 153
154 ASSERT(pFormFillEnv); 154 ASSERT(pFormFillEnv);
155 if (action.GetType() == CPDF_Action::JavaScript) { 155 if (action.GetType() == CPDF_Action::JavaScript) {
156 if (pFormFillEnv->IsJSInitiated()) { 156 if (pFormFillEnv->IsJSInitiated()) {
157 CFX_WideString swJS = action.GetJavaScript(); 157 CFX_WideString swJS = action.GetJavaScript();
158 if (!swJS.IsEmpty()) { 158 if (!swJS.IsEmpty()) {
159 IJS_Runtime* pRuntime = pFormFillEnv->GetJSRuntime(); 159 IJS_Runtime* pRuntime = pFormFillEnv->GetJSRuntime();
160 IJS_Context* pContext = pRuntime->NewContext(); 160 IJS_Context* pContext = pRuntime->NewContext();
161 pContext->OnLink_MouseUp(pFormFillEnv); 161 pContext->OnLink_MouseUp(pFormFillEnv);
162 162
163 CFX_WideString csInfo; 163 CFX_WideString csInfo;
164 FX_BOOL bRet = pContext->RunScript(swJS, &csInfo); 164 bool bRet = pContext->RunScript(swJS, &csInfo);
165 if (!bRet) { 165 if (!bRet) {
166 // FIXME: return error. 166 // FIXME: return error.
167 } 167 }
168 168
169 pRuntime->ReleaseContext(pContext); 169 pRuntime->ReleaseContext(pContext);
170 } 170 }
171 } 171 }
172 } else { 172 } else {
173 DoAction_NoJs(action, pFormFillEnv); 173 DoAction_NoJs(action, pFormFillEnv);
174 } 174 }
175 175
176 for (int32_t i = 0, sz = action.GetSubActionsCount(); i < sz; i++) { 176 for (int32_t i = 0, sz = action.GetSubActionsCount(); i < sz; i++) {
177 CPDF_Action subaction = action.GetSubAction(i); 177 CPDF_Action subaction = action.GetSubAction(i);
178 if (!ExecuteLinkAction(subaction, pFormFillEnv, visited)) 178 if (!ExecuteLinkAction(subaction, pFormFillEnv, visited))
179 return FALSE; 179 return false;
180 } 180 }
181 181
182 return TRUE; 182 return true;
183 } 183 }
184 184
185 FX_BOOL CPDFSDK_ActionHandler::ExecuteDocumentPageAction( 185 bool CPDFSDK_ActionHandler::ExecuteDocumentPageAction(
186 const CPDF_Action& action, 186 const CPDF_Action& action,
187 CPDF_AAction::AActionType type, 187 CPDF_AAction::AActionType type,
188 CPDFSDK_FormFillEnvironment* pFormFillEnv, 188 CPDFSDK_FormFillEnvironment* pFormFillEnv,
189 std::set<CPDF_Dictionary*>* visited) { 189 std::set<CPDF_Dictionary*>* visited) {
190 CPDF_Dictionary* pDict = action.GetDict(); 190 CPDF_Dictionary* pDict = action.GetDict();
191 if (pdfium::ContainsKey(*visited, pDict)) 191 if (pdfium::ContainsKey(*visited, pDict))
192 return FALSE; 192 return false;
193 193
194 visited->insert(pDict); 194 visited->insert(pDict);
195 195
196 ASSERT(pFormFillEnv); 196 ASSERT(pFormFillEnv);
197 if (action.GetType() == CPDF_Action::JavaScript) { 197 if (action.GetType() == CPDF_Action::JavaScript) {
198 if (pFormFillEnv->IsJSInitiated()) { 198 if (pFormFillEnv->IsJSInitiated()) {
199 CFX_WideString swJS = action.GetJavaScript(); 199 CFX_WideString swJS = action.GetJavaScript();
200 if (!swJS.IsEmpty()) { 200 if (!swJS.IsEmpty()) {
201 RunDocumentPageJavaScript(pFormFillEnv, type, swJS); 201 RunDocumentPageJavaScript(pFormFillEnv, type, swJS);
202 } 202 }
203 } 203 }
204 } else { 204 } else {
205 DoAction_NoJs(action, pFormFillEnv); 205 DoAction_NoJs(action, pFormFillEnv);
206 } 206 }
207 207
208 if (!IsValidDocView(pFormFillEnv)) 208 if (!IsValidDocView(pFormFillEnv))
209 return FALSE; 209 return false;
210 210
211 for (int32_t i = 0, sz = action.GetSubActionsCount(); i < sz; i++) { 211 for (int32_t i = 0, sz = action.GetSubActionsCount(); i < sz; i++) {
212 CPDF_Action subaction = action.GetSubAction(i); 212 CPDF_Action subaction = action.GetSubAction(i);
213 if (!ExecuteDocumentPageAction(subaction, type, pFormFillEnv, visited)) 213 if (!ExecuteDocumentPageAction(subaction, type, pFormFillEnv, visited))
214 return FALSE; 214 return false;
215 } 215 }
216 216
217 return TRUE; 217 return true;
218 } 218 }
219 219
220 FX_BOOL CPDFSDK_ActionHandler::IsValidField( 220 bool CPDFSDK_ActionHandler::IsValidField(
221 CPDFSDK_FormFillEnvironment* pFormFillEnv, 221 CPDFSDK_FormFillEnvironment* pFormFillEnv,
222 CPDF_Dictionary* pFieldDict) { 222 CPDF_Dictionary* pFieldDict) {
223 ASSERT(pFieldDict); 223 ASSERT(pFieldDict);
224 224
225 CPDFSDK_InterForm* pInterForm = pFormFillEnv->GetInterForm(); 225 CPDFSDK_InterForm* pInterForm = pFormFillEnv->GetInterForm();
226 CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm(); 226 CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm();
227 return !!pPDFInterForm->GetFieldByDict(pFieldDict); 227 return !!pPDFInterForm->GetFieldByDict(pFieldDict);
228 } 228 }
229 229
230 FX_BOOL CPDFSDK_ActionHandler::ExecuteFieldAction( 230 bool CPDFSDK_ActionHandler::ExecuteFieldAction(
231 const CPDF_Action& action, 231 const CPDF_Action& action,
232 CPDF_AAction::AActionType type, 232 CPDF_AAction::AActionType type,
233 CPDFSDK_FormFillEnvironment* pFormFillEnv, 233 CPDFSDK_FormFillEnvironment* pFormFillEnv,
234 CPDF_FormField* pFormField, 234 CPDF_FormField* pFormField,
235 PDFSDK_FieldAction& data, 235 PDFSDK_FieldAction& data,
236 std::set<CPDF_Dictionary*>* visited) { 236 std::set<CPDF_Dictionary*>* visited) {
237 CPDF_Dictionary* pDict = action.GetDict(); 237 CPDF_Dictionary* pDict = action.GetDict();
238 if (pdfium::ContainsKey(*visited, pDict)) 238 if (pdfium::ContainsKey(*visited, pDict))
239 return FALSE; 239 return false;
240 240
241 visited->insert(pDict); 241 visited->insert(pDict);
242 242
243 ASSERT(pFormFillEnv); 243 ASSERT(pFormFillEnv);
244 if (action.GetType() == CPDF_Action::JavaScript) { 244 if (action.GetType() == CPDF_Action::JavaScript) {
245 if (pFormFillEnv->IsJSInitiated()) { 245 if (pFormFillEnv->IsJSInitiated()) {
246 CFX_WideString swJS = action.GetJavaScript(); 246 CFX_WideString swJS = action.GetJavaScript();
247 if (!swJS.IsEmpty()) { 247 if (!swJS.IsEmpty()) {
248 RunFieldJavaScript(pFormFillEnv, pFormField, type, data, swJS); 248 RunFieldJavaScript(pFormFillEnv, pFormField, type, data, swJS);
249 if (!IsValidField(pFormFillEnv, pFormField->GetFieldDict())) 249 if (!IsValidField(pFormFillEnv, pFormField->GetFieldDict()))
250 return FALSE; 250 return false;
251 } 251 }
252 } 252 }
253 } else { 253 } else {
254 DoAction_NoJs(action, pFormFillEnv); 254 DoAction_NoJs(action, pFormFillEnv);
255 } 255 }
256 256
257 for (int32_t i = 0, sz = action.GetSubActionsCount(); i < sz; i++) { 257 for (int32_t i = 0, sz = action.GetSubActionsCount(); i < sz; i++) {
258 CPDF_Action subaction = action.GetSubAction(i); 258 CPDF_Action subaction = action.GetSubAction(i);
259 if (!ExecuteFieldAction(subaction, type, pFormFillEnv, pFormField, data, 259 if (!ExecuteFieldAction(subaction, type, pFormFillEnv, pFormField, data,
260 visited)) 260 visited))
261 return FALSE; 261 return false;
262 } 262 }
263 263
264 return TRUE; 264 return true;
265 } 265 }
266 266
267 FX_BOOL CPDFSDK_ActionHandler::ExecuteScreenAction( 267 bool CPDFSDK_ActionHandler::ExecuteScreenAction(
268 const CPDF_Action& action, 268 const CPDF_Action& action,
269 CPDF_AAction::AActionType type, 269 CPDF_AAction::AActionType type,
270 CPDFSDK_FormFillEnvironment* pFormFillEnv, 270 CPDFSDK_FormFillEnvironment* pFormFillEnv,
271 CPDFSDK_Annot* pScreen, 271 CPDFSDK_Annot* pScreen,
272 std::set<CPDF_Dictionary*>* visited) { 272 std::set<CPDF_Dictionary*>* visited) {
273 CPDF_Dictionary* pDict = action.GetDict(); 273 CPDF_Dictionary* pDict = action.GetDict();
274 if (pdfium::ContainsKey(*visited, pDict)) 274 if (pdfium::ContainsKey(*visited, pDict))
275 return FALSE; 275 return false;
276 276
277 visited->insert(pDict); 277 visited->insert(pDict);
278 278
279 ASSERT(pFormFillEnv); 279 ASSERT(pFormFillEnv);
280 if (action.GetType() == CPDF_Action::JavaScript) { 280 if (action.GetType() == CPDF_Action::JavaScript) {
281 if (pFormFillEnv->IsJSInitiated()) { 281 if (pFormFillEnv->IsJSInitiated()) {
282 CFX_WideString swJS = action.GetJavaScript(); 282 CFX_WideString swJS = action.GetJavaScript();
283 if (!swJS.IsEmpty()) { 283 if (!swJS.IsEmpty()) {
284 IJS_Runtime* pRuntime = pFormFillEnv->GetJSRuntime(); 284 IJS_Runtime* pRuntime = pFormFillEnv->GetJSRuntime();
285 IJS_Context* pContext = pRuntime->NewContext(); 285 IJS_Context* pContext = pRuntime->NewContext();
286 CFX_WideString csInfo; 286 CFX_WideString csInfo;
287 FX_BOOL bRet = pContext->RunScript(swJS, &csInfo); 287 bool bRet = pContext->RunScript(swJS, &csInfo);
288 if (!bRet) { 288 if (!bRet) {
289 // FIXME: return error. 289 // FIXME: return error.
290 } 290 }
291 291
292 pRuntime->ReleaseContext(pContext); 292 pRuntime->ReleaseContext(pContext);
293 } 293 }
294 } 294 }
295 } else { 295 } else {
296 DoAction_NoJs(action, pFormFillEnv); 296 DoAction_NoJs(action, pFormFillEnv);
297 } 297 }
298 298
299 for (int32_t i = 0, sz = action.GetSubActionsCount(); i < sz; i++) { 299 for (int32_t i = 0, sz = action.GetSubActionsCount(); i < sz; i++) {
300 CPDF_Action subaction = action.GetSubAction(i); 300 CPDF_Action subaction = action.GetSubAction(i);
301 if (!ExecuteScreenAction(subaction, type, pFormFillEnv, pScreen, visited)) 301 if (!ExecuteScreenAction(subaction, type, pFormFillEnv, pScreen, visited))
302 return FALSE; 302 return false;
303 } 303 }
304 304
305 return TRUE; 305 return true;
306 } 306 }
307 307
308 FX_BOOL CPDFSDK_ActionHandler::ExecuteBookMark( 308 bool CPDFSDK_ActionHandler::ExecuteBookMark(
309 const CPDF_Action& action, 309 const CPDF_Action& action,
310 CPDFSDK_FormFillEnvironment* pFormFillEnv, 310 CPDFSDK_FormFillEnvironment* pFormFillEnv,
311 CPDF_Bookmark* pBookmark, 311 CPDF_Bookmark* pBookmark,
312 std::set<CPDF_Dictionary*>* visited) { 312 std::set<CPDF_Dictionary*>* visited) {
313 CPDF_Dictionary* pDict = action.GetDict(); 313 CPDF_Dictionary* pDict = action.GetDict();
314 if (pdfium::ContainsKey(*visited, pDict)) 314 if (pdfium::ContainsKey(*visited, pDict))
315 return FALSE; 315 return false;
316 316
317 visited->insert(pDict); 317 visited->insert(pDict);
318 318
319 ASSERT(pFormFillEnv); 319 ASSERT(pFormFillEnv);
320 if (action.GetType() == CPDF_Action::JavaScript) { 320 if (action.GetType() == CPDF_Action::JavaScript) {
321 if (pFormFillEnv->IsJSInitiated()) { 321 if (pFormFillEnv->IsJSInitiated()) {
322 CFX_WideString swJS = action.GetJavaScript(); 322 CFX_WideString swJS = action.GetJavaScript();
323 if (!swJS.IsEmpty()) { 323 if (!swJS.IsEmpty()) {
324 IJS_Runtime* pRuntime = pFormFillEnv->GetJSRuntime(); 324 IJS_Runtime* pRuntime = pFormFillEnv->GetJSRuntime();
325 IJS_Context* pContext = pRuntime->NewContext(); 325 IJS_Context* pContext = pRuntime->NewContext();
326 pContext->OnBookmark_MouseUp(pBookmark); 326 pContext->OnBookmark_MouseUp(pBookmark);
327 327
328 CFX_WideString csInfo; 328 CFX_WideString csInfo;
329 FX_BOOL bRet = pContext->RunScript(swJS, &csInfo); 329 bool bRet = pContext->RunScript(swJS, &csInfo);
330 if (!bRet) { 330 if (!bRet) {
331 // FIXME: return error. 331 // FIXME: return error.
332 } 332 }
333 333
334 pRuntime->ReleaseContext(pContext); 334 pRuntime->ReleaseContext(pContext);
335 } 335 }
336 } 336 }
337 } else { 337 } else {
338 DoAction_NoJs(action, pFormFillEnv); 338 DoAction_NoJs(action, pFormFillEnv);
339 } 339 }
340 340
341 for (int32_t i = 0, sz = action.GetSubActionsCount(); i < sz; i++) { 341 for (int32_t i = 0, sz = action.GetSubActionsCount(); i < sz; i++) {
342 CPDF_Action subaction = action.GetSubAction(i); 342 CPDF_Action subaction = action.GetSubAction(i);
343 if (!ExecuteBookMark(subaction, pFormFillEnv, pBookmark, visited)) 343 if (!ExecuteBookMark(subaction, pFormFillEnv, pBookmark, visited))
344 return FALSE; 344 return false;
345 } 345 }
346 346
347 return TRUE; 347 return true;
348 } 348 }
349 349
350 void CPDFSDK_ActionHandler::DoAction_NoJs( 350 void CPDFSDK_ActionHandler::DoAction_NoJs(
351 const CPDF_Action& action, 351 const CPDF_Action& action,
352 CPDFSDK_FormFillEnvironment* pFormFillEnv) { 352 CPDFSDK_FormFillEnvironment* pFormFillEnv) {
353 ASSERT(pFormFillEnv); 353 ASSERT(pFormFillEnv);
354 354
355 switch (action.GetType()) { 355 switch (action.GetType()) {
356 case CPDF_Action::GoTo: 356 case CPDF_Action::GoTo:
357 DoAction_GoTo(pFormFillEnv, action); 357 DoAction_GoTo(pFormFillEnv, action);
(...skipping 24 matching lines...) Expand all
382 case CPDF_Action::SubmitForm: 382 case CPDF_Action::SubmitForm:
383 DoAction_SubmitForm(action, pFormFillEnv); 383 DoAction_SubmitForm(action, pFormFillEnv);
384 break; 384 break;
385 case CPDF_Action::ResetForm: 385 case CPDF_Action::ResetForm:
386 DoAction_ResetForm(action, pFormFillEnv); 386 DoAction_ResetForm(action, pFormFillEnv);
387 break; 387 break;
388 case CPDF_Action::ImportData: 388 case CPDF_Action::ImportData:
389 DoAction_ImportData(action, pFormFillEnv); 389 DoAction_ImportData(action, pFormFillEnv);
390 break; 390 break;
391 case CPDF_Action::JavaScript: 391 case CPDF_Action::JavaScript:
392 ASSERT(FALSE); 392 ASSERT(false);
393 break; 393 break;
394 case CPDF_Action::SetOCGState: 394 case CPDF_Action::SetOCGState:
395 DoAction_SetOCGState(pFormFillEnv, action); 395 DoAction_SetOCGState(pFormFillEnv, action);
396 break; 396 break;
397 case CPDF_Action::Rendition: 397 case CPDF_Action::Rendition:
398 break; 398 break;
399 case CPDF_Action::Trans: 399 case CPDF_Action::Trans:
400 break; 400 break;
401 case CPDF_Action::GoTo3DView: 401 case CPDF_Action::GoTo3DView:
402 break; 402 break;
403 default: 403 default:
404 break; 404 break;
405 } 405 }
406 } 406 }
407 407
408 FX_BOOL CPDFSDK_ActionHandler::IsValidDocView( 408 bool CPDFSDK_ActionHandler::IsValidDocView(
409 CPDFSDK_FormFillEnvironment* pFormFillEnv) { 409 CPDFSDK_FormFillEnvironment* pFormFillEnv) {
410 ASSERT(pFormFillEnv); 410 ASSERT(pFormFillEnv);
411 return TRUE; 411 return true;
412 } 412 }
413 413
414 void CPDFSDK_ActionHandler::DoAction_GoTo( 414 void CPDFSDK_ActionHandler::DoAction_GoTo(
415 CPDFSDK_FormFillEnvironment* pFormFillEnv, 415 CPDFSDK_FormFillEnvironment* pFormFillEnv,
416 const CPDF_Action& action) { 416 const CPDF_Action& action) {
417 ASSERT(action.GetDict()); 417 ASSERT(action.GetDict());
418 418
419 CPDF_Document* pPDFDocument = pFormFillEnv->GetPDFDocument(); 419 CPDF_Document* pPDFDocument = pFormFillEnv->GetPDFDocument();
420 ASSERT(pPDFDocument); 420 ASSERT(pPDFDocument);
421 421
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 data.bModifier, data.nSelEnd, data.nSelStart, 505 data.bModifier, data.nSelEnd, data.nSelStart,
506 data.bShift, pFormField, data.sValue, 506 data.bShift, pFormField, data.sValue,
507 data.bWillCommit, data.bFieldFull, data.bRC); 507 data.bWillCommit, data.bFieldFull, data.bRC);
508 break; 508 break;
509 case CPDF_AAction::Validate: 509 case CPDF_AAction::Validate:
510 pContext->OnField_Validate(data.sChange, data.sChangeEx, data.bKeyDown, 510 pContext->OnField_Validate(data.sChange, data.sChangeEx, data.bKeyDown,
511 data.bModifier, data.bShift, pFormField, 511 data.bModifier, data.bShift, pFormField,
512 data.sValue, data.bRC); 512 data.sValue, data.bRC);
513 break; 513 break;
514 default: 514 default:
515 ASSERT(FALSE); 515 ASSERT(false);
516 break; 516 break;
517 } 517 }
518 518
519 CFX_WideString csInfo; 519 CFX_WideString csInfo;
520 FX_BOOL bRet = pContext->RunScript(script, &csInfo); 520 bool bRet = pContext->RunScript(script, &csInfo);
521 if (!bRet) { 521 if (!bRet) {
522 // FIXME: return error. 522 // FIXME: return error.
523 } 523 }
524 524
525 pRuntime->ReleaseContext(pContext); 525 pRuntime->ReleaseContext(pContext);
526 } 526 }
527 527
528 void CPDFSDK_ActionHandler::RunDocumentOpenJavaScript( 528 void CPDFSDK_ActionHandler::RunDocumentOpenJavaScript(
529 CPDFSDK_FormFillEnvironment* pFormFillEnv, 529 CPDFSDK_FormFillEnvironment* pFormFillEnv,
530 const CFX_WideString& sScriptName, 530 const CFX_WideString& sScriptName,
531 const CFX_WideString& script) { 531 const CFX_WideString& script) {
532 IJS_Runtime* pRuntime = pFormFillEnv->GetJSRuntime(); 532 IJS_Runtime* pRuntime = pFormFillEnv->GetJSRuntime();
533 IJS_Context* pContext = pRuntime->NewContext(); 533 IJS_Context* pContext = pRuntime->NewContext();
534 pContext->OnDoc_Open(pFormFillEnv, sScriptName); 534 pContext->OnDoc_Open(pFormFillEnv, sScriptName);
535 535
536 CFX_WideString csInfo; 536 CFX_WideString csInfo;
537 FX_BOOL bRet = pContext->RunScript(script, &csInfo); 537 bool bRet = pContext->RunScript(script, &csInfo);
538 if (!bRet) { 538 if (!bRet) {
539 // FIXME: return error. 539 // FIXME: return error.
540 } 540 }
541 541
542 pRuntime->ReleaseContext(pContext); 542 pRuntime->ReleaseContext(pContext);
543 } 543 }
544 544
545 void CPDFSDK_ActionHandler::RunDocumentPageJavaScript( 545 void CPDFSDK_ActionHandler::RunDocumentPageJavaScript(
546 CPDFSDK_FormFillEnvironment* pFormFillEnv, 546 CPDFSDK_FormFillEnvironment* pFormFillEnv,
547 CPDF_AAction::AActionType type, 547 CPDF_AAction::AActionType type,
(...skipping 22 matching lines...) Expand all
570 case CPDF_AAction::DocumentPrinted: 570 case CPDF_AAction::DocumentPrinted:
571 pContext->OnDoc_DidPrint(pFormFillEnv); 571 pContext->OnDoc_DidPrint(pFormFillEnv);
572 break; 572 break;
573 case CPDF_AAction::PageVisible: 573 case CPDF_AAction::PageVisible:
574 pContext->OnPage_InView(pFormFillEnv); 574 pContext->OnPage_InView(pFormFillEnv);
575 break; 575 break;
576 case CPDF_AAction::PageInvisible: 576 case CPDF_AAction::PageInvisible:
577 pContext->OnPage_OutView(pFormFillEnv); 577 pContext->OnPage_OutView(pFormFillEnv);
578 break; 578 break;
579 default: 579 default:
580 ASSERT(FALSE); 580 ASSERT(false);
581 break; 581 break;
582 } 582 }
583 583
584 CFX_WideString csInfo; 584 CFX_WideString csInfo;
585 FX_BOOL bRet = pContext->RunScript(script, &csInfo); 585 bool bRet = pContext->RunScript(script, &csInfo);
586 if (!bRet) { 586 if (!bRet) {
587 // FIXME: return error. 587 // FIXME: return error.
588 } 588 }
589 589
590 pRuntime->ReleaseContext(pContext); 590 pRuntime->ReleaseContext(pContext);
591 } 591 }
592 592
593 FX_BOOL CPDFSDK_ActionHandler::DoAction_Hide( 593 bool CPDFSDK_ActionHandler::DoAction_Hide(
594 const CPDF_Action& action, 594 const CPDF_Action& action,
595 CPDFSDK_FormFillEnvironment* pFormFillEnv) { 595 CPDFSDK_FormFillEnvironment* pFormFillEnv) {
596 CPDFSDK_InterForm* pInterForm = pFormFillEnv->GetInterForm(); 596 CPDFSDK_InterForm* pInterForm = pFormFillEnv->GetInterForm();
597 if (pInterForm->DoAction_Hide(action)) { 597 if (pInterForm->DoAction_Hide(action)) {
598 pFormFillEnv->SetChangeMark(); 598 pFormFillEnv->SetChangeMark();
599 return TRUE; 599 return true;
600 } 600 }
601 601
602 return FALSE; 602 return false;
603 } 603 }
604 604
605 FX_BOOL CPDFSDK_ActionHandler::DoAction_SubmitForm( 605 bool CPDFSDK_ActionHandler::DoAction_SubmitForm(
606 const CPDF_Action& action, 606 const CPDF_Action& action,
607 CPDFSDK_FormFillEnvironment* pFormFillEnv) { 607 CPDFSDK_FormFillEnvironment* pFormFillEnv) {
608 CPDFSDK_InterForm* pInterForm = pFormFillEnv->GetInterForm(); 608 CPDFSDK_InterForm* pInterForm = pFormFillEnv->GetInterForm();
609 return pInterForm->DoAction_SubmitForm(action); 609 return pInterForm->DoAction_SubmitForm(action);
610 } 610 }
611 611
612 FX_BOOL CPDFSDK_ActionHandler::DoAction_ResetForm( 612 bool CPDFSDK_ActionHandler::DoAction_ResetForm(
613 const CPDF_Action& action, 613 const CPDF_Action& action,
614 CPDFSDK_FormFillEnvironment* pFormFillEnv) { 614 CPDFSDK_FormFillEnvironment* pFormFillEnv) {
615 CPDFSDK_InterForm* pInterForm = pFormFillEnv->GetInterForm(); 615 CPDFSDK_InterForm* pInterForm = pFormFillEnv->GetInterForm();
616 return pInterForm->DoAction_ResetForm(action); 616 return pInterForm->DoAction_ResetForm(action);
617 } 617 }
618 618
619 FX_BOOL CPDFSDK_ActionHandler::DoAction_ImportData( 619 bool CPDFSDK_ActionHandler::DoAction_ImportData(
620 const CPDF_Action& action, 620 const CPDF_Action& action,
621 CPDFSDK_FormFillEnvironment* pFormFillEnv) { 621 CPDFSDK_FormFillEnvironment* pFormFillEnv) {
622 CPDFSDK_InterForm* pInterForm = pFormFillEnv->GetInterForm(); 622 CPDFSDK_InterForm* pInterForm = pFormFillEnv->GetInterForm();
623 if (pInterForm->DoAction_ImportData(action)) { 623 if (pInterForm->DoAction_ImportData(action)) {
624 pFormFillEnv->SetChangeMark(); 624 pFormFillEnv->SetChangeMark();
625 return TRUE; 625 return true;
626 } 626 }
627 627
628 return FALSE; 628 return false;
629 } 629 }
OLDNEW
« no previous file with comments | « fpdfsdk/fsdk_actionhandler.h ('k') | fpdfsdk/fsdk_define.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698