Initial commit.
[pdfium.git] / fpdfsdk / include / javascript / IJavaScript.h
1 // Copyright 2014 PDFium Authors. All rights reserved.\r
2 // Use of this source code is governed by a BSD-style license that can be\r
3 // found in the LICENSE file.\r
4  \r
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com\r
6 \r
7 #ifndef _IJAVASCRIPT_H_\r
8 #define _IJAVASCRIPT_H_\r
9 \r
10 class IFXJS_Context  \r
11 {\r
12 public:\r
13         virtual FX_BOOL                         Compile(const CFX_WideString& script, CFX_WideString& info) = 0;\r
14         virtual FX_BOOL                         RunScript(const CFX_WideString& script, CFX_WideString& info) = 0;\r
15 \r
16 public:\r
17         virtual void                            OnApp_Init() = 0;\r
18 \r
19         virtual void                            OnDoc_Open(CPDFSDK_Document* pDoc, const CFX_WideString& strTargetName) = 0;\r
20         virtual void                            OnDoc_WillPrint(CPDFSDK_Document* pDoc) = 0;\r
21         virtual void                            OnDoc_DidPrint(CPDFSDK_Document* pDoc) = 0;\r
22         virtual void                            OnDoc_WillSave(CPDFSDK_Document* pDoc) = 0;\r
23         virtual void                            OnDoc_DidSave(CPDFSDK_Document* pDoc) = 0;\r
24         virtual void                            OnDoc_WillClose(CPDFSDK_Document* pDoc) = 0;\r
25 \r
26         virtual void                            OnPage_Open(CPDFSDK_Document* pTarget) = 0;\r
27         virtual void                            OnPage_Close(CPDFSDK_Document* pTarget) = 0;\r
28         virtual void                            OnPage_InView(CPDFSDK_Document* pTarget) = 0;\r
29         virtual void                            OnPage_OutView(CPDFSDK_Document* pTarget) = 0;\r
30         \r
31         virtual void                            OnField_MouseDown(FX_BOOL bModifier, FX_BOOL bShift, CPDF_FormField* pTarget) = 0;\r
32         virtual void                            OnField_MouseEnter(FX_BOOL bModifier, FX_BOOL bShift, CPDF_FormField* pTarget) = 0;\r
33         virtual void                            OnField_MouseExit(FX_BOOL bModifier, FX_BOOL bShift, CPDF_FormField* pTarget) = 0;\r
34         virtual void                            OnField_MouseUp(FX_BOOL bModifier, FX_BOOL bShift, CPDF_FormField* pTarget) = 0;\r
35         virtual void                            OnField_Focus(FX_BOOL bModifier, FX_BOOL bShift, CPDF_FormField* pTarget, const CFX_WideString& Value) = 0;\r
36         virtual void                            OnField_Blur(FX_BOOL bModifier, FX_BOOL bShift, CPDF_FormField* pTarget, const CFX_WideString& Value) = 0;\r
37 \r
38         virtual void                            OnField_Calculate(CPDF_FormField* pSource, CPDF_FormField* pTarget, CFX_WideString& Value, FX_BOOL& bRc) = 0;\r
39         virtual void                            OnField_Format(int nCommitKey, CPDF_FormField* pTarget, CFX_WideString& Value, FX_BOOL bWillCommit) = 0;\r
40         virtual void                            OnField_Keystroke(int nCommitKey, CFX_WideString& strChange, const CFX_WideString& strChangeEx,\r
41                                                                         FX_BOOL KeyDown, FX_BOOL bModifier, int &nSelEnd,int &nSelStart, FX_BOOL bShift,\r
42                                                                         CPDF_FormField* pTarget, CFX_WideString& Value, FX_BOOL bWillCommit, \r
43                                                                         FX_BOOL bFieldFull, FX_BOOL &bRc) = 0;\r
44         virtual void                            OnField_Validate(CFX_WideString& strChange, const CFX_WideString& strChangeEx, FX_BOOL bKeyDown,\r
45                                                                         FX_BOOL bModifier, FX_BOOL bShift, CPDF_FormField* pTarget, CFX_WideString& Value, FX_BOOL& bRc) = 0;\r
46 \r
47         virtual void                            OnScreen_Focus(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen) = 0;\r
48         virtual void                            OnScreen_Blur(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen) = 0;\r
49         virtual void                            OnScreen_Open(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen) = 0;\r
50         virtual void                            OnScreen_Close(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen) = 0;\r
51         virtual void                            OnScreen_MouseDown(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen) = 0;\r
52         virtual void                            OnScreen_MouseUp(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen) = 0;\r
53         virtual void                            OnScreen_MouseEnter(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen) = 0;\r
54         virtual void                            OnScreen_MouseExit(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen) = 0;\r
55         virtual void                            OnScreen_InView(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen) = 0;\r
56         virtual void                            OnScreen_OutView(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen) = 0;\r
57 \r
58         virtual void                            OnBookmark_MouseUp(CPDF_Bookmark* pBookMark) = 0;\r
59         virtual void                            OnLink_MouseUp(CPDFSDK_Document* pTarget) = 0;\r
60 \r
61         virtual void                            OnMenu_Exec(CPDFSDK_Document* pTarget, const CFX_WideString &) = 0;\r
62         virtual void                            OnBatchExec(CPDFSDK_Document* pTarget) = 0;\r
63         virtual void                            OnConsole_Exec() = 0;\r
64         virtual void                            OnExternal_Exec() = 0;\r
65 \r
66         virtual void                            EnableMessageBox(FX_BOOL bEnable) = 0;\r
67 };\r
68 \r
69 class IFXJS_Runtime\r
70 {\r
71 public:\r
72         virtual IFXJS_Context*          NewContext() = 0;\r
73         virtual void                            ReleaseContext(IFXJS_Context * pContext) = 0;\r
74         virtual IFXJS_Context*          GetCurrentContext() = 0;\r
75 \r
76         virtual void                            SetReaderDocument(CPDFSDK_Document* pReaderDoc) = 0;\r
77         virtual CPDFSDK_Document*       GetReaderDocument() = 0;        \r
78 \r
79         virtual void                            GetObjectNames(CFX_WideStringArray& array) = 0;\r
80         virtual void                            GetObjectConsts(const CFX_WideString& swObjName, CFX_WideStringArray& array) = 0;\r
81         virtual void                            GetObjectProps(const CFX_WideString& swObjName, CFX_WideStringArray& array) = 0;\r
82         virtual void                            GetObjectMethods(const CFX_WideString& swObjName, CFX_WideStringArray& array) = 0;\r
83 \r
84         virtual void                            Exit() = 0;\r
85         virtual void                            Enter() = 0;\r
86         virtual FX_BOOL                         IsEntered() = 0;\r
87 };\r
88 \r
89 class CPDFDoc_Environment;\r
90 class CJS_GlobalData;\r
91 \r
92 class CJS_RuntimeFactory\r
93 {\r
94 public:\r
95         CJS_RuntimeFactory():m_bInit(FALSE),m_nRef(0),m_pGlobalData(NULL),m_nGlobalDataCount(0) {}\r
96         ~CJS_RuntimeFactory();\r
97         IFXJS_Runtime*                                  NewJSRuntime(CPDFDoc_Environment* pApp);\r
98         void                                                    DeleteJSRuntime(IFXJS_Runtime* pRuntime);\r
99         void                                                    AddRef();\r
100         void                                                    Release();\r
101 \r
102         CJS_GlobalData*                                 NewGlobalData(CPDFDoc_Environment* pApp);\r
103         void                                                    ReleaseGlobalData();\r
104 private:\r
105         FX_BOOL m_bInit;\r
106         int m_nRef;\r
107         CJS_GlobalData*                                 m_pGlobalData;\r
108         FX_INT32                                                m_nGlobalDataCount;\r
109 };\r
110 \r
111 #endif //_IJAVASCRIPT_H_\r
112 \r