summaryrefslogtreecommitdiff
path: root/svx/source/styles
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2022-12-12 20:17:09 +0900
committerTomaž Vajngerl <quikee@gmail.com>2022-12-26 07:53:45 +0000
commit1386e26b2d7fc5173266ffbfb94bc82b1d3f7bb9 (patch)
tree4dc37db1a0716db7452af316ec7f3a178dd7357e /svx/source/styles
parent18b39c8c9b35528c8fb172339126b613827d09aa (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>
Diffstat (limited to 'svx/source/styles')
-rw-r--r--svx/source/styles/ColorSets.cxx31
1 files changed, 14 insertions, 17 deletions
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 <svx/svdpage.hxx>
#include <svx/svditer.hxx>
#include <editeng/unoprnms.hxx>
+#include <o3tl/enumrange.hxx>
#include <utility>
using namespace com::sun::star;
@@ -38,12 +39,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{};
@@ -73,12 +74,11 @@ void UpdateFillColorSet(const uno::Reference<beans::XPropertySet>& 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<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();
@@ -349,14 +350,12 @@ void Theme::UpdateSdrPage(const 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;
}
@@ -364,11 +363,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