summaryrefslogtreecommitdiff
path: root/chart2
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2015-07-25 22:25:10 +0200
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2015-07-26 00:27:03 +0200
commit9ba833f0148522e14a2c639017afd90749816380 (patch)
tree9c0c9e7defafed7d7a10aa14645b9988277c3ab5 /chart2
parent87f750f1c574142958331643e7b0a9fb0b182102 (diff)
don't show the area sidebar for panels where it makes no sense
Change-Id: I06655e0574b28a88db920424fa515b8350133f10
Diffstat (limited to 'chart2')
-rw-r--r--chart2/source/controller/sidebar/ChartAreaPanel.cxx8
-rw-r--r--chart2/source/controller/sidebar/ChartAreaPanel.hxx2
-rw-r--r--chart2/source/controller/sidebar/ChartSidebarSelectionListener.cxx22
-rw-r--r--chart2/source/controller/sidebar/ChartSidebarSelectionListener.hxx7
4 files changed, 22 insertions, 17 deletions
diff --git a/chart2/source/controller/sidebar/ChartAreaPanel.cxx b/chart2/source/controller/sidebar/ChartAreaPanel.cxx
index 267387fce0e4..f19f6903ed07 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 827f1c9d37ac..ccd9acc47d63 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 1f435e1e7d4b..7f1347955e09 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 cfe90e784e4d..3c31644e4872 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;
};
} }