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. 4 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 6 7 #ifndef FPDFSDK_FSDK_ACTIONHANDLER_H_ 8 #define FPDFSDK_FSDK_ACTIONHANDLER_H_ 9 10 #include <memory> 11 #include <set> 12 13 #include "core/fpdfdoc/cpdf_aaction.h" 14 #include "core/fpdfdoc/cpdf_action.h" 15 #include "core/fxcrt/fx_string.h" 16 #include "fpdfsdk/pdfsdk_fieldaction.h" 17 18 class CPDFSDK_Annot; 19 class CPDFSDK_FormFillEnvironment; 20 class CPDF_Bookmark; 21 class CPDF_Dictionary; 22 class CPDF_FormField; 23 24 class CPDFSDK_ActionHandler { 25 public: 26 bool DoAction_DocOpen(const CPDF_Action& action, 27 CPDFSDK_FormFillEnvironment* pFormFillEnv); 28 bool DoAction_JavaScript(const CPDF_Action& JsAction, 29 WideString csJSName, 30 CPDFSDK_FormFillEnvironment* pFormFillEnv); 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, 39 CPDF_AAction::AActionType type, 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); 57 58 private: 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, 68 CPDFSDK_FormFillEnvironment* pFormFillEnv, 69 CPDF_FormField* pFormField, 70 PDFSDK_FieldAction& data, 71 std::set<CPDF_Dictionary*>* visited); 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); 84 85 void DoAction_NoJs(const CPDF_Action& action, 86 CPDFSDK_FormFillEnvironment* pFormFillEnv); 87 void RunDocumentPageJavaScript(CPDFSDK_FormFillEnvironment* pFormFillEnv, 88 CPDF_AAction::AActionType type, 89 const WideString& script); 90 void RunDocumentOpenJavaScript(CPDFSDK_FormFillEnvironment* pFormFillEnv, 91 const WideString& sScriptName, 92 const WideString& script); 93 void RunFieldJavaScript(CPDFSDK_FormFillEnvironment* pFormFillEnv, 94 CPDF_FormField* pFormField, 95 CPDF_AAction::AActionType type, 96 PDFSDK_FieldAction& data, 97 const WideString& script); 98 99 bool IsValidField(CPDFSDK_FormFillEnvironment* pFormFillEnv, 100 CPDF_Dictionary* pFieldDict); 101 bool IsValidDocView(CPDFSDK_FormFillEnvironment* pFormFillEnv); 102 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, 114 const CPDF_Action& action); 115 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); 124 }; 125 126 #endif // FPDFSDK_FSDK_ACTIONHANDLER_H_ 127