Coverage Report

Created: 2026-04-09 11:41

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/vcl/source/control/NotebookbarPopup.cxx
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
10
#include <vcl/bitmap.hxx>
11
#include <vcl/builder.hxx>
12
#include <vcl/layout.hxx>
13
#include <IPrioritable.hxx>
14
#include <NotebookbarPopup.hxx>
15
16
NotebookbarPopup::NotebookbarPopup(const VclPtr<VclHBox>& pParent)
17
0
    : FloatingWindow(pParent, u"Popup"_ustr, u"sfx/ui/notebookbarpopup.ui"_ustr)
18
0
    , m_pParent(pParent)
19
0
{
20
0
    m_pBox = m_pUIBuilder->get<VclHBox>(u"box");
21
0
    m_pBox->SetSizePixel(Size(100, 75));
22
0
    m_pBox->SetBackground(GetSettings().GetStyleSettings().GetDialogColor());
23
0
}
Unexecuted instantiation: NotebookbarPopup::NotebookbarPopup(VclPtr<VclHBox> const&)
Unexecuted instantiation: NotebookbarPopup::NotebookbarPopup(VclPtr<VclHBox> const&)
24
25
0
NotebookbarPopup::~NotebookbarPopup() { disposeOnce(); }
26
27
0
VclHBox* NotebookbarPopup::getBox() { return m_pBox.get(); }
28
29
void NotebookbarPopup::PopupModeEnd()
30
0
{
31
0
    hideSeparators(false);
32
0
    while (m_pBox->GetChildCount())
33
0
    {
34
0
        vcl::IPrioritable* pChild = dynamic_cast<vcl::IPrioritable*>(GetChild(0));
35
0
        if (pChild)
36
0
            pChild->HideContent();
37
38
0
        vcl::Window* pWindow = m_pBox->GetChild(0);
39
0
        pWindow->SetParent(m_pParent);
40
41
        // resize after all children of box are empty
42
0
        if (m_pParent && !m_pBox->GetChildCount())
43
0
            m_pParent->Resize();
44
0
    }
45
46
0
    FloatingWindow::PopupModeEnd();
47
0
}
48
49
void NotebookbarPopup::hideSeparators(bool bHide)
50
0
{
51
    // separator on the beginning
52
0
    vcl::Window* pWindow = m_pBox->GetChild(0);
53
0
    while (pWindow && pWindow->GetType() == WindowType::CONTAINER)
54
0
    {
55
0
        pWindow = pWindow->GetChild(0);
56
0
    }
57
0
    if (pWindow && pWindow->GetType() == WindowType::FIXEDLINE)
58
0
    {
59
0
        if (bHide)
60
0
            pWindow->Hide();
61
0
        else
62
0
            pWindow->Show();
63
0
    }
64
65
    // separator on the end
66
0
    pWindow = m_pBox->GetChild(m_pBox->GetChildCount() - 1);
67
0
    while (pWindow && pWindow->GetType() == WindowType::CONTAINER)
68
0
    {
69
0
        pWindow = pWindow->GetChild(pWindow->GetChildCount() - 1);
70
0
    }
71
0
    if (pWindow && pWindow->GetType() == WindowType::FIXEDLINE)
72
0
    {
73
0
        if (bHide)
74
0
            pWindow->Hide();
75
0
        else
76
0
            pWindow->Show();
77
0
    }
78
79
0
    if (bHide)
80
0
    {
81
0
        sal_Int32 BoxId = 0;
82
0
        while (BoxId <= m_pBox->GetChildCount() - 1)
83
0
        {
84
0
            if (m_pBox->GetChild(BoxId))
85
0
            {
86
0
                pWindow = m_pBox->GetChild(BoxId);
87
0
                ApplyBackground(pWindow);
88
0
            }
89
0
            BoxId++;
90
0
        }
91
0
    }
92
0
    else
93
0
    {
94
0
        sal_Int32 BoxId = m_pBox->GetChildCount() - 1;
95
0
        while (BoxId >= 0)
96
0
        {
97
0
            if (m_pBox->GetChild(BoxId))
98
0
            {
99
0
                pWindow = m_pBox->GetChild(BoxId);
100
0
                RemoveBackground(pWindow);
101
0
            }
102
0
            BoxId--;
103
0
        }
104
0
    }
105
0
}
106
107
void NotebookbarPopup::dispose()
108
0
{
109
0
    PopupModeEnd();
110
0
    m_pBox.disposeAndClear();
111
0
    m_pParent.reset();
112
113
0
    FloatingWindow::dispose();
114
0
}
115
116
void NotebookbarPopup::ApplyBackground(vcl::Window* pWindow)
117
0
{
118
0
    pWindow->SetBackground(GetSettings().GetStyleSettings().GetDialogColor());
119
120
0
    sal_Int32 nNext = 0;
121
0
    VclPtr<vcl::Window> pChild = pWindow->GetChild(nNext);
122
0
    while (pChild && pWindow->GetType() == WindowType::CONTAINER)
123
0
    {
124
0
        ApplyBackground(pChild);
125
0
        nNext++;
126
0
        if (pWindow->GetChild(nNext) && pWindow->GetType() == WindowType::CONTAINER)
127
0
            pChild = pWindow->GetChild(nNext);
128
0
        else
129
0
            break;
130
0
    }
131
0
}
132
133
void NotebookbarPopup::RemoveBackground(vcl::Window* pWindow)
134
0
{
135
0
    pWindow->SetBackground(Wallpaper(COL_TRANSPARENT));
136
137
0
    sal_Int32 nNext = 0;
138
0
    VclPtr<vcl::Window> pChild = pWindow->GetChild(nNext);
139
0
    while (pChild && pWindow->GetType() == WindowType::CONTAINER)
140
0
    {
141
0
        RemoveBackground(pChild);
142
0
        nNext++;
143
0
        if (pWindow->GetChild(nNext) && pWindow->GetType() == WindowType::CONTAINER)
144
0
            pChild = pWindow->GetChild(nNext);
145
0
        else
146
0
            break;
147
0
    }
148
0
}
149
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */