Coverage Report

Created: 2025-11-16 09:57

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.2M
    UIName() {}
19
    constexpr explicit UIName(const OUString& s)
20
148M
        : m_s(s)
21
148M
    {
22
148M
    }
23
307M
    const OUString& toString() const { return m_s; }
24
35.6M
    bool isEmpty() const { return m_s.isEmpty(); }
25
84.1M
    bool operator==(const UIName& s) const { return m_s == s.m_s; }
26
31.0M
    bool operator==(const OUString& s) const { return m_s == s; }
27
53.5M
    bool operator==(std::u16string_view s) const { return m_s == s; }
28
83.8M
    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
20.0M
    std::size_t operator()(UIName const& s) const { return std::hash<OUString>()(s.toString()); }
39
};
40
}
41
42
class ProgName
43
{
44
public:
45
6.17M
    ProgName() {}
46
    constexpr explicit ProgName(const OUString& s)
47
9.33M
        : m_s(s)
48
9.33M
    {
49
9.33M
    }
50
27.0M
    const OUString& toString() const { return m_s; }
51
15.9k
    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
987k
    SwMarkName() {}
66
    explicit SwMarkName(const OUString& s)
67
1.42M
        : m_s(s)
68
1.42M
    {
69
1.42M
    }
70
679k
    const OUString& toString() const { return m_s; }
71
61.0k
    bool isEmpty() const { return m_s.isEmpty(); }
72
20.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
207k
    {
87
207k
        return std::hash<OUString>()(s.toString());
88
207k
    }
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
84.3k
    TableStyleName() {}
98
    constexpr explicit TableStyleName(const OUString& s)
99
599
        : m_s(s)
100
599
    {
101
599
    }
102
53.6k
    const OUString& toString() const { return m_s; }
103
0
    bool isEmpty() const { return m_s.isEmpty(); }
104
313
    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: */