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 | 319 |
320 CPDFSDK_InterForm* pInterForm = m_pDocument->GetInterForm(); | 320 CPDFSDK_InterForm* pInterForm = m_pDocument->GetInterForm(); |
321 CPDF_InterForm* pPDFForm = pInterForm->GetInterForm(); | 321 CPDF_InterForm* pPDFForm = pInterForm->GetInterForm(); |
322 if (pPDFForm->CountFields(wideName) <= 0) { | 322 if (pPDFForm->CountFields(wideName) <= 0) { |
323 vRet.SetNull(); | 323 vRet.SetNull(); |
324 return TRUE; | 324 return TRUE; |
325 } | 325 } |
326 | 326 |
327 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 327 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
328 v8::Local<v8::Object> pFieldObj = | 328 v8::Local<v8::Object> pFieldObj = |
329 JS_NewFxDynamicObj(pRuntime->GetIsolate(), pContext, | 329 FXJS_NewFxDynamicObj(pRuntime->GetIsolate(), pContext, |
330 JS_GetObjDefnID(pRuntime->GetIsolate(), L"Field")); | 330 FXJS_GetObjDefnID(pRuntime->GetIsolate(), L"Field")); |
331 | 331 |
332 v8::Isolate* isolate = GetIsolate(cc); | 332 v8::Isolate* isolate = GetIsolate(cc); |
333 CJS_Field* pJSField = (CJS_Field*)JS_GetPrivate(isolate, pFieldObj); | 333 CJS_Field* pJSField = (CJS_Field*)FXJS_GetPrivate(isolate, pFieldObj); |
334 Field* pField = (Field*)pJSField->GetEmbedObject(); | 334 Field* pField = (Field*)pJSField->GetEmbedObject(); |
335 pField->AttachField(this, wideName); | 335 pField->AttachField(this, wideName); |
336 | 336 |
337 vRet = pJSField; | 337 vRet = pJSField; |
338 return TRUE; | 338 return TRUE; |
339 } | 339 } |
340 | 340 |
341 // Gets the name of the nth field in the document | 341 // Gets the name of the nth field in the document |
342 FX_BOOL Document::getNthFieldName(IFXJS_Context* cc, | 342 FX_BOOL Document::getNthFieldName(IFXJS_Context* cc, |
343 const CJS_Parameters& params, | 343 const CJS_Parameters& params, |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 int nStart = 0; | 450 int nStart = 0; |
451 int nEnd = 0; | 451 int nEnd = 0; |
452 FX_BOOL bSilent = FALSE; | 452 FX_BOOL bSilent = FALSE; |
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 if (params[8].GetType() == VT_fxobject) { | 460 if (params[8].GetType() == CJS_Value::VT_fxobject) { |
461 v8::Local<v8::Object> pObj = params[8].ToV8Object(); | 461 v8::Local<v8::Object> pObj = params[8].ToV8Object(); |
462 { | 462 { |
463 if (JS_GetObjDefnID(pObj) == | 463 if (FXJS_GetObjDefnID(pObj) == |
464 JS_GetObjDefnID(pRuntime->GetIsolate(), L"PrintParamsObj")) { | 464 FXJS_GetObjDefnID(pRuntime->GetIsolate(), L"PrintParamsObj")) { |
465 if (CJS_Object* pJSObj = params[8].ToCJSObject()) { | 465 if (CJS_Object* pJSObj = params[8].ToCJSObject()) { |
466 if (PrintParamsObj* pprintparamsObj = | 466 if (PrintParamsObj* pprintparamsObj = |
467 (PrintParamsObj*)pJSObj->GetEmbedObject()) { | 467 (PrintParamsObj*)pJSObj->GetEmbedObject()) { |
468 bUI = pprintparamsObj->bUI; | 468 bUI = pprintparamsObj->bUI; |
469 nStart = pprintparamsObj->nStart; | 469 nStart = pprintparamsObj->nStart; |
470 nEnd = pprintparamsObj->nEnd; | 470 nEnd = pprintparamsObj->nEnd; |
471 bSilent = pprintparamsObj->bSilent; | 471 bSilent = pprintparamsObj->bSilent; |
472 bShrinkToFit = pprintparamsObj->bShrinkToFit; | 472 bShrinkToFit = pprintparamsObj->bShrinkToFit; |
473 bPrintAsImage = pprintparamsObj->bPrintAsImage; | 473 bPrintAsImage = pprintparamsObj->bPrintAsImage; |
474 bReverse = pprintparamsObj->bReverse; | 474 bReverse = pprintparamsObj->bReverse; |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
588 ASSERT(pPDFForm != NULL); | 588 ASSERT(pPDFForm != NULL); |
589 | 589 |
590 v8::Isolate* isolate = GetIsolate(cc); | 590 v8::Isolate* isolate = GetIsolate(cc); |
591 CJS_Array aName(isolate); | 591 CJS_Array aName(isolate); |
592 | 592 |
593 if (params.size() > 0) { | 593 if (params.size() > 0) { |
594 switch (params[0].GetType()) { | 594 switch (params[0].GetType()) { |
595 default: | 595 default: |
596 aName.Attach(params[0].ToV8Array()); | 596 aName.Attach(params[0].ToV8Array()); |
597 break; | 597 break; |
598 case VT_string: | 598 case CJS_Value::VT_string: |
599 aName.SetElement(0, params[0]); | 599 aName.SetElement(0, params[0]); |
600 break; | 600 break; |
601 } | 601 } |
602 | 602 |
603 CFX_PtrArray aFields; | 603 CFX_PtrArray aFields; |
604 | 604 |
605 for (int i = 0, isz = aName.GetLength(); i < isz; i++) { | 605 for (int i = 0, isz = aName.GetLength(); i < isz; i++) { |
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.ToCFXWideString(); | 608 CFX_WideString swVal = valElement.ToCFXWideString(); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
644 return FALSE; | 644 return FALSE; |
645 } | 645 } |
646 | 646 |
647 CFX_WideString strURL; | 647 CFX_WideString strURL; |
648 FX_BOOL bFDF = TRUE; | 648 FX_BOOL bFDF = TRUE; |
649 FX_BOOL bEmpty = FALSE; | 649 FX_BOOL bEmpty = FALSE; |
650 v8::Isolate* isolate = GetIsolate(cc); | 650 v8::Isolate* isolate = GetIsolate(cc); |
651 CJS_Array aFields(isolate); | 651 CJS_Array aFields(isolate); |
652 | 652 |
653 CJS_Value v = params[0]; | 653 CJS_Value v = params[0]; |
654 if (v.GetType() == VT_string) { | 654 if (v.GetType() == CJS_Value::VT_string) { |
655 strURL = params[0].ToCFXWideString(); | 655 strURL = params[0].ToCFXWideString(); |
656 if (nSize > 1) | 656 if (nSize > 1) |
657 bFDF = params[1].ToBool(); | 657 bFDF = params[1].ToBool(); |
658 if (nSize > 2) | 658 if (nSize > 2) |
659 bEmpty = params[2].ToBool(); | 659 bEmpty = params[2].ToBool(); |
660 if (nSize > 3) | 660 if (nSize > 3) |
661 aFields.Attach(params[3].ToV8Array()); | 661 aFields.Attach(params[3].ToV8Array()); |
662 } else if (v.GetType() == VT_object) { | 662 } else if (v.GetType() == CJS_Value::VT_object) { |
663 v8::Local<v8::Object> pObj = params[0].ToV8Object(); | 663 v8::Local<v8::Object> pObj = params[0].ToV8Object(); |
664 v8::Local<v8::Value> pValue = JS_GetObjectElement(isolate, pObj, L"cURL"); | 664 v8::Local<v8::Value> pValue = FXJS_GetObjectElement(isolate, pObj, L"cURL"); |
665 if (!pValue.IsEmpty()) | 665 if (!pValue.IsEmpty()) |
666 strURL = | 666 strURL = |
667 CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString(); | 667 CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString(); |
668 pValue = JS_GetObjectElement(isolate, pObj, L"bFDF"); | 668 pValue = FXJS_GetObjectElement(isolate, pObj, L"bFDF"); |
669 bFDF = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToBool(); | 669 bFDF = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToBool(); |
670 pValue = JS_GetObjectElement(isolate, pObj, L"bEmpty"); | 670 pValue = FXJS_GetObjectElement(isolate, pObj, L"bEmpty"); |
671 bEmpty = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToBool(); | 671 bEmpty = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToBool(); |
672 pValue = JS_GetObjectElement(isolate, pObj, L"aFields"); | 672 pValue = FXJS_GetObjectElement(isolate, pObj, L"aFields"); |
673 aFields.Attach( | 673 aFields.Attach( |
674 CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToV8Array()); | 674 CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToV8Array()); |
675 } | 675 } |
676 | 676 |
677 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 677 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
678 CPDFSDK_InterForm* pInterForm = | 678 CPDFSDK_InterForm* pInterForm = |
679 (CPDFSDK_InterForm*)m_pDocument->GetInterForm(); | 679 (CPDFSDK_InterForm*)m_pDocument->GetInterForm(); |
680 CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm(); | 680 CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm(); |
681 FX_BOOL bAll = (aFields.GetLength() == 0); | 681 FX_BOOL bAll = (aFields.GetLength() == 0); |
682 if (bAll && bEmpty) { | 682 if (bAll && bEmpty) { |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
759 cCc = params[2].ToCFXWideString(); | 759 cCc = params[2].ToCFXWideString(); |
760 if (params.size() >= 4) | 760 if (params.size() >= 4) |
761 cBcc = params[3].ToCFXWideString(); | 761 cBcc = params[3].ToCFXWideString(); |
762 if (params.size() >= 5) | 762 if (params.size() >= 5) |
763 cSubject = params[4].ToCFXWideString(); | 763 cSubject = params[4].ToCFXWideString(); |
764 if (params.size() >= 6) | 764 if (params.size() >= 6) |
765 cMsg = params[5].ToCFXWideString(); | 765 cMsg = params[5].ToCFXWideString(); |
766 | 766 |
767 v8::Isolate* isolate = GetIsolate(cc); | 767 v8::Isolate* isolate = GetIsolate(cc); |
768 | 768 |
769 if (params.size() >= 1 && params[0].GetType() == VT_object) { | 769 if (params.size() >= 1 && params[0].GetType() == CJS_Value::VT_object) { |
770 v8::Local<v8::Object> pObj = params[0].ToV8Object(); | 770 v8::Local<v8::Object> pObj = params[0].ToV8Object(); |
771 | 771 |
772 v8::Local<v8::Value> pValue = JS_GetObjectElement(isolate, pObj, L"bUI"); | 772 v8::Local<v8::Value> pValue = FXJS_GetObjectElement(isolate, pObj, L"bUI"); |
773 bUI = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToInt(); | 773 bUI = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToInt(); |
774 | 774 |
775 pValue = JS_GetObjectElement(isolate, pObj, L"cTo"); | 775 pValue = FXJS_GetObjectElement(isolate, pObj, L"cTo"); |
776 cTo = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString(); | 776 cTo = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString(); |
777 | 777 |
778 pValue = JS_GetObjectElement(isolate, pObj, L"cCc"); | 778 pValue = FXJS_GetObjectElement(isolate, pObj, L"cCc"); |
779 cCc = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString(); | 779 cCc = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString(); |
780 | 780 |
781 pValue = JS_GetObjectElement(isolate, pObj, L"cBcc"); | 781 pValue = FXJS_GetObjectElement(isolate, pObj, L"cBcc"); |
782 cBcc = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString(); | 782 cBcc = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString(); |
783 | 783 |
784 pValue = JS_GetObjectElement(isolate, pObj, L"cSubject"); | 784 pValue = FXJS_GetObjectElement(isolate, pObj, L"cSubject"); |
785 cSubject = | 785 cSubject = |
786 CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString(); | 786 CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString(); |
787 | 787 |
788 pValue = JS_GetObjectElement(isolate, pObj, L"cMsg"); | 788 pValue = FXJS_GetObjectElement(isolate, pObj, L"cMsg"); |
789 cMsg = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString(); | 789 cMsg = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString(); |
790 } | 790 } |
791 | 791 |
792 CJS_Context* pContext = (CJS_Context*)cc; | 792 CJS_Context* pContext = (CJS_Context*)cc; |
793 ASSERT(pContext != NULL); | 793 ASSERT(pContext != NULL); |
794 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 794 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
795 ASSERT(pRuntime != NULL); | 795 ASSERT(pRuntime != NULL); |
796 | 796 |
797 pRuntime->BeginBlock(); | 797 pRuntime->BeginBlock(); |
798 CPDFDoc_Environment* pEnv = pRuntime->GetReaderApp(); | 798 CPDFDoc_Environment* pEnv = pRuntime->GetReaderApp(); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
844 CFX_WideString cwProducer = pDictionary->GetUnicodeText("Producer"); | 844 CFX_WideString cwProducer = pDictionary->GetUnicodeText("Producer"); |
845 CFX_WideString cwCreationDate = pDictionary->GetUnicodeText("CreationDate"); | 845 CFX_WideString cwCreationDate = pDictionary->GetUnicodeText("CreationDate"); |
846 CFX_WideString cwModDate = pDictionary->GetUnicodeText("ModDate"); | 846 CFX_WideString cwModDate = pDictionary->GetUnicodeText("ModDate"); |
847 CFX_WideString cwTrapped = pDictionary->GetUnicodeText("Trapped"); | 847 CFX_WideString cwTrapped = pDictionary->GetUnicodeText("Trapped"); |
848 | 848 |
849 v8::Isolate* isolate = GetIsolate(cc); | 849 v8::Isolate* isolate = GetIsolate(cc); |
850 if (vp.IsGetting()) { | 850 if (vp.IsGetting()) { |
851 CJS_Context* pContext = (CJS_Context*)cc; | 851 CJS_Context* pContext = (CJS_Context*)cc; |
852 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 852 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
853 v8::Local<v8::Object> pObj = | 853 v8::Local<v8::Object> pObj = |
854 JS_NewFxDynamicObj(pRuntime->GetIsolate(), pContext, -1); | 854 FXJS_NewFxDynamicObj(pRuntime->GetIsolate(), pContext, -1); |
855 JS_PutObjectString(isolate, pObj, L"Author", cwAuthor.c_str()); | 855 FXJS_PutObjectString(isolate, pObj, L"Author", cwAuthor.c_str()); |
856 JS_PutObjectString(isolate, pObj, L"Title", cwTitle.c_str()); | 856 FXJS_PutObjectString(isolate, pObj, L"Title", cwTitle.c_str()); |
857 JS_PutObjectString(isolate, pObj, L"Subject", cwSubject.c_str()); | 857 FXJS_PutObjectString(isolate, pObj, L"Subject", cwSubject.c_str()); |
858 JS_PutObjectString(isolate, pObj, L"Keywords", cwKeywords.c_str()); | 858 FXJS_PutObjectString(isolate, pObj, L"Keywords", cwKeywords.c_str()); |
859 JS_PutObjectString(isolate, pObj, L"Creator", cwCreator.c_str()); | 859 FXJS_PutObjectString(isolate, pObj, L"Creator", cwCreator.c_str()); |
860 JS_PutObjectString(isolate, pObj, L"Producer", cwProducer.c_str()); | 860 FXJS_PutObjectString(isolate, pObj, L"Producer", cwProducer.c_str()); |
861 JS_PutObjectString(isolate, pObj, L"CreationDate", cwCreationDate.c_str()); | 861 FXJS_PutObjectString(isolate, pObj, L"CreationDate", |
862 JS_PutObjectString(isolate, pObj, L"ModDate", cwModDate.c_str()); | 862 cwCreationDate.c_str()); |
863 JS_PutObjectString(isolate, pObj, L"Trapped", cwTrapped.c_str()); | 863 FXJS_PutObjectString(isolate, pObj, L"ModDate", cwModDate.c_str()); |
| 864 FXJS_PutObjectString(isolate, pObj, L"Trapped", cwTrapped.c_str()); |
864 | 865 |
865 // It's to be compatible to non-standard info dictionary. | 866 // It's to be compatible to non-standard info dictionary. |
866 FX_POSITION pos = pDictionary->GetStartPos(); | 867 FX_POSITION pos = pDictionary->GetStartPos(); |
867 while (pos) { | 868 while (pos) { |
868 CFX_ByteString bsKey; | 869 CFX_ByteString bsKey; |
869 CPDF_Object* pValueObj = pDictionary->GetNextElement(pos, bsKey); | 870 CPDF_Object* pValueObj = pDictionary->GetNextElement(pos, bsKey); |
870 CFX_WideString wsKey = CFX_WideString::FromUTF8(bsKey, bsKey.GetLength()); | 871 CFX_WideString wsKey = CFX_WideString::FromUTF8(bsKey, bsKey.GetLength()); |
871 if ((pValueObj->GetType() == PDFOBJ_STRING) || | 872 if ((pValueObj->GetType() == PDFOBJ_STRING) || |
872 (pValueObj->GetType() == PDFOBJ_NAME)) | 873 (pValueObj->GetType() == PDFOBJ_NAME)) |
873 JS_PutObjectString(isolate, pObj, wsKey.c_str(), | 874 FXJS_PutObjectString(isolate, pObj, wsKey.c_str(), |
874 pValueObj->GetUnicodeText().c_str()); | 875 pValueObj->GetUnicodeText().c_str()); |
875 if (pValueObj->GetType() == PDFOBJ_NUMBER) | 876 if (pValueObj->GetType() == PDFOBJ_NUMBER) |
876 JS_PutObjectNumber(isolate, pObj, wsKey.c_str(), | 877 FXJS_PutObjectNumber(isolate, pObj, wsKey.c_str(), |
877 (float)pValueObj->GetNumber()); | 878 (float)pValueObj->GetNumber()); |
878 if (pValueObj->GetType() == PDFOBJ_BOOLEAN) | 879 if (pValueObj->GetType() == PDFOBJ_BOOLEAN) |
879 JS_PutObjectBoolean(isolate, pObj, wsKey.c_str(), | 880 FXJS_PutObjectBoolean(isolate, pObj, wsKey.c_str(), |
880 (bool)pValueObj->GetInteger()); | 881 (bool)pValueObj->GetInteger()); |
881 } | 882 } |
882 vp << pObj; | 883 vp << pObj; |
883 } | 884 } |
884 return TRUE; | 885 return TRUE; |
885 } | 886 } |
886 | 887 |
887 FX_BOOL Document::creationDate(IFXJS_Context* cc, | 888 FX_BOOL Document::creationDate(IFXJS_Context* cc, |
888 CJS_PropValue& vp, | 889 CJS_PropValue& vp, |
889 CFX_WideString& sError) { | 890 CFX_WideString& sError) { |
890 CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetInfo(); | 891 CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetInfo(); |
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1280 CJS_Value& vRet, | 1281 CJS_Value& vRet, |
1281 CFX_WideString& sError) { | 1282 CFX_WideString& sError) { |
1282 vRet.SetNull(); | 1283 vRet.SetNull(); |
1283 return TRUE; | 1284 return TRUE; |
1284 } | 1285 } |
1285 | 1286 |
1286 FX_BOOL Document::getAnnots3D(IFXJS_Context* cc, | 1287 FX_BOOL Document::getAnnots3D(IFXJS_Context* cc, |
1287 const CJS_Parameters& params, | 1288 const CJS_Parameters& params, |
1288 CJS_Value& vRet, | 1289 CJS_Value& vRet, |
1289 CFX_WideString& sError) { | 1290 CFX_WideString& sError) { |
1290 vRet = VT_undefined; | 1291 vRet = CJS_Value::VT_undefined; |
1291 return TRUE; | 1292 return TRUE; |
1292 } | 1293 } |
1293 | 1294 |
1294 FX_BOOL Document::getOCGs(IFXJS_Context* cc, | 1295 FX_BOOL Document::getOCGs(IFXJS_Context* cc, |
1295 const CJS_Parameters& params, | 1296 const CJS_Parameters& params, |
1296 CJS_Value& vRet, | 1297 CJS_Value& vRet, |
1297 CFX_WideString& sError) { | 1298 CFX_WideString& sError) { |
1298 return TRUE; | 1299 return TRUE; |
1299 } | 1300 } |
1300 | 1301 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1359 const CJS_Parameters& params, | 1360 const CJS_Parameters& params, |
1360 CJS_Value& vRet, | 1361 CJS_Value& vRet, |
1361 CFX_WideString& sError) { | 1362 CFX_WideString& sError) { |
1362 CJS_Context* pContext = (CJS_Context*)cc; | 1363 CJS_Context* pContext = (CJS_Context*)cc; |
1363 if (params.size() != 2) { | 1364 if (params.size() != 2) { |
1364 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); | 1365 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); |
1365 return FALSE; | 1366 return FALSE; |
1366 } | 1367 } |
1367 CFX_WideString swIconName = params[0].ToCFXWideString(); | 1368 CFX_WideString swIconName = params[0].ToCFXWideString(); |
1368 | 1369 |
1369 if (params[1].GetType() != VT_object) { | 1370 if (params[1].GetType() != CJS_Value::VT_object) { |
1370 sError = JSGetStringFromID(pContext, IDS_STRING_JSTYPEERROR); | 1371 sError = JSGetStringFromID(pContext, IDS_STRING_JSTYPEERROR); |
1371 return FALSE; | 1372 return FALSE; |
1372 } | 1373 } |
1373 v8::Local<v8::Object> pJSIcon = params[1].ToV8Object(); | 1374 v8::Local<v8::Object> pJSIcon = params[1].ToV8Object(); |
1374 | 1375 |
1375 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 1376 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
1376 if (JS_GetObjDefnID(pJSIcon) != | 1377 if (FXJS_GetObjDefnID(pJSIcon) != |
1377 JS_GetObjDefnID(pRuntime->GetIsolate(), L"Icon")) { | 1378 FXJS_GetObjDefnID(pRuntime->GetIsolate(), L"Icon")) { |
1378 sError = JSGetStringFromID(pContext, IDS_STRING_JSTYPEERROR); | 1379 sError = JSGetStringFromID(pContext, IDS_STRING_JSTYPEERROR); |
1379 return FALSE; | 1380 return FALSE; |
1380 } | 1381 } |
1381 | 1382 |
1382 CJS_EmbedObj* pEmbedObj = params[1].ToCJSObject()->GetEmbedObject(); | 1383 CJS_EmbedObj* pEmbedObj = params[1].ToCJSObject()->GetEmbedObject(); |
1383 if (!pEmbedObj) { | 1384 if (!pEmbedObj) { |
1384 sError = JSGetStringFromID(pContext, IDS_STRING_JSTYPEERROR); | 1385 sError = JSGetStringFromID(pContext, IDS_STRING_JSTYPEERROR); |
1385 return FALSE; | 1386 return FALSE; |
1386 } | 1387 } |
1387 | 1388 |
(...skipping 26 matching lines...) Expand all Loading... |
1414 CJS_Array Icons(m_isolate); | 1415 CJS_Array Icons(m_isolate); |
1415 IconElement* pIconElement = NULL; | 1416 IconElement* pIconElement = NULL; |
1416 int iIconTreeLength = m_pIconTree->GetLength(); | 1417 int iIconTreeLength = m_pIconTree->GetLength(); |
1417 | 1418 |
1418 CJS_Context* pContext = (CJS_Context*)cc; | 1419 CJS_Context* pContext = (CJS_Context*)cc; |
1419 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 1420 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
1420 | 1421 |
1421 for (int i = 0; i < iIconTreeLength; i++) { | 1422 for (int i = 0; i < iIconTreeLength; i++) { |
1422 pIconElement = (*m_pIconTree)[i]; | 1423 pIconElement = (*m_pIconTree)[i]; |
1423 | 1424 |
1424 v8::Local<v8::Object> pObj = | 1425 v8::Local<v8::Object> pObj = FXJS_NewFxDynamicObj( |
1425 JS_NewFxDynamicObj(pRuntime->GetIsolate(), pContext, | 1426 pRuntime->GetIsolate(), pContext, |
1426 JS_GetObjDefnID(pRuntime->GetIsolate(), L"Icon")); | 1427 FXJS_GetObjDefnID(pRuntime->GetIsolate(), L"Icon")); |
1427 if (pObj.IsEmpty()) | 1428 if (pObj.IsEmpty()) |
1428 return FALSE; | 1429 return FALSE; |
1429 | 1430 |
1430 CJS_Icon* pJS_Icon = (CJS_Icon*)JS_GetPrivate(pObj); | 1431 CJS_Icon* pJS_Icon = (CJS_Icon*)FXJS_GetPrivate(pObj); |
1431 if (!pJS_Icon) | 1432 if (!pJS_Icon) |
1432 return FALSE; | 1433 return FALSE; |
1433 | 1434 |
1434 Icon* pIcon = (Icon*)pJS_Icon->GetEmbedObject(); | 1435 Icon* pIcon = (Icon*)pJS_Icon->GetEmbedObject(); |
1435 if (!pIcon) | 1436 if (!pIcon) |
1436 return FALSE; | 1437 return FALSE; |
1437 | 1438 |
1438 pIcon->SetStream(pIconElement->IconStream->GetStream()); | 1439 pIcon->SetStream(pIconElement->IconStream->GetStream()); |
1439 pIcon->SetIconName(pIconElement->IconName); | 1440 pIcon->SetIconName(pIconElement->IconName); |
1440 Icons.SetElement(i, CJS_Value(m_isolate, pJS_Icon)); | 1441 Icons.SetElement(i, CJS_Value(m_isolate, pJS_Icon)); |
(...skipping 17 matching lines...) Expand all Loading... |
1458 return FALSE; | 1459 return FALSE; |
1459 CFX_WideString swIconName = params[0].ToCFXWideString(); | 1460 CFX_WideString swIconName = params[0].ToCFXWideString(); |
1460 int iIconCounts = m_pIconTree->GetLength(); | 1461 int iIconCounts = m_pIconTree->GetLength(); |
1461 | 1462 |
1462 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 1463 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
1463 | 1464 |
1464 for (int i = 0; i < iIconCounts; i++) { | 1465 for (int i = 0; i < iIconCounts; i++) { |
1465 if ((*m_pIconTree)[i]->IconName == swIconName) { | 1466 if ((*m_pIconTree)[i]->IconName == swIconName) { |
1466 Icon* pRetIcon = (*m_pIconTree)[i]->IconStream; | 1467 Icon* pRetIcon = (*m_pIconTree)[i]->IconStream; |
1467 | 1468 |
1468 v8::Local<v8::Object> pObj = | 1469 v8::Local<v8::Object> pObj = FXJS_NewFxDynamicObj( |
1469 JS_NewFxDynamicObj(pRuntime->GetIsolate(), pContext, | 1470 pRuntime->GetIsolate(), pContext, |
1470 JS_GetObjDefnID(pRuntime->GetIsolate(), L"Icon")); | 1471 FXJS_GetObjDefnID(pRuntime->GetIsolate(), L"Icon")); |
1471 if (pObj.IsEmpty()) | 1472 if (pObj.IsEmpty()) |
1472 return FALSE; | 1473 return FALSE; |
1473 | 1474 |
1474 CJS_Icon* pJS_Icon = (CJS_Icon*)JS_GetPrivate(pObj); | 1475 CJS_Icon* pJS_Icon = (CJS_Icon*)FXJS_GetPrivate(pObj); |
1475 if (!pJS_Icon) | 1476 if (!pJS_Icon) |
1476 return FALSE; | 1477 return FALSE; |
1477 | 1478 |
1478 Icon* pIcon = (Icon*)pJS_Icon->GetEmbedObject(); | 1479 Icon* pIcon = (Icon*)pJS_Icon->GetEmbedObject(); |
1479 if (!pIcon) | 1480 if (!pIcon) |
1480 return FALSE; | 1481 return FALSE; |
1481 | 1482 |
1482 pIcon->SetIconName(swIconName); | 1483 pIcon->SetIconName(swIconName); |
1483 pIcon->SetStream(pRetIcon->GetStream()); | 1484 pIcon->SetStream(pRetIcon->GetStream()); |
1484 vRet = pJS_Icon; | 1485 vRet = pJS_Icon; |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1655 | 1656 |
1656 return TRUE; | 1657 return TRUE; |
1657 } | 1658 } |
1658 | 1659 |
1659 FX_BOOL Document::getPrintParams(IFXJS_Context* cc, | 1660 FX_BOOL Document::getPrintParams(IFXJS_Context* cc, |
1660 const CJS_Parameters& params, | 1661 const CJS_Parameters& params, |
1661 CJS_Value& vRet, | 1662 CJS_Value& vRet, |
1662 CFX_WideString& sError) { | 1663 CFX_WideString& sError) { |
1663 CJS_Context* pContext = (CJS_Context*)cc; | 1664 CJS_Context* pContext = (CJS_Context*)cc; |
1664 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 1665 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
1665 v8::Local<v8::Object> pRetObj = JS_NewFxDynamicObj( | 1666 v8::Local<v8::Object> pRetObj = FXJS_NewFxDynamicObj( |
1666 pRuntime->GetIsolate(), pContext, | 1667 pRuntime->GetIsolate(), pContext, |
1667 JS_GetObjDefnID(pRuntime->GetIsolate(), L"PrintParamsObj")); | 1668 FXJS_GetObjDefnID(pRuntime->GetIsolate(), L"PrintParamsObj")); |
1668 | 1669 |
1669 // Not implemented yet. | 1670 // Not implemented yet. |
1670 | 1671 |
1671 vRet = pRetObj; | 1672 vRet = pRetObj; |
1672 return TRUE; | 1673 return TRUE; |
1673 } | 1674 } |
1674 | 1675 |
1675 #define ISLATINWORD(u) (u != 0x20 && u <= 0x28FF) | 1676 #define ISLATINWORD(u) (u != 0x20 && u <= 0x28FF) |
1676 | 1677 |
1677 int Document::CountWords(CPDF_TextObject* pTextObj) { | 1678 int Document::CountWords(CPDF_TextObject* pTextObj) { |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1849 CFX_DWordArray DelArray; | 1850 CFX_DWordArray DelArray; |
1850 | 1851 |
1851 for (int j = DelArray.GetSize() - 1; j >= 0; j--) { | 1852 for (int j = DelArray.GetSize() - 1; j >= 0; j--) { |
1852 m_DelayData.RemoveAt(DelArray[j]); | 1853 m_DelayData.RemoveAt(DelArray[j]); |
1853 } | 1854 } |
1854 } | 1855 } |
1855 | 1856 |
1856 CJS_Document* Document::GetCJSDoc() const { | 1857 CJS_Document* Document::GetCJSDoc() const { |
1857 return static_cast<CJS_Document*>(m_pJSObject); | 1858 return static_cast<CJS_Document*>(m_pJSObject); |
1858 } | 1859 } |
OLD | NEW |