CJS_Context::compile unused
[pdfium.git] / fpdfsdk / include / javascript / JS_Context.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_JS_CONTEXT_H_
8 #define FPDFSDK_INCLUDE_JAVASCRIPT_JS_CONTEXT_H_
9
10 #include "../../../core/include/fxcrt/fx_system.h"
11 #include "../../../core/include/fxcrt/fx_string.h"
12 #include "IJavaScript.h"
13
14 class CJS_EventHandler;
15 class CJS_Runtime;
16
17 class CJS_Context : public IFXJS_Context {
18  public:
19   explicit CJS_Context(CJS_Runtime* pRuntime);
20   ~CJS_Context() override;
21
22   // IFXJS_Context
23   FX_BOOL RunScript(const CFX_WideString& script,
24                     CFX_WideString& info) override;
25   void OnApp_Init() override;
26   void OnDoc_Open(CPDFSDK_Document* pDoc,
27                   const CFX_WideString& strTargetName) override;
28   void OnDoc_WillPrint(CPDFSDK_Document* pDoc) override;
29   void OnDoc_DidPrint(CPDFSDK_Document* pDoc) override;
30   void OnDoc_WillSave(CPDFSDK_Document* pDoc) override;
31   void OnDoc_DidSave(CPDFSDK_Document* pDoc) override;
32   void OnDoc_WillClose(CPDFSDK_Document* pDoc) override;
33   void OnPage_Open(CPDFSDK_Document* pTarget) override;
34   void OnPage_Close(CPDFSDK_Document* pTarget) override;
35   void OnPage_InView(CPDFSDK_Document* pTarget) override;
36   void OnPage_OutView(CPDFSDK_Document* pTarget) override;
37   void OnField_MouseDown(FX_BOOL bModifier,
38                          FX_BOOL bShift,
39                          CPDF_FormField* pTarget) override;
40   void OnField_MouseEnter(FX_BOOL bModifier,
41                           FX_BOOL bShift,
42                           CPDF_FormField* pTarget) override;
43   void OnField_MouseExit(FX_BOOL bModifier,
44                          FX_BOOL bShift,
45                          CPDF_FormField* pTarget) override;
46   void OnField_MouseUp(FX_BOOL bModifier,
47                        FX_BOOL bShift,
48                        CPDF_FormField* pTarget) override;
49   void OnField_Focus(FX_BOOL bModifier,
50                      FX_BOOL bShift,
51                      CPDF_FormField* pTarget,
52                      const CFX_WideString& Value) override;
53   void OnField_Blur(FX_BOOL bModifier,
54                     FX_BOOL bShift,
55                     CPDF_FormField* pTarget,
56                     const CFX_WideString& Value) override;
57   void OnField_Calculate(CPDF_FormField* pSource,
58                          CPDF_FormField* pTarget,
59                          CFX_WideString& Value,
60                          FX_BOOL& bRc) override;
61   void OnField_Format(CPDF_FormField* pTarget,
62                       CFX_WideString& Value,
63                       FX_BOOL bWillCommit) override;
64   void OnField_Keystroke(CFX_WideString& strChange,
65                          const CFX_WideString& strChangeEx,
66                          FX_BOOL bKeyDown,
67                          FX_BOOL bModifier,
68                          int& nSelEnd,
69                          int& nSelStart,
70                          FX_BOOL bShift,
71                          CPDF_FormField* pTarget,
72                          CFX_WideString& Value,
73                          FX_BOOL bWillCommit,
74                          FX_BOOL bFieldFull,
75                          FX_BOOL& bRc) override;
76   void OnField_Validate(CFX_WideString& strChange,
77                         const CFX_WideString& strChangeEx,
78                         FX_BOOL bKeyDown,
79                         FX_BOOL bModifier,
80                         FX_BOOL bShift,
81                         CPDF_FormField* pTarget,
82                         CFX_WideString& Value,
83                         FX_BOOL& bRc) override;
84   void OnScreen_Focus(FX_BOOL bModifier,
85                       FX_BOOL bShift,
86                       CPDFSDK_Annot* pScreen) override;
87   void OnScreen_Blur(FX_BOOL bModifier,
88                      FX_BOOL bShift,
89                      CPDFSDK_Annot* pScreen) override;
90   void OnScreen_Open(FX_BOOL bModifier,
91                      FX_BOOL bShift,
92                      CPDFSDK_Annot* pScreen) override;
93   void OnScreen_Close(FX_BOOL bModifier,
94                       FX_BOOL bShift,
95                       CPDFSDK_Annot* pScreen) override;
96   void OnScreen_MouseDown(FX_BOOL bModifier,
97                           FX_BOOL bShift,
98                           CPDFSDK_Annot* pScreen) override;
99   void OnScreen_MouseUp(FX_BOOL bModifier,
100                         FX_BOOL bShift,
101                         CPDFSDK_Annot* pScreen) override;
102   void OnScreen_MouseEnter(FX_BOOL bModifier,
103                            FX_BOOL bShift,
104                            CPDFSDK_Annot* pScreen) override;
105   void OnScreen_MouseExit(FX_BOOL bModifier,
106                           FX_BOOL bShift,
107                           CPDFSDK_Annot* pScreen) override;
108   void OnScreen_InView(FX_BOOL bModifier,
109                        FX_BOOL bShift,
110                        CPDFSDK_Annot* pScreen) override;
111   void OnScreen_OutView(FX_BOOL bModifier,
112                         FX_BOOL bShift,
113                         CPDFSDK_Annot* pScreen) override;
114   void OnBookmark_MouseUp(CPDF_Bookmark* pBookMark) override;
115   void OnLink_MouseUp(CPDFSDK_Document* pTarget) override;
116   void OnMenu_Exec(CPDFSDK_Document* pTarget,
117                    const CFX_WideString& strTargetName) override;
118   void OnBatchExec(CPDFSDK_Document* pTarget) override;
119   void OnConsole_Exec() override;
120   void OnExternal_Exec() override;
121   void EnableMessageBox(FX_BOOL bEnable) override { m_bMsgBoxEnable = bEnable; }
122
123   FX_BOOL IsMsgBoxEnabled() const { return m_bMsgBoxEnable; }
124
125   CPDFDoc_Environment* GetReaderApp();
126   CJS_Runtime* GetJSRuntime() const { return m_pRuntime; }
127   CJS_EventHandler* GetEventHandler() const { return m_pEventHandler; }
128   CPDFSDK_Document* GetReaderDocument();
129
130  private:
131   CJS_Runtime* m_pRuntime;
132   CJS_EventHandler* m_pEventHandler;
133   FX_BOOL m_bBusy;
134   FX_BOOL m_bMsgBoxEnable;
135 };
136
137 #endif  // FPDFSDK_INCLUDE_JAVASCRIPT_JS_CONTEXT_H_