diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2023-05-08 14:09:00 +0900 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2023-05-12 05:00:28 +0200 |
commit | 1df0565fb92972bd410e7db85eef1e4bec3fcc31 (patch) | |
tree | 863c5cf54a5941ca84e2d76b68c4e895159d78de /oox/source/export | |
parent | 99a88c9e55872214ce01d89447d18708e47e956b (diff) |
use ComplexColor instead of ThemeColor for better OOXML compat.
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 <quikee@gmail.com>
Diffstat (limited to 'oox/source/export')
-rw-r--r-- | oox/source/export/drawingml.cxx | 38 |
1 files changed, 18 insertions, 20 deletions
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 <editeng/flditem.hxx> #include <editeng/escapementitem.hxx> #include <editeng/unonrule.hxx> -#include <docmodel/uno/UnoThemeColor.hxx> +#include <docmodel/uno/UnoComplexColor.hxx> #include <svx/svdoashp.hxx> #include <svx/svdomedia.hxx> #include <svx/svdtrans.hxx> @@ -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<util::XThemeColor> xThemeColor; - xPropertySet->getPropertyValue(rPropertyName) >>= xThemeColor; - if (!xThemeColor.is()) + uno::Reference<util::XComplexColor> 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<XPropertySet>& 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); } |