OLD | NEW |
1 // Copyright 2015 PDFium Authors. All rights reserved. | 1 // Copyright 2015 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 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "fpdfsdk/javascript/ijs_context.h" | 9 #include "fpdfsdk/javascript/ijs_context.h" |
10 #include "fpdfsdk/javascript/ijs_runtime.h" | 10 #include "fpdfsdk/javascript/ijs_runtime.h" |
11 #include "third_party/base/ptr_util.h" | 11 #include "third_party/base/ptr_util.h" |
12 | 12 |
13 class CJS_ContextStub final : public IJS_Context { | 13 class CJS_ContextStub final : public IJS_Context { |
14 public: | 14 public: |
15 CJS_ContextStub() {} | 15 CJS_ContextStub() {} |
16 ~CJS_ContextStub() override {} | 16 ~CJS_ContextStub() override {} |
17 | 17 |
18 // IJS_Context: | 18 // IJS_Context: |
19 FX_BOOL RunScript(const CFX_WideString& script, | 19 bool RunScript(const CFX_WideString& script, CFX_WideString* info) override { |
20 CFX_WideString* info) override { | 20 return false; |
21 return FALSE; | |
22 } | 21 } |
23 | 22 |
24 void OnApp_Init() override {} | 23 void OnApp_Init() override {} |
25 void OnDoc_Open(CPDFSDK_FormFillEnvironment* pFormFillEnv, | 24 void OnDoc_Open(CPDFSDK_FormFillEnvironment* pFormFillEnv, |
26 const CFX_WideString& strTargetName) override {} | 25 const CFX_WideString& strTargetName) override {} |
27 void OnDoc_WillPrint(CPDFSDK_FormFillEnvironment* pFormFillEnv) override {} | 26 void OnDoc_WillPrint(CPDFSDK_FormFillEnvironment* pFormFillEnv) override {} |
28 void OnDoc_DidPrint(CPDFSDK_FormFillEnvironment* pFormFillEnv) override {} | 27 void OnDoc_DidPrint(CPDFSDK_FormFillEnvironment* pFormFillEnv) override {} |
29 void OnDoc_WillSave(CPDFSDK_FormFillEnvironment* pFormFillEnv) override {} | 28 void OnDoc_WillSave(CPDFSDK_FormFillEnvironment* pFormFillEnv) override {} |
30 void OnDoc_DidSave(CPDFSDK_FormFillEnvironment* pFormFillEnv) override {} | 29 void OnDoc_DidSave(CPDFSDK_FormFillEnvironment* pFormFillEnv) override {} |
31 void OnDoc_WillClose(CPDFSDK_FormFillEnvironment* pFormFillEnv) override {} | 30 void OnDoc_WillClose(CPDFSDK_FormFillEnvironment* pFormFillEnv) override {} |
32 void OnPage_Open(CPDFSDK_FormFillEnvironment* pFormFillEnv) override {} | 31 void OnPage_Open(CPDFSDK_FormFillEnvironment* pFormFillEnv) override {} |
33 void OnPage_Close(CPDFSDK_FormFillEnvironment* pFormFillEnv) override {} | 32 void OnPage_Close(CPDFSDK_FormFillEnvironment* pFormFillEnv) override {} |
34 void OnPage_InView(CPDFSDK_FormFillEnvironment* pFormFillEnv) override {} | 33 void OnPage_InView(CPDFSDK_FormFillEnvironment* pFormFillEnv) override {} |
35 void OnPage_OutView(CPDFSDK_FormFillEnvironment* pFormFillEnv) override {} | 34 void OnPage_OutView(CPDFSDK_FormFillEnvironment* pFormFillEnv) override {} |
36 void OnField_MouseDown(FX_BOOL bModifier, | 35 void OnField_MouseDown(bool bModifier, |
37 FX_BOOL bShift, | 36 bool bShift, |
38 CPDF_FormField* pTarget) override {} | 37 CPDF_FormField* pTarget) override {} |
39 void OnField_MouseEnter(FX_BOOL bModifier, | 38 void OnField_MouseEnter(bool bModifier, |
40 FX_BOOL bShift, | 39 bool bShift, |
41 CPDF_FormField* pTarget) override {} | 40 CPDF_FormField* pTarget) override {} |
42 void OnField_MouseExit(FX_BOOL bModifier, | 41 void OnField_MouseExit(bool bModifier, |
43 FX_BOOL bShift, | 42 bool bShift, |
44 CPDF_FormField* pTarget) override {} | 43 CPDF_FormField* pTarget) override {} |
45 void OnField_MouseUp(FX_BOOL bModifier, | 44 void OnField_MouseUp(bool bModifier, |
46 FX_BOOL bShift, | 45 bool bShift, |
47 CPDF_FormField* pTarget) override {} | 46 CPDF_FormField* pTarget) override {} |
48 void OnField_Focus(FX_BOOL bModifier, | 47 void OnField_Focus(bool bModifier, |
49 FX_BOOL bShift, | 48 bool bShift, |
50 CPDF_FormField* pTarget, | 49 CPDF_FormField* pTarget, |
51 const CFX_WideString& Value) override {} | 50 const CFX_WideString& Value) override {} |
52 void OnField_Blur(FX_BOOL bModifier, | 51 void OnField_Blur(bool bModifier, |
53 FX_BOOL bShift, | 52 bool bShift, |
54 CPDF_FormField* pTarget, | 53 CPDF_FormField* pTarget, |
55 const CFX_WideString& Value) override {} | 54 const CFX_WideString& Value) override {} |
56 void OnField_Calculate(CPDF_FormField* pSource, | 55 void OnField_Calculate(CPDF_FormField* pSource, |
57 CPDF_FormField* pTarget, | 56 CPDF_FormField* pTarget, |
58 CFX_WideString& Value, | 57 CFX_WideString& Value, |
59 FX_BOOL& bRc) override {} | 58 bool& bRc) override {} |
60 void OnField_Format(CPDF_FormField* pTarget, | 59 void OnField_Format(CPDF_FormField* pTarget, |
61 CFX_WideString& Value, | 60 CFX_WideString& Value, |
62 FX_BOOL bWillCommit) override {} | 61 bool bWillCommit) override {} |
63 void OnField_Keystroke(CFX_WideString& strChange, | 62 void OnField_Keystroke(CFX_WideString& strChange, |
64 const CFX_WideString& strChangeEx, | 63 const CFX_WideString& strChangeEx, |
65 FX_BOOL KeyDown, | 64 bool KeyDown, |
66 FX_BOOL bModifier, | 65 bool bModifier, |
67 int& nSelEnd, | 66 int& nSelEnd, |
68 int& nSelStart, | 67 int& nSelStart, |
69 FX_BOOL bShift, | 68 bool bShift, |
70 CPDF_FormField* pTarget, | 69 CPDF_FormField* pTarget, |
71 CFX_WideString& Value, | 70 CFX_WideString& Value, |
72 FX_BOOL bWillCommit, | 71 bool bWillCommit, |
73 FX_BOOL bFieldFull, | 72 bool bFieldFull, |
74 FX_BOOL& bRc) override {} | 73 bool& bRc) override {} |
75 void OnField_Validate(CFX_WideString& strChange, | 74 void OnField_Validate(CFX_WideString& strChange, |
76 const CFX_WideString& strChangeEx, | 75 const CFX_WideString& strChangeEx, |
77 FX_BOOL bKeyDown, | 76 bool bKeyDown, |
78 FX_BOOL bModifier, | 77 bool bModifier, |
79 FX_BOOL bShift, | 78 bool bShift, |
80 CPDF_FormField* pTarget, | 79 CPDF_FormField* pTarget, |
81 CFX_WideString& Value, | 80 CFX_WideString& Value, |
82 FX_BOOL& bRc) override {} | 81 bool& bRc) override {} |
83 void OnScreen_Focus(FX_BOOL bModifier, | 82 void OnScreen_Focus(bool bModifier, |
84 FX_BOOL bShift, | 83 bool bShift, |
85 CPDFSDK_Annot* pScreen) override {} | 84 CPDFSDK_Annot* pScreen) override {} |
86 void OnScreen_Blur(FX_BOOL bModifier, | 85 void OnScreen_Blur(bool bModifier, |
87 FX_BOOL bShift, | 86 bool bShift, |
88 CPDFSDK_Annot* pScreen) override {} | 87 CPDFSDK_Annot* pScreen) override {} |
89 void OnScreen_Open(FX_BOOL bModifier, | 88 void OnScreen_Open(bool bModifier, |
90 FX_BOOL bShift, | 89 bool bShift, |
91 CPDFSDK_Annot* pScreen) override {} | 90 CPDFSDK_Annot* pScreen) override {} |
92 void OnScreen_Close(FX_BOOL bModifier, | 91 void OnScreen_Close(bool bModifier, |
93 FX_BOOL bShift, | 92 bool bShift, |
94 CPDFSDK_Annot* pScreen) override {} | 93 CPDFSDK_Annot* pScreen) override {} |
95 void OnScreen_MouseDown(FX_BOOL bModifier, | 94 void OnScreen_MouseDown(bool bModifier, |
96 FX_BOOL bShift, | 95 bool bShift, |
97 CPDFSDK_Annot* pScreen) override {} | 96 CPDFSDK_Annot* pScreen) override {} |
98 void OnScreen_MouseUp(FX_BOOL bModifier, | 97 void OnScreen_MouseUp(bool bModifier, |
99 FX_BOOL bShift, | 98 bool bShift, |
100 CPDFSDK_Annot* pScreen) override {} | 99 CPDFSDK_Annot* pScreen) override {} |
101 void OnScreen_MouseEnter(FX_BOOL bModifier, | 100 void OnScreen_MouseEnter(bool bModifier, |
102 FX_BOOL bShift, | 101 bool bShift, |
103 CPDFSDK_Annot* pScreen) override {} | 102 CPDFSDK_Annot* pScreen) override {} |
104 void OnScreen_MouseExit(FX_BOOL bModifier, | 103 void OnScreen_MouseExit(bool bModifier, |
105 FX_BOOL bShift, | 104 bool bShift, |
106 CPDFSDK_Annot* pScreen) override {} | 105 CPDFSDK_Annot* pScreen) override {} |
107 void OnScreen_InView(FX_BOOL bModifier, | 106 void OnScreen_InView(bool bModifier, |
108 FX_BOOL bShift, | 107 bool bShift, |
109 CPDFSDK_Annot* pScreen) override {} | 108 CPDFSDK_Annot* pScreen) override {} |
110 void OnScreen_OutView(FX_BOOL bModifier, | 109 void OnScreen_OutView(bool bModifier, |
111 FX_BOOL bShift, | 110 bool bShift, |
112 CPDFSDK_Annot* pScreen) override {} | 111 CPDFSDK_Annot* pScreen) override {} |
113 void OnBookmark_MouseUp(CPDF_Bookmark* pBookMark) override {} | 112 void OnBookmark_MouseUp(CPDF_Bookmark* pBookMark) override {} |
114 void OnLink_MouseUp(CPDFSDK_FormFillEnvironment* pFormFillEnv) override {} | 113 void OnLink_MouseUp(CPDFSDK_FormFillEnvironment* pFormFillEnv) override {} |
115 void OnMenu_Exec(CPDFSDK_FormFillEnvironment* pFormFillEnv, | 114 void OnMenu_Exec(CPDFSDK_FormFillEnvironment* pFormFillEnv, |
116 const CFX_WideString&) override {} | 115 const CFX_WideString&) override {} |
117 void OnBatchExec(CPDFSDK_FormFillEnvironment* pFormFillEnv) override {} | 116 void OnBatchExec(CPDFSDK_FormFillEnvironment* pFormFillEnv) override {} |
118 void OnConsole_Exec() override {} | 117 void OnConsole_Exec() override {} |
119 void OnExternal_Exec() override {} | 118 void OnExternal_Exec() override {} |
120 }; | 119 }; |
121 | 120 |
(...skipping 10 matching lines...) Expand all Loading... |
132 } | 131 } |
133 | 132 |
134 IJS_Context* GetCurrentContext() override { return m_pContext.get(); } | 133 IJS_Context* GetCurrentContext() override { return m_pContext.get(); } |
135 void ReleaseContext(IJS_Context* pContext) override {} | 134 void ReleaseContext(IJS_Context* pContext) override {} |
136 | 135 |
137 CPDFSDK_FormFillEnvironment* GetFormFillEnv() const override { | 136 CPDFSDK_FormFillEnvironment* GetFormFillEnv() const override { |
138 return m_pFormFillEnv; | 137 return m_pFormFillEnv; |
139 } | 138 } |
140 | 139 |
141 #ifdef PDF_ENABLE_XFA | 140 #ifdef PDF_ENABLE_XFA |
142 FX_BOOL GetValueByName(const CFX_ByteStringC&, CFXJSE_Value*) override { | 141 bool GetValueByName(const CFX_ByteStringC&, CFXJSE_Value*) override { |
143 return FALSE; | 142 return false; |
144 } | 143 } |
145 | 144 |
146 FX_BOOL SetValueByName(const CFX_ByteStringC&, CFXJSE_Value*) override { | 145 bool SetValueByName(const CFX_ByteStringC&, CFXJSE_Value*) override { |
147 return FALSE; | 146 return false; |
148 } | 147 } |
149 #endif // PDF_ENABLE_XFA | 148 #endif // PDF_ENABLE_XFA |
150 | 149 |
151 int ExecuteScript(const CFX_WideString& script, | 150 int ExecuteScript(const CFX_WideString& script, |
152 CFX_WideString* info) override { | 151 CFX_WideString* info) override { |
153 return 0; | 152 return 0; |
154 } | 153 } |
155 | 154 |
156 protected: | 155 protected: |
157 CPDFSDK_FormFillEnvironment* m_pFormFillEnv; | 156 CPDFSDK_FormFillEnvironment* m_pFormFillEnv; |
158 std::unique_ptr<CJS_ContextStub> m_pContext; | 157 std::unique_ptr<CJS_ContextStub> m_pContext; |
159 }; | 158 }; |
160 | 159 |
161 // static | 160 // static |
162 void IJS_Runtime::Initialize(unsigned int slot, void* isolate) {} | 161 void IJS_Runtime::Initialize(unsigned int slot, void* isolate) {} |
163 | 162 |
164 // static | 163 // static |
165 void IJS_Runtime::Destroy() {} | 164 void IJS_Runtime::Destroy() {} |
166 | 165 |
167 // static | 166 // static |
168 IJS_Runtime* IJS_Runtime::Create(CPDFSDK_FormFillEnvironment* pFormFillEnv) { | 167 IJS_Runtime* IJS_Runtime::Create(CPDFSDK_FormFillEnvironment* pFormFillEnv) { |
169 return new CJS_RuntimeStub(pFormFillEnv); | 168 return new CJS_RuntimeStub(pFormFillEnv); |
170 } | 169 } |
OLD | NEW |