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

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

Issue 2239853002: Hidden annotations should not be drawn (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 4 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 | « no previous file | no next file » | 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"
11 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" 11 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h"
12 #include "core/fpdfapi/fpdf_parser/include/cpdf_simple_parser.h" 12 #include "core/fpdfapi/fpdf_parser/include/cpdf_simple_parser.h"
13 #include "core/fpdfapi/fpdf_parser/include/cpdf_stream.h" 13 #include "core/fpdfapi/fpdf_parser/include/cpdf_stream.h"
14 #include "core/fpdfapi/fpdf_parser/include/fpdf_parser_decode.h" 14 #include "core/fpdfapi/fpdf_parser/include/fpdf_parser_decode.h"
15 #include "core/fpdfdoc/cpvt_color.h" 15 #include "core/fpdfdoc/cpvt_color.h"
16 #include "core/fpdfdoc/cpvt_fontmap.h" 16 #include "core/fpdfdoc/cpvt_fontmap.h"
17 #include "core/fpdfdoc/include/cpdf_annot.h"
17 #include "core/fpdfdoc/include/cpdf_formfield.h" 18 #include "core/fpdfdoc/include/cpdf_formfield.h"
18 #include "core/fpdfdoc/include/cpvt_word.h" 19 #include "core/fpdfdoc/include/cpvt_word.h"
19 20
20 namespace { 21 namespace {
21 22
22 bool GenerateWidgetAP(CPDF_Document* pDoc, 23 bool GenerateWidgetAP(CPDF_Document* pDoc,
23 CPDF_Dictionary* pAnnotDict, 24 CPDF_Dictionary* pAnnotDict,
24 const int32_t& nWidgetType) { 25 const int32_t& nWidgetType) {
25 CPDF_Dictionary* pFormDict = nullptr; 26 CPDF_Dictionary* pFormDict = nullptr;
26 if (CPDF_Dictionary* pRootDict = pDoc->GetRoot()) 27 if (CPDF_Dictionary* pRootDict = pDoc->GetRoot())
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 return GenerateWidgetAP(pDoc, pAnnotDict, 0); 613 return GenerateWidgetAP(pDoc, pAnnotDict, 0);
613 } 614 }
614 615
615 bool CPVT_GenerateAP::GenerateCircleAP(CPDF_Document* pDoc, 616 bool CPVT_GenerateAP::GenerateCircleAP(CPDF_Document* pDoc,
616 CPDF_Dictionary* pAnnotDict) { 617 CPDF_Dictionary* pAnnotDict) {
617 // If AP dictionary exists, we use the appearance defined in the 618 // If AP dictionary exists, we use the appearance defined in the
618 // existing AP dictionary. 619 // existing AP dictionary.
619 if (pAnnotDict->KeyExist("AP")) 620 if (pAnnotDict->KeyExist("AP"))
620 return false; 621 return false;
621 622
623 uint32_t flags = pAnnotDict->GetIntegerBy("F");
624 if (flags & ANNOTFLAG_HIDDEN)
625 return false;
626
jaepark 2016/08/11 21:39:20 Wouldn't the annotation still be drawn if it has a
622 CFX_ByteTextBuf sAppStream; 627 CFX_ByteTextBuf sAppStream;
623 CFX_ByteString sExtGSDictName = "GS"; 628 CFX_ByteString sExtGSDictName = "GS";
624 sAppStream << "/" << sExtGSDictName << " gs "; 629 sAppStream << "/" << sExtGSDictName << " gs ";
625 630
626 CPDF_Array* pInteriorColor = pAnnotDict->GetArrayBy("IC"); 631 CPDF_Array* pInteriorColor = pAnnotDict->GetArrayBy("IC");
627 sAppStream << GetColorStringWithDefault(pInteriorColor, 632 sAppStream << GetColorStringWithDefault(pInteriorColor,
628 CPVT_Color(CPVT_Color::kTransparent), 633 CPVT_Color(CPVT_Color::kTransparent),
629 PaintOperation::FILL); 634 PaintOperation::FILL);
630 635
631 sAppStream << GetColorStringWithDefault(pAnnotDict->GetArrayBy("C"), 636 sAppStream << GetColorStringWithDefault(pAnnotDict->GetArrayBy("C"),
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
688 return true; 693 return true;
689 } 694 }
690 695
691 bool CPVT_GenerateAP::GenerateHighlightAP(CPDF_Document* pDoc, 696 bool CPVT_GenerateAP::GenerateHighlightAP(CPDF_Document* pDoc,
692 CPDF_Dictionary* pAnnotDict) { 697 CPDF_Dictionary* pAnnotDict) {
693 // If AP dictionary exists, we use the appearance defined in the 698 // If AP dictionary exists, we use the appearance defined in the
694 // existing AP dictionary. 699 // existing AP dictionary.
695 if (pAnnotDict->KeyExist("AP")) 700 if (pAnnotDict->KeyExist("AP"))
696 return false; 701 return false;
697 702
703 uint32_t flags = pAnnotDict->GetIntegerBy("F");
704 if (flags & ANNOTFLAG_HIDDEN)
705 return false;
706
698 CFX_ByteTextBuf sAppStream; 707 CFX_ByteTextBuf sAppStream;
699 CFX_ByteString sExtGSDictName = "GS"; 708 CFX_ByteString sExtGSDictName = "GS";
700 sAppStream << "/" << sExtGSDictName << " gs "; 709 sAppStream << "/" << sExtGSDictName << " gs ";
701 710
702 sAppStream << GetColorStringWithDefault(pAnnotDict->GetArrayBy("C"), 711 sAppStream << GetColorStringWithDefault(pAnnotDict->GetArrayBy("C"),
703 CPVT_Color(CPVT_Color::kRGB, 1, 1, 0), 712 CPVT_Color(CPVT_Color::kRGB, 1, 1, 0),
704 PaintOperation::FILL); 713 PaintOperation::FILL);
705 714
706 CFX_FloatRect rect = pAnnotDict->GetRectBy("Rect"); 715 CFX_FloatRect rect = pAnnotDict->GetRectBy("Rect");
707 rect.Normalize(); 716 rect.Normalize();
(...skipping 10 matching lines...) Expand all
718 return true; 727 return true;
719 } 728 }
720 729
721 bool CPVT_GenerateAP::GenerateInkAP(CPDF_Document* pDoc, 730 bool CPVT_GenerateAP::GenerateInkAP(CPDF_Document* pDoc,
722 CPDF_Dictionary* pAnnotDict) { 731 CPDF_Dictionary* pAnnotDict) {
723 // If AP dictionary exists, we use the appearance defined in the 732 // If AP dictionary exists, we use the appearance defined in the
724 // existing AP dictionary. 733 // existing AP dictionary.
725 if (pAnnotDict->KeyExist("AP")) 734 if (pAnnotDict->KeyExist("AP"))
726 return false; 735 return false;
727 736
737 uint32_t flags = pAnnotDict->GetIntegerBy("F");
738 if (flags & ANNOTFLAG_HIDDEN)
739 return false;
740
728 FX_FLOAT fBorderWidth = GetBorderWidth(*pAnnotDict); 741 FX_FLOAT fBorderWidth = GetBorderWidth(*pAnnotDict);
729 bool bIsStroke = fBorderWidth > 0; 742 bool bIsStroke = fBorderWidth > 0;
730 743
731 if (!bIsStroke) 744 if (!bIsStroke)
732 return false; 745 return false;
733 746
734 CPDF_Array* pInkList = pAnnotDict->GetArrayBy("InkList"); 747 CPDF_Array* pInkList = pAnnotDict->GetArrayBy("InkList");
735 if (!pInkList || pInkList->IsEmpty()) 748 if (!pInkList || pInkList->IsEmpty())
736 return false; 749 return false;
737 750
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
774 return true; 787 return true;
775 } 788 }
776 789
777 bool CPVT_GenerateAP::GenerateUnderlineAP(CPDF_Document* pDoc, 790 bool CPVT_GenerateAP::GenerateUnderlineAP(CPDF_Document* pDoc,
778 CPDF_Dictionary* pAnnotDict) { 791 CPDF_Dictionary* pAnnotDict) {
779 // If AP dictionary exists, we use the appearance defined in the 792 // If AP dictionary exists, we use the appearance defined in the
780 // existing AP dictionary. 793 // existing AP dictionary.
781 if (pAnnotDict->KeyExist("AP")) 794 if (pAnnotDict->KeyExist("AP"))
782 return false; 795 return false;
783 796
797 uint32_t flags = pAnnotDict->GetIntegerBy("F");
798 if (flags & ANNOTFLAG_HIDDEN)
dsinclair 2016/08/12 03:06:58 if flags is just used in the if no need to store i
799 return false;
800
784 CFX_ByteTextBuf sAppStream; 801 CFX_ByteTextBuf sAppStream;
785 CFX_ByteString sExtGSDictName = "GS"; 802 CFX_ByteString sExtGSDictName = "GS";
786 sAppStream << "/" << sExtGSDictName << " gs "; 803 sAppStream << "/" << sExtGSDictName << " gs ";
787 804
788 sAppStream << GetColorStringWithDefault(pAnnotDict->GetArrayBy("C"), 805 sAppStream << GetColorStringWithDefault(pAnnotDict->GetArrayBy("C"),
789 CPVT_Color(CPVT_Color::kRGB, 0, 0, 0), 806 CPVT_Color(CPVT_Color::kRGB, 0, 0, 0),
790 PaintOperation::STROKE); 807 PaintOperation::STROKE);
791 808
792 CFX_FloatRect rect = pAnnotDict->GetRectBy("Rect"); 809 CFX_FloatRect rect = pAnnotDict->GetRectBy("Rect");
793 rect.Normalize(); 810 rect.Normalize();
794 811
795 FX_FLOAT fLineWidth = 1.0; 812 FX_FLOAT fLineWidth = 1.0;
796 sAppStream << fLineWidth << " w " << rect.left << " " 813 sAppStream << fLineWidth << " w " << rect.left << " "
797 << rect.bottom + fLineWidth << " m " << rect.right << " " 814 << rect.bottom + fLineWidth << " m " << rect.right << " "
798 << rect.bottom + fLineWidth << " l S\n"; 815 << rect.bottom + fLineWidth << " l S\n";
799 816
800 CPDF_Dictionary* pExtGStateDict = 817 CPDF_Dictionary* pExtGStateDict =
801 GenerateExtGStateDict(*pAnnotDict, sExtGSDictName, "Normal"); 818 GenerateExtGStateDict(*pAnnotDict, sExtGSDictName, "Normal");
802 GenerateAndSetAPDict(pDoc, pAnnotDict, sAppStream, pExtGStateDict); 819 GenerateAndSetAPDict(pDoc, pAnnotDict, sAppStream, pExtGStateDict);
803 return true; 820 return true;
804 } 821 }
805 822
806 bool CPVT_GenerateAP::GenerateSquareAP(CPDF_Document* pDoc, 823 bool CPVT_GenerateAP::GenerateSquareAP(CPDF_Document* pDoc,
807 CPDF_Dictionary* pAnnotDict) { 824 CPDF_Dictionary* pAnnotDict) {
808 // If AP dictionary exists, we use the appearance defined in the 825 // If AP dictionary exists, we use the appearance defined in the
809 // existing AP dictionary. 826 // existing AP dictionary.
810 if (pAnnotDict->KeyExist("AP")) 827 if (pAnnotDict->KeyExist("AP"))
811 return false; 828 return false;
812 829
830 uint32_t flags = pAnnotDict->GetIntegerBy("F");
831 if (flags & ANNOTFLAG_HIDDEN)
832 return false;
833
813 CFX_ByteTextBuf sAppStream; 834 CFX_ByteTextBuf sAppStream;
814 CFX_ByteString sExtGSDictName = "GS"; 835 CFX_ByteString sExtGSDictName = "GS";
815 sAppStream << "/" << sExtGSDictName << " gs "; 836 sAppStream << "/" << sExtGSDictName << " gs ";
816 837
817 CPDF_Array* pInteriorColor = pAnnotDict->GetArrayBy("IC"); 838 CPDF_Array* pInteriorColor = pAnnotDict->GetArrayBy("IC");
818 sAppStream << GetColorStringWithDefault(pInteriorColor, 839 sAppStream << GetColorStringWithDefault(pInteriorColor,
819 CPVT_Color(CPVT_Color::kTransparent), 840 CPVT_Color(CPVT_Color::kTransparent),
820 PaintOperation::FILL); 841 PaintOperation::FILL);
821 842
822 sAppStream << GetColorStringWithDefault(pAnnotDict->GetArrayBy("C"), 843 sAppStream << GetColorStringWithDefault(pAnnotDict->GetArrayBy("C"),
(...skipping 30 matching lines...) Expand all
853 return true; 874 return true;
854 } 875 }
855 876
856 bool CPVT_GenerateAP::GenerateSquigglyAP(CPDF_Document* pDoc, 877 bool CPVT_GenerateAP::GenerateSquigglyAP(CPDF_Document* pDoc,
857 CPDF_Dictionary* pAnnotDict) { 878 CPDF_Dictionary* pAnnotDict) {
858 // If AP dictionary exists, we use the appearance defined in the 879 // If AP dictionary exists, we use the appearance defined in the
859 // existing AP dictionary. 880 // existing AP dictionary.
860 if (pAnnotDict->KeyExist("AP")) 881 if (pAnnotDict->KeyExist("AP"))
861 return false; 882 return false;
862 883
884 uint32_t flags = pAnnotDict->GetIntegerBy("F");
885 if (flags & ANNOTFLAG_HIDDEN)
886 return false;
887
863 CFX_ByteTextBuf sAppStream; 888 CFX_ByteTextBuf sAppStream;
864 CFX_ByteString sExtGSDictName = "GS"; 889 CFX_ByteString sExtGSDictName = "GS";
865 sAppStream << "/" << sExtGSDictName << " gs "; 890 sAppStream << "/" << sExtGSDictName << " gs ";
866 891
867 sAppStream << GetColorStringWithDefault(pAnnotDict->GetArrayBy("C"), 892 sAppStream << GetColorStringWithDefault(pAnnotDict->GetArrayBy("C"),
868 CPVT_Color(CPVT_Color::kRGB, 0, 0, 0), 893 CPVT_Color(CPVT_Color::kRGB, 0, 0, 0),
869 PaintOperation::STROKE); 894 PaintOperation::STROKE);
870 895
871 CFX_FloatRect rect = pAnnotDict->GetRectBy("Rect"); 896 CFX_FloatRect rect = pAnnotDict->GetRectBy("Rect");
872 rect.Normalize(); 897 rect.Normalize();
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
904 return true; 929 return true;
905 } 930 }
906 931
907 bool CPVT_GenerateAP::GenerateStrikeOutAP(CPDF_Document* pDoc, 932 bool CPVT_GenerateAP::GenerateStrikeOutAP(CPDF_Document* pDoc,
908 CPDF_Dictionary* pAnnotDict) { 933 CPDF_Dictionary* pAnnotDict) {
909 // If AP dictionary exists, we use the appearance defined in the 934 // If AP dictionary exists, we use the appearance defined in the
910 // existing AP dictionary. 935 // existing AP dictionary.
911 if (pAnnotDict->KeyExist("AP")) 936 if (pAnnotDict->KeyExist("AP"))
912 return false; 937 return false;
913 938
939 uint32_t flags = pAnnotDict->GetIntegerBy("F");
940 if (flags & ANNOTFLAG_HIDDEN)
941 return false;
942
914 CFX_ByteTextBuf sAppStream; 943 CFX_ByteTextBuf sAppStream;
915 CFX_ByteString sExtGSDictName = "GS"; 944 CFX_ByteString sExtGSDictName = "GS";
916 sAppStream << "/" << sExtGSDictName << " gs "; 945 sAppStream << "/" << sExtGSDictName << " gs ";
917 946
918 sAppStream << GetColorStringWithDefault(pAnnotDict->GetArrayBy("C"), 947 sAppStream << GetColorStringWithDefault(pAnnotDict->GetArrayBy("C"),
919 CPVT_Color(CPVT_Color::kRGB, 0, 0, 0), 948 CPVT_Color(CPVT_Color::kRGB, 0, 0, 0),
920 PaintOperation::STROKE); 949 PaintOperation::STROKE);
921 950
922 CFX_FloatRect rect = pAnnotDict->GetRectBy("Rect"); 951 CFX_FloatRect rect = pAnnotDict->GetRectBy("Rect");
923 rect.Normalize(); 952 rect.Normalize();
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
1194 int32_t nFontIndex, 1223 int32_t nFontIndex,
1195 FX_FLOAT fFontSize) { 1224 FX_FLOAT fFontSize) {
1196 CFX_ByteTextBuf sRet; 1225 CFX_ByteTextBuf sRet;
1197 if (pFontMap) { 1226 if (pFontMap) {
1198 CFX_ByteString sFontAlias = pFontMap->GetPDFFontAlias(nFontIndex); 1227 CFX_ByteString sFontAlias = pFontMap->GetPDFFontAlias(nFontIndex);
1199 if (sFontAlias.GetLength() > 0 && fFontSize > 0) 1228 if (sFontAlias.GetLength() > 0 && fFontSize > 0)
1200 sRet << "/" << sFontAlias << " " << fFontSize << " Tf\n"; 1229 sRet << "/" << sFontAlias << " " << fFontSize << " Tf\n";
1201 } 1230 }
1202 return sRet.MakeString(); 1231 return sRet.MakeString();
1203 } 1232 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698