Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(455)

Side by Side Diff: xfa/fxfa/parser/xfa_script_hostpseudomodel.cpp

Issue 2043153002: Remove various FXJSE Value methods. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « xfa/fxfa/parser/xfa_script_eventpseudomodel.cpp ('k') | xfa/fxfa/parser/xfa_script_imp.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "xfa/fxfa/parser/xfa_script_hostpseudomodel.h" 7 #include "xfa/fxfa/parser/xfa_script_hostpseudomodel.h"
8 8
9 #include "xfa/fxfa/app/xfa_ffnotify.h" 9 #include "xfa/fxfa/app/xfa_ffnotify.h"
10 #include "xfa/fxfa/parser/xfa_doclayout.h" 10 #include "xfa/fxfa/parser/xfa_doclayout.h"
(...skipping 20 matching lines...) Expand all
31 : CXFA_OrdinaryObject(pDocument, XFA_ELEMENT_HostPseudoModel) { 31 : CXFA_OrdinaryObject(pDocument, XFA_ELEMENT_HostPseudoModel) {
32 m_uScriptHash = XFA_HASHCODE_Host; 32 m_uScriptHash = XFA_HASHCODE_Host;
33 } 33 }
34 CScript_HostPseudoModel::~CScript_HostPseudoModel() {} 34 CScript_HostPseudoModel::~CScript_HostPseudoModel() {}
35 void CScript_HostPseudoModel::Script_HostPseudoModel_LoadString( 35 void CScript_HostPseudoModel::Script_HostPseudoModel_LoadString(
36 CFXJSE_Value* pValue, 36 CFXJSE_Value* pValue,
37 CXFA_FFNotify* pNotify, 37 CXFA_FFNotify* pNotify,
38 uint32_t dwFlag) { 38 uint32_t dwFlag) {
39 CFX_WideString wsValue; 39 CFX_WideString wsValue;
40 pNotify->GetAppProvider()->LoadString(dwFlag, wsValue); 40 pNotify->GetAppProvider()->LoadString(dwFlag, wsValue);
41 FXJSE_Value_SetUTF8String(pValue, FX_UTF8Encode(wsValue).AsStringC()); 41 pValue->SetString(FX_UTF8Encode(wsValue).AsStringC());
42 } 42 }
43 void CScript_HostPseudoModel::Script_HostPseudoModel_AppType( 43 void CScript_HostPseudoModel::Script_HostPseudoModel_AppType(
44 CFXJSE_Value* pValue, 44 CFXJSE_Value* pValue,
45 FX_BOOL bSetting, 45 FX_BOOL bSetting,
46 XFA_ATTRIBUTE eAttribute) { 46 XFA_ATTRIBUTE eAttribute) {
47 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); 47 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify();
48 if (!pNotify) { 48 if (!pNotify) {
49 return; 49 return;
50 } 50 }
51 if (bSetting) { 51 if (bSetting) {
52 ThrowException(XFA_IDS_INVAlID_PROP_SET); 52 ThrowException(XFA_IDS_INVAlID_PROP_SET);
53 return; 53 return;
54 } 54 }
55 CFX_WideString wsAppType; 55 CFX_WideString wsAppType;
56 pNotify->GetAppProvider()->GetAppType(wsAppType); 56 pNotify->GetAppProvider()->GetAppType(wsAppType);
57 FXJSE_Value_SetUTF8String(pValue, FX_UTF8Encode(wsAppType).AsStringC()); 57 pValue->SetString(FX_UTF8Encode(wsAppType).AsStringC());
58 } 58 }
59 void CScript_HostPseudoModel::Script_HostPseudoModel_FoxitAppType( 59 void CScript_HostPseudoModel::Script_HostPseudoModel_FoxitAppType(
60 CFXJSE_Value* pValue, 60 CFXJSE_Value* pValue,
61 FX_BOOL bSetting, 61 FX_BOOL bSetting,
62 XFA_ATTRIBUTE eAttribute) { 62 XFA_ATTRIBUTE eAttribute) {
63 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); 63 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify();
64 if (!pNotify) { 64 if (!pNotify) {
65 return; 65 return;
66 } 66 }
67 if (bSetting) { 67 if (bSetting) {
68 ThrowException(XFA_IDS_INVAlID_PROP_SET); 68 ThrowException(XFA_IDS_INVAlID_PROP_SET);
69 return; 69 return;
70 } 70 }
71 CFX_WideString wsAppType; 71 CFX_WideString wsAppType;
72 pNotify->GetAppProvider()->GetFoxitAppType(wsAppType); 72 pNotify->GetAppProvider()->GetFoxitAppType(wsAppType);
73 FXJSE_Value_SetUTF8String(pValue, FX_UTF8Encode(wsAppType).AsStringC()); 73 pValue->SetString(FX_UTF8Encode(wsAppType).AsStringC());
74 } 74 }
75 void CScript_HostPseudoModel::Script_HostPseudoModel_CalculationsEnabled( 75 void CScript_HostPseudoModel::Script_HostPseudoModel_CalculationsEnabled(
76 CFXJSE_Value* pValue, 76 CFXJSE_Value* pValue,
77 FX_BOOL bSetting, 77 FX_BOOL bSetting,
78 XFA_ATTRIBUTE eAttribute) { 78 XFA_ATTRIBUTE eAttribute) {
79 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); 79 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify();
80 if (!pNotify) { 80 if (!pNotify) {
81 return; 81 return;
82 } 82 }
83 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); 83 CXFA_FFDoc* hDoc = pNotify->GetHDOC();
84 if (bSetting) { 84 if (bSetting) {
85 pNotify->GetDocProvider()->SetCalculationsEnabled( 85 pNotify->GetDocProvider()->SetCalculationsEnabled(hDoc,
86 hDoc, FXJSE_Value_ToBoolean(pValue)); 86 pValue->ToBoolean());
87 return; 87 return;
88 } 88 }
89 FX_BOOL bEnabled = pNotify->GetDocProvider()->IsCalculationsEnabled(hDoc); 89 pValue->SetBoolean(pNotify->GetDocProvider()->IsCalculationsEnabled(hDoc));
90 FXJSE_Value_SetBoolean(pValue, bEnabled);
91 } 90 }
92 void CScript_HostPseudoModel::Script_HostPseudoModel_CurrentPage( 91 void CScript_HostPseudoModel::Script_HostPseudoModel_CurrentPage(
93 CFXJSE_Value* pValue, 92 CFXJSE_Value* pValue,
94 FX_BOOL bSetting, 93 FX_BOOL bSetting,
95 XFA_ATTRIBUTE eAttribute) { 94 XFA_ATTRIBUTE eAttribute) {
96 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); 95 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify();
97 if (!pNotify) { 96 if (!pNotify) {
98 return; 97 return;
99 } 98 }
100 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); 99 CXFA_FFDoc* hDoc = pNotify->GetHDOC();
101 if (bSetting) { 100 if (bSetting) {
102 pNotify->GetDocProvider()->SetCurrentPage(hDoc, 101 pNotify->GetDocProvider()->SetCurrentPage(hDoc, pValue->ToInteger());
103 FXJSE_Value_ToInteger(pValue));
104 return; 102 return;
105 } 103 }
106 int32_t iCurrentPage = pNotify->GetDocProvider()->GetCurrentPage(hDoc); 104 pValue->SetInteger(pNotify->GetDocProvider()->GetCurrentPage(hDoc));
107 FXJSE_Value_SetInteger(pValue, iCurrentPage);
108 } 105 }
109 void CScript_HostPseudoModel::Script_HostPseudoModel_Language( 106 void CScript_HostPseudoModel::Script_HostPseudoModel_Language(
110 CFXJSE_Value* pValue, 107 CFXJSE_Value* pValue,
111 FX_BOOL bSetting, 108 FX_BOOL bSetting,
112 XFA_ATTRIBUTE eAttribute) { 109 XFA_ATTRIBUTE eAttribute) {
113 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); 110 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify();
114 if (!pNotify) { 111 if (!pNotify) {
115 return; 112 return;
116 } 113 }
117 if (bSetting) { 114 if (bSetting) {
118 ThrowException(XFA_IDS_UNABLE_SET_LANGUAGE); 115 ThrowException(XFA_IDS_UNABLE_SET_LANGUAGE);
119 return; 116 return;
120 } 117 }
121 CFX_WideString wsLanguage; 118 CFX_WideString wsLanguage;
122 pNotify->GetAppProvider()->GetLanguage(wsLanguage); 119 pNotify->GetAppProvider()->GetLanguage(wsLanguage);
123 FXJSE_Value_SetUTF8String(pValue, FX_UTF8Encode(wsLanguage).AsStringC()); 120 pValue->SetString(FX_UTF8Encode(wsLanguage).AsStringC());
124 } 121 }
125 void CScript_HostPseudoModel::Script_HostPseudoModel_NumPages( 122 void CScript_HostPseudoModel::Script_HostPseudoModel_NumPages(
126 CFXJSE_Value* pValue, 123 CFXJSE_Value* pValue,
127 FX_BOOL bSetting, 124 FX_BOOL bSetting,
128 XFA_ATTRIBUTE eAttribute) { 125 XFA_ATTRIBUTE eAttribute) {
129 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); 126 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify();
130 if (!pNotify) { 127 if (!pNotify) {
131 return; 128 return;
132 } 129 }
133 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); 130 CXFA_FFDoc* hDoc = pNotify->GetHDOC();
134 if (bSetting) { 131 if (bSetting) {
135 ThrowException(XFA_IDS_UNABLE_SET_NUMPAGES); 132 ThrowException(XFA_IDS_UNABLE_SET_NUMPAGES);
136 return; 133 return;
137 } 134 }
138 int32_t iNumPages = pNotify->GetDocProvider()->CountPages(hDoc); 135 pValue->SetInteger(pNotify->GetDocProvider()->CountPages(hDoc));
139 FXJSE_Value_SetInteger(pValue, iNumPages);
140 } 136 }
141 void CScript_HostPseudoModel::Script_HostPseudoModel_Platform( 137 void CScript_HostPseudoModel::Script_HostPseudoModel_Platform(
142 CFXJSE_Value* pValue, 138 CFXJSE_Value* pValue,
143 FX_BOOL bSetting, 139 FX_BOOL bSetting,
144 XFA_ATTRIBUTE eAttribute) { 140 XFA_ATTRIBUTE eAttribute) {
145 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); 141 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify();
146 if (!pNotify) { 142 if (!pNotify) {
147 return; 143 return;
148 } 144 }
149 if (bSetting) { 145 if (bSetting) {
150 ThrowException(XFA_IDS_UNABLE_SET_PLATFORM); 146 ThrowException(XFA_IDS_UNABLE_SET_PLATFORM);
151 return; 147 return;
152 } 148 }
153 CFX_WideString wsPlatform; 149 CFX_WideString wsPlatform;
154 pNotify->GetAppProvider()->GetPlatform(wsPlatform); 150 pNotify->GetAppProvider()->GetPlatform(wsPlatform);
155 FXJSE_Value_SetUTF8String(pValue, FX_UTF8Encode(wsPlatform).AsStringC()); 151 pValue->SetString(FX_UTF8Encode(wsPlatform).AsStringC());
156 } 152 }
157 void CScript_HostPseudoModel::Script_HostPseudoModel_Title( 153 void CScript_HostPseudoModel::Script_HostPseudoModel_Title(
158 CFXJSE_Value* pValue, 154 CFXJSE_Value* pValue,
159 FX_BOOL bSetting, 155 FX_BOOL bSetting,
160 XFA_ATTRIBUTE eAttribute) { 156 XFA_ATTRIBUTE eAttribute) {
161 if (!m_pDocument->GetScriptContext()->IsRunAtClient()) { 157 if (!m_pDocument->GetScriptContext()->IsRunAtClient()) {
162 return; 158 return;
163 } 159 }
164 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); 160 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify();
165 if (!pNotify) { 161 if (!pNotify) {
166 return; 162 return;
167 } 163 }
168 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); 164 CXFA_FFDoc* hDoc = pNotify->GetHDOC();
169 if (bSetting) { 165 if (bSetting) {
170 CFX_ByteString bsValue; 166 CFX_ByteString bsValue;
171 FXJSE_Value_ToUTF8String(pValue, bsValue); 167 pValue->ToString(bsValue);
172 pNotify->GetDocProvider()->SetTitle( 168 pNotify->GetDocProvider()->SetTitle(
173 hDoc, CFX_WideString::FromUTF8(bsValue.AsStringC())); 169 hDoc, CFX_WideString::FromUTF8(bsValue.AsStringC()));
174 return; 170 return;
175 } 171 }
176 CFX_WideString wsTitle; 172 CFX_WideString wsTitle;
177 pNotify->GetDocProvider()->GetTitle(hDoc, wsTitle); 173 pNotify->GetDocProvider()->GetTitle(hDoc, wsTitle);
178 FXJSE_Value_SetUTF8String(pValue, FX_UTF8Encode(wsTitle).AsStringC()); 174 pValue->SetString(FX_UTF8Encode(wsTitle).AsStringC());
179 } 175 }
180 void CScript_HostPseudoModel::Script_HostPseudoModel_ValidationsEnabled( 176 void CScript_HostPseudoModel::Script_HostPseudoModel_ValidationsEnabled(
181 CFXJSE_Value* pValue, 177 CFXJSE_Value* pValue,
182 FX_BOOL bSetting, 178 FX_BOOL bSetting,
183 XFA_ATTRIBUTE eAttribute) { 179 XFA_ATTRIBUTE eAttribute) {
184 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); 180 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify();
185 if (!pNotify) { 181 if (!pNotify) {
186 return; 182 return;
187 } 183 }
188 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); 184 CXFA_FFDoc* hDoc = pNotify->GetHDOC();
189 if (bSetting) { 185 if (bSetting) {
190 pNotify->GetDocProvider()->SetValidationsEnabled( 186 pNotify->GetDocProvider()->SetValidationsEnabled(hDoc, pValue->ToBoolean());
191 hDoc, FXJSE_Value_ToBoolean(pValue));
192 return; 187 return;
193 } 188 }
194 FX_BOOL bEnabled = pNotify->GetDocProvider()->IsValidationsEnabled(hDoc); 189 FX_BOOL bEnabled = pNotify->GetDocProvider()->IsValidationsEnabled(hDoc);
195 FXJSE_Value_SetBoolean(pValue, bEnabled); 190 pValue->SetBoolean(bEnabled);
196 } 191 }
197 void CScript_HostPseudoModel::Script_HostPseudoModel_Variation( 192 void CScript_HostPseudoModel::Script_HostPseudoModel_Variation(
198 CFXJSE_Value* pValue, 193 CFXJSE_Value* pValue,
199 FX_BOOL bSetting, 194 FX_BOOL bSetting,
200 XFA_ATTRIBUTE eAttribute) { 195 XFA_ATTRIBUTE eAttribute) {
201 if (!m_pDocument->GetScriptContext()->IsRunAtClient()) { 196 if (!m_pDocument->GetScriptContext()->IsRunAtClient()) {
202 return; 197 return;
203 } 198 }
204 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); 199 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify();
205 if (!pNotify) { 200 if (!pNotify) {
206 return; 201 return;
207 } 202 }
208 if (bSetting) { 203 if (bSetting) {
209 ThrowException(XFA_IDS_UNABLE_SET_VARIATION); 204 ThrowException(XFA_IDS_UNABLE_SET_VARIATION);
210 return; 205 return;
211 } 206 }
212 CFX_WideString wsVariation; 207 CFX_WideString wsVariation;
213 pNotify->GetAppProvider()->GetVariation(wsVariation); 208 pNotify->GetAppProvider()->GetVariation(wsVariation);
214 FXJSE_Value_SetUTF8String(pValue, FX_UTF8Encode(wsVariation).AsStringC()); 209 pValue->SetString(FX_UTF8Encode(wsVariation).AsStringC());
215 } 210 }
216 void CScript_HostPseudoModel::Script_HostPseudoModel_Version( 211 void CScript_HostPseudoModel::Script_HostPseudoModel_Version(
217 CFXJSE_Value* pValue, 212 CFXJSE_Value* pValue,
218 FX_BOOL bSetting, 213 FX_BOOL bSetting,
219 XFA_ATTRIBUTE eAttribute) { 214 XFA_ATTRIBUTE eAttribute) {
220 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); 215 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify();
221 if (!pNotify) { 216 if (!pNotify) {
222 return; 217 return;
223 } 218 }
224 if (bSetting) { 219 if (bSetting) {
225 ThrowException(XFA_IDS_UNABLE_SET_VERSION); 220 ThrowException(XFA_IDS_UNABLE_SET_VERSION);
226 return; 221 return;
227 } 222 }
228 CFX_WideString wsVersion; 223 CFX_WideString wsVersion;
229 pNotify->GetAppProvider()->GetVersion(wsVersion); 224 pNotify->GetAppProvider()->GetVersion(wsVersion);
230 FXJSE_Value_SetUTF8String(pValue, FX_UTF8Encode(wsVersion).AsStringC()); 225 pValue->SetString(FX_UTF8Encode(wsVersion).AsStringC());
231 } 226 }
232 void CScript_HostPseudoModel::Script_HostPseudoModel_FoxitVersion( 227 void CScript_HostPseudoModel::Script_HostPseudoModel_FoxitVersion(
233 CFXJSE_Value* pValue, 228 CFXJSE_Value* pValue,
234 FX_BOOL bSetting, 229 FX_BOOL bSetting,
235 XFA_ATTRIBUTE eAttribute) { 230 XFA_ATTRIBUTE eAttribute) {
236 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); 231 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify();
237 if (!pNotify) { 232 if (!pNotify) {
238 return; 233 return;
239 } 234 }
240 if (bSetting) { 235 if (bSetting) {
241 ThrowException(XFA_IDS_UNABLE_SET_VERSION); 236 ThrowException(XFA_IDS_UNABLE_SET_VERSION);
242 return; 237 return;
243 } 238 }
244 CFX_WideString wsVersion; 239 CFX_WideString wsVersion;
245 pNotify->GetAppProvider()->GetFoxitVersion(wsVersion); 240 pNotify->GetAppProvider()->GetFoxitVersion(wsVersion);
246 FXJSE_Value_SetUTF8String(pValue, FX_UTF8Encode(wsVersion).AsStringC()); 241 pValue->SetString(FX_UTF8Encode(wsVersion).AsStringC());
247 } 242 }
248 void CScript_HostPseudoModel::Script_HostPseudoModel_Name( 243 void CScript_HostPseudoModel::Script_HostPseudoModel_Name(
249 CFXJSE_Value* pValue, 244 CFXJSE_Value* pValue,
250 FX_BOOL bSetting, 245 FX_BOOL bSetting,
251 XFA_ATTRIBUTE eAttribute) { 246 XFA_ATTRIBUTE eAttribute) {
252 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); 247 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify();
253 if (!pNotify) { 248 if (!pNotify) {
254 return; 249 return;
255 } 250 }
256 if (bSetting) { 251 if (bSetting) {
257 ThrowException(XFA_IDS_INVAlID_PROP_SET); 252 ThrowException(XFA_IDS_INVAlID_PROP_SET);
258 return; 253 return;
259 } 254 }
260 CFX_WideString wsAppName; 255 CFX_WideString wsAppName;
261 pNotify->GetAppProvider()->GetAppName(wsAppName); 256 pNotify->GetAppProvider()->GetAppName(wsAppName);
262 FXJSE_Value_SetUTF8String(pValue, FX_UTF8Encode(wsAppName).AsStringC()); 257 pValue->SetString(FX_UTF8Encode(wsAppName).AsStringC());
263 } 258 }
264 void CScript_HostPseudoModel::Script_HostPseudoModel_FoxitName( 259 void CScript_HostPseudoModel::Script_HostPseudoModel_FoxitName(
265 CFXJSE_Value* pValue, 260 CFXJSE_Value* pValue,
266 FX_BOOL bSetting, 261 FX_BOOL bSetting,
267 XFA_ATTRIBUTE eAttribute) { 262 XFA_ATTRIBUTE eAttribute) {
268 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); 263 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify();
269 if (!pNotify) { 264 if (!pNotify) {
270 return; 265 return;
271 } 266 }
272 if (bSetting) { 267 if (bSetting) {
273 ThrowException(XFA_IDS_INVAlID_PROP_SET); 268 ThrowException(XFA_IDS_INVAlID_PROP_SET);
274 return; 269 return;
275 } 270 }
276 CFX_WideString wsFoxitAppName; 271 CFX_WideString wsFoxitAppName;
277 pNotify->GetAppProvider()->GetFoxitAppName(wsFoxitAppName); 272 pNotify->GetAppProvider()->GetFoxitAppName(wsFoxitAppName);
278 FXJSE_Value_SetUTF8String(pValue, FX_UTF8Encode(wsFoxitAppName).AsStringC()); 273 pValue->SetString(FX_UTF8Encode(wsFoxitAppName).AsStringC());
279 } 274 }
280 void CScript_HostPseudoModel::Script_HostPseudoModel_GotoURL( 275 void CScript_HostPseudoModel::Script_HostPseudoModel_GotoURL(
281 CFXJSE_Arguments* pArguments) { 276 CFXJSE_Arguments* pArguments) {
282 if (!m_pDocument->GetScriptContext()->IsRunAtClient()) { 277 if (!m_pDocument->GetScriptContext()->IsRunAtClient()) {
283 return; 278 return;
284 } 279 }
285 int32_t iLength = pArguments->GetLength(); 280 int32_t iLength = pArguments->GetLength();
286 if (iLength != 1) { 281 if (iLength != 1) {
287 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"gotoURL"); 282 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"gotoURL");
288 return; 283 return;
(...skipping 24 matching lines...) Expand all
313 if (!pNotify) { 308 if (!pNotify) {
314 return; 309 return;
315 } 310 }
316 CXFA_Node* pNode = NULL; 311 CXFA_Node* pNode = NULL;
317 if (iLength >= 1) { 312 if (iLength >= 1) {
318 std::unique_ptr<CFXJSE_Value> pValue(pArguments->GetValue(0)); 313 std::unique_ptr<CFXJSE_Value> pValue(pArguments->GetValue(0));
319 if (FXJSE_Value_IsObject(pValue.get())) { 314 if (FXJSE_Value_IsObject(pValue.get())) {
320 pNode = ToNode(pValue.get(), nullptr); 315 pNode = ToNode(pValue.get(), nullptr);
321 } else if (FXJSE_Value_IsUTF8String(pValue.get())) { 316 } else if (FXJSE_Value_IsUTF8String(pValue.get())) {
322 CFX_ByteString bsString; 317 CFX_ByteString bsString;
323 FXJSE_Value_ToUTF8String(pValue.get(), bsString); 318 pValue->ToString(bsString);
324 CFX_WideString wsExpression = 319 CFX_WideString wsExpression =
325 CFX_WideString::FromUTF8(bsString.AsStringC()); 320 CFX_WideString::FromUTF8(bsString.AsStringC());
326 CXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext(); 321 CXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext();
327 if (!pScriptContext) 322 if (!pScriptContext)
328 return; 323 return;
329 324
330 CXFA_Object* pObject = pScriptContext->GetThisObject(); 325 CXFA_Object* pObject = pScriptContext->GetThisObject();
331 if (!pObject) 326 if (!pObject)
332 return; 327 return;
333 328
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 if (iLength >= 3) { 375 if (iLength >= 3) {
381 CFX_ByteString bsDefaultAnswer = pArguments->GetUTF8String(2); 376 CFX_ByteString bsDefaultAnswer = pArguments->GetUTF8String(2);
382 wsDefaultAnswer = CFX_WideString::FromUTF8(bsDefaultAnswer.AsStringC()); 377 wsDefaultAnswer = CFX_WideString::FromUTF8(bsDefaultAnswer.AsStringC());
383 } 378 }
384 if (iLength >= 4) { 379 if (iLength >= 4) {
385 bMark = pArguments->GetInt32(3) == 0 ? FALSE : TRUE; 380 bMark = pArguments->GetInt32(3) == 0 ? FALSE : TRUE;
386 } 381 }
387 CFX_WideString wsAnswer = pNotify->GetAppProvider()->Response( 382 CFX_WideString wsAnswer = pNotify->GetAppProvider()->Response(
388 wsQuestion, wsTitle, wsDefaultAnswer, bMark); 383 wsQuestion, wsTitle, wsDefaultAnswer, bMark);
389 CFXJSE_Value* pValue = pArguments->GetReturnValue(); 384 CFXJSE_Value* pValue = pArguments->GetReturnValue();
390 if (pValue) { 385 if (pValue)
391 FXJSE_Value_SetUTF8String(pValue, FX_UTF8Encode(wsAnswer).AsStringC()); 386 pValue->SetString(FX_UTF8Encode(wsAnswer).AsStringC());
392 }
393 } 387 }
394 void CScript_HostPseudoModel::Script_HostPseudoModel_DocumentInBatch( 388 void CScript_HostPseudoModel::Script_HostPseudoModel_DocumentInBatch(
395 CFXJSE_Arguments* pArguments) { 389 CFXJSE_Arguments* pArguments) {
396 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); 390 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify();
397 if (!pNotify) { 391 if (!pNotify) {
398 return; 392 return;
399 } 393 }
400 int32_t iCur = pNotify->GetAppProvider()->GetCurDocumentInBatch(); 394 int32_t iCur = pNotify->GetAppProvider()->GetCurDocumentInBatch();
401 CFXJSE_Value* pValue = pArguments->GetReturnValue(); 395 CFXJSE_Value* pValue = pArguments->GetReturnValue();
402 if (pValue) { 396 if (pValue)
403 FXJSE_Value_SetInteger(pValue, iCur); 397 pValue->SetInteger(iCur);
404 }
405 } 398 }
406 static int32_t XFA_FilterName(const CFX_WideStringC& wsExpression, 399 static int32_t XFA_FilterName(const CFX_WideStringC& wsExpression,
407 int32_t nStart, 400 int32_t nStart,
408 CFX_WideString& wsFilter) { 401 CFX_WideString& wsFilter) {
409 ASSERT(nStart > -1); 402 ASSERT(nStart > -1);
410 int32_t iLength = wsExpression.GetLength(); 403 int32_t iLength = wsExpression.GetLength();
411 if (nStart >= iLength) { 404 if (nStart >= iLength) {
412 return iLength; 405 return iLength;
413 } 406 }
414 FX_WCHAR* pBuf = wsFilter.GetBuffer(iLength - nStart); 407 FX_WCHAR* pBuf = wsFilter.GetBuffer(iLength - nStart);
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 if (!pNotify) { 503 if (!pNotify) {
511 return; 504 return;
512 } 505 }
513 CXFA_Node* pNode = NULL; 506 CXFA_Node* pNode = NULL;
514 if (iLength >= 1) { 507 if (iLength >= 1) {
515 std::unique_ptr<CFXJSE_Value> pValue(pArguments->GetValue(0)); 508 std::unique_ptr<CFXJSE_Value> pValue(pArguments->GetValue(0));
516 if (FXJSE_Value_IsObject(pValue.get())) { 509 if (FXJSE_Value_IsObject(pValue.get())) {
517 pNode = ToNode(pValue.get(), nullptr); 510 pNode = ToNode(pValue.get(), nullptr);
518 } else if (FXJSE_Value_IsUTF8String(pValue.get())) { 511 } else if (FXJSE_Value_IsUTF8String(pValue.get())) {
519 CFX_ByteString bsString; 512 CFX_ByteString bsString;
520 FXJSE_Value_ToUTF8String(pValue.get(), bsString); 513 pValue->ToString(bsString);
521 CFX_WideString wsExpression = 514 CFX_WideString wsExpression =
522 CFX_WideString::FromUTF8(bsString.AsStringC()); 515 CFX_WideString::FromUTF8(bsString.AsStringC());
523 CXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext(); 516 CXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext();
524 if (!pScriptContext) 517 if (!pScriptContext)
525 return; 518 return;
526 519
527 CXFA_Object* pObject = pScriptContext->GetThisObject(); 520 CXFA_Object* pObject = pScriptContext->GetThisObject();
528 if (!pObject) 521 if (!pObject)
529 return; 522 return;
530 523
(...skipping 13 matching lines...) Expand all
544 void CScript_HostPseudoModel::Script_HostPseudoModel_GetFocus( 537 void CScript_HostPseudoModel::Script_HostPseudoModel_GetFocus(
545 CFXJSE_Arguments* pArguments) { 538 CFXJSE_Arguments* pArguments) {
546 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); 539 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify();
547 if (!pNotify) { 540 if (!pNotify) {
548 return; 541 return;
549 } 542 }
550 CXFA_Node* pNode = pNotify->GetFocusWidgetNode(); 543 CXFA_Node* pNode = pNotify->GetFocusWidgetNode();
551 if (!pNode) { 544 if (!pNode) {
552 return; 545 return;
553 } 546 }
554 FXJSE_Value_Set(pArguments->GetReturnValue(), 547 pArguments->GetReturnValue()->Assign(
555 m_pDocument->GetScriptContext()->GetJSValueFromMap(pNode)); 548 m_pDocument->GetScriptContext()->GetJSValueFromMap(pNode));
556 } 549 }
557 void CScript_HostPseudoModel::Script_HostPseudoModel_MessageBox( 550 void CScript_HostPseudoModel::Script_HostPseudoModel_MessageBox(
558 CFXJSE_Arguments* pArguments) { 551 CFXJSE_Arguments* pArguments) {
559 if (!m_pDocument->GetScriptContext()->IsRunAtClient()) { 552 if (!m_pDocument->GetScriptContext()->IsRunAtClient()) {
560 return; 553 return;
561 } 554 }
562 int32_t iLength = pArguments->GetLength(); 555 int32_t iLength = pArguments->GetLength();
563 if (iLength < 1 || iLength > 4) { 556 if (iLength < 1 || iLength > 4) {
564 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"messageBox"); 557 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"messageBox");
565 return; 558 return;
(...skipping 24 matching lines...) Expand all
590 } 583 }
591 if (iLength >= 4) { 584 if (iLength >= 4) {
592 dwButtonType = pArguments->GetInt32(3); 585 dwButtonType = pArguments->GetInt32(3);
593 if (dwButtonType > XFA_MB_YesNoCancel) { 586 if (dwButtonType > XFA_MB_YesNoCancel) {
594 dwButtonType = XFA_MB_OK; 587 dwButtonType = XFA_MB_OK;
595 } 588 }
596 } 589 }
597 int32_t iValue = pNotify->GetAppProvider()->MsgBox( 590 int32_t iValue = pNotify->GetAppProvider()->MsgBox(
598 wsMessage, bsTitle, dwMessageType, dwButtonType); 591 wsMessage, bsTitle, dwMessageType, dwButtonType);
599 CFXJSE_Value* pValue = pArguments->GetReturnValue(); 592 CFXJSE_Value* pValue = pArguments->GetReturnValue();
600 if (pValue) { 593 if (pValue)
601 FXJSE_Value_SetInteger(pValue, iValue); 594 pValue->SetInteger(iValue);
602 }
603 } 595 }
604 FX_BOOL CScript_HostPseudoModel::Script_HostPseudoModel_ValidateArgsForMsg( 596 FX_BOOL CScript_HostPseudoModel::Script_HostPseudoModel_ValidateArgsForMsg(
605 CFXJSE_Arguments* pArguments, 597 CFXJSE_Arguments* pArguments,
606 int32_t iArgIndex, 598 int32_t iArgIndex,
607 CFX_WideString& wsValue) { 599 CFX_WideString& wsValue) {
608 if (pArguments == NULL || iArgIndex < 0) { 600 if (pArguments == NULL || iArgIndex < 0) {
609 return FALSE; 601 return FALSE;
610 } 602 }
611 FX_BOOL bIsJsType = FALSE; 603 FX_BOOL bIsJsType = FALSE;
612 if (m_pDocument->GetScriptContext()->GetType() == 604 if (m_pDocument->GetScriptContext()->GetType() ==
613 XFA_SCRIPTLANGTYPE_Javascript) { 605 XFA_SCRIPTLANGTYPE_Javascript) {
614 bIsJsType = TRUE; 606 bIsJsType = TRUE;
615 } 607 }
616 std::unique_ptr<CFXJSE_Value> pValueArg(pArguments->GetValue(iArgIndex)); 608 std::unique_ptr<CFXJSE_Value> pValueArg(pArguments->GetValue(iArgIndex));
617 if (!FXJSE_Value_IsUTF8String(pValueArg.get()) && bIsJsType) { 609 if (!FXJSE_Value_IsUTF8String(pValueArg.get()) && bIsJsType) {
618 ThrowException(XFA_IDS_ARGUMENT_MISMATCH); 610 ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
619 return FALSE; 611 return FALSE;
620 } 612 }
621 if (FXJSE_Value_IsNull(pValueArg.get())) { 613 if (FXJSE_Value_IsNull(pValueArg.get())) {
622 wsValue = FX_WSTRC(L""); 614 wsValue = FX_WSTRC(L"");
623 } else { 615 } else {
624 CFX_ByteString byMessage; 616 CFX_ByteString byMessage;
625 FXJSE_Value_ToUTF8String(pValueArg.get(), byMessage); 617 pValueArg->ToString(byMessage);
626 wsValue = CFX_WideString::FromUTF8(byMessage.AsStringC()); 618 wsValue = CFX_WideString::FromUTF8(byMessage.AsStringC());
627 } 619 }
628 return TRUE; 620 return TRUE;
629 } 621 }
630 void CScript_HostPseudoModel::Script_HostPseudoModel_DocumentCountInBatch( 622 void CScript_HostPseudoModel::Script_HostPseudoModel_DocumentCountInBatch(
631 CFXJSE_Arguments* pArguments) { 623 CFXJSE_Arguments* pArguments) {
632 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); 624 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify();
633 if (!pNotify) { 625 if (!pNotify) {
634 return; 626 return;
635 } 627 }
636 int32_t iValue = pNotify->GetAppProvider()->GetDocumentCountInBatch(); 628 int32_t iValue = pNotify->GetAppProvider()->GetDocumentCountInBatch();
637 CFXJSE_Value* pValue = pArguments->GetReturnValue(); 629 CFXJSE_Value* pValue = pArguments->GetReturnValue();
638 if (pValue) { 630 if (pValue)
639 FXJSE_Value_SetInteger(pValue, iValue); 631 pValue->SetInteger(iValue);
640 }
641 } 632 }
642 void CScript_HostPseudoModel::Script_HostPseudoModel_Print( 633 void CScript_HostPseudoModel::Script_HostPseudoModel_Print(
643 CFXJSE_Arguments* pArguments) { 634 CFXJSE_Arguments* pArguments) {
644 if (!m_pDocument->GetScriptContext()->IsRunAtClient()) { 635 if (!m_pDocument->GetScriptContext()->IsRunAtClient()) {
645 return; 636 return;
646 } 637 }
647 int32_t iLength = pArguments->GetLength(); 638 int32_t iLength = pArguments->GetLength();
648 if (iLength != 8) { 639 if (iLength != 8) {
649 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"print"); 640 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"print");
650 return; 641 return;
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
786 pNotify->GetDocProvider()->SetCurrentPage(hDoc, nNewPage); 777 pNotify->GetDocProvider()->SetCurrentPage(hDoc, nNewPage);
787 } 778 }
788 void CScript_HostPseudoModel::Script_HostPseudoModel_CurrentDateTime( 779 void CScript_HostPseudoModel::Script_HostPseudoModel_CurrentDateTime(
789 CFXJSE_Arguments* pArguments) { 780 CFXJSE_Arguments* pArguments) {
790 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); 781 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify();
791 if (!pNotify) { 782 if (!pNotify) {
792 return; 783 return;
793 } 784 }
794 CFX_WideString wsDataTime = pNotify->GetCurrentDateTime(); 785 CFX_WideString wsDataTime = pNotify->GetCurrentDateTime();
795 CFXJSE_Value* pValue = pArguments->GetReturnValue(); 786 CFXJSE_Value* pValue = pArguments->GetReturnValue();
796 if (pValue) { 787 if (pValue)
797 FXJSE_Value_SetUTF8String(pValue, FX_UTF8Encode(wsDataTime).AsStringC()); 788 pValue->SetString(FX_UTF8Encode(wsDataTime).AsStringC());
798 }
799 } 789 }
OLDNEW
« no previous file with comments | « xfa/fxfa/parser/xfa_script_eventpseudomodel.cpp ('k') | xfa/fxfa/parser/xfa_script_imp.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698