1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
11 #include <sidebar/UnoSidebar.hxx>
12 #include <sidebar/Tools.hxx>
14 #include <sfx2/sidebar/SidebarController.hxx>
15 #include <sidebar/UnoDecks.hxx>
17 #include <com/sun/star/frame/XDispatch.hpp>
19 #include <vcl/svapp.hxx>
22 using namespace ::sfx2::sidebar
;
24 using ::com::sun::star::uno::RuntimeException
;
26 SfxUnoSidebar::SfxUnoSidebar(const uno::Reference
<frame::XFrame
>& rFrame
)
31 SidebarController
* SfxUnoSidebar::getSidebarController()
33 return SidebarController::GetSidebarControllerForFrame(xFrame
);
36 void SAL_CALL
SfxUnoSidebar::showDecks(const sal_Bool bVisible
)
38 SolarMutexGuard aGuard
;
40 SidebarController
* pSidebarController
= getSidebarController();
42 if (pSidebarController
)
45 pSidebarController
->RequestOpenDeck();
47 pSidebarController
->RequestCloseDeck();
51 void SAL_CALL
SfxUnoSidebar::setVisible(const sal_Bool bVisible
)
53 SolarMutexGuard aGuard
;
55 SidebarController
* pSidebarController
= getSidebarController();
57 if ((bVisible
&& !pSidebarController
) || (!bVisible
&& pSidebarController
))
59 const util::URL
aURL(Tools::GetURL(".uno:Sidebar"));
60 uno::Reference
<frame::XDispatch
> xDispatch(Tools::GetDispatch(xFrame
, aURL
));
62 xDispatch
->dispatch(aURL
, uno::Sequence
<beans::PropertyValue
>());
66 sal_Bool SAL_CALL
SfxUnoSidebar::isVisible()
68 SolarMutexGuard aGuard
;
70 SidebarController
* pSidebarController
= getSidebarController();
72 return pSidebarController
!= nullptr;
75 uno::Reference
<frame::XFrame
> SAL_CALL
SfxUnoSidebar::getFrame()
77 SolarMutexGuard aGuard
;
80 throw uno::RuntimeException();
85 uno::Reference
<ui::XDecks
> SAL_CALL
SfxUnoSidebar::getDecks()
87 SolarMutexGuard aGuard
;
89 uno::Reference
<ui::XDecks
> decks
= new SfxUnoDecks(xFrame
);
93 uno::Reference
<ui::XSidebar
> SAL_CALL
SfxUnoSidebar::getSidebar() { return getSidebarController(); }
95 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */