| 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 #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 23 matching lines...) Expand all Loading... |
| 34 } | 34 } |
| 35 void CScript_HostPseudoModel::Script_HostPseudoModel_AppType( | 35 void CScript_HostPseudoModel::Script_HostPseudoModel_AppType( |
| 36 CFXJSE_Value* pValue, | 36 CFXJSE_Value* pValue, |
| 37 FX_BOOL bSetting, | 37 FX_BOOL bSetting, |
| 38 XFA_ATTRIBUTE eAttribute) { | 38 XFA_ATTRIBUTE eAttribute) { |
| 39 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 39 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
| 40 if (!pNotify) { | 40 if (!pNotify) { |
| 41 return; | 41 return; |
| 42 } | 42 } |
| 43 if (bSetting) { | 43 if (bSetting) { |
| 44 ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET); | 44 Throw(XFA_IDS_INVAlID_PROP_SET); |
| 45 return; | 45 return; |
| 46 } | 46 } |
| 47 CFX_WideString wsAppType; | 47 CFX_WideString wsAppType; |
| 48 pNotify->GetAppProvider()->GetAppType(wsAppType); | 48 pNotify->GetAppProvider()->GetAppType(wsAppType); |
| 49 FXJSE_Value_SetUTF8String(pValue, FX_UTF8Encode(wsAppType).AsStringC()); | 49 FXJSE_Value_SetUTF8String(pValue, FX_UTF8Encode(wsAppType).AsStringC()); |
| 50 } | 50 } |
| 51 void CScript_HostPseudoModel::Script_HostPseudoModel_FoxitAppType( | 51 void CScript_HostPseudoModel::Script_HostPseudoModel_FoxitAppType( |
| 52 CFXJSE_Value* pValue, | 52 CFXJSE_Value* pValue, |
| 53 FX_BOOL bSetting, | 53 FX_BOOL bSetting, |
| 54 XFA_ATTRIBUTE eAttribute) { | 54 XFA_ATTRIBUTE eAttribute) { |
| 55 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 55 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
| 56 if (!pNotify) { | 56 if (!pNotify) { |
| 57 return; | 57 return; |
| 58 } | 58 } |
| 59 if (bSetting) { | 59 if (bSetting) { |
| 60 ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET); | 60 Throw(XFA_IDS_INVAlID_PROP_SET); |
| 61 return; | 61 return; |
| 62 } | 62 } |
| 63 CFX_WideString wsAppType; | 63 CFX_WideString wsAppType; |
| 64 pNotify->GetAppProvider()->GetFoxitAppType(wsAppType); | 64 pNotify->GetAppProvider()->GetFoxitAppType(wsAppType); |
| 65 FXJSE_Value_SetUTF8String(pValue, FX_UTF8Encode(wsAppType).AsStringC()); | 65 FXJSE_Value_SetUTF8String(pValue, FX_UTF8Encode(wsAppType).AsStringC()); |
| 66 } | 66 } |
| 67 void CScript_HostPseudoModel::Script_HostPseudoModel_CalculationsEnabled( | 67 void CScript_HostPseudoModel::Script_HostPseudoModel_CalculationsEnabled( |
| 68 CFXJSE_Value* pValue, | 68 CFXJSE_Value* pValue, |
| 69 FX_BOOL bSetting, | 69 FX_BOOL bSetting, |
| 70 XFA_ATTRIBUTE eAttribute) { | 70 XFA_ATTRIBUTE eAttribute) { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 100 } | 100 } |
| 101 void CScript_HostPseudoModel::Script_HostPseudoModel_Language( | 101 void CScript_HostPseudoModel::Script_HostPseudoModel_Language( |
| 102 CFXJSE_Value* pValue, | 102 CFXJSE_Value* pValue, |
| 103 FX_BOOL bSetting, | 103 FX_BOOL bSetting, |
| 104 XFA_ATTRIBUTE eAttribute) { | 104 XFA_ATTRIBUTE eAttribute) { |
| 105 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 105 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
| 106 if (!pNotify) { | 106 if (!pNotify) { |
| 107 return; | 107 return; |
| 108 } | 108 } |
| 109 if (bSetting) { | 109 if (bSetting) { |
| 110 ThrowScriptErrorMessage(XFA_IDS_UNABLE_SET_LANGUAGE); | 110 Throw(XFA_IDS_UNABLE_SET_LANGUAGE); |
| 111 return; | 111 return; |
| 112 } | 112 } |
| 113 CFX_WideString wsLanguage; | 113 CFX_WideString wsLanguage; |
| 114 pNotify->GetAppProvider()->GetLanguage(wsLanguage); | 114 pNotify->GetAppProvider()->GetLanguage(wsLanguage); |
| 115 FXJSE_Value_SetUTF8String(pValue, FX_UTF8Encode(wsLanguage).AsStringC()); | 115 FXJSE_Value_SetUTF8String(pValue, FX_UTF8Encode(wsLanguage).AsStringC()); |
| 116 } | 116 } |
| 117 void CScript_HostPseudoModel::Script_HostPseudoModel_NumPages( | 117 void CScript_HostPseudoModel::Script_HostPseudoModel_NumPages( |
| 118 CFXJSE_Value* pValue, | 118 CFXJSE_Value* pValue, |
| 119 FX_BOOL bSetting, | 119 FX_BOOL bSetting, |
| 120 XFA_ATTRIBUTE eAttribute) { | 120 XFA_ATTRIBUTE eAttribute) { |
| 121 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 121 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
| 122 if (!pNotify) { | 122 if (!pNotify) { |
| 123 return; | 123 return; |
| 124 } | 124 } |
| 125 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); | 125 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); |
| 126 if (bSetting) { | 126 if (bSetting) { |
| 127 ThrowScriptErrorMessage(XFA_IDS_UNABLE_SET_NUMPAGES); | 127 Throw(XFA_IDS_UNABLE_SET_NUMPAGES); |
| 128 return; | 128 return; |
| 129 } | 129 } |
| 130 int32_t iNumPages = pNotify->GetDocProvider()->CountPages(hDoc); | 130 int32_t iNumPages = pNotify->GetDocProvider()->CountPages(hDoc); |
| 131 FXJSE_Value_SetInteger(pValue, iNumPages); | 131 FXJSE_Value_SetInteger(pValue, iNumPages); |
| 132 } | 132 } |
| 133 void CScript_HostPseudoModel::Script_HostPseudoModel_Platform( | 133 void CScript_HostPseudoModel::Script_HostPseudoModel_Platform( |
| 134 CFXJSE_Value* pValue, | 134 CFXJSE_Value* pValue, |
| 135 FX_BOOL bSetting, | 135 FX_BOOL bSetting, |
| 136 XFA_ATTRIBUTE eAttribute) { | 136 XFA_ATTRIBUTE eAttribute) { |
| 137 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 137 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
| 138 if (!pNotify) { | 138 if (!pNotify) { |
| 139 return; | 139 return; |
| 140 } | 140 } |
| 141 if (bSetting) { | 141 if (bSetting) { |
| 142 ThrowScriptErrorMessage(XFA_IDS_UNABLE_SET_PLATFORM); | 142 Throw(XFA_IDS_UNABLE_SET_PLATFORM); |
| 143 return; | 143 return; |
| 144 } | 144 } |
| 145 CFX_WideString wsPlatform; | 145 CFX_WideString wsPlatform; |
| 146 pNotify->GetAppProvider()->GetPlatform(wsPlatform); | 146 pNotify->GetAppProvider()->GetPlatform(wsPlatform); |
| 147 FXJSE_Value_SetUTF8String(pValue, FX_UTF8Encode(wsPlatform).AsStringC()); | 147 FXJSE_Value_SetUTF8String(pValue, FX_UTF8Encode(wsPlatform).AsStringC()); |
| 148 } | 148 } |
| 149 void CScript_HostPseudoModel::Script_HostPseudoModel_Title( | 149 void CScript_HostPseudoModel::Script_HostPseudoModel_Title( |
| 150 CFXJSE_Value* pValue, | 150 CFXJSE_Value* pValue, |
| 151 FX_BOOL bSetting, | 151 FX_BOOL bSetting, |
| 152 XFA_ATTRIBUTE eAttribute) { | 152 XFA_ATTRIBUTE eAttribute) { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 FX_BOOL bSetting, | 191 FX_BOOL bSetting, |
| 192 XFA_ATTRIBUTE eAttribute) { | 192 XFA_ATTRIBUTE eAttribute) { |
| 193 if (!m_pDocument->GetScriptContext()->IsRunAtClient()) { | 193 if (!m_pDocument->GetScriptContext()->IsRunAtClient()) { |
| 194 return; | 194 return; |
| 195 } | 195 } |
| 196 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 196 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
| 197 if (!pNotify) { | 197 if (!pNotify) { |
| 198 return; | 198 return; |
| 199 } | 199 } |
| 200 if (bSetting) { | 200 if (bSetting) { |
| 201 ThrowScriptErrorMessage(XFA_IDS_UNABLE_SET_VARIATION); | 201 Throw(XFA_IDS_UNABLE_SET_VARIATION); |
| 202 return; | 202 return; |
| 203 } | 203 } |
| 204 CFX_WideString wsVariation; | 204 CFX_WideString wsVariation; |
| 205 pNotify->GetAppProvider()->GetVariation(wsVariation); | 205 pNotify->GetAppProvider()->GetVariation(wsVariation); |
| 206 FXJSE_Value_SetUTF8String(pValue, FX_UTF8Encode(wsVariation).AsStringC()); | 206 FXJSE_Value_SetUTF8String(pValue, FX_UTF8Encode(wsVariation).AsStringC()); |
| 207 } | 207 } |
| 208 void CScript_HostPseudoModel::Script_HostPseudoModel_Version( | 208 void CScript_HostPseudoModel::Script_HostPseudoModel_Version( |
| 209 CFXJSE_Value* pValue, | 209 CFXJSE_Value* pValue, |
| 210 FX_BOOL bSetting, | 210 FX_BOOL bSetting, |
| 211 XFA_ATTRIBUTE eAttribute) { | 211 XFA_ATTRIBUTE eAttribute) { |
| 212 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 212 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
| 213 if (!pNotify) { | 213 if (!pNotify) { |
| 214 return; | 214 return; |
| 215 } | 215 } |
| 216 if (bSetting) { | 216 if (bSetting) { |
| 217 ThrowScriptErrorMessage(XFA_IDS_UNABLE_SET_VERSION); | 217 Throw(XFA_IDS_UNABLE_SET_VERSION); |
| 218 return; | 218 return; |
| 219 } | 219 } |
| 220 CFX_WideString wsVersion; | 220 CFX_WideString wsVersion; |
| 221 pNotify->GetAppProvider()->GetVersion(wsVersion); | 221 pNotify->GetAppProvider()->GetVersion(wsVersion); |
| 222 FXJSE_Value_SetUTF8String(pValue, FX_UTF8Encode(wsVersion).AsStringC()); | 222 FXJSE_Value_SetUTF8String(pValue, FX_UTF8Encode(wsVersion).AsStringC()); |
| 223 } | 223 } |
| 224 void CScript_HostPseudoModel::Script_HostPseudoModel_FoxitVersion( | 224 void CScript_HostPseudoModel::Script_HostPseudoModel_FoxitVersion( |
| 225 CFXJSE_Value* pValue, | 225 CFXJSE_Value* pValue, |
| 226 FX_BOOL bSetting, | 226 FX_BOOL bSetting, |
| 227 XFA_ATTRIBUTE eAttribute) { | 227 XFA_ATTRIBUTE eAttribute) { |
| 228 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 228 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
| 229 if (!pNotify) { | 229 if (!pNotify) { |
| 230 return; | 230 return; |
| 231 } | 231 } |
| 232 if (bSetting) { | 232 if (bSetting) { |
| 233 ThrowScriptErrorMessage(XFA_IDS_UNABLE_SET_VERSION); | 233 Throw(XFA_IDS_UNABLE_SET_VERSION); |
| 234 return; | 234 return; |
| 235 } | 235 } |
| 236 CFX_WideString wsVersion; | 236 CFX_WideString wsVersion; |
| 237 pNotify->GetAppProvider()->GetFoxitVersion(wsVersion); | 237 pNotify->GetAppProvider()->GetFoxitVersion(wsVersion); |
| 238 FXJSE_Value_SetUTF8String(pValue, FX_UTF8Encode(wsVersion).AsStringC()); | 238 FXJSE_Value_SetUTF8String(pValue, FX_UTF8Encode(wsVersion).AsStringC()); |
| 239 } | 239 } |
| 240 void CScript_HostPseudoModel::Script_HostPseudoModel_Name( | 240 void CScript_HostPseudoModel::Script_HostPseudoModel_Name( |
| 241 CFXJSE_Value* pValue, | 241 CFXJSE_Value* pValue, |
| 242 FX_BOOL bSetting, | 242 FX_BOOL bSetting, |
| 243 XFA_ATTRIBUTE eAttribute) { | 243 XFA_ATTRIBUTE eAttribute) { |
| 244 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 244 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
| 245 if (!pNotify) { | 245 if (!pNotify) { |
| 246 return; | 246 return; |
| 247 } | 247 } |
| 248 if (bSetting) { | 248 if (bSetting) { |
| 249 ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET); | 249 Throw(XFA_IDS_INVAlID_PROP_SET); |
| 250 return; | 250 return; |
| 251 } | 251 } |
| 252 CFX_WideString wsAppName; | 252 CFX_WideString wsAppName; |
| 253 pNotify->GetAppProvider()->GetAppName(wsAppName); | 253 pNotify->GetAppProvider()->GetAppName(wsAppName); |
| 254 FXJSE_Value_SetUTF8String(pValue, FX_UTF8Encode(wsAppName).AsStringC()); | 254 FXJSE_Value_SetUTF8String(pValue, FX_UTF8Encode(wsAppName).AsStringC()); |
| 255 } | 255 } |
| 256 void CScript_HostPseudoModel::Script_HostPseudoModel_FoxitName( | 256 void CScript_HostPseudoModel::Script_HostPseudoModel_FoxitName( |
| 257 CFXJSE_Value* pValue, | 257 CFXJSE_Value* pValue, |
| 258 FX_BOOL bSetting, | 258 FX_BOOL bSetting, |
| 259 XFA_ATTRIBUTE eAttribute) { | 259 XFA_ATTRIBUTE eAttribute) { |
| 260 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 260 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
| 261 if (!pNotify) { | 261 if (!pNotify) { |
| 262 return; | 262 return; |
| 263 } | 263 } |
| 264 if (bSetting) { | 264 if (bSetting) { |
| 265 ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET); | 265 Throw(XFA_IDS_INVAlID_PROP_SET); |
| 266 return; | 266 return; |
| 267 } | 267 } |
| 268 CFX_WideString wsFoxitAppName; | 268 CFX_WideString wsFoxitAppName; |
| 269 pNotify->GetAppProvider()->GetFoxitAppName(wsFoxitAppName); | 269 pNotify->GetAppProvider()->GetFoxitAppName(wsFoxitAppName); |
| 270 FXJSE_Value_SetUTF8String(pValue, FX_UTF8Encode(wsFoxitAppName).AsStringC()); | 270 FXJSE_Value_SetUTF8String(pValue, FX_UTF8Encode(wsFoxitAppName).AsStringC()); |
| 271 } | 271 } |
| 272 void CScript_HostPseudoModel::Script_HostPseudoModel_GotoURL( | 272 void CScript_HostPseudoModel::Script_HostPseudoModel_GotoURL( |
| 273 CFXJSE_Arguments* pArguments) { | 273 CFXJSE_Arguments* pArguments) { |
| 274 if (!m_pDocument->GetScriptContext()->IsRunAtClient()) { | 274 if (!m_pDocument->GetScriptContext()->IsRunAtClient()) { |
| 275 return; | 275 return; |
| 276 } | 276 } |
| 277 int32_t iLength = pArguments->GetLength(); | 277 int32_t iLength = pArguments->GetLength(); |
| 278 if (iLength != 1) { | 278 if (iLength != 1) { |
| 279 ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"gotoURL"); | 279 Throw(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"gotoURL"); |
| 280 return; | 280 return; |
| 281 } | 281 } |
| 282 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 282 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
| 283 if (!pNotify) { | 283 if (!pNotify) { |
| 284 return; | 284 return; |
| 285 } | 285 } |
| 286 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); | 286 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); |
| 287 CFX_WideString wsURL; | 287 CFX_WideString wsURL; |
| 288 if (iLength >= 1) { | 288 if (iLength >= 1) { |
| 289 CFX_ByteString bsURL = pArguments->GetUTF8String(0); | 289 CFX_ByteString bsURL = pArguments->GetUTF8String(0); |
| 290 wsURL = CFX_WideString::FromUTF8(bsURL.AsStringC()); | 290 wsURL = CFX_WideString::FromUTF8(bsURL.AsStringC()); |
| 291 } | 291 } |
| 292 pNotify->GetDocProvider()->GotoURL(hDoc, wsURL); | 292 pNotify->GetDocProvider()->GotoURL(hDoc, wsURL); |
| 293 } | 293 } |
| 294 void CScript_HostPseudoModel::Script_HostPseudoModel_OpenList( | 294 void CScript_HostPseudoModel::Script_HostPseudoModel_OpenList( |
| 295 CFXJSE_Arguments* pArguments) { | 295 CFXJSE_Arguments* pArguments) { |
| 296 if (!m_pDocument->GetScriptContext()->IsRunAtClient()) { | 296 if (!m_pDocument->GetScriptContext()->IsRunAtClient()) { |
| 297 return; | 297 return; |
| 298 } | 298 } |
| 299 int32_t iLength = pArguments->GetLength(); | 299 int32_t iLength = pArguments->GetLength(); |
| 300 if (iLength != 1) { | 300 if (iLength != 1) { |
| 301 ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"openList"); | 301 Throw(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"openList"); |
| 302 return; | 302 return; |
| 303 } | 303 } |
| 304 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 304 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
| 305 if (!pNotify) { | 305 if (!pNotify) { |
| 306 return; | 306 return; |
| 307 } | 307 } |
| 308 CXFA_Node* pNode = NULL; | 308 CXFA_Node* pNode = NULL; |
| 309 if (iLength >= 1) { | 309 if (iLength >= 1) { |
| 310 std::unique_ptr<CFXJSE_Value> pValue(pArguments->GetValue(0)); | 310 std::unique_ptr<CFXJSE_Value> pValue(pArguments->GetValue(0)); |
| 311 if (FXJSE_Value_IsObject(pValue.get())) { | 311 if (FXJSE_Value_IsObject(pValue.get())) { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 if (!hWidget) { | 343 if (!hWidget) { |
| 344 return; | 344 return; |
| 345 } | 345 } |
| 346 pNotify->GetDocProvider()->SetFocusWidget(pNotify->GetHDOC(), hWidget); | 346 pNotify->GetDocProvider()->SetFocusWidget(pNotify->GetHDOC(), hWidget); |
| 347 pNotify->OpenDropDownList(hWidget); | 347 pNotify->OpenDropDownList(hWidget); |
| 348 } | 348 } |
| 349 void CScript_HostPseudoModel::Script_HostPseudoModel_Response( | 349 void CScript_HostPseudoModel::Script_HostPseudoModel_Response( |
| 350 CFXJSE_Arguments* pArguments) { | 350 CFXJSE_Arguments* pArguments) { |
| 351 int32_t iLength = pArguments->GetLength(); | 351 int32_t iLength = pArguments->GetLength(); |
| 352 if (iLength < 1 || iLength > 4) { | 352 if (iLength < 1 || iLength > 4) { |
| 353 ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"response"); | 353 Throw(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"response"); |
| 354 return; | 354 return; |
| 355 } | 355 } |
| 356 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 356 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
| 357 if (!pNotify) { | 357 if (!pNotify) { |
| 358 return; | 358 return; |
| 359 } | 359 } |
| 360 CFX_WideString wsQuestion; | 360 CFX_WideString wsQuestion; |
| 361 CFX_WideString wsTitle; | 361 CFX_WideString wsTitle; |
| 362 CFX_WideString wsDefaultAnswer; | 362 CFX_WideString wsDefaultAnswer; |
| 363 FX_BOOL bMark = FALSE; | 363 FX_BOOL bMark = FALSE; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 } | 416 } |
| 417 wsFilter.ReleaseBuffer(nCount); | 417 wsFilter.ReleaseBuffer(nCount); |
| 418 wsFilter.TrimLeft(); | 418 wsFilter.TrimLeft(); |
| 419 wsFilter.TrimRight(); | 419 wsFilter.TrimRight(); |
| 420 return nStart; | 420 return nStart; |
| 421 } | 421 } |
| 422 void CScript_HostPseudoModel::Script_HostPseudoModel_ResetData( | 422 void CScript_HostPseudoModel::Script_HostPseudoModel_ResetData( |
| 423 CFXJSE_Arguments* pArguments) { | 423 CFXJSE_Arguments* pArguments) { |
| 424 int32_t iLength = pArguments->GetLength(); | 424 int32_t iLength = pArguments->GetLength(); |
| 425 if (iLength < 0 || iLength > 1) { | 425 if (iLength < 0 || iLength > 1) { |
| 426 ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"resetData"); | 426 Throw(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"resetData"); |
| 427 return; | 427 return; |
| 428 } | 428 } |
| 429 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 429 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
| 430 if (!pNotify) { | 430 if (!pNotify) { |
| 431 return; | 431 return; |
| 432 } | 432 } |
| 433 CFX_WideString wsExpression; | 433 CFX_WideString wsExpression; |
| 434 if (iLength >= 1) { | 434 if (iLength >= 1) { |
| 435 CFX_ByteString bsExpression = pArguments->GetUTF8String(0); | 435 CFX_ByteString bsExpression = pArguments->GetUTF8String(0); |
| 436 wsExpression = CFX_WideString::FromUTF8(bsExpression.AsStringC()); | 436 wsExpression = CFX_WideString::FromUTF8(bsExpression.AsStringC()); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 468 pNotify->ResetData(); | 468 pNotify->ResetData(); |
| 469 } | 469 } |
| 470 } | 470 } |
| 471 void CScript_HostPseudoModel::Script_HostPseudoModel_Beep( | 471 void CScript_HostPseudoModel::Script_HostPseudoModel_Beep( |
| 472 CFXJSE_Arguments* pArguments) { | 472 CFXJSE_Arguments* pArguments) { |
| 473 if (!m_pDocument->GetScriptContext()->IsRunAtClient()) { | 473 if (!m_pDocument->GetScriptContext()->IsRunAtClient()) { |
| 474 return; | 474 return; |
| 475 } | 475 } |
| 476 int32_t iLength = pArguments->GetLength(); | 476 int32_t iLength = pArguments->GetLength(); |
| 477 if (iLength < 0 || iLength > 1) { | 477 if (iLength < 0 || iLength > 1) { |
| 478 ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"beep"); | 478 Throw(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"beep"); |
| 479 return; | 479 return; |
| 480 } | 480 } |
| 481 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 481 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
| 482 if (!pNotify) { | 482 if (!pNotify) { |
| 483 return; | 483 return; |
| 484 } | 484 } |
| 485 uint32_t dwType = 4; | 485 uint32_t dwType = 4; |
| 486 if (iLength >= 1) { | 486 if (iLength >= 1) { |
| 487 dwType = pArguments->GetInt32(0); | 487 dwType = pArguments->GetInt32(0); |
| 488 } | 488 } |
| 489 pNotify->GetAppProvider()->Beep(dwType); | 489 pNotify->GetAppProvider()->Beep(dwType); |
| 490 } | 490 } |
| 491 void CScript_HostPseudoModel::Script_HostPseudoModel_SetFocus( | 491 void CScript_HostPseudoModel::Script_HostPseudoModel_SetFocus( |
| 492 CFXJSE_Arguments* pArguments) { | 492 CFXJSE_Arguments* pArguments) { |
| 493 if (!m_pDocument->GetScriptContext()->IsRunAtClient()) { | 493 if (!m_pDocument->GetScriptContext()->IsRunAtClient()) { |
| 494 return; | 494 return; |
| 495 } | 495 } |
| 496 int32_t iLength = pArguments->GetLength(); | 496 int32_t iLength = pArguments->GetLength(); |
| 497 if (iLength != 1) { | 497 if (iLength != 1) { |
| 498 ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"setFocus"); | 498 Throw(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"setFocus"); |
| 499 return; | 499 return; |
| 500 } | 500 } |
| 501 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 501 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
| 502 if (!pNotify) { | 502 if (!pNotify) { |
| 503 return; | 503 return; |
| 504 } | 504 } |
| 505 CXFA_Node* pNode = NULL; | 505 CXFA_Node* pNode = NULL; |
| 506 if (iLength >= 1) { | 506 if (iLength >= 1) { |
| 507 std::unique_ptr<CFXJSE_Value> pValue(pArguments->GetValue(0)); | 507 std::unique_ptr<CFXJSE_Value> pValue(pArguments->GetValue(0)); |
| 508 if (FXJSE_Value_IsObject(pValue.get())) { | 508 if (FXJSE_Value_IsObject(pValue.get())) { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 546 FXJSE_Value_Set(pArguments->GetReturnValue(), | 546 FXJSE_Value_Set(pArguments->GetReturnValue(), |
| 547 m_pDocument->GetScriptContext()->GetJSValueFromMap(pNode)); | 547 m_pDocument->GetScriptContext()->GetJSValueFromMap(pNode)); |
| 548 } | 548 } |
| 549 void CScript_HostPseudoModel::Script_HostPseudoModel_MessageBox( | 549 void CScript_HostPseudoModel::Script_HostPseudoModel_MessageBox( |
| 550 CFXJSE_Arguments* pArguments) { | 550 CFXJSE_Arguments* pArguments) { |
| 551 if (!m_pDocument->GetScriptContext()->IsRunAtClient()) { | 551 if (!m_pDocument->GetScriptContext()->IsRunAtClient()) { |
| 552 return; | 552 return; |
| 553 } | 553 } |
| 554 int32_t iLength = pArguments->GetLength(); | 554 int32_t iLength = pArguments->GetLength(); |
| 555 if (iLength < 1 || iLength > 4) { | 555 if (iLength < 1 || iLength > 4) { |
| 556 ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"messageBox"); | 556 Throw(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"messageBox"); |
| 557 return; | 557 return; |
| 558 } | 558 } |
| 559 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 559 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
| 560 if (!pNotify) { | 560 if (!pNotify) { |
| 561 return; | 561 return; |
| 562 } | 562 } |
| 563 CFX_WideString wsMessage; | 563 CFX_WideString wsMessage; |
| 564 CFX_WideString bsTitle; | 564 CFX_WideString bsTitle; |
| 565 uint32_t dwMessageType = XFA_MBICON_Error; | 565 uint32_t dwMessageType = XFA_MBICON_Error; |
| 566 uint32_t dwButtonType = XFA_MB_OK; | 566 uint32_t dwButtonType = XFA_MB_OK; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 600 if (pArguments == NULL || iArgIndex < 0) { | 600 if (pArguments == NULL || iArgIndex < 0) { |
| 601 return FALSE; | 601 return FALSE; |
| 602 } | 602 } |
| 603 FX_BOOL bIsJsType = FALSE; | 603 FX_BOOL bIsJsType = FALSE; |
| 604 if (m_pDocument->GetScriptContext()->GetType() == | 604 if (m_pDocument->GetScriptContext()->GetType() == |
| 605 XFA_SCRIPTLANGTYPE_Javascript) { | 605 XFA_SCRIPTLANGTYPE_Javascript) { |
| 606 bIsJsType = TRUE; | 606 bIsJsType = TRUE; |
| 607 } | 607 } |
| 608 std::unique_ptr<CFXJSE_Value> pValueArg(pArguments->GetValue(iArgIndex)); | 608 std::unique_ptr<CFXJSE_Value> pValueArg(pArguments->GetValue(iArgIndex)); |
| 609 if (!FXJSE_Value_IsUTF8String(pValueArg.get()) && bIsJsType) { | 609 if (!FXJSE_Value_IsUTF8String(pValueArg.get()) && bIsJsType) { |
| 610 ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); | 610 Throw(XFA_IDS_ARGUMENT_MISMATCH); |
| 611 return FALSE; | 611 return FALSE; |
| 612 } | 612 } |
| 613 if (FXJSE_Value_IsNull(pValueArg.get())) { | 613 if (FXJSE_Value_IsNull(pValueArg.get())) { |
| 614 wsValue = FX_WSTRC(L""); | 614 wsValue = FX_WSTRC(L""); |
| 615 } else { | 615 } else { |
| 616 CFX_ByteString byMessage; | 616 CFX_ByteString byMessage; |
| 617 FXJSE_Value_ToUTF8String(pValueArg.get(), byMessage); | 617 FXJSE_Value_ToUTF8String(pValueArg.get(), byMessage); |
| 618 wsValue = CFX_WideString::FromUTF8(byMessage.AsStringC()); | 618 wsValue = CFX_WideString::FromUTF8(byMessage.AsStringC()); |
| 619 } | 619 } |
| 620 return TRUE; | 620 return TRUE; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 631 FXJSE_Value_SetInteger(pValue, iValue); | 631 FXJSE_Value_SetInteger(pValue, iValue); |
| 632 } | 632 } |
| 633 } | 633 } |
| 634 void CScript_HostPseudoModel::Script_HostPseudoModel_Print( | 634 void CScript_HostPseudoModel::Script_HostPseudoModel_Print( |
| 635 CFXJSE_Arguments* pArguments) { | 635 CFXJSE_Arguments* pArguments) { |
| 636 if (!m_pDocument->GetScriptContext()->IsRunAtClient()) { | 636 if (!m_pDocument->GetScriptContext()->IsRunAtClient()) { |
| 637 return; | 637 return; |
| 638 } | 638 } |
| 639 int32_t iLength = pArguments->GetLength(); | 639 int32_t iLength = pArguments->GetLength(); |
| 640 if (iLength != 8) { | 640 if (iLength != 8) { |
| 641 ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"print"); | 641 Throw(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"print"); |
| 642 return; | 642 return; |
| 643 } | 643 } |
| 644 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 644 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
| 645 if (!pNotify) { | 645 if (!pNotify) { |
| 646 return; | 646 return; |
| 647 } | 647 } |
| 648 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); | 648 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); |
| 649 uint32_t dwOptions = 0; | 649 uint32_t dwOptions = 0; |
| 650 FX_BOOL bShowDialog = TRUE; | 650 FX_BOOL bShowDialog = TRUE; |
| 651 if (iLength >= 1) { | 651 if (iLength >= 1) { |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 697 } | 697 } |
| 698 if (bPrintAnnot) { | 698 if (bPrintAnnot) { |
| 699 dwOptions |= XFA_PRINTOPT_PrintAnnot; | 699 dwOptions |= XFA_PRINTOPT_PrintAnnot; |
| 700 } | 700 } |
| 701 pNotify->GetDocProvider()->Print(hDoc, nStartPage, nEndPage, dwOptions); | 701 pNotify->GetDocProvider()->Print(hDoc, nStartPage, nEndPage, dwOptions); |
| 702 } | 702 } |
| 703 void CScript_HostPseudoModel::Script_HostPseudoModel_ImportData( | 703 void CScript_HostPseudoModel::Script_HostPseudoModel_ImportData( |
| 704 CFXJSE_Arguments* pArguments) { | 704 CFXJSE_Arguments* pArguments) { |
| 705 int32_t iLength = pArguments->GetLength(); | 705 int32_t iLength = pArguments->GetLength(); |
| 706 if (iLength < 0 || iLength > 1) { | 706 if (iLength < 0 || iLength > 1) { |
| 707 ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"importData"); | 707 Throw(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"importData"); |
| 708 return; | 708 return; |
| 709 } | 709 } |
| 710 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 710 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
| 711 if (!pNotify) { | 711 if (!pNotify) { |
| 712 return; | 712 return; |
| 713 } | 713 } |
| 714 CFX_WideString wsFilePath; | 714 CFX_WideString wsFilePath; |
| 715 if (iLength > 0) { | 715 if (iLength > 0) { |
| 716 CFX_ByteString bsFilePath = pArguments->GetUTF8String(0); | 716 CFX_ByteString bsFilePath = pArguments->GetUTF8String(0); |
| 717 wsFilePath = CFX_WideString::FromUTF8(bsFilePath.AsStringC()); | 717 wsFilePath = CFX_WideString::FromUTF8(bsFilePath.AsStringC()); |
| 718 } | 718 } |
| 719 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); | 719 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); |
| 720 pNotify->GetDocProvider()->ImportData(hDoc, wsFilePath); | 720 pNotify->GetDocProvider()->ImportData(hDoc, wsFilePath); |
| 721 } | 721 } |
| 722 void CScript_HostPseudoModel::Script_HostPseudoModel_ExportData( | 722 void CScript_HostPseudoModel::Script_HostPseudoModel_ExportData( |
| 723 CFXJSE_Arguments* pArguments) { | 723 CFXJSE_Arguments* pArguments) { |
| 724 int32_t iLength = pArguments->GetLength(); | 724 int32_t iLength = pArguments->GetLength(); |
| 725 if (iLength < 0 || iLength > 2) { | 725 if (iLength < 0 || iLength > 2) { |
| 726 ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"exportData"); | 726 Throw(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"exportData"); |
| 727 return; | 727 return; |
| 728 } | 728 } |
| 729 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 729 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
| 730 if (!pNotify) { | 730 if (!pNotify) { |
| 731 return; | 731 return; |
| 732 } | 732 } |
| 733 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); | 733 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); |
| 734 CFX_WideString wsFilePath; | 734 CFX_WideString wsFilePath; |
| 735 FX_BOOL bXDP = TRUE; | 735 FX_BOOL bXDP = TRUE; |
| 736 if (iLength >= 1) { | 736 if (iLength >= 1) { |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 782 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 782 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
| 783 if (!pNotify) { | 783 if (!pNotify) { |
| 784 return; | 784 return; |
| 785 } | 785 } |
| 786 CFX_WideString wsDataTime = pNotify->GetCurrentDateTime(); | 786 CFX_WideString wsDataTime = pNotify->GetCurrentDateTime(); |
| 787 CFXJSE_Value* pValue = pArguments->GetReturnValue(); | 787 CFXJSE_Value* pValue = pArguments->GetReturnValue(); |
| 788 if (pValue) { | 788 if (pValue) { |
| 789 FXJSE_Value_SetUTF8String(pValue, FX_UTF8Encode(wsDataTime).AsStringC()); | 789 FXJSE_Value_SetUTF8String(pValue, FX_UTF8Encode(wsDataTime).AsStringC()); |
| 790 } | 790 } |
| 791 } | 791 } |
| OLD | NEW |