From 6f50fe6f524d922c27ec1313ebef49352a2f9128 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Wed, 2 Mar 2022 20:27:09 +0100 Subject: sd theme: add rendering for shape fill color I.e. update the shape fill color when the theme of the master page changes if the color is a theme color. Change-Id: Ia1ed566230a8547334aa4a7d69627882aa690546 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130894 Tested-by: Jenkins Reviewed-by: Miklos Vajna --- svx/source/styles/ColorSets.cxx | 48 +++++++++++++++++++++++++++++------------ 1 file changed, 34 insertions(+), 14 deletions(-) (limited to 'svx/source/styles') diff --git a/svx/source/styles/ColorSets.cxx b/svx/source/styles/ColorSets.cxx index 97c79b58bcc6..5dcd089fd4ba 100644 --- a/svx/source/styles/ColorSets.cxx +++ b/svx/source/styles/ColorSets.cxx @@ -65,33 +65,53 @@ void UpdateTextPortionColorSet(const uno::Reference& xPorti uno::makeAny(static_cast(aColor))); } -void UpdateSdrObject(svx::Theme* pTheme, SdrObject* pObject) +void UpdateFillColorSet(const uno::Reference& xShape, svx::ColorSet& rColorSet) { - svx::ColorSet* pColorSet = pTheme->GetColorSet(); - if (!pColorSet) + if (!xShape->getPropertySetInfo()->hasPropertyByName(UNO_NAME_FILLCOLOR_THEME)) { return; } - uno::Reference xShape(pObject->getUnoShape(), uno::UNO_QUERY); - if (!xShape.is()) + sal_Int16 nFillColorTheme = -1; + xShape->getPropertyValue(UNO_NAME_FILLCOLOR_THEME) >>= nFillColorTheme; + if (nFillColorTheme < 0 || nFillColorTheme > 11) + { + return; + } + + Color aColor = rColorSet.getColor(nFillColorTheme); + xShape->setPropertyValue(UNO_NAME_FILLCOLOR, uno::makeAny(static_cast(aColor))); +} + +void UpdateSdrObject(svx::Theme* pTheme, SdrObject* pObject) +{ + svx::ColorSet* pColorSet = pTheme->GetColorSet(); + if (!pColorSet) { - // E.g. group shapes have no text. return; } - uno::Reference xText(xShape->getText(), uno::UNO_QUERY); - uno::Reference xParagraphs = xText->createEnumeration(); - while (xParagraphs->hasMoreElements()) + uno::Reference xShape = pObject->getUnoShape(); + uno::Reference xShapeText(xShape, uno::UNO_QUERY); + if (xShapeText.is()) { - uno::Reference xParagraph(xParagraphs->nextElement(), uno::UNO_QUERY); - uno::Reference xPortions = xParagraph->createEnumeration(); - while (xPortions->hasMoreElements()) + // E.g. group shapes have no text. + uno::Reference xText(xShapeText->getText(), uno::UNO_QUERY); + uno::Reference xParagraphs = xText->createEnumeration(); + while (xParagraphs->hasMoreElements()) { - uno::Reference xPortion(xPortions->nextElement(), uno::UNO_QUERY); - UpdateTextPortionColorSet(xPortion, *pColorSet); + uno::Reference xParagraph(xParagraphs->nextElement(), uno::UNO_QUERY); + uno::Reference xPortions = xParagraph->createEnumeration(); + while (xPortions->hasMoreElements()) + { + uno::Reference xPortion(xPortions->nextElement(), uno::UNO_QUERY); + UpdateTextPortionColorSet(xPortion, *pColorSet); + } } } + + uno::Reference xShapeProps(xShape, uno::UNO_QUERY); + UpdateFillColorSet(xShapeProps, *pColorSet); } } -- cgit