From 2eaf79131dab04acce1411fed1d8ac8ab5c51575 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Mon, 22 Nov 2021 13:31:58 +0100 Subject: PPTX: implement native handling of children This was already handled by converting them to raw colors at import time. This commit imports the color scheme contents (the 12 colors) into the doc model. This is a dependency to export them back to PPTX and to be able to update these colors on the UI by picking a different theme. Change-Id: I177de4f15d5f0e628669998d1cda7db24220b2eb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125651 Reviewed-by: Miklos Vajna Tested-by: Jenkins --- svx/source/styles/ColorSets.cxx | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) (limited to 'svx/source/styles') diff --git a/svx/source/styles/ColorSets.cxx b/svx/source/styles/ColorSets.cxx index fbcf4bd4a889..773e7c414ef3 100644 --- a/svx/source/styles/ColorSets.cxx +++ b/svx/source/styles/ColorSets.cxx @@ -15,9 +15,12 @@ #include #include +#include #include #include +#include +#include using namespace com::sun::star; @@ -169,7 +172,14 @@ void Theme::ToAny(css::uno::Any& rVal) const if (mpColorSet) { + std::vector aColorScheme; + for (size_t i = 0; i < 12; ++i) + { + aColorScheme.push_back(static_cast(mpColorSet->getColor(i))); + } + aMap["ColorSchemeName"] <<= mpColorSet->getName(); + aMap["ColorScheme"] <<= comphelper::containerToSequence(aColorScheme); } rVal <<= aMap.getAsConstPropertyValueList(); @@ -179,6 +189,7 @@ std::unique_ptr Theme::FromAny(const css::uno::Any& rVal) { comphelper::SequenceAsHashMap aMap(rVal); std::unique_ptr pTheme; + ColorSet* pColorSet = nullptr; auto it = aMap.find("Name"); if (it != aMap.end()) @@ -193,8 +204,26 @@ std::unique_ptr Theme::FromAny(const css::uno::Any& rVal) { OUString aName; it->second >>= aName; - auto pColorSet = std::make_unique(aName); - pTheme->SetColorSet(std::move(pColorSet)); + auto pSet = std::make_unique(aName); + pTheme->SetColorSet(std::move(pSet)); + pColorSet = pTheme->GetColorSet(); + } + + it = aMap.find("ColorScheme"); + if (it != aMap.end() && pColorSet) + { + uno::Sequence aColors; + it->second >>= aColors; + for (size_t i = 0; i < aColors.size(); ++i) + { + if (i >= 12) + { + SAL_WARN("svx", "Theme::FromAny: too many colors in the color set"); + break; + } + + pColorSet->add(i, Color(ColorTransparency, aColors[i])); + } } return pTheme; -- cgit