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_IJAVASCRIPT_H_ | 7 #ifndef FPDFSDK_INCLUDE_JAVASCRIPT_IJAVASCRIPT_H_ |
8 #define FPDFSDK_INCLUDE_JAVASCRIPT_IJAVASCRIPT_H_ | 8 #define FPDFSDK_INCLUDE_JAVASCRIPT_IJAVASCRIPT_H_ |
9 | 9 |
10 #include "../../../core/include/fxcrt/fx_string.h" | 10 #include "../../../core/include/fxcrt/fx_string.h" |
11 #include "../../../core/include/fxcrt/fx_system.h" | 11 #include "../../../core/include/fxcrt/fx_system.h" |
12 #include "../../../xfa/include/fxjse/fxjse.h" | 12 #include "../../../xfa/include/fxjse/fxjse.h" |
13 | 13 |
14 class CPDFDoc_Environment; | 14 class CPDFDoc_Environment; |
15 class CPDFSDK_Annot; | 15 class CPDFSDK_Annot; |
16 class CPDFSDK_Document; | 16 class CPDFSDK_Document; |
17 class CPDF_Bookmark; | 17 class CPDF_Bookmark; |
18 class CPDF_FormField; | 18 class CPDF_FormField; |
19 | 19 |
| 20 // Records the details of an event and triggers JS execution for it. |
20 class IJS_Context { | 21 class IJS_Context { |
21 public: | 22 public: |
22 virtual FX_BOOL RunScript(const CFX_WideString& script, | 23 virtual FX_BOOL RunScript(const CFX_WideString& script, |
23 CFX_WideString& info) = 0; | 24 CFX_WideString* info) = 0; |
24 | 25 |
25 virtual void OnApp_Init() = 0; | 26 virtual void OnApp_Init() = 0; |
26 | 27 |
27 virtual void OnDoc_Open(CPDFSDK_Document* pDoc, | 28 virtual void OnDoc_Open(CPDFSDK_Document* pDoc, |
28 const CFX_WideString& strTargetName) = 0; | 29 const CFX_WideString& strTargetName) = 0; |
29 virtual void OnDoc_WillPrint(CPDFSDK_Document* pDoc) = 0; | 30 virtual void OnDoc_WillPrint(CPDFSDK_Document* pDoc) = 0; |
30 virtual void OnDoc_DidPrint(CPDFSDK_Document* pDoc) = 0; | 31 virtual void OnDoc_DidPrint(CPDFSDK_Document* pDoc) = 0; |
31 virtual void OnDoc_WillSave(CPDFSDK_Document* pDoc) = 0; | 32 virtual void OnDoc_WillSave(CPDFSDK_Document* pDoc) = 0; |
32 virtual void OnDoc_DidSave(CPDFSDK_Document* pDoc) = 0; | 33 virtual void OnDoc_DidSave(CPDFSDK_Document* pDoc) = 0; |
33 virtual void OnDoc_WillClose(CPDFSDK_Document* pDoc) = 0; | 34 virtual void OnDoc_WillClose(CPDFSDK_Document* pDoc) = 0; |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 virtual void OnBatchExec(CPDFSDK_Document* pTarget) = 0; | 126 virtual void OnBatchExec(CPDFSDK_Document* pTarget) = 0; |
126 virtual void OnConsole_Exec() = 0; | 127 virtual void OnConsole_Exec() = 0; |
127 virtual void OnExternal_Exec() = 0; | 128 virtual void OnExternal_Exec() = 0; |
128 | 129 |
129 virtual void EnableMessageBox(FX_BOOL bEnable) = 0; | 130 virtual void EnableMessageBox(FX_BOOL bEnable) = 0; |
130 | 131 |
131 protected: | 132 protected: |
132 virtual ~IJS_Context() {} | 133 virtual ~IJS_Context() {} |
133 }; | 134 }; |
134 | 135 |
| 136 // Owns the FJXS objects needed to actually execute JS. |
135 class IJS_Runtime { | 137 class IJS_Runtime { |
136 public: | 138 public: |
137 static void Initialize(unsigned int slot, void* isolate); | 139 static void Initialize(unsigned int slot, void* isolate); |
138 static IJS_Runtime* Create(CPDFDoc_Environment* pEnv); | 140 static IJS_Runtime* Create(CPDFDoc_Environment* pEnv); |
139 virtual ~IJS_Runtime() {} | 141 virtual ~IJS_Runtime() {} |
140 | 142 |
141 virtual IJS_Context* NewContext() = 0; | 143 virtual IJS_Context* NewContext() = 0; |
142 virtual void ReleaseContext(IJS_Context* pContext) = 0; | 144 virtual void ReleaseContext(IJS_Context* pContext) = 0; |
143 virtual IJS_Context* GetCurrentContext() = 0; | 145 virtual IJS_Context* GetCurrentContext() = 0; |
144 virtual void SetReaderDocument(CPDFSDK_Document* pReaderDoc) = 0; | 146 virtual void SetReaderDocument(CPDFSDK_Document* pReaderDoc) = 0; |
145 | 147 |
146 virtual CPDFSDK_Document* GetReaderDocument() = 0; | 148 virtual CPDFSDK_Document* GetReaderDocument() = 0; |
| 149 virtual int Execute(IJS_Context* cc, |
| 150 const wchar_t* script, |
| 151 CFX_WideString* info) = 0; |
147 | 152 |
148 virtual FX_BOOL GetHValueByName(const CFX_ByteStringC& utf8Name, | 153 virtual FX_BOOL GetHValueByName(const CFX_ByteStringC& utf8Name, |
149 FXJSE_HVALUE hValue) = 0; | 154 FXJSE_HVALUE hValue) = 0; |
150 virtual FX_BOOL SetHValueByName(const CFX_ByteStringC& utf8Name, | 155 virtual FX_BOOL SetHValueByName(const CFX_ByteStringC& utf8Name, |
151 FXJSE_HVALUE hValue) = 0; | 156 FXJSE_HVALUE hValue) = 0; |
152 | 157 |
153 protected: | 158 protected: |
154 IJS_Runtime() {} | 159 IJS_Runtime() {} |
155 }; | 160 }; |
156 | 161 |
157 #endif // FPDFSDK_INCLUDE_JAVASCRIPT_IJAVASCRIPT_H_ | 162 #endif // FPDFSDK_INCLUDE_JAVASCRIPT_IJAVASCRIPT_H_ |
OLD | NEW |