oox/qa/unit/data/refer-to-theme.pptx |binary oox/qa/unit/export.cxx | 25 ++++++++++++++++++++++++- oox/source/export/drawingml.cxx | 24 ++++++++++++++++++------ 3 files changed, 42 insertions(+), 7 deletions(-)
New commits: commit f67b10f2a34b4180c4e7fd9191ed5abf45f7b29a Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Mon Dec 6 08:53:50 2021 +0100 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Tue Jun 28 08:14:37 2022 +0200 PPTX export: handle theme color of shape text with effects Handle luminance modulation and offset (lighter and darker colors in PowerPoint); not handling tinting/shading for now, as that seems to be not used in DrawingML (only in WordprocessingML), and this code is for shape text only at the moment. (cherry picked from commit 51c3d8d7f6a2a3b95e97b9a151df0e63ff09cb74) Change-Id: I5e97f890d3072c7ef282ed4fb971362b3ddaaa4d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136494 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Miklos Vajna <vmik...@collabora.com> diff --git a/oox/qa/unit/data/refer-to-theme.pptx b/oox/qa/unit/data/refer-to-theme.pptx index 9a45799ab977..9f05bf7b07e5 100644 Binary files a/oox/qa/unit/data/refer-to-theme.pptx and b/oox/qa/unit/data/refer-to-theme.pptx differ diff --git a/oox/qa/unit/export.cxx b/oox/qa/unit/export.cxx index 58169c558e48..960df6dd43e7 100644 --- a/oox/qa/unit/export.cxx +++ b/oox/qa/unit/export.cxx @@ -587,7 +587,30 @@ CPPUNIT_TEST_FIXTURE(Test, testReferToTheme) // - Actual : 0 // - XPath '//p:sp/p:txBody/a:p/a:r/a:rPr/a:solidFill/a:schemeClr' number of nodes is incorrect // i.e. the <a:schemeClr> element was not written. - assertXPath(pXmlDoc, "//p:sp/p:txBody/a:p/a:r/a:rPr/a:solidFill/a:schemeClr", "val", "accent1"); + assertXPath(pXmlDoc, "//p:sp[1]/p:txBody/a:p/a:r/a:rPr/a:solidFill/a:schemeClr", "val", + "accent1"); + assertXPath(pXmlDoc, "//p:sp[1]/p:txBody/a:p/a:r/a:rPr/a:solidFill/a:schemeClr/a:lumMod", 0); + assertXPath(pXmlDoc, "//p:sp[1]/p:txBody/a:p/a:r/a:rPr/a:solidFill/a:schemeClr/a:lumOff", 0); + + // Second shape: lighter color: + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 1 + // - Actual : 0 + // - XPath '//p:sp[2]/p:txBody/a:p/a:r/a:rPr/a:solidFill/a:schemeClr' number of nodes is incorrect + // i.e. the effects case did not write scheme colors. + assertXPath(pXmlDoc, "//p:sp[2]/p:txBody/a:p/a:r/a:rPr/a:solidFill/a:schemeClr", "val", + "accent1"); + assertXPath(pXmlDoc, "//p:sp[2]/p:txBody/a:p/a:r/a:rPr/a:solidFill/a:schemeClr/a:lumMod", "val", + "40000"); + assertXPath(pXmlDoc, "//p:sp[2]/p:txBody/a:p/a:r/a:rPr/a:solidFill/a:schemeClr/a:lumOff", "val", + "60000"); + + // Third shape, darker color: + assertXPath(pXmlDoc, "//p:sp[3]/p:txBody/a:p/a:r/a:rPr/a:solidFill/a:schemeClr", "val", + "accent1"); + assertXPath(pXmlDoc, "//p:sp[3]/p:txBody/a:p/a:r/a:rPr/a:solidFill/a:schemeClr/a:lumMod", "val", + "75000"); + assertXPath(pXmlDoc, "//p:sp[3]/p:txBody/a:p/a:r/a:rPr/a:solidFill/a:schemeClr/a:lumOff", 0); } } diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx index 45274efa9315..46098e9d04a3 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -433,19 +433,31 @@ bool DrawingML::WriteCharColor(const css::uno::Reference<css::beans::XPropertySe const char* pColorName = g_aPredefinedClrNames[nCharColorTheme]; - sal_Int32 nCharColorLumMod{}; - xPropertySet->getPropertyValue("CharColorLumMod") >>= nCharColorLumMod; - sal_Int32 nCharColorLumOff{}; - xPropertySet->getPropertyValue("CharColorLumOff") >>= nCharColorLumOff; sal_Int32 nCharColorTintOrShade{}; xPropertySet->getPropertyValue("CharColorTintOrShade") >>= nCharColorTintOrShade; - if (nCharColorLumMod != 10000 || nCharColorLumOff != 0 || nCharColorTintOrShade != 0) + if (nCharColorTintOrShade != 0) { return false; } 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 nCharColorLumMod{}; + xPropertySet->getPropertyValue("CharColorLumMod") >>= nCharColorLumMod; + if (nCharColorLumMod != 10000) + { + mpFS->singleElementNS(XML_a, XML_lumMod, XML_val, OString::number(nCharColorLumMod * 10)); + } + + sal_Int32 nCharColorLumOff{}; + xPropertySet->getPropertyValue("CharColorLumOff") >>= nCharColorLumOff; + if (nCharColorLumOff != 0) + { + mpFS->singleElementNS(XML_a, XML_lumOff, XML_val, OString::number(nCharColorLumOff * 10)); + } + + mpFS->endElementNS(XML_a, XML_schemeClr); mpFS->endElementNS(XML_a, XML_solidFill); return true;