OLD | NEW |
---|---|
1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 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 "core/fpdfdoc/cpvt_generateap.h" | 7 #include "core/fpdfdoc/cpvt_generateap.h" |
8 | 8 |
9 #include "core/fpdfapi/fpdf_font/include/cpdf_font.h" | 9 #include "core/fpdfapi/fpdf_font/include/cpdf_font.h" |
10 #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" | 10 #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" |
(...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
589 if (pResourceFontDict) | 589 if (pResourceFontDict) |
590 pResourceDict->SetAt("Font", pResourceFontDict); | 590 pResourceDict->SetAt("Font", pResourceFontDict); |
591 | 591 |
592 return pResourceDict; | 592 return pResourceDict; |
593 } | 593 } |
594 | 594 |
595 // Takes ownership of |pResourceDict|. | 595 // Takes ownership of |pResourceDict|. |
596 void GenerateAndSetAPDict(CPDF_Document* pDoc, | 596 void GenerateAndSetAPDict(CPDF_Document* pDoc, |
597 CPDF_Dictionary* pAnnotDict, | 597 CPDF_Dictionary* pAnnotDict, |
598 const CFX_ByteTextBuf& sAppStream, | 598 const CFX_ByteTextBuf& sAppStream, |
599 CPDF_Dictionary* pResourceDict) { | 599 CPDF_Dictionary* pResourceDict, |
600 bool bIsTextAnnotation) { | |
jaepark
2016/09/07 17:30:09
bIsTextMarkupAnnotation.
In PDF annotation, there
tonikitoo
2016/09/08 04:10:35
Done.
| |
600 CPDF_Dictionary* pAPDict = new CPDF_Dictionary; | 601 CPDF_Dictionary* pAPDict = new CPDF_Dictionary; |
601 pAnnotDict->SetAt("AP", pAPDict); | 602 pAnnotDict->SetAt("AP", pAPDict); |
602 | 603 |
603 CPDF_Stream* pNormalStream = new CPDF_Stream(nullptr, 0, nullptr); | 604 CPDF_Stream* pNormalStream = new CPDF_Stream(nullptr, 0, nullptr); |
604 int32_t objnum = pDoc->AddIndirectObject(pNormalStream); | 605 int32_t objnum = pDoc->AddIndirectObject(pNormalStream); |
605 pAnnotDict->GetDictBy("AP")->SetAtReference("N", pDoc, objnum); | 606 pAnnotDict->GetDictBy("AP")->SetAtReference("N", pDoc, objnum); |
606 | 607 |
607 pNormalStream->SetData(sAppStream.GetBuffer(), sAppStream.GetSize(), FALSE, | 608 pNormalStream->SetData(sAppStream.GetBuffer(), sAppStream.GetSize(), FALSE, |
608 FALSE); | 609 FALSE); |
609 | 610 |
610 CPDF_Dictionary* pStreamDict = pNormalStream->GetDict(); | 611 CPDF_Dictionary* pStreamDict = pNormalStream->GetDict(); |
611 pStreamDict->SetAtInteger("FormType", 1); | 612 pStreamDict->SetAtInteger("FormType", 1); |
612 pStreamDict->SetAtString("Subtype", "Form"); | 613 pStreamDict->SetAtString("Subtype", "Form"); |
613 pStreamDict->SetAtMatrix("Matrix", CFX_Matrix()); | 614 pStreamDict->SetAtMatrix("Matrix", CFX_Matrix()); |
614 | 615 |
615 CFX_FloatRect rect = pAnnotDict->GetRectBy("Rect"); | 616 CFX_FloatRect rect = bIsTextAnnotation ? CPDF_Annot::RectFromQuads(pAnnotDict) |
617 : pAnnotDict->GetRectBy("Rect"); | |
jaepark
2016/09/07 17:30:09
It seems like this and RectForDrawing is basically
tonikitoo
2016/09/08 04:10:35
Good point. Ideally yes, we could use RectForDrawi
| |
616 pStreamDict->SetAtRect("BBox", rect); | 618 pStreamDict->SetAtRect("BBox", rect); |
617 | 619 |
618 pStreamDict->SetAt("Resources", pResourceDict); | 620 pStreamDict->SetAt("Resources", pResourceDict); |
619 } | 621 } |
620 | 622 |
621 CFX_ByteString GetPaintOperatorString(bool bIsStrokeRect, bool bIsFillRect) { | 623 CFX_ByteString GetPaintOperatorString(bool bIsStrokeRect, bool bIsFillRect) { |
622 if (bIsStrokeRect) | 624 if (bIsStrokeRect) |
623 return bIsFillRect ? "b" : "s"; | 625 return bIsFillRect ? "b" : "s"; |
624 return bIsFillRect ? "f" : "n"; | 626 return bIsFillRect ? "f" : "n"; |
625 } | 627 } |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
786 << fMiddleX - fDeltaX << " " << rect.top << " " << fMiddleX << " " | 788 << fMiddleX - fDeltaX << " " << rect.top << " " << fMiddleX << " " |
787 << rect.top << " c\n"; | 789 << rect.top << " c\n"; |
788 | 790 |
789 bool bIsFillRect = pInteriorColor && !pInteriorColor->IsEmpty(); | 791 bool bIsFillRect = pInteriorColor && !pInteriorColor->IsEmpty(); |
790 sAppStream << GetPaintOperatorString(bIsStrokeRect, bIsFillRect) << "\n"; | 792 sAppStream << GetPaintOperatorString(bIsStrokeRect, bIsFillRect) << "\n"; |
791 | 793 |
792 CPDF_Dictionary* pExtGStateDict = | 794 CPDF_Dictionary* pExtGStateDict = |
793 GenerateExtGStateDict(*pAnnotDict, sExtGSDictName, "Normal"); | 795 GenerateExtGStateDict(*pAnnotDict, sExtGSDictName, "Normal"); |
794 CPDF_Dictionary* pResourceDict = | 796 CPDF_Dictionary* pResourceDict = |
795 GenerateResourceDict(pExtGStateDict, nullptr); | 797 GenerateResourceDict(pExtGStateDict, nullptr); |
796 GenerateAndSetAPDict(pDoc, pAnnotDict, sAppStream, pResourceDict); | 798 GenerateAndSetAPDict(pDoc, pAnnotDict, sAppStream, pResourceDict, |
799 false /*IsTextMarkupAnnotation*/); | |
797 return true; | 800 return true; |
798 } | 801 } |
799 | 802 |
800 bool CPVT_GenerateAP::GenerateHighlightAP(CPDF_Document* pDoc, | 803 bool CPVT_GenerateAP::GenerateHighlightAP(CPDF_Document* pDoc, |
801 CPDF_Dictionary* pAnnotDict) { | 804 CPDF_Dictionary* pAnnotDict) { |
802 CFX_ByteTextBuf sAppStream; | 805 CFX_ByteTextBuf sAppStream; |
803 CFX_ByteString sExtGSDictName = "GS"; | 806 CFX_ByteString sExtGSDictName = "GS"; |
804 sAppStream << "/" << sExtGSDictName << " gs "; | 807 sAppStream << "/" << sExtGSDictName << " gs "; |
805 | 808 |
806 sAppStream << GetColorStringWithDefault(pAnnotDict->GetArrayBy("C"), | 809 sAppStream << GetColorStringWithDefault(pAnnotDict->GetArrayBy("C"), |
807 CPVT_Color(CPVT_Color::kRGB, 1, 1, 0), | 810 CPVT_Color(CPVT_Color::kRGB, 1, 1, 0), |
808 PaintOperation::FILL); | 811 PaintOperation::FILL); |
809 | 812 |
810 CFX_FloatRect rect = pAnnotDict->GetRectBy("Rect"); | 813 CFX_FloatRect rect = CPDF_Annot::RectFromQuads(pAnnotDict); |
811 rect.Normalize(); | 814 rect.Normalize(); |
812 | 815 |
813 sAppStream << rect.left << " " << rect.top << " m " << rect.right << " " | 816 sAppStream << rect.left << " " << rect.top << " m " << rect.right << " " |
814 << rect.top << " l " << rect.right << " " << rect.bottom << " l " | 817 << rect.top << " l " << rect.right << " " << rect.bottom << " l " |
815 << rect.left << " " << rect.bottom << " l " | 818 << rect.left << " " << rect.bottom << " l " |
816 << "h f\n"; | 819 << "h f\n"; |
817 | 820 |
818 CPDF_Dictionary* pExtGStateDict = | 821 CPDF_Dictionary* pExtGStateDict = |
819 GenerateExtGStateDict(*pAnnotDict, sExtGSDictName, "Multiply"); | 822 GenerateExtGStateDict(*pAnnotDict, sExtGSDictName, "Multiply"); |
820 CPDF_Dictionary* pResourceDict = | 823 CPDF_Dictionary* pResourceDict = |
821 GenerateResourceDict(pExtGStateDict, nullptr); | 824 GenerateResourceDict(pExtGStateDict, nullptr); |
822 GenerateAndSetAPDict(pDoc, pAnnotDict, sAppStream, pResourceDict); | 825 GenerateAndSetAPDict(pDoc, pAnnotDict, sAppStream, pResourceDict, |
826 true /*IsTextMarkupAnnotation*/); | |
823 | 827 |
824 return true; | 828 return true; |
825 } | 829 } |
826 | 830 |
827 bool CPVT_GenerateAP::GenerateInkAP(CPDF_Document* pDoc, | 831 bool CPVT_GenerateAP::GenerateInkAP(CPDF_Document* pDoc, |
828 CPDF_Dictionary* pAnnotDict) { | 832 CPDF_Dictionary* pAnnotDict) { |
829 FX_FLOAT fBorderWidth = GetBorderWidth(*pAnnotDict); | 833 FX_FLOAT fBorderWidth = GetBorderWidth(*pAnnotDict); |
830 bool bIsStroke = fBorderWidth > 0; | 834 bool bIsStroke = fBorderWidth > 0; |
831 | 835 |
832 if (!bIsStroke) | 836 if (!bIsStroke) |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
866 << pInkCoordList->GetNumberAt(j + 1) << " l "; | 870 << pInkCoordList->GetNumberAt(j + 1) << " l "; |
867 } | 871 } |
868 | 872 |
869 sAppStream << "S\n"; | 873 sAppStream << "S\n"; |
870 } | 874 } |
871 | 875 |
872 CPDF_Dictionary* pExtGStateDict = | 876 CPDF_Dictionary* pExtGStateDict = |
873 GenerateExtGStateDict(*pAnnotDict, sExtGSDictName, "Normal"); | 877 GenerateExtGStateDict(*pAnnotDict, sExtGSDictName, "Normal"); |
874 CPDF_Dictionary* pResourceDict = | 878 CPDF_Dictionary* pResourceDict = |
875 GenerateResourceDict(pExtGStateDict, nullptr); | 879 GenerateResourceDict(pExtGStateDict, nullptr); |
876 GenerateAndSetAPDict(pDoc, pAnnotDict, sAppStream, pResourceDict); | 880 GenerateAndSetAPDict(pDoc, pAnnotDict, sAppStream, pResourceDict, |
881 false /*IsTextMarkupAnnotation*/); | |
877 return true; | 882 return true; |
878 } | 883 } |
879 | 884 |
880 bool CPVT_GenerateAP::GenerateTextAP(CPDF_Document* pDoc, | 885 bool CPVT_GenerateAP::GenerateTextAP(CPDF_Document* pDoc, |
881 CPDF_Dictionary* pAnnotDict) { | 886 CPDF_Dictionary* pAnnotDict) { |
882 CFX_ByteTextBuf sAppStream; | 887 CFX_ByteTextBuf sAppStream; |
883 CFX_ByteString sExtGSDictName = "GS"; | 888 CFX_ByteString sExtGSDictName = "GS"; |
884 sAppStream << "/" << sExtGSDictName << " gs "; | 889 sAppStream << "/" << sExtGSDictName << " gs "; |
885 | 890 |
886 CFX_FloatRect rect = pAnnotDict->GetRectBy("Rect"); | 891 CFX_FloatRect rect = pAnnotDict->GetRectBy("Rect"); |
887 const FX_FLOAT fNoteLength = 20; | 892 const FX_FLOAT fNoteLength = 20; |
888 CFX_FloatRect noteRect(rect.left, rect.bottom, rect.left + fNoteLength, | 893 CFX_FloatRect noteRect(rect.left, rect.bottom, rect.left + fNoteLength, |
889 rect.bottom + fNoteLength); | 894 rect.bottom + fNoteLength); |
890 pAnnotDict->SetAtRect("Rect", noteRect); | 895 pAnnotDict->SetAtRect("Rect", noteRect); |
891 | 896 |
892 sAppStream << GenerateTextSymbolAP(noteRect); | 897 sAppStream << GenerateTextSymbolAP(noteRect); |
893 | 898 |
894 CPDF_Dictionary* pExtGStateDict = | 899 CPDF_Dictionary* pExtGStateDict = |
895 GenerateExtGStateDict(*pAnnotDict, sExtGSDictName, "Normal"); | 900 GenerateExtGStateDict(*pAnnotDict, sExtGSDictName, "Normal"); |
896 CPDF_Dictionary* pResourceDict = | 901 CPDF_Dictionary* pResourceDict = |
897 GenerateResourceDict(pExtGStateDict, nullptr); | 902 GenerateResourceDict(pExtGStateDict, nullptr); |
898 GenerateAndSetAPDict(pDoc, pAnnotDict, sAppStream, pResourceDict); | 903 GenerateAndSetAPDict(pDoc, pAnnotDict, sAppStream, pResourceDict, |
904 false /*IsTextMarkupAnnotation*/); | |
899 return true; | 905 return true; |
900 } | 906 } |
901 | 907 |
902 bool CPVT_GenerateAP::GenerateUnderlineAP(CPDF_Document* pDoc, | 908 bool CPVT_GenerateAP::GenerateUnderlineAP(CPDF_Document* pDoc, |
903 CPDF_Dictionary* pAnnotDict) { | 909 CPDF_Dictionary* pAnnotDict) { |
904 CFX_ByteTextBuf sAppStream; | 910 CFX_ByteTextBuf sAppStream; |
905 CFX_ByteString sExtGSDictName = "GS"; | 911 CFX_ByteString sExtGSDictName = "GS"; |
906 sAppStream << "/" << sExtGSDictName << " gs "; | 912 sAppStream << "/" << sExtGSDictName << " gs "; |
907 | 913 |
908 sAppStream << GetColorStringWithDefault(pAnnotDict->GetArrayBy("C"), | 914 sAppStream << GetColorStringWithDefault(pAnnotDict->GetArrayBy("C"), |
909 CPVT_Color(CPVT_Color::kRGB, 0, 0, 0), | 915 CPVT_Color(CPVT_Color::kRGB, 0, 0, 0), |
910 PaintOperation::STROKE); | 916 PaintOperation::STROKE); |
911 | 917 |
912 CFX_FloatRect rect = pAnnotDict->GetRectBy("Rect"); | 918 CFX_FloatRect rect = CPDF_Annot::RectFromQuads(pAnnotDict); |
913 rect.Normalize(); | 919 rect.Normalize(); |
914 | 920 |
915 FX_FLOAT fLineWidth = 1.0; | 921 FX_FLOAT fLineWidth = 1.0; |
916 sAppStream << fLineWidth << " w " << rect.left << " " | 922 sAppStream << fLineWidth << " w " << rect.left << " " |
917 << rect.bottom + fLineWidth << " m " << rect.right << " " | 923 << rect.bottom + fLineWidth << " m " << rect.right << " " |
918 << rect.bottom + fLineWidth << " l S\n"; | 924 << rect.bottom + fLineWidth << " l S\n"; |
919 | 925 |
920 CPDF_Dictionary* pExtGStateDict = | 926 CPDF_Dictionary* pExtGStateDict = |
921 GenerateExtGStateDict(*pAnnotDict, sExtGSDictName, "Normal"); | 927 GenerateExtGStateDict(*pAnnotDict, sExtGSDictName, "Normal"); |
922 CPDF_Dictionary* pResourceDict = | 928 CPDF_Dictionary* pResourceDict = |
923 GenerateResourceDict(pExtGStateDict, nullptr); | 929 GenerateResourceDict(pExtGStateDict, nullptr); |
924 GenerateAndSetAPDict(pDoc, pAnnotDict, sAppStream, pResourceDict); | 930 GenerateAndSetAPDict(pDoc, pAnnotDict, sAppStream, pResourceDict, |
931 true /*IsTextMarkupAnnotation*/); | |
925 return true; | 932 return true; |
926 } | 933 } |
927 | 934 |
928 bool CPVT_GenerateAP::GeneratePopupAP(CPDF_Document* pDoc, | 935 bool CPVT_GenerateAP::GeneratePopupAP(CPDF_Document* pDoc, |
929 CPDF_Dictionary* pAnnotDict) { | 936 CPDF_Dictionary* pAnnotDict) { |
930 CFX_ByteTextBuf sAppStream; | 937 CFX_ByteTextBuf sAppStream; |
931 CFX_ByteString sExtGSDictName = "GS"; | 938 CFX_ByteString sExtGSDictName = "GS"; |
932 sAppStream << "/" << sExtGSDictName << " gs\n"; | 939 sAppStream << "/" << sExtGSDictName << " gs\n"; |
933 | 940 |
934 sAppStream << GenerateColorAP(CPVT_Color(CPVT_Color::kRGB, 1, 1, 0), | 941 sAppStream << GenerateColorAP(CPVT_Color(CPVT_Color::kRGB, 1, 1, 0), |
(...skipping 17 matching lines...) Expand all Loading... | |
952 CPDF_Dictionary* pResourceFontDict = | 959 CPDF_Dictionary* pResourceFontDict = |
953 GenerateResourceFontDict(pDoc, sFontName); | 960 GenerateResourceFontDict(pDoc, sFontName); |
954 CPDF_Dictionary* pResourceDict = | 961 CPDF_Dictionary* pResourceDict = |
955 GenerateResourceDict(pResourceFontDict, pExtGStateDict); | 962 GenerateResourceDict(pResourceFontDict, pExtGStateDict); |
956 | 963 |
957 CPDF_Font* pDefFont = pDoc->LoadFont(pResourceFontDict); | 964 CPDF_Font* pDefFont = pDoc->LoadFont(pResourceFontDict); |
958 if (!pDefFont) | 965 if (!pDefFont) |
959 return false; | 966 return false; |
960 | 967 |
961 sAppStream << GetPopupContentsString(pDoc, *pAnnotDict, pDefFont, sFontName); | 968 sAppStream << GetPopupContentsString(pDoc, *pAnnotDict, pDefFont, sFontName); |
962 GenerateAndSetAPDict(pDoc, pAnnotDict, sAppStream, pResourceDict); | 969 GenerateAndSetAPDict(pDoc, pAnnotDict, sAppStream, pResourceDict, |
970 false /*IsTextMarkupAnnotation*/); | |
963 return true; | 971 return true; |
964 } | 972 } |
965 | 973 |
966 bool CPVT_GenerateAP::GenerateSquareAP(CPDF_Document* pDoc, | 974 bool CPVT_GenerateAP::GenerateSquareAP(CPDF_Document* pDoc, |
967 CPDF_Dictionary* pAnnotDict) { | 975 CPDF_Dictionary* pAnnotDict) { |
968 CFX_ByteTextBuf sAppStream; | 976 CFX_ByteTextBuf sAppStream; |
969 CFX_ByteString sExtGSDictName = "GS"; | 977 CFX_ByteString sExtGSDictName = "GS"; |
970 sAppStream << "/" << sExtGSDictName << " gs "; | 978 sAppStream << "/" << sExtGSDictName << " gs "; |
971 | 979 |
972 CPDF_Array* pInteriorColor = pAnnotDict->GetArrayBy("IC"); | 980 CPDF_Array* pInteriorColor = pAnnotDict->GetArrayBy("IC"); |
(...skipping 26 matching lines...) Expand all Loading... | |
999 bool bIsFillRect = pInteriorColor && (pInteriorColor->GetCount() > 0); | 1007 bool bIsFillRect = pInteriorColor && (pInteriorColor->GetCount() > 0); |
1000 | 1008 |
1001 sAppStream << rect.left << " " << rect.bottom << " " << rect.Width() << " " | 1009 sAppStream << rect.left << " " << rect.bottom << " " << rect.Width() << " " |
1002 << rect.Height() << " re " | 1010 << rect.Height() << " re " |
1003 << GetPaintOperatorString(bIsStrokeRect, bIsFillRect) << "\n"; | 1011 << GetPaintOperatorString(bIsStrokeRect, bIsFillRect) << "\n"; |
1004 | 1012 |
1005 CPDF_Dictionary* pExtGStateDict = | 1013 CPDF_Dictionary* pExtGStateDict = |
1006 GenerateExtGStateDict(*pAnnotDict, sExtGSDictName, "Normal"); | 1014 GenerateExtGStateDict(*pAnnotDict, sExtGSDictName, "Normal"); |
1007 CPDF_Dictionary* pResourceDict = | 1015 CPDF_Dictionary* pResourceDict = |
1008 GenerateResourceDict(pExtGStateDict, nullptr); | 1016 GenerateResourceDict(pExtGStateDict, nullptr); |
1009 GenerateAndSetAPDict(pDoc, pAnnotDict, sAppStream, pResourceDict); | 1017 GenerateAndSetAPDict(pDoc, pAnnotDict, sAppStream, pResourceDict, |
1018 false /*IsTextMarkupAnnotation*/); | |
1010 return true; | 1019 return true; |
1011 } | 1020 } |
1012 | 1021 |
1013 bool CPVT_GenerateAP::GenerateSquigglyAP(CPDF_Document* pDoc, | 1022 bool CPVT_GenerateAP::GenerateSquigglyAP(CPDF_Document* pDoc, |
1014 CPDF_Dictionary* pAnnotDict) { | 1023 CPDF_Dictionary* pAnnotDict) { |
1015 CFX_ByteTextBuf sAppStream; | 1024 CFX_ByteTextBuf sAppStream; |
1016 CFX_ByteString sExtGSDictName = "GS"; | 1025 CFX_ByteString sExtGSDictName = "GS"; |
1017 sAppStream << "/" << sExtGSDictName << " gs "; | 1026 sAppStream << "/" << sExtGSDictName << " gs "; |
1018 | 1027 |
1019 sAppStream << GetColorStringWithDefault(pAnnotDict->GetArrayBy("C"), | 1028 sAppStream << GetColorStringWithDefault(pAnnotDict->GetArrayBy("C"), |
1020 CPVT_Color(CPVT_Color::kRGB, 0, 0, 0), | 1029 CPVT_Color(CPVT_Color::kRGB, 0, 0, 0), |
1021 PaintOperation::STROKE); | 1030 PaintOperation::STROKE); |
1022 | 1031 |
1023 CFX_FloatRect rect = pAnnotDict->GetRectBy("Rect"); | 1032 CFX_FloatRect rect = CPDF_Annot::RectFromQuads(pAnnotDict); |
1024 rect.Normalize(); | 1033 rect.Normalize(); |
1025 | 1034 |
1026 FX_FLOAT fLineWidth = 1.0; | 1035 FX_FLOAT fLineWidth = 1.0; |
1027 sAppStream << fLineWidth << " w "; | 1036 sAppStream << fLineWidth << " w "; |
1028 | 1037 |
1029 const FX_FLOAT fDelta = 2.0; | 1038 const FX_FLOAT fDelta = 2.0; |
1030 const FX_FLOAT fTop = rect.bottom + fDelta; | 1039 const FX_FLOAT fTop = rect.bottom + fDelta; |
1031 const FX_FLOAT fBottom = rect.bottom; | 1040 const FX_FLOAT fBottom = rect.bottom; |
1032 | 1041 |
1033 sAppStream << rect.left << " " << fTop << " m "; | 1042 sAppStream << rect.left << " " << fTop << " m "; |
(...skipping 13 matching lines...) Expand all Loading... | |
1047 sAppStream << rect.right << " " << fBottom + fRemainder << " l "; | 1056 sAppStream << rect.right << " " << fBottom + fRemainder << " l "; |
1048 else | 1057 else |
1049 sAppStream << rect.right << " " << fTop - fRemainder << " l "; | 1058 sAppStream << rect.right << " " << fTop - fRemainder << " l "; |
1050 | 1059 |
1051 sAppStream << "S\n"; | 1060 sAppStream << "S\n"; |
1052 | 1061 |
1053 CPDF_Dictionary* pExtGStateDict = | 1062 CPDF_Dictionary* pExtGStateDict = |
1054 GenerateExtGStateDict(*pAnnotDict, sExtGSDictName, "Normal"); | 1063 GenerateExtGStateDict(*pAnnotDict, sExtGSDictName, "Normal"); |
1055 CPDF_Dictionary* pResourceDict = | 1064 CPDF_Dictionary* pResourceDict = |
1056 GenerateResourceDict(pExtGStateDict, nullptr); | 1065 GenerateResourceDict(pExtGStateDict, nullptr); |
1057 GenerateAndSetAPDict(pDoc, pAnnotDict, sAppStream, pResourceDict); | 1066 GenerateAndSetAPDict(pDoc, pAnnotDict, sAppStream, pResourceDict, |
1067 true /*IsTextMarkupAnnotation*/); | |
1058 return true; | 1068 return true; |
1059 } | 1069 } |
1060 | 1070 |
1061 bool CPVT_GenerateAP::GenerateStrikeOutAP(CPDF_Document* pDoc, | 1071 bool CPVT_GenerateAP::GenerateStrikeOutAP(CPDF_Document* pDoc, |
1062 CPDF_Dictionary* pAnnotDict) { | 1072 CPDF_Dictionary* pAnnotDict) { |
1063 CFX_ByteTextBuf sAppStream; | 1073 CFX_ByteTextBuf sAppStream; |
1064 CFX_ByteString sExtGSDictName = "GS"; | 1074 CFX_ByteString sExtGSDictName = "GS"; |
1065 sAppStream << "/" << sExtGSDictName << " gs "; | 1075 sAppStream << "/" << sExtGSDictName << " gs "; |
1066 | 1076 |
1067 sAppStream << GetColorStringWithDefault(pAnnotDict->GetArrayBy("C"), | 1077 sAppStream << GetColorStringWithDefault(pAnnotDict->GetArrayBy("C"), |
1068 CPVT_Color(CPVT_Color::kRGB, 0, 0, 0), | 1078 CPVT_Color(CPVT_Color::kRGB, 0, 0, 0), |
1069 PaintOperation::STROKE); | 1079 PaintOperation::STROKE); |
1070 | 1080 |
1071 CFX_FloatRect rect = pAnnotDict->GetRectBy("Rect"); | 1081 CFX_FloatRect rect = CPDF_Annot::RectFromQuads(pAnnotDict); |
1072 rect.Normalize(); | 1082 rect.Normalize(); |
1073 | 1083 |
1074 FX_FLOAT fLineWidth = 1.0; | 1084 FX_FLOAT fLineWidth = 1.0; |
1075 FX_FLOAT fY = (rect.top + rect.bottom) / 2; | 1085 FX_FLOAT fY = (rect.top + rect.bottom) / 2; |
1076 sAppStream << fLineWidth << " w " << rect.left << " " << fY << " m " | 1086 sAppStream << fLineWidth << " w " << rect.left << " " << fY << " m " |
1077 << rect.right << " " << fY << " l S\n"; | 1087 << rect.right << " " << fY << " l S\n"; |
1078 | 1088 |
1079 CPDF_Dictionary* pExtGStateDict = | 1089 CPDF_Dictionary* pExtGStateDict = |
1080 GenerateExtGStateDict(*pAnnotDict, sExtGSDictName, "Normal"); | 1090 GenerateExtGStateDict(*pAnnotDict, sExtGSDictName, "Normal"); |
1081 CPDF_Dictionary* pResourceDict = | 1091 CPDF_Dictionary* pResourceDict = |
1082 GenerateResourceDict(pExtGStateDict, nullptr); | 1092 GenerateResourceDict(pExtGStateDict, nullptr); |
1083 GenerateAndSetAPDict(pDoc, pAnnotDict, sAppStream, pResourceDict); | 1093 GenerateAndSetAPDict(pDoc, pAnnotDict, sAppStream, pResourceDict, |
1094 true /*IsTextMarkupAnnotation*/); | |
1084 return true; | 1095 return true; |
1085 } | 1096 } |
1086 | 1097 |
1087 // Static. | 1098 // Static. |
1088 CFX_ByteString CPVT_GenerateAP::GenerateEditAP( | 1099 CFX_ByteString CPVT_GenerateAP::GenerateEditAP( |
1089 IPVT_FontMap* pFontMap, | 1100 IPVT_FontMap* pFontMap, |
1090 CPDF_VariableText::Iterator* pIterator, | 1101 CPDF_VariableText::Iterator* pIterator, |
1091 const CFX_FloatPoint& ptOffset, | 1102 const CFX_FloatPoint& ptOffset, |
1092 FX_BOOL bContinuous, | 1103 FX_BOOL bContinuous, |
1093 uint16_t SubWord) { | 1104 uint16_t SubWord) { |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1345 int32_t nFontIndex, | 1356 int32_t nFontIndex, |
1346 FX_FLOAT fFontSize) { | 1357 FX_FLOAT fFontSize) { |
1347 CFX_ByteTextBuf sRet; | 1358 CFX_ByteTextBuf sRet; |
1348 if (pFontMap) { | 1359 if (pFontMap) { |
1349 CFX_ByteString sFontAlias = pFontMap->GetPDFFontAlias(nFontIndex); | 1360 CFX_ByteString sFontAlias = pFontMap->GetPDFFontAlias(nFontIndex); |
1350 if (sFontAlias.GetLength() > 0 && fFontSize > 0) | 1361 if (sFontAlias.GetLength() > 0 && fFontSize > 0) |
1351 sRet << "/" << sFontAlias << " " << fFontSize << " Tf\n"; | 1362 sRet << "/" << sFontAlias << " " << fFontSize << " Tf\n"; |
1352 } | 1363 } |
1353 return sRet.MakeString(); | 1364 return sRet.MakeString(); |
1354 } | 1365 } |
OLD | NEW |