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 "fxjse/include/cfxjse_arguments.h" | 9 #include "fxjse/include/cfxjse_arguments.h" |
10 #include "xfa/fxfa/app/xfa_ffnotify.h" | 10 #include "xfa/fxfa/app/xfa_ffnotify.h" |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 } | 298 } |
299 int32_t iLength = pArguments->GetLength(); | 299 int32_t iLength = pArguments->GetLength(); |
300 if (iLength != 1) { | 300 if (iLength != 1) { |
301 ThrowException(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 = nullptr; |
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 (pValue->IsObject()) { | 311 if (pValue->IsObject()) { |
312 pNode = ToNode(pValue.get(), nullptr); | 312 pNode = ToNode(pValue.get(), nullptr); |
313 } else if (pValue->IsString()) { | 313 } else if (pValue->IsString()) { |
314 CXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext(); | 314 CXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext(); |
315 if (!pScriptContext) | 315 if (!pScriptContext) |
316 return; | 316 return; |
317 | 317 |
318 CXFA_Object* pObject = pScriptContext->GetThisObject(); | 318 CXFA_Object* pObject = pScriptContext->GetThisObject(); |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
428 if (iLength >= 1) { | 428 if (iLength >= 1) { |
429 CFX_ByteString bsExpression = pArguments->GetUTF8String(0); | 429 CFX_ByteString bsExpression = pArguments->GetUTF8String(0); |
430 wsExpression = CFX_WideString::FromUTF8(bsExpression.AsStringC()); | 430 wsExpression = CFX_WideString::FromUTF8(bsExpression.AsStringC()); |
431 } | 431 } |
432 if (wsExpression.IsEmpty()) { | 432 if (wsExpression.IsEmpty()) { |
433 pNotify->ResetData(); | 433 pNotify->ResetData(); |
434 return; | 434 return; |
435 } | 435 } |
436 int32_t iStart = 0; | 436 int32_t iStart = 0; |
437 CFX_WideString wsName; | 437 CFX_WideString wsName; |
438 CXFA_Node* pNode = NULL; | 438 CXFA_Node* pNode = nullptr; |
439 int32_t iExpLength = wsExpression.GetLength(); | 439 int32_t iExpLength = wsExpression.GetLength(); |
440 while (iStart < iExpLength) { | 440 while (iStart < iExpLength) { |
441 iStart = XFA_FilterName(wsExpression.AsStringC(), iStart, wsName); | 441 iStart = XFA_FilterName(wsExpression.AsStringC(), iStart, wsName); |
442 CXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext(); | 442 CXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext(); |
443 if (!pScriptContext) { | 443 if (!pScriptContext) { |
444 return; | 444 return; |
445 } | 445 } |
446 CXFA_Object* pObject = pScriptContext->GetThisObject(); | 446 CXFA_Object* pObject = pScriptContext->GetThisObject(); |
447 if (!pObject) { | 447 if (!pObject) { |
448 return; | 448 return; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
489 } | 489 } |
490 int32_t iLength = pArguments->GetLength(); | 490 int32_t iLength = pArguments->GetLength(); |
491 if (iLength != 1) { | 491 if (iLength != 1) { |
492 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"setFocus"); | 492 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"setFocus"); |
493 return; | 493 return; |
494 } | 494 } |
495 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 495 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
496 if (!pNotify) { | 496 if (!pNotify) { |
497 return; | 497 return; |
498 } | 498 } |
499 CXFA_Node* pNode = NULL; | 499 CXFA_Node* pNode = nullptr; |
500 if (iLength >= 1) { | 500 if (iLength >= 1) { |
501 std::unique_ptr<CFXJSE_Value> pValue(pArguments->GetValue(0)); | 501 std::unique_ptr<CFXJSE_Value> pValue(pArguments->GetValue(0)); |
502 if (pValue->IsObject()) { | 502 if (pValue->IsObject()) { |
503 pNode = ToNode(pValue.get(), nullptr); | 503 pNode = ToNode(pValue.get(), nullptr); |
504 } else if (pValue->IsString()) { | 504 } else if (pValue->IsString()) { |
505 CXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext(); | 505 CXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext(); |
506 if (!pScriptContext) | 506 if (!pScriptContext) |
507 return; | 507 return; |
508 | 508 |
509 CXFA_Object* pObject = pScriptContext->GetThisObject(); | 509 CXFA_Object* pObject = pScriptContext->GetThisObject(); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
579 int32_t iValue = pNotify->GetAppProvider()->MsgBox( | 579 int32_t iValue = pNotify->GetAppProvider()->MsgBox( |
580 wsMessage, bsTitle, dwMessageType, dwButtonType); | 580 wsMessage, bsTitle, dwMessageType, dwButtonType); |
581 CFXJSE_Value* pValue = pArguments->GetReturnValue(); | 581 CFXJSE_Value* pValue = pArguments->GetReturnValue(); |
582 if (pValue) | 582 if (pValue) |
583 pValue->SetInteger(iValue); | 583 pValue->SetInteger(iValue); |
584 } | 584 } |
585 FX_BOOL CScript_HostPseudoModel::Script_HostPseudoModel_ValidateArgsForMsg( | 585 FX_BOOL CScript_HostPseudoModel::Script_HostPseudoModel_ValidateArgsForMsg( |
586 CFXJSE_Arguments* pArguments, | 586 CFXJSE_Arguments* pArguments, |
587 int32_t iArgIndex, | 587 int32_t iArgIndex, |
588 CFX_WideString& wsValue) { | 588 CFX_WideString& wsValue) { |
589 if (pArguments == NULL || iArgIndex < 0) { | 589 if (!pArguments || iArgIndex < 0) { |
590 return FALSE; | 590 return FALSE; |
591 } | 591 } |
592 FX_BOOL bIsJsType = FALSE; | 592 FX_BOOL bIsJsType = FALSE; |
593 if (m_pDocument->GetScriptContext()->GetType() == | 593 if (m_pDocument->GetScriptContext()->GetType() == |
594 XFA_SCRIPTLANGTYPE_Javascript) { | 594 XFA_SCRIPTLANGTYPE_Javascript) { |
595 bIsJsType = TRUE; | 595 bIsJsType = TRUE; |
596 } | 596 } |
597 std::unique_ptr<CFXJSE_Value> pValueArg(pArguments->GetValue(iArgIndex)); | 597 std::unique_ptr<CFXJSE_Value> pValueArg(pArguments->GetValue(iArgIndex)); |
598 if (!pValueArg->IsString() && bIsJsType) { | 598 if (!pValueArg->IsString() && bIsJsType) { |
599 ThrowException(XFA_IDS_ARGUMENT_MISMATCH); | 599 ThrowException(XFA_IDS_ARGUMENT_MISMATCH); |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
767 CFXJSE_Arguments* pArguments) { | 767 CFXJSE_Arguments* pArguments) { |
768 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 768 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
769 if (!pNotify) { | 769 if (!pNotify) { |
770 return; | 770 return; |
771 } | 771 } |
772 CFX_WideString wsDataTime = pNotify->GetCurrentDateTime(); | 772 CFX_WideString wsDataTime = pNotify->GetCurrentDateTime(); |
773 CFXJSE_Value* pValue = pArguments->GetReturnValue(); | 773 CFXJSE_Value* pValue = pArguments->GetReturnValue(); |
774 if (pValue) | 774 if (pValue) |
775 pValue->SetString(FX_UTF8Encode(wsDataTime).AsStringC()); | 775 pValue->SetString(FX_UTF8Encode(wsDataTime).AsStringC()); |
776 } | 776 } |
OLD | NEW |