• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2016 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 FXJS_IJS_EVENT_CONTEXT_H_
8 #define FXJS_IJS_EVENT_CONTEXT_H_
9 
10 #include "core/fxcrt/fx_string.h"
11 #include "core/fxcrt/fx_system.h"
12 
13 class CPDF_Bookmark;
14 class CPDF_FormField;
15 class CPDFSDK_Annot;
16 class CPDFSDK_FormFillEnvironment;
17 
18 // Records the details of an event and triggers JS execution for it. There
19 // can be more than one of these at any given time, as JS callbacks to C++
20 // may trigger new events on top of one another.
21 class IJS_EventContext {
22  public:
23   virtual bool RunScript(const WideString& script, WideString* info) = 0;
24 
25   virtual void OnApp_Init() = 0;
26 
27   virtual void OnDoc_Open(CPDFSDK_FormFillEnvironment* pFormFillEnv,
28                           const WideString& strTargetName) = 0;
29   virtual void OnDoc_WillPrint(CPDFSDK_FormFillEnvironment* pFormFillEnv) = 0;
30   virtual void OnDoc_DidPrint(CPDFSDK_FormFillEnvironment* pFormFillEnv) = 0;
31   virtual void OnDoc_WillSave(CPDFSDK_FormFillEnvironment* pFormFillEnv) = 0;
32   virtual void OnDoc_DidSave(CPDFSDK_FormFillEnvironment* pFormFillEnv) = 0;
33   virtual void OnDoc_WillClose(CPDFSDK_FormFillEnvironment* pFormFillEnv) = 0;
34 
35   virtual void OnPage_Open(CPDFSDK_FormFillEnvironment* pFormFillEnv) = 0;
36   virtual void OnPage_Close(CPDFSDK_FormFillEnvironment* pFormFillEnv) = 0;
37   virtual void OnPage_InView(CPDFSDK_FormFillEnvironment* pFormFillEnv) = 0;
38   virtual void OnPage_OutView(CPDFSDK_FormFillEnvironment* pFormFillEnv) = 0;
39 
40   virtual void OnField_MouseDown(bool bModifier,
41                                  bool bShift,
42                                  CPDF_FormField* pTarget) = 0;
43   virtual void OnField_MouseEnter(bool bModifier,
44                                   bool bShift,
45                                   CPDF_FormField* pTarget) = 0;
46   virtual void OnField_MouseExit(bool bModifier,
47                                  bool bShift,
48                                  CPDF_FormField* pTarget) = 0;
49   virtual void OnField_MouseUp(bool bModifier,
50                                bool bShift,
51                                CPDF_FormField* pTarget) = 0;
52   virtual void OnField_Focus(bool bModifier,
53                              bool bShift,
54                              CPDF_FormField* pTarget,
55                              const WideString& Value) = 0;
56   virtual void OnField_Blur(bool bModifier,
57                             bool bShift,
58                             CPDF_FormField* pTarget,
59                             const WideString& Value) = 0;
60 
61   virtual void OnField_Calculate(CPDF_FormField* pSource,
62                                  CPDF_FormField* pTarget,
63                                  WideString& Value,
64                                  bool& bRc) = 0;
65   virtual void OnField_Format(CPDF_FormField* pTarget,
66                               WideString& Value,
67                               bool bWillCommit) = 0;
68   virtual void OnField_Keystroke(WideString& strChange,
69                                  const WideString& strChangeEx,
70                                  bool KeyDown,
71                                  bool bModifier,
72                                  int& nSelEnd,
73                                  int& nSelStart,
74                                  bool bShift,
75                                  CPDF_FormField* pTarget,
76                                  WideString& Value,
77                                  bool bWillCommit,
78                                  bool bFieldFull,
79                                  bool& bRc) = 0;
80   virtual void OnField_Validate(WideString& strChange,
81                                 const WideString& strChangeEx,
82                                 bool bKeyDown,
83                                 bool bModifier,
84                                 bool bShift,
85                                 CPDF_FormField* pTarget,
86                                 WideString& Value,
87                                 bool& bRc) = 0;
88 
89   virtual void OnScreen_Focus(bool bModifier,
90                               bool bShift,
91                               CPDFSDK_Annot* pScreen) = 0;
92   virtual void OnScreen_Blur(bool bModifier,
93                              bool bShift,
94                              CPDFSDK_Annot* pScreen) = 0;
95   virtual void OnScreen_Open(bool bModifier,
96                              bool bShift,
97                              CPDFSDK_Annot* pScreen) = 0;
98   virtual void OnScreen_Close(bool bModifier,
99                               bool bShift,
100                               CPDFSDK_Annot* pScreen) = 0;
101   virtual void OnScreen_MouseDown(bool bModifier,
102                                   bool bShift,
103                                   CPDFSDK_Annot* pScreen) = 0;
104   virtual void OnScreen_MouseUp(bool bModifier,
105                                 bool bShift,
106                                 CPDFSDK_Annot* pScreen) = 0;
107   virtual void OnScreen_MouseEnter(bool bModifier,
108                                    bool bShift,
109                                    CPDFSDK_Annot* pScreen) = 0;
110   virtual void OnScreen_MouseExit(bool bModifier,
111                                   bool bShift,
112                                   CPDFSDK_Annot* pScreen) = 0;
113   virtual void OnScreen_InView(bool bModifier,
114                                bool bShift,
115                                CPDFSDK_Annot* pScreen) = 0;
116   virtual void OnScreen_OutView(bool bModifier,
117                                 bool bShift,
118                                 CPDFSDK_Annot* pScreen) = 0;
119 
120   virtual void OnBookmark_MouseUp(CPDF_Bookmark* pBookMark) = 0;
121   virtual void OnLink_MouseUp(CPDFSDK_FormFillEnvironment* pFormFillEnv) = 0;
122 
123   virtual void OnMenu_Exec(CPDFSDK_FormFillEnvironment* pFormFillEnv,
124                            const WideString&) = 0;
125   virtual void OnBatchExec(CPDFSDK_FormFillEnvironment* pFormFillEnv) = 0;
126   virtual void OnConsole_Exec() = 0;
127   virtual void OnExternal_Exec() = 0;
128 
129  protected:
~IJS_EventContext()130   virtual ~IJS_EventContext() {}
131 };
132 
133 #endif  // FXJS_IJS_EVENT_CONTEXT_H_
134