summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2023-01-05 23:22:47 +0900
committerTomaž Vajngerl <quikee@gmail.com>2023-01-18 12:58:25 +0000
commit5b303365fcdb050a1a5e1421160fa7bc7fdccbde (patch)
tree78b388ad3da10c03b80b3637915c2c1d8e5132b8 /svx
parent80795935980abd9a2b255b8f963691f199d1363f (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> (cherry picked from commit 4d17d06279d3bceee8d4b92f444b5e425412c576) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145653 Tested-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'svx')
-rw-r--r--svx/source/styles/ColorSets.cxx28
1 files changed, 24 insertions, 4 deletions
diff --git a/svx/source/styles/ColorSets.cxx b/svx/source/styles/ColorSets.cxx
index 1cc9e5ed44cf..ee450f4a25ff 100644
--- a/svx/source/styles/ColorSets.cxx
+++ b/svx/source/styles/ColorSets.cxx
@@ -54,8 +54,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::makeAny(static_cast<sal_Int32>(aColor)));
}
@@ -76,8 +75,7 @@ void UpdateFillColorSet(const uno::Reference<beans::XPropertySet>& xShape, svx::
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::makeAny(static_cast<sal_Int32>(aColor)));
}
@@ -127,6 +125,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"));