summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2017-02-01 10:52:19 +0100
committerAndras Timar <andras.timar@collabora.com>2017-02-08 11:56:05 +0100
commit77c7a319a702f3165d34d3390ea8432071363097 (patch)
tree148a69b6eb627f3e372ef32de06225e7fb3a65d1 /vcl
parente5a528017fccc01f4e250583d47063d5224600e1 (diff)
tdf#105461 PDF export: handle text fill color
Text portion level background in Writer text was working already, as Writer paints its background explicitly, and then uses no text fill color in the metafile (that is turned into a PDF later). However, text fill color is used for Writer shape text and also in Impress. The rectangle is not just the text itself, but also the ascent / descent region, this matches the desktop rendering result. (cherry picked from commit ee32c7d8083ae1449d6b379034be92995c142da9) Change-Id: I644007ade43a8b9e663890643b826ae12c427ea5 Reviewed-on: https://gerrit.libreoffice.org/33795 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Michael Stahl <mstahl@redhat.com> (cherry picked from commit 264f2265884b3d50103a5315c6bd46df3be04451)
Diffstat (limited to 'vcl')
-rw-r--r--vcl/source/gdi/pdfwriter_impl.cxx23
1 files changed, 23 insertions, 0 deletions
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx
index e914c06fcbb7..d1c4364e0bd1 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -9063,6 +9063,29 @@ void PDFWriterImpl::drawLayout( SalLayout& rLayout, const OUString& rText, bool
}
}
+ if (m_aCurrentPDFState.m_aFont.GetFillColor() != Color(COL_TRANSPARENT))
+ {
+ // PDF doesn't have a text fill color, so draw a rectangle before
+ // drawing the actual text.
+ push(PushFlags::FILLCOLOR | PushFlags::LINECOLOR);
+ setFillColor(m_aCurrentPDFState.m_aFont.GetFillColor());
+ // Avoid border around the rectangle for Writer shape text.
+ setLineColor(Color(COL_TRANSPARENT));
+
+ // The rectangle is the bounding box of the text, but also includes
+ // ascent / descent to match the on-screen rendering.
+ Rectangle aRectangle;
+ // This is the top left of the text without ascent / descent.
+ aRectangle.SetPos(m_pReferenceDevice->PixelToLogic(rLayout.GetDrawPosition()));
+ aRectangle.setY(aRectangle.getY() - aRefDevFontMetric.GetAscent());
+ aRectangle.SetSize(m_pReferenceDevice->PixelToLogic(Size(rLayout.GetTextWidth(), 0)));
+ // This includes ascent / descent.
+ aRectangle.setHeight(aRefDevFontMetric.GetLineHeight());
+ drawRectangle(aRectangle);
+
+ pop();
+ }
+
Point aAlignOffset;
if ( eAlign == ALIGN_BOTTOM )
aAlignOffset.Y() -= aRefDevFontMetric.GetDescent();