| 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 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 CJS_Context* pContext = static_cast<CJS_Context*>(cc); | 396 CJS_Context* pContext = static_cast<CJS_Context*>(cc); |
| 397 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); | 397 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); |
| 398 std::vector<CJS_Value> newParams = JS_ExpandKeywordParams( | 398 std::vector<CJS_Value> newParams = JS_ExpandKeywordParams( |
| 399 pRuntime, params, 4, L"cMsg", L"nIcon", L"nType", L"cTitle"); | 399 pRuntime, params, 4, L"cMsg", L"nIcon", L"nType", L"cTitle"); |
| 400 | 400 |
| 401 if (newParams[0].GetType() == CJS_Value::VT_unknown) { | 401 if (newParams[0].GetType() == CJS_Value::VT_unknown) { |
| 402 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); | 402 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); |
| 403 return FALSE; | 403 return FALSE; |
| 404 } | 404 } |
| 405 | 405 |
| 406 CPDFDoc_Environment* pApp = pRuntime->GetReaderApp(); |
| 407 if (!pApp) { |
| 408 vRet = 0; |
| 409 return TRUE; |
| 410 } |
| 411 |
| 406 CFX_WideString swMsg; | 412 CFX_WideString swMsg; |
| 407 if (newParams[0].GetType() == CJS_Value::VT_object) { | 413 if (newParams[0].GetType() == CJS_Value::VT_object) { |
| 408 CJS_Array carray; | 414 CJS_Array carray; |
| 409 if (newParams[0].ConvertToArray(carray)) { | 415 if (newParams[0].ConvertToArray(carray)) { |
| 410 swMsg = L"["; | 416 swMsg = L"["; |
| 411 CJS_Value element(pRuntime); | 417 CJS_Value element(pRuntime); |
| 412 for (int i = 0; i < carray.GetLength(); ++i) { | 418 for (int i = 0; i < carray.GetLength(); ++i) { |
| 413 if (i) | 419 if (i) |
| 414 swMsg += L", "; | 420 swMsg += L", "; |
| 415 carray.GetElement(pRuntime->GetIsolate(), i, element); | 421 carray.GetElement(pRuntime->GetIsolate(), i, element); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 431 if (newParams[2].GetType() != CJS_Value::VT_unknown) | 437 if (newParams[2].GetType() != CJS_Value::VT_unknown) |
| 432 iType = newParams[2].ToInt(); | 438 iType = newParams[2].ToInt(); |
| 433 | 439 |
| 434 CFX_WideString swTitle; | 440 CFX_WideString swTitle; |
| 435 if (newParams[3].GetType() != CJS_Value::VT_unknown) | 441 if (newParams[3].GetType() != CJS_Value::VT_unknown) |
| 436 swTitle = newParams[3].ToCFXWideString(); | 442 swTitle = newParams[3].ToCFXWideString(); |
| 437 else | 443 else |
| 438 swTitle = JSGetStringFromID(pContext, IDS_STRING_JSALERT); | 444 swTitle = JSGetStringFromID(pContext, IDS_STRING_JSALERT); |
| 439 | 445 |
| 440 pRuntime->BeginBlock(); | 446 pRuntime->BeginBlock(); |
| 441 vRet = MsgBox(pRuntime->GetReaderApp(), swMsg.c_str(), swTitle.c_str(), iType, | 447 if (CPDFSDK_Document* pDoc = pApp->GetSDKDocument()) |
| 442 iIcon); | 448 pDoc->KillFocusAnnot(); |
| 449 |
| 450 vRet = pApp->JS_appAlert(swMsg.c_str(), swTitle.c_str(), iType, iIcon); |
| 443 pRuntime->EndBlock(); | 451 pRuntime->EndBlock(); |
| 444 return TRUE; | 452 return TRUE; |
| 445 } | 453 } |
| 446 | 454 |
| 447 FX_BOOL app::beep(IJS_Context* cc, | 455 FX_BOOL app::beep(IJS_Context* cc, |
| 448 const std::vector<CJS_Value>& params, | 456 const std::vector<CJS_Value>& params, |
| 449 CJS_Value& vRet, | 457 CJS_Value& vRet, |
| 450 CFX_WideString& sError) { | 458 CFX_WideString& sError) { |
| 451 if (params.size() == 1) { | 459 if (params.size() == 1) { |
| 452 CJS_Context* pContext = (CJS_Context*)cc; | 460 CJS_Context* pContext = (CJS_Context*)cc; |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 819 FX_BOOL app::media(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) { | 827 FX_BOOL app::media(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) { |
| 820 return FALSE; | 828 return FALSE; |
| 821 } | 829 } |
| 822 | 830 |
| 823 FX_BOOL app::execDialog(IJS_Context* cc, | 831 FX_BOOL app::execDialog(IJS_Context* cc, |
| 824 const std::vector<CJS_Value>& params, | 832 const std::vector<CJS_Value>& params, |
| 825 CJS_Value& vRet, | 833 CJS_Value& vRet, |
| 826 CFX_WideString& sError) { | 834 CFX_WideString& sError) { |
| 827 return TRUE; | 835 return TRUE; |
| 828 } | 836 } |
| OLD | NEW |