LanguageTool: don't crash if REST protocol isn't set
[LibreOffice.git] / sfx2 / source / sidebar / UnoSidebar.cxx
blobb39a8519b3435830fe2d01eac91d29dacaf98f22
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 <vcl/svapp.hxx>
21 using namespace css;
22 using namespace ::sfx2::sidebar;
24 using ::com::sun::star::uno::RuntimeException;
26 SfxUnoSidebar::SfxUnoSidebar(const uno::Reference<frame::XFrame>& rFrame)
27 : 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)
44 if (bVisible)
45 pSidebarController->RequestOpenDeck();
46 else
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));
61 if (xDispatch.is())
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;
79 if (!xFrame.is())
80 throw uno::RuntimeException();
82 return xFrame;
85 uno::Reference<ui::XDecks> SAL_CALL SfxUnoSidebar::getDecks()
87 SolarMutexGuard aGuard;
89 uno::Reference<ui::XDecks> decks = new SfxUnoDecks(xFrame);
90 return decks;
93 uno::Reference<ui::XSidebar> SAL_CALL SfxUnoSidebar::getSidebar() { return getSidebarController(); }
95 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */