blob: dfb7d488c2cc17bc8d7a9e31dc4bdf2ca5696f1e [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
Tom Sepez245c80e2015-04-08 16:19:33 -070010#include "../../core/include/fpdfdoc/fpdf_doc.h"
11#include "../../core/include/fxcrt/fx_string.h"
Tom Sepez2c286192015-06-18 12:47:11 -070012#include "../../third_party/base/nonstd_unique_ptr.h"
Tom Sepez245c80e2015-04-08 16:19:33 -070013#include "fsdk_baseform.h"
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070014
Tom Sepez245c80e2015-04-08 16:19:33 -070015class CFX_PtrList;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070016class CPDFDoc_Environment;
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 -070021class IFXJS_Runtime;
22
Nico Weber9d8ec5a2015-08-04 13:00:21 -070023class CPDFSDK_FormActionHandler {
24 public:
25 FX_BOOL DoAction_Hide(const CPDF_Action& action, CPDFSDK_Document* pDocument);
26 FX_BOOL DoAction_SubmitForm(const CPDF_Action& action,
27 CPDFSDK_Document* pDocument);
28 FX_BOOL DoAction_ResetForm(const CPDF_Action& action,
29 CPDFSDK_Document* pDocument);
30 FX_BOOL DoAction_ImportData(const CPDF_Action& action,
31 CPDFSDK_Document* pDocument);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070032};
33
Nico Weber9d8ec5a2015-08-04 13:00:21 -070034class CPDFSDK_MediaActionHandler {
35 public:
36 FX_BOOL DoAction_Rendition(const CPDF_Action& action,
37 CPDFSDK_Document* pDocument);
38 FX_BOOL DoAction_Sound(const CPDF_Action& action,
39 CPDFSDK_Document* pDocument);
40 FX_BOOL DoAction_Movie(const CPDF_Action& action,
41 CPDFSDK_Document* pDocument);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070042};
43
Nico Weber9d8ec5a2015-08-04 13:00:21 -070044class CPDFSDK_ActionHandler {
45 public:
46 CPDFSDK_ActionHandler(CPDFDoc_Environment* pEvi);
Lei Zhanga6d9f0e2015-06-13 00:48:38 -070047
Nico Weber9d8ec5a2015-08-04 13:00:21 -070048 void SetMediaActionHandler(CPDFSDK_MediaActionHandler* pHandler);
Tom Sepez2c286192015-06-18 12:47:11 -070049
Nico Weber9d8ec5a2015-08-04 13:00:21 -070050 FX_BOOL DoAction_DocOpen(const CPDF_Action& action,
51 CPDFSDK_Document* pDocument);
52 FX_BOOL DoAction_JavaScript(const CPDF_Action& JsAction,
53 CFX_WideString csJSName,
54 CPDFSDK_Document* pDocument);
55 FX_BOOL DoAction_Page(const CPDF_Action& action,
56 enum CPDF_AAction::AActionType eType,
57 CPDFSDK_Document* pDocument);
58 FX_BOOL DoAction_Document(const CPDF_Action& action,
59 enum CPDF_AAction::AActionType eType,
60 CPDFSDK_Document* pDocument);
61 FX_BOOL DoAction_BookMark(CPDF_Bookmark* pBookMark,
62 const CPDF_Action& action,
63 CPDF_AAction::AActionType type,
64 CPDFSDK_Document* pDocument);
65 FX_BOOL DoAction_Screen(const CPDF_Action& action,
66 CPDF_AAction::AActionType type,
67 CPDFSDK_Document* pDocument,
68 CPDFSDK_Annot* pScreen);
69 FX_BOOL DoAction_Link(const CPDF_Action& action, CPDFSDK_Document* pDocument);
70 FX_BOOL DoAction_Field(const CPDF_Action& action,
71 CPDF_AAction::AActionType type,
72 CPDFSDK_Document* pDocument,
73 CPDF_FormField* pFormField,
74 PDFSDK_FieldAction& data);
75 FX_BOOL DoAction_FieldJavaScript(const CPDF_Action& JsAction,
76 CPDF_AAction::AActionType type,
77 CPDFSDK_Document* pDocument,
78 CPDF_FormField* pFormField,
79 PDFSDK_FieldAction& data);
Lei Zhanga6d9f0e2015-06-13 00:48:38 -070080
Nico Weber9d8ec5a2015-08-04 13:00:21 -070081 private:
82 FX_BOOL ExecuteDocumentOpenAction(const CPDF_Action& action,
83 CPDFSDK_Document* pDocument,
84 CFX_PtrList& list);
85 FX_BOOL ExecuteDocumentPageAction(const CPDF_Action& action,
86 CPDF_AAction::AActionType type,
87 CPDFSDK_Document* pDocument,
88 CFX_PtrList& list);
89 FX_BOOL ExecuteFieldAction(const CPDF_Action& action,
90 CPDF_AAction::AActionType type,
91 CPDFSDK_Document* pDocument,
92 CPDF_FormField* pFormField,
93 PDFSDK_FieldAction& data,
94 CFX_PtrList& list);
95 FX_BOOL ExecuteScreenAction(const CPDF_Action& action,
96 CPDF_AAction::AActionType type,
97 CPDFSDK_Document* pDocument,
98 CPDFSDK_Annot* pScreen,
99 CFX_PtrList& list);
100 FX_BOOL ExecuteBookMark(const CPDF_Action& action,
101 CPDFSDK_Document* pDocument,
102 CPDF_Bookmark* pBookmark,
103 CFX_PtrList& list);
104 FX_BOOL ExecuteLinkAction(const CPDF_Action& action,
105 CPDFSDK_Document* pDocument,
106 CFX_PtrList& list);
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700107
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700108 void DoAction_NoJs(const CPDF_Action& action, CPDFSDK_Document* pDocument);
109 void RunDocumentPageJavaScript(CPDFSDK_Document* pDocument,
110 CPDF_AAction::AActionType type,
111 const CFX_WideString& script);
112 void RunDocumentOpenJavaScript(CPDFSDK_Document* pDocument,
113 const CFX_WideString& sScriptName,
114 const CFX_WideString& script);
115 void RunFieldJavaScript(CPDFSDK_Document* pDocument,
116 CPDF_FormField* pFormField,
117 CPDF_AAction::AActionType type,
118 PDFSDK_FieldAction& data,
119 const CFX_WideString& script);
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700120
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700121 FX_BOOL IsValidField(CPDFSDK_Document* pDocument,
122 CPDF_Dictionary* pFieldDict);
123 FX_BOOL IsValidDocView(CPDFSDK_Document* pDocument);
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700124
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700125 void DoAction_GoTo(CPDFSDK_Document* pDocument, const CPDF_Action& action);
126 void DoAction_GoToR(CPDFSDK_Document* pDocument, const CPDF_Action& action);
127 void DoAction_Launch(CPDFSDK_Document* pDocument, const CPDF_Action& action);
128 void DoAction_URI(CPDFSDK_Document* pDocument, const CPDF_Action& action);
129 void DoAction_Named(CPDFSDK_Document* pDocument, const CPDF_Action& action);
130 void DoAction_SetOCGState(CPDFSDK_Document* pDocument,
131 const CPDF_Action& action);
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700132
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700133 nonstd::unique_ptr<CPDFSDK_FormActionHandler> m_pFormActionHandler;
134 CPDFSDK_MediaActionHandler* m_pMediaActionHandler;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700135};
136
Tom Sepez19922bb2015-05-28 13:23:12 -0700137#endif // FPDFSDK_INCLUDE_FSDK_ACTIONHANDLER_H_