diff options
-rw-r--r-- | include/svx/ColorSets.hxx | 2 | ||||
-rw-r--r-- | oox/source/drawingml/clrscheme.cxx | 24 | ||||
-rw-r--r-- | svx/source/styles/ColorSets.cxx | 109 |
3 files changed, 49 insertions, 86 deletions
diff --git a/include/svx/ColorSets.hxx b/include/svx/ColorSets.hxx index a5d41cc05a57..174e3ff70cce 100644 --- a/include/svx/ColorSets.hxx +++ b/include/svx/ColorSets.hxx @@ -36,7 +36,7 @@ class SVXCORE_DLLPUBLIC ColorSet public: ColorSet(OUString const& rName); - void add(sal_uInt32 nIndex, Color aColorData); + void add(model::ThemeColorType Type, Color aColorData); const OUString& getName() const { diff --git a/oox/source/drawingml/clrscheme.cxx b/oox/source/drawingml/clrscheme.cxx index 5360ae423478..f4f14d0e1bce 100644 --- a/oox/source/drawingml/clrscheme.cxx +++ b/oox/source/drawingml/clrscheme.cxx @@ -137,21 +137,21 @@ void ClrScheme::fill(svx::ColorSet& rColorSet) const switch (nToken) { case XML_tx1: - case XML_dk1: rColorSet.add(0, rColor); break; + case XML_dk1: rColorSet.add(model::ThemeColorType::Dark1, rColor); break; case XML_bg1: - case XML_lt1: rColorSet.add(1, rColor); break; + case XML_lt1: rColorSet.add(model::ThemeColorType::Light1, rColor); break; case XML_tx2: - case XML_dk2: rColorSet.add(2, rColor); break; + case XML_dk2: rColorSet.add(model::ThemeColorType::Dark2, rColor); break; case XML_bg2: - case XML_lt2: rColorSet.add(3, rColor); break; - case XML_accent1: rColorSet.add(4, rColor); break; - case XML_accent2: rColorSet.add(5, rColor); break; - case XML_accent3: rColorSet.add(6, rColor); break; - case XML_accent4: rColorSet.add(7, rColor); break; - case XML_accent5: rColorSet.add(8, rColor); break; - case XML_accent6: rColorSet.add(9, rColor); break; - case XML_hlink: rColorSet.add(10, rColor); break; - case XML_folHlink: rColorSet.add(11, rColor); break; + case XML_lt2: rColorSet.add(model::ThemeColorType::Light2, rColor); break; + case XML_accent1: rColorSet.add(model::ThemeColorType::Accent1, rColor); break; + case XML_accent2: rColorSet.add(model::ThemeColorType::Accent2, rColor); break; + case XML_accent3: rColorSet.add(model::ThemeColorType::Accent3, rColor); break; + case XML_accent4: rColorSet.add(model::ThemeColorType::Accent4, rColor); break; + case XML_accent5: rColorSet.add(model::ThemeColorType::Accent5, rColor); break; + case XML_accent6: rColorSet.add(model::ThemeColorType::Accent6, rColor); break; + case XML_hlink: rColorSet.add(model::ThemeColorType::Hyperlink, rColor); break; + case XML_folHlink: rColorSet.add(model::ThemeColorType::FollowedHyperlink, rColor); break; default: break; } } diff --git a/svx/source/styles/ColorSets.cxx b/svx/source/styles/ColorSets.cxx index b8a4fa08e157..0f24480c15e6 100644 --- a/svx/source/styles/ColorSets.cxx +++ b/svx/source/styles/ColorSets.cxx @@ -118,9 +118,11 @@ ColorSet::ColorSet(OUString const& rName) : maName(rName) {} -void ColorSet::add(sal_uInt32 nIndex, Color aColorData) +void ColorSet::add(model::ThemeColorType eType, Color aColorData) { - maColors[nIndex] = aColorData; + if (eType == model::ThemeColorType::Unknown) + return; + maColors[sal_Int16(eType)] = aColorData; } void ColorSet::dumpAsXml(xmlTextWriterPtr pWriter) const @@ -150,70 +152,22 @@ ColorSets::~ColorSets() void ColorSets::init() { - { + //{ ColorSet aColorSet("Breeze"); - aColorSet.add(0, 0xFCFCFC); - aColorSet.add(1, 0x232629); - aColorSet.add(2, 0xEFF0F1); - aColorSet.add(3, 0x31363B); - aColorSet.add(4, 0xDA4453); - aColorSet.add(5, 0xF47750); - aColorSet.add(6, 0xFDBC4B); - aColorSet.add(7, 0xC9CE3B); - aColorSet.add(8, 0x1CDC9A); - aColorSet.add(9, 0x2ECC71); - aColorSet.add(10, 0x1D99F3); - aColorSet.add(11, 0x3DAEE9); - maColorSets.push_back(aColorSet); - } - { - ColorSet aColorSet("Material Blue"); - aColorSet.add(0, 0xFFFFFF); - aColorSet.add(1, 0x212121); - aColorSet.add(2, 0xECEFF1); - aColorSet.add(3, 0x37474F); - aColorSet.add(4, 0x7986CB); - aColorSet.add(5, 0x303F9F); - aColorSet.add(6, 0x64B5F6); - aColorSet.add(7, 0x1976D2); - aColorSet.add(8, 0x4FC3F7); - aColorSet.add(9, 0x0277BD); - aColorSet.add(10, 0x4DD0E1); - aColorSet.add(11, 0x0097A7); - maColorSets.push_back(aColorSet); - } - { - ColorSet aColorSet("Material Red"); - aColorSet.add(0, 0xFFFFFF); - aColorSet.add(1, 0x212121); - aColorSet.add(2, 0xF5F5F5); - aColorSet.add(3, 0x424242); - aColorSet.add(4, 0xFF9800); - aColorSet.add(5, 0xFF6D00); - aColorSet.add(6, 0xFF5722); - aColorSet.add(7, 0xDD2C00); - aColorSet.add(8, 0xF44336); - aColorSet.add(9, 0xD50000); - aColorSet.add(10, 0xE91E63); - aColorSet.add(11, 0xC51162); - maColorSets.push_back(aColorSet); - } - { - ColorSet aColorSet("Material Green"); - aColorSet.add(0, 0xFFFFFF); - aColorSet.add(1, 0x212121); - aColorSet.add(2, 0xF5F5F5); - aColorSet.add(3, 0x424242); - aColorSet.add(4, 0x009688); - aColorSet.add(5, 0x00bfa5); - aColorSet.add(6, 0x4caf50); - aColorSet.add(7, 0x00c853); - aColorSet.add(8, 0x8bc34a); - aColorSet.add(9, 0x64dd17); - aColorSet.add(10, 0xcddc39); - aColorSet.add(11, 0xaeea00); + aColorSet.add(model::ThemeColorType::Dark1, 0x232629); + aColorSet.add(model::ThemeColorType::Light1, 0xFCFCFC); + aColorSet.add(model::ThemeColorType::Dark2, 0x31363B); + aColorSet.add(model::ThemeColorType::Light2, 0xEFF0F1); + aColorSet.add(model::ThemeColorType::Accent1, 0xDA4453); + aColorSet.add(model::ThemeColorType::Accent2, 0xF47750); + aColorSet.add(model::ThemeColorType::Accent3, 0xFDBC4B); + aColorSet.add(model::ThemeColorType::Accent4, 0xC9CE3B); + aColorSet.add(model::ThemeColorType::Accent5, 0x1CDC9A); + aColorSet.add(model::ThemeColorType::Accent6, 0x2ECC71); + aColorSet.add(model::ThemeColorType::Hyperlink, 0x1D99F3); + aColorSet.add(model::ThemeColorType::FollowedHyperlink, 0x3DAEE9); maColorSets.push_back(aColorSet); - } + //} } const ColorSet& ColorSets::getColorSet(std::u16string_view rName) @@ -271,8 +225,11 @@ void Theme::ToAny(css::uno::Any& rVal) const std::vector<util::Color> aColorScheme; for (auto eThemeColorType : o3tl::enumrange<model::ThemeColorType>()) { - Color aColor = mpColorSet->getColor(eThemeColorType); - aColorScheme.push_back(sal_Int32(aColor)); + if (eThemeColorType != model::ThemeColorType::Unknown) + { + Color aColor = mpColorSet->getColor(eThemeColorType); + aColorScheme.push_back(sal_Int32(aColor)); + } } aMap["ColorSchemeName"] <<= mpColorSet->getName(); @@ -311,15 +268,20 @@ std::unique_ptr<Theme> Theme::FromAny(const css::uno::Any& rVal) { uno::Sequence<util::Color> aColors; it->second >>= aColors; - for (size_t i = 0; i < aColors.size(); ++i) + + SAL_WARN_IF(aColors.size() > 12, "svx", "Theme::FromAny: number of colors greater than max theme colors supported"); + + for (auto eThemeColorType : o3tl::enumrange<model::ThemeColorType>()) { - if (i >= 12) + if (eThemeColorType != model::ThemeColorType::Unknown) { - SAL_WARN("svx", "Theme::FromAny: too many colors in the color set"); - break; + size_t nIndex(static_cast<sal_Int16>(eThemeColorType)); + if (nIndex < aColors.size()) + { + Color aColor(ColorTransparency, aColors[nIndex]); + pColorSet->add(eThemeColorType, aColor); + } } - - pColorSet->add(i, Color(ColorTransparency, aColors[i])); } } @@ -352,7 +314,8 @@ std::vector<Color> Theme::GetColors() const std::vector<Color> aColors; for (auto eThemeColorType : o3tl::enumrange<model::ThemeColorType>()) { - aColors.push_back(mpColorSet->getColor(eThemeColorType)); + if (eThemeColorType != model::ThemeColorType::Unknown) + aColors.push_back(mpColorSet->getColor(eThemeColorType)); } return aColors; } |