From 48f0c5f73f99c919ec24deadc96c3cf5483c9314 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Tue, 30 Nov 2021 08:44:02 +0100 Subject: svx: update objects of pages of a master page when the theme changes Only text color as a start, and without effects. Change-Id: I52b1c110870605134c414bcc94b50871cd49975b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126082 Reviewed-by: Miklos Vajna Tested-by: Jenkins --- svx/source/styles/ColorSets.cxx | 59 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) (limited to 'svx/source/styles') diff --git a/svx/source/styles/ColorSets.cxx b/svx/source/styles/ColorSets.cxx index 773e7c414ef3..a5f8c6e7c548 100644 --- a/svx/source/styles/ColorSets.cxx +++ b/svx/source/styles/ColorSets.cxx @@ -16,14 +16,55 @@ #include #include +#include +#include +#include +#include #include #include #include #include +#include +#include +#include using namespace com::sun::star; +namespace +{ +void UpdateSdrObject(svx::Theme* pTheme, SdrObject* pObject) +{ + svx::ColorSet* pColorSet = pTheme->GetColorSet(); + if (!pColorSet) + { + return; + } + + uno::Reference xShape(pObject->getUnoShape(), uno::UNO_QUERY); + uno::Reference xText(xShape->getText(), uno::UNO_QUERY); + uno::Reference xParagraphs = xText->createEnumeration(); + while (xParagraphs->hasMoreElements()) + { + uno::Reference xParagraph(xParagraphs->nextElement(), uno::UNO_QUERY); + uno::Reference xPortions = xParagraph->createEnumeration(); + while (xPortions->hasMoreElements()) + { + uno::Reference xPortion(xPortions->nextElement(), uno::UNO_QUERY); + sal_Int16 nCharColorTheme = -1; + xPortion->getPropertyValue(UNO_NAME_EDIT_CHAR_COLOR_THEME) >>= nCharColorTheme; + if (nCharColorTheme < 0 || nCharColorTheme > 11) + { + continue; + } + + Color aColor = pColorSet->getColor(nCharColorTheme); + xPortion->setPropertyValue(UNO_NAME_EDIT_CHAR_COLOR, uno::makeAny(static_cast(aColor))); + } + } +} +} + namespace svx { @@ -229,6 +270,24 @@ std::unique_ptr Theme::FromAny(const css::uno::Any& rVal) return pTheme; } +void Theme::UpdateSdrPage(SdrPage* pPage) +{ + for (size_t nObject = 0; nObject < pPage->GetObjCount(); ++nObject) + { + SdrObject* pObject = pPage->GetObj(nObject); + UpdateSdrObject(this, pObject); + SdrObjList* pList = pObject->GetSubList(); + if (pList) + { + SdrObjListIter aIter(pList, SdrIterMode::DeepWithGroups); + while (aIter.IsMore()) + { + UpdateSdrObject(this, aIter.Next()); + } + } + } +} + } // end of namespace svx /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit