[Libreoffice-commits] core.git: Branch 'feature/chart-sidebar' - 29 commits - chart2/Library_chartcontroller.mk chart2/source chart2/uiconfig include/sfx2 include/svx offapi/com offapi/UnoApi_offapi.mk officecfg/registry sfx2/Library_sfx.mk sfx2/source svx/Library_svx.mk svx/source

Markus Mohrhard markus.mohrhard at googlemail.com
Sat Jul 25 15:28:34 PDT 2015


Rebased ref, commits from common ancestor:
commit 9ba833f0148522e14a2c639017afd90749816380
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Sat Jul 25 22:25:10 2015 +0200

    don't show the area sidebar for panels where it makes no sense
    
    Change-Id: I06655e0574b28a88db920424fa515b8350133f10

diff --git a/chart2/source/controller/sidebar/ChartAreaPanel.cxx b/chart2/source/controller/sidebar/ChartAreaPanel.cxx
index 267387f..f19f690 100644
--- a/chart2/source/controller/sidebar/ChartAreaPanel.cxx
+++ b/chart2/source/controller/sidebar/ChartAreaPanel.cxx
@@ -212,6 +212,8 @@ ChartAreaPanel::ChartAreaPanel(vcl::Window* pParent,
     mxSelectionListener(new ChartSidebarSelectionListener(this)),
     mbUpdate(true)
 {
+    std::vector<ObjectType> aAcceptedTypes { OBJECTTYPE_PAGE, OBJECTTYPE_DIAGRAM, OBJECTTYPE_DATA_SERIES, OBJECTTYPE_TITLE, OBJECTTYPE_LEGEND};
+    mxSelectionListener->setAcceptedTypes(aAcceptedTypes);
     Initialize();
 }
 
@@ -227,7 +229,7 @@ void ChartAreaPanel::dispose()
 
     css::uno::Reference<css::view::XSelectionSupplier> xSelectionSupplier(mxModel->getCurrentController(), css::uno::UNO_QUERY);
     if (xSelectionSupplier.is())
-        xSelectionSupplier->removeSelectionChangeListener(mxSelectionListener);
+        xSelectionSupplier->removeSelectionChangeListener(mxSelectionListener.get());
 
     AreaPropertyPanelBase::dispose();
 }
@@ -239,7 +241,7 @@ void ChartAreaPanel::Initialize()
 
     css::uno::Reference<css::view::XSelectionSupplier> xSelectionSupplier(mxModel->getCurrentController(), css::uno::UNO_QUERY);
     if (xSelectionSupplier.is())
-        xSelectionSupplier->addSelectionChangeListener(mxSelectionListener);
+        xSelectionSupplier->addSelectionChangeListener(mxSelectionListener.get());
 
     updateData();
 }
@@ -404,7 +406,7 @@ void ChartAreaPanel::updateModel(
 
     css::uno::Reference<css::view::XSelectionSupplier> xSelectionSupplier(mxModel->getCurrentController(), css::uno::UNO_QUERY);
     if (xSelectionSupplier.is())
-        xSelectionSupplier->addSelectionChangeListener(mxSelectionListener);
+        xSelectionSupplier->addSelectionChangeListener(mxSelectionListener.get());
 }
 
 
diff --git a/chart2/source/controller/sidebar/ChartAreaPanel.hxx b/chart2/source/controller/sidebar/ChartAreaPanel.hxx
index 827f1c9..ccd9acc 100644
--- a/chart2/source/controller/sidebar/ChartAreaPanel.hxx
+++ b/chart2/source/controller/sidebar/ChartAreaPanel.hxx
@@ -86,7 +86,7 @@ private:
 
     css::uno::Reference<css::frame::XModel> mxModel;
     css::uno::Reference<css::util::XModifyListener> mxListener;
-    css::uno::Reference<css::view::XSelectionChangeListener> mxSelectionListener;
+    rtl::Reference<ChartSidebarSelectionListener> mxSelectionListener;
 
     void Initialize();
 
diff --git a/chart2/source/controller/sidebar/ChartSidebarSelectionListener.cxx b/chart2/source/controller/sidebar/ChartSidebarSelectionListener.cxx
index 1f435e1..7f13479 100644
--- a/chart2/source/controller/sidebar/ChartSidebarSelectionListener.cxx
+++ b/chart2/source/controller/sidebar/ChartSidebarSelectionListener.cxx
@@ -23,19 +23,16 @@ ChartSidebarSelectionListenerParent::~ChartSidebarSelectionListenerParent()
 
 ChartSidebarSelectionListener::ChartSidebarSelectionListener(
         ChartSidebarSelectionListenerParent* pParent):
-    mpParent(pParent),
-    mbAll(true),
-    meType()
+    mpParent(pParent)
 {
 }
 
 ChartSidebarSelectionListener::ChartSidebarSelectionListener(
         ChartSidebarSelectionListenerParent* pParent,
         ObjectType eType):
-    mpParent(pParent),
-    mbAll(false),
-    meType(eType)
+    mpParent(pParent)
 {
+    maTypes.push_back(eType);
 }
 
 ChartSidebarSelectionListener::~ChartSidebarSelectionListener()
@@ -45,13 +42,10 @@ ChartSidebarSelectionListener::~ChartSidebarSelectionListener()
 void ChartSidebarSelectionListener::selectionChanged(const css::lang::EventObject& rEvent)
         throw (::css::uno::RuntimeException, ::std::exception)
 {
-    (void)rEvent;
     bool bCorrectObjectSelected = false;
-    if (mbAll)
-        bCorrectObjectSelected = true;
 
     css::uno::Reference<css::frame::XController> xController(rEvent.Source, css::uno::UNO_QUERY);
-    if (!mbAll && xController.is())
+    if (xController.is())
     {
         css::uno::Reference<css::view::XSelectionSupplier> xSelectionSupplier(xController, css::uno::UNO_QUERY);
         if (xSelectionSupplier.is())
@@ -62,7 +56,8 @@ void ChartSidebarSelectionListener::selectionChanged(const css::lang::EventObjec
                 OUString aCID;
                 aAny >>= aCID;
                 ObjectType eType = ObjectIdentifier::getObjectType(aCID);
-                bCorrectObjectSelected = eType == meType;
+                bCorrectObjectSelected = std::any_of(maTypes.begin(), maTypes.end(),
+                        [=](const ObjectType& eTypeInVector) { return eType == eTypeInVector; });
             }
         }
     }
@@ -76,6 +71,11 @@ void ChartSidebarSelectionListener::disposing(const css::lang::EventObject& /*rE
     mpParent->SelectionInvalid();
 }
 
+void ChartSidebarSelectionListener::setAcceptedTypes(const std::vector<ObjectType>& aTypes)
+{
+    maTypes = aTypes;
+}
+
 } }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/controller/sidebar/ChartSidebarSelectionListener.hxx b/chart2/source/controller/sidebar/ChartSidebarSelectionListener.hxx
index cfe90e7..3c31644 100644
--- a/chart2/source/controller/sidebar/ChartSidebarSelectionListener.hxx
+++ b/chart2/source/controller/sidebar/ChartSidebarSelectionListener.hxx
@@ -15,6 +15,8 @@
 
 #include "ObjectIdentifier.hxx"
 
+#include <vector>
+
 namespace chart {
 namespace sidebar {
 
@@ -44,11 +46,12 @@ public:
     virtual void SAL_CALL disposing(const css::lang::EventObject& rEvent)
         throw (::css::uno::RuntimeException, ::std::exception) SAL_OVERRIDE;
 
+    void setAcceptedTypes(const std::vector<ObjectType>& aTypes);
+
 private:
     ChartSidebarSelectionListenerParent* mpParent;
 
-    bool mbAll;
-    ObjectType meType;
+    std::vector<ObjectType> maTypes;
 };
 
 } }
diff --git a/officecfg/registry/data/org/openoffice/Office/UI/Sidebar.xcu b/officecfg/registry/data/org/openoffice/Office/UI/Sidebar.xcu
index da8c01f..01e184b 100644
--- a/officecfg/registry/data/org/openoffice/Office/UI/Sidebar.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/UI/Sidebar.xcu
@@ -1266,7 +1266,8 @@
         </prop>
         <prop oor:name="ContextList">
           <value oor:separator=";">
-            Chart, any, visible ;
+            Chart, Chart, visible ;
+            Chart, Series, visible ;
           </value>
         </prop>
         <prop oor:name="ImplementationURL" oor:type="xs:string">
commit 87f750f1c574142958331643e7b0a9fb0b182102
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Sat Jul 25 17:46:43 2015 +0200

    also update for the first selected object
    
    Change-Id: I7df8772c7414df694eda5ea30b74eccd6e9b98db

diff --git a/chart2/source/controller/sidebar/ChartAreaPanel.cxx b/chart2/source/controller/sidebar/ChartAreaPanel.cxx
index 7f5077f..267387f 100644
--- a/chart2/source/controller/sidebar/ChartAreaPanel.cxx
+++ b/chart2/source/controller/sidebar/ChartAreaPanel.cxx
@@ -240,6 +240,8 @@ void ChartAreaPanel::Initialize()
     css::uno::Reference<css::view::XSelectionSupplier> xSelectionSupplier(mxModel->getCurrentController(), css::uno::UNO_QUERY);
     if (xSelectionSupplier.is())
         xSelectionSupplier->addSelectionChangeListener(mxSelectionListener);
+
+    updateData();
 }
 
 void ChartAreaPanel::setFillTransparence(const XFillTransparenceItem& rItem)
commit 5845e73783fc99cd42188481fc5df29f0786394f
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Sat Jul 25 01:55:36 2015 +0200

    handle chart wall correctly in area panel
    
    Change-Id: Iacd9498884a20357f217e1165a3422b6f1e2aa81

diff --git a/chart2/source/controller/sidebar/ChartAreaPanel.cxx b/chart2/source/controller/sidebar/ChartAreaPanel.cxx
index 9343499..7f5077f 100644
--- a/chart2/source/controller/sidebar/ChartAreaPanel.cxx
+++ b/chart2/source/controller/sidebar/ChartAreaPanel.cxx
@@ -42,7 +42,21 @@ css::uno::Reference<css::beans::XPropertySet> getPropSet(
         css::uno::Reference<css::frame::XModel> xModel)
 {
     OUString aCID = getCID(xModel);
-    return ObjectIdentifier::getObjectPropertySet(aCID, xModel);
+    css::uno::Reference<css::beans::XPropertySet> xPropSet =
+        ObjectIdentifier::getObjectPropertySet(aCID, xModel);
+
+    ObjectType eType = ObjectIdentifier::getObjectType(aCID);
+    if (eType == OBJECTTYPE_DIAGRAM)
+    {
+        css::uno::Reference<css::chart2::XDiagram> xDiagram(
+                xPropSet, css::uno::UNO_QUERY);
+        if (!xDiagram.is())
+            return xPropSet;
+
+        xPropSet.set(xDiagram->getWall());
+    }
+
+    return xPropSet;
 }
 
 ChartController* getController(css::uno::Reference<css::frame::XModel> xModel)
commit 6301e1e8b983f099d1f93140a3fb54c635206ac6
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Sat Jul 25 01:31:50 2015 +0200

    provide a few more common property names
    
    Change-Id: I574af7999f8a76457dd61e66854db191b8876dfa

diff --git a/chart2/source/tools/FillProperties.cxx b/chart2/source/tools/FillProperties.cxx
index 123275f..37b4a8f 100644
--- a/chart2/source/tools/FillProperties.cxx
+++ b/chart2/source/tools/FillProperties.cxx
@@ -60,6 +60,13 @@ void lcl_AddPropertiesToVector_without_BitmapProperties( ::std::vector< ::com::s
                   | beans::PropertyAttribute::MAYBEDEFAULT ));
 
     rOutProperties.push_back(
+        Property( "Transparency",
+                  FillProperties::PROP_FILL_TRANSPARENCE,
+                  cppu::UnoType<sal_Int16>::get(),
+                  beans::PropertyAttribute::BOUND
+                  | beans::PropertyAttribute::MAYBEDEFAULT ));
+
+    rOutProperties.push_back(
         Property( "FillTransparence",
                   FillProperties::PROP_FILL_TRANSPARENCE,
                   cppu::UnoType<sal_Int16>::get(),
commit 7b9818c4cc0c955d9b5a0f0adba34a9c44b6065c
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Fri Jul 24 16:58:04 2015 +0200

    handle bitmap in chart area panel
    
    Change-Id: I3137fc1ac066b712594d0cf471ca4eb8a344c0bd

diff --git a/chart2/source/controller/inc/ChartController.hxx b/chart2/source/controller/inc/ChartController.hxx
index 9749b36..e5d40d2 100644
--- a/chart2/source/controller/inc/ChartController.hxx
+++ b/chart2/source/controller/inc/ChartController.hxx
@@ -435,6 +435,7 @@ public:
     bool isShapeContext() const;
 
     ViewElementListProvider getViewElementListProvider();
+    DrawModelWrapper* GetDrawModelWrapper();
 
     DECL_LINK( NotifyUndoActionHdl, SdrUndoAction* );
 
@@ -442,7 +443,6 @@ public:
     //private
 
 private:
-    DrawModelWrapper* GetDrawModelWrapper();
     DrawViewWrapper* GetDrawViewWrapper();
 
 private:
diff --git a/chart2/source/controller/sidebar/ChartAreaPanel.cxx b/chart2/source/controller/sidebar/ChartAreaPanel.cxx
index 966a9fd..9343499 100644
--- a/chart2/source/controller/sidebar/ChartAreaPanel.cxx
+++ b/chart2/source/controller/sidebar/ChartAreaPanel.cxx
@@ -12,6 +12,8 @@
 #include "ChartController.hxx"
 #include "ViewElementListProvider.hxx"
 
+#include "chartview/DrawModelWrapper.hxx"
+
 #include <svx/xfltrit.hxx>
 #include <svx/xflftrit.hxx>
 
@@ -43,7 +45,7 @@ css::uno::Reference<css::beans::XPropertySet> getPropSet(
     return ObjectIdentifier::getObjectPropertySet(aCID, xModel);
 }
 
-ViewElementListProvider getViewElementListProvider( css::uno::Reference<css::frame::XModel> xModel)
+ChartController* getController(css::uno::Reference<css::frame::XModel> xModel)
 {
     css::uno::Reference<css::frame::XController>xController = xModel->getCurrentController();
     if (!xController.is())
@@ -53,10 +55,22 @@ ViewElementListProvider getViewElementListProvider( css::uno::Reference<css::fra
     if (!pController)
         throw std::exception();
 
+    return pController;
+}
+
+ViewElementListProvider getViewElementListProvider( css::uno::Reference<css::frame::XModel> xModel)
+{
+    ChartController* pController = getController(xModel);
     ViewElementListProvider aProvider = pController->getViewElementListProvider();
     return aProvider;
 }
 
+DrawModelWrapper* getDrawModelWrapper(css::uno::Reference<css::frame::XModel> xModel)
+{
+    ChartController* pController = getController(xModel);
+    return pController->GetDrawModelWrapper();
+}
+
 XGradient getXGradientForName(css::uno::Reference<css::frame::XModel> xModel,
         const OUString& rName)
 {
@@ -113,6 +127,34 @@ XHatch getXHatchFromName(css::uno::Reference<css::frame::XModel> xModel,
     return XHatch();
 }
 
+GraphicObject getXBitmapFromName(css::uno::Reference<css::frame::XModel> xModel,
+        const OUString& rName)
+{
+    try
+    {
+        ViewElementListProvider aProvider = getViewElementListProvider(xModel);
+        XBitmapListRef aRef = aProvider.GetBitmapList();
+        size_t n = aRef->Count();
+        for (size_t i = 0; i < n; ++i)
+        {
+            XBitmapEntry* pBitmap = aRef->GetBitmap(i);
+            if (!pBitmap)
+                continue;
+
+            if (pBitmap->GetName().equalsIgnoreAsciiCase(rName))
+            {
+                return GraphicObject(pBitmap->GetGraphicObject());
+            }
+        }
+    }
+    catch (...)
+    {
+        // ignore exception
+    }
+
+    return GraphicObject();
+}
+
 class PreventUpdate
 {
 public:
@@ -298,6 +340,25 @@ void ChartAreaPanel::updateData()
     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 = NULL;
+    try
+    {
+        DrawModelWrapper* pModelWrapper = getDrawModelWrapper(mxModel);
+        if (pModelWrapper)
+        {
+            pBitmapItem = aBitmapItem.checkForUniqueItem(&pModelWrapper->getSdrModel());
+        }
+    }
+    catch (...)
+    {
+    }
+    updateFillBitmap(false, true, pBitmapItem ? pBitmapItem : &aBitmapItem);
+    delete pBitmapItem;
 }
 
 void ChartAreaPanel::modelInvalid()
commit 8ab10c27be8ab33e5cf355ab91f6783175184784
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Fri Jul 24 13:37:15 2015 +0200

    update hatch in chart sidebar
    
    There is a huge level of insanity in the hatch handling. Apparently
    different parts of the code use different case of the hatch id which
    makes it difficult to handle it.
    
    Change-Id: I5674e21a6c9a2d01d7b641473e00ab5e2bcaffd4

diff --git a/chart2/source/controller/sidebar/ChartAreaPanel.cxx b/chart2/source/controller/sidebar/ChartAreaPanel.cxx
index 9e1b5e8..966a9fd 100644
--- a/chart2/source/controller/sidebar/ChartAreaPanel.cxx
+++ b/chart2/source/controller/sidebar/ChartAreaPanel.cxx
@@ -43,33 +43,76 @@ css::uno::Reference<css::beans::XPropertySet> getPropSet(
     return ObjectIdentifier::getObjectPropertySet(aCID, xModel);
 }
 
-XGradient getXGradientForName(css::uno::Reference<css::frame::XModel> xModel,
-        const OUString& rName)
+ViewElementListProvider getViewElementListProvider( css::uno::Reference<css::frame::XModel> xModel)
 {
     css::uno::Reference<css::frame::XController>xController = xModel->getCurrentController();
     if (!xController.is())
-        return XGradient();
+        throw std::exception();
 
     ChartController* pController = dynamic_cast<ChartController*>(xController.get());
     if (!pController)
-        return XGradient();
+        throw std::exception();
 
     ViewElementListProvider aProvider = pController->getViewElementListProvider();
-    XGradientListRef aRef = aProvider.GetGradientList();
-    size_t n = aRef->Count();
-    for (size_t i = 0; i < n; ++i)
-    {
-        XGradientEntry* pGradient = aRef->GetGradient(i);
-        if (!pGradient)
-            continue;
+    return aProvider;
+}
 
-        if (pGradient->GetName() == rName)
-            return XGradient(pGradient->GetGradient());
+XGradient getXGradientForName(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)
+        {
+            XGradientEntry* pGradient = aRef->GetGradient(i);
+            if (!pGradient)
+                continue;
+
+            if (pGradient->GetName() == rName)
+                return XGradient(pGradient->GetGradient());
+        }
+    }
+    catch (...)
+    {
+        // ignore exception
     }
 
     return XGradient();
 }
 
+XHatch getXHatchFromName(css::uno::Reference<css::frame::XModel> xModel,
+        OUString& rName)
+{
+    try
+    {
+        ViewElementListProvider aProvider = getViewElementListProvider(xModel);
+        XHatchListRef aRef = aProvider.GetHatchList();
+        size_t n = aRef->Count();
+        for (size_t i = 0; i < n; ++i)
+        {
+            XHatchEntry* pHatch = aRef->GetHatch(i);
+            if (!pHatch)
+                continue;
+
+            if (pHatch->GetName().equalsIgnoreAsciiCase(rName))
+            {
+                // we need to update the hatch name
+                rName = pHatch->GetName();
+                return XHatch(pHatch->GetHatch());
+            }
+        }
+    }
+    catch (...)
+    {
+        // ignore exception
+    }
+
+    return XHatch();
+}
+
 class PreventUpdate
 {
 public:
@@ -249,6 +292,12 @@ void ChartAreaPanel::updateData()
     XGradient xGradient = getXGradientForName(mxModel, aGradientName);
     XFillGradientItem aGradientItem(aGradientName, xGradient);
     updateFillGradient(false, true, &aGradientItem);
+
+    OUString aHatchName;
+    xPropSet->getPropertyValue("HatchName") >>= aHatchName;
+    XHatch xHatch = getXHatchFromName(mxModel, aHatchName);
+    XFillHatchItem aHatchItem(aHatchName, xHatch);
+    updateFillHatch(false, true, &aHatchItem);
 }
 
 void ChartAreaPanel::modelInvalid()
commit b5c0f852b51dd8b0e9b8bf65fbaa18bc61558107
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Fri Jul 24 01:47:31 2015 +0200

    update gradients in sidebar as well
    
    Change-Id: I0dc737c133e905d75fab23457fb86c8d2b724ce8

diff --git a/chart2/source/controller/inc/ChartController.hxx b/chart2/source/controller/inc/ChartController.hxx
index fb84c45..9749b36 100644
--- a/chart2/source/controller/inc/ChartController.hxx
+++ b/chart2/source/controller/inc/ChartController.hxx
@@ -127,6 +127,7 @@ class ChartWindow;
 class DrawModelWrapper;
 class DrawViewWrapper;
 class ReferenceSizeProvider;
+class ViewElementListProvider;
 
 class ChartController   : public ::cppu::WeakImplHelper12 <
          ::com::sun::star::frame::XController   //comprehends XComponent (required interface)
@@ -433,6 +434,8 @@ public:
 
     bool isShapeContext() const;
 
+    ViewElementListProvider getViewElementListProvider();
+
     DECL_LINK( NotifyUndoActionHdl, SdrUndoAction* );
 
 public:
diff --git a/chart2/source/controller/main/ChartController.cxx b/chart2/source/controller/main/ChartController.cxx
index 138fc65..66a7b29 100644
--- a/chart2/source/controller/main/ChartController.cxx
+++ b/chart2/source/controller/main/ChartController.cxx
@@ -43,6 +43,7 @@
 #include "DrawCommandDispatch.hxx"
 #include "ShapeController.hxx"
 #include "UndoActions.hxx"
+#include "ViewElementListProvider.hxx"
 
 #include <comphelper/InlineContainer.hxx>
 #include <cppuhelper/supportsservice.hxx>
@@ -1623,6 +1624,11 @@ void ChartController::impl_initializeAccessible( const uno::Reference< lang::XIn
         ;
 }
 
+ViewElementListProvider ChartController::getViewElementListProvider()
+{
+    return ViewElementListProvider(m_pDrawModelWrapper.get());
+}
+
 } //namespace chart
 
 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
diff --git a/chart2/source/controller/sidebar/ChartAreaPanel.cxx b/chart2/source/controller/sidebar/ChartAreaPanel.cxx
index 6dcadd1..9e1b5e8 100644
--- a/chart2/source/controller/sidebar/ChartAreaPanel.cxx
+++ b/chart2/source/controller/sidebar/ChartAreaPanel.cxx
@@ -10,6 +10,7 @@
 #include "ChartAreaPanel.hxx"
 
 #include "ChartController.hxx"
+#include "ViewElementListProvider.hxx"
 
 #include <svx/xfltrit.hxx>
 #include <svx/xflftrit.hxx>
@@ -42,6 +43,33 @@ css::uno::Reference<css::beans::XPropertySet> getPropSet(
     return ObjectIdentifier::getObjectPropertySet(aCID, xModel);
 }
 
+XGradient getXGradientForName(css::uno::Reference<css::frame::XModel> xModel,
+        const OUString& rName)
+{
+    css::uno::Reference<css::frame::XController>xController = xModel->getCurrentController();
+    if (!xController.is())
+        return XGradient();
+
+    ChartController* pController = dynamic_cast<ChartController*>(xController.get());
+    if (!pController)
+        return XGradient();
+
+    ViewElementListProvider aProvider = pController->getViewElementListProvider();
+    XGradientListRef aRef = aProvider.GetGradientList();
+    size_t n = aRef->Count();
+    for (size_t i = 0; i < n; ++i)
+    {
+        XGradientEntry* pGradient = aRef->GetGradient(i);
+        if (!pGradient)
+            continue;
+
+        if (pGradient->GetName() == rName)
+            return XGradient(pGradient->GetGradient());
+    }
+
+    return XGradient();
+}
+
 class PreventUpdate
 {
 public:
@@ -215,6 +243,12 @@ void ChartAreaPanel::updateData()
     xPropSet->getPropertyValue("Transparency") >>= nFillTransparence;
     SfxUInt16Item aTransparenceItem(0, nFillTransparence);
     updateFillTransparence(false, true, &aTransparenceItem);
+
+    OUString aGradientName;
+    xPropSet->getPropertyValue("GradientName") >>= aGradientName;
+    XGradient xGradient = getXGradientForName(mxModel, aGradientName);
+    XFillGradientItem aGradientItem(aGradientName, xGradient);
+    updateFillGradient(false, true, &aGradientItem);
 }
 
 void ChartAreaPanel::modelInvalid()
commit e4daf8be5e9c84c378ec6477163647d1c9b7ef55
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Fri Jul 24 00:52:42 2015 +0200

    this nasty update cycle was causing many issues
    
    Setting the property from the sidebar was causing the model to be
    changed and therefore updating the sidebar again.
    
    Change-Id: I9ca690ae05d4cb0f2ce16f905a29582cc9e86f64

diff --git a/chart2/source/controller/sidebar/ChartAreaPanel.cxx b/chart2/source/controller/sidebar/ChartAreaPanel.cxx
index 72da2c9..6dcadd1 100644
--- a/chart2/source/controller/sidebar/ChartAreaPanel.cxx
+++ b/chart2/source/controller/sidebar/ChartAreaPanel.cxx
@@ -42,6 +42,24 @@ css::uno::Reference<css::beans::XPropertySet> getPropSet(
     return ObjectIdentifier::getObjectPropertySet(aCID, xModel);
 }
 
+class PreventUpdate
+{
+public:
+    PreventUpdate(bool& bUpdate):
+        mbUpdate(bUpdate)
+    {
+        mbUpdate = false;
+    }
+
+    ~PreventUpdate()
+    {
+        mbUpdate = true;
+    }
+
+private:
+    bool& mbUpdate;
+};
+
 }
 
 VclPtr<vcl::Window> ChartAreaPanel::Create(
@@ -64,7 +82,8 @@ ChartAreaPanel::ChartAreaPanel(vcl::Window* pParent,
     svx::sidebar::AreaPropertyPanelBase(pParent, rxFrame),
     mxModel(pController->getModel()),
     mxListener(new ChartSidebarModifyListener(this)),
-    mxSelectionListener(new ChartSidebarSelectionListener(this))
+    mxSelectionListener(new ChartSidebarSelectionListener(this)),
+    mbUpdate(true)
 {
     Initialize();
 }
@@ -98,6 +117,7 @@ void ChartAreaPanel::Initialize()
 
 void ChartAreaPanel::setFillTransparence(const XFillTransparenceItem& rItem)
 {
+    PreventUpdate aProtector(mbUpdate);
     css::uno::Reference<css::beans::XPropertySet> xPropSet = getPropSet(mxModel);
     if (!xPropSet.is())
         return;
@@ -108,6 +128,7 @@ void ChartAreaPanel::setFillTransparence(const XFillTransparenceItem& rItem)
 void ChartAreaPanel::setFillFloatTransparence(
         const XFillFloatTransparenceItem& rItem)
 {
+    PreventUpdate aProtector(mbUpdate);
     css::uno::Reference<css::beans::XPropertySet> xPropSet = getPropSet(mxModel);
     if (!xPropSet.is())
         return;
@@ -117,6 +138,7 @@ void ChartAreaPanel::setFillFloatTransparence(
 
 void ChartAreaPanel::setFillStyle(const XFillStyleItem& rItem)
 {
+    PreventUpdate aProtector(mbUpdate);
     css::uno::Reference<css::beans::XPropertySet> xPropSet = getPropSet(mxModel);
     if (!xPropSet.is())
         return;
@@ -139,6 +161,7 @@ void ChartAreaPanel::setFillStyleAndColor(const XFillStyleItem* pStyleItem,
 void ChartAreaPanel::setFillStyleAndGradient(const XFillStyleItem* pStyleItem,
         const XFillGradientItem& rGradientItem)
 {
+    PreventUpdate aProtector(mbUpdate);
     css::uno::Reference<css::beans::XPropertySet> xPropSet = getPropSet(mxModel);
     if (!xPropSet.is())
         return;
@@ -151,6 +174,7 @@ void ChartAreaPanel::setFillStyleAndGradient(const XFillStyleItem* pStyleItem,
 void ChartAreaPanel::setFillStyleAndHatch(const XFillStyleItem* pStyleItem,
         const XFillHatchItem& rHatchItem)
 {
+    PreventUpdate aProtector(mbUpdate);
     css::uno::Reference<css::beans::XPropertySet> xPropSet = getPropSet(mxModel);
     if (!xPropSet.is())
         return;
@@ -163,6 +187,7 @@ void ChartAreaPanel::setFillStyleAndHatch(const XFillStyleItem* pStyleItem,
 void ChartAreaPanel::setFillStyleAndBitmap(const XFillStyleItem* pStyleItem,
         const XFillBitmapItem& rBitmapItem)
 {
+    PreventUpdate aProtector(mbUpdate);
     css::uno::Reference<css::beans::XPropertySet> xPropSet = getPropSet(mxModel);
     if (!xPropSet.is())
         return;
@@ -174,6 +199,9 @@ void ChartAreaPanel::setFillStyleAndBitmap(const XFillStyleItem* pStyleItem,
 
 void ChartAreaPanel::updateData()
 {
+    if (!mbUpdate)
+        return;
+
     css::uno::Reference<css::beans::XPropertySet> xPropSet = getPropSet(mxModel);
     if (!xPropSet.is())
         return;
diff --git a/chart2/source/controller/sidebar/ChartAreaPanel.hxx b/chart2/source/controller/sidebar/ChartAreaPanel.hxx
index 6678fee..827f1c9 100644
--- a/chart2/source/controller/sidebar/ChartAreaPanel.hxx
+++ b/chart2/source/controller/sidebar/ChartAreaPanel.hxx
@@ -90,6 +90,7 @@ private:
 
     void Initialize();
 
+    bool mbUpdate;
 };
 
 } } // end of namespace svx::sidebar
commit dbeba7e2aa2effee5f73382573b6523d70e0f4d2
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Thu Jul 23 21:01:00 2015 +0200

    we should not disable items because they are set twice
    
    Change-Id: I73130922a773df353db509b0ea62d0013a1df292

diff --git a/svx/source/sidebar/area/AreaPropertyPanelBase.cxx b/svx/source/sidebar/area/AreaPropertyPanelBase.cxx
index 3b94efc..9db2ad5 100644
--- a/svx/source/sidebar/area/AreaPropertyPanelBase.cxx
+++ b/svx/source/sidebar/area/AreaPropertyPanelBase.cxx
@@ -473,7 +473,7 @@ void AreaPropertyPanelBase::DataChanged(
 
 void AreaPropertyPanelBase::ImpUpdateTransparencies()
 {
-    if(mpTransparanceItem.get() && mpFloatTransparenceItem.get())
+    if(mpTransparanceItem.get() || mpFloatTransparenceItem.get())
     {
         bool bZeroValue(false);
 
@@ -601,7 +601,7 @@ void AreaPropertyPanelBase::updateFillTransparence(bool bDisabled, bool bDefault
     }
     else if(bDefault)
     {
-        if(pItem && (!mpTransparanceItem || *pItem != *mpTransparanceItem))
+        if(pItem)
         {
             mpTransparanceItem.reset(static_cast<SfxUInt16Item*>(pItem->Clone()));
         }
@@ -629,7 +629,7 @@ void AreaPropertyPanelBase::updateFillFloatTransparence(bool bDisabled, bool bDe
 
     if(bDefault)
     {
-        if(pItem && (!mpFloatTransparenceItem || *pItem != *mpFloatTransparenceItem))
+        if(pItem)
         {
             mpFloatTransparenceItem.reset(static_cast<XFillFloatTransparenceItem*>(pItem->Clone()));
         }
commit b3a52304593328b8950602535ef03d026ee27bf0
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Thu Jul 23 21:00:37 2015 +0200

    update some area properties
    
    Change-Id: Iab888226ef1b8f18a6cdfd0ddf58077405306510

diff --git a/chart2/source/controller/sidebar/ChartAreaPanel.cxx b/chart2/source/controller/sidebar/ChartAreaPanel.cxx
index 5a3d4b6..72da2c9 100644
--- a/chart2/source/controller/sidebar/ChartAreaPanel.cxx
+++ b/chart2/source/controller/sidebar/ChartAreaPanel.cxx
@@ -66,6 +66,7 @@ ChartAreaPanel::ChartAreaPanel(vcl::Window* pParent,
     mxListener(new ChartSidebarModifyListener(this)),
     mxSelectionListener(new ChartSidebarSelectionListener(this))
 {
+    Initialize();
 }
 
 ChartAreaPanel::~ChartAreaPanel()
@@ -173,6 +174,19 @@ void ChartAreaPanel::setFillStyleAndBitmap(const XFillStyleItem* pStyleItem,
 
 void ChartAreaPanel::updateData()
 {
+    css::uno::Reference<css::beans::XPropertySet> xPropSet = getPropSet(mxModel);
+    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("Transparency") >>= nFillTransparence;
+    SfxUInt16Item aTransparenceItem(0, nFillTransparence);
+    updateFillTransparence(false, true, &aTransparenceItem);
 }
 
 void ChartAreaPanel::modelInvalid()
commit 427f28ea2f49005c63338e6df4fc5cf010fa38c0
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Thu Jul 23 16:47:49 2015 +0200

    add selection change listener to area panel
    
    Change-Id: I4e3f0c1c669ec1c584cc2d6932fd78e177effa89

diff --git a/chart2/source/controller/sidebar/ChartAreaPanel.cxx b/chart2/source/controller/sidebar/ChartAreaPanel.cxx
index 897d8ad..5a3d4b6 100644
--- a/chart2/source/controller/sidebar/ChartAreaPanel.cxx
+++ b/chart2/source/controller/sidebar/ChartAreaPanel.cxx
@@ -63,7 +63,8 @@ ChartAreaPanel::ChartAreaPanel(vcl::Window* pParent,
         ChartController* pController):
     svx::sidebar::AreaPropertyPanelBase(pParent, rxFrame),
     mxModel(pController->getModel()),
-    mxListener(new ChartSidebarModifyListener(this))
+    mxListener(new ChartSidebarModifyListener(this)),
+    mxSelectionListener(new ChartSidebarSelectionListener(this))
 {
 }
 
@@ -77,6 +78,10 @@ void ChartAreaPanel::dispose()
     css::uno::Reference<css::util::XModifyBroadcaster> xBroadcaster(mxModel, css::uno::UNO_QUERY_THROW);
     xBroadcaster->removeModifyListener(mxListener);
 
+    css::uno::Reference<css::view::XSelectionSupplier> xSelectionSupplier(mxModel->getCurrentController(), css::uno::UNO_QUERY);
+    if (xSelectionSupplier.is())
+        xSelectionSupplier->removeSelectionChangeListener(mxSelectionListener);
+
     AreaPropertyPanelBase::dispose();
 }
 
@@ -84,6 +89,10 @@ void ChartAreaPanel::Initialize()
 {
     css::uno::Reference<css::util::XModifyBroadcaster> xBroadcaster(mxModel, css::uno::UNO_QUERY_THROW);
     xBroadcaster->addModifyListener(mxListener);
+
+    css::uno::Reference<css::view::XSelectionSupplier> xSelectionSupplier(mxModel->getCurrentController(), css::uno::UNO_QUERY);
+    if (xSelectionSupplier.is())
+        xSelectionSupplier->addSelectionChangeListener(mxSelectionListener);
 }
 
 void ChartAreaPanel::setFillTransparence(const XFillTransparenceItem& rItem)
@@ -170,6 +179,16 @@ void ChartAreaPanel::modelInvalid()
 {
 }
 
+void ChartAreaPanel::selectionChanged(bool bCorrectType)
+{
+    if (bCorrectType)
+        updateData();
+}
+
+void ChartAreaPanel::SelectionInvalid()
+{
+}
+
 void ChartAreaPanel::updateModel(
         css::uno::Reference<css::frame::XModel> xModel)
 {
@@ -180,6 +199,10 @@ void ChartAreaPanel::updateModel(
 
     css::uno::Reference<css::util::XModifyBroadcaster> xBroadcasterNew(mxModel, css::uno::UNO_QUERY_THROW);
     xBroadcasterNew->addModifyListener(mxListener);
+
+    css::uno::Reference<css::view::XSelectionSupplier> xSelectionSupplier(mxModel->getCurrentController(), css::uno::UNO_QUERY);
+    if (xSelectionSupplier.is())
+        xSelectionSupplier->addSelectionChangeListener(mxSelectionListener);
 }
 
 
diff --git a/chart2/source/controller/sidebar/ChartAreaPanel.hxx b/chart2/source/controller/sidebar/ChartAreaPanel.hxx
index 7a0875b..6678fee 100644
--- a/chart2/source/controller/sidebar/ChartAreaPanel.hxx
+++ b/chart2/source/controller/sidebar/ChartAreaPanel.hxx
@@ -29,6 +29,7 @@
 #include <svx/sidebar/AreaPropertyPanelBase.hxx>
 
 #include "ChartSidebarModifyListener.hxx"
+#include "ChartSidebarSelectionListener.hxx"
 
 class XFillFloatTransparenceItem;
 class XFillTransparenceItem;
@@ -47,7 +48,7 @@ namespace sidebar {
 class ChartAreaPanel : public svx::sidebar::AreaPropertyPanelBase,
     public sfx2::sidebar::SidebarModelUpdate,
     public ChartSidebarModifyListenerParent,
-    public sfx2::sidebar::SidebarModelUpdate
+    public ChartSidebarSelectionListenerParent
 {
 public:
     static VclPtr<vcl::Window> Create(
@@ -72,9 +73,11 @@ public:
     virtual void setFillStyleAndBitmap(const XFillStyleItem* pStyleItem, const XFillBitmapItem& rBitmapItem);
 
     virtual void updateData() SAL_OVERRIDE;
-
     virtual void modelInvalid() SAL_OVERRIDE;
 
+    virtual void selectionChanged(bool bCorrectType) SAL_OVERRIDE;
+    virtual void SelectionInvalid() SAL_OVERRIDE;
+
     virtual void dispose() SAL_OVERRIDE;
 
     virtual void updateModel(css::uno::Reference<css::frame::XModel> xModel) SAL_OVERRIDE;
@@ -83,6 +86,7 @@ private:
 
     css::uno::Reference<css::frame::XModel> mxModel;
     css::uno::Reference<css::util::XModifyListener> mxListener;
+    css::uno::Reference<css::view::XSelectionChangeListener> mxSelectionListener;
 
     void Initialize();
 
commit bc4592132f3f6b5b04c8c9c5e63976c5d2dc6b4f
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Thu Jul 23 16:20:36 2015 +0200

    add selection change listener
    
    This finally allows us to handle the case where you switch between
    objects of the same type.
    
    Change-Id: Ic13e15e2a426d08995a577dfc1b7ee6f7da04f30

diff --git a/chart2/Library_chartcontroller.mk b/chart2/Library_chartcontroller.mk
index 198640e..2e03a7e 100644
--- a/chart2/Library_chartcontroller.mk
+++ b/chart2/Library_chartcontroller.mk
@@ -194,6 +194,7 @@ $(eval $(call gb_Library_add_exception_objects,chartcontroller,\
     chart2/source/controller/sidebar/ChartErrorBarPanel \
     chart2/source/controller/sidebar/ChartSeriesPanel \
     chart2/source/controller/sidebar/ChartSidebarModifyListener \
+    chart2/source/controller/sidebar/ChartSidebarSelectionListener \
 ))
 
 # Runtime dependency for unit-tests
diff --git a/chart2/source/controller/sidebar/ChartAxisPanel.cxx b/chart2/source/controller/sidebar/ChartAxisPanel.cxx
index ba1a5e7..a9dcae7 100644
--- a/chart2/source/controller/sidebar/ChartAxisPanel.cxx
+++ b/chart2/source/controller/sidebar/ChartAxisPanel.cxx
@@ -190,7 +190,8 @@ ChartAxisPanel::ChartAxisPanel(
   : PanelLayout(pParent, "ChartAxisPanel", "modules/schart/ui/sidebaraxis.ui", rxFrame),
     mxFrame(rxFrame),
     mxModel(pController->getModel()),
-    mxListener(new ChartSidebarModifyListener(this))
+    mxModifyListener(new ChartSidebarModifyListener(this)),
+    mxSelectionListener(new ChartSidebarSelectionListener(this, OBJECTTYPE_AXIS))
 {
     get(mpCBShowLabel, "checkbutton_show_label");
     get(mpCBReverse, "checkbutton_reverse");
@@ -208,7 +209,11 @@ ChartAxisPanel::~ChartAxisPanel()
 void ChartAxisPanel::dispose()
 {
     css::uno::Reference<css::util::XModifyBroadcaster> xBroadcaster(mxModel, css::uno::UNO_QUERY_THROW);
-    xBroadcaster->removeModifyListener(mxListener);
+    xBroadcaster->removeModifyListener(mxModifyListener);
+
+    css::uno::Reference<css::view::XSelectionSupplier> xSelectionSupplier(mxModel->getCurrentController(), css::uno::UNO_QUERY);
+    if (xSelectionSupplier.is())
+        xSelectionSupplier->removeSelectionChangeListener(mxSelectionListener);
 
     mpCBShowLabel.clear();
     mpCBReverse.clear();
@@ -221,7 +226,11 @@ void ChartAxisPanel::dispose()
 void ChartAxisPanel::Initialize()
 {
     css::uno::Reference<css::util::XModifyBroadcaster> xBroadcaster(mxModel, css::uno::UNO_QUERY_THROW);
-    xBroadcaster->addModifyListener(mxListener);
+    xBroadcaster->addModifyListener(mxModifyListener);
+
+    css::uno::Reference<css::view::XSelectionSupplier> xSelectionSupplier(mxModel->getCurrentController(), css::uno::UNO_QUERY);
+    if (xSelectionSupplier.is())
+        xSelectionSupplier->addSelectionChangeListener(mxSelectionListener);
 
     updateData();
 
@@ -285,12 +294,26 @@ void ChartAxisPanel::updateModel(
         css::uno::Reference<css::frame::XModel> xModel)
 {
     css::uno::Reference<css::util::XModifyBroadcaster> xBroadcaster(mxModel, css::uno::UNO_QUERY_THROW);
-    xBroadcaster->removeModifyListener(mxListener);
+    xBroadcaster->removeModifyListener(mxModifyListener);
 
     mxModel = xModel;
 
     css::uno::Reference<css::util::XModifyBroadcaster> xBroadcasterNew(mxModel, css::uno::UNO_QUERY_THROW);
-    xBroadcasterNew->addModifyListener(mxListener);
+    xBroadcasterNew->addModifyListener(mxModifyListener);
+
+    css::uno::Reference<css::view::XSelectionSupplier> xSelectionSupplier(mxModel->getCurrentController(), css::uno::UNO_QUERY);
+    if (xSelectionSupplier.is())
+        xSelectionSupplier->addSelectionChangeListener(mxSelectionListener);
+}
+
+void ChartAxisPanel::selectionChanged(bool bCorrectType)
+{
+    if (bCorrectType)
+        updateData();
+}
+
+void ChartAxisPanel::SelectionInvalid()
+{
 }
 
 IMPL_LINK(ChartAxisPanel, CheckBoxHdl, CheckBox*, pCheckbox)
diff --git a/chart2/source/controller/sidebar/ChartAxisPanel.hxx b/chart2/source/controller/sidebar/ChartAxisPanel.hxx
index 5c1177f..c21fa33 100644
--- a/chart2/source/controller/sidebar/ChartAxisPanel.hxx
+++ b/chart2/source/controller/sidebar/ChartAxisPanel.hxx
@@ -17,8 +17,10 @@
 #include <svx/sidebar/PanelLayout.hxx>
 
 #include "ChartSidebarModifyListener.hxx"
+#include "ChartSidebarSelectionListener.hxx"
 
 #include <com/sun/star/util/XModifyListener.hpp>
+#include <com/sun/star/view/XSelectionChangeListener.hpp>
 
 class FixedText;
 class ListBox;
@@ -34,7 +36,8 @@ class ChartAxisPanel : public PanelLayout,
     public ::sfx2::sidebar::IContextChangeReceiver,
     public ::sfx2::sidebar::ControllerItem::ItemUpdateReceiverInterface,
     public sfx2::sidebar::SidebarModelUpdate,
-    public ChartSidebarModifyListenerParent
+    public ChartSidebarModifyListenerParent,
+    public ChartSidebarSelectionListenerParent
 {
 public:
     static VclPtr<vcl::Window> Create(
@@ -65,6 +68,9 @@ public:
     virtual void updateData() SAL_OVERRIDE;
     virtual void modelInvalid() SAL_OVERRIDE;
 
+    virtual void selectionChanged(bool bCorrectType) SAL_OVERRIDE;
+    virtual void SelectionInvalid() SAL_OVERRIDE;
+
     virtual void updateModel(css::uno::Reference<css::frame::XModel> xModel) SAL_OVERRIDE;
 
 private:
@@ -77,7 +83,8 @@ private:
     css::uno::Reference<css::frame::XFrame> mxFrame;
 
     css::uno::Reference<css::frame::XModel> mxModel;
-    css::uno::Reference<css::util::XModifyListener> mxListener;
+    css::uno::Reference<css::util::XModifyListener> mxModifyListener;
+    css::uno::Reference<css::view::XSelectionChangeListener> mxSelectionListener;
 
     void Initialize();
 
diff --git a/chart2/source/controller/sidebar/ChartSeriesPanel.cxx b/chart2/source/controller/sidebar/ChartSeriesPanel.cxx
index 0cb9aee..644766d 100644
--- a/chart2/source/controller/sidebar/ChartSeriesPanel.cxx
+++ b/chart2/source/controller/sidebar/ChartSeriesPanel.cxx
@@ -291,7 +291,8 @@ ChartSeriesPanel::ChartSeriesPanel(
   : PanelLayout(pParent, "ChartSeriesPanel", "modules/schart/ui/sidebarseries.ui", rxFrame),
     mxFrame(rxFrame),
     mxModel(pController->getModel()),
-    mxListener(new ChartSidebarModifyListener(this))
+    mxListener(new ChartSidebarModifyListener(this)),
+    mxSelectionListener(new ChartSidebarSelectionListener(this, OBJECTTYPE_DATA_SERIES))
 {
     get(mpCBLabel, "checkbutton_label");
     get(mpCBTrendline, "checkbutton_trendline");
@@ -317,6 +318,9 @@ void ChartSeriesPanel::dispose()
 {
     css::uno::Reference<css::util::XModifyBroadcaster> xBroadcaster(mxModel, css::uno::UNO_QUERY_THROW);
     xBroadcaster->removeModifyListener(mxListener);
+    css::uno::Reference<css::view::XSelectionSupplier> xSelectionSupplier(mxModel->getCurrentController(), css::uno::UNO_QUERY);
+    if (xSelectionSupplier.is())
+        xSelectionSupplier->removeSelectionChangeListener(mxSelectionListener);
 
     mpCBLabel.clear();
     mpCBTrendline.clear();
@@ -337,6 +341,9 @@ void ChartSeriesPanel::Initialize()
 {
     css::uno::Reference<css::util::XModifyBroadcaster> xBroadcaster(mxModel, css::uno::UNO_QUERY_THROW);
     xBroadcaster->addModifyListener(mxListener);
+    css::uno::Reference<css::view::XSelectionSupplier> xSelectionSupplier(mxModel->getCurrentController(), css::uno::UNO_QUERY);
+    if (xSelectionSupplier.is())
+        xSelectionSupplier->addSelectionChangeListener(mxSelectionListener);
 
     updateData();
 
@@ -422,6 +429,20 @@ void ChartSeriesPanel::updateModel(
 
     css::uno::Reference<css::util::XModifyBroadcaster> xBroadcasterNew(mxModel, css::uno::UNO_QUERY_THROW);
     xBroadcasterNew->addModifyListener(mxListener);
+
+    css::uno::Reference<css::view::XSelectionSupplier> xSelectionSupplier(mxModel->getCurrentController(), css::uno::UNO_QUERY);
+    if (xSelectionSupplier.is())
+        xSelectionSupplier->addSelectionChangeListener(mxSelectionListener);
+}
+
+void ChartSeriesPanel::selectionChanged(bool bCorrectType)
+{
+    if (bCorrectType)
+        updateData();
+}
+
+void ChartSeriesPanel::SelectionInvalid()
+{
 }
 
 IMPL_LINK(ChartSeriesPanel, CheckBoxHdl, CheckBox*, pCheckBox)
diff --git a/chart2/source/controller/sidebar/ChartSeriesPanel.hxx b/chart2/source/controller/sidebar/ChartSeriesPanel.hxx
index 10d73ee..156bbc7 100644
--- a/chart2/source/controller/sidebar/ChartSeriesPanel.hxx
+++ b/chart2/source/controller/sidebar/ChartSeriesPanel.hxx
@@ -25,8 +25,10 @@
 #include <svx/sidebar/PanelLayout.hxx>
 
 #include "ChartSidebarModifyListener.hxx"
+#include "ChartSidebarSelectionListener.hxx"
 
 #include <com/sun/star/util/XModifyListener.hpp>
+#include <com/sun/star/view/XSelectionChangeListener.hpp>
 
 class FixedText;
 class ListBox;
@@ -42,7 +44,8 @@ class ChartSeriesPanel : public PanelLayout,
     public ::sfx2::sidebar::IContextChangeReceiver,
     public ::sfx2::sidebar::ControllerItem::ItemUpdateReceiverInterface,
     public sfx2::sidebar::SidebarModelUpdate,
-    public ChartSidebarModifyListenerParent
+    public ChartSidebarModifyListenerParent,
+    public ChartSidebarSelectionListenerParent
 {
 public:
     static VclPtr<vcl::Window> Create(
@@ -73,6 +76,9 @@ public:
     virtual void updateData() SAL_OVERRIDE;
     virtual void modelInvalid() SAL_OVERRIDE;
 
+    virtual void selectionChanged(bool bCorrectType) SAL_OVERRIDE;
+    virtual void SelectionInvalid() SAL_OVERRIDE;
+
     virtual void updateModel(css::uno::Reference<css::frame::XModel> xModel) SAL_OVERRIDE;
 
 private:
@@ -93,6 +99,7 @@ private:
 
     css::uno::Reference<css::frame::XModel> mxModel;
     css::uno::Reference<css::util::XModifyListener> mxListener;
+    css::uno::Reference<css::view::XSelectionChangeListener> mxSelectionListener;
 
     void Initialize();
 
diff --git a/chart2/source/controller/sidebar/ChartSidebarSelectionListener.cxx b/chart2/source/controller/sidebar/ChartSidebarSelectionListener.cxx
new file mode 100644
index 0000000..1f435e1
--- /dev/null
+++ b/chart2/source/controller/sidebar/ChartSidebarSelectionListener.cxx
@@ -0,0 +1,81 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include "ChartSidebarSelectionListener.hxx"
+
+#include <com/sun/star/view/XSelectionSupplier.hpp>
+#include <com/sun/star/frame/XController.hpp>
+
+#include "ObjectIdentifier.hxx"
+
+namespace chart {
+namespace sidebar {
+
+ChartSidebarSelectionListenerParent::~ChartSidebarSelectionListenerParent()
+{
+}
+
+ChartSidebarSelectionListener::ChartSidebarSelectionListener(
+        ChartSidebarSelectionListenerParent* pParent):
+    mpParent(pParent),
+    mbAll(true),
+    meType()
+{
+}
+
+ChartSidebarSelectionListener::ChartSidebarSelectionListener(
+        ChartSidebarSelectionListenerParent* pParent,
+        ObjectType eType):
+    mpParent(pParent),
+    mbAll(false),
+    meType(eType)
+{
+}
+
+ChartSidebarSelectionListener::~ChartSidebarSelectionListener()
+{
+}
+
+void ChartSidebarSelectionListener::selectionChanged(const css::lang::EventObject& rEvent)
+        throw (::css::uno::RuntimeException, ::std::exception)
+{
+    (void)rEvent;
+    bool bCorrectObjectSelected = false;
+    if (mbAll)
+        bCorrectObjectSelected = true;
+
+    css::uno::Reference<css::frame::XController> xController(rEvent.Source, css::uno::UNO_QUERY);
+    if (!mbAll && xController.is())
+    {
+        css::uno::Reference<css::view::XSelectionSupplier> xSelectionSupplier(xController, css::uno::UNO_QUERY);
+        if (xSelectionSupplier.is())
+        {
+            css::uno::Any aAny = xSelectionSupplier->getSelection();
+            if (aAny.hasValue())
+            {
+                OUString aCID;
+                aAny >>= aCID;
+                ObjectType eType = ObjectIdentifier::getObjectType(aCID);
+                bCorrectObjectSelected = eType == meType;
+            }
+        }
+    }
+
+    mpParent->selectionChanged(bCorrectObjectSelected);
+}
+
+void ChartSidebarSelectionListener::disposing(const css::lang::EventObject& /*rEvent*/)
+        throw (::css::uno::RuntimeException, ::std::exception)
+{
+    mpParent->SelectionInvalid();
+}
+
+} }
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/controller/sidebar/ChartSidebarSelectionListener.hxx b/chart2/source/controller/sidebar/ChartSidebarSelectionListener.hxx
new file mode 100644
index 0000000..cfe90e7
--- /dev/null
+++ b/chart2/source/controller/sidebar/ChartSidebarSelectionListener.hxx
@@ -0,0 +1,58 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef INCLUDED_CHART2_SOURCE_CONTROLLER_SIDEBAR_CHARTSIDEBARSELECTIONLISTENER_HXX
+#define INCLUDED_CHART2_SOURCE_CONTROLLER_SIDEBAR_CHARTSIDEBARSELECTIONLISTENER_HXX
+
+#include <com/sun/star/view/XSelectionChangeListener.hpp>
+#include <cppuhelper/implbase1.hxx>
+
+#include "ObjectIdentifier.hxx"
+
+namespace chart {
+namespace sidebar {
+
+class ChartSidebarSelectionListenerParent
+{
+public:
+    virtual ~ChartSidebarSelectionListenerParent();
+
+    virtual void selectionChanged(bool bSelected) = 0;
+
+    virtual void SelectionInvalid() = 0;
+};
+
+class ChartSidebarSelectionListener : public cppu::WeakImplHelper1<css::view::XSelectionChangeListener>
+{
+public:
+
+    // listen to all chart selection changes
+    ChartSidebarSelectionListener(ChartSidebarSelectionListenerParent* pParent);
+    // only liste to the changes of eType
+    ChartSidebarSelectionListener(ChartSidebarSelectionListenerParent* pParent, ObjectType eType);
+    virtual ~ChartSidebarSelectionListener();
+
+    virtual void SAL_CALL selectionChanged(const css::lang::EventObject& rEvent)
+        throw (::css::uno::RuntimeException, ::std::exception) SAL_OVERRIDE;
+
+    virtual void SAL_CALL disposing(const css::lang::EventObject& rEvent)
+        throw (::css::uno::RuntimeException, ::std::exception) SAL_OVERRIDE;
+
+private:
+    ChartSidebarSelectionListenerParent* mpParent;
+
+    bool mbAll;
+    ObjectType meType;
+};
+
+} }
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 0635208edf1cdee4235ea87666a473ac81007555
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Thu Jul 23 01:20:45 2015 +0200

    handle more than one chart with chart sidebar
    
    Change-Id: I4998904a9273f2c67114a246d7f234843602573c

