| 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 "fpdfsdk/javascript/app.h" | 7 #include "fpdfsdk/javascript/app.h" |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 return FALSE; | 228 return FALSE; |
| 229 | 229 |
| 230 CJS_Context* pContext = (CJS_Context*)cc; | 230 CJS_Context* pContext = (CJS_Context*)cc; |
| 231 CPDFDoc_Environment* pApp = pContext->GetReaderApp(); | 231 CPDFDoc_Environment* pApp = pContext->GetReaderApp(); |
| 232 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 232 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
| 233 CPDFSDK_Document* pCurDoc = pContext->GetReaderDocument(); | 233 CPDFSDK_Document* pCurDoc = pContext->GetReaderDocument(); |
| 234 CJS_Array aDocs; | 234 CJS_Array aDocs; |
| 235 if (CPDFSDK_Document* pDoc = pApp->GetSDKDocument()) { | 235 if (CPDFSDK_Document* pDoc = pApp->GetSDKDocument()) { |
| 236 CJS_Document* pJSDocument = nullptr; | 236 CJS_Document* pJSDocument = nullptr; |
| 237 if (pDoc == pCurDoc) { | 237 if (pDoc == pCurDoc) { |
| 238 v8::Local<v8::Object> pObj = FXJS_GetThisObj(pRuntime->GetIsolate()); | 238 v8::Local<v8::Object> pObj = pRuntime->GetThisObj(); |
| 239 if (FXJS_GetObjDefnID(pObj) == CJS_Document::g_nObjDefnID) | 239 if (CFXJS_Engine::GetObjDefnID(pObj) == CJS_Document::g_nObjDefnID) { |
| 240 pJSDocument = | 240 pJSDocument = |
| 241 (CJS_Document*)FXJS_GetPrivate(pRuntime->GetIsolate(), pObj); | 241 static_cast<CJS_Document*>(pRuntime->GetObjectPrivate(pObj)); |
| 242 } |
| 242 } else { | 243 } else { |
| 243 v8::Local<v8::Object> pObj = FXJS_NewFxDynamicObj( | 244 v8::Local<v8::Object> pObj = |
| 244 pRuntime->GetIsolate(), pRuntime, CJS_Document::g_nObjDefnID); | 245 pRuntime->NewFxDynamicObj(CJS_Document::g_nObjDefnID); |
| 245 pJSDocument = | 246 pJSDocument = |
| 246 (CJS_Document*)FXJS_GetPrivate(pRuntime->GetIsolate(), pObj); | 247 static_cast<CJS_Document*>(pRuntime->GetObjectPrivate(pObj)); |
| 247 ASSERT(pJSDocument); | 248 ASSERT(pJSDocument); |
| 248 } | 249 } |
| 249 aDocs.SetElement(pRuntime->GetIsolate(), 0, | 250 aDocs.SetElement(pRuntime, 0, CJS_Value(pRuntime, pJSDocument)); |
| 250 CJS_Value(pRuntime, pJSDocument)); | |
| 251 } | 251 } |
| 252 if (aDocs.GetLength() > 0) | 252 if (aDocs.GetLength(pRuntime) > 0) |
| 253 vp << aDocs; | 253 vp << aDocs; |
| 254 else | 254 else |
| 255 vp.GetJSValue()->SetNull(pRuntime); | 255 vp.GetJSValue()->SetNull(pRuntime); |
| 256 | 256 |
| 257 return TRUE; | 257 return TRUE; |
| 258 } | 258 } |
| 259 | 259 |
| 260 FX_BOOL app::calculate(IJS_Context* cc, | 260 FX_BOOL app::calculate(IJS_Context* cc, |
| 261 CJS_PropValue& vp, | 261 CJS_PropValue& vp, |
| 262 CFX_WideString& sError) { | 262 CFX_WideString& sError) { |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 | 405 |
| 406 CPDFDoc_Environment* pApp = pRuntime->GetReaderApp(); | 406 CPDFDoc_Environment* pApp = pRuntime->GetReaderApp(); |
| 407 if (!pApp) { | 407 if (!pApp) { |
| 408 vRet = CJS_Value(pRuntime, 0); | 408 vRet = CJS_Value(pRuntime, 0); |
| 409 return TRUE; | 409 return TRUE; |
| 410 } | 410 } |
| 411 | 411 |
| 412 CFX_WideString swMsg; | 412 CFX_WideString swMsg; |
| 413 if (newParams[0].GetType() == CJS_Value::VT_object) { | 413 if (newParams[0].GetType() == CJS_Value::VT_object) { |
| 414 CJS_Array carray; | 414 CJS_Array carray; |
| 415 if (newParams[0].ConvertToArray(pRuntime->GetIsolate(), carray)) { | 415 if (newParams[0].ConvertToArray(pRuntime, carray)) { |
| 416 swMsg = L"["; | 416 swMsg = L"["; |
| 417 CJS_Value element(pRuntime); | 417 CJS_Value element(pRuntime); |
| 418 for (int i = 0; i < carray.GetLength(); ++i) { | 418 for (int i = 0; i < carray.GetLength(pRuntime); ++i) { |
| 419 if (i) | 419 if (i) |
| 420 swMsg += L", "; | 420 swMsg += L", "; |
| 421 carray.GetElement(pRuntime->GetIsolate(), i, element); | 421 carray.GetElement(pRuntime, i, element); |
| 422 swMsg += element.ToCFXWideString(pRuntime->GetIsolate()); | 422 swMsg += element.ToCFXWideString(pRuntime); |
| 423 } | 423 } |
| 424 swMsg += L"]"; | 424 swMsg += L"]"; |
| 425 } else { | 425 } else { |
| 426 swMsg = newParams[0].ToCFXWideString(pRuntime->GetIsolate()); | 426 swMsg = newParams[0].ToCFXWideString(pRuntime); |
| 427 } | 427 } |
| 428 } else { | 428 } else { |
| 429 swMsg = newParams[0].ToCFXWideString(pRuntime->GetIsolate()); | 429 swMsg = newParams[0].ToCFXWideString(pRuntime); |
| 430 } | 430 } |
| 431 | 431 |
| 432 int iIcon = 0; | 432 int iIcon = 0; |
| 433 if (newParams[1].GetType() != CJS_Value::VT_unknown) | 433 if (newParams[1].GetType() != CJS_Value::VT_unknown) |
| 434 iIcon = newParams[1].ToInt(pRuntime->GetIsolate()); | 434 iIcon = newParams[1].ToInt(pRuntime); |
| 435 | 435 |
| 436 int iType = 0; | 436 int iType = 0; |
| 437 if (newParams[2].GetType() != CJS_Value::VT_unknown) | 437 if (newParams[2].GetType() != CJS_Value::VT_unknown) |
| 438 iType = newParams[2].ToInt(pRuntime->GetIsolate()); | 438 iType = newParams[2].ToInt(pRuntime); |
| 439 | 439 |
| 440 CFX_WideString swTitle; | 440 CFX_WideString swTitle; |
| 441 if (newParams[3].GetType() != CJS_Value::VT_unknown) | 441 if (newParams[3].GetType() != CJS_Value::VT_unknown) |
| 442 swTitle = newParams[3].ToCFXWideString(pRuntime->GetIsolate()); | 442 swTitle = newParams[3].ToCFXWideString(pRuntime); |
| 443 else | 443 else |
| 444 swTitle = JSGetStringFromID(pContext, IDS_STRING_JSALERT); | 444 swTitle = JSGetStringFromID(pContext, IDS_STRING_JSALERT); |
| 445 | 445 |
| 446 pRuntime->BeginBlock(); | 446 pRuntime->BeginBlock(); |
| 447 if (CPDFSDK_Document* pDoc = pApp->GetSDKDocument()) | 447 if (CPDFSDK_Document* pDoc = pApp->GetSDKDocument()) |
| 448 pDoc->KillFocusAnnot(); | 448 pDoc->KillFocusAnnot(); |
| 449 | 449 |
| 450 vRet = CJS_Value(pRuntime, pApp->JS_appAlert(swMsg.c_str(), swTitle.c_str(), | 450 vRet = CJS_Value(pRuntime, pApp->JS_appAlert(swMsg.c_str(), swTitle.c_str(), |
| 451 iType, iIcon)); | 451 iType, iIcon)); |
| 452 pRuntime->EndBlock(); | 452 pRuntime->EndBlock(); |
| 453 return TRUE; | 453 return TRUE; |
| 454 } | 454 } |
| 455 | 455 |
| 456 FX_BOOL app::beep(IJS_Context* cc, | 456 FX_BOOL app::beep(IJS_Context* cc, |
| 457 const std::vector<CJS_Value>& params, | 457 const std::vector<CJS_Value>& params, |
| 458 CJS_Value& vRet, | 458 CJS_Value& vRet, |
| 459 CFX_WideString& sError) { | 459 CFX_WideString& sError) { |
| 460 if (params.size() == 1) { | 460 if (params.size() == 1) { |
| 461 CJS_Context* pContext = (CJS_Context*)cc; | 461 CJS_Context* pContext = (CJS_Context*)cc; |
| 462 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 462 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
| 463 CPDFDoc_Environment* pEnv = pRuntime->GetReaderApp(); | 463 CPDFDoc_Environment* pEnv = pRuntime->GetReaderApp(); |
| 464 pEnv->JS_appBeep(params[0].ToInt(pRuntime->GetIsolate())); | 464 pEnv->JS_appBeep(params[0].ToInt(pRuntime)); |
| 465 return TRUE; | 465 return TRUE; |
| 466 } | 466 } |
| 467 | 467 |
| 468 sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSPARAMERROR); | 468 sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSPARAMERROR); |
| 469 return FALSE; | 469 return FALSE; |
| 470 } | 470 } |
| 471 | 471 |
| 472 FX_BOOL app::findComponent(IJS_Context* cc, | 472 FX_BOOL app::findComponent(IJS_Context* cc, |
| 473 const std::vector<CJS_Value>& params, | 473 const std::vector<CJS_Value>& params, |
| 474 CJS_Value& vRet, | 474 CJS_Value& vRet, |
| (...skipping 18 matching lines...) Expand all Loading... |
| 493 CFX_WideString& sError) { | 493 CFX_WideString& sError) { |
| 494 CJS_Context* pContext = (CJS_Context*)cc; | 494 CJS_Context* pContext = (CJS_Context*)cc; |
| 495 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); | 495 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); |
| 496 | 496 |
| 497 if (params.size() > 2 || params.size() == 0) { | 497 if (params.size() > 2 || params.size() == 0) { |
| 498 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); | 498 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); |
| 499 return FALSE; | 499 return FALSE; |
| 500 } | 500 } |
| 501 | 501 |
| 502 CFX_WideString script = | 502 CFX_WideString script = |
| 503 params.size() > 0 ? params[0].ToCFXWideString(pRuntime->GetIsolate()) | 503 params.size() > 0 ? params[0].ToCFXWideString(pRuntime) : L""; |
| 504 : L""; | |
| 505 if (script.IsEmpty()) { | 504 if (script.IsEmpty()) { |
| 506 sError = JSGetStringFromID(pContext, IDS_STRING_JSAFNUMBER_KEYSTROKE); | 505 sError = JSGetStringFromID(pContext, IDS_STRING_JSAFNUMBER_KEYSTROKE); |
| 507 return TRUE; | 506 return TRUE; |
| 508 } | 507 } |
| 509 | 508 |
| 510 uint32_t dwInterval = | 509 uint32_t dwInterval = params.size() > 1 ? params[1].ToInt(pRuntime) : 1000; |
| 511 params.size() > 1 ? params[1].ToInt(pRuntime->GetIsolate()) : 1000; | |
| 512 CPDFDoc_Environment* pApp = pRuntime->GetReaderApp(); | 510 CPDFDoc_Environment* pApp = pRuntime->GetReaderApp(); |
| 513 m_Timers.push_back(std::unique_ptr<GlobalTimer>( | 511 m_Timers.push_back(std::unique_ptr<GlobalTimer>( |
| 514 new GlobalTimer(this, pApp, pRuntime, 0, script, dwInterval, 0))); | 512 new GlobalTimer(this, pApp, pRuntime, 0, script, dwInterval, 0))); |
| 515 | 513 |
| 516 v8::Local<v8::Object> pRetObj = FXJS_NewFxDynamicObj( | 514 v8::Local<v8::Object> pRetObj = |
| 517 pRuntime->GetIsolate(), pRuntime, CJS_TimerObj::g_nObjDefnID); | 515 pRuntime->NewFxDynamicObj(CJS_TimerObj::g_nObjDefnID); |
| 518 CJS_TimerObj* pJS_TimerObj = static_cast<CJS_TimerObj*>( | 516 CJS_TimerObj* pJS_TimerObj = |
| 519 FXJS_GetPrivate(pRuntime->GetIsolate(), pRetObj)); | 517 static_cast<CJS_TimerObj*>(pRuntime->GetObjectPrivate(pRetObj)); |
| 520 TimerObj* pTimerObj = static_cast<TimerObj*>(pJS_TimerObj->GetEmbedObject()); | 518 TimerObj* pTimerObj = static_cast<TimerObj*>(pJS_TimerObj->GetEmbedObject()); |
| 521 pTimerObj->SetTimer(m_Timers.back().get()); | 519 pTimerObj->SetTimer(m_Timers.back().get()); |
| 522 | 520 |
| 523 vRet = CJS_Value(pRuntime, pRetObj); | 521 vRet = CJS_Value(pRuntime, pRetObj); |
| 524 return TRUE; | 522 return TRUE; |
| 525 } | 523 } |
| 526 | 524 |
| 527 FX_BOOL app::setTimeOut(IJS_Context* cc, | 525 FX_BOOL app::setTimeOut(IJS_Context* cc, |
| 528 const std::vector<CJS_Value>& params, | 526 const std::vector<CJS_Value>& params, |
| 529 CJS_Value& vRet, | 527 CJS_Value& vRet, |
| 530 CFX_WideString& sError) { | 528 CFX_WideString& sError) { |
| 531 CJS_Context* pContext = static_cast<CJS_Context*>(cc); | 529 CJS_Context* pContext = static_cast<CJS_Context*>(cc); |
| 532 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 530 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
| 533 | 531 |
| 534 if (params.size() > 2 || params.size() == 0) { | 532 if (params.size() > 2 || params.size() == 0) { |
| 535 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); | 533 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); |
| 536 return FALSE; | 534 return FALSE; |
| 537 } | 535 } |
| 538 | 536 |
| 539 CFX_WideString script = params[0].ToCFXWideString(pRuntime->GetIsolate()); | 537 CFX_WideString script = params[0].ToCFXWideString(pRuntime); |
| 540 if (script.IsEmpty()) { | 538 if (script.IsEmpty()) { |
| 541 sError = JSGetStringFromID(pContext, IDS_STRING_JSAFNUMBER_KEYSTROKE); | 539 sError = JSGetStringFromID(pContext, IDS_STRING_JSAFNUMBER_KEYSTROKE); |
| 542 return TRUE; | 540 return TRUE; |
| 543 } | 541 } |
| 544 | 542 |
| 545 uint32_t dwTimeOut = | 543 uint32_t dwTimeOut = params.size() > 1 ? params[1].ToInt(pRuntime) : 1000; |
| 546 params.size() > 1 ? params[1].ToInt(pRuntime->GetIsolate()) : 1000; | |
| 547 CPDFDoc_Environment* pApp = pRuntime->GetReaderApp(); | 544 CPDFDoc_Environment* pApp = pRuntime->GetReaderApp(); |
| 548 m_Timers.push_back(std::unique_ptr<GlobalTimer>( | 545 m_Timers.push_back(std::unique_ptr<GlobalTimer>( |
| 549 new GlobalTimer(this, pApp, pRuntime, 1, script, dwTimeOut, dwTimeOut))); | 546 new GlobalTimer(this, pApp, pRuntime, 1, script, dwTimeOut, dwTimeOut))); |
| 550 | 547 |
| 551 v8::Local<v8::Object> pRetObj = FXJS_NewFxDynamicObj( | 548 v8::Local<v8::Object> pRetObj = |
| 552 pRuntime->GetIsolate(), pRuntime, CJS_TimerObj::g_nObjDefnID); | 549 pRuntime->NewFxDynamicObj(CJS_TimerObj::g_nObjDefnID); |
| 553 | 550 |
| 554 CJS_TimerObj* pJS_TimerObj = static_cast<CJS_TimerObj*>( | 551 CJS_TimerObj* pJS_TimerObj = |
| 555 FXJS_GetPrivate(pRuntime->GetIsolate(), pRetObj)); | 552 static_cast<CJS_TimerObj*>(pRuntime->GetObjectPrivate(pRetObj)); |
| 556 | 553 |
| 557 TimerObj* pTimerObj = static_cast<TimerObj*>(pJS_TimerObj->GetEmbedObject()); | 554 TimerObj* pTimerObj = static_cast<TimerObj*>(pJS_TimerObj->GetEmbedObject()); |
| 558 pTimerObj->SetTimer(m_Timers.back().get()); | 555 pTimerObj->SetTimer(m_Timers.back().get()); |
| 559 | 556 |
| 560 vRet = CJS_Value(pRuntime, pRetObj); | 557 vRet = CJS_Value(pRuntime, pRetObj); |
| 561 return TRUE; | 558 return TRUE; |
| 562 } | 559 } |
| 563 | 560 |
| 564 FX_BOOL app::clearTimeOut(IJS_Context* cc, | 561 FX_BOOL app::clearTimeOut(IJS_Context* cc, |
| 565 const std::vector<CJS_Value>& params, | 562 const std::vector<CJS_Value>& params, |
| 566 CJS_Value& vRet, | 563 CJS_Value& vRet, |
| 567 CFX_WideString& sError) { | 564 CFX_WideString& sError) { |
| 568 CJS_Context* pContext = (CJS_Context*)cc; | 565 CJS_Context* pContext = (CJS_Context*)cc; |
| 569 if (params.size() != 1) { | 566 if (params.size() != 1) { |
| 570 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); | 567 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); |
| 571 return FALSE; | 568 return FALSE; |
| 572 } | 569 } |
| 573 | 570 |
| 574 app::ClearTimerCommon(params[0]); | 571 app::ClearTimerCommon(pContext->GetJSRuntime(), params[0]); |
| 575 return TRUE; | 572 return TRUE; |
| 576 } | 573 } |
| 577 | 574 |
| 578 FX_BOOL app::clearInterval(IJS_Context* cc, | 575 FX_BOOL app::clearInterval(IJS_Context* cc, |
| 579 const std::vector<CJS_Value>& params, | 576 const std::vector<CJS_Value>& params, |
| 580 CJS_Value& vRet, | 577 CJS_Value& vRet, |
| 581 CFX_WideString& sError) { | 578 CFX_WideString& sError) { |
| 582 CJS_Context* pContext = (CJS_Context*)cc; | 579 CJS_Context* pContext = (CJS_Context*)cc; |
| 583 if (params.size() != 1) { | 580 if (params.size() != 1) { |
| 584 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); | 581 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); |
| 585 return FALSE; | 582 return FALSE; |
| 586 } | 583 } |
| 587 | 584 |
| 588 app::ClearTimerCommon(params[0]); | 585 app::ClearTimerCommon(pContext->GetJSRuntime(), params[0]); |
| 589 return TRUE; | 586 return TRUE; |
| 590 } | 587 } |
| 591 | 588 |
| 592 void app::ClearTimerCommon(const CJS_Value& param) { | 589 void app::ClearTimerCommon(CJS_Runtime* pRuntime, const CJS_Value& param) { |
| 593 if (param.GetType() != CJS_Value::VT_object) | 590 if (param.GetType() != CJS_Value::VT_object) |
| 594 return; | 591 return; |
| 595 | 592 |
| 596 v8::Local<v8::Object> pObj = param.ToV8Object(GetJSObject()->GetIsolate()); | 593 v8::Local<v8::Object> pObj = param.ToV8Object(pRuntime); |
| 597 if (FXJS_GetObjDefnID(pObj) != CJS_TimerObj::g_nObjDefnID) | 594 if (CFXJS_Engine::GetObjDefnID(pObj) != CJS_TimerObj::g_nObjDefnID) |
| 598 return; | 595 return; |
| 599 | 596 |
| 600 CJS_Object* pJSObj = param.ToCJSObject(GetJSObject()->GetIsolate()); | 597 CJS_Object* pJSObj = param.ToCJSObject(pRuntime); |
| 601 if (!pJSObj) | 598 if (!pJSObj) |
| 602 return; | 599 return; |
| 603 | 600 |
| 604 TimerObj* pTimerObj = static_cast<TimerObj*>(pJSObj->GetEmbedObject()); | 601 TimerObj* pTimerObj = static_cast<TimerObj*>(pJSObj->GetEmbedObject()); |
| 605 if (!pTimerObj) | 602 if (!pTimerObj) |
| 606 return; | 603 return; |
| 607 | 604 |
| 608 GlobalTimer::Cancel(pTimerObj->GetTimerID()); | 605 GlobalTimer::Cancel(pTimerObj->GetTimerID()); |
| 609 } | 606 } |
| 610 | 607 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 664 CJS_Context* pContext = static_cast<CJS_Context*>(cc); | 661 CJS_Context* pContext = static_cast<CJS_Context*>(cc); |
| 665 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 662 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
| 666 std::vector<CJS_Value> newParams = | 663 std::vector<CJS_Value> newParams = |
| 667 JS_ExpandKeywordParams(pRuntime, params, 6, L"bUI", L"cTo", L"cCc", | 664 JS_ExpandKeywordParams(pRuntime, params, 6, L"bUI", L"cTo", L"cCc", |
| 668 L"cBcc", L"cSubject", L"cMsg"); | 665 L"cBcc", L"cSubject", L"cMsg"); |
| 669 | 666 |
| 670 if (newParams[0].GetType() == CJS_Value::VT_unknown) { | 667 if (newParams[0].GetType() == CJS_Value::VT_unknown) { |
| 671 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); | 668 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); |
| 672 return FALSE; | 669 return FALSE; |
| 673 } | 670 } |
| 674 bool bUI = newParams[0].ToBool(pRuntime->GetIsolate()); | 671 bool bUI = newParams[0].ToBool(pRuntime); |
| 675 | 672 |
| 676 CFX_WideString cTo; | 673 CFX_WideString cTo; |
| 677 if (newParams[1].GetType() != CJS_Value::VT_unknown) { | 674 if (newParams[1].GetType() != CJS_Value::VT_unknown) { |
| 678 cTo = newParams[1].ToCFXWideString(pRuntime->GetIsolate()); | 675 cTo = newParams[1].ToCFXWideString(pRuntime); |
| 679 } else { | 676 } else { |
| 680 if (!bUI) { | 677 if (!bUI) { |
| 681 // cTo parameter required when UI not invoked. | 678 // cTo parameter required when UI not invoked. |
| 682 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); | 679 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); |
| 683 return FALSE; | 680 return FALSE; |
| 684 } | 681 } |
| 685 } | 682 } |
| 686 | 683 |
| 687 CFX_WideString cCc; | 684 CFX_WideString cCc; |
| 688 if (newParams[2].GetType() != CJS_Value::VT_unknown) | 685 if (newParams[2].GetType() != CJS_Value::VT_unknown) |
| 689 cCc = newParams[2].ToCFXWideString(pRuntime->GetIsolate()); | 686 cCc = newParams[2].ToCFXWideString(pRuntime); |
| 690 | 687 |
| 691 CFX_WideString cBcc; | 688 CFX_WideString cBcc; |
| 692 if (newParams[3].GetType() != CJS_Value::VT_unknown) | 689 if (newParams[3].GetType() != CJS_Value::VT_unknown) |
| 693 cBcc = newParams[3].ToCFXWideString(pRuntime->GetIsolate()); | 690 cBcc = newParams[3].ToCFXWideString(pRuntime); |
| 694 | 691 |
| 695 CFX_WideString cSubject; | 692 CFX_WideString cSubject; |
| 696 if (newParams[4].GetType() != CJS_Value::VT_unknown) | 693 if (newParams[4].GetType() != CJS_Value::VT_unknown) |
| 697 cSubject = newParams[4].ToCFXWideString(pRuntime->GetIsolate()); | 694 cSubject = newParams[4].ToCFXWideString(pRuntime); |
| 698 | 695 |
| 699 CFX_WideString cMsg; | 696 CFX_WideString cMsg; |
| 700 if (newParams[5].GetType() != CJS_Value::VT_unknown) | 697 if (newParams[5].GetType() != CJS_Value::VT_unknown) |
| 701 cMsg = newParams[5].ToCFXWideString(pRuntime->GetIsolate()); | 698 cMsg = newParams[5].ToCFXWideString(pRuntime); |
| 702 | 699 |
| 703 pRuntime->BeginBlock(); | 700 pRuntime->BeginBlock(); |
| 704 pContext->GetReaderApp()->JS_docmailForm(nullptr, 0, bUI, cTo.c_str(), | 701 pContext->GetReaderApp()->JS_docmailForm(nullptr, 0, bUI, cTo.c_str(), |
| 705 cSubject.c_str(), cCc.c_str(), | 702 cSubject.c_str(), cCc.c_str(), |
| 706 cBcc.c_str(), cMsg.c_str()); | 703 cBcc.c_str(), cMsg.c_str()); |
| 707 pRuntime->EndBlock(); | 704 pRuntime->EndBlock(); |
| 708 return TRUE; | 705 return TRUE; |
| 709 } | 706 } |
| 710 | 707 |
| 711 FX_BOOL app::launchURL(IJS_Context* cc, | 708 FX_BOOL app::launchURL(IJS_Context* cc, |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 787 CJS_Context* pContext = static_cast<CJS_Context*>(cc); | 784 CJS_Context* pContext = static_cast<CJS_Context*>(cc); |
| 788 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); | 785 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); |
| 789 std::vector<CJS_Value> newParams = | 786 std::vector<CJS_Value> newParams = |
| 790 JS_ExpandKeywordParams(pRuntime, params, 5, L"cQuestion", L"cTitle", | 787 JS_ExpandKeywordParams(pRuntime, params, 5, L"cQuestion", L"cTitle", |
| 791 L"cDefault", L"bPassword", L"cLabel"); | 788 L"cDefault", L"bPassword", L"cLabel"); |
| 792 | 789 |
| 793 if (newParams[0].GetType() == CJS_Value::VT_unknown) { | 790 if (newParams[0].GetType() == CJS_Value::VT_unknown) { |
| 794 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); | 791 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); |
| 795 return FALSE; | 792 return FALSE; |
| 796 } | 793 } |
| 797 CFX_WideString swQuestion = | 794 CFX_WideString swQuestion = newParams[0].ToCFXWideString(pRuntime); |
| 798 newParams[0].ToCFXWideString(pRuntime->GetIsolate()); | |
| 799 | 795 |
| 800 CFX_WideString swTitle = L"PDF"; | 796 CFX_WideString swTitle = L"PDF"; |
| 801 if (newParams[1].GetType() != CJS_Value::VT_unknown) | 797 if (newParams[1].GetType() != CJS_Value::VT_unknown) |
| 802 swTitle = newParams[1].ToCFXWideString(pRuntime->GetIsolate()); | 798 swTitle = newParams[1].ToCFXWideString(pRuntime); |
| 803 | 799 |
| 804 CFX_WideString swDefault; | 800 CFX_WideString swDefault; |
| 805 if (newParams[2].GetType() != CJS_Value::VT_unknown) | 801 if (newParams[2].GetType() != CJS_Value::VT_unknown) |
| 806 swDefault = newParams[2].ToCFXWideString(pRuntime->GetIsolate()); | 802 swDefault = newParams[2].ToCFXWideString(pRuntime); |
| 807 | 803 |
| 808 bool bPassword = false; | 804 bool bPassword = false; |
| 809 if (newParams[3].GetType() != CJS_Value::VT_unknown) | 805 if (newParams[3].GetType() != CJS_Value::VT_unknown) |
| 810 bPassword = newParams[3].ToBool(pRuntime->GetIsolate()); | 806 bPassword = newParams[3].ToBool(pRuntime); |
| 811 | 807 |
| 812 CFX_WideString swLabel; | 808 CFX_WideString swLabel; |
| 813 if (newParams[4].GetType() != CJS_Value::VT_unknown) | 809 if (newParams[4].GetType() != CJS_Value::VT_unknown) |
| 814 swLabel = newParams[4].ToCFXWideString(pRuntime->GetIsolate()); | 810 swLabel = newParams[4].ToCFXWideString(pRuntime); |
| 815 | 811 |
| 816 const int MAX_INPUT_BYTES = 2048; | 812 const int MAX_INPUT_BYTES = 2048; |
| 817 std::unique_ptr<char[]> pBuff(new char[MAX_INPUT_BYTES + 2]); | 813 std::unique_ptr<char[]> pBuff(new char[MAX_INPUT_BYTES + 2]); |
| 818 memset(pBuff.get(), 0, MAX_INPUT_BYTES + 2); | 814 memset(pBuff.get(), 0, MAX_INPUT_BYTES + 2); |
| 819 | 815 |
| 820 int nLengthBytes = pContext->GetReaderApp()->JS_appResponse( | 816 int nLengthBytes = pContext->GetReaderApp()->JS_appResponse( |
| 821 swQuestion.c_str(), swTitle.c_str(), swDefault.c_str(), swLabel.c_str(), | 817 swQuestion.c_str(), swTitle.c_str(), swDefault.c_str(), swLabel.c_str(), |
| 822 bPassword, pBuff.get(), MAX_INPUT_BYTES); | 818 bPassword, pBuff.get(), MAX_INPUT_BYTES); |
| 823 | 819 |
| 824 if (nLengthBytes < 0 || nLengthBytes > MAX_INPUT_BYTES) { | 820 if (nLengthBytes < 0 || nLengthBytes > MAX_INPUT_BYTES) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 837 FX_BOOL app::media(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) { | 833 FX_BOOL app::media(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) { |
| 838 return FALSE; | 834 return FALSE; |
| 839 } | 835 } |
| 840 | 836 |
| 841 FX_BOOL app::execDialog(IJS_Context* cc, | 837 FX_BOOL app::execDialog(IJS_Context* cc, |
| 842 const std::vector<CJS_Value>& params, | 838 const std::vector<CJS_Value>& params, |
| 843 CJS_Value& vRet, | 839 CJS_Value& vRet, |
| 844 CFX_WideString& sError) { | 840 CFX_WideString& sError) { |
| 845 return TRUE; | 841 return TRUE; |
| 846 } | 842 } |
| OLD | NEW |