Coverage Report

Created: 2026-04-09 11:41

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/sfx2/source/sidebar/uiobject.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 "uiobject.hxx"
11
#include <sfx2/sidebar/SidebarController.hxx>
12
#include <rtl/ustrbuf.hxx>
13
#include <vcl/weld/Toolbar.hxx>
14
15
namespace sfx2::sidebar
16
{
17
TabBarUIObject::TabBarUIObject(const VclPtr<TabBar>& xTabBar)
18
0
    : WindowUIObject(xTabBar)
19
0
    , mxTabBar(xTabBar)
20
0
{
21
0
}
22
23
StringMap TabBarUIObject::get_state()
24
0
{
25
0
    StringMap aMap = WindowUIObject::get_state();
26
0
    OUStringBuffer rsHighlightedTabsIds;
27
0
    for (auto const& item : mxTabBar->maItems)
28
0
    {
29
0
        if (item->mxButton->get_item_active(u"toggle"_ustr))
30
0
        {
31
0
            if (!rsHighlightedTabsIds.isEmpty())
32
0
                rsHighlightedTabsIds.append(",");
33
0
            rsHighlightedTabsIds.append(item->msDeckId);
34
0
        }
35
0
    }
36
0
    aMap[u"HighlightedTabsIds"_ustr] = rsHighlightedTabsIds;
37
0
    return aMap;
38
0
}
39
40
void TabBarUIObject::execute(const OUString& rAction, const StringMap& rParameters)
41
0
{
42
0
    if (rAction == "CLICK")
43
0
    {
44
0
        if (rParameters.find(u"POS"_ustr) != rParameters.end())
45
0
            mxTabBar->mrParentSidebarController.OpenThenToggleDeck(
46
0
                mxTabBar->GetDeckIdForIndex(rParameters.find(u"POS"_ustr)->second.toInt32()));
47
0
    }
48
0
    else
49
0
        WindowUIObject::execute(rAction, rParameters);
50
0
}
51
52
std::unique_ptr<UIObject> TabBarUIObject::create(vcl::Window* pWindow)
53
0
{
54
0
    TabBar* pTabBar = dynamic_cast<TabBar*>(pWindow);
55
0
    assert(pTabBar);
56
0
    return std::unique_ptr<UIObject>(new TabBarUIObject(pTabBar));
57
0
}
58
59
0
OUString TabBarUIObject::get_name() const { return u"TabBarUIObject"_ustr; }
60
61
} // namespace sidebar
62
63
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */