Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(72)

Side by Side Diff: fpdfsdk/src/javascript/app.cpp

Issue 1096813008: Kill overloaded cast operators in CJS_Value. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: fix nit. Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « fpdfsdk/src/javascript/PublicMethods.cpp ('k') | fpdfsdk/src/javascript/color.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 CFX_WideString swTitle = L""; 318 CFX_WideString swTitle = L"";
319 int iIcon = 0; 319 int iIcon = 0;
320 int iType = 0; 320 int iType = 0;
321 321
322 v8::Isolate* isolate = GetIsolate(cc); 322 v8::Isolate* isolate = GetIsolate(cc);
323 323
324 if (iSize == 1) 324 if (iSize == 1)
325 { 325 {
326 if (params[0].GetType() == VT_object) 326 if (params[0].GetType() == VT_object)
327 { 327 {
328 » » » JSObject pObj = params[0]; 328 » » » JSObject pObj = params[0].ToV8Object();
329 { 329 {
330 v8::Handle<v8::Value> pValue = JS_GetObjectEleme nt(isolate, pObj, L"cMsg"); 330 v8::Handle<v8::Value> pValue = JS_GetObjectEleme nt(isolate, pObj, L"cMsg");
331 » » » » swMsg = CJS_Value(isolate,pValue,VT_unknown).ope rator CFX_WideString(); 331 » » » » swMsg = CJS_Value(isolate, pValue, VT_unknown).T oCFXWideString();
332 332
333 » » » » pValue = JS_GetObjectElement(isolate,pObj,L"cTit le"); 333 » » » » pValue = JS_GetObjectElement(isolate, pObj, L"cT itle");
334 » » » » swTitle = CJS_Value(isolate, pValue,VT_unknown). operator CFX_WideString(); 334 » » » » swTitle = CJS_Value(isolate, pValue, VT_unknown) .ToCFXWideString();
335 335
336 » » » » pValue = JS_GetObjectElement(isolate,pObj,L"nIco n"); 336 » » » » pValue = JS_GetObjectElement(isolate, pObj, L"nI con");
337 » » » » iIcon = (int)CJS_Value(isolate,pValue,VT_unknown ); 337 » » » » iIcon = CJS_Value(isolate, pValue, VT_unknown).T oInt();
338 338
339 » » » » pValue = JS_GetObjectElement(isolate,pObj,L"nTyp e"); 339 » » » » pValue = JS_GetObjectElement(isolate, pObj, L"nT ype");
340 » » » » iType = (int)CJS_Value(isolate,pValue,VT_unknown ); 340 » » » » iType = CJS_Value(isolate, pValue, VT_unknown).T oInt();
341 } 341 }
342 342
343 if (swMsg == L"") 343 if (swMsg == L"")
344 { 344 {
345 CJS_Array carray(isolate); 345 CJS_Array carray(isolate);
346 if (params[0].ConvertToArray(carray)) 346 if (params[0].ConvertToArray(carray))
347 { 347 {
348 int iLenth = carray.GetLength(); 348 int iLenth = carray.GetLength();
349 CJS_Value* pValue = new CJS_Value(isolat e); 349 CJS_Value* pValue = new CJS_Value(isolat e);
350 // if (iLenth == 1) 350 // if (iLenth == 1)
351 // pValue = new CJS_Value(isolate); 351 // pValue = new CJS_Value(isolate);
352 // else if (iLenth > 1) 352 // else if (iLenth > 1)
353 // pValue = new CJS_Value[iLenth]; 353 // pValue = new CJS_Value[iLenth];
354 354
355 for(int i = 0; i < iLenth; i++) 355 for(int i = 0; i < iLenth; i++)
356 { 356 {
357 carray.GetElement(i, *pValue); 357 carray.GetElement(i, *pValue);
358 » » » » » » swMsg += (*pValue).operator CFX_ WideString(); 358 » » » » » » swMsg += (*pValue).ToCFXWideStri ng();
359 if (i < iLenth - 1) 359 if (i < iLenth - 1)
360 swMsg += L", "; 360 swMsg += L", ";
361 } 361 }
362 362
363 if(pValue) delete pValue; 363 if(pValue) delete pValue;
364 // if ((iLenth > 1) && pValue)
365 // {
366 // delete[]pValue;
367 // pValue = NULL;
368 // }
369 // else if ((iLenth == 1) && pValue)
370 // {
371 // delete pValue;
372 // pValue = NULL;
373 // }
374 } 364 }
375 } 365 }
376 366
377 if (swTitle == L"") 367 if (swTitle == L"")
378 swTitle = JSGetStringFromID((CJS_Context*)cc, ID S_STRING_JSALERT); 368 swTitle = JSGetStringFromID((CJS_Context*)cc, ID S_STRING_JSALERT);
379 } 369 }
380 else if (params[0].GetType() == VT_boolean) 370 else if (params[0].GetType() == VT_boolean)
381 { 371 {
382 » » » FX_BOOL bGet = (FX_BOOL)params[0]; 372 » » » FX_BOOL bGet = params[0].ToBool();
383 if (bGet) 373 if (bGet)
384 swMsg = L"true"; 374 swMsg = L"true";
385 else 375 else
386 swMsg = L"false"; 376 swMsg = L"false";
387 377
388 swTitle = JSGetStringFromID((CJS_Context*)cc, IDS_STRING _JSALERT); 378 swTitle = JSGetStringFromID((CJS_Context*)cc, IDS_STRING _JSALERT);
389 } 379 }
390 else 380 else
391 { 381 {
392 » » » swMsg = params[0]; 382 » » » swMsg = params[0].ToCFXWideString();
393 swTitle = JSGetStringFromID((CJS_Context*)cc, IDS_STRING _JSALERT); 383 swTitle = JSGetStringFromID((CJS_Context*)cc, IDS_STRING _JSALERT);
394 } 384 }
395 } 385 }
396 else 386 else
397 { 387 {
398 if (params[0].GetType() == VT_boolean) 388 if (params[0].GetType() == VT_boolean)
399 { 389 {
400 » » » FX_BOOL bGet = (FX_BOOL)params[0]; 390 » » » FX_BOOL bGet = params[0].ToBool();
401 if (bGet) 391 if (bGet)
402 swMsg = L"true"; 392 swMsg = L"true";
403 else 393 else
404 swMsg = L"false"; 394 swMsg = L"false";
405 } 395 }
406 else 396 else
407 { 397 {
408 » » » swMsg = params[0]; 398 » » » swMsg = params[0].ToCFXWideString();
409 } 399 }
410 swTitle = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSALERT ); 400 swTitle = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSALERT );
411 401
412 for(int i = 1;i<iSize;i++) 402 for(int i = 1;i<iSize;i++)
413 { 403 {
414 if (i == 1) 404 if (i == 1)
415 » » » » iIcon = int(params[i]); 405 » » » » iIcon = params[i].ToInt();
416 if (i == 2) 406 if (i == 2)
417 » » » » iType = int(params[i]); 407 » » » » iType = params[i].ToInt();
418 if (i == 3) 408 if (i == 3)
419 » » » » swTitle = params[i]; 409 » » » » swTitle = params[i].ToCFXWideString();
420 } 410 }
421 } 411 }
422 412
423 413
424 CJS_Context* pContext = (CJS_Context*)cc; 414 CJS_Context* pContext = (CJS_Context*)cc;
425 ASSERT(pContext != NULL); 415 ASSERT(pContext != NULL);
426 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); 416 CJS_Runtime* pRuntime = pContext->GetJSRuntime();
427 ASSERT(pRuntime != NULL); 417 ASSERT(pRuntime != NULL);
428 pRuntime->BeginBlock(); 418 pRuntime->BeginBlock();
429 vRet = MsgBox(pRuntime->GetReaderApp(), JSGetPageView(cc),swMsg,swTitle, iType,iIcon); 419 vRet = MsgBox(pRuntime->GetReaderApp(), JSGetPageView(cc),swMsg,swTitle, iType,iIcon);
430 pRuntime->EndBlock(); 420 pRuntime->EndBlock();
431 421
432 return TRUE; 422 return TRUE;
433 } 423 }
434 424
435 425
436 FX_BOOL app::beep(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vR et, CFX_WideString& sError) 426 FX_BOOL app::beep(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vR et, CFX_WideString& sError)
437 { 427 {
438 if (params.size() == 1) 428 if (params.size() == 1)
439 { 429 {
440 CJS_Context* pContext = (CJS_Context*)cc; 430 CJS_Context* pContext = (CJS_Context*)cc;
441 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); 431 CJS_Runtime* pRuntime = pContext->GetJSRuntime();
442 CPDFDoc_Environment * pEnv = pRuntime->GetReaderApp(); 432 CPDFDoc_Environment * pEnv = pRuntime->GetReaderApp();
443 » » pEnv->JS_appBeep((int)params[0]); 433 » » pEnv->JS_appBeep(params[0].ToInt());
444
445 return TRUE; 434 return TRUE;
446 } 435 }
447 » else 436
448 » { 437 » sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSPARAMERROR);
449 » » sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSPARAME RROR); 438 » return FALSE;
450 » » return FALSE;
451 » }
452 } 439 }
453 440
454 FX_BOOL app::findComponent(IFXJS_Context* cc, const CJS_Parameters& params, CJS_ Value& vRet, CFX_WideString& sError) 441 FX_BOOL app::findComponent(IFXJS_Context* cc, const CJS_Parameters& params, CJS_ Value& vRet, CFX_WideString& sError)
455 { 442 {
456 return TRUE; 443 return TRUE;
457 } 444 }
458 445
459 FX_BOOL app::popUpMenuEx(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Va lue& vRet, CFX_WideString& sError) 446 FX_BOOL app::popUpMenuEx(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Va lue& vRet, CFX_WideString& sError)
460 { 447 {
461 return FALSE; 448 return FALSE;
(...skipping 10 matching lines...) Expand all
472 { 459 {
473 sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSPARAME RROR); 460 sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSPARAME RROR);
474 return FALSE; 461 return FALSE;
475 } 462 }
476 463
477 CJS_Context* pContext = (CJS_Context*)cc; 464 CJS_Context* pContext = (CJS_Context*)cc;
478 ASSERT(pContext != NULL); 465 ASSERT(pContext != NULL);
479 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); 466 CJS_Runtime* pRuntime = pContext->GetJSRuntime();
480 ASSERT(pRuntime != NULL); 467 ASSERT(pRuntime != NULL);
481 468
482 » CFX_WideString script = params.size() > 0 ? (FX_LPCWSTR)(params[0].oper ator CFX_WideString()) : L""; 469 » CFX_WideString script = params.size() > 0 ? (FX_LPCWSTR)(params[0].ToCF XWideString()) : L"";
483 if (script.IsEmpty()) 470 if (script.IsEmpty())
484 { 471 {
485 sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSAFNUMB ER_KEYSTROKE); 472 sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSAFNUMB ER_KEYSTROKE);
486 return TRUE; 473 return TRUE;
487 } 474 }
488 475
489 » FX_DWORD dwInterval = params.size() > 1 ? (int)params[1] : 1000; 476 » FX_DWORD dwInterval = params.size() > 1 ? params[1].ToInt() : 1000;
490 477
491 CPDFDoc_Environment* pApp = pRuntime->GetReaderApp(); 478 CPDFDoc_Environment* pApp = pRuntime->GetReaderApp();
492 ASSERT(pApp); 479 ASSERT(pApp);
493 CJS_Timer* pTimer = new CJS_Timer(this, pApp); 480 CJS_Timer* pTimer = new CJS_Timer(this, pApp);
494 m_aTimer.Add(pTimer); 481 m_aTimer.Add(pTimer);
495 482
496 pTimer->SetType(0); 483 pTimer->SetType(0);
497 pTimer->SetRuntime(pRuntime); 484 pTimer->SetRuntime(pRuntime);
498 pTimer->SetJScript(script); 485 pTimer->SetJScript(script);
499 pTimer->SetTimeOut(0); 486 pTimer->SetTimeOut(0);
(...skipping 21 matching lines...) Expand all
521 { 508 {
522 sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSPARAME RROR); 509 sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSPARAME RROR);
523 return FALSE; 510 return FALSE;
524 } 511 }
525 512
526 CJS_Context* pContext = (CJS_Context*)cc; 513 CJS_Context* pContext = (CJS_Context*)cc;
527 ASSERT(pContext != NULL); 514 ASSERT(pContext != NULL);
528 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); 515 CJS_Runtime* pRuntime = pContext->GetJSRuntime();
529 ASSERT(pRuntime != NULL); 516 ASSERT(pRuntime != NULL);
530 517
531 » CFX_WideString script = params.size() > 0 ? (FX_LPCWSTR)(params[0].oper ator CFX_WideString()) : L""; 518 » CFX_WideString script = params.size() > 0 ? (FX_LPCWSTR)(params[0].ToCF XWideString()) : L"";
532 if (script.IsEmpty()) 519 if (script.IsEmpty())
533 { 520 {
534 sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSAFNUMB ER_KEYSTROKE); 521 sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSAFNUMB ER_KEYSTROKE);
535 return TRUE; 522 return TRUE;
536 } 523 }
537 524
538 » FX_DWORD dwTimeOut = params.size() > 1 ? (int)params[1] : 1000; 525 » FX_DWORD dwTimeOut = params.size() > 1 ? params[1].ToInt() : 1000;
539 526
540 CPDFDoc_Environment* pApp = pRuntime->GetReaderApp(); 527 CPDFDoc_Environment* pApp = pRuntime->GetReaderApp();
541 ASSERT(pApp); 528 ASSERT(pApp);
529
542 CJS_Timer* pTimer = new CJS_Timer(this, pApp); 530 CJS_Timer* pTimer = new CJS_Timer(this, pApp);
543 m_aTimer.Add(pTimer); 531 m_aTimer.Add(pTimer);
544 532
545 pTimer->SetType(1); 533 pTimer->SetType(1);
546 pTimer->SetRuntime(pRuntime); 534 pTimer->SetRuntime(pRuntime);
547 pTimer->SetJScript(script); 535 pTimer->SetJScript(script);
548 pTimer->SetTimeOut(dwTimeOut); 536 pTimer->SetTimeOut(dwTimeOut);
549 // pTimer->SetStartTime(GetTickCount());
550 // pTimer->SetJSTimer(1000);
551 pTimer->SetJSTimer(dwTimeOut); 537 pTimer->SetJSTimer(dwTimeOut);
552 538
553 JSFXObject pRetObj = JS_NewFxDynamicObj(*pRuntime, pContext, JS_GetObjDe fnID(*pRuntime, L"TimerObj")); 539 JSFXObject pRetObj = JS_NewFxDynamicObj(*pRuntime, pContext, JS_GetObjDe fnID(*pRuntime, L"TimerObj"));
554 // ASSERT(pRetObj != NULL);
555 540
556 CJS_TimerObj* pJS_TimerObj = (CJS_TimerObj*)JS_GetPrivate(pRuntime->GetI solate(),pRetObj); 541 CJS_TimerObj* pJS_TimerObj = (CJS_TimerObj*)JS_GetPrivate(pRuntime->GetI solate(),pRetObj);
557 ASSERT(pJS_TimerObj != NULL); 542 ASSERT(pJS_TimerObj != NULL);
558 543
559 TimerObj* pTimerObj = (TimerObj*)pJS_TimerObj->GetEmbedObject(); 544 TimerObj* pTimerObj = (TimerObj*)pJS_TimerObj->GetEmbedObject();
560 ASSERT(pTimerObj != NULL); 545 ASSERT(pTimerObj != NULL);
561 546
562 pTimerObj->SetTimer(pTimer); 547 pTimerObj->SetTimer(pTimer);
563 548
564 vRet = pRetObj; 549 vRet = pRetObj;
565 550
566 return TRUE; 551 return TRUE;
567 } 552 }
568 553
569 FX_BOOL app::clearTimeOut(IFXJS_Context* cc, const CJS_Parameters& params, CJS_V alue& vRet, CFX_WideString& sError) 554 FX_BOOL app::clearTimeOut(IFXJS_Context* cc, const CJS_Parameters& params, CJS_V alue& vRet, CFX_WideString& sError)
570 { 555 {
571 CJS_Context* pContext = (CJS_Context*)cc; 556 CJS_Context* pContext = (CJS_Context*)cc;
572 ASSERT(pContext != NULL); 557 ASSERT(pContext != NULL);
573 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); 558 CJS_Runtime* pRuntime = pContext->GetJSRuntime();
574 ASSERT(pRuntime != NULL); 559 ASSERT(pRuntime != NULL);
575 560
576 if (params.size() != 1) 561 if (params.size() != 1)
577 { 562 {
578 sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSPARAME RROR); 563 sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSPARAME RROR);
579 return FALSE; 564 return FALSE;
580 } 565 }
581 566
582 if (params[0].GetType() == VT_fxobject) 567 if (params[0].GetType() == VT_fxobject)
583 { 568 {
584 » » JSFXObject pObj = (JSFXObject)params[0]; 569 » » JSFXObject pObj = params[0].ToV8Object();
585 { 570 {
586 if (JS_GetObjDefnID(pObj) == JS_GetObjDefnID(*pRuntime, L"TimerObj")) 571 if (JS_GetObjDefnID(pObj) == JS_GetObjDefnID(*pRuntime, L"TimerObj"))
587 { 572 {
588 » » » » if (CJS_Object* pJSObj = (CJS_Object*)params[0]) 573 » » » » if (CJS_Object* pJSObj = params[0].ToCJSObject() )
589 { 574 {
590 if (TimerObj* pTimerObj = (TimerObj*)pJS Obj->GetEmbedObject()) 575 if (TimerObj* pTimerObj = (TimerObj*)pJS Obj->GetEmbedObject())
591 { 576 {
592 if (CJS_Timer* pTimer = pTimerOb j->GetTimer()) 577 if (CJS_Timer* pTimer = pTimerOb j->GetTimer())
593 { 578 {
594 pTimer->KillJSTimer(); 579 pTimer->KillJSTimer();
595 580
596 for (int i=0,sz=m_aTimer .GetSize(); i<sz; i++) 581 for (int i=0,sz=m_aTimer .GetSize(); i<sz; i++)
597 { 582 {
598 if (m_aTimer[i] == pTimer) 583 if (m_aTimer[i] == pTimer)
(...skipping 23 matching lines...) Expand all
622 ASSERT(pRuntime != NULL); 607 ASSERT(pRuntime != NULL);
623 608
624 if (params.size() != 1) 609 if (params.size() != 1)
625 { 610 {
626 sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSPARAME RROR); 611 sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSPARAME RROR);
627 return FALSE; 612 return FALSE;
628 } 613 }
629 614
630 if (params[0].GetType() == VT_fxobject) 615 if (params[0].GetType() == VT_fxobject)
631 { 616 {
632 » » JSFXObject pObj = (JSFXObject)params[0]; 617 » » JSFXObject pObj = params[0].ToV8Object();
633 { 618 {
634 if (JS_GetObjDefnID(pObj) == JS_GetObjDefnID(*pRuntime, L"TimerObj")) 619 if (JS_GetObjDefnID(pObj) == JS_GetObjDefnID(*pRuntime, L"TimerObj"))
635 { 620 {
636 » » » » if (CJS_Object* pJSObj = (CJS_Object*)params[0]) 621 » » » » if (CJS_Object* pJSObj = params[0].ToCJSObject() )
637 { 622 {
638 if (TimerObj* pTimerObj = (TimerObj*)pJS Obj->GetEmbedObject()) 623 if (TimerObj* pTimerObj = (TimerObj*)pJS Obj->GetEmbedObject())
639 { 624 {
640 if (CJS_Timer* pTimer = pTimerOb j->GetTimer()) 625 if (CJS_Timer* pTimer = pTimerOb j->GetTimer())
641 { 626 {
642 pTimer->KillJSTimer(); 627 pTimer->KillJSTimer();
643 628
644 for (int i=0,sz=m_aTimer .GetSize(); i<sz; i++) 629 for (int i=0,sz=m_aTimer .GetSize(); i<sz; i++)
645 { 630 {
646 if (m_aTimer[i] == pTimer) 631 if (m_aTimer[i] == pTimer)
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
710 695
711 FX_BOOL app::goForward(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Valu e& vRet, CFX_WideString& sError) 696 FX_BOOL app::goForward(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Valu e& vRet, CFX_WideString& sError)
712 { 697 {
713 // Not supported. 698 // Not supported.
714 return TRUE; 699 return TRUE;
715 } 700 }
716 701
717 FX_BOOL app::mailMsg(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError) 702 FX_BOOL app::mailMsg(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
718 { 703 {
719 CJS_Context* pContext = (CJS_Context*)cc; 704 CJS_Context* pContext = (CJS_Context*)cc;
720 ASSERT(pContext != NULL);
721
722 v8::Isolate* isolate = GetIsolate(cc); 705 v8::Isolate* isolate = GetIsolate(cc);
723 706
724 FX_BOOL bUI = TRUE; 707 FX_BOOL bUI = TRUE;
725 CFX_WideString cTo = L""; 708 CFX_WideString cTo = L"";
726 CFX_WideString cCc = L""; 709 CFX_WideString cCc = L"";
727 CFX_WideString cBcc = L""; 710 CFX_WideString cBcc = L"";
728 CFX_WideString cSubject = L""; 711 CFX_WideString cSubject = L"";
729 CFX_WideString cMsg = L""; 712 CFX_WideString cMsg = L"";
730 » if(params.size() < 2) 713
714 » if (params.size() < 1)
731 return FALSE; 715 return FALSE;
732 716
733 bUI = params.size()>=1?(int)params[0]:TRUE;
734 cTo = params.size()>=2?(const wchar_t*)(FX_LPCWSTR)params[1].operator CF X_WideString():L"";
735 cCc = params.size()>=3?(const wchar_t*)(FX_LPCWSTR)params[2].operator CF X_WideString():L"";
736 cBcc = params.size()>=4?(const wchar_t*)(FX_LPCWSTR)params[3].operator C FX_WideString():L"";
737 cSubject = params.size()>=5?(const wchar_t*)(FX_LPCWSTR)params[4].operat or CFX_WideString():L"";
738 cMsg = params.size()>=6?(const wchar_t*)(FX_LPCWSTR)params[5].operator C FX_WideString():L"";
739
740
741 if (params[0].GetType() == VT_object) 717 if (params[0].GetType() == VT_object)
742 { 718 {
743 » » JSObject pObj = (JSObject)params[0]; 719 » » JSObject pObj = params[0].ToV8Object();
744 720
745 » » v8::Handle<v8::Value> pValue = JS_GetObjectElement(isolate,pObj, L"bUI"); 721 » » v8::Handle<v8::Value> pValue = JS_GetObjectElement(isolate, pObj , L"bUI");
746 » » » bUI = (int)CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValu e)); 722 » » bUI = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToBool( );
747 723
748 pValue = JS_GetObjectElement(isolate, pObj, L"cTo"); 724 pValue = JS_GetObjectElement(isolate, pObj, L"cTo");
749 » » » cTo = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).o perator CFX_WideString(); 725 » » cTo = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToCFXWi deString();
750 726
751 » » pValue = JS_GetObjectElement(isolate,pObj, L"cCc"); 727 » » pValue = JS_GetObjectElement(isolate, pObj, L"cCc");
752 » » » cCc = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).o perator CFX_WideString(); 728 » » cCc = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToCFXWi deString();
753 729
754 » » pValue = JS_GetObjectElement(isolate,pObj, L"cBcc"); 730 » » pValue = JS_GetObjectElement(isolate, pObj, L"cBcc");
755 » » » cBcc = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)). operator CFX_WideString(); 731 » » cBcc = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToCFXW ideString();
756 732
757 » » pValue = JS_GetObjectElement(isolate,pObj, L"cSubject"); 733 » » pValue = JS_GetObjectElement(isolate, pObj, L"cSubject");
758 » » » cSubject = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValu e)).operator CFX_WideString(); 734 » » cSubject = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).To CFXWideString();
759 735
760 » » pValue = JS_GetObjectElement(isolate,pObj, L"cMsg"); 736 » » pValue = JS_GetObjectElement(isolate, pObj, L"cMsg");
761 » » » cMsg = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)). operator CFX_WideString(); 737 » » cMsg = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToCFXW ideString();
738 » } else {
739 » » if (params.size() < 2)
740 » » » return FALSE;
741
742 » » bUI = params[0].ToBool();
743 » » cTo = params[1].ToCFXWideString();
744
745 » » if (params.size() >= 3)
746 » » » cCc = params[2].ToCFXWideString();
747 » » if (params.size() >= 4)
748 » » » cBcc = params[3].ToCFXWideString();
749 » » if (params.size() >= 5)
750 » » » cSubject = params[4].ToCFXWideString();
751 » » if (params.size() >= 6)
752 » » » cMsg = params[5].ToCFXWideString();
762 } 753 }
763 754
764
765
766 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); 755 CJS_Runtime* pRuntime = pContext->GetJSRuntime();
767 ASSERT(pRuntime != NULL); 756 ASSERT(pRuntime != NULL);
768 757
769 CPDFDoc_Environment* pApp = pContext->GetReaderApp(); 758 CPDFDoc_Environment* pApp = pContext->GetReaderApp();
770 ASSERT(pApp != NULL); 759 ASSERT(pApp != NULL);
771 760
772 pRuntime->BeginBlock(); 761 pRuntime->BeginBlock();
773 pApp->JS_docmailForm(NULL, 0, bUI, cTo.c_str(), cSubject.c_str(), cCc.c_ str(), cBcc.c_str(), cMsg.c_str()); 762 pApp->JS_docmailForm(NULL, 0, bUI, cTo.c_str(), cSubject.c_str(), cCc.c_ str(), cBcc.c_str(), cMsg.c_str());
774 //////////////////////////////////////////////////////////////////////// ///////////////////////
775 pRuntime->EndBlock(); 763 pRuntime->EndBlock();
776 764
777 //return bRet;
778 return FALSE; 765 return FALSE;
779 } 766 }
780 767
781 FX_BOOL app::launchURL(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Valu e& vRet, CFX_WideString& sError) 768 FX_BOOL app::launchURL(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Valu e& vRet, CFX_WideString& sError)
782 { 769 {
783 // Unsafe, not supported. 770 // Unsafe, not supported.
784 return TRUE; 771 return TRUE;
785 } 772 }
786 773
787 FX_BOOL app::runtimeHighlight(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideStri ng& sError) 774 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
857 CFX_WideString swLabel = L""; 844 CFX_WideString swLabel = L"";
858 CFX_WideString swTitle = L"PDF"; 845 CFX_WideString swTitle = L"PDF";
859 CFX_WideString swDefault = L""; 846 CFX_WideString swDefault = L"";
860 bool bPassWord = false; 847 bool bPassWord = false;
861 848
862 v8::Isolate* isolate = GetIsolate(cc); 849 v8::Isolate* isolate = GetIsolate(cc);
863 850
864 int iLength = params.size(); 851 int iLength = params.size();
865 if (iLength > 0 && params[0].GetType() == VT_object) 852 if (iLength > 0 && params[0].GetType() == VT_object)
866 { 853 {
867 » » JSObject pObj = (JSObject )params[0]; 854 » » JSObject pObj = params[0].ToV8Object();
868 v8::Handle<v8::Value> pValue = JS_GetObjectElement(isolate,pObj, L"cQuestion"); 855 v8::Handle<v8::Value> pValue = JS_GetObjectElement(isolate,pObj, L"cQuestion");
869 » » swQuestion = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).op erator CFX_WideString(); 856 » » swQuestion = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).To CFXWideString();
870 857
871 pValue = JS_GetObjectElement(isolate,pObj,L"cTitle"); 858 pValue = JS_GetObjectElement(isolate,pObj,L"cTitle");
872 » » swTitle = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).opera tor CFX_WideString(); 859 » » swTitle = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).ToCFX WideString();
873 860
874 pValue = JS_GetObjectElement(isolate,pObj,L"cDefault"); 861 pValue = JS_GetObjectElement(isolate,pObj,L"cDefault");
875 » » swDefault = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).ope rator CFX_WideString(); 862 » » swDefault = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).ToC FXWideString();
876 863
877 pValue = JS_GetObjectElement(isolate,pObj,L"cLabel"); 864 pValue = JS_GetObjectElement(isolate,pObj,L"cLabel");
878 » » swLabel = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).opera tor CFX_WideString(); 865 » » swLabel = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).ToCFX WideString();
879 866
880 pValue = JS_GetObjectElement(isolate,pObj,L"bPassword"); 867 pValue = JS_GetObjectElement(isolate,pObj,L"bPassword");
881 » » bPassWord = (bool)CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue )); 868 » » bPassWord = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).ToB ool();
882 } 869 }
883 else 870 else
884 { 871 {
885 switch(iLength) 872 switch(iLength)
886 { 873 {
887 case 5: 874 case 5:
888 » » » swLabel = params[4]; 875 » » » swLabel = params[4].ToCFXWideString();
889 // FALLTHROUGH 876 // FALLTHROUGH
890 case 4: 877 case 4:
891 » » » bPassWord = params[3]; 878 » » » bPassWord = params[3].ToBool();
892 // FALLTHROUGH 879 // FALLTHROUGH
893 case 3: 880 case 3:
894 » » » swDefault = params[2]; 881 » » » swDefault = params[2].ToCFXWideString();
895 // FALLTHROUGH 882 // FALLTHROUGH
896 case 2: 883 case 2:
897 » » » swTitle = params[1]; 884 » » » swTitle = params[1].ToCFXWideString();
898 // FALLTHROUGH 885 // FALLTHROUGH
899 case 1: 886 case 1:
900 » » » swQuestion = params[0]; 887 » » » swQuestion = params[0].ToCFXWideString();
901 // FALLTHROUGH 888 // FALLTHROUGH
902 default: 889 default:
903 break; 890 break;
904 } 891 }
905 } 892 }
906 893
907 CJS_Context* pContext = (CJS_Context *)cc; 894 CJS_Context* pContext = (CJS_Context *)cc;
908 ASSERT(pContext != NULL); 895 ASSERT(pContext != NULL);
909 896
910 CPDFDoc_Environment* pApp = pContext->GetReaderApp(); 897 CPDFDoc_Environment* pApp = pContext->GetReaderApp();
(...skipping 22 matching lines...) Expand all
933 920
934 FX_BOOL app::media(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) 921 FX_BOOL app::media(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)
935 { 922 {
936 return FALSE; 923 return FALSE;
937 } 924 }
938 925
939 FX_BOOL app::execDialog(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Val ue& vRet, CFX_WideString& sError) 926 FX_BOOL app::execDialog(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Val ue& vRet, CFX_WideString& sError)
940 { 927 {
941 return TRUE; 928 return TRUE;
942 } 929 }
OLDNEW
« no previous file with comments | « fpdfsdk/src/javascript/PublicMethods.cpp ('k') | fpdfsdk/src/javascript/color.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698