Use override in more classes in fpdfsdk/
[pdfium.git] / fpdfsdk / include / javascript / IJavaScript.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_JAVASCRIPT_IJAVASCRIPT_H_
8 #define FPDFSDK_INCLUDE_JAVASCRIPT_IJAVASCRIPT_H_
9
10 #include "../../../core/include/fxcrt/fx_string.h"
11 #include "../../../core/include/fxcrt/fx_system.h"
12
13 class CPDF_Bookmark;
14 class CPDF_FormField;
15 class CPDFSDK_Annot;
16 class CPDFSDK_Document;
17
18 class IFXJS_Context {
19  public:
20   virtual FX_BOOL Compile(const CFX_WideString& script,
21                           CFX_WideString& info) = 0;
22   virtual FX_BOOL RunScript(const CFX_WideString& script,
23                             CFX_WideString& info) = 0;
24
25   virtual void OnApp_Init() = 0;
26
27   virtual void OnDoc_Open(CPDFSDK_Document* pDoc,
28                           const CFX_WideString& strTargetName) = 0;
29   virtual void OnDoc_WillPrint(CPDFSDK_Document* pDoc) = 0;
30   virtual void OnDoc_DidPrint(CPDFSDK_Document* pDoc) = 0;
31   virtual void OnDoc_WillSave(CPDFSDK_Document* pDoc) = 0;
32   virtual void OnDoc_DidSave(CPDFSDK_Document* pDoc) = 0;
33   virtual void OnDoc_WillClose(CPDFSDK_Document* pDoc) = 0;
34
35   virtual void OnPage_Open(CPDFSDK_Document* pTarget) = 0;
36   virtual void OnPage_Close(CPDFSDK_Document* pTarget) = 0;
37   virtual void OnPage_InView(CPDFSDK_Document* pTarget) = 0;
38   virtual void OnPage_OutView(CPDFSDK_Document* pTarget) = 0;
39
40   virtual void OnField_MouseDown(FX_BOOL bModifier,
41                                  FX_BOOL bShift,
42                                  CPDF_FormField* pTarget) = 0;
43   virtual void OnField_MouseEnter(FX_BOOL bModifier,
44                                   FX_BOOL bShift,
45                                   CPDF_FormField* pTarget) = 0;
46   virtual void OnField_MouseExit(FX_BOOL bModifier,
47                                  FX_BOOL bShift,
48                                  CPDF_FormField* pTarget) = 0;
49   virtual void OnField_MouseUp(FX_BOOL bModifier,
50                                FX_BOOL bShift,
51                                CPDF_FormField* pTarget) = 0;
52   virtual void OnField_Focus(FX_BOOL bModifier,
53                              FX_BOOL bShift,
54                              CPDF_FormField* pTarget,
55                              const CFX_WideString& Value) = 0;
56   virtual void OnField_Blur(FX_BOOL bModifier,
57                             FX_BOOL bShift,
58                             CPDF_FormField* pTarget,
59                             const CFX_WideString& Value) = 0;
60
61   virtual void OnField_Calculate(CPDF_FormField* pSource,
62                                  CPDF_FormField* pTarget,
63                                  CFX_WideString& Value,
64                                  FX_BOOL& bRc) = 0;
65   virtual void OnField_Format(CPDF_FormField* pTarget,
66                               CFX_WideString& Value,
67                               FX_BOOL bWillCommit) = 0;
68   virtual void OnField_Keystroke(CFX_WideString& strChange,
69                                  const CFX_WideString& strChangeEx,
70                                  FX_BOOL KeyDown,
71                                  FX_BOOL bModifier,
72                                  int& nSelEnd,
73                                  int& nSelStart,
74                                  FX_BOOL bShift,
75                                  CPDF_FormField* pTarget,
76                                  CFX_WideString& Value,
77                                  FX_BOOL bWillCommit,
78                                  FX_BOOL bFieldFull,
79                                  FX_BOOL& bRc) = 0;
80   virtual void OnField_Validate(CFX_WideString& strChange,
81                                 const CFX_WideString& strChangeEx,
82                                 FX_BOOL bKeyDown,
83                                 FX_BOOL bModifier,
84                                 FX_BOOL bShift,
85                                 CPDF_FormField* pTarget,
86                                 CFX_WideString& Value,
87                                 FX_BOOL& bRc) = 0;
88
89   virtual void OnScreen_Focus(FX_BOOL bModifier,
90                               FX_BOOL bShift,
91                               CPDFSDK_Annot* pScreen) = 0;
92   virtual void OnScreen_Blur(FX_BOOL bModifier,
93                              FX_BOOL bShift,
94                              CPDFSDK_Annot* pScreen) = 0;
95   virtual void OnScreen_Open(FX_BOOL bModifier,
96                              FX_BOOL bShift,
97                              CPDFSDK_Annot* pScreen) = 0;
98   virtual void OnScreen_Close(FX_BOOL bModifier,
99                               FX_BOOL bShift,
100                               CPDFSDK_Annot* pScreen) = 0;
101   virtual void OnScreen_MouseDown(FX_BOOL bModifier,
102                                   FX_BOOL bShift,
103                                   CPDFSDK_Annot* pScreen) = 0;
104   virtual void OnScreen_MouseUp(FX_BOOL bModifier,
105                                 FX_BOOL bShift,
106                                 CPDFSDK_Annot* pScreen) = 0;
107   virtual void OnScreen_MouseEnter(FX_BOOL bModifier,
108                                    FX_BOOL bShift,
109                                    CPDFSDK_Annot* pScreen) = 0;
110   virtual void OnScreen_MouseExit(FX_BOOL bModifier,
111                                   FX_BOOL bShift,
112                                   CPDFSDK_Annot* pScreen) = 0;
113   virtual void OnScreen_InView(FX_BOOL bModifier,
114                                FX_BOOL bShift,
115                                CPDFSDK_Annot* pScreen) = 0;
116   virtual void OnScreen_OutView(FX_BOOL bModifier,
117                                 FX_BOOL bShift,
118                                 CPDFSDK_Annot* pScreen) = 0;
119
120   virtual void OnBookmark_MouseUp(CPDF_Bookmark* pBookMark) = 0;
121   virtual void OnLink_MouseUp(CPDFSDK_Document* pTarget) = 0;
122
123   virtual void OnMenu_Exec(CPDFSDK_Document* pTarget,
124                            const CFX_WideString&) = 0;
125   virtual void OnBatchExec(CPDFSDK_Document* pTarget) = 0;
126   virtual void OnConsole_Exec() = 0;
127   virtual void OnExternal_Exec() = 0;
128
129   virtual void EnableMessageBox(FX_BOOL bEnable) = 0;
130
131  protected:
132   virtual ~IFXJS_Context() {}
133 };
134
135 class IFXJS_Runtime {
136  public:
137   virtual IFXJS_Context* NewContext() = 0;
138   virtual void ReleaseContext(IFXJS_Context* pContext) = 0;
139   virtual IFXJS_Context* GetCurrentContext() = 0;
140
141   virtual void SetReaderDocument(CPDFSDK_Document* pReaderDoc) = 0;
142   virtual CPDFSDK_Document* GetReaderDocument() = 0;
143
144  protected:
145   virtual ~IFXJS_Runtime() {}
146 };
147
148 class CPDFDoc_Environment;
149 class CJS_GlobalData;
150
151 class CJS_RuntimeFactory {
152  public:
153   CJS_RuntimeFactory()
154       : m_bInit(FALSE), m_nRef(0), m_pGlobalData(NULL), m_nGlobalDataCount(0) {}
155   ~CJS_RuntimeFactory();
156   IFXJS_Runtime* NewJSRuntime(CPDFDoc_Environment* pApp);
157   void DeleteJSRuntime(IFXJS_Runtime* pRuntime);
158   void AddRef();
159   void Release();
160
161   CJS_GlobalData* NewGlobalData(CPDFDoc_Environment* pApp);
162   void ReleaseGlobalData();
163
164  private:
165   FX_BOOL m_bInit;
166   int m_nRef;
167   CJS_GlobalData* m_pGlobalData;
168   int32_t m_nGlobalDataCount;
169 };
170
171 #endif  // FPDFSDK_INCLUDE_JAVASCRIPT_IJAVASCRIPT_H_