FX Bool considered harmful, part 3
[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 {
19 public:
20         CJS_Context(CJS_Runtime* pRuntime);
21         virtual ~CJS_Context();
22
23 public:
24         virtual bool                            Compile(const CFX_WideString& script, CFX_WideString& info);
25         virtual bool                            RunScript(const CFX_WideString& script, CFX_WideString& info);
26
27 public:
28         virtual void                            OnApp_Init();
29
30         virtual void                            OnDoc_Open(CPDFSDK_Document* pDoc, const CFX_WideString& strTargetName);
31         virtual void                            OnDoc_WillPrint(CPDFSDK_Document* pDoc);
32         virtual void                            OnDoc_DidPrint(CPDFSDK_Document* pDoc);
33         virtual void                            OnDoc_WillSave(CPDFSDK_Document* pDoc);
34         virtual void                            OnDoc_DidSave(CPDFSDK_Document* pDoc);
35         virtual void                            OnDoc_WillClose(CPDFSDK_Document* pDoc);
36
37         virtual void                            OnPage_Open(CPDFSDK_Document* pTarget);
38         virtual void                            OnPage_Close(CPDFSDK_Document* pTarget);
39         virtual void                            OnPage_InView(CPDFSDK_Document* pTarget);
40         virtual void                            OnPage_OutView(CPDFSDK_Document* pTarget);
41
42         virtual void                            OnField_MouseDown(bool bModifier, bool bShift, CPDF_FormField *pTarget);
43         virtual void                            OnField_MouseEnter(bool bModifier, bool bShift, CPDF_FormField *pTarget);
44         virtual void                            OnField_MouseExit(bool bModifier, bool bShift, CPDF_FormField *pTarget);
45         virtual void                            OnField_MouseUp(bool bModifier, bool bShift, CPDF_FormField *pTarget);
46         virtual void                            OnField_Focus(bool bModifier, bool bShift, CPDF_FormField* pTarget, const CFX_WideString& Value);
47         virtual void                            OnField_Blur(bool bModifier, bool bShift, CPDF_FormField* pTarget, const CFX_WideString& Value);
48
49         virtual void                            OnField_Calculate(CPDF_FormField* pSource, CPDF_FormField* pTarget, CFX_WideString& Value, bool& bRc);
50         virtual void                            OnField_Format(CPDF_FormField* pTarget, CFX_WideString& Value, bool bWillCommit);
51         virtual void                            OnField_Keystroke(CFX_WideString& strChange, const CFX_WideString& strChangeEx,
52                                                                         bool bKeyDown, bool bModifier, int &nSelEnd,int &nSelStart, bool bShift,
53                                                                         CPDF_FormField* pTarget, CFX_WideString& Value, bool bWillCommit,
54                                                                         bool bFieldFull, bool &bRc);
55         virtual void                            OnField_Validate(CFX_WideString& strChange, const CFX_WideString& strChangeEx, bool bKeyDown,
56                                                                         bool bModifier, bool bShift, CPDF_FormField* pTarget, CFX_WideString& Value, bool& bRc);
57
58         virtual void                            OnScreen_Focus(bool bModifier, bool bShift, CPDFSDK_Annot* pScreen);
59         virtual void                            OnScreen_Blur(bool bModifier, bool bShift, CPDFSDK_Annot* pScreen);
60         virtual void                            OnScreen_Open(bool bModifier, bool bShift, CPDFSDK_Annot* pScreen);
61         virtual void                            OnScreen_Close(bool bModifier, bool bShift, CPDFSDK_Annot* pScreen);
62         virtual void                            OnScreen_MouseDown(bool bModifier, bool bShift, CPDFSDK_Annot* pScreen);
63         virtual void                            OnScreen_MouseUp(bool bModifier, bool bShift, CPDFSDK_Annot* pScreen);
64         virtual void                            OnScreen_MouseEnter(bool bModifier, bool bShift, CPDFSDK_Annot* pScreen);
65         virtual void                            OnScreen_MouseExit(bool bModifier, bool bShift, CPDFSDK_Annot* pScreen);
66         virtual void                            OnScreen_InView(bool bModifier, bool bShift, CPDFSDK_Annot* pScreen);
67         virtual void                            OnScreen_OutView(bool bModifier, bool bShift, CPDFSDK_Annot* pScreen);
68
69         virtual void                            OnBookmark_MouseUp(CPDF_Bookmark* pBookMark);
70         virtual void                            OnLink_MouseUp(CPDFSDK_Document* pTarget);
71
72         virtual void                            OnMenu_Exec(CPDFSDK_Document* pTarget, const CFX_WideString& strTargetName);
73         virtual void                            OnBatchExec(CPDFSDK_Document* pTarget);
74         virtual void                            OnConsole_Exec();
75         virtual void                            OnExternal_Exec();
76
77         virtual void                            EnableMessageBox(bool bEnable) {m_bMsgBoxEnable = bEnable;}
78         bool                                            IsMsgBoxEnabled() const {return m_bMsgBoxEnable;}
79
80 public:
81         CPDFDoc_Environment*                    GetReaderApp();
82         CJS_Runtime*                            GetJSRuntime(){return m_pRuntime;}
83
84         bool                                            DoJob(int nMode, const CFX_WideString& script, CFX_WideString& info);
85
86         CJS_EventHandler*                       GetEventHandler(){return m_pEventHandler;};
87         CPDFSDK_Document*                       GetReaderDocument();
88
89 private:
90         CJS_Runtime*                            m_pRuntime;
91         CJS_EventHandler*                       m_pEventHandler;
92
93         bool                                            m_bBusy;
94         bool                                            m_bMsgBoxEnable;
95 };
96
97 #endif  // FPDFSDK_INCLUDE_JAVASCRIPT_JS_CONTEXT_H_