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

Side by Side Diff: fpdfsdk/fsdk_actionhandler.cpp

Issue 2391313002: Rename CPDFSDK_Environment to CPDFSDK_FormfillEnvironment (Closed)
Patch Set: Rebase to master Created 4 years, 2 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
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_document.h" 14 #include "fpdfsdk/cpdfsdk_document.h"
15 #include "fpdfsdk/cpdfsdk_environment.h" 15 #include "fpdfsdk/cpdfsdk_formfillenvironment.h"
16 #include "fpdfsdk/cpdfsdk_interform.h" 16 #include "fpdfsdk/cpdfsdk_interform.h"
17 #include "fpdfsdk/fsdk_define.h" 17 #include "fpdfsdk/fsdk_define.h"
18 #include "fpdfsdk/javascript/ijs_context.h" 18 #include "fpdfsdk/javascript/ijs_context.h"
19 #include "fpdfsdk/javascript/ijs_runtime.h" 19 #include "fpdfsdk/javascript/ijs_runtime.h"
20 #include "third_party/base/stl_util.h" 20 #include "third_party/base/stl_util.h"
21 21
22 FX_BOOL CPDFSDK_ActionHandler::DoAction_DocOpen(const CPDF_Action& action, 22 FX_BOOL CPDFSDK_ActionHandler::DoAction_DocOpen(const CPDF_Action& action,
23 CPDFSDK_Document* pDocument) { 23 CPDFSDK_Document* pDocument) {
24 std::set<CPDF_Dictionary*> visited; 24 std::set<CPDF_Dictionary*> visited;
25 return ExecuteDocumentOpenAction(action, pDocument, &visited); 25 return ExecuteDocumentOpenAction(action, pDocument, &visited);
(...skipping 13 matching lines...) Expand all
39 39
40 return FALSE; 40 return FALSE;
41 } 41 }
42 42
43 FX_BOOL CPDFSDK_ActionHandler::DoAction_FieldJavaScript( 43 FX_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_Document* pDocument, 46 CPDFSDK_Document* pDocument,
47 CPDF_FormField* pFormField, 47 CPDF_FormField* pFormField,
48 PDFSDK_FieldAction& data) { 48 PDFSDK_FieldAction& data) {
49 CPDFSDK_Environment* pEnv = pDocument->GetEnv(); 49 CPDFSDK_FormFillEnvironment* pEnv = pDocument->GetEnv();
50 ASSERT(pEnv); 50 ASSERT(pEnv);
51 if (pEnv->IsJSInitiated() && JsAction.GetType() == CPDF_Action::JavaScript) { 51 if (pEnv->IsJSInitiated() && 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(pDocument, pFormField, type, data, swJS); 54 RunFieldJavaScript(pDocument, pFormField, type, data, swJS);
55 return TRUE; 55 return TRUE;
56 } 56 }
57 } 57 }
58 return FALSE; 58 return FALSE;
59 } 59 }
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 FX_BOOL CPDFSDK_ActionHandler::ExecuteDocumentOpenAction( 109 FX_BOOL CPDFSDK_ActionHandler::ExecuteDocumentOpenAction(
110 const CPDF_Action& action, 110 const CPDF_Action& action,
111 CPDFSDK_Document* pDocument, 111 CPDFSDK_Document* pDocument,
112 std::set<CPDF_Dictionary*>* visited) { 112 std::set<CPDF_Dictionary*>* visited) {
113 CPDF_Dictionary* pDict = action.GetDict(); 113 CPDF_Dictionary* pDict = action.GetDict();
114 if (pdfium::ContainsKey(*visited, pDict)) 114 if (pdfium::ContainsKey(*visited, pDict))
115 return FALSE; 115 return FALSE;
116 116
117 visited->insert(pDict); 117 visited->insert(pDict);
118 118
119 CPDFSDK_Environment* pEnv = pDocument->GetEnv(); 119 CPDFSDK_FormFillEnvironment* pEnv = pDocument->GetEnv();
120 ASSERT(pEnv); 120 ASSERT(pEnv);
121 if (action.GetType() == CPDF_Action::JavaScript) { 121 if (action.GetType() == CPDF_Action::JavaScript) {
122 if (pEnv->IsJSInitiated()) { 122 if (pEnv->IsJSInitiated()) {
123 CFX_WideString swJS = action.GetJavaScript(); 123 CFX_WideString swJS = action.GetJavaScript();
124 if (!swJS.IsEmpty()) { 124 if (!swJS.IsEmpty()) {
125 RunDocumentOpenJavaScript(pDocument, L"", swJS); 125 RunDocumentOpenJavaScript(pDocument, L"", swJS);
126 } 126 }
127 } 127 }
128 } else { 128 } else {
129 DoAction_NoJs(action, pDocument); 129 DoAction_NoJs(action, pDocument);
(...skipping 11 matching lines...) Expand all
141 FX_BOOL CPDFSDK_ActionHandler::ExecuteLinkAction( 141 FX_BOOL CPDFSDK_ActionHandler::ExecuteLinkAction(
142 const CPDF_Action& action, 142 const CPDF_Action& action,
143 CPDFSDK_Document* pDocument, 143 CPDFSDK_Document* pDocument,
144 std::set<CPDF_Dictionary*>* visited) { 144 std::set<CPDF_Dictionary*>* visited) {
145 CPDF_Dictionary* pDict = action.GetDict(); 145 CPDF_Dictionary* pDict = action.GetDict();
146 if (pdfium::ContainsKey(*visited, pDict)) 146 if (pdfium::ContainsKey(*visited, pDict))
147 return FALSE; 147 return FALSE;
148 148
149 visited->insert(pDict); 149 visited->insert(pDict);
150 150
151 CPDFSDK_Environment* pEnv = pDocument->GetEnv(); 151 CPDFSDK_FormFillEnvironment* pEnv = pDocument->GetEnv();
152 ASSERT(pEnv); 152 ASSERT(pEnv);
153 if (action.GetType() == CPDF_Action::JavaScript) { 153 if (action.GetType() == CPDF_Action::JavaScript) {
154 if (pEnv->IsJSInitiated()) { 154 if (pEnv->IsJSInitiated()) {
155 CFX_WideString swJS = action.GetJavaScript(); 155 CFX_WideString swJS = action.GetJavaScript();
156 if (!swJS.IsEmpty()) { 156 if (!swJS.IsEmpty()) {
157 IJS_Runtime* pRuntime = pDocument->GetJsRuntime(); 157 IJS_Runtime* pRuntime = pDocument->GetJsRuntime();
158 pRuntime->SetReaderDocument(pDocument); 158 pRuntime->SetReaderDocument(pDocument);
159 159
160 IJS_Context* pContext = pRuntime->NewContext(); 160 IJS_Context* pContext = pRuntime->NewContext();
161 pContext->OnLink_MouseUp(pDocument); 161 pContext->OnLink_MouseUp(pDocument);
(...skipping 24 matching lines...) Expand all
186 const CPDF_Action& action, 186 const CPDF_Action& action,
187 CPDF_AAction::AActionType type, 187 CPDF_AAction::AActionType type,
188 CPDFSDK_Document* pDocument, 188 CPDFSDK_Document* pDocument,
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 CPDFSDK_Environment* pEnv = pDocument->GetEnv(); 196 CPDFSDK_FormFillEnvironment* pEnv = pDocument->GetEnv();
197 ASSERT(pEnv); 197 ASSERT(pEnv);
198 if (action.GetType() == CPDF_Action::JavaScript) { 198 if (action.GetType() == CPDF_Action::JavaScript) {
199 if (pEnv->IsJSInitiated()) { 199 if (pEnv->IsJSInitiated()) {
200 CFX_WideString swJS = action.GetJavaScript(); 200 CFX_WideString swJS = action.GetJavaScript();
201 if (!swJS.IsEmpty()) { 201 if (!swJS.IsEmpty()) {
202 RunDocumentPageJavaScript(pDocument, type, swJS); 202 RunDocumentPageJavaScript(pDocument, type, swJS);
203 } 203 }
204 } 204 }
205 } else { 205 } else {
206 DoAction_NoJs(action, pDocument); 206 DoAction_NoJs(action, pDocument);
(...skipping 26 matching lines...) Expand all
233 CPDFSDK_Document* pDocument, 233 CPDFSDK_Document* pDocument,
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 CPDFSDK_Environment* pEnv = pDocument->GetEnv(); 243 CPDFSDK_FormFillEnvironment* pEnv = pDocument->GetEnv();
244 ASSERT(pEnv); 244 ASSERT(pEnv);
245 if (action.GetType() == CPDF_Action::JavaScript) { 245 if (action.GetType() == CPDF_Action::JavaScript) {
246 if (pEnv->IsJSInitiated()) { 246 if (pEnv->IsJSInitiated()) {
247 CFX_WideString swJS = action.GetJavaScript(); 247 CFX_WideString swJS = action.GetJavaScript();
248 if (!swJS.IsEmpty()) { 248 if (!swJS.IsEmpty()) {
249 RunFieldJavaScript(pDocument, pFormField, type, data, swJS); 249 RunFieldJavaScript(pDocument, pFormField, type, data, swJS);
250 if (!IsValidField(pDocument, pFormField->GetFieldDict())) 250 if (!IsValidField(pDocument, pFormField->GetFieldDict()))
251 return FALSE; 251 return FALSE;
252 } 252 }
253 } 253 }
(...skipping 16 matching lines...) Expand all
270 CPDF_AAction::AActionType type, 270 CPDF_AAction::AActionType type,
271 CPDFSDK_Document* pDocument, 271 CPDFSDK_Document* pDocument,
272 CPDFSDK_Annot* pScreen, 272 CPDFSDK_Annot* pScreen,
273 std::set<CPDF_Dictionary*>* visited) { 273 std::set<CPDF_Dictionary*>* visited) {
274 CPDF_Dictionary* pDict = action.GetDict(); 274 CPDF_Dictionary* pDict = action.GetDict();
275 if (pdfium::ContainsKey(*visited, pDict)) 275 if (pdfium::ContainsKey(*visited, pDict))
276 return FALSE; 276 return FALSE;
277 277
278 visited->insert(pDict); 278 visited->insert(pDict);
279 279
280 CPDFSDK_Environment* pEnv = pDocument->GetEnv(); 280 CPDFSDK_FormFillEnvironment* pEnv = pDocument->GetEnv();
281 ASSERT(pEnv); 281 ASSERT(pEnv);
282 if (action.GetType() == CPDF_Action::JavaScript) { 282 if (action.GetType() == CPDF_Action::JavaScript) {
283 if (pEnv->IsJSInitiated()) { 283 if (pEnv->IsJSInitiated()) {
284 CFX_WideString swJS = action.GetJavaScript(); 284 CFX_WideString swJS = action.GetJavaScript();
285 if (!swJS.IsEmpty()) { 285 if (!swJS.IsEmpty()) {
286 IJS_Runtime* pRuntime = pDocument->GetJsRuntime(); 286 IJS_Runtime* pRuntime = pDocument->GetJsRuntime();
287 pRuntime->SetReaderDocument(pDocument); 287 pRuntime->SetReaderDocument(pDocument);
288 288
289 IJS_Context* pContext = pRuntime->NewContext(); 289 IJS_Context* pContext = pRuntime->NewContext();
290 CFX_WideString csInfo; 290 CFX_WideString csInfo;
(...skipping 22 matching lines...) Expand all
313 const CPDF_Action& action, 313 const CPDF_Action& action,
314 CPDFSDK_Document* pDocument, 314 CPDFSDK_Document* pDocument,
315 CPDF_Bookmark* pBookmark, 315 CPDF_Bookmark* pBookmark,
316 std::set<CPDF_Dictionary*>* visited) { 316 std::set<CPDF_Dictionary*>* visited) {
317 CPDF_Dictionary* pDict = action.GetDict(); 317 CPDF_Dictionary* pDict = action.GetDict();
318 if (pdfium::ContainsKey(*visited, pDict)) 318 if (pdfium::ContainsKey(*visited, pDict))
319 return FALSE; 319 return FALSE;
320 320
321 visited->insert(pDict); 321 visited->insert(pDict);
322 322
323 CPDFSDK_Environment* pEnv = pDocument->GetEnv(); 323 CPDFSDK_FormFillEnvironment* pEnv = pDocument->GetEnv();
324 ASSERT(pEnv); 324 ASSERT(pEnv);
325 if (action.GetType() == CPDF_Action::JavaScript) { 325 if (action.GetType() == CPDF_Action::JavaScript) {
326 if (pEnv->IsJSInitiated()) { 326 if (pEnv->IsJSInitiated()) {
327 CFX_WideString swJS = action.GetJavaScript(); 327 CFX_WideString swJS = action.GetJavaScript();
328 if (!swJS.IsEmpty()) { 328 if (!swJS.IsEmpty()) {
329 IJS_Runtime* pRuntime = pDocument->GetJsRuntime(); 329 IJS_Runtime* pRuntime = pDocument->GetJsRuntime();
330 pRuntime->SetReaderDocument(pDocument); 330 pRuntime->SetReaderDocument(pDocument);
331 331
332 IJS_Context* pContext = pRuntime->NewContext(); 332 IJS_Context* pContext = pRuntime->NewContext();
333 pContext->OnBookmark_MouseUp(pBookmark); 333 pContext->OnBookmark_MouseUp(pBookmark);
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 int sizeOfAry = 0; 431 int sizeOfAry = 0;
432 if (pMyArray) { 432 if (pMyArray) {
433 pPosAry = new float[pMyArray->GetCount()]; 433 pPosAry = new float[pMyArray->GetCount()];
434 int j = 0; 434 int j = 0;
435 for (size_t i = 2; i < pMyArray->GetCount(); i++) { 435 for (size_t i = 2; i < pMyArray->GetCount(); i++) {
436 pPosAry[j++] = pMyArray->GetFloatAt(i); 436 pPosAry[j++] = pMyArray->GetFloatAt(i);
437 } 437 }
438 sizeOfAry = j; 438 sizeOfAry = j;
439 } 439 }
440 440
441 CPDFSDK_Environment* pApp = pDocument->GetEnv(); 441 CPDFSDK_FormFillEnvironment* pApp = pDocument->GetEnv();
442 pApp->DoGoToAction(nPageIndex, nFitType, pPosAry, sizeOfAry); 442 pApp->DoGoToAction(nPageIndex, nFitType, pPosAry, sizeOfAry);
443 delete[] pPosAry; 443 delete[] pPosAry;
444 } 444 }
445 445
446 void CPDFSDK_ActionHandler::DoAction_GoToR(CPDFSDK_Document* pDocument, 446 void CPDFSDK_ActionHandler::DoAction_GoToR(CPDFSDK_Document* pDocument,
447 const CPDF_Action& action) {} 447 const CPDF_Action& action) {}
448 448
449 void CPDFSDK_ActionHandler::DoAction_Launch(CPDFSDK_Document* pDocument, 449 void CPDFSDK_ActionHandler::DoAction_Launch(CPDFSDK_Document* pDocument,
450 const CPDF_Action& action) {} 450 const CPDF_Action& action) {}
451 451
452 void CPDFSDK_ActionHandler::DoAction_URI(CPDFSDK_Document* pDocument, 452 void CPDFSDK_ActionHandler::DoAction_URI(CPDFSDK_Document* pDocument,
453 const CPDF_Action& action) { 453 const CPDF_Action& action) {
454 ASSERT(action.GetDict()); 454 ASSERT(action.GetDict());
455 455
456 CPDFSDK_Environment* pApp = pDocument->GetEnv(); 456 CPDFSDK_FormFillEnvironment* pApp = pDocument->GetEnv();
457 CFX_ByteString sURI = action.GetURI(pDocument->GetPDFDocument()); 457 CFX_ByteString sURI = action.GetURI(pDocument->GetPDFDocument());
458 pApp->DoURIAction(sURI.c_str()); 458 pApp->DoURIAction(sURI.c_str());
459 } 459 }
460 460
461 void CPDFSDK_ActionHandler::DoAction_Named(CPDFSDK_Document* pDocument, 461 void CPDFSDK_ActionHandler::DoAction_Named(CPDFSDK_Document* pDocument,
462 const CPDF_Action& action) { 462 const CPDF_Action& action) {
463 ASSERT(action.GetDict()); 463 ASSERT(action.GetDict());
464 464
465 CFX_ByteString csName = action.GetNamedAction(); 465 CFX_ByteString csName = action.GetNamedAction();
466 pDocument->GetEnv()->ExecuteNamedAction(csName.c_str()); 466 pDocument->GetEnv()->ExecuteNamedAction(csName.c_str());
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 const CPDF_Action& action, 623 const CPDF_Action& action,
624 CPDFSDK_Document* pDocument) { 624 CPDFSDK_Document* pDocument) {
625 CPDFSDK_InterForm* pInterForm = pDocument->GetInterForm(); 625 CPDFSDK_InterForm* pInterForm = pDocument->GetInterForm();
626 if (pInterForm->DoAction_ImportData(action)) { 626 if (pInterForm->DoAction_ImportData(action)) {
627 pDocument->SetChangeMark(); 627 pDocument->SetChangeMark();
628 return TRUE; 628 return TRUE;
629 } 629 }
630 630
631 return FALSE; 631 return FALSE;
632 } 632 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698