summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--DEPS2
-rw-r--r--core/fpdfdoc/cpdf_annot.cpp2
-rw-r--r--core/fpdfdoc/cpvt_generateap.cpp74
-rw-r--r--core/fpdfdoc/cpvt_generateap.h1
4 files changed, 78 insertions, 1 deletions
diff --git a/DEPS b/DEPS
index 37daf56c52..dcb66d3304 100644
--- a/DEPS
+++ b/DEPS
@@ -14,7 +14,7 @@ vars = {
'gmock_revision': '29763965ab52f24565299976b936d1265cb6a271',
'gtest_revision': '8245545b6dc9c4703e6496d1efd19e975ad2b038',
'icu_revision': 'a5f86adbb0a58d04c035a5d1228747b1823cd485',
- 'pdfium_tests_revision': '1fdec9eaee514481092dd8e066029db71644829a',
+ 'pdfium_tests_revision': 'afbac944ba4b41252e4bd16372f27806bc0ed924',
'skia_revision': '36c38cbb29744e0b5390a38367e47c0c74287c2d',
'tools_memory_revision': '427f10475e1a8d72424c29d00bf689122b738e5d',
'trace_event_revision': '54b8455be9505c2cb0cf5c26bb86739c236471aa',
diff --git a/core/fpdfdoc/cpdf_annot.cpp b/core/fpdfdoc/cpdf_annot.cpp
index 617ea0fdc3..df12e9a82e 100644
--- a/core/fpdfdoc/cpdf_annot.cpp
+++ b/core/fpdfdoc/cpdf_annot.cpp
@@ -34,6 +34,8 @@ CPDF_Annot::CPDF_Annot(CPDF_Dictionary* pDict, CPDF_Document* pDocument)
CPVT_GenerateAP::GenerateSquigglyAP(m_pDocument, m_pAnnotDict);
else if (m_sSubtype == "StrikeOut")
CPVT_GenerateAP::GenerateStrikeOutAP(m_pDocument, m_pAnnotDict);
+ else if (m_sSubtype == "Text")
+ CPVT_GenerateAP::GenerateTextAP(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 da3c052b85..12ba4ef295 100644
--- a/core/fpdfdoc/cpvt_generateap.cpp
+++ b/core/fpdfdoc/cpvt_generateap.cpp
@@ -563,6 +563,56 @@ CFX_ByteString GetPaintOperatorString(bool bIsStrokeRect, bool bIsFillRect) {
return bIsFillRect ? "f" : "n";
}
+CFX_ByteString GenerateTextSymbolAP(const CFX_FloatRect& rect) {
+ CFX_ByteTextBuf sAppStream;
+ sAppStream << CPVT_GenerateAP::GenerateColorAP(
+ CPVT_Color(CPVT_Color::kRGB, 1, 1, 0), PaintOperation::FILL);
+ sAppStream << CPVT_GenerateAP::GenerateColorAP(
+ CPVT_Color(CPVT_Color::kRGB, 0, 0, 0), PaintOperation::STROKE);
+
+ const FX_FLOAT fBorderWidth = 1;
+ sAppStream << fBorderWidth << " w\n";
+
+ const FX_FLOAT fHalfWidth = fBorderWidth / 2;
+ const FX_FLOAT fTipDelta = 4;
+
+ CFX_FloatRect outerRect1 = rect;
+ outerRect1.Deflate(fHalfWidth, fHalfWidth);
+ outerRect1.bottom += fTipDelta;
+
+ CFX_FloatRect outerRect2 = outerRect1;
+ outerRect2.left += fTipDelta;
+ outerRect2.right = outerRect2.left + fTipDelta;
+ outerRect2.top = outerRect2.bottom - fTipDelta;
+ FX_FLOAT outerRect2Middle = (outerRect2.left + outerRect2.right) / 2;
+
+ // Draw outer boxes.
+ sAppStream << outerRect1.left << " " << outerRect1.bottom << " m\n"
+ << outerRect1.left << " " << outerRect1.top << " l\n"
+ << outerRect1.right << " " << outerRect1.top << " l\n"
+ << outerRect1.right << " " << outerRect1.bottom << " l\n"
+ << outerRect2.right << " " << outerRect2.bottom << " l\n"
+ << outerRect2Middle << " " << outerRect2.top << " l\n"
+ << outerRect2.left << " " << outerRect2.bottom << " l\n"
+ << outerRect1.left << " " << outerRect1.bottom << " l\n";
+
+ // Draw inner lines.
+ CFX_FloatRect lineRect = outerRect1;
+ const FX_FLOAT fXDelta = 2;
+ const FX_FLOAT fYDelta = (lineRect.top - lineRect.bottom) / 4;
+
+ lineRect.left += fXDelta;
+ lineRect.right -= fXDelta;
+ for (int i = 0; i < 3; ++i) {
+ lineRect.top -= fYDelta;
+ sAppStream << lineRect.left << " " << lineRect.top << " m\n"
+ << lineRect.right << " " << lineRect.top << " l\n";
+ }
+ sAppStream << "B*\n";
+
+ return sAppStream.MakeString();
+}
+
bool ShouldGenerateAPForAnnotation(CPDF_Dictionary* pAnnotDict) {
// If AP dictionary exists, we use the appearance defined in the
// existing AP dictionary.
@@ -778,6 +828,30 @@ bool CPVT_GenerateAP::GenerateInkAP(CPDF_Document* pDoc,
return true;
}
+bool CPVT_GenerateAP::GenerateTextAP(CPDF_Document* pDoc,
+ CPDF_Dictionary* pAnnotDict) {
+ if (!ShouldGenerateAPForAnnotation(pAnnotDict))
+ return false;
+
+ CFX_ByteTextBuf sAppStream;
+ CFX_ByteString sExtGSDictName = "GS";
+ sAppStream << "/" << sExtGSDictName << " gs ";
+
+ CFX_FloatRect rect = pAnnotDict->GetRectBy("Rect");
+ const FX_FLOAT fNoteLength = 20;
+ CFX_FloatRect noteRect(rect.left, rect.bottom, rect.left + fNoteLength,
+ rect.bottom + fNoteLength);
+ pAnnotDict->SetAtRect("Rect", noteRect);
+
+ sAppStream << GenerateTextSymbolAP(noteRect);
+
+ CPDF_Dictionary* pExtGStateDict =
+ GenerateExtGStateDict(*pAnnotDict, sExtGSDictName, "Normal");
+ GenerateAndSetAPDict(pDoc, pAnnotDict, sAppStream, pExtGStateDict);
+
+ return true;
+}
+
bool CPVT_GenerateAP::GenerateUnderlineAP(CPDF_Document* pDoc,
CPDF_Dictionary* pAnnotDict) {
if (!ShouldGenerateAPForAnnotation(pAnnotDict))
diff --git a/core/fpdfdoc/cpvt_generateap.h b/core/fpdfdoc/cpvt_generateap.h
index e36693901b..062acf684b 100644
--- a/core/fpdfdoc/cpvt_generateap.h
+++ b/core/fpdfdoc/cpvt_generateap.h
@@ -40,6 +40,7 @@ class CPVT_GenerateAP {
CPDF_Dictionary* pAnnotDict);
static bool GenerateStrikeOutAP(CPDF_Document* pDoc,
CPDF_Dictionary* pAnnotDict);
+ static bool GenerateTextAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict);
static bool GenerateTextFieldAP(CPDF_Document* pDoc,
CPDF_Dictionary* pAnnotDict);
static bool GenerateUnderlineAP(CPDF_Document* pDoc,