summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOliver Specht <oliver.specht@cib.de>2016-02-17 12:07:59 +0100
committerAndras Timar <andras.timar@collabora.com>2016-02-22 08:58:21 +0100
commit02341810df1b262ea51b2f5af71a532db08acde1 (patch)
treef12229cad4275185616da1f58b3aaeceb3df2151
parent75b473258d6f06e68af3fd49fc2f168e88934b72 (diff)
tdf#98001: allow disabling file/new, wizards, recent documents menu entries
disabling the dispatches '.uno:AutoPilotMenu' and '.uno:AddDirect' and .uno:RecentFileList via UNO API now results in disabled menu entries as expected Change-Id: Id99be9374306ff8c0cea919ea94ed96f715a8058 Reviewed-on: https://gerrit.libreoffice.org/22422 Reviewed-by: Oliver Specht <oliver.specht@cib.de> Tested-by: Oliver Specht <oliver.specht@cib.de> Reviewed-on: https://gerrit.libreoffice.org/22461 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com> (cherry picked from commit 8a50946c2868f196a1f4571e491a5ca7fb12492a)
-rw-r--r--framework/source/classes/menumanager.cxx46
-rw-r--r--framework/source/uielement/menubarmanager.cxx26
-rw-r--r--framework/source/uielement/newmenucontroller.cxx11
3 files changed, 47 insertions, 36 deletions
diff --git a/framework/source/classes/menumanager.cxx b/framework/source/classes/menumanager.cxx
index 7cd0e7dd6c06..6a491bd2da3e 100644
--- a/framework/source/classes/menumanager.cxx
+++ b/framework/source/classes/menumanager.cxx
@@ -177,33 +177,33 @@ MenuManager::MenuManager(
}
else
{
- if ( nItemId == SID_NEWDOCDIRECT || aItemCommand == aSlotNewDocDirect )
+ bool isNewDoc = nItemId == SID_NEWDOCDIRECT || aItemCommand == aSlotNewDocDirect;
+ bool isAutoPilot = nItemId == SID_AUTOPILOTMENU || aItemCommand == aSlotAutoPilot;
+ if(isNewDoc || isAutoPilot)
{
- MenuConfiguration aMenuCfg( m_xContext );
- BmkMenu* pSubMenu = static_cast<BmkMenu*>(aMenuCfg.CreateBookmarkMenu( rFrame, BOOKMARK_NEWMENU ));
- pMenu->SetPopupMenu( nItemId, pSubMenu );
-
- AddMenu(pSubMenu,OUString(),nItemId,true,false);
- if ( bShowMenuImages && !pMenu->GetItemImage( nItemId ))
+ Reference< XDispatchProvider > xDispatchProvider( m_xFrame, UNO_QUERY );
+ URL aTargetURL;
+ aTargetURL.Complete = OUString::createFromAscii(isNewDoc ? aSlotNewDocDirect : aSlotAutoPilot);
+ m_xURLTransformer->parseStrict( aTargetURL );
+ Reference< XDispatch > xMenuItemDispatch = xDispatchProvider->queryDispatch(
+ aTargetURL, OUString(), 0 );
+ if(xMenuItemDispatch == nullptr)
{
- Image aImage = GetImageFromURL( rFrame, aItemCommand, false );
- if ( !!aImage )
- pMenu->SetItemImage( nItemId, aImage );
+ m_pVCLMenu->EnableItem( nItemId, false );
}
- }
- else if ( nItemId == SID_AUTOPILOTMENU || aItemCommand == aSlotAutoPilot )
- {
- MenuConfiguration aMenuCfg( m_xContext );
- BmkMenu* pSubMenu = static_cast<BmkMenu*>(aMenuCfg.CreateBookmarkMenu( rFrame, BOOKMARK_WIZARDMENU ));
- pMenu->SetPopupMenu( nItemId, pSubMenu );
-
- AddMenu(pSubMenu,OUString(),nItemId,true,false);
-
- if ( bShowMenuImages && !pMenu->GetItemImage( nItemId ))
+ else
{
- Image aImage = GetImageFromURL( rFrame, aItemCommand, false );
- if ( !!aImage )
- pMenu->SetItemImage( nItemId, aImage );
+ MenuConfiguration aMenuCfg( m_xContext );
+ BmkMenu* pSubMenu = static_cast<BmkMenu*>(aMenuCfg.CreateBookmarkMenu( rFrame,
+ OUString::createFromAscii(isNewDoc ? BOOKMARK_NEWMENU : BOOKMARK_WIZARDMENU)));
+ pMenu->SetPopupMenu( nItemId, pSubMenu );
+ AddMenu(pSubMenu,OUString(),nItemId,true,false);
+ if ( bShowMenuImages && !pMenu->GetItemImage( nItemId ))
+ {
+ Image aImage = GetImageFromURL( rFrame, aItemCommand, false );
+ if ( !!aImage )
+ pMenu->SetItemImage( nItemId, aImage );
+ }
}
}
else if ( pMenu->GetItemType( i ) != MenuItemType::SEPARATOR )
diff --git a/framework/source/uielement/menubarmanager.cxx b/framework/source/uielement/menubarmanager.cxx
index 9e360738bcc8..d66f20b6f328 100644
--- a/framework/source/uielement/menubarmanager.cxx
+++ b/framework/source/uielement/menubarmanager.cxx
@@ -872,20 +872,22 @@ IMPL_LINK_TYPED( MenuBarManager, Activate, Menu *, pMenu, bool )
xMenuItemDispatch = xDispatchProvider->queryDispatch( aTargetURL, OUString(), 0 );
bool bPopupMenu( false );
- if ( !pMenuItemHandler->xPopupMenuController.is() &&
- m_xPopupMenuControllerFactory->hasController( aItemCommand, OUString() ))
+ if(xMenuItemDispatch != nullptr)
{
- bPopupMenu = CreatePopupMenuController( pMenuItemHandler );
- }
- else if ( pMenuItemHandler->xPopupMenuController.is() )
- {
- // Force update of popup menu
- pMenuItemHandler->xPopupMenuController->updatePopupMenu();
- bPopupMenu = true;
- if (PopupMenu* pThisPopup = pMenu->GetPopupMenu( pMenuItemHandler->nItemId ))
- pMenu->EnableItem( pMenuItemHandler->nItemId, pThisPopup->GetItemCount() != 0 );
+ if ( !pMenuItemHandler->xPopupMenuController.is() &&
+ m_xPopupMenuControllerFactory->hasController( aItemCommand, m_aModuleIdentifier ) )
+ {
+ bPopupMenu = CreatePopupMenuController( pMenuItemHandler );
+ }
+ else if ( pMenuItemHandler->xPopupMenuController.is() )
+ {
+ // Force update of popup menu
+ pMenuItemHandler->xPopupMenuController->updatePopupMenu();
+ bPopupMenu = true;
+ if (PopupMenu* pThisPopup = pMenu->GetPopupMenu( pMenuItemHandler->nItemId ))
+ pMenu->EnableItem( pMenuItemHandler->nItemId, pThisPopup->GetItemCount() != 0 );
+ }
}
-
lcl_CheckForChildren(pMenu, pMenuItemHandler->nItemId);
if ( xMenuItemDispatch.is() )
diff --git a/framework/source/uielement/newmenucontroller.cxx b/framework/source/uielement/newmenucontroller.cxx
index 9a02716b1082..b5bd5f76fa80 100644
--- a/framework/source/uielement/newmenucontroller.cxx
+++ b/framework/source/uielement/newmenucontroller.cxx
@@ -47,6 +47,8 @@
#include <boost/scoped_ptr.hpp>
// Defines
+#define aSlotNewDocDirect ".uno:AddDirect"
+#define aSlotAutoPilot ".uno:AutoPilotMenu"
using namespace com::sun::star::uno;
using namespace com::sun::star::lang;
@@ -328,6 +330,13 @@ void NewMenuController::fillPopupMenu( Reference< css::awt::XPopupMenu >& rPopup
MenuConfiguration aMenuCfg( m_xContext );
boost::scoped_ptr<BmkMenu> pSubMenu;
+ Reference< XDispatchProvider > xDispatchProvider( m_xFrame, UNO_QUERY );
+ URL aTargetURL;
+ aTargetURL.Complete = rtl::OUString::createFromAscii(m_bNewMenu ? aSlotNewDocDirect : aSlotAutoPilot);
+ m_xURLTransformer->parseStrict( aTargetURL );
+ Reference< XDispatch > xMenuItemDispatch = xDispatchProvider->queryDispatch( aTargetURL, OUString(), 0 );
+ if(xMenuItemDispatch == nullptr)
+ return;
if ( m_bNewMenu )
pSubMenu.reset(static_cast<BmkMenu*>(aMenuCfg.CreateBookmarkMenu( m_xFrame, BOOKMARK_NEWMENU )));
else
@@ -518,7 +527,7 @@ void SAL_CALL NewMenuController::initialize( const Sequence< Any >& aArguments )
const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings();
m_bShowImages = rSettings.GetUseImagesInMenus();
- m_bNewMenu = m_aCommandURL == ".uno:AddDirect";
+ m_bNewMenu = m_aCommandURL == aSlotNewDocDirect;
}
}
}