LibreOffice Module sfx2 (master) 1
UnoSidebar.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 */
10
12#include <sidebar/Tools.hxx>
13
15#include <sidebar/UnoDecks.hxx>
16
17#include <com/sun/star/frame/XDispatch.hpp>
18
19#include <utility>
20#include <vcl/svapp.hxx>
21
22using namespace css;
23using namespace ::sfx2::sidebar;
24
25using ::com::sun::star::uno::RuntimeException;
26
27SfxUnoSidebar::SfxUnoSidebar(uno::Reference<frame::XFrame> _xFrame)
28 : xFrame(std::move(_xFrame))
29{
30}
31
33{
34 return SidebarController::GetSidebarControllerForFrame(xFrame);
35}
36
37void SAL_CALL SfxUnoSidebar::showDecks(const sal_Bool bVisible)
38{
39 SolarMutexGuard aGuard;
40
41 SidebarController* pSidebarController = getSidebarController();
42
43 if (pSidebarController)
44 {
45 if (bVisible)
46 pSidebarController->RequestOpenDeck();
47 else
48 pSidebarController->RequestCloseDeck();
49 }
50}
51
52void SAL_CALL SfxUnoSidebar::setVisible(const sal_Bool bVisible)
53{
54 SolarMutexGuard aGuard;
55
56 SidebarController* pSidebarController = getSidebarController();
57
58 if ((bVisible && !pSidebarController) || (!bVisible && pSidebarController))
59 {
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>());
64 }
65}
66
68{
69 SolarMutexGuard aGuard;
70
71 SidebarController* pSidebarController = getSidebarController();
72
73 return pSidebarController != nullptr;
74}
75
76uno::Reference<frame::XFrame> SAL_CALL SfxUnoSidebar::getFrame()
77{
78 SolarMutexGuard aGuard;
79
80 if (!xFrame.is())
81 throw uno::RuntimeException();
82
83 return xFrame;
84}
85
86uno::Reference<ui::XDecks> SAL_CALL SfxUnoSidebar::getDecks()
87{
88 SolarMutexGuard aGuard;
89
90 uno::Reference<ui::XDecks> decks = new SfxUnoDecks(xFrame);
91 return decks;
92}
93
94uno::Reference<ui::XSidebar> SAL_CALL SfxUnoSidebar::getSidebar() { return getSidebarController(); }
95
96/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
get the decks
Definition: UnoDecks.hxx:23
virtual void SAL_CALL setVisible(const sal_Bool bVisible) override
Definition: UnoSidebar.cxx:52
virtual sal_Bool SAL_CALL isVisible() override
Definition: UnoSidebar.cxx:67
SfxUnoSidebar(css::uno::Reference< css::frame::XFrame >)
Definition: UnoSidebar.cxx:27
virtual css::uno::Reference< css::ui::XDecks > SAL_CALL getDecks() override
Definition: UnoSidebar.cxx:86
virtual css::uno::Reference< css::frame::XFrame > SAL_CALL getFrame() override
Definition: UnoSidebar.cxx:76
sfx2::sidebar::SidebarController * getSidebarController()
Definition: UnoSidebar.cxx:32
const css::uno::Reference< css::frame::XFrame > xFrame
Definition: UnoSidebar.hxx:30
virtual css::uno::Reference< css::ui::XSidebar > SAL_CALL getSidebar() override
Definition: UnoSidebar.cxx:94
virtual void SAL_CALL showDecks(const sal_Bool bVisible) override
Definition: UnoSidebar.cxx:37
Reference< XDispatch > xDispatch
URL aURL
Reference< XFrame > xFrame
bool bVisible
unsigned char sal_Bool