[Libreoffice-commits] core.git: extras/source include/sfx2 sfx2/Library_sfx.mk sfx2/source sw/uiconfig
Maxim Monastirsky
momonasmon at gmail.com
Wed Feb 15 00:20:05 UTC 2017
extras/source/glade/libreoffice-catalog.xml.in | 12 +-
include/sfx2/sidebar/SidebarToolBox.hxx | 7 -
sfx2/Library_sfx.mk | 2
sfx2/source/notebookbar/BigToolBox.cxx | 53 ------------
sfx2/source/notebookbar/BigToolBox.hxx | 48 -----------
sfx2/source/notebookbar/NotebookbarToolBox.cxx | 49 -----------
sfx2/source/sidebar/SidebarToolBox.cxx | 108 ++++++++++++++++---------
sw/uiconfig/swriter/ui/notebookbar.ui | 24 ++++-
8 files changed, 100 insertions(+), 203 deletions(-)
New commits:
commit cdf4b2bba8d694299c784f46fe3ecef2ce41171e
Author: Maxim Monastirsky <momonasmon at gmail.com>
Date: Wed Feb 15 01:39:02 2017 +0200
Related: tdf#105672 Load toolbar properties from .ui
- Supports toolbar-style, icon-size, orientation.
- Defaults are:
toolbar-style = icons only
icon-size = what's set in Tools > Options... for Sidebar/Notebookbar
orientation = horizontal
- Remove no longer needed BigToolBox (use toolbar-style=both + icon-size=3 instead).
Change-Id: I185388255a351dfd6719a363b7e399bf36b0b25d
Reviewed-on: https://gerrit.libreoffice.org/34281
Reviewed-by: Maxim Monastirsky <momonasmon at gmail.com>
Tested-by: Maxim Monastirsky <momonasmon at gmail.com>
diff --git a/extras/source/glade/libreoffice-catalog.xml.in b/extras/source/glade/libreoffice-catalog.xml.in
index 2019ab2..6fea54a 100644
--- a/extras/source/glade/libreoffice-catalog.xml.in
+++ b/extras/source/glade/libreoffice-catalog.xml.in
@@ -726,7 +726,12 @@
<glade-widget-class title="Sidebar ToolBox" name="sfxlo-SidebarToolBox"
generic-name="Sidebar ToolBox" parent="GtkToolbar"
- icon-name="widget-gtk-toolbar"/>
+ icon-name="widget-gtk-toolbar">
+ <properties>
+ <!-- Must override the default value of "icon-size", so "Large Toolbar" will be saved into .ui -->
+ <property id="icon-size" optional-default="False" optional="True" default="GTK_ICON_SIZE_BUTTON"/>
+ </properties>
+ </glade-widget-class>
<glade-widget-class title="Writer Navigator ToolBox" name="swlo-SwNavHelpToolBox"
generic-name="Writer Navigator ToolBox" parent="GtkToolbar"
@@ -841,11 +846,8 @@
<glade-widget-class title="Box which can move own content to the popup" name="sfxlo-DropdownBox"
generic-name="DropdownBox" parent="GtkBox"
icon-name="widget-gtk-box"/>
- <glade-widget-class title="Big ToolBox" name="sfxlo-BigToolBox"
- generic-name="Big ToolBox" parent="GtkToolbar"
- icon-name="widget-gtk-toolbar"/>
<glade-widget-class title="Notebookbar ToolBox" name="sfxlo-NotebookbarToolBox"
- generic-name="Notebookbar ToolBox" parent="GtkToolbar"
+ generic-name="Notebookbar ToolBox" parent="sfxlo-SidebarToolBox"
icon-name="widget-gtk-toolbar"/>
<glade-widget-class title="Vertical box hiding childs depending on context" name="sfxlo-ContextVBox"
generic-name="ContextVBox" parent="GtkBox"
diff --git a/include/sfx2/sidebar/SidebarToolBox.hxx b/include/sfx2/sidebar/SidebarToolBox.hxx
index 19d923d..793d2a7 100644
--- a/include/sfx2/sidebar/SidebarToolBox.hxx
+++ b/include/sfx2/sidebar/SidebarToolBox.hxx
@@ -20,7 +20,6 @@
#define INCLUDED_SFX2_SIDEBAR_SIDEBARTOOLBOX_HXX
#include <sfx2/dllapi.h>
-#include <sfx2/sidebar/SidebarToolBox.hxx>
#include <vcl/toolbox.hxx>
#include <com/sun/star/frame/XDispatch.hpp>
#include <com/sun/star/frame/XFrame.hpp>
@@ -28,7 +27,6 @@
#include <com/sun/star/util/URL.hpp>
#include <map>
-
namespace sfx2 { namespace sidebar {
/** The sidebar tool box has two responsibilities:
@@ -43,7 +41,7 @@ public:
virtual ~SidebarToolBox() override;
virtual void dispose() override;
- virtual ToolBoxButtonSize GetIconSize() const;
+ virtual ToolBoxButtonSize GetDefaultButtonSize() const;
using ToolBox::InsertItem;
virtual void InsertItem(const OUString& rCommand,
@@ -59,10 +57,13 @@ public:
css::uno::Reference<css::frame::XToolbarController> GetFirstController();
+ void InitToolBox(VclBuilder::stringmap& rMap);
+
protected:
typedef std::map<sal_uInt16, css::uno::Reference<css::frame::XToolbarController>> ControllerContainer;
ControllerContainer maControllers;
bool mbAreHandlersRegistered;
+ bool mbUseDefaultButtonSize;
DECL_LINK(DropDownClickHandler, ToolBox*, void);
DECL_LINK(ClickHandler, ToolBox*, void);
diff --git a/sfx2/Library_sfx.mk b/sfx2/Library_sfx.mk
index 65e5286..6b301ba 100644
--- a/sfx2/Library_sfx.mk
+++ b/sfx2/Library_sfx.mk
@@ -239,10 +239,8 @@ $(eval $(call gb_Library_add_exception_objects,sfx,\
sfx2/source/doc/saveastemplatedlg \
sfx2/source/explorer/nochaos \
sfx2/source/inet/inettbc \
- sfx2/source/notebookbar/BigToolBox \
sfx2/source/notebookbar/ContextVBox \
sfx2/source/notebookbar/DropdownBox \
- sfx2/source/notebookbar/NotebookbarToolBox \
sfx2/source/notebookbar/PriorityHBox \
sfx2/source/notebookbar/SfxNotebookBar \
sfx2/source/notify/eventsupplier \
diff --git a/sfx2/source/notebookbar/BigToolBox.cxx b/sfx2/source/notebookbar/BigToolBox.cxx
deleted file mode 100644
index a271f04..0000000
--- a/sfx2/source/notebookbar/BigToolBox.cxx
+++ /dev/null
@@ -1,53 +0,0 @@
-/* -*- 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 "BigToolBox.hxx"
-#include <sfx2/sidebar/ControllerFactory.hxx>
-#include <sfx2/sidebar/Theme.hxx>
-#include <sfx2/sidebar/Tools.hxx>
-#include <sfx2/viewfrm.hxx>
-
-#include <vcl/builderfactory.hxx>
-#include <vcl/commandinfoprovider.hxx>
-#include <vcl/gradient.hxx>
-#include <vcl/settings.hxx>
-#include <vcl/svapp.hxx>
-#include <toolkit/helper/vclunohelper.hxx>
-#include <svtools/miscopt.hxx>
-#include <com/sun/star/frame/XSubToolbarController.hpp>
-#include <framework/addonsoptions.hxx>
-
-namespace sfx2 { namespace notebookbar {
-
-BigToolBox::BigToolBox(vcl::Window* pParent)
- : SidebarToolBox(pParent)
-{
- SvtMiscOptions aMiscOptions;
- aMiscOptions.RemoveListenerLink(LINK(this, SidebarToolBox, ChangedIconSizeHandler));
-
- SetToolboxButtonSize(ToolBoxButtonSize::Large);
- SetButtonType(ButtonType::SYMBOLTEXT);
- SetToolBoxTextPosition(ToolBoxTextPosition::Bottom);
-}
-
-VCL_BUILDER_FACTORY(BigToolBox)
-
-} } // end of namespace sfx2::notebookbar
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/notebookbar/BigToolBox.hxx b/sfx2/source/notebookbar/BigToolBox.hxx
deleted file mode 100644
index 69d2375..0000000
--- a/sfx2/source/notebookbar/BigToolBox.hxx
+++ /dev/null
@@ -1,48 +0,0 @@
-/* -*- 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_SFX2_SOURCE_NOTEBOOKBAR_BIGTOOLBOX_HXX
-#define INCLUDED_SFX2_SOURCE_NOTEBOOKBAR_BIGTOOLBOX_HXX
-
-#include <sfx2/sidebar/SidebarToolBox.hxx>
-#include <sfx2/dllapi.h>
-#include <vcl/toolbox.hxx>
-#include <com/sun/star/frame/XDispatch.hpp>
-#include <com/sun/star/frame/XFrame.hpp>
-#include <com/sun/star/frame/XToolbarController.hpp>
-#include <com/sun/star/util/URL.hpp>
-#include <map>
-
-
-namespace sfx2 { namespace notebookbar {
-
-/** BigToolBox
-*/
-
-class SFX2_DLLPUBLIC BigToolBox : public sfx2::sidebar::SidebarToolBox
-{
-public:
- explicit BigToolBox(vcl::Window* pParent);
-};
-
-
-} } // end of namespace sfx2::notebookbar
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/notebookbar/NotebookbarToolBox.cxx b/sfx2/source/notebookbar/NotebookbarToolBox.cxx
deleted file mode 100644
index 99dc666..0000000
--- a/sfx2/source/notebookbar/NotebookbarToolBox.cxx
+++ /dev/null
@@ -1,49 +0,0 @@
-/* -*- 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 <sfx2/sidebar/SidebarToolBox.hxx>
-#include <vcl/builderfactory.hxx>
-#include <svtools/miscopt.hxx>
-
-namespace sfx2 { namespace notebookbar {
-
-class NotebookbarToolBox : public sfx2::sidebar::SidebarToolBox
-{
-public:
-
- explicit NotebookbarToolBox(vcl::Window* pParentWindow)
- : sfx2::sidebar::SidebarToolBox(pParentWindow)
- {
- ToolBoxButtonSize eSize = ToolBoxButtonSize::Small;
- eSize = GetIconSize();
- SetToolboxButtonSize(eSize);
- }
-
- virtual ToolBoxButtonSize GetIconSize() const override
- {
- SvtMiscOptions aMiscOptions;
- return aMiscOptions.GetNotebookbarIconSize();
- }
-};
-
-VCL_BUILDER_FACTORY(NotebookbarToolBox)
-
-} } // end of namespace sfx2::notebookbar
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/sidebar/SidebarToolBox.cxx b/sfx2/source/sidebar/SidebarToolBox.cxx
index bb948b0..ae1855f 100644
--- a/sfx2/source/sidebar/SidebarToolBox.cxx
+++ b/sfx2/source/sidebar/SidebarToolBox.cxx
@@ -19,19 +19,15 @@
#include <sfx2/sidebar/SidebarToolBox.hxx>
#include <sfx2/sidebar/ControllerFactory.hxx>
-#include <sfx2/sidebar/Theme.hxx>
-#include <sfx2/sidebar/Tools.hxx>
#include <sfx2/viewfrm.hxx>
#include <vcl/builderfactory.hxx>
#include <vcl/commandinfoprovider.hxx>
-#include <vcl/gradient.hxx>
#include <vcl/settings.hxx>
#include <vcl/svapp.hxx>
#include <toolkit/helper/vclunohelper.hxx>
#include <svtools/miscopt.hxx>
#include <com/sun/star/frame/XSubToolbarController.hpp>
-#include <framework/addonsoptions.hxx>
using namespace css;
using namespace css::uno;
@@ -58,28 +54,20 @@ namespace sfx2 { namespace sidebar {
SidebarToolBox::SidebarToolBox (vcl::Window* pParentWindow)
: ToolBox(pParentWindow, 0),
- maControllers(),
- mbAreHandlersRegistered(false)
+ mbAreHandlersRegistered(false),
+ mbUseDefaultButtonSize(true)
{
SetBackground(Wallpaper());
SetPaintTransparent(true);
+ SetToolboxButtonSize(GetDefaultButtonSize());
- ToolBoxButtonSize eSize = ToolBoxButtonSize::Small;
-
- SvtMiscOptions aMiscOptions;
- aMiscOptions.AddListenerLink(LINK(this, SidebarToolBox, ChangedIconSizeHandler));
-
- eSize = GetIconSize();
-
- SetToolboxButtonSize(eSize);
+ SvtMiscOptions().AddListenerLink(LINK(this, SidebarToolBox, ChangedIconSizeHandler));
#ifdef DEBUG
SetText(OUString("SidebarToolBox"));
#endif
}
-VCL_BUILDER_FACTORY(SidebarToolBox)
-
SidebarToolBox::~SidebarToolBox()
{
disposeOnce();
@@ -87,8 +75,7 @@ SidebarToolBox::~SidebarToolBox()
void SidebarToolBox::dispose()
{
- SvtMiscOptions aMiscOptions;
- aMiscOptions.RemoveListenerLink(LINK(this, SidebarToolBox, ChangedIconSizeHandler));
+ SvtMiscOptions().RemoveListenerLink(LINK(this, SidebarToolBox, ChangedIconSizeHandler));
ControllerContainer aControllers;
aControllers.swap(maControllers);
@@ -115,10 +102,9 @@ void SidebarToolBox::dispose()
ToolBox::dispose();
}
-ToolBoxButtonSize SidebarToolBox::GetIconSize() const
+ToolBoxButtonSize SidebarToolBox::GetDefaultButtonSize() const
{
- SvtMiscOptions aMiscOptions;
- return aMiscOptions.GetSidebarIconSize();
+ return SvtMiscOptions().GetSidebarIconSize();
}
void SidebarToolBox::InsertItem(const OUString& rCommand,
@@ -266,18 +252,16 @@ IMPL_LINK_NOARG(SidebarToolBox, ChangedIconSizeHandler, LinkParamNone*, void)
{
SolarMutexGuard g;
- ToolBoxButtonSize eSize = GetIconSize();
+ if (mbUseDefaultButtonSize)
+ SetToolboxButtonSize(GetDefaultButtonSize());
vcl::ImageType eImageType = vcl::ImageType::Size16;
+ ToolBoxButtonSize eSize = GetToolboxButtonSize();
if (eSize == ToolBoxButtonSize::Large)
eImageType = vcl::ImageType::Size26;
else if (eSize == ToolBoxButtonSize::Size32)
eImageType = vcl::ImageType::Size32;
- bool bBig = (eImageType == vcl::ImageType::Size26 || eImageType == vcl::ImageType::Size32);
-
- SetToolboxButtonSize(eSize);
-
for (auto const& it : maControllers)
{
Reference<frame::XSubToolbarController> xController(it.second, UNO_QUERY);
@@ -287,19 +271,12 @@ IMPL_LINK_NOARG(SidebarToolBox, ChangedIconSizeHandler, LinkParamNone*, void)
// dropdown. The controller should know better than us what it was.
xController->updateImage();
}
- else
+ else if (SfxViewFrame::Current())
{
OUString aCommandURL = GetItemCommand(it.first);
- if(SfxViewFrame::Current())
- {
- css::uno::Reference<frame::XFrame> xFrame = SfxViewFrame::Current()->GetFrame().GetFrameInterface();
- Image aImage = vcl::CommandInfoProvider::Instance().GetImageForCommand(aCommandURL, xFrame, eImageType);
- // Try also to query for add-on images before giving up and use an
- // empty image.
- if (!aImage)
- aImage = framework::AddonsOptions().GetImageFromURL(aCommandURL, bBig);
- SetItemImage(it.first, aImage);
- }
+ css::uno::Reference<frame::XFrame> xFrame = SfxViewFrame::Current()->GetFrame().GetFrameInterface();
+ Image aImage = vcl::CommandInfoProvider::Instance().GetImageForCommand(aCommandURL, xFrame, eImageType);
+ SetItemImage(it.first, aImage);
}
}
@@ -307,6 +284,63 @@ IMPL_LINK_NOARG(SidebarToolBox, ChangedIconSizeHandler, LinkParamNone*, void)
queue_resize();
}
+void SidebarToolBox::InitToolBox(VclBuilder::stringmap& rMap)
+{
+ for (const auto& it : rMap)
+ {
+ if (it.first == "toolbar-style")
+ {
+ if (it.second == "text")
+ SetButtonType(ButtonType::TEXT);
+ else if (it.second == "both-horiz")
+ SetButtonType(ButtonType::SYMBOLTEXT);
+ else if (it.second == "both")
+ {
+ SetButtonType(ButtonType::SYMBOLTEXT);
+ SetToolBoxTextPosition(ToolBoxTextPosition::Bottom);
+ }
+ }
+ else if (it.first == "icon-size")
+ {
+ mbUseDefaultButtonSize = false;
+ if (it.second == "1" || it.second == "2" || it.second == "4")
+ SetToolboxButtonSize(ToolBoxButtonSize::Small);
+ else if (it.second == "3")
+ SetToolboxButtonSize(ToolBoxButtonSize::Large);
+ else if (it.second == "5")
+ SetToolboxButtonSize(ToolBoxButtonSize::Size32);
+ }
+ else if (it.first == "orientation" && it.second == "vertical")
+ SetAlign(WindowAlign::Left);
+ }
+}
+
+class NotebookbarToolBox : public SidebarToolBox
+{
+public:
+ explicit NotebookbarToolBox(vcl::Window* pParentWindow)
+ : SidebarToolBox(pParentWindow) {}
+
+ virtual ToolBoxButtonSize GetDefaultButtonSize() const override
+ {
+ return SvtMiscOptions().GetNotebookbarIconSize();
+ }
+};
+
+VCL_BUILDER_DECL_FACTORY(SidebarToolBox)
+{
+ VclPtrInstance<SidebarToolBox> pBox(pParent);
+ pBox->InitToolBox(rMap);
+ rRet = pBox;
+}
+
+VCL_BUILDER_DECL_FACTORY(NotebookbarToolBox)
+{
+ VclPtrInstance<NotebookbarToolBox> pBox(pParent);
+ pBox->InitToolBox(rMap);
+ rRet = pBox;
+}
+
} } // end of namespace sfx2::sidebar
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/uiconfig/swriter/ui/notebookbar.ui b/sw/uiconfig/swriter/ui/notebookbar.ui
index fa77d74..cc0c70c 100644
--- a/sw/uiconfig/swriter/ui/notebookbar.ui
+++ b/sw/uiconfig/swriter/ui/notebookbar.ui
@@ -406,9 +406,11 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
- <object class="sfxlo-BigToolBox" id="pastebox">
+ <object class="sfxlo-NotebookbarToolBox" id="pastebox">
<property name="visible">True</property>
<property name="can_focus">False</property>
+ <property name="toolbar_style">both</property>
+ <property name="icon_size">3</property>
<property name="valign">center</property>
<property name="show_arrow">False</property>
<child>
@@ -1875,9 +1877,11 @@
</packing>
</child>
<child>
- <object class="sfxlo-BigToolBox" id="tablebox">
+ <object class="sfxlo-NotebookbarToolBox" id="tablebox">
<property name="visible">True</property>
<property name="can_focus">False</property>
+ <property name="toolbar_style">both</property>
+ <property name="icon_size">3</property>
<property name="valign">center</property>
<property name="show_arrow">False</property>
<child>
@@ -2801,9 +2805,11 @@
</packing>
</child>
<child>
- <object class="sfxlo-BigToolBox" id="sizebox">
+ <object class="sfxlo-NotebookbarToolBox" id="sizebox">
<property name="visible">True</property>
<property name="can_focus">False</property>
+ <property name="toolbar_style">both</property>
+ <property name="icon_size">3</property>
<property name="valign">center</property>
<property name="show_arrow">False</property>
<child>
@@ -2828,9 +2834,11 @@
</packing>
</child>
<child>
- <object class="sfxlo-BigToolBox" id="columnbox">
+ <object class="sfxlo-NotebookbarToolBox" id="columnbox">
<property name="visible">True</property>
<property name="can_focus">False</property>
+ <property name="toolbar_style">both</property>
+ <property name="icon_size">3</property>
<property name="valign">center</property>
<property name="show_arrow">False</property>
<child>
@@ -2855,9 +2863,11 @@
</packing>
</child>
<child>
- <object class="sfxlo-BigToolBox" id="orientationbox">
+ <object class="sfxlo-NotebookbarToolBox" id="orientationbox">
<property name="visible">True</property>
<property name="can_focus">False</property>
+ <property name="toolbar_style">both</property>
+ <property name="icon_size">3</property>
<property name="valign">center</property>
<property name="show_arrow">False</property>
<child>
@@ -2882,9 +2892,11 @@
</packing>
</child>
<child>
- <object class="sfxlo-BigToolBox" id="marginbox">
+ <object class="sfxlo-NotebookbarToolBox" id="marginbox">
<property name="visible">True</property>
<property name="can_focus">False</property>
+ <property name="toolbar_style">both</property>
+ <property name="icon_size">3</property>
<property name="valign">center</property>
<property name="show_arrow">False</property>
<child>
More information about the Libreoffice-commits
mailing list