diff options
author | jaepark <jaepark@google.com> | 2016-08-02 17:32:23 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-08-02 17:32:23 -0700 |
commit | 0d8c2d120efe62d79d083f25b43aa814d0f24646 (patch) | |
tree | ff010c1ca336ef612b76a226093b769aa0a71786 /core/fpdfdoc | |
parent | 33e9b26ba3c191262d0abb945fda1efb3cdb3051 (diff) | |
download | pdfium-0d8c2d120efe62d79d083f25b43aa814d0f24646.tar.xz |
Generate default AP stream for strike out annotation.
This patch generates a default AP stream for strike out annotation so that
strike out annotations without AP stream can be displayed.
Also, roll DEPS for testing/corpus to ddc1938 to test strike out annotations.
BUG=62625
Review-Url: https://codereview.chromium.org/2206083002
Diffstat (limited to 'core/fpdfdoc')
-rw-r--r-- | core/fpdfdoc/cpdf_annot.cpp | 2 | ||||
-rw-r--r-- | core/fpdfdoc/cpvt_generateap.cpp | 29 | ||||
-rw-r--r-- | core/fpdfdoc/cpvt_generateap.h | 2 |
3 files changed, 33 insertions, 0 deletions
diff --git a/core/fpdfdoc/cpdf_annot.cpp b/core/fpdfdoc/cpdf_annot.cpp index 77c117dae4..9a3797d351 100644 --- a/core/fpdfdoc/cpdf_annot.cpp +++ b/core/fpdfdoc/cpdf_annot.cpp @@ -22,6 +22,8 @@ CPDF_Annot::CPDF_Annot(CPDF_Dictionary* pDict, CPDF_Document* pDocument) m_sSubtype(m_pAnnotDict->GetStringBy("Subtype")) { if (m_sSubtype == "Highlight") CPVT_GenerateAP::GenerateHighlightAP(m_pDocument, m_pAnnotDict); + else if (m_sSubtype == "StrikeOut") + CPVT_GenerateAP::GenerateStrikeOutAP(m_pDocument, m_pAnnotDict); else if (m_sSubtype == "Underline") CPVT_GenerateAP::GenerateUnderlineAP(m_pDocument, m_pAnnotDict); } diff --git a/core/fpdfdoc/cpvt_generateap.cpp b/core/fpdfdoc/cpvt_generateap.cpp index 9bde7e6b85..a19332bb7c 100644 --- a/core/fpdfdoc/cpvt_generateap.cpp +++ b/core/fpdfdoc/cpvt_generateap.cpp @@ -619,6 +619,35 @@ bool CPVT_GenerateAP::GenerateUnderlineAP(CPDF_Document* pDoc, return true; } +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")) + return false; + + CFX_ByteTextBuf sAppStream; + CFX_ByteString sExtGSDictName = "GS"; + sAppStream << "/" << sExtGSDictName << " gs "; + + sAppStream << GetColorStringWithDefault(pAnnotDict, + CPVT_Color(CPVT_Color::kRGB, 0, 0, 0), + PaintOperation::STROKE); + + CFX_FloatRect rect = pAnnotDict->GetRectBy("Rect"); + rect.Normalize(); + + FX_FLOAT fLineWidth = 1.0; + FX_FLOAT fY = (rect.top + rect.bottom) / 2; + sAppStream << fLineWidth << " w " << rect.left << " " << fY << " m " + << rect.right << " " << fY << " l S\n"; + + CPDF_Dictionary* pExtGStateDict = + GenerateExtGStateDict(*pAnnotDict, sExtGSDictName, "Normal"); + GenerateAndSetAPDict(pDoc, pAnnotDict, sAppStream, pExtGStateDict); + return true; +} + // Static. CFX_ByteString CPVT_GenerateAP::GenerateEditAP( IPVT_FontMap* pFontMap, diff --git a/core/fpdfdoc/cpvt_generateap.h b/core/fpdfdoc/cpvt_generateap.h index 233a6f39fe..ad4b7f0d3f 100644 --- a/core/fpdfdoc/cpvt_generateap.h +++ b/core/fpdfdoc/cpvt_generateap.h @@ -31,6 +31,8 @@ class CPVT_GenerateAP { CPDF_Dictionary* pAnnotDict); static bool GenerateListBoxAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict); + static bool GenerateStrikeOutAP(CPDF_Document* pDoc, + CPDF_Dictionary* pAnnotDict); static bool GenerateTextFieldAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict); static bool GenerateUnderlineAP(CPDF_Document* pDoc, |