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,
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());
}
......
......@@ -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();
......
......@@ -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: */
......@@ -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;
};
} }
......
......@@ -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">
......
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