Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(90)

Side by Side Diff: core/fpdfdoc/cpvt_generateap.cpp

Issue 2289293005: Use /RECT or /QuadPoints for annotation coordinates, depending on /AP (Closed)
Patch Set: rebased + new DEPS Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « core/fpdfdoc/cpdf_annot.cpp ('k') | core/fpdfdoc/include/cpdf_annot.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 568 matching lines...) Expand 10 before | Expand all | Expand 10 after
579 if (pResourceFontDict) 579 if (pResourceFontDict)
580 pResourceDict->SetFor("Font", pResourceFontDict); 580 pResourceDict->SetFor("Font", pResourceFontDict);
581 581
582 return pResourceDict; 582 return pResourceDict;
583 } 583 }
584 584
585 // Takes ownership of |pResourceDict|. 585 // Takes ownership of |pResourceDict|.
586 void GenerateAndSetAPDict(CPDF_Document* pDoc, 586 void GenerateAndSetAPDict(CPDF_Document* pDoc,
587 CPDF_Dictionary* pAnnotDict, 587 CPDF_Dictionary* pAnnotDict,
588 const CFX_ByteTextBuf& sAppStream, 588 const CFX_ByteTextBuf& sAppStream,
589 CPDF_Dictionary* pResourceDict) { 589 CPDF_Dictionary* pResourceDict,
590 bool bIsTextMarkupAnnotation) {
590 CPDF_Dictionary* pAPDict = new CPDF_Dictionary; 591 CPDF_Dictionary* pAPDict = new CPDF_Dictionary;
591 pAnnotDict->SetFor("AP", pAPDict); 592 pAnnotDict->SetFor("AP", pAPDict);
592 593
593 CPDF_Stream* pNormalStream = new CPDF_Stream(nullptr, 0, nullptr); 594 CPDF_Stream* pNormalStream = new CPDF_Stream(nullptr, 0, nullptr);
594 int32_t objnum = pDoc->AddIndirectObject(pNormalStream); 595 int32_t objnum = pDoc->AddIndirectObject(pNormalStream);
595 pAnnotDict->GetDictFor("AP")->SetReferenceFor("N", pDoc, objnum); 596 pAnnotDict->GetDictFor("AP")->SetReferenceFor("N", pDoc, objnum);
596 597
597 pNormalStream->SetData(sAppStream.GetBuffer(), sAppStream.GetSize(), FALSE, 598 pNormalStream->SetData(sAppStream.GetBuffer(), sAppStream.GetSize(), FALSE,
598 FALSE); 599 FALSE);
599 600
600 CPDF_Dictionary* pStreamDict = pNormalStream->GetDict(); 601 CPDF_Dictionary* pStreamDict = pNormalStream->GetDict();
601 pStreamDict->SetIntegerFor("FormType", 1); 602 pStreamDict->SetIntegerFor("FormType", 1);
602 pStreamDict->SetStringFor("Subtype", "Form"); 603 pStreamDict->SetStringFor("Subtype", "Form");
603 pStreamDict->SetMatrixFor("Matrix", CFX_Matrix()); 604 pStreamDict->SetMatrixFor("Matrix", CFX_Matrix());
604 605
605 CFX_FloatRect rect = pAnnotDict->GetRectFor("Rect"); 606 CFX_FloatRect rect = bIsTextMarkupAnnotation
607 ? CPDF_Annot::RectFromQuadPoints(pAnnotDict)
608 : pAnnotDict->GetRectFor("Rect");
606 pStreamDict->SetRectFor("BBox", rect); 609 pStreamDict->SetRectFor("BBox", rect);
607 610
608 pStreamDict->SetFor("Resources", pResourceDict); 611 pStreamDict->SetFor("Resources", pResourceDict);
609 } 612 }
610 613
611 CFX_ByteString GetPaintOperatorString(bool bIsStrokeRect, bool bIsFillRect) { 614 CFX_ByteString GetPaintOperatorString(bool bIsStrokeRect, bool bIsFillRect) {
612 if (bIsStrokeRect) 615 if (bIsStrokeRect)
613 return bIsFillRect ? "b" : "s"; 616 return bIsFillRect ? "b" : "s";
614 return bIsFillRect ? "f" : "n"; 617 return bIsFillRect ? "f" : "n";
615 } 618 }
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
776 << fMiddleX - fDeltaX << " " << rect.top << " " << fMiddleX << " " 779 << fMiddleX - fDeltaX << " " << rect.top << " " << fMiddleX << " "
777 << rect.top << " c\n"; 780 << rect.top << " c\n";
778 781
779 bool bIsFillRect = pInteriorColor && !pInteriorColor->IsEmpty(); 782 bool bIsFillRect = pInteriorColor && !pInteriorColor->IsEmpty();
780 sAppStream << GetPaintOperatorString(bIsStrokeRect, bIsFillRect) << "\n"; 783 sAppStream << GetPaintOperatorString(bIsStrokeRect, bIsFillRect) << "\n";
781 784
782 CPDF_Dictionary* pExtGStateDict = 785 CPDF_Dictionary* pExtGStateDict =
783 GenerateExtGStateDict(*pAnnotDict, sExtGSDictName, "Normal"); 786 GenerateExtGStateDict(*pAnnotDict, sExtGSDictName, "Normal");
784 CPDF_Dictionary* pResourceDict = 787 CPDF_Dictionary* pResourceDict =
785 GenerateResourceDict(pExtGStateDict, nullptr); 788 GenerateResourceDict(pExtGStateDict, nullptr);
786 GenerateAndSetAPDict(pDoc, pAnnotDict, sAppStream, pResourceDict); 789 GenerateAndSetAPDict(pDoc, pAnnotDict, sAppStream, pResourceDict,
790 false /*IsTextMarkupAnnotation*/);
787 return true; 791 return true;
788 } 792 }
789 793
790 bool CPVT_GenerateAP::GenerateHighlightAP(CPDF_Document* pDoc, 794 bool CPVT_GenerateAP::GenerateHighlightAP(CPDF_Document* pDoc,
791 CPDF_Dictionary* pAnnotDict) { 795 CPDF_Dictionary* pAnnotDict) {
792 CFX_ByteTextBuf sAppStream; 796 CFX_ByteTextBuf sAppStream;
793 CFX_ByteString sExtGSDictName = "GS"; 797 CFX_ByteString sExtGSDictName = "GS";
794 sAppStream << "/" << sExtGSDictName << " gs "; 798 sAppStream << "/" << sExtGSDictName << " gs ";
795 799
796 sAppStream << GetColorStringWithDefault(pAnnotDict->GetArrayFor("C"), 800 sAppStream << GetColorStringWithDefault(pAnnotDict->GetArrayFor("C"),
797 CPVT_Color(CPVT_Color::kRGB, 1, 1, 0), 801 CPVT_Color(CPVT_Color::kRGB, 1, 1, 0),
798 PaintOperation::FILL); 802 PaintOperation::FILL);
799 803
800 CFX_FloatRect rect = pAnnotDict->GetRectFor("Rect"); 804 CFX_FloatRect rect = CPDF_Annot::RectFromQuadPoints(pAnnotDict);
801 rect.Normalize(); 805 rect.Normalize();
802 806
803 sAppStream << rect.left << " " << rect.top << " m " << rect.right << " " 807 sAppStream << rect.left << " " << rect.top << " m " << rect.right << " "
804 << rect.top << " l " << rect.right << " " << rect.bottom << " l " 808 << rect.top << " l " << rect.right << " " << rect.bottom << " l "
805 << rect.left << " " << rect.bottom << " l " 809 << rect.left << " " << rect.bottom << " l "
806 << "h f\n"; 810 << "h f\n";
807 811
808 CPDF_Dictionary* pExtGStateDict = 812 CPDF_Dictionary* pExtGStateDict =
809 GenerateExtGStateDict(*pAnnotDict, sExtGSDictName, "Multiply"); 813 GenerateExtGStateDict(*pAnnotDict, sExtGSDictName, "Multiply");
810 CPDF_Dictionary* pResourceDict = 814 CPDF_Dictionary* pResourceDict =
811 GenerateResourceDict(pExtGStateDict, nullptr); 815 GenerateResourceDict(pExtGStateDict, nullptr);
812 GenerateAndSetAPDict(pDoc, pAnnotDict, sAppStream, pResourceDict); 816 GenerateAndSetAPDict(pDoc, pAnnotDict, sAppStream, pResourceDict,
817 true /*IsTextMarkupAnnotation*/);
813 818
814 return true; 819 return true;
815 } 820 }
816 821
817 bool CPVT_GenerateAP::GenerateInkAP(CPDF_Document* pDoc, 822 bool CPVT_GenerateAP::GenerateInkAP(CPDF_Document* pDoc,
818 CPDF_Dictionary* pAnnotDict) { 823 CPDF_Dictionary* pAnnotDict) {
819 FX_FLOAT fBorderWidth = GetBorderWidth(*pAnnotDict); 824 FX_FLOAT fBorderWidth = GetBorderWidth(*pAnnotDict);
820 bool bIsStroke = fBorderWidth > 0; 825 bool bIsStroke = fBorderWidth > 0;
821 826
822 if (!bIsStroke) 827 if (!bIsStroke)
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
856 << pInkCoordList->GetNumberAt(j + 1) << " l "; 861 << pInkCoordList->GetNumberAt(j + 1) << " l ";
857 } 862 }
858 863
859 sAppStream << "S\n"; 864 sAppStream << "S\n";
860 } 865 }
861 866
862 CPDF_Dictionary* pExtGStateDict = 867 CPDF_Dictionary* pExtGStateDict =
863 GenerateExtGStateDict(*pAnnotDict, sExtGSDictName, "Normal"); 868 GenerateExtGStateDict(*pAnnotDict, sExtGSDictName, "Normal");
864 CPDF_Dictionary* pResourceDict = 869 CPDF_Dictionary* pResourceDict =
865 GenerateResourceDict(pExtGStateDict, nullptr); 870 GenerateResourceDict(pExtGStateDict, nullptr);
866 GenerateAndSetAPDict(pDoc, pAnnotDict, sAppStream, pResourceDict); 871 GenerateAndSetAPDict(pDoc, pAnnotDict, sAppStream, pResourceDict,
872 false /*IsTextMarkupAnnotation*/);
867 return true; 873 return true;
868 } 874 }
869 875
870 bool CPVT_GenerateAP::GenerateTextAP(CPDF_Document* pDoc, 876 bool CPVT_GenerateAP::GenerateTextAP(CPDF_Document* pDoc,
871 CPDF_Dictionary* pAnnotDict) { 877 CPDF_Dictionary* pAnnotDict) {
872 CFX_ByteTextBuf sAppStream; 878 CFX_ByteTextBuf sAppStream;
873 CFX_ByteString sExtGSDictName = "GS"; 879 CFX_ByteString sExtGSDictName = "GS";
874 sAppStream << "/" << sExtGSDictName << " gs "; 880 sAppStream << "/" << sExtGSDictName << " gs ";
875 881
876 CFX_FloatRect rect = pAnnotDict->GetRectFor("Rect"); 882 CFX_FloatRect rect = pAnnotDict->GetRectFor("Rect");
877 const FX_FLOAT fNoteLength = 20; 883 const FX_FLOAT fNoteLength = 20;
878 CFX_FloatRect noteRect(rect.left, rect.bottom, rect.left + fNoteLength, 884 CFX_FloatRect noteRect(rect.left, rect.bottom, rect.left + fNoteLength,
879 rect.bottom + fNoteLength); 885 rect.bottom + fNoteLength);
880 pAnnotDict->SetRectFor("Rect", noteRect); 886 pAnnotDict->SetRectFor("Rect", noteRect);
881 887
882 sAppStream << GenerateTextSymbolAP(noteRect); 888 sAppStream << GenerateTextSymbolAP(noteRect);
883 889
884 CPDF_Dictionary* pExtGStateDict = 890 CPDF_Dictionary* pExtGStateDict =
885 GenerateExtGStateDict(*pAnnotDict, sExtGSDictName, "Normal"); 891 GenerateExtGStateDict(*pAnnotDict, sExtGSDictName, "Normal");
886 CPDF_Dictionary* pResourceDict = 892 CPDF_Dictionary* pResourceDict =
887 GenerateResourceDict(pExtGStateDict, nullptr); 893 GenerateResourceDict(pExtGStateDict, nullptr);
888 GenerateAndSetAPDict(pDoc, pAnnotDict, sAppStream, pResourceDict); 894 GenerateAndSetAPDict(pDoc, pAnnotDict, sAppStream, pResourceDict,
895 false /*IsTextMarkupAnnotation*/);
889 return true; 896 return true;
890 } 897 }
891 898
892 bool CPVT_GenerateAP::GenerateUnderlineAP(CPDF_Document* pDoc, 899 bool CPVT_GenerateAP::GenerateUnderlineAP(CPDF_Document* pDoc,
893 CPDF_Dictionary* pAnnotDict) { 900 CPDF_Dictionary* pAnnotDict) {
894 CFX_ByteTextBuf sAppStream; 901 CFX_ByteTextBuf sAppStream;
895 CFX_ByteString sExtGSDictName = "GS"; 902 CFX_ByteString sExtGSDictName = "GS";
896 sAppStream << "/" << sExtGSDictName << " gs "; 903 sAppStream << "/" << sExtGSDictName << " gs ";
897 904
898 sAppStream << GetColorStringWithDefault(pAnnotDict->GetArrayFor("C"), 905 sAppStream << GetColorStringWithDefault(pAnnotDict->GetArrayFor("C"),
899 CPVT_Color(CPVT_Color::kRGB, 0, 0, 0), 906 CPVT_Color(CPVT_Color::kRGB, 0, 0, 0),
900 PaintOperation::STROKE); 907 PaintOperation::STROKE);
901 908
902 CFX_FloatRect rect = pAnnotDict->GetRectFor("Rect"); 909 CFX_FloatRect rect = CPDF_Annot::RectFromQuadPoints(pAnnotDict);
903 rect.Normalize(); 910 rect.Normalize();
904 911
905 FX_FLOAT fLineWidth = 1.0; 912 FX_FLOAT fLineWidth = 1.0;
906 sAppStream << fLineWidth << " w " << rect.left << " " 913 sAppStream << fLineWidth << " w " << rect.left << " "
907 << rect.bottom + fLineWidth << " m " << rect.right << " " 914 << rect.bottom + fLineWidth << " m " << rect.right << " "
908 << rect.bottom + fLineWidth << " l S\n"; 915 << rect.bottom + fLineWidth << " l S\n";
909 916
910 CPDF_Dictionary* pExtGStateDict = 917 CPDF_Dictionary* pExtGStateDict =
911 GenerateExtGStateDict(*pAnnotDict, sExtGSDictName, "Normal"); 918 GenerateExtGStateDict(*pAnnotDict, sExtGSDictName, "Normal");
912 CPDF_Dictionary* pResourceDict = 919 CPDF_Dictionary* pResourceDict =
913 GenerateResourceDict(pExtGStateDict, nullptr); 920 GenerateResourceDict(pExtGStateDict, nullptr);
914 GenerateAndSetAPDict(pDoc, pAnnotDict, sAppStream, pResourceDict); 921 GenerateAndSetAPDict(pDoc, pAnnotDict, sAppStream, pResourceDict,
922 true /*IsTextMarkupAnnotation*/);
915 return true; 923 return true;
916 } 924 }
917 925
918 bool CPVT_GenerateAP::GeneratePopupAP(CPDF_Document* pDoc, 926 bool CPVT_GenerateAP::GeneratePopupAP(CPDF_Document* pDoc,
919 CPDF_Dictionary* pAnnotDict) { 927 CPDF_Dictionary* pAnnotDict) {
920 CFX_ByteTextBuf sAppStream; 928 CFX_ByteTextBuf sAppStream;
921 CFX_ByteString sExtGSDictName = "GS"; 929 CFX_ByteString sExtGSDictName = "GS";
922 sAppStream << "/" << sExtGSDictName << " gs\n"; 930 sAppStream << "/" << sExtGSDictName << " gs\n";
923 931
924 sAppStream << GenerateColorAP(CPVT_Color(CPVT_Color::kRGB, 1, 1, 0), 932 sAppStream << GenerateColorAP(CPVT_Color(CPVT_Color::kRGB, 1, 1, 0),
(...skipping 17 matching lines...) Expand all
942 CPDF_Dictionary* pResourceFontDict = 950 CPDF_Dictionary* pResourceFontDict =
943 GenerateResourceFontDict(pDoc, sFontName); 951 GenerateResourceFontDict(pDoc, sFontName);
944 CPDF_Dictionary* pResourceDict = 952 CPDF_Dictionary* pResourceDict =
945 GenerateResourceDict(pResourceFontDict, pExtGStateDict); 953 GenerateResourceDict(pResourceFontDict, pExtGStateDict);
946 954
947 CPDF_Font* pDefFont = pDoc->LoadFont(pResourceFontDict); 955 CPDF_Font* pDefFont = pDoc->LoadFont(pResourceFontDict);
948 if (!pDefFont) 956 if (!pDefFont)
949 return false; 957 return false;
950 958
951 sAppStream << GetPopupContentsString(pDoc, *pAnnotDict, pDefFont, sFontName); 959 sAppStream << GetPopupContentsString(pDoc, *pAnnotDict, pDefFont, sFontName);
952 GenerateAndSetAPDict(pDoc, pAnnotDict, sAppStream, pResourceDict); 960 GenerateAndSetAPDict(pDoc, pAnnotDict, sAppStream, pResourceDict,
961 false /*IsTextMarkupAnnotation*/);
953 return true; 962 return true;
954 } 963 }
955 964
956 bool CPVT_GenerateAP::GenerateSquareAP(CPDF_Document* pDoc, 965 bool CPVT_GenerateAP::GenerateSquareAP(CPDF_Document* pDoc,
957 CPDF_Dictionary* pAnnotDict) { 966 CPDF_Dictionary* pAnnotDict) {
958 CFX_ByteTextBuf sAppStream; 967 CFX_ByteTextBuf sAppStream;
959 CFX_ByteString sExtGSDictName = "GS"; 968 CFX_ByteString sExtGSDictName = "GS";
960 sAppStream << "/" << sExtGSDictName << " gs "; 969 sAppStream << "/" << sExtGSDictName << " gs ";
961 970
962 CPDF_Array* pInteriorColor = pAnnotDict->GetArrayFor("IC"); 971 CPDF_Array* pInteriorColor = pAnnotDict->GetArrayFor("IC");
(...skipping 26 matching lines...) Expand all
989 bool bIsFillRect = pInteriorColor && (pInteriorColor->GetCount() > 0); 998 bool bIsFillRect = pInteriorColor && (pInteriorColor->GetCount() > 0);
990 999
991 sAppStream << rect.left << " " << rect.bottom << " " << rect.Width() << " " 1000 sAppStream << rect.left << " " << rect.bottom << " " << rect.Width() << " "
992 << rect.Height() << " re " 1001 << rect.Height() << " re "
993 << GetPaintOperatorString(bIsStrokeRect, bIsFillRect) << "\n"; 1002 << GetPaintOperatorString(bIsStrokeRect, bIsFillRect) << "\n";
994 1003
995 CPDF_Dictionary* pExtGStateDict = 1004 CPDF_Dictionary* pExtGStateDict =
996 GenerateExtGStateDict(*pAnnotDict, sExtGSDictName, "Normal"); 1005 GenerateExtGStateDict(*pAnnotDict, sExtGSDictName, "Normal");
997 CPDF_Dictionary* pResourceDict = 1006 CPDF_Dictionary* pResourceDict =
998 GenerateResourceDict(pExtGStateDict, nullptr); 1007 GenerateResourceDict(pExtGStateDict, nullptr);
999 GenerateAndSetAPDict(pDoc, pAnnotDict, sAppStream, pResourceDict); 1008 GenerateAndSetAPDict(pDoc, pAnnotDict, sAppStream, pResourceDict,
1009 false /*IsTextMarkupAnnotation*/);
1000 return true; 1010 return true;
1001 } 1011 }
1002 1012
1003 bool CPVT_GenerateAP::GenerateSquigglyAP(CPDF_Document* pDoc, 1013 bool CPVT_GenerateAP::GenerateSquigglyAP(CPDF_Document* pDoc,
1004 CPDF_Dictionary* pAnnotDict) { 1014 CPDF_Dictionary* pAnnotDict) {
1005 CFX_ByteTextBuf sAppStream; 1015 CFX_ByteTextBuf sAppStream;
1006 CFX_ByteString sExtGSDictName = "GS"; 1016 CFX_ByteString sExtGSDictName = "GS";
1007 sAppStream << "/" << sExtGSDictName << " gs "; 1017 sAppStream << "/" << sExtGSDictName << " gs ";
1008 1018
1009 sAppStream << GetColorStringWithDefault(pAnnotDict->GetArrayFor("C"), 1019 sAppStream << GetColorStringWithDefault(pAnnotDict->GetArrayFor("C"),
1010 CPVT_Color(CPVT_Color::kRGB, 0, 0, 0), 1020 CPVT_Color(CPVT_Color::kRGB, 0, 0, 0),
1011 PaintOperation::STROKE); 1021 PaintOperation::STROKE);
1012 1022
1013 CFX_FloatRect rect = pAnnotDict->GetRectFor("Rect"); 1023 CFX_FloatRect rect = CPDF_Annot::RectFromQuadPoints(pAnnotDict);
1014 rect.Normalize(); 1024 rect.Normalize();
1015 1025
1016 FX_FLOAT fLineWidth = 1.0; 1026 FX_FLOAT fLineWidth = 1.0;
1017 sAppStream << fLineWidth << " w "; 1027 sAppStream << fLineWidth << " w ";
1018 1028
1019 const FX_FLOAT fDelta = 2.0; 1029 const FX_FLOAT fDelta = 2.0;
1020 const FX_FLOAT fTop = rect.bottom + fDelta; 1030 const FX_FLOAT fTop = rect.bottom + fDelta;
1021 const FX_FLOAT fBottom = rect.bottom; 1031 const FX_FLOAT fBottom = rect.bottom;
1022 1032
1023 sAppStream << rect.left << " " << fTop << " m "; 1033 sAppStream << rect.left << " " << fTop << " m ";
(...skipping 13 matching lines...) Expand all
1037 sAppStream << rect.right << " " << fBottom + fRemainder << " l "; 1047 sAppStream << rect.right << " " << fBottom + fRemainder << " l ";
1038 else 1048 else
1039 sAppStream << rect.right << " " << fTop - fRemainder << " l "; 1049 sAppStream << rect.right << " " << fTop - fRemainder << " l ";
1040 1050
1041 sAppStream << "S\n"; 1051 sAppStream << "S\n";
1042 1052
1043 CPDF_Dictionary* pExtGStateDict = 1053 CPDF_Dictionary* pExtGStateDict =
1044 GenerateExtGStateDict(*pAnnotDict, sExtGSDictName, "Normal"); 1054 GenerateExtGStateDict(*pAnnotDict, sExtGSDictName, "Normal");
1045 CPDF_Dictionary* pResourceDict = 1055 CPDF_Dictionary* pResourceDict =
1046 GenerateResourceDict(pExtGStateDict, nullptr); 1056 GenerateResourceDict(pExtGStateDict, nullptr);
1047 GenerateAndSetAPDict(pDoc, pAnnotDict, sAppStream, pResourceDict); 1057 GenerateAndSetAPDict(pDoc, pAnnotDict, sAppStream, pResourceDict,
1058 true /*IsTextMarkupAnnotation*/);
1048 return true; 1059 return true;
1049 } 1060 }
1050 1061
1051 bool CPVT_GenerateAP::GenerateStrikeOutAP(CPDF_Document* pDoc, 1062 bool CPVT_GenerateAP::GenerateStrikeOutAP(CPDF_Document* pDoc,
1052 CPDF_Dictionary* pAnnotDict) { 1063 CPDF_Dictionary* pAnnotDict) {
1053 CFX_ByteTextBuf sAppStream; 1064 CFX_ByteTextBuf sAppStream;
1054 CFX_ByteString sExtGSDictName = "GS"; 1065 CFX_ByteString sExtGSDictName = "GS";
1055 sAppStream << "/" << sExtGSDictName << " gs "; 1066 sAppStream << "/" << sExtGSDictName << " gs ";
1056 1067
1057 sAppStream << GetColorStringWithDefault(pAnnotDict->GetArrayFor("C"), 1068 sAppStream << GetColorStringWithDefault(pAnnotDict->GetArrayFor("C"),
1058 CPVT_Color(CPVT_Color::kRGB, 0, 0, 0), 1069 CPVT_Color(CPVT_Color::kRGB, 0, 0, 0),
1059 PaintOperation::STROKE); 1070 PaintOperation::STROKE);
1060 1071
1061 CFX_FloatRect rect = pAnnotDict->GetRectFor("Rect"); 1072 CFX_FloatRect rect = CPDF_Annot::RectFromQuadPoints(pAnnotDict);
1062 rect.Normalize(); 1073 rect.Normalize();
1063 1074
1064 FX_FLOAT fLineWidth = 1.0; 1075 FX_FLOAT fLineWidth = 1.0;
1065 FX_FLOAT fY = (rect.top + rect.bottom) / 2; 1076 FX_FLOAT fY = (rect.top + rect.bottom) / 2;
1066 sAppStream << fLineWidth << " w " << rect.left << " " << fY << " m " 1077 sAppStream << fLineWidth << " w " << rect.left << " " << fY << " m "
1067 << rect.right << " " << fY << " l S\n"; 1078 << rect.right << " " << fY << " l S\n";
1068 1079
1069 CPDF_Dictionary* pExtGStateDict = 1080 CPDF_Dictionary* pExtGStateDict =
1070 GenerateExtGStateDict(*pAnnotDict, sExtGSDictName, "Normal"); 1081 GenerateExtGStateDict(*pAnnotDict, sExtGSDictName, "Normal");
1071 CPDF_Dictionary* pResourceDict = 1082 CPDF_Dictionary* pResourceDict =
1072 GenerateResourceDict(pExtGStateDict, nullptr); 1083 GenerateResourceDict(pExtGStateDict, nullptr);
1073 GenerateAndSetAPDict(pDoc, pAnnotDict, sAppStream, pResourceDict); 1084 GenerateAndSetAPDict(pDoc, pAnnotDict, sAppStream, pResourceDict,
1085 true /*IsTextMarkupAnnotation*/);
1074 return true; 1086 return true;
1075 } 1087 }
1076 1088
1077 // Static. 1089 // Static.
1078 CFX_ByteString CPVT_GenerateAP::GenerateEditAP( 1090 CFX_ByteString CPVT_GenerateAP::GenerateEditAP(
1079 IPVT_FontMap* pFontMap, 1091 IPVT_FontMap* pFontMap,
1080 CPDF_VariableText::Iterator* pIterator, 1092 CPDF_VariableText::Iterator* pIterator,
1081 const CFX_FloatPoint& ptOffset, 1093 const CFX_FloatPoint& ptOffset,
1082 FX_BOOL bContinuous, 1094 FX_BOOL bContinuous,
1083 uint16_t SubWord) { 1095 uint16_t SubWord) {
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
1334 int32_t nFontIndex, 1346 int32_t nFontIndex,
1335 FX_FLOAT fFontSize) { 1347 FX_FLOAT fFontSize) {
1336 CFX_ByteTextBuf sRet; 1348 CFX_ByteTextBuf sRet;
1337 if (pFontMap) { 1349 if (pFontMap) {
1338 CFX_ByteString sFontAlias = pFontMap->GetPDFFontAlias(nFontIndex); 1350 CFX_ByteString sFontAlias = pFontMap->GetPDFFontAlias(nFontIndex);
1339 if (sFontAlias.GetLength() > 0 && fFontSize > 0) 1351 if (sFontAlias.GetLength() > 0 && fFontSize > 0)
1340 sRet << "/" << sFontAlias << " " << fFontSize << " Tf\n"; 1352 sRet << "/" << sFontAlias << " " << fFontSize << " Tf\n";
1341 } 1353 }
1342 return sRet.MakeString(); 1354 return sRet.MakeString();
1343 } 1355 }
OLDNEW
« no previous file with comments | « core/fpdfdoc/cpdf_annot.cpp ('k') | core/fpdfdoc/include/cpdf_annot.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698