| 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 "../../include/javascript/JavaScript.h" | 7 #include "../../include/javascript/JavaScript.h" |
| 8 #include "../../include/javascript/IJavaScript.h" | 8 #include "../../include/javascript/IJavaScript.h" |
| 9 #include "../../include/javascript/JS_Define.h" | 9 #include "../../include/javascript/JS_Define.h" |
| 10 #include "../../include/javascript/JS_Object.h" | 10 #include "../../include/javascript/JS_Object.h" |
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 swTitle = params[i].ToCFXWideString(); | 409 swTitle = params[i].ToCFXWideString(); |
| 410 } | 410 } |
| 411 } | 411 } |
| 412 | 412 |
| 413 | 413 |
| 414 CJS_Context* pContext = (CJS_Context*)cc; | 414 CJS_Context* pContext = (CJS_Context*)cc; |
| 415 ASSERT(pContext != NULL); | 415 ASSERT(pContext != NULL); |
| 416 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 416 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
| 417 ASSERT(pRuntime != NULL); | 417 ASSERT(pRuntime != NULL); |
| 418 pRuntime->BeginBlock(); | 418 pRuntime->BeginBlock(); |
| 419 » vRet = MsgBox(pRuntime->GetReaderApp(), JSGetPageView(cc),swMsg,swTitle,
iType,iIcon); | 419 » vRet = MsgBox(pRuntime->GetReaderApp(), JSGetPageView(cc), swMsg.c_str()
, swTitle.c_str(), iType, iIcon); |
| 420 pRuntime->EndBlock(); | 420 pRuntime->EndBlock(); |
| 421 | 421 |
| 422 return TRUE; | 422 return TRUE; |
| 423 } | 423 } |
| 424 | 424 |
| 425 | 425 |
| 426 FX_BOOL app::beep(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vR
et, CFX_WideString& sError) | 426 FX_BOOL app::beep(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vR
et, CFX_WideString& sError) |
| 427 { | 427 { |
| 428 if (params.size() == 1) | 428 if (params.size() == 1) |
| 429 { | 429 { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 448 return FALSE; | 448 return FALSE; |
| 449 } | 449 } |
| 450 | 450 |
| 451 FX_BOOL app::fs(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) | 451 FX_BOOL app::fs(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) |
| 452 { | 452 { |
| 453 return FALSE; | 453 return FALSE; |
| 454 } | 454 } |
| 455 | 455 |
| 456 FX_BOOL app::setInterval(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Va
lue& vRet, CFX_WideString& sError) | 456 FX_BOOL app::setInterval(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Va
lue& vRet, CFX_WideString& sError) |
| 457 { | 457 { |
| 458 CJS_Context* pContext = (CJS_Context*)cc; |
| 458 if (params.size() > 2 || params.size() == 0) | 459 if (params.size() > 2 || params.size() == 0) |
| 459 { | 460 { |
| 460 » » sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSPARAME
RROR); | 461 » » sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); |
| 461 return FALSE; | 462 return FALSE; |
| 462 } | 463 } |
| 463 | 464 |
| 464 » CJS_Context* pContext = (CJS_Context*)cc; | 465 » CFX_WideString script = params.size() > 0 ? params[0].ToCFXWideString()
: L""; |
| 465 » ASSERT(pContext != NULL); | |
| 466 » CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | |
| 467 » ASSERT(pRuntime != NULL); | |
| 468 | |
| 469 » CFX_WideString script = params.size() > 0 ? (FX_LPCWSTR)(params[0].ToCF
XWideString()) : L""; | |
| 470 if (script.IsEmpty()) | 466 if (script.IsEmpty()) |
| 471 { | 467 { |
| 472 » » sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSAFNUMB
ER_KEYSTROKE); | 468 » » sError = JSGetStringFromID(pContext, IDS_STRING_JSAFNUMBER_KEYST
ROKE); |
| 473 return TRUE; | 469 return TRUE; |
| 474 } | 470 } |
| 475 | 471 |
| 472 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
| 476 FX_DWORD dwInterval = params.size() > 1 ? params[1].ToInt() : 1000; | 473 FX_DWORD dwInterval = params.size() > 1 ? params[1].ToInt() : 1000; |
| 477 | 474 |
| 478 CPDFDoc_Environment* pApp = pRuntime->GetReaderApp(); | 475 CPDFDoc_Environment* pApp = pRuntime->GetReaderApp(); |
| 479 ASSERT(pApp); | 476 ASSERT(pApp); |
| 480 CJS_Timer* pTimer = new CJS_Timer(this, pApp); | 477 CJS_Timer* pTimer = new CJS_Timer(this, pApp); |
| 481 m_aTimer.Add(pTimer); | 478 m_aTimer.Add(pTimer); |
| 482 | 479 |
| 483 pTimer->SetType(0); | 480 pTimer->SetType(0); |
| 484 pTimer->SetRuntime(pRuntime); | 481 pTimer->SetRuntime(pRuntime); |
| 485 pTimer->SetJScript(script); | 482 pTimer->SetJScript(script); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 508 { | 505 { |
| 509 sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSPARAME
RROR); | 506 sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSPARAME
RROR); |
| 510 return FALSE; | 507 return FALSE; |
| 511 } | 508 } |
| 512 | 509 |
| 513 CJS_Context* pContext = (CJS_Context*)cc; | 510 CJS_Context* pContext = (CJS_Context*)cc; |
| 514 ASSERT(pContext != NULL); | 511 ASSERT(pContext != NULL); |
| 515 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 512 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
| 516 ASSERT(pRuntime != NULL); | 513 ASSERT(pRuntime != NULL); |
| 517 | 514 |
| 518 » CFX_WideString script = params.size() > 0 ? (FX_LPCWSTR)(params[0].ToCF
XWideString()) : L""; | 515 » CFX_WideString script = params.size() > 0 ? params[0].ToCFXWideString()
: L""; |
| 519 if (script.IsEmpty()) | 516 if (script.IsEmpty()) |
| 520 { | 517 { |
| 521 sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSAFNUMB
ER_KEYSTROKE); | 518 sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSAFNUMB
ER_KEYSTROKE); |
| 522 return TRUE; | 519 return TRUE; |
| 523 } | 520 } |
| 524 | 521 |
| 525 FX_DWORD dwTimeOut = params.size() > 1 ? params[1].ToInt() : 1000; | 522 FX_DWORD dwTimeOut = params.size() > 1 ? params[1].ToInt() : 1000; |
| 526 | 523 |
| 527 CPDFDoc_Environment* pApp = pRuntime->GetReaderApp(); | 524 CPDFDoc_Environment* pApp = pRuntime->GetReaderApp(); |
| 528 ASSERT(pApp); | 525 ASSERT(pApp); |
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 896 | 893 |
| 897 CPDFDoc_Environment* pApp = pContext->GetReaderApp(); | 894 CPDFDoc_Environment* pApp = pContext->GetReaderApp(); |
| 898 ASSERT(pApp != NULL); | 895 ASSERT(pApp != NULL); |
| 899 | 896 |
| 900 const int MAX_INPUT_BYTES = 2048; | 897 const int MAX_INPUT_BYTES = 2048; |
| 901 char* pBuff = new char[MAX_INPUT_BYTES + 2]; | 898 char* pBuff = new char[MAX_INPUT_BYTES + 2]; |
| 902 if (!pBuff) | 899 if (!pBuff) |
| 903 return FALSE; | 900 return FALSE; |
| 904 | 901 |
| 905 memset(pBuff, 0, MAX_INPUT_BYTES + 2); | 902 memset(pBuff, 0, MAX_INPUT_BYTES + 2); |
| 906 » int nLengthBytes = pApp->JS_appResponse(swQuestion, swTitle, swDefault,
swLabel, bPassWord, pBuff, MAX_INPUT_BYTES); | 903 » int nLengthBytes = pApp->JS_appResponse(swQuestion.c_str(), swTitle.c_st
r(), swDefault.c_str(), |
| 904 swLabel.c_str(), bPassWord, pBuff, M
AX_INPUT_BYTES); |
| 907 if (nLengthBytes <= 0) | 905 if (nLengthBytes <= 0) |
| 908 { | 906 { |
| 909 vRet.SetNull(); | 907 vRet.SetNull(); |
| 910 delete[] pBuff; | 908 delete[] pBuff; |
| 911 return FALSE; | 909 return FALSE; |
| 912 } | 910 } |
| 913 if (nLengthBytes > MAX_INPUT_BYTES) | 911 if (nLengthBytes > MAX_INPUT_BYTES) |
| 914 nLengthBytes = MAX_INPUT_BYTES; | 912 nLengthBytes = MAX_INPUT_BYTES; |
| 915 | 913 |
| 916 » vRet = CFX_WideString::FromUTF16LE((unsigned short*)pBuff, nLengthBytes
/ sizeof(unsigned short)); | 914 » vRet = CFX_WideString::FromUTF16LE((unsigned short*)pBuff, nLengthBytes
/ sizeof(unsigned short)).c_str(); |
| 917 delete[] pBuff; | 915 delete[] pBuff; |
| 918 return TRUE; | 916 return TRUE; |
| 919 } | 917 } |
| 920 | 918 |
| 921 FX_BOOL app::media(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) | 919 FX_BOOL app::media(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) |
| 922 { | 920 { |
| 923 return FALSE; | 921 return FALSE; |
| 924 } | 922 } |
| 925 | 923 |
| 926 FX_BOOL app::execDialog(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Val
ue& vRet, CFX_WideString& sError) | 924 FX_BOOL app::execDialog(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Val
ue& vRet, CFX_WideString& sError) |
| 927 { | 925 { |
| 928 return TRUE; | 926 return TRUE; |
| 929 } | 927 } |
| OLD | NEW |