| 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/fm2js/xfa_fm2jsapi.h" | 10 #include "xfa/fxfa/fm2js/xfa_fm2jsapi.h" |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 283 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
| 284 if (!pNotify) { | 284 if (!pNotify) { |
| 285 return; | 285 return; |
| 286 } | 286 } |
| 287 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); | 287 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); |
| 288 CFX_WideString wsURL; | 288 CFX_WideString wsURL; |
| 289 if (iLength >= 1) { | 289 if (iLength >= 1) { |
| 290 CFX_ByteString bsURL = pArguments->GetUTF8String(0); | 290 CFX_ByteString bsURL = pArguments->GetUTF8String(0); |
| 291 wsURL = CFX_WideString::FromUTF8(bsURL.AsStringC()); | 291 wsURL = CFX_WideString::FromUTF8(bsURL.AsStringC()); |
| 292 } | 292 } |
| 293 pNotify->GetDocProvider()->GotoURL(hDoc, wsURL.AsStringC()); | 293 pNotify->GetDocProvider()->GotoURL(hDoc, wsURL); |
| 294 } | 294 } |
| 295 void CScript_HostPseudoModel::Script_HostPseudoModel_OpenList( | 295 void CScript_HostPseudoModel::Script_HostPseudoModel_OpenList( |
| 296 CFXJSE_Arguments* pArguments) { | 296 CFXJSE_Arguments* pArguments) { |
| 297 if (!m_pDocument->GetScriptContext()->IsRunAtClient()) { | 297 if (!m_pDocument->GetScriptContext()->IsRunAtClient()) { |
| 298 return; | 298 return; |
| 299 } | 299 } |
| 300 int32_t iLength = pArguments->GetLength(); | 300 int32_t iLength = pArguments->GetLength(); |
| 301 if (iLength != 1) { | 301 if (iLength != 1) { |
| 302 ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"openList"); | 302 ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"openList"); |
| 303 return; | 303 return; |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 CFX_ByteString bsTitle = pArguments->GetUTF8String(1); | 374 CFX_ByteString bsTitle = pArguments->GetUTF8String(1); |
| 375 wsTitle = CFX_WideString::FromUTF8(bsTitle.AsStringC()); | 375 wsTitle = CFX_WideString::FromUTF8(bsTitle.AsStringC()); |
| 376 } | 376 } |
| 377 if (iLength >= 3) { | 377 if (iLength >= 3) { |
| 378 CFX_ByteString bsDefaultAnswer = pArguments->GetUTF8String(2); | 378 CFX_ByteString bsDefaultAnswer = pArguments->GetUTF8String(2); |
| 379 wsDefaultAnswer = CFX_WideString::FromUTF8(bsDefaultAnswer.AsStringC()); | 379 wsDefaultAnswer = CFX_WideString::FromUTF8(bsDefaultAnswer.AsStringC()); |
| 380 } | 380 } |
| 381 if (iLength >= 4) { | 381 if (iLength >= 4) { |
| 382 bMark = pArguments->GetInt32(3) == 0 ? FALSE : TRUE; | 382 bMark = pArguments->GetInt32(3) == 0 ? FALSE : TRUE; |
| 383 } | 383 } |
| 384 CFX_WideString wsAnswer; | 384 CFX_WideString wsAnswer = pNotify->GetAppProvider()->Response( |
| 385 pNotify->GetAppProvider()->Response(wsAnswer, wsQuestion.AsStringC(), | 385 wsQuestion, wsTitle, wsDefaultAnswer, bMark); |
| 386 wsTitle.AsStringC(), | |
| 387 wsDefaultAnswer.AsStringC(), bMark); | |
| 388 FXJSE_HVALUE hValue = pArguments->GetReturnValue(); | 386 FXJSE_HVALUE hValue = pArguments->GetReturnValue(); |
| 389 if (hValue) { | 387 if (hValue) { |
| 390 FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsAnswer).AsStringC()); | 388 FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsAnswer).AsStringC()); |
| 391 } | 389 } |
| 392 } | 390 } |
| 393 void CScript_HostPseudoModel::Script_HostPseudoModel_DocumentInBatch( | 391 void CScript_HostPseudoModel::Script_HostPseudoModel_DocumentInBatch( |
| 394 CFXJSE_Arguments* pArguments) { | 392 CFXJSE_Arguments* pArguments) { |
| 395 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 393 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
| 396 if (!pNotify) { | 394 if (!pNotify) { |
| 397 return; | 395 return; |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 591 dwMessageType = XFA_MBICON_Error; | 589 dwMessageType = XFA_MBICON_Error; |
| 592 } | 590 } |
| 593 } | 591 } |
| 594 if (iLength >= 4) { | 592 if (iLength >= 4) { |
| 595 dwButtonType = pArguments->GetInt32(3); | 593 dwButtonType = pArguments->GetInt32(3); |
| 596 if (dwButtonType > XFA_MB_YesNoCancel) { | 594 if (dwButtonType > XFA_MB_YesNoCancel) { |
| 597 dwButtonType = XFA_MB_OK; | 595 dwButtonType = XFA_MB_OK; |
| 598 } | 596 } |
| 599 } | 597 } |
| 600 int32_t iValue = pNotify->GetAppProvider()->MsgBox( | 598 int32_t iValue = pNotify->GetAppProvider()->MsgBox( |
| 601 wsMessage.AsStringC(), bsTitle.AsStringC(), dwMessageType, dwButtonType); | 599 wsMessage, bsTitle, dwMessageType, dwButtonType); |
| 602 FXJSE_HVALUE hValue = pArguments->GetReturnValue(); | 600 FXJSE_HVALUE hValue = pArguments->GetReturnValue(); |
| 603 if (hValue) { | 601 if (hValue) { |
| 604 FXJSE_Value_SetInteger(hValue, iValue); | 602 FXJSE_Value_SetInteger(hValue, iValue); |
| 605 } | 603 } |
| 606 } | 604 } |
| 607 FX_BOOL CScript_HostPseudoModel::Script_HostPseudoModel_ValidateArgsForMsg( | 605 FX_BOOL CScript_HostPseudoModel::Script_HostPseudoModel_ValidateArgsForMsg( |
| 608 CFXJSE_Arguments* pArguments, | 606 CFXJSE_Arguments* pArguments, |
| 609 int32_t iArgIndex, | 607 int32_t iArgIndex, |
| 610 CFX_WideString& wsValue) { | 608 CFX_WideString& wsValue) { |
| 611 if (pArguments == NULL || iArgIndex < 0) { | 609 if (pArguments == NULL || iArgIndex < 0) { |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 723 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 721 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
| 724 if (!pNotify) { | 722 if (!pNotify) { |
| 725 return; | 723 return; |
| 726 } | 724 } |
| 727 CFX_WideString wsFilePath; | 725 CFX_WideString wsFilePath; |
| 728 if (iLength > 0) { | 726 if (iLength > 0) { |
| 729 CFX_ByteString bsFilePath = pArguments->GetUTF8String(0); | 727 CFX_ByteString bsFilePath = pArguments->GetUTF8String(0); |
| 730 wsFilePath = CFX_WideString::FromUTF8(bsFilePath.AsStringC()); | 728 wsFilePath = CFX_WideString::FromUTF8(bsFilePath.AsStringC()); |
| 731 } | 729 } |
| 732 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); | 730 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); |
| 733 pNotify->GetDocProvider()->ImportData(hDoc, wsFilePath.AsStringC()); | 731 pNotify->GetDocProvider()->ImportData(hDoc, wsFilePath); |
| 734 } | 732 } |
| 735 void CScript_HostPseudoModel::Script_HostPseudoModel_ExportData( | 733 void CScript_HostPseudoModel::Script_HostPseudoModel_ExportData( |
| 736 CFXJSE_Arguments* pArguments) { | 734 CFXJSE_Arguments* pArguments) { |
| 737 int32_t iLength = pArguments->GetLength(); | 735 int32_t iLength = pArguments->GetLength(); |
| 738 if (iLength < 0 || iLength > 2) { | 736 if (iLength < 0 || iLength > 2) { |
| 739 ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"exportData"); | 737 ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"exportData"); |
| 740 return; | 738 return; |
| 741 } | 739 } |
| 742 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 740 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
| 743 if (!pNotify) { | 741 if (!pNotify) { |
| 744 return; | 742 return; |
| 745 } | 743 } |
| 746 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); | 744 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); |
| 747 CFX_WideString wsFilePath; | 745 CFX_WideString wsFilePath; |
| 748 FX_BOOL bXDP = TRUE; | 746 FX_BOOL bXDP = TRUE; |
| 749 if (iLength >= 1) { | 747 if (iLength >= 1) { |
| 750 CFX_ByteString bsFilePath = pArguments->GetUTF8String(0); | 748 CFX_ByteString bsFilePath = pArguments->GetUTF8String(0); |
| 751 wsFilePath = CFX_WideString::FromUTF8(bsFilePath.AsStringC()); | 749 wsFilePath = CFX_WideString::FromUTF8(bsFilePath.AsStringC()); |
| 752 } | 750 } |
| 753 if (iLength >= 2) { | 751 if (iLength >= 2) { |
| 754 bXDP = pArguments->GetInt32(1) == 0 ? FALSE : TRUE; | 752 bXDP = pArguments->GetInt32(1) == 0 ? FALSE : TRUE; |
| 755 } | 753 } |
| 756 pNotify->GetDocProvider()->ExportData(hDoc, wsFilePath.AsStringC(), bXDP); | 754 pNotify->GetDocProvider()->ExportData(hDoc, wsFilePath, bXDP); |
| 757 } | 755 } |
| 758 void CScript_HostPseudoModel::Script_HostPseudoModel_PageUp( | 756 void CScript_HostPseudoModel::Script_HostPseudoModel_PageUp( |
| 759 CFXJSE_Arguments* pArguments) { | 757 CFXJSE_Arguments* pArguments) { |
| 760 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 758 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
| 761 if (!pNotify) { | 759 if (!pNotify) { |
| 762 return; | 760 return; |
| 763 } | 761 } |
| 764 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); | 762 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); |
| 765 int32_t nCurPage = pNotify->GetDocProvider()->GetCurrentPage(hDoc); | 763 int32_t nCurPage = pNotify->GetDocProvider()->GetCurrentPage(hDoc); |
| 766 int32_t nNewPage = 0; | 764 int32_t nNewPage = 0; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 795 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 793 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
| 796 if (!pNotify) { | 794 if (!pNotify) { |
| 797 return; | 795 return; |
| 798 } | 796 } |
| 799 CFX_WideString wsDataTime = pNotify->GetCurrentDateTime(); | 797 CFX_WideString wsDataTime = pNotify->GetCurrentDateTime(); |
| 800 FXJSE_HVALUE hValue = pArguments->GetReturnValue(); | 798 FXJSE_HVALUE hValue = pArguments->GetReturnValue(); |
| 801 if (hValue) { | 799 if (hValue) { |
| 802 FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsDataTime).AsStringC()); | 800 FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsDataTime).AsStringC()); |
| 803 } | 801 } |
| 804 } | 802 } |
| OLD | NEW |