diff options
author | Caolán McNamara <caolanm@redhat.com> | 2021-11-29 11:57:55 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2021-11-29 21:21:12 +0100 |
commit | 88b69059c34a6ff85f1e61d9bc8906bfd8e432aa (patch) | |
tree | 021b9bc545e04706ff30b28903343cf643a02cb9 /framework | |
parent | 67df0664609336faf205f80fdb5115d9edb985c3 (diff) |
use more XPopupMenu methods over PopupMenu ones
Change-Id: I54acdcb82b90d363e48543de99c75adea8fceb2a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126047
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'framework')
-rw-r--r-- | framework/inc/uielement/newmenucontroller.hxx | 4 | ||||
-rw-r--r-- | framework/source/uielement/newmenucontroller.cxx | 39 |
2 files changed, 22 insertions, 21 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 <services.h> +#include <com/sun/star/awt/MenuItemType.hpp> #include <com/sun/star/beans/PropertyValue.hpp> #include <com/sun/star/ui/theModuleUIConfigurationManagerSupplier.hpp> #include <com/sun/star/ui/XUIConfigurationManagerSupplier.hpp> @@ -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 |