diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2021-11-22 13:31:58 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2021-11-22 15:20:09 +0100 |
commit | 2eaf79131dab04acce1411fed1d8ac8ab5c51575 (patch) | |
tree | 4eb99b5c4fac381ece1457969aabaf41a08cdcb1 /svx/source/styles | |
parent | 5c6c3c0b75a3584258b786c7e9bf8789d31847e8 (diff) |
PPTX: implement native handling of <a:clrScheme> 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 <vmiklos@collabora.com>
Tested-by: Jenkins
Diffstat (limited to 'svx/source/styles')
-rw-r--r-- | svx/source/styles/ColorSets.cxx | 33 |
1 files changed, 31 insertions, 2 deletions
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 <libxml/xmlwriter.h> #include <com/sun/star/beans/PropertyValues.hpp> +#include <com/sun/star/util/Color.hpp> #include <comphelper/propertyvalue.hxx> #include <comphelper/sequenceashashmap.hxx> +#include <comphelper/sequence.hxx> +#include <sal/log.hxx> using namespace com::sun::star; @@ -169,7 +172,14 @@ void Theme::ToAny(css::uno::Any& rVal) const if (mpColorSet) { + std::vector<util::Color> aColorScheme; + for (size_t i = 0; i < 12; ++i) + { + aColorScheme.push_back(static_cast<sal_Int32>(mpColorSet->getColor(i))); + } + aMap["ColorSchemeName"] <<= mpColorSet->getName(); + aMap["ColorScheme"] <<= comphelper::containerToSequence(aColorScheme); } rVal <<= aMap.getAsConstPropertyValueList(); @@ -179,6 +189,7 @@ std::unique_ptr<Theme> Theme::FromAny(const css::uno::Any& rVal) { comphelper::SequenceAsHashMap aMap(rVal); std::unique_ptr<Theme> pTheme; + ColorSet* pColorSet = nullptr; auto it = aMap.find("Name"); if (it != aMap.end()) @@ -193,8 +204,26 @@ std::unique_ptr<Theme> Theme::FromAny(const css::uno::Any& rVal) { OUString aName; it->second >>= aName; - auto pColorSet = std::make_unique<ColorSet>(aName); - pTheme->SetColorSet(std::move(pColorSet)); + auto pSet = std::make_unique<ColorSet>(aName); + pTheme->SetColorSet(std::move(pSet)); + pColorSet = pTheme->GetColorSet(); + } + + it = aMap.find("ColorScheme"); + if (it != aMap.end() && pColorSet) + { + uno::Sequence<util::Color> 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; |