summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2021-12-06 08:53:50 +0100
committerMiklos Vajna <vmiklos@collabora.com>2022-06-28 08:14:37 +0200
commitf67b10f2a34b4180c4e7fd9191ed5abf45f7b29a (patch)
tree15f02c24dcf844496146cfc9be27d2d6467a205d /oox
parent121786fd81b3df3160d620bfc4b3916ac81fbc4c (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. (cherry picked from commit 51c3d8d7f6a2a3b95e97b9a151df0e63ff09cb74) Change-Id: I5e97f890d3072c7ef282ed4fb971362b3ddaaa4d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136494 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'oox')
-rw-r--r--oox/qa/unit/data/refer-to-theme.pptxbin32686 -> 33853 bytes
-rw-r--r--oox/qa/unit/export.cxx25
-rw-r--r--oox/source/export/drawingml.cxx24
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
index 9a45799ab977..9f05bf7b07e5 100644
--- a/oox/qa/unit/data/refer-to-theme.pptx
+++ b/oox/qa/unit/data/refer-to-theme.pptx
Binary files 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;