Coverage Report

Created: 2026-02-14 09:37

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/sc/source/ui/inc/namemgrtable.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
10
#pragma once
11
12
#include <vcl/weld/TreeView.hxx>
13
#include <vcl/weld/weld.hxx>
14
15
#include <address.hxx>
16
17
#include <memory>
18
#include <vector>
19
#include <map>
20
21
class ScRangeName;
22
class ScRangeData;
23
24
struct ScRangeNameLine
25
{
26
    OUString aName;
27
    OUString aExpression;
28
    OUString aScope;
29
};
30
31
class SC_DLLPUBLIC ScRangeManagerTable
32
{
33
private:
34
    std::unique_ptr<weld::TreeView> m_xTreeView;
35
36
    OUString maGlobalString;
37
38
    // should be const because we should not modify it here
39
    const std::map<OUString, ScRangeName>& m_RangeMap;
40
    // for performance, save which entries already have the formula entry
41
    // otherwise opening the dialog with a lot of range names is extremely slow because
42
    // we would calculate all formula strings during opening
43
    std::map<OUString, bool> maCalculatedFormulaEntries;
44
    const ScAddress maPos;
45
46
    int m_nId;
47
48
    bool mbNeedUpdate;
49
50
    void GetLine(ScRangeNameLine& aLine, const weld::TreeIter& rEntry);
51
    void Init();
52
    const ScRangeData* findRangeData(const ScRangeNameLine& rLine);
53
54
    DECL_DLLPRIVATE_LINK(SizeAllocHdl, const Size&, void);
55
    DECL_DLLPRIVATE_LINK(VisRowsScrolledHdl, weld::TreeView&, void);
56
57
public:
58
    ScRangeManagerTable(std::unique_ptr<weld::TreeView>,
59
        const std::map<OUString, ScRangeName>& rTabRangeNames,
60
        const ScAddress& rPos);
61
62
    void CheckForFormulaString();
63
64
0
    int n_children() const { return m_xTreeView->n_children(); }
65
    void connect_changed(const Link<weld::TreeView&, void>& rLink)
66
0
    {
67
0
        m_xTreeView->connect_selection_changed(rLink);
68
0
    }
69
0
    void set_cursor(int nPos) { m_xTreeView->set_cursor(nPos); }
70
71
    void addEntry(const ScRangeNameLine& rLine, bool bSetCurEntry);
72
    void DeleteSelectedEntries();
73
    void SetEntry( const ScRangeNameLine& rLine );
74
75
    void GetCurrentLine(ScRangeNameLine& rLine);
76
    bool IsMultiSelection() const;
77
    std::vector<ScRangeNameLine> GetSelectedEntries();
78
79
    void BlockUpdate()
80
0
    {
81
0
        mbNeedUpdate = false;
82
0
    }
83
84
    bool UpdatesBlocked() const
85
0
    {
86
0
        return !mbNeedUpdate;
87
0
    }
88
89
    void UnblockUpdate()
90
0
    {
91
0
        mbNeedUpdate = true;
92
0
    }
93
};
94
95
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */