From 1df0565fb92972bd410e7db85eef1e4bec3fcc31 Mon Sep 17 00:00:00 2001 From: Tomaž Vajngerl Date: Mon, 8 May 2023 14:09:00 +0900 Subject: use ComplexColor instead of ThemeColor for better OOXML compat. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In OOXML a color definition includes more represenations, one of which is scheme color (which is what is implemented in ThemeColor currently), but it supports other representations too (RGB, HSL, System,..). ComplexColor includes all the representations, so to have a better compatibility with OOXML, this changes all uses of ThemeColor to ComplexColor. In many cases the usage of ComplexColor isn't the same as the usage of ThemeColors, but this cases will need to be changed in a later commit. Change-Id: I9cc8acee2ac0a1998fe9b98247bcf4a96273149a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151492 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl --- oox/source/export/drawingml.cxx | 38 ++++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 20 deletions(-) (limited to 'oox/source/export') diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx index 9f705a20cf9e..fa587d6190bf 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -128,7 +128,7 @@ #include #include #include -#include +#include #include #include #include @@ -516,7 +516,7 @@ void DrawingML::WriteSolidFill( const Reference< XPropertySet >& rXPropSet ) else if ( nFillColor != nOriginalColor ) { // the user has set a different color for the shape - if (!WriteSchemeColor(u"FillColorThemeReference", rXPropSet)) + if (!WriteSchemeColor(u"FillComplexColor", rXPropSet)) { WriteSolidFill(::Color(ColorTransparency, nFillColor & 0xffffff), nAlpha); } @@ -540,19 +540,18 @@ bool DrawingML::WriteSchemeColor(OUString const& rPropertyName, const uno::Refer if (!xPropertySet->getPropertySetInfo()->hasPropertyByName(rPropertyName)) return false; - uno::Reference xThemeColor; - xPropertySet->getPropertyValue(rPropertyName) >>= xThemeColor; - if (!xThemeColor.is()) + uno::Reference xComplexColor; + xPropertySet->getPropertyValue(rPropertyName) >>= xComplexColor; + if (!xComplexColor.is()) return false; - model::ThemeColor aThemeColor; - model::theme::setFromXThemeColor(aThemeColor, xThemeColor); - if (aThemeColor.getType() == model::ThemeColorType::Unknown) + auto aComplexColor = model::color::getFromXComplexColor(xComplexColor); + if (aComplexColor.getSchemeType() == model::ThemeColorType::Unknown) return false; - const char* pColorName = g_aPredefinedClrNames[sal_Int16(aThemeColor.getType())]; + const char* pColorName = g_aPredefinedClrNames[sal_Int16(aComplexColor.getSchemeType())]; mpFS->startElementNS(XML_a, XML_solidFill); mpFS->startElementNS(XML_a, XML_schemeClr, XML_val, pColorName); - for (auto const& rTransform : aThemeColor.getTransformations()) + for (auto const& rTransform : aComplexColor.getTransformations()) { switch (rTransform.meType) { @@ -574,13 +573,12 @@ bool DrawingML::WriteSchemeColor(OUString const& rPropertyName, const uno::Refer } // Alpha is actually not contained in maTransformations although possible (as of Mar 2023). sal_Int16 nAPITransparency(0); - if ((rPropertyName == u"FillColorThemeReference" - && GetProperty(xPropertySet, "FillTransparence")) - || (rPropertyName == u"LineColorThemeReference" - && GetProperty(xPropertySet, "LineTransparence")) - || (rPropertyName == u"CharColorThemeReference" - && GetProperty(xPropertySet, "CharTransparence"))) + if ((rPropertyName == u"FillComplexColor" && GetProperty(xPropertySet, "FillTransparence")) + || (rPropertyName == u"LineComplexColor" && GetProperty(xPropertySet, "LineTransparence")) + || (rPropertyName == u"CharComplexColor" && GetProperty(xPropertySet, "CharTransparence"))) + { mAny >>= nAPITransparency; + } if (nAPITransparency != 0) mpFS->singleElementNS(XML_a, XML_alpha, XML_val, OString::number(MAX_PERCENT - (PER_PERCENT * nAPITransparency))); @@ -1145,8 +1143,8 @@ void DrawingML::WriteOutline( const Reference& rXPropSet, Referenc if( nColor != nOriginalColor ) { // the user has set a different color for the line - if (!WriteSchemeColor(u"LineColorThemeReference", rXPropSet)) - WriteSolidFill(nColor, nColorAlpha); + if (!WriteSchemeColor(u"LineComplexColor", rXPropSet)) + WriteSolidFill(nColor, nColorAlpha); } else if( !sColorFillScheme.isEmpty() ) { @@ -2673,7 +2671,7 @@ void DrawingML::WriteRunProperties( const Reference< XPropertySet >& rRun, bool else { color.SetAlpha(255); - if (!WriteSchemeColor(u"CharColorThemeReference", rXPropSet)) + if (!WriteSchemeColor(u"CharComplexColor", rXPropSet)) WriteSolidFill(color, nTransparency); } mpFS->endElementNS(XML_a, XML_ln); @@ -2686,7 +2684,7 @@ void DrawingML::WriteRunProperties( const Reference< XPropertySet >& rRun, bool { color.SetAlpha(255); // TODO: special handle embossed/engraved - if (!WriteSchemeColor(u"CharColorThemeReference", rXPropSet)) + if (!WriteSchemeColor(u"CharComplexColor", rXPropSet)) { WriteSolidFill(color, nTransparency); } -- cgit