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> |
11 | 11 |
12 #include "fpdfsdk/include/cpdfsdk_document.h" | 12 #include "fpdfsdk/include/cpdfsdk_document.h" |
13 #include "fpdfsdk/include/cpdfsdk_environment.h" | 13 #include "fpdfsdk/include/cpdfsdk_environment.h" |
14 #include "fpdfsdk/include/cpdfsdk_interform.h" | 14 #include "fpdfsdk/include/cpdfsdk_interform.h" |
15 #include "fpdfsdk/javascript/Document.h" | 15 #include "fpdfsdk/javascript/Document.h" |
16 #include "fpdfsdk/javascript/JS_Define.h" | 16 #include "fpdfsdk/javascript/JS_Define.h" |
17 #include "fpdfsdk/javascript/JS_EventHandler.h" | 17 #include "fpdfsdk/javascript/JS_EventHandler.h" |
18 #include "fpdfsdk/javascript/JS_Object.h" | 18 #include "fpdfsdk/javascript/JS_Object.h" |
19 #include "fpdfsdk/javascript/JS_Value.h" | 19 #include "fpdfsdk/javascript/JS_Value.h" |
20 #include "fpdfsdk/javascript/cjs_context.h" | 20 #include "fpdfsdk/javascript/cjs_context.h" |
21 #include "fpdfsdk/javascript/cjs_runtime.h" | 21 #include "fpdfsdk/javascript/cjs_runtime.h" |
22 #include "fpdfsdk/javascript/resource.h" | 22 #include "fpdfsdk/javascript/resource.h" |
23 #include "third_party/base/stl_util.h" | 23 #include "third_party/base/stl_util.h" |
24 | 24 |
25 class GlobalTimer { | 25 class GlobalTimer { |
26 public: | 26 public: |
27 GlobalTimer(app* pObj, | 27 GlobalTimer(app* pObj, |
28 CPDFSDK_Environment* pApp, | 28 CPDFSDK_Environment* pEnv, |
29 CJS_Runtime* pRuntime, | 29 CJS_Runtime* pRuntime, |
30 int nType, | 30 int nType, |
31 const CFX_WideString& script, | 31 const CFX_WideString& script, |
32 uint32_t dwElapse, | 32 uint32_t dwElapse, |
33 uint32_t dwTimeOut); | 33 uint32_t dwTimeOut); |
34 ~GlobalTimer(); | 34 ~GlobalTimer(); |
35 | 35 |
36 static void Trigger(int nTimerID); | 36 static void Trigger(int nTimerID); |
37 static void Cancel(int nTimerID); | 37 static void Cancel(int nTimerID); |
38 | 38 |
39 bool IsOneShot() const { return m_nType == 1; } | 39 bool IsOneShot() const { return m_nType == 1; } |
40 uint32_t GetTimeOut() const { return m_dwTimeOut; } | 40 uint32_t GetTimeOut() const { return m_dwTimeOut; } |
41 int GetTimerID() const { return m_nTimerID; } | 41 int GetTimerID() const { return m_nTimerID; } |
42 CJS_Runtime* GetRuntime() const { return m_pRuntime.Get(); } | 42 CJS_Runtime* GetRuntime() const { return m_pRuntime.Get(); } |
43 CFX_WideString GetJScript() const { return m_swJScript; } | 43 CFX_WideString GetJScript() const { return m_swJScript; } |
44 | 44 |
45 private: | 45 private: |
46 using TimerMap = std::map<uint32_t, GlobalTimer*>; | 46 using TimerMap = std::map<uint32_t, GlobalTimer*>; |
47 static TimerMap* GetGlobalTimerMap(); | 47 static TimerMap* GetGlobalTimerMap(); |
48 | 48 |
49 uint32_t m_nTimerID; | 49 uint32_t m_nTimerID; |
50 app* const m_pEmbedObj; | 50 app* const m_pEmbedObj; |
51 bool m_bProcessing; | 51 bool m_bProcessing; |
52 | 52 |
53 // data | 53 // data |
54 const int m_nType; // 0:Interval; 1:TimeOut | 54 const int m_nType; // 0:Interval; 1:TimeOut |
55 const uint32_t m_dwTimeOut; | 55 const uint32_t m_dwTimeOut; |
56 const CFX_WideString m_swJScript; | 56 const CFX_WideString m_swJScript; |
57 CJS_Runtime::ObservedPtr m_pRuntime; | 57 CJS_Runtime::ObservedPtr m_pRuntime; |
58 CPDFSDK_Environment* const m_pApp; | 58 CPDFSDK_Environment* const m_pEnv; |
59 }; | 59 }; |
60 | 60 |
61 GlobalTimer::GlobalTimer(app* pObj, | 61 GlobalTimer::GlobalTimer(app* pObj, |
62 CPDFSDK_Environment* pApp, | 62 CPDFSDK_Environment* pEnv, |
63 CJS_Runtime* pRuntime, | 63 CJS_Runtime* pRuntime, |
64 int nType, | 64 int nType, |
65 const CFX_WideString& script, | 65 const CFX_WideString& script, |
66 uint32_t dwElapse, | 66 uint32_t dwElapse, |
67 uint32_t dwTimeOut) | 67 uint32_t dwTimeOut) |
68 : m_nTimerID(0), | 68 : m_nTimerID(0), |
69 m_pEmbedObj(pObj), | 69 m_pEmbedObj(pObj), |
70 m_bProcessing(false), | 70 m_bProcessing(false), |
71 m_nType(nType), | 71 m_nType(nType), |
72 m_dwTimeOut(dwTimeOut), | 72 m_dwTimeOut(dwTimeOut), |
73 m_swJScript(script), | 73 m_swJScript(script), |
74 m_pRuntime(pRuntime), | 74 m_pRuntime(pRuntime), |
75 m_pApp(pApp) { | 75 m_pEnv(pEnv) { |
76 CFX_SystemHandler* pHandler = m_pApp->GetSysHandler(); | 76 CFX_SystemHandler* pHandler = m_pEnv->GetSysHandler(); |
77 m_nTimerID = pHandler->SetTimer(dwElapse, Trigger); | 77 m_nTimerID = pHandler->SetTimer(dwElapse, Trigger); |
78 (*GetGlobalTimerMap())[m_nTimerID] = this; | 78 (*GetGlobalTimerMap())[m_nTimerID] = this; |
79 } | 79 } |
80 | 80 |
81 GlobalTimer::~GlobalTimer() { | 81 GlobalTimer::~GlobalTimer() { |
82 if (!m_nTimerID) | 82 if (!m_nTimerID) |
83 return; | 83 return; |
84 | 84 |
85 if (GetRuntime()) | 85 if (GetRuntime()) |
86 m_pApp->GetSysHandler()->KillTimer(m_nTimerID); | 86 m_pEnv->GetSysHandler()->KillTimer(m_nTimerID); |
87 | 87 |
88 GetGlobalTimerMap()->erase(m_nTimerID); | 88 GetGlobalTimerMap()->erase(m_nTimerID); |
89 } | 89 } |
90 | 90 |
91 // static | 91 // static |
92 void GlobalTimer::Trigger(int nTimerID) { | 92 void GlobalTimer::Trigger(int nTimerID) { |
93 auto it = GetGlobalTimerMap()->find(nTimerID); | 93 auto it = GetGlobalTimerMap()->find(nTimerID); |
94 if (it == GetGlobalTimerMap()->end()) | 94 if (it == GetGlobalTimerMap()->end()) |
95 return; | 95 return; |
96 | 96 |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 app::~app() { | 210 app::~app() { |
211 } | 211 } |
212 | 212 |
213 FX_BOOL app::activeDocs(IJS_Context* cc, | 213 FX_BOOL app::activeDocs(IJS_Context* cc, |
214 CJS_PropValue& vp, | 214 CJS_PropValue& vp, |
215 CFX_WideString& sError) { | 215 CFX_WideString& sError) { |
216 if (!vp.IsGetting()) | 216 if (!vp.IsGetting()) |
217 return FALSE; | 217 return FALSE; |
218 | 218 |
219 CJS_Context* pContext = (CJS_Context*)cc; | 219 CJS_Context* pContext = (CJS_Context*)cc; |
220 CPDFSDK_Environment* pApp = pContext->GetReaderApp(); | 220 CPDFSDK_Environment* pEnv = pContext->GetReaderEnv(); |
221 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 221 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
222 CPDFSDK_Document* pCurDoc = pContext->GetReaderDocument(); | 222 CPDFSDK_Document* pCurDoc = pContext->GetReaderDocument(); |
223 CJS_Array aDocs; | 223 CJS_Array aDocs; |
224 if (CPDFSDK_Document* pDoc = pApp->GetSDKDocument()) { | 224 if (CPDFSDK_Document* pDoc = pEnv->GetSDKDocument()) { |
225 CJS_Document* pJSDocument = nullptr; | 225 CJS_Document* pJSDocument = nullptr; |
226 if (pDoc == pCurDoc) { | 226 if (pDoc == pCurDoc) { |
227 v8::Local<v8::Object> pObj = pRuntime->GetThisObj(); | 227 v8::Local<v8::Object> pObj = pRuntime->GetThisObj(); |
228 if (CFXJS_Engine::GetObjDefnID(pObj) == CJS_Document::g_nObjDefnID) { | 228 if (CFXJS_Engine::GetObjDefnID(pObj) == CJS_Document::g_nObjDefnID) { |
229 pJSDocument = | 229 pJSDocument = |
230 static_cast<CJS_Document*>(pRuntime->GetObjectPrivate(pObj)); | 230 static_cast<CJS_Document*>(pRuntime->GetObjectPrivate(pObj)); |
231 } | 231 } |
232 } else { | 232 } else { |
233 v8::Local<v8::Object> pObj = | 233 v8::Local<v8::Object> pObj = |
234 pRuntime->NewFxDynamicObj(CJS_Document::g_nObjDefnID); | 234 pRuntime->NewFxDynamicObj(CJS_Document::g_nObjDefnID); |
(...skipping 13 matching lines...) Expand all Loading... |
248 | 248 |
249 FX_BOOL app::calculate(IJS_Context* cc, | 249 FX_BOOL app::calculate(IJS_Context* cc, |
250 CJS_PropValue& vp, | 250 CJS_PropValue& vp, |
251 CFX_WideString& sError) { | 251 CFX_WideString& sError) { |
252 if (vp.IsSetting()) { | 252 if (vp.IsSetting()) { |
253 bool bVP; | 253 bool bVP; |
254 vp >> bVP; | 254 vp >> bVP; |
255 m_bCalculate = (FX_BOOL)bVP; | 255 m_bCalculate = (FX_BOOL)bVP; |
256 | 256 |
257 CJS_Context* pContext = (CJS_Context*)cc; | 257 CJS_Context* pContext = (CJS_Context*)cc; |
258 CPDFSDK_Environment* pApp = pContext->GetReaderApp(); | 258 CPDFSDK_Environment* pEnv = pContext->GetReaderEnv(); |
259 if (CPDFSDK_Document* pDoc = pApp->GetSDKDocument()) | 259 if (CPDFSDK_Document* pDoc = pEnv->GetSDKDocument()) |
260 pDoc->GetInterForm()->EnableCalculate((FX_BOOL)m_bCalculate); | 260 pDoc->GetInterForm()->EnableCalculate((FX_BOOL)m_bCalculate); |
261 } else { | 261 } else { |
262 vp << (bool)m_bCalculate; | 262 vp << (bool)m_bCalculate; |
263 } | 263 } |
264 return TRUE; | 264 return TRUE; |
265 } | 265 } |
266 | 266 |
267 FX_BOOL app::formsVersion(IJS_Context* cc, | 267 FX_BOOL app::formsVersion(IJS_Context* cc, |
268 CJS_PropValue& vp, | 268 CJS_PropValue& vp, |
269 CFX_WideString& sError) { | 269 CFX_WideString& sError) { |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 return TRUE; | 315 return TRUE; |
316 } | 316 } |
317 | 317 |
318 FX_BOOL app::platform(IJS_Context* cc, | 318 FX_BOOL app::platform(IJS_Context* cc, |
319 CJS_PropValue& vp, | 319 CJS_PropValue& vp, |
320 CFX_WideString& sError) { | 320 CFX_WideString& sError) { |
321 if (!vp.IsGetting()) | 321 if (!vp.IsGetting()) |
322 return FALSE; | 322 return FALSE; |
323 #ifdef PDF_ENABLE_XFA | 323 #ifdef PDF_ENABLE_XFA |
324 CPDFSDK_Environment* pEnv = | 324 CPDFSDK_Environment* pEnv = |
325 static_cast<CJS_Context*>(cc)->GetJSRuntime()->GetReaderApp(); | 325 static_cast<CJS_Context*>(cc)->GetJSRuntime()->GetReaderEnv(); |
326 if (!pEnv) | 326 if (!pEnv) |
327 return FALSE; | 327 return FALSE; |
328 CFX_WideString platfrom = pEnv->GetPlatform(); | 328 CFX_WideString platfrom = pEnv->GetPlatform(); |
329 if (!platfrom.IsEmpty()) { | 329 if (!platfrom.IsEmpty()) { |
330 vp << platfrom; | 330 vp << platfrom; |
331 return TRUE; | 331 return TRUE; |
332 } | 332 } |
333 #endif | 333 #endif |
334 vp << JS_STR_PLATFORM; | 334 vp << JS_STR_PLATFORM; |
335 return TRUE; | 335 return TRUE; |
336 } | 336 } |
337 | 337 |
338 FX_BOOL app::language(IJS_Context* cc, | 338 FX_BOOL app::language(IJS_Context* cc, |
339 CJS_PropValue& vp, | 339 CJS_PropValue& vp, |
340 CFX_WideString& sError) { | 340 CFX_WideString& sError) { |
341 if (!vp.IsGetting()) | 341 if (!vp.IsGetting()) |
342 return FALSE; | 342 return FALSE; |
343 #ifdef PDF_ENABLE_XFA | 343 #ifdef PDF_ENABLE_XFA |
344 CPDFSDK_Environment* pEnv = | 344 CPDFSDK_Environment* pEnv = |
345 static_cast<CJS_Context*>(cc)->GetJSRuntime()->GetReaderApp(); | 345 static_cast<CJS_Context*>(cc)->GetJSRuntime()->GetReaderEnv(); |
346 if (!pEnv) | 346 if (!pEnv) |
347 return FALSE; | 347 return FALSE; |
348 CFX_WideString language = pEnv->GetLanguage(); | 348 CFX_WideString language = pEnv->GetLanguage(); |
349 if (!language.IsEmpty()) { | 349 if (!language.IsEmpty()) { |
350 vp << language; | 350 vp << language; |
351 return TRUE; | 351 return TRUE; |
352 } | 352 } |
353 #endif | 353 #endif |
354 vp << JS_STR_LANGUANGE; | 354 vp << JS_STR_LANGUANGE; |
355 return TRUE; | 355 return TRUE; |
(...skipping 28 matching lines...) Expand all Loading... |
384 CFX_WideString& sError) { | 384 CFX_WideString& sError) { |
385 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); | 385 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); |
386 std::vector<CJS_Value> newParams = JS_ExpandKeywordParams( | 386 std::vector<CJS_Value> newParams = JS_ExpandKeywordParams( |
387 pRuntime, params, 4, L"cMsg", L"nIcon", L"nType", L"cTitle"); | 387 pRuntime, params, 4, L"cMsg", L"nIcon", L"nType", L"cTitle"); |
388 | 388 |
389 if (newParams[0].GetType() == CJS_Value::VT_unknown) { | 389 if (newParams[0].GetType() == CJS_Value::VT_unknown) { |
390 sError = JSGetStringFromID(IDS_STRING_JSPARAMERROR); | 390 sError = JSGetStringFromID(IDS_STRING_JSPARAMERROR); |
391 return FALSE; | 391 return FALSE; |
392 } | 392 } |
393 | 393 |
394 CPDFSDK_Environment* pApp = pRuntime->GetReaderApp(); | 394 CPDFSDK_Environment* pEnv = pRuntime->GetReaderEnv(); |
395 if (!pApp) { | 395 if (!pEnv) { |
396 vRet = CJS_Value(pRuntime, 0); | 396 vRet = CJS_Value(pRuntime, 0); |
397 return TRUE; | 397 return TRUE; |
398 } | 398 } |
399 | 399 |
400 CFX_WideString swMsg; | 400 CFX_WideString swMsg; |
401 if (newParams[0].GetType() == CJS_Value::VT_object) { | 401 if (newParams[0].GetType() == CJS_Value::VT_object) { |
402 CJS_Array carray; | 402 CJS_Array carray; |
403 if (newParams[0].ConvertToArray(pRuntime, carray)) { | 403 if (newParams[0].ConvertToArray(pRuntime, carray)) { |
404 swMsg = L"["; | 404 swMsg = L"["; |
405 CJS_Value element(pRuntime); | 405 CJS_Value element(pRuntime); |
(...skipping 19 matching lines...) Expand all Loading... |
425 if (newParams[2].GetType() != CJS_Value::VT_unknown) | 425 if (newParams[2].GetType() != CJS_Value::VT_unknown) |
426 iType = newParams[2].ToInt(pRuntime); | 426 iType = newParams[2].ToInt(pRuntime); |
427 | 427 |
428 CFX_WideString swTitle; | 428 CFX_WideString swTitle; |
429 if (newParams[3].GetType() != CJS_Value::VT_unknown) | 429 if (newParams[3].GetType() != CJS_Value::VT_unknown) |
430 swTitle = newParams[3].ToCFXWideString(pRuntime); | 430 swTitle = newParams[3].ToCFXWideString(pRuntime); |
431 else | 431 else |
432 swTitle = JSGetStringFromID(IDS_STRING_JSALERT); | 432 swTitle = JSGetStringFromID(IDS_STRING_JSALERT); |
433 | 433 |
434 pRuntime->BeginBlock(); | 434 pRuntime->BeginBlock(); |
435 if (CPDFSDK_Document* pDoc = pApp->GetSDKDocument()) | 435 if (CPDFSDK_Document* pDoc = pEnv->GetSDKDocument()) |
436 pDoc->KillFocusAnnot(); | 436 pDoc->KillFocusAnnot(); |
437 | 437 |
438 vRet = CJS_Value(pRuntime, pApp->JS_appAlert(swMsg.c_str(), swTitle.c_str(), | 438 vRet = CJS_Value(pRuntime, pEnv->JS_appAlert(swMsg.c_str(), swTitle.c_str(), |
439 iType, iIcon)); | 439 iType, iIcon)); |
440 pRuntime->EndBlock(); | 440 pRuntime->EndBlock(); |
441 return TRUE; | 441 return TRUE; |
442 } | 442 } |
443 | 443 |
444 FX_BOOL app::beep(IJS_Context* cc, | 444 FX_BOOL app::beep(IJS_Context* cc, |
445 const std::vector<CJS_Value>& params, | 445 const std::vector<CJS_Value>& params, |
446 CJS_Value& vRet, | 446 CJS_Value& vRet, |
447 CFX_WideString& sError) { | 447 CFX_WideString& sError) { |
448 if (params.size() == 1) { | 448 if (params.size() == 1) { |
449 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); | 449 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); |
450 CPDFSDK_Environment* pEnv = pRuntime->GetReaderApp(); | 450 CPDFSDK_Environment* pEnv = pRuntime->GetReaderEnv(); |
451 pEnv->JS_appBeep(params[0].ToInt(pRuntime)); | 451 pEnv->JS_appBeep(params[0].ToInt(pRuntime)); |
452 return TRUE; | 452 return TRUE; |
453 } | 453 } |
454 | 454 |
455 sError = JSGetStringFromID(IDS_STRING_JSPARAMERROR); | 455 sError = JSGetStringFromID(IDS_STRING_JSPARAMERROR); |
456 return FALSE; | 456 return FALSE; |
457 } | 457 } |
458 | 458 |
459 FX_BOOL app::findComponent(IJS_Context* cc, | 459 FX_BOOL app::findComponent(IJS_Context* cc, |
460 const std::vector<CJS_Value>& params, | 460 const std::vector<CJS_Value>& params, |
(...skipping 24 matching lines...) Expand all Loading... |
485 | 485 |
486 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); | 486 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); |
487 CFX_WideString script = | 487 CFX_WideString script = |
488 params.size() > 0 ? params[0].ToCFXWideString(pRuntime) : L""; | 488 params.size() > 0 ? params[0].ToCFXWideString(pRuntime) : L""; |
489 if (script.IsEmpty()) { | 489 if (script.IsEmpty()) { |
490 sError = JSGetStringFromID(IDS_STRING_JSAFNUMBER_KEYSTROKE); | 490 sError = JSGetStringFromID(IDS_STRING_JSAFNUMBER_KEYSTROKE); |
491 return TRUE; | 491 return TRUE; |
492 } | 492 } |
493 | 493 |
494 uint32_t dwInterval = params.size() > 1 ? params[1].ToInt(pRuntime) : 1000; | 494 uint32_t dwInterval = params.size() > 1 ? params[1].ToInt(pRuntime) : 1000; |
495 CPDFSDK_Environment* pApp = pRuntime->GetReaderApp(); | 495 CPDFSDK_Environment* pEnv = pRuntime->GetReaderEnv(); |
496 | 496 |
497 GlobalTimer* timerRef = | 497 GlobalTimer* timerRef = |
498 new GlobalTimer(this, pApp, pRuntime, 0, script, dwInterval, 0); | 498 new GlobalTimer(this, pEnv, pRuntime, 0, script, dwInterval, 0); |
499 m_Timers.insert(std::unique_ptr<GlobalTimer>(timerRef)); | 499 m_Timers.insert(std::unique_ptr<GlobalTimer>(timerRef)); |
500 | 500 |
501 v8::Local<v8::Object> pRetObj = | 501 v8::Local<v8::Object> pRetObj = |
502 pRuntime->NewFxDynamicObj(CJS_TimerObj::g_nObjDefnID); | 502 pRuntime->NewFxDynamicObj(CJS_TimerObj::g_nObjDefnID); |
503 CJS_TimerObj* pJS_TimerObj = | 503 CJS_TimerObj* pJS_TimerObj = |
504 static_cast<CJS_TimerObj*>(pRuntime->GetObjectPrivate(pRetObj)); | 504 static_cast<CJS_TimerObj*>(pRuntime->GetObjectPrivate(pRetObj)); |
505 TimerObj* pTimerObj = static_cast<TimerObj*>(pJS_TimerObj->GetEmbedObject()); | 505 TimerObj* pTimerObj = static_cast<TimerObj*>(pJS_TimerObj->GetEmbedObject()); |
506 pTimerObj->SetTimer(timerRef); | 506 pTimerObj->SetTimer(timerRef); |
507 | 507 |
508 vRet = CJS_Value(pRuntime, pRetObj); | 508 vRet = CJS_Value(pRuntime, pRetObj); |
(...skipping 10 matching lines...) Expand all Loading... |
519 } | 519 } |
520 | 520 |
521 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); | 521 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); |
522 CFX_WideString script = params[0].ToCFXWideString(pRuntime); | 522 CFX_WideString script = params[0].ToCFXWideString(pRuntime); |
523 if (script.IsEmpty()) { | 523 if (script.IsEmpty()) { |
524 sError = JSGetStringFromID(IDS_STRING_JSAFNUMBER_KEYSTROKE); | 524 sError = JSGetStringFromID(IDS_STRING_JSAFNUMBER_KEYSTROKE); |
525 return TRUE; | 525 return TRUE; |
526 } | 526 } |
527 | 527 |
528 uint32_t dwTimeOut = params.size() > 1 ? params[1].ToInt(pRuntime) : 1000; | 528 uint32_t dwTimeOut = params.size() > 1 ? params[1].ToInt(pRuntime) : 1000; |
529 CPDFSDK_Environment* pApp = pRuntime->GetReaderApp(); | 529 CPDFSDK_Environment* pEnv = pRuntime->GetReaderEnv(); |
530 | 530 |
531 GlobalTimer* timerRef = | 531 GlobalTimer* timerRef = |
532 new GlobalTimer(this, pApp, pRuntime, 1, script, dwTimeOut, dwTimeOut); | 532 new GlobalTimer(this, pEnv, pRuntime, 1, script, dwTimeOut, dwTimeOut); |
533 m_Timers.insert(std::unique_ptr<GlobalTimer>(timerRef)); | 533 m_Timers.insert(std::unique_ptr<GlobalTimer>(timerRef)); |
534 | 534 |
535 v8::Local<v8::Object> pRetObj = | 535 v8::Local<v8::Object> pRetObj = |
536 pRuntime->NewFxDynamicObj(CJS_TimerObj::g_nObjDefnID); | 536 pRuntime->NewFxDynamicObj(CJS_TimerObj::g_nObjDefnID); |
537 | 537 |
538 CJS_TimerObj* pJS_TimerObj = | 538 CJS_TimerObj* pJS_TimerObj = |
539 static_cast<CJS_TimerObj*>(pRuntime->GetObjectPrivate(pRetObj)); | 539 static_cast<CJS_TimerObj*>(pRuntime->GetObjectPrivate(pRetObj)); |
540 | 540 |
541 TimerObj* pTimerObj = static_cast<TimerObj*>(pJS_TimerObj->GetEmbedObject()); | 541 TimerObj* pTimerObj = static_cast<TimerObj*>(pJS_TimerObj->GetEmbedObject()); |
542 pTimerObj->SetTimer(timerRef); | 542 pTimerObj->SetTimer(timerRef); |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
670 CFX_WideString cSubject; | 670 CFX_WideString cSubject; |
671 if (newParams[4].GetType() != CJS_Value::VT_unknown) | 671 if (newParams[4].GetType() != CJS_Value::VT_unknown) |
672 cSubject = newParams[4].ToCFXWideString(pRuntime); | 672 cSubject = newParams[4].ToCFXWideString(pRuntime); |
673 | 673 |
674 CFX_WideString cMsg; | 674 CFX_WideString cMsg; |
675 if (newParams[5].GetType() != CJS_Value::VT_unknown) | 675 if (newParams[5].GetType() != CJS_Value::VT_unknown) |
676 cMsg = newParams[5].ToCFXWideString(pRuntime); | 676 cMsg = newParams[5].ToCFXWideString(pRuntime); |
677 | 677 |
678 pRuntime->BeginBlock(); | 678 pRuntime->BeginBlock(); |
679 CJS_Context* pContext = static_cast<CJS_Context*>(cc); | 679 CJS_Context* pContext = static_cast<CJS_Context*>(cc); |
680 pContext->GetReaderApp()->JS_docmailForm(nullptr, 0, bUI, cTo.c_str(), | 680 pContext->GetReaderEnv()->JS_docmailForm(nullptr, 0, bUI, cTo.c_str(), |
681 cSubject.c_str(), cCc.c_str(), | 681 cSubject.c_str(), cCc.c_str(), |
682 cBcc.c_str(), cMsg.c_str()); | 682 cBcc.c_str(), cMsg.c_str()); |
683 pRuntime->EndBlock(); | 683 pRuntime->EndBlock(); |
684 return TRUE; | 684 return TRUE; |
685 } | 685 } |
686 | 686 |
687 FX_BOOL app::launchURL(IJS_Context* cc, | 687 FX_BOOL app::launchURL(IJS_Context* cc, |
688 const std::vector<CJS_Value>& params, | 688 const std::vector<CJS_Value>& params, |
689 CJS_Value& vRet, | 689 CJS_Value& vRet, |
690 CFX_WideString& sError) { | 690 CFX_WideString& sError) { |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
785 | 785 |
786 CFX_WideString swLabel; | 786 CFX_WideString swLabel; |
787 if (newParams[4].GetType() != CJS_Value::VT_unknown) | 787 if (newParams[4].GetType() != CJS_Value::VT_unknown) |
788 swLabel = newParams[4].ToCFXWideString(pRuntime); | 788 swLabel = newParams[4].ToCFXWideString(pRuntime); |
789 | 789 |
790 const int MAX_INPUT_BYTES = 2048; | 790 const int MAX_INPUT_BYTES = 2048; |
791 std::unique_ptr<char[]> pBuff(new char[MAX_INPUT_BYTES + 2]); | 791 std::unique_ptr<char[]> pBuff(new char[MAX_INPUT_BYTES + 2]); |
792 memset(pBuff.get(), 0, MAX_INPUT_BYTES + 2); | 792 memset(pBuff.get(), 0, MAX_INPUT_BYTES + 2); |
793 | 793 |
794 CJS_Context* pContext = static_cast<CJS_Context*>(cc); | 794 CJS_Context* pContext = static_cast<CJS_Context*>(cc); |
795 int nLengthBytes = pContext->GetReaderApp()->JS_appResponse( | 795 int nLengthBytes = pContext->GetReaderEnv()->JS_appResponse( |
796 swQuestion.c_str(), swTitle.c_str(), swDefault.c_str(), swLabel.c_str(), | 796 swQuestion.c_str(), swTitle.c_str(), swDefault.c_str(), swLabel.c_str(), |
797 bPassword, pBuff.get(), MAX_INPUT_BYTES); | 797 bPassword, pBuff.get(), MAX_INPUT_BYTES); |
798 | 798 |
799 if (nLengthBytes < 0 || nLengthBytes > MAX_INPUT_BYTES) { | 799 if (nLengthBytes < 0 || nLengthBytes > MAX_INPUT_BYTES) { |
800 sError = JSGetStringFromID(IDS_STRING_JSPARAM_TOOLONG); | 800 sError = JSGetStringFromID(IDS_STRING_JSPARAM_TOOLONG); |
801 return FALSE; | 801 return FALSE; |
802 } | 802 } |
803 | 803 |
804 vRet = CJS_Value(pRuntime, CFX_WideString::FromUTF16LE( | 804 vRet = CJS_Value(pRuntime, CFX_WideString::FromUTF16LE( |
805 reinterpret_cast<uint16_t*>(pBuff.get()), | 805 reinterpret_cast<uint16_t*>(pBuff.get()), |
806 nLengthBytes / sizeof(uint16_t)) | 806 nLengthBytes / sizeof(uint16_t)) |
807 .c_str()); | 807 .c_str()); |
808 | 808 |
809 return TRUE; | 809 return TRUE; |
810 } | 810 } |
811 | 811 |
812 FX_BOOL app::media(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) { | 812 FX_BOOL app::media(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) { |
813 return FALSE; | 813 return FALSE; |
814 } | 814 } |
815 | 815 |
816 FX_BOOL app::execDialog(IJS_Context* cc, | 816 FX_BOOL app::execDialog(IJS_Context* cc, |
817 const std::vector<CJS_Value>& params, | 817 const std::vector<CJS_Value>& params, |
818 CJS_Value& vRet, | 818 CJS_Value& vRet, |
819 CFX_WideString& sError) { | 819 CFX_WideString& sError) { |
820 return TRUE; | 820 return TRUE; |
821 } | 821 } |
OLD | NEW |