[Libreoffice-commits] core.git: Branch 'libreoffice-6-3' - chart2/source

Katarina Behrens (via logerrit) logerrit at kemper.freedesktop.org
Wed Aug 7 21:30:16 UTC 2019


 chart2/source/controller/sidebar/ChartAreaPanel.cxx |   52 ++++++++++----------
 1 file changed, 26 insertions(+), 26 deletions(-)

New commits:
commit dda72e5088a20360ebf18900e608994311fa0f5c
Author:     Katarina Behrens <Katarina.Behrens at cib.de>
AuthorDate: Tue Jul 16 09:48:12 2019 +0200
Commit:     Thorsten Behrens <Thorsten.Behrens at CIB.de>
CommitDate: Wed Aug 7 23:29:38 2019 +0200

    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 at cib.de>
    (cherry picked from commit 0e15fb798a0d1fc8cc221ae2334411fac144f173)
    Reviewed-on: https://gerrit.libreoffice.org/77035
    Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>

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"))


More information about the Libreoffice-commits mailing list