From 197e5f81213d14fdcbff40edf73385ecd4cd9815 Mon Sep 17 00:00:00 2001 From: Tomaž Vajngerl Date: Sun, 1 Jan 2023 23:25:38 +0900 Subject: introduce {Char,Fill}ColorThemeReference which uses XThemeColor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds a unified UNO property for theme colors *ColorTheme (CharColorTheme and FillColorTheme) which uses XThemeColor, that replaces the properties *Theme, *TintOrShade, *LumOff, *LumMod. The properties are still present for backwards compatibility and to keep ODF support working in tests as that needs a bigger change. Reactor the code and tests to accomodate for this change. Change-Id: If7983decb4ba528b49fe7b5968aa9efc696a9efc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144783 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl --- svx/source/styles/ColorSets.cxx | 62 +++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 37 deletions(-) (limited to 'svx/source/styles') diff --git a/svx/source/styles/ColorSets.cxx b/svx/source/styles/ColorSets.cxx index 00ffdae3b031..b8a4fa08e157 100644 --- a/svx/source/styles/ColorSets.cxx +++ b/svx/source/styles/ColorSets.cxx @@ -26,6 +26,7 @@ #include #include #include +#include #include #include @@ -37,57 +38,44 @@ namespace void UpdateTextPortionColorSet(const uno::Reference& xPortion, const svx::ColorSet& rColorSet) { - sal_Int16 nCharColorTheme = -1; - xPortion->getPropertyValue(UNO_NAME_EDIT_CHAR_COLOR_THEME) >>= nCharColorTheme; - model::ThemeColorType eColorThemeType = model::convertToThemeColorType(nCharColorTheme); + if (!xPortion->getPropertySetInfo()->hasPropertyByName(UNO_NAME_EDIT_CHAR_COLOR_THEME_REFERENCE)) + return; - if (eColorThemeType == model::ThemeColorType::Unknown) + uno::Reference xThemeColor; + xPortion->getPropertyValue(UNO_NAME_EDIT_CHAR_COLOR_THEME_REFERENCE) >>= xThemeColor; + if (!xThemeColor.is()) return; - Color aColor = rColorSet.getColor(eColorThemeType); - 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); - } + model::ThemeColor aThemeColor; + model::theme::setFromXThemeColor(aThemeColor, xThemeColor); - sal_Int32 nCharColorTintOrShade{}; - xPortion->getPropertyValue(UNO_NAME_EDIT_CHAR_COLOR_TINT_OR_SHADE) >>= nCharColorTintOrShade; - if (nCharColorTintOrShade != 0) - { - aColor.ApplyTintOrShade(nCharColorTintOrShade); - } + if (aThemeColor.getType() == model::ThemeColorType::Unknown) + return; + + Color aColor = rColorSet.getColor(aThemeColor.getType()); + aColor = aThemeColor.applyTransformations(aColor); - xPortion->setPropertyValue(UNO_NAME_EDIT_CHAR_COLOR, - uno::Any(static_cast(aColor))); + xPortion->setPropertyValue(UNO_NAME_EDIT_CHAR_COLOR, uno::Any(static_cast(aColor))); } void UpdateFillColorSet(const uno::Reference& xShape, const svx::ColorSet& rColorSet) { - if (!xShape->getPropertySetInfo()->hasPropertyByName(UNO_NAME_FILLCOLOR_THEME)) - { + if (!xShape->getPropertySetInfo()->hasPropertyByName(UNO_NAME_FILLCOLOR_THEME_REFERENCE)) return; - } - sal_Int16 nFillColorTheme = -1; - xShape->getPropertyValue(UNO_NAME_FILLCOLOR_THEME) >>= nFillColorTheme; - model::ThemeColorType eColorThemeType = model::convertToThemeColorType(nFillColorTheme); - if (eColorThemeType == model::ThemeColorType::Unknown) + uno::Reference xThemeColor; + xShape->getPropertyValue(UNO_NAME_FILLCOLOR_THEME_REFERENCE) >>= xThemeColor; + if (!xThemeColor.is()) return; - Color aColor = rColorSet.getColor(eColorThemeType); - sal_Int32 nFillColorLumMod{}; - xShape->getPropertyValue(UNO_NAME_FILLCOLOR_LUM_MOD) >>= nFillColorLumMod; - sal_Int32 nFillColorLumOff{}; - xShape->getPropertyValue(UNO_NAME_FILLCOLOR_LUM_OFF) >>= nFillColorLumOff; - if (nFillColorLumMod != 10000 || nFillColorLumOff != 0) - { - aColor.ApplyLumModOff(nFillColorLumMod, nFillColorLumOff); - } + model::ThemeColor aThemeColor; + model::theme::setFromXThemeColor(aThemeColor, xThemeColor); + + if (aThemeColor.getType() == model::ThemeColorType::Unknown) + return; + Color aColor = rColorSet.getColor(aThemeColor.getType()); + aColor = aThemeColor.applyTransformations(aColor); xShape->setPropertyValue(UNO_NAME_FILLCOLOR, uno::Any(static_cast(aColor))); } -- cgit