a527d19544182720c77c3c4c5a9e0c419593ecd7
[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 CPDFDoc_Environment;
14 class CPDFSDK_Annot;
15 class CPDFSDK_Document;
16 class CPDF_Bookmark;
17 class CPDF_FormField;
18
19 class IJS_Context {
20  public:
21   virtual FX_BOOL RunScript(const CFX_WideString& script,
22                             CFX_WideString& info) = 0;
23
24   virtual void OnApp_Init() = 0;
25
26   virtual void OnDoc_Open(CPDFSDK_Document* pDoc,
27                           const CFX_WideString& strTargetName) = 0;
28   virtual void OnDoc_WillPrint(CPDFSDK_Document* pDoc) = 0;
29   virtual void OnDoc_DidPrint(CPDFSDK_Document* pDoc) = 0;
30   virtual void OnDoc_WillSave(CPDFSDK_Document* pDoc) = 0;
31   virtual void OnDoc_DidSave(CPDFSDK_Document* pDoc) = 0;
32   virtual void OnDoc_WillClose(CPDFSDK_Document* pDoc) = 0;
33
34   virtual void OnPage_Open(CPDFSDK_Document* pTarget) = 0;
35   virtual void OnPage_Close(CPDFSDK_Document* pTarget) = 0;
36   virtual void OnPage_InView(CPDFSDK_Document* pTarget) = 0;
37   virtual void OnPage_OutView(CPDFSDK_Document* pTarget) = 0;
38
39   virtual void OnField_MouseDown(FX_BOOL bModifier,
40                                  FX_BOOL bShift,
41                                  CPDF_FormField* pTarget) = 0;
42   virtual void OnField_MouseEnter(FX_BOOL bModifier,
43                                   FX_BOOL bShift,
44                                   CPDF_FormField* pTarget) = 0;
45   virtual void OnField_MouseExit(FX_BOOL bModifier,
46                                  FX_BOOL bShift,
47                                  CPDF_FormField* pTarget) = 0;
48   virtual void OnField_MouseUp(FX_BOOL bModifier,
49                                FX_BOOL bShift,
50                                CPDF_FormField* pTarget) = 0;
51   virtual void OnField_Focus(FX_BOOL bModifier,
52                              FX_BOOL bShift,
53                              CPDF_FormField* pTarget,
54                              const CFX_WideString& Value) = 0;
55   virtual void OnField_Blur(FX_BOOL bModifier,
56                             FX_BOOL bShift,
57                             CPDF_FormField* pTarget,
58                             const CFX_WideString& Value) = 0;
59
60   virtual void OnField_Calculate(CPDF_FormField* pSource,
61                                  CPDF_FormField* pTarget,
62                                  CFX_WideString& Value,
63                                  FX_BOOL& bRc) = 0;
64   virtual void OnField_Format(CPDF_FormField* pTarget,
65                               CFX_WideString& Value,
66                               FX_BOOL bWillCommit) = 0;
67   virtual void OnField_Keystroke(CFX_WideString& strChange,
68                                  const CFX_WideString& strChangeEx,
69                                  FX_BOOL KeyDown,
70                                  FX_BOOL bModifier,
71                                  int& nSelEnd,
72                                  int& nSelStart,
73                                  FX_BOOL bShift,
74                                  CPDF_FormField* pTarget,
75                                  CFX_WideString& Value,
76                                  FX_BOOL bWillCommit,
77                                  FX_BOOL bFieldFull,
78                                  FX_BOOL& bRc) = 0;
79   virtual void OnField_Validate(CFX_WideString& strChange,
80                                 const CFX_WideString& strChangeEx,
81                                 FX_BOOL bKeyDown,
82                                 FX_BOOL bModifier,
83                                 FX_BOOL bShift,
84                                 CPDF_FormField* pTarget,
85                                 CFX_WideString& Value,
86                                 FX_BOOL& bRc) = 0;
87
88   virtual void OnScreen_Focus(FX_BOOL bModifier,
89                               FX_BOOL bShift,
90                               CPDFSDK_Annot* pScreen) = 0;
91   virtual void OnScreen_Blur(FX_BOOL bModifier,
92                              FX_BOOL bShift,
93                              CPDFSDK_Annot* pScreen) = 0;
94   virtual void OnScreen_Open(FX_BOOL bModifier,
95                              FX_BOOL bShift,
96                              CPDFSDK_Annot* pScreen) = 0;
97   virtual void OnScreen_Close(FX_BOOL bModifier,
98                               FX_BOOL bShift,
99                               CPDFSDK_Annot* pScreen) = 0;
100   virtual void OnScreen_MouseDown(FX_BOOL bModifier,
101                                   FX_BOOL bShift,
102                                   CPDFSDK_Annot* pScreen) = 0;
103   virtual void OnScreen_MouseUp(FX_BOOL bModifier,
104                                 FX_BOOL bShift,
105                                 CPDFSDK_Annot* pScreen) = 0;
106   virtual void OnScreen_MouseEnter(FX_BOOL bModifier,
107                                    FX_BOOL bShift,
108                                    CPDFSDK_Annot* pScreen) = 0;
109   virtual void OnScreen_MouseExit(FX_BOOL bModifier,
110                                   FX_BOOL bShift,
111                                   CPDFSDK_Annot* pScreen) = 0;
112   virtual void OnScreen_InView(FX_BOOL bModifier,
113                                FX_BOOL bShift,
114                                CPDFSDK_Annot* pScreen) = 0;
115   virtual void OnScreen_OutView(FX_BOOL bModifier,
116                                 FX_BOOL bShift,
117                                 CPDFSDK_Annot* pScreen) = 0;
118
119   virtual void OnBookmark_MouseUp(CPDF_Bookmark* pBookMark) = 0;
120   virtual void OnLink_MouseUp(CPDFSDK_Document* pTarget) = 0;
121
122   virtual void OnMenu_Exec(CPDFSDK_Document* pTarget,
123                            const CFX_WideString&) = 0;
124   virtual void OnBatchExec(CPDFSDK_Document* pTarget) = 0;
125   virtual void OnConsole_Exec() = 0;
126   virtual void OnExternal_Exec() = 0;
127
128   virtual void EnableMessageBox(FX_BOOL bEnable) = 0;
129
130  protected:
131   virtual ~IJS_Context() {}
132 };
133
134 class IJS_Runtime {
135  public:
136   static IJS_Runtime* Create(CPDFDoc_Environment* pEnv);
137   virtual ~IJS_Runtime() {}
138
139   virtual IJS_Context* NewContext() = 0;
140   virtual void ReleaseContext(IJS_Context* pContext) = 0;
141   virtual IJS_Context* GetCurrentContext() = 0;
142   virtual void SetReaderDocument(CPDFSDK_Document* pReaderDoc) = 0;
143   virtual CPDFSDK_Document* GetReaderDocument() = 0;
144
145  protected:
146   IJS_Runtime() {}
147 };
148
149 #endif  // FPDFSDK_INCLUDE_JAVASCRIPT_IJAVASCRIPT_H_