Index: core/fpdfdoc/cpvt_generateap.cpp |
diff --git a/core/fpdfdoc/cpvt_generateap.cpp b/core/fpdfdoc/cpvt_generateap.cpp |
index da3c052b85809ea938baad35b5ef3b38e07f2f46..0be76a51c590aacb96c1174eadc86ec5bf24d0c7 100644 |
--- a/core/fpdfdoc/cpvt_generateap.cpp |
+++ b/core/fpdfdoc/cpvt_generateap.cpp |
@@ -563,6 +563,57 @@ 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; |
+ |
+ const FX_FLOAT fLeftBound = rect.left + fHalfWidth; |
Lei Zhang
2016/08/22 22:53:38
Can we create a new FloatRect, Inflate() it, and u
jaepark
2016/08/22 23:19:51
Done.
|
+ const FX_FLOAT fRightBound = rect.right - fHalfWidth; |
+ const FX_FLOAT fBottomBound = rect.bottom + fHalfWidth; |
+ const FX_FLOAT fTopBound = rect.top - fHalfWidth; |
+ |
+ // Draw outer box. |
+ sAppStream << fLeftBound << " " << fBottomBound + fTipDelta << " m\n" |
+ << fLeftBound << " " << fTopBound << " l\n" |
+ << fRightBound << " " << fTopBound << " l\n" |
+ << fRightBound << " " << fBottomBound + fTipDelta << " l\n" |
+ << fLeftBound + (2 * fTipDelta) << " " << fBottomBound + fTipDelta |
+ << " l\n" |
+ << fLeftBound + fTipDelta + (fTipDelta / 2) << " " << fBottomBound |
+ << " l\n" |
+ << fLeftBound + fTipDelta << " " << fBottomBound + fTipDelta |
+ << " l\n" |
+ << fLeftBound + fTipDelta << " " << fBottomBound + fTipDelta |
+ << " l\n" |
+ << fLeftBound << " " << fBottomBound + fTipDelta << " l\n"; |
+ |
+ // Draw inner lines. |
+ const FX_FLOAT fXDelta = 2; |
+ const FX_FLOAT fYDelta = (fTopBound - (fBottomBound + fTipDelta)) / 4; |
+ sAppStream << fLeftBound + fXDelta << " " << fTopBound - fYDelta << " m\n" |
+ << fRightBound - fXDelta << " " << fTopBound - fYDelta << " l\n" |
+ << fLeftBound + fXDelta << " " << fTopBound - (2 * fYDelta) |
+ << " m\n" |
+ << fRightBound - fXDelta << " " << fTopBound - (2 * fYDelta) |
+ << " l\n" |
+ << fLeftBound + fXDelta << " " << fTopBound - (3 * fYDelta) |
+ << " m\n" |
+ << fRightBound - fXDelta << " " << fTopBound - (3 * fYDelta) |
+ << " l\n" |
+ << "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 +829,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)) |