From 1386e26b2d7fc5173266ffbfb94bc82b1d3f7bb9 Mon Sep 17 00:00:00 2001 From: Tomaž Vajngerl Date: Mon, 12 Dec 2022 20:17:09 +0900 Subject: svx: rename ThemeColorType enum values, use enum instead of index MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I81c1553205365c4076562474078b3b0aa834b249 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143990 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl --- svx/source/styles/ColorSets.cxx | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) (limited to 'svx/source/styles') diff --git a/svx/source/styles/ColorSets.cxx b/svx/source/styles/ColorSets.cxx index 0dde00e219c0..6af2ee6313bc 100644 --- a/svx/source/styles/ColorSets.cxx +++ b/svx/source/styles/ColorSets.cxx @@ -26,6 +26,7 @@ #include #include #include +#include #include using namespace com::sun::star; @@ -38,12 +39,12 @@ void UpdateTextPortionColorSet(const uno::Reference& xPorti { sal_Int16 nCharColorTheme = -1; xPortion->getPropertyValue(UNO_NAME_EDIT_CHAR_COLOR_THEME) >>= nCharColorTheme; - if (nCharColorTheme < 0 || nCharColorTheme > 11) - { + svx::ThemeColorType eColorThemeType = svx::convertToThemeColorType(nCharColorTheme); + + if (eColorThemeType == svx::ThemeColorType::Unknown) return; - } - Color aColor = rColorSet.getColor(nCharColorTheme); + Color aColor = rColorSet.getColor(eColorThemeType); sal_Int32 nCharColorLumMod{}; xPortion->getPropertyValue(UNO_NAME_EDIT_CHAR_COLOR_LUM_MOD) >>= nCharColorLumMod; sal_Int32 nCharColorLumOff{}; @@ -73,12 +74,11 @@ void UpdateFillColorSet(const uno::Reference& xShape, const sal_Int16 nFillColorTheme = -1; xShape->getPropertyValue(UNO_NAME_FILLCOLOR_THEME) >>= nFillColorTheme; - if (nFillColorTheme < 0 || nFillColorTheme > 11) - { + svx::ThemeColorType eColorThemeType = svx::convertToThemeColorType(nFillColorTheme); + if (eColorThemeType == svx::ThemeColorType::Unknown) return; - } - Color aColor = rColorSet.getColor(nFillColorTheme); + Color aColor = rColorSet.getColor(eColorThemeType); sal_Int32 nFillColorLumMod{}; xShape->getPropertyValue(UNO_NAME_FILLCOLOR_LUM_MOD) >>= nFillColorLumMod; sal_Int32 nFillColorLumOff{}; @@ -272,9 +272,10 @@ void Theme::ToAny(css::uno::Any& rVal) const if (mpColorSet) { std::vector aColorScheme; - for (size_t i = 0; i < 12; ++i) + for (auto eThemeColorType : o3tl::enumrange()) { - aColorScheme.push_back(static_cast(mpColorSet->getColor(i))); + Color aColor = mpColorSet->getColor(eThemeColorType); + aColorScheme.push_back(sal_Int32(aColor)); } aMap["ColorSchemeName"] <<= mpColorSet->getName(); @@ -349,14 +350,12 @@ void Theme::UpdateSdrPage(const SdrPage* pPage) std::vector Theme::GetColors() const { if (!mpColorSet) - { return {}; - } std::vector aColors; - for (size_t i = 0; i < 12; ++i) + for (auto eThemeColorType : o3tl::enumrange()) { - aColors.push_back(mpColorSet->getColor(i)); + aColors.push_back(mpColorSet->getColor(eThemeColorType)); } return aColors; } @@ -364,11 +363,9 @@ std::vector Theme::GetColors() const Color Theme::GetColor(ThemeColorType eType) const { if (!mpColorSet) - { return {}; - } - return mpColorSet->getColor(static_cast(eType)); + return mpColorSet->getColor(eType); } } // end of namespace svx -- cgit