diff options
author | Tamás Zolnai <tamas.zolnai@collabora.com> | 2019-11-22 18:05:26 +0100 |
---|---|---|
committer | Tamás Zolnai <tamas.zolnai@collabora.com> | 2019-11-23 15:38:44 +0100 |
commit | 3437e328a69b25c42638446e0633491035603057 (patch) | |
tree | 4044eaaeb60e312d74fa995c45c359dcc4b3abde | |
parent | 33d3d9dacb8a2f962048cd7ab701380824ae0e21 (diff) |
lok: Chart context menu: Disable menu items which are not available.feature/spellig_popup_SID
Change-Id: Id7487c581759389e66ca513381d6706f3ae49980
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 ab04c1a941ec..6d820bef9598 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> @@ -1281,6 +1282,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 ); |