Coverage Report

Created: 2026-06-30 11:14

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/sc/inc/sheetlimits.hxx
Line
Count
Source
1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
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
20
#pragma once
21
22
#include <salhelper/simplereferenceobject.hxx>
23
#include "address.hxx"
24
25
// Because some stuff needs this info, and those objects lifetimes sometimes exceeds the lifetime
26
// of the ScDocument.
27
struct ScSheetLimits final : public salhelper::SimpleReferenceObject
28
{
29
    const SCCOL mnMaxCol; /// Maximum addressable column
30
    const SCROW mnMaxRow; /// Maximum addressable row
31
32
    ScSheetLimits(SCCOL nMaxCol, SCROW nMaxRow)
33
138k
        : mnMaxCol(nMaxCol)
34
138k
        , mnMaxRow(nMaxRow)
35
138k
    {
36
138k
    }
37
38
    SC_DLLPUBLIC static ScSheetLimits CreateDefault();
39
40
31.4M
    [[nodiscard]] bool ValidCol(SCCOL nCol) const { return ::ValidCol(nCol, mnMaxCol); }
41
31.4M
    [[nodiscard]] bool ValidRow(SCROW nRow) const { return ::ValidRow(nRow, mnMaxRow); }
42
    [[nodiscard]] bool ValidColRow(SCCOL nCol, SCROW nRow) const
43
0
    {
44
0
        return ::ValidColRow(nCol, nRow, mnMaxCol, mnMaxRow);
45
0
    }
46
    [[nodiscard]] bool ValidColRowTab(SCCOL nCol, SCROW nRow, SCTAB nTab) const
47
0
    {
48
0
        return ::ValidColRowTab(nCol, nRow, nTab, mnMaxCol, mnMaxRow);
49
0
    }
50
    [[nodiscard]] bool ValidRange(const ScRange& rRange) const
51
135
    {
52
135
        return ::ValidRange(rRange, mnMaxCol, mnMaxRow);
53
135
    }
54
    [[nodiscard]] bool ValidAddress(const ScAddress& rAddress) const
55
552k
    {
56
552k
        return ::ValidAddress(rAddress, mnMaxCol, mnMaxRow);
57
552k
    }
58
0
    [[nodiscard]] SCCOL SanitizeCol(SCCOL nCol) const { return ::SanitizeCol(nCol, mnMaxCol); }
59
0
    [[nodiscard]] SCROW SanitizeRow(SCROW nRow) const { return ::SanitizeRow(nRow, mnMaxRow); }
60
61
    // equivalent of MAXROW in address.hxx
62
7.09k
    SCROW MaxRow() const { return mnMaxRow; }
63
    // equivalent of MAXCOL in address.hxx
64
6.67k
    SCCOL MaxCol() const { return mnMaxCol; }
65
    // equivalent of MAXROWCOUNT in address.hxx
66
1.37G
    SCROW GetMaxRowCount() const { return mnMaxRow + 1; }
67
    // equivalent of MAXCOLCOUNT in address.hxx
68
41.9k
    SCCOL GetMaxColCount() const { return mnMaxCol + 1; }
69
    // mac col as string ("AMJ" or "XFD")
70
    const OUString& MaxColAsString() const
71
0
    {
72
0
        return mnMaxCol == MAXCOL ? MAXCOL_STRING : MAXCOL_JUMBO_STRING;
73
0
    }
74
};
75
76
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */