diff --git a/framework/inc/classes/resource.hxx b/framework/inc/classes/resource.hxx index a9f98e607baa..04f00677c69d 100644 --- a/framework/inc/classes/resource.hxx +++ b/framework/inc/classes/resource.hxx @@ -22,10 +22,11 @@ #define MENUITEM_TOOLBAR_VISIBLEBUTTON 1 #define MENUITEM_TOOLBAR_CUSTOMIZETOOLBAR 2 -#define MENUITEM_TOOLBAR_DOCKTOOLBAR 3 -#define MENUITEM_TOOLBAR_DOCKALLTOOLBAR 4 -#define MENUITEM_TOOLBAR_LOCKTOOLBARPOSITION 5 -#define MENUITEM_TOOLBAR_CLOSE 6 +#define MENUITEM_TOOLBAR_UNDOCKTOOLBAR 3 +#define MENUITEM_TOOLBAR_DOCKTOOLBAR 4 +#define MENUITEM_TOOLBAR_DOCKALLTOOLBAR 5 +#define MENUITEM_TOOLBAR_LOCKTOOLBARPOSITION 6 +#define MENUITEM_TOOLBAR_CLOSE 7 #endif diff --git a/framework/inc/strings.hrc b/framework/inc/strings.hrc index ef3ad73c1956..d3f28fcc9e21 100644 --- a/framework/inc/strings.hrc +++ b/framework/inc/strings.hrc @@ -27,6 +27,7 @@ #define STR_CLOSEDOC_ANDRETURN NC_("STR_CLOSEDOC_ANDRETURN", "~Close & Return to " ) #define STR_TOOLBAR_VISIBLE_BUTTONS NC_("STR_TOOLBAR_VISIBLE_BUTTONS", "Visible ~Buttons") #define STR_TOOLBAR_CUSTOMIZE_TOOLBAR NC_("STR_TOOLBAR_CUSTOMIZE_TOOLBAR", "~Customize Toolbar...") +#define STR_TOOLBAR_UNDOCK_TOOLBAR NC_("STR_TOOLBAR_UNDOCK_TOOLBAR", "U~ndock Toolbar" ) #define STR_TOOLBAR_DOCK_TOOLBAR NC_("STR_TOOLBAR_DOCK_TOOLBAR", "~Dock Toolbar" ) #define STR_TOOLBAR_DOCK_ALL_TOOLBARS NC_("STR_TOOLBAR_DOCK_ALL_TOOLBARS", "Dock ~All Toolbars" ) #define STR_TOOLBAR_LOCK_TOOLBAR NC_("STR_TOOLBAR_LOCK_TOOLBAR", "~Lock Toolbar Position" ) diff --git a/framework/inc/uielement/toolbarmanager.hxx b/framework/inc/uielement/toolbarmanager.hxx index f43a3511b85d..8f3eb4c2b2eb 100644 --- a/framework/inc/uielement/toolbarmanager.hxx +++ b/framework/inc/uielement/toolbarmanager.hxx @@ -94,6 +94,7 @@ class ToolBarManager : public ToolbarManager_Base enum ExecuteCommand { EXEC_CMD_CLOSETOOLBAR, + EXEC_CMD_UNDOCKTOOLBAR, EXEC_CMD_DOCKTOOLBAR, EXEC_CMD_DOCKALLTOOLBARS }; diff --git a/framework/source/uielement/toolbarmanager.cxx b/framework/source/uielement/toolbarmanager.cxx index 78a5c1198584..d224cfc2a955 100644 --- a/framework/source/uielement/toolbarmanager.cxx +++ b/framework/source/uielement/toolbarmanager.cxx @@ -1447,8 +1447,22 @@ void ToolBarManager::AddCustomizeMenuItems(ToolBox const * pToolBar) nGroupLen = pMenu->GetItemCount(); } - if (MenuItemAllowed(MENUITEM_TOOLBAR_DOCKTOOLBAR)) - pMenu->InsertItem(MENUITEM_TOOLBAR_DOCKTOOLBAR, FwkResId(STR_TOOLBAR_DOCK_TOOLBAR)); + if (pToolBar->IsFloatingMode()) + { + if (MenuItemAllowed(MENUITEM_TOOLBAR_DOCKTOOLBAR)) + { + pMenu->InsertItem(MENUITEM_TOOLBAR_DOCKTOOLBAR, FwkResId(STR_TOOLBAR_DOCK_TOOLBAR)); + pMenu->SetAccelKey(MENUITEM_TOOLBAR_DOCKTOOLBAR, vcl::KeyCode(KEY_F10, true, true, false, false)); + } + } + else + { + if (MenuItemAllowed(MENUITEM_TOOLBAR_UNDOCKTOOLBAR)) + { + pMenu->InsertItem(MENUITEM_TOOLBAR_UNDOCKTOOLBAR, FwkResId(STR_TOOLBAR_UNDOCK_TOOLBAR)); + pMenu->SetAccelKey(MENUITEM_TOOLBAR_UNDOCKTOOLBAR, vcl::KeyCode(KEY_F10, true, true, false, false)); + } + } if (MenuItemAllowed(MENUITEM_TOOLBAR_DOCKALLTOOLBAR)) pMenu->InsertItem(MENUITEM_TOOLBAR_DOCKALLTOOLBAR, FwkResId(STR_TOOLBAR_DOCK_ALL_TOOLBARS)); @@ -1475,7 +1489,6 @@ void ToolBarManager::AddCustomizeMenuItems(ToolBox const * pToolBar) if ( !bIsFloating ) { - pMenu->EnableItem(MENUITEM_TOOLBAR_DOCKTOOLBAR, false); pMenu->EnableItem(MENUITEM_TOOLBAR_DOCKALLTOOLBAR, false); Reference< XDockableWindow > xDockable( VCLUnoHelper::GetInterface( m_pToolBar ), UNO_QUERY ); if( xDockable.is() ) @@ -1647,6 +1660,18 @@ IMPL_LINK( ToolBarManager, MenuSelect, Menu*, pMenu, bool ) break; } + case MENUITEM_TOOLBAR_UNDOCKTOOLBAR: + { + ExecuteInfo* pExecuteInfo = new ExecuteInfo; + + pExecuteInfo->aToolbarResName = m_aResourceName; + pExecuteInfo->nCmd = EXEC_CMD_UNDOCKTOOLBAR; + pExecuteInfo->xLayoutManager = getLayoutManagerFromFrame( m_xFrame ); + + Application::PostUserEvent( LINK(nullptr, ToolBarManager, ExecuteHdl_Impl), pExecuteInfo ); + break; + } + case MENUITEM_TOOLBAR_DOCKTOOLBAR: { ExecuteInfo* pExecuteInfo = new ExecuteInfo; @@ -1883,6 +1908,11 @@ IMPL_STATIC_LINK( ToolBarManager, ExecuteHdl_Impl, void*, p, void ) if ( pDockWin ) pDockWin->Close(); } + else if (( pExecuteInfo->nCmd == EXEC_CMD_UNDOCKTOOLBAR ) && + ( pExecuteInfo->xLayoutManager.is() )) + { + pExecuteInfo->xLayoutManager->floatWindow( pExecuteInfo->aToolbarResName ); + } else if (( pExecuteInfo->nCmd == EXEC_CMD_DOCKTOOLBAR ) && ( pExecuteInfo->xLayoutManager.is() )) {