diff options
author | Maxim Monastirsky <momonasmon@gmail.com> | 2022-06-27 12:27:35 +0300 |
---|---|---|
committer | Maxim Monastirsky <momonasmon@gmail.com> | 2022-06-28 13:55:56 +0200 |
commit | bdd217c1f23e0fb5f84542f1fb41036c3de538df (patch) | |
tree | 5bdee1f50a4f5dc3769f964a6b7a494d5d40b391 | |
parent | d0e49c07203c9ae33c5dfa1855b2b8909c3e16dc (diff) |
NewMenuController: Use status update to determine the default factory
This is a follow-up to 2446fdba3ec4a81d6e3b619a1d9e91b3c6dcbd54
("tdf#134887 Rework last item handling in NewToolbarController").
We should better get the information on what is going to be
executed from the entity that will actually execute it, instead
of guessing on our own. This makes a difference for at least
XML Form Document, where CTRL+N used to be shown next to the
"XML Form Document" entry, although pressing that shortcut
will open a regular writer doc.
Change-Id: Ib9b58ea2fb83a6cfe9a603af6be97fb36a25ddc6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136554
Tested-by: Jenkins
Reviewed-by: Maxim Monastirsky <momonasmon@gmail.com>
-rw-r--r-- | framework/source/uielement/newmenucontroller.cxx | 45 |
1 files changed, 2 insertions, 43 deletions
diff --git a/framework/source/uielement/newmenucontroller.cxx b/framework/source/uielement/newmenucontroller.cxx index d282509d93f5..14b59c263b85 100644 --- a/framework/source/uielement/newmenucontroller.cxx +++ b/framework/source/uielement/newmenucontroller.cxx @@ -40,7 +40,6 @@ #include <toolkit/awt/vclxmenu.hxx> #include <tools/urlobj.hxx> #include <unotools/dynamicmenuoptions.hxx> -#include <unotools/moduleoptions.hxx> #include <osl/mutex.hxx> #include <cppuhelper/supportsservice.hxx> @@ -111,7 +110,6 @@ void NewMenuController::determineAndSetNewDocAccel(const css::awt::KeyEvent& rKe { sal_uInt16 nCount(m_xPopupMenu->getItemCount()); sal_uInt16 nId( 0 ); - bool bFound( false ); OUString aCommand; if ( !m_aEmptyDocURL.isEmpty() ) @@ -127,34 +125,11 @@ void NewMenuController::determineAndSetNewDocAccel(const css::awt::KeyEvent& rKe if ( aCommand.startsWith( m_aEmptyDocURL ) ) { m_xPopupMenu->setAcceleratorKeyEvent(nId, rKeyCode); - bFound = true; break; } } } } - - if ( bFound ) - return; - - // Search for the default module name - OUString aDefaultModuleName( SvtModuleOptions().GetDefaultModuleName() ); - if ( aDefaultModuleName.isEmpty() ) - return; - - for ( sal_uInt16 i = 0; i < nCount; i++ ) - { - if (m_xPopupMenu->getItemType(i) != css::awt::MenuItemType_SEPARATOR) - { - nId = m_xPopupMenu->getItemId(i); - aCommand = m_xPopupMenu->getCommand(nId); - if ( aCommand.indexOf( aDefaultModuleName ) >= 0 ) - { - m_xPopupMenu->setAcceleratorKeyEvent(nId, rKeyCode); - break; - } - } - } } void NewMenuController::setAccelerators() @@ -372,8 +347,9 @@ void SAL_CALL NewMenuController::disposing( const EventObject& ) } // XStatusListener -void SAL_CALL NewMenuController::statusChanged( const FeatureStateEvent& ) +void SAL_CALL NewMenuController::statusChanged( const FeatureStateEvent& Event ) { + Event.State >>= m_aEmptyDocURL; } // XMenuListener @@ -452,23 +428,6 @@ void NewMenuController::impl_setPopupMenu() { m_aModuleIdentifier = xModuleManager->identify( m_xFrame ); m_bModuleIdentified = true; - - if ( !m_aModuleIdentifier.isEmpty() ) - { - Sequence< PropertyValue > aSeq; - - if ( xModuleManager->getByName( m_aModuleIdentifier ) >>= aSeq ) - { - for ( PropertyValue const & prop : std::as_const(aSeq) ) - { - if ( prop.Name == "ooSetupFactoryEmptyDocumentURL" ) - { - prop.Value >>= m_aEmptyDocURL; - break; - } - } - } - } } catch ( const RuntimeException& ) { |