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 "fpdfsdk/include/fsdk_actionhandler.h" | 7 #include "fpdfsdk/include/fsdk_actionhandler.h" |
8 | 8 |
9 #include <set> | 9 #include <set> |
10 | 10 |
11 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" | 11 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" |
12 #include "core/fpdfdoc/include/cpdf_formfield.h" | 12 #include "core/fpdfdoc/include/cpdf_formfield.h" |
13 #include "core/fpdfdoc/include/cpdf_interform.h" | 13 #include "core/fpdfdoc/include/cpdf_interform.h" |
14 #include "fpdfsdk/include/fsdk_define.h" | 14 #include "fpdfsdk/include/fsdk_define.h" |
15 #include "fpdfsdk/include/fsdk_mgr.h" | 15 #include "fpdfsdk/include/fsdk_mgr.h" |
16 #include "fpdfsdk/javascript/ijs_context.h" | 16 #include "fpdfsdk/javascript/ijs_context.h" |
17 #include "fpdfsdk/javascript/ijs_runtime.h" | 17 #include "fpdfsdk/javascript/ijs_runtime.h" |
18 #include "third_party/base/stl_util.h" | 18 #include "third_party/base/stl_util.h" |
19 | 19 |
20 CPDFSDK_ActionHandler::CPDFSDK_ActionHandler() | 20 class NoJsActionHandler { |
21 : m_pFormActionHandler(new CPDFSDK_FormActionHandler) {} | 21 public: |
22 NoJsActionHandler(const CPDF_Action&, CPDFSDK_Document*); | |
23 void Run(); | |
24 | |
25 private: | |
26 static void DoAction_GoTo(CPDFSDK_Document* pDocument, | |
27 const CPDF_Action& action); | |
28 static void DoAction_GoToR(CPDFSDK_Document* pDocument, | |
29 const CPDF_Action& action); | |
30 static void DoAction_Launch(CPDFSDK_Document* pDocument, | |
31 const CPDF_Action& action); | |
32 static void DoAction_URI(CPDFSDK_Document* pDocument, | |
33 const CPDF_Action& action); | |
34 static void DoAction_Named(CPDFSDK_Document* pDocument, | |
35 const CPDF_Action& action); | |
36 static void DoAction_SetOCGState(CPDFSDK_Document* pDocument, | |
37 const CPDF_Action& action); | |
38 static void DoAction_Hide(CPDFSDK_Document* pDocument, | |
39 const CPDF_Action& action); | |
40 static void DoAction_SubmitForm(CPDFSDK_Document* pDocument, | |
41 const CPDF_Action& action); | |
42 static void DoAction_ResetForm(CPDFSDK_Document* pDocument, | |
43 const CPDF_Action& action); | |
44 static void DoAction_ImportData(CPDFSDK_Document* pDocument, | |
45 const CPDF_Action& action); | |
46 | |
47 CPDF_Action m_action; | |
48 CPDFSDK_Document* m_document; | |
49 | |
50 typedef void (*Callback)(CPDFSDK_Document*, const CPDF_Action&); | |
51 Callback m_callback = nullptr; | |
Tom Sepez
2016/08/09 21:11:20
Instead of storing the callback, can we store the
| |
52 }; | |
53 | |
54 CPDFSDK_ActionHandler::CPDFSDK_ActionHandler() {} | |
22 | 55 |
23 CPDFSDK_ActionHandler::~CPDFSDK_ActionHandler() {} | 56 CPDFSDK_ActionHandler::~CPDFSDK_ActionHandler() {} |
24 | 57 |
25 FX_BOOL CPDFSDK_ActionHandler::DoAction_DocOpen(const CPDF_Action& action, | 58 FX_BOOL CPDFSDK_ActionHandler::DoAction_DocOpen(const CPDF_Action& action, |
26 CPDFSDK_Document* pDocument) { | 59 CPDFSDK_Document* pDocument) { |
27 std::set<CPDF_Dictionary*> visited; | 60 std::set<CPDF_Dictionary*> visited; |
28 return ExecuteDocumentOpenAction(action, pDocument, &visited); | 61 return ExecuteDocumentOpenAction(action, pDocument, &visited); |
29 } | 62 } |
30 | 63 |
31 FX_BOOL CPDFSDK_ActionHandler::DoAction_JavaScript( | 64 FX_BOOL CPDFSDK_ActionHandler::DoAction_JavaScript( |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
122 CPDFDoc_Environment* pEnv = pDocument->GetEnv(); | 155 CPDFDoc_Environment* pEnv = pDocument->GetEnv(); |
123 ASSERT(pEnv); | 156 ASSERT(pEnv); |
124 if (action.GetType() == CPDF_Action::JavaScript) { | 157 if (action.GetType() == CPDF_Action::JavaScript) { |
125 if (pEnv->IsJSInitiated()) { | 158 if (pEnv->IsJSInitiated()) { |
126 CFX_WideString swJS = action.GetJavaScript(); | 159 CFX_WideString swJS = action.GetJavaScript(); |
127 if (!swJS.IsEmpty()) { | 160 if (!swJS.IsEmpty()) { |
128 RunDocumentOpenJavaScript(pDocument, L"", swJS); | 161 RunDocumentOpenJavaScript(pDocument, L"", swJS); |
129 } | 162 } |
130 } | 163 } |
131 } else { | 164 } else { |
132 DoAction_NoJs(action, pDocument); | 165 NoJsActionHandler(action, pDocument).Run(); |
133 } | 166 } |
134 | 167 |
135 for (int32_t i = 0, sz = action.GetSubActionsCount(); i < sz; i++) { | 168 for (int32_t i = 0, sz = action.GetSubActionsCount(); i < sz; i++) { |
136 CPDF_Action subaction = action.GetSubAction(i); | 169 CPDF_Action subaction = action.GetSubAction(i); |
137 if (!ExecuteDocumentOpenAction(subaction, pDocument, visited)) | 170 if (!ExecuteDocumentOpenAction(subaction, pDocument, visited)) |
138 return FALSE; | 171 return FALSE; |
139 } | 172 } |
140 | 173 |
141 return TRUE; | 174 return TRUE; |
142 } | 175 } |
(...skipping 23 matching lines...) Expand all Loading... | |
166 CFX_WideString csInfo; | 199 CFX_WideString csInfo; |
167 FX_BOOL bRet = pContext->RunScript(swJS, &csInfo); | 200 FX_BOOL bRet = pContext->RunScript(swJS, &csInfo); |
168 if (!bRet) { | 201 if (!bRet) { |
169 // FIXME: return error. | 202 // FIXME: return error. |
170 } | 203 } |
171 | 204 |
172 pRuntime->ReleaseContext(pContext); | 205 pRuntime->ReleaseContext(pContext); |
173 } | 206 } |
174 } | 207 } |
175 } else { | 208 } else { |
176 DoAction_NoJs(action, pDocument); | 209 NoJsActionHandler(action, pDocument).Run(); |
177 } | 210 } |
178 | 211 |
179 for (int32_t i = 0, sz = action.GetSubActionsCount(); i < sz; i++) { | 212 for (int32_t i = 0, sz = action.GetSubActionsCount(); i < sz; i++) { |
180 CPDF_Action subaction = action.GetSubAction(i); | 213 CPDF_Action subaction = action.GetSubAction(i); |
181 if (!ExecuteLinkAction(subaction, pDocument, visited)) | 214 if (!ExecuteLinkAction(subaction, pDocument, visited)) |
182 return FALSE; | 215 return FALSE; |
183 } | 216 } |
184 | 217 |
185 return TRUE; | 218 return TRUE; |
186 } | 219 } |
187 | 220 |
221 FX_BOOL CPDFSDK_ActionHandler::IsValidDocView(CPDFSDK_Document* pDocument) { | |
222 ASSERT(pDocument); | |
223 return TRUE; | |
224 } | |
225 | |
188 FX_BOOL CPDFSDK_ActionHandler::ExecuteDocumentPageAction( | 226 FX_BOOL CPDFSDK_ActionHandler::ExecuteDocumentPageAction( |
189 const CPDF_Action& action, | 227 const CPDF_Action& action, |
190 CPDF_AAction::AActionType type, | 228 CPDF_AAction::AActionType type, |
191 CPDFSDK_Document* pDocument, | 229 CPDFSDK_Document* pDocument, |
192 std::set<CPDF_Dictionary*>* visited) { | 230 std::set<CPDF_Dictionary*>* visited) { |
193 CPDF_Dictionary* pDict = action.GetDict(); | 231 CPDF_Dictionary* pDict = action.GetDict(); |
194 if (pdfium::ContainsKey(*visited, pDict)) | 232 if (pdfium::ContainsKey(*visited, pDict)) |
195 return FALSE; | 233 return FALSE; |
196 | 234 |
197 visited->insert(pDict); | 235 visited->insert(pDict); |
198 | 236 |
199 CPDFDoc_Environment* pEnv = pDocument->GetEnv(); | 237 CPDFDoc_Environment* pEnv = pDocument->GetEnv(); |
200 ASSERT(pEnv); | 238 ASSERT(pEnv); |
201 if (action.GetType() == CPDF_Action::JavaScript) { | 239 if (action.GetType() == CPDF_Action::JavaScript) { |
202 if (pEnv->IsJSInitiated()) { | 240 if (pEnv->IsJSInitiated()) { |
203 CFX_WideString swJS = action.GetJavaScript(); | 241 CFX_WideString swJS = action.GetJavaScript(); |
204 if (!swJS.IsEmpty()) { | 242 if (!swJS.IsEmpty()) { |
205 RunDocumentPageJavaScript(pDocument, type, swJS); | 243 RunDocumentPageJavaScript(pDocument, type, swJS); |
206 } | 244 } |
207 } | 245 } |
208 } else { | 246 } else { |
209 DoAction_NoJs(action, pDocument); | 247 NoJsActionHandler(action, pDocument).Run(); |
210 } | 248 } |
211 | 249 |
212 if (!IsValidDocView(pDocument)) | 250 if (!IsValidDocView(pDocument)) |
213 return FALSE; | 251 return FALSE; |
214 | 252 |
215 for (int32_t i = 0, sz = action.GetSubActionsCount(); i < sz; i++) { | 253 for (int32_t i = 0, sz = action.GetSubActionsCount(); i < sz; i++) { |
216 CPDF_Action subaction = action.GetSubAction(i); | 254 CPDF_Action subaction = action.GetSubAction(i); |
217 if (!ExecuteDocumentPageAction(subaction, type, pDocument, visited)) | 255 if (!ExecuteDocumentPageAction(subaction, type, pDocument, visited)) |
218 return FALSE; | 256 return FALSE; |
219 } | 257 } |
(...skipping 28 matching lines...) Expand all Loading... | |
248 if (action.GetType() == CPDF_Action::JavaScript) { | 286 if (action.GetType() == CPDF_Action::JavaScript) { |
249 if (pEnv->IsJSInitiated()) { | 287 if (pEnv->IsJSInitiated()) { |
250 CFX_WideString swJS = action.GetJavaScript(); | 288 CFX_WideString swJS = action.GetJavaScript(); |
251 if (!swJS.IsEmpty()) { | 289 if (!swJS.IsEmpty()) { |
252 RunFieldJavaScript(pDocument, pFormField, type, data, swJS); | 290 RunFieldJavaScript(pDocument, pFormField, type, data, swJS); |
253 if (!IsValidField(pDocument, pFormField->GetFieldDict())) | 291 if (!IsValidField(pDocument, pFormField->GetFieldDict())) |
254 return FALSE; | 292 return FALSE; |
255 } | 293 } |
256 } | 294 } |
257 } else { | 295 } else { |
258 DoAction_NoJs(action, pDocument); | 296 NoJsActionHandler(action, pDocument).Run(); |
259 } | 297 } |
260 | 298 |
261 for (int32_t i = 0, sz = action.GetSubActionsCount(); i < sz; i++) { | 299 for (int32_t i = 0, sz = action.GetSubActionsCount(); i < sz; i++) { |
262 CPDF_Action subaction = action.GetSubAction(i); | 300 CPDF_Action subaction = action.GetSubAction(i); |
263 if (!ExecuteFieldAction(subaction, type, pDocument, pFormField, data, | 301 if (!ExecuteFieldAction(subaction, type, pDocument, pFormField, data, |
264 visited)) | 302 visited)) |
265 return FALSE; | 303 return FALSE; |
266 } | 304 } |
267 | 305 |
268 return TRUE; | 306 return TRUE; |
(...skipping 24 matching lines...) Expand all Loading... | |
293 CFX_WideString csInfo; | 331 CFX_WideString csInfo; |
294 FX_BOOL bRet = pContext->RunScript(swJS, &csInfo); | 332 FX_BOOL bRet = pContext->RunScript(swJS, &csInfo); |
295 if (!bRet) { | 333 if (!bRet) { |
296 // FIXME: return error. | 334 // FIXME: return error. |
297 } | 335 } |
298 | 336 |
299 pRuntime->ReleaseContext(pContext); | 337 pRuntime->ReleaseContext(pContext); |
300 } | 338 } |
301 } | 339 } |
302 } else { | 340 } else { |
303 DoAction_NoJs(action, pDocument); | 341 NoJsActionHandler(action, pDocument).Run(); |
304 } | 342 } |
305 | 343 |
306 for (int32_t i = 0, sz = action.GetSubActionsCount(); i < sz; i++) { | 344 for (int32_t i = 0, sz = action.GetSubActionsCount(); i < sz; i++) { |
307 CPDF_Action subaction = action.GetSubAction(i); | 345 CPDF_Action subaction = action.GetSubAction(i); |
308 if (!ExecuteScreenAction(subaction, type, pDocument, pScreen, visited)) | 346 if (!ExecuteScreenAction(subaction, type, pDocument, pScreen, visited)) |
309 return FALSE; | 347 return FALSE; |
310 } | 348 } |
311 | 349 |
312 return TRUE; | 350 return TRUE; |
313 } | 351 } |
(...skipping 24 matching lines...) Expand all Loading... | |
338 CFX_WideString csInfo; | 376 CFX_WideString csInfo; |
339 FX_BOOL bRet = pContext->RunScript(swJS, &csInfo); | 377 FX_BOOL bRet = pContext->RunScript(swJS, &csInfo); |
340 if (!bRet) { | 378 if (!bRet) { |
341 // FIXME: return error. | 379 // FIXME: return error. |
342 } | 380 } |
343 | 381 |
344 pRuntime->ReleaseContext(pContext); | 382 pRuntime->ReleaseContext(pContext); |
345 } | 383 } |
346 } | 384 } |
347 } else { | 385 } else { |
348 DoAction_NoJs(action, pDocument); | 386 NoJsActionHandler(action, pDocument).Run(); |
349 } | 387 } |
350 | 388 |
351 for (int32_t i = 0, sz = action.GetSubActionsCount(); i < sz; i++) { | 389 for (int32_t i = 0, sz = action.GetSubActionsCount(); i < sz; i++) { |
352 CPDF_Action subaction = action.GetSubAction(i); | 390 CPDF_Action subaction = action.GetSubAction(i); |
353 if (!ExecuteBookMark(subaction, pDocument, pBookmark, visited)) | 391 if (!ExecuteBookMark(subaction, pDocument, pBookmark, visited)) |
354 return FALSE; | 392 return FALSE; |
355 } | 393 } |
356 | 394 |
357 return TRUE; | 395 return TRUE; |
358 } | 396 } |
359 | 397 |
360 void CPDFSDK_ActionHandler::DoAction_NoJs(const CPDF_Action& action, | 398 NoJsActionHandler::NoJsActionHandler(const CPDF_Action& action, |
361 CPDFSDK_Document* pDocument) { | 399 CPDFSDK_Document* document) |
362 ASSERT(pDocument); | 400 : m_action(action), m_document(document) { |
363 | 401 switch (m_action.GetType()) { |
364 switch (action.GetType()) { | |
365 case CPDF_Action::GoTo: | 402 case CPDF_Action::GoTo: |
366 DoAction_GoTo(pDocument, action); | 403 m_callback = &DoAction_GoTo; |
367 break; | 404 break; |
368 case CPDF_Action::GoToR: | 405 case CPDF_Action::GoToR: |
369 DoAction_GoToR(pDocument, action); | 406 m_callback = &DoAction_GoToR; |
370 break; | |
371 case CPDF_Action::GoToE: | |
372 break; | 407 break; |
373 case CPDF_Action::Launch: | 408 case CPDF_Action::Launch: |
374 DoAction_Launch(pDocument, action); | 409 m_callback = &DoAction_Launch; |
375 break; | |
376 case CPDF_Action::Thread: | |
377 break; | 410 break; |
378 case CPDF_Action::URI: | 411 case CPDF_Action::URI: |
379 DoAction_URI(pDocument, action); | 412 m_callback = &DoAction_URI; |
380 break; | |
381 case CPDF_Action::Sound: | |
382 break; | |
383 case CPDF_Action::Movie: | |
384 break; | 413 break; |
385 case CPDF_Action::Hide: | 414 case CPDF_Action::Hide: |
386 if (m_pFormActionHandler) { | 415 m_callback = &DoAction_Hide; |
387 m_pFormActionHandler->DoAction_Hide(action, pDocument); | |
388 } | |
389 break; | 416 break; |
390 case CPDF_Action::Named: | 417 case CPDF_Action::Named: |
391 DoAction_Named(pDocument, action); | 418 m_callback = &DoAction_Named; |
392 break; | 419 break; |
393 case CPDF_Action::SubmitForm: | 420 case CPDF_Action::SubmitForm: |
394 if (m_pFormActionHandler) { | 421 m_callback = &DoAction_SubmitForm; |
395 m_pFormActionHandler->DoAction_SubmitForm(action, pDocument); | |
396 } | |
397 break; | 422 break; |
398 case CPDF_Action::ResetForm: | 423 case CPDF_Action::ResetForm: |
399 if (m_pFormActionHandler) { | 424 m_callback = &DoAction_ResetForm; |
400 m_pFormActionHandler->DoAction_ResetForm(action, pDocument); | |
401 } | |
402 break; | 425 break; |
403 case CPDF_Action::ImportData: | 426 case CPDF_Action::ImportData: |
404 if (m_pFormActionHandler) { | 427 m_callback = &DoAction_ImportData; |
405 m_pFormActionHandler->DoAction_ImportData(action, pDocument); | |
406 } | |
407 break; | 428 break; |
408 case CPDF_Action::JavaScript: | 429 case CPDF_Action::JavaScript: |
409 ASSERT(FALSE); | 430 ASSERT(FALSE); |
410 break; | 431 break; |
411 case CPDF_Action::SetOCGState: | 432 case CPDF_Action::SetOCGState: |
412 DoAction_SetOCGState(pDocument, action); | 433 m_callback = &DoAction_SetOCGState; |
413 break; | 434 break; |
435 case CPDF_Action::GoToE: | |
436 case CPDF_Action::Thread: | |
437 case CPDF_Action::Sound: | |
438 case CPDF_Action::Movie: | |
414 case CPDF_Action::Rendition: | 439 case CPDF_Action::Rendition: |
415 break; | |
416 case CPDF_Action::Trans: | 440 case CPDF_Action::Trans: |
417 break; | |
418 case CPDF_Action::GoTo3DView: | 441 case CPDF_Action::GoTo3DView: |
419 break; | 442 break; |
420 default: | 443 default: |
421 break; | 444 break; |
422 } | 445 } |
423 } | 446 } |
424 | 447 |
425 FX_BOOL CPDFSDK_ActionHandler::IsValidDocView(CPDFSDK_Document* pDocument) { | 448 void NoJsActionHandler::Run() { |
426 ASSERT(pDocument); | 449 if (!m_callback) |
427 return TRUE; | 450 return; |
451 | |
452 ASSERT(m_document); | |
453 m_callback(m_document, m_action); | |
428 } | 454 } |
429 | 455 |
430 void CPDFSDK_ActionHandler::DoAction_GoTo(CPDFSDK_Document* pDocument, | 456 void NoJsActionHandler::DoAction_GoTo(CPDFSDK_Document* pDocument, |
431 const CPDF_Action& action) { | 457 const CPDF_Action& action) { |
432 ASSERT(action.GetDict()); | 458 ASSERT(action.GetDict()); |
433 | 459 |
434 CPDF_Document* pPDFDocument = pDocument->GetPDFDocument(); | 460 CPDF_Document* pPDFDocument = pDocument->GetPDFDocument(); |
435 ASSERT(pPDFDocument); | 461 ASSERT(pPDFDocument); |
436 | 462 |
437 CPDF_Dest MyDest = action.GetDest(pPDFDocument); | 463 CPDF_Dest MyDest = action.GetDest(pPDFDocument); |
438 int nPageIndex = MyDest.GetPageIndex(pPDFDocument); | 464 int nPageIndex = MyDest.GetPageIndex(pPDFDocument); |
439 int nFitType = MyDest.GetZoomMode(); | 465 int nFitType = MyDest.GetZoomMode(); |
440 const CPDF_Array* pMyArray = ToArray(MyDest.GetObject()); | 466 const CPDF_Array* pMyArray = ToArray(MyDest.GetObject()); |
441 float* pPosAry = nullptr; | 467 float* pPosAry = nullptr; |
442 int sizeOfAry = 0; | 468 int sizeOfAry = 0; |
443 if (pMyArray) { | 469 if (pMyArray) { |
444 pPosAry = new float[pMyArray->GetCount()]; | 470 pPosAry = new float[pMyArray->GetCount()]; |
445 int j = 0; | 471 int j = 0; |
446 for (size_t i = 2; i < pMyArray->GetCount(); i++) { | 472 for (size_t i = 2; i < pMyArray->GetCount(); i++) { |
447 pPosAry[j++] = pMyArray->GetFloatAt(i); | 473 pPosAry[j++] = pMyArray->GetFloatAt(i); |
448 } | 474 } |
449 sizeOfAry = j; | 475 sizeOfAry = j; |
450 } | 476 } |
451 | 477 |
452 CPDFDoc_Environment* pApp = pDocument->GetEnv(); | 478 CPDFDoc_Environment* pApp = pDocument->GetEnv(); |
453 pApp->FFI_DoGoToAction(nPageIndex, nFitType, pPosAry, sizeOfAry); | 479 pApp->FFI_DoGoToAction(nPageIndex, nFitType, pPosAry, sizeOfAry); |
454 delete[] pPosAry; | 480 delete[] pPosAry; |
455 } | 481 } |
456 | 482 |
457 void CPDFSDK_ActionHandler::DoAction_GoToR(CPDFSDK_Document* pDocument, | 483 void NoJsActionHandler::DoAction_GoToR(CPDFSDK_Document* pDocument, |
458 const CPDF_Action& action) {} | 484 const CPDF_Action& action) {} |
459 | 485 |
460 void CPDFSDK_ActionHandler::DoAction_Launch(CPDFSDK_Document* pDocument, | 486 void NoJsActionHandler::DoAction_Launch(CPDFSDK_Document* pDocument, |
461 const CPDF_Action& action) {} | 487 const CPDF_Action& action) {} |
462 | 488 |
463 void CPDFSDK_ActionHandler::DoAction_URI(CPDFSDK_Document* pDocument, | 489 void NoJsActionHandler::DoAction_URI(CPDFSDK_Document* pDocument, |
464 const CPDF_Action& action) { | 490 const CPDF_Action& action) { |
465 ASSERT(action.GetDict()); | 491 ASSERT(action.GetDict()); |
466 | 492 |
467 CPDFDoc_Environment* pApp = pDocument->GetEnv(); | 493 CPDFDoc_Environment* pApp = pDocument->GetEnv(); |
468 CFX_ByteString sURI = action.GetURI(pDocument->GetPDFDocument()); | 494 CFX_ByteString sURI = action.GetURI(pDocument->GetPDFDocument()); |
469 pApp->FFI_DoURIAction(sURI.c_str()); | 495 pApp->FFI_DoURIAction(sURI.c_str()); |
470 } | 496 } |
471 | 497 |
472 void CPDFSDK_ActionHandler::DoAction_Named(CPDFSDK_Document* pDocument, | 498 void NoJsActionHandler::DoAction_Named(CPDFSDK_Document* pDocument, |
473 const CPDF_Action& action) { | 499 const CPDF_Action& action) { |
474 ASSERT(action.GetDict()); | 500 ASSERT(action.GetDict()); |
475 | 501 |
476 CFX_ByteString csName = action.GetNamedAction(); | 502 CFX_ByteString csName = action.GetNamedAction(); |
477 pDocument->GetEnv()->FFI_ExecuteNamedAction(csName.c_str()); | 503 pDocument->GetEnv()->FFI_ExecuteNamedAction(csName.c_str()); |
478 } | 504 } |
479 | 505 |
480 void CPDFSDK_ActionHandler::DoAction_SetOCGState(CPDFSDK_Document* pDocument, | 506 void NoJsActionHandler::DoAction_SetOCGState(CPDFSDK_Document* pDocument, |
481 const CPDF_Action& action) {} | 507 const CPDF_Action& action) {} |
482 | 508 |
483 void CPDFSDK_ActionHandler::RunFieldJavaScript(CPDFSDK_Document* pDocument, | 509 void CPDFSDK_ActionHandler::RunFieldJavaScript(CPDFSDK_Document* pDocument, |
484 CPDF_FormField* pFormField, | 510 CPDF_FormField* pFormField, |
485 CPDF_AAction::AActionType type, | 511 CPDF_AAction::AActionType type, |
486 PDFSDK_FieldAction& data, | 512 PDFSDK_FieldAction& data, |
487 const CFX_WideString& script) { | 513 const CFX_WideString& script) { |
488 ASSERT(type != CPDF_AAction::Calculate); | 514 ASSERT(type != CPDF_AAction::Calculate); |
489 ASSERT(type != CPDF_AAction::Format); | 515 ASSERT(type != CPDF_AAction::Format); |
490 | 516 |
491 IJS_Runtime* pRuntime = pDocument->GetJsRuntime(); | 517 IJS_Runtime* pRuntime = pDocument->GetJsRuntime(); |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
599 | 625 |
600 CFX_WideString csInfo; | 626 CFX_WideString csInfo; |
601 FX_BOOL bRet = pContext->RunScript(script, &csInfo); | 627 FX_BOOL bRet = pContext->RunScript(script, &csInfo); |
602 if (!bRet) { | 628 if (!bRet) { |
603 // FIXME: return error. | 629 // FIXME: return error. |
604 } | 630 } |
605 | 631 |
606 pRuntime->ReleaseContext(pContext); | 632 pRuntime->ReleaseContext(pContext); |
607 } | 633 } |
608 | 634 |
609 FX_BOOL CPDFSDK_FormActionHandler::DoAction_Hide(const CPDF_Action& action, | 635 void NoJsActionHandler::DoAction_Hide(CPDFSDK_Document* pDocument, |
610 CPDFSDK_Document* pDocument) { | 636 const CPDF_Action& action) { |
611 CPDFSDK_InterForm* pInterForm = pDocument->GetInterForm(); | 637 CPDFSDK_InterForm* pInterForm = pDocument->GetInterForm(); |
612 if (pInterForm->DoAction_Hide(action)) { | 638 if (pInterForm->DoAction_Hide(action)) |
613 pDocument->SetChangeMark(); | 639 pDocument->SetChangeMark(); |
614 return TRUE; | |
615 } | |
616 | |
617 return FALSE; | |
618 } | 640 } |
619 | 641 |
620 FX_BOOL CPDFSDK_FormActionHandler::DoAction_SubmitForm( | 642 void NoJsActionHandler::DoAction_SubmitForm(CPDFSDK_Document* pDocument, |
621 const CPDF_Action& action, | 643 const CPDF_Action& action) { |
622 CPDFSDK_Document* pDocument) { | |
623 CPDFSDK_InterForm* pInterForm = pDocument->GetInterForm(); | 644 CPDFSDK_InterForm* pInterForm = pDocument->GetInterForm(); |
624 return pInterForm->DoAction_SubmitForm(action); | 645 pInterForm->DoAction_SubmitForm(action); |
625 } | 646 } |
626 | 647 |
627 FX_BOOL CPDFSDK_FormActionHandler::DoAction_ResetForm( | 648 void NoJsActionHandler::DoAction_ResetForm(CPDFSDK_Document* pDocument, |
628 const CPDF_Action& action, | 649 const CPDF_Action& action) { |
629 CPDFSDK_Document* pDocument) { | |
630 CPDFSDK_InterForm* pInterForm = pDocument->GetInterForm(); | 650 CPDFSDK_InterForm* pInterForm = pDocument->GetInterForm(); |
631 return pInterForm->DoAction_ResetForm(action); | 651 pInterForm->DoAction_ResetForm(action); |
632 } | 652 } |
633 | 653 |
634 FX_BOOL CPDFSDK_FormActionHandler::DoAction_ImportData( | 654 void NoJsActionHandler::DoAction_ImportData(CPDFSDK_Document* pDocument, |
635 const CPDF_Action& action, | 655 const CPDF_Action& action) { |
636 CPDFSDK_Document* pDocument) { | |
637 CPDFSDK_InterForm* pInterForm = pDocument->GetInterForm(); | 656 CPDFSDK_InterForm* pInterForm = pDocument->GetInterForm(); |
638 if (pInterForm->DoAction_ImportData(action)) { | 657 if (pInterForm->DoAction_ImportData(action)) |
639 pDocument->SetChangeMark(); | 658 pDocument->SetChangeMark(); |
640 return TRUE; | |
641 } | |
642 | |
643 return FALSE; | |
644 } | 659 } |
OLD | NEW |