From af97c180983e5a8ac147b97f7773d483bba8cfef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Szymon=20K=C5=82os?= Date: Thu, 11 Aug 2016 13:53:20 +0200 Subject: [PATCH] GSoC notebookbar: multiple .ui implementations + added menu controller for .uno:Notebookbar showing all implementations + switching between .ui files + officecfg stores implementation description + added second implementation file notebookbar_groups.ui Change-Id: I9f406daced7a111793f61a2e9f939cba27d92184 Reviewed-on: https://gerrit.libreoffice.org/28067 Reviewed-by: Samuel Mehrbrodt Tested-by: Samuel Mehrbrodt --- framework/Library_fwl.mk | 2 + framework/inc/services.h | 1 + .../uielement/notebookbarmenucontroller.hxx | 86 ++++++ framework/source/register/registertemp.cxx | 2 + .../uielement/notebookbarmenucontroller.cxx | 270 ++++++++++++++++++ framework/util/fwl.component | 3 + include/sfx2/notebookbar/SfxNotebookBar.hxx | 2 + officecfg/Configuration_officecfg.mk | 1 + officecfg/files.mk | 1 + .../org/openoffice/Office/UI/Controller.xcu | 11 + .../org/openoffice/Office/UI/Notebookbar.xcu | 33 +++ .../org/openoffice/Office/UI/Notebookbar.xcs | 53 ++++ postprocess/CustomTarget_registry.mk | 2 + sc/UIConfig_scalc.mk | 1 + sc/source/ui/docshell/docsh4.cxx | 12 +- sc/uiconfig/scalc/ui/notebookbar_groups.ui | 133 +++++++++ sd/UIConfig_simpress.mk | 1 + sd/source/ui/docshell/docshel3.cxx | 17 +- sd/source/ui/docshell/docshell.cxx | 2 +- sd/uiconfig/simpress/ui/notebookbar_groups.ui | 133 +++++++++ sfx2/sdi/sfx.sdi | 1 + sfx2/source/notebookbar/SfxNotebookBar.cxx | 46 +-- sw/UIConfig_swriter.mk | 1 + sw/source/uibase/app/docsh.cxx | 2 +- sw/source/uibase/app/docsh2.cxx | 12 +- sw/uiconfig/swriter/ui/notebookbar_groups.ui | 133 +++++++++ 26 files changed, 938 insertions(+), 23 deletions(-) create mode 100644 framework/inc/uielement/notebookbarmenucontroller.hxx create mode 100644 framework/source/uielement/notebookbarmenucontroller.cxx create mode 100644 officecfg/registry/data/org/openoffice/Office/UI/Notebookbar.xcu create mode 100644 officecfg/registry/schema/org/openoffice/Office/UI/Notebookbar.xcs create mode 100644 sc/uiconfig/scalc/ui/notebookbar_groups.ui create mode 100644 sd/uiconfig/simpress/ui/notebookbar_groups.ui create mode 100644 sw/uiconfig/swriter/ui/notebookbar_groups.ui diff --git a/framework/Library_fwl.mk b/framework/Library_fwl.mk index f3729c4ea112..33edfbc86603 100644 --- a/framework/Library_fwl.mk +++ b/framework/Library_fwl.mk @@ -24,6 +24,7 @@ $(eval $(call gb_Library_set_componentfile,fwl,framework/util/fwl)) $(eval $(call gb_Library_set_include,fwl,\ -I$(SRCDIR)/framework/inc \ -I$(SRCDIR)/framework/source/inc \ + -I$(WORKDIR)/CustomTarget/officecfg/registry \ $$(INCLUDE) \ )) @@ -70,6 +71,7 @@ $(eval $(call gb_Library_add_exception_objects,fwl,\ framework/source/uielement/macrosmenucontroller \ framework/source/uielement/newmenucontroller \ framework/source/uielement/toolbarsmenucontroller \ + framework/source/uielement/notebookbarmenucontroller \ )) # vim: set noet sw=4 ts=4: diff --git a/framework/inc/services.h b/framework/inc/services.h index 92643375c526..c4a87babc92a 100644 --- a/framework/inc/services.h +++ b/framework/inc/services.h @@ -52,6 +52,7 @@ namespace framework{ #define IMPLEMENTATIONNAME_FOOTERMENUCONTROLLER "com.sun.star.comp.framework.FooterMenuController" #define IMPLEMENTATIONNAME_NEWMENUCONTROLLER "com.sun.star.comp.framework.NewMenuController" #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" #define IMPLEMENTATIONNAME_SHELLJOB "com.sun.star.comp.framework.ShellJob" #define IMPLEMENTATIONNAME_FWK_TASKCREATOR "com.sun.star.comp.framework.TaskCreator" diff --git a/framework/inc/uielement/notebookbarmenucontroller.hxx b/framework/inc/uielement/notebookbarmenucontroller.hxx new file mode 100644 index 000000000000..754933f5ec75 --- /dev/null +++ b/framework/inc/uielement/notebookbarmenucontroller.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_NOTEBOOKBARMENUCONTROLLER_HXX +#define INCLUDED_FRAMEWORK_INC_UIELEMENT_NOTEBOOKBARMENUCONTROLLER_HXX + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include + +namespace framework +{ + class NotebookbarMenuController : public svt::PopupMenuControllerBase + { + using svt::PopupMenuControllerBase::disposing; + + public: + NotebookbarMenuController( const css::uno::Reference< css::uno::XComponentContext >& xContext ); + virtual ~NotebookbarMenuController(); + + // 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( NotebookbarMenuController, 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_NOTEBOOKBARMENUCONTROLLER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/source/register/registertemp.cxx b/framework/source/register/registertemp.cxx index f6c28ef7dbab..fb6bdabca78b 100644 --- a/framework/source/register/registertemp.cxx +++ b/framework/source/register/registertemp.cxx @@ -50,6 +50,7 @@ #include #include #include +#include COMPONENTGETFACTORY ( fwl, IFFACTORY( ::framework::MediaTypeDetectionHelper ) @@ -61,6 +62,7 @@ COMPONENTGETFACTORY ( fwl, IFFACTORY( ::framework::DispatchRecorder ) else IFFACTORY( ::framework::DispatchRecorderSupplier ) else IFFACTORY( ::framework::ToolbarsMenuController ) else + IFFACTORY( ::framework::NotebookbarMenuController ) else IFFACTORY( ::framework::FontMenuController ) else IFFACTORY( ::framework::MacrosMenuController ) else IFFACTORY( ::framework::NewMenuController ) else diff --git a/framework/source/uielement/notebookbarmenucontroller.cxx b/framework/source/uielement/notebookbarmenucontroller.cxx new file mode 100644 index 000000000000..1c08b6e2b2eb --- /dev/null +++ b/framework/source/uielement/notebookbarmenucontroller.cxx @@ -0,0 +1,270 @@ +/* -*- 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 + +// 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 ( NotebookbarMenuController , + OWeakObject , + SERVICENAME_POPUPMENUCONTROLLER , + IMPLEMENTATIONNAME_NOTEBOOKBARMENUCONTROLLER + ) + +DEFINE_INIT_SERVICE ( NotebookbarMenuController, {} ) + +NotebookbarMenuController::NotebookbarMenuController( const css::uno::Reference< css::uno::XComponentContext >& xContext ) : + svt::PopupMenuControllerBase( xContext ), + m_xContext( xContext ) +{ +} + +NotebookbarMenuController::~NotebookbarMenuController() +{ +} + +void NotebookbarMenuController::fillPopupMenu( Reference< css::awt::XPopupMenu >& rPopupMenu ) +{ + if ( SvtMiscOptions().DisableUICustomization() ) + return; + + SolarMutexGuard aSolarMutexGuard; + resetPopupMenu( rPopupMenu ); + + const utl::OConfigurationTreeRoot aImplementationsNode( + m_xContext, + OUString("org.openoffice.Office.UI.Notebookbar/Implementations"), + false); + if ( !aImplementationsNode.isValid() ) + return; + + const Sequence aImplNodeNames (aImplementationsNode.getNodeNames()); + const sal_Int32 nCount(aImplNodeNames.getLength()); + + for ( sal_Int32 nReadIndex = 0; nReadIndex < nCount; ++nReadIndex ) + { + const utl::OConfigurationNode aImplNode(aImplementationsNode.openNode(aImplNodeNames[nReadIndex])); + if ( !aImplNode.isValid() ) + continue; + + OUString aLabel = comphelper::getString( aImplNode.getNodeValue( "Label" ) ); + OUString aFile = comphelper::getString( aImplNode.getNodeValue( "File" ) ); + m_xPopupMenu->insertItem( nReadIndex+1, aLabel, css::awt::MenuItemStyle::RADIOCHECK, m_xPopupMenu->getItemCount() ); + rPopupMenu->setCommand( nReadIndex+1, aFile ); + } +} + +// XEventListener +void SAL_CALL NotebookbarMenuController::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 NotebookbarMenuController::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 NotebookbarMenuController::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 )); + URL aTargetURL; + Sequence aArgs; + + 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() ) + { + 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, NotebookbarMenuController, ExecuteHdl_Impl), pExecuteInfo ); + } + } + } +} + +void SAL_CALL NotebookbarMenuController::itemActivated( const css::awt::MenuEvent& ) throw (RuntimeException, std::exception) +{ + OUString aActive = officecfg::Office::UI::Notebookbar::Active::get( m_xContext ); + + for ( int i = 0; i < m_xPopupMenu->getItemCount(); ++i ) + m_xPopupMenu->checkItem( i+1, ( aActive.compareTo( m_xPopupMenu->getCommand( i+1 ) ) == 0 ) ); +} + +// XPopupMenuController +void SAL_CALL NotebookbarMenuController::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( NotebookbarMenuController, 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 83e513c53b5f..7e8fa1b140e7 100644 --- a/framework/util/fwl.component +++ b/framework/util/fwl.component @@ -64,6 +64,9 @@ + + + diff --git a/include/sfx2/notebookbar/SfxNotebookBar.hxx b/include/sfx2/notebookbar/SfxNotebookBar.hxx index d3387a2e5338..939dac3ea051 100644 --- a/include/sfx2/notebookbar/SfxNotebookBar.hxx +++ b/include/sfx2/notebookbar/SfxNotebookBar.hxx @@ -26,6 +26,8 @@ public: static void CloseMethod(SfxBindings& rBindings); static void CloseMethod(SystemWindow* pSysWindow); + static bool IsActive(); + /// Function to be called from the sdi's ExecMethod. static void ExecMethod(SfxBindings& rBindings); diff --git a/officecfg/Configuration_officecfg.mk b/officecfg/Configuration_officecfg.mk index 01741a5efdb7..388bf54fa393 100644 --- a/officecfg/Configuration_officecfg.mk +++ b/officecfg/Configuration_officecfg.mk @@ -165,6 +165,7 @@ $(eval $(call gb_Configuration_add_localized_datas,registry,officecfg/registry/d org/openoffice/Office/UI/DrawWindowState.xcu \ org/openoffice/Office/UI/ImpressWindowState.xcu \ org/openoffice/Office/UI/MathWindowState.xcu \ + org/openoffice/Office/UI/Notebookbar.xcu \ org/openoffice/Office/UI/ReportCommands.xcu \ org/openoffice/Office/UI/Sidebar.xcu \ org/openoffice/Office/UI/StartModuleWindowState.xcu \ diff --git a/officecfg/files.mk b/officecfg/files.mk index 69d0cf1e0a9f..ed3f460cfe64 100644 --- a/officecfg/files.mk +++ b/officecfg/files.mk @@ -81,6 +81,7 @@ officecfg_XCSFILES := \ Office/UI/ImpressWindowState \ Office/UI/MathCommands \ Office/UI/MathWindowState \ + Office/UI/Notebookbar \ Office/UI/ReportCommands \ Office/UI/Sidebar \ Office/UI/StartModuleCommands \ diff --git a/officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu b/officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu index 0f7d229ed4d0..14f6fc649293 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu @@ -347,6 +347,17 @@ anchor + + + .uno:Notebookbar + + + + + + com.sun.star.comp.framework.NotebookbarMenuController + + diff --git a/officecfg/registry/data/org/openoffice/Office/UI/Notebookbar.xcu b/officecfg/registry/data/org/openoffice/Office/UI/Notebookbar.xcu new file mode 100644 index 000000000000..776dd9fdf545 --- /dev/null +++ b/officecfg/registry/data/org/openoffice/Office/UI/Notebookbar.xcu @@ -0,0 +1,33 @@ + + + + + + + + + + Off + + + + + + + + Tabbed + + + notebookbar.ui + + + + + Contextual groups + + + notebookbar_groups.ui + + + + diff --git a/officecfg/registry/schema/org/openoffice/Office/UI/Notebookbar.xcs b/officecfg/registry/schema/org/openoffice/Office/UI/Notebookbar.xcs new file mode 100644 index 000000000000..51dbeed451f6 --- /dev/null +++ b/officecfg/registry/schema/org/openoffice/Office/UI/Notebookbar.xcs @@ -0,0 +1,53 @@ + + + + + + Contains information about Notebookbar. + + + + + The implementation description container. + + + + The implementation name. + + + + + The .ui file name. + + + + + + + + Contains name of currently used implementation. + + + + + List of implementations. + + + + diff --git a/postprocess/CustomTarget_registry.mk b/postprocess/CustomTarget_registry.mk index 186522d43d24..ab04159b0322 100644 --- a/postprocess/CustomTarget_registry.mk +++ b/postprocess/CustomTarget_registry.mk @@ -184,6 +184,7 @@ postprocess_FILES_main := \ $(postprocess_XCS)/Office/UI/GenericCategories.xcs \ $(postprocess_XCS)/Office/UI/GenericCommands.xcs \ $(postprocess_XCS)/Office/UI/GlobalSettings.xcs \ + $(postprocess_XCS)/Office/UI/Notebookbar.xcs \ $(postprocess_XCS)/Office/UI/Sidebar.xcs \ $(postprocess_XCS)/Office/UI/StartModuleCommands.xcs \ $(postprocess_XCS)/Office/UI/StartModuleWindowState.xcs \ @@ -247,6 +248,7 @@ postprocess_FILES_main := \ $(postprocess_XCU)/Office/UI/Factories.xcu \ $(postprocess_XCU)/Office/UI/GenericCategories.xcu \ $(postprocess_XCU)/Office/UI/GenericCommands.xcu \ + $(postprocess_XCU)/Office/UI/Notebookbar.xcu \ $(postprocess_XCU)/Office/UI/Sidebar.xcu \ $(postprocess_XCU)/Office/UI/StartModuleCommands.xcu \ $(postprocess_XCU)/Office/UI/StartModuleWindowState.xcu \ diff --git a/sc/UIConfig_scalc.mk b/sc/UIConfig_scalc.mk index 7ab8cd4fbdfa..366eef035f34 100644 --- a/sc/UIConfig_scalc.mk +++ b/sc/UIConfig_scalc.mk @@ -139,6 +139,7 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/scalc,\ sc/uiconfig/scalc/ui/leftheaderdialog \ sc/uiconfig/scalc/ui/namerangesdialog \ sc/uiconfig/scalc/ui/notebookbar \ + sc/uiconfig/scalc/ui/notebookbar_groups \ sc/uiconfig/scalc/ui/managenamesdialog \ sc/uiconfig/scalc/ui/movecopysheet \ sc/uiconfig/scalc/ui/movingaveragedialog \ diff --git a/sc/source/ui/docshell/docsh4.cxx b/sc/source/ui/docshell/docsh4.cxx index 6ce6eae2e36d..8fcb604ca0dd 100644 --- a/sc/source/ui/docshell/docsh4.cxx +++ b/sc/source/ui/docshell/docsh4.cxx @@ -1097,8 +1097,16 @@ void ScDocShell::Execute( SfxRequest& rReq ) break; case SID_NOTEBOOKBAR: { - if (pBindings) + 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() ) + { + sfx2::SfxNotebookBar::CloseMethod(*pBindings); + if ( sfx2::SfxNotebookBar::IsActive() ) + sfx2::SfxNotebookBar::ExecMethod(*pBindings); + } } break; default: @@ -1858,7 +1866,7 @@ void ScDocShell::GetState( SfxItemSet &rSet ) case SID_NOTEBOOKBAR: { if (GetViewBindings()) - sfx2::SfxNotebookBar::StateMethod(*GetViewBindings(), "modules/scalc/ui/notebookbar.ui"); + sfx2::SfxNotebookBar::StateMethod(*GetViewBindings(), "modules/scalc/ui/"); } break; diff --git a/sc/uiconfig/scalc/ui/notebookbar_groups.ui b/sc/uiconfig/scalc/ui/notebookbar_groups.ui new file mode 100644 index 000000000000..0154978af690 --- /dev/null +++ b/sc/uiconfig/scalc/ui/notebookbar_groups.ui @@ -0,0 +1,133 @@ + + + + + + + + True + False + + + True + False + vertical + + + True + True + True + True + + + True + False + 6 + + + + + + + + + + + + + + + + + + + + + + + + True + False + + + + + + + False + True + 7 + + + + + + + True + False + File + True + + + False + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + False + True + 0 + + + + + 0 + 0 + + + + diff --git a/sd/UIConfig_simpress.mk b/sd/UIConfig_simpress.mk index dad22b214fb5..b71f7096766d 100644 --- a/sd/UIConfig_simpress.mk +++ b/sd/UIConfig_simpress.mk @@ -120,6 +120,7 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/simpress,\ sd/uiconfig/simpress/ui/interactionpage \ sd/uiconfig/simpress/ui/masterlayoutdlg \ sd/uiconfig/simpress/ui/notebookbar \ + sd/uiconfig/simpress/ui/notebookbar_groups \ sd/uiconfig/simpress/ui/optimpressgeneralpage \ sd/uiconfig/simpress/ui/photoalbum \ sd/uiconfig/simpress/ui/presentationdialog \ diff --git a/sd/source/ui/docshell/docshel3.cxx b/sd/source/ui/docshell/docshel3.cxx index 142e38184426..056d59b44ff0 100644 --- a/sd/source/ui/docshell/docshel3.cxx +++ b/sd/source/ui/docshell/docshel3.cxx @@ -320,8 +320,21 @@ void DrawDocShell::Execute( SfxRequest& rReq ) case SID_NOTEBOOKBAR: { - if (mpViewShell) - sfx2::SfxNotebookBar::ExecMethod(mpViewShell->GetFrame()->GetBindings()); + const SfxStringItem* pFile = rReq.GetArg( SID_NOTEBOOKBAR ); + + if ( mpViewShell ) + { + SfxBindings& rBindings( mpViewShell->GetFrame()->GetBindings() ); + + if ( !pFile || ( pFile && !sfx2::SfxNotebookBar::IsActive() ) ) + sfx2::SfxNotebookBar::ExecMethod( rBindings ); + else if ( pFile && pFile->GetValue().isEmpty() ) + { + 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 9a0698234420..fc54b20373bc 100644 --- a/sd/source/ui/docshell/docshell.cxx +++ b/sd/source/ui/docshell/docshell.cxx @@ -274,7 +274,7 @@ void DrawDocShell::GetState(SfxItemSet &rSet) case SID_NOTEBOOKBAR: { - sfx2::SfxNotebookBar::StateMethod(mpViewShell->GetFrame()->GetBindings(), "modules/simpress/ui/notebookbar.ui"); + sfx2::SfxNotebookBar::StateMethod(mpViewShell->GetFrame()->GetBindings(), "modules/simpress/ui/"); } break; diff --git a/sd/uiconfig/simpress/ui/notebookbar_groups.ui b/sd/uiconfig/simpress/ui/notebookbar_groups.ui new file mode 100644 index 000000000000..0154978af690 --- /dev/null +++ b/sd/uiconfig/simpress/ui/notebookbar_groups.ui @@ -0,0 +1,133 @@ + + + + + + + + True + False + + + True + False + vertical + + + True + True + True + True + + + True + False + 6 + + + + + + + + + + + + + + + + + + + + + + + + True + False + + + + + + + False + True + 7 + + + + + + + True + False + File + True + + + False + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + False + True + 0 + + + + + 0 + 0 + + + + diff --git a/sfx2/sdi/sfx.sdi b/sfx2/sdi/sfx.sdi index 023c84af7dd0..b80b5fdde711 100644 --- a/sfx2/sdi/sfx.sdi +++ b/sfx2/sdi/sfx.sdi @@ -2625,6 +2625,7 @@ SfxBoolItem Sidebar SID_SIDEBAR SfxBoolItem Notebookbar SID_NOTEBOOKBAR +(SfxStringItem File SID_NOTEBOOKBAR) [ AutoUpdate = TRUE, FastCall = FALSE, diff --git a/sfx2/source/notebookbar/SfxNotebookBar.cxx b/sfx2/source/notebookbar/SfxNotebookBar.cxx index ad8e7e5625cb..c20e35e865a8 100644 --- a/sfx2/source/notebookbar/SfxNotebookBar.cxx +++ b/sfx2/source/notebookbar/SfxNotebookBar.cxx @@ -21,6 +21,7 @@ #include #include #include "NotebookBarPopupMenu.hxx" +#include using namespace sfx2; using namespace css::uno; @@ -46,6 +47,12 @@ void SfxNotebookBar::CloseMethod(SystemWindow* pSysWindow) m_xFrame.clear(); } +bool SfxNotebookBar::IsActive() +{ + SvtViewOptions aViewOpt(E_WINDOW, "notebookbar"); + return aViewOpt.IsVisible(); +} + void SfxNotebookBar::ExecMethod(SfxBindings& rBindings) { SvtViewOptions aViewOpt(E_WINDOW, "notebookbar"); @@ -87,25 +94,32 @@ void SfxNotebookBar::StateMethod(SystemWindow* pSysWindow, { RemoveListeners(pSysWindow); - // setup if necessary - pSysWindow->SetNotebookBar(rUIFile, xFrame); - - pSysWindow->GetNotebookBar()->Show(); - pSysWindow->GetNotebookBar()->SetIconClickHdl(LINK(nullptr, SfxNotebookBar, ToggleMenubar)); - - SfxViewFrame* pView = SfxViewFrame::Current(); - - if(pView) + OUString sFile = officecfg::Office::UI::Notebookbar::Active::get(); + if ( !sFile.isEmpty() ) { - Reference xMultiplexer - = ContextChangeEventMultiplexer::get( - ::comphelper::getProcessComponentContext()); + OUStringBuffer aBuf(rUIFile); + aBuf.append( sFile ); - if(xFrame.is() && xMultiplexer.is()) + // setup if necessary + pSysWindow->SetNotebookBar(aBuf.makeStringAndClear(), xFrame); + + pSysWindow->GetNotebookBar()->Show(); + pSysWindow->GetNotebookBar()->SetIconClickHdl(LINK(nullptr, SfxNotebookBar, ToggleMenubar)); + + SfxViewFrame* pView = SfxViewFrame::Current(); + + if(pView) { - xMultiplexer->addContextChangeEventListener( - pSysWindow->GetNotebookBar()->getContextChangeEventListener(), - xFrame->getController()); + Reference xMultiplexer + = ContextChangeEventMultiplexer::get( + ::comphelper::getProcessComponentContext()); + + if(xFrame.is() && xMultiplexer.is()) + { + xMultiplexer->addContextChangeEventListener( + pSysWindow->GetNotebookBar()->getContextChangeEventListener(), + xFrame->getController()); + } } } } diff --git a/sw/UIConfig_swriter.mk b/sw/UIConfig_swriter.mk index 174575ba55af..bfe8d92e6078 100644 --- a/sw/UIConfig_swriter.mk +++ b/sw/UIConfig_swriter.mk @@ -204,6 +204,7 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/swriter,\ sw/uiconfig/swriter/ui/mmsendmails \ sw/uiconfig/swriter/ui/mmsalutationpage \ sw/uiconfig/swriter/ui/notebookbar \ + sw/uiconfig/swriter/ui/notebookbar_groups \ sw/uiconfig/swriter/ui/paradialog \ sw/uiconfig/swriter/ui/picturedialog \ sw/uiconfig/swriter/ui/picturepage \ diff --git a/sw/source/uibase/app/docsh.cxx b/sw/source/uibase/app/docsh.cxx index c0068d01db76..06708852497c 100644 --- a/sw/source/uibase/app/docsh.cxx +++ b/sw/source/uibase/app/docsh.cxx @@ -1073,7 +1073,7 @@ void SwDocShell::GetState(SfxItemSet& rSet) case SID_NOTEBOOKBAR: { SfxViewShell* pViewShell = GetView()? GetView(): SfxViewShell::Current(); - sfx2::SfxNotebookBar::StateMethod(pViewShell->GetViewFrame()->GetBindings(), "modules/swriter/ui/notebookbar.ui"); + sfx2::SfxNotebookBar::StateMethod(pViewShell->GetViewFrame()->GetBindings(), "modules/swriter/ui/"); } break; diff --git a/sw/source/uibase/app/docsh2.cxx b/sw/source/uibase/app/docsh2.cxx index b4607eb74544..d49a09f41e0e 100644 --- a/sw/source/uibase/app/docsh2.cxx +++ b/sw/source/uibase/app/docsh2.cxx @@ -1160,8 +1160,18 @@ void SwDocShell::Execute(SfxRequest& rReq) break; case SID_NOTEBOOKBAR: { + const SfxStringItem* pFile = rReq.GetArg( SID_NOTEBOOKBAR ); SfxViewShell* pViewShell = GetView()? GetView(): SfxViewShell::Current(); - sfx2::SfxNotebookBar::ExecMethod(pViewShell->GetViewFrame()->GetBindings()); + SfxBindings& rBindings( pViewShell->GetViewFrame()->GetBindings() ); + + if ( !pFile || ( pFile && !SfxNotebookBar::IsActive() ) ) + sfx2::SfxNotebookBar::ExecMethod( rBindings ); + else if ( pFile && pFile->GetValue().isEmpty() ) + { + sfx2::SfxNotebookBar::CloseMethod( rBindings ); + if ( sfx2::SfxNotebookBar::IsActive() ) + sfx2::SfxNotebookBar::ExecMethod( rBindings ); + } } break; diff --git a/sw/uiconfig/swriter/ui/notebookbar_groups.ui b/sw/uiconfig/swriter/ui/notebookbar_groups.ui new file mode 100644 index 000000000000..0154978af690 --- /dev/null +++ b/sw/uiconfig/swriter/ui/notebookbar_groups.ui @@ -0,0 +1,133 @@ + + + + + + + + True + False + + + True + False + vertical + + + True + True + True + True + + + True + False + 6 + + + + + + + + + + + + + + + + + + + + + + + + True + False + + + + + + + False + True + 7 + + + + + + + True + False + File + True + + + False + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + False + True + 0 + + + + + 0 + 0 + + + +