summaryrefslogtreecommitdiff
path: root/oox/source/drawingml/color.cxx
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2023-02-24 00:29:45 +0900
committerTomaž Vajngerl <quikee@gmail.com>2023-03-22 09:24:46 +0000
commit7a0cf6797bb53d1fec5101a8f7007d2287ae53b0 (patch)
tree1c4b519794844f7e501b7640e095b1e93fb08314 /oox/source/drawingml/color.cxx
parent9111536f1bbaed489ed3ed36315e05d4b3940f5b (diff)
oox: introduce FormatScheme - use in Theme import
Introduces model::FormatScheme as an member of model::Theme, which is used in the theme import. As an first step it imports FillStyleList, but only SolidFill and NoFill. Change-Id: I14a75782ebabcf7ff69b0872752d411183653a47 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147573 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'oox/source/drawingml/color.cxx')
-rw-r--r--oox/source/drawingml/color.cxx56
1 files changed, 41 insertions, 15 deletions
diff --git a/oox/source/drawingml/color.cxx b/oox/source/drawingml/color.cxx
index 9e9218f285e8..592d0734efc2 100644
--- a/oox/source/drawingml/color.cxx
+++ b/oox/source/drawingml/color.cxx
@@ -19,6 +19,7 @@
#include <oox/drawingml/color.hxx>
#include <algorithm>
+#include <unordered_map>
#include <math.h>
#include <osl/diagnose.h>
#include <sal/log.hxx>
@@ -211,6 +212,44 @@ void lclOffValue( sal_Int32& ornValue, sal_Int32 nOff, sal_Int32 nMax = MAX_PERC
} // namespace
+model::ThemeColorType schemeNameToThemeColorType(OUString const& rSchemeName)
+{
+ static std::unordered_map<OUString, model::ThemeColorType> const aSchemeColorNameToIndex{
+ { u"dk1", model::ThemeColorType::Dark1 },
+ { u"lt1", model::ThemeColorType::Light1 },
+ { u"dk2", model::ThemeColorType::Dark2 },
+ { u"lt2", model::ThemeColorType::Light2 },
+ { u"accent1", model::ThemeColorType::Accent1 },
+ { u"accent2", model::ThemeColorType::Accent2 },
+ { u"accent3", model::ThemeColorType::Accent3 },
+ { u"accent4", model::ThemeColorType::Accent4 },
+ { u"accent5", model::ThemeColorType::Accent5 },
+ { u"accent6", model::ThemeColorType::Accent6 },
+ { u"hlink", model::ThemeColorType::Hyperlink },
+ { u"folHlink", model::ThemeColorType::FollowedHyperlink },
+ { u"tx1", model::ThemeColorType::Dark1 },
+ { u"bg1", model::ThemeColorType::Light1 },
+ { u"tx2", model::ThemeColorType::Dark2 },
+ { u"bg2", model::ThemeColorType::Light2 },
+ { u"dark1", model::ThemeColorType::Dark1},
+ { u"light1", model::ThemeColorType::Light1},
+ { u"dark2", model::ThemeColorType::Dark2 },
+ { u"light2", model::ThemeColorType::Light2 },
+ { u"text1", model::ThemeColorType::Dark1 },
+ { u"background1", model::ThemeColorType::Light1 },
+ { u"text2", model::ThemeColorType::Dark2 },
+ { u"background2", model::ThemeColorType::Light2 },
+ { u"hyperlink", model::ThemeColorType::Hyperlink },
+ { u"followedHyperlink", model::ThemeColorType::FollowedHyperlink}
+ };
+
+ auto aIterator = aSchemeColorNameToIndex.find(rSchemeName);
+ if (aIterator == aSchemeColorNameToIndex.end())
+ return model::ThemeColorType::Unknown;
+ else
+ return aIterator->second;
+}
+
Color::Color() :
meMode( COLOR_UNUSED ),
mnC1( 0 ),
@@ -712,21 +751,8 @@ sal_Int16 Color::getTransparency() const
sal_Int16 Color::getSchemeColorIndex() const
{
- static std::map<OUString, sal_Int32> const aSchemeColorNameToIndex{
- { "dk1", 0 }, { "lt1", 1 }, { "dk2", 2 }, { "lt2", 3 },
- { "accent1", 4 }, { "accent2", 5 }, { "accent3", 6 }, { "accent4", 7 },
- { "accent5", 8 }, { "accent6", 9 }, { "hlink", 10 }, { "folHlink", 11 },
- { "tx1", 0 }, { "bg1", 1 }, { "tx2", 2 }, { "bg2", 3 },
- { "dark1", 0}, { "light1", 1}, { "dark2", 2 }, { "light2", 3 },
- { "text1", 0 }, { "background1", 1 }, { "text2", 2 }, { "background2", 3 },
- { "hyperlink", 10 }, { "followedHyperlink", 11}
- };
-
- auto aIt = aSchemeColorNameToIndex.find(msSchemeName);
- if( aIt == aSchemeColorNameToIndex.end() )
- return -1;
- else
- return aIt->second;
+ auto eThemeType = schemeNameToThemeColorType(msSchemeName);
+ return sal_Int16(eThemeType);
}
// private --------------------------------------------------------------------