Coverage Report

Created: 2026-08-14 10:22

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/include/sfx2/sidebar/Panel.hxx
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
 * This file incorporates work covered by the following license notice:
10
 *
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 .
18
 */
19
#pragma once
20
21
#include <sfx2/dllapi.h>
22
#include <rtl/ustring.hxx>
23
#include <tools/link.hxx>
24
#include <vcl/vclptr.hxx>
25
26
#include <vector>
27
28
namespace com::sun::star::frame
29
{
30
class XFrame;
31
}
32
namespace com::sun::star::ui
33
{
34
class XSidebarPanel;
35
}
36
namespace com::sun::star::ui
37
{
38
class XUIElement;
39
}
40
namespace com::sun::star::awt
41
{
42
class XWindow;
43
}
44
namespace tools
45
{
46
class JsonWriter;
47
}
48
namespace tools
49
{
50
class Rectangle;
51
}
52
namespace weld
53
{
54
class Box;
55
}
56
namespace weld
57
{
58
class Builder;
59
}
60
namespace weld
61
{
62
class Widget;
63
}
64
namespace weld
65
{
66
class Window;
67
}
68
69
namespace sfx2::sidebar
70
{
71
class Context;
72
class Deck;
73
class PanelDescriptor;
74
class PanelTitleBar;
75
76
/**
77
 * Multiple panels form a single deck.
78
 * E.g. the Properties deck has panels like Styles, Character, paragraph.
79
 */
80
class SFX2_DLLPUBLIC Panel final
81
{
82
public:
83
    SAL_DLLPRIVATE Panel(const PanelDescriptor& rPanelDescriptor, weld::Widget* pParentWindow,
84
                         const bool bIsInitiallyExpanded, Deck* pDeck,
85
                         std::function<Context()> aContextAccess,
86
                         const css::uno::Reference<css::frame::XFrame>& rxFrame);
87
88
    SAL_DLLPRIVATE ~Panel();
89
90
    SAL_DLLPRIVATE PanelTitleBar* GetTitleBar() const;
91
    SAL_DLLPRIVATE weld::Box* GetContents() const;
92
    SAL_DLLPRIVATE void Show(bool bShow);
93
0
    bool IsTitleBarOptional() const { return mbIsTitleBarOptional; }
94
    SAL_DLLPRIVATE void SetUIElement(const css::uno::Reference<css::ui::XUIElement>& rxElement);
95
    const css::uno::Reference<css::ui::XSidebarPanel>& GetPanelComponent() const
96
0
    {
97
0
        return mxPanelComponent;
98
0
    }
99
    SAL_DLLPRIVATE const css::uno::Reference<css::awt::XWindow>& GetElementParentWindow();
100
    SAL_DLLPRIVATE css::uno::Reference<css::awt::XWindow> GetElementWindow();
101
    SAL_DLLPRIVATE void SetExpanded(const bool bIsExpanded);
102
0
    bool IsExpanded() const { return mbIsExpanded; }
103
    SAL_DLLPRIVATE bool HasIdPredicate(std::u16string_view rsId) const;
104
0
    const OUString& GetId() const { return msPanelId; }
105
    void TriggerDeckLayouting();
106
107
    SAL_DLLPRIVATE void SetHeightPixel(int nHeight);
108
109
    SAL_DLLPRIVATE bool get_extents(tools::Rectangle& rExtents) const;
110
111
    /// Set whether a panel should be present but invisible / inactive
112
    SAL_DLLPRIVATE void SetLurkMode(bool bLurk);
113
0
    bool IsLurking() const { return mbLurking; }
114
115
    SAL_DLLPRIVATE void set_margin_top(int nMargin);
116
    SAL_DLLPRIVATE void set_margin_bottom(int nMargin);
117
    SAL_DLLPRIVATE void set_vexpand(bool bExpand);
118
119
    SAL_DLLPRIVATE weld::Window* GetFrameWeld();
120
121
    SAL_DLLPRIVATE void DataChanged();
122
123
private:
124
    std::unique_ptr<weld::Builder> mxBuilder;
125
    const OUString msPanelId;
126
    const OUString msTitle;
127
    const bool mbIsTitleBarOptional;
128
    const bool mbWantsAWT;
129
    css::uno::Reference<css::ui::XUIElement> mxElement;
130
    css::uno::Reference<css::ui::XSidebarPanel> mxPanelComponent;
131
    bool mbIsExpanded;
132
    bool mbLurking;
133
    const std::function<Context()> maContextAccess;
134
    const css::uno::Reference<css::frame::XFrame>& mxFrame;
135
    weld::Widget* mpParentWindow;
136
    VclPtr<Deck> mxDeck;
137
    std::unique_ptr<weld::Box> mxContainer;
138
    std::unique_ptr<PanelTitleBar> mxTitleBar;
139
    std::unique_ptr<weld::Box> mxContents;
140
    css::uno::Reference<css::awt::XWindow> mxXWindow;
141
};
142
143
typedef std::vector<std::shared_ptr<Panel>> SharedPanelContainer;
144
145
} // end of namespace sfx2::sidebar
146
147
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */