[Libreoffice-commits] core.git: Branch 'feature/chart-sidebar' - 2 commits - chart2/source officecfg/registry

Markus Mohrhard markus.mohrhard at googlemail.com
Sat Jul 25 13:27:48 PDT 2015


 chart2/source/controller/sidebar/ChartAreaPanel.cxx                |   10 +++-
 chart2/source/controller/sidebar/ChartAreaPanel.hxx                |    2 
 chart2/source/controller/sidebar/ChartSidebarSelectionListener.cxx |   22 +++++-----
 chart2/source/controller/sidebar/ChartSidebarSelectionListener.hxx |    7 ++-
 officecfg/registry/data/org/openoffice/Office/UI/Sidebar.xcu       |    3 -
 5 files changed, 26 insertions(+), 18 deletions(-)

New commits:
commit 259a00681a5032d2a9d74c17e82d6c7e82c1d90c
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 c407ccdaa52fd1ec92bdd3c3c877ca0b363baf25
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)


More information about the Libreoffice-commits mailing list