summaryrefslogtreecommitdiff
path: root/svx/source/styles
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2023-01-01 23:25:38 +0900
committerTomaž Vajngerl <quikee@gmail.com>2023-01-13 00:49:24 +0000
commit197e5f81213d14fdcbff40edf73385ecd4cd9815 (patch)
tree5bc1735ec61200a895b5edcf684d846245286ba5 /svx/source/styles
parentc82fa434dab8744c548db166cd24ee82e8759e1f (diff)
introduce {Char,Fill}ColorThemeReference which uses XThemeColor
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 <quikee@gmail.com>
Diffstat (limited to 'svx/source/styles')
-rw-r--r--svx/source/styles/ColorSets.cxx62
1 files changed, 25 insertions, 37 deletions
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 <svx/svdpage.hxx>
#include <svx/svditer.hxx>
#include <editeng/unoprnms.hxx>
+#include <docmodel/uno/UnoThemeColor.hxx>
#include <o3tl/enumrange.hxx>
#include <utility>
@@ -37,57 +38,44 @@ namespace
void UpdateTextPortionColorSet(const uno::Reference<beans::XPropertySet>& 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<util::XThemeColor> 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<sal_Int32>(aColor)));
+ xPortion->setPropertyValue(UNO_NAME_EDIT_CHAR_COLOR, uno::Any(static_cast<sal_Int32>(aColor)));
}
void UpdateFillColorSet(const uno::Reference<beans::XPropertySet>& 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<util::XThemeColor> 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<sal_Int32>(aColor)));
}