summaryrefslogtreecommitdiff
path: root/sfx2/source/sidebar/SidebarToolBox.cxx
diff options
context:
space:
mode:
authorAndre Fischer <af@apache.org>2013-05-16 11:43:55 +0000
committerCaolán McNamara <caolanm@redhat.com>2013-05-21 16:36:07 +0100
commitedaca7c6e1d1ade6bf6cdae753028ee62297f0b1 (patch)
tree7d753b4337f8b993c3585fd4597a65e7672c2d49 /sfx2/source/sidebar/SidebarToolBox.cxx
parentaad035bd70b29253e9206de48259a9f0943bbc41 (diff)
Resolves: #i121960# Improve creation of toolbox/toolbar controllers
(cherry picked from commit 3608a33d8362cbc44a2eb7203b7d1bffe481c7ab) Conflicts: sfx2/inc/sfx2/sidebar/ControlFactory.hxx sfx2/inc/sfx2/sidebar/ControllerFactory.hxx sfx2/inc/sfx2/sidebar/SidebarToolBox.hxx sfx2/inc/sfx2/sidebar/Tools.hxx sfx2/source/sidebar/ToolBoxBackground.cxx Change-Id: I833a33bbc58ebe46bd28c6d97a4d76329f1f0186
Diffstat (limited to 'sfx2/source/sidebar/SidebarToolBox.cxx')
-rw-r--r--sfx2/source/sidebar/SidebarToolBox.cxx28
1 files changed, 20 insertions, 8 deletions
diff --git a/sfx2/source/sidebar/SidebarToolBox.cxx b/sfx2/source/sidebar/SidebarToolBox.cxx
index 0fcf64e45fdf..d4aa7b6afe78 100644
--- a/sfx2/source/sidebar/SidebarToolBox.cxx
+++ b/sfx2/source/sidebar/SidebarToolBox.cxx
@@ -23,6 +23,7 @@
#include "sfx2/sidebar/Tools.hxx"
#include <vcl/gradient.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
#include <svtools/miscopt.hxx>
#include <framework/imageproducer.hxx>
#include <com/sun/star/frame/XSubToolbarController.hpp>
@@ -51,8 +52,15 @@ SidebarToolBox::SidebarToolBox (
if (rxFrame.is())
{
const sal_uInt16 nItemCount (GetItemCount());
- for (sal_uInt16 nItemIndex=0; nItemIndex<nItemCount; ++nItemIndex)
- CreateController(GetItemId(nItemIndex), rxFrame);
+ if (nItemCount == 1)
+ {
+ // When there is only one item then make that as wide as
+ // the tool box.
+ CreateController(GetItemId(0), rxFrame, GetSizePixel().Width());
+ }
+ else
+ for (sal_uInt16 nItemIndex=0; nItemIndex<nItemCount; ++nItemIndex)
+ CreateController(GetItemId(nItemIndex), rxFrame, 0);
UpdateIcons(rxFrame);
SetSizePixel(CalcWindowSizePixel());
@@ -215,7 +223,8 @@ long SidebarToolBox::Notify (NotifyEvent& rEvent)
void SidebarToolBox::CreateController (
const sal_uInt16 nItemId,
- const cssu::Reference<css::frame::XFrame>& rxFrame)
+ const cssu::Reference<css::frame::XFrame>& rxFrame,
+ const sal_Int32 nItemWidth)
{
ItemDescriptor aDescriptor;
@@ -225,13 +234,16 @@ void SidebarToolBox::CreateController (
this,
nItemId,
sCommandName,
- rxFrame);
- aDescriptor.maURL = sfx2::sidebar::Tools::GetURL(sCommandName);
- aDescriptor.msCurrentCommand = sCommandName;
- aDescriptor.mxDispatch = sfx2::sidebar::Tools::GetDispatch(rxFrame, aDescriptor.maURL);
+ rxFrame,
+ VCLUnoHelper::GetInterface(this),
+ nItemWidth);
+ if (aDescriptor.mxController.is())
+ {
+ aDescriptor.maURL = sfx2::sidebar::Tools::GetURL(sCommandName);
+ aDescriptor.msCurrentCommand = sCommandName;
- if (aDescriptor.mxController.is() && aDescriptor.mxDispatch.is())
maControllers.insert(::std::make_pair(nItemId, aDescriptor));
+ }
}