From 4d17d06279d3bceee8d4b92f444b5e425412c576 Mon Sep 17 00:00:00 2001 From: Tomaž Vajngerl Date: Thu, 5 Jan 2023 23:22:47 +0900 Subject: svx: add resolveColor that resolves the color for input theme MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit resolveColor added to ColorSet resolves the color for the input ThemeColor, which contains the index for the color in the ColorSet and applies all the additional tranformations defined in the ThemeColor. Change-Id: I5c6d53d5e1d2c61bdb22b0e58c034ec91fbeb2d4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145085 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl --- svx/source/styles/ColorSets.cxx | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) (limited to 'svx/source/styles') diff --git a/svx/source/styles/ColorSets.cxx b/svx/source/styles/ColorSets.cxx index 0f24480c15e6..cf634b735c37 100644 --- a/svx/source/styles/ColorSets.cxx +++ b/svx/source/styles/ColorSets.cxx @@ -52,9 +52,7 @@ void UpdateTextPortionColorSet(const uno::Reference& xPorti if (aThemeColor.getType() == model::ThemeColorType::Unknown) return; - Color aColor = rColorSet.getColor(aThemeColor.getType()); - aColor = aThemeColor.applyTransformations(aColor); - + Color aColor = rColorSet.resolveColor(aThemeColor); xPortion->setPropertyValue(UNO_NAME_EDIT_CHAR_COLOR, uno::Any(static_cast(aColor))); } @@ -74,8 +72,7 @@ void UpdateFillColorSet(const uno::Reference& xShape, const if (aThemeColor.getType() == model::ThemeColorType::Unknown) return; - Color aColor = rColorSet.getColor(aThemeColor.getType()); - aColor = aThemeColor.applyTransformations(aColor); + Color aColor = rColorSet.resolveColor(aThemeColor); xShape->setPropertyValue(UNO_NAME_FILLCOLOR, uno::Any(static_cast(aColor))); } @@ -125,6 +122,28 @@ void ColorSet::add(model::ThemeColorType eType, Color aColorData) maColors[sal_Int16(eType)] = aColorData; } +Color ColorSet::getColor(model::ThemeColorType eType) const +{ + if (eType == model::ThemeColorType::Unknown) + { + SAL_WARN("svx", "ColorSet::getColor with ThemeColorType::Unknown"); + return COL_AUTO; + } + return maColors[size_t(eType)]; +} + +Color ColorSet::resolveColor(model::ThemeColor const& rThemeColor) const +{ + auto eType = rThemeColor.getType(); + if (eType == model::ThemeColorType::Unknown) + { + SAL_WARN("svx", "ColorSet::resolveColor with ThemeColorType::Unknown"); + return COL_AUTO; + } + Color aColor = getColor(eType); + return rThemeColor.applyTransformations(aColor); +} + void ColorSet::dumpAsXml(xmlTextWriterPtr pWriter) const { (void)xmlTextWriterStartElement(pWriter, BAD_CAST("ColorSet")); -- cgit