diff --git a/chart2/source/controller/main/ChartController.cxx b/chart2/source/controller/main/ChartController.cxx
index 9c51cf5..138fc65 100644
--- a/chart2/source/controller/main/ChartController.cxx
+++ b/chart2/source/controller/main/ChartController.cxx
@@ -421,6 +421,7 @@ void SAL_CALL ChartController::attachFrame(
     {
         sfx2::sidebar::SidebarController* pSidebar = dynamic_cast<sfx2::sidebar::SidebarController*>(xSidebar.get());
         sfx2::sidebar::SidebarController::registerSidebarForFrame(pSidebar, this);
+        pSidebar->updateModel(getModel());
     }
 
     if(m_xFrame.is()) //what happens, if we do have a Frame already??
diff --git a/chart2/source/controller/sidebar/ChartAreaPanel.cxx b/chart2/source/controller/sidebar/ChartAreaPanel.cxx
index 945e505..897d8ad 100644
--- a/chart2/source/controller/sidebar/ChartAreaPanel.cxx
+++ b/chart2/source/controller/sidebar/ChartAreaPanel.cxx
@@ -170,6 +170,18 @@ void ChartAreaPanel::modelInvalid()
 {
 }
 
+void ChartAreaPanel::updateModel(
+        css::uno::Reference<css::frame::XModel> xModel)
+{
+    css::uno::Reference<css::util::XModifyBroadcaster> xBroadcaster(mxModel, css::uno::UNO_QUERY_THROW);
+    xBroadcaster->removeModifyListener(mxListener);
+
+    mxModel = xModel;
+
+    css::uno::Reference<css::util::XModifyBroadcaster> xBroadcasterNew(mxModel, css::uno::UNO_QUERY_THROW);
+    xBroadcasterNew->addModifyListener(mxListener);
+}
+
 
 } }
 
