diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2023-01-05 23:22:47 +0900 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2023-01-14 04:44:08 +0000 |
commit | 4d17d06279d3bceee8d4b92f444b5e425412c576 (patch) | |
tree | 0a0a833cd62a28a13fbaf7f34a9c6ab0b97f43c6 /svx/source/styles | |
parent | 0b35b239c0ff1adad2c4544d8692b5b13a0d363b (diff) |
svx: add resolveColor that resolves the color for input theme
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 <quikee@gmail.com>
Diffstat (limited to 'svx/source/styles')
-rw-r--r-- | svx/source/styles/ColorSets.cxx | 29 |
1 files changed, 24 insertions, 5 deletions
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<beans::XPropertySet>& 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<sal_Int32>(aColor))); } @@ -74,8 +72,7 @@ void UpdateFillColorSet(const uno::Reference<beans::XPropertySet>& 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<sal_Int32>(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")); |