LanguageTool: don't crash if REST protocol isn't set
[LibreOffice.git] / sfx2 / source / sidebar / PanelLayout.cxx
blobfb7e5a48c2a24016ffca449185fd81edf368cbe1
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/.
8 */
10 #include <sal/log.hxx>
11 #include <sfx2/sidebar/SidebarController.hxx>
12 #include <sfx2/sidebar/PanelLayout.hxx>
13 #include <sfx2/sidebar/TabBar.hxx>
14 #include <sfx2/sidebar/Theme.hxx>
15 #include <sfx2/viewsh.hxx>
16 #include <vcl/event.hxx>
18 using namespace sfx2::sidebar;
20 PanelLayout::PanelLayout(weld::Widget* pParent, const OString& 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)
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));
30 IMPL_LINK(PanelLayout, DumpAsPropertyTreeHdl, tools::JsonWriter&, rJsonWriter, void)
32 DumpAsPropertyTree(rJsonWriter);
35 void PanelLayout::DumpAsPropertyTree(tools::JsonWriter&)
39 IMPL_LINK(PanelLayout, DataChangedEventListener, VclSimpleEvent&, rEvent, void)
41 if (rEvent.GetId() != VclEventId::ApplicationDataChanged)
42 return;
44 DataChangedEvent* pData = static_cast<DataChangedEvent*>(static_cast<VclWindowEvent&>(rEvent).GetData());
45 DataChanged(*pData);
48 void PanelLayout::DataChanged(const DataChangedEvent& rEvent)
50 if (rEvent.GetType() != DataChangedEventType::SETTINGS)
51 return;
52 if (rEvent.GetFlags() & AllSettingsFlags::STYLE)
53 m_xContainer->set_background(Theme::GetColor(Theme::Color_PanelBackground));
56 void PanelLayout::SetPanel(sfx2::sidebar::Panel* pPanel)
58 m_pPanel = pPanel;
61 weld::Window* PanelLayout::GetFrameWeld() const
63 if (!m_pPanel)
65 SAL_WARN("sfx.sidebar", "Expected a toplevel Panel to exist");
66 return nullptr;
68 return m_pPanel->GetFrameWeld();
71 PanelLayout::~PanelLayout()
73 ::Application::RemoveEventListener(LINK(this, PanelLayout, DataChangedEventListener));
75 m_xContainer.reset();
76 m_xBuilder.reset();
79 void PanelLayout::queue_resize()
81 if (!m_xContainer)
82 return;
83 m_xContainer->queue_resize();
86 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */