Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / sfx2 / source / sidebar / UnoSidebar.cxx
blob5142d8a4fc508f7c1cc1331ae4e5f48cb550dad6
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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/.
9 */
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 <utility>
20 #include <vcl/svapp.hxx>
22 using namespace css;
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)
45 if (bVisible)
46 pSidebarController->RequestOpenDeck();
47 else
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));
62 if (xDispatch.is())
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;
80 if (!xFrame.is())
81 throw uno::RuntimeException();
83 return xFrame;
86 uno::Reference<ui::XDecks> SAL_CALL SfxUnoSidebar::getDecks()
88 SolarMutexGuard aGuard;
90 uno::Reference<ui::XDecks> decks = new SfxUnoDecks(xFrame);
91 return decks;
94 uno::Reference<ui::XSidebar> SAL_CALL SfxUnoSidebar::getSidebar() { return getSidebarController(); }
96 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */