diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2022-12-12 20:17:09 +0900 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2023-01-12 06:12:10 +0000 |
commit | a047aabb2756d143c8e01c1625ef435188af3085 (patch) | |
tree | 04a98cf3fb06bec887c557223117cb72ed9e6694 /svx | |
parent | 0ba2265645f884d9a3df89fb95e8695998e2a832 (diff) |
svx: rename ThemeColorType enum values, use enum instead of index
Change-Id: I81c1553205365c4076562474078b3b0aa834b249
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143990
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
(cherry picked from commit 1386e26b2d7fc5173266ffbfb94bc82b1d3f7bb9)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145369
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Diffstat (limited to 'svx')
-rw-r--r-- | svx/source/styles/ColorSets.cxx | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/svx/source/styles/ColorSets.cxx b/svx/source/styles/ColorSets.cxx index 88284249fc67..5dc82cf67947 100644 --- a/svx/source/styles/ColorSets.cxx +++ b/svx/source/styles/ColorSets.cxx @@ -28,6 +28,8 @@ #include <svx/svdpage.hxx> #include <svx/svditer.hxx> #include <editeng/unoprnms.hxx> +#include <o3tl/enumrange.hxx> +#include <utility> using namespace com::sun::star; @@ -39,12 +41,12 @@ void UpdateTextPortionColorSet(const uno::Reference<beans::XPropertySet>& 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{}; @@ -74,12 +76,11 @@ void UpdateFillColorSet(const uno::Reference<beans::XPropertySet>& xShape, svx:: 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{}; @@ -273,9 +274,10 @@ void Theme::ToAny(css::uno::Any& rVal) const if (mpColorSet) { std::vector<util::Color> aColorScheme; - for (size_t i = 0; i < 12; ++i) + for (auto eThemeColorType : o3tl::enumrange<svx::ThemeColorType>()) { - aColorScheme.push_back(static_cast<sal_Int32>(mpColorSet->getColor(i))); + Color aColor = mpColorSet->getColor(eThemeColorType); + aColorScheme.push_back(sal_Int32(aColor)); } aMap["ColorSchemeName"] <<= mpColorSet->getName(); @@ -350,14 +352,12 @@ void Theme::UpdateSdrPage(SdrPage* pPage) std::vector<Color> Theme::GetColors() const { if (!mpColorSet) - { return {}; - } std::vector<Color> aColors; - for (size_t i = 0; i < 12; ++i) + for (auto eThemeColorType : o3tl::enumrange<svx::ThemeColorType>()) { - aColors.push_back(mpColorSet->getColor(i)); + aColors.push_back(mpColorSet->getColor(eThemeColorType)); } return aColors; } @@ -365,11 +365,9 @@ std::vector<Color> Theme::GetColors() const Color Theme::GetColor(ThemeColorType eType) const { if (!mpColorSet) - { return {}; - } - return mpColorSet->getColor(static_cast<size_t>(eType)); + return mpColorSet->getColor(eType); } } // end of namespace svx |