summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTamás Zolnai <tamas.zolnai@collabora.com>2019-11-22 18:05:26 +0100
committerTamás Zolnai <tamas.zolnai@collabora.com>2019-11-24 13:52:32 +0100
commit4582222a3ade99584514a86dbaddf0c80f7e7196 (patch)
tree26943eeba065365822b989a9d985303724af546e
parent08d0326cd2125dabb94102adaf06e34fc49974bc (diff)
lok: Chart context menu: Disable menu items which are not available.
Change-Id: Id7487c581759389e66ca513381d6706f3ae49980 Reviewed-on: https://gerrit.libreoffice.org/83605 Reviewed-by: Tamás Zolnai <tamas.zolnai@collabora.com> Tested-by: Tamás Zolnai <tamas.zolnai@collabora.com>
-rw-r--r--chart2/source/controller/inc/CommandDispatchContainer.hxx2
-rw-r--r--chart2/source/controller/main/ChartController_Window.cxx13
-rw-r--r--chart2/source/controller/main/ControllerCommandDispatch.hxx3
3 files changed, 17 insertions, 1 deletions
diff --git a/chart2/source/controller/inc/CommandDispatchContainer.hxx b/chart2/source/controller/inc/CommandDispatchContainer.hxx
index 72c2daaa9367..9d6cd7e2e97b 100644
--- a/chart2/source/controller/inc/CommandDispatchContainer.hxx
+++ b/chart2/source/controller/inc/CommandDispatchContainer.hxx
@@ -103,6 +103,8 @@ public:
const css::uno::Reference< css::frame::XController > & xChartController,
const css::util::URL & rURL );
+ css::uno::Reference< css::frame::XDispatch > getChartDispatcher() { return m_xChartDispatcher; }
+
void setDrawCommandDispatch( DrawCommandDispatch* pDispatch );
DrawCommandDispatch* getDrawCommandDispatch() { return m_pDrawCommandDispatch; }
void setShapeController( ShapeController* pController );
diff --git a/chart2/source/controller/main/ChartController_Window.cxx b/chart2/source/controller/main/ChartController_Window.cxx
index c4f20d871aa7..9266e61005c7 100644
--- a/chart2/source/controller/main/ChartController_Window.cxx
+++ b/chart2/source/controller/main/ChartController_Window.cxx
@@ -44,6 +44,7 @@
#include <servicenames_charttypes.hxx>
#include "DrawCommandDispatch.hxx"
#include <PopupRequest.hxx>
+#include "ControllerCommandDispatch.hxx"
#include <com/sun/star/chart2/RelativePosition.hpp>
#include <com/sun/star/chart2/RelativeSize.hpp>
@@ -1283,6 +1284,18 @@ void ChartController::execute_Command( const CommandEvent& rCEvt )
if (SfxViewShell* pViewShell = SfxViewShell::Current())
{
PopupMenu* pPopupMenu = static_cast<PopupMenu*>(comphelper::getUnoTunnelImplementation<VCLXMenu>(xPopupMenu)->GetMenu());
+ ControllerCommandDispatch* pCommandDispatch = dynamic_cast<ControllerCommandDispatch*>(m_aDispatchContainer.getChartDispatcher().get());
+ if(pCommandDispatch)
+ {
+ for (sal_uInt16 nPos = 0; nPos < pPopupMenu->GetItemCount(); nPos++)
+ {
+ const sal_uInt16 nItemId = pPopupMenu->GetItemId(nPos);
+ OUString aCommandURL = pPopupMenu->GetItemCommand(nItemId);
+ if(!pCommandDispatch->commandAvailable(aCommandURL))
+ pPopupMenu->EnableItem(nItemId, false);
+ }
+ }
+
boost::property_tree::ptree aMenu = SfxDispatcher::fillPopupMenu(pPopupMenu);
boost::property_tree::ptree aRoot;
aRoot.add_child("menu", aMenu);
diff --git a/chart2/source/controller/main/ControllerCommandDispatch.hxx b/chart2/source/controller/main/ControllerCommandDispatch.hxx
index 4e105f86702c..b2f2a5e3dc51 100644
--- a/chart2/source/controller/main/ControllerCommandDispatch.hxx
+++ b/chart2/source/controller/main/ControllerCommandDispatch.hxx
@@ -65,6 +65,8 @@ public:
// late initialisation, especially for adding as listener
virtual void initialize() override;
+ bool commandAvailable( const OUString & rCommand );
+
protected:
// ____ XDispatch ____
virtual void SAL_CALL dispatch(
@@ -96,7 +98,6 @@ private:
const OUString & rURL,
const css::uno::Reference< css::frame::XStatusListener > & xSingleListener );
- bool commandAvailable( const OUString & rCommand );
void updateCommandAvailability();
bool isShapeControllerCommandAvailable( const OUString& rCommand );