From 823a351adb0384598304d597ae7f637079ca6175 Mon Sep 17 00:00:00 2001 From: Justin Luth Date: Tue, 16 Nov 2021 13:46:07 +0200 Subject: tdf#118776 drawingml: treat XML_nofill as (mostly) transparent 100% transparent typically ends up as COL_AUTO which certainly doesn't do what is intended. So set as 99% transparent to get effectively the same invisible effect. Adapted patch and re-used unit test from an earlier commit authored by Xisco. This depends on tdf#137438 not spamming the text properties with outline props. Only one existing unit test that matched this condition: -export-tests-ooxml1.cxx customxml.pptx -empty textbox - text entered here SHOULD be invisible. Change-Id: I077b748e500713188421f0eeefdfd85c46555e84 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125301 Tested-by: Jenkins Tested-by: Xisco Fauli Reviewed-by: Xisco Fauli Reviewed-by: Justin Luth --- oox/source/drawingml/textcharacterproperties.cxx | 5 +++++ sd/qa/unit/data/pptx/tdf118776.pptx | Bin 0 -> 31591 bytes sd/qa/unit/import-tests2.cxx | 23 +++++++++++++++++++++++ 3 files changed, 28 insertions(+) create mode 100644 sd/qa/unit/data/pptx/tdf118776.pptx diff --git a/oox/source/drawingml/textcharacterproperties.cxx b/oox/source/drawingml/textcharacterproperties.cxx index 9200e9666cbf..a34cb14af639 100644 --- a/oox/source/drawingml/textcharacterproperties.cxx +++ b/oox/source/drawingml/textcharacterproperties.cxx @@ -111,6 +111,11 @@ void TextCharacterProperties::pushToPropMap( PropertyMap& rPropMap, const XmlFil if ( maFillProperties.moFillType.has() ) { Color aColor = maFillProperties.getBestSolidColor(); + + // noFill doesn't exist for characters. Map noFill to 99% transparency + if (maFillProperties.moFillType.get() == XML_noFill) + aColor.addTransformation(XML_alpha, 1000); + // tdf#137438 Emulate text outline color/transparency. // If the outline color dominates, then use it as the text color. if (moTextOutlineProperties.has() diff --git a/sd/qa/unit/data/pptx/tdf118776.pptx b/sd/qa/unit/data/pptx/tdf118776.pptx new file mode 100644 index 000000000000..8df94522ab29 Binary files /dev/null and b/sd/qa/unit/data/pptx/tdf118776.pptx differ diff --git a/sd/qa/unit/import-tests2.cxx b/sd/qa/unit/import-tests2.cxx index 9a5021f533b6..c299ad4303dd 100644 --- a/sd/qa/unit/import-tests2.cxx +++ b/sd/qa/unit/import-tests2.cxx @@ -118,6 +118,7 @@ public: void testTdf103792(); void testTdf103876(); void testTdf79007(); + void testTdf118776(); void testTdf129686(); void testTdf104015(); void testTdf104201(); @@ -183,6 +184,7 @@ public: CPPUNIT_TEST(testTdf103792); CPPUNIT_TEST(testTdf103876); CPPUNIT_TEST(testTdf79007); + CPPUNIT_TEST(testTdf118776); CPPUNIT_TEST(testTdf129686); CPPUNIT_TEST(testTdf104015); CPPUNIT_TEST(testTdf104201); @@ -547,6 +549,27 @@ void SdImportTest2::testTdf79007() xDocShRef->DoClose(); } +void SdImportTest2::testTdf118776() +{ + sd::DrawDocShellRef xDocShRef + = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/tdf118776.pptx"), PPTX); + uno::Reference xShape(getShapeFromPage(0, 0, xDocShRef)); + + // Get first paragraph of the text + uno::Reference const xParagraph(getParagraphFromShape(0, xShape)); + + // Get first run of the paragraph + uno::Reference xRun(getRunFromParagraph(0, xParagraph)); + uno::Reference xPropSet(xRun, uno::UNO_QUERY_THROW); + sal_Int16 nTransparency = 0; + xPropSet->getPropertyValue("CharTransparence") >>= nTransparency; + + // Import noFill color as 99% transparency + CPPUNIT_ASSERT_EQUAL(static_cast(99), nTransparency); + + xDocShRef->DoClose(); +} + void SdImportTest2::testTdf129686() { sd::DrawDocShellRef xDocShRef -- cgit v1.2.3