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 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
529 for (CPDFSDK_Widget* pWidget : widgets) { | 529 for (CPDFSDK_Widget* pWidget : widgets) { |
530 CPDF_Rect rcAnnot = pWidget->GetRect(); | 530 CPDF_Rect rcAnnot = pWidget->GetRect(); |
531 --rcAnnot.left; | 531 --rcAnnot.left; |
532 --rcAnnot.bottom; | 532 --rcAnnot.bottom; |
533 ++rcAnnot.right; | 533 ++rcAnnot.right; |
534 ++rcAnnot.top; | 534 ++rcAnnot.top; |
535 | 535 |
536 CFX_RectArray aRefresh; | 536 CFX_RectArray aRefresh; |
537 aRefresh.Add(rcAnnot); | 537 aRefresh.Add(rcAnnot); |
538 | 538 |
539 CPDFXFA_Page* pPage = pWidget->GetPDFXFAPage(); | 539 UnderlyingPageType* pPage = pWidget->GetUnderlyingPage(); |
540 ASSERT(pPage); | 540 ASSERT(pPage); |
541 | 541 |
542 CPDFSDK_PageView* pPageView = m_pDocument->GetPageView(pPage); | 542 CPDFSDK_PageView* pPageView = m_pDocument->GetPageView(pPage); |
543 pPageView->DeleteAnnot(pWidget); | 543 pPageView->DeleteAnnot(pWidget); |
544 pPageView->UpdateRects(aRefresh); | 544 pPageView->UpdateRects(aRefresh); |
545 } | 545 } |
546 m_pDocument->SetChangeMark(); | 546 m_pDocument->SetChangeMark(); |
547 | 547 |
548 return TRUE; | 548 return TRUE; |
549 } | 549 } |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
772 pEnv->JS_docmailForm(NULL, 0, bUI, cTo.c_str(), cSubject.c_str(), cCc.c_str(), | 772 pEnv->JS_docmailForm(NULL, 0, bUI, cTo.c_str(), cSubject.c_str(), cCc.c_str(), |
773 cBcc.c_str(), cMsg.c_str()); | 773 cBcc.c_str(), cMsg.c_str()); |
774 pRuntime->EndBlock(); | 774 pRuntime->EndBlock(); |
775 | 775 |
776 return TRUE; | 776 return TRUE; |
777 } | 777 } |
778 | 778 |
779 FX_BOOL Document::author(IJS_Context* cc, | 779 FX_BOOL Document::author(IJS_Context* cc, |
780 CJS_PropValue& vp, | 780 CJS_PropValue& vp, |
781 CFX_WideString& sError) { | 781 CFX_WideString& sError) { |
782 CPDF_Dictionary* pDictionary = | 782 CPDF_Dictionary* pDictionary = m_pDocument->GetPDFDocument()->GetInfo(); |
783 m_pDocument->GetDocument()->GetPDFDoc()->GetInfo(); | |
784 if (!pDictionary) | 783 if (!pDictionary) |
785 return FALSE; | 784 return FALSE; |
786 | 785 |
787 if (vp.IsGetting()) { | 786 if (vp.IsGetting()) { |
788 vp << pDictionary->GetUnicodeText("Author"); | 787 vp << pDictionary->GetUnicodeText("Author"); |
789 return TRUE; | 788 return TRUE; |
790 } else { | 789 } else { |
791 if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) | 790 if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) |
792 return FALSE; | 791 return FALSE; |
793 | 792 |
794 CFX_WideString csAuthor; | 793 CFX_WideString csAuthor; |
795 vp >> csAuthor; | 794 vp >> csAuthor; |
796 pDictionary->SetAtString("Author", PDF_EncodeText(csAuthor)); | 795 pDictionary->SetAtString("Author", PDF_EncodeText(csAuthor)); |
797 m_pDocument->SetChangeMark(); | 796 m_pDocument->SetChangeMark(); |
798 return TRUE; | 797 return TRUE; |
799 } | 798 } |
800 } | 799 } |
801 | 800 |
802 FX_BOOL Document::info(IJS_Context* cc, | 801 FX_BOOL Document::info(IJS_Context* cc, |
803 CJS_PropValue& vp, | 802 CJS_PropValue& vp, |
804 CFX_WideString& sError) { | 803 CFX_WideString& sError) { |
805 CPDF_Dictionary* pDictionary = | 804 CPDF_Dictionary* pDictionary = m_pDocument->GetPDFDocument()->GetInfo(); |
806 m_pDocument->GetDocument()->GetPDFDoc()->GetInfo(); | |
807 if (!pDictionary) | 805 if (!pDictionary) |
808 return FALSE; | 806 return FALSE; |
809 | 807 |
810 CFX_WideString cwAuthor = pDictionary->GetUnicodeText("Author"); | 808 CFX_WideString cwAuthor = pDictionary->GetUnicodeText("Author"); |
811 CFX_WideString cwTitle = pDictionary->GetUnicodeText("Title"); | 809 CFX_WideString cwTitle = pDictionary->GetUnicodeText("Title"); |
812 CFX_WideString cwSubject = pDictionary->GetUnicodeText("Subject"); | 810 CFX_WideString cwSubject = pDictionary->GetUnicodeText("Subject"); |
813 CFX_WideString cwKeywords = pDictionary->GetUnicodeText("Keywords"); | 811 CFX_WideString cwKeywords = pDictionary->GetUnicodeText("Keywords"); |
814 CFX_WideString cwCreator = pDictionary->GetUnicodeText("Creator"); | 812 CFX_WideString cwCreator = pDictionary->GetUnicodeText("Creator"); |
815 CFX_WideString cwProducer = pDictionary->GetUnicodeText("Producer"); | 813 CFX_WideString cwProducer = pDictionary->GetUnicodeText("Producer"); |
816 CFX_WideString cwCreationDate = pDictionary->GetUnicodeText("CreationDate"); | 814 CFX_WideString cwCreationDate = pDictionary->GetUnicodeText("CreationDate"); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
853 } | 851 } |
854 } | 852 } |
855 vp << pObj; | 853 vp << pObj; |
856 } | 854 } |
857 return TRUE; | 855 return TRUE; |
858 } | 856 } |
859 | 857 |
860 FX_BOOL Document::creationDate(IJS_Context* cc, | 858 FX_BOOL Document::creationDate(IJS_Context* cc, |
861 CJS_PropValue& vp, | 859 CJS_PropValue& vp, |
862 CFX_WideString& sError) { | 860 CFX_WideString& sError) { |
863 CPDF_Dictionary* pDictionary = | 861 CPDF_Dictionary* pDictionary = m_pDocument->GetPDFDocument()->GetInfo(); |
864 m_pDocument->GetDocument()->GetPDFDoc()->GetInfo(); | |
865 if (!pDictionary) | 862 if (!pDictionary) |
866 return FALSE; | 863 return FALSE; |
867 | 864 |
868 if (vp.IsGetting()) { | 865 if (vp.IsGetting()) { |
869 vp << pDictionary->GetUnicodeText("CreationDate"); | 866 vp << pDictionary->GetUnicodeText("CreationDate"); |
870 } else { | 867 } else { |
871 if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) | 868 if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) |
872 return FALSE; | 869 return FALSE; |
873 | 870 |
874 CFX_WideString csCreationDate; | 871 CFX_WideString csCreationDate; |
875 vp >> csCreationDate; | 872 vp >> csCreationDate; |
876 pDictionary->SetAtString("CreationDate", PDF_EncodeText(csCreationDate)); | 873 pDictionary->SetAtString("CreationDate", PDF_EncodeText(csCreationDate)); |
877 m_pDocument->SetChangeMark(); | 874 m_pDocument->SetChangeMark(); |
878 } | 875 } |
879 return TRUE; | 876 return TRUE; |
880 } | 877 } |
881 | 878 |
882 FX_BOOL Document::creator(IJS_Context* cc, | 879 FX_BOOL Document::creator(IJS_Context* cc, |
883 CJS_PropValue& vp, | 880 CJS_PropValue& vp, |
884 CFX_WideString& sError) { | 881 CFX_WideString& sError) { |
885 CPDF_Dictionary* pDictionary = | 882 CPDF_Dictionary* pDictionary = m_pDocument->GetPDFDocument()->GetInfo(); |
886 m_pDocument->GetDocument()->GetPDFDoc()->GetInfo(); | |
887 if (!pDictionary) | 883 if (!pDictionary) |
888 return FALSE; | 884 return FALSE; |
889 | 885 |
890 if (vp.IsGetting()) { | 886 if (vp.IsGetting()) { |
891 vp << pDictionary->GetUnicodeText("Creator"); | 887 vp << pDictionary->GetUnicodeText("Creator"); |
892 } else { | 888 } else { |
893 if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) | 889 if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) |
894 return FALSE; | 890 return FALSE; |
895 | 891 |
896 CFX_WideString csCreator; | 892 CFX_WideString csCreator; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
932 delete pData; | 928 delete pData; |
933 } | 929 } |
934 } | 930 } |
935 } | 931 } |
936 return TRUE; | 932 return TRUE; |
937 } | 933 } |
938 | 934 |
939 FX_BOOL Document::keywords(IJS_Context* cc, | 935 FX_BOOL Document::keywords(IJS_Context* cc, |
940 CJS_PropValue& vp, | 936 CJS_PropValue& vp, |
941 CFX_WideString& sError) { | 937 CFX_WideString& sError) { |
942 CPDF_Dictionary* pDictionary = | 938 CPDF_Dictionary* pDictionary = m_pDocument->GetPDFDocument()->GetInfo(); |
943 m_pDocument->GetDocument()->GetPDFDoc()->GetInfo(); | |
944 if (!pDictionary) | 939 if (!pDictionary) |
945 return FALSE; | 940 return FALSE; |
946 | 941 |
947 if (vp.IsGetting()) { | 942 if (vp.IsGetting()) { |
948 vp << pDictionary->GetUnicodeText("Keywords"); | 943 vp << pDictionary->GetUnicodeText("Keywords"); |
949 } else { | 944 } else { |
950 if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) | 945 if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) |
951 return FALSE; | 946 return FALSE; |
952 | 947 |
953 CFX_WideString csKeywords; | 948 CFX_WideString csKeywords; |
954 vp >> csKeywords; | 949 vp >> csKeywords; |
955 pDictionary->SetAtString("Keywords", PDF_EncodeText(csKeywords)); | 950 pDictionary->SetAtString("Keywords", PDF_EncodeText(csKeywords)); |
956 m_pDocument->SetChangeMark(); | 951 m_pDocument->SetChangeMark(); |
957 } | 952 } |
958 return TRUE; | 953 return TRUE; |
959 } | 954 } |
960 | 955 |
961 FX_BOOL Document::modDate(IJS_Context* cc, | 956 FX_BOOL Document::modDate(IJS_Context* cc, |
962 CJS_PropValue& vp, | 957 CJS_PropValue& vp, |
963 CFX_WideString& sError) { | 958 CFX_WideString& sError) { |
964 CPDF_Dictionary* pDictionary = | 959 CPDF_Dictionary* pDictionary = m_pDocument->GetPDFDocument()->GetInfo(); |
965 m_pDocument->GetDocument()->GetPDFDoc()->GetInfo(); | |
966 if (!pDictionary) | 960 if (!pDictionary) |
967 return FALSE; | 961 return FALSE; |
968 | 962 |
969 if (vp.IsGetting()) { | 963 if (vp.IsGetting()) { |
970 vp << pDictionary->GetUnicodeText("ModDate"); | 964 vp << pDictionary->GetUnicodeText("ModDate"); |
971 } else { | 965 } else { |
972 if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) | 966 if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) |
973 return FALSE; | 967 return FALSE; |
974 | 968 |
975 CFX_WideString csmodDate; | 969 CFX_WideString csmodDate; |
976 vp >> csmodDate; | 970 vp >> csmodDate; |
977 pDictionary->SetAtString("ModDate", PDF_EncodeText(csmodDate)); | 971 pDictionary->SetAtString("ModDate", PDF_EncodeText(csmodDate)); |
978 m_pDocument->SetChangeMark(); | 972 m_pDocument->SetChangeMark(); |
979 } | 973 } |
980 return TRUE; | 974 return TRUE; |
981 } | 975 } |
982 | 976 |
983 FX_BOOL Document::producer(IJS_Context* cc, | 977 FX_BOOL Document::producer(IJS_Context* cc, |
984 CJS_PropValue& vp, | 978 CJS_PropValue& vp, |
985 CFX_WideString& sError) { | 979 CFX_WideString& sError) { |
986 CPDF_Dictionary* pDictionary = | 980 CPDF_Dictionary* pDictionary = m_pDocument->GetPDFDocument()->GetInfo(); |
987 m_pDocument->GetDocument()->GetPDFDoc()->GetInfo(); | |
988 if (!pDictionary) | 981 if (!pDictionary) |
989 return FALSE; | 982 return FALSE; |
990 | 983 |
991 if (vp.IsGetting()) { | 984 if (vp.IsGetting()) { |
992 vp << pDictionary->GetUnicodeText("Producer"); | 985 vp << pDictionary->GetUnicodeText("Producer"); |
993 } else { | 986 } else { |
994 if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) | 987 if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) |
995 return FALSE; | 988 return FALSE; |
996 | 989 |
997 CFX_WideString csproducer; | 990 CFX_WideString csproducer; |
998 vp >> csproducer; | 991 vp >> csproducer; |
999 pDictionary->SetAtString("Producer", PDF_EncodeText(csproducer)); | 992 pDictionary->SetAtString("Producer", PDF_EncodeText(csproducer)); |
1000 m_pDocument->SetChangeMark(); | 993 m_pDocument->SetChangeMark(); |
1001 } | 994 } |
1002 return TRUE; | 995 return TRUE; |
1003 } | 996 } |
1004 | 997 |
1005 FX_BOOL Document::subject(IJS_Context* cc, | 998 FX_BOOL Document::subject(IJS_Context* cc, |
1006 CJS_PropValue& vp, | 999 CJS_PropValue& vp, |
1007 CFX_WideString& sError) { | 1000 CFX_WideString& sError) { |
1008 CPDF_Dictionary* pDictionary = | 1001 CPDF_Dictionary* pDictionary = m_pDocument->GetPDFDocument()->GetInfo(); |
1009 m_pDocument->GetDocument()->GetPDFDoc()->GetInfo(); | |
1010 if (!pDictionary) | 1002 if (!pDictionary) |
1011 return FALSE; | 1003 return FALSE; |
1012 | 1004 |
1013 if (vp.IsGetting()) { | 1005 if (vp.IsGetting()) { |
1014 vp << pDictionary->GetUnicodeText("Subject"); | 1006 vp << pDictionary->GetUnicodeText("Subject"); |
1015 } else { | 1007 } else { |
1016 if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) | 1008 if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) |
1017 return FALSE; | 1009 return FALSE; |
1018 | 1010 |
1019 CFX_WideString cssubject; | 1011 CFX_WideString cssubject; |
1020 vp >> cssubject; | 1012 vp >> cssubject; |
1021 pDictionary->SetAtString("Subject", PDF_EncodeText(cssubject)); | 1013 pDictionary->SetAtString("Subject", PDF_EncodeText(cssubject)); |
1022 m_pDocument->SetChangeMark(); | 1014 m_pDocument->SetChangeMark(); |
1023 } | 1015 } |
1024 return TRUE; | 1016 return TRUE; |
1025 } | 1017 } |
1026 | 1018 |
1027 FX_BOOL Document::title(IJS_Context* cc, | 1019 FX_BOOL Document::title(IJS_Context* cc, |
1028 CJS_PropValue& vp, | 1020 CJS_PropValue& vp, |
1029 CFX_WideString& sError) { | 1021 CFX_WideString& sError) { |
1030 if (m_pDocument == NULL || m_pDocument->GetDocument() == NULL) | 1022 if (!m_pDocument || !m_pDocument->GetUnderlyingDocument()) |
1031 return FALSE; | 1023 return FALSE; |
1032 | 1024 |
1033 CPDF_Dictionary* pDictionary = | 1025 CPDF_Dictionary* pDictionary = m_pDocument->GetPDFDocument()->GetInfo(); |
1034 m_pDocument->GetDocument()->GetPDFDoc()->GetInfo(); | |
1035 if (!pDictionary) | 1026 if (!pDictionary) |
1036 return FALSE; | 1027 return FALSE; |
1037 | 1028 |
1038 if (vp.IsGetting()) { | 1029 if (vp.IsGetting()) { |
1039 vp << pDictionary->GetUnicodeText("Title"); | 1030 vp << pDictionary->GetUnicodeText("Title"); |
1040 } else { | 1031 } else { |
1041 if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) | 1032 if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) |
1042 return FALSE; | 1033 return FALSE; |
1043 | 1034 |
1044 CFX_WideString cstitle; | 1035 CFX_WideString cstitle; |
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1514 CFX_WideString& sError) { | 1505 CFX_WideString& sError) { |
1515 ASSERT(m_pDocument != NULL); | 1506 ASSERT(m_pDocument != NULL); |
1516 | 1507 |
1517 if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) | 1508 if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) |
1518 return FALSE; | 1509 return FALSE; |
1519 | 1510 |
1520 int nPageNo = params.size() > 0 ? params[0].ToInt() : 0; | 1511 int nPageNo = params.size() > 0 ? params[0].ToInt() : 0; |
1521 int nWordNo = params.size() > 1 ? params[1].ToInt() : 0; | 1512 int nWordNo = params.size() > 1 ? params[1].ToInt() : 0; |
1522 bool bStrip = params.size() > 2 ? params[2].ToBool() : true; | 1513 bool bStrip = params.size() > 2 ? params[2].ToBool() : true; |
1523 | 1514 |
1524 CPDF_Document* pDocument = m_pDocument->GetDocument()->GetPDFDoc(); | 1515 CPDF_Document* pDocument = m_pDocument->GetPDFDocument(); |
1525 if (!pDocument) | 1516 if (!pDocument) |
1526 return FALSE; | 1517 return FALSE; |
1527 | 1518 |
1528 CJS_Context* pContext = static_cast<CJS_Context*>(cc); | 1519 CJS_Context* pContext = static_cast<CJS_Context*>(cc); |
1529 if (nPageNo < 0 || nPageNo >= pDocument->GetPageCount()) { | 1520 if (nPageNo < 0 || nPageNo >= pDocument->GetPageCount()) { |
1530 sError = JSGetStringFromID(pContext, IDS_STRING_JSVALUEERROR); | 1521 sError = JSGetStringFromID(pContext, IDS_STRING_JSVALUEERROR); |
1531 return FALSE; | 1522 return FALSE; |
1532 } | 1523 } |
1533 | 1524 |
1534 CPDF_Dictionary* pPageDict = pDocument->GetPage(nPageNo); | 1525 CPDF_Dictionary* pPageDict = pDocument->GetPage(nPageNo); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1586 const std::vector<CJS_Value>& params, | 1577 const std::vector<CJS_Value>& params, |
1587 CJS_Value& vRet, | 1578 CJS_Value& vRet, |
1588 CFX_WideString& sError) { | 1579 CFX_WideString& sError) { |
1589 ASSERT(m_pDocument != NULL); | 1580 ASSERT(m_pDocument != NULL); |
1590 | 1581 |
1591 if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) | 1582 if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) |
1592 return FALSE; | 1583 return FALSE; |
1593 | 1584 |
1594 int nPageNo = params.size() > 0 ? params[0].ToInt() : 0; | 1585 int nPageNo = params.size() > 0 ? params[0].ToInt() : 0; |
1595 | 1586 |
1596 CPDF_Document* pDocument = m_pDocument->GetDocument()->GetPDFDoc(); | 1587 CPDF_Document* pDocument = m_pDocument->GetPDFDocument(); |
1597 ASSERT(pDocument != NULL); | 1588 ASSERT(pDocument != NULL); |
1598 | 1589 |
1599 CJS_Context* pContext = static_cast<CJS_Context*>(cc); | 1590 CJS_Context* pContext = static_cast<CJS_Context*>(cc); |
1600 if (nPageNo < 0 || nPageNo >= pDocument->GetPageCount()) { | 1591 if (nPageNo < 0 || nPageNo >= pDocument->GetPageCount()) { |
1601 sError = JSGetStringFromID(pContext, IDS_STRING_JSVALUEERROR); | 1592 sError = JSGetStringFromID(pContext, IDS_STRING_JSVALUEERROR); |
1602 return FALSE; | 1593 return FALSE; |
1603 } | 1594 } |
1604 | 1595 |
1605 CPDF_Dictionary* pPageDict = pDocument->GetPage(nPageNo); | 1596 CPDF_Dictionary* pPageDict = pDocument->GetPage(nPageNo); |
1606 if (!pPageDict) | 1597 if (!pPageDict) |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1821 CFX_DWordArray DelArray; | 1812 CFX_DWordArray DelArray; |
1822 | 1813 |
1823 for (int j = DelArray.GetSize() - 1; j >= 0; j--) { | 1814 for (int j = DelArray.GetSize() - 1; j >= 0; j--) { |
1824 m_DelayData.RemoveAt(DelArray[j]); | 1815 m_DelayData.RemoveAt(DelArray[j]); |
1825 } | 1816 } |
1826 } | 1817 } |
1827 | 1818 |
1828 CJS_Document* Document::GetCJSDoc() const { | 1819 CJS_Document* Document::GetCJSDoc() const { |
1829 return static_cast<CJS_Document*>(m_pJSObject); | 1820 return static_cast<CJS_Document*>(m_pJSObject); |
1830 } | 1821 } |
OLD | NEW |