diff options
author | tonikitoo <tonikitoo@igalia.com> | 2016-08-16 13:34:35 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-08-16 13:34:35 -0700 |
commit | 66c26e84e6e154f0466db6fce4f3f36d445c579a (patch) | |
tree | efa79443b3e0bf04abcb4bade437e75ce30f7cff /core/fpdfdoc/cpvt_generateap.cpp | |
parent | f85e7e2ea29179dfe4ddc25ab410f8898391999c (diff) | |
download | pdfium-66c26e84e6e154f0466db6fce4f3f36d445c579a.tar.xz |
Hidden annotations should not be drawn
Now that PDFium supports drawing of more annotation
types, it should also respect the "hidden" flag that
annotations might feature.
For instance, in IE/Acroread if an annotation is flagged as
"hidden" it does not get drawn.
CL adds a check for the specific "hidden" flag, not drawing
annotation that are flagged with it, in order to match IE + acrobat
reader behavior.
The "flags" definition can be seen by looking at "/F {value}"
syntax in a PDF file source, where {value} is an predefined
integer value.
Test: PDF files being added in [1].
[1] https://codereview.chromium.org/2239713003/
BUG=62625
Review-Url: https://codereview.chromium.org/2239853002
Diffstat (limited to 'core/fpdfdoc/cpvt_generateap.cpp')
-rw-r--r-- | core/fpdfdoc/cpvt_generateap.cpp | 38 |
1 files changed, 17 insertions, 21 deletions
diff --git a/core/fpdfdoc/cpvt_generateap.cpp b/core/fpdfdoc/cpvt_generateap.cpp index f15869b130..da3c052b85 100644 --- a/core/fpdfdoc/cpvt_generateap.cpp +++ b/core/fpdfdoc/cpvt_generateap.cpp @@ -14,6 +14,7 @@ #include "core/fpdfapi/fpdf_parser/include/fpdf_parser_decode.h" #include "core/fpdfdoc/cpvt_color.h" #include "core/fpdfdoc/cpvt_fontmap.h" +#include "core/fpdfdoc/include/cpdf_annot.h" #include "core/fpdfdoc/include/cpdf_formfield.h" #include "core/fpdfdoc/include/cpvt_word.h" @@ -562,6 +563,15 @@ CFX_ByteString GetPaintOperatorString(bool bIsStrokeRect, bool bIsFillRect) { return bIsFillRect ? "f" : "n"; } +bool ShouldGenerateAPForAnnotation(CPDF_Dictionary* pAnnotDict) { + // If AP dictionary exists, we use the appearance defined in the + // existing AP dictionary. + if (pAnnotDict->KeyExist("AP")) + return false; + + return !CPDF_Annot::IsAnnotationHidden(pAnnotDict); +} + } // namespace bool FPDF_GenerateAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict) { @@ -614,9 +624,7 @@ bool CPVT_GenerateAP::GenerateTextFieldAP(CPDF_Document* pDoc, bool CPVT_GenerateAP::GenerateCircleAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict) { - // If AP dictionary exists, we use the appearance defined in the - // existing AP dictionary. - if (pAnnotDict->KeyExist("AP")) + if (!ShouldGenerateAPForAnnotation(pAnnotDict)) return false; CFX_ByteTextBuf sAppStream; @@ -690,9 +698,7 @@ bool CPVT_GenerateAP::GenerateCircleAP(CPDF_Document* pDoc, bool CPVT_GenerateAP::GenerateHighlightAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict) { - // If AP dictionary exists, we use the appearance defined in the - // existing AP dictionary. - if (pAnnotDict->KeyExist("AP")) + if (!ShouldGenerateAPForAnnotation(pAnnotDict)) return false; CFX_ByteTextBuf sAppStream; @@ -720,9 +726,7 @@ bool CPVT_GenerateAP::GenerateHighlightAP(CPDF_Document* pDoc, bool CPVT_GenerateAP::GenerateInkAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict) { - // If AP dictionary exists, we use the appearance defined in the - // existing AP dictionary. - if (pAnnotDict->KeyExist("AP")) + if (!ShouldGenerateAPForAnnotation(pAnnotDict)) return false; FX_FLOAT fBorderWidth = GetBorderWidth(*pAnnotDict); @@ -776,9 +780,7 @@ bool CPVT_GenerateAP::GenerateInkAP(CPDF_Document* pDoc, bool CPVT_GenerateAP::GenerateUnderlineAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict) { - // If AP dictionary exists, we use the appearance defined in the - // existing AP dictionary. - if (pAnnotDict->KeyExist("AP")) + if (!ShouldGenerateAPForAnnotation(pAnnotDict)) return false; CFX_ByteTextBuf sAppStream; @@ -805,9 +807,7 @@ bool CPVT_GenerateAP::GenerateUnderlineAP(CPDF_Document* pDoc, bool CPVT_GenerateAP::GenerateSquareAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict) { - // If AP dictionary exists, we use the appearance defined in the - // existing AP dictionary. - if (pAnnotDict->KeyExist("AP")) + if (!ShouldGenerateAPForAnnotation(pAnnotDict)) return false; CFX_ByteTextBuf sAppStream; @@ -855,9 +855,7 @@ bool CPVT_GenerateAP::GenerateSquareAP(CPDF_Document* pDoc, bool CPVT_GenerateAP::GenerateSquigglyAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict) { - // If AP dictionary exists, we use the appearance defined in the - // existing AP dictionary. - if (pAnnotDict->KeyExist("AP")) + if (!ShouldGenerateAPForAnnotation(pAnnotDict)) return false; CFX_ByteTextBuf sAppStream; @@ -906,9 +904,7 @@ bool CPVT_GenerateAP::GenerateSquigglyAP(CPDF_Document* pDoc, bool CPVT_GenerateAP::GenerateStrikeOutAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict) { - // If AP dictionary exists, we use the appearance defined in the - // existing AP dictionary. - if (pAnnotDict->KeyExist("AP")) + if (!ShouldGenerateAPForAnnotation(pAnnotDict)) return false; CFX_ByteTextBuf sAppStream; |