diff --git a/chart2/source/controller/sidebar/ChartAreaPanel.hxx b/chart2/source/controller/sidebar/ChartAreaPanel.hxx
index f5b45ae..7a0875b 100644
--- a/chart2/source/controller/sidebar/ChartAreaPanel.hxx
+++ b/chart2/source/controller/sidebar/ChartAreaPanel.hxx
@@ -12,6 +12,7 @@
 
 #include <vcl/ctrl.hxx>
 #include <sfx2/sidebar/ControllerItem.hxx>
+#include <sfx2/sidebar/SidebarModelUpdate.hxx>
 #include <svx/xgrad.hxx>
 #include <svx/itemwin.hxx>
 #include <svx/xfillit0.hxx>
@@ -44,7 +45,9 @@ class ChartController;
 namespace sidebar {
 
 class ChartAreaPanel : public svx::sidebar::AreaPropertyPanelBase,
-    public ChartSidebarModifyListenerParent
+    public sfx2::sidebar::SidebarModelUpdate,
+    public ChartSidebarModifyListenerParent,
+    public sfx2::sidebar::SidebarModelUpdate
 {
 public:
     static VclPtr<vcl::Window> Create(
@@ -74,6 +77,8 @@ public:
 
     virtual void dispose() SAL_OVERRIDE;
 
+    virtual void updateModel(css::uno::Reference<css::frame::XModel> xModel) SAL_OVERRIDE;
+
 private:
 
     css::uno::Reference<css::frame::XModel> mxModel;
diff --git a/chart2/source/controller/sidebar/ChartAxisPanel.cxx b/chart2/source/controller/sidebar/ChartAxisPanel.cxx
index e6fa2e3..ba1a5e7 100644
--- a/chart2/source/controller/sidebar/ChartAxisPanel.cxx
+++ b/chart2/source/controller/sidebar/ChartAxisPanel.cxx
@@ -281,6 +281,18 @@ void ChartAxisPanel::modelInvalid()
 {
 }
 
+void ChartAxisPanel::updateModel(
+        css::uno::Reference<css::frame::XModel> xModel)
+{
+    css::uno::Reference<css::util::XModifyBroadcaster> xBroadcaster(mxModel, css::uno::UNO_QUERY_THROW);
+    xBroadcaster->removeModifyListener(mxListener);
+
+    mxModel = xModel;
+
+    css::uno::Reference<css::util::XModifyBroadcaster> xBroadcasterNew(mxModel, css::uno::UNO_QUERY_THROW);
+    xBroadcasterNew->addModifyListener(mxListener);
+}
+
 IMPL_LINK(ChartAxisPanel, CheckBoxHdl, CheckBox*, pCheckbox)
 {
     OUString aCID = getCID(mxModel);
diff --git a/chart2/source/controller/sidebar/ChartAxisPanel.hxx b/chart2/source/controller/sidebar/ChartAxisPanel.hxx
index 8737ab4..5c1177f 100644
--- a/chart2/source/controller/sidebar/ChartAxisPanel.hxx
+++ b/chart2/source/controller/sidebar/ChartAxisPanel.hxx
@@ -13,6 +13,7 @@
 
 #include <sfx2/sidebar/ControllerItem.hxx>
 #include <sfx2/sidebar/IContextChangeReceiver.hxx>
+#include <sfx2/sidebar/SidebarModelUpdate.hxx>
 #include <svx/sidebar/PanelLayout.hxx>
 
 #include "ChartSidebarModifyListener.hxx"
@@ -32,6 +33,7 @@ namespace sidebar {
 class ChartAxisPanel : public PanelLayout,
     public ::sfx2::sidebar::IContextChangeReceiver,
     public ::sfx2::sidebar::ControllerItem::ItemUpdateReceiverInterface,
+    public sfx2::sidebar::SidebarModelUpdate,
     public ChartSidebarModifyListenerParent
 {
 public:
@@ -63,6 +65,8 @@ public:
     virtual void updateData() SAL_OVERRIDE;
     virtual void modelInvalid() SAL_OVERRIDE;
 
+    virtual void updateModel(css::uno::Reference<css::frame::XModel> xModel) SAL_OVERRIDE;
+
 private:
     //ui controls
     VclPtr<CheckBox> mpCBShowLabel;
diff --git a/chart2/source/controller/sidebar/ChartElementsPanel.cxx b/chart2/source/controller/sidebar/ChartElementsPanel.cxx
index 1cbec9e..fd498ff 100644
--- a/chart2/source/controller/sidebar/ChartElementsPanel.cxx
+++ b/chart2/source/controller/sidebar/ChartElementsPanel.cxx
@@ -451,6 +451,18 @@ void ChartElementsPanel::modelInvalid()
 
 }
 
+void ChartElementsPanel::updateModel(
+        css::uno::Reference<css::frame::XModel> xModel)
+{
+    css::uno::Reference<css::util::XModifyBroadcaster> xBroadcaster(mxModel, css::uno::UNO_QUERY_THROW);
+    xBroadcaster->removeModifyListener(mxListener);
+
+    mxModel = xModel;
+
+    css::uno::Reference<css::util::XModifyBroadcaster> xBroadcasterNew(mxModel, css::uno::UNO_QUERY_THROW);
+    xBroadcasterNew->addModifyListener(mxListener);
+}
+
 IMPL_LINK(ChartElementsPanel, CheckBoxHdl, CheckBox*, pCheckBox)
 {
     bool bChecked = pCheckBox->IsChecked();
diff --git a/chart2/source/controller/sidebar/ChartElementsPanel.hxx b/chart2/source/controller/sidebar/ChartElementsPanel.hxx
index 32ffb7d..766915c 100644
--- a/chart2/source/controller/sidebar/ChartElementsPanel.hxx
+++ b/chart2/source/controller/sidebar/ChartElementsPanel.hxx
@@ -21,6 +21,7 @@
 
 #include <sfx2/sidebar/ControllerItem.hxx>
 #include <sfx2/sidebar/IContextChangeReceiver.hxx>
+#include <sfx2/sidebar/SidebarModelUpdate.hxx>
 #include <svx/sidebar/PanelLayout.hxx>
 #include "ChartSidebarModifyListener.hxx"
 
@@ -39,6 +40,7 @@ namespace sidebar {
 class ChartElementsPanel : public PanelLayout,
     public ::sfx2::sidebar::IContextChangeReceiver,
     public ::sfx2::sidebar::ControllerItem::ItemUpdateReceiverInterface,
+    public sfx2::sidebar::SidebarModelUpdate,
     public ChartSidebarModifyListenerParent
 {
 public:
@@ -70,6 +72,8 @@ public:
     virtual void updateData() SAL_OVERRIDE;
     virtual void modelInvalid() SAL_OVERRIDE;
 
+    virtual void updateModel(css::uno::Reference<css::frame::XModel> xModel) SAL_OVERRIDE;
+
 private:
     //ui controls
     VclPtr<CheckBox> mpCBTitle;
diff --git a/chart2/source/controller/sidebar/ChartErrorBarPanel.cxx b/chart2/source/controller/sidebar/ChartErrorBarPanel.cxx
index b5a5075..3163f95 100644
--- a/chart2/source/controller/sidebar/ChartErrorBarPanel.cxx
+++ b/chart2/source/controller/sidebar/ChartErrorBarPanel.cxx
@@ -381,6 +381,18 @@ void ChartErrorBarPanel::modelInvalid()
 {
 }
 
+void ChartErrorBarPanel::updateModel(
+        css::uno::Reference<css::frame::XModel> xModel)
+{
+    css::uno::Reference<css::util::XModifyBroadcaster> xBroadcaster(mxModel, css::uno::UNO_QUERY_THROW);
+    xBroadcaster->removeModifyListener(mxListener);
+
+    mxModel = xModel;
+
+    css::uno::Reference<css::util::XModifyBroadcaster> xBroadcasterNew(mxModel, css::uno::UNO_QUERY_THROW);
+    xBroadcasterNew->addModifyListener(mxListener);
+}
+
 IMPL_LINK_NOARG(ChartErrorBarPanel, RadioBtnHdl)
 {
     OUString aCID = getCID(mxModel);
diff --git a/chart2/source/controller/sidebar/ChartErrorBarPanel.hxx b/chart2/source/controller/sidebar/ChartErrorBarPanel.hxx
index 84d4b9c..e9c102b 100644
--- a/chart2/source/controller/sidebar/ChartErrorBarPanel.hxx
+++ b/chart2/source/controller/sidebar/ChartErrorBarPanel.hxx
@@ -13,6 +13,7 @@
 
 #include <sfx2/sidebar/ControllerItem.hxx>
 #include <sfx2/sidebar/IContextChangeReceiver.hxx>
+#include <sfx2/sidebar/SidebarModelUpdate.hxx>
 #include <svx/sidebar/PanelLayout.hxx>
 
 #include "ChartSidebarModifyListener.hxx"
@@ -33,6 +34,7 @@ namespace sidebar {
 class ChartErrorBarPanel : public PanelLayout,
     public ::sfx2::sidebar::IContextChangeReceiver,
     public ::sfx2::sidebar::ControllerItem::ItemUpdateReceiverInterface,
+    public sfx2::sidebar::SidebarModelUpdate,
     public ChartSidebarModifyListenerParent
 {
 public:
@@ -64,6 +66,8 @@ public:
     virtual void updateData() SAL_OVERRIDE;
     virtual void modelInvalid() SAL_OVERRIDE;
 
+    virtual void updateModel(css::uno::Reference<css::frame::XModel> xModel) SAL_OVERRIDE;
+
 private:
     //ui controls
     VclPtr<RadioButton> mpRBPosAndNeg;
diff --git a/chart2/source/controller/sidebar/ChartSeriesPanel.cxx b/chart2/source/controller/sidebar/ChartSeriesPanel.cxx
index 483ae91..0cb9aee 100644
--- a/chart2/source/controller/sidebar/ChartSeriesPanel.cxx
+++ b/chart2/source/controller/sidebar/ChartSeriesPanel.cxx
@@ -269,7 +269,9 @@ OUString getCID(css::uno::Reference<css::frame::XModel> xModel)
         return OUString();
 
     uno::Any aAny = xSelectionSupplier->getSelection();
-    assert(aAny.hasValue());
+    if (!aAny.hasValue())
+        return OUString();
+
     OUString aCID;
     aAny >>= aCID;
 #ifdef DBG_UTIL
@@ -410,6 +412,18 @@ void ChartSeriesPanel::modelInvalid()
 
 }
 
+void ChartSeriesPanel::updateModel(
+        css::uno::Reference<css::frame::XModel> xModel)
+{
+    css::uno::Reference<css::util::XModifyBroadcaster> xBroadcaster(mxModel, css::uno::UNO_QUERY_THROW);
+    xBroadcaster->removeModifyListener(mxListener);
+
+    mxModel = xModel;
+
+    css::uno::Reference<css::util::XModifyBroadcaster> xBroadcasterNew(mxModel, css::uno::UNO_QUERY_THROW);
+    xBroadcasterNew->addModifyListener(mxListener);
+}
+
 IMPL_LINK(ChartSeriesPanel, CheckBoxHdl, CheckBox*, pCheckBox)
 {
     bool bChecked = pCheckBox->IsChecked();
diff --git a/chart2/source/controller/sidebar/ChartSeriesPanel.hxx b/chart2/source/controller/sidebar/ChartSeriesPanel.hxx
index 7c951f6..10d73ee 100644
--- a/chart2/source/controller/sidebar/ChartSeriesPanel.hxx
+++ b/chart2/source/controller/sidebar/ChartSeriesPanel.hxx
@@ -21,6 +21,7 @@
 
 #include <sfx2/sidebar/ControllerItem.hxx>
 #include <sfx2/sidebar/IContextChangeReceiver.hxx>
+#include <sfx2/sidebar/SidebarModelUpdate.hxx>
 #include <svx/sidebar/PanelLayout.hxx>
 
 #include "ChartSidebarModifyListener.hxx"
@@ -40,6 +41,7 @@ namespace sidebar {
 class ChartSeriesPanel : public PanelLayout,
     public ::sfx2::sidebar::IContextChangeReceiver,
     public ::sfx2::sidebar::ControllerItem::ItemUpdateReceiverInterface,
+    public sfx2::sidebar::SidebarModelUpdate,
     public ChartSidebarModifyListenerParent
 {
 public:
@@ -71,6 +73,8 @@ public:
     virtual void updateData() SAL_OVERRIDE;
     virtual void modelInvalid() SAL_OVERRIDE;
 
+    virtual void updateModel(css::uno::Reference<css::frame::XModel> xModel) SAL_OVERRIDE;
+
 private:
     //ui controls
     VclPtr<CheckBox> mpCBLabel;
diff --git a/include/sfx2/sidebar/ResourceManager.hxx b/include/sfx2/sidebar/ResourceManager.hxx
index 568b7f8..8708707 100644
--- a/include/sfx2/sidebar/ResourceManager.hxx
+++ b/include/sfx2/sidebar/ResourceManager.hxx
@@ -66,6 +66,8 @@ public:
 
     void SetPanelOrderIndex(const OUString& rsPanelId, const sal_Int32 orderIndex);
 
+    void UpdateModel(css::uno::Reference<css::frame::XModel> xModel);
+
 
     class DeckContextDescriptor
     {
diff --git a/include/sfx2/sidebar/SidebarController.hxx b/include/sfx2/sidebar/SidebarController.hxx
index db0a9a1..00a53b3 100644
--- a/include/sfx2/sidebar/SidebarController.hxx
+++ b/include/sfx2/sidebar/SidebarController.hxx
@@ -156,6 +156,8 @@ public:
 
     void notifyDeckTitle(const OUString& targetDeckId);
 
+    void updateModel(css::uno::Reference<css::frame::XModel> xModel);
+
 private:
 
     VclPtr<Deck> mpCurrentDeck;
diff --git a/include/sfx2/sidebar/SidebarModelUpdate.hxx b/include/sfx2/sidebar/SidebarModelUpdate.hxx
new file mode 100644
index 0000000..981f7fa
--- /dev/null
+++ b/include/sfx2/sidebar/SidebarModelUpdate.hxx
@@ -0,0 +1,30 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef INCLUDED_INCLUDE_SFX2_SIDEBAR_SIDEBARUPDATEMODEL_HXX
+#define INCLUDED_INCLUDE_SFX2_SIDEBAR_SIDEBARUPDATEMODEL_HXX
+
+#include <com/sun/star/frame/XModel.hpp>
+
+#include <sfx2/dllapi.h>
+
+namespace sfx2 { namespace sidebar {
+
+class SFX2_DLLPUBLIC SidebarModelUpdate
+{
+public:
+    virtual ~SidebarModelUpdate();
+    virtual void updateModel(css::uno::Reference<css::frame::XModel> xModel) = 0;
+};
+
+} }
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/sfx2/sidebar/SidebarPanelBase.hxx b/include/sfx2/sidebar/SidebarPanelBase.hxx
index e08f3c3..75d155e 100644
--- a/include/sfx2/sidebar/SidebarPanelBase.hxx
+++ b/include/sfx2/sidebar/SidebarPanelBase.hxx
@@ -22,7 +22,7 @@
 #include <sfx2/sidebar/EnumContext.hxx>
 #include <sfx2/sidebar/IContextChangeReceiver.hxx>
 
-#include <cppuhelper/compbase4.hxx>
+#include <cppuhelper/compbase5.hxx>
 #include <cppuhelper/basemutex.hxx>
 
 #include <com/sun/star/frame/XController.hpp>
@@ -30,6 +30,7 @@
 #include <com/sun/star/ui/XUIElement.hpp>
 #include <com/sun/star/ui/XToolPanel.hpp>
 #include <com/sun/star/ui/XSidebarPanel.hpp>
+#include <com/sun/star/ui/XUpdateModel.hpp>
 
 #include <boost/noncopyable.hpp>
 #include <boost/function.hpp>
@@ -43,10 +44,11 @@ namespace sfx2 { namespace sidebar {
 namespace
 {
 
-typedef cppu::WeakComponentImplHelper4<css::ui::XContextChangeEventListener,
+typedef cppu::WeakComponentImplHelper5<css::ui::XContextChangeEventListener,
                                        css::ui::XUIElement,
                                        css::ui::XToolPanel,
-                                       css::ui::XSidebarPanel>
+                                       css::ui::XSidebarPanel,
+                                       css::ui::XUpdateModel>
             SidebarPanelBaseInterfaceBase;
 }
 
@@ -94,6 +96,10 @@ public:
     virtual sal_Int32 SAL_CALL getMinimalWidth()
         throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
 
+    // XUpdateModel
+    virtual void SAL_CALL updateModel(const css::uno::Reference<css::frame::XModel>& xModel)
+        throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
+
 protected:
     css::uno::Reference<css::frame::XFrame> mxFrame;
 
diff --git a/offapi/UnoApi_offapi.mk b/offapi/UnoApi_offapi.mk
index fd1b03a..0a915f4 100644
--- a/offapi/UnoApi_offapi.mk
+++ b/offapi/UnoApi_offapi.mk
@@ -4039,6 +4039,7 @@ $(eval $(call gb_UnoApi_add_idlfiles,offapi,com/sun/star/ui,\
     XUIElementFactoryManager \
 	XUIElementFactoryRegistration \
 	XUIElementSettings \
+	XUpdateModel \
 	XUIFunctionListener \
 ))
 $(eval $(call gb_UnoApi_add_idlfiles,offapi,com/sun/star/ui/dialogs,\
diff --git a/offapi/com/sun/star/ui/XUpdateModel.idl b/offapi/com/sun/star/ui/XUpdateModel.idl
new file mode 100644
index 0000000..59b1f68
--- /dev/null
+++ b/offapi/com/sun/star/ui/XUpdateModel.idl
@@ -0,0 +1,34 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef __com_sun_star_ui_XUpdateModel_idl__
+#define __com_sun_star_ui_XUpdateModel_idl__
+
+#include <com/sun/star/uno/XInterface.idl>
+#include <com/sun/star/frame/XModel.idl>
+
+
+module com { module sun { module star { module ui {
+
+
+/** Internal interface to update the used css::frame::XModel
+    </p>
+*/
+
+interface XUpdateModel : com::sun::star::uno::XInterface
+{
+    void updateModel( [in] com::sun::star::frame::XModel xModel);
+};
+
+}; }; }; };
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/Library_sfx.mk b/sfx2/Library_sfx.mk
index b56f7f5..faba426 100644
--- a/sfx2/Library_sfx.mk
+++ b/sfx2/Library_sfx.mk
@@ -251,6 +251,7 @@ $(eval $(call gb_Library_add_exception_objects,sfx,\
     sfx2/source/sidebar/SidebarChildWindow \
     sfx2/source/sidebar/SidebarDockingWindow \
     sfx2/source/sidebar/SidebarController \
+    sfx2/source/sidebar/SidebarModelUpdate \
     sfx2/source/sidebar/SidebarPanelBase \
     sfx2/source/sidebar/SidebarToolBox \
     sfx2/source/sidebar/Accessible \
diff --git a/sfx2/source/sidebar/ResourceManager.cxx b/sfx2/source/sidebar/ResourceManager.cxx
index bce5bbc..28f9e68 100644
--- a/sfx2/source/sidebar/ResourceManager.cxx
+++ b/sfx2/source/sidebar/ResourceManager.cxx
@@ -29,6 +29,7 @@
 #include <tools/diagnose_ex.h>
 
 #include <com/sun/star/frame/ModuleManager.hpp>
+#include <com/sun/star/ui/XUpdateModel.hpp>
 
 #include <map>
 
@@ -646,6 +647,24 @@ bool ResourceManager::IsDeckEnabled (
     return false;
 }
 
+void ResourceManager::UpdateModel(css::uno::Reference<css::frame::XModel> xModel)
+{
+    for (DeckContainer::iterator itr = maDecks.begin(); itr != maDecks.end(); ++itr) {
+        if (!itr->mpDeck)
+            continue;
+
+        const SharedPanelContainer& rContainer = itr->mpDeck->GetPanels();
+
+        for (SharedPanelContainer::const_iterator it = rContainer.begin(); it != rContainer.end(); ++it) {
+            css::uno::Reference<css::ui::XUpdateModel> xPanel((*it)->GetPanelComponent(), css::uno::UNO_QUERY);
+            xPanel->updateModel(xModel);
+        }
+
+    }
+
+
+}
+
 } } // end of namespace sfx2::sidebar
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/sidebar/SidebarController.cxx b/sfx2/source/sidebar/SidebarController.cxx
index 9bdd5e0..ed4cee0 100644
--- a/sfx2/source/sidebar/SidebarController.cxx
+++ b/sfx2/source/sidebar/SidebarController.cxx
@@ -1252,6 +1252,11 @@ ResourceManager::PanelContextDescriptorContainer SidebarController::GetMatchingP
     return aPanels;
 }
 
+void SidebarController::updateModel(css::uno::Reference<css::frame::XModel> xModel)
+{
+    mpResourceManager->UpdateModel(xModel);
+}
+
 
 } } // end of namespace sfx2::sidebar
 
diff --git a/sfx2/source/sidebar/SidebarModelUpdate.cxx b/sfx2/source/sidebar/SidebarModelUpdate.cxx
new file mode 100644
index 0000000..91c423b
--- /dev/null
+++ b/sfx2/source/sidebar/SidebarModelUpdate.cxx
@@ -0,0 +1,20 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <sfx2/sidebar/SidebarModelUpdate.hxx>
+
+namespace sfx2 { namespace sidebar {
+
+SidebarModelUpdate::~SidebarModelUpdate()
+{
+}
+
+} }
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/sidebar/SidebarPanelBase.cxx b/sfx2/source/sidebar/SidebarPanelBase.cxx
index a7ec830..c8d3992 100644
--- a/sfx2/source/sidebar/SidebarPanelBase.cxx
+++ b/sfx2/source/sidebar/SidebarPanelBase.cxx
@@ -20,6 +20,7 @@
 #include <sfx2/sidebar/Theme.hxx>
 #include <sfx2/sidebar/ILayoutableWindow.hxx>
 #include <sfx2/sidebar/IContextChangeReceiver.hxx>
+#include <sfx2/sidebar/SidebarModelUpdate.hxx>
 #include <sfx2/imagemgr.hxx>
 #include <vcl/ctrl.hxx>
 #include <vcl/layout.hxx>
@@ -203,6 +204,16 @@ sal_Int32 SAL_CALL SidebarPanelBase::getMinimalWidth () throw(css::uno::RuntimeE
     return 0;
 }
 
+void SAL_CALL SidebarPanelBase::updateModel(const css::uno::Reference<css::frame::XModel>& xModel)
+    throw(css::uno::RuntimeException, std::exception)
+{
+    SidebarModelUpdate* pModelUpdate = dynamic_cast<SidebarModelUpdate*>(mpControl.get());
+    if (!pModelUpdate)
+        return;
+
+    pModelUpdate->updateModel(xModel);
+}
+
 } } // end of namespace sfx2::sidebar
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit cfac266d061c4fe83bebe203519b746538e47157
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Thu Jul 23 00:44:48 2015 +0200

    implement a few more methods
    
    Change-Id: Ieab088f2ad48f313c913424c60a10b59de4e0bcb

diff --git a/chart2/source/controller/sidebar/ChartAreaPanel.cxx b/chart2/source/controller/sidebar/ChartAreaPanel.cxx
index 13c4a7c..945e505 100644
--- a/chart2/source/controller/sidebar/ChartAreaPanel.cxx
+++ b/chart2/source/controller/sidebar/ChartAreaPanel.cxx
@@ -11,6 +11,9 @@
 
 #include "ChartController.hxx"
 
+#include <svx/xfltrit.hxx>
+#include <svx/xflftrit.hxx>
+
 namespace chart { namespace sidebar {
 
 namespace {
@@ -83,14 +86,23 @@ void ChartAreaPanel::Initialize()
     xBroadcaster->addModifyListener(mxListener);
 }
 
-void ChartAreaPanel::setFillTransparence(const XFillTransparenceItem& /*rItem*/)
+void ChartAreaPanel::setFillTransparence(const XFillTransparenceItem& rItem)
 {
+    css::uno::Reference<css::beans::XPropertySet> xPropSet = getPropSet(mxModel);
+    if (!xPropSet.is())
+        return;
 
+    xPropSet->setPropertyValue("Transparency", css::uno::makeAny(rItem.GetValue()));
 }
 
-void ChartAreaPanel::setFillFloatTransparence(const XFillFloatTransparenceItem& /*rItem*/)
+void ChartAreaPanel::setFillFloatTransparence(
+        const XFillFloatTransparenceItem& rItem)
 {
+    css::uno::Reference<css::beans::XPropertySet> xPropSet = getPropSet(mxModel);
+    if (!xPropSet.is())
+        return;
 
+    xPropSet->setPropertyValue("TransparencyGradientName", css::uno::makeAny(rItem.GetValue()));
 }
 
 void ChartAreaPanel::setFillStyle(const XFillStyleItem& rItem)
commit 5ee0e6ab93ad791f5e79506efafd16cb7364ffb1
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Tue Jul 21 19:01:26 2015 +0200

    avoid crash with color listbox for now
    
    Change-Id: I36ac6513546961ec8d8d1e9437a8ef88574acbf4

diff --git a/svx/source/sidebar/area/AreaPropertyPanelBase.cxx b/svx/source/sidebar/area/AreaPropertyPanelBase.cxx
index bf48573..3b94efc 100644
--- a/svx/source/sidebar/area/AreaPropertyPanelBase.cxx
+++ b/svx/source/sidebar/area/AreaPropertyPanelBase.cxx
@@ -207,7 +207,7 @@ IMPL_LINK(AreaPropertyPanelBase, SelectFillTypeHdl, ListBox *, pToolBox)
                 mpLbFillAttr->Hide();
                 mpToolBoxColor->Show();
                 const OUString aTmpStr;
-                const Color aColor = mpColorItem->GetColorValue();
+                const Color aColor = mpColorItem ? mpColorItem->GetColorValue() : COL_AUTO;
                 const XFillColorItem aXFillColorItem( aTmpStr, aColor );
 
                 // #i122676# change FillStyle and Color in one call
commit c36df7c0844be4831380d90d68489100da3f0a30
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Tue Jul 21 19:01:06 2015 +0200

    avoid a crash that occures sometimes
    
    Change-Id: Iccbdfdb8a46b45b76756ff8080757db3770d691c

diff --git a/chart2/source/controller/sidebar/ChartAreaPanel.cxx b/chart2/source/controller/sidebar/ChartAreaPanel.cxx
index 89eb74b..13c4a7c 100644
--- a/chart2/source/controller/sidebar/ChartAreaPanel.cxx
+++ b/chart2/source/controller/sidebar/ChartAreaPanel.cxx
@@ -23,7 +23,9 @@ OUString getCID(css::uno::Reference<css::frame::XModel> xModel)
         return OUString();
 
     css::uno::Any aAny = xSelectionSupplier->getSelection();
-    assert(aAny.hasValue());
+    if (!aAny.hasValue())
+        return OUString();
+
     OUString aCID;
     aAny >>= aCID;
 
@@ -94,6 +96,9 @@ void ChartAreaPanel::setFillFloatTransparence(const XFillFloatTransparenceItem&
 void ChartAreaPanel::setFillStyle(const XFillStyleItem& rItem)
 {
     css::uno::Reference<css::beans::XPropertySet> xPropSet = getPropSet(mxModel);
+    if (!xPropSet.is())
+        return;
+
     xPropSet->setPropertyValue("FillStyle", css::uno::makeAny(rItem.GetValue()));
 }
 
@@ -101,6 +106,9 @@ void ChartAreaPanel::setFillStyleAndColor(const XFillStyleItem* pStyleItem,
         const XFillColorItem& rColorItem)
 {
     css::uno::Reference<css::beans::XPropertySet> xPropSet = getPropSet(mxModel);
+    if (!xPropSet.is())
+        return;
+
     if (pStyleItem)
         xPropSet->setPropertyValue("FillStyle", css::uno::makeAny(pStyleItem->GetValue()));
     xPropSet->setPropertyValue("Color", css::uno::makeAny(rColorItem.GetValue()));
@@ -110,6 +118,9 @@ void ChartAreaPanel::setFillStyleAndGradient(const XFillStyleItem* pStyleItem,
         const XFillGradientItem& rGradientItem)
 {
     css::uno::Reference<css::beans::XPropertySet> xPropSet = getPropSet(mxModel);
+    if (!xPropSet.is())
+        return;
+
     if (pStyleItem)
         xPropSet->setPropertyValue("FillStyle", css::uno::makeAny(pStyleItem->GetValue()));
     xPropSet->setPropertyValue("GradientName", css::uno::makeAny(rGradientItem.GetValue()));
@@ -119,6 +130,9 @@ void ChartAreaPanel::setFillStyleAndHatch(const XFillStyleItem* pStyleItem,
         const XFillHatchItem& rHatchItem)
 {
     css::uno::Reference<css::beans::XPropertySet> xPropSet = getPropSet(mxModel);
+    if (!xPropSet.is())
+        return;
+
     if (pStyleItem)
         xPropSet->setPropertyValue("FillStyle", css::uno::makeAny(pStyleItem->GetValue()));
     xPropSet->setPropertyValue("HatchName", css::uno::makeAny(rHatchItem.GetValue()));
@@ -128,6 +142,9 @@ void ChartAreaPanel::setFillStyleAndBitmap(const XFillStyleItem* pStyleItem,
         const XFillBitmapItem& rBitmapItem)
 {
     css::uno::Reference<css::beans::XPropertySet> xPropSet = getPropSet(mxModel);
+    if (!xPropSet.is())
+        return;
+
     if (pStyleItem)
         xPropSet->setPropertyValue("FillStyle", css::uno::makeAny(pStyleItem->GetValue()));
     xPropSet->setPropertyValue("FillBitmapName", css::uno::makeAny(rBitmapItem.GetValue()));
commit 0066d74fe51444cf459d1218b3de3d4a7502faeb
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Tue Jul 21 19:00:37 2015 +0200

    dispose all children
    
    Change-Id: I96501640bc15836476eaa6ff7784ab299277ced9

diff --git a/chart2/source/controller/sidebar/ChartAreaPanel.cxx b/chart2/source/controller/sidebar/ChartAreaPanel.cxx
index 3319bf5..89eb74b 100644
--- a/chart2/source/controller/sidebar/ChartAreaPanel.cxx
+++ b/chart2/source/controller/sidebar/ChartAreaPanel.cxx
@@ -71,6 +71,8 @@ void ChartAreaPanel::dispose()
 {
     css::uno::Reference<css::util::XModifyBroadcaster> xBroadcaster(mxModel, css::uno::UNO_QUERY_THROW);
     xBroadcaster->removeModifyListener(mxListener);
+
+    AreaPropertyPanelBase::dispose();
 }
 
 void ChartAreaPanel::Initialize()
commit c6ac33db57df1a7e8b2faf45c0bc23d86503a813
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Tue Jul 21 18:11:08 2015 +0200

    extract some code for reuse by chart2 sidebar
    
    Change-Id: I44e2378dafa66f53588027cca56dc52cb4cec794

diff --git a/include/svx/sidebar/AreaPropertyPanelBase.hxx b/include/svx/sidebar/AreaPropertyPanelBase.hxx
index 45bda7d..3f7d574 100644
--- a/include/svx/sidebar/AreaPropertyPanelBase.hxx
+++ b/include/svx/sidebar/AreaPropertyPanelBase.hxx
@@ -97,6 +97,14 @@ public:
     virtual void setFillStyleAndHatch(const XFillStyleItem* pStyleItem, const XFillHatchItem& aHatchItem) = 0;
     virtual void setFillStyleAndBitmap(const XFillStyleItem* pStyleItem, const XFillBitmapItem& aHatchItem) = 0;
 
+    void updateFillTransparence(bool bDisabled, bool bDefault, const SfxUInt16Item* pItem);
+    void updateFillFloatTransparence(bool bDisabled, bool bDefault, const XFillFloatTransparenceItem* pItem);
+    void updateFillStyle(bool bDisabled, bool bDefault, const XFillStyleItem* pItem);
+    void updateFillGradient(bool bDisabled, bool bDefault, const XFillGradientItem* pItem);
+    void updateFillHatch(bool bDisabled, bool bDefault, const XFillHatchItem* pItem);
+    void updateFillColor(bool bDefault, const XFillColorItem* pItem);
+    void updateFillBitmap(bool BDisabled, bool bDefault, const XFillBitmapItem* pItem);
+
 protected:
     sal_uInt16                                          meLastXFS;
 
diff --git a/svx/source/sidebar/area/AreaPropertyPanelBase.cxx b/svx/source/sidebar/area/AreaPropertyPanelBase.cxx
index 890abe3..bf48573 100644
--- a/svx/source/sidebar/area/AreaPropertyPanelBase.cxx
+++ b/svx/source/sidebar/area/AreaPropertyPanelBase.cxx
@@ -592,226 +592,248 @@ void AreaPropertyPanelBase::ImpUpdateTransparencies()
     }
 }
 
-void AreaPropertyPanelBase::NotifyItemUpdate(
-    sal_uInt16 nSID,
-    SfxItemState eState,
-    const SfxPoolItem* pState,
-    const bool /*bIsEnabled*/)
+void AreaPropertyPanelBase::updateFillTransparence(bool bDisabled, bool bDefault, const SfxUInt16Item* pItem)
 {
-    const bool bDisabled(SfxItemState::DISABLED == eState);
+    if (bDisabled)
+    {
+        mpTransparanceItem.reset();
+        return;
+    }
+    else if(bDefault)
+    {
+        if(pItem && (!mpTransparanceItem || *pItem != *mpTransparanceItem))
+        {
+            mpTransparanceItem.reset(static_cast<SfxUInt16Item*>(pItem->Clone()));
+        }
+        else
+        {
+            mpTransparanceItem.reset();
+        }
+    }
+    else
+    {
+        mpTransparanceItem.reset();
+    }
 
-    switch(nSID)
+    // update transparency settings dependent of mpTransparanceItem and mpFloatTransparenceItem
+    ImpUpdateTransparencies();
+}
+
+void AreaPropertyPanelBase::updateFillFloatTransparence(bool bDisabled, bool bDefault, const XFillFloatTransparenceItem* pItem)
+{
+    if (bDisabled)
     {
-        case SID_ATTR_FILL_TRANSPARENCE:
-        case SID_ATTR_FILL_FLOATTRANSPARENCE:
+        mpFloatTransparenceItem.reset();
+        return;
+    }
+
+    if(bDefault)
+    {
+        if(pItem && (!mpFloatTransparenceItem || *pItem != *mpFloatTransparenceItem))
+        {
+            mpFloatTransparenceItem.reset(static_cast<XFillFloatTransparenceItem*>(pItem->Clone()));
+        }
+        else
         {
-            bool bFillTransparenceChanged(false);
+            mpFloatTransparenceItem.reset();
+        }
+    }
+    else
+    {
+        mpFloatTransparenceItem.reset();
+    }
 
-            if(SID_ATTR_FILL_TRANSPARENCE == nSID)
-            {
-                bFillTransparenceChanged = true;
+    // update transparency settings dependent of mpTransparanceItem and mpFloatTransparenceItem
+    ImpUpdateTransparencies();
+}
 
-                if(eState >= SfxItemState::DEFAULT)
-                {
-                    const SfxUInt16Item* pItem = dynamic_cast< const SfxUInt16Item* >(pState);
+void AreaPropertyPanelBase::updateFillStyle(bool bDisabled, bool bDefault, const XFillStyleItem* pItem)
+{
+    if(bDisabled)
+    {
+        mpLbFillType->Disable();
+        mpColorTextFT->Disable();
+        mpLbFillType->SetNoSelection();
+        mpLbFillAttr->Show();
+        mpLbFillAttr->Disable();
+        mpLbFillAttr->SetNoSelection();
+        mpToolBoxColor->Hide();
+        meLastXFS = static_cast<sal_uInt16>(-1);
+        mpStyleItem.reset();
+    }
+    else if(bDefault && pItem)
+    {
+        mpStyleItem.reset(dynamic_cast< XFillStyleItem* >(pItem->Clone()));
+        mpLbFillType->Enable();
+        mpColorTextFT->Enable();
+        drawing::FillStyle eXFS = (drawing::FillStyle)mpStyleItem->GetValue();
+        meLastXFS = eXFS;
+        mpLbFillType->SelectEntryPos(sal::static_int_cast< sal_Int32 >(eXFS));
+
+        if(drawing::FillStyle_NONE == eXFS)
+        {
+            mpLbFillAttr->SetNoSelection();
+            mpLbFillAttr->Disable();
+        }
 
-                    if(pItem && (!mpTransparanceItem || *pItem != *mpTransparanceItem))
-                    {
-                        mpTransparanceItem.reset(static_cast<SfxUInt16Item*>(pItem->Clone()));
-                    }
-                    else
-                    {
-                        mpTransparanceItem.reset();
-                    }
-                }
-                else
-                {
-                    mpTransparanceItem.reset();
-                }
-            }
-            else // if(SID_ATTR_FILL_FLOATTRANSPARENCE == nSID)
-            {
-                bFillTransparenceChanged = true;
+        Update();
+        return;
+    }
 
-                if(eState >= SfxItemState::DEFAULT)
-                {
-                    const XFillFloatTransparenceItem* pItem = dynamic_cast< const XFillFloatTransparenceItem* >(pState);
+    mpLbFillType->SetNoSelection();
+    mpLbFillAttr->Show();
+    mpLbFillAttr->Disable();
+    mpLbFillAttr->SetNoSelection();
+    mpToolBoxColor->Hide();
+    meLastXFS = static_cast<sal_uInt16>(-1);
+    mpStyleItem.reset();
+}
 
-                    if(pItem && (!mpFloatTransparenceItem || *pItem != *mpFloatTransparenceItem))
-                    {
-                        mpFloatTransparenceItem.reset(static_cast<XFillFloatTransparenceItem*>(pItem->Clone()));
-                    }
-                    else
-                    {
-                        mpFloatTransparenceItem.reset();
-                    }
-                }
-                else
-                {
-                    mpFloatTransparenceItem.reset();
-                }
-            }
+void AreaPropertyPanelBase::updateFillGradient(bool bDisabled, bool bDefault, const XFillGradientItem* pItem)
+{
+    if(bDefault)
+    {
+        mpFillGradientItem.reset(pItem ? static_cast<XFillGradientItem*>(pItem->Clone()) : 0);
+    }
 
-            if(bFillTransparenceChanged)
-            {
-                // update transparency settings dependent of mpTransparanceItem and mpFloatTransparenceItem
-                ImpUpdateTransparencies();
-            }
-            break;
+    if(mpStyleItem && drawing::FillStyle_GRADIENT == (drawing::FillStyle)mpStyleItem->GetValue())
+    {
+        mpLbFillAttr->Show();
+        mpToolBoxColor->Hide();
+
+        if(bDefault)
+        {
+            mpLbFillAttr->Enable();
+            Update();
         }
-        case SID_ATTR_FILL_STYLE:
+        else if(bDisabled)
         {
-            if(bDisabled)
-            {
-                mpLbFillType->Disable();
-                mpColorTextFT->Disable();
-                mpLbFillType->SetNoSelection();
-                mpLbFillAttr->Show();
-                mpLbFillAttr->Disable();
-                mpLbFillAttr->SetNoSelection();
-                mpToolBoxColor->Hide();
-                meLastXFS = static_cast<sal_uInt16>(-1);
-                mpStyleItem.reset();
-            }
-            else if(eState >= SfxItemState::DEFAULT)
-            {
-                const XFillStyleItem* pItem = dynamic_cast< const XFillStyleItem* >(pState);
+            mpLbFillAttr->Disable();
+            mpLbFillAttr->SetNoSelection();
+        }
+        else
+        {
+            mpLbFillAttr->SetNoSelection();
+        }
+    }
+}
 
-                if(pItem)
-                {
-                    mpStyleItem.reset(dynamic_cast< XFillStyleItem* >(pItem->Clone()));
-                    mpLbFillType->Enable();
-                    mpColorTextFT->Enable();
-                    drawing::FillStyle eXFS = (drawing::FillStyle)mpStyleItem->GetValue();
-                    meLastXFS = eXFS;
-                    mpLbFillType->SelectEntryPos(sal::static_int_cast< sal_Int32 >(eXFS));
-
-                    if(drawing::FillStyle_NONE == eXFS)
-                    {
-                        mpLbFillAttr->SetNoSelection();
-                        mpLbFillAttr->Disable();
-                    }
+void AreaPropertyPanelBase::updateFillHatch(bool bDisabled, bool bDefault, const XFillHatchItem* pItem)
+{
+    if(bDefault)
+    {
+        mpHatchItem.reset(pItem ? static_cast<XFillHatchItem*>(pItem->Clone()) : 0);
+    }
 
-                    Update();
-                    break;
-                }
-            }
+    if(mpStyleItem && drawing::FillStyle_HATCH == (drawing::FillStyle)mpStyleItem->GetValue())
+    {
+        mpLbFillAttr->Show();
+        mpToolBoxColor->Hide();
 
-            mpLbFillType->SetNoSelection();
-            mpLbFillAttr->Show();
+        if(bDefault)
+        {
+            mpLbFillAttr->Enable();
+            Update();
+        }
+        else if(bDisabled)
+        {
             mpLbFillAttr->Disable();
             mpLbFillAttr->SetNoSelection();
-            mpToolBoxColor->Hide();
-            meLastXFS = static_cast<sal_uInt16>(-1);
-            mpStyleItem.reset();
-            break;
         }
-        case SID_ATTR_FILL_COLOR:
+        else
         {
-            if(SfxItemState::DEFAULT == eState)
-            {
-                mpColorItem.reset(pState ? static_cast<XFillColorItem*>(pState->Clone()) : 0);
-            }
+            mpLbFillAttr->SetNoSelection();
+        }
+    }
+}
 
-            if(mpStyleItem && drawing::FillStyle_SOLID == (drawing::FillStyle)mpStyleItem->GetValue())
-            {
-                mpLbFillAttr->Hide();
-                mpToolBoxColor->Show();
+void AreaPropertyPanelBase::updateFillColor(bool bDefault, const XFillColorItem* pItem)
+{
+    if(bDefault)
+    {
+        mpColorItem.reset(pItem ? static_cast<XFillColorItem*>(pItem->Clone()) : 0);
+    }
 
-                Update();
-            }
-            break;
-        }
-        case SID_ATTR_FILL_GRADIENT:
-        {
-            if(SfxItemState::DEFAULT == eState)
-            {
-                mpFillGradientItem.reset(pState ? static_cast<XFillGradientItem*>(pState->Clone()) : 0);
-            }
+    if(mpStyleItem && drawing::FillStyle_SOLID == (drawing::FillStyle)mpStyleItem->GetValue())
+    {
+        mpLbFillAttr->Hide();
+        mpToolBoxColor->Show();
 
-            if(mpStyleItem && drawing::FillStyle_GRADIENT == (drawing::FillStyle)mpStyleItem->GetValue())
-            {
-                mpLbFillAttr->Show();
-                mpToolBoxColor->Hide();
+        Update();
+    }
+}
 
-                if(SfxItemState::DEFAULT == eState)
-                {
-                    mpLbFillAttr->Enable();
-                    Update();
-                }
-                else if(SfxItemState::DISABLED == eState )
-                {
-                    mpLbFillAttr->Disable();
-                    mpLbFillAttr->SetNoSelection();
-                }
-                else
-                {
-                    mpLbFillAttr->SetNoSelection();
-                }
-            }
-            break;
-        }
-        case SID_ATTR_FILL_HATCH:
-        {
-            if(SfxItemState::DEFAULT == eState)
-            {
-                mpHatchItem.reset(pState ? static_cast<XFillHatchItem*>(pState->Clone()) : 0);
-            }
+void AreaPropertyPanelBase::updateFillBitmap(bool bDisabled, bool bDefault, const XFillBitmapItem* pItem)
+{
+    if(bDefault)
+    {
+        mpBitmapItem.reset(pItem ? static_cast<XFillBitmapItem*>(pItem->Clone()) : 0);
+    }
 
-            if(mpStyleItem && drawing::FillStyle_HATCH == (drawing::FillStyle)mpStyleItem->GetValue())
-            {
-                mpLbFillAttr->Show();
-                mpToolBoxColor->Hide();
+    if(mpStyleItem && drawing::FillStyle_BITMAP == (drawing::FillStyle)mpStyleItem->GetValue())
+    {
+        mpLbFillAttr->Show();
+        mpToolBoxColor->Hide();
 
-                if(SfxItemState::DEFAULT == eState)
-                {
-                    mpLbFillAttr->Enable();
-                    Update();
-                }
-                else if(SfxItemState::DISABLED == eState )
-                {
-                    mpLbFillAttr->Disable();
-                    mpLbFillAttr->SetNoSelection();
-                }
-                else
-                {
-                    mpLbFillAttr->SetNoSelection();
-                }
-            }
-            break;
+        if(bDefault)
+        {
+            mpLbFillAttr->Enable();
+            Update();
         }
-        case SID_ATTR_FILL_BITMAP:
+        else if(bDisabled)
         {
-            if(SfxItemState::DEFAULT == eState)
-            {
-                mpBitmapItem.reset(pState ? static_cast<XFillBitmapItem*>(pState->Clone()) : 0);
-            }
+            mpLbFillAttr->Disable();
+            mpLbFillAttr->SetNoSelection();
+        }
+        else
+        {
+            mpLbFillAttr->SetNoSelection();
+        }
+    }
+}
 
-            if(mpStyleItem && drawing::FillStyle_BITMAP == (drawing::FillStyle)mpStyleItem->GetValue())
-            {
-                mpLbFillAttr->Show();
-                mpToolBoxColor->Hide();
+void AreaPropertyPanelBase::NotifyItemUpdate(
+    sal_uInt16 nSID,
+    SfxItemState eState,
+    const SfxPoolItem* pState,
+    const bool /*bIsEnabled*/)
+{
+    const bool bDisabled(SfxItemState::DISABLED == eState);
+    const bool bDefault(SfxItemState::DEFAULT == eState);
 
-                if(SfxItemState::DEFAULT == eState)
-                {
-                    mpLbFillAttr->Enable();
-                    Update();
-                }
-                else if(SfxItemState::DISABLED == eState )
-                {
-                    mpLbFillAttr->Disable();
-                    mpLbFillAttr->SetNoSelection();
-                }
-                else
-                {
-                    mpLbFillAttr->SetNoSelection();
-                }
-            }
-            break;
-        }
+    switch(nSID)
+    {
+        case SID_ATTR_FILL_TRANSPARENCE:
+            updateFillTransparence(bDisabled, bDefault,
+                    static_cast<const SfxUInt16Item*>(pState));
+        break;
+        case SID_ATTR_FILL_FLOATTRANSPARENCE:
+            updateFillFloatTransparence(bDisabled, bDefault,
+                    static_cast<const XFillFloatTransparenceItem*>(pState));
+        break;
+        case SID_ATTR_FILL_STYLE:
+            updateFillStyle(bDisabled, bDefault,
+                    static_cast<const XFillStyleItem*>(pState));
+        break;
+        case SID_ATTR_FILL_COLOR:
+            updateFillColor(bDefault,
+                    static_cast<const XFillColorItem*>(pState));
+        break;
+        case SID_ATTR_FILL_GRADIENT:
+            updateFillGradient(bDisabled, bDefault,
+                    static_cast<const XFillGradientItem*>(pState));
+        break;
+        case SID_ATTR_FILL_HATCH:
+            updateFillHatch(bDisabled, bDefault,
+                    static_cast<const XFillHatchItem*>(pState));
+        break;
+        case SID_ATTR_FILL_BITMAP:
+            updateFillBitmap(bDisabled, bDefault,
+                    static_cast<const XFillBitmapItem*>(pState));
+        break;
         case SID_GRADIENT_LIST:
         {
-            if(SfxItemState::DEFAULT == eState)
+            if(bDefault)
             {
                 if(mpStyleItem && drawing::FillStyle_GRADIENT == (drawing::FillStyle)mpStyleItem->GetValue())
                 {
@@ -836,7 +858,7 @@ void AreaPropertyPanelBase::NotifyItemUpdate(
         }
         case SID_HATCH_LIST:
         {
-            if(SfxItemState::DEFAULT == eState)
+            if(bDefault)
             {
                 if(mpStyleItem && drawing::FillStyle_HATCH == (drawing::FillStyle)mpStyleItem->GetValue())
                 {
@@ -861,7 +883,7 @@ void AreaPropertyPanelBase::NotifyItemUpdate(
         }
         case SID_BITMAP_LIST:
         {
-            if(SfxItemState::DEFAULT == eState)
+            if(bDefault)
             {
                 if(mpStyleItem && drawing::FillStyle_BITMAP == (drawing::FillStyle)mpStyleItem->GetValue())
                 {
commit ab0c81c09798ae5d028a87dfcf249953f1b42f8e
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Tue Jul 21 15:03:48 2015 +0200

    handle some of the property changes correctly in area panel
    
    Change-Id: I107245f52504c6dc059554346e00402534cf6243

diff --git a/chart2/source/controller/sidebar/ChartAreaPanel.cxx b/chart2/source/controller/sidebar/ChartAreaPanel.cxx
index a4241c9..3319bf5 100644
--- a/chart2/source/controller/sidebar/ChartAreaPanel.cxx
+++ b/chart2/source/controller/sidebar/ChartAreaPanel.cxx
@@ -13,6 +13,32 @@
 
 namespace chart { namespace sidebar {
 
+namespace {
+
+OUString getCID(css::uno::Reference<css::frame::XModel> xModel)
+{
+    css::uno::Reference<css::frame::XController> xController(xModel->getCurrentController());
+    css::uno::Reference<css::view::XSelectionSupplier> xSelectionSupplier(xController, css::uno::UNO_QUERY);
+    if (!xSelectionSupplier.is())
+        return OUString();
+
+    css::uno::Any aAny = xSelectionSupplier->getSelection();
+    assert(aAny.hasValue());
+    OUString aCID;
+    aAny >>= aCID;
+
+    return aCID;
+}
+
+css::uno::Reference<css::beans::XPropertySet> getPropSet(
+        css::uno::Reference<css::frame::XModel> xModel)
+{
+    OUString aCID = getCID(xModel);
+    return ObjectIdentifier::getObjectPropertySet(aCID, xModel);
+}
+
+}
+
 VclPtr<vcl::Window> ChartAreaPanel::Create(
         vcl::Window* pParent,
         const css::uno::Reference<css::frame::XFrame>& rxFrame,
@@ -29,8 +55,10 @@ VclPtr<vcl::Window> ChartAreaPanel::Create(
 
 ChartAreaPanel::ChartAreaPanel(vcl::Window* pParent,
         const css::uno::Reference<css::frame::XFrame>& rxFrame,
-        ChartController* /*pController*/):
-    svx::sidebar::AreaPropertyPanelBase(pParent, rxFrame)
+        ChartController* pController):
+    svx::sidebar::AreaPropertyPanelBase(pParent, rxFrame),
+    mxModel(pController->getModel()),
+    mxListener(new ChartSidebarModifyListener(this))
 {
 }
 
@@ -39,43 +67,76 @@ ChartAreaPanel::~ChartAreaPanel()
     disposeOnce();
 }
 
-void ChartAreaPanel::setFillTransparence(const XFillTransparenceItem& /*rItem*/)
+void ChartAreaPanel::dispose()
 {
+    css::uno::Reference<css::util::XModifyBroadcaster> xBroadcaster(mxModel, css::uno::UNO_QUERY_THROW);
+    xBroadcaster->removeModifyListener(mxListener);
+}
 
+void ChartAreaPanel::Initialize()
+{
+    css::uno::Reference<css::util::XModifyBroadcaster> xBroadcaster(mxModel, css::uno::UNO_QUERY_THROW);
+    xBroadcaster->addModifyListener(mxListener);
 }
 
-void ChartAreaPanel::setFillFloatTransparence(const XFillFloatTransparenceItem& /*rItem*/)
+void ChartAreaPanel::setFillTransparence(const XFillTransparenceItem& /*rItem*/)
 {
 
 }
 
-void ChartAreaPanel::setFillStyle(const XFillStyleItem& /*rItem*/)
+void ChartAreaPanel::setFillFloatTransparence(const XFillFloatTransparenceItem& /*rItem*/)
 {
 
 }
 
-void ChartAreaPanel::setFillStyleAndColor(const XFillStyleItem* /*pStyleItem*/,
-        const XFillColorItem& /*rColorItem*/)
+void ChartAreaPanel::setFillStyle(const XFillStyleItem& rItem)
 {
-
+    css::uno::Reference<css::beans::XPropertySet> xPropSet = getPropSet(mxModel);
+    xPropSet->setPropertyValue("FillStyle", css::uno::makeAny(rItem.GetValue()));
 }
 
-void ChartAreaPanel::setFillStyleAndGradient(const XFillStyleItem* /*pStyleItem*/,
-        const XFillGradientItem& /*rGradientItem*/)
+void ChartAreaPanel::setFillStyleAndColor(const XFillStyleItem* pStyleItem,
+        const XFillColorItem& rColorItem)
 {
+    css::uno::Reference<css::beans::XPropertySet> xPropSet = getPropSet(mxModel);
+    if (pStyleItem)
+        xPropSet->setPropertyValue("FillStyle", css::uno::makeAny(pStyleItem->GetValue()));
+    xPropSet->setPropertyValue("Color", css::uno::makeAny(rColorItem.GetValue()));
+}
 
+void ChartAreaPanel::setFillStyleAndGradient(const XFillStyleItem* pStyleItem,
+        const XFillGradientItem& rGradientItem)
+{
+    css::uno::Reference<css::beans::XPropertySet> xPropSet = getPropSet(mxModel);
+    if (pStyleItem)
+        xPropSet->setPropertyValue("FillStyle", css::uno::makeAny(pStyleItem->GetValue()));
+    xPropSet->setPropertyValue("GradientName", css::uno::makeAny(rGradientItem.GetValue()));
 }
 
-void ChartAreaPanel::setFillStyleAndHatch(const XFillStyleItem* /*pStyleItem*/,
-        const XFillHatchItem& /*rHatchItem*/)
+void ChartAreaPanel::setFillStyleAndHatch(const XFillStyleItem* pStyleItem,
+        const XFillHatchItem& rHatchItem)
 {
+    css::uno::Reference<css::beans::XPropertySet> xPropSet = getPropSet(mxModel);
+    if (pStyleItem)
+        xPropSet->setPropertyValue("FillStyle", css::uno::makeAny(pStyleItem->GetValue()));
+    xPropSet->setPropertyValue("HatchName", css::uno::makeAny(rHatchItem.GetValue()));
+}
 
+void ChartAreaPanel::setFillStyleAndBitmap(const XFillStyleItem* pStyleItem,
+        const XFillBitmapItem& rBitmapItem)
+{
+    css::uno::Reference<css::beans::XPropertySet> xPropSet = getPropSet(mxModel);
+    if (pStyleItem)
+        xPropSet->setPropertyValue("FillStyle", css::uno::makeAny(pStyleItem->GetValue()));
+    xPropSet->setPropertyValue("FillBitmapName", css::uno::makeAny(rBitmapItem.GetValue()));
 }
 
-void ChartAreaPanel::setFillStyleAndBitmap(const XFillStyleItem* /*pStyleItem*/,
-        const XFillBitmapItem& /*rBitmapItem*/)
+void ChartAreaPanel::updateData()
 {
+}
 
+void ChartAreaPanel::modelInvalid()
+{
 }
 
 
diff --git a/chart2/source/controller/sidebar/ChartAreaPanel.hxx b/chart2/source/controller/sidebar/ChartAreaPanel.hxx
index 4f4ac8b..f5b45ae 100644
--- a/chart2/source/controller/sidebar/ChartAreaPanel.hxx
+++ b/chart2/source/controller/sidebar/ChartAreaPanel.hxx
@@ -27,6 +27,8 @@
 
 #include <svx/sidebar/AreaPropertyPanelBase.hxx>
 
+#include "ChartSidebarModifyListener.hxx"
+
 class XFillFloatTransparenceItem;
 class XFillTransparenceItem;
 class XFillStyleItem;
@@ -41,7 +43,8 @@ class ChartController;
 
 namespace sidebar {
 
-class ChartAreaPanel : public svx::sidebar::AreaPropertyPanelBase
+class ChartAreaPanel : public svx::sidebar::AreaPropertyPanelBase,
+    public ChartSidebarModifyListenerParent
 {
 public:
     static VclPtr<vcl::Window> Create(
@@ -65,8 +68,19 @@ public:
     virtual void setFillStyleAndHatch(const XFillStyleItem* pStyleItem, const XFillHatchItem& rHatchItem);
     virtual void setFillStyleAndBitmap(const XFillStyleItem* pStyleItem, const XFillBitmapItem& rBitmapItem);
 
+    virtual void updateData() SAL_OVERRIDE;
+
+    virtual void modelInvalid() SAL_OVERRIDE;
+
+    virtual void dispose() SAL_OVERRIDE;
+
 private:
 
+    css::uno::Reference<css::frame::XModel> mxModel;
+    css::uno::Reference<css::util::XModifyListener> mxListener;
+
+    void Initialize();
+
 };
 
 } } // end of namespace svx::sidebar
commit 3d32e9f81b263884ec0a3b262e71ae78fcb892b7
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Tue Jul 21 15:01:57 2015 +0200

    provide some common fill property name aliases
    
    They are mapped to the same entry as the exisiting ones but make it much
    easier to select the correct property name.
    
    Change-Id: I6f334284825c809f50a35c4566889b01950734ce

diff --git a/chart2/source/tools/FillProperties.cxx b/chart2/source/tools/FillProperties.cxx
index 5316984..123275f 100644
--- a/chart2/source/tools/FillProperties.cxx
+++ b/chart2/source/tools/FillProperties.cxx
@@ -44,6 +44,14 @@ void lcl_AddPropertiesToVector_without_BitmapProperties( ::std::vector< ::com::s
                   | beans::PropertyAttribute::MAYBEDEFAULT ));
 

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list