diff options
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); } } |