From 288e8e9c291160916d26a559ff01a176fa9b9bec Mon Sep 17 00:00:00 2001
From: Caolán McNamara <caolanm@redhat.com>
Date: Tue, 23 Feb 2021 14:32:30 +0000
Subject: we don't need the PopupMenu to derive the info we need here
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Change-Id: Idc8b658ee4b8cb983dbc95f8614141402811ac3a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111406
Tested-by: Caolán McNamara <caolanm@redhat.com>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
---
 chart2/source/controller/main/ChartController_Window.cxx | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

(limited to 'chart2')

diff --git a/chart2/source/controller/main/ChartController_Window.cxx b/chart2/source/controller/main/ChartController_Window.cxx
index d9879174656d..a8d71e903fd3 100644
--- a/chart2/source/controller/main/ChartController_Window.cxx
+++ b/chart2/source/controller/main/ChartController_Window.cxx
@@ -78,7 +78,6 @@
 #include <svx/svddrgmt.hxx>
 #include <vcl/commandevent.hxx>
 #include <vcl/event.hxx>
-#include <vcl/menu.hxx>
 #include <vcl/svapp.hxx>
 #include <vcl/settings.hxx>
 #include <vcl/weld.hxx>
@@ -1289,19 +1288,19 @@ 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)
+                if (pCommandDispatch)
                 {
-                    for (sal_uInt16 nPos = 0; nPos < pPopupMenu->GetItemCount(); nPos++)
+                    for (int nPos = 0, nCount = xPopupMenu->getItemCount(); nPos < nCount; ++nPos)
                     {
-                        const sal_uInt16 nItemId = pPopupMenu->GetItemId(nPos);
-                        OUString aCommandURL = pPopupMenu->GetItemCommand(nItemId);
-                        if(!pCommandDispatch->commandAvailable(aCommandURL))
-                            pPopupMenu->EnableItem(nItemId, false);
+                        auto nItemId = xPopupMenu->getItemId(nPos);
+                        OUString aCommandURL = xPopupMenu->getCommand(nItemId);
+                        if (!pCommandDispatch->commandAvailable(aCommandURL))
+                            xPopupMenu->enableItem(nItemId, false);
                     }
                 }
 
+                Menu* pPopupMenu = comphelper::getUnoTunnelImplementation<VCLXMenu>(xPopupMenu)->GetMenu();
                 boost::property_tree::ptree aMenu = SfxDispatcher::fillPopupMenu(pPopupMenu);
                 boost::property_tree::ptree aRoot;
                 aRoot.add_child("menu", aMenu);
-- 
cgit