Coverage Report

Created: 2026-04-09 11:41

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/sc/inc/userlist.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 "scdllapi.h"
23
24
#include <rtl/ustring.hxx>
25
26
#include <vector>
27
28
/**
29
 * Stores individual user-defined sort list.
30
 */
31
class SC_DLLPUBLIC ScUserListData final
32
{
33
private:
34
    struct SAL_DLLPRIVATE SubStr
35
    {
36
        OUString maReal;
37
        OUString maUpper;
38
        SubStr(OUString&& aReal);
39
    };
40
41
    std::vector<SubStr> maSubStrings;
42
    OUString aStr;
43
44
    SAL_DLLPRIVATE void InitTokens();
45
46
public:
47
    ScUserListData(OUString aStr);
48
49
35
    const OUString& GetString() const { return aStr; }
50
    void SetString(const OUString& rStr);
51
0
    size_t GetSubCount() const { return maSubStrings.size(); }
52
    bool GetSubIndex(const OUString& rSubStr, sal_uInt16& rIndex, bool& bMatchCase) const;
53
    const OUString& GetSubStr(sal_uInt16 nIndex) const;
54
    sal_Int32 Compare(const OUString& rSubStr1, const OUString& rSubStr2) const;
55
    sal_Int32 ICompare(const OUString& rSubStr1, const OUString& rSubStr2) const;
56
};
57
58
/**
59
 * Collection of user-defined sort lists.
60
 */
61
class SC_DLLPUBLIC ScUserList
62
{
63
    typedef std::vector<ScUserListData> DataType;
64
    DataType maData;
65
66
public:
67
    explicit ScUserList(bool initDefault = true);
68
0
    ScUserList(const ScUserList& r) = default;
69
70
    void AddDefaults();
71
0
    void EraseData(size_t nIndex) { maData.erase(maData.cbegin() + nIndex); }
72
73
    const ScUserListData* GetData(const OUString& rSubStr) const;
74
    /// If the list in rStr is already inserted
75
    bool HasEntry(std::u16string_view rStr) const;
76
77
0
    const ScUserListData& operator[](size_t nIndex) const { return maData[nIndex]; }
78
13
    ScUserListData& operator[](size_t nIndex) { return maData[nIndex]; }
79
0
    ScUserList& operator=(const ScUserList& r) = default;
80
    bool operator==(const ScUserList& r) const;
81
82
0
    void clear() { maData.clear(); }
83
22
    size_t size() const { return maData.size(); }
84
    template <class... Args> void emplace_back(Args&&... args)
85
14
    {
86
14
        maData.emplace_back(std::forward<Args>(args)...);
87
14
    }
void ScUserList::emplace_back<rtl::OUString const&>(rtl::OUString const&)
Line
Count
Source
85
8
    {
86
8
        maData.emplace_back(std::forward<Args>(args)...);
87
8
    }
void ScUserList::emplace_back<rtl::OUString&>(rtl::OUString&)
Line
Count
Source
85
6
    {
86
6
        maData.emplace_back(std::forward<Args>(args)...);
87
6
    }
88
};
89
90
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */