writerfilter/qa/cppunittests/dmapper/TextEffectsHandler.cxx | 18 ++++++++++ writerfilter/qa/cppunittests/dmapper/data/tdf152884_Char_Transparency.docx |binary writerfilter/source/dmapper/TextEffectsHandler.cxx | 4 +- 3 files changed, 21 insertions(+), 1 deletion(-)
New commits: commit 585f65738270ba8ab2fdc4c49063c3b5663fe768 Author: Regina Henschel <rb.hensc...@t-online.de> AuthorDate: Thu Jan 5 18:33:46 2023 +0100 Commit: Regina Henschel <rb.hensc...@t-online.de> CommitDate: Fri Jan 6 01:19:12 2023 +0000 tdf#152884 import alpha too for schemeClr Without fix the alpha child element was only read for w14:srgbClr but no for w14:schemeClr. Thus character colored by theme color had no transparency. Change-Id: I73c01b7142d3eab83400d2e5eb9dce01ff8d4a19 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145099 Tested-by: Jenkins Reviewed-by: Regina Henschel <rb.hensc...@t-online.de> diff --git a/writerfilter/qa/cppunittests/dmapper/TextEffectsHandler.cxx b/writerfilter/qa/cppunittests/dmapper/TextEffectsHandler.cxx index 7788abe1a62b..f31d9862a1ac 100644 --- a/writerfilter/qa/cppunittests/dmapper/TextEffectsHandler.cxx +++ b/writerfilter/qa/cppunittests/dmapper/TextEffectsHandler.cxx @@ -47,6 +47,24 @@ CPPUNIT_TEST_FIXTURE(Test, testSemiTransparentText) // i.e. text was imported as regular text with solid color only. CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(74), nCharTransparence); } + +CPPUNIT_TEST_FIXTURE(Test, testThemeColorTransparency) +{ + // Load a document with a single paragraph. It has semi-transparent text and the color is + // determined by a w14:schemeClr element. + loadFromURL(u"tdf152884_Char_Transparency.docx"); + uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), + uno::UNO_QUERY); + uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration(); + uno::Reference<container::XEnumerationAccess> xPara(xParaEnum->nextElement(), uno::UNO_QUERY); + uno::Reference<container::XEnumeration> xPortionEnum = xPara->createEnumeration(); + sal_Int16 nCharTransparence = 0; + uno::Reference<beans::XPropertySet> xPortion(xPortionEnum->nextElement(), uno::UNO_QUERY); + xPortion->getPropertyValue("CharTransparence") >>= nCharTransparence; + // Without the fix this test would have failed with: Expected 74, Actual 0 + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(74), nCharTransparence); +} } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerfilter/qa/cppunittests/dmapper/data/tdf152884_Char_Transparency.docx b/writerfilter/qa/cppunittests/dmapper/data/tdf152884_Char_Transparency.docx new file mode 100644 index 000000000000..e1603956948f Binary files /dev/null and b/writerfilter/qa/cppunittests/dmapper/data/tdf152884_Char_Transparency.docx differ diff --git a/writerfilter/source/dmapper/TextEffectsHandler.cxx b/writerfilter/source/dmapper/TextEffectsHandler.cxx index cce02393cd5a..2a3deb5d0e87 100644 --- a/writerfilter/source/dmapper/TextEffectsHandler.cxx +++ b/writerfilter/source/dmapper/TextEffectsHandler.cxx @@ -771,7 +771,9 @@ sal_uInt8 TextEffectsHandler::GetTextFillSolidFillAlpha(const css::beans::Proper it = aSolidFillMap.find("srgbClr"); if (it == aSolidFillMap.end()) { - return 0; + it = aSolidFillMap.find("schemeClr"); + if (it == aSolidFillMap.end()) + return 0; } comphelper::SequenceAsHashMap aSrgbClrMap(it->second);