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 <ci@libreoffice.org>
Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
This commit is contained in:
Szymon Kłos
2017-02-21 11:31:18 +01:00
committed by Samuel Mehrbrodt
parent 5411d99c0a
commit e681749ffa
24 changed files with 431 additions and 83 deletions

View File

@@ -825,7 +825,7 @@
<glade-widget-class title="Show Text" name="cuilo-SvxShowText"
generic-name="ShowText" parent="GtkDrawingArea"
icon-name="widget-gtk-drawingarea"/>
<glade-widget-class title="Notebook switching tabs depending on context" name="vcllo-NotebookbarTabControl"
<glade-widget-class title="Notebook switching tabs depending on context" name="sfxlo-NotebookbarTabControl"
generic-name="NotebookbarTabControl" parent="GtkNotebook"
icon-name="widget-gtk-notebook"/>
<glade-widget-class title="Slide Transition Pane" name="sdlo-SlideTransitionBox"

View File

@@ -19,7 +19,6 @@ class NotebookbarContextControl
public:
virtual ~NotebookbarContextControl() {}
virtual void SetContext( vcl::EnumContext::Context eContext ) = 0;
virtual void SetIconClickHdl( Link<NotebookBar*, void> aHdl ) = 0;
};
#endif // INCLUDED_SFX2_NOTEBOOKBAR_NOTEBOOKBARCONTEXTCONTROL_HXX

View File

@@ -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 <vcl/toolbox.hxx>
#include <sfx2/dllapi.h>
#include <com/sun/star/frame/XLayoutManager.hpp>
#include <vcl/tabctrl.hxx>
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<css::uno::XComponentContext>& xContext,
const css::uno::Reference<css::frame::XFrame>& 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: */

View File

@@ -50,8 +50,6 @@ public:
private:
static bool m_bLock;
static bool m_bHide;
DECL_STATIC_LINK(SfxNotebookBar, OpenNotebookbarPopupMenu, NotebookBar*, void);
};
} // namespace sfx2

View File

@@ -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<NotebookBar*, void> aHdl);
void SetSystemWindow(SystemWindow* pSystemWindow);
const css::uno::Reference<css::ui::XContextChangeEventListener>& getContextChangeEventListener() const { return m_pEventListener; }

View File

@@ -22,6 +22,7 @@
#include <vcl/dllapi.h>
#include <vcl/ctrl.hxx>
#include <vcl/toolbox.hxx>
#include <vcl/EnumContext.hxx>
#include <sfx2/notebookbar/NotebookbarContextControl.hxx>
@@ -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<NotebookBar*, void> aHdl ) override;
void SetIconClickHdl( Link<NotebookBar*, void> 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<NotebookBar*,void> m_aIconClickHdl;
static sal_uInt16 m_nHeaderHeight;
VclPtr<ToolBox> m_pShortcuts;
};
#endif // INCLUDED_VCL_TABCTRL_HXX

View File

@@ -733,6 +733,17 @@
<value>false</value>
</prop>
</node>
<node oor:name="private:resource/toolbar/notebookbarshortcuts" oor:op="replace">
<prop oor:name="UIName" oor:type="xs:string">
<value xml:lang="en-US">Notebookbar shortcuts</value>
</prop>
<prop oor:name="Visible" oor:type="xs:boolean">
<value>false</value>
</prop>
<prop oor:name="HideFromToolbarMenu" oor:type="xs:boolean">
<value>true</value>
</prop>
</node>
</node>
</node>
</oor:component-data>

View File

@@ -1028,6 +1028,17 @@
<value>false</value>
</prop>
</node>
<node oor:name="private:resource/toolbar/notebookbarshortcuts" oor:op="replace">
<prop oor:name="UIName" oor:type="xs:string">
<value xml:lang="en-US">Notebookbar shortcuts</value>
</prop>
<prop oor:name="Visible" oor:type="xs:boolean">
<value>false</value>
</prop>
<prop oor:name="HideFromToolbarMenu" oor:type="xs:boolean">
<value>true</value>
</prop>
</node>
</node>
</node>
</oor:component-data>

View File

@@ -108,6 +108,17 @@
<value>true</value>
</prop>
</node>
<node oor:name="private:resource/toolbar/notebookbarshortcuts" oor:op="replace">
<prop oor:name="UIName" oor:type="xs:string">
<value xml:lang="en-US">Notebookbar shortcuts</value>
</prop>
<prop oor:name="Visible" oor:type="xs:boolean">
<value>false</value>
</prop>
<prop oor:name="HideFromToolbarMenu" oor:type="xs:boolean">
<value>true</value>
</prop>
</node>
<node oor:name="private:resource/toolbar/findbar" oor:op="replace">
<prop oor:name="DockPos" oor:type="xs:string">
<value>0,1</value>

View File

@@ -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 \

