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 <s.mehrbrodt@gmail.com>
Tested-by: Samuel Mehrbrodt <s.mehrbrodt@gmail.com>
This commit is contained in:
Szymon Kłos
2016-08-06 23:31:18 +02:00
committed by Samuel Mehrbrodt
parent fc185fd353
commit dabb20ebd5
31 changed files with 1247 additions and 51 deletions

View File

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

View File

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

View File

@@ -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 <macros/xserviceinfo.hxx>
#include <stdtypes.h>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/lang/XTypeProvider.hpp>
#include <com/sun/star/lang/XInitialization.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/frame/XFrame.hpp>
#include <com/sun/star/frame/XDispatch.hpp>
#include <com/sun/star/frame/XStatusListener.hpp>
#include <com/sun/star/frame/XPopupMenuController.hpp>
#include <svtools/popupmenucontrollerbase.hxx>
#include <toolkit/awt/vclxmenu.hxx>
#include <cppuhelper/weak.hxx>
#include <rtl/ustring.hxx>
#include <vector>
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: */

View File

@@ -49,6 +49,7 @@
#include <uielement/langselectionmenucontroller.hxx>
#include <uielement/macrosmenucontroller.hxx>
#include <uielement/newmenucontroller.hxx>
#include <uielement/toolbarmodemenucontroller.hxx>
#include <uielement/toolbarsmenucontroller.hxx>
#include <uielement/notebookbarmenucontroller.hxx>
@@ -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

View File

@@ -30,6 +30,9 @@
#include <com/sun/star/frame/XLayoutManager.hpp>
#include <com/sun/star/ui/UIElementType.hpp>
#include <officecfg/Office/UI/Notebookbar.hxx>
#include <officecfg/Office/UI/ToolbarMode.hxx>
#include <com/sun/star/frame/XModuleManager.hpp>
#include <com/sun/star/frame/ModuleManager.hpp>
#include <vcl/menu.hxx>
#include <vcl/svapp.hxx>
@@ -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<comphelper::ConfigurationChanges> 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<frame::XModuleManager> 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

View File

@@ -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 <uielement/toolbarmodemenucontroller.hxx>
#include "services.h"
#include <framework/sfxhelperfunctions.hxx>
#include <com/sun/star/beans/PropertyValue.hpp>
#include <com/sun/star/awt/MenuItemStyle.hpp>
#include <com/sun/star/frame/XDispatchProvider.hpp>
#include <com/sun/star/container/XNameContainer.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/frame/XLayoutManager.hpp>
#include <com/sun/star/ui/UIElementType.hpp>
#include <com/sun/star/frame/XModuleManager.hpp>
#include <com/sun/star/frame/ModuleManager.hpp>
#include <vcl/menu.hxx>
#include <vcl/svapp.hxx>
#include <vcl/settings.hxx>
#include <rtl/ustrbuf.hxx>
#include <toolkit/helper/vclunohelper.hxx>
#include <vcl/window.hxx>
#include <svtools/menuoptions.hxx>
#include <svtools/miscopt.hxx>
#include <officecfg/Office/UI/ToolbarMode.hxx>
#include <unotools/confignode.hxx>
// 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<XComponentContext> xContext (::comphelper::getProcessComponentContext() );
const Reference<frame::XModuleManager> 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<OUString> 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<OWeakObject *>(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<OWeakObject *>(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<VCLXPopupMenu *>(VCLXMenu::GetImplementation( xPopupMenu ));
PopupMenu* pVCLPopupMenu = pXPopupMenu ? static_cast<PopupMenu *>(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 *>(VCLXPopupMenu::GetImplementation( xPopupMenu ));
if ( pPopupMenu )
{
SolarMutexGuard aSolarMutexGuard;
PopupMenu* pVCLPopupMenu = static_cast<PopupMenu *>(pPopupMenu->GetMenu());
OUString aCmd( pVCLPopupMenu->GetItemCommand( rEvent.MenuId ));
OUStringBuffer aBuf(".uno:ToolbarMode?Mode:string=");
aBuf.append( aCmd );
URL aTargetURL;
Sequence<PropertyValue> 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<frame::XModuleManager> 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<OWeakObject*>(this), UNO_QUERY ));
fillPopupMenu( m_xPopupMenu );
}
}
IMPL_STATIC_LINK_TYPED( ToolbarModeMenuController, ExecuteHdl_Impl, void*, p, void )
{
ExecuteInfo* pExecuteInfo = static_cast<ExecuteInfo*>(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: */

View File

@@ -61,6 +61,9 @@
<implementation name="com.sun.star.comp.framework.ServiceHandler">
<service name="com.sun.star.frame.ProtocolHandler"/>
</implementation>
<implementation name="com.sun.star.comp.framework.ToolbarModeMenuController">
<service name="com.sun.star.frame.PopupMenuController"/>
</implementation>
<implementation name="com.sun.star.comp.framework.ToolBarsMenuController">
<service name="com.sun.star.frame.PopupMenuController"/>
</implementation>

View File

@@ -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<css::frame::XFrame> & xFrame,
const OUString& rUIFile);

View File

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

View File

@@ -163,6 +163,9 @@ public:
void disposeDecks();
void FadeIn();
void FadeOut();
private:
VclPtr<Deck> mpCurrentDeck;

View File

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

View File

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

View File

@@ -386,6 +386,17 @@
<value>row_operations</value>
</prop>
</node>
<node oor:name="c32" oor:op="replace">
<prop oor:name="Command">
<value>.uno:ToolbarMode</value>
</prop>
<prop oor:name="Module">
<value/>
</prop>
<prop oor:name="Controller">
<value>com.sun.star.comp.framework.ToolbarModeMenuController</value>
</prop>
</node>
</node>
<node oor:name="ToolBar">
<node oor:name="ZoomToolBox" oor:op="replace">

View File

@@ -5635,6 +5635,11 @@
<value xml:lang="en-US">~Toolbars</value>
</prop>
</node>
<node oor:name=".uno:ToolbarMode" oor:op="replace">
<prop oor:name="Label" oor:type="xs:string">
<value xml:lang="en-US">Toolbar Layout</value>
</prop>
</node>
<node oor:name=".uno:AvailableToolbars" oor:op="replace">
<prop oor:name="Label" oor:type="xs:string">
<value xml:lang="en-US">~Toolbars</value>

View File

@@ -2,17 +2,9 @@
<!DOCTYPE oor:component-data SYSTEM "../../../../../component-update.dtd">
<oor:component-data xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:install="http://openoffice.org/2004/installation" oor:name="Notebookbar" oor:package="org.openoffice.Office.UI">
<prop oor:name="Active">
<value></value>
<value>notebookbar.ui</value>
</prop>
<node oor:name="Implementations">
<node oor:name="Off" oor:op="replace">
<prop oor:name="Label">
<value xml:lang="en-US">Off</value>
</prop>
<prop oor:name="File">
<value></value>
</prop>
</node>
<node oor:name="Tabbed" oor:op="replace">
<prop oor:name="Label">
<value xml:lang="en-US">Tabbed</value>

View File

@@ -0,0 +1,288 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE oor:component-data SYSTEM "../../../../../component-update.dtd">
<oor:component-data xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:install="http://openoffice.org/2004/installation" oor:name="ToolbarMode" oor:package="org.openoffice.Office.UI">
<node oor:name="Applications">
<node oor:name="Writer" oor:op="replace">
<prop oor:name="Active">
<value>Default</value>
</prop>
<node oor:name="Modes">
<node oor:name="Default" oor:op="replace">
<prop oor:name="Label">
<value>Default</value>
</prop>
<prop oor:name="CommandArg">
<value>Default</value>
</prop>
<prop oor:name="MenuPosition">
<value>0</value>
</prop>
<prop oor:name="HasNotebookbar">
<value>false</value>
</prop>
<prop oor:name="Toolbars">
<value>
<it>private:resource/toolbar/standardbar</it>
<it>private:resource/toolbar/textobjectbar</it>
</value>
</prop>
<prop oor:name="UserToolbars">
<value>
</value>
</prop>
<prop oor:name="Sidebar">
<value>Tabs</value>
</prop>
</node>
<node oor:name="Single" oor:op="replace">
<prop oor:name="Label">
<value>Single toolbar</value>
</prop>
<prop oor:name="CommandArg">
<value>Single</value>
</prop>
<prop oor:name="MenuPosition">
<value>1</value>
</prop>
<prop oor:name="HasNotebookbar">
<value>false</value>
</prop>
<prop oor:name="Toolbars">
<value>
<it>private:resource/toolbar/singlemode</it>
</value>
</prop>
<prop oor:name="UserToolbars">
<value>
</value>
</prop>
<prop oor:name="Sidebar">
<value>Arrow</value>
</prop>
</node>
<node oor:name="Sidebar" oor:op="replace">
<prop oor:name="Label">
<value>Sidebar</value>
</prop>
<prop oor:name="CommandArg">
<value>Sidebar</value>
</prop>
<prop oor:name="MenuPosition">
<value>2</value>
</prop>
<prop oor:name="HasNotebookbar">
<value>false</value>
</prop>
<prop oor:name="Toolbars">
<value>
<it>private:resource/toolbar/standardbar</it>
</value>
</prop>
<prop oor:name="UserToolbars">
<value>
</value>
</prop>
<prop oor:name="Sidebar">
<value>Opened</value>
</prop>
</node>
<node oor:name="Notebookbar" oor:op="replace">
<prop oor:name="Label">
<value>Notebookbar</value>
</prop>
<prop oor:name="HasNotebookbar">
<value>true</value>
</prop>
<prop oor:name="MenuPosition">
<value>3</value>
</prop>
<prop oor:name="CommandArg">
<value>Notebookbar</value>
</prop>
<prop oor:name="Toolbars">
<value>
</value>
</prop>
<prop oor:name="UserToolbars">
<value>
</value>
</prop>
<prop oor:name="Sidebar">
<value>Arrow</value>
</prop>
</node>
</node>
</node>
<node oor:name="Calc" oor:op="replace">
<prop oor:name="Active">
<value>Default</value>
</prop>
<node oor:name="Modes">
<node oor:name="Default" oor:op="replace">
<prop oor:name="Label">
<value>Default</value>
</prop>
<prop oor:name="CommandArg">
<value>Default</value>
</prop>
<prop oor:name="MenuPosition">
<value>0</value>
</prop>
<prop oor:name="HasNotebookbar">
<value>false</value>
</prop>
<prop oor:name="Toolbars">
<value>
<it>private:resource/toolbar/standardbar</it>
<it>private:resource/toolbar/formatobjectbar</it>
</value>
</prop>
<prop oor:name="UserToolbars">
<value>
</value>
</prop>
<prop oor:name="Sidebar">
<value>Tabs</value>
</prop>
</node>
<node oor:name="Single" oor:op="replace">
<prop oor:name="Label">
<value>Single toolbar</value>
</prop>
<prop oor:name="CommandArg">
<value>Single</value>
</prop>
<prop oor:name="MenuPosition">
<value>1</value>
</prop>
<prop oor:name="HasNotebookbar">
<value>false</value>
</prop>
<prop oor:name="Toolbars">
<value>
<it>private:resource/toolbar/singlemode</it>
</value>
</prop>
<prop oor:name="UserToolbars">
<value>
</value>
</prop>
<prop oor:name="Sidebar">
<value>Arrow</value>
</prop>
</node>
<node oor:name="Sidebar" oor:op="replace">
<prop oor:name="Label">
<value>Sidebar</value>
</prop>
<prop oor:name="CommandArg">
<value>Sidebar</value>
</prop>
<prop oor:name="MenuPosition">
<value>2</value>
</prop>
<prop oor:name="HasNotebookbar">
<value>false</value>
</prop>
<prop oor:name="Toolbars">
<value>
<it>private:resource/toolbar/standardbar</it>
</value>
</prop>
<prop oor:name="UserToolbars">
<value>
</value>
</prop>
<prop oor:name="Sidebar">
<value>Opened</value>
</prop>
</node>
<node oor:name="Notebookbar" oor:op="replace">
<prop oor:name="Label">
<value>Notebookbar</value>
</prop>
<prop oor:name="HasNotebookbar">
<value>true</value>
</prop>
<prop oor:name="MenuPosition">
<value>3</value>
</prop>
<prop oor:name="CommandArg">
<value>Notebookbar</value>
</prop>
<prop oor:name="Toolbars">
<value>
</value>
</prop>
<prop oor:name="UserToolbars">
<value>
</value>
</prop>
<prop oor:name="Sidebar">
<value>Arrow</value>
</prop>
</node>
</node>
</node>
<node oor:name="Impress" oor:op="replace">
<prop oor:name="Active">
<value>Default</value>
</prop>
<node oor:name="Modes">
<node oor:name="Default" oor:op="replace">
<prop oor:name="Label">
<value>Default</value>
</prop>
<prop oor:name="CommandArg">
<value>Default</value>
</prop>
<prop oor:name="MenuPosition">
<value>0</value>
</prop>
<prop oor:name="HasNotebookbar">
<value>false</value>
</prop>
<prop oor:name="Toolbars">
<value>
<it>private:resource/toolbar/standardbar</it>
<it>private:resource/toolbar/toolbar</it>
<it>private:resource/toolbar/commontaskbar</it>
</value>
</prop>
<prop oor:name="UserToolbars">
<value>
</value>
</prop>
<prop oor:name="Sidebar">
<value>Opened</value>
</prop>
</node>
<node oor:name="Notebookbar" oor:op="replace">
<prop oor:name="Label">
<value>Notebookbar</value>
</prop>
<prop oor:name="HasNotebookbar">
<value>true</value>
</prop>
<prop oor:name="MenuPosition">
<value>3</value>
</prop>
<prop oor:name="CommandArg">
<value>Notebookbar</value>
</prop>
<prop oor:name="Toolbars">
<value>
</value>
</prop>
<prop oor:name="UserToolbars">
<value>
</value>
</prop>
<prop oor:name="Sidebar">
<value>Arrow</value>
</prop>
</node>
</node>
</node>
</node>
</oor:component-data>

View File

@@ -0,0 +1,93 @@
<?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/.
*
* 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 .
-->
<!DOCTYPE oor:component-schema SYSTEM "../../../../../component-schema.dtd">
<oor:component-schema xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" oor:name="ToolbarMode" oor:package="org.openoffice.Office.UI" xml:lang="en-US">
<info>
<desc>Contains information about toolbar modes.</desc>
</info>
<templates>
<group oor:name="ModeEntry">
<info>
<desc>The container for mode description.</desc>
</info>
<prop oor:name="Label" oor:type="xs:string" oor:nillable="false" oor:localized="true">
<info>
<desc>The toolbar mode label.</desc>
</info>
</prop>
<prop oor:name="CommandArg" oor:type="xs:string" oor:nillable="false">
<info>
<desc>The toolbar mode name to use as a parameter in the UNO command. Must be a single word.</desc>
</info>
</prop>
<prop oor:name="MenuPosition" oor:type="xs:int" oor:nillable="false">
<info>
<desc>Position in the menu.</desc>
</info>
</prop>
<prop oor:name="HasNotebookbar" oor:type="xs:boolean" oor:nillable="false">
<info>
<desc>Determines if Notebookbar is visible.</desc>
</info>
</prop>
<prop oor:name="Toolbars" oor:type="oor:string-list" oor:nillable="false">
<info>
<desc>List of mandatory toolbars.</desc>
</info>
</prop>
<prop oor:name="UserToolbars" oor:type="oor:string-list" oor:nillable="false">
<info>
<desc>List of visible toolbars activated by user.</desc>
</info>
</prop>
<prop oor:name="Sidebar" oor:type="xs:string" oor:nillable="false">
<info>
<desc>
Describes sidebar mode.
Arrow - sidebar coollapsed, showing the 'open' arrow button
Tabs - sidebar is showing only tab bars
Opened - sidebar fully opened
</desc>
</info>
</prop>
</group>
<group oor:name="Application">
<info>
<desc>Describes toolbar modes for one application.</desc>
</info>
<prop oor:name="Active" oor:type="xs:string" oor:nillable="false">
<info>
<desc>Contains name of currently used mode.</desc>
</info>
</prop>
<set oor:name="Modes" oor:node-type="ModeEntry">
<info>
<desc>Contains list of toolbar modes.</desc>
</info>
</set>
</group>
</templates>
<component>
<set oor:name="Applications" oor:node-type="Application">
<info>
<desc>Contains list of toolbar mode settings for each application.</desc>
</info>
</set>
</component>
</oor:component-schema>

View File

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

View File

@@ -1099,14 +1099,10 @@ void ScDocShell::Execute( SfxRequest& rReq )
{
const SfxStringItem* pFile = rReq.GetArg<SfxStringItem>( 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;

View File

@@ -132,7 +132,9 @@
<menu:menuitem menu:id=".uno:NormalViewMode" menu:style="radio"/>
<menu:menuitem menu:id=".uno:PagebreakMode" menu:style="radio"/>
<menu:menuseparator/>
<menu:menuitem menu:id=".uno:ToolbarMode"/>
<menu:menuitem menu:id=".uno:AvailableToolbars"/>
<menu:menuitem menu:id=".uno:Notebookbar"/>
<menu:menuitem menu:id=".uno:InputLineVisible"/>
<menu:menuitem menu:id=".uno:StatusBarVisible"/>
<menu:menuitem menu:id=".uno:ShowImeStatusWindow"/>

View File

@@ -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() )
{
sfx2::SfxNotebookBar::CloseMethod( rBindings );
if ( sfx2::SfxNotebookBar::IsActive() )
sfx2::SfxNotebookBar::ExecMethod( rBindings );
}
sfx2::SfxNotebookBar::ExecMethod( rBindings, pFile ? pFile->GetValue() : "" );
else
sfx2::SfxNotebookBar::CloseMethod( rBindings );
}
}
break;

