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