| 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/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" | |
| 15 #include "fpdfsdk/cpdfsdk_formfillenvironment.h" | 14 #include "fpdfsdk/cpdfsdk_formfillenvironment.h" |
| 16 #include "fpdfsdk/cpdfsdk_interform.h" | 15 #include "fpdfsdk/cpdfsdk_interform.h" |
| 17 #include "fpdfsdk/fsdk_define.h" | 16 #include "fpdfsdk/fsdk_define.h" |
| 18 #include "fpdfsdk/javascript/ijs_context.h" | 17 #include "fpdfsdk/javascript/ijs_context.h" |
| 19 #include "fpdfsdk/javascript/ijs_runtime.h" | 18 #include "fpdfsdk/javascript/ijs_runtime.h" |
| 20 #include "third_party/base/stl_util.h" | 19 #include "third_party/base/stl_util.h" |
| 21 | 20 |
| 22 FX_BOOL CPDFSDK_ActionHandler::DoAction_DocOpen( | 21 FX_BOOL CPDFSDK_ActionHandler::DoAction_DocOpen( |
| 23 const CPDF_Action& action, | 22 const CPDF_Action& action, |
| 24 CPDFSDK_FormFillEnvironment* pFormFillEnv) { | 23 CPDFSDK_FormFillEnvironment* pFormFillEnv) { |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 } | 215 } |
| 217 | 216 |
| 218 return TRUE; | 217 return TRUE; |
| 219 } | 218 } |
| 220 | 219 |
| 221 FX_BOOL CPDFSDK_ActionHandler::IsValidField( | 220 FX_BOOL CPDFSDK_ActionHandler::IsValidField( |
| 222 CPDFSDK_FormFillEnvironment* pFormFillEnv, | 221 CPDFSDK_FormFillEnvironment* pFormFillEnv, |
| 223 CPDF_Dictionary* pFieldDict) { | 222 CPDF_Dictionary* pFieldDict) { |
| 224 ASSERT(pFieldDict); | 223 ASSERT(pFieldDict); |
| 225 | 224 |
| 226 CPDFSDK_InterForm* pInterForm = | 225 CPDFSDK_InterForm* pInterForm = pFormFillEnv->GetInterForm(); |
| 227 pFormFillEnv->GetSDKDocument()->GetInterForm(); | |
| 228 CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm(); | 226 CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm(); |
| 229 return !!pPDFInterForm->GetFieldByDict(pFieldDict); | 227 return !!pPDFInterForm->GetFieldByDict(pFieldDict); |
| 230 } | 228 } |
| 231 | 229 |
| 232 FX_BOOL CPDFSDK_ActionHandler::ExecuteFieldAction( | 230 FX_BOOL CPDFSDK_ActionHandler::ExecuteFieldAction( |
| 233 const CPDF_Action& action, | 231 const CPDF_Action& action, |
| 234 CPDF_AAction::AActionType type, | 232 CPDF_AAction::AActionType type, |
| 235 CPDFSDK_FormFillEnvironment* pFormFillEnv, | 233 CPDFSDK_FormFillEnvironment* pFormFillEnv, |
| 236 CPDF_FormField* pFormField, | 234 CPDF_FormField* pFormField, |
| 237 PDFSDK_FieldAction& data, | 235 PDFSDK_FieldAction& data, |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 CPDFSDK_FormFillEnvironment* pFormFillEnv) { | 409 CPDFSDK_FormFillEnvironment* pFormFillEnv) { |
| 412 ASSERT(pFormFillEnv); | 410 ASSERT(pFormFillEnv); |
| 413 return TRUE; | 411 return TRUE; |
| 414 } | 412 } |
| 415 | 413 |
| 416 void CPDFSDK_ActionHandler::DoAction_GoTo( | 414 void CPDFSDK_ActionHandler::DoAction_GoTo( |
| 417 CPDFSDK_FormFillEnvironment* pFormFillEnv, | 415 CPDFSDK_FormFillEnvironment* pFormFillEnv, |
| 418 const CPDF_Action& action) { | 416 const CPDF_Action& action) { |
| 419 ASSERT(action.GetDict()); | 417 ASSERT(action.GetDict()); |
| 420 | 418 |
| 421 CPDF_Document* pPDFDocument = | 419 CPDF_Document* pPDFDocument = pFormFillEnv->GetPDFDocument(); |
| 422 pFormFillEnv->GetSDKDocument()->GetPDFDocument(); | |
| 423 ASSERT(pPDFDocument); | 420 ASSERT(pPDFDocument); |
| 424 | 421 |
| 425 CPDF_Dest MyDest = action.GetDest(pPDFDocument); | 422 CPDF_Dest MyDest = action.GetDest(pPDFDocument); |
| 426 int nPageIndex = MyDest.GetPageIndex(pPDFDocument); | 423 int nPageIndex = MyDest.GetPageIndex(pPDFDocument); |
| 427 int nFitType = MyDest.GetZoomMode(); | 424 int nFitType = MyDest.GetZoomMode(); |
| 428 const CPDF_Array* pMyArray = ToArray(MyDest.GetObject()); | 425 const CPDF_Array* pMyArray = ToArray(MyDest.GetObject()); |
| 429 float* pPosAry = nullptr; | 426 float* pPosAry = nullptr; |
| 430 int sizeOfAry = 0; | 427 int sizeOfAry = 0; |
| 431 if (pMyArray) { | 428 if (pMyArray) { |
| 432 pPosAry = new float[pMyArray->GetCount()]; | 429 pPosAry = new float[pMyArray->GetCount()]; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 447 | 444 |
| 448 void CPDFSDK_ActionHandler::DoAction_Launch( | 445 void CPDFSDK_ActionHandler::DoAction_Launch( |
| 449 CPDFSDK_FormFillEnvironment* pFormFillEnv, | 446 CPDFSDK_FormFillEnvironment* pFormFillEnv, |
| 450 const CPDF_Action& action) {} | 447 const CPDF_Action& action) {} |
| 451 | 448 |
| 452 void CPDFSDK_ActionHandler::DoAction_URI( | 449 void CPDFSDK_ActionHandler::DoAction_URI( |
| 453 CPDFSDK_FormFillEnvironment* pFormFillEnv, | 450 CPDFSDK_FormFillEnvironment* pFormFillEnv, |
| 454 const CPDF_Action& action) { | 451 const CPDF_Action& action) { |
| 455 ASSERT(action.GetDict()); | 452 ASSERT(action.GetDict()); |
| 456 | 453 |
| 457 CFX_ByteString sURI = | 454 CFX_ByteString sURI = action.GetURI(pFormFillEnv->GetPDFDocument()); |
| 458 action.GetURI(pFormFillEnv->GetSDKDocument()->GetPDFDocument()); | |
| 459 pFormFillEnv->DoURIAction(sURI.c_str()); | 455 pFormFillEnv->DoURIAction(sURI.c_str()); |
| 460 } | 456 } |
| 461 | 457 |
| 462 void CPDFSDK_ActionHandler::DoAction_Named( | 458 void CPDFSDK_ActionHandler::DoAction_Named( |
| 463 CPDFSDK_FormFillEnvironment* pFormFillEnv, | 459 CPDFSDK_FormFillEnvironment* pFormFillEnv, |
| 464 const CPDF_Action& action) { | 460 const CPDF_Action& action) { |
| 465 ASSERT(action.GetDict()); | 461 ASSERT(action.GetDict()); |
| 466 | 462 |
| 467 CFX_ByteString csName = action.GetNamedAction(); | 463 CFX_ByteString csName = action.GetNamedAction(); |
| 468 pFormFillEnv->ExecuteNamedAction(csName.c_str()); | 464 pFormFillEnv->ExecuteNamedAction(csName.c_str()); |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 590 if (!bRet) { | 586 if (!bRet) { |
| 591 // FIXME: return error. | 587 // FIXME: return error. |
| 592 } | 588 } |
| 593 | 589 |
| 594 pRuntime->ReleaseContext(pContext); | 590 pRuntime->ReleaseContext(pContext); |
| 595 } | 591 } |
| 596 | 592 |
| 597 FX_BOOL CPDFSDK_ActionHandler::DoAction_Hide( | 593 FX_BOOL CPDFSDK_ActionHandler::DoAction_Hide( |
| 598 const CPDF_Action& action, | 594 const CPDF_Action& action, |
| 599 CPDFSDK_FormFillEnvironment* pFormFillEnv) { | 595 CPDFSDK_FormFillEnvironment* pFormFillEnv) { |
| 600 CPDFSDK_InterForm* pInterForm = | 596 CPDFSDK_InterForm* pInterForm = pFormFillEnv->GetInterForm(); |
| 601 pFormFillEnv->GetSDKDocument()->GetInterForm(); | |
| 602 if (pInterForm->DoAction_Hide(action)) { | 597 if (pInterForm->DoAction_Hide(action)) { |
| 603 pFormFillEnv->GetSDKDocument()->SetChangeMark(); | 598 pFormFillEnv->SetChangeMark(); |
| 604 return TRUE; | 599 return TRUE; |
| 605 } | 600 } |
| 606 | 601 |
| 607 return FALSE; | 602 return FALSE; |
| 608 } | 603 } |
| 609 | 604 |
| 610 FX_BOOL CPDFSDK_ActionHandler::DoAction_SubmitForm( | 605 FX_BOOL CPDFSDK_ActionHandler::DoAction_SubmitForm( |
| 611 const CPDF_Action& action, | 606 const CPDF_Action& action, |
| 612 CPDFSDK_FormFillEnvironment* pFormFillEnv) { | 607 CPDFSDK_FormFillEnvironment* pFormFillEnv) { |
| 613 CPDFSDK_InterForm* pInterForm = | 608 CPDFSDK_InterForm* pInterForm = pFormFillEnv->GetInterForm(); |
| 614 pFormFillEnv->GetSDKDocument()->GetInterForm(); | |
| 615 return pInterForm->DoAction_SubmitForm(action); | 609 return pInterForm->DoAction_SubmitForm(action); |
| 616 } | 610 } |
| 617 | 611 |
| 618 FX_BOOL CPDFSDK_ActionHandler::DoAction_ResetForm( | 612 FX_BOOL CPDFSDK_ActionHandler::DoAction_ResetForm( |
| 619 const CPDF_Action& action, | 613 const CPDF_Action& action, |
| 620 CPDFSDK_FormFillEnvironment* pFormFillEnv) { | 614 CPDFSDK_FormFillEnvironment* pFormFillEnv) { |
| 621 CPDFSDK_InterForm* pInterForm = | 615 CPDFSDK_InterForm* pInterForm = pFormFillEnv->GetInterForm(); |
| 622 pFormFillEnv->GetSDKDocument()->GetInterForm(); | |
| 623 return pInterForm->DoAction_ResetForm(action); | 616 return pInterForm->DoAction_ResetForm(action); |
| 624 } | 617 } |
| 625 | 618 |
| 626 FX_BOOL CPDFSDK_ActionHandler::DoAction_ImportData( | 619 FX_BOOL CPDFSDK_ActionHandler::DoAction_ImportData( |
| 627 const CPDF_Action& action, | 620 const CPDF_Action& action, |
| 628 CPDFSDK_FormFillEnvironment* pFormFillEnv) { | 621 CPDFSDK_FormFillEnvironment* pFormFillEnv) { |
| 629 CPDFSDK_InterForm* pInterForm = | 622 CPDFSDK_InterForm* pInterForm = pFormFillEnv->GetInterForm(); |
| 630 pFormFillEnv->GetSDKDocument()->GetInterForm(); | |
| 631 if (pInterForm->DoAction_ImportData(action)) { | 623 if (pInterForm->DoAction_ImportData(action)) { |
| 632 pFormFillEnv->GetSDKDocument()->SetChangeMark(); | 624 pFormFillEnv->SetChangeMark(); |
| 633 return TRUE; | 625 return TRUE; |
| 634 } | 626 } |
| 635 | 627 |
| 636 return FALSE; | 628 return FALSE; |
| 637 } | 629 } |
| OLD | NEW |