| 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 ThrowException(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 ThrowException(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 ThrowException(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 ThrowException(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 ThrowException(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 ThrowException(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 ThrowException(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 ThrowException(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 ThrowException(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 ThrowException(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 ThrowException(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 ThrowException(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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 if (!hWidget) { | 344 if (!hWidget) { |
| 345 return; | 345 return; |
| 346 } | 346 } |
| 347 pNotify->GetDocProvider()->SetFocusWidget(pNotify->GetHDOC(), hWidget); | 347 pNotify->GetDocProvider()->SetFocusWidget(pNotify->GetHDOC(), hWidget); |
| 348 pNotify->OpenDropDownList(hWidget); | 348 pNotify->OpenDropDownList(hWidget); |
| 349 } | 349 } |
| 350 void CScript_HostPseudoModel::Script_HostPseudoModel_Response( | 350 void CScript_HostPseudoModel::Script_HostPseudoModel_Response( |
| 351 CFXJSE_Arguments* pArguments) { | 351 CFXJSE_Arguments* pArguments) { |
| 352 int32_t iLength = pArguments->GetLength(); | 352 int32_t iLength = pArguments->GetLength(); |
| 353 if (iLength < 1 || iLength > 4) { | 353 if (iLength < 1 || iLength > 4) { |
| 354 ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"response"); | 354 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"response"); |
| 355 return; | 355 return; |
| 356 } | 356 } |
| 357 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 357 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
| 358 if (!pNotify) { | 358 if (!pNotify) { |
| 359 return; | 359 return; |
| 360 } | 360 } |
| 361 CFX_WideString wsQuestion; | 361 CFX_WideString wsQuestion; |
| 362 CFX_WideString wsTitle; | 362 CFX_WideString wsTitle; |
| 363 CFX_WideString wsDefaultAnswer; | 363 CFX_WideString wsDefaultAnswer; |
| 364 FX_BOOL bMark = FALSE; | 364 FX_BOOL bMark = FALSE; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 417 } | 417 } |
| 418 wsFilter.ReleaseBuffer(nCount); | 418 wsFilter.ReleaseBuffer(nCount); |
| 419 wsFilter.TrimLeft(); | 419 wsFilter.TrimLeft(); |
| 420 wsFilter.TrimRight(); | 420 wsFilter.TrimRight(); |
| 421 return nStart; | 421 return nStart; |
| 422 } | 422 } |
| 423 void CScript_HostPseudoModel::Script_HostPseudoModel_ResetData( | 423 void CScript_HostPseudoModel::Script_HostPseudoModel_ResetData( |
| 424 CFXJSE_Arguments* pArguments) { | 424 CFXJSE_Arguments* pArguments) { |
| 425 int32_t iLength = pArguments->GetLength(); | 425 int32_t iLength = pArguments->GetLength(); |
| 426 if (iLength < 0 || iLength > 1) { | 426 if (iLength < 0 || iLength > 1) { |
| 427 ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"resetData"); | 427 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"resetData"); |
| 428 return; | 428 return; |
| 429 } | 429 } |
| 430 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 430 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
| 431 if (!pNotify) { | 431 if (!pNotify) { |
| 432 return; | 432 return; |
| 433 } | 433 } |
| 434 CFX_WideString wsExpression; | 434 CFX_WideString wsExpression; |
| 435 if (iLength >= 1) { | 435 if (iLength >= 1) { |
| 436 CFX_ByteString bsExpression = pArguments->GetUTF8String(0); | 436 CFX_ByteString bsExpression = pArguments->GetUTF8String(0); |
| 437 wsExpression = CFX_WideString::FromUTF8(bsExpression.AsStringC()); | 437 wsExpression = CFX_WideString::FromUTF8(bsExpression.AsStringC()); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 469 pNotify->ResetData(); | 469 pNotify->ResetData(); |
| 470 } | 470 } |
| 471 } | 471 } |
| 472 void CScript_HostPseudoModel::Script_HostPseudoModel_Beep( | 472 void CScript_HostPseudoModel::Script_HostPseudoModel_Beep( |
| 473 CFXJSE_Arguments* pArguments) { | 473 CFXJSE_Arguments* pArguments) { |
| 474 if (!m_pDocument->GetScriptContext()->IsRunAtClient()) { | 474 if (!m_pDocument->GetScriptContext()->IsRunAtClient()) { |
| 475 return; | 475 return; |
| 476 } | 476 } |
| 477 int32_t iLength = pArguments->GetLength(); | 477 int32_t iLength = pArguments->GetLength(); |
| 478 if (iLength < 0 || iLength > 1) { | 478 if (iLength < 0 || iLength > 1) { |
| 479 ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"beep"); | 479 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"beep"); |
| 480 return; | 480 return; |
| 481 } | 481 } |
| 482 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 482 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
| 483 if (!pNotify) { | 483 if (!pNotify) { |
| 484 return; | 484 return; |
| 485 } | 485 } |
| 486 uint32_t dwType = 4; | 486 uint32_t dwType = 4; |
| 487 if (iLength >= 1) { | 487 if (iLength >= 1) { |
| 488 dwType = pArguments->GetInt32(0); | 488 dwType = pArguments->GetInt32(0); |
| 489 } | 489 } |
| 490 pNotify->GetAppProvider()->Beep(dwType); | 490 pNotify->GetAppProvider()->Beep(dwType); |
| 491 } | 491 } |
| 492 void CScript_HostPseudoModel::Script_HostPseudoModel_SetFocus( | 492 void CScript_HostPseudoModel::Script_HostPseudoModel_SetFocus( |
| 493 CFXJSE_Arguments* pArguments) { | 493 CFXJSE_Arguments* pArguments) { |
| 494 if (!m_pDocument->GetScriptContext()->IsRunAtClient()) { | 494 if (!m_pDocument->GetScriptContext()->IsRunAtClient()) { |
| 495 return; | 495 return; |
| 496 } | 496 } |
| 497 int32_t iLength = pArguments->GetLength(); | 497 int32_t iLength = pArguments->GetLength(); |
| 498 if (iLength != 1) { | 498 if (iLength != 1) { |
| 499 ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"setFocus"); | 499 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"setFocus"); |
| 500 return; | 500 return; |
| 501 } | 501 } |
| 502 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 502 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
| 503 if (!pNotify) { | 503 if (!pNotify) { |
| 504 return; | 504 return; |
| 505 } | 505 } |
| 506 CXFA_Node* pNode = NULL; | 506 CXFA_Node* pNode = NULL; |
| 507 if (iLength >= 1) { | 507 if (iLength >= 1) { |
| 508 std::unique_ptr<CFXJSE_Value> pValue(pArguments->GetValue(0)); | 508 std::unique_ptr<CFXJSE_Value> pValue(pArguments->GetValue(0)); |
| 509 if (FXJSE_Value_IsObject(pValue.get())) { | 509 if (FXJSE_Value_IsObject(pValue.get())) { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 548 FXJSE_Value_Set(pArguments->GetReturnValue(), | 548 FXJSE_Value_Set(pArguments->GetReturnValue(), |
| 549 m_pDocument->GetScriptContext()->GetJSValueFromMap(pNode)); | 549 m_pDocument->GetScriptContext()->GetJSValueFromMap(pNode)); |
| 550 } | 550 } |
| 551 void CScript_HostPseudoModel::Script_HostPseudoModel_MessageBox( | 551 void CScript_HostPseudoModel::Script_HostPseudoModel_MessageBox( |
| 552 CFXJSE_Arguments* pArguments) { | 552 CFXJSE_Arguments* pArguments) { |
| 553 if (!m_pDocument->GetScriptContext()->IsRunAtClient()) { | 553 if (!m_pDocument->GetScriptContext()->IsRunAtClient()) { |
| 554 return; | 554 return; |
| 555 } | 555 } |
| 556 int32_t iLength = pArguments->GetLength(); | 556 int32_t iLength = pArguments->GetLength(); |
| 557 if (iLength < 1 || iLength > 4) { | 557 if (iLength < 1 || iLength > 4) { |
| 558 ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"messageBox"); | 558 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"messageBox"); |
| 559 return; | 559 return; |
| 560 } | 560 } |
| 561 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 561 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
| 562 if (!pNotify) { | 562 if (!pNotify) { |
| 563 return; | 563 return; |
| 564 } | 564 } |
| 565 CFX_WideString wsMessage; | 565 CFX_WideString wsMessage; |
| 566 CFX_WideString bsTitle; | 566 CFX_WideString bsTitle; |
| 567 uint32_t dwMessageType = XFA_MBICON_Error; | 567 uint32_t dwMessageType = XFA_MBICON_Error; |
| 568 uint32_t dwButtonType = XFA_MB_OK; | 568 uint32_t dwButtonType = XFA_MB_OK; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 602 if (pArguments == NULL || iArgIndex < 0) { | 602 if (pArguments == NULL || iArgIndex < 0) { |
| 603 return FALSE; | 603 return FALSE; |
| 604 } | 604 } |
| 605 FX_BOOL bIsJsType = FALSE; | 605 FX_BOOL bIsJsType = FALSE; |
| 606 if (m_pDocument->GetScriptContext()->GetType() == | 606 if (m_pDocument->GetScriptContext()->GetType() == |
| 607 XFA_SCRIPTLANGTYPE_Javascript) { | 607 XFA_SCRIPTLANGTYPE_Javascript) { |
| 608 bIsJsType = TRUE; | 608 bIsJsType = TRUE; |
| 609 } | 609 } |
| 610 std::unique_ptr<CFXJSE_Value> pValueArg(pArguments->GetValue(iArgIndex)); | 610 std::unique_ptr<CFXJSE_Value> pValueArg(pArguments->GetValue(iArgIndex)); |
| 611 if (!FXJSE_Value_IsUTF8String(pValueArg.get()) && bIsJsType) { | 611 if (!FXJSE_Value_IsUTF8String(pValueArg.get()) && bIsJsType) { |
| 612 ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); | 612 ThrowException(XFA_IDS_ARGUMENT_MISMATCH); |
| 613 return FALSE; | 613 return FALSE; |
| 614 } | 614 } |
| 615 if (FXJSE_Value_IsNull(pValueArg.get())) { | 615 if (FXJSE_Value_IsNull(pValueArg.get())) { |
| 616 wsValue = FX_WSTRC(L""); | 616 wsValue = FX_WSTRC(L""); |
| 617 } else { | 617 } else { |
| 618 CFX_ByteString byMessage; | 618 CFX_ByteString byMessage; |
| 619 FXJSE_Value_ToUTF8String(pValueArg.get(), byMessage); | 619 FXJSE_Value_ToUTF8String(pValueArg.get(), byMessage); |
| 620 wsValue = CFX_WideString::FromUTF8(byMessage.AsStringC()); | 620 wsValue = CFX_WideString::FromUTF8(byMessage.AsStringC()); |
| 621 } | 621 } |
| 622 return TRUE; | 622 return TRUE; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 633 FXJSE_Value_SetInteger(pValue, iValue); | 633 FXJSE_Value_SetInteger(pValue, iValue); |
| 634 } | 634 } |
| 635 } | 635 } |
| 636 void CScript_HostPseudoModel::Script_HostPseudoModel_Print( | 636 void CScript_HostPseudoModel::Script_HostPseudoModel_Print( |
| 637 CFXJSE_Arguments* pArguments) { | 637 CFXJSE_Arguments* pArguments) { |
| 638 if (!m_pDocument->GetScriptContext()->IsRunAtClient()) { | 638 if (!m_pDocument->GetScriptContext()->IsRunAtClient()) { |
| 639 return; | 639 return; |
| 640 } | 640 } |
| 641 int32_t iLength = pArguments->GetLength(); | 641 int32_t iLength = pArguments->GetLength(); |
| 642 if (iLength != 8) { | 642 if (iLength != 8) { |
| 643 ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"print"); | 643 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"print"); |
| 644 return; | 644 return; |
| 645 } | 645 } |
| 646 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 646 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
| 647 if (!pNotify) { | 647 if (!pNotify) { |
| 648 return; | 648 return; |
| 649 } | 649 } |
| 650 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); | 650 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); |
| 651 uint32_t dwOptions = 0; | 651 uint32_t dwOptions = 0; |
| 652 FX_BOOL bShowDialog = TRUE; | 652 FX_BOOL bShowDialog = TRUE; |
| 653 if (iLength >= 1) { | 653 if (iLength >= 1) { |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 699 } | 699 } |
| 700 if (bPrintAnnot) { | 700 if (bPrintAnnot) { |
| 701 dwOptions |= XFA_PRINTOPT_PrintAnnot; | 701 dwOptions |= XFA_PRINTOPT_PrintAnnot; |
| 702 } | 702 } |
| 703 pNotify->GetDocProvider()->Print(hDoc, nStartPage, nEndPage, dwOptions); | 703 pNotify->GetDocProvider()->Print(hDoc, nStartPage, nEndPage, dwOptions); |
| 704 } | 704 } |
| 705 void CScript_HostPseudoModel::Script_HostPseudoModel_ImportData( | 705 void CScript_HostPseudoModel::Script_HostPseudoModel_ImportData( |
| 706 CFXJSE_Arguments* pArguments) { | 706 CFXJSE_Arguments* pArguments) { |
| 707 int32_t iLength = pArguments->GetLength(); | 707 int32_t iLength = pArguments->GetLength(); |
| 708 if (iLength < 0 || iLength > 1) { | 708 if (iLength < 0 || iLength > 1) { |
| 709 ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"importData"); | 709 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"importData"); |
| 710 return; | 710 return; |
| 711 } | 711 } |
| 712 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 712 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
| 713 if (!pNotify) { | 713 if (!pNotify) { |
| 714 return; | 714 return; |
| 715 } | 715 } |
| 716 CFX_WideString wsFilePath; | 716 CFX_WideString wsFilePath; |
| 717 if (iLength > 0) { | 717 if (iLength > 0) { |
| 718 CFX_ByteString bsFilePath = pArguments->GetUTF8String(0); | 718 CFX_ByteString bsFilePath = pArguments->GetUTF8String(0); |
| 719 wsFilePath = CFX_WideString::FromUTF8(bsFilePath.AsStringC()); | 719 wsFilePath = CFX_WideString::FromUTF8(bsFilePath.AsStringC()); |
| 720 } | 720 } |
| 721 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); | 721 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); |
| 722 pNotify->GetDocProvider()->ImportData(hDoc, wsFilePath); | 722 pNotify->GetDocProvider()->ImportData(hDoc, wsFilePath); |
| 723 } | 723 } |
| 724 void CScript_HostPseudoModel::Script_HostPseudoModel_ExportData( | 724 void CScript_HostPseudoModel::Script_HostPseudoModel_ExportData( |
| 725 CFXJSE_Arguments* pArguments) { | 725 CFXJSE_Arguments* pArguments) { |
| 726 int32_t iLength = pArguments->GetLength(); | 726 int32_t iLength = pArguments->GetLength(); |
| 727 if (iLength < 0 || iLength > 2) { | 727 if (iLength < 0 || iLength > 2) { |
| 728 ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"exportData"); | 728 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"exportData"); |
| 729 return; | 729 return; |
| 730 } | 730 } |
| 731 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 731 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
| 732 if (!pNotify) { | 732 if (!pNotify) { |
| 733 return; | 733 return; |
| 734 } | 734 } |
| 735 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); | 735 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); |
| 736 CFX_WideString wsFilePath; | 736 CFX_WideString wsFilePath; |
| 737 FX_BOOL bXDP = TRUE; | 737 FX_BOOL bXDP = TRUE; |
| 738 if (iLength >= 1) { | 738 if (iLength >= 1) { |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 784 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 784 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
| 785 if (!pNotify) { | 785 if (!pNotify) { |
| 786 return; | 786 return; |
| 787 } | 787 } |
| 788 CFX_WideString wsDataTime = pNotify->GetCurrentDateTime(); | 788 CFX_WideString wsDataTime = pNotify->GetCurrentDateTime(); |
| 789 CFXJSE_Value* pValue = pArguments->GetReturnValue(); | 789 CFXJSE_Value* pValue = pArguments->GetReturnValue(); |
| 790 if (pValue) { | 790 if (pValue) { |
| 791 FXJSE_Value_SetUTF8String(pValue, FX_UTF8Encode(wsDataTime).AsStringC()); | 791 FXJSE_Value_SetUTF8String(pValue, FX_UTF8Encode(wsDataTime).AsStringC()); |
| 792 } | 792 } |
| 793 } | 793 } |
| OLD | NEW |