oox/source/drawingml/shape.cxx | 6 +++ sd/qa/unit/data/pptx/tdf149588_transparentSolidFill.pptx |binary sd/qa/unit/import-tests2.cxx | 25 +++++++++++++++ 3 files changed, 31 insertions(+)
New commits: commit 2e3cf5e21c9a4aba8623e89e5e472efa6586619d Author: Attila Szűcs <attila.sz...@collabora.com> AuthorDate: Thu Jan 5 13:29:32 2023 +0100 Commit: Andras Timar <andras.ti...@collabora.com> CommitDate: Fri Jan 6 09:29:32 2023 +0000 tdf#149588 pptx import: transparency at SolidFill When copied color (RGB) property from text content to shape, copy alpha component as well. (If text color have alpha component) Change-Id: Ib86c48ab7b2d3c5f9491a2211b05e90b2c2ea10f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145079 Tested-by: Jenkins Reviewed-by: Andras Timar <andras.ti...@collabora.com> diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx index 1dd4eb319c26..8fefc18fdbf6 100644 --- a/oox/source/drawingml/shape.cxx +++ b/oox/source/drawingml/shape.cxx @@ -662,6 +662,12 @@ static void lcl_createPresetShape(const uno::Reference<drawing::XShape>& xShape, const sal_Int32 aFillColor = static_cast<sal_Int32>( pProperties.maFillProperties.maFillColor.getColor( rGraphicHelper ).GetRGBColor() ); xSet->setPropertyValue( UNO_NAME_FILLCOLOR, uno::Any( aFillColor ) ); + + if (pProperties.maFillProperties.maFillColor.hasTransparency()) + { + const sal_Int16 aTransparence = pProperties.maFillProperties.maFillColor.getTransparency(); + xSet->setPropertyValue(UNO_NAME_FILL_TRANSPARENCE, uno::Any(aTransparence)); + } } else { diff --git a/sd/qa/unit/data/pptx/tdf149588_transparentSolidFill.pptx b/sd/qa/unit/data/pptx/tdf149588_transparentSolidFill.pptx new file mode 100644 index 000000000000..8967590b9284 Binary files /dev/null and b/sd/qa/unit/data/pptx/tdf149588_transparentSolidFill.pptx differ diff --git a/sd/qa/unit/import-tests2.cxx b/sd/qa/unit/import-tests2.cxx index 969eb250fb80..e9f2ce067740 100644 --- a/sd/qa/unit/import-tests2.cxx +++ b/sd/qa/unit/import-tests2.cxx @@ -141,6 +141,7 @@ public: void testTdf89928BlackWhiteThreshold(); void testTdf151547TransparentWhiteText(); void testTdf149961AutofitIndentation(); + void testTdf149588TransparentSolidFill(); CPPUNIT_TEST_SUITE(SdImportTest2); @@ -216,6 +217,7 @@ public: CPPUNIT_TEST(testTdf89928BlackWhiteThreshold); CPPUNIT_TEST(testTdf151547TransparentWhiteText); CPPUNIT_TEST(testTdf149961AutofitIndentation); + CPPUNIT_TEST(testTdf149588TransparentSolidFill); CPPUNIT_TEST_SUITE_END(); }; @@ -2206,6 +2208,29 @@ void SdImportTest2::testTdf149961AutofitIndentation() } } +void SdImportTest2::testTdf149588TransparentSolidFill() +{ + sd::DrawDocShellRef xDocShRef = loadURL( + m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/tdf149588_transparentSolidFill.pptx"), + PPTX); + + xDocShRef = saveAndReload(xDocShRef.get(), PPTX); + + uno::Reference<beans::XPropertySet> xShape(getShapeFromPage(6, 0, xDocShRef)); + uno::Reference<text::XTextRange> xParagraph(getParagraphFromShape(0, xShape)); + uno::Reference<text::XTextRange> xRun(getRunFromParagraph(0, xParagraph)); + uno::Reference<beans::XPropertySet> xPropSet(xRun, uno::UNO_QUERY_THROW); + + Color nCharColor; + xPropSet->getPropertyValue("CharColor") >>= nCharColor; + // Without the accompanying fix in place, this test would have failed with: + // - Expected: Color: R:99 G:99 B:99 A 51 (T:204) + // - Actual : Color: R:99 G:99 B:99 A: 255 (T: 0) + CPPUNIT_ASSERT_EQUAL(Color(ColorTransparency, 0xCC636363), nCharColor); + + xDocShRef->DoClose(); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SdImportTest2); CPPUNIT_PLUGIN_IMPLEMENT();