/src/libreoffice/sfx2/source/sidebar/UnoSidebar.cxx
Line | Count | Source |
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 | | |
11 | | #include <sidebar/UnoSidebar.hxx> |
12 | | #include <sidebar/Tools.hxx> |
13 | | |
14 | | #include <sfx2/sidebar/SidebarController.hxx> |
15 | | #include <sidebar/UnoDecks.hxx> |
16 | | |
17 | | #include <com/sun/star/frame/XDispatch.hpp> |
18 | | |
19 | | #include <utility> |
20 | | #include <vcl/svapp.hxx> |
21 | | |
22 | | using namespace css; |
23 | | using namespace ::sfx2::sidebar; |
24 | | |
25 | | using ::com::sun::star::uno::RuntimeException; |
26 | | |
27 | | SfxUnoSidebar::SfxUnoSidebar(uno::Reference<frame::XFrame> _xFrame) |
28 | 0 | : xFrame(std::move(_xFrame)) |
29 | 0 | { |
30 | 0 | } |
31 | | |
32 | | SidebarController* SfxUnoSidebar::getSidebarController() |
33 | 0 | { |
34 | 0 | return SidebarController::GetSidebarControllerForFrame(xFrame); |
35 | 0 | } |
36 | | |
37 | | void SAL_CALL SfxUnoSidebar::showDecks(const sal_Bool bVisible) |
38 | 0 | { |
39 | 0 | SolarMutexGuard aGuard; |
40 | |
|
41 | 0 | SidebarController* pSidebarController = getSidebarController(); |
42 | |
|
43 | 0 | if (pSidebarController) |
44 | 0 | { |
45 | 0 | if (bVisible) |
46 | 0 | pSidebarController->RequestOpenDeck(); |
47 | 0 | else |
48 | 0 | pSidebarController->RequestCloseDeck(); |
49 | 0 | } |
50 | 0 | } |
51 | | |
52 | | void SAL_CALL SfxUnoSidebar::setVisible(const sal_Bool bVisible) |
53 | 0 | { |
54 | 0 | SolarMutexGuard aGuard; |
55 | |
|
56 | 0 | SidebarController* pSidebarController = getSidebarController(); |
57 | |
|
58 | 0 | if ((bVisible && !pSidebarController) || (!bVisible && pSidebarController)) |
59 | 0 | { |
60 | 0 | const util::URL aURL(Tools::GetURL(u".uno:Sidebar"_ustr)); |
61 | 0 | uno::Reference<frame::XDispatch> xDispatch(Tools::GetDispatch(xFrame, aURL)); |
62 | 0 | if (xDispatch.is()) |
63 | 0 | xDispatch->dispatch(aURL, uno::Sequence<beans::PropertyValue>()); |
64 | 0 | } |
65 | 0 | } |
66 | | |
67 | | sal_Bool SAL_CALL SfxUnoSidebar::isVisible() |
68 | 0 | { |
69 | 0 | SolarMutexGuard aGuard; |
70 | |
|
71 | 0 | SidebarController* pSidebarController = getSidebarController(); |
72 | |
|
73 | 0 | return pSidebarController != nullptr; |
74 | 0 | } |
75 | | |
76 | | uno::Reference<frame::XFrame> SAL_CALL SfxUnoSidebar::getFrame() |
77 | 0 | { |
78 | 0 | SolarMutexGuard aGuard; |
79 | |
|
80 | 0 | if (!xFrame.is()) |
81 | 0 | throw uno::RuntimeException(); |
82 | | |
83 | 0 | return xFrame; |
84 | 0 | } |
85 | | |
86 | | uno::Reference<ui::XDecks> SAL_CALL SfxUnoSidebar::getDecks() |
87 | 0 | { |
88 | 0 | SolarMutexGuard aGuard; |
89 | |
|
90 | 0 | uno::Reference<ui::XDecks> decks = new SfxUnoDecks(xFrame); |
91 | 0 | return decks; |
92 | 0 | } |
93 | | |
94 | 0 | uno::Reference<ui::XSidebar> SAL_CALL SfxUnoSidebar::getSidebar() { return getSidebarController(); } |
95 | | |
96 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |