| 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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 XFA_ATTRIBUTE eAttribute) { | 156 XFA_ATTRIBUTE eAttribute) { |
| 157 if (!m_pDocument->GetScriptContext()->IsRunAtClient()) { | 157 if (!m_pDocument->GetScriptContext()->IsRunAtClient()) { |
| 158 return; | 158 return; |
| 159 } | 159 } |
| 160 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 160 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
| 161 if (!pNotify) { | 161 if (!pNotify) { |
| 162 return; | 162 return; |
| 163 } | 163 } |
| 164 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); | 164 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); |
| 165 if (bSetting) { | 165 if (bSetting) { |
| 166 CFX_ByteString bsValue; | 166 pNotify->GetDocProvider()->SetTitle(hDoc, pValue->ToWideString()); |
| 167 pValue->ToString(bsValue); | |
| 168 pNotify->GetDocProvider()->SetTitle( | |
| 169 hDoc, CFX_WideString::FromUTF8(bsValue.AsStringC())); | |
| 170 return; | 167 return; |
| 171 } | 168 } |
| 172 CFX_WideString wsTitle; | 169 CFX_WideString wsTitle; |
| 173 pNotify->GetDocProvider()->GetTitle(hDoc, wsTitle); | 170 pNotify->GetDocProvider()->GetTitle(hDoc, wsTitle); |
| 174 pValue->SetString(FX_UTF8Encode(wsTitle).AsStringC()); | 171 pValue->SetString(FX_UTF8Encode(wsTitle).AsStringC()); |
| 175 } | 172 } |
| 176 void CScript_HostPseudoModel::Script_HostPseudoModel_ValidationsEnabled( | 173 void CScript_HostPseudoModel::Script_HostPseudoModel_ValidationsEnabled( |
| 177 CFXJSE_Value* pValue, | 174 CFXJSE_Value* pValue, |
| 178 FX_BOOL bSetting, | 175 FX_BOOL bSetting, |
| 179 XFA_ATTRIBUTE eAttribute) { | 176 XFA_ATTRIBUTE eAttribute) { |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 304 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
| 308 if (!pNotify) { | 305 if (!pNotify) { |
| 309 return; | 306 return; |
| 310 } | 307 } |
| 311 CXFA_Node* pNode = NULL; | 308 CXFA_Node* pNode = NULL; |
| 312 if (iLength >= 1) { | 309 if (iLength >= 1) { |
| 313 std::unique_ptr<CFXJSE_Value> pValue(pArguments->GetValue(0)); | 310 std::unique_ptr<CFXJSE_Value> pValue(pArguments->GetValue(0)); |
| 314 if (pValue->IsObject()) { | 311 if (pValue->IsObject()) { |
| 315 pNode = ToNode(pValue.get(), nullptr); | 312 pNode = ToNode(pValue.get(), nullptr); |
| 316 } else if (pValue->IsString()) { | 313 } else if (pValue->IsString()) { |
| 317 CFX_ByteString bsString; | |
| 318 pValue->ToString(bsString); | |
| 319 CFX_WideString wsExpression = | |
| 320 CFX_WideString::FromUTF8(bsString.AsStringC()); | |
| 321 CXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext(); | 314 CXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext(); |
| 322 if (!pScriptContext) | 315 if (!pScriptContext) |
| 323 return; | 316 return; |
| 324 | 317 |
| 325 CXFA_Object* pObject = pScriptContext->GetThisObject(); | 318 CXFA_Object* pObject = pScriptContext->GetThisObject(); |
| 326 if (!pObject) | 319 if (!pObject) |
| 327 return; | 320 return; |
| 328 | 321 |
| 329 uint32_t dwFlag = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Parent | | 322 uint32_t dwFlag = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Parent | |
| 330 XFA_RESOLVENODE_Siblings; | 323 XFA_RESOLVENODE_Siblings; |
| 331 XFA_RESOLVENODE_RS resoveNodeRS; | 324 XFA_RESOLVENODE_RS resoveNodeRS; |
| 332 int32_t iRet = pScriptContext->ResolveObjects( | 325 int32_t iRet = pScriptContext->ResolveObjects( |
| 333 pObject, wsExpression.AsStringC(), resoveNodeRS, dwFlag); | 326 pObject, pValue->ToWideString().AsStringC(), resoveNodeRS, dwFlag); |
| 334 if (iRet < 1 || !resoveNodeRS.nodes[0]->IsNode()) | 327 if (iRet < 1 || !resoveNodeRS.nodes[0]->IsNode()) |
| 335 return; | 328 return; |
| 336 | 329 |
| 337 pNode = resoveNodeRS.nodes[0]->AsNode(); | 330 pNode = resoveNodeRS.nodes[0]->AsNode(); |
| 338 } | 331 } |
| 339 } | 332 } |
| 340 CXFA_LayoutProcessor* pDocLayout = m_pDocument->GetDocLayout(); | 333 CXFA_LayoutProcessor* pDocLayout = m_pDocument->GetDocLayout(); |
| 341 if (!pDocLayout) { | 334 if (!pDocLayout) { |
| 342 return; | 335 return; |
| 343 } | 336 } |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 502 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 495 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
| 503 if (!pNotify) { | 496 if (!pNotify) { |
| 504 return; | 497 return; |
| 505 } | 498 } |
| 506 CXFA_Node* pNode = NULL; | 499 CXFA_Node* pNode = NULL; |
| 507 if (iLength >= 1) { | 500 if (iLength >= 1) { |
| 508 std::unique_ptr<CFXJSE_Value> pValue(pArguments->GetValue(0)); | 501 std::unique_ptr<CFXJSE_Value> pValue(pArguments->GetValue(0)); |
| 509 if (pValue->IsObject()) { | 502 if (pValue->IsObject()) { |
| 510 pNode = ToNode(pValue.get(), nullptr); | 503 pNode = ToNode(pValue.get(), nullptr); |
| 511 } else if (pValue->IsString()) { | 504 } else if (pValue->IsString()) { |
| 512 CFX_ByteString bsString; | |
| 513 pValue->ToString(bsString); | |
| 514 CFX_WideString wsExpression = | |
| 515 CFX_WideString::FromUTF8(bsString.AsStringC()); | |
| 516 CXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext(); | 505 CXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext(); |
| 517 if (!pScriptContext) | 506 if (!pScriptContext) |
| 518 return; | 507 return; |
| 519 | 508 |
| 520 CXFA_Object* pObject = pScriptContext->GetThisObject(); | 509 CXFA_Object* pObject = pScriptContext->GetThisObject(); |
| 521 if (!pObject) | 510 if (!pObject) |
| 522 return; | 511 return; |
| 523 | 512 |
| 524 uint32_t dwFlag = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Parent | | 513 uint32_t dwFlag = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Parent | |
| 525 XFA_RESOLVENODE_Siblings; | 514 XFA_RESOLVENODE_Siblings; |
| 526 XFA_RESOLVENODE_RS resoveNodeRS; | 515 XFA_RESOLVENODE_RS resoveNodeRS; |
| 527 int32_t iRet = pScriptContext->ResolveObjects( | 516 int32_t iRet = pScriptContext->ResolveObjects( |
| 528 pObject, wsExpression.AsStringC(), resoveNodeRS, dwFlag); | 517 pObject, pValue->ToWideString().AsStringC(), resoveNodeRS, dwFlag); |
| 529 if (iRet < 1 || !resoveNodeRS.nodes[0]->IsNode()) | 518 if (iRet < 1 || !resoveNodeRS.nodes[0]->IsNode()) |
| 530 return; | 519 return; |
| 531 | 520 |
| 532 pNode = resoveNodeRS.nodes[0]->AsNode(); | 521 pNode = resoveNodeRS.nodes[0]->AsNode(); |
| 533 } | 522 } |
| 534 } | 523 } |
| 535 pNotify->SetFocusWidgetNode(pNode); | 524 pNotify->SetFocusWidgetNode(pNode); |
| 536 } | 525 } |
| 537 void CScript_HostPseudoModel::Script_HostPseudoModel_GetFocus( | 526 void CScript_HostPseudoModel::Script_HostPseudoModel_GetFocus( |
| 538 CFXJSE_Arguments* pArguments) { | 527 CFXJSE_Arguments* pArguments) { |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 606 bIsJsType = TRUE; | 595 bIsJsType = TRUE; |
| 607 } | 596 } |
| 608 std::unique_ptr<CFXJSE_Value> pValueArg(pArguments->GetValue(iArgIndex)); | 597 std::unique_ptr<CFXJSE_Value> pValueArg(pArguments->GetValue(iArgIndex)); |
| 609 if (!pValueArg->IsString() && bIsJsType) { | 598 if (!pValueArg->IsString() && bIsJsType) { |
| 610 ThrowException(XFA_IDS_ARGUMENT_MISMATCH); | 599 ThrowException(XFA_IDS_ARGUMENT_MISMATCH); |
| 611 return FALSE; | 600 return FALSE; |
| 612 } | 601 } |
| 613 if (pValueArg->IsNull()) { | 602 if (pValueArg->IsNull()) { |
| 614 wsValue = FX_WSTRC(L""); | 603 wsValue = FX_WSTRC(L""); |
| 615 } else { | 604 } else { |
| 616 CFX_ByteString byMessage; | 605 wsValue = pValueArg->ToWideString(); |
| 617 pValueArg->ToString(byMessage); | |
| 618 wsValue = CFX_WideString::FromUTF8(byMessage.AsStringC()); | |
| 619 } | 606 } |
| 620 return TRUE; | 607 return TRUE; |
| 621 } | 608 } |
| 622 void CScript_HostPseudoModel::Script_HostPseudoModel_DocumentCountInBatch( | 609 void CScript_HostPseudoModel::Script_HostPseudoModel_DocumentCountInBatch( |
| 623 CFXJSE_Arguments* pArguments) { | 610 CFXJSE_Arguments* pArguments) { |
| 624 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 611 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
| 625 if (!pNotify) { | 612 if (!pNotify) { |
| 626 return; | 613 return; |
| 627 } | 614 } |
| 628 int32_t iValue = pNotify->GetAppProvider()->GetDocumentCountInBatch(); | 615 int32_t iValue = pNotify->GetAppProvider()->GetDocumentCountInBatch(); |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 780 CFXJSE_Arguments* pArguments) { | 767 CFXJSE_Arguments* pArguments) { |
| 781 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 768 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
| 782 if (!pNotify) { | 769 if (!pNotify) { |
| 783 return; | 770 return; |
| 784 } | 771 } |
| 785 CFX_WideString wsDataTime = pNotify->GetCurrentDateTime(); | 772 CFX_WideString wsDataTime = pNotify->GetCurrentDateTime(); |
| 786 CFXJSE_Value* pValue = pArguments->GetReturnValue(); | 773 CFXJSE_Value* pValue = pArguments->GetReturnValue(); |
| 787 if (pValue) | 774 if (pValue) |
| 788 pValue->SetString(FX_UTF8Encode(wsDataTime).AsStringC()); | 775 pValue->SetString(FX_UTF8Encode(wsDataTime).AsStringC()); |
| 789 } | 776 } |
| OLD | NEW |