blob: e8f1a0deb9cc77ffe322cb0c451b75803aa5303a [file] [log] [blame]
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001// 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 Zhanga6d9f0e2015-06-13 00:48:38 -07004
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07005// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
Tom Sepez19922bb2015-05-28 13:23:12 -07007#ifndef FPDFSDK_INCLUDE_FSDK_ACTIONHANDLER_H_
8#define FPDFSDK_INCLUDE_FSDK_ACTIONHANDLER_H_
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07009
Lei Zhangaa8bf7e2015-12-24 19:13:32 -080010#include <memory>
Tom Sepez6c7508b2016-01-20 14:59:25 -080011#include <set>
Lei Zhangaa8bf7e2015-12-24 19:13:32 -080012
Dan Sinclaira8a28e02016-03-23 15:41:39 -040013#include "core/fxcrt/include/fx_string.h"
Dan Sinclairefbc1912016-02-17 16:54:43 -050014#include "fpdfsdk/include/fsdk_baseform.h"
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070015
Tom Sepez245c80e2015-04-08 16:19:33 -070016class CPDFSDK_Annot;
17class CPDFSDK_Document;
18class CPDF_Bookmark;
19class CPDF_Dictionary;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070020
Nico Weber9d8ec5a2015-08-04 13:00:21 -070021class CPDFSDK_FormActionHandler {
22 public:
23 FX_BOOL DoAction_Hide(const CPDF_Action& action, CPDFSDK_Document* pDocument);
24 FX_BOOL DoAction_SubmitForm(const CPDF_Action& action,
25 CPDFSDK_Document* pDocument);
26 FX_BOOL DoAction_ResetForm(const CPDF_Action& action,
27 CPDFSDK_Document* pDocument);
28 FX_BOOL DoAction_ImportData(const CPDF_Action& action,
29 CPDFSDK_Document* pDocument);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070030};
31
Nico Weber9d8ec5a2015-08-04 13:00:21 -070032class CPDFSDK_ActionHandler {
33 public:
Tom Sepez3b5f1242015-09-01 14:06:55 -070034 CPDFSDK_ActionHandler();
weili625ad662016-06-15 11:21:33 -070035 ~CPDFSDK_ActionHandler();
Tom Sepez2c286192015-06-18 12:47:11 -070036
Nico Weber9d8ec5a2015-08-04 13:00:21 -070037 FX_BOOL DoAction_DocOpen(const CPDF_Action& action,
38 CPDFSDK_Document* pDocument);
39 FX_BOOL DoAction_JavaScript(const CPDF_Action& JsAction,
40 CFX_WideString csJSName,
41 CPDFSDK_Document* pDocument);
42 FX_BOOL DoAction_Page(const CPDF_Action& action,
43 enum CPDF_AAction::AActionType eType,
44 CPDFSDK_Document* pDocument);
45 FX_BOOL DoAction_Document(const CPDF_Action& action,
46 enum CPDF_AAction::AActionType eType,
47 CPDFSDK_Document* pDocument);
48 FX_BOOL DoAction_BookMark(CPDF_Bookmark* pBookMark,
49 const CPDF_Action& action,
50 CPDF_AAction::AActionType type,
51 CPDFSDK_Document* pDocument);
52 FX_BOOL DoAction_Screen(const CPDF_Action& action,
53 CPDF_AAction::AActionType type,
54 CPDFSDK_Document* pDocument,
55 CPDFSDK_Annot* pScreen);
56 FX_BOOL DoAction_Link(const CPDF_Action& action, CPDFSDK_Document* pDocument);
57 FX_BOOL DoAction_Field(const CPDF_Action& action,
58 CPDF_AAction::AActionType type,
59 CPDFSDK_Document* pDocument,
60 CPDF_FormField* pFormField,
61 PDFSDK_FieldAction& data);
62 FX_BOOL DoAction_FieldJavaScript(const CPDF_Action& JsAction,
63 CPDF_AAction::AActionType type,
64 CPDFSDK_Document* pDocument,
65 CPDF_FormField* pFormField,
66 PDFSDK_FieldAction& data);
Lei Zhanga6d9f0e2015-06-13 00:48:38 -070067
Nico Weber9d8ec5a2015-08-04 13:00:21 -070068 private:
69 FX_BOOL ExecuteDocumentOpenAction(const CPDF_Action& action,
70 CPDFSDK_Document* pDocument,
Tom Sepez6c7508b2016-01-20 14:59:25 -080071 std::set<CPDF_Dictionary*>* visited);
Nico Weber9d8ec5a2015-08-04 13:00:21 -070072 FX_BOOL ExecuteDocumentPageAction(const CPDF_Action& action,
73 CPDF_AAction::AActionType type,
74 CPDFSDK_Document* pDocument,
Tom Sepez6c7508b2016-01-20 14:59:25 -080075 std::set<CPDF_Dictionary*>* visited);
Nico Weber9d8ec5a2015-08-04 13:00:21 -070076 FX_BOOL ExecuteFieldAction(const CPDF_Action& action,
77 CPDF_AAction::AActionType type,
78 CPDFSDK_Document* pDocument,
79 CPDF_FormField* pFormField,
80 PDFSDK_FieldAction& data,
Tom Sepez6c7508b2016-01-20 14:59:25 -080081 std::set<CPDF_Dictionary*>* visited);
Nico Weber9d8ec5a2015-08-04 13:00:21 -070082 FX_BOOL ExecuteScreenAction(const CPDF_Action& action,
83 CPDF_AAction::AActionType type,
84 CPDFSDK_Document* pDocument,
85 CPDFSDK_Annot* pScreen,
Tom Sepez6c7508b2016-01-20 14:59:25 -080086 std::set<CPDF_Dictionary*>* visited);
Nico Weber9d8ec5a2015-08-04 13:00:21 -070087 FX_BOOL ExecuteBookMark(const CPDF_Action& action,
88 CPDFSDK_Document* pDocument,
89 CPDF_Bookmark* pBookmark,
Tom Sepez6c7508b2016-01-20 14:59:25 -080090 std::set<CPDF_Dictionary*>* visited);
Nico Weber9d8ec5a2015-08-04 13:00:21 -070091 FX_BOOL ExecuteLinkAction(const CPDF_Action& action,
92 CPDFSDK_Document* pDocument,
Tom Sepez6c7508b2016-01-20 14:59:25 -080093 std::set<CPDF_Dictionary*>* visited);
Lei Zhanga6d9f0e2015-06-13 00:48:38 -070094
Nico Weber9d8ec5a2015-08-04 13:00:21 -070095 void DoAction_NoJs(const CPDF_Action& action, CPDFSDK_Document* pDocument);
96 void RunDocumentPageJavaScript(CPDFSDK_Document* pDocument,
97 CPDF_AAction::AActionType type,
98 const CFX_WideString& script);
99 void RunDocumentOpenJavaScript(CPDFSDK_Document* pDocument,
100 const CFX_WideString& sScriptName,
101 const CFX_WideString& script);
102 void RunFieldJavaScript(CPDFSDK_Document* pDocument,
103 CPDF_FormField* pFormField,
104 CPDF_AAction::AActionType type,
105 PDFSDK_FieldAction& data,
106 const CFX_WideString& script);
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700107
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700108 FX_BOOL IsValidField(CPDFSDK_Document* pDocument,
109 CPDF_Dictionary* pFieldDict);
110 FX_BOOL IsValidDocView(CPDFSDK_Document* pDocument);
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700111
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700112 void DoAction_GoTo(CPDFSDK_Document* pDocument, const CPDF_Action& action);
113 void DoAction_GoToR(CPDFSDK_Document* pDocument, const CPDF_Action& action);
114 void DoAction_Launch(CPDFSDK_Document* pDocument, const CPDF_Action& action);
115 void DoAction_URI(CPDFSDK_Document* pDocument, const CPDF_Action& action);
116 void DoAction_Named(CPDFSDK_Document* pDocument, const CPDF_Action& action);
117 void DoAction_SetOCGState(CPDFSDK_Document* pDocument,
118 const CPDF_Action& action);
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700119
Lei Zhangaa8bf7e2015-12-24 19:13:32 -0800120 std::unique_ptr<CPDFSDK_FormActionHandler> m_pFormActionHandler;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700121};
122
Tom Sepez19922bb2015-05-28 13:23:12 -0700123#endif // FPDFSDK_INCLUDE_FSDK_ACTIONHANDLER_H_