John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1 | // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 4 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 5 | // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | |
dsinclair | 114e46a | 2016-09-29 17:18:21 -0700 | [diff] [blame] | 7 | #ifndef FPDFSDK_FSDK_ACTIONHANDLER_H_ |
| 8 | #define FPDFSDK_FSDK_ACTIONHANDLER_H_ |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 9 | |
Lei Zhang | aa8bf7e | 2015-12-24 19:13:32 -0800 | [diff] [blame] | 10 | #include <memory> |
Tom Sepez | 6c7508b | 2016-01-20 14:59:25 -0800 | [diff] [blame] | 11 | #include <set> |
Lei Zhang | aa8bf7e | 2015-12-24 19:13:32 -0800 | [diff] [blame] | 12 | |
dsinclair | 1727aee | 2016-09-29 13:12:56 -0700 | [diff] [blame] | 13 | #include "core/fpdfdoc/cpdf_aaction.h" |
| 14 | #include "core/fpdfdoc/cpdf_action.h" |
dsinclair | a52ab74 | 2016-09-29 13:59:29 -0700 | [diff] [blame] | 15 | #include "core/fxcrt/fx_string.h" |
dsinclair | 114e46a | 2016-09-29 17:18:21 -0700 | [diff] [blame] | 16 | #include "fpdfsdk/pdfsdk_fieldaction.h" |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 17 | |
Tom Sepez | 245c80e | 2015-04-08 16:19:33 -0700 | [diff] [blame] | 18 | class CPDFSDK_Annot; |
dsinclair | 19c198b | 2016-10-11 12:51:37 -0700 | [diff] [blame] | 19 | class CPDFSDK_FormFillEnvironment; |
Tom Sepez | 245c80e | 2015-04-08 16:19:33 -0700 | [diff] [blame] | 20 | class CPDF_Bookmark; |
| 21 | class CPDF_Dictionary; |
jaepark | 611adb8 | 2016-08-17 11:34:36 -0700 | [diff] [blame] | 22 | class CPDF_FormField; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 23 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 24 | class CPDFSDK_ActionHandler { |
| 25 | public: |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 26 | bool DoAction_DocOpen(const CPDF_Action& action, |
| 27 | CPDFSDK_FormFillEnvironment* pFormFillEnv); |
| 28 | bool DoAction_JavaScript(const CPDF_Action& JsAction, |
Ryan Harrison | 275e260 | 2017-09-18 14:23:18 -0400 | [diff] [blame] | 29 | WideString csJSName, |
dsinclair | 19c198b | 2016-10-11 12:51:37 -0700 | [diff] [blame] | 30 | CPDFSDK_FormFillEnvironment* pFormFillEnv); |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 31 | bool DoAction_Page(const CPDF_Action& action, |
| 32 | enum CPDF_AAction::AActionType eType, |
| 33 | CPDFSDK_FormFillEnvironment* pFormFillEnv); |
| 34 | bool DoAction_Document(const CPDF_Action& action, |
| 35 | enum CPDF_AAction::AActionType eType, |
| 36 | CPDFSDK_FormFillEnvironment* pFormFillEnv); |
| 37 | bool DoAction_BookMark(CPDF_Bookmark* pBookMark, |
| 38 | const CPDF_Action& action, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 39 | CPDF_AAction::AActionType type, |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 40 | CPDFSDK_FormFillEnvironment* pFormFillEnv); |
| 41 | bool DoAction_Screen(const CPDF_Action& action, |
| 42 | CPDF_AAction::AActionType type, |
| 43 | CPDFSDK_FormFillEnvironment* pFormFillEnv, |
| 44 | CPDFSDK_Annot* pScreen); |
| 45 | bool DoAction_Link(const CPDF_Action& action, |
| 46 | CPDFSDK_FormFillEnvironment* pFormFillEnv); |
| 47 | bool DoAction_Field(const CPDF_Action& action, |
| 48 | CPDF_AAction::AActionType type, |
| 49 | CPDFSDK_FormFillEnvironment* pFormFillEnv, |
| 50 | CPDF_FormField* pFormField, |
| 51 | PDFSDK_FieldAction& data); |
| 52 | bool DoAction_FieldJavaScript(const CPDF_Action& JsAction, |
| 53 | CPDF_AAction::AActionType type, |
| 54 | CPDFSDK_FormFillEnvironment* pFormFillEnv, |
| 55 | CPDF_FormField* pFormField, |
| 56 | PDFSDK_FieldAction& data); |
Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 57 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 58 | private: |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 59 | bool ExecuteDocumentOpenAction(const CPDF_Action& action, |
| 60 | CPDFSDK_FormFillEnvironment* pFormFillEnv, |
| 61 | std::set<CPDF_Dictionary*>* visited); |
| 62 | bool ExecuteDocumentPageAction(const CPDF_Action& action, |
| 63 | CPDF_AAction::AActionType type, |
| 64 | CPDFSDK_FormFillEnvironment* pFormFillEnv, |
| 65 | std::set<CPDF_Dictionary*>* visited); |
| 66 | bool ExecuteFieldAction(const CPDF_Action& action, |
| 67 | CPDF_AAction::AActionType type, |
dsinclair | 19c198b | 2016-10-11 12:51:37 -0700 | [diff] [blame] | 68 | CPDFSDK_FormFillEnvironment* pFormFillEnv, |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 69 | CPDF_FormField* pFormField, |
| 70 | PDFSDK_FieldAction& data, |
Tom Sepez | 6c7508b | 2016-01-20 14:59:25 -0800 | [diff] [blame] | 71 | std::set<CPDF_Dictionary*>* visited); |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 72 | bool ExecuteScreenAction(const CPDF_Action& action, |
| 73 | CPDF_AAction::AActionType type, |
| 74 | CPDFSDK_FormFillEnvironment* pFormFillEnv, |
| 75 | CPDFSDK_Annot* pScreen, |
| 76 | std::set<CPDF_Dictionary*>* visited); |
| 77 | bool ExecuteBookMark(const CPDF_Action& action, |
| 78 | CPDFSDK_FormFillEnvironment* pFormFillEnv, |
| 79 | CPDF_Bookmark* pBookmark, |
| 80 | std::set<CPDF_Dictionary*>* visited); |
| 81 | bool ExecuteLinkAction(const CPDF_Action& action, |
| 82 | CPDFSDK_FormFillEnvironment* pFormFillEnv, |
| 83 | std::set<CPDF_Dictionary*>* visited); |
Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 84 | |
dsinclair | 19c198b | 2016-10-11 12:51:37 -0700 | [diff] [blame] | 85 | void DoAction_NoJs(const CPDF_Action& action, |
| 86 | CPDFSDK_FormFillEnvironment* pFormFillEnv); |
| 87 | void RunDocumentPageJavaScript(CPDFSDK_FormFillEnvironment* pFormFillEnv, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 88 | CPDF_AAction::AActionType type, |
Ryan Harrison | 275e260 | 2017-09-18 14:23:18 -0400 | [diff] [blame] | 89 | const WideString& script); |
dsinclair | 19c198b | 2016-10-11 12:51:37 -0700 | [diff] [blame] | 90 | void RunDocumentOpenJavaScript(CPDFSDK_FormFillEnvironment* pFormFillEnv, |
Ryan Harrison | 275e260 | 2017-09-18 14:23:18 -0400 | [diff] [blame] | 91 | const WideString& sScriptName, |
| 92 | const WideString& script); |
dsinclair | 19c198b | 2016-10-11 12:51:37 -0700 | [diff] [blame] | 93 | void RunFieldJavaScript(CPDFSDK_FormFillEnvironment* pFormFillEnv, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 94 | CPDF_FormField* pFormField, |
| 95 | CPDF_AAction::AActionType type, |
| 96 | PDFSDK_FieldAction& data, |
Ryan Harrison | 275e260 | 2017-09-18 14:23:18 -0400 | [diff] [blame] | 97 | const WideString& script); |
Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 98 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 99 | bool IsValidField(CPDFSDK_FormFillEnvironment* pFormFillEnv, |
| 100 | CPDF_Dictionary* pFieldDict); |
| 101 | bool IsValidDocView(CPDFSDK_FormFillEnvironment* pFormFillEnv); |
Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 102 | |
dsinclair | 19c198b | 2016-10-11 12:51:37 -0700 | [diff] [blame] | 103 | void DoAction_GoTo(CPDFSDK_FormFillEnvironment* pFormFillEnv, |
| 104 | const CPDF_Action& action); |
| 105 | void DoAction_GoToR(CPDFSDK_FormFillEnvironment* pFormFillEnv, |
| 106 | const CPDF_Action& action); |
| 107 | void DoAction_Launch(CPDFSDK_FormFillEnvironment* pFormFillEnv, |
| 108 | const CPDF_Action& action); |
| 109 | void DoAction_URI(CPDFSDK_FormFillEnvironment* pFormFillEnv, |
| 110 | const CPDF_Action& action); |
| 111 | void DoAction_Named(CPDFSDK_FormFillEnvironment* pFormFillEnv, |
| 112 | const CPDF_Action& action); |
| 113 | void DoAction_SetOCGState(CPDFSDK_FormFillEnvironment* pFormFillEnv, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 114 | const CPDF_Action& action); |
Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 115 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 116 | bool DoAction_Hide(const CPDF_Action& action, |
| 117 | CPDFSDK_FormFillEnvironment* pFormFillEnv); |
| 118 | bool DoAction_SubmitForm(const CPDF_Action& action, |
| 119 | CPDFSDK_FormFillEnvironment* pFormFillEnv); |
| 120 | bool DoAction_ResetForm(const CPDF_Action& action, |
| 121 | CPDFSDK_FormFillEnvironment* pFormFillEnv); |
| 122 | bool DoAction_ImportData(const CPDF_Action& action, |
| 123 | CPDFSDK_FormFillEnvironment* pFormFillEnv); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 124 | }; |
| 125 | |
dsinclair | 114e46a | 2016-09-29 17:18:21 -0700 | [diff] [blame] | 126 | #endif // FPDFSDK_FSDK_ACTIONHANDLER_H_ |