[Libreoffice-commits] core.git: Branch 'aoo/trunk' - 2 commits - sfx2/inc sfx2/source svx/source
Andre Fischer
af at apache.org
Thu May 16 05:07:15 PDT 2013
sfx2/inc/sfx2/sidebar/ControlFactory.hxx | 29 ++++
sfx2/inc/sfx2/sidebar/ControllerFactory.hxx | 16 ++
sfx2/inc/sfx2/sidebar/SidebarToolBox.hxx | 4
sfx2/inc/sfx2/sidebar/Tools.hxx | 3
sfx2/source/sidebar/ControlFactory.cxx | 5
sfx2/source/sidebar/ControllerFactory.cxx | 132 +++++++++++++++++++---
sfx2/source/sidebar/Deck.cxx | 86 +++++++-------
sfx2/source/sidebar/Deck.hxx | 5
sfx2/source/sidebar/FocusManager.cxx | 8 +
sfx2/source/sidebar/ResourceManager.cxx | 26 ----
sfx2/source/sidebar/ResourceManager.hxx | 3
sfx2/source/sidebar/SidebarToolBox.cxx | 28 +++-
sfx2/source/sidebar/ToolBoxBackground.cxx | 13 +-
sfx2/source/sidebar/ToolBoxBackground.hxx | 4
sfx2/source/sidebar/Tools.cxx | 25 ++++
svx/source/sidebar/insert/InsertPropertyPanel.hxx | 2
16 files changed, 279 insertions(+), 110 deletions(-)
New commits:
commit 3608a33d8362cbc44a2eb7203b7d1bffe481c7ab
Author: Andre Fischer <af at apache.org>
Date: Thu May 16 11:43:55 2013 +0000
121960: Improve creation of toolbox/toolbar controllers.
diff --git a/sfx2/inc/sfx2/sidebar/ControlFactory.hxx b/sfx2/inc/sfx2/sidebar/ControlFactory.hxx
index 623abf1..f232835 100644
--- a/sfx2/inc/sfx2/sidebar/ControlFactory.hxx
+++ b/sfx2/inc/sfx2/sidebar/ControlFactory.hxx
@@ -32,26 +32,49 @@ namespace sfx2 { namespace sidebar {
class ToolBoxBackground;
+/** Factory for controls used in sidebar panels.
+ The reason to use this factory instead of creating the controls
+ directly is that this way the sidebar has a little more control
+ over look and feel of its controls.
+*/
class SFX2_DLLPUBLIC ControlFactory
{
public:
+ /** Create the menu button for the task bar.
+ */
static CheckBox* CreateMenuButton (Window* pParentWindow);
+
static ImageRadioButton* CreateTabItem (Window* pParentWindow);
- /** Create a tool box that does *not* handle its items.
+ /** Create a tool box that does *not* handle its items. The
+ caller has to register callbacks to process, among others,
+ click and selection events.
*/
static SidebarToolBox* CreateToolBox (
Window* pParentWindow,
const ResId& rResId);
- /** Create a tool box that *does* handle its items.
+ /** Create a tool box that *does* handle its items. All event
+ processing is done by toolbox controllers.
*/
static SidebarToolBox* CreateToolBox (
Window* pParentWindow,
const ResId& rResId,
const ::com::sun::star::uno::Reference<com::sun::star::frame::XFrame>& rxFrame);
- static Window* CreateToolBoxBackground (Window* pParentWindow);
+ /** Create a window that acts as background of a tool box.
+ In general it is slightly larger than the tool box.
+ @param pParentWindow
+ The parent window of the new background control.
+ @param bShowBorder
+ When <TRUE/> then the background control is made slightly
+ larger then its tool box child, once that is created.
+ Otherwise the background control will not be visible.
+ */
+ static Window* CreateToolBoxBackground (
+ Window* pParentWindow,
+ const bool bShowBorder = true);
+
static ImageRadioButton* CreateCustomImageRadionButton(
Window* pParentWindow,
const ResId& rResId );
diff --git a/sfx2/inc/sfx2/sidebar/ControllerFactory.hxx b/sfx2/inc/sfx2/sidebar/ControllerFactory.hxx
index 8a08050..3f9e45b 100644
--- a/sfx2/inc/sfx2/sidebar/ControllerFactory.hxx
+++ b/sfx2/inc/sfx2/sidebar/ControllerFactory.hxx
@@ -23,8 +23,9 @@
#define SFX_SIDEBAR_CONTROLLER_FACTORY_HXX
#include "sfx2/dllapi.h"
-#include <com/sun/star/frame/XToolbarController.hpp>
+#include <com/sun/star/awt/XWindow.hpp>
#include <com/sun/star/frame/XFrame.hpp>
+#include <com/sun/star/frame/XToolbarController.hpp>
namespace css = ::com::sun::star;
namespace cssu = ::com::sun::star::uno;
@@ -33,7 +34,7 @@ class ToolBox;
namespace sfx2 { namespace sidebar {
-/** Convenience class for easy creation of toolbox controllers.
+/** Convenience class for the easy creation of toolbox controllers.
*/
class SFX2_DLLPUBLIC ControllerFactory
{
@@ -42,7 +43,16 @@ public:
ToolBox* pToolBox,
const sal_uInt16 nItemId,
const ::rtl::OUString& rsCommandName,
- const cssu::Reference<css::frame::XFrame>& rxFrame);
+ const cssu::Reference<css::frame::XFrame>& rxFrame,
+ const cssu::Reference<css::awt::XWindow>& rxParentWindow,
+ const sal_Int32 nItemWidth);
+
+private:
+ static cssu::Reference<css::frame::XToolbarController> CreateToolBarController(
+ ToolBox* pToolBox,
+ const ::rtl::OUString& rsCommandName,
+ const cssu::Reference<css::frame::XFrame>& rxFrame,
+ const sal_Int32 nWidth);
};
diff --git a/sfx2/inc/sfx2/sidebar/SidebarToolBox.hxx b/sfx2/inc/sfx2/sidebar/SidebarToolBox.hxx
index 0f97943..74ad5f5 100644
--- a/sfx2/inc/sfx2/sidebar/SidebarToolBox.hxx
+++ b/sfx2/inc/sfx2/sidebar/SidebarToolBox.hxx
@@ -80,7 +80,6 @@ private:
cssu::Reference<css::frame::XToolbarController> mxController;
css::util::URL maURL;
rtl::OUString msCurrentCommand;
- cssu::Reference<css::frame::XDispatch> mxDispatch;
};
typedef ::std::map<sal_uInt16, ItemDescriptor> ControllerContainer;
ControllerContainer maControllers;
@@ -94,7 +93,8 @@ private:
void CreateController (
const sal_uInt16 nItemId,
- const cssu::Reference<css::frame::XFrame>& rxFrame);
+ const cssu::Reference<css::frame::XFrame>& rxFrame,
+ const sal_Int32 nItemWidth = 0);
void UpdateIcons (
const cssu::Reference<css::frame::XFrame>& rxFrame);
};
diff --git a/sfx2/inc/sfx2/sidebar/Tools.hxx b/sfx2/inc/sfx2/sidebar/Tools.hxx
index 9bed4fe..c84423e 100755
--- a/sfx2/inc/sfx2/sidebar/Tools.hxx
+++ b/sfx2/inc/sfx2/sidebar/Tools.hxx
@@ -64,6 +64,9 @@ public:
static cssu::Reference<css::frame::XDispatch> GetDispatch (
const cssu::Reference<css::frame::XFrame>& rxFrame,
const css::util::URL& rURL);
+
+ static ::rtl::OUString GetModuleName (
+ const cssu::Reference<css::frame::XFrame>& rxFrame);
};
diff --git a/sfx2/source/sidebar/ControlFactory.cxx b/sfx2/source/sidebar/ControlFactory.cxx
index d35bf33..2dcb493 100644
--- a/sfx2/source/sidebar/ControlFactory.cxx
+++ b/sfx2/source/sidebar/ControlFactory.cxx
@@ -82,9 +82,10 @@ SidebarToolBox* ControlFactory::CreateToolBox (
Window* ControlFactory::CreateToolBoxBackground (
- Window* pParentWindow)
+ Window* pParentWindow,
+ const bool bShowBorder)
{
- ToolBoxBackground* pBorderWindow = new ToolBoxBackground(pParentWindow);
+ ToolBoxBackground* pBorderWindow = new ToolBoxBackground(pParentWindow, bShowBorder);
pBorderWindow->Show();
return pBorderWindow;
}
diff --git a/sfx2/source/sidebar/ControllerFactory.cxx b/sfx2/source/sidebar/ControllerFactory.cxx
index aeea2e6..304dd7b 100644
--- a/sfx2/source/sidebar/ControllerFactory.cxx
+++ b/sfx2/source/sidebar/ControllerFactory.cxx
@@ -27,10 +27,12 @@
#include <com/sun/star/frame/XToolbarController.hpp>
#include <com/sun/star/frame/XFrame.hpp>
+#include <com/sun/star/frame/XUIControllerFactory.hpp>
#include <framework/sfxhelperfunctions.hxx>
#include <svtools/generictoolboxcontroller.hxx>
#include <comphelper/processfactory.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
using namespace css;
@@ -44,17 +46,30 @@ Reference<frame::XToolbarController> ControllerFactory::CreateToolBoxController(
ToolBox* pToolBox,
const sal_uInt16 nItemId,
const OUString& rsCommandName,
- const Reference<frame::XFrame>& rxFrame)
+ const Reference<frame::XFrame>& rxFrame,
+ const Reference<awt::XWindow>& rxParentWindow,
+ const sal_Int32 nWidth)
{
+ Reference<frame::XToolbarController> xController (
+ CreateToolBarController(
+ pToolBox,
+ rsCommandName,
+ rxFrame,
+ nWidth));
+
// Create a controller for the new item.
- Reference<frame::XToolbarController> xController(
- static_cast<XWeak*>(::framework::CreateToolBoxController(
- rxFrame,
- pToolBox,
- nItemId,
- rsCommandName)),
+ if ( ! xController.is())
+ {
+ xController.set(
+ static_cast<XWeak*>(::framework::CreateToolBoxController(
+ rxFrame,
+ pToolBox,
+ nItemId,
+ rsCommandName)),
UNO_QUERY);
+ }
if ( ! xController.is())
+ {
xController.set(
static_cast<XWeak*>(new svt::GenericToolboxController(
::comphelper::getProcessServiceFactory(),
@@ -63,6 +78,7 @@ Reference<frame::XToolbarController> ControllerFactory::CreateToolBoxController(
nItemId,
rsCommandName)),
UNO_QUERY);
+ }
// Initialize the controller with eg a service factory.
Reference<lang::XInitialization> xInitialization (xController, UNO_QUERY);
@@ -87,22 +103,104 @@ Reference<frame::XToolbarController> ControllerFactory::CreateToolBoxController(
xInitialization->initialize(aArgs);
}
- Reference<util::XUpdatable> xUpdatable (xController, UNO_QUERY);
- if (xUpdatable.is())
- xUpdatable->update();
-
- // Add label.
if (xController.is())
{
- const OUString sLabel (sfx2::sidebar::CommandInfoProvider::Instance().GetLabelForCommand(
- rsCommandName,
- rxFrame));
- pToolBox->SetQuickHelpText(nItemId, sLabel);
- pToolBox->EnableItem(nItemId);
+ if (rxParentWindow.is())
+ {
+ Reference<awt::XWindow> xItemWindow (xController->createItemWindow(rxParentWindow));
+ Window* pItemWindow = VCLUnoHelper::GetWindow(xItemWindow);
+ if (pItemWindow != NULL)
+ {
+ WindowType nType = pItemWindow->GetType();
+ if (nType == WINDOW_LISTBOX || nType == WINDOW_MULTILISTBOX || nType == WINDOW_COMBOBOX)
+ pItemWindow->SetAccessibleName(pToolBox->GetItemText(nItemId));
+ if (nWidth > 0)
+ pItemWindow->SetSizePixel(Size(nWidth, pItemWindow->GetSizePixel().Height()));
+ pToolBox->SetItemWindow(nItemId, pItemWindow);
+ }
+ }
+
+ Reference<util::XUpdatable> xUpdatable (xController, UNO_QUERY);
+ if (xUpdatable.is())
+ xUpdatable->update();
+
+ // Add label.
+ if (xController.is())
+ {
+ const OUString sLabel (sfx2::sidebar::CommandInfoProvider::Instance().GetLabelForCommand(
+ rsCommandName,
+ rxFrame));
+ pToolBox->SetQuickHelpText(nItemId, sLabel);
+ pToolBox->EnableItem(nItemId);
+ }
}
return xController;
}
+
+
+Reference<frame::XToolbarController> ControllerFactory::CreateToolBarController(
+ ToolBox* pToolBox,
+ const OUString& rsCommandName,
+ const Reference<frame::XFrame>& rxFrame,
+ const sal_Int32 nWidth)
+{
+ try
+ {
+ Reference<frame::XUIControllerFactory> xFactory (
+ comphelper::getProcessServiceFactory()->createInstance(A2S("com.sun.star.frame.ToolbarControllerFactory")),
+ UNO_QUERY);
+ OUString sModuleName (Tools::GetModuleName(rxFrame));
+
+ if (xFactory.is() && xFactory->hasController(rsCommandName, sModuleName))
+ {
+ beans::PropertyValue aPropValue;
+ std::vector<Any> aPropertyVector;
+
+ aPropValue.Name = A2S("ModuleIdentifier");
+ aPropValue.Value <<= sModuleName;
+ aPropertyVector.push_back( makeAny( aPropValue ));
+
+ aPropValue.Name = A2S("Frame");
+ aPropValue.Value <<= rxFrame;
+ aPropertyVector.push_back( makeAny( aPropValue ));
+
+ aPropValue.Name = A2S("ServiceManager");
+ aPropValue.Value <<= comphelper::getProcessServiceFactory();
+ aPropertyVector.push_back( makeAny( aPropValue ));
+
+ aPropValue.Name = A2S("ParentWindow");
+ aPropValue.Value <<= VCLUnoHelper::GetInterface(pToolBox);
+ aPropertyVector.push_back( makeAny( aPropValue ));
+
+ if (nWidth > 0)
+ {
+ aPropValue.Name = A2S("Width");
+ aPropValue.Value <<= nWidth;
+ aPropertyVector.push_back( makeAny( aPropValue ));
+ }
+
+ Reference<beans::XPropertySet> xFactoryProperties (comphelper::getProcessServiceFactory(), UNO_QUERY);
+ Reference<XComponentContext > xComponentContext;
+ if (xFactoryProperties.is())
+ xFactoryProperties->getPropertyValue(A2S("DefaultContext")) >>= xComponentContext;
+
+ Sequence<Any> aArgs (comphelper::containerToSequence(aPropertyVector));
+ return Reference<frame::XToolbarController>(
+ xFactory->createInstanceWithArgumentsAndContext(
+ rsCommandName,
+ aArgs,
+ xComponentContext),
+ UNO_QUERY);
+ }
+ }
+ catch (Exception& rException)
+ {
+ // Ignore exception.
+ }
+ return NULL;
+}
+
} } // end of namespace sfx2::sidebar
diff --git a/sfx2/source/sidebar/ResourceManager.cxx b/sfx2/source/sidebar/ResourceManager.cxx
index 32b5800..b83fa03 100644
--- a/sfx2/source/sidebar/ResourceManager.cxx
+++ b/sfx2/source/sidebar/ResourceManager.cxx
@@ -506,7 +506,7 @@ void ResourceManager::ReadContextList (
void ResourceManager::ReadLegacyAddons (const Reference<frame::XFrame>& rxFrame)
{
// Get module name for given frame.
- ::rtl::OUString sModuleName (GetModuleName(rxFrame));
+ ::rtl::OUString sModuleName (Tools::GetModuleName(rxFrame));
if (sModuleName.getLength() == 0)
return;
if (maProcessedApplications.find(sModuleName) != maProcessedApplications.end())
@@ -597,30 +597,6 @@ void ResourceManager::StorePanelExpansionState (
-::rtl::OUString ResourceManager::GetModuleName (
- const cssu::Reference<css::frame::XFrame>& rxFrame)
-{
- if ( ! rxFrame.is() || ! rxFrame->getController().is())
- return OUString();
-
- try
- {
- const ::comphelper::ComponentContext aContext (::comphelper::getProcessServiceFactory());
- const Reference<frame::XModuleManager> xModuleManager (
- aContext.createComponent("com.sun.star.frame.ModuleManager"),
- UNO_QUERY_THROW);
- return xModuleManager->identify(rxFrame);
- }
- catch (const Exception&)
- {
- DBG_UNHANDLED_EXCEPTION();
- }
- return OUString();
-}
-
-
-
-
::utl::OConfigurationTreeRoot ResourceManager::GetLegacyAddonRootNode (
const ::rtl::OUString& rsModuleName) const
{
diff --git a/sfx2/source/sidebar/ResourceManager.hxx b/sfx2/source/sidebar/ResourceManager.hxx
index 7420c1d..61514d1 100644
--- a/sfx2/source/sidebar/ResourceManager.hxx
+++ b/sfx2/source/sidebar/ResourceManager.hxx
@@ -102,9 +102,6 @@ public:
const bool bExpansionState,
const Context& rContext);
- static ::rtl::OUString GetModuleName (
- const cssu::Reference<css::frame::XFrame>& rxFrame);
-
private:
ResourceManager (void);
~ResourceManager (void);
diff --git a/sfx2/source/sidebar/SidebarToolBox.cxx b/sfx2/source/sidebar/SidebarToolBox.cxx
index 20408dd..9bab344 100644
--- a/sfx2/source/sidebar/SidebarToolBox.cxx
+++ b/sfx2/source/sidebar/SidebarToolBox.cxx
@@ -28,6 +28,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>
@@ -55,8 +56,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());
@@ -219,7 +227,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;
@@ -229,13 +238,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));
+ }
}
diff --git a/sfx2/source/sidebar/ToolBoxBackground.cxx b/sfx2/source/sidebar/ToolBoxBackground.cxx
index bc457ab..46d8d88 100755
--- a/sfx2/source/sidebar/ToolBoxBackground.cxx
+++ b/sfx2/source/sidebar/ToolBoxBackground.cxx
@@ -34,11 +34,18 @@
namespace sfx2 { namespace sidebar {
-ToolBoxBackground::ToolBoxBackground (Window* pParentWindow)
+ToolBoxBackground::ToolBoxBackground (
+ Window* pParentWindow,
+ const bool bShowBorder)
: Window(pParentWindow, WB_DIALOGCONTROL),
- maPadding(Tools::RectangleToSvBorder(Theme::GetRectangle(Theme::Rect_ToolBoxPadding)))
+ maPadding(bShowBorder
+ ? Tools::RectangleToSvBorder(Theme::GetRectangle(Theme::Rect_ToolBoxPadding))
+ : SvBorder())
{
- SetBackground(Theme::GetPaint(Theme::Paint_ToolBoxBackground).GetWallpaper());
+ if (bShowBorder)
+ SetBackground(Theme::GetPaint(Theme::Paint_ToolBoxBackground).GetWallpaper());
+ else
+ SetBackground(Wallpaper());
#ifdef DEBUG
SetText(A2S("ToolBoxBackground"));
diff --git a/sfx2/source/sidebar/ToolBoxBackground.hxx b/sfx2/source/sidebar/ToolBoxBackground.hxx
index 387384b..ac6bf8b 100755
--- a/sfx2/source/sidebar/ToolBoxBackground.hxx
+++ b/sfx2/source/sidebar/ToolBoxBackground.hxx
@@ -35,7 +35,9 @@ class ToolBoxBackground
: public Window
{
public:
- ToolBoxBackground (Window* pParentWindow);
+ ToolBoxBackground (
+ Window* pParentWindow,
+ const bool bShowBorder);
virtual ~ToolBoxBackground (void);
/** Call this method once to
diff --git a/sfx2/source/sidebar/Tools.cxx b/sfx2/source/sidebar/Tools.cxx
index b6802dc..9a7d6fa 100644
--- a/sfx2/source/sidebar/Tools.cxx
+++ b/sfx2/source/sidebar/Tools.cxx
@@ -34,6 +34,7 @@
#include <com/sun/star/frame/XDispatchProvider.hpp>
#include <com/sun/star/graphic/XGraphicProvider.hpp>
#include <com/sun/star/util/XURLTransformer.hpp>
+#include <com/sun/star/frame/XModuleManager.hpp>
#include <cstring>
@@ -185,4 +186,28 @@ Reference<frame::XDispatch> Tools::GetDispatch (
}
+
+
+::rtl::OUString Tools::GetModuleName (
+ const cssu::Reference<css::frame::XFrame>& rxFrame)
+{
+ if ( ! rxFrame.is() || ! rxFrame->getController().is())
+ return ::rtl::OUString();
+
+ try
+ {
+ const ::comphelper::ComponentContext aContext (::comphelper::getProcessServiceFactory());
+ const Reference<frame::XModuleManager> xModuleManager (
+ aContext.createComponent("com.sun.star.frame.ModuleManager"),
+ UNO_QUERY_THROW);
+ return xModuleManager->identify(rxFrame);
+ }
+ catch (const Exception&)
+ {
+ // Ignored.
+ }
+ return ::rtl::OUString();
+}
+
+
} } // end of namespace sfx2::sidebar
diff --git a/svx/source/sidebar/insert/InsertPropertyPanel.hxx b/svx/source/sidebar/insert/InsertPropertyPanel.hxx
index a97e473..0a441a1 100755
--- a/svx/source/sidebar/insert/InsertPropertyPanel.hxx
+++ b/svx/source/sidebar/insert/InsertPropertyPanel.hxx
@@ -39,6 +39,8 @@ class ToolBox;
namespace svx { namespace sidebar {
+/** This panel provides buttons for inserting shapes into a document.
+*/
class InsertPropertyPanel
: public Control
{
commit 0a5d252c19fdd4e1e705668a604fb319dc6ceccb
Author: Andre Fischer <af at apache.org>
Date: Thu May 16 11:08:30 2013 +0000
122321: Fix processing of scroll whell to not block other events.
diff --git a/sfx2/source/sidebar/Deck.cxx b/sfx2/source/sidebar/Deck.cxx
index eb62058..4de29cd 100644
--- a/sfx2/source/sidebar/Deck.cxx
+++ b/sfx2/source/sidebar/Deck.cxx
@@ -222,49 +222,57 @@ void Deck::DataChanged (const DataChangedEvent& rEvent)
long Deck::Notify (NotifyEvent& rEvent)
{
- if (rEvent.GetType() != EVENT_COMMAND)
- return sal_False;
+ if (rEvent.GetType() == EVENT_COMMAND)
+ {
+ CommandEvent* pCommandEvent = reinterpret_cast<CommandEvent*>(rEvent.GetData());
+ if (pCommandEvent != NULL)
+ switch (pCommandEvent->GetCommand())
+ {
+ case COMMAND_WHEEL:
+ return ProcessWheelEvent(pCommandEvent, rEvent)
+ ? sal_True
+ : sal_False;
+
+ default:
+ break;
+ }
+ }
- CommandEvent* pCommandEvent = reinterpret_cast<CommandEvent*>(rEvent.GetData());
- if (pCommandEvent == NULL)
- return sal_False;
+ return Window::Notify(rEvent);
+}
- switch (pCommandEvent->GetCommand())
- {
- case COMMAND_WHEEL:
- {
- if ( ! mpVerticalScrollBar
- || ! mpVerticalScrollBar->IsVisible())
- return sal_False;
-
- // Ignore all wheel commands from outside the vertical
- // scroll bar. Otherwise after a scroll we might land on
- // a spin field and subsequent wheel events would change
- // the value of that control.
- if (rEvent.GetWindow() != mpVerticalScrollBar.get())
- return sal_True;
-
- // Get the wheel data and check that it describes a valid
- // vertical scroll.
- const CommandWheelData* pData = pCommandEvent->GetWheelData();
- if (pData==NULL
- || pData->GetModifier()
- || pData->GetMode() != COMMAND_WHEEL_SCROLL
- || pData->IsHorz())
- return sal_False;
-
- // Execute the actual scroll action.
- long nDelta = pData->GetDelta();
- mpVerticalScrollBar->DoScroll(
- mpVerticalScrollBar->GetThumbPos() - nDelta);
- return sal_True;
- }
- default:
- break;
- }
- return sal_False;
+
+bool Deck::ProcessWheelEvent (
+ CommandEvent* pCommandEvent,
+ NotifyEvent& rEvent)
+{
+ if ( ! mpVerticalScrollBar)
+ return false;
+ if ( ! mpVerticalScrollBar->IsVisible())
+ return false;
+
+ // Ignore all wheel commands from outside the vertical scroll bar.
+ // Otherwise after a scroll we might land on a spin field and
+ // subsequent wheel events would change the value of that control.
+ if (rEvent.GetWindow() != mpVerticalScrollBar.get())
+ return true;
+
+ // Get the wheel data and check that it describes a valid vertical
+ // scroll.
+ const CommandWheelData* pData = pCommandEvent->GetWheelData();
+ if (pData==NULL
+ || pData->GetModifier()
+ || pData->GetMode() != COMMAND_WHEEL_SCROLL
+ || pData->IsHorz())
+ return false;
+
+ // Execute the actual scroll action.
+ long nDelta = pData->GetDelta();
+ mpVerticalScrollBar->DoScroll(
+ mpVerticalScrollBar->GetThumbPos() - nDelta);
+ return true;
}
diff --git a/sfx2/source/sidebar/Deck.hxx b/sfx2/source/sidebar/Deck.hxx
index 89f5e4b..7cb4a18 100644
--- a/sfx2/source/sidebar/Deck.hxx
+++ b/sfx2/source/sidebar/Deck.hxx
@@ -104,8 +104,9 @@ private:
::boost::scoped_ptr<ScrollBar> mpVerticalScrollBar;
DECL_LINK(HandleVerticalScrollBarChange,void*);
-
-
+ bool ProcessWheelEvent (
+ CommandEvent* pCommandEvent,
+ NotifyEvent& rEvent);
};
diff --git a/sfx2/source/sidebar/FocusManager.cxx b/sfx2/source/sidebar/FocusManager.cxx
index 93ff036..5416c76 100644
--- a/sfx2/source/sidebar/FocusManager.cxx
+++ b/sfx2/source/sidebar/FocusManager.cxx
@@ -559,6 +559,10 @@ IMPL_LINK(FocusManager, WindowEventListener, VclSimpleEvent*, pEvent)
case VCLEVENT_WINDOW_GETFOCUS:
case VCLEVENT_WINDOW_LOSEFOCUS:
pSource->Invalidate();
+ return 1;
+
+ default:
+ break;
}
return 0;
@@ -613,14 +617,14 @@ IMPL_LINK(FocusManager, ChildEventListener, VclSimpleEvent*, pEvent)
break;
}
}
- break;
+ return 1;
}
default:
break;
}
- return 1;
+ return 0;
}
More information about the Libreoffice-commits
mailing list