View File

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

View File

@@ -107,7 +107,9 @@
<menu:menuitem menu:id=".uno:NotesMasterPage" menu:style="radio"/>
<menu:menuitem menu:id=".uno:HandoutMode" menu:style="radio"/>
<menu:menuseparator/>
<menu:menuitem menu:id=".uno:ToolbarMode"/>
<menu:menuitem menu:id=".uno:AvailableToolbars"/>
<menu:menuitem menu:id=".uno:Notebookbar"/>
<menu:menuitem menu:id=".uno:StatusBarVisible"/>
<menu:menuitem menu:id=".uno:ShowRuler"/>
<menu:menuitem menu:id=".uno:LeftPaneImpress"/>

View File

@@ -166,6 +166,11 @@ interface Application
SID_RECENTFILELIST
[
]
SID_TOOLBAR_MODE
[
ExecMethod = MiscExec_Impl ;
StateMethod = MiscState_Impl ;
]
SID_AVAILABLE_TOOLBARS
[
ExecMethod = MiscExec_Impl ;

View File

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

View File

@@ -38,6 +38,8 @@
#include <com/sun/star/task/XJobExecutor.hpp>
#include <com/sun/star/text/ModuleDispatcher.hpp>
#include <com/sun/star/ui/dialogs/AddressBookSourcePilot.hpp>
#include <com/sun/star/ui/UIElementType.hpp>
#include <com/sun/star/ui/XUIElement.hpp>
#include <com/sun/star/uno/Reference.hxx>
#include <com/sun/star/util/XCloseable.hpp>
#include <com/sun/star/util/CloseVetoException.hpp>
@@ -70,9 +72,11 @@
#include <vcl/stdtext.hxx>
#include <rtl/ustrbuf.hxx>
#include <osl/file.hxx>
#include <vcl/EnumContext.hxx>
#include <unotools/pathoptions.hxx>
#include <unotools/moduleoptions.hxx>
#include <unotools/viewoptions.hxx>
#include <svtools/helpopt.hxx>
#include <toolkit/helper/vclunohelper.hxx>
#include <unotools/bootstrap.hxx>
@@ -118,8 +122,14 @@
#include <sfx2/sfxhelp.hxx>
#include <sfx2/zoomitem.hxx>
#include <sfx2/templatedlg.hxx>
#include <sfx2/sidebar/Sidebar.hxx>
#include <sfx2/notebookbar/SfxNotebookBar.hxx>
#include <sfx2/sidebar/SidebarController.hxx>
#include <comphelper/types.hxx>
#include <officecfg/Office/Common.hxx>
#include <officecfg/Office/UI/ToolbarMode.hxx>
#include <unotools/confignode.hxx>
#include <officecfg/Setup.hxx>
#include <memory>
@@ -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<SfxStringItem>( SID_TOOLBAR_MODE );
if ( !pModeName )
{
bDone = true;
break;
}
OUString aNewName(pModeName->GetValue());
uno::Reference< uno::XComponentContext > xContext =
::comphelper::getProcessComponentContext();
Reference<XDesktop2> xDesktop = Desktop::create( xContext );
Reference<XFrame> xFrame = xDesktop->getActiveFrame();
const Reference<frame::XModuleManager> 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<css::beans::XPropertySet> xPropSet( xFrame, UNO_QUERY );
Reference<css::frame::XLayoutManager> 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<OUString> aMandatoryToolbars;
css::uno::Sequence<OUString> aUserToolbars;
std::vector<OUString> 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<OUString> 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<OUString> >();
aUserToolbars = aModeNode.getNodeValue( "UserToolbars" ).get< uno::Sequence<OUString> >();
aSidebarMode = comphelper::getString( aModeNode.getNodeValue( "Sidebar" ) );
break;
}
}
if ( bCorrectMode )
{
// Backup visible toolbar list and hide all toolbars
Sequence<Reference<XUIElement>> 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<OUString> 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<SfxStringItem>(SID_AVAILABLE_TOOLBARS);

View File

@@ -22,10 +22,15 @@
#include <com/sun/star/frame/XLayoutManager.hpp>
#include "NotebookBarPopupMenu.hxx"
#include <officecfg/Office/UI/Notebookbar.hxx>
#include <com/sun/star/frame/XModuleManager.hpp>
#include <com/sun/star/frame/ModuleManager.hpp>
#include <unotools/confignode.hxx>
#include <comphelper/types.hxx>
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())
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<frame::XModuleManager> 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<OUString> 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<comphelper::ConfigurationChanges> 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<css::frame::XFrame> & 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)

View File

@@ -1303,6 +1303,18 @@ void SidebarController::updateModel(const css::uno::Reference<css::frame::XModel
mpResourceManager->UpdateModel(xModel);
}
void SidebarController::FadeOut()
{
if (mpSplitWindow)
mpSplitWindow->FadeOut();
}
void SidebarController::FadeIn()
{
if (mpSplitWindow)
mpSplitWindow->FadeIn();
}
} } // end of namespace sfx2::sidebar

View File

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

View File

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

View File

@@ -146,7 +146,9 @@
<menu:menuitem menu:id=".uno:PrintLayout" menu:style="radio"/>
<menu:menuitem menu:id=".uno:BrowseView" menu:style="radio"/>
<menu:menuseparator/>
<menu:menuitem menu:id=".uno:ToolbarMode"/>
<menu:menuitem menu:id=".uno:AvailableToolbars"/>
<menu:menuitem menu:id=".uno:Notebookbar"/>
<menu:menuitem menu:id=".uno:StatusBarVisible"/>
<menu:menu menu:id=".uno:RulerMenu">
<menu:menupopup>