From 88b69059c34a6ff85f1e61d9bc8906bfd8e432aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= Date: Mon, 29 Nov 2021 11:57:55 +0000 Subject: [PATCH] use more XPopupMenu methods over PopupMenu ones MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I54acdcb82b90d363e48543de99c75adea8fceb2a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126047 Tested-by: Jenkins Reviewed-by: Caolán McNamara --- framework/inc/uielement/newmenucontroller.hxx | 4 +- .../source/uielement/newmenucontroller.cxx | 39 ++++++++++--------- toolkit/source/awt/vclxmenu.cxx | 2 +- 3 files changed, 23 insertions(+), 22 deletions(-) diff --git a/framework/inc/uielement/newmenucontroller.hxx b/framework/inc/uielement/newmenucontroller.hxx index 2c745cc2b64d..57e58239fc19 100644 --- a/framework/inc/uielement/newmenucontroller.hxx +++ b/framework/inc/uielement/newmenucontroller.hxx @@ -60,8 +60,8 @@ namespace framework void retrieveShortcutsFromConfiguration( const css::uno::Reference< css::ui::XAcceleratorConfiguration >& rAccelCfg, const css::uno::Sequence< OUString >& rCommands, std::vector< vcl::KeyCode >& aMenuShortCuts ); - void setAccelerators( PopupMenu* pPopupMenu ); - void determineAndSetNewDocAccel( PopupMenu* pPopupMenu, const vcl::KeyCode& rKeyCode ); + void setAccelerators(); + void determineAndSetNewDocAccel(const css::awt::KeyEvent& rKeyCode); void setMenuImages( PopupMenu* pPopupMenu, bool bSetImages ); private: diff --git a/framework/source/uielement/newmenucontroller.cxx b/framework/source/uielement/newmenucontroller.cxx index 710f49c264d4..59e9160f8ced 100644 --- a/framework/source/uielement/newmenucontroller.cxx +++ b/framework/source/uielement/newmenucontroller.cxx @@ -22,6 +22,7 @@ #include +#include #include #include #include @@ -106,10 +107,10 @@ void NewMenuController::setMenuImages( PopupMenu* pPopupMenu, bool bSetImages ) } } -void NewMenuController::determineAndSetNewDocAccel( PopupMenu* pPopupMenu, const vcl::KeyCode& rKeyCode ) +void NewMenuController::determineAndSetNewDocAccel(const css::awt::KeyEvent& rKeyCode) { - sal_uInt16 nCount( pPopupMenu->GetItemCount() ); - sal_uInt16 nId( 0 ); + sal_uInt16 nCount(m_xPopupMenu->getItemCount()); + sal_uInt16 nId( 0 ); bool bFound( false ); OUString aCommand; @@ -119,13 +120,13 @@ void NewMenuController::determineAndSetNewDocAccel( PopupMenu* pPopupMenu, const for ( sal_uInt16 i = 0; i < nCount; i++ ) { - if ( pPopupMenu->GetItemType( i ) != MenuItemType::SEPARATOR ) + if (m_xPopupMenu->getItemType(i) != css::awt::MenuItemType_SEPARATOR) { - nId = pPopupMenu->GetItemId( i ); - aCommand = pPopupMenu->GetItemCommand( nId ); + nId = m_xPopupMenu->getItemId(i); + aCommand = m_xPopupMenu->getCommand(nId); if ( aCommand.startsWith( m_aEmptyDocURL ) ) { - pPopupMenu->SetAccelKey( nId, rKeyCode ); + m_xPopupMenu->setAcceleratorKeyEvent(nId, rKeyCode); bFound = true; break; } @@ -143,20 +144,20 @@ void NewMenuController::determineAndSetNewDocAccel( PopupMenu* pPopupMenu, const for ( sal_uInt16 i = 0; i < nCount; i++ ) { - if ( pPopupMenu->GetItemType( i ) != MenuItemType::SEPARATOR ) + if (m_xPopupMenu->getItemType(i) != css::awt::MenuItemType_SEPARATOR) { - nId = pPopupMenu->GetItemId( i ); - aCommand = pPopupMenu->GetItemCommand( nId ); + nId = m_xPopupMenu->getItemId(i); + aCommand = m_xPopupMenu->getCommand(nId); if ( aCommand.indexOf( aDefaultModuleName ) >= 0 ) { - pPopupMenu->SetAccelKey( nId, rKeyCode ); + m_xPopupMenu->setAcceleratorKeyEvent(nId, rKeyCode); break; } } } } -void NewMenuController::setAccelerators( PopupMenu* pPopupMenu ) +void NewMenuController::setAccelerators() { if ( !m_bModuleIdentified ) return; @@ -212,18 +213,18 @@ void NewMenuController::setAccelerators( PopupMenu* pPopupMenu ) } vcl::KeyCode aEmptyKeyCode; - sal_uInt16 nItemCount( pPopupMenu->GetItemCount() ); + sal_uInt16 nItemCount(m_xPopupMenu->getItemCount()); std::vector< vcl::KeyCode > aMenuShortCuts; std::vector< OUString > aCmds; std::vector< sal_uInt16 > aIds; for ( sal_uInt16 i = 0; i < nItemCount; i++ ) { - if ( pPopupMenu->GetItemType( i ) != MenuItemType::SEPARATOR ) + if (m_xPopupMenu->getItemType(i) != css::awt::MenuItemType_SEPARATOR) { - sal_uInt16 nId( pPopupMenu->GetItemId( i )); + sal_uInt16 nId(m_xPopupMenu->getItemId(i)); aIds.push_back( nId ); aMenuShortCuts.push_back( aEmptyKeyCode ); - aCmds.push_back( pPopupMenu->GetItemCommand( nId )); + aCmds.push_back(m_xPopupMenu->getCommand(nId)); } } @@ -255,14 +256,14 @@ void NewMenuController::setAccelerators( PopupMenu* pPopupMenu ) const sal_uInt32 nCount2 = aIds.size(); for ( sal_uInt32 i = 0; i < nCount2; i++ ) - pPopupMenu->SetAccelKey( aIds[i], aMenuShortCuts[i] ); + m_xPopupMenu->setAcceleratorKeyEvent(aIds[i], svt::AcceleratorExecute::st_VCLKey2AWTKey(aMenuShortCuts[i])); // Special handling for "New" menu short-cut should be set at the // document which will be opened using it. if ( m_bNewMenu ) { if ( aMenuShortCuts[nSeqCount-1] != aEmptyKeyCode ) - determineAndSetNewDocAccel( pPopupMenu, aMenuShortCuts[nSeqCount-1] ); + determineAndSetNewDocAccel(svt::AcceleratorExecute::st_VCLKey2AWTKey(aMenuShortCuts[nSeqCount-1])); } } @@ -436,7 +437,7 @@ void SAL_CALL NewMenuController::itemActivated( const css::awt::MenuEvent& ) setMenuImages( pVCLPopupMenu, m_bShowImages ); } - setAccelerators( pVCLPopupMenu ); + setAccelerators(); } // XPopupMenuController diff --git a/toolkit/source/awt/vclxmenu.cxx b/toolkit/source/awt/vclxmenu.cxx index 31c0f7f08edf..56b0bb49a6ca 100644 --- a/toolkit/source/awt/vclxmenu.cxx +++ b/toolkit/source/awt/vclxmenu.cxx @@ -575,7 +575,7 @@ namespace return aImage; } - /** Copied from svtools/inc/acceleratorexecute.hxx */ + /** Copied from include/svtools/acceleratorexecute.hxx */ css::awt::KeyEvent lcl_VCLKey2AWTKey( const vcl::KeyCode& aVCLKey) {