Merge to XFA: Fix ALL the include guards.
[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 FX_BOOL                         Compile(const CFX_WideString& script, CFX_WideString& info);
25         virtual FX_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(FX_BOOL bModifier, FX_BOOL bShift, CPDF_FormField *pTarget);
43         virtual void                            OnField_MouseEnter(FX_BOOL bModifier, FX_BOOL bShift, CPDF_FormField *pTarget);
44         virtual void                            OnField_MouseExit(FX_BOOL bModifier, FX_BOOL bShift, CPDF_FormField *pTarget);
45         virtual void                            OnField_MouseUp(FX_BOOL bModifier, FX_BOOL bShift, CPDF_FormField *pTarget);
46         virtual void                            OnField_Focus(FX_BOOL bModifier, FX_BOOL bShift, CPDF_FormField* pTarget, const CFX_WideString& Value);
47         virtual void                            OnField_Blur(FX_BOOL bModifier, FX_BOOL bShift, CPDF_FormField* pTarget, const CFX_WideString& Value);
48
49         virtual void                            OnField_Calculate(CPDF_FormField* pSource, CPDF_FormField* pTarget, CFX_WideString& Value, FX_BOOL& bRc);
50         virtual void                            OnField_Format(int nCommitKey, CPDF_FormField* pTarget, CFX_WideString& Value, FX_BOOL bWillCommit);
51         virtual void                            OnField_Keystroke(int nCommitKey, CFX_WideString& strChange, const CFX_WideString& strChangeEx,
52                                                                         FX_BOOL bKeyDown, FX_BOOL bModifier, int &nSelEnd,int &nSelStart, FX_BOOL bShift,
53                                                                         CPDF_FormField* pTarget, CFX_WideString& Value, FX_BOOL bWillCommit, 
54                                                                         FX_BOOL bFieldFull, FX_BOOL &bRc);
55         virtual void                            OnField_Validate(CFX_WideString& strChange, const CFX_WideString& strChangeEx, FX_BOOL bKeyDown,
56                                                                         FX_BOOL bModifier, FX_BOOL bShift, CPDF_FormField* pTarget, CFX_WideString& Value, FX_BOOL& bRc);
57
58         virtual void                            OnScreen_Focus(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen);
59         virtual void                            OnScreen_Blur(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen);
60         virtual void                            OnScreen_Open(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen);
61         virtual void                            OnScreen_Close(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen);
62         virtual void                            OnScreen_MouseDown(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen);
63         virtual void                            OnScreen_MouseUp(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen);
64         virtual void                            OnScreen_MouseEnter(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen);
65         virtual void                            OnScreen_MouseExit(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen);
66         virtual void                            OnScreen_InView(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen);
67         virtual void                            OnScreen_OutView(FX_BOOL bModifier, FX_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(FX_BOOL bEnable) {m_bMsgBoxEnable = bEnable;}
78         FX_BOOL                                         IsMsgBoxEnabled() const {return m_bMsgBoxEnable;}
79
80 public:
81         CPDFDoc_Environment*            GetReaderApp();
82         CJS_Runtime*                            GetJSRuntime(){return m_pRuntime;}
83
84         FX_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         FX_BOOL                                         m_bBusy;        
94         FX_BOOL                                         m_bMsgBoxEnable;
95 };
96
97 #endif  // FPDFSDK_INCLUDE_JAVASCRIPT_JS_CONTEXT_H_