diff options
author | Katarina Behrens <Katarina.Behrens@cib.de> | 2019-07-16 09:48:12 +0200 |
---|---|---|
committer | Katarina Behrens <Katarina.Behrens@cib.de> | 2019-07-17 11:03:49 +0200 |
commit | 0e15fb798a0d1fc8cc221ae2334411fac144f173 (patch) | |
tree | 3a213dd9bf4d525100ebe4eb041f4017273ee724 /chart2 | |
parent | 5f4ae86cfe05f6e4d42c9b106e2f6b0e348e890d (diff) |
tdf#94300: custom gradients apply also from chart sidebar
Change-Id: Id6ba90b404ad97cdfc4091bcb4028677f1600fa2
Reviewed-on: https://gerrit.libreoffice.org/75693
Tested-by: Jenkins
Reviewed-by: Katarina Behrens <Katarina.Behrens@cib.de>
Diffstat (limited to 'chart2')
-rw-r--r-- | chart2/source/controller/sidebar/ChartAreaPanel.cxx | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/chart2/source/controller/sidebar/ChartAreaPanel.cxx b/chart2/source/controller/sidebar/ChartAreaPanel.cxx index 3c0f55ed0ea3..843c4e720e0d 100644 --- a/chart2/source/controller/sidebar/ChartAreaPanel.cxx +++ b/chart2/source/controller/sidebar/ChartAreaPanel.cxx @@ -100,30 +100,26 @@ DrawModelWrapper* getDrawModelWrapper(const css::uno::Reference<css::frame::XMod return pController->GetDrawModelWrapper(); } -XGradient getXGradientForName(const css::uno::Reference<css::frame::XModel>& xModel, +XFillGradientItem getXGradientForName(const css::uno::Reference<css::frame::XModel>& xModel, const OUString& rName) { - try - { - ViewElementListProvider aProvider = getViewElementListProvider(xModel); - XGradientListRef aRef = aProvider.GetGradientList(); - size_t n = aRef->Count(); - for (size_t i = 0; i < n; ++i) - { - const XGradientEntry* pGradient = aRef->GetGradient(i); - if (!pGradient) - continue; + css::uno::Reference<css::lang::XMultiServiceFactory> xFact(xModel, css::uno::UNO_QUERY); + css::uno::Reference<css::container::XNameAccess> xNameAccess( + xFact->createInstance("com.sun.star.drawing.GradientTable"), css::uno::UNO_QUERY); + if (!xNameAccess.is()) + return XFillGradientItem(); - if (pGradient->GetName() == rName) - return pGradient->GetGradient(); - } - } - catch (...) - { - // ignore exception - } + if (!xNameAccess->hasByName(rName)) + return XFillGradientItem(); + + css::uno::Any aAny = xNameAccess->getByName(rName); + + XFillGradientItem aItem; + aItem.SetName(rName); + aItem.PutValue(aAny, MID_FILLGRADIENT); + + return aItem; - return XGradient(); } XFillFloatTransparenceItem getXTransparencyGradientForName(const css::uno::Reference<css::frame::XModel>& xModel, @@ -369,7 +365,12 @@ void ChartAreaPanel::setFillStyleAndGradient(const XFillStyleItem* pStyleItem, if (pStyleItem) xPropSet->setPropertyValue("FillStyle", css::uno::Any(pStyleItem->GetValue())); - xPropSet->setPropertyValue("FillGradientName", css::uno::Any(rGradientItem.GetValue())); + + const OUString& aName = rGradientItem.GetName(); + css::uno::Any aGradientVal; + rGradientItem.QueryValue(aGradientVal, MID_FILLGRADIENT); + OUString aNewName = PropertyHelper::addGradientUniqueNameToTable(aGradientVal, css::uno::Reference<css::lang::XMultiServiceFactory>(mxModel, css::uno::UNO_QUERY_THROW), aName); + xPropSet->setPropertyValue("FillGradientName", css::uno::Any(aNewName)); } void ChartAreaPanel::setFillStyleAndHatch(const XFillStyleItem* pStyleItem, @@ -435,11 +436,10 @@ void ChartAreaPanel::updateData() if (xInfo->hasPropertyByName("FillGradientName")) { - OUString aGradientName; - xPropSet->getPropertyValue("FillGradientName") >>= aGradientName; - XGradient aGradient = getXGradientForName(mxModel, aGradientName); - XFillGradientItem aGradientItem(aGradientName, aGradient); - updateFillGradient(false, true, &aGradientItem); + OUString aGradientName; + xPropSet->getPropertyValue("FillGradientName") >>= aGradientName; + XFillGradientItem aGradientItem = getXGradientForName(mxModel, aGradientName); + updateFillGradient(false, true, &aGradientItem); } if (xInfo->hasPropertyByName("FillHatchName")) |