Version 6.1.4.1, tag libreoffice-6.1.4.1
[LibreOffice.git] / sfx2 / source / sidebar / Sidebar.cxx
blob7abf8ace8db82fd26e0b1bac269783a3ee1844f0
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 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <sfx2/sidebar/Sidebar.hxx>
21 #include <sfx2/sidebar/SidebarController.hxx>
22 #include <sfx2/sidebar/ResourceManager.hxx>
24 using namespace css;
26 namespace sfx2 { namespace sidebar {
28 void Sidebar::ShowPanel (
29 const OUString& rsPanelId,
30 const css::uno::Reference<frame::XFrame>& rxFrame, bool bFocus)
32 SidebarController* pController = SidebarController::GetSidebarControllerForFrame(rxFrame);
33 if (!pController)
34 return;
36 std::shared_ptr<PanelDescriptor> xPanelDescriptor = pController->GetResourceManager()->GetPanelDescriptor(rsPanelId);
38 if (!xPanelDescriptor)
39 return;
41 // This should be a lot more sophisticated:
42 // - Make the deck switching asynchronous
43 // - Make sure to use a context that really shows the panel
45 // All that is not necessary for the current use cases so lets
46 // keep it simple for the time being.
47 pController->OpenThenSwitchToDeck(xPanelDescriptor->msDeckId);
49 if (bFocus)
50 pController->GetFocusManager().GrabFocusPanel();
53 void Sidebar::TogglePanel (
54 const OUString& rsPanelId,
55 const css::uno::Reference<frame::XFrame>& rxFrame)
57 SidebarController* pController = SidebarController::GetSidebarControllerForFrame(rxFrame);
58 if (!pController)
59 return;
61 std::shared_ptr<PanelDescriptor> xPanelDescriptor = pController->GetResourceManager()->GetPanelDescriptor(rsPanelId);
63 if (!xPanelDescriptor)
64 return;
66 // This should be a lot more sophisticated:
67 // - Make the deck switching asynchronous
68 // - Make sure to use a context that really shows the panel
70 // All that is not necessary for the current use cases so lets
71 // keep it simple for the time being.
72 pController->OpenThenToggleDeck(xPanelDescriptor->msDeckId);
75 bool Sidebar::IsPanelVisible(
76 const OUString& rsPanelId,
77 const css::uno::Reference<frame::XFrame>& rxFrame)
79 SidebarController* pController = SidebarController::GetSidebarControllerForFrame(rxFrame);
80 if (!pController)
81 return false;
83 std::shared_ptr<PanelDescriptor> xPanelDescriptor = pController->GetResourceManager()->GetPanelDescriptor(rsPanelId);
84 if (!xPanelDescriptor)
85 return false;
87 return pController->IsDeckVisible(xPanelDescriptor->msDeckId);
90 } } // end of namespace sfx2::sidebar
92 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */