1b9e67834SAndre Fischer /**************************************************************
2b9e67834SAndre Fischer  *
3b9e67834SAndre Fischer  * Licensed to the Apache Software Foundation (ASF) under one
4b9e67834SAndre Fischer  * or more contributor license agreements.  See the NOTICE file
5b9e67834SAndre Fischer  * distributed with this work for additional information
6b9e67834SAndre Fischer  * regarding copyright ownership.  The ASF licenses this file
7b9e67834SAndre Fischer  * to you under the Apache License, Version 2.0 (the
8b9e67834SAndre Fischer  * "License"); you may not use this file except in compliance
9b9e67834SAndre Fischer  * with the License.  You may obtain a copy of the License at
10b9e67834SAndre Fischer  *
11b9e67834SAndre Fischer  *   http://www.apache.org/licenses/LICENSE-2.0
12b9e67834SAndre Fischer  *
13b9e67834SAndre Fischer  * Unless required by applicable law or agreed to in writing,
14b9e67834SAndre Fischer  * software distributed under the License is distributed on an
15b9e67834SAndre Fischer  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16b9e67834SAndre Fischer  * KIND, either express or implied.  See the License for the
17b9e67834SAndre Fischer  * specific language governing permissions and limitations
18b9e67834SAndre Fischer  * under the License.
19b9e67834SAndre Fischer  *
20b9e67834SAndre Fischer  *************************************************************/
21b9e67834SAndre Fischer 
22b9e67834SAndre Fischer #include "precompiled_sfx2.hxx"
23b9e67834SAndre Fischer 
24ae13266dSAndre Fischer #include "sfx2/sidebar/SidebarToolBox.hxx"
2595a18594SAndre Fischer #include "ToolBoxBackground.hxx"
26ae13266dSAndre Fischer #include "sfx2/sidebar/ControllerFactory.hxx"
2795a18594SAndre Fischer #include "sfx2/sidebar/Theme.hxx"
28f35c6d02SAndre Fischer #include "sfx2/sidebar/Tools.hxx"
29b9e67834SAndre Fischer 
30b9e67834SAndre Fischer #include <vcl/gradient.hxx>
31d46a1e42SAndre Fischer #include <toolkit/helper/vclunohelper.hxx>
32edc7f530SAndre Fischer #include <svtools/miscopt.hxx>
33edc7f530SAndre Fischer #include <framework/imageproducer.hxx>
34edc7f530SAndre Fischer #include <com/sun/star/frame/XSubToolbarController.hpp>
35b9e67834SAndre Fischer 
3695a18594SAndre Fischer 
37b9e67834SAndre Fischer using namespace ::com::sun::star;
38b9e67834SAndre Fischer using namespace ::com::sun::star::uno;
39ae13266dSAndre Fischer using ::rtl::OUString;
40b9e67834SAndre Fischer 
41b9e67834SAndre Fischer 
42b9e67834SAndre Fischer namespace sfx2 { namespace sidebar {
43b9e67834SAndre Fischer 
44b9e67834SAndre Fischer 
SidebarToolBox(Window * pParentWindow,const ResId & rResId,const cssu::Reference<css::frame::XFrame> & rxFrame)45b9e67834SAndre Fischer SidebarToolBox::SidebarToolBox (
46b9e67834SAndre Fischer     Window* pParentWindow,
47ae13266dSAndre Fischer     const ResId& rResId,
48ae13266dSAndre Fischer     const cssu::Reference<css::frame::XFrame>& rxFrame)
4995a18594SAndre Fischer     : ToolBox(pParentWindow, rResId),
5095a18594SAndre Fischer       mbParentIsBorder(false),
51*8a1a651aSAndre Fischer       maItemSeparator(Theme::GetImage(Theme::Image_ToolBoxItemSeparator)),
52*8a1a651aSAndre Fischer       maControllers(),
53*8a1a651aSAndre Fischer       mbAreHandlersRegistered(false)
54b9e67834SAndre Fischer {
5595a18594SAndre Fischer     SetBackground(Wallpaper());
5695a18594SAndre Fischer     SetPaintTransparent(true);
57ae13266dSAndre Fischer 
58ae13266dSAndre Fischer     if (rxFrame.is())
59ae13266dSAndre Fischer     {
60ae13266dSAndre Fischer         const sal_uInt16 nItemCount (GetItemCount());
61d46a1e42SAndre Fischer         if (nItemCount == 1)
62d46a1e42SAndre Fischer         {
63d46a1e42SAndre Fischer             // When there is only one item then make that as wide as
64d46a1e42SAndre Fischer             // the tool box.
65d46a1e42SAndre Fischer             CreateController(GetItemId(0), rxFrame, GetSizePixel().Width());
66d46a1e42SAndre Fischer         }
67d46a1e42SAndre Fischer         else
68d46a1e42SAndre Fischer             for (sal_uInt16 nItemIndex=0; nItemIndex<nItemCount; ++nItemIndex)
69d46a1e42SAndre Fischer                 CreateController(GetItemId(nItemIndex), rxFrame, 0);
70ae13266dSAndre Fischer         UpdateIcons(rxFrame);
71ae13266dSAndre Fischer 
72ae13266dSAndre Fischer         SetSizePixel(CalcWindowSizePixel());
73ae13266dSAndre Fischer 
74*8a1a651aSAndre Fischer         RegisterHandlers();
75ae13266dSAndre Fischer     }
76ae13266dSAndre Fischer 
777a32b0c8SAndre Fischer #ifdef DEBUG
787a32b0c8SAndre Fischer     SetText(A2S("SidebarToolBox"));
797a32b0c8SAndre Fischer #endif
80b9e67834SAndre Fischer }
81b9e67834SAndre Fischer 
82b9e67834SAndre Fischer 
83b9e67834SAndre Fischer 
84b9e67834SAndre Fischer 
SidebarToolBox(Window * pParentWindow)85*8a1a651aSAndre Fischer SidebarToolBox::SidebarToolBox (Window* pParentWindow)
86*8a1a651aSAndre Fischer     : ToolBox(pParentWindow, 0),
87*8a1a651aSAndre Fischer       mbParentIsBorder(false),
88*8a1a651aSAndre Fischer       maItemSeparator(Theme::GetImage(Theme::Image_ToolBoxItemSeparator)),
89*8a1a651aSAndre Fischer       maControllers(),
90*8a1a651aSAndre Fischer       mbAreHandlersRegistered(false)
91*8a1a651aSAndre Fischer {
92*8a1a651aSAndre Fischer     SetBackground(Wallpaper());
93*8a1a651aSAndre Fischer     SetPaintTransparent(true);
94*8a1a651aSAndre Fischer 
95*8a1a651aSAndre Fischer #ifdef DEBUG
96*8a1a651aSAndre Fischer     SetText(A2S("SidebarToolBox"));
97*8a1a651aSAndre Fischer #endif
98*8a1a651aSAndre Fischer }
99*8a1a651aSAndre Fischer 
100*8a1a651aSAndre Fischer 
101*8a1a651aSAndre Fischer 
102*8a1a651aSAndre Fischer 
~SidebarToolBox(void)103b9e67834SAndre Fischer SidebarToolBox::~SidebarToolBox (void)
104b9e67834SAndre Fischer {
105ae13266dSAndre Fischer     ControllerContainer aControllers;
106ae13266dSAndre Fischer     aControllers.swap(maControllers);
107ae13266dSAndre Fischer     for (ControllerContainer::iterator iController(aControllers.begin()), iEnd(aControllers.end());
108ae13266dSAndre Fischer          iController!=iEnd;
109ae13266dSAndre Fischer          ++iController)
110ae13266dSAndre Fischer     {
111ae13266dSAndre Fischer         Reference<lang::XComponent> xComponent (iController->second.mxController, UNO_QUERY);
112ae13266dSAndre Fischer         if (xComponent.is())
113ae13266dSAndre Fischer             xComponent->dispose();
114ae13266dSAndre Fischer     }
115ae13266dSAndre Fischer 
116*8a1a651aSAndre Fischer     if (mbAreHandlersRegistered)
117*8a1a651aSAndre Fischer     {
118*8a1a651aSAndre Fischer         SetDropdownClickHdl(Link());
119*8a1a651aSAndre Fischer         SetClickHdl(Link());
120*8a1a651aSAndre Fischer         SetDoubleClickHdl(Link());
121*8a1a651aSAndre Fischer         SetSelectHdl(Link());
122*8a1a651aSAndre Fischer         SetActivateHdl(Link());
123*8a1a651aSAndre Fischer         SetDeactivateHdl(Link());
124*8a1a651aSAndre Fischer     }
125b9e67834SAndre Fischer }
126b9e67834SAndre Fischer 
127b9e67834SAndre Fischer 
128b9e67834SAndre Fischer 
129b9e67834SAndre Fischer 
SetBorderWindow(const Window * pBorderWindow)13095a18594SAndre Fischer void SidebarToolBox::SetBorderWindow (const Window* pBorderWindow)
131b9e67834SAndre Fischer {
13295a18594SAndre Fischer     if (pBorderWindow != GetParent())
13395a18594SAndre Fischer     {
13495a18594SAndre Fischer         OSL_ASSERT("SetBorderWindow can only handle parent as border window");
13595a18594SAndre Fischer         return;
13695a18594SAndre Fischer     }
137b9e67834SAndre Fischer 
13895a18594SAndre Fischer     if ( ! mbParentIsBorder)
139b9e67834SAndre Fischer     {
14095a18594SAndre Fischer         mbParentIsBorder = true;
14195a18594SAndre Fischer 
14295a18594SAndre Fischer         SetPosSizePixel (
14395a18594SAndre Fischer             GetPosPixel().X(),
14495a18594SAndre Fischer             GetPosPixel().Y(),
14595a18594SAndre Fischer             GetSizePixel().Width(),
14695a18594SAndre Fischer             GetSizePixel().Height(),
14795a18594SAndre Fischer             WINDOW_POSSIZE_ALL);
148b9e67834SAndre Fischer     }
14995a18594SAndre Fischer }
15095a18594SAndre Fischer 
15195a18594SAndre Fischer 
15295a18594SAndre Fischer 
153b9e67834SAndre Fischer 
Paint(const Rectangle & rRect)15495a18594SAndre Fischer void SidebarToolBox::Paint (const Rectangle& rRect)
15595a18594SAndre Fischer {
156b9e67834SAndre Fischer     ToolBox::Paint(rRect);
15795a18594SAndre Fischer 
15895a18594SAndre Fischer     if (Theme::GetBoolean(Theme::Bool_UseToolBoxItemSeparator))
15995a18594SAndre Fischer     {
16095a18594SAndre Fischer         const sal_Int32 nSeparatorY ((GetSizePixel().Height() - maItemSeparator.GetSizePixel().Height())/2);
16195a18594SAndre Fischer         const sal_uInt16 nItemCount (GetItemCount());
16295a18594SAndre Fischer         int nLastRight (-1);
16395a18594SAndre Fischer         for (sal_uInt16 nIndex=0; nIndex<nItemCount; ++nIndex)
16495a18594SAndre Fischer         {
16595a18594SAndre Fischer             const Rectangle aItemBoundingBox (GetItemPosRect(nIndex));
16695a18594SAndre Fischer             if (nLastRight >= 0)
16795a18594SAndre Fischer             {
16895a18594SAndre Fischer                 const int nSeparatorX ((nLastRight + aItemBoundingBox.Left() - 1) / 2);
16995a18594SAndre Fischer                 DrawImage(Point(nSeparatorX,nSeparatorY), maItemSeparator);
17095a18594SAndre Fischer             }
17195a18594SAndre Fischer 
17295a18594SAndre Fischer             nLastRight = aItemBoundingBox.Right();
17395a18594SAndre Fischer         }
17495a18594SAndre Fischer     }
175b9e67834SAndre Fischer }
176b9e67834SAndre Fischer 
17795a18594SAndre Fischer 
17895a18594SAndre Fischer 
17995a18594SAndre Fischer 
GetPosPixel(void) const18095a18594SAndre Fischer Point SidebarToolBox::GetPosPixel (void) const
18195a18594SAndre Fischer {
18295a18594SAndre Fischer     if (mbParentIsBorder)
18395a18594SAndre Fischer     {
18495a18594SAndre Fischer         const Point aParentPoint (GetParent()->GetPosPixel());
18595a18594SAndre Fischer         const Point aChildPoint (ToolBox::GetPosPixel());
18695a18594SAndre Fischer         return Point(
18795a18594SAndre Fischer             aParentPoint.X() + aChildPoint.X(),
18895a18594SAndre Fischer             aParentPoint.Y() + aChildPoint.Y());
18995a18594SAndre Fischer     }
19095a18594SAndre Fischer     else
19195a18594SAndre Fischer         return ToolBox::GetPosPixel();
19295a18594SAndre Fischer }
19395a18594SAndre Fischer 
19495a18594SAndre Fischer 
19595a18594SAndre Fischer 
19695a18594SAndre Fischer 
SetPosSizePixel(long nX,long nY,long nWidth,long nHeight,sal_uInt16 nFlags)19795a18594SAndre Fischer void SidebarToolBox::SetPosSizePixel (
19895a18594SAndre Fischer     long nX,
19995a18594SAndre Fischer     long nY,
20095a18594SAndre Fischer     long nWidth,
20195a18594SAndre Fischer     long nHeight,
20295a18594SAndre Fischer     sal_uInt16 nFlags)
20395a18594SAndre Fischer {
20495a18594SAndre Fischer     if (mbParentIsBorder)
20595a18594SAndre Fischer     {
20695a18594SAndre Fischer         const Point aRelativePosition (static_cast<ToolBoxBackground*>(GetParent())->SetToolBoxChild(
20795a18594SAndre Fischer                 this,
20895a18594SAndre Fischer                 nX,
20995a18594SAndre Fischer                 nY,
21095a18594SAndre Fischer                 nWidth,
21195a18594SAndre Fischer                 nHeight,
21295a18594SAndre Fischer                 nFlags));
21395a18594SAndre Fischer         ToolBox::SetPosSizePixel(
21495a18594SAndre Fischer             aRelativePosition.X(),
21595a18594SAndre Fischer             aRelativePosition.Y(),
21695a18594SAndre Fischer             nWidth,
21795a18594SAndre Fischer             nHeight,
21895a18594SAndre Fischer             nFlags);
21995a18594SAndre Fischer     }
22095a18594SAndre Fischer     else
22195a18594SAndre Fischer         ToolBox::SetPosSizePixel(nX, nY, nWidth, nHeight, nFlags);
22295a18594SAndre Fischer }
22395a18594SAndre Fischer 
22495a18594SAndre Fischer 
22595a18594SAndre Fischer 
22652d13b84SAndre Fischer 
Notify(NotifyEvent & rEvent)22752d13b84SAndre Fischer long SidebarToolBox::Notify (NotifyEvent& rEvent)
22852d13b84SAndre Fischer {
22952d13b84SAndre Fischer     if (rEvent.GetType() == EVENT_KEYINPUT)
23052d13b84SAndre Fischer     {
23152d13b84SAndre Fischer         if (rEvent.GetKeyEvent()->GetKeyCode().GetCode() == KEY_TAB)
23252d13b84SAndre Fischer         {
23352d13b84SAndre Fischer             // Special handling for transferring handling of KEY_TAB
23452d13b84SAndre Fischer             // that becomes necessary because of our parent that is
23552d13b84SAndre Fischer             // not the dialog but a background control.
23652d13b84SAndre Fischer             return DockingWindow::Notify(rEvent);
23752d13b84SAndre Fischer         }
23852d13b84SAndre Fischer     }
23952d13b84SAndre Fischer     return ToolBox::Notify(rEvent);
24052d13b84SAndre Fischer }
241ae13266dSAndre Fischer 
242ae13266dSAndre Fischer 
243ae13266dSAndre Fischer 
244ae13266dSAndre Fischer 
CreateController(const sal_uInt16 nItemId,const cssu::Reference<css::frame::XFrame> & rxFrame,const sal_Int32 nItemWidth)245ae13266dSAndre Fischer void SidebarToolBox::CreateController (
246ae13266dSAndre Fischer     const sal_uInt16 nItemId,
247d46a1e42SAndre Fischer     const cssu::Reference<css::frame::XFrame>& rxFrame,
248d46a1e42SAndre Fischer     const sal_Int32 nItemWidth)
249ae13266dSAndre Fischer {
250ae13266dSAndre Fischer     ItemDescriptor aDescriptor;
251ae13266dSAndre Fischer 
252ae13266dSAndre Fischer     const OUString sCommandName (GetItemCommand(nItemId));
253ae13266dSAndre Fischer 
254ae13266dSAndre Fischer     aDescriptor.mxController = sfx2::sidebar::ControllerFactory::CreateToolBoxController(
255ae13266dSAndre Fischer         this,
256ae13266dSAndre Fischer         nItemId,
257ae13266dSAndre Fischer         sCommandName,
258d46a1e42SAndre Fischer         rxFrame,
259d46a1e42SAndre Fischer         VCLUnoHelper::GetInterface(this),
260d46a1e42SAndre Fischer         nItemWidth);
261d46a1e42SAndre Fischer     if (aDescriptor.mxController.is())
262d46a1e42SAndre Fischer     {
263d46a1e42SAndre Fischer         aDescriptor.maURL = sfx2::sidebar::Tools::GetURL(sCommandName);
264d46a1e42SAndre Fischer         aDescriptor.msCurrentCommand = sCommandName;
265ae13266dSAndre Fischer 
266ae13266dSAndre Fischer         maControllers.insert(::std::make_pair(nItemId, aDescriptor));
267d46a1e42SAndre Fischer     }
268ae13266dSAndre Fischer }
269ae13266dSAndre Fischer 
270ae13266dSAndre Fischer 
271ae13266dSAndre Fischer 
272ae13266dSAndre Fischer 
GetControllerForItemId(const sal_uInt16 nItemId) const273ae13266dSAndre Fischer Reference<frame::XToolbarController> SidebarToolBox::GetControllerForItemId (const sal_uInt16 nItemId) const
274ae13266dSAndre Fischer {
275ae13266dSAndre Fischer     ControllerContainer::const_iterator iController (maControllers.find(nItemId));
276ae13266dSAndre Fischer     if (iController != maControllers.end())
277ae13266dSAndre Fischer         return iController->second.mxController;
278ae13266dSAndre Fischer     else
279ae13266dSAndre Fischer         return NULL;
280ae13266dSAndre Fischer }
281ae13266dSAndre Fischer 
282ae13266dSAndre Fischer 
283ae13266dSAndre Fischer 
284ae13266dSAndre Fischer 
SetController(const sal_uInt16 nItemId,const cssu::Reference<css::frame::XToolbarController> & rxController,const::rtl::OUString & rsCommandName)285*8a1a651aSAndre Fischer void SidebarToolBox::SetController(
286*8a1a651aSAndre Fischer     const sal_uInt16 nItemId,
287*8a1a651aSAndre Fischer     const cssu::Reference<css::frame::XToolbarController>& rxController,
288*8a1a651aSAndre Fischer     const ::rtl::OUString& rsCommandName)
289*8a1a651aSAndre Fischer {
290*8a1a651aSAndre Fischer     ItemDescriptor aDescriptor;
291*8a1a651aSAndre Fischer     aDescriptor.mxController = rxController;
292*8a1a651aSAndre Fischer     aDescriptor.maURL = sfx2::sidebar::Tools::GetURL(rsCommandName);
293*8a1a651aSAndre Fischer     aDescriptor.msCurrentCommand = rsCommandName;
294*8a1a651aSAndre Fischer 
295*8a1a651aSAndre Fischer     ControllerContainer::iterator iController (maControllers.find(nItemId));
296*8a1a651aSAndre Fischer     if (iController != maControllers.end())
297*8a1a651aSAndre Fischer     {
298*8a1a651aSAndre Fischer         Reference<lang::XComponent> xComponent (iController->second.mxController, UNO_QUERY);
299*8a1a651aSAndre Fischer         if (xComponent.is())
300*8a1a651aSAndre Fischer             xComponent->dispose();
301*8a1a651aSAndre Fischer 
302*8a1a651aSAndre Fischer         iController->second = aDescriptor;
303*8a1a651aSAndre Fischer     }
304*8a1a651aSAndre Fischer     else
305*8a1a651aSAndre Fischer     {
306*8a1a651aSAndre Fischer         maControllers[nItemId] = aDescriptor;
307*8a1a651aSAndre Fischer     }
308*8a1a651aSAndre Fischer 
309*8a1a651aSAndre Fischer     if (rxController.is())
310*8a1a651aSAndre Fischer         RegisterHandlers();
311*8a1a651aSAndre Fischer }
312*8a1a651aSAndre Fischer 
313*8a1a651aSAndre Fischer 
314*8a1a651aSAndre Fischer 
315*8a1a651aSAndre Fischer 
UpdateIcons(const Reference<frame::XFrame> & rxFrame)316ae13266dSAndre Fischer void SidebarToolBox::UpdateIcons (const Reference<frame::XFrame>& rxFrame)
317ae13266dSAndre Fischer {
318ae13266dSAndre Fischer     const sal_Bool bBigImages (SvtMiscOptions().AreCurrentSymbolsLarge());
319ae13266dSAndre Fischer     const bool bIsHighContrastActive (sfx2::sidebar::Theme::IsHighContrastMode());
320ae13266dSAndre Fischer 
321ae13266dSAndre Fischer     for (ControllerContainer::iterator iController(maControllers.begin()), iEnd(maControllers.end());
322ae13266dSAndre Fischer          iController!=iEnd;
323ae13266dSAndre Fischer          ++iController)
324ae13266dSAndre Fischer     {
325ae13266dSAndre Fischer         const ::rtl::OUString sCommandURL (iController->second.msCurrentCommand);
326ae13266dSAndre Fischer         Image aImage (framework::GetImageFromURL(rxFrame, sCommandURL, bBigImages, bIsHighContrastActive));
327ae13266dSAndre Fischer         SetItemImage(iController->first, aImage);
328ae13266dSAndre Fischer     }
329ae13266dSAndre Fischer }
330ae13266dSAndre Fischer 
331ae13266dSAndre Fischer 
332ae13266dSAndre Fischer 
333ae13266dSAndre Fischer 
GetItemIdForSubToolbarName(const OUString & rsSubToolbarName) const334ae13266dSAndre Fischer sal_uInt16 SidebarToolBox::GetItemIdForSubToolbarName (const OUString& rsSubToolbarName) const
335ae13266dSAndre Fischer {
336ae13266dSAndre Fischer     for (ControllerContainer::const_iterator iController(maControllers.begin()), iEnd(maControllers.end());
337ae13266dSAndre Fischer          iController!=iEnd;
338ae13266dSAndre Fischer          ++iController)
339ae13266dSAndre Fischer     {
340ae13266dSAndre Fischer         Reference<frame::XToolbarController> xController (iController->second.mxController);
341ae13266dSAndre Fischer         Reference<frame::XSubToolbarController> xSubToolbarController (xController, UNO_QUERY);
342ae13266dSAndre Fischer         if (xSubToolbarController.is())
343ae13266dSAndre Fischer         {
344ae13266dSAndre Fischer             const OUString sName (xSubToolbarController->getSubToolbarName());
345ae13266dSAndre Fischer             if (sName.equals(rsSubToolbarName))
346ae13266dSAndre Fischer                 return iController->first;
347ae13266dSAndre Fischer         }
348ae13266dSAndre Fischer     }
349ae13266dSAndre Fischer     return 0;
350ae13266dSAndre Fischer }
351ae13266dSAndre Fischer 
352ae13266dSAndre Fischer 
353ae13266dSAndre Fischer 
354*8a1a651aSAndre Fischer 
RegisterHandlers(void)355*8a1a651aSAndre Fischer void SidebarToolBox::RegisterHandlers (void)
356*8a1a651aSAndre Fischer {
357*8a1a651aSAndre Fischer     if ( ! mbAreHandlersRegistered)
358*8a1a651aSAndre Fischer     {
359*8a1a651aSAndre Fischer         mbAreHandlersRegistered = true;
360*8a1a651aSAndre Fischer         SetDropdownClickHdl(LINK(this, SidebarToolBox, DropDownClickHandler));
361*8a1a651aSAndre Fischer         SetClickHdl(LINK(this, SidebarToolBox, ClickHandler));
362*8a1a651aSAndre Fischer         SetDoubleClickHdl(LINK(this, SidebarToolBox, DoubleClickHandler));
363*8a1a651aSAndre Fischer         SetSelectHdl(LINK(this, SidebarToolBox, SelectHandler));
364*8a1a651aSAndre Fischer         SetActivateHdl(LINK(this, SidebarToolBox, Activate));
365*8a1a651aSAndre Fischer         SetDeactivateHdl(LINK(this, SidebarToolBox, Deactivate));
366*8a1a651aSAndre Fischer     }
367*8a1a651aSAndre Fischer }
368*8a1a651aSAndre Fischer 
369*8a1a651aSAndre Fischer 
370*8a1a651aSAndre Fischer 
371*8a1a651aSAndre Fischer 
IMPL_LINK(SidebarToolBox,DropDownClickHandler,ToolBox *,pToolBox)372ae13266dSAndre Fischer IMPL_LINK(SidebarToolBox, DropDownClickHandler, ToolBox*, pToolBox)
373ae13266dSAndre Fischer {
374ae13266dSAndre Fischer     if (pToolBox != NULL)
375ae13266dSAndre Fischer     {
376ae13266dSAndre Fischer         Reference<frame::XToolbarController> xController (GetControllerForItemId(pToolBox->GetCurItemId()));
377ae13266dSAndre Fischer         if (xController.is())
378ae13266dSAndre Fischer         {
379ae13266dSAndre Fischer             Reference<awt::XWindow> xWindow = xController->createPopupWindow();
380ae13266dSAndre Fischer             if (xWindow.is() )
381ae13266dSAndre Fischer                 xWindow->setFocus();
382ae13266dSAndre Fischer         }
383ae13266dSAndre Fischer     }
384ae13266dSAndre Fischer     return 1;
385ae13266dSAndre Fischer }
386ae13266dSAndre Fischer 
387ae13266dSAndre Fischer 
388ae13266dSAndre Fischer 
389ae13266dSAndre Fischer 
IMPL_LINK(SidebarToolBox,ClickHandler,ToolBox *,pToolBox)390ae13266dSAndre Fischer IMPL_LINK(SidebarToolBox, ClickHandler, ToolBox*, pToolBox)
391ae13266dSAndre Fischer {
392ae13266dSAndre Fischer     if (pToolBox == NULL)
393ae13266dSAndre Fischer         return 0;
394ae13266dSAndre Fischer 
395ae13266dSAndre Fischer     Reference<frame::XToolbarController> xController (GetControllerForItemId(pToolBox->GetCurItemId()));
396ae13266dSAndre Fischer     if (xController.is())
397ae13266dSAndre Fischer         xController->click();
398ae13266dSAndre Fischer 
399ae13266dSAndre Fischer     return 1;
400ae13266dSAndre Fischer }
401ae13266dSAndre Fischer 
402ae13266dSAndre Fischer 
403ae13266dSAndre Fischer 
404ae13266dSAndre Fischer 
IMPL_LINK(SidebarToolBox,DoubleClickHandler,ToolBox *,pToolBox)405ae13266dSAndre Fischer IMPL_LINK(SidebarToolBox, DoubleClickHandler, ToolBox*, pToolBox)
406ae13266dSAndre Fischer {
407ae13266dSAndre Fischer     if (pToolBox == NULL)
408ae13266dSAndre Fischer         return 0;
409ae13266dSAndre Fischer 
410ae13266dSAndre Fischer     Reference<frame::XToolbarController> xController (GetControllerForItemId(pToolBox->GetCurItemId()));
411ae13266dSAndre Fischer     if (xController.is())
412ae13266dSAndre Fischer         xController->doubleClick();
413ae13266dSAndre Fischer 
414ae13266dSAndre Fischer     return 1;
415ae13266dSAndre Fischer }
416ae13266dSAndre Fischer 
417ae13266dSAndre Fischer 
418ae13266dSAndre Fischer 
419ae13266dSAndre Fischer 
IMPL_LINK(SidebarToolBox,SelectHandler,ToolBox *,pToolBox)420ae13266dSAndre Fischer IMPL_LINK(SidebarToolBox, SelectHandler, ToolBox*, pToolBox)
421ae13266dSAndre Fischer {
422ae13266dSAndre Fischer     if (pToolBox == NULL)
423ae13266dSAndre Fischer         return 0;
424ae13266dSAndre Fischer 
425ae13266dSAndre Fischer     Reference<frame::XToolbarController> xController (GetControllerForItemId(pToolBox->GetCurItemId()));
426ae13266dSAndre Fischer     if (xController.is())
427ae13266dSAndre Fischer         xController->execute((sal_Int16)pToolBox->GetModifier());
428ae13266dSAndre Fischer 
429ae13266dSAndre Fischer     return 1;
430ae13266dSAndre Fischer }
431ae13266dSAndre Fischer 
432ae13266dSAndre Fischer 
433ae13266dSAndre Fischer 
434ae13266dSAndre Fischer 
IMPL_LINK(SidebarToolBox,Activate,ToolBox *,EMPTYARG)435ae13266dSAndre Fischer IMPL_LINK(SidebarToolBox, Activate, ToolBox*, EMPTYARG)
436ae13266dSAndre Fischer {
437ae13266dSAndre Fischer     return 1;
438ae13266dSAndre Fischer }
439ae13266dSAndre Fischer 
440ae13266dSAndre Fischer 
441ae13266dSAndre Fischer 
442ae13266dSAndre Fischer 
IMPL_LINK(SidebarToolBox,Deactivate,ToolBox *,EMPTYARG)443ae13266dSAndre Fischer IMPL_LINK(SidebarToolBox, Deactivate, ToolBox*, EMPTYARG)
444ae13266dSAndre Fischer {
445ae13266dSAndre Fischer     return 1;
446ae13266dSAndre Fischer }
447ae13266dSAndre Fischer 
448ae13266dSAndre Fischer 
44952d13b84SAndre Fischer 
450b9e67834SAndre Fischer } } // end of namespace sfx2::sidebar
451