View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
* 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/.
*
-->
<toolbar:toolbar xmlns:toolbar="http://openoffice.org/2001/toolbar" xmlns:xlink="http://www.w3.org/1999/xlink">
<toolbar:toolbaritem xlink:href=".uno:Open"/>
<toolbar:toolbaritem xlink:href=".uno:Save"/>
<toolbar:toolbaritem xlink:href=".uno:Undo"/>
<toolbar:toolbaritem xlink:href=".uno:Redo"/>
</toolbar:toolbar>

View File

@@ -197,7 +197,7 @@
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="vcllo-NotebookbarTabControl" id="ContextContainer">
<object class="sfxlo-NotebookbarTabControl" id="ContextContainer">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>

View File

@@ -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 \

View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
* 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/.
*
-->
<toolbar:toolbar xmlns:toolbar="http://openoffice.org/2001/toolbar" xmlns:xlink="http://www.w3.org/1999/xlink">
<toolbar:toolbaritem xlink:href=".uno:Open"/>
<toolbar:toolbaritem xlink:href=".uno:Save"/>
<toolbar:toolbaritem xlink:href=".uno:Undo"/>
<toolbar:toolbaritem xlink:href=".uno:Redo"/>
</toolbar:toolbar>

View File

@@ -187,7 +187,7 @@
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="vcllo-NotebookbarTabControl" id="ContextContainer">
<object class="sfxlo-NotebookbarTabControl" id="ContextContainer">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>

View File

@@ -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 \

View File

@@ -68,11 +68,6 @@ public:
aSize.Width() += 6;
SetSizePixel( aSize );
}
void SetIconClickHdl( Link<NotebookBar*, void> ) override
{
// Menu not supported
}
};
VCL_BUILDER_FACTORY(ContextVBox)

View File

