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 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 //comment: | 319 //comment: |
320 //note: the paremter cName, this is clue how to treat if the cName is not a vali
able filed name in this document | 320 //note: the paremter cName, this is clue how to treat if the cName is not a vali
able filed name in this document |
321 | 321 |
322 FX_BOOL Document::getField(IFXJS_Context* cc, const CJS_Parameters& params, CJS_
Value& vRet, CFX_WideString& sError) | 322 FX_BOOL Document::getField(IFXJS_Context* cc, const CJS_Parameters& params, CJS_
Value& vRet, CFX_WideString& sError) |
323 { | 323 { |
324 v8::Isolate* isolate = GetIsolate(cc); | 324 v8::Isolate* isolate = GetIsolate(cc); |
325 ASSERT(m_pDocument != NULL); | 325 ASSERT(m_pDocument != NULL); |
326 | 326 |
327 if (params.size() < 1) return FALSE; | 327 if (params.size() < 1) return FALSE; |
328 | 328 |
329 » CFX_WideString wideName = params[0].operator CFX_WideString(); | 329 » CFX_WideString wideName = params[0].ToCFXWideString(); |
330 | 330 |
331 CPDFSDK_InterForm* pInterForm = m_pDocument->GetInterForm(); | 331 CPDFSDK_InterForm* pInterForm = m_pDocument->GetInterForm(); |
332 ASSERT(pInterForm != NULL); | 332 ASSERT(pInterForm != NULL); |
333 | 333 |
334 CPDF_InterForm* pPDFForm = pInterForm->GetInterForm(); | 334 CPDF_InterForm* pPDFForm = pInterForm->GetInterForm(); |
335 ASSERT(pPDFForm != NULL); | 335 ASSERT(pPDFForm != NULL); |
336 | 336 |
337 if (pPDFForm->CountFields(wideName) <= 0) | 337 if (pPDFForm->CountFields(wideName) <= 0) |
338 { | 338 { |
339 vRet.SetNull(); | 339 vRet.SetNull(); |
(...skipping 17 matching lines...) Expand all Loading... |
357 vRet = pJSField; | 357 vRet = pJSField; |
358 | 358 |
359 return TRUE; | 359 return TRUE; |
360 } | 360 } |
361 | 361 |
362 //Gets the name of the nth field in the document | 362 //Gets the name of the nth field in the document |
363 FX_BOOL Document::getNthFieldName(IFXJS_Context* cc, const CJS_Parameters& param
s, CJS_Value& vRet, CFX_WideString& sError) | 363 FX_BOOL Document::getNthFieldName(IFXJS_Context* cc, const CJS_Parameters& param
s, CJS_Value& vRet, CFX_WideString& sError) |
364 { | 364 { |
365 ASSERT(m_pDocument != NULL); | 365 ASSERT(m_pDocument != NULL); |
366 | 366 |
367 » int nIndex = params.size() > 0 ? (int)params[0] : -1; | 367 » int nIndex = params.size() > 0 ? params[0].ToInt() : -1; |
368 if (nIndex == -1) return FALSE; | 368 if (nIndex == -1) return FALSE; |
369 | 369 |
370 CPDFSDK_InterForm* pInterForm = m_pDocument->GetInterForm(); | 370 CPDFSDK_InterForm* pInterForm = m_pDocument->GetInterForm(); |
371 ASSERT(pInterForm != NULL); | 371 ASSERT(pInterForm != NULL); |
372 | 372 |
373 CPDF_InterForm* pPDFForm = pInterForm->GetInterForm(); | 373 CPDF_InterForm* pPDFForm = pInterForm->GetInterForm(); |
374 ASSERT(pPDFForm != NULL); | 374 ASSERT(pPDFForm != NULL); |
375 | 375 |
376 CPDF_FormField* pField = pPDFForm->GetField(nIndex); | 376 CPDF_FormField* pField = pPDFForm->GetField(nIndex); |
377 if (!pField) | 377 if (!pField) |
(...skipping 27 matching lines...) Expand all Loading... |
405 //int CPDFSDK_Document::mailForm(FX_BOOL bUI,String cto,string ccc,string cbcc,s
tring cSubject,string cms); | 405 //int CPDFSDK_Document::mailForm(FX_BOOL bUI,String cto,string ccc,string cbcc,s
tring cSubject,string cms); |
406 | 406 |
407 FX_BOOL Document::mailForm(IFXJS_Context* cc, const CJS_Parameters& params, CJS_
Value& vRet, CFX_WideString& sError) | 407 FX_BOOL Document::mailForm(IFXJS_Context* cc, const CJS_Parameters& params, CJS_
Value& vRet, CFX_WideString& sError) |
408 { | 408 { |
409 ASSERT(m_pDocument != NULL); | 409 ASSERT(m_pDocument != NULL); |
410 | 410 |
411 if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) return FALSE; | 411 if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) return FALSE; |
412 | 412 |
413 int iLength = params.size(); | 413 int iLength = params.size(); |
414 | 414 |
415 » FX_BOOL bUI = iLength > 0 ? (FX_BOOL)params[0] : TRUE; | 415 » FX_BOOL bUI = iLength > 0 ? params[0].ToBool() : TRUE; |
416 » CFX_WideString cTo = iLength > 1 ? (FX_LPCWSTR)params[1].operator CFX_Wi
deString() : L""; | 416 » CFX_WideString cTo = iLength > 1 ? params[1].ToCFXWideString() : L""; |
417 » CFX_WideString cCc = iLength > 2 ? (FX_LPCWSTR)params[2].operator CFX_Wi
deString() : L""; | 417 » CFX_WideString cCc = iLength > 2 ? params[2].ToCFXWideString() : L""; |
418 » CFX_WideString cBcc = iLength > 3 ? (FX_LPCWSTR)params[3].operator CFX_W
ideString() : L""; | 418 » CFX_WideString cBcc = iLength > 3 ? params[3].ToCFXWideString() : L""; |
419 » CFX_WideString cSubject = iLength > 4 ? (FX_LPCWSTR)params[4].operator C
FX_WideString() : L""; | 419 » CFX_WideString cSubject = iLength > 4 ? params[4].ToCFXWideString() : L"
"; |
420 » CFX_WideString cMsg = iLength > 5 ? (FX_LPCWSTR)params[5].operator CFX_W
ideString() : L""; | 420 » CFX_WideString cMsg = iLength > 5 ? params[5].ToCFXWideString() : L""; |
421 | 421 |
422 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInte
rForm(); | 422 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInte
rForm(); |
423 ASSERT(pInterForm != NULL); | 423 ASSERT(pInterForm != NULL); |
424 | 424 |
425 CFX_ByteTextBuf textBuf; | 425 CFX_ByteTextBuf textBuf; |
426 if (!pInterForm->ExportFormToFDFTextBuf(textBuf)) | 426 if (!pInterForm->ExportFormToFDFTextBuf(textBuf)) |
427 return FALSE; | 427 return FALSE; |
428 | 428 |
429 CJS_Context* pContext = (CJS_Context*)cc; | 429 CJS_Context* pContext = (CJS_Context*)cc; |
430 ASSERT(pContext != NULL); | 430 ASSERT(pContext != NULL); |
(...skipping 22 matching lines...) Expand all Loading... |
453 FX_BOOL bShrinkToFit = FALSE; | 453 FX_BOOL bShrinkToFit = FALSE; |
454 FX_BOOL bPrintAsImage = FALSE; | 454 FX_BOOL bPrintAsImage = FALSE; |
455 FX_BOOL bReverse = FALSE; | 455 FX_BOOL bReverse = FALSE; |
456 FX_BOOL bAnnotations = FALSE; | 456 FX_BOOL bAnnotations = FALSE; |
457 | 457 |
458 int nlength = params.size(); | 458 int nlength = params.size(); |
459 if(nlength ==9) | 459 if(nlength ==9) |
460 { | 460 { |
461 if (params[8].GetType() == VT_fxobject) | 461 if (params[8].GetType() == VT_fxobject) |
462 { | 462 { |
463 » » » JSFXObject pObj = (JSFXObject)params[8]; | 463 » » » JSFXObject pObj = params[8].ToV8Object(); |
464 { | 464 { |
465 if (JS_GetObjDefnID(pObj) == JS_GetObjDefnID(*pR
untime, L"PrintParamsObj")) | 465 if (JS_GetObjDefnID(pObj) == JS_GetObjDefnID(*pR
untime, L"PrintParamsObj")) |
466 { | 466 { |
467 » » » » » if (CJS_Object* pJSObj = (CJS_Object*)pa
rams[8]) | 467 » » » » » if (CJS_Object* pJSObj = params[8].ToCJS
Object()) |
468 { | 468 { |
469 if (PrintParamsObj* ppri
ntparamsObj = (PrintParamsObj*)pJSObj->GetEmbedObject()) | 469 if (PrintParamsObj* ppri
ntparamsObj = (PrintParamsObj*)pJSObj->GetEmbedObject()) |
470 { | 470 { |
471 bUI = pprintpara
msObj->bUI; | 471 bUI = pprintpara
msObj->bUI; |
472 nStart = pprintp
aramsObj->nStart; | 472 nStart = pprintp
aramsObj->nStart; |
473 nEnd = pprintpar
amsObj->nEnd; | 473 nEnd = pprintpar
amsObj->nEnd; |
474 bSilent = pprint
paramsObj->bSilent; | 474 bSilent = pprint
paramsObj->bSilent; |
475 bShrinkToFit = p
printparamsObj->bShrinkToFit; | 475 bShrinkToFit = p
printparamsObj->bShrinkToFit; |
476 bPrintAsImage =
pprintparamsObj->bPrintAsImage; | 476 bPrintAsImage =
pprintparamsObj->bPrintAsImage; |
477 bReverse = pprin
tparamsObj->bReverse; | 477 bReverse = pprin
tparamsObj->bReverse; |
478 bAnnotations = p
printparamsObj->bAnnotations; | 478 bAnnotations = p
printparamsObj->bAnnotations; |
479 } | 479 } |
480 } | 480 } |
481 } | 481 } |
482 } | 482 } |
483 } | 483 } |
484 } | 484 } |
485 else | 485 else |
486 { | 486 { |
487 if(nlength >= 1) | 487 if(nlength >= 1) |
488 » » » bUI = params[0]; | 488 » » » bUI = params[0].ToBool(); |
489 if(nlength >= 2) | 489 if(nlength >= 2) |
490 » » » nStart = (int)params[1]; | 490 » » » nStart = params[1].ToInt(); |
491 if(nlength >= 3) | 491 if(nlength >= 3) |
492 » » » nEnd = (int)params[2]; | 492 » » » nEnd = params[2].ToInt(); |
493 if(nlength >= 4) | 493 if(nlength >= 4) |
494 » » » bSilent = params[3]; | 494 » » » bSilent = params[3].ToBool(); |
495 if(nlength >= 5) | 495 if(nlength >= 5) |
496 » » » bShrinkToFit = params[4]; | 496 » » » bShrinkToFit = params[4].ToBool(); |
497 if(nlength >= 6) | 497 if(nlength >= 6) |
498 » » » bPrintAsImage = params[5]; | 498 » » » bPrintAsImage = params[5].ToBool(); |
499 if(nlength >= 7) | 499 if(nlength >= 7) |
500 » » » bReverse = params[6]; | 500 » » » bReverse = params[6].ToBool(); |
501 if(nlength >= 8) | 501 if(nlength >= 8) |
502 » » » bAnnotations = params[7]; | 502 » » » bAnnotations = params[7].ToBool(); |
503 } | 503 } |
504 | 504 |
505 ASSERT(m_pDocument != NULL); | 505 ASSERT(m_pDocument != NULL); |
506 | 506 |
507 if (CPDFDoc_Environment* pEnv = m_pDocument->GetEnv()) | 507 if (CPDFDoc_Environment* pEnv = m_pDocument->GetEnv()) |
508 { | 508 { |
509 pEnv->JS_docprint(bUI, nStart, nEnd, bSilent, bShrinkToFit, bPri
ntAsImage, bReverse, bAnnotations); | 509 pEnv->JS_docprint(bUI, nStart, nEnd, bSilent, bShrinkToFit, bPri
ntAsImage, bReverse, bAnnotations); |
510 return TRUE; | 510 return TRUE; |
511 } | 511 } |
512 return FALSE; | 512 return FALSE; |
513 } | 513 } |
514 | 514 |
515 //removes the specified field from the document. | 515 //removes the specified field from the document. |
516 //comment: | 516 //comment: |
517 //note: if the filed name is not retional, adobe is dumb for it. | 517 //note: if the filed name is not retional, adobe is dumb for it. |
518 | 518 |
519 FX_BOOL Document::removeField(IFXJS_Context* cc, const CJS_Parameters& params, C
JS_Value& vRet, CFX_WideString& sError) | 519 FX_BOOL Document::removeField(IFXJS_Context* cc, const CJS_Parameters& params, C
JS_Value& vRet, CFX_WideString& sError) |
520 { | 520 { |
521 ASSERT(m_pDocument != NULL); | 521 ASSERT(m_pDocument != NULL); |
522 | 522 |
523 if (!(m_pDocument->GetPermissions(FPDFPERM_MODIFY) || | 523 if (!(m_pDocument->GetPermissions(FPDFPERM_MODIFY) || |
524 m_pDocument->GetPermissions(FPDFPERM_ANNOT_FORM))) return FALSE; | 524 m_pDocument->GetPermissions(FPDFPERM_ANNOT_FORM))) return FALSE; |
525 | 525 |
526 if (params.size() < 1) | 526 if (params.size() < 1) |
527 return TRUE; | 527 return TRUE; |
528 | 528 |
529 » CFX_WideString sFieldName = params[0].operator CFX_WideString(); | 529 » CFX_WideString sFieldName = params[0].ToCFXWideString(); |
530 | 530 |
531 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInte
rForm(); | 531 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInte
rForm(); |
532 ASSERT(pInterForm != NULL); | 532 ASSERT(pInterForm != NULL); |
533 | 533 |
534 CFX_PtrArray widgets; | 534 CFX_PtrArray widgets; |
535 pInterForm->GetWidgets(sFieldName, widgets); | 535 pInterForm->GetWidgets(sFieldName, widgets); |
536 | 536 |
537 int nSize = widgets.GetSize(); | 537 int nSize = widgets.GetSize(); |
538 | 538 |
539 if (nSize > 0) | 539 if (nSize > 0) |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
585 ASSERT(pPDFForm != NULL); | 585 ASSERT(pPDFForm != NULL); |
586 | 586 |
587 v8::Isolate* isolate = GetIsolate(cc); | 587 v8::Isolate* isolate = GetIsolate(cc); |
588 CJS_Array aName(isolate); | 588 CJS_Array aName(isolate); |
589 | 589 |
590 if (params.size() > 0) | 590 if (params.size() > 0) |
591 { | 591 { |
592 switch (params[0].GetType()) | 592 switch (params[0].GetType()) |
593 { | 593 { |
594 default: | 594 default: |
595 » » » aName.Attach(params[0]); | 595 » » » aName.Attach(params[0].ToV8Array()); |
596 break; | 596 break; |
597 case VT_string: | 597 case VT_string: |
598 aName.SetElement(0,params[0]); | 598 aName.SetElement(0,params[0]); |
599 break; | 599 break; |
600 } | 600 } |
601 | 601 |
602 CFX_PtrArray aFields; | 602 CFX_PtrArray aFields; |
603 | 603 |
604 for (int i=0,isz=aName.GetLength(); i<isz; i++) | 604 for (int i=0,isz=aName.GetLength(); i<isz; i++) |
605 { | 605 { |
606 CJS_Value valElement(isolate); | 606 CJS_Value valElement(isolate); |
607 aName.GetElement(i,valElement); | 607 aName.GetElement(i,valElement); |
608 » » » CFX_WideString swVal = valElement.operator CFX_WideStrin
g(); | 608 » » » CFX_WideString swVal = valElement.ToCFXWideString(); |
609 | 609 |
610 for (int j=0,jsz=pPDFForm->CountFields(swVal); j<jsz; j+
+) | 610 for (int j=0,jsz=pPDFForm->CountFields(swVal); j<jsz; j+
+) |
611 { | 611 { |
612 aFields.Add((void*)pPDFForm->GetField(j,swVal)); | 612 aFields.Add((void*)pPDFForm->GetField(j,swVal)); |
613 } | 613 } |
614 } | 614 } |
615 | 615 |
616 if (aFields.GetSize() > 0) | 616 if (aFields.GetSize() > 0) |
617 { | 617 { |
618 pPDFForm->ResetForm(aFields, TRUE, TRUE); | 618 pPDFForm->ResetForm(aFields, TRUE, TRUE); |
(...skipping 30 matching lines...) Expand all Loading... |
649 | 649 |
650 CFX_WideString strURL; | 650 CFX_WideString strURL; |
651 FX_BOOL bFDF = TRUE; | 651 FX_BOOL bFDF = TRUE; |
652 FX_BOOL bEmpty = FALSE; | 652 FX_BOOL bEmpty = FALSE; |
653 v8::Isolate* isolate = GetIsolate(cc); | 653 v8::Isolate* isolate = GetIsolate(cc); |
654 CJS_Array aFields(isolate); | 654 CJS_Array aFields(isolate); |
655 | 655 |
656 CJS_Value v = params[0]; | 656 CJS_Value v = params[0]; |
657 if (v.GetType() == VT_string) | 657 if (v.GetType() == VT_string) |
658 { | 658 { |
659 » » strURL = params[0].operator CFX_WideString(); | 659 » » strURL = params[0].ToCFXWideString(); |
660 if (nSize > 1) | 660 if (nSize > 1) |
661 » » » bFDF = params[1]; | 661 » » » bFDF = params[1].ToBool(); |
662 if (nSize > 2) | 662 if (nSize > 2) |
663 » » » bEmpty = params[2]; | 663 » » » bEmpty = params[2].ToBool(); |
664 if (nSize > 3) | 664 if (nSize > 3) |
665 » » » aFields.Attach(params[3]); | 665 » » » aFields.Attach(params[3].ToV8Array()); |
666 } | 666 } |
667 else if (v.GetType() == VT_object) | 667 else if (v.GetType() == VT_object) |
668 { | 668 { |
669 » » JSObject pObj = (JSObject)params[0]; | 669 » » JSObject pObj = params[0].ToV8Object(); |
670 » » v8::Handle<v8::Value> pValue = JS_GetObjectElement(isolate,pObj,
L"cURL"); | 670 » » v8::Handle<v8::Value> pValue = JS_GetObjectElement(isolate, pObj
, L"cURL"); |
671 if (!pValue.IsEmpty()) | 671 if (!pValue.IsEmpty()) |
672 » » » strURL = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)
); | 672 » » » strURL = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValu
e)).ToCFXWideString(); |
673 » » pValue = JS_GetObjectElement(isolate,pObj, L"bFDF"); | 673 » » pValue = JS_GetObjectElement(isolate, pObj, L"bFDF"); |
674 » » » bFDF = CJS_Value(isolate,pValue, GET_VALUE_TYPE(pValue))
; | 674 » » bFDF = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToBool
(); |
675 » » pValue = JS_GetObjectElement(isolate,pObj, L"bEmpty"); | 675 » » pValue = JS_GetObjectElement(isolate, pObj, L"bEmpty"); |
676 » » » bEmpty = CJS_Value(isolate,pValue, GET_VALUE_TYPE(pValue
)); | 676 » » bEmpty = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToBo
ol(); |
677 » » pValue = JS_GetObjectElement(isolate,pObj,L"aFields"); | 677 » » pValue = JS_GetObjectElement(isolate, pObj,L"aFields"); |
678 » » » aFields.Attach(CJS_Value(isolate,pValue, GET_VALUE_TYPE(
pValue))); | 678 » » aFields.Attach(CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)
).ToV8Array()); |
679 } | 679 } |
680 | 680 |
681 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInte
rForm(); | 681 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInte
rForm(); |
682 ASSERT(pInterForm != NULL); | 682 ASSERT(pInterForm != NULL); |
683 CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm(); | 683 CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm(); |
684 ASSERT(pPDFInterForm != NULL); | 684 ASSERT(pPDFInterForm != NULL); |
685 | 685 |
686 FX_BOOL bAll = (aFields.GetLength() == 0); | 686 FX_BOOL bAll = (aFields.GetLength() == 0); |
687 | 687 |
688 if (bAll && bEmpty) | 688 if (bAll && bEmpty) |
(...skipping 14 matching lines...) Expand all Loading... |
703 return TRUE; | 703 return TRUE; |
704 } | 704 } |
705 else | 705 else |
706 { | 706 { |
707 CFX_PtrArray fieldObjects; | 707 CFX_PtrArray fieldObjects; |
708 | 708 |
709 for (int i=0,sz=aFields.GetLength(); i<sz; i++) | 709 for (int i=0,sz=aFields.GetLength(); i<sz; i++) |
710 { | 710 { |
711 CJS_Value valName(isolate); | 711 CJS_Value valName(isolate); |
712 aFields.GetElement(i, valName); | 712 aFields.GetElement(i, valName); |
713 » » » CFX_WideString sName = valName.operator CFX_WideString()
; | 713 » » » CFX_WideString sName = valName.ToCFXWideString(); |
714 | 714 |
715 CPDF_InterForm* pPDFForm = pInterForm->GetInterForm(); | 715 CPDF_InterForm* pPDFForm = pInterForm->GetInterForm(); |
716 ASSERT(pPDFForm != NULL); | 716 ASSERT(pPDFForm != NULL); |
717 | 717 |
718 for (int j=0, jsz=pPDFForm->CountFields(sName); j<jsz; j
++) | 718 for (int j=0, jsz=pPDFForm->CountFields(sName); j<jsz; j
++) |
719 { | 719 { |
720 CPDF_FormField* pField = pPDFForm->GetField(j, s
Name); | 720 CPDF_FormField* pField = pPDFForm->GetField(j, s
Name); |
721 if (!bEmpty && pField->GetValue().IsEmpty()) | 721 if (!bEmpty && pField->GetValue().IsEmpty()) |
722 continue; | 722 continue; |
723 | 723 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
774 { | 774 { |
775 ASSERT(m_pDocument != NULL); | 775 ASSERT(m_pDocument != NULL); |
776 | 776 |
777 FX_BOOL bUI = TRUE; | 777 FX_BOOL bUI = TRUE; |
778 CFX_WideString cTo = L""; | 778 CFX_WideString cTo = L""; |
779 CFX_WideString cCc = L""; | 779 CFX_WideString cCc = L""; |
780 CFX_WideString cBcc = L""; | 780 CFX_WideString cBcc = L""; |
781 CFX_WideString cSubject = L""; | 781 CFX_WideString cSubject = L""; |
782 CFX_WideString cMsg = L""; | 782 CFX_WideString cMsg = L""; |
783 | 783 |
784 | 784 » if (params.size() >= 1) |
785 » bUI = params.size()>=1?static_cast<FX_BOOL>(params[0]):TRUE; | 785 » » bUI = params[0].ToBool(); |
786 » cTo = params.size()>=2?(const wchar_t*)params[1].operator CFX_WideString
():L""; | 786 » if (params.size() >= 2) |
787 » cCc = params.size()>=3?(const wchar_t*)params[2].operator CFX_WideString
():L""; | 787 » » cTo = params[1].ToCFXWideString(); |
788 » cBcc = params.size()>=4?(const wchar_t*)params[3].operator CFX_WideStrin
g():L""; | 788 » if (params.size() >= 3) |
789 » cSubject = params.size()>=5?(const wchar_t*)params[4].operator CFX_WideS
tring():L""; | 789 » » cCc = params[2].ToCFXWideString(); |
790 » cMsg = params.size()>=6?(const wchar_t*)params[5].operator CFX_WideStrin
g():L""; | 790 » if (params.size() >= 4) |
| 791 » » cBcc = params[3].ToCFXWideString(); |
| 792 » if (params.size() >= 5) |
| 793 » » cSubject = params[4].ToCFXWideString(); |
| 794 » if (params.size() >= 6) |
| 795 » » cMsg = params[5].ToCFXWideString(); |
791 | 796 |
792 v8::Isolate* isolate = GetIsolate(cc); | 797 v8::Isolate* isolate = GetIsolate(cc); |
793 | 798 |
794 » if(params.size()>=1 && params[0].GetType() == VT_object) | 799 » if(params.size() >= 1 && params[0].GetType() == VT_object) |
795 { | 800 { |
796 » » JSObject pObj = (JSObject )params[0]; | 801 » » JSObject pObj = params[0].ToV8Object(); |
797 | 802 |
798 v8::Handle<v8::Value> pValue = JS_GetObjectElement(isolate,pObj,
L"bUI"); | 803 v8::Handle<v8::Value> pValue = JS_GetObjectElement(isolate,pObj,
L"bUI"); |
799 » » » bUI = (int)CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValu
e)); | 804 » » bUI = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).ToInt(); |
800 | 805 |
801 pValue = JS_GetObjectElement(isolate,pObj, L"cTo"); | 806 pValue = JS_GetObjectElement(isolate,pObj, L"cTo"); |
802 » » » cTo = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).o
perator CFX_WideString(); | 807 » » cTo = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).ToCFXWide
String(); |
803 | 808 |
804 pValue = JS_GetObjectElement(isolate,pObj, L"cCc"); | 809 pValue = JS_GetObjectElement(isolate,pObj, L"cCc"); |
805 » » » cCc = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).o
perator CFX_WideString(); | 810 » » cCc = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).ToCFXWide
String(); |
806 | 811 |
807 pValue = JS_GetObjectElement(isolate,pObj, L"cBcc"); | 812 pValue = JS_GetObjectElement(isolate,pObj, L"cBcc"); |
808 » » » cBcc = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).
operator CFX_WideString(); | 813 » » cBcc = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).ToCFXWid
eString(); |
809 | 814 |
810 pValue = JS_GetObjectElement(isolate,pObj, L"cSubject"); | 815 pValue = JS_GetObjectElement(isolate,pObj, L"cSubject"); |
811 » » » cSubject = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValu
e)).operator CFX_WideString(); | 816 » » cSubject = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).ToCF
XWideString(); |
812 | 817 |
813 pValue = JS_GetObjectElement(isolate,pObj, L"cMsg"); | 818 pValue = JS_GetObjectElement(isolate,pObj, L"cMsg"); |
814 » » » cMsg = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).
operator CFX_WideString(); | 819 » » cMsg = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).ToCFXWid
eString(); |
815 | 820 |
816 } | 821 } |
817 | 822 |
818 CJS_Context* pContext = (CJS_Context*)cc; | 823 CJS_Context* pContext = (CJS_Context*)cc; |
819 ASSERT(pContext != NULL); | 824 ASSERT(pContext != NULL); |
820 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 825 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
821 ASSERT(pRuntime != NULL); | 826 ASSERT(pRuntime != NULL); |
822 | 827 |
823 pRuntime->BeginBlock(); | 828 pRuntime->BeginBlock(); |
824 CPDFDoc_Environment* pEnv = pRuntime->GetReaderApp(); | 829 CPDFDoc_Environment* pEnv = pRuntime->GetReaderApp(); |
(...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1452 | 1457 |
1453 FX_BOOL Document::addIcon(IFXJS_Context* cc, const CJS_Parameters& params, CJS_V
alue& vRet, CFX_WideString& sError) | 1458 FX_BOOL Document::addIcon(IFXJS_Context* cc, const CJS_Parameters& params, CJS_V
alue& vRet, CFX_WideString& sError) |
1454 { | 1459 { |
1455 if (params.size() != 2)return FALSE; | 1460 if (params.size() != 2)return FALSE; |
1456 | 1461 |
1457 CJS_Context* pContext = (CJS_Context*)cc; | 1462 CJS_Context* pContext = (CJS_Context*)cc; |
1458 ASSERT(pContext != NULL); | 1463 ASSERT(pContext != NULL); |
1459 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 1464 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
1460 ASSERT(pRuntime != NULL); | 1465 ASSERT(pRuntime != NULL); |
1461 | 1466 |
1462 » CFX_WideString swIconName = params[0].operator CFX_WideString(); | 1467 » CFX_WideString swIconName = params[0].ToCFXWideString(); |
1463 | 1468 |
1464 » JSFXObject pJSIcon = (JSFXObject)params[1]; | 1469 » JSFXObject pJSIcon = params[1].ToV8Object(); |
1465 if (JS_GetObjDefnID(pJSIcon) != JS_GetObjDefnID(*pRuntime, L"Icon")) ret
urn FALSE; | 1470 if (JS_GetObjDefnID(pJSIcon) != JS_GetObjDefnID(*pRuntime, L"Icon")) ret
urn FALSE; |
1466 | 1471 |
1467 » CJS_EmbedObj* pEmbedObj = ((CJS_Object*)params[1])->GetEmbedObject(); | 1472 » CJS_EmbedObj* pEmbedObj = params[1].ToCJSObject()->GetEmbedObject(); |
1468 if (!pEmbedObj)return FALSE; | 1473 if (!pEmbedObj)return FALSE; |
1469 Icon* pIcon = (Icon*)pEmbedObj; | 1474 Icon* pIcon = (Icon*)pEmbedObj; |
1470 | 1475 |
1471 if (!m_pIconTree) | 1476 if (!m_pIconTree) |
1472 m_pIconTree = new IconTree(); | 1477 m_pIconTree = new IconTree(); |
1473 | 1478 |
1474 IconElement* pNewIcon = new IconElement(); | 1479 IconElement* pNewIcon = new IconElement(); |
1475 pNewIcon->IconName = swIconName; | 1480 pNewIcon->IconName = swIconName; |
1476 pNewIcon->NextIcon = NULL; | 1481 pNewIcon->NextIcon = NULL; |
1477 pNewIcon->IconStream = pIcon; | 1482 pNewIcon->IconStream = pIcon; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1520 | 1525 |
1521 vp << Icons; | 1526 vp << Icons; |
1522 return TRUE; | 1527 return TRUE; |
1523 } | 1528 } |
1524 | 1529 |
1525 FX_BOOL Document::getIcon(IFXJS_Context* cc, const CJS_Parameters& params, CJS_V
alue& vRet, CFX_WideString& sError) | 1530 FX_BOOL Document::getIcon(IFXJS_Context* cc, const CJS_Parameters& params, CJS_V
alue& vRet, CFX_WideString& sError) |
1526 { | 1531 { |
1527 if (params.size() != 1)return FALSE; | 1532 if (params.size() != 1)return FALSE; |
1528 if(!m_pIconTree) | 1533 if(!m_pIconTree) |
1529 return FALSE; | 1534 return FALSE; |
1530 » CFX_WideString swIconName = params[0].operator CFX_WideString(); | 1535 » CFX_WideString swIconName = params[0].ToCFXWideString(); |
1531 int iIconCounts = m_pIconTree->GetLength(); | 1536 int iIconCounts = m_pIconTree->GetLength(); |
1532 | 1537 |
1533 CJS_Context* pContext = (CJS_Context *)cc; | 1538 CJS_Context* pContext = (CJS_Context *)cc; |
1534 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 1539 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
1535 | 1540 |
1536 for (int i = 0; i < iIconCounts; i++) | 1541 for (int i = 0; i < iIconCounts; i++) |
1537 { | 1542 { |
1538 if ((*m_pIconTree)[i]->IconName == swIconName) | 1543 if ((*m_pIconTree)[i]->IconName == swIconName) |
1539 { | 1544 { |
1540 Icon* pRetIcon = (*m_pIconTree)[i]->IconStream; | 1545 Icon* pRetIcon = (*m_pIconTree)[i]->IconStream; |
(...skipping 15 matching lines...) Expand all Loading... |
1556 } | 1561 } |
1557 | 1562 |
1558 return FALSE; | 1563 return FALSE; |
1559 } | 1564 } |
1560 | 1565 |
1561 FX_BOOL Document::removeIcon(IFXJS_Context* cc, const CJS_Parameters& params, CJ
S_Value& vRet, CFX_WideString& sError) | 1566 FX_BOOL Document::removeIcon(IFXJS_Context* cc, const CJS_Parameters& params, CJ
S_Value& vRet, CFX_WideString& sError) |
1562 { | 1567 { |
1563 if (params.size() != 1)return FALSE; | 1568 if (params.size() != 1)return FALSE; |
1564 if(!m_pIconTree) | 1569 if(!m_pIconTree) |
1565 return FALSE; | 1570 return FALSE; |
1566 » CFX_WideString swIconName = params[0].operator CFX_WideString(); | 1571 » CFX_WideString swIconName = params[0].ToCFXWideString(); |
1567 return TRUE; | 1572 return TRUE; |
1568 } | 1573 } |
1569 | 1574 |
1570 FX_BOOL Document::createDataObject(IFXJS_Context* cc, const CJS_Parameters& para
ms, CJS_Value& vRet, CFX_WideString& sError) | 1575 FX_BOOL Document::createDataObject(IFXJS_Context* cc, const CJS_Parameters& para
ms, CJS_Value& vRet, CFX_WideString& sError) |
1571 { | 1576 { |
1572 // Unsafe, not implemented. | 1577 // Unsafe, not implemented. |
1573 return TRUE; | 1578 return TRUE; |
1574 } | 1579 } |
1575 | 1580 |
1576 FX_BOOL Document::media(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sE
rror) | 1581 FX_BOOL Document::media(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sE
rror) |
(...skipping 19 matching lines...) Expand all Loading... |
1596 { | 1601 { |
1597 return TRUE; | 1602 return TRUE; |
1598 } | 1603 } |
1599 | 1604 |
1600 FX_BOOL Document::getPageNthWord(IFXJS_Context* cc, const CJS_Parameters& params
, CJS_Value& vRet, CFX_WideString& sError) | 1605 FX_BOOL Document::getPageNthWord(IFXJS_Context* cc, const CJS_Parameters& params
, CJS_Value& vRet, CFX_WideString& sError) |
1601 { | 1606 { |
1602 ASSERT(m_pDocument != NULL); | 1607 ASSERT(m_pDocument != NULL); |
1603 | 1608 |
1604 if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) return FALSE; | 1609 if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) return FALSE; |
1605 | 1610 |
1606 » int nPageNo = params.GetSize() > 0 ? (int)params[0] : 0; | 1611 » int nPageNo = params.GetSize() > 0 ? params[0].ToInt() : 0; |
1607 » int nWordNo = params.GetSize() > 1 ? (int)params[1] : 0; | 1612 » int nWordNo = params.GetSize() > 1 ? params[1].ToInt() : 0; |
1608 » bool bStrip = params.GetSize() > 2 ? (bool)params[2] : true; | 1613 » bool bStrip = params.GetSize() > 2 ? params[2].ToBool() : true; |
1609 | 1614 |
1610 CPDF_Document* pDocument = m_pDocument->GetDocument()->GetPDFDoc(); | 1615 CPDF_Document* pDocument = m_pDocument->GetDocument()->GetPDFDoc(); |
1611 if (!pDocument) return FALSE; | 1616 if (!pDocument) return FALSE; |
1612 | 1617 |
1613 if (nPageNo < 0 || nPageNo >= pDocument->GetPageCount()) | 1618 if (nPageNo < 0 || nPageNo >= pDocument->GetPageCount()) |
1614 { | 1619 { |
1615 CJS_Context* pContext = static_cast<CJS_Context*>(cc); | 1620 CJS_Context* pContext = static_cast<CJS_Context*>(cc); |
1616 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); | 1621 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); |
1617 return FALSE; | 1622 return FALSE; |
1618 } | 1623 } |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1668 | 1673 |
1669 return FALSE; | 1674 return FALSE; |
1670 } | 1675 } |
1671 | 1676 |
1672 FX_BOOL Document::getPageNumWords(IFXJS_Context* cc, const CJS_Parameters& param
s, CJS_Value& vRet, CFX_WideString& sError) | 1677 FX_BOOL Document::getPageNumWords(IFXJS_Context* cc, const CJS_Parameters& param
s, CJS_Value& vRet, CFX_WideString& sError) |
1673 { | 1678 { |
1674 ASSERT(m_pDocument != NULL); | 1679 ASSERT(m_pDocument != NULL); |
1675 | 1680 |
1676 if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) return FALSE; | 1681 if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) return FALSE; |
1677 | 1682 |
1678 » int nPageNo = params.GetSize() > 0 ? (int)params[0] : 0; | 1683 » int nPageNo = params.GetSize() > 0 ? params[0].ToInt() : 0; |
1679 | 1684 |
1680 CPDF_Document* pDocument = m_pDocument->GetDocument()->GetPDFDoc(); | 1685 CPDF_Document* pDocument = m_pDocument->GetDocument()->GetPDFDoc(); |
1681 ASSERT(pDocument != NULL); | 1686 ASSERT(pDocument != NULL); |
1682 | 1687 |
1683 if (nPageNo < 0 || nPageNo >= pDocument->GetPageCount()) | 1688 if (nPageNo < 0 || nPageNo >= pDocument->GetPageCount()) |
1684 { | 1689 { |
1685 CJS_Context* pContext = static_cast<CJS_Context*>(cc); | 1690 CJS_Context* pContext = static_cast<CJS_Context*>(cc); |
1686 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); | 1691 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); |
1687 return FALSE; | 1692 return FALSE; |
1688 } | 1693 } |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1840 int nStart = 0; | 1845 int nStart = 0; |
1841 int nEnd = 0; | 1846 int nEnd = 0; |
1842 | 1847 |
1843 if (iSize < 1) | 1848 if (iSize < 1) |
1844 { | 1849 { |
1845 } | 1850 } |
1846 else if (iSize == 1) | 1851 else if (iSize == 1) |
1847 { | 1852 { |
1848 if (params[0].GetType() == VT_object) | 1853 if (params[0].GetType() == VT_object) |
1849 { | 1854 { |
1850 » » » JSObject pObj = (JSObject )params[0]; | 1855 » » » JSObject pObj = params[0].ToV8Object(); |
1851 » » » v8::Handle<v8::Value> pValue = JS_GetObjectElement(isola
te,pObj, L"nStart"); | 1856 » » » v8::Handle<v8::Value> pValue = JS_GetObjectElement(isola
te, pObj, L"nStart"); |
1852 » » » » nStart = (int)CJS_Value(m_isolate,pValue,GET_VAL
UE_TYPE(pValue)); | 1857 nStart = CJS_Value(m_isolate, pValue, GET_VALUE_TYPE(pValue)).ToInt(
); |
1853 | 1858 |
1854 » » » pValue = JS_GetObjectElement(isolate,pObj, L"nEnd"); | 1859 » » » pValue = JS_GetObjectElement(isolate, pObj, L"nEnd"); |
1855 » » » » nEnd = (int)CJS_Value(m_isolate,pValue,GET_VALUE
_TYPE(pValue)); | 1860 » » » nEnd = CJS_Value(m_isolate, pValue, GET_VALUE_TYPE(pValu
e)).ToInt(); |
1856 } | 1861 } |
1857 else | 1862 else |
1858 { | 1863 { |
1859 » » » nStart = (int)params[0]; | 1864 » » » nStart = params[0].ToInt(); |
1860 } | 1865 } |
1861 } | 1866 } |
1862 else | 1867 else |
1863 { | 1868 { |
1864 » » nStart = (int)params[0]; | 1869 » » nStart = params[0].ToInt(); |
1865 » » nEnd = (int)params[1]; | 1870 » » nEnd = params[1].ToInt(); |
1866 } | 1871 } |
1867 | 1872 |
1868 int nTotal = m_pDocument->GetPageCount(); | 1873 int nTotal = m_pDocument->GetPageCount(); |
1869 | 1874 |
1870 if (nStart < 0) nStart = 0; | 1875 if (nStart < 0) nStart = 0; |
1871 if (nStart >= nTotal) nStart = nTotal - 1; | 1876 if (nStart >= nTotal) nStart = nTotal - 1; |
1872 | 1877 |
1873 if (nEnd < 0) nEnd = 0; | 1878 if (nEnd < 0) nEnd = 0; |
1874 if (nEnd >= nTotal) nEnd = nTotal - 1; | 1879 if (nEnd >= nTotal) nEnd = nTotal - 1; |
1875 | 1880 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1946 { | 1951 { |
1947 m_DelayData.RemoveAt(DelArray[j]); | 1952 m_DelayData.RemoveAt(DelArray[j]); |
1948 } | 1953 } |
1949 } | 1954 } |
1950 | 1955 |
1951 CJS_Document* Document::GetCJSDoc() const | 1956 CJS_Document* Document::GetCJSDoc() const |
1952 { | 1957 { |
1953 return static_cast<CJS_Document*>(m_pJSObject); | 1958 return static_cast<CJS_Document*>(m_pJSObject); |
1954 } | 1959 } |
1955 | 1960 |
OLD | NEW |