[Libreoffice-commits] core.git: Branch 'libreoffice-5-1' - chart2/source

Caolán McNamara caolanm at redhat.com
Mon Mar 14 15:59:45 UTC 2016


 chart2/source/controller/sidebar/ChartAreaPanel.cxx |  117 ++++++++++++--------
 1 file changed, 71 insertions(+), 46 deletions(-)

New commits:
commit b067f794b99855c318f894dd4ec247f65cec0dd3
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Mar 11 12:16:18 2016 +0000

    Resolves: tdf#98390 ChartAreaPanel throw during ctor
    
    after a ChartSidebarModifyListener pointing to it has been created and added to
    the model, so ChartSidebarModifyListeners exist which point to a dead
    ChartAreaPanel which has never even completed its ctor
    
    workaround this by checking that properties it querys for exist
    before accessing them and triggering the IllegalProperty throw
    
    Change-Id: I0c251360714592c78132c0867903216f3866489a
    (cherry picked from commit 9048e7f58763cf87460a25cba374741352ceb98b)
    Reviewed-on: https://gerrit.libreoffice.org/23148
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Eike Rathke <erack at redhat.com>
    Tested-by: Eike Rathke <erack at redhat.com>

diff --git a/chart2/source/controller/sidebar/ChartAreaPanel.cxx b/chart2/source/controller/sidebar/ChartAreaPanel.cxx
index 7dc2b76..1039214 100644
--- a/chart2/source/controller/sidebar/ChartAreaPanel.cxx
+++ b/chart2/source/controller/sidebar/ChartAreaPanel.cxx
@@ -387,59 +387,84 @@ void ChartAreaPanel::updateData()
     if (!xPropSet.is())
         return;
 
-    css::drawing::FillStyle eFillStyle = css::drawing::FillStyle_SOLID;
-    xPropSet->getPropertyValue("FillStyle") >>= eFillStyle;
-    XFillStyleItem aFillStyleItem(eFillStyle);
-    updateFillStyle(false, true, &aFillStyleItem);
-
-    sal_uInt16 nFillTransparence = 0;
-    xPropSet->getPropertyValue("FillTransparence") >>= nFillTransparence;
-    SfxUInt16Item aTransparenceItem(0, nFillTransparence);
-    updateFillTransparence(false, true, &aTransparenceItem);
-
-    OUString aGradientName;
-    xPropSet->getPropertyValue("FillGradientName") >>= aGradientName;
-    XGradient xGradient = getXGradientForName(mxModel, aGradientName);
-    XFillGradientItem aGradientItem(aGradientName, xGradient);
-    updateFillGradient(false, true, &aGradientItem);
-
-    OUString aHatchName;
-    xPropSet->getPropertyValue("FillHatchName") >>= aHatchName;
-    XHatch xHatch = getXHatchFromName(mxModel, aHatchName);
-    XFillHatchItem aHatchItem(aHatchName, xHatch);
-    updateFillHatch(false, true, &aHatchItem);
-
-    OUString aBitmapName;
-    xPropSet->getPropertyValue("FillBitmapName") >>= aBitmapName;
-    GraphicObject xBitmap = getXBitmapFromName(mxModel, aBitmapName);
-    XFillBitmapItem aBitmapItem(aBitmapName, xBitmap);
-    XFillBitmapItem* pBitmapItem = nullptr;
-    DrawModelWrapper* pModelWrapper = nullptr;
-    try
+    css::uno::Reference<css::beans::XPropertySetInfo> xInfo(xPropSet->getPropertySetInfo());
+    if (!xInfo.is())
+        return;
+
+    if (xInfo->hasPropertyByName("FillStyle"))
     {
-        pModelWrapper = getDrawModelWrapper(mxModel);
-        if (pModelWrapper)
-        {
-            pBitmapItem = aBitmapItem.checkForUniqueItem(&pModelWrapper->getSdrModel());
-        }
+        css::drawing::FillStyle eFillStyle = css::drawing::FillStyle_SOLID;
+        xPropSet->getPropertyValue("FillStyle") >>= eFillStyle;
+        XFillStyleItem aFillStyleItem(eFillStyle);
+        updateFillStyle(false, true, &aFillStyleItem);
     }
-    catch (...)
+
+    if (xInfo->hasPropertyByName("FillTransparence"))
+    {
+        sal_uInt16 nFillTransparence = 0;
+        xPropSet->getPropertyValue("FillTransparence") >>= nFillTransparence;
+        SfxUInt16Item aTransparenceItem(0, nFillTransparence);
+        updateFillTransparence(false, true, &aTransparenceItem);
+    }
+
+    if (xInfo->hasPropertyByName("FillGradientName"))
+    {
+       OUString aGradientName;
+       xPropSet->getPropertyValue("FillGradientName") >>= aGradientName;
+       XGradient xGradient = getXGradientForName(mxModel, aGradientName);
+       XFillGradientItem aGradientItem(aGradientName, xGradient);
+       updateFillGradient(false, true, &aGradientItem);
+    }
+
+    if (xInfo->hasPropertyByName("FillHatchName"))
     {
+        OUString aHatchName;
+        xPropSet->getPropertyValue("FillHatchName") >>= aHatchName;
+        XHatch xHatch = getXHatchFromName(mxModel, aHatchName);
+        XFillHatchItem aHatchItem(aHatchName, xHatch);
+        updateFillHatch(false, true, &aHatchItem);
     }
-    updateFillBitmap(false, true, pBitmapItem ? pBitmapItem : &aBitmapItem);
-    delete pBitmapItem;
 
-    OUString aFillFloatTransparenceName;
-    xPropSet->getPropertyValue("FillTransparenceGradientName") >>= aFillFloatTransparenceName;
-    XFillFloatTransparenceItem aFillFloatTransparenceItem = getXTransparencyGradientForName(mxModel, aFillFloatTransparenceName);
-    updateFillFloatTransparence(false, true, &aFillFloatTransparenceItem);
+    if (xInfo->hasPropertyByName("FillBitmapName"))
+    {
+        OUString aBitmapName;
+        xPropSet->getPropertyValue("FillBitmapName") >>= aBitmapName;
+        GraphicObject xBitmap = getXBitmapFromName(mxModel, aBitmapName);
+        XFillBitmapItem aBitmapItem(aBitmapName, xBitmap);
+        XFillBitmapItem* pBitmapItem = nullptr;
+        DrawModelWrapper* pModelWrapper = nullptr;
+        try
+        {
+            pModelWrapper = getDrawModelWrapper(mxModel);
+            if (pModelWrapper)
+            {
+                pBitmapItem = aBitmapItem.checkForUniqueItem(&pModelWrapper->getSdrModel());
+            }
+        }
+        catch (...)
+        {
+        }
+        updateFillBitmap(false, true, pBitmapItem ? pBitmapItem : &aBitmapItem);
+        delete pBitmapItem;
+    }
+
+    if (xInfo->hasPropertyByName("FillTransparenceGradientName"))
+    {
+        OUString aFillFloatTransparenceName;
+        xPropSet->getPropertyValue("FillTransparenceGradientName") >>= aFillFloatTransparenceName;
+        XFillFloatTransparenceItem aFillFloatTransparenceItem = getXTransparencyGradientForName(mxModel, aFillFloatTransparenceName);
+        updateFillFloatTransparence(false, true, &aFillFloatTransparenceItem);
 
-    maFillColorWrapper.updateData();
+        maFillColorWrapper.updateData();
+    }
 
-    sal_uInt32 nFillColor = 0;
-    xPropSet->getPropertyValue("FillColor") >>= nFillColor;
-    XFillColorItem aFillColorItem("", Color(nFillColor));
-    updateFillColor(true, &aFillColorItem);
+    if (xInfo->hasPropertyByName("FillColor"))
+    {
+        sal_uInt32 nFillColor = 0;
+        xPropSet->getPropertyValue("FillColor") >>= nFillColor;
+        XFillColorItem aFillColorItem("", Color(nFillColor));
+        updateFillColor(true, &aFillColorItem);
+    }
 }
 
 void ChartAreaPanel::modelInvalid()


More information about the Libreoffice-commits mailing list