@@ -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 <vcl/builderfactory.hxx>
#include <vcl/layout.hxx>
#include <sfx2/viewfrm.hxx>
#include <sfx2/notebookbar/NotebookbarTabControl.hxx>
#include <com/sun/star/ui/theModuleUIConfigurationManagerSupplier.hpp>
#include <com/sun/star/ui/XUIConfigurationManagerSupplier.hpp>
#include <com/sun/star/ui/ItemType.hpp>
#include <com/sun/star/frame/XModuleManager.hpp>
#include <com/sun/star/frame/ModuleManager.hpp>
#include <sfx2/notebookbar/SfxNotebookBar.hxx>
#include <com/sun/star/uno/Reference.h>
#include <toolkit/awt/vclxmenu.hxx>
#include <com/sun/star/frame/XPopupMenuController.hpp>
#include <comphelper/processfactory.hxx>
#include <comphelper/propertyvalue.hxx>
#include <sfx2/sidebar/SidebarToolBox.hxx>
#include <cppuhelper/queryinterface.hxx>
#include <cppuhelper/implbase.hxx>
#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<XUIConfigurationListener>
{
VclPtr<NotebookbarTabControl> m_pParent;
public:
explicit ChangedUIEventListener(NotebookbarTabControl *p)
: m_pParent(p)
{
try
{
Reference<XComponentContext> xContext = comphelper::getProcessComponentContext();
const Reference<XModuleManager> xModuleManager = ModuleManager::create( xContext );
Reference<XFrame> xFrame = SfxViewFrame::Current()->GetFrame().GetFrameInterface();
OUString aModuleName = xModuleManager->identify( xFrame );
Reference<XUIConfigurationManager> m_xConfigManager;
Reference<XModuleUIConfigurationManagerSupplier > 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<ShortcutsToolBox> pShortcuts = VclPtr<ShortcutsToolBox>::Create( this );
pShortcuts->Show();
SetToolBox( static_cast<ToolBox*>( 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<XComponentContext> xContext = comphelper::getProcessComponentContext();
const Reference<XModuleManager> xModuleManager = ModuleManager::create( xContext );
Reference<XFrame> 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<XComponentContext>& xContext,
const Reference<XFrame>& xFrame,
const OUString& aModuleName,
ToolBox* pShortcuts
)
{
Reference<::com::sun::star::container::XIndexAccess> xIndex;
try
{
Reference<XUIConfigurationManager> m_xConfigManager;
Reference<XModuleUIConfigurationManagerSupplier > 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<Any> aArgs {
makeAny(comphelper::makePropertyValue("Value", OUString("notebookbar"))),
makeAny(comphelper::makePropertyValue("Frame", pViewFrame->GetFrame().GetFrameInterface())) };
Reference<XComponentContext> xContext = comphelper::getProcessComponentContext();
Reference<XPopupMenuController> xPopupController(
xContext->getServiceManager()->createInstanceWithArgumentsAndContext(
"com.sun.star.comp.framework.ResourceMenuController", aArgs, xContext), UNO_QUERY);
Reference<css::awt::XPopupMenu> 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<PopupMenu*>(pAwtMenu->GetMenu());
Point aPos(0, NotebookbarTabControl::GetHeaderHeight());
pVCLMenu->Execute(pNotebookbar, Rectangle(aPos, aPos),PopupMenuFlags::ExecuteDown|PopupMenuFlags::NoMouseUpClose);
Reference<css::lang::XComponent> xComponent(xPopupController, UNO_QUERY);
if (xComponent.is())
xComponent->dispose();
}
}
VCL_BUILDER_FACTORY( NotebookbarTabControl )
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -270,8 +270,10 @@ bool SfxNotebookBar::StateMethod(SystemWindow* pSysWindow,
if (IsActive())
{
const Reference<frame::XModuleManager> xModuleManager = frame::ModuleManager::create( ::comphelper::getProcessComponentContext() );
vcl::EnumContext::Application eApp = vcl::EnumContext::GetApplicationEnum(xModuleManager->identify(xFrame));
css::uno::Reference<css::uno::XComponentContext> xContext = comphelper::getProcessComponentContext();
const Reference<frame::XModuleManager> 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<XContextChangeEventMultiplexer> 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<css::uno::Any> aArgs {
css::uno::makeAny(comphelper::makePropertyValue("Value", OUString("notebookbar"))),
css::uno::makeAny(comphelper::makePropertyValue("Frame", pViewFrame->GetFrame().GetFrameInterface())) };
css::uno::Reference<css::uno::XComponentContext> xContext = comphelper::getProcessComponentContext();
css::uno::Reference<css::frame::XPopupMenuController> xPopupController(
xContext->getServiceManager()->createInstanceWithArgumentsAndContext(
"com.sun.star.comp.framework.ResourceMenuController", aArgs, xContext), css::uno::UNO_QUERY);
css::uno::Reference<css::awt::XPopupMenu> 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<PopupMenu*>(pAwtMenu->GetMenu());
Point aPos(0, NotebookbarTabControl::GetHeaderHeight());
pVCLMenu->Execute(pNotebookbar, Rectangle(aPos, aPos),PopupMenuFlags::ExecuteDown|PopupMenuFlags::NoMouseUpClose);
css::uno::Reference<css::lang::XComponent> xComponent(xPopupController, css::uno::UNO_QUERY);
if (xComponent.is())
xComponent->dispose();
}
}
void SfxNotebookBar::ShowMenubar(bool bShow)
{
if (!m_bLock)

View File

@@ -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 \

View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
* 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/.
*
-->
<toolbar:toolbar xmlns:toolbar="http://openoffice.org/2001/toolbar" xmlns:xlink="http://www.w3.org/1999/xlink">
<toolbar:toolbaritem xlink:href=".uno:OpenFromWriter"/>
<toolbar:toolbaritem xlink:href=".uno:Save"/>
<toolbar:toolbaritem xlink:href=".uno:Undo"/>
<toolbar:toolbaritem xlink:href=".uno:Redo"/>
</toolbar:toolbar>

View File

@@ -208,7 +208,7 @@
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="vcllo-NotebookbarTabControl" id="ContextContainer">
<object class="sfxlo-NotebookbarTabControl" id="ContextContainer">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>

View File

@@ -120,12 +120,6 @@ void NotebookBar::Resize()
Control::Resize();
}
void NotebookBar::SetIconClickHdl(Link<NotebookBar*, void> aHdl)
{
if (m_pContextContainer)
m_pContextContainer->SetIconClickHdl(aHdl);
}
void NotebookBar::SetSystemWindow(SystemWindow* pSystemWindow)
{
m_pSystemWindow = pSystemWindow;

View File

@@ -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<TabPage*>(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<NotebookBar*, void> aHdl )
void NotebookbarTabControlBase::dispose()
{
m_pShortcuts.disposeAndClear();
TabControl::dispose();
}
void NotebookbarTabControlBase::SetToolBox( ToolBox* pToolBox )
{
m_pShortcuts.set( pToolBox );
}
void NotebookbarTabControlBase::SetIconClickHdl( Link<NotebookBar*, void> 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<NotebookbarTabControl*>(this)->ImplGetTabRect( static_cast<sal_uInt16>(i) ).IsInside( rPos ) )
if ( const_cast<NotebookbarTabControlBase*>(this)->ImplGetTabRect( static_cast<sal_uInt16>(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<NotebookBar*>(GetParent()) );
m_aIconClickHdl.Call( static_cast<NotebookBar*>(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<ImplTabItem>::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<NotebookbarTabControl*>(this);
NotebookbarTabControlBase *pThis = const_cast<NotebookbarTabControlBase*>(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<NotebookbarTabControl*>(this);
NotebookbarTabControlBase *pThis = const_cast<NotebookbarTabControlBase*>(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<NotebookbarTabControl*>(this);
NotebookbarTabControlBase* pThis = const_cast<NotebookbarTabControlBase*>(this);
sal_uInt16 nPos = it - mpTabCtrlData->maItemList.begin();
Rectangle aTabRect = pThis->ImplGetTabRect(nPos, aOptimalPageSize.Width(), LONG_MAX);