| 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 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"openList"); | 304 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"openList"); |
| 305 return; | 305 return; |
| 306 } | 306 } |
| 307 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 307 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
| 308 if (!pNotify) { | 308 if (!pNotify) { |
| 309 return; | 309 return; |
| 310 } | 310 } |
| 311 CXFA_Node* pNode = NULL; | 311 CXFA_Node* pNode = NULL; |
| 312 if (iLength >= 1) { | 312 if (iLength >= 1) { |
| 313 std::unique_ptr<CFXJSE_Value> pValue(pArguments->GetValue(0)); | 313 std::unique_ptr<CFXJSE_Value> pValue(pArguments->GetValue(0)); |
| 314 if (FXJSE_Value_IsObject(pValue.get())) { | 314 if (pValue->IsObject()) { |
| 315 pNode = ToNode(pValue.get(), nullptr); | 315 pNode = ToNode(pValue.get(), nullptr); |
| 316 } else if (FXJSE_Value_IsUTF8String(pValue.get())) { | 316 } else if (pValue->IsString()) { |
| 317 CFX_ByteString bsString; | 317 CFX_ByteString bsString; |
| 318 pValue->ToString(bsString); | 318 pValue->ToString(bsString); |
| 319 CFX_WideString wsExpression = | 319 CFX_WideString wsExpression = |
| 320 CFX_WideString::FromUTF8(bsString.AsStringC()); | 320 CFX_WideString::FromUTF8(bsString.AsStringC()); |
| 321 CXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext(); | 321 CXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext(); |
| 322 if (!pScriptContext) | 322 if (!pScriptContext) |
| 323 return; | 323 return; |
| 324 | 324 |
| 325 CXFA_Object* pObject = pScriptContext->GetThisObject(); | 325 CXFA_Object* pObject = pScriptContext->GetThisObject(); |
| 326 if (!pObject) | 326 if (!pObject) |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 499 ThrowException(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 (pValue->IsObject()) { |
| 510 pNode = ToNode(pValue.get(), nullptr); | 510 pNode = ToNode(pValue.get(), nullptr); |
| 511 } else if (FXJSE_Value_IsUTF8String(pValue.get())) { | 511 } else if (pValue->IsString()) { |
| 512 CFX_ByteString bsString; | 512 CFX_ByteString bsString; |
| 513 pValue->ToString(bsString); | 513 pValue->ToString(bsString); |
| 514 CFX_WideString wsExpression = | 514 CFX_WideString wsExpression = |
| 515 CFX_WideString::FromUTF8(bsString.AsStringC()); | 515 CFX_WideString::FromUTF8(bsString.AsStringC()); |
| 516 CXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext(); | 516 CXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext(); |
| 517 if (!pScriptContext) | 517 if (!pScriptContext) |
| 518 return; | 518 return; |
| 519 | 519 |
| 520 CXFA_Object* pObject = pScriptContext->GetThisObject(); | 520 CXFA_Object* pObject = pScriptContext->GetThisObject(); |
| 521 if (!pObject) | 521 if (!pObject) |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 599 CFX_WideString& wsValue) { | 599 CFX_WideString& wsValue) { |
| 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 (!pValueArg->IsString() && bIsJsType) { |
| 610 ThrowException(XFA_IDS_ARGUMENT_MISMATCH); | 610 ThrowException(XFA_IDS_ARGUMENT_MISMATCH); |
| 611 return FALSE; | 611 return FALSE; |
| 612 } | 612 } |
| 613 if (FXJSE_Value_IsNull(pValueArg.get())) { | 613 if (pValueArg->IsNull()) { |
| 614 wsValue = FX_WSTRC(L""); | 614 wsValue = FX_WSTRC(L""); |
| 615 } else { | 615 } else { |
| 616 CFX_ByteString byMessage; | 616 CFX_ByteString byMessage; |
| 617 pValueArg->ToString(byMessage); | 617 pValueArg->ToString(byMessage); |
| 618 wsValue = CFX_WideString::FromUTF8(byMessage.AsStringC()); | 618 wsValue = CFX_WideString::FromUTF8(byMessage.AsStringC()); |
| 619 } | 619 } |
| 620 return TRUE; | 620 return TRUE; |
| 621 } | 621 } |
| 622 void CScript_HostPseudoModel::Script_HostPseudoModel_DocumentCountInBatch( | 622 void CScript_HostPseudoModel::Script_HostPseudoModel_DocumentCountInBatch( |
| 623 CFXJSE_Arguments* pArguments) { | 623 CFXJSE_Arguments* pArguments) { |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 780 CFXJSE_Arguments* pArguments) { | 780 CFXJSE_Arguments* pArguments) { |
| 781 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 781 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
| 782 if (!pNotify) { | 782 if (!pNotify) { |
| 783 return; | 783 return; |
| 784 } | 784 } |
| 785 CFX_WideString wsDataTime = pNotify->GetCurrentDateTime(); | 785 CFX_WideString wsDataTime = pNotify->GetCurrentDateTime(); |
| 786 CFXJSE_Value* pValue = pArguments->GetReturnValue(); | 786 CFXJSE_Value* pValue = pArguments->GetReturnValue(); |
| 787 if (pValue) | 787 if (pValue) |
| 788 pValue->SetString(FX_UTF8Encode(wsDataTime).AsStringC()); | 788 pValue->SetString(FX_UTF8Encode(wsDataTime).AsStringC()); |
| 789 } | 789 } |
| OLD | NEW |