summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjaepark <jaepark@google.com>2016-08-02 17:32:23 -0700
committerCommit bot <commit-bot@chromium.org>2016-08-02 17:32:23 -0700
commit0d8c2d120efe62d79d083f25b43aa814d0f24646 (patch)
treeff010c1ca336ef612b76a226093b769aa0a71786
parent33e9b26ba3c191262d0abb945fda1efb3cdb3051 (diff)
downloadpdfium-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
-rw-r--r--DEPS2
-rw-r--r--core/fpdfdoc/cpdf_annot.cpp2
-rw-r--r--core/fpdfdoc/cpvt_generateap.cpp29
-rw-r--r--core/fpdfdoc/cpvt_generateap.h2
4 files changed, 34 insertions, 1 deletions
diff --git a/DEPS b/DEPS
index ed8924771b..ba3dce790d 100644
--- a/DEPS
+++ b/DEPS
@@ -14,7 +14,7 @@ vars = {
'gmock_revision': '29763965ab52f24565299976b936d1265cb6a271',
'gtest_revision': '8245545b6dc9c4703e6496d1efd19e975ad2b038',
'icu_revision': 'a5f86adbb0a58d04c035a5d1228747b1823cd485',
- 'pdfium_tests_revision': 'cae29d1e4ac7a9c32add1a6ac0d04d60298a278e',
+ 'pdfium_tests_revision': 'ddc1938d718be26a64192cfabdbeb64792d58fb6',
'skia_revision': '7d46f4af7dc759002537a172af121f2bfe200981',
'tools_memory_revision': '427f10475e1a8d72424c29d00bf689122b738e5d',
'trace_event_revision': '54b8455be9505c2cb0cf5c26bb86739c236471aa',
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,