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-26 18:40:28 +0100 |
commit | 8fd190c24d021e91b9849c991250032b23b7bff2 (patch) | |
tree | fd52e8f4e880d5810f2d3c441027b6ef1ffb9ed2 /chart2 | |
parent | f5faf300f8c0c9a33978b8560ed136844b0235e6 (diff) |
lok: Chart context menu: Disable menu items which are not available.
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>
(cherry picked from commit 4582222a3ade99584514a86dbaddf0c80f7e7196)
Change-Id: Id7487c581759389e66ca513381d6706f3ae49980
Diffstat (limited to 'chart2')
3 files changed, 17 insertions, 1 deletions
diff --git a/chart2/source/controller/inc/CommandDispatchContainer.hxx b/chart2/source/controller/inc/CommandDispatchContainer.hxx index cbcf4345377b..61561da08e2f 100644 --- a/chart2/source/controller/inc/CommandDispatchContainer.hxx +++ b/chart2/source/controller/inc/CommandDispatchContainer.hxx @@ -104,6 +104,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 6c9ba58839fb..e3d65bd670d7 100644 --- a/chart2/source/controller/main/ChartController_Window.cxx +++ b/chart2/source/controller/main/ChartController_Window.cxx @@ -46,6 +46,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*>(VCLXMenu::GetImplementation( 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 ); |