Coverage Report

Created: 2026-08-14 10:22

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/sc/inc/convuno.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
 * 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 <algorithm>
23
#include <i18nlangtag/lang.h>
24
#include <com/sun/star/table/CellAddress.hpp>
25
#include <com/sun/star/table/CellRangeAddress.hpp>
26
#include "address.hxx"
27
28
namespace com::sun::star::lang { struct Locale; }
29
30
class ScUnoConversion
31
{
32
public:
33
    static LanguageType GetLanguage( const css::lang::Locale& rLocale );
34
    static void FillLocale( css::lang::Locale& rLocale, LanguageType eLang );
35
36
    // CellAddress -> ScAddress
37
    static inline void  FillScAddress(
38
                            ScAddress& rScAddress,
39
                            const css::table::CellAddress& rApiAddress );
40
    // ScAddress -> CellAddress
41
    static inline void  FillApiAddress(
42
                            css::table::CellAddress& rApiAddress,
43
                            const ScAddress& rScAddress );
44
    // CellRangeAddress -> ScRange
45
    static inline void  FillScRange(
46
                            ScRange& rScRange,
47
                            const css::table::CellRangeAddress& rApiRange );
48
    // ScRange -> CellRangeAddress
49
    static inline void  FillApiRange(
50
                            css::table::CellRangeAddress& rApiRange,
51
                            const ScRange& rScRange );
52
53
    /** Returns true, if the passed ranges have at least one common cell. */
54
    static inline bool  Intersects(
55
                            const css::table::CellRangeAddress& rApiARange1,
56
                            const css::table::CellRangeAddress& rApiARange2 );
57
    /** Returns true, if the passed range rApiInner is completely inside the passed range rApiOuter. */
58
    static inline bool  Contains(
59
                            const css::table::CellRangeAddress& rApiOuter,
60
                            const css::table::CellRangeAddress& rApiInner );
61
};
62
63
inline void ScUnoConversion::FillScAddress(
64
        ScAddress& rScAddress,
65
        const css::table::CellAddress& rApiAddress )
66
5.34k
{
67
5.34k
    rScAddress.Set( static_cast<SCCOL>(rApiAddress.Column), static_cast<SCROW>(rApiAddress.Row), static_cast<SCTAB>(rApiAddress.Sheet) );
68
5.34k
}
69
70
inline void ScUnoConversion::FillApiAddress(
71
        css::table::CellAddress& rApiAddress,
72
        const ScAddress& rScAddress )
73
0
{
74
0
    rApiAddress.Column = rScAddress.Col();
75
0
    rApiAddress.Row = rScAddress.Row();
76
0
    rApiAddress.Sheet = rScAddress.Tab();
77
0
}
78
79
inline void ScUnoConversion::FillScRange(
80
        ScRange& rScRange,
81
        const css::table::CellRangeAddress& rApiRange )
82
1.46k
{
83
1.46k
    rScRange.aStart.Set( static_cast<SCCOL>(rApiRange.StartColumn), static_cast<SCROW>(rApiRange.StartRow), static_cast<SCTAB>(rApiRange.Sheet) );
84
1.46k
    rScRange.aEnd.Set( static_cast<SCCOL>(rApiRange.EndColumn), static_cast<SCROW>(rApiRange.EndRow), static_cast<SCTAB>(rApiRange.Sheet) );
85
1.46k
}
86
87
inline void ScUnoConversion::FillApiRange(
88
        css::table::CellRangeAddress& rApiRange,
89
        const ScRange& rScRange )
90
623
{
91
623
    rApiRange.StartColumn = rScRange.aStart.Col();
92
623
    rApiRange.StartRow = rScRange.aStart.Row();
93
623
    rApiRange.Sheet = rScRange.aStart.Tab();
94
623
    rApiRange.EndColumn = rScRange.aEnd.Col();
95
623
    rApiRange.EndRow = rScRange.aEnd.Row();
96
623
}
97
98
inline bool ScUnoConversion::Intersects(
99
        const css::table::CellRangeAddress& rApiRange1,
100
        const css::table::CellRangeAddress& rApiRange2 )
101
0
{
102
0
    return (rApiRange1.Sheet == rApiRange2.Sheet) &&
103
0
        (::std::max( rApiRange1.StartColumn, rApiRange2.StartColumn ) <= ::std::min( rApiRange1.EndColumn, rApiRange2.EndColumn )) &&
104
0
        (::std::max( rApiRange1.StartRow, rApiRange2.StartRow ) <= ::std::min( rApiRange1.EndRow, rApiRange2.EndRow ));
105
0
}
106
107
inline bool ScUnoConversion::Contains(
108
        const css::table::CellRangeAddress& rApiOuter,
109
        const css::table::CellRangeAddress& rApiInner )
110
0
{
111
0
    return (rApiOuter.Sheet == rApiInner.Sheet) &&
112
0
        (rApiOuter.StartColumn <= rApiInner.StartColumn) && (rApiInner.EndColumn <= rApiOuter.EndColumn) &&
113
0
        (rApiOuter.StartRow <= rApiInner.StartRow) && (rApiInner.EndRow <= rApiOuter.EndRow);
114
0
}
115
116
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */