blob: 45ff5571a5cc964d7d19e0af38e4059a4c690263 [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
dsinclaire530fb72016-04-06 12:09:37 -070013#include "core/fpdfdoc/include/fpdf_doc.h"
Dan Sinclaira8a28e02016-03-23 15:41:39 -040014#include "core/fxcrt/include/fx_string.h"
Dan Sinclairefbc1912016-02-17 16:54:43 -050015#include "fpdfsdk/include/fsdk_baseform.h"
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070016
Tom Sepez245c80e2015-04-08 16:19:33 -070017class CPDFSDK_Annot;
18class CPDFSDK_Document;
19class CPDF_Bookmark;
20class CPDF_Dictionary;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070021
Nico Weber9d8ec5a2015-08-04 13:00:21 -070022class CPDFSDK_FormActionHandler {
23 public:
24 FX_BOOL DoAction_Hide(const CPDF_Action& action, CPDFSDK_Document* pDocument);
25 FX_BOOL DoAction_SubmitForm(const CPDF_Action& action,
26 CPDFSDK_Document* pDocument);
27 FX_BOOL DoAction_ResetForm(const CPDF_Action& action,
28 CPDFSDK_Document* pDocument);
29 FX_BOOL DoAction_ImportData(const CPDF_Action& action,
30 CPDFSDK_Document* pDocument);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070031};
32
Nico Weber9d8ec5a2015-08-04 13:00:21 -070033class CPDFSDK_ActionHandler {
34 public:
Tom Sepez3b5f1242015-09-01 14:06:55 -070035 CPDFSDK_ActionHandler();
weili625ad662016-06-15 11:21:33 -070036 ~CPDFSDK_ActionHandler();
Tom Sepez2c286192015-06-18 12:47:11 -070037
Nico Weber9d8ec5a2015-08-04 13:00:21 -070038 FX_BOOL DoAction_DocOpen(const CPDF_Action& action,
39 CPDFSDK_Document* pDocument);
40 FX_BOOL DoAction_JavaScript(const CPDF_Action& JsAction,
41 CFX_WideString csJSName,
42 CPDFSDK_Document* pDocument);
43 FX_BOOL DoAction_Page(const CPDF_Action& action,
44 enum CPDF_AAction::AActionType eType,
45 CPDFSDK_Document* pDocument);
46 FX_BOOL DoAction_Document(const CPDF_Action& action,
47 enum CPDF_AAction::AActionType eType,
48 CPDFSDK_Document* pDocument);
49 FX_BOOL DoAction_BookMark(CPDF_Bookmark* pBookMark,
50 const CPDF_Action& action,
51 CPDF_AAction::AActionType type,
52 CPDFSDK_Document* pDocument);
53 FX_BOOL DoAction_Screen(const CPDF_Action& action,
54 CPDF_AAction::AActionType type,
55 CPDFSDK_Document* pDocument,
56 CPDFSDK_Annot* pScreen);
57 FX_BOOL DoAction_Link(const CPDF_Action& action, CPDFSDK_Document* pDocument);
58 FX_BOOL DoAction_Field(const CPDF_Action& action,
59 CPDF_AAction::AActionType type,
60 CPDFSDK_Document* pDocument,
61 CPDF_FormField* pFormField,
62 PDFSDK_FieldAction& data);
63 FX_BOOL DoAction_FieldJavaScript(const CPDF_Action& JsAction,
64 CPDF_AAction::AActionType type,
65 CPDFSDK_Document* pDocument,
66 CPDF_FormField* pFormField,
67 PDFSDK_FieldAction& data);
Lei Zhanga6d9f0e2015-06-13 00:48:38 -070068
Nico Weber9d8ec5a2015-08-04 13:00:21 -070069 private:
70 FX_BOOL ExecuteDocumentOpenAction(const CPDF_Action& action,
71 CPDFSDK_Document* pDocument,
Tom Sepez6c7508b2016-01-20 14:59:25 -080072 std::set<CPDF_Dictionary*>* visited);
Nico Weber9d8ec5a2015-08-04 13:00:21 -070073 FX_BOOL ExecuteDocumentPageAction(const CPDF_Action& action,
74 CPDF_AAction::AActionType type,
75 CPDFSDK_Document* pDocument,
Tom Sepez6c7508b2016-01-20 14:59:25 -080076 std::set<CPDF_Dictionary*>* visited);
Nico Weber9d8ec5a2015-08-04 13:00:21 -070077 FX_BOOL ExecuteFieldAction(const CPDF_Action& action,
78 CPDF_AAction::AActionType type,
79 CPDFSDK_Document* pDocument,
80 CPDF_FormField* pFormField,
81 PDFSDK_FieldAction& data,
Tom Sepez6c7508b2016-01-20 14:59:25 -080082 std::set<CPDF_Dictionary*>* visited);
Nico Weber9d8ec5a2015-08-04 13:00:21 -070083 FX_BOOL ExecuteScreenAction(const CPDF_Action& action,
84 CPDF_AAction::AActionType type,
85 CPDFSDK_Document* pDocument,
86 CPDFSDK_Annot* pScreen,
Tom Sepez6c7508b2016-01-20 14:59:25 -080087 std::set<CPDF_Dictionary*>* visited);
Nico Weber9d8ec5a2015-08-04 13:00:21 -070088 FX_BOOL ExecuteBookMark(const CPDF_Action& action,
89 CPDFSDK_Document* pDocument,
90 CPDF_Bookmark* pBookmark,
Tom Sepez6c7508b2016-01-20 14:59:25 -080091 std::set<CPDF_Dictionary*>* visited);
Nico Weber9d8ec5a2015-08-04 13:00:21 -070092 FX_BOOL ExecuteLinkAction(const CPDF_Action& action,
93 CPDFSDK_Document* pDocument,
Tom Sepez6c7508b2016-01-20 14:59:25 -080094 std::set<CPDF_Dictionary*>* visited);
Lei Zhanga6d9f0e2015-06-13 00:48:38 -070095
Nico Weber9d8ec5a2015-08-04 13:00:21 -070096 void DoAction_NoJs(const CPDF_Action& action, CPDFSDK_Document* pDocument);
97 void RunDocumentPageJavaScript(CPDFSDK_Document* pDocument,
98 CPDF_AAction::AActionType type,
99 const CFX_WideString& script);
100 void RunDocumentOpenJavaScript(CPDFSDK_Document* pDocument,
101 const CFX_WideString& sScriptName,
102 const CFX_WideString& script);
103 void RunFieldJavaScript(CPDFSDK_Document* pDocument,
104 CPDF_FormField* pFormField,
105 CPDF_AAction::AActionType type,
106 PDFSDK_FieldAction& data,
107 const CFX_WideString& script);
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700108
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700109 FX_BOOL IsValidField(CPDFSDK_Document* pDocument,
110 CPDF_Dictionary* pFieldDict);
111 FX_BOOL IsValidDocView(CPDFSDK_Document* pDocument);
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700112
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700113 void DoAction_GoTo(CPDFSDK_Document* pDocument, const CPDF_Action& action);
114 void DoAction_GoToR(CPDFSDK_Document* pDocument, const CPDF_Action& action);
115 void DoAction_Launch(CPDFSDK_Document* pDocument, const CPDF_Action& action);
116 void DoAction_URI(CPDFSDK_Document* pDocument, const CPDF_Action& action);
117 void DoAction_Named(CPDFSDK_Document* pDocument, const CPDF_Action& action);
118 void DoAction_SetOCGState(CPDFSDK_Document* pDocument,
119 const CPDF_Action& action);
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700120
Lei Zhangaa8bf7e2015-12-24 19:13:32 -0800121 std::unique_ptr<CPDFSDK_FormActionHandler> m_pFormActionHandler;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700122};
123
Tom Sepez19922bb2015-05-28 13:23:12 -0700124#endif // FPDFSDK_INCLUDE_FSDK_ACTIONHANDLER_H_