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 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 CFX_WideString swTitle = L""; | 331 CFX_WideString swTitle = L""; |
332 int iIcon = 0; | 332 int iIcon = 0; |
333 int iType = 0; | 333 int iType = 0; |
334 | 334 |
335 v8::Isolate* isolate = GetIsolate(cc); | 335 v8::Isolate* isolate = GetIsolate(cc); |
336 | 336 |
337 if (iSize == 1) | 337 if (iSize == 1) |
338 { | 338 { |
339 if (params[0].GetType() == VT_object) | 339 if (params[0].GetType() == VT_object) |
340 { | 340 { |
341 » » » JSObject pObj = params[0]; | 341 » » » JSObject pObj = params[0].ToV8Object(); |
342 { | 342 { |
343 v8::Handle<v8::Value> pValue = JS_GetObjectEleme
nt(isolate, pObj, L"cMsg"); | 343 v8::Handle<v8::Value> pValue = JS_GetObjectEleme
nt(isolate, pObj, L"cMsg"); |
344 » » » » swMsg = CJS_Value(isolate,pValue,VT_unknown).ope
rator CFX_WideString(); | 344 » » » » swMsg = CJS_Value(isolate, pValue, VT_unknown).T
oCFXWideString(); |
345 | 345 |
346 » » » » pValue = JS_GetObjectElement(isolate,pObj,L"cTit
le"); | 346 » » » » pValue = JS_GetObjectElement(isolate, pObj, L"cT
itle"); |
347 » » » » swTitle = CJS_Value(isolate, pValue,VT_unknown).
operator CFX_WideString(); | 347 » » » » swTitle = CJS_Value(isolate, pValue, VT_unknown)
.ToCFXWideString(); |
348 | 348 |
349 » » » » pValue = JS_GetObjectElement(isolate,pObj,L"nIco
n"); | 349 » » » » pValue = JS_GetObjectElement(isolate, pObj, L"nI
con"); |
350 » » » » iIcon = (int)CJS_Value(isolate,pValue,VT_unknown
); | 350 » » » » iIcon = CJS_Value(isolate, pValue, VT_unknown).T
oInt(); |
351 | 351 |
352 » » » » pValue = JS_GetObjectElement(isolate,pObj,L"nTyp
e"); | 352 » » » » pValue = JS_GetObjectElement(isolate, pObj, L"nT
ype"); |
353 » » » » iType = (int)CJS_Value(isolate,pValue,VT_unknown
); | 353 » » » » iType = CJS_Value(isolate, pValue, VT_unknown).T
oInt(); |
354 } | 354 } |
355 | 355 |
356 if (swMsg == L"") | 356 if (swMsg == L"") |
357 { | 357 { |
358 CJS_Array carray(isolate); | 358 CJS_Array carray(isolate); |
359 if (params[0].ConvertToArray(carray)) | 359 if (params[0].ConvertToArray(carray)) |
360 { | 360 { |
361 int iLenth = carray.GetLength(); | 361 int iLenth = carray.GetLength(); |
362 CJS_Value* pValue = new CJS_Value(isolat
e); | 362 CJS_Value* pValue = new CJS_Value(isolat
e); |
363 // if (iLenth == 1) | 363 // if (iLenth == 1) |
364 // pValue = new CJS_Value(isolate); | 364 // pValue = new CJS_Value(isolate); |
365 // else if (iLenth > 1) | 365 // else if (iLenth > 1) |
366 // pValue = new CJS_Value[iLenth]; | 366 // pValue = new CJS_Value[iLenth]; |
367 | 367 |
368 for(int i = 0; i < iLenth; i++) | 368 for(int i = 0; i < iLenth; i++) |
369 { | 369 { |
370 carray.GetElement(i, *pValue); | 370 carray.GetElement(i, *pValue); |
371 » » » » » » swMsg += (*pValue).operator CFX_
WideString(); | 371 » » » » » » swMsg += (*pValue).ToCFXWideStri
ng(); |
372 if (i < iLenth - 1) | 372 if (i < iLenth - 1) |
373 swMsg += L", "; | 373 swMsg += L", "; |
374 } | 374 } |
375 | 375 |
376 if(pValue) delete pValue; | 376 if(pValue) delete pValue; |
377 // if ((iLenth > 1) && pValue) | |
378 // { | |
379 // delete[]pValue; | |
380 // pValue = NULL; | |
381 // } | |
382 // else if ((iLenth == 1) && pValue) | |
383 // { | |
384 // delete pValue; | |
385 // pValue = NULL; | |
386 // } | |
387 } | 377 } |
388 } | 378 } |
389 | 379 |
390 if (swTitle == L"") | 380 if (swTitle == L"") |
391 swTitle = JSGetStringFromID((CJS_Context*)cc, ID
S_STRING_JSALERT); | 381 swTitle = JSGetStringFromID((CJS_Context*)cc, ID
S_STRING_JSALERT); |
392 } | 382 } |
393 else if (params[0].GetType() == VT_boolean) | 383 else if (params[0].GetType() == VT_boolean) |
394 { | 384 { |
395 » » » FX_BOOL bGet = (FX_BOOL)params[0]; | 385 » » » FX_BOOL bGet = params[0].ToBool(); |
396 if (bGet) | 386 if (bGet) |
397 swMsg = L"true"; | 387 swMsg = L"true"; |
398 else | 388 else |
399 swMsg = L"false"; | 389 swMsg = L"false"; |
400 | 390 |
401 swTitle = JSGetStringFromID((CJS_Context*)cc, IDS_STRING
_JSALERT); | 391 swTitle = JSGetStringFromID((CJS_Context*)cc, IDS_STRING
_JSALERT); |
402 } | 392 } |
403 else | 393 else |
404 { | 394 { |
405 » » » swMsg = params[0]; | 395 » » » swMsg = params[0].ToCFXWideString(); |
406 swTitle = JSGetStringFromID((CJS_Context*)cc, IDS_STRING
_JSALERT); | 396 swTitle = JSGetStringFromID((CJS_Context*)cc, IDS_STRING
_JSALERT); |
407 } | 397 } |
408 } | 398 } |
409 else | 399 else |
410 { | 400 { |
411 if (params[0].GetType() == VT_boolean) | 401 if (params[0].GetType() == VT_boolean) |
412 { | 402 { |
413 » » » FX_BOOL bGet = (FX_BOOL)params[0]; | 403 » » » FX_BOOL bGet = params[0].ToBool(); |
414 if (bGet) | 404 if (bGet) |
415 swMsg = L"true"; | 405 swMsg = L"true"; |
416 else | 406 else |
417 swMsg = L"false"; | 407 swMsg = L"false"; |
418 } | 408 } |
419 else | 409 else |
420 { | 410 { |
421 » » » swMsg = params[0]; | 411 » » » swMsg = params[0].ToCFXWideString(); |
422 } | 412 } |
423 swTitle = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSALERT
); | 413 swTitle = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSALERT
); |
424 | 414 |
425 for(int i = 1;i<iSize;i++) | 415 for(int i = 1;i<iSize;i++) |
426 { | 416 { |
427 if (i == 1) | 417 if (i == 1) |
428 » » » » iIcon = int(params[i]); | 418 » » » » iIcon = params[i].ToInt(); |
429 if (i == 2) | 419 if (i == 2) |
430 » » » » iType = int(params[i]); | 420 » » » » iType = params[i].ToInt(); |
431 if (i == 3) | 421 if (i == 3) |
432 » » » » swTitle = params[i]; | 422 » » » » swTitle = params[i].ToCFXWideString(); |
433 } | 423 } |
434 } | 424 } |
435 | 425 |
436 | 426 |
437 CJS_Context* pContext = (CJS_Context*)cc; | 427 CJS_Context* pContext = (CJS_Context*)cc; |
438 ASSERT(pContext != NULL); | 428 ASSERT(pContext != NULL); |
439 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 429 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
440 ASSERT(pRuntime != NULL); | 430 ASSERT(pRuntime != NULL); |
441 pRuntime->BeginBlock(); | 431 pRuntime->BeginBlock(); |
442 vRet = MsgBox(pRuntime->GetReaderApp(), JSGetPageView(cc),swMsg,swTitle,
iType,iIcon); | 432 vRet = MsgBox(pRuntime->GetReaderApp(), JSGetPageView(cc),swMsg,swTitle,
iType,iIcon); |
443 pRuntime->EndBlock(); | 433 pRuntime->EndBlock(); |
444 | 434 |
445 return TRUE; | 435 return TRUE; |
446 } | 436 } |
447 | 437 |
448 | 438 |
449 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) |
450 { | 440 { |
451 if (params.size() == 1) | 441 if (params.size() == 1) |
452 { | 442 { |
453 CJS_Context* pContext = (CJS_Context*)cc; | 443 CJS_Context* pContext = (CJS_Context*)cc; |
454 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 444 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
455 CPDFDoc_Environment * pEnv = pRuntime->GetReaderApp(); | 445 CPDFDoc_Environment * pEnv = pRuntime->GetReaderApp(); |
456 » » pEnv->JS_appBeep((int)params[0]); | 446 » » pEnv->JS_appBeep(params[0].ToInt()); |
457 | |
458 return TRUE; | 447 return TRUE; |
459 } | 448 } |
460 » else | 449 |
461 » { | 450 » sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSPARAMERROR); |
462 » » sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSPARAME
RROR); | 451 » return FALSE; |
463 » » return FALSE; | |
464 » } | |
465 } | 452 } |
466 | 453 |
467 FX_BOOL app::findComponent(IFXJS_Context* cc, const CJS_Parameters& params, CJS_
Value& vRet, CFX_WideString& sError) | 454 FX_BOOL app::findComponent(IFXJS_Context* cc, const CJS_Parameters& params, CJS_
Value& vRet, CFX_WideString& sError) |
468 { | 455 { |
469 return TRUE; | 456 return TRUE; |
470 } | 457 } |
471 | 458 |
472 FX_BOOL app::popUpMenuEx(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Va
lue& vRet, CFX_WideString& sError) | 459 FX_BOOL app::popUpMenuEx(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Va
lue& vRet, CFX_WideString& sError) |
473 { | 460 { |
474 return FALSE; | 461 return FALSE; |
(...skipping 10 matching lines...) Expand all Loading... |
485 { | 472 { |
486 sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSPARAME
RROR); | 473 sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSPARAME
RROR); |
487 return FALSE; | 474 return FALSE; |
488 } | 475 } |
489 | 476 |
490 CJS_Context* pContext = (CJS_Context*)cc; | 477 CJS_Context* pContext = (CJS_Context*)cc; |
491 ASSERT(pContext != NULL); | 478 ASSERT(pContext != NULL); |
492 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 479 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
493 ASSERT(pRuntime != NULL); | 480 ASSERT(pRuntime != NULL); |
494 | 481 |
495 » CFX_WideString script = params.size() > 0 ? (FX_LPCWSTR)(params[0].oper
ator CFX_WideString()) : L""; | 482 » CFX_WideString script = params.size() > 0 ? (FX_LPCWSTR)(params[0].ToCF
XWideString()) : L""; |
496 if (script.IsEmpty()) | 483 if (script.IsEmpty()) |
497 { | 484 { |
498 sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSAFNUMB
ER_KEYSTROKE); | 485 sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSAFNUMB
ER_KEYSTROKE); |
499 return TRUE; | 486 return TRUE; |
500 } | 487 } |
501 | 488 |
502 » FX_DWORD dwInterval = params.size() > 1 ? (int)params[1] : 1000; | 489 » FX_DWORD dwInterval = params.size() > 1 ? params[1].ToInt() : 1000; |
503 | 490 |
504 CPDFDoc_Environment* pApp = pRuntime->GetReaderApp(); | 491 CPDFDoc_Environment* pApp = pRuntime->GetReaderApp(); |
505 ASSERT(pApp); | 492 ASSERT(pApp); |
506 CJS_Timer* pTimer = new CJS_Timer(this, pApp); | 493 CJS_Timer* pTimer = new CJS_Timer(this, pApp); |
507 m_aTimer.Add(pTimer); | 494 m_aTimer.Add(pTimer); |
508 | 495 |
509 pTimer->SetType(0); | 496 pTimer->SetType(0); |
510 pTimer->SetRuntime(pRuntime); | 497 pTimer->SetRuntime(pRuntime); |
511 pTimer->SetJScript(script); | 498 pTimer->SetJScript(script); |
512 pTimer->SetTimeOut(0); | 499 pTimer->SetTimeOut(0); |
(...skipping 21 matching lines...) Expand all Loading... |
534 { | 521 { |
535 sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSPARAME
RROR); | 522 sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSPARAME
RROR); |
536 return FALSE; | 523 return FALSE; |
537 } | 524 } |
538 | 525 |
539 CJS_Context* pContext = (CJS_Context*)cc; | 526 CJS_Context* pContext = (CJS_Context*)cc; |
540 ASSERT(pContext != NULL); | 527 ASSERT(pContext != NULL); |
541 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 528 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
542 ASSERT(pRuntime != NULL); | 529 ASSERT(pRuntime != NULL); |
543 | 530 |
544 » CFX_WideString script = params.size() > 0 ? (FX_LPCWSTR)(params[0].oper
ator CFX_WideString()) : L""; | 531 » CFX_WideString script = params.size() > 0 ? (FX_LPCWSTR)(params[0].ToCF
XWideString()) : L""; |
545 if (script.IsEmpty()) | 532 if (script.IsEmpty()) |
546 { | 533 { |
547 sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSAFNUMB
ER_KEYSTROKE); | 534 sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSAFNUMB
ER_KEYSTROKE); |
548 return TRUE; | 535 return TRUE; |
549 } | 536 } |
550 | 537 |
551 » FX_DWORD dwTimeOut = params.size() > 1 ? (int)params[1] : 1000; | 538 » FX_DWORD dwTimeOut = params.size() > 1 ? params[1].ToInt() : 1000; |
552 | 539 |
553 CPDFDoc_Environment* pApp = pRuntime->GetReaderApp(); | 540 CPDFDoc_Environment* pApp = pRuntime->GetReaderApp(); |
554 ASSERT(pApp); | 541 ASSERT(pApp); |
| 542 |
555 CJS_Timer* pTimer = new CJS_Timer(this, pApp); | 543 CJS_Timer* pTimer = new CJS_Timer(this, pApp); |
556 m_aTimer.Add(pTimer); | 544 m_aTimer.Add(pTimer); |
557 | 545 |
558 pTimer->SetType(1); | 546 pTimer->SetType(1); |
559 pTimer->SetRuntime(pRuntime); | 547 pTimer->SetRuntime(pRuntime); |
560 pTimer->SetJScript(script); | 548 pTimer->SetJScript(script); |
561 pTimer->SetTimeOut(dwTimeOut); | 549 pTimer->SetTimeOut(dwTimeOut); |
562 // pTimer->SetStartTime(GetTickCount()); | |
563 // pTimer->SetJSTimer(1000); | |
564 pTimer->SetJSTimer(dwTimeOut); | 550 pTimer->SetJSTimer(dwTimeOut); |
565 | 551 |
566 JSFXObject pRetObj = JS_NewFxDynamicObj(*pRuntime, pContext, JS_GetObjDe
fnID(*pRuntime, L"TimerObj")); | 552 JSFXObject pRetObj = JS_NewFxDynamicObj(*pRuntime, pContext, JS_GetObjDe
fnID(*pRuntime, L"TimerObj")); |
567 // ASSERT(pRetObj != NULL); | |
568 | 553 |
569 CJS_TimerObj* pJS_TimerObj = (CJS_TimerObj*)JS_GetPrivate(pRuntime->GetI
solate(),pRetObj); | 554 CJS_TimerObj* pJS_TimerObj = (CJS_TimerObj*)JS_GetPrivate(pRuntime->GetI
solate(),pRetObj); |
570 ASSERT(pJS_TimerObj != NULL); | 555 ASSERT(pJS_TimerObj != NULL); |
571 | 556 |
572 TimerObj* pTimerObj = (TimerObj*)pJS_TimerObj->GetEmbedObject(); | 557 TimerObj* pTimerObj = (TimerObj*)pJS_TimerObj->GetEmbedObject(); |
573 ASSERT(pTimerObj != NULL); | 558 ASSERT(pTimerObj != NULL); |
574 | 559 |
575 pTimerObj->SetTimer(pTimer); | 560 pTimerObj->SetTimer(pTimer); |
576 | 561 |
577 vRet = pRetObj; | 562 vRet = pRetObj; |
578 | 563 |
579 return TRUE; | 564 return TRUE; |
580 } | 565 } |
581 | 566 |
582 FX_BOOL app::clearTimeOut(IFXJS_Context* cc, const CJS_Parameters& params, CJS_V
alue& vRet, CFX_WideString& sError) | 567 FX_BOOL app::clearTimeOut(IFXJS_Context* cc, const CJS_Parameters& params, CJS_V
alue& vRet, CFX_WideString& sError) |
583 { | 568 { |
584 CJS_Context* pContext = (CJS_Context*)cc; | 569 CJS_Context* pContext = (CJS_Context*)cc; |
585 ASSERT(pContext != NULL); | 570 ASSERT(pContext != NULL); |
586 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 571 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
587 ASSERT(pRuntime != NULL); | 572 ASSERT(pRuntime != NULL); |
588 | 573 |
589 if (params.size() != 1) | 574 if (params.size() != 1) |
590 { | 575 { |
591 sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSPARAME
RROR); | 576 sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSPARAME
RROR); |
592 return FALSE; | 577 return FALSE; |
593 } | 578 } |
594 | 579 |
595 if (params[0].GetType() == VT_fxobject) | 580 if (params[0].GetType() == VT_fxobject) |
596 { | 581 { |
597 » » JSFXObject pObj = (JSFXObject)params[0]; | 582 » » JSFXObject pObj = params[0].ToV8Object(); |
598 { | 583 { |
599 if (JS_GetObjDefnID(pObj) == JS_GetObjDefnID(*pRuntime,
L"TimerObj")) | 584 if (JS_GetObjDefnID(pObj) == JS_GetObjDefnID(*pRuntime,
L"TimerObj")) |
600 { | 585 { |
601 » » » » if (CJS_Object* pJSObj = (CJS_Object*)params[0]) | 586 » » » » if (CJS_Object* pJSObj = params[0].ToCJSObject()
) |
602 { | 587 { |
603 if (TimerObj* pTimerObj = (TimerObj*)pJS
Obj->GetEmbedObject()) | 588 if (TimerObj* pTimerObj = (TimerObj*)pJS
Obj->GetEmbedObject()) |
604 { | 589 { |
605 if (CJS_Timer* pTimer = pTimerOb
j->GetTimer()) | 590 if (CJS_Timer* pTimer = pTimerOb
j->GetTimer()) |
606 { | 591 { |
607 pTimer->KillJSTimer(); | 592 pTimer->KillJSTimer(); |
608 | 593 |
609 for (int i=0,sz=m_aTimer
.GetSize(); i<sz; i++) | 594 for (int i=0,sz=m_aTimer
.GetSize(); i<sz; i++) |
610 { | 595 { |
611 if (m_aTimer[i]
== pTimer) | 596 if (m_aTimer[i]
== pTimer) |
(...skipping 23 matching lines...) Expand all Loading... |
635 ASSERT(pRuntime != NULL); | 620 ASSERT(pRuntime != NULL); |
636 | 621 |
637 if (params.size() != 1) | 622 if (params.size() != 1) |
638 { | 623 { |
639 sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSPARAME
RROR); | 624 sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSPARAME
RROR); |
640 return FALSE; | 625 return FALSE; |
641 } | 626 } |
642 | 627 |
643 if (params[0].GetType() == VT_fxobject) | 628 if (params[0].GetType() == VT_fxobject) |
644 { | 629 { |
645 » » JSFXObject pObj = (JSFXObject)params[0]; | 630 » » JSFXObject pObj = params[0].ToV8Object(); |
646 { | 631 { |
647 if (JS_GetObjDefnID(pObj) == JS_GetObjDefnID(*pRuntime,
L"TimerObj")) | 632 if (JS_GetObjDefnID(pObj) == JS_GetObjDefnID(*pRuntime,
L"TimerObj")) |
648 { | 633 { |
649 » » » » if (CJS_Object* pJSObj = (CJS_Object*)params[0]) | 634 » » » » if (CJS_Object* pJSObj = params[0].ToCJSObject()
) |
650 { | 635 { |
651 if (TimerObj* pTimerObj = (TimerObj*)pJS
Obj->GetEmbedObject()) | 636 if (TimerObj* pTimerObj = (TimerObj*)pJS
Obj->GetEmbedObject()) |
652 { | 637 { |
653 if (CJS_Timer* pTimer = pTimerOb
j->GetTimer()) | 638 if (CJS_Timer* pTimer = pTimerOb
j->GetTimer()) |
654 { | 639 { |
655 pTimer->KillJSTimer(); | 640 pTimer->KillJSTimer(); |
656 | 641 |
657 for (int i=0,sz=m_aTimer
.GetSize(); i<sz; i++) | 642 for (int i=0,sz=m_aTimer
.GetSize(); i<sz; i++) |
658 { | 643 { |
659 if (m_aTimer[i]
== pTimer) | 644 if (m_aTimer[i]
== pTimer) |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
723 | 708 |
724 FX_BOOL app::goForward(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Valu
e& vRet, CFX_WideString& sError) | 709 FX_BOOL app::goForward(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Valu
e& vRet, CFX_WideString& sError) |
725 { | 710 { |
726 // Not supported. | 711 // Not supported. |
727 return TRUE; | 712 return TRUE; |
728 } | 713 } |
729 | 714 |
730 FX_BOOL app::mailMsg(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value&
vRet, CFX_WideString& sError) | 715 FX_BOOL app::mailMsg(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value&
vRet, CFX_WideString& sError) |
731 { | 716 { |
732 CJS_Context* pContext = (CJS_Context*)cc; | 717 CJS_Context* pContext = (CJS_Context*)cc; |
733 ASSERT(pContext != NULL); | |
734 | |
735 v8::Isolate* isolate = GetIsolate(cc); | 718 v8::Isolate* isolate = GetIsolate(cc); |
736 | 719 |
737 FX_BOOL bUI = TRUE; | 720 FX_BOOL bUI = TRUE; |
738 CFX_WideString cTo = L""; | 721 CFX_WideString cTo = L""; |
739 CFX_WideString cCc = L""; | 722 CFX_WideString cCc = L""; |
740 CFX_WideString cBcc = L""; | 723 CFX_WideString cBcc = L""; |
741 CFX_WideString cSubject = L""; | 724 CFX_WideString cSubject = L""; |
742 CFX_WideString cMsg = L""; | 725 CFX_WideString cMsg = L""; |
743 » if(params.size() < 2) | 726 |
| 727 » if (params.size() < 1) |
744 return FALSE; | 728 return FALSE; |
745 | 729 |
746 bUI = params.size()>=1?(int)params[0]:TRUE; | |
747 cTo = params.size()>=2?(const wchar_t*)(FX_LPCWSTR)params[1].operator CF
X_WideString():L""; | |
748 cCc = params.size()>=3?(const wchar_t*)(FX_LPCWSTR)params[2].operator CF
X_WideString():L""; | |
749 cBcc = params.size()>=4?(const wchar_t*)(FX_LPCWSTR)params[3].operator C
FX_WideString():L""; | |
750 cSubject = params.size()>=5?(const wchar_t*)(FX_LPCWSTR)params[4].operat
or CFX_WideString():L""; | |
751 cMsg = params.size()>=6?(const wchar_t*)(FX_LPCWSTR)params[5].operator C
FX_WideString():L""; | |
752 | |
753 | |
754 if (params[0].GetType() == VT_object) | 730 if (params[0].GetType() == VT_object) |
755 { | 731 { |
756 » » JSObject pObj = (JSObject)params[0]; | 732 » » JSObject pObj = params[0].ToV8Object(); |
757 | 733 |
758 » » v8::Handle<v8::Value> pValue = JS_GetObjectElement(isolate,pObj,
L"bUI"); | 734 » » v8::Handle<v8::Value> pValue = JS_GetObjectElement(isolate, pObj
, L"bUI"); |
759 » » » bUI = (int)CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValu
e)); | 735 » » bUI = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToBool(
); |
760 | 736 |
761 pValue = JS_GetObjectElement(isolate, pObj, L"cTo"); | 737 pValue = JS_GetObjectElement(isolate, pObj, L"cTo"); |
762 » » » cTo = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).o
perator CFX_WideString(); | 738 » » cTo = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToCFXWi
deString(); |
763 | 739 |
764 » » pValue = JS_GetObjectElement(isolate,pObj, L"cCc"); | 740 » » pValue = JS_GetObjectElement(isolate, pObj, L"cCc"); |
765 » » » cCc = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).o
perator CFX_WideString(); | 741 » » cCc = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToCFXWi
deString(); |
766 | 742 |
767 » » pValue = JS_GetObjectElement(isolate,pObj, L"cBcc"); | 743 » » pValue = JS_GetObjectElement(isolate, pObj, L"cBcc"); |
768 » » » cBcc = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).
operator CFX_WideString(); | 744 » » cBcc = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToCFXW
ideString(); |
769 | 745 |
770 » » pValue = JS_GetObjectElement(isolate,pObj, L"cSubject"); | 746 » » pValue = JS_GetObjectElement(isolate, pObj, L"cSubject"); |
771 » » » cSubject = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValu
e)).operator CFX_WideString(); | 747 » » cSubject = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).To
CFXWideString(); |
772 | 748 |
773 » » pValue = JS_GetObjectElement(isolate,pObj, L"cMsg"); | 749 » » pValue = JS_GetObjectElement(isolate, pObj, L"cMsg"); |
774 » » » cMsg = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).
operator CFX_WideString(); | 750 » » cMsg = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToCFXW
ideString(); |
| 751 » } else { |
| 752 » » if (params.size() < 2) |
| 753 » » » return FALSE; |
| 754 |
| 755 » » bUI = params[0].ToBool(); |
| 756 » » cTo = params[1].ToCFXWideString(); |
| 757 |
| 758 » » if (params.size() >= 3) |
| 759 » » » cCc = params[2].ToCFXWideString(); |
| 760 » » if (params.size() >= 4) |
| 761 » » » cBcc = params[3].ToCFXWideString(); |
| 762 » » if (params.size() >= 5) |
| 763 » » » cSubject = params[4].ToCFXWideString(); |
| 764 » » if (params.size() >= 6) |
| 765 » » » cMsg = params[5].ToCFXWideString(); |
775 } | 766 } |
776 | 767 |
777 | |
778 | |
779 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 768 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
780 ASSERT(pRuntime != NULL); | 769 ASSERT(pRuntime != NULL); |
781 | 770 |
782 CPDFDoc_Environment* pApp = pContext->GetReaderApp(); | 771 CPDFDoc_Environment* pApp = pContext->GetReaderApp(); |
783 ASSERT(pApp != NULL); | 772 ASSERT(pApp != NULL); |
784 | 773 |
785 pRuntime->BeginBlock(); | 774 pRuntime->BeginBlock(); |
786 pApp->JS_docmailForm(NULL, 0, bUI, cTo.c_str(), cSubject.c_str(), cCc.c_
str(), cBcc.c_str(), cMsg.c_str()); | 775 pApp->JS_docmailForm(NULL, 0, bUI, cTo.c_str(), cSubject.c_str(), cCc.c_
str(), cBcc.c_str(), cMsg.c_str()); |
787 ////////////////////////////////////////////////////////////////////////
/////////////////////// | |
788 pRuntime->EndBlock(); | 776 pRuntime->EndBlock(); |
789 | 777 |
790 //return bRet; | |
791 return FALSE; | 778 return FALSE; |
792 } | 779 } |
793 | 780 |
794 FX_BOOL app::launchURL(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Valu
e& vRet, CFX_WideString& sError) | 781 FX_BOOL app::launchURL(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Valu
e& vRet, CFX_WideString& sError) |
795 { | 782 { |
796 // Unsafe, not supported. | 783 // Unsafe, not supported. |
797 return TRUE; | 784 return TRUE; |
798 } | 785 } |
799 | 786 |
800 FX_BOOL app::runtimeHighlight(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideStri
ng& sError) | 787 FX_BOOL app::runtimeHighlight(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideStri
ng& sError) |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
870 CFX_WideString swLabel = L""; | 857 CFX_WideString swLabel = L""; |
871 CFX_WideString swTitle = L"PDF"; | 858 CFX_WideString swTitle = L"PDF"; |
872 CFX_WideString swDefault = L""; | 859 CFX_WideString swDefault = L""; |
873 bool bPassWord = false; | 860 bool bPassWord = false; |
874 | 861 |
875 v8::Isolate* isolate = GetIsolate(cc); | 862 v8::Isolate* isolate = GetIsolate(cc); |
876 | 863 |
877 int iLength = params.size(); | 864 int iLength = params.size(); |
878 if (iLength > 0 && params[0].GetType() == VT_object) | 865 if (iLength > 0 && params[0].GetType() == VT_object) |
879 { | 866 { |
880 » » JSObject pObj = (JSObject )params[0]; | 867 » » JSObject pObj = params[0].ToV8Object(); |
881 v8::Handle<v8::Value> pValue = JS_GetObjectElement(isolate,pObj,
L"cQuestion"); | 868 v8::Handle<v8::Value> pValue = JS_GetObjectElement(isolate,pObj,
L"cQuestion"); |
882 » » swQuestion = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).op
erator CFX_WideString(); | 869 » » swQuestion = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).To
CFXWideString(); |
883 | 870 |
884 pValue = JS_GetObjectElement(isolate,pObj,L"cTitle"); | 871 pValue = JS_GetObjectElement(isolate,pObj,L"cTitle"); |
885 » » swTitle = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).opera
tor CFX_WideString(); | 872 » » swTitle = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).ToCFX
WideString(); |
886 | 873 |
887 pValue = JS_GetObjectElement(isolate,pObj,L"cDefault"); | 874 pValue = JS_GetObjectElement(isolate,pObj,L"cDefault"); |
888 » » swDefault = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).ope
rator CFX_WideString(); | 875 » » swDefault = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).ToC
FXWideString(); |
889 | 876 |
890 pValue = JS_GetObjectElement(isolate,pObj,L"cLabel"); | 877 pValue = JS_GetObjectElement(isolate,pObj,L"cLabel"); |
891 » » swLabel = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).opera
tor CFX_WideString(); | 878 » » swLabel = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).ToCFX
WideString(); |
892 | 879 |
893 pValue = JS_GetObjectElement(isolate,pObj,L"bPassword"); | 880 pValue = JS_GetObjectElement(isolate,pObj,L"bPassword"); |
894 » » bPassWord = (bool)CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue
)); | 881 » » bPassWord = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).ToB
ool(); |
895 } | 882 } |
896 else | 883 else |
897 { | 884 { |
898 switch(iLength) | 885 switch(iLength) |
899 { | 886 { |
900 case 5: | 887 case 5: |
901 » » » swLabel = params[4]; | 888 » » » swLabel = params[4].ToCFXWideString(); |
902 // FALLTHROUGH | 889 // FALLTHROUGH |
903 case 4: | 890 case 4: |
904 » » » bPassWord = params[3]; | 891 » » » bPassWord = params[3].ToBool(); |
905 // FALLTHROUGH | 892 // FALLTHROUGH |
906 case 3: | 893 case 3: |
907 » » » swDefault = params[2]; | 894 » » » swDefault = params[2].ToCFXWideString(); |
908 // FALLTHROUGH | 895 // FALLTHROUGH |
909 case 2: | 896 case 2: |
910 » » » swTitle = params[1]; | 897 » » » swTitle = params[1].ToCFXWideString(); |
911 // FALLTHROUGH | 898 // FALLTHROUGH |
912 case 1: | 899 case 1: |
913 » » » swQuestion = params[0]; | 900 » » » swQuestion = params[0].ToCFXWideString(); |
914 // FALLTHROUGH | 901 // FALLTHROUGH |
915 default: | 902 default: |
916 break; | 903 break; |
917 } | 904 } |
918 } | 905 } |
919 | 906 |
920 CJS_Context* pContext = (CJS_Context *)cc; | 907 CJS_Context* pContext = (CJS_Context *)cc; |
921 ASSERT(pContext != NULL); | 908 ASSERT(pContext != NULL); |
922 | 909 |
923 CPDFDoc_Environment* pApp = pContext->GetReaderApp(); | 910 CPDFDoc_Environment* pApp = pContext->GetReaderApp(); |
(...skipping 22 matching lines...) Expand all Loading... |
946 | 933 |
947 FX_BOOL app::media(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) | 934 FX_BOOL app::media(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) |
948 { | 935 { |
949 return FALSE; | 936 return FALSE; |
950 } | 937 } |
951 | 938 |
952 FX_BOOL app::execDialog(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Val
ue& vRet, CFX_WideString& sError) | 939 FX_BOOL app::execDialog(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Val
ue& vRet, CFX_WideString& sError) |
953 { | 940 { |
954 return TRUE; | 941 return TRUE; |
955 } | 942 } |
OLD | NEW |