Coverage Report

Created: 2026-04-09 11:41

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.4M
    UIName() {}
19
    constexpr explicit UIName(const OUString& s)
20
44.4M
        : m_s(s)
21
44.4M
    {
22
44.4M
    }
23
301M
    const OUString& toString() const { return m_s; }
24
33.6M
    bool isEmpty() const { return m_s.isEmpty(); }
25
30.6M
    bool operator==(const UIName& s) const { return m_s == s.m_s; }
26
23.6M
    bool operator==(const OUString& s) const { return m_s == s; }
27
56.0M
    bool operator==(std::u16string_view s) const { return m_s == s; }
28
98.0M
    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
18.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.80M
    ProgName() {}
46
    constexpr explicit ProgName(const OUString& s)
47
8.99M
        : m_s(s)
48
8.99M
    {
49
8.99M
    }
50
25.8M
    const OUString& toString() const { return m_s; }
51
13.2k
    bool isEmpty() const { return m_s.isEmpty(); }
52
    bool operator==(const ProgName& s) const = default;
53
272k
    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
1.00M
    SwMarkName() {}
66
    explicit SwMarkName(const OUString& s)
67
1.49M
        : m_s(s)
68
1.49M
    {
69
1.49M
    }
70
748k
    const OUString& toString() const { return m_s; }
71
64.0k
    bool isEmpty() const { return m_s.isEmpty(); }
72
23.9M
    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
216k
    {
87
216k
        return std::hash<OUString>()(s.toString());
88
216k
    }
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
83.2k
    TableStyleName() {}
98
    constexpr explicit TableStyleName(const OUString& s)
99
780
        : m_s(s)
100
780
    {
101
780
    }
102
1.56k
    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: */