Coverage Report

Created: 2026-03-31 11:00

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/sw/inc/names.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
#pragma once
10
11
#include <rtl/ustring.hxx>
12
#include <functional>
13
14
/// Thin wrapper around OUString to make visible in code when we are dealing with a UIName vs a Programmatic Name
15
class UIName
16
{
17
public:
18
16.5M
    UIName() {}
19
    constexpr explicit UIName(const OUString& s)
20
46.3M
        : m_s(s)
21
46.3M
    {
22
46.3M
    }
23
336M
    const OUString& toString() const { return m_s; }
24
34.9M
    bool isEmpty() const { return m_s.isEmpty(); }
25
31.4M
    bool operator==(const UIName& s) const { return m_s == s.m_s; }
26
23.1M
    bool operator==(const OUString& s) const { return m_s == s; }
27
55.3M
    bool operator==(std::u16string_view s) const { return m_s == s; }
28
103M
    bool operator<(const UIName& s) const { return m_s < s.m_s; }
29
30
private:
31
    OUString m_s;
32
};
33
34
namespace std
35
{
36
template <> struct hash<UIName>
37
{
38
19.3M
    std::size_t operator()(UIName const& s) const { return std::hash<OUString>()(s.toString()); }
39
};
40
}
41
42
class ProgName
43
{
44
public:
45
5.76M
    ProgName() {}
46
    constexpr explicit ProgName(const OUString& s)
47
9.04M
        : m_s(s)
48
9.04M
    {
49
9.04M
    }
50
25.7M
    const OUString& toString() const { return m_s; }
51
10.8k
    bool isEmpty() const { return m_s.isEmpty(); }
52
    bool operator==(const ProgName& s) const = default;
53
261k
    bool operator==(const OUString& s) const { return m_s == s; }
54
0
    bool operator==(std::u16string_view s) const { return m_s == s; }
55
0
    bool operator<(const ProgName& s) const { return m_s < s.m_s; }
56
0
    bool operator>(const ProgName& s) const { return m_s > s.m_s; }
57
58
private:
59
    OUString m_s;
60
};
61
62
class SwMarkName
63
{
64
public:
65
977k
    SwMarkName() {}
66
    explicit SwMarkName(const OUString& s)
67
1.46M
        : m_s(s)
68
1.46M
    {
69
1.46M
    }
70
733k
    const OUString& toString() const { return m_s; }
71
63.0k
    bool isEmpty() const { return m_s.isEmpty(); }
72
24.7M
    bool operator==(const SwMarkName& s) const = default;
73
0
    bool operator==(const OUString& s) const { return m_s == s; }
74
0
    bool operator==(std::u16string_view s) const { return m_s == s; }
75
0
    bool operator<(const SwMarkName& s) const { return m_s < s.m_s; }
76
77
private:
78
    OUString m_s;
79
};
80
81
namespace std
82
{
83
template <> struct hash<SwMarkName>
84
{
85
    std::size_t operator()(SwMarkName const& s) const
86
214k
    {
87
214k
        return std::hash<OUString>()(s.toString());
88
214k
    }
89
};
90
}
91
92
// SwTableAutoFormat names are their special little snowflake. Mostly they are UINames, but sometimes they
93
// are programmatic names, so I isolated them into their own world.
94
class TableStyleName
95
{
96
public:
97
82.1k
    TableStyleName() {}
98
    constexpr explicit TableStyleName(const OUString& s)
99
823
        : m_s(s)
100
823
    {
101
823
    }
102
1.50k
    const OUString& toString() const { return m_s; }
103
0
    bool isEmpty() const { return m_s.isEmpty(); }
104
0
    bool operator==(const TableStyleName& s) const = default;
105
0
    bool operator==(std::u16string_view s) const { return m_s == s; }
106
107
private:
108
    OUString m_s;
109
};
110
111
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */