From bf540873f5e258452fed5006f65a403c95e7872a Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Mon, 6 Jan 2020 20:35:08 +0100 Subject: sw: add rendering for semi-transparent text I considered passing the text color's alpha value down to the various vcl backends, but this would need changes everywhere (cairo, opengl, pdf export, etc). It's much easier to go via DrawTransparent(), that's how semi-transparent text in Draw/Impress already works. Change-Id: I96f15e6764c3c88ba67dd72dc8708414d7c6050c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86294 Tested-by: Jenkins Reviewed-by: Miklos Vajna --- sw/qa/core/text/text.cxx | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'sw/qa/core/text/text.cxx') diff --git a/sw/qa/core/text/text.cxx b/sw/qa/core/text/text.cxx index 8074cbc9f45e..4e6d4fcdb14e 100644 --- a/sw/qa/core/text/text.cxx +++ b/sw/qa/core/text/text.cxx @@ -8,6 +8,9 @@ */ #include + +#include + #include static char const DATA_DIRECTORY[] = "/sw/qa/core/text/data/"; @@ -46,6 +49,35 @@ CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testFootnoteConnect) pWrtShell->DelLeft(); } +CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testSemiTransparentText) +{ + // Create an in-memory empty document. + loadURL("private:factory/swriter", nullptr); + + // Set text to half-transparent and type a character. + uno::Reference xParagraph(getParagraph(1), uno::UNO_QUERY); + CPPUNIT_ASSERT(xParagraph.is()); + sal_Int16 nTransparence = 50; + xParagraph->setPropertyValue("CharTransparence", uno::makeAny(nTransparence)); + uno::Reference xTextRange(xParagraph, uno::UNO_QUERY); + CPPUNIT_ASSERT(xTextRange.is()); + xTextRange->setString("x"); + + // Render the document to a metafile. + SwXTextDocument* pTextDoc = dynamic_cast(mxComponent.get()); + CPPUNIT_ASSERT(pTextDoc); + SwDocShell* pDocShell = pTextDoc->GetDocShell(); + CPPUNIT_ASSERT(pDocShell); + std::shared_ptr xMetaFile = pDocShell->GetPreviewMetaFile(); + CPPUNIT_ASSERT(xMetaFile); + + // Make sure that DrawTransparent() was used during rendering. + MetafileXmlDump dumper; + xmlDocPtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); + CPPUNIT_ASSERT(pXmlDoc); + assertXPath(pXmlDoc, "//floattransparent"); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit v1.2.3