diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2021-12-06 08:53:50 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2021-12-06 10:10:59 +0100 |
commit | 51c3d8d7f6a2a3b95e97b9a151df0e63ff09cb74 (patch) | |
tree | dea18f57897b38ce35dda03b4e7d26ea81c4c713 | |
parent | f72bb33e78ac9eb7d9f21b61bd89b186547993dd (diff) |
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.
Change-Id: I5e97f890d3072c7ef282ed4fb971362b3ddaaa4d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126400
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
-rw-r--r-- | oox/qa/unit/data/refer-to-theme.pptx | bin | 32686 -> 33853 bytes | |||
-rw-r--r-- | oox/qa/unit/export.cxx | 25 | ||||
-rw-r--r-- | oox/source/export/drawingml.cxx | 24 |
3 files changed, 42 insertions, 7 deletions
diff --git a/oox/qa/unit/data/refer-to-theme.pptx b/oox/qa/unit/data/refer-to-theme.pptx Binary files differindex 9a45799ab977..9f05bf7b07e5 100644 --- a/oox/qa/unit/data/refer-to-theme.pptx +++ b/oox/qa/unit/data/refer-to-theme.pptx diff --git a/oox/qa/unit/export.cxx b/oox/qa/unit/export.cxx index fee130d77971..950a1559f621 100644 --- a/oox/qa/unit/export.cxx +++ b/oox/qa/unit/export.cxx @@ -343,7 +343,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 0c8235a3a1da..249c897740a9 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -431,19 +431,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; |