OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #ifndef FPDFSDK_INCLUDE_JAVASCRIPT_JS_CONTEXT_H_ | 7 #ifndef FPDFSDK_INCLUDE_JAVASCRIPT_JS_CONTEXT_H_ |
8 #define FPDFSDK_INCLUDE_JAVASCRIPT_JS_CONTEXT_H_ | 8 #define FPDFSDK_INCLUDE_JAVASCRIPT_JS_CONTEXT_H_ |
9 | 9 |
10 #include "../../../core/include/fxcrt/fx_system.h" | 10 #include "../../../core/include/fxcrt/fx_system.h" |
11 #include "../../../core/include/fxcrt/fx_string.h" | 11 #include "../../../core/include/fxcrt/fx_string.h" |
12 #include "IJavaScript.h" | 12 #include "IJavaScript.h" |
13 | 13 |
14 class CJS_EventHandler; | 14 class CJS_EventHandler; |
15 class CJS_Runtime; | 15 class CJS_Runtime; |
16 | 16 |
17 class CJS_Context : public IFXJS_Context { | 17 class CJS_Context : public IFXJS_Context { |
18 public: | 18 public: |
19 CJS_Context(CJS_Runtime* pRuntime); | 19 CJS_Context(CJS_Runtime* pRuntime); |
20 virtual ~CJS_Context(); | 20 ~CJS_Context() override; |
21 | 21 |
22 public: | 22 // IFXJS_Context |
23 virtual FX_BOOL Compile(const CFX_WideString& script, CFX_WideString& info); | 23 FX_BOOL Compile(const CFX_WideString& script, CFX_WideString& info) override; |
24 virtual FX_BOOL RunScript(const CFX_WideString& script, CFX_WideString& info); | 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; } |
25 | 123 |
26 public: | |
27 virtual void OnApp_Init(); | |
28 | |
29 virtual void OnDoc_Open(CPDFSDK_Document* pDoc, | |
30 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, | |
43 FX_BOOL bShift, | |
44 CPDF_FormField* pTarget); | |
45 virtual void OnField_MouseEnter(FX_BOOL bModifier, | |
46 FX_BOOL bShift, | |
47 CPDF_FormField* pTarget); | |
48 virtual void OnField_MouseExit(FX_BOOL bModifier, | |
49 FX_BOOL bShift, | |
50 CPDF_FormField* pTarget); | |
51 virtual void OnField_MouseUp(FX_BOOL bModifier, | |
52 FX_BOOL bShift, | |
53 CPDF_FormField* pTarget); | |
54 virtual void OnField_Focus(FX_BOOL bModifier, | |
55 FX_BOOL bShift, | |
56 CPDF_FormField* pTarget, | |
57 const CFX_WideString& Value); | |
58 virtual void OnField_Blur(FX_BOOL bModifier, | |
59 FX_BOOL bShift, | |
60 CPDF_FormField* pTarget, | |
61 const CFX_WideString& Value); | |
62 | |
63 virtual void OnField_Calculate(CPDF_FormField* pSource, | |
64 CPDF_FormField* pTarget, | |
65 CFX_WideString& Value, | |
66 FX_BOOL& bRc); | |
67 virtual void OnField_Format(CPDF_FormField* pTarget, | |
68 CFX_WideString& Value, | |
69 FX_BOOL bWillCommit); | |
70 virtual void OnField_Keystroke(CFX_WideString& strChange, | |
71 const CFX_WideString& strChangeEx, | |
72 FX_BOOL bKeyDown, | |
73 FX_BOOL bModifier, | |
74 int& nSelEnd, | |
75 int& nSelStart, | |
76 FX_BOOL bShift, | |
77 CPDF_FormField* pTarget, | |
78 CFX_WideString& Value, | |
79 FX_BOOL bWillCommit, | |
80 FX_BOOL bFieldFull, | |
81 FX_BOOL& bRc); | |
82 virtual void OnField_Validate(CFX_WideString& strChange, | |
83 const CFX_WideString& strChangeEx, | |
84 FX_BOOL bKeyDown, | |
85 FX_BOOL bModifier, | |
86 FX_BOOL bShift, | |
87 CPDF_FormField* pTarget, | |
88 CFX_WideString& Value, | |
89 FX_BOOL& bRc); | |
90 | |
91 virtual void OnScreen_Focus(FX_BOOL bModifier, | |
92 FX_BOOL bShift, | |
93 CPDFSDK_Annot* pScreen); | |
94 virtual void OnScreen_Blur(FX_BOOL bModifier, | |
95 FX_BOOL bShift, | |
96 CPDFSDK_Annot* pScreen); | |
97 virtual void OnScreen_Open(FX_BOOL bModifier, | |
98 FX_BOOL bShift, | |
99 CPDFSDK_Annot* pScreen); | |
100 virtual void OnScreen_Close(FX_BOOL bModifier, | |
101 FX_BOOL bShift, | |
102 CPDFSDK_Annot* pScreen); | |
103 virtual void OnScreen_MouseDown(FX_BOOL bModifier, | |
104 FX_BOOL bShift, | |
105 CPDFSDK_Annot* pScreen); | |
106 virtual void OnScreen_MouseUp(FX_BOOL bModifier, | |
107 FX_BOOL bShift, | |
108 CPDFSDK_Annot* pScreen); | |
109 virtual void OnScreen_MouseEnter(FX_BOOL bModifier, | |
110 FX_BOOL bShift, | |
111 CPDFSDK_Annot* pScreen); | |
112 virtual void OnScreen_MouseExit(FX_BOOL bModifier, | |
113 FX_BOOL bShift, | |
114 CPDFSDK_Annot* pScreen); | |
115 virtual void OnScreen_InView(FX_BOOL bModifier, | |
116 FX_BOOL bShift, | |
117 CPDFSDK_Annot* pScreen); | |
118 virtual void OnScreen_OutView(FX_BOOL bModifier, | |
119 FX_BOOL bShift, | |
120 CPDFSDK_Annot* pScreen); | |
121 | |
122 virtual void OnBookmark_MouseUp(CPDF_Bookmark* pBookMark); | |
123 virtual void OnLink_MouseUp(CPDFSDK_Document* pTarget); | |
124 | |
125 virtual void OnMenu_Exec(CPDFSDK_Document* pTarget, | |
126 const CFX_WideString& strTargetName); | |
127 virtual void OnBatchExec(CPDFSDK_Document* pTarget); | |
128 virtual void OnConsole_Exec(); | |
129 virtual void OnExternal_Exec(); | |
130 | |
131 virtual void EnableMessageBox(FX_BOOL bEnable) { m_bMsgBoxEnable = bEnable; } | |
132 FX_BOOL IsMsgBoxEnabled() const { return m_bMsgBoxEnable; } | 124 FX_BOOL IsMsgBoxEnabled() const { return m_bMsgBoxEnable; } |
133 | 125 |
134 public: | |
135 CPDFDoc_Environment* GetReaderApp(); | 126 CPDFDoc_Environment* GetReaderApp(); |
136 CJS_Runtime* GetJSRuntime() { return m_pRuntime; } | 127 CJS_Runtime* GetJSRuntime() { return m_pRuntime; } |
137 | 128 |
138 FX_BOOL DoJob(int nMode, const CFX_WideString& script, CFX_WideString& info); | 129 FX_BOOL DoJob(int nMode, const CFX_WideString& script, CFX_WideString& info); |
139 | 130 |
140 CJS_EventHandler* GetEventHandler() { return m_pEventHandler; }; | 131 CJS_EventHandler* GetEventHandler() { return m_pEventHandler; }; |
141 CPDFSDK_Document* GetReaderDocument(); | 132 CPDFSDK_Document* GetReaderDocument(); |
142 | 133 |
143 private: | 134 private: |
144 CJS_Runtime* m_pRuntime; | 135 CJS_Runtime* m_pRuntime; |
145 CJS_EventHandler* m_pEventHandler; | 136 CJS_EventHandler* m_pEventHandler; |
146 | |
147 FX_BOOL m_bBusy; | 137 FX_BOOL m_bBusy; |
148 FX_BOOL m_bMsgBoxEnable; | 138 FX_BOOL m_bMsgBoxEnable; |
149 }; | 139 }; |
150 | 140 |
151 #endif // FPDFSDK_INCLUDE_JAVASCRIPT_JS_CONTEXT_H_ | 141 #endif // FPDFSDK_INCLUDE_JAVASCRIPT_JS_CONTEXT_H_ |
OLD | NEW |