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/fsdk_define.h" | 7 #include "../include/fsdk_define.h" |
8 #include "../include/fsdk_mgr.h" | 8 #include "../include/fsdk_mgr.h" |
9 #include "../include/fsdk_baseannot.h" | 9 #include "../include/fsdk_baseannot.h" |
10 | 10 |
(...skipping 762 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
773 //border | 773 //border |
774 void CPDFSDK_Annot::SetBorderWidth(int nWidth) | 774 void CPDFSDK_Annot::SetBorderWidth(int nWidth) |
775 { | 775 { |
776 ASSERT(m_pAnnot != NULL); | 776 ASSERT(m_pAnnot != NULL); |
777 ASSERT(m_pAnnot->m_pAnnotDict != NULL); | 777 ASSERT(m_pAnnot->m_pAnnotDict != NULL); |
778 | 778 |
779 CPDF_Array* pBorder = m_pAnnot->m_pAnnotDict->GetArray("Border"); | 779 CPDF_Array* pBorder = m_pAnnot->m_pAnnotDict->GetArray("Border"); |
780 | 780 |
781 if (pBorder) | 781 if (pBorder) |
782 { | 782 { |
783 » » pBorder->SetAt(2, FX_NEW CPDF_Number(nWidth)); | 783 » » pBorder->SetAt(2, new CPDF_Number(nWidth)); |
784 } | 784 } |
785 else | 785 else |
786 { | 786 { |
787 CPDF_Dictionary* pBSDict = m_pAnnot->m_pAnnotDict->GetDict("BS")
; | 787 CPDF_Dictionary* pBSDict = m_pAnnot->m_pAnnotDict->GetDict("BS")
; |
788 | 788 |
789 if (!pBSDict) | 789 if (!pBSDict) |
790 { | 790 { |
791 » » » pBSDict = FX_NEW CPDF_Dictionary; | 791 » » » pBSDict = new CPDF_Dictionary; |
792 m_pAnnot->m_pAnnotDict->SetAt("BS", pBSDict); | 792 m_pAnnot->m_pAnnotDict->SetAt("BS", pBSDict); |
793 } | 793 } |
794 | 794 |
795 pBSDict->SetAtInteger("W", nWidth); | 795 pBSDict->SetAtInteger("W", nWidth); |
796 } | 796 } |
797 } | 797 } |
798 | 798 |
799 int CPDFSDK_Annot::GetBorderWidth() const | 799 int CPDFSDK_Annot::GetBorderWidth() const |
800 { | 800 { |
801 ASSERT(m_pAnnot != NULL); | 801 ASSERT(m_pAnnot != NULL); |
(...skipping 18 matching lines...) Expand all Loading... |
820 } | 820 } |
821 | 821 |
822 void CPDFSDK_Annot::SetBorderStyle(int nStyle) | 822 void CPDFSDK_Annot::SetBorderStyle(int nStyle) |
823 { | 823 { |
824 ASSERT(m_pAnnot != NULL); | 824 ASSERT(m_pAnnot != NULL); |
825 ASSERT(m_pAnnot->m_pAnnotDict != NULL); | 825 ASSERT(m_pAnnot->m_pAnnotDict != NULL); |
826 | 826 |
827 CPDF_Dictionary* pBSDict = m_pAnnot->m_pAnnotDict->GetDict("BS"); | 827 CPDF_Dictionary* pBSDict = m_pAnnot->m_pAnnotDict->GetDict("BS"); |
828 if (!pBSDict) | 828 if (!pBSDict) |
829 { | 829 { |
830 » » pBSDict = FX_NEW CPDF_Dictionary; | 830 » » pBSDict = new CPDF_Dictionary; |
831 m_pAnnot->m_pAnnotDict->SetAt("BS", pBSDict); | 831 m_pAnnot->m_pAnnotDict->SetAt("BS", pBSDict); |
832 } | 832 } |
833 | 833 |
834 switch (nStyle) | 834 switch (nStyle) |
835 { | 835 { |
836 case BBS_SOLID: | 836 case BBS_SOLID: |
837 pBSDict->SetAtName("S", "S"); | 837 pBSDict->SetAtName("S", "S"); |
838 break; | 838 break; |
839 case BBS_DASH: | 839 case BBS_DASH: |
840 pBSDict->SetAtName("S", "D"); | 840 pBSDict->SetAtName("S", "D"); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
882 } | 882 } |
883 | 883 |
884 void CPDFSDK_Annot::SetBorderDash(const CFX_IntArray& array) | 884 void CPDFSDK_Annot::SetBorderDash(const CFX_IntArray& array) |
885 { | 885 { |
886 ASSERT(m_pAnnot != NULL); | 886 ASSERT(m_pAnnot != NULL); |
887 ASSERT(m_pAnnot->m_pAnnotDict != NULL); | 887 ASSERT(m_pAnnot->m_pAnnotDict != NULL); |
888 | 888 |
889 CPDF_Dictionary* pBSDict = m_pAnnot->m_pAnnotDict->GetDict("BS"); | 889 CPDF_Dictionary* pBSDict = m_pAnnot->m_pAnnotDict->GetDict("BS"); |
890 if (!pBSDict) | 890 if (!pBSDict) |
891 { | 891 { |
892 » » pBSDict = FX_NEW CPDF_Dictionary; | 892 » » pBSDict = new CPDF_Dictionary; |
893 m_pAnnot->m_pAnnotDict->SetAt("BS", pBSDict); | 893 m_pAnnot->m_pAnnotDict->SetAt("BS", pBSDict); |
894 } | 894 } |
895 | 895 |
896 » CPDF_Array* pArray = FX_NEW CPDF_Array; | 896 » CPDF_Array* pArray = new CPDF_Array; |
897 for (int i=0,sz=array.GetSize(); i<sz; i++) | 897 for (int i=0,sz=array.GetSize(); i<sz; i++) |
898 { | 898 { |
899 pArray->AddInteger(array[i]); | 899 pArray->AddInteger(array[i]); |
900 } | 900 } |
901 | 901 |
902 pBSDict->SetAt("D", pArray); | 902 pBSDict->SetAt("D", pArray); |
903 } | 903 } |
904 | 904 |
905 void CPDFSDK_Annot::GetBorderDash(CFX_IntArray& array) const | 905 void CPDFSDK_Annot::GetBorderDash(CFX_IntArray& array) const |
906 { | 906 { |
(...skipping 23 matching lines...) Expand all Loading... |
930 array.Add(pDash->GetInteger(i)); | 930 array.Add(pDash->GetInteger(i)); |
931 } | 931 } |
932 } | 932 } |
933 } | 933 } |
934 | 934 |
935 void CPDFSDK_Annot::SetColor(FX_COLORREF color) | 935 void CPDFSDK_Annot::SetColor(FX_COLORREF color) |
936 { | 936 { |
937 ASSERT(m_pAnnot != NULL); | 937 ASSERT(m_pAnnot != NULL); |
938 ASSERT(m_pAnnot->m_pAnnotDict != NULL); | 938 ASSERT(m_pAnnot->m_pAnnotDict != NULL); |
939 | 939 |
940 » CPDF_Array* pArray = FX_NEW CPDF_Array; | 940 » CPDF_Array* pArray = new CPDF_Array; |
941 pArray->AddNumber((FX_FLOAT)FXSYS_GetRValue(color) / 255.0f); | 941 pArray->AddNumber((FX_FLOAT)FXSYS_GetRValue(color) / 255.0f); |
942 pArray->AddNumber((FX_FLOAT)FXSYS_GetGValue(color) / 255.0f); | 942 pArray->AddNumber((FX_FLOAT)FXSYS_GetGValue(color) / 255.0f); |
943 pArray->AddNumber((FX_FLOAT)FXSYS_GetBValue(color) / 255.0f); | 943 pArray->AddNumber((FX_FLOAT)FXSYS_GetBValue(color) / 255.0f); |
944 m_pAnnot->m_pAnnotDict->SetAt("C", pArray); | 944 m_pAnnot->m_pAnnotDict->SetAt("C", pArray); |
945 } | 945 } |
946 | 946 |
947 void CPDFSDK_Annot::RemoveColor() | 947 void CPDFSDK_Annot::RemoveColor() |
948 { | 948 { |
949 ASSERT(m_pAnnot != NULL); | 949 ASSERT(m_pAnnot != NULL); |
950 ASSERT(m_pAnnot->m_pAnnotDict != NULL); | 950 ASSERT(m_pAnnot->m_pAnnotDict != NULL); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1003 const CPDF_Matri
x& matrix, const CFX_ByteString& sContents, | 1003 const CPDF_Matri
x& matrix, const CFX_ByteString& sContents, |
1004 const CFX_ByteSt
ring& sAPState) | 1004 const CFX_ByteSt
ring& sAPState) |
1005 { | 1005 { |
1006 ASSERT(m_pAnnot != NULL); | 1006 ASSERT(m_pAnnot != NULL); |
1007 ASSERT(m_pAnnot->m_pAnnotDict != NULL); | 1007 ASSERT(m_pAnnot->m_pAnnotDict != NULL); |
1008 | 1008 |
1009 CPDF_Dictionary* pAPDict = m_pAnnot->m_pAnnotDict->GetDict("AP"); | 1009 CPDF_Dictionary* pAPDict = m_pAnnot->m_pAnnotDict->GetDict("AP"); |
1010 | 1010 |
1011 if (!pAPDict) | 1011 if (!pAPDict) |
1012 { | 1012 { |
1013 » » pAPDict = FX_NEW CPDF_Dictionary; | 1013 » » pAPDict = new CPDF_Dictionary; |
1014 m_pAnnot->m_pAnnotDict->SetAt("AP", pAPDict); | 1014 m_pAnnot->m_pAnnotDict->SetAt("AP", pAPDict); |
1015 } | 1015 } |
1016 | 1016 |
1017 CPDF_Stream* pStream = NULL; | 1017 CPDF_Stream* pStream = NULL; |
1018 CPDF_Dictionary* pParentDict = NULL; | 1018 CPDF_Dictionary* pParentDict = NULL; |
1019 | 1019 |
1020 if (sAPState.IsEmpty()) | 1020 if (sAPState.IsEmpty()) |
1021 { | 1021 { |
1022 pParentDict = pAPDict; | 1022 pParentDict = pAPDict; |
1023 pStream = pAPDict->GetStream(sAPType); | 1023 pStream = pAPDict->GetStream(sAPType); |
1024 } | 1024 } |
1025 else | 1025 else |
1026 { | 1026 { |
1027 CPDF_Dictionary* pAPTypeDict = pAPDict->GetDict(sAPType); | 1027 CPDF_Dictionary* pAPTypeDict = pAPDict->GetDict(sAPType); |
1028 if (!pAPTypeDict) | 1028 if (!pAPTypeDict) |
1029 { | 1029 { |
1030 » » » pAPTypeDict = FX_NEW CPDF_Dictionary; | 1030 » » » pAPTypeDict = new CPDF_Dictionary; |
1031 pAPDict->SetAt(sAPType, pAPTypeDict); | 1031 pAPDict->SetAt(sAPType, pAPTypeDict); |
1032 } | 1032 } |
1033 | 1033 |
1034 pParentDict = pAPTypeDict; | 1034 pParentDict = pAPTypeDict; |
1035 pStream = pAPTypeDict->GetStream(sAPState); | 1035 pStream = pAPTypeDict->GetStream(sAPState); |
1036 } | 1036 } |
1037 | 1037 |
1038 » if (!pStream) | 1038 » if (!pStream) |
1039 { | 1039 { |
1040 ASSERT(m_pPageView != NULL); | |
1041 CPDF_Document* pDoc = m_pPageView->GetPDFDocument(); | 1040 CPDF_Document* pDoc = m_pPageView->GetPDFDocument(); |
1042 » » ASSERT(pDoc != NULL); | 1041 » » pStream = new CPDF_Stream(NULL, 0, NULL); |
1043 » » | |
1044 » » pStream = FX_NEW CPDF_Stream(NULL, 0, NULL); | |
1045 FX_INT32 objnum = pDoc->AddIndirectObject(pStream); | 1042 FX_INT32 objnum = pDoc->AddIndirectObject(pStream); |
1046 //pAPDict->SetAtReference(sAPType, pDoc, objnum); | |
1047 ASSERT(pParentDict != NULL); | |
1048 pParentDict->SetAtReference(sAPType, pDoc, objnum); | 1043 pParentDict->SetAtReference(sAPType, pDoc, objnum); |
1049 } | 1044 } |
1050 » | 1045 |
1051 » CPDF_Dictionary * pStreamDict = pStream->GetDict(); | 1046 » CPDF_Dictionary *pStreamDict = pStream->GetDict(); |
1052 » | |
1053 if (!pStreamDict) | 1047 if (!pStreamDict) |
1054 { | 1048 { |
1055 » » pStreamDict = FX_NEW CPDF_Dictionary; | 1049 » » pStreamDict = new CPDF_Dictionary; |
1056 pStreamDict->SetAtName("Type", "XObject"); | 1050 pStreamDict->SetAtName("Type", "XObject"); |
1057 pStreamDict->SetAtName("Subtype", "Form"); | 1051 pStreamDict->SetAtName("Subtype", "Form"); |
1058 pStreamDict->SetAtInteger("FormType", 1); | 1052 pStreamDict->SetAtInteger("FormType", 1); |
1059 pStream->InitStream(NULL,0,pStreamDict); | 1053 pStream->InitStream(NULL,0,pStreamDict); |
1060 } | 1054 } |
1061 | 1055 |
1062 if (pStreamDict) | 1056 if (pStreamDict) |
1063 { | 1057 { |
1064 pStreamDict->SetAtMatrix("Matrix",matrix); | 1058 pStreamDict->SetAtMatrix("Matrix",matrix); |
1065 pStreamDict->SetAtRect("BBox", rcBBox); | 1059 pStreamDict->SetAtRect("BBox", rcBBox); |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1160 return ; | 1154 return ; |
1161 } | 1155 } |
1162 | 1156 |
1163 CPDF_Page* CPDFSDK_Annot::GetPDFPage() | 1157 CPDF_Page* CPDFSDK_Annot::GetPDFPage() |
1164 { | 1158 { |
1165 if(m_pPageView) | 1159 if(m_pPageView) |
1166 return m_pPageView->GetPDFPage(); | 1160 return m_pPageView->GetPDFPage(); |
1167 return NULL; | 1161 return NULL; |
1168 } | 1162 } |
1169 | 1163 |
OLD | NEW |