Coverage Report

Created: 2026-02-14 09:37

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/sc/inc/SheetViewManager.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
#include "SheetViewTypes.hxx"
12
#include "SheetView.hxx"
13
#include "types.hxx"
14
#include "scdllapi.h"
15
16
#include <o3tl/safeint.hxx>
17
#include <vector>
18
#include <memory>
19
20
class ScTable;
21
22
namespace sc
23
{
24
/** Manager and the holder of the sheet views for a sheet. */
25
class SC_DLLPUBLIC SheetViewManager
26
{
27
private:
28
    std::vector<std::shared_ptr<SheetView>> maViews;
29
    sal_Int32 maNameCounter = 0;
30
31
    std::optional<SortOrderReverser> moSortOrder;
32
33
    bool isValidSheetViewID(SheetViewID nID) const
34
0
    {
35
0
        return nID >= 0 && o3tl::make_unsigned(nID) < maViews.size();
36
0
    }
37
38
    OUString generateName();
39
40
public:
41
    SheetViewManager();
42
43
    /** Creates a new sheet view. */
44
    SheetViewID create(ScTable* pSheetViewTable);
45
46
    /** Returns a sheet view for the ID. */
47
    std::shared_ptr<SheetView> get(SheetViewID nID) const;
48
49
    /** True if there are no sheet views. */
50
0
    bool isEmpty() const { return maViews.empty(); }
51
52
    /** Remove the sheet view with the ID. True if successful. */
53
    bool remove(SheetViewID nID);
54
55
    /** Remove all sheet views. */
56
    void removeAll();
57
58
    /** Return the list of sheet views. */
59
0
    std::vector<std::shared_ptr<SheetView>> const& getSheetViews() const { return maViews; }
60
61
    /** Calculate the next sheet view ID from the current ID. */
62
    SheetViewID getNextSheetView(SheetViewID nID);
63
64
    /** Calculate the previous sheet view ID from the current ID. */
65
    SheetViewID getPreviousSheetView(SheetViewID nID);
66
67
    void unsyncAllSheetViews();
68
69
    static OUString defaultViewName();
70
71
0
    std::optional<SortOrderReverser> const& getSortOrder() const { return moSortOrder; }
72
    void addOrderIndices(std::vector<SCCOLROW> const& rOrder, SCROW firstRow, SCROW lastRow);
73
};
74
}
75
76
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */