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 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 swTitle = params[i].ToCFXWideString(); | 422 swTitle = params[i].ToCFXWideString(); |
423 } | 423 } |
424 } | 424 } |
425 | 425 |
426 | 426 |
427 CJS_Context* pContext = (CJS_Context*)cc; | 427 CJS_Context* pContext = (CJS_Context*)cc; |
428 ASSERT(pContext != NULL); | 428 ASSERT(pContext != NULL); |
429 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 429 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
430 ASSERT(pRuntime != NULL); | 430 ASSERT(pRuntime != NULL); |
431 pRuntime->BeginBlock(); | 431 pRuntime->BeginBlock(); |
432 » vRet = MsgBox(pRuntime->GetReaderApp(), JSGetPageView(cc),swMsg,swTitle,
iType,iIcon); | 432 » vRet = MsgBox(pRuntime->GetReaderApp(), JSGetPageView(cc), swMsg.c_str()
, swTitle.c_str(), iType, iIcon); |
433 pRuntime->EndBlock(); | 433 pRuntime->EndBlock(); |
434 | 434 |
435 return TRUE; | 435 return TRUE; |
436 } | 436 } |
437 | 437 |
438 | 438 |
439 FX_BOOL app::beep(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vR
et, CFX_WideString& sError) | 439 FX_BOOL app::beep(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vR
et, CFX_WideString& sError) |
440 { | 440 { |
441 if (params.size() == 1) | 441 if (params.size() == 1) |
442 { | 442 { |
(...skipping 18 matching lines...) Expand all Loading... |
461 return FALSE; | 461 return FALSE; |
462 } | 462 } |
463 | 463 |
464 FX_BOOL app::fs(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) | 464 FX_BOOL app::fs(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) |
465 { | 465 { |
466 return FALSE; | 466 return FALSE; |
467 } | 467 } |
468 | 468 |
469 FX_BOOL app::setInterval(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Va
lue& vRet, CFX_WideString& sError) | 469 FX_BOOL app::setInterval(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Va
lue& vRet, CFX_WideString& sError) |
470 { | 470 { |
| 471 CJS_Context* pContext = (CJS_Context*)cc; |
471 if (params.size() > 2 || params.size() == 0) | 472 if (params.size() > 2 || params.size() == 0) |
472 { | 473 { |
473 » » sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSPARAME
RROR); | 474 » » sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); |
474 return FALSE; | 475 return FALSE; |
475 } | 476 } |
476 | 477 |
477 » CJS_Context* pContext = (CJS_Context*)cc; | 478 » CFX_WideString script = params.size() > 0 ? params[0].ToCFXWideString()
: L""; |
478 » ASSERT(pContext != NULL); | |
479 » CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | |
480 » ASSERT(pRuntime != NULL); | |
481 | |
482 » CFX_WideString script = params.size() > 0 ? (FX_LPCWSTR)(params[0].ToCF
XWideString()) : L""; | |
483 if (script.IsEmpty()) | 479 if (script.IsEmpty()) |
484 { | 480 { |
485 » » sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSAFNUMB
ER_KEYSTROKE); | 481 » » sError = JSGetStringFromID(pContext, IDS_STRING_JSAFNUMBER_KEYST
ROKE); |
486 return TRUE; | 482 return TRUE; |
487 } | 483 } |
488 | 484 |
| 485 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
489 FX_DWORD dwInterval = params.size() > 1 ? params[1].ToInt() : 1000; | 486 FX_DWORD dwInterval = params.size() > 1 ? params[1].ToInt() : 1000; |
490 | 487 |
491 CPDFDoc_Environment* pApp = pRuntime->GetReaderApp(); | 488 CPDFDoc_Environment* pApp = pRuntime->GetReaderApp(); |
492 ASSERT(pApp); | 489 ASSERT(pApp); |
493 CJS_Timer* pTimer = new CJS_Timer(this, pApp); | 490 CJS_Timer* pTimer = new CJS_Timer(this, pApp); |
494 m_aTimer.Add(pTimer); | 491 m_aTimer.Add(pTimer); |
495 | 492 |
496 pTimer->SetType(0); | 493 pTimer->SetType(0); |
497 pTimer->SetRuntime(pRuntime); | 494 pTimer->SetRuntime(pRuntime); |
498 pTimer->SetJScript(script); | 495 pTimer->SetJScript(script); |
(...skipping 22 matching lines...) Expand all Loading... |
521 { | 518 { |
522 sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSPARAME
RROR); | 519 sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSPARAME
RROR); |
523 return FALSE; | 520 return FALSE; |
524 } | 521 } |
525 | 522 |
526 CJS_Context* pContext = (CJS_Context*)cc; | 523 CJS_Context* pContext = (CJS_Context*)cc; |
527 ASSERT(pContext != NULL); | 524 ASSERT(pContext != NULL); |
528 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 525 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
529 ASSERT(pRuntime != NULL); | 526 ASSERT(pRuntime != NULL); |
530 | 527 |
531 » CFX_WideString script = params.size() > 0 ? (FX_LPCWSTR)(params[0].ToCF
XWideString()) : L""; | 528 » CFX_WideString script = params.size() > 0 ? params[0].ToCFXWideString()
: L""; |
532 if (script.IsEmpty()) | 529 if (script.IsEmpty()) |
533 { | 530 { |
534 sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSAFNUMB
ER_KEYSTROKE); | 531 sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSAFNUMB
ER_KEYSTROKE); |
535 return TRUE; | 532 return TRUE; |
536 } | 533 } |
537 | 534 |
538 FX_DWORD dwTimeOut = params.size() > 1 ? params[1].ToInt() : 1000; | 535 FX_DWORD dwTimeOut = params.size() > 1 ? params[1].ToInt() : 1000; |
539 | 536 |
540 CPDFDoc_Environment* pApp = pRuntime->GetReaderApp(); | 537 CPDFDoc_Environment* pApp = pRuntime->GetReaderApp(); |
541 ASSERT(pApp); | 538 ASSERT(pApp); |
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
909 | 906 |
910 CPDFDoc_Environment* pApp = pContext->GetReaderApp(); | 907 CPDFDoc_Environment* pApp = pContext->GetReaderApp(); |
911 ASSERT(pApp != NULL); | 908 ASSERT(pApp != NULL); |
912 | 909 |
913 const int MAX_INPUT_BYTES = 2048; | 910 const int MAX_INPUT_BYTES = 2048; |
914 char* pBuff = new char[MAX_INPUT_BYTES + 2]; | 911 char* pBuff = new char[MAX_INPUT_BYTES + 2]; |
915 if (!pBuff) | 912 if (!pBuff) |
916 return FALSE; | 913 return FALSE; |
917 | 914 |
918 memset(pBuff, 0, MAX_INPUT_BYTES + 2); | 915 memset(pBuff, 0, MAX_INPUT_BYTES + 2); |
919 » int nLengthBytes = pApp->JS_appResponse(swQuestion, swTitle, swDefault,
swLabel, bPassWord, pBuff, MAX_INPUT_BYTES); | 916 » int nLengthBytes = pApp->JS_appResponse(swQuestion.c_str(), swTitle.c_st
r(), swDefault.c_str(), |
| 917 swLabel.c_str(), bPassWord, pBuff, M
AX_INPUT_BYTES); |
920 if (nLengthBytes <= 0) | 918 if (nLengthBytes <= 0) |
921 { | 919 { |
922 vRet.SetNull(); | 920 vRet.SetNull(); |
923 delete[] pBuff; | 921 delete[] pBuff; |
924 return FALSE; | 922 return FALSE; |
925 } | 923 } |
926 if (nLengthBytes > MAX_INPUT_BYTES) | 924 if (nLengthBytes > MAX_INPUT_BYTES) |
927 nLengthBytes = MAX_INPUT_BYTES; | 925 nLengthBytes = MAX_INPUT_BYTES; |
928 | 926 |
929 » vRet = CFX_WideString::FromUTF16LE((unsigned short*)pBuff, nLengthBytes
/ sizeof(unsigned short)); | 927 » vRet = CFX_WideString::FromUTF16LE((unsigned short*)pBuff, nLengthBytes
/ sizeof(unsigned short)).c_str(); |
930 delete[] pBuff; | 928 delete[] pBuff; |
931 return TRUE; | 929 return TRUE; |
932 } | 930 } |
933 | 931 |
934 FX_BOOL app::media(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) | 932 FX_BOOL app::media(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) |
935 { | 933 { |
936 return FALSE; | 934 return FALSE; |
937 } | 935 } |
938 | 936 |
939 FX_BOOL app::execDialog(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Val
ue& vRet, CFX_WideString& sError) | 937 FX_BOOL app::execDialog(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Val
ue& vRet, CFX_WideString& sError) |
940 { | 938 { |
941 return TRUE; | 939 return TRUE; |
942 } | 940 } |
OLD | NEW |