1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
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
);
36 std::shared_ptr
<PanelDescriptor
> xPanelDescriptor
= pController
->GetResourceManager()->GetPanelDescriptor(rsPanelId
);
38 if (!xPanelDescriptor
)
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
);
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
);
61 std::shared_ptr
<PanelDescriptor
> xPanelDescriptor
= pController
->GetResourceManager()->GetPanelDescriptor(rsPanelId
);
63 if (!xPanelDescriptor
)
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
);
83 std::shared_ptr
<PanelDescriptor
> xPanelDescriptor
= pController
->GetResourceManager()->GetPanelDescriptor(rsPanelId
);
84 if (!xPanelDescriptor
)
87 return pController
->IsDeckVisible(xPanelDescriptor
->msDeckId
);
90 } } // end of namespace sfx2::sidebar
92 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */