From 67f12a2b49179f1f4e655d80942e4aef22e1f37c Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Wed, 11 May 2022 20:17:16 +0200 Subject: tdf#148961 sd theme: add PPTX export for shape fill color effects Which allows taking the fill color theme index from the model even in case there are effects. Previously effects meant reading from the grab-bag, and only the no-effect case read the color theme index from the doc model. (cherry picked from commit 109debb0ca0c864296ad7f557cfbc2b05c9ec3c2) Conflicts: oox/qa/unit/export.cxx Change-Id: Ib50c3128b971a388f14ad721ed7f73043916a736 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136732 Tested-by: Jenkins CollaboraOffice Reviewed-by: Miklos Vajna --- oox/qa/unit/data/refer-to-theme-shape-fill.odp | Bin 15506 -> 14638 bytes oox/qa/unit/export.cxx | 5 +++++ oox/source/export/drawingml.cxx | 20 ++++++++++++++++++-- 3 files changed, 23 insertions(+), 2 deletions(-) (limited to 'oox') diff --git a/oox/qa/unit/data/refer-to-theme-shape-fill.odp b/oox/qa/unit/data/refer-to-theme-shape-fill.odp index b12772e111e3..3a32aa71690a 100644 Binary files a/oox/qa/unit/data/refer-to-theme-shape-fill.odp and b/oox/qa/unit/data/refer-to-theme-shape-fill.odp differ diff --git a/oox/qa/unit/export.cxx b/oox/qa/unit/export.cxx index 009e63d23e85..05735d0c8d61 100644 --- a/oox/qa/unit/export.cxx +++ b/oox/qa/unit/export.cxx @@ -630,6 +630,11 @@ CPPUNIT_TEST_FIXTURE(Test, testReferToThemeShapeFill) std::unique_ptr pStream = parseExportStream(getTempFile(), "ppt/slides/slide1.xml"); xmlDocUniquePtr pXmlDoc = parseXmlStream(pStream.get()); assertXPath(pXmlDoc, "//p:sp[1]/p:spPr/a:solidFill/a:schemeClr", "val", "accent1"); + // Without the accompanying fix in place, this test would have failed with: + // - XPath '//p:sp[1]/p:spPr/a:solidFill/a:schemeClr/a:lumMod' number of nodes is incorrect + // i.e. the effects of the themed color were lost. + assertXPath(pXmlDoc, "//p:sp[1]/p:spPr/a:solidFill/a:schemeClr/a:lumMod", "val", "40000"); + assertXPath(pXmlDoc, "//p:sp[1]/p:spPr/a:solidFill/a:schemeClr/a:lumOff", "val", "60000"); } } diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx index 23d67eb1c713..57199b4a0d24 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -555,7 +555,7 @@ void DrawingML::WriteSolidFill( const Reference< XPropertySet >& rXPropSet ) else if ( nFillColor != nOriginalColor ) { // the user has set a different color for the shape - if (aTransformations.hasElements() || !WriteFillColor(rXPropSet)) + if (!WriteFillColor(rXPropSet)) { WriteSolidFill(::Color(ColorTransparency, nFillColor & 0xffffff), nAlpha); } @@ -590,7 +590,23 @@ bool DrawingML::WriteFillColor(const uno::Reference& xPrope const char* pColorName = g_aPredefinedClrNames[nFillColorTheme]; mpFS->startElementNS(XML_a, XML_solidFill); - mpFS->singleElementNS(XML_a, XML_schemeClr, XML_val, pColorName); + mpFS->startElementNS(XML_a, XML_schemeClr, XML_val, pColorName); + + sal_Int32 nFillColorLumMod{}; + xPropertySet->getPropertyValue("FillColorLumMod") >>= nFillColorLumMod; + if (nFillColorLumMod != 10000) + { + mpFS->singleElementNS(XML_a, XML_lumMod, XML_val, OString::number(nFillColorLumMod * 10)); + } + + sal_Int32 nFillColorLumOff{}; + xPropertySet->getPropertyValue("FillColorLumOff") >>= nFillColorLumOff; + if (nFillColorLumOff != 0) + { + mpFS->singleElementNS(XML_a, XML_lumOff, XML_val, OString::number(nFillColorLumOff * 10)); + } + + mpFS->endElementNS(XML_a, XML_schemeClr); mpFS->endElementNS(XML_a, XML_solidFill); return true; -- cgit