Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(120)

Unified Diff: core/fpdfdoc/cpvt_generateap.cpp

Issue 2206773004: Generate default AP stream for squiggly annotation. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Generate default AP stream for squiggly annotation. Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « core/fpdfdoc/cpvt_generateap.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/fpdfdoc/cpvt_generateap.cpp
diff --git a/core/fpdfdoc/cpvt_generateap.cpp b/core/fpdfdoc/cpvt_generateap.cpp
index a19332bb7c1443b48e6771235712f5332ed59b0b..6da25b61f7ab8131212680778215409c0ca4d28b 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
« no previous file with comments | « core/fpdfdoc/cpvt_generateap.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698