diff options
Diffstat (limited to 'core/fpdfdoc')
-rw-r--r-- | core/fpdfdoc/cpdf_annot.cpp | 9 | ||||
-rw-r--r-- | core/fpdfdoc/cpvt_generateap.cpp | 38 | ||||
-rw-r--r-- | core/fpdfdoc/include/cpdf_annot.h | 2 |
3 files changed, 28 insertions, 21 deletions
diff --git a/core/fpdfdoc/cpdf_annot.cpp b/core/fpdfdoc/cpdf_annot.cpp index 2b9b936cd1..617ea0fdc3 100644 --- a/core/fpdfdoc/cpdf_annot.cpp +++ b/core/fpdfdoc/cpdf_annot.cpp @@ -133,11 +133,20 @@ static CPDF_Form* FPDFDOC_Annot_GetMatrix(const CPDF_Page* pPage, matrix.Concat(*pUser2Device); return pForm; } + +// static +bool CPDF_Annot::IsAnnotationHidden(CPDF_Dictionary* pAnnotDict) { + return !!(pAnnotDict->GetIntegerBy("F") & ANNOTFLAG_HIDDEN); +} + FX_BOOL CPDF_Annot::DrawAppearance(CPDF_Page* pPage, CFX_RenderDevice* pDevice, const CFX_Matrix* pUser2Device, AppearanceMode mode, const CPDF_RenderOptions* pOptions) { + if (IsAnnotationHidden(m_pAnnotDict)) + return FALSE; + CFX_Matrix matrix; CPDF_Form* pForm = FPDFDOC_Annot_GetMatrix(pPage, this, mode, pUser2Device, matrix); 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; diff --git a/core/fpdfdoc/include/cpdf_annot.h b/core/fpdfdoc/include/cpdf_annot.h index 99efd98886..4999349155 100644 --- a/core/fpdfdoc/include/cpdf_annot.h +++ b/core/fpdfdoc/include/cpdf_annot.h @@ -37,6 +37,8 @@ class CPDF_Annot { public: enum AppearanceMode { Normal, Rollover, Down }; + static bool IsAnnotationHidden(CPDF_Dictionary* pAnnotDict); + CPDF_Annot(CPDF_Dictionary* pDict, CPDF_Document* pDocument); ~CPDF_Annot(); |