From e681749ffa5a18c8a6ff874787d4ab8411a46125 Mon Sep 17 00:00:00 2001 From: Szymon Kłos Date: Tue, 21 Feb 2017 11:31:18 +0100 Subject: tdf#105040 Notebookbar: added shortcuts toolbox In the tabbed notebookbar the shortcuts toolbox is introduced. It is placed before tab labels, after the menu button. Customization is possible, buttons are loaded from the newly created toolbar "Notebookbar shortcuts". NotebookbarTabControl was moved to the sfx module. Change-Id: Ifa4a1688c6e92c2f03bd386608e3e9d1c28069d4 Reviewed-on: https://gerrit.libreoffice.org/35194 Tested-by: Jenkins Reviewed-by: Samuel Mehrbrodt --- extras/source/glade/libreoffice-catalog.xml.in | 2 +- .../sfx2/notebookbar/NotebookbarContextControl.hxx | 1 - include/sfx2/notebookbar/NotebookbarTabControl.hxx | 46 ++++ include/sfx2/notebookbar/SfxNotebookBar.hxx | 2 - include/vcl/notebookbar.hxx | 2 - include/vcl/tabctrl.hxx | 12 +- .../org/openoffice/Office/UI/CalcWindowState.xcu | 11 + .../openoffice/Office/UI/ImpressWindowState.xcu | 11 + .../org/openoffice/Office/UI/WriterWindowState.xcu | 11 + sc/UIConfig_scalc.mk | 1 + sc/uiconfig/scalc/toolbar/notebookbarshortcuts.xml | 15 ++ sc/uiconfig/scalc/ui/notebookbar.ui | 2 +- sd/UIConfig_simpress.mk | 1 + .../simpress/toolbar/notebookbarshortcuts.xml | 15 ++ sd/uiconfig/simpress/ui/notebookbar.ui | 2 +- sfx2/Library_sfx.mk | 1 + sfx2/source/notebookbar/ContextVBox.cxx | 5 - sfx2/source/notebookbar/NotebookbarTabControl.cxx | 241 +++++++++++++++++++++ sfx2/source/notebookbar/SfxNotebookBar.cxx | 42 +--- sw/UIConfig_swriter.mk | 1 + .../swriter/toolbar/notebookbarshortcuts.xml | 15 ++ sw/uiconfig/swriter/ui/notebookbar.ui | 2 +- vcl/source/control/notebookbar.cxx | 6 - vcl/source/control/tabctrl.cxx | 67 ++++-- 24 files changed, 431 insertions(+), 83 deletions(-) create mode 100644 include/sfx2/notebookbar/NotebookbarTabControl.hxx create mode 100644 sc/uiconfig/scalc/toolbar/notebookbarshortcuts.xml create mode 100644 sd/uiconfig/simpress/toolbar/notebookbarshortcuts.xml create mode 100644 sfx2/source/notebookbar/NotebookbarTabControl.cxx create mode 100644 sw/uiconfig/swriter/toolbar/notebookbarshortcuts.xml diff --git a/extras/source/glade/libreoffice-catalog.xml.in b/extras/source/glade/libreoffice-catalog.xml.in index 017945162449..ec767c48f696 100644 --- a/extras/source/glade/libreoffice-catalog.xml.in +++ b/extras/source/glade/libreoffice-catalog.xml.in @@ -825,7 +825,7 @@ - aHdl ) = 0; }; #endif // INCLUDED_SFX2_NOTEBOOKBAR_NOTEBOOKBARCONTEXTCONTROL_HXX diff --git a/include/sfx2/notebookbar/NotebookbarTabControl.hxx b/include/sfx2/notebookbar/NotebookbarTabControl.hxx new file mode 100644 index 000000000000..062fe9631f48 --- /dev/null +++ b/include/sfx2/notebookbar/NotebookbarTabControl.hxx @@ -0,0 +1,46 @@ +/* -*- 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/. + */ + +#ifndef INCLUDED_SFX2_NOTEBOOKBAR_NOTEBOOKBARTABCONTROL_HXX +#define INCLUDED_SFX2_NOTEBOOKBAR_NOTEBOOKBARTABCONTROL_HXX + +#include +#include +#include +#include + +class ChangedUIEventListener; + +class SFX2_DLLPUBLIC NotebookbarTabControl : public NotebookbarTabControlBase +{ +friend class ChangedUIEventListener; + +public: + NotebookbarTabControl( Window* pParent ); + + virtual void StateChanged(StateChangedType nStateChange) override; + +private: + static void FillShortcutsToolBox(css::uno::Reference& xContext, + const css::uno::Reference& xFrame, + const OUString& aModuleName, + ToolBox* pShortcuts + ); + DECL_STATIC_LINK(NotebookbarTabControl, OpenNotebookbarPopupMenu, NotebookBar*, void); + + ChangedUIEventListener* m_pListener; + +protected: + bool m_bInitialized; + bool m_bInvalidate; +}; + +#endif // INCLUDED_SFX2_NOTEBOOKBAR_NOTEBOOKBARTABCONTROL_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/notebookbar/SfxNotebookBar.hxx b/include/sfx2/notebookbar/SfxNotebookBar.hxx index 8792eecf3a4f..e87e7d928c45 100644 --- a/include/sfx2/notebookbar/SfxNotebookBar.hxx +++ b/include/sfx2/notebookbar/SfxNotebookBar.hxx @@ -50,8 +50,6 @@ public: private: static bool m_bLock; static bool m_bHide; - - DECL_STATIC_LINK(SfxNotebookBar, OpenNotebookbarPopupMenu, NotebookBar*, void); }; } // namespace sfx2 diff --git a/include/vcl/notebookbar.hxx b/include/vcl/notebookbar.hxx index 9a41152ab505..f16b3ed38976 100644 --- a/include/vcl/notebookbar.hxx +++ b/include/vcl/notebookbar.hxx @@ -32,8 +32,6 @@ public: virtual void setPosSizePixel(long nX, long nY, long nWidth, long nHeight, PosSizeFlags nFlags = PosSizeFlags::All) SAL_OVERRIDE; virtual void Resize() override; - void SetIconClickHdl(Link aHdl); - void SetSystemWindow(SystemWindow* pSystemWindow); const css::uno::Reference& getContextChangeEventListener() const { return m_pEventListener; } diff --git a/include/vcl/tabctrl.hxx b/include/vcl/tabctrl.hxx index fc7d1a8a9064..bdc1d3289a58 100644 --- a/include/vcl/tabctrl.hxx +++ b/include/vcl/tabctrl.hxx @@ -22,6 +22,7 @@ #include #include +#include #include #include @@ -190,14 +191,18 @@ public: class NotebookBar; -class VCL_DLLPUBLIC NotebookbarTabControl : public TabControl, +class VCL_DLLPUBLIC NotebookbarTabControlBase : public TabControl, public NotebookbarContextControl { public: - NotebookbarTabControl( vcl::Window* pParent ); + NotebookbarTabControlBase( vcl::Window* pParent ); + ~NotebookbarTabControlBase() override; + void dispose() override; void SetContext( vcl::EnumContext::Context eContext ) override; - void SetIconClickHdl( Link aHdl ) override; + void SetIconClickHdl( Link aHdl ); + void SetToolBox( ToolBox* pToolBox ); + ToolBox* GetToolBox() { return m_pShortcuts; } virtual sal_uInt16 GetPageId( const Point& rPos ) const override; virtual void SelectTabPage( sal_uInt16 nPageId ) override; @@ -215,6 +220,7 @@ private: vcl::EnumContext::Context eLastContext; Link m_aIconClickHdl; static sal_uInt16 m_nHeaderHeight; + VclPtr m_pShortcuts; }; #endif // INCLUDED_VCL_TABCTRL_HXX diff --git a/officecfg/registry/data/org/openoffice/Office/UI/CalcWindowState.xcu b/officecfg/registry/data/org/openoffice/Office/UI/CalcWindowState.xcu index 0bbaab8d50d5..7614ea3827c0 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/CalcWindowState.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/CalcWindowState.xcu @@ -733,6 +733,17 @@ false + + + Notebookbar shortcuts + + + false + + + true + + diff --git a/officecfg/registry/data/org/openoffice/Office/UI/ImpressWindowState.xcu b/officecfg/registry/data/org/openoffice/Office/UI/ImpressWindowState.xcu index 2f81b1143f78..9cef881c7c83 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/ImpressWindowState.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/ImpressWindowState.xcu @@ -1028,6 +1028,17 @@ false + + + Notebookbar shortcuts + + + false + + + true + + diff --git a/officecfg/registry/data/org/openoffice/Office/UI/WriterWindowState.xcu b/officecfg/registry/data/org/openoffice/Office/UI/WriterWindowState.xcu index 740462ad46c7..ac0b4c2a750c 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/WriterWindowState.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/WriterWindowState.xcu @@ -108,6 +108,17 @@ true + + + Notebookbar shortcuts + + + false + + + true + + 0,1 diff --git a/sc/UIConfig_scalc.mk b/sc/UIConfig_scalc.mk index 89527f367a4f..a5e1d6de324e 100644 --- a/sc/UIConfig_scalc.mk +++ b/sc/UIConfig_scalc.mk @@ -79,6 +79,7 @@ $(eval $(call gb_UIConfig_add_toolbarfiles,modules/scalc,\ sc/uiconfig/scalc/toolbar/linesbar \ sc/uiconfig/scalc/toolbar/mediaobjectbar \ sc/uiconfig/scalc/toolbar/moreformcontrols \ + sc/uiconfig/scalc/toolbar/notebookbarshortcuts \ sc/uiconfig/scalc/toolbar/previewbar \ sc/uiconfig/scalc/toolbar/singlemode \ sc/uiconfig/scalc/toolbar/standardbar \ diff --git a/sc/uiconfig/scalc/toolbar/notebookbarshortcuts.xml b/sc/uiconfig/scalc/toolbar/notebookbarshortcuts.xml new file mode 100644 index 000000000000..6bf1a4e8a4b3 --- /dev/null +++ b/sc/uiconfig/scalc/toolbar/notebookbarshortcuts.xml @@ -0,0 +1,15 @@ + + + + + + + + diff --git a/sc/uiconfig/scalc/ui/notebookbar.ui b/sc/uiconfig/scalc/ui/notebookbar.ui index f922d4ba7a2a..9ac3e0480b0c 100644 --- a/sc/uiconfig/scalc/ui/notebookbar.ui +++ b/sc/uiconfig/scalc/ui/notebookbar.ui @@ -197,7 +197,7 @@ False vertical - + True True True diff --git a/sd/UIConfig_simpress.mk b/sd/UIConfig_simpress.mk index f268c0074d62..6bf23ea2f9ae 100644 --- a/sd/UIConfig_simpress.mk +++ b/sd/UIConfig_simpress.mk @@ -85,6 +85,7 @@ $(eval $(call gb_UIConfig_add_toolbarfiles,modules/simpress,\ sd/uiconfig/simpress/toolbar/masterviewtoolbar \ sd/uiconfig/simpress/toolbar/mediaobjectbar \ sd/uiconfig/simpress/toolbar/moreformcontrols \ + sd/uiconfig/simpress/toolbar/notebookbarshortcuts \ sd/uiconfig/simpress/toolbar/optimizetablebar \ sd/uiconfig/simpress/toolbar/optionsbar \ sd/uiconfig/simpress/toolbar/outlinetoolbar \ diff --git a/sd/uiconfig/simpress/toolbar/notebookbarshortcuts.xml b/sd/uiconfig/simpress/toolbar/notebookbarshortcuts.xml new file mode 100644 index 000000000000..6bf1a4e8a4b3 --- /dev/null +++ b/sd/uiconfig/simpress/toolbar/notebookbarshortcuts.xml @@ -0,0 +1,15 @@ + + + + + + + + diff --git a/sd/uiconfig/simpress/ui/notebookbar.ui b/sd/uiconfig/simpress/ui/notebookbar.ui index 0dd20814afee..f6c0dccbd7c6 100644 --- a/sd/uiconfig/simpress/ui/notebookbar.ui +++ b/sd/uiconfig/simpress/ui/notebookbar.ui @@ -187,7 +187,7 @@ False vertical - + True True True diff --git a/sfx2/Library_sfx.mk b/sfx2/Library_sfx.mk index 148a9b0d45b9..f0a5a52c0cc2 100644 --- a/sfx2/Library_sfx.mk +++ b/sfx2/Library_sfx.mk @@ -242,6 +242,7 @@ $(eval $(call gb_Library_add_exception_objects,sfx,\ sfx2/source/notebookbar/DropdownBox \ sfx2/source/notebookbar/PriorityHBox \ sfx2/source/notebookbar/SfxNotebookBar \ + sfx2/source/notebookbar/NotebookbarTabControl \ sfx2/source/notify/eventsupplier \ sfx2/source/notify/globalevents \ sfx2/source/notify/hintpost \ diff --git a/sfx2/source/notebookbar/ContextVBox.cxx b/sfx2/source/notebookbar/ContextVBox.cxx index a02cc51051ee..a89c9c2938ce 100644 --- a/sfx2/source/notebookbar/ContextVBox.cxx +++ b/sfx2/source/notebookbar/ContextVBox.cxx @@ -68,11 +68,6 @@ public: aSize.Width() += 6; SetSizePixel( aSize ); } - - void SetIconClickHdl( Link ) override - { - // Menu not supported - } }; VCL_BUILDER_FACTORY(ContextVBox) diff --git a/sfx2/source/notebookbar/NotebookbarTabControl.cxx b/sfx2/source/notebookbar/NotebookbarTabControl.cxx new file mode 100644 index 000000000000..b4a946502222 --- /dev/null +++ b/sfx2/source/notebookbar/NotebookbarTabControl.cxx @@ -0,0 +1,241 @@ +/* -*- 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define ICON_SIZE 25 +#define TOOLBAR_STR "private:resource/toolbar/notebookbarshortcuts" + +using namespace css::uno; +using namespace css::ui; +using namespace css::frame; + +class ChangedUIEventListener : public ::cppu::WeakImplHelper +{ + VclPtr m_pParent; + +public: + explicit ChangedUIEventListener(NotebookbarTabControl *p) + : m_pParent(p) + { + try + { + Reference xContext = comphelper::getProcessComponentContext(); + const Reference xModuleManager = ModuleManager::create( xContext ); + Reference xFrame = SfxViewFrame::Current()->GetFrame().GetFrameInterface(); + OUString aModuleName = xModuleManager->identify( xFrame ); + + Reference m_xConfigManager; + Reference xModuleCfgMgrSupplier( + theModuleUIConfigurationManagerSupplier::get( xContext ) ); + m_xConfigManager.set( xModuleCfgMgrSupplier->getUIConfigurationManager( aModuleName ) ); + css::uno::Reference< css::ui::XUIConfiguration > xConfig( m_xConfigManager, css::uno::UNO_QUERY_THROW ); + xConfig->addConfigurationListener( this ); + } + catch( const css::uno::RuntimeException& ) {} + } + + // XUIConfigurationListener + virtual void SAL_CALL elementInserted( const ConfigurationEvent& rEvent ) override + { + if( rEvent.ResourceURL == TOOLBAR_STR ) + { + m_pParent->m_bInvalidate = true; + m_pParent->StateChanged(StateChangedType::UpdateMode); + } + } + + virtual void SAL_CALL elementRemoved( const ConfigurationEvent& rEvent ) override + { + elementInserted( rEvent ); + } + + virtual void SAL_CALL elementReplaced( const ConfigurationEvent& rEvent ) override + { + elementInserted( rEvent ); + } + + virtual void SAL_CALL disposing(const ::css::lang::EventObject&) override + { + m_pParent.clear(); + } +}; + +class ShortcutsToolBox : public sfx2::sidebar::SidebarToolBox +{ +public: + ShortcutsToolBox( Window* pParent ) + : sfx2::sidebar::SidebarToolBox( pParent ) + { + mbUseDefaultButtonSize = false; + SetToolboxButtonSize(ToolBoxButtonSize::Small); + } +}; + +NotebookbarTabControl::NotebookbarTabControl( Window* pParent ) +: NotebookbarTabControlBase( pParent ) +, m_pListener( nullptr ) +, m_bInitialized( false ) +, m_bInvalidate( true ) +{ +} + +void NotebookbarTabControl::StateChanged(StateChangedType nStateChange) +{ + if( !m_bInitialized && SfxViewFrame::Current() ) + { + VclPtr pShortcuts = VclPtr::Create( this ); + pShortcuts->Show(); + + SetToolBox( static_cast( pShortcuts.get() ) ); + SetIconClickHdl( LINK( nullptr, NotebookbarTabControl, OpenNotebookbarPopupMenu ) ); + + m_pListener = new ChangedUIEventListener( this ); + + m_bInitialized = true; + } + if( m_bInitialized && m_bInvalidate && SfxViewFrame::Current() ) + { + ToolBox* pToolBox = GetToolBox(); + pToolBox->Clear(); + + Reference xContext = comphelper::getProcessComponentContext(); + const Reference xModuleManager = ModuleManager::create( xContext ); + Reference xFrame = SfxViewFrame::Current()->GetFrame().GetFrameInterface(); + OUString aModuleName = xModuleManager->identify( xFrame ); + + FillShortcutsToolBox( xContext, xFrame, aModuleName, pToolBox ); + + Size aSize( pToolBox->GetOptimalSize() ); + Point aPos( ICON_SIZE + 10, 0 ); + pToolBox->SetPosSizePixel( aPos, aSize ); + ImplPlaceTabs( GetSizePixel().getWidth() ); + + m_bInvalidate = false; + } + NotebookbarTabControlBase::StateChanged( nStateChange ); +} + +void NotebookbarTabControl::FillShortcutsToolBox(Reference& xContext, + const Reference& xFrame, + const OUString& aModuleName, + ToolBox* pShortcuts +) +{ + Reference<::com::sun::star::container::XIndexAccess> xIndex; + + try + { + Reference m_xConfigManager; + Reference xModuleCfgMgrSupplier( + theModuleUIConfigurationManagerSupplier::get( xContext ) ); + m_xConfigManager.set( xModuleCfgMgrSupplier->getUIConfigurationManager( aModuleName ) ); + xIndex = m_xConfigManager->getSettings( TOOLBAR_STR, false ); + } + catch( const Exception& ) {} + + if ( !xIndex.is() ) + return; + + Sequence< css::beans::PropertyValue > aPropSequence; + for ( sal_Int32 i = 0; i < xIndex->getCount(); ++i ) + { + try + { + if ( xIndex->getByIndex( i ) >>= aPropSequence ) + { + OUString aCommandURL; + OUString aLabel; + sal_uInt16 nType = ItemType::DEFAULT; + bool bVisible = true; + + for ( const auto& aProp: aPropSequence ) + { + if ( aProp.Name == "CommandURL" ) + aProp.Value >>= aCommandURL; + else if ( aProp.Name == "Label" ) + aProp.Value >>= aLabel; + else if ( aProp.Name == "Type" ) + aProp.Value >>= nType; + else if ( aProp.Name == "IsVisible" ) + aProp.Value >>= bVisible; + } + if ( bVisible && ( nType == ItemType::DEFAULT ) ) + pShortcuts->InsertItem( aCommandURL, xFrame, ToolBoxItemBits::ICON_ONLY, Size( ICON_SIZE, ICON_SIZE ) ); + } + } + catch ( const Exception& ) + { + break; + } + } +} + +IMPL_STATIC_LINK(NotebookbarTabControl, OpenNotebookbarPopupMenu, NotebookBar*, pNotebookbar, void) +{ + SfxViewFrame* pViewFrame = SfxViewFrame::Current(); + if (pNotebookbar && pViewFrame) + { + Sequence aArgs { + makeAny(comphelper::makePropertyValue("Value", OUString("notebookbar"))), + makeAny(comphelper::makePropertyValue("Frame", pViewFrame->GetFrame().GetFrameInterface())) }; + + Reference xContext = comphelper::getProcessComponentContext(); + Reference xPopupController( + xContext->getServiceManager()->createInstanceWithArgumentsAndContext( + "com.sun.star.comp.framework.ResourceMenuController", aArgs, xContext), UNO_QUERY); + + Reference xPopupMenu(xContext->getServiceManager()->createInstanceWithContext( + "com.sun.star.awt.PopupMenu", xContext), UNO_QUERY); + + if (!xPopupController.is() || !xPopupMenu.is()) + return; + + xPopupController->setPopupMenu(xPopupMenu); + VCLXMenu* pAwtMenu = VCLXMenu::GetImplementation(xPopupMenu); + PopupMenu* pVCLMenu = static_cast(pAwtMenu->GetMenu()); + Point aPos(0, NotebookbarTabControl::GetHeaderHeight()); + pVCLMenu->Execute(pNotebookbar, Rectangle(aPos, aPos),PopupMenuFlags::ExecuteDown|PopupMenuFlags::NoMouseUpClose); + + Reference xComponent(xPopupController, UNO_QUERY); + if (xComponent.is()) + xComponent->dispose(); + } +} + +VCL_BUILDER_FACTORY( NotebookbarTabControl ) + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/source/notebookbar/SfxNotebookBar.cxx b/sfx2/source/notebookbar/SfxNotebookBar.cxx index 2976f43a6524..15d89bce4205 100644 --- a/sfx2/source/notebookbar/SfxNotebookBar.cxx +++ b/sfx2/source/notebookbar/SfxNotebookBar.cxx @@ -270,8 +270,10 @@ bool SfxNotebookBar::StateMethod(SystemWindow* pSysWindow, if (IsActive()) { - const Reference xModuleManager = frame::ModuleManager::create( ::comphelper::getProcessComponentContext() ); - vcl::EnumContext::Application eApp = vcl::EnumContext::GetApplicationEnum(xModuleManager->identify(xFrame)); + css::uno::Reference xContext = comphelper::getProcessComponentContext(); + const Reference xModuleManager = frame::ModuleManager::create( xContext ); + OUString aModuleName = xModuleManager->identify( xFrame ); + vcl::EnumContext::Application eApp = vcl::EnumContext::GetApplicationEnum( aModuleName ); OUString sFile = lcl_getNotebookbarFileName( eApp ); OUString sNewFile = rUIFile + sFile; OUString sCurrentFile; @@ -302,7 +304,6 @@ bool SfxNotebookBar::StateMethod(SystemWindow* pSysWindow, pNotebookBar = pSysWindow->GetNotebookBar(); pNotebookBar->Show(); pNotebookBar->GetParent()->Resize(); - pNotebookBar->SetIconClickHdl( LINK( nullptr, SfxNotebookBar, OpenNotebookbarPopupMenu ) ); utl::OConfigurationTreeRoot aRoot(lcl_getCurrentImplConfigRoot()); const utl::OConfigurationNode aModeNode(lcl_getCurrentImplConfigNode(xFrame, aRoot)); @@ -313,8 +314,7 @@ bool SfxNotebookBar::StateMethod(SystemWindow* pSysWindow, if(pView) { Reference xMultiplexer - = ContextChangeEventMultiplexer::get( - ::comphelper::getProcessComponentContext()); + = ContextChangeEventMultiplexer::get( xContext ); if(xFrame.is()) { @@ -350,38 +350,6 @@ void SfxNotebookBar::RemoveListeners(SystemWindow* pSysWindow) } } -IMPL_STATIC_LINK(SfxNotebookBar, OpenNotebookbarPopupMenu, NotebookBar*, pNotebookbar, void) -{ - SfxViewFrame* pViewFrame = SfxViewFrame::Current(); - if (pNotebookbar && pViewFrame) - { - css::uno::Sequence aArgs { - css::uno::makeAny(comphelper::makePropertyValue("Value", OUString("notebookbar"))), - css::uno::makeAny(comphelper::makePropertyValue("Frame", pViewFrame->GetFrame().GetFrameInterface())) }; - - css::uno::Reference xContext = comphelper::getProcessComponentContext(); - css::uno::Reference xPopupController( - xContext->getServiceManager()->createInstanceWithArgumentsAndContext( - "com.sun.star.comp.framework.ResourceMenuController", aArgs, xContext), css::uno::UNO_QUERY); - - css::uno::Reference xPopupMenu(xContext->getServiceManager()->createInstanceWithContext( - "com.sun.star.awt.PopupMenu", xContext), css::uno::UNO_QUERY); - - if (!xPopupController.is() || !xPopupMenu.is()) - return; - - xPopupController->setPopupMenu(xPopupMenu); - VCLXMenu* pAwtMenu = VCLXMenu::GetImplementation(xPopupMenu); - PopupMenu* pVCLMenu = static_cast(pAwtMenu->GetMenu()); - Point aPos(0, NotebookbarTabControl::GetHeaderHeight()); - pVCLMenu->Execute(pNotebookbar, Rectangle(aPos, aPos),PopupMenuFlags::ExecuteDown|PopupMenuFlags::NoMouseUpClose); - - css::uno::Reference xComponent(xPopupController, css::uno::UNO_QUERY); - if (xComponent.is()) - xComponent->dispose(); - } -} - void SfxNotebookBar::ShowMenubar(bool bShow) { if (!m_bLock) diff --git a/sw/UIConfig_swriter.mk b/sw/UIConfig_swriter.mk index 8d51e8c4bc55..41fed854c5d4 100644 --- a/sw/UIConfig_swriter.mk +++ b/sw/UIConfig_swriter.mk @@ -68,6 +68,7 @@ $(eval $(call gb_UIConfig_add_toolbarfiles,modules/swriter,\ sw/uiconfig/swriter/toolbar/mediaobjectbar \ sw/uiconfig/swriter/toolbar/moreformcontrols \ sw/uiconfig/swriter/toolbar/navigationobjectbar \ + sw/uiconfig/swriter/toolbar/notebookbarshortcuts \ sw/uiconfig/swriter/toolbar/numobjectbar \ sw/uiconfig/swriter/toolbar/oleobjectbar \ sw/uiconfig/swriter/toolbar/optimizetablebar \ diff --git a/sw/uiconfig/swriter/toolbar/notebookbarshortcuts.xml b/sw/uiconfig/swriter/toolbar/notebookbarshortcuts.xml new file mode 100644 index 000000000000..6a067ef567fd --- /dev/null +++ b/sw/uiconfig/swriter/toolbar/notebookbarshortcuts.xml @@ -0,0 +1,15 @@ + + + + + + + + diff --git a/sw/uiconfig/swriter/ui/notebookbar.ui b/sw/uiconfig/swriter/ui/notebookbar.ui index 21dbfbee0973..9313942dc3b7 100644 --- a/sw/uiconfig/swriter/ui/notebookbar.ui +++ b/sw/uiconfig/swriter/ui/notebookbar.ui @@ -208,7 +208,7 @@ False vertical - + True True True diff --git a/vcl/source/control/notebookbar.cxx b/vcl/source/control/notebookbar.cxx index 453236012c21..f23e2d57d21a 100644 --- a/vcl/source/control/notebookbar.cxx +++ b/vcl/source/control/notebookbar.cxx @@ -120,12 +120,6 @@ void NotebookBar::Resize() Control::Resize(); } -void NotebookBar::SetIconClickHdl(Link aHdl) -{ - if (m_pContextContainer) - m_pContextContainer->SetIconClickHdl(aHdl); -} - void NotebookBar::SetSystemWindow(SystemWindow* pSystemWindow) { m_pSystemWindow = pSystemWindow; diff --git a/vcl/source/control/tabctrl.cxx b/vcl/source/control/tabctrl.cxx index 34dc980808bf..753aa8996a2d 100644 --- a/vcl/source/control/tabctrl.cxx +++ b/vcl/source/control/tabctrl.cxx @@ -2202,11 +2202,9 @@ FactoryFunction TabControl::GetUITestFactory() const return TabControlUIObject::create; } -VCL_BUILDER_FACTORY(NotebookbarTabControl); +sal_uInt16 NotebookbarTabControlBase::m_nHeaderHeight = 0; -sal_uInt16 NotebookbarTabControl::m_nHeaderHeight = 0; - -NotebookbarTabControl::NotebookbarTabControl(vcl::Window* pParent) +NotebookbarTabControlBase::NotebookbarTabControlBase(vcl::Window* pParent) : TabControl(pParent, WB_STDTABCONTROL) , bLastContextWasSupported(true) , eLastContext(vcl::EnumContext::Context::Any) @@ -2216,7 +2214,12 @@ NotebookbarTabControl::NotebookbarTabControl(vcl::Window* pParent) SetPageImage(1, Image(aBitmap)); } -void NotebookbarTabControl::SetContext( vcl::EnumContext::Context eContext ) +NotebookbarTabControlBase::~NotebookbarTabControlBase() +{ + disposeOnce(); +} + +void NotebookbarTabControlBase::SetContext( vcl::EnumContext::Context eContext ) { if (eLastContext != eContext) { @@ -2225,21 +2228,22 @@ void NotebookbarTabControl::SetContext( vcl::EnumContext::Context eContext ) for (int nChild = 0; nChild < GetChildCount(); ++nChild) { TabPage* pPage = static_cast(GetChild(nChild)); + sal_uInt16 nPageId = TabControl::GetPageId(*pPage); if (pPage->HasContext(eContext) || pPage->HasContext(vcl::EnumContext::Context::Any)) - EnablePage(nChild + 2); + EnablePage(nPageId); else - EnablePage(nChild + 2, false); + EnablePage(nPageId, false); if (!bHandled && bLastContextWasSupported && pPage->HasContext(vcl::EnumContext::Context::Default)) { - SetCurPageId(nChild + 2); + SetCurPageId(nPageId); } if (pPage->HasContext(eContext) && eContext != vcl::EnumContext::Context::Any) { - SetCurPageId(nChild + 2); + SetCurPageId(nPageId); bHandled = true; bLastContextWasSupported = true; } @@ -2251,16 +2255,27 @@ void NotebookbarTabControl::SetContext( vcl::EnumContext::Context eContext ) } } -void NotebookbarTabControl::SetIconClickHdl( Link aHdl ) +void NotebookbarTabControlBase::dispose() +{ + m_pShortcuts.disposeAndClear(); + TabControl::dispose(); +} + +void NotebookbarTabControlBase::SetToolBox( ToolBox* pToolBox ) +{ + m_pShortcuts.set( pToolBox ); +} + +void NotebookbarTabControlBase::SetIconClickHdl( Link aHdl ) { m_aIconClickHdl = aHdl; } -sal_uInt16 NotebookbarTabControl::GetPageId( const Point& rPos ) const +sal_uInt16 NotebookbarTabControlBase::GetPageId( const Point& rPos ) const { for( size_t i = 0; i < mpTabCtrlData->maItemList.size(); ++i ) { - if ( const_cast(this)->ImplGetTabRect( static_cast(i) ).IsInside( rPos ) ) + if ( const_cast(this)->ImplGetTabRect( static_cast(i) ).IsInside( rPos ) ) if ( mpTabCtrlData->maItemList[ i ].mbEnabled ) return mpTabCtrlData->maItemList[ i ].mnId; } @@ -2268,10 +2283,10 @@ sal_uInt16 NotebookbarTabControl::GetPageId( const Point& rPos ) const return 0; } -void NotebookbarTabControl::SelectTabPage( sal_uInt16 nPageId ) +void NotebookbarTabControlBase::SelectTabPage( sal_uInt16 nPageId ) { if ( nPageId == 1 ) - m_aIconClickHdl.Call( static_cast(GetParent()) ); + m_aIconClickHdl.Call( static_cast(GetParent()->GetParent()) ); else { TabControl::SelectTabPage( nPageId ); @@ -2279,7 +2294,7 @@ void NotebookbarTabControl::SelectTabPage( sal_uInt16 nPageId ) } } -void NotebookbarTabControl::SetCurPageId( sal_uInt16 nPageId ) +void NotebookbarTabControlBase::SetCurPageId( sal_uInt16 nPageId ) { if ( nPageId != 1 ) { @@ -2290,7 +2305,7 @@ void NotebookbarTabControl::SetCurPageId( sal_uInt16 nPageId ) ImplActivateTabPage( true ); } -void NotebookbarTabControl::ImplActivateTabPage( bool bNext ) +void NotebookbarTabControlBase::ImplActivateTabPage( bool bNext ) { sal_uInt16 nCurPos = GetPagePos( GetCurPageId() ); @@ -2323,12 +2338,12 @@ void NotebookbarTabControl::ImplActivateTabPage( bool bNext ) SelectTabPage( TabControl::GetPageId( nCurPos ) ); } -sal_uInt16 NotebookbarTabControl::GetHeaderHeight() +sal_uInt16 NotebookbarTabControlBase::GetHeaderHeight() { return m_nHeaderHeight; } -bool NotebookbarTabControl::ImplPlaceTabs( long nWidth ) +bool NotebookbarTabControlBase::ImplPlaceTabs( long nWidth ) { if ( nWidth <= 0 ) return false; @@ -2358,6 +2373,7 @@ bool NotebookbarTabControl::ImplPlaceTabs( long nWidth ) nMaxWidth = mnMaxPageWidth; nMaxWidth -= GetItemsOffset().X(); + long nShortcutsWidth = m_pShortcuts != nullptr ? m_pShortcuts->GetSizePixel().getWidth() : 0; long nX = nOffsetX; long nY = nOffsetY; @@ -2376,6 +2392,9 @@ bool NotebookbarTabControl::ImplPlaceTabs( long nWidth ) for( std::vector::iterator it = mpTabCtrlData->maItemList.begin(); it != mpTabCtrlData->maItemList.end(); ++it, ++nIndex ) { + if( it == mpTabCtrlData->maItemList.begin() + 1 ) + nX += nShortcutsWidth; + Size aSize = ImplGetItemSize( &(*it), nMaxWidth ); bool bNewLine = false; @@ -2506,7 +2525,7 @@ bool NotebookbarTabControl::ImplPlaceTabs( long nWidth ) return true; } -void NotebookbarTabControl::ImplPaint(vcl::RenderContext& rRenderContext, const Rectangle& rRect) +void NotebookbarTabControlBase::ImplPaint(vcl::RenderContext& rRenderContext, const Rectangle& rRect) { HideFocus(); @@ -2697,9 +2716,11 @@ void NotebookbarTabControl::ImplPaint(vcl::RenderContext& rRenderContext, const ImplShowFocus(); mbSmallInvalidate = true; + + Control::Paint(rRenderContext, rRect); } -Size NotebookbarTabControl::calculateRequisition() const +Size NotebookbarTabControlBase::calculateRequisition() const { Size aOptimalPageSize(0, 0); @@ -2712,7 +2733,7 @@ Size NotebookbarTabControl::calculateRequisition() const //We need to force all tabs to exist to get overall optimal size for dialog if (!pPage) { - NotebookbarTabControl *pThis = const_cast(this); + NotebookbarTabControlBase *pThis = const_cast(this); pThis->SetCurPageId(it->mnId); pThis->ActivatePage(); pPage = it->mpTabPage; @@ -2734,7 +2755,7 @@ Size NotebookbarTabControl::calculateRequisition() const //page and re-activate it if (nOrigPageId != GetCurPageId()) { - NotebookbarTabControl *pThis = const_cast(this); + NotebookbarTabControlBase *pThis = const_cast(this); pThis->SetCurPageId(nOrigPageId); pThis->ActivatePage(); } @@ -2743,7 +2764,7 @@ Size NotebookbarTabControl::calculateRequisition() const for( std::vector< ImplTabItem >::const_iterator it = mpTabCtrlData->maItemList.begin(); it != mpTabCtrlData->maItemList.end(); ++it ) { - NotebookbarTabControl* pThis = const_cast(this); + NotebookbarTabControlBase* pThis = const_cast(this); sal_uInt16 nPos = it - mpTabCtrlData->maItemList.begin(); Rectangle aTabRect = pThis->ImplGetTabRect(nPos, aOptimalPageSize.Width(), LONG_MAX); -- cgit