diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2022-03-02 20:27:09 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2022-03-03 08:16:57 +0100 |
commit | 6f50fe6f524d922c27ec1313ebef49352a2f9128 (patch) | |
tree | f0117b103821d608e4b521cfe7d0b40db43e6caa /svx/source/styles | |
parent | fb9270b238cba4f36e595c5d7f4d85f6f3f18e1c (diff) |
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 <vmiklos@collabora.com>
Diffstat (limited to 'svx/source/styles')
-rw-r--r-- | svx/source/styles/ColorSets.cxx | 48 |
1 files changed, 34 insertions, 14 deletions
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<beans::XPropertySet>& xPorti uno::makeAny(static_cast<sal_Int32>(aColor))); } -void UpdateSdrObject(svx::Theme* pTheme, SdrObject* pObject) +void UpdateFillColorSet(const uno::Reference<beans::XPropertySet>& xShape, svx::ColorSet& rColorSet) { - svx::ColorSet* pColorSet = pTheme->GetColorSet(); - if (!pColorSet) + if (!xShape->getPropertySetInfo()->hasPropertyByName(UNO_NAME_FILLCOLOR_THEME)) { return; } - uno::Reference<text::XTextRange> 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<sal_Int32>(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<container::XEnumerationAccess> xText(xShape->getText(), uno::UNO_QUERY); - uno::Reference<container::XEnumeration> xParagraphs = xText->createEnumeration(); - while (xParagraphs->hasMoreElements()) + uno::Reference<drawing::XShape> xShape = pObject->getUnoShape(); + uno::Reference<text::XTextRange> xShapeText(xShape, uno::UNO_QUERY); + if (xShapeText.is()) { - uno::Reference<container::XEnumerationAccess> xParagraph(xParagraphs->nextElement(), uno::UNO_QUERY); - uno::Reference<container::XEnumeration> xPortions = xParagraph->createEnumeration(); - while (xPortions->hasMoreElements()) + // E.g. group shapes have no text. + uno::Reference<container::XEnumerationAccess> xText(xShapeText->getText(), uno::UNO_QUERY); + uno::Reference<container::XEnumeration> xParagraphs = xText->createEnumeration(); + while (xParagraphs->hasMoreElements()) { - uno::Reference<beans::XPropertySet> xPortion(xPortions->nextElement(), uno::UNO_QUERY); - UpdateTextPortionColorSet(xPortion, *pColorSet); + uno::Reference<container::XEnumerationAccess> xParagraph(xParagraphs->nextElement(), uno::UNO_QUERY); + uno::Reference<container::XEnumeration> xPortions = xParagraph->createEnumeration(); + while (xPortions->hasMoreElements()) + { + uno::Reference<beans::XPropertySet> xPortion(xPortions->nextElement(), uno::UNO_QUERY); + UpdateTextPortionColorSet(xPortion, *pColorSet); + } } } + + uno::Reference<beans::XPropertySet> xShapeProps(xShape, uno::UNO_QUERY); + UpdateFillColorSet(xShapeProps, *pColorSet); } } |