summaryrefslogtreecommitdiff
path: root/svx/source/styles
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2021-12-03 08:38:18 +0100
committerMiklos Vajna <vmiklos@collabora.com>2021-12-03 13:34:58 +0100
commit9ebf7034c9cd3a0601542397254ebc97647a862e (patch)
treed5f29dcdb6c623018da2e96af9883040c4167651 /svx/source/styles
parent8e2fe1bb107c263cd3a0b04c14fc0267b3df2380 (diff)
svx: consider color effects when updating objects for theme changes
This builds on top of commit 48f0c5f73f99c919ec24deadc96c3cf5483c9314 (svx: update objects of pages of a master page when the theme changes, 2021-11-30), but now not only plain colors with colors with effects are also considered. The luminance modulation / offset is what PowerPoint uses the generate lighter / darker variants, tinting / shading is what Word uses. Change-Id: Ibfafb9be9986645117015bf3b05491daec8914be Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126270 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'svx/source/styles')
-rw-r--r--svx/source/styles/ColorSets.cxx42
1 files changed, 33 insertions, 9 deletions
diff --git a/svx/source/styles/ColorSets.cxx b/svx/source/styles/ColorSets.cxx
index a5f8c6e7c548..30a9dd423d78 100644
--- a/svx/source/styles/ColorSets.cxx
+++ b/svx/source/styles/ColorSets.cxx
@@ -33,6 +33,38 @@ using namespace com::sun::star;
namespace
{
+/// Updates a text portion to match a new color set, in case it already uses theme colors.
+void UpdateTextPortionColorSet(const uno::Reference<beans::XPropertySet>& xPortion,
+ svx::ColorSet& rColorSet)
+{
+ sal_Int16 nCharColorTheme = -1;
+ xPortion->getPropertyValue(UNO_NAME_EDIT_CHAR_COLOR_THEME) >>= nCharColorTheme;
+ if (nCharColorTheme < 0 || nCharColorTheme > 11)
+ {
+ return;
+ }
+
+ Color aColor = rColorSet.getColor(nCharColorTheme);
+ sal_Int32 nCharColorLumMod{};
+ xPortion->getPropertyValue(UNO_NAME_EDIT_CHAR_COLOR_LUM_MOD) >>= nCharColorLumMod;
+ sal_Int32 nCharColorLumOff{};
+ xPortion->getPropertyValue(UNO_NAME_EDIT_CHAR_COLOR_LUM_OFF) >>= nCharColorLumOff;
+ if (nCharColorLumMod != 10000 || nCharColorLumOff != 0)
+ {
+ aColor.ApplyLumModOff(nCharColorLumMod, nCharColorLumOff);
+ }
+
+ sal_Int32 nCharColorTintOrShade{};
+ xPortion->getPropertyValue(UNO_NAME_EDIT_CHAR_COLOR_TINT_OR_SHADE) >>= nCharColorTintOrShade;
+ if (nCharColorTintOrShade != 0)
+ {
+ aColor.ApplyTintOrShade(nCharColorTintOrShade);
+ }
+
+ xPortion->setPropertyValue(UNO_NAME_EDIT_CHAR_COLOR,
+ uno::makeAny(static_cast<sal_Int32>(aColor)));
+}
+
void UpdateSdrObject(svx::Theme* pTheme, SdrObject* pObject)
{
svx::ColorSet* pColorSet = pTheme->GetColorSet();
@@ -51,15 +83,7 @@ void UpdateSdrObject(svx::Theme* pTheme, SdrObject* pObject)
while (xPortions->hasMoreElements())
{
uno::Reference<beans::XPropertySet> xPortion(xPortions->nextElement(), uno::UNO_QUERY);
- sal_Int16 nCharColorTheme = -1;
- xPortion->getPropertyValue(UNO_NAME_EDIT_CHAR_COLOR_THEME) >>= nCharColorTheme;
- if (nCharColorTheme < 0 || nCharColorTheme > 11)
- {
- continue;
- }
-
- Color aColor = pColorSet->getColor(nCharColorTheme);
- xPortion->setPropertyValue(UNO_NAME_EDIT_CHAR_COLOR, uno::makeAny(static_cast<sal_Int32>(aColor)));
+ UpdateTextPortionColorSet(xPortion, *pColorSet);
}
}
}