| 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 "Document.h" | 7 #include "Document.h" |
| 8 | 8 |
| 9 #include "Field.h" | 9 #include "Field.h" |
| 10 #include "Icon.h" | 10 #include "Icon.h" |
| (...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 734 } | 734 } |
| 735 | 735 |
| 736 FX_BOOL Document::author(IJS_Context* cc, | 736 FX_BOOL Document::author(IJS_Context* cc, |
| 737 CJS_PropValue& vp, | 737 CJS_PropValue& vp, |
| 738 CFX_WideString& sError) { | 738 CFX_WideString& sError) { |
| 739 CPDF_Dictionary* pDictionary = m_pDocument->GetPDFDocument()->GetInfo(); | 739 CPDF_Dictionary* pDictionary = m_pDocument->GetPDFDocument()->GetInfo(); |
| 740 if (!pDictionary) | 740 if (!pDictionary) |
| 741 return FALSE; | 741 return FALSE; |
| 742 | 742 |
| 743 if (vp.IsGetting()) { | 743 if (vp.IsGetting()) { |
| 744 vp << pDictionary->GetUnicodeText("Author"); | 744 vp << pDictionary->GetUnicodeTextBy("Author"); |
| 745 return TRUE; | 745 return TRUE; |
| 746 } else { | 746 } else { |
| 747 if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) | 747 if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) |
| 748 return FALSE; | 748 return FALSE; |
| 749 | 749 |
| 750 CFX_WideString csAuthor; | 750 CFX_WideString csAuthor; |
| 751 vp >> csAuthor; | 751 vp >> csAuthor; |
| 752 pDictionary->SetAtString("Author", PDF_EncodeText(csAuthor)); | 752 pDictionary->SetAtString("Author", PDF_EncodeText(csAuthor)); |
| 753 m_pDocument->SetChangeMark(); | 753 m_pDocument->SetChangeMark(); |
| 754 return TRUE; | 754 return TRUE; |
| 755 } | 755 } |
| 756 } | 756 } |
| 757 | 757 |
| 758 FX_BOOL Document::info(IJS_Context* cc, | 758 FX_BOOL Document::info(IJS_Context* cc, |
| 759 CJS_PropValue& vp, | 759 CJS_PropValue& vp, |
| 760 CFX_WideString& sError) { | 760 CFX_WideString& sError) { |
| 761 CPDF_Dictionary* pDictionary = m_pDocument->GetPDFDocument()->GetInfo(); | 761 CPDF_Dictionary* pDictionary = m_pDocument->GetPDFDocument()->GetInfo(); |
| 762 if (!pDictionary) | 762 if (!pDictionary) |
| 763 return FALSE; | 763 return FALSE; |
| 764 | 764 |
| 765 CFX_WideString cwAuthor = pDictionary->GetUnicodeText("Author"); | 765 CFX_WideString cwAuthor = pDictionary->GetUnicodeTextBy("Author"); |
| 766 CFX_WideString cwTitle = pDictionary->GetUnicodeText("Title"); | 766 CFX_WideString cwTitle = pDictionary->GetUnicodeTextBy("Title"); |
| 767 CFX_WideString cwSubject = pDictionary->GetUnicodeText("Subject"); | 767 CFX_WideString cwSubject = pDictionary->GetUnicodeTextBy("Subject"); |
| 768 CFX_WideString cwKeywords = pDictionary->GetUnicodeText("Keywords"); | 768 CFX_WideString cwKeywords = pDictionary->GetUnicodeTextBy("Keywords"); |
| 769 CFX_WideString cwCreator = pDictionary->GetUnicodeText("Creator"); | 769 CFX_WideString cwCreator = pDictionary->GetUnicodeTextBy("Creator"); |
| 770 CFX_WideString cwProducer = pDictionary->GetUnicodeText("Producer"); | 770 CFX_WideString cwProducer = pDictionary->GetUnicodeTextBy("Producer"); |
| 771 CFX_WideString cwCreationDate = pDictionary->GetUnicodeText("CreationDate"); | 771 CFX_WideString cwCreationDate = pDictionary->GetUnicodeTextBy("CreationDate"); |
| 772 CFX_WideString cwModDate = pDictionary->GetUnicodeText("ModDate"); | 772 CFX_WideString cwModDate = pDictionary->GetUnicodeTextBy("ModDate"); |
| 773 CFX_WideString cwTrapped = pDictionary->GetUnicodeText("Trapped"); | 773 CFX_WideString cwTrapped = pDictionary->GetUnicodeTextBy("Trapped"); |
| 774 | 774 |
| 775 v8::Isolate* isolate = GetIsolate(cc); | 775 v8::Isolate* isolate = GetIsolate(cc); |
| 776 if (vp.IsGetting()) { | 776 if (vp.IsGetting()) { |
| 777 CJS_Context* pContext = (CJS_Context*)cc; | 777 CJS_Context* pContext = (CJS_Context*)cc; |
| 778 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 778 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
| 779 v8::Local<v8::Object> pObj = | 779 v8::Local<v8::Object> pObj = |
| 780 FXJS_NewFxDynamicObj(pRuntime->GetIsolate(), pRuntime, -1); | 780 FXJS_NewFxDynamicObj(pRuntime->GetIsolate(), pRuntime, -1); |
| 781 FXJS_PutObjectString(isolate, pObj, L"Author", cwAuthor.c_str()); | 781 FXJS_PutObjectString(isolate, pObj, L"Author", cwAuthor.c_str()); |
| 782 FXJS_PutObjectString(isolate, pObj, L"Title", cwTitle.c_str()); | 782 FXJS_PutObjectString(isolate, pObj, L"Title", cwTitle.c_str()); |
| 783 FXJS_PutObjectString(isolate, pObj, L"Subject", cwSubject.c_str()); | 783 FXJS_PutObjectString(isolate, pObj, L"Subject", cwSubject.c_str()); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 812 } | 812 } |
| 813 | 813 |
| 814 FX_BOOL Document::creationDate(IJS_Context* cc, | 814 FX_BOOL Document::creationDate(IJS_Context* cc, |
| 815 CJS_PropValue& vp, | 815 CJS_PropValue& vp, |
| 816 CFX_WideString& sError) { | 816 CFX_WideString& sError) { |
| 817 CPDF_Dictionary* pDictionary = m_pDocument->GetPDFDocument()->GetInfo(); | 817 CPDF_Dictionary* pDictionary = m_pDocument->GetPDFDocument()->GetInfo(); |
| 818 if (!pDictionary) | 818 if (!pDictionary) |
| 819 return FALSE; | 819 return FALSE; |
| 820 | 820 |
| 821 if (vp.IsGetting()) { | 821 if (vp.IsGetting()) { |
| 822 vp << pDictionary->GetUnicodeText("CreationDate"); | 822 vp << pDictionary->GetUnicodeTextBy("CreationDate"); |
| 823 } else { | 823 } else { |
| 824 if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) | 824 if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) |
| 825 return FALSE; | 825 return FALSE; |
| 826 | 826 |
| 827 CFX_WideString csCreationDate; | 827 CFX_WideString csCreationDate; |
| 828 vp >> csCreationDate; | 828 vp >> csCreationDate; |
| 829 pDictionary->SetAtString("CreationDate", PDF_EncodeText(csCreationDate)); | 829 pDictionary->SetAtString("CreationDate", PDF_EncodeText(csCreationDate)); |
| 830 m_pDocument->SetChangeMark(); | 830 m_pDocument->SetChangeMark(); |
| 831 } | 831 } |
| 832 return TRUE; | 832 return TRUE; |
| 833 } | 833 } |
| 834 | 834 |
| 835 FX_BOOL Document::creator(IJS_Context* cc, | 835 FX_BOOL Document::creator(IJS_Context* cc, |
| 836 CJS_PropValue& vp, | 836 CJS_PropValue& vp, |
| 837 CFX_WideString& sError) { | 837 CFX_WideString& sError) { |
| 838 CPDF_Dictionary* pDictionary = m_pDocument->GetPDFDocument()->GetInfo(); | 838 CPDF_Dictionary* pDictionary = m_pDocument->GetPDFDocument()->GetInfo(); |
| 839 if (!pDictionary) | 839 if (!pDictionary) |
| 840 return FALSE; | 840 return FALSE; |
| 841 | 841 |
| 842 if (vp.IsGetting()) { | 842 if (vp.IsGetting()) { |
| 843 vp << pDictionary->GetUnicodeText("Creator"); | 843 vp << pDictionary->GetUnicodeTextBy("Creator"); |
| 844 } else { | 844 } else { |
| 845 if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) | 845 if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) |
| 846 return FALSE; | 846 return FALSE; |
| 847 | 847 |
| 848 CFX_WideString csCreator; | 848 CFX_WideString csCreator; |
| 849 vp >> csCreator; | 849 vp >> csCreator; |
| 850 pDictionary->SetAtString("Creator", PDF_EncodeText(csCreator)); | 850 pDictionary->SetAtString("Creator", PDF_EncodeText(csCreator)); |
| 851 m_pDocument->SetChangeMark(); | 851 m_pDocument->SetChangeMark(); |
| 852 } | 852 } |
| 853 return TRUE; | 853 return TRUE; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 889 } | 889 } |
| 890 | 890 |
| 891 FX_BOOL Document::keywords(IJS_Context* cc, | 891 FX_BOOL Document::keywords(IJS_Context* cc, |
| 892 CJS_PropValue& vp, | 892 CJS_PropValue& vp, |
| 893 CFX_WideString& sError) { | 893 CFX_WideString& sError) { |
| 894 CPDF_Dictionary* pDictionary = m_pDocument->GetPDFDocument()->GetInfo(); | 894 CPDF_Dictionary* pDictionary = m_pDocument->GetPDFDocument()->GetInfo(); |
| 895 if (!pDictionary) | 895 if (!pDictionary) |
| 896 return FALSE; | 896 return FALSE; |
| 897 | 897 |
| 898 if (vp.IsGetting()) { | 898 if (vp.IsGetting()) { |
| 899 vp << pDictionary->GetUnicodeText("Keywords"); | 899 vp << pDictionary->GetUnicodeTextBy("Keywords"); |
| 900 } else { | 900 } else { |
| 901 if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) | 901 if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) |
| 902 return FALSE; | 902 return FALSE; |
| 903 | 903 |
| 904 CFX_WideString csKeywords; | 904 CFX_WideString csKeywords; |
| 905 vp >> csKeywords; | 905 vp >> csKeywords; |
| 906 pDictionary->SetAtString("Keywords", PDF_EncodeText(csKeywords)); | 906 pDictionary->SetAtString("Keywords", PDF_EncodeText(csKeywords)); |
| 907 m_pDocument->SetChangeMark(); | 907 m_pDocument->SetChangeMark(); |
| 908 } | 908 } |
| 909 return TRUE; | 909 return TRUE; |
| 910 } | 910 } |
| 911 | 911 |
| 912 FX_BOOL Document::modDate(IJS_Context* cc, | 912 FX_BOOL Document::modDate(IJS_Context* cc, |
| 913 CJS_PropValue& vp, | 913 CJS_PropValue& vp, |
| 914 CFX_WideString& sError) { | 914 CFX_WideString& sError) { |
| 915 CPDF_Dictionary* pDictionary = m_pDocument->GetPDFDocument()->GetInfo(); | 915 CPDF_Dictionary* pDictionary = m_pDocument->GetPDFDocument()->GetInfo(); |
| 916 if (!pDictionary) | 916 if (!pDictionary) |
| 917 return FALSE; | 917 return FALSE; |
| 918 | 918 |
| 919 if (vp.IsGetting()) { | 919 if (vp.IsGetting()) { |
| 920 vp << pDictionary->GetUnicodeText("ModDate"); | 920 vp << pDictionary->GetUnicodeTextBy("ModDate"); |
| 921 } else { | 921 } else { |
| 922 if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) | 922 if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) |
| 923 return FALSE; | 923 return FALSE; |
| 924 | 924 |
| 925 CFX_WideString csmodDate; | 925 CFX_WideString csmodDate; |
| 926 vp >> csmodDate; | 926 vp >> csmodDate; |
| 927 pDictionary->SetAtString("ModDate", PDF_EncodeText(csmodDate)); | 927 pDictionary->SetAtString("ModDate", PDF_EncodeText(csmodDate)); |
| 928 m_pDocument->SetChangeMark(); | 928 m_pDocument->SetChangeMark(); |
| 929 } | 929 } |
| 930 return TRUE; | 930 return TRUE; |
| 931 } | 931 } |
| 932 | 932 |
| 933 FX_BOOL Document::producer(IJS_Context* cc, | 933 FX_BOOL Document::producer(IJS_Context* cc, |
| 934 CJS_PropValue& vp, | 934 CJS_PropValue& vp, |
| 935 CFX_WideString& sError) { | 935 CFX_WideString& sError) { |
| 936 CPDF_Dictionary* pDictionary = m_pDocument->GetPDFDocument()->GetInfo(); | 936 CPDF_Dictionary* pDictionary = m_pDocument->GetPDFDocument()->GetInfo(); |
| 937 if (!pDictionary) | 937 if (!pDictionary) |
| 938 return FALSE; | 938 return FALSE; |
| 939 | 939 |
| 940 if (vp.IsGetting()) { | 940 if (vp.IsGetting()) { |
| 941 vp << pDictionary->GetUnicodeText("Producer"); | 941 vp << pDictionary->GetUnicodeTextBy("Producer"); |
| 942 } else { | 942 } else { |
| 943 if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) | 943 if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) |
| 944 return FALSE; | 944 return FALSE; |
| 945 | 945 |
| 946 CFX_WideString csproducer; | 946 CFX_WideString csproducer; |
| 947 vp >> csproducer; | 947 vp >> csproducer; |
| 948 pDictionary->SetAtString("Producer", PDF_EncodeText(csproducer)); | 948 pDictionary->SetAtString("Producer", PDF_EncodeText(csproducer)); |
| 949 m_pDocument->SetChangeMark(); | 949 m_pDocument->SetChangeMark(); |
| 950 } | 950 } |
| 951 return TRUE; | 951 return TRUE; |
| 952 } | 952 } |
| 953 | 953 |
| 954 FX_BOOL Document::subject(IJS_Context* cc, | 954 FX_BOOL Document::subject(IJS_Context* cc, |
| 955 CJS_PropValue& vp, | 955 CJS_PropValue& vp, |
| 956 CFX_WideString& sError) { | 956 CFX_WideString& sError) { |
| 957 CPDF_Dictionary* pDictionary = m_pDocument->GetPDFDocument()->GetInfo(); | 957 CPDF_Dictionary* pDictionary = m_pDocument->GetPDFDocument()->GetInfo(); |
| 958 if (!pDictionary) | 958 if (!pDictionary) |
| 959 return FALSE; | 959 return FALSE; |
| 960 | 960 |
| 961 if (vp.IsGetting()) { | 961 if (vp.IsGetting()) { |
| 962 vp << pDictionary->GetUnicodeText("Subject"); | 962 vp << pDictionary->GetUnicodeTextBy("Subject"); |
| 963 } else { | 963 } else { |
| 964 if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) | 964 if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) |
| 965 return FALSE; | 965 return FALSE; |
| 966 | 966 |
| 967 CFX_WideString cssubject; | 967 CFX_WideString cssubject; |
| 968 vp >> cssubject; | 968 vp >> cssubject; |
| 969 pDictionary->SetAtString("Subject", PDF_EncodeText(cssubject)); | 969 pDictionary->SetAtString("Subject", PDF_EncodeText(cssubject)); |
| 970 m_pDocument->SetChangeMark(); | 970 m_pDocument->SetChangeMark(); |
| 971 } | 971 } |
| 972 return TRUE; | 972 return TRUE; |
| 973 } | 973 } |
| 974 | 974 |
| 975 FX_BOOL Document::title(IJS_Context* cc, | 975 FX_BOOL Document::title(IJS_Context* cc, |
| 976 CJS_PropValue& vp, | 976 CJS_PropValue& vp, |
| 977 CFX_WideString& sError) { | 977 CFX_WideString& sError) { |
| 978 if (!m_pDocument || !m_pDocument->GetUnderlyingDocument()) | 978 if (!m_pDocument || !m_pDocument->GetUnderlyingDocument()) |
| 979 return FALSE; | 979 return FALSE; |
| 980 | 980 |
| 981 CPDF_Dictionary* pDictionary = m_pDocument->GetPDFDocument()->GetInfo(); | 981 CPDF_Dictionary* pDictionary = m_pDocument->GetPDFDocument()->GetInfo(); |
| 982 if (!pDictionary) | 982 if (!pDictionary) |
| 983 return FALSE; | 983 return FALSE; |
| 984 | 984 |
| 985 if (vp.IsGetting()) { | 985 if (vp.IsGetting()) { |
| 986 vp << pDictionary->GetUnicodeText("Title"); | 986 vp << pDictionary->GetUnicodeTextBy("Title"); |
| 987 } else { | 987 } else { |
| 988 if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) | 988 if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) |
| 989 return FALSE; | 989 return FALSE; |
| 990 | 990 |
| 991 CFX_WideString cstitle; | 991 CFX_WideString cstitle; |
| 992 vp >> cstitle; | 992 vp >> cstitle; |
| 993 pDictionary->SetAtString("Title", PDF_EncodeText(cstitle)); | 993 pDictionary->SetAtString("Title", PDF_EncodeText(cstitle)); |
| 994 m_pDocument->SetChangeMark(); | 994 m_pDocument->SetChangeMark(); |
| 995 } | 995 } |
| 996 return TRUE; | 996 return TRUE; |
| (...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1636 CJS_DelayData* pData = DelayDataForFieldAndControlIndex.GetAt(i); | 1636 CJS_DelayData* pData = DelayDataForFieldAndControlIndex.GetAt(i); |
| 1637 Field::DoDelay(m_pDocument, pData); | 1637 Field::DoDelay(m_pDocument, pData); |
| 1638 DelayDataForFieldAndControlIndex.SetAt(i, NULL); | 1638 DelayDataForFieldAndControlIndex.SetAt(i, NULL); |
| 1639 delete pData; | 1639 delete pData; |
| 1640 } | 1640 } |
| 1641 } | 1641 } |
| 1642 | 1642 |
| 1643 CJS_Document* Document::GetCJSDoc() const { | 1643 CJS_Document* Document::GetCJSDoc() const { |
| 1644 return static_cast<CJS_Document*>(m_pJSObject); | 1644 return static_cast<CJS_Document*>(m_pJSObject); |
| 1645 } | 1645 } |
| OLD | NEW |