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>
This commit is contained in:
@@ -60,8 +60,8 @@ namespace framework
|
|||||||
void retrieveShortcutsFromConfiguration( const css::uno::Reference< css::ui::XAcceleratorConfiguration >& rAccelCfg,
|
void retrieveShortcutsFromConfiguration( const css::uno::Reference< css::ui::XAcceleratorConfiguration >& rAccelCfg,
|
||||||
const css::uno::Sequence< OUString >& rCommands,
|
const css::uno::Sequence< OUString >& rCommands,
|
||||||
std::vector< vcl::KeyCode >& aMenuShortCuts );
|
std::vector< vcl::KeyCode >& aMenuShortCuts );
|
||||||
void setAccelerators( PopupMenu* pPopupMenu );
|
void setAccelerators();
|
||||||
void determineAndSetNewDocAccel( PopupMenu* pPopupMenu, const vcl::KeyCode& rKeyCode );
|
void determineAndSetNewDocAccel(const css::awt::KeyEvent& rKeyCode);
|
||||||
void setMenuImages( PopupMenu* pPopupMenu, bool bSetImages );
|
void setMenuImages( PopupMenu* pPopupMenu, bool bSetImages );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@@ -22,6 +22,7 @@
|
|||||||
|
|
||||||
#include <services.h>
|
#include <services.h>
|
||||||
|
|
||||||
|
#include <com/sun/star/awt/MenuItemType.hpp>
|
||||||
#include <com/sun/star/beans/PropertyValue.hpp>
|
#include <com/sun/star/beans/PropertyValue.hpp>
|
||||||
#include <com/sun/star/ui/theModuleUIConfigurationManagerSupplier.hpp>
|
#include <com/sun/star/ui/theModuleUIConfigurationManagerSupplier.hpp>
|
||||||
#include <com/sun/star/ui/XUIConfigurationManagerSupplier.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 nCount(m_xPopupMenu->getItemCount());
|
||||||
sal_uInt16 nId( 0 );
|
sal_uInt16 nId( 0 );
|
||||||
bool bFound( false );
|
bool bFound( false );
|
||||||
OUString aCommand;
|
OUString aCommand;
|
||||||
|
|
||||||
@@ -119,13 +120,13 @@ void NewMenuController::determineAndSetNewDocAccel( PopupMenu* pPopupMenu, const
|
|||||||
|
|
||||||
for ( sal_uInt16 i = 0; i < nCount; i++ )
|
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 );
|
nId = m_xPopupMenu->getItemId(i);
|
||||||
aCommand = pPopupMenu->GetItemCommand( nId );
|
aCommand = m_xPopupMenu->getCommand(nId);
|
||||||
if ( aCommand.startsWith( m_aEmptyDocURL ) )
|
if ( aCommand.startsWith( m_aEmptyDocURL ) )
|
||||||
{
|
{
|
||||||
pPopupMenu->SetAccelKey( nId, rKeyCode );
|
m_xPopupMenu->setAcceleratorKeyEvent(nId, rKeyCode);
|
||||||
bFound = true;
|
bFound = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -143,20 +144,20 @@ void NewMenuController::determineAndSetNewDocAccel( PopupMenu* pPopupMenu, const
|
|||||||
|
|
||||||
for ( sal_uInt16 i = 0; i < nCount; i++ )
|
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 );
|
nId = m_xPopupMenu->getItemId(i);
|
||||||
aCommand = pPopupMenu->GetItemCommand( nId );
|
aCommand = m_xPopupMenu->getCommand(nId);
|
||||||
if ( aCommand.indexOf( aDefaultModuleName ) >= 0 )
|
if ( aCommand.indexOf( aDefaultModuleName ) >= 0 )
|
||||||
{
|
{
|
||||||
pPopupMenu->SetAccelKey( nId, rKeyCode );
|
m_xPopupMenu->setAcceleratorKeyEvent(nId, rKeyCode);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void NewMenuController::setAccelerators( PopupMenu* pPopupMenu )
|
void NewMenuController::setAccelerators()
|
||||||
{
|
{
|
||||||
if ( !m_bModuleIdentified )
|
if ( !m_bModuleIdentified )
|
||||||
return;
|
return;
|
||||||
@@ -212,18 +213,18 @@ void NewMenuController::setAccelerators( PopupMenu* pPopupMenu )
|
|||||||
}
|
}
|
||||||
|
|
||||||
vcl::KeyCode aEmptyKeyCode;
|
vcl::KeyCode aEmptyKeyCode;
|
||||||
sal_uInt16 nItemCount( pPopupMenu->GetItemCount() );
|
sal_uInt16 nItemCount(m_xPopupMenu->getItemCount());
|
||||||
std::vector< vcl::KeyCode > aMenuShortCuts;
|
std::vector< vcl::KeyCode > aMenuShortCuts;
|
||||||
std::vector< OUString > aCmds;
|
std::vector< OUString > aCmds;
|
||||||
std::vector< sal_uInt16 > aIds;
|
std::vector< sal_uInt16 > aIds;
|
||||||
for ( sal_uInt16 i = 0; i < nItemCount; i++ )
|
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 );
|
aIds.push_back( nId );
|
||||||
aMenuShortCuts.push_back( aEmptyKeyCode );
|
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();
|
const sal_uInt32 nCount2 = aIds.size();
|
||||||
for ( sal_uInt32 i = 0; i < nCount2; i++ )
|
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
|
// Special handling for "New" menu short-cut should be set at the
|
||||||
// document which will be opened using it.
|
// document which will be opened using it.
|
||||||
if ( m_bNewMenu )
|
if ( m_bNewMenu )
|
||||||
{
|
{
|
||||||
if ( aMenuShortCuts[nSeqCount-1] != aEmptyKeyCode )
|
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 );
|
setMenuImages( pVCLPopupMenu, m_bShowImages );
|
||||||
}
|
}
|
||||||
|
|
||||||
setAccelerators( pVCLPopupMenu );
|
setAccelerators();
|
||||||
}
|
}
|
||||||
|
|
||||||
// XPopupMenuController
|
// XPopupMenuController
|
||||||
|
@@ -575,7 +575,7 @@ namespace
|
|||||||
return aImage;
|
return aImage;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Copied from svtools/inc/acceleratorexecute.hxx */
|
/** Copied from include/svtools/acceleratorexecute.hxx */
|
||||||
css::awt::KeyEvent lcl_VCLKey2AWTKey(
|
css::awt::KeyEvent lcl_VCLKey2AWTKey(
|
||||||
const vcl::KeyCode& aVCLKey)
|
const vcl::KeyCode& aVCLKey)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user