From dabb20ebd5fa3b0d4bdb063b32f6ffbe2f59c3a2 Mon Sep 17 00:00:00 2001 From: Szymon Kłos Date: Sat, 6 Aug 2016 23:31:18 +0200 Subject: GSoC: tdf#101249 Toolbar Mode switching + added registry entry for storing current toolbar mode for each application + registry entries to store toolbar mode configuration, remember additional visible toolbars activated by user + changing toolbar mode hides and shows suitable toolbars + added menu controller for toolbar mode + notebookbar implementation entries are disabled when notebookbar mode is not active + each mode can open/collapse the sidebar Change-Id: I2b03f87c6dce53190d12102892d9ad30fbfd3bf6 Reviewed-on: https://gerrit.libreoffice.org/27991 Reviewed-by: Samuel Mehrbrodt Tested-by: Samuel Mehrbrodt --- framework/Library_fwl.mk | 1 + framework/inc/services.h | 1 + .../inc/uielement/toolbarmodemenucontroller.hxx | 86 ++++++ framework/source/register/registertemp.cxx | 2 + .../source/uielement/notebookbarmenucontroller.cxx | 42 ++- .../source/uielement/toolbarmodemenucontroller.cxx | 325 +++++++++++++++++++++ framework/util/fwl.component | 3 + include/sfx2/notebookbar/SfxNotebookBar.hxx | 6 +- include/sfx2/sfxsids.hrc | 3 +- include/sfx2/sidebar/SidebarController.hxx | 3 + officecfg/Configuration_officecfg.mk | 1 + officecfg/files.mk | 1 + .../data/org/openoffice/Office/UI/Controller.xcu | 11 + .../org/openoffice/Office/UI/GenericCommands.xcu | 5 + .../data/org/openoffice/Office/UI/Notebookbar.xcu | 10 +- .../data/org/openoffice/Office/UI/ToolbarMode.xcu | 288 ++++++++++++++++++ .../org/openoffice/Office/UI/ToolbarMode.xcs | 93 ++++++ postprocess/CustomTarget_registry.mk | 2 + sc/source/ui/docshell/docsh4.cxx | 16 +- sc/uiconfig/scalc/menubar/menubar.xml | 2 + sd/source/ui/docshell/docshel3.cxx | 10 +- sd/source/ui/docshell/docshell.cxx | 4 +- sd/uiconfig/simpress/menubar/menubar.xml | 2 + sfx2/sdi/appslots.sdi | 5 + sfx2/sdi/sfx.sdi | 16 + sfx2/source/appl/appserv.cxx | 242 +++++++++++++++ sfx2/source/notebookbar/SfxNotebookBar.cxx | 92 +++++- sfx2/source/sidebar/SidebarController.cxx | 12 + sw/source/uibase/app/docsh.cxx | 4 +- sw/source/uibase/app/docsh2.cxx | 8 +- sw/uiconfig/swriter/menubar/menubar.xml | 2 + 31 files changed, 1247 insertions(+), 51 deletions(-) create mode 100644 framework/inc/uielement/toolbarmodemenucontroller.hxx create mode 100644 framework/source/uielement/toolbarmodemenucontroller.cxx create mode 100644 officecfg/registry/data/org/openoffice/Office/UI/ToolbarMode.xcu create mode 100644 officecfg/registry/schema/org/openoffice/Office/UI/ToolbarMode.xcs diff --git a/framework/Library_fwl.mk b/framework/Library_fwl.mk index 33edfbc86603..44781e32977f 100644 --- a/framework/Library_fwl.mk +++ b/framework/Library_fwl.mk @@ -70,6 +70,7 @@ $(eval $(call gb_Library_add_exception_objects,fwl,\ framework/source/uielement/langselectionmenucontroller \ framework/source/uielement/macrosmenucontroller \ framework/source/uielement/newmenucontroller \ + framework/source/uielement/toolbarmodemenucontroller \ framework/source/uielement/toolbarsmenucontroller \ framework/source/uielement/notebookbarmenucontroller \ )) diff --git a/framework/inc/services.h b/framework/inc/services.h index c4a87babc92a..7e1166d81907 100644 --- a/framework/inc/services.h +++ b/framework/inc/services.h @@ -51,6 +51,7 @@ namespace framework{ #define IMPLEMENTATIONNAME_HEADERMENUCONTROLLER "com.sun.star.comp.framework.HeaderMenuController" #define IMPLEMENTATIONNAME_FOOTERMENUCONTROLLER "com.sun.star.comp.framework.FooterMenuController" #define IMPLEMENTATIONNAME_NEWMENUCONTROLLER "com.sun.star.comp.framework.NewMenuController" +#define IMPLEMENTATIONNAME_TOOLBARMODEMENUCONTROLLER "com.sun.star.comp.framework.ToolbarModeMenuController" #define IMPLEMENTATIONNAME_TOOLBARSMENUCONTROLLER "com.sun.star.comp.framework.ToolBarsMenuController" #define IMPLEMENTATIONNAME_NOTEBOOKBARMENUCONTROLLER "com.sun.star.comp.framework.NotebookbarMenuController" #define IMPLEMENTATIONNAME_HELPONSTARTUP "com.sun.star.comp.framework.HelpOnStartup" diff --git a/framework/inc/uielement/toolbarmodemenucontroller.hxx b/framework/inc/uielement/toolbarmodemenucontroller.hxx new file mode 100644 index 000000000000..6f084b733010 --- /dev/null +++ b/framework/inc/uielement/toolbarmodemenucontroller.hxx @@ -0,0 +1,86 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_UIELEMENT_TOOLBARMODEMENUCONTROLLER_HXX +#define INCLUDED_FRAMEWORK_INC_UIELEMENT_TOOLBARMODEMENUCONTROLLER_HXX + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include + +namespace framework +{ + class ToolbarModeMenuController : public svt::PopupMenuControllerBase + { + using svt::PopupMenuControllerBase::disposing; + + public: + ToolbarModeMenuController( const css::uno::Reference< css::uno::XComponentContext >& xContext ); + virtual ~ToolbarModeMenuController(); + + // XServiceInfo + DECLARE_XSERVICEINFO + + // XPopupMenuController + virtual void SAL_CALL setPopupMenu( const css::uno::Reference< css::awt::XPopupMenu >& PopupMenu ) throw (css::uno::RuntimeException, std::exception) override; + + // XStatusListener + virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& Event ) throw ( css::uno::RuntimeException, std::exception ) override; + + // XMenuListener + virtual void SAL_CALL itemSelected( const css::awt::MenuEvent& rEvent ) throw (css::uno::RuntimeException, std::exception) override; + virtual void SAL_CALL itemActivated( const css::awt::MenuEvent& rEvent ) throw (css::uno::RuntimeException, std::exception) override; + + // XEventListener + virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) throw ( css::uno::RuntimeException, std::exception ) override; + + struct ExecuteInfo + { + css::uno::Reference< css::frame::XDispatch > xDispatch; + css::util::URL aTargetURL; + css::uno::Sequence< css::beans::PropertyValue > aArgs; + }; + + DECL_STATIC_LINK_TYPED( ToolbarModeMenuController, ExecuteHdl_Impl, void*, void ); + + private: + void fillPopupMenu( css::uno::Reference< css::awt::XPopupMenu >& rPopupMenu ); + + css::uno::Reference< css::uno::XComponentContext > m_xContext; + }; +} + +#endif // INCLUDED_FRAMEWORK_INC_UIELEMENT_TOOLBARMODEMENUCONTROLLER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/source/register/registertemp.cxx b/framework/source/register/registertemp.cxx index fb6bdabca78b..80ca3da5ac77 100644 --- a/framework/source/register/registertemp.cxx +++ b/framework/source/register/registertemp.cxx @@ -49,6 +49,7 @@ #include #include #include +#include #include #include @@ -61,6 +62,7 @@ COMPONENTGETFACTORY ( fwl, IFFACTORY( ::framework::DispatchDisabler ) else IFFACTORY( ::framework::DispatchRecorder ) else IFFACTORY( ::framework::DispatchRecorderSupplier ) else + IFFACTORY( ::framework::ToolbarModeMenuController ) else IFFACTORY( ::framework::ToolbarsMenuController ) else IFFACTORY( ::framework::NotebookbarMenuController ) else IFFACTORY( ::framework::FontMenuController ) else diff --git a/framework/source/uielement/notebookbarmenucontroller.cxx b/framework/source/uielement/notebookbarmenucontroller.cxx index 1c08b6e2b2eb..c5de77f306b5 100644 --- a/framework/source/uielement/notebookbarmenucontroller.cxx +++ b/framework/source/uielement/notebookbarmenucontroller.cxx @@ -30,6 +30,9 @@ #include #include #include +#include +#include +#include #include #include @@ -199,9 +202,7 @@ void SAL_CALL NotebookbarMenuController::itemSelected( const css::awt::MenuEvent OUStringBuffer aBuf(".uno:Notebookbar?File:string="); aBuf.append( aCmd ); aTargetURL.Complete = aBuf.makeStringAndClear(); - std::shared_ptr batch( comphelper::ConfigurationChanges::create( m_xContext ) ); - officecfg::Office::UI::Notebookbar::Active::set( aCmd, batch ); - batch->commit(); + xURLTransformer->parseStrict( aTargetURL ); Reference< XDispatchProvider > xDispatchProvider( m_xFrame, UNO_QUERY ); if ( xDispatchProvider.is() ) @@ -223,8 +224,43 @@ void SAL_CALL NotebookbarMenuController::itemActivated( const css::awt::MenuEven { OUString aActive = officecfg::Office::UI::Notebookbar::Active::get( m_xContext ); + const Reference xModuleManager = frame::ModuleManager::create( m_xContext ); + vcl::EnumContext::Application eApp = vcl::EnumContext::GetApplicationEnum(xModuleManager->identify(m_xFrame)); + + OUStringBuffer aPath("org.openoffice.Office.UI.ToolbarMode/Applications/"); + switch ( eApp ) + { + case vcl::EnumContext::Application::Application_Writer: + aPath.append("Writer"); + break; + case vcl::EnumContext::Application::Application_Calc: + aPath.append("Calc"); + break; + case vcl::EnumContext::Application::Application_Impress: + aPath.append("Impress"); + break; + case vcl::EnumContext::Application::Application_Draw: + aPath.append("Draw"); + break; + default: + break; + } + + const utl::OConfigurationTreeRoot aModesNode( + m_xContext, + aPath.makeStringAndClear(), + false); + if ( !aModesNode.isValid() ) + return; + + // Entries are enabled only when Notebookbar mode is active + bool bActive = ( comphelper::getString( aModesNode.getNodeValue( "Active" ) ).compareTo("Notebookbar") == 0 ); + for ( int i = 0; i < m_xPopupMenu->getItemCount(); ++i ) + { m_xPopupMenu->checkItem( i+1, ( aActive.compareTo( m_xPopupMenu->getCommand( i+1 ) ) == 0 ) ); + m_xPopupMenu->enableItem( i+1, bActive ); + } } // XPopupMenuController diff --git a/framework/source/uielement/toolbarmodemenucontroller.cxx b/framework/source/uielement/toolbarmodemenucontroller.cxx new file mode 100644 index 000000000000..b39fa3b7877b --- /dev/null +++ b/framework/source/uielement/toolbarmodemenucontroller.cxx @@ -0,0 +1,325 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include + +#include "services.h" +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// Defines + +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::frame; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::util; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::ui; + +namespace framework +{ + +DEFINE_XSERVICEINFO_MULTISERVICE_2 ( ToolbarModeMenuController , + OWeakObject , + SERVICENAME_POPUPMENUCONTROLLER , + IMPLEMENTATIONNAME_TOOLBARMODEMENUCONTROLLER + ) + +DEFINE_INIT_SERVICE ( ToolbarModeMenuController, {} ) + +ToolbarModeMenuController::ToolbarModeMenuController( const css::uno::Reference< css::uno::XComponentContext >& xContext ) : + svt::PopupMenuControllerBase( xContext ), + m_xContext( xContext ) +{ +} + +ToolbarModeMenuController::~ToolbarModeMenuController() +{ +} + +void ToolbarModeMenuController::fillPopupMenu( Reference< css::awt::XPopupMenu >& rPopupMenu ) +{ + if ( SvtMiscOptions().DisableUICustomization() ) + return; + + SolarMutexGuard aSolarMutexGuard; + resetPopupMenu( rPopupMenu ); + + const Reference xContext (::comphelper::getProcessComponentContext() ); + const Reference xModuleManager = frame::ModuleManager::create( xContext ); + vcl::EnumContext::Application eApp = vcl::EnumContext::GetApplicationEnum(xModuleManager->identify(m_xFrame)); + + OUStringBuffer aPath("org.openoffice.Office.UI.ToolbarMode/Applications/"); + switch ( eApp ) + { + case vcl::EnumContext::Application::Application_Writer: + aPath.append("Writer"); + break; + case vcl::EnumContext::Application::Application_Calc: + aPath.append("Calc"); + break; + case vcl::EnumContext::Application::Application_Impress: + aPath.append("Impress"); + break; + case vcl::EnumContext::Application::Application_Draw: + aPath.append("Draw"); + break; + default: + break; + } + aPath.append("/Modes"); + + const utl::OConfigurationTreeRoot aModesNode( + m_xContext, + aPath.makeStringAndClear(), + false); + if ( !aModesNode.isValid() ) + return; + + const Sequence aModeNodeNames (aModesNode.getNodeNames()); + const sal_Int32 nCount(aModeNodeNames.getLength()); + + for ( sal_Int32 nReadIndex = 0; nReadIndex < nCount; ++nReadIndex ) + { + const utl::OConfigurationNode aModeNode(aModesNode.openNode(aModeNodeNames[nReadIndex])); + if ( !aModeNode.isValid() ) + continue; + + OUString aLabel = comphelper::getString( aModeNode.getNodeValue( "Label" ) ); + OUString aCommandArg = comphelper::getString( aModeNode.getNodeValue( "CommandArg" ) ); + long nPosition = comphelper::getINT32( aModeNode.getNodeValue( "MenuPosition" ) ); + + m_xPopupMenu->insertItem( nReadIndex+1, aLabel, css::awt::MenuItemStyle::RADIOCHECK, nPosition ); + rPopupMenu->setCommand( nReadIndex+1, aCommandArg ); + } +} + +// XEventListener +void SAL_CALL ToolbarModeMenuController::disposing( const EventObject& ) throw ( RuntimeException, std::exception ) +{ + Reference< css::awt::XMenuListener > xHolder(static_cast(this), UNO_QUERY ); + + osl::MutexGuard aLock( m_aMutex ); + m_xFrame.clear(); + m_xDispatch.clear(); + + if ( m_xPopupMenu.is() ) + m_xPopupMenu->removeMenuListener( Reference< css::awt::XMenuListener >(static_cast(this), UNO_QUERY )); + m_xPopupMenu.clear(); +} + +// XStatusListener +void SAL_CALL ToolbarModeMenuController::statusChanged( const FeatureStateEvent& Event ) throw ( RuntimeException, std::exception ) +{ + OUString aFeatureURL( Event.FeatureURL.Complete ); + + // All other status events will be processed here + osl::ClearableMutexGuard aLock( m_aMutex ); + Reference< css::awt::XPopupMenu > xPopupMenu( m_xPopupMenu ); + aLock.clear(); + + if ( xPopupMenu.is() ) + { + SolarMutexGuard aGuard; + VCLXPopupMenu* pXPopupMenu = static_cast(VCLXMenu::GetImplementation( xPopupMenu )); + PopupMenu* pVCLPopupMenu = pXPopupMenu ? static_cast(pXPopupMenu->GetMenu()) : nullptr; + + SAL_WARN_IF(!pVCLPopupMenu, "fwk.uielement", "worrying lack of popup menu"); + if (!pVCLPopupMenu) + return; + + bool bSetCheckmark = false; + bool bCheckmark = false; + for ( sal_uInt16 i = 0; i < pVCLPopupMenu->GetItemCount(); i++ ) + { + sal_uInt16 nId = pVCLPopupMenu->GetItemId( i ); + if ( nId == 0 ) + continue; + + OUString aCmd = pVCLPopupMenu->GetItemCommand( nId ); + if ( aCmd == aFeatureURL ) + { + // Enable/disable item + pVCLPopupMenu->EnableItem( nId, Event.IsEnabled ); + + // Checkmark + if ( Event.State >>= bCheckmark ) + bSetCheckmark = true; + + if ( bSetCheckmark ) + pVCLPopupMenu->CheckItem( nId, bCheckmark ); + else + { + OUString aItemText; + + if ( Event.State >>= aItemText ) + pVCLPopupMenu->SetItemText( nId, aItemText ); + } + } + } + } +} + +// XMenuListener +void SAL_CALL ToolbarModeMenuController::itemSelected( const css::awt::MenuEvent& rEvent ) throw (RuntimeException, std::exception) +{ + Reference< css::awt::XPopupMenu > xPopupMenu; + Reference< XURLTransformer > xURLTransformer; + Reference< XFrame > xFrame; + Reference< XNameAccess > xPersistentWindowState; + + osl::ClearableMutexGuard aLock( m_aMutex ); + xPopupMenu = m_xPopupMenu; + xURLTransformer = m_xURLTransformer; + xFrame = m_xFrame; + aLock.clear(); + + if ( xPopupMenu.is() ) + { + VCLXPopupMenu* pPopupMenu = static_cast(VCLXPopupMenu::GetImplementation( xPopupMenu )); + if ( pPopupMenu ) + { + SolarMutexGuard aSolarMutexGuard; + PopupMenu* pVCLPopupMenu = static_cast(pPopupMenu->GetMenu()); + + OUString aCmd( pVCLPopupMenu->GetItemCommand( rEvent.MenuId )); + OUStringBuffer aBuf(".uno:ToolbarMode?Mode:string="); + aBuf.append( aCmd ); + URL aTargetURL; + Sequence aArgs; + + aTargetURL.Complete = aBuf.makeStringAndClear(); + xURLTransformer->parseStrict( aTargetURL ); + Reference< XDispatchProvider > xDispatchProvider( m_xFrame, UNO_QUERY ); + if ( xDispatchProvider.is() ) + { + Reference< XDispatch > xDispatch = xDispatchProvider->queryDispatch( + aTargetURL, OUString(), 0 ); + + ExecuteInfo* pExecuteInfo = new ExecuteInfo; + pExecuteInfo->xDispatch = xDispatch; + pExecuteInfo->aTargetURL = aTargetURL; + pExecuteInfo->aArgs = aArgs; + Application::PostUserEvent( LINK(nullptr, ToolbarModeMenuController, ExecuteHdl_Impl), pExecuteInfo ); + } + } + } +} + +void SAL_CALL ToolbarModeMenuController::itemActivated( const css::awt::MenuEvent& ) throw (RuntimeException, std::exception) +{ + const Reference xModuleManager = frame::ModuleManager::create( m_xContext ); + vcl::EnumContext::Application eApp = vcl::EnumContext::GetApplicationEnum(xModuleManager->identify(m_xFrame)); + + OUStringBuffer aPath("org.openoffice.Office.UI.ToolbarMode/Applications/"); + switch ( eApp ) + { + case vcl::EnumContext::Application::Application_Writer: + aPath.append("Writer"); + break; + case vcl::EnumContext::Application::Application_Calc: + aPath.append("Calc"); + break; + case vcl::EnumContext::Application::Application_Impress: + aPath.append("Impress"); + break; + case vcl::EnumContext::Application::Application_Draw: + aPath.append("Draw"); + break; + default: + break; + } + + const utl::OConfigurationTreeRoot aModesNode( + m_xContext, + aPath.makeStringAndClear(), + false); + if ( !aModesNode.isValid() ) + return; + + OUString aMode = comphelper::getString( aModesNode.getNodeValue( "Active" ) ); + + for ( int i = 0; i < m_xPopupMenu->getItemCount(); ++i ) + m_xPopupMenu->checkItem( i+1, (aMode.compareTo( m_xPopupMenu->getCommand( i+1 ) ) == 0) ); +} + +// XPopupMenuController +void SAL_CALL ToolbarModeMenuController::setPopupMenu( const Reference< css::awt::XPopupMenu >& xPopupMenu ) throw ( RuntimeException, std::exception ) +{ + osl::MutexGuard aLock( m_aMutex ); + + throwIfDisposed(); + + if ( m_xFrame.is() && !m_xPopupMenu.is() ) + { + // Create popup menu on demand + SolarMutexGuard aSolarMutexGuard; + + m_xPopupMenu = xPopupMenu; + m_xPopupMenu->addMenuListener( Reference< css::awt::XMenuListener >( static_cast(this), UNO_QUERY )); + fillPopupMenu( m_xPopupMenu ); + } +} + +IMPL_STATIC_LINK_TYPED( ToolbarModeMenuController, ExecuteHdl_Impl, void*, p, void ) +{ + ExecuteInfo* pExecuteInfo = static_cast(p); + try + { + // Asynchronous execution as this can lead to our own destruction! + // Framework can recycle our current frame and the layout manager disposes all user interface + // elements if a component gets detached from its frame! + if ( pExecuteInfo->xDispatch.is() ) + { + pExecuteInfo->xDispatch->dispatch( pExecuteInfo->aTargetURL, pExecuteInfo->aArgs ); + } + } + catch ( const Exception& ) + { + } + + delete pExecuteInfo; +} + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/util/fwl.component b/framework/util/fwl.component index 7e8fa1b140e7..b7a56dc96f7a 100644 --- a/framework/util/fwl.component +++ b/framework/util/fwl.component @@ -61,6 +61,9 @@ + + + diff --git a/include/sfx2/notebookbar/SfxNotebookBar.hxx b/include/sfx2/notebookbar/SfxNotebookBar.hxx index 939dac3ea051..67ee405fb355 100644 --- a/include/sfx2/notebookbar/SfxNotebookBar.hxx +++ b/include/sfx2/notebookbar/SfxNotebookBar.hxx @@ -29,11 +29,11 @@ public: static bool IsActive(); /// Function to be called from the sdi's ExecMethod. - static void ExecMethod(SfxBindings& rBindings); + static void ExecMethod(SfxBindings& rBindings, const OUString& rUIName); /// Function to be called from the sdi's StateMethod. - static void StateMethod(SfxBindings& rBindings, const OUString& rUIFile); - static void StateMethod(SystemWindow* pSysWindow, + static bool StateMethod(SfxBindings& rBindings, const OUString& rUIFile); + static bool StateMethod(SystemWindow* pSysWindow, const css::uno::Reference & xFrame, const OUString& rUIFile); diff --git a/include/sfx2/sfxsids.hrc b/include/sfx2/sfxsids.hrc index fbbea370c1e7..249894298f99 100644 --- a/include/sfx2/sfxsids.hrc +++ b/include/sfx2/sfxsids.hrc @@ -251,8 +251,9 @@ #define SID_SHOWLINES (SID_SFX_START + 1725) #define SID_BLUETOOTH_SENDDOC (SID_SFX_START + 1726) #define SID_TEMPLATE_MANAGER (SID_SFX_START + 1727) +#define SID_TOOLBAR_MODE (SID_SFX_START + 1728) -// SID_SFX_free_START (SID_SFX_START + 1728) +// SID_SFX_free_START (SID_SFX_START + 1729) // SID_SFX_free_END (SID_SFX_START + 3999) #define SID_OPEN_NEW_VIEW (SID_SFX_START + 520) diff --git a/include/sfx2/sidebar/SidebarController.hxx b/include/sfx2/sidebar/SidebarController.hxx index 8eff2ae13055..8ff117f7d7cf 100644 --- a/include/sfx2/sidebar/SidebarController.hxx +++ b/include/sfx2/sidebar/SidebarController.hxx @@ -163,6 +163,9 @@ public: void disposeDecks(); + void FadeIn(); + void FadeOut(); + private: VclPtr mpCurrentDeck; diff --git a/officecfg/Configuration_officecfg.mk b/officecfg/Configuration_officecfg.mk index 388bf54fa393..195535002381 100644 --- a/officecfg/Configuration_officecfg.mk +++ b/officecfg/Configuration_officecfg.mk @@ -175,5 +175,6 @@ $(eval $(call gb_Configuration_add_localized_datas,registry,officecfg/registry/d org/openoffice/Office/UI/WriterWebWindowState.xcu \ org/openoffice/Office/UI/WriterCommands.xcu \ org/openoffice/Office/UI/GenericCategories.xcu \ + org/openoffice/Office/UI/ToolbarMode.xcu \ )) diff --git a/officecfg/files.mk b/officecfg/files.mk index ed3f460cfe64..adbce6b1d7d8 100644 --- a/officecfg/files.mk +++ b/officecfg/files.mk @@ -86,6 +86,7 @@ officecfg_XCSFILES := \ Office/UI/Sidebar \ Office/UI/StartModuleCommands \ Office/UI/StartModuleWindowState \ + Office/UI/ToolbarMode \ Office/UI/WindowContentFactories \ Office/UI/WindowState \ Office/UI/WriterCommands \ diff --git a/officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu b/officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu index 3f7a319fd646..096ed337bf1c 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu @@ -386,6 +386,17 @@ row_operations + + + .uno:ToolbarMode + + + + + + com.sun.star.comp.framework.ToolbarModeMenuController + + diff --git a/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu index 5723254436e6..0247b1769d16 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu @@ -5635,6 +5635,11 @@ ~Toolbars + + + Toolbar Layout + + ~Toolbars diff --git a/officecfg/registry/data/org/openoffice/Office/UI/Notebookbar.xcu b/officecfg/registry/data/org/openoffice/Office/UI/Notebookbar.xcu index 776dd9fdf545..3814b3e71e3c 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/Notebookbar.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/Notebookbar.xcu @@ -2,17 +2,9 @@ - + notebookbar.ui - - - Off - - - - - Tabbed diff --git a/officecfg/registry/data/org/openoffice/Office/UI/ToolbarMode.xcu b/officecfg/registry/data/org/openoffice/Office/UI/ToolbarMode.xcu new file mode 100644 index 000000000000..e9e8ddb6f98e --- /dev/null +++ b/officecfg/registry/data/org/openoffice/Office/UI/ToolbarMode.xcu @@ -0,0 +1,288 @@ + + + + + + + Default + + + + + Default + + + Default + + + 0 + + + false + + + + private:resource/toolbar/standardbar + private:resource/toolbar/textobjectbar + + + + + + + + Tabs + + + + + Single toolbar + + + Single + + + 1 + + + false + + + + private:resource/toolbar/singlemode + + + + + + + + Arrow + + + + + Sidebar + + + Sidebar + + + 2 + + + false + + + + private:resource/toolbar/standardbar + + + + + + + + Opened + + + + + Notebookbar + + + true + + + 3 + + + Notebookbar + + + + + + + + + + + Arrow + + + + + + + Default + + + + + Default + + + Default + + + 0 + + + false + + + + private:resource/toolbar/standardbar + private:resource/toolbar/formatobjectbar + + + + + + + + Tabs + + + + + Single toolbar + + + Single + + + 1 + + + false + + + + private:resource/toolbar/singlemode + + + + + + + + Arrow + + + + + Sidebar + + + Sidebar + + + 2 + + + false + + + + private:resource/toolbar/standardbar + + + + + + + + Opened + + + + + Notebookbar + + + true + + + 3 + + + Notebookbar + + + + + + + + + + + Arrow + + + + + + + Default + + + + + Default + + + Default + + + 0 + + + false + + + + private:resource/toolbar/standardbar + private:resource/toolbar/toolbar + private:resource/toolbar/commontaskbar + + + + + + + + Opened + + + + + Notebookbar + + + true + + + 3 + + + Notebookbar + + + + + + + + + + + Arrow + + + + + + diff --git a/officecfg/registry/schema/org/openoffice/Office/UI/ToolbarMode.xcs b/officecfg/registry/schema/org/openoffice/Office/UI/ToolbarMode.xcs new file mode 100644 index 000000000000..4a2a5adc6282 --- /dev/null +++ b/officecfg/registry/schema/org/openoffice/Office/UI/ToolbarMode.xcs @@ -0,0 +1,93 @@ + + + + + + Contains information about toolbar modes. + + + + + The container for mode description. + + + + The toolbar mode label. + + + + + The toolbar mode name to use as a parameter in the UNO command. Must be a single word. + + + + + Position in the menu. + + + + + Determines if Notebookbar is visible. + + + + + List of mandatory toolbars. + + + + + List of visible toolbars activated by user. + + + + + + Describes sidebar mode. + Arrow - sidebar coollapsed, showing the 'open' arrow button + Tabs - sidebar is showing only tab bars + Opened - sidebar fully opened + + + + + + + Describes toolbar modes for one application. + + + + Contains name of currently used mode. + + + + + Contains list of toolbar modes. + + + + + + + + Contains list of toolbar mode settings for each application. + + + + diff --git a/postprocess/CustomTarget_registry.mk b/postprocess/CustomTarget_registry.mk index ab04159b0322..b472323cf243 100644 --- a/postprocess/CustomTarget_registry.mk +++ b/postprocess/CustomTarget_registry.mk @@ -188,6 +188,7 @@ postprocess_FILES_main := \ $(postprocess_XCS)/Office/UI/Sidebar.xcs \ $(postprocess_XCS)/Office/UI/StartModuleCommands.xcs \ $(postprocess_XCS)/Office/UI/StartModuleWindowState.xcs \ + $(postprocess_XCS)/Office/UI/ToolbarMode.xcs \ $(postprocess_XCS)/Office/UI/WindowContentFactories.xcs \ $(postprocess_XCS)/Office/UI/WindowState.xcs \ $(postprocess_XCS)/Office/UI.xcs \ @@ -252,6 +253,7 @@ postprocess_FILES_main := \ $(postprocess_XCU)/Office/UI/Sidebar.xcu \ $(postprocess_XCU)/Office/UI/StartModuleCommands.xcu \ $(postprocess_XCU)/Office/UI/StartModuleWindowState.xcu \ + $(postprocess_XCU)/Office/UI/ToolbarMode.xcu \ $(postprocess_XCU)/Office/UI.xcu \ $(postprocess_XCU)/Office/Views.xcu \ $(postprocess_XCU)/Office/WebWizard.xcu \ diff --git a/sc/source/ui/docshell/docsh4.cxx b/sc/source/ui/docshell/docsh4.cxx index 8fcb604ca0dd..b9dff306376c 100644 --- a/sc/source/ui/docshell/docsh4.cxx +++ b/sc/source/ui/docshell/docsh4.cxx @@ -1099,14 +1099,10 @@ void ScDocShell::Execute( SfxRequest& rReq ) { const SfxStringItem* pFile = rReq.GetArg( SID_NOTEBOOKBAR ); - if ( pBindings && ( !pFile || ( pFile && !sfx2::SfxNotebookBar::IsActive() ) ) ) - sfx2::SfxNotebookBar::ExecMethod(*pBindings); - else if ( pBindings && pFile && pFile->GetValue().isEmpty() ) - { + if ( pBindings && sfx2::SfxNotebookBar::IsActive() ) + sfx2::SfxNotebookBar::ExecMethod(*pBindings, pFile ? pFile->GetValue() : ""); + else if ( pBindings ) sfx2::SfxNotebookBar::CloseMethod(*pBindings); - if ( sfx2::SfxNotebookBar::IsActive() ) - sfx2::SfxNotebookBar::ExecMethod(*pBindings); - } } break; default: @@ -1866,7 +1862,11 @@ void ScDocShell::GetState( SfxItemSet &rSet ) case SID_NOTEBOOKBAR: { if (GetViewBindings()) - sfx2::SfxNotebookBar::StateMethod(*GetViewBindings(), "modules/scalc/ui/"); + { + bool bVisible = sfx2::SfxNotebookBar::StateMethod(*GetViewBindings(), + "modules/scalc/ui/"); + rSet.Put( SfxBoolItem( SID_NOTEBOOKBAR, bVisible ) ); + } } break; diff --git a/sc/uiconfig/scalc/menubar/menubar.xml b/sc/uiconfig/scalc/menubar/menubar.xml index 3c42f20054be..eb2d383a2bda 100644 --- a/sc/uiconfig/scalc/menubar/menubar.xml +++ b/sc/uiconfig/scalc/menubar/menubar.xml @@ -132,7 +132,9 @@ + + diff --git a/sd/source/ui/docshell/docshel3.cxx b/sd/source/ui/docshell/docshel3.cxx index 056d59b44ff0..5aa32ba9f24e 100644 --- a/sd/source/ui/docshell/docshel3.cxx +++ b/sd/source/ui/docshell/docshel3.cxx @@ -326,14 +326,10 @@ void DrawDocShell::Execute( SfxRequest& rReq ) { SfxBindings& rBindings( mpViewShell->GetFrame()->GetBindings() ); - if ( !pFile || ( pFile && !sfx2::SfxNotebookBar::IsActive() ) ) - sfx2::SfxNotebookBar::ExecMethod( rBindings ); - else if ( pFile && pFile->GetValue().isEmpty() ) - { + if ( sfx2::SfxNotebookBar::IsActive() ) + sfx2::SfxNotebookBar::ExecMethod( rBindings, pFile ? pFile->GetValue() : "" ); + else sfx2::SfxNotebookBar::CloseMethod( rBindings ); - if ( sfx2::SfxNotebookBar::IsActive() ) - sfx2::SfxNotebookBar::ExecMethod( rBindings ); - } } } break; diff --git a/sd/source/ui/docshell/docshell.cxx b/sd/source/ui/docshell/docshell.cxx index fc54b20373bc..2cd6107d1b26 100644 --- a/sd/source/ui/docshell/docshell.cxx +++ b/sd/source/ui/docshell/docshell.cxx @@ -274,7 +274,9 @@ void DrawDocShell::GetState(SfxItemSet &rSet) case SID_NOTEBOOKBAR: { - sfx2::SfxNotebookBar::StateMethod(mpViewShell->GetFrame()->GetBindings(), "modules/simpress/ui/"); + bool bVisible = sfx2::SfxNotebookBar::StateMethod(mpViewShell->GetFrame()->GetBindings(), + "modules/simpress/ui/"); + rSet.Put( SfxBoolItem( SID_NOTEBOOKBAR, bVisible ) ); } break; diff --git a/sd/uiconfig/simpress/menubar/menubar.xml b/sd/uiconfig/simpress/menubar/menubar.xml index 15394f6948cb..20c52ccf0494 100644 --- a/sd/uiconfig/simpress/menubar/menubar.xml +++ b/sd/uiconfig/simpress/menubar/menubar.xml @@ -107,7 +107,9 @@ + + diff --git a/sfx2/sdi/appslots.sdi b/sfx2/sdi/appslots.sdi index 85191e6666fb..d103b962669a 100644 --- a/sfx2/sdi/appslots.sdi +++ b/sfx2/sdi/appslots.sdi @@ -166,6 +166,11 @@ interface Application SID_RECENTFILELIST [ ] + SID_TOOLBAR_MODE + [ + ExecMethod = MiscExec_Impl ; + StateMethod = MiscState_Impl ; + ] SID_AVAILABLE_TOOLBARS [ ExecMethod = MiscExec_Impl ; diff --git a/sfx2/sdi/sfx.sdi b/sfx2/sdi/sfx.sdi index b80b5fdde711..3afeb51b32d2 100644 --- a/sfx2/sdi/sfx.sdi +++ b/sfx2/sdi/sfx.sdi @@ -5401,6 +5401,22 @@ SfxVoidItem RecentFileList SID_RECENTFILELIST GroupId = GID_APPLICATION; ] +SfxVoidItem ToolbarMode SID_TOOLBAR_MODE +(SfxStringItem Mode SID_TOOLBAR_MODE) +[ + AutoUpdate = FALSE, + FastCall = FALSE, + ReadOnlyDoc = TRUE, + Toggle = FALSE, + Container = FALSE, + RecordAbsolute = FALSE, + RecordPerSet; + + AccelConfig = FALSE, + MenuConfig = TRUE, + ToolBoxConfig = FALSE, + GroupId = GID_APPLICATION; +] SfxVoidItem AvailableToolbars SID_AVAILABLE_TOOLBARS (SfxStringItem Toolbar SID_AVAILABLE_TOOLBARS) diff --git a/sfx2/source/appl/appserv.cxx b/sfx2/source/appl/appserv.cxx index 7a0d18a3f7ee..0014f059c469 100644 --- a/sfx2/source/appl/appserv.cxx +++ b/sfx2/source/appl/appserv.cxx @@ -38,6 +38,8 @@ #include #include #include +#include +#include #include #include #include @@ -70,9 +72,11 @@ #include #include #include +#include #include #include +#include #include #include #include @@ -118,8 +122,14 @@ #include #include #include +#include +#include +#include +#include #include +#include +#include #include #include @@ -133,9 +143,32 @@ using namespace ::com::sun::star::script; using namespace ::com::sun::star::system; using namespace ::com::sun::star::lang; using namespace ::com::sun::star::document; +using namespace ::com::sun::star::ui; namespace { + OUString lcl_getAppName( vcl::EnumContext::Application eApp ) + { + switch ( eApp ) + { + case vcl::EnumContext::Application::Application_Writer: + return OUString( "Writer" ); + break; + case vcl::EnumContext::Application::Application_Calc: + return OUString( "Calc" ); + break; + case vcl::EnumContext::Application::Application_Impress: + return OUString( "Impress" ); + break; + case vcl::EnumContext::Application::Application_Draw: + return OUString( "Draw" ); + break; + default: + return OUString( "" ); + break; + } + } + // lp#527938, debian#602953, fdo#33266, i#105408 bool lcl_isBaseAvailable() { @@ -652,6 +685,215 @@ void SfxApplication::MiscExec_Impl( SfxRequest& rReq ) break; } + case SID_TOOLBAR_MODE: + { + const SfxStringItem* pModeName = rReq.GetArg( SID_TOOLBAR_MODE ); + + if ( !pModeName ) + { + bDone = true; + break; + } + + OUString aNewName(pModeName->GetValue()); + uno::Reference< uno::XComponentContext > xContext = + ::comphelper::getProcessComponentContext(); + + Reference xDesktop = Desktop::create( xContext ); + Reference xFrame = xDesktop->getActiveFrame(); + + const Reference xModuleManager = frame::ModuleManager::create( xContext ); + vcl::EnumContext::Application eApp = vcl::EnumContext::GetApplicationEnum( xModuleManager->identify( xFrame ) ); + + OUStringBuffer aPath("org.openoffice.Office.UI.ToolbarMode/Applications/"); + aPath.append( lcl_getAppName(eApp) ); + + const utl::OConfigurationTreeRoot aAppNode( + xContext, + aPath.makeStringAndClear(), + true); + if ( !aAppNode.isValid() ) + { + bDone = true; + break; + } + + OUString aCurrentMode = comphelper::getString( aAppNode.getNodeValue( "Active" ) ); + + if ( aCurrentMode.compareTo( aNewName ) == 0 ) + { + bDone = true; + break; + } + + aAppNode.setNodeValue( "Active", makeAny( aNewName ) ); + aAppNode.commit(); + + Reference xPropSet( xFrame, UNO_QUERY ); + Reference xLayoutManager; + if ( xPropSet.is() ) + { + try + { + Any aValue = xPropSet->getPropertyValue( "LayoutManager" ); + aValue >>= xLayoutManager; + } + catch ( const css::uno::RuntimeException& ) + { + throw; + } + catch ( css::uno::Exception& ) + { + } + } + + if ( xLayoutManager.is() ) + { + css::uno::Sequence aMandatoryToolbars; + css::uno::Sequence aUserToolbars; + std::vector aBackupList; + OUString aSidebarMode; + bool bCorrectMode = true; + + aPath = OUStringBuffer("org.openoffice.Office.UI.ToolbarMode/Applications/"); + aPath.append( lcl_getAppName(eApp) ); + aPath.append( "/Modes" ); + + // Read mode settings + const utl::OConfigurationTreeRoot aModesNode( + xContext, + aPath.makeStringAndClear(), + true); + if ( !aModesNode.isValid() ) + { + bDone = true; + break; + } + + const Sequence aModeNodeNames( aModesNode.getNodeNames() ); + const sal_Int32 nCount( aModeNodeNames.getLength() ); + + for ( sal_Int32 nReadIndex = 0; nReadIndex < nCount; ++nReadIndex ) + { + const utl::OConfigurationNode aModeNode( aModesNode.openNode( aModeNodeNames[nReadIndex] ) ); + if ( !aModeNode.isValid() ) + continue; + + OUString aCommandArg = comphelper::getString( aModeNode.getNodeValue( "CommandArg" ) ); + + if ( aCommandArg.compareTo( aNewName ) == 0 ) + { + aMandatoryToolbars = aModeNode.getNodeValue( "Toolbars" ).get< uno::Sequence >(); + aUserToolbars = aModeNode.getNodeValue( "UserToolbars" ).get< uno::Sequence >(); + aSidebarMode = comphelper::getString( aModeNode.getNodeValue( "Sidebar" ) ); + break; + } + } + + if ( bCorrectMode ) + { + // Backup visible toolbar list and hide all toolbars + Sequence> aUIElements = xLayoutManager->getElements(); + for ( sal_Int32 i = 0; i < aUIElements.getLength(); i++ ) + { + Reference< XUIElement > xUIElement( aUIElements[i] ); + Reference< XPropertySet > xPropertySet( aUIElements[i], UNO_QUERY ); + if ( xPropertySet.is() && xUIElement.is() ) + { + try + { + OUString aResName; + sal_Int16 nType( -1 ); + xPropertySet->getPropertyValue( "Type" ) >>= nType; + xPropertySet->getPropertyValue( "ResourceURL" ) >>= aResName; + + if (( nType == css::ui::UIElementType::TOOLBAR ) && + !aResName.isEmpty() ) + { + if ( xLayoutManager->isElementVisible( aResName ) ) + aBackupList.push_back( aResName ); + xLayoutManager->hideElement( aResName ); + } + } + catch ( const Exception& ) + { + } + } + } + + // Show toolbars + for ( OUString& rName : aMandatoryToolbars ) + { + xLayoutManager->createElement( rName ); + xLayoutManager->showElement( rName ); + } + + for ( OUString& rName : aUserToolbars ) + { + xLayoutManager->createElement( rName ); + xLayoutManager->showElement( rName ); + } + + // Sidebar + if ( SfxViewFrame::Current() ) + SfxViewFrame::Current()->ShowChildWindow( SID_SIDEBAR ); + + sfx2::sidebar::SidebarController* pSidebar = + sfx2::sidebar::SidebarController::GetSidebarControllerForFrame( xFrame ); + if ( pSidebar ) + { + if ( aSidebarMode.compareTo( "Arrow" ) == 0 ) + { + pSidebar->FadeOut(); + } + else if ( aSidebarMode.compareTo( "Tabs" ) == 0 ) + { + pSidebar->FadeIn(); + pSidebar->RequestOpenDeck(); + pSidebar->RequestCloseDeck(); + } + else if ( aSidebarMode.compareTo( "Opened" ) == 0 ) + { + pSidebar->FadeIn(); + pSidebar->RequestOpenDeck(); + } + } + + // Show/Hide the Notebookbar + for ( SfxObjectShell *pObjSh = SfxObjectShell::GetFirst(); + pObjSh; + pObjSh = SfxObjectShell::GetNext( *pObjSh ) ) + { + const SfxPoolItem *pItem; + pObjSh->GetDispatcher()->QueryState(SID_NOTEBOOKBAR, pItem); + } + + // Save settings + css::uno::Sequence aBackup( aBackupList.size() ); + for ( size_t i = 0; i < aBackupList.size(); ++i ) + aBackup[i] = aBackupList[i]; + + for ( sal_Int32 nReadIndex = 0; nReadIndex < nCount; ++nReadIndex ) + { + const utl::OConfigurationNode aModeNode( aModesNode.openNode( aModeNodeNames[nReadIndex] ) ); + if ( !aModeNode.isValid() ) + continue; + + OUString aCommandArg = comphelper::getString( aModeNode.getNodeValue( "CommandArg" ) ); + + if ( aCommandArg.compareTo( aCurrentMode ) == 0 ) + { + aModeNode.setNodeValue( "UserToolbars", makeAny( aBackup ) ); + break; + } + } + aModesNode.commit(); + } + } + + bDone = true; + break; + } case SID_AVAILABLE_TOOLBARS: { const SfxStringItem* pToolbarName = rReq.GetArg(SID_AVAILABLE_TOOLBARS); diff --git a/sfx2/source/notebookbar/SfxNotebookBar.cxx b/sfx2/source/notebookbar/SfxNotebookBar.cxx index c20e35e865a8..64be63f50da0 100644 --- a/sfx2/source/notebookbar/SfxNotebookBar.cxx +++ b/sfx2/source/notebookbar/SfxNotebookBar.cxx @@ -22,10 +22,15 @@ #include #include "NotebookBarPopupMenu.hxx" #include +#include +#include +#include +#include using namespace sfx2; using namespace css::uno; using namespace css::ui; +using namespace css; #define MENUBAR_STR "private:resource/menubar/menubar" @@ -41,35 +46,94 @@ void SfxNotebookBar::CloseMethod(SfxBindings& rBindings) void SfxNotebookBar::CloseMethod(SystemWindow* pSysWindow) { - if (pSysWindow && pSysWindow->GetNotebookBar()) - pSysWindow->CloseNotebookBar(); + if (pSysWindow) + { + RemoveListeners(pSysWindow); + if(pSysWindow->GetNotebookBar()) + pSysWindow->CloseNotebookBar(); + } m_xLayoutManager.clear(); m_xFrame.clear(); } bool SfxNotebookBar::IsActive() { - SvtViewOptions aViewOpt(E_WINDOW, "notebookbar"); - return aViewOpt.IsVisible(); + const Reference xModuleManager = frame::ModuleManager::create( ::comphelper::getProcessComponentContext() ); + vcl::EnumContext::Application eApp = vcl::EnumContext::GetApplicationEnum(xModuleManager->identify(m_xFrame)); + + OUStringBuffer aPath("org.openoffice.Office.UI.ToolbarMode/Applications/"); + switch ( eApp ) + { + case vcl::EnumContext::Application::Application_Writer: + aPath.append("Writer"); + break; + case vcl::EnumContext::Application::Application_Calc: + aPath.append("Calc"); + break; + case vcl::EnumContext::Application::Application_Impress: + aPath.append("Impress"); + break; + case vcl::EnumContext::Application::Application_Draw: + aPath.append("Draw"); + break; + default: + break; + } + + const utl::OConfigurationTreeRoot aAppNode( + ::comphelper::getProcessComponentContext(), + aPath.makeStringAndClear(), + false); + if ( !aAppNode.isValid() ) + return false; + + OUString aActive = comphelper::getString( aAppNode.getNodeValue( "Active" ) ); + + const utl::OConfigurationNode aModesNode = aAppNode.openNode("Modes"); + const Sequence aModeNodeNames( aModesNode.getNodeNames() ); + const sal_Int32 nCount( aModeNodeNames.getLength() ); + bool bNotebookbarVisible = false; + + for ( sal_Int32 nReadIndex = 0; nReadIndex < nCount; ++nReadIndex ) + { + const utl::OConfigurationNode aModeNode( aModesNode.openNode( aModeNodeNames[nReadIndex] ) ); + if ( !aModeNode.isValid() ) + continue; + + OUString aCommandArg = comphelper::getString( aModeNode.getNodeValue( "CommandArg" ) ); + + if ( aCommandArg.compareTo( aActive ) == 0 ) + { + bNotebookbarVisible = comphelper::getBOOL( aModeNode.getNodeValue( "HasNotebookbar" ) ); + break; + } + } + return bNotebookbarVisible; } -void SfxNotebookBar::ExecMethod(SfxBindings& rBindings) +void SfxNotebookBar::ExecMethod(SfxBindings& rBindings, const OUString& rUIName) { - SvtViewOptions aViewOpt(E_WINDOW, "notebookbar"); - aViewOpt.SetVisible(!aViewOpt.IsVisible()); + // Save active UI file name + if ( !rUIName.isEmpty() ) + { + std::shared_ptr batch( + comphelper::ConfigurationChanges::create( ::comphelper::getProcessComponentContext() ) ); + officecfg::Office::UI::Notebookbar::Active::set( rUIName, batch ); + batch->commit(); + } // trigger the StateMethod rBindings.Invalidate(SID_NOTEBOOKBAR); rBindings.Update(); } -void SfxNotebookBar::StateMethod(SfxBindings& rBindings, const OUString& rUIFile) +bool SfxNotebookBar::StateMethod(SfxBindings& rBindings, const OUString& rUIFile) { SfxFrame& rFrame = rBindings.GetDispatcher_Impl()->GetFrame()->GetFrame(); - StateMethod(rFrame.GetSystemWindow(), rFrame.GetFrameInterface(), rUIFile); + return StateMethod(rFrame.GetSystemWindow(), rFrame.GetFrameInterface(), rUIFile); } -void SfxNotebookBar::StateMethod(SystemWindow* pSysWindow, +bool SfxNotebookBar::StateMethod(SystemWindow* pSysWindow, const Reference & xFrame, const OUString& rUIFile) { @@ -88,9 +152,7 @@ void SfxNotebookBar::StateMethod(SystemWindow* pSysWindow, } } - SvtViewOptions aViewOpt(E_WINDOW, "notebookbar"); - - if (aViewOpt.IsVisible()) + if (IsActive()) { RemoveListeners(pSysWindow); @@ -122,9 +184,13 @@ void SfxNotebookBar::StateMethod(SystemWindow* pSysWindow, } } } + + return true; } else if (auto pNotebookBar = pSysWindow->GetNotebookBar()) pNotebookBar->Hide(); + + return false; } void SfxNotebookBar::RemoveListeners(SystemWindow* pSysWindow) diff --git a/sfx2/source/sidebar/SidebarController.cxx b/sfx2/source/sidebar/SidebarController.cxx index e61cd8431f09..0aa352c1666f 100644 --- a/sfx2/source/sidebar/SidebarController.cxx +++ b/sfx2/source/sidebar/SidebarController.cxx @@ -1303,6 +1303,18 @@ void SidebarController::updateModel(const css::uno::ReferenceUpdateModel(xModel); } +void SidebarController::FadeOut() +{ + if (mpSplitWindow) + mpSplitWindow->FadeOut(); +} + +void SidebarController::FadeIn() +{ + if (mpSplitWindow) + mpSplitWindow->FadeIn(); +} + } } // end of namespace sfx2::sidebar diff --git a/sw/source/uibase/app/docsh.cxx b/sw/source/uibase/app/docsh.cxx index 03ea367f5c7c..c12ed6c5aeaa 100644 --- a/sw/source/uibase/app/docsh.cxx +++ b/sw/source/uibase/app/docsh.cxx @@ -1073,7 +1073,9 @@ void SwDocShell::GetState(SfxItemSet& rSet) case SID_NOTEBOOKBAR: { SfxViewShell* pViewShell = GetView()? GetView(): SfxViewShell::Current(); - sfx2::SfxNotebookBar::StateMethod(pViewShell->GetViewFrame()->GetBindings(), "modules/swriter/ui/"); + bool bVisible = sfx2::SfxNotebookBar::StateMethod(pViewShell->GetViewFrame()->GetBindings(), + "modules/swriter/ui/"); + rSet.Put( SfxBoolItem( SID_NOTEBOOKBAR, bVisible ) ); } break; diff --git a/sw/source/uibase/app/docsh2.cxx b/sw/source/uibase/app/docsh2.cxx index d49a09f41e0e..6f2249dfc9aa 100644 --- a/sw/source/uibase/app/docsh2.cxx +++ b/sw/source/uibase/app/docsh2.cxx @@ -1164,13 +1164,11 @@ void SwDocShell::Execute(SfxRequest& rReq) SfxViewShell* pViewShell = GetView()? GetView(): SfxViewShell::Current(); SfxBindings& rBindings( pViewShell->GetViewFrame()->GetBindings() ); - if ( !pFile || ( pFile && !SfxNotebookBar::IsActive() ) ) - sfx2::SfxNotebookBar::ExecMethod( rBindings ); - else if ( pFile && pFile->GetValue().isEmpty() ) + if ( SfxNotebookBar::IsActive() ) + sfx2::SfxNotebookBar::ExecMethod( rBindings, pFile ? pFile->GetValue() : "" ); + else { sfx2::SfxNotebookBar::CloseMethod( rBindings ); - if ( sfx2::SfxNotebookBar::IsActive() ) - sfx2::SfxNotebookBar::ExecMethod( rBindings ); } } break; diff --git a/sw/uiconfig/swriter/menubar/menubar.xml b/sw/uiconfig/swriter/menubar/menubar.xml index e29239fd0fd9..1c6da9018dc8 100644 --- a/sw/uiconfig/swriter/menubar/menubar.xml +++ b/sw/uiconfig/swriter/menubar/menubar.xml @@ -146,7 +146,9 @@ + + -- cgit