summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/fpdfdoc/cpdf_annot.cpp2
-rw-r--r--core/fpdfdoc/cpvt_generateap.cpp51
-rw-r--r--core/fpdfdoc/cpvt_generateap.h2
3 files changed, 55 insertions, 0 deletions
diff --git a/core/fpdfdoc/cpdf_annot.cpp b/core/fpdfdoc/cpdf_annot.cpp
index 9a3797d351..7396aa2558 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 == "Squiggly")
+ CPVT_GenerateAP::GenerateSquigglyAP(m_pDocument, m_pAnnotDict);
else if (m_sSubtype == "StrikeOut")
CPVT_GenerateAP::GenerateStrikeOutAP(m_pDocument, m_pAnnotDict);
else if (m_sSubtype == "Underline")
diff --git a/core/fpdfdoc/cpvt_generateap.cpp b/core/fpdfdoc/cpvt_generateap.cpp
index a19332bb7c..6da25b61f7 100644
--- a/core/fpdfdoc/cpvt_generateap.cpp
+++ b/core/fpdfdoc/cpvt_generateap.cpp
@@ -619,6 +619,57 @@ bool CPVT_GenerateAP::GenerateUnderlineAP(CPDF_Document* pDoc,
return true;
}
+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"))
+ 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;
+ sAppStream << fLineWidth << " w ";
+
+ const FX_FLOAT fDelta = 2.0;
+ const FX_FLOAT fTop = rect.bottom + fDelta;
+ const FX_FLOAT fBottom = rect.bottom;
+
+ sAppStream << rect.left << " " << fTop << " m ";
+
+ FX_FLOAT fX = rect.left + fDelta;
+ bool isUpwards = false;
+
+ while (fX < rect.right) {
+ sAppStream << fX << " " << (isUpwards ? fTop : fBottom) << " l ";
+
+ fX += fDelta;
+ isUpwards = !isUpwards;
+ }
+
+ FX_FLOAT fRemainder = rect.right - (fX - fDelta);
+ if (isUpwards)
+ sAppStream << rect.right << " " << fBottom + fRemainder << " l ";
+ else
+ sAppStream << rect.right << " " << fTop - fRemainder << " l ";
+
+ sAppStream << "S\n";
+
+ CPDF_Dictionary* pExtGStateDict =
+ GenerateExtGStateDict(*pAnnotDict, sExtGSDictName, "Normal");
+ GenerateAndSetAPDict(pDoc, pAnnotDict, sAppStream, pExtGStateDict);
+ return true;
+}
+
bool CPVT_GenerateAP::GenerateStrikeOutAP(CPDF_Document* pDoc,
CPDF_Dictionary* pAnnotDict) {
// If AP dictionary exists, we use the appearance defined in the
diff --git a/core/fpdfdoc/cpvt_generateap.h b/core/fpdfdoc/cpvt_generateap.h
index ad4b7f0d3f..3e4bbfe5ce 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 GenerateSquigglyAP(CPDF_Document* pDoc,
+ CPDF_Dictionary* pAnnotDict);
static bool GenerateStrikeOutAP(CPDF_Document* pDoc,
CPDF_Dictionary* pAnnotDict);
static bool GenerateTextFieldAP(CPDF_Document* pDoc,