Add unit test for top-level bookmarks.
[pdfium.git] / fpdfsdk / include / fsdk_actionhandler.h
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_INCLUDE_FSDK_ACTIONHANDLER_H_
8 #define FPDFSDK_INCLUDE_FSDK_ACTIONHANDLER_H_
9
10 #include "../../core/include/fpdfdoc/fpdf_doc.h"
11 #include "../../core/include/fxcrt/fx_string.h"
12 #include "../../third_party/base/nonstd_unique_ptr.h"
13 #include "fsdk_baseform.h"
14
15 class CFX_PtrList;
16 class CPDFSDK_Annot;
17 class CPDFSDK_Document;
18 class CPDF_Bookmark;
19 class CPDF_Dictionary;
20
21 class 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);
30 };
31
32 class CPDFSDK_ActionHandler {
33  public:
34   CPDFSDK_ActionHandler();
35
36   FX_BOOL DoAction_DocOpen(const CPDF_Action& action,
37                            CPDFSDK_Document* pDocument);
38   FX_BOOL DoAction_JavaScript(const CPDF_Action& JsAction,
39                               CFX_WideString csJSName,
40                               CPDFSDK_Document* pDocument);
41   FX_BOOL DoAction_Page(const CPDF_Action& action,
42                         enum CPDF_AAction::AActionType eType,
43                         CPDFSDK_Document* pDocument);
44   FX_BOOL DoAction_Document(const CPDF_Action& action,
45                             enum CPDF_AAction::AActionType eType,
46                             CPDFSDK_Document* pDocument);
47   FX_BOOL DoAction_BookMark(CPDF_Bookmark* pBookMark,
48                             const CPDF_Action& action,
49                             CPDF_AAction::AActionType type,
50                             CPDFSDK_Document* pDocument);
51   FX_BOOL DoAction_Screen(const CPDF_Action& action,
52                           CPDF_AAction::AActionType type,
53                           CPDFSDK_Document* pDocument,
54                           CPDFSDK_Annot* pScreen);
55   FX_BOOL DoAction_Link(const CPDF_Action& action, CPDFSDK_Document* pDocument);
56   FX_BOOL DoAction_Field(const CPDF_Action& action,
57                          CPDF_AAction::AActionType type,
58                          CPDFSDK_Document* pDocument,
59                          CPDF_FormField* pFormField,
60                          PDFSDK_FieldAction& data);
61   FX_BOOL DoAction_FieldJavaScript(const CPDF_Action& JsAction,
62                                    CPDF_AAction::AActionType type,
63                                    CPDFSDK_Document* pDocument,
64                                    CPDF_FormField* pFormField,
65                                    PDFSDK_FieldAction& data);
66
67  private:
68   FX_BOOL ExecuteDocumentOpenAction(const CPDF_Action& action,
69                                     CPDFSDK_Document* pDocument,
70                                     CFX_PtrList& list);
71   FX_BOOL ExecuteDocumentPageAction(const CPDF_Action& action,
72                                     CPDF_AAction::AActionType type,
73                                     CPDFSDK_Document* pDocument,
74                                     CFX_PtrList& list);
75   FX_BOOL ExecuteFieldAction(const CPDF_Action& action,
76                              CPDF_AAction::AActionType type,
77                              CPDFSDK_Document* pDocument,
78                              CPDF_FormField* pFormField,
79                              PDFSDK_FieldAction& data,
80                              CFX_PtrList& list);
81   FX_BOOL ExecuteScreenAction(const CPDF_Action& action,
82                               CPDF_AAction::AActionType type,
83                               CPDFSDK_Document* pDocument,
84                               CPDFSDK_Annot* pScreen,
85                               CFX_PtrList& list);
86   FX_BOOL ExecuteBookMark(const CPDF_Action& action,
87                           CPDFSDK_Document* pDocument,
88                           CPDF_Bookmark* pBookmark,
89                           CFX_PtrList& list);
90   FX_BOOL ExecuteLinkAction(const CPDF_Action& action,
91                             CPDFSDK_Document* pDocument,
92                             CFX_PtrList& list);
93
94   void DoAction_NoJs(const CPDF_Action& action, CPDFSDK_Document* pDocument);
95   void RunDocumentPageJavaScript(CPDFSDK_Document* pDocument,
96                                  CPDF_AAction::AActionType type,
97                                  const CFX_WideString& script);
98   void RunDocumentOpenJavaScript(CPDFSDK_Document* pDocument,
99                                  const CFX_WideString& sScriptName,
100                                  const CFX_WideString& script);
101   void RunFieldJavaScript(CPDFSDK_Document* pDocument,
102                           CPDF_FormField* pFormField,
103                           CPDF_AAction::AActionType type,
104                           PDFSDK_FieldAction& data,
105                           const CFX_WideString& script);
106
107   FX_BOOL IsValidField(CPDFSDK_Document* pDocument,
108                        CPDF_Dictionary* pFieldDict);
109   FX_BOOL IsValidDocView(CPDFSDK_Document* pDocument);
110
111   void DoAction_GoTo(CPDFSDK_Document* pDocument, const CPDF_Action& action);
112   void DoAction_GoToR(CPDFSDK_Document* pDocument, const CPDF_Action& action);
113   void DoAction_Launch(CPDFSDK_Document* pDocument, const CPDF_Action& action);
114   void DoAction_URI(CPDFSDK_Document* pDocument, const CPDF_Action& action);
115   void DoAction_Named(CPDFSDK_Document* pDocument, const CPDF_Action& action);
116   void DoAction_SetOCGState(CPDFSDK_Document* pDocument,
117                             const CPDF_Action& action);
118
119   nonstd::unique_ptr<CPDFSDK_FormActionHandler> m_pFormActionHandler;
120 };
121
122 #endif  // FPDFSDK_INCLUDE_FSDK_ACTIONHANDLER_H_