Kaydet (Commit) 9ba833f0 authored tarafından Markus Mohrhard's avatar Markus Mohrhard

don't show the area sidebar for panels where it makes no sense

Change-Id: I06655e0574b28a88db920424fa515b8350133f10
üst 87f750f1
...@@ -212,6 +212,8 @@ ChartAreaPanel::ChartAreaPanel(vcl::Window* pParent, ...@@ -212,6 +212,8 @@ ChartAreaPanel::ChartAreaPanel(vcl::Window* pParent,
mxSelectionListener(new ChartSidebarSelectionListener(this)), mxSelectionListener(new ChartSidebarSelectionListener(this)),
mbUpdate(true) mbUpdate(true)
{ {
std::vector<ObjectType> aAcceptedTypes { OBJECTTYPE_PAGE, OBJECTTYPE_DIAGRAM, OBJECTTYPE_DATA_SERIES, OBJECTTYPE_TITLE, OBJECTTYPE_LEGEND};
mxSelectionListener->setAcceptedTypes(aAcceptedTypes);
Initialize(); Initialize();
} }
...@@ -227,7 +229,7 @@ void ChartAreaPanel::dispose() ...@@ -227,7 +229,7 @@ void ChartAreaPanel::dispose()
css::uno::Reference<css::view::XSelectionSupplier> xSelectionSupplier(mxModel->getCurrentController(), css::uno::UNO_QUERY); css::uno::Reference<css::view::XSelectionSupplier> xSelectionSupplier(mxModel->getCurrentController(), css::uno::UNO_QUERY);
if (xSelectionSupplier.is()) if (xSelectionSupplier.is())
xSelectionSupplier->removeSelectionChangeListener(mxSelectionListener); xSelectionSupplier->removeSelectionChangeListener(mxSelectionListener.get());
AreaPropertyPanelBase::dispose(); AreaPropertyPanelBase::dispose();
} }
...@@ -239,7 +241,7 @@ void ChartAreaPanel::Initialize() ...@@ -239,7 +241,7 @@ void ChartAreaPanel::Initialize()
css::uno::Reference<css::view::XSelectionSupplier> xSelectionSupplier(mxModel->getCurrentController(), css::uno::UNO_QUERY); css::uno::Reference<css::view::XSelectionSupplier> xSelectionSupplier(mxModel->getCurrentController(), css::uno::UNO_QUERY);
if (xSelectionSupplier.is()) if (xSelectionSupplier.is())
xSelectionSupplier->addSelectionChangeListener(mxSelectionListener); xSelectionSupplier->addSelectionChangeListener(mxSelectionListener.get());
updateData(); updateData();
} }
...@@ -404,7 +406,7 @@ void ChartAreaPanel::updateModel( ...@@ -404,7 +406,7 @@ void ChartAreaPanel::updateModel(
css::uno::Reference<css::view::XSelectionSupplier> xSelectionSupplier(mxModel->getCurrentController(), css::uno::UNO_QUERY); css::uno::Reference<css::view::XSelectionSupplier> xSelectionSupplier(mxModel->getCurrentController(), css::uno::UNO_QUERY);
if (xSelectionSupplier.is()) if (xSelectionSupplier.is())
xSelectionSupplier->addSelectionChangeListener(mxSelectionListener); xSelectionSupplier->addSelectionChangeListener(mxSelectionListener.get());
} }
......
...@@ -86,7 +86,7 @@ private: ...@@ -86,7 +86,7 @@ private:
css::uno::Reference<css::frame::XModel> mxModel; css::uno::Reference<css::frame::XModel> mxModel;
css::uno::Reference<css::util::XModifyListener> mxListener; css::uno::Reference<css::util::XModifyListener> mxListener;
css::uno::Reference<css::view::XSelectionChangeListener> mxSelectionListener; rtl::Reference<ChartSidebarSelectionListener> mxSelectionListener;
void Initialize(); void Initialize();
......
...@@ -23,19 +23,16 @@ ChartSidebarSelectionListenerParent::~ChartSidebarSelectionListenerParent() ...@@ -23,19 +23,16 @@ ChartSidebarSelectionListenerParent::~ChartSidebarSelectionListenerParent()
ChartSidebarSelectionListener::ChartSidebarSelectionListener( ChartSidebarSelectionListener::ChartSidebarSelectionListener(
ChartSidebarSelectionListenerParent* pParent): ChartSidebarSelectionListenerParent* pParent):
mpParent(pParent), mpParent(pParent)
mbAll(true),
meType()
{ {
} }
ChartSidebarSelectionListener::ChartSidebarSelectionListener( ChartSidebarSelectionListener::ChartSidebarSelectionListener(
ChartSidebarSelectionListenerParent* pParent, ChartSidebarSelectionListenerParent* pParent,
ObjectType eType): ObjectType eType):
mpParent(pParent), mpParent(pParent)
mbAll(false),
meType(eType)
{ {
maTypes.push_back(eType);
} }
ChartSidebarSelectionListener::~ChartSidebarSelectionListener() ChartSidebarSelectionListener::~ChartSidebarSelectionListener()
...@@ -45,13 +42,10 @@ ChartSidebarSelectionListener::~ChartSidebarSelectionListener() ...@@ -45,13 +42,10 @@ ChartSidebarSelectionListener::~ChartSidebarSelectionListener()
void ChartSidebarSelectionListener::selectionChanged(const css::lang::EventObject& rEvent) void ChartSidebarSelectionListener::selectionChanged(const css::lang::EventObject& rEvent)
throw (::css::uno::RuntimeException, ::std::exception) throw (::css::uno::RuntimeException, ::std::exception)
{ {
(void)rEvent;
bool bCorrectObjectSelected = false; bool bCorrectObjectSelected = false;
if (mbAll)
bCorrectObjectSelected = true;
css::uno::Reference<css::frame::XController> xController(rEvent.Source, css::uno::UNO_QUERY); 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); css::uno::Reference<css::view::XSelectionSupplier> xSelectionSupplier(xController, css::uno::UNO_QUERY);
if (xSelectionSupplier.is()) if (xSelectionSupplier.is())
...@@ -62,7 +56,8 @@ void ChartSidebarSelectionListener::selectionChanged(const css::lang::EventObjec ...@@ -62,7 +56,8 @@ void ChartSidebarSelectionListener::selectionChanged(const css::lang::EventObjec
OUString aCID; OUString aCID;
aAny >>= aCID; aAny >>= aCID;
ObjectType eType = ObjectIdentifier::getObjectType(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 ...@@ -76,6 +71,11 @@ void ChartSidebarSelectionListener::disposing(const css::lang::EventObject& /*rE
mpParent->SelectionInvalid(); mpParent->SelectionInvalid();
} }
void ChartSidebarSelectionListener::setAcceptedTypes(const std::vector<ObjectType>& aTypes)
{
maTypes = aTypes;
}
} } } }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -15,6 +15,8 @@ ...@@ -15,6 +15,8 @@
#include "ObjectIdentifier.hxx" #include "ObjectIdentifier.hxx"
#include <vector>
namespace chart { namespace chart {
namespace sidebar { namespace sidebar {
...@@ -44,11 +46,12 @@ public: ...@@ -44,11 +46,12 @@ public:
virtual void SAL_CALL disposing(const css::lang::EventObject& rEvent) virtual void SAL_CALL disposing(const css::lang::EventObject& rEvent)
throw (::css::uno::RuntimeException, ::std::exception) SAL_OVERRIDE; throw (::css::uno::RuntimeException, ::std::exception) SAL_OVERRIDE;
void setAcceptedTypes(const std::vector<ObjectType>& aTypes);
private: private:
ChartSidebarSelectionListenerParent* mpParent; ChartSidebarSelectionListenerParent* mpParent;
bool mbAll; std::vector<ObjectType> maTypes;
ObjectType meType;
}; };
} } } }
......
...@@ -1266,7 +1266,8 @@ ...@@ -1266,7 +1266,8 @@
</prop> </prop>
<prop oor:name="ContextList"> <prop oor:name="ContextList">
<value oor:separator=";"> <value oor:separator=";">
Chart, any, visible ; Chart, Chart, visible ;
Chart, Series, visible ;
</value> </value>
</prop> </prop>
<prop oor:name="ImplementationURL" oor:type="xs:string"> <prop oor:name="ImplementationURL" oor:type="xs:string">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment