LibreOffice Module sfx2 (master) 1
PanelLayout.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#include <sal/log.hxx>
14#include <sfx2/viewsh.hxx>
15#include <vcl/event.hxx>
16#include <vcl/svapp.hxx>
17
18using namespace sfx2::sidebar;
19
20PanelLayout::PanelLayout(weld::Widget* pParent, const OUString& rID, const OUString& rUIXMLDescription)
21 : m_xBuilder(Application::CreateBuilder(pParent, rUIXMLDescription, false, reinterpret_cast<sal_uInt64>(SfxViewShell::Current())))
22 , m_xContainer(m_xBuilder->weld_container(rID))
23 , m_pPanel(nullptr)
24{
25 m_xContainer->set_background(Theme::GetColor(Theme::Color_PanelBackground));
26 m_xContainer->connect_get_property_tree(LINK(this, PanelLayout, DumpAsPropertyTreeHdl));
27 ::Application::AddEventListener(LINK(this, PanelLayout, DataChangedEventListener));
28}
29
30IMPL_LINK(PanelLayout, DumpAsPropertyTreeHdl, tools::JsonWriter&, rJsonWriter, void)
31{
32 DumpAsPropertyTree(rJsonWriter);
33}
34
36{
37}
38
39IMPL_LINK(PanelLayout, DataChangedEventListener, VclSimpleEvent&, rEvent, void)
40{
41 if (rEvent.GetId() != VclEventId::ApplicationDataChanged)
42 return;
43
44 DataChangedEvent* pData = static_cast<DataChangedEvent*>(static_cast<VclWindowEvent&>(rEvent).GetData());
46}
47
49{
50 if (rEvent.GetType() != DataChangedEventType::SETTINGS)
51 return;
52 if (rEvent.GetFlags() & AllSettingsFlags::STYLE)
53 m_xContainer->set_background(Theme::GetColor(Theme::Color_PanelBackground));
54}
55
57{
58 m_pPanel = pPanel;
59}
60
62{
63 if (!m_pPanel)
64 {
65 SAL_WARN("sfx.sidebar", "Expected a toplevel Panel to exist");
66 return nullptr;
67 }
68 return m_pPanel->GetFrameWeld();
69}
70
72{
73 ::Application::RemoveEventListener(LINK(this, PanelLayout, DataChangedEventListener));
74
75 m_xContainer.reset();
76 m_xBuilder.reset();
77}
78
80{
81 if (!m_xContainer)
82 return;
83 m_xContainer->queue_resize();
84}
85
86/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
IMPL_LINK(PanelLayout, DumpAsPropertyTreeHdl, tools::JsonWriter &, rJsonWriter, void)
Definition: PanelLayout.cxx:30
static void AddEventListener(const Link< VclSimpleEvent &, void > &rEventListener)
static void RemoveEventListener(const Link< VclSimpleEvent &, void > &rEventListener)
DataChangedEventType GetType() const
AllSettingsFlags GetFlags() const
This class is the base for the Widget Layout-based sidebar panels.
Definition: PanelLayout.hxx:22
sfx2::sidebar::Panel * m_pPanel
Definition: PanelLayout.hxx:26
void queue_resize()
Definition: PanelLayout.cxx:79
void SetPanel(sfx2::sidebar::Panel *pPanel)
Definition: PanelLayout.cxx:56
virtual weld::Window * GetFrameWeld() const
Definition: PanelLayout.cxx:61
std::unique_ptr< weld::Builder > m_xBuilder
Definition: PanelLayout.hxx:24
virtual ~PanelLayout()
Definition: PanelLayout.cxx:71
virtual void DumpAsPropertyTree(tools::JsonWriter &)
Definition: PanelLayout.cxx:35
PanelLayout(weld::Widget *pParent, const OUString &rID, const OUString &rUIXMLDescription)
Definition: PanelLayout.cxx:20
std::unique_ptr< weld::Container > m_xContainer
Definition: PanelLayout.hxx:25
virtual void DataChanged(const DataChangedEvent &rEvent)
Definition: PanelLayout.cxx:48
One SfxViewShell more or less represents one edit window for a document, there can be multiple ones f...
Definition: viewsh.hxx:165
Multiple panels form a single deck.
Definition: Panel.hxx:54
weld::Window * GetFrameWeld()
Definition: Panel.cxx:178
#define SAL_WARN(area, stream)
std::unique_ptr< sal_Int32[]> pData
Reference< XNameAccess > m_xContainer