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>
20 #include <vcl/svapp.hxx>
23 using namespace ::sfx2::sidebar
;
25 using ::com::sun::star::uno::RuntimeException
;
27 SfxUnoSidebar::SfxUnoSidebar(uno::Reference
<frame::XFrame
> _xFrame
)
28 : xFrame(std::move(_xFrame
))
32 SidebarController
* SfxUnoSidebar::getSidebarController()
34 return SidebarController::GetSidebarControllerForFrame(xFrame
);
37 void SAL_CALL
SfxUnoSidebar::showDecks(const sal_Bool bVisible
)
39 SolarMutexGuard aGuard
;
41 SidebarController
* pSidebarController
= getSidebarController();
43 if (pSidebarController
)
46 pSidebarController
->RequestOpenDeck();
48 pSidebarController
->RequestCloseDeck();
52 void SAL_CALL
SfxUnoSidebar::setVisible(const sal_Bool bVisible
)
54 SolarMutexGuard aGuard
;
56 SidebarController
* pSidebarController
= getSidebarController();
58 if ((bVisible
&& !pSidebarController
) || (!bVisible
&& pSidebarController
))
60 const util::URL
aURL(Tools::GetURL(".uno:Sidebar"));
61 uno::Reference
<frame::XDispatch
> xDispatch(Tools::GetDispatch(xFrame
, aURL
));
63 xDispatch
->dispatch(aURL
, uno::Sequence
<beans::PropertyValue
>());
67 sal_Bool SAL_CALL
SfxUnoSidebar::isVisible()
69 SolarMutexGuard aGuard
;
71 SidebarController
* pSidebarController
= getSidebarController();
73 return pSidebarController
!= nullptr;
76 uno::Reference
<frame::XFrame
> SAL_CALL
SfxUnoSidebar::getFrame()
78 SolarMutexGuard aGuard
;
81 throw uno::RuntimeException();
86 uno::Reference
<ui::XDecks
> SAL_CALL
SfxUnoSidebar::getDecks()
88 SolarMutexGuard aGuard
;
90 uno::Reference
<ui::XDecks
> decks
= new SfxUnoDecks(xFrame
);
94 uno::Reference
<ui::XSidebar
> SAL_CALL
SfxUnoSidebar::getSidebar() { return getSidebarController(); }
96 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */