Coverage Report

Created: 2025-07-07 10:01

/src/libreoffice/sw/inc/list.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
#ifndef INCLUDED_SW_INC_LIST_HXX
21
#define INCLUDED_SW_INC_LIST_HXX
22
23
#include <rtl/ustring.hxx>
24
#include "SwNodeNum.hxx"
25
#include "pam.hxx"
26
#include <memory>
27
28
class SwDoc;
29
class SwNumRule;
30
class SwNodes;
31
32
enum class SwListRedlineType
33
{
34
    SHOW,
35
    HIDDEN,
36
    ORIGTEXT,
37
};
38
39
class SwList
40
{
41
    public:
42
        SwList( OUString sListId,
43
                SwNumRule& rDefaultListStyle,
44
                const SwNodes& rNodes );
45
        ~SwList() COVERITY_NOEXCEPT_FALSE;
46
47
526k
        const OUString & GetListId() const { return msListId; }
48
49
12.2M
        const UIName & GetDefaultListStyleName() const { return msDefaultListStyleName; }
50
51
        void SetDefaultListStyleName(UIName const&);
52
53
        void InsertListItem(SwNodeNum& rNodeNum,
54
                            SwListRedlineType eRedlines,
55
                            const int nLevel,
56
                            const SwDoc& rDoc);
57
        static void RemoveListItem(SwNodeNum& rNodeNum, const SwDoc& rDoc);
58
59
        void InvalidateListTree();
60
        void ValidateListTree(const SwDoc& rDoc);
61
62
        void MarkListLevel( const int nListLevel,
63
                            const bool bValue );
64
65
        bool IsListLevelMarked( const int nListLevel ) const;
66
67
        bool HasNodes() const;
68
69
    private:
70
        SwList( const SwList& ) = delete;
71
        SwList& operator=( const SwList& ) = delete;
72
73
        void NotifyItemsOnListLevel( const int nLevel );
74
75
        // unique identifier of the list
76
        const OUString msListId;
77
        // default list style for the list items, identified by the list style name
78
        UIName msDefaultListStyleName;
79
80
        // list trees for certain document ranges
81
        struct tListTreeForRange
82
        {
83
            /// tree always corresponds to document model
84
            std::unique_ptr<SwNodeNum> pRoot;
85
            /// Tree that is missing those nodes that are merged or hidden
86
            /// by delete redlines; this is only used if there is a layout
87
            /// that has IsHideRedlines() enabled.
88
            /// A second tree is needed because not only are the numbers in
89
            /// the nodes different, the structure of the tree may be different
90
            /// as well, if a high-level node is hidden its children go under
91
            /// the previous node on the same level.
92
            /// The nodes of pRootRLHidden are a subset of the nodes of pRoot.
93
            std::unique_ptr<SwNodeNum> pRootRLHidden;
94
            /// Tree that is missing those nodes that are merged or hidden
95
            /// by insert redlines; this is only used if there is a layout
96
            /// that has IsHideRedlines() disabled, and the numbering of the
97
            /// original text is also shown.
98
            /// A third tree is needed because not only are the numbers in
99
            /// the nodes different, the structure of the tree may be different
100
            /// The nodes of pRootOrigText are a subset of the nodes of pRoot.
101
            std::unique_ptr<SwNodeNum> pRootOrigText;
102
            /// top-level SwNodes section
103
            std::unique_ptr<SwPaM> pSection;
104
            tListTreeForRange(std::unique_ptr<SwNodeNum> p1, std::unique_ptr<SwNodeNum> p2,
105
                                                std::unique_ptr<SwNodeNum> p3, std::unique_ptr<SwPaM> p4)
106
1.85M
                : pRoot(std::move(p1)), pRootRLHidden(std::move(p2)),
107
1.85M
                                                pRootOrigText(std::move(p3)), pSection(std::move(p4)) {}
108
        };
109
        std::vector<tListTreeForRange> maListTrees;
110
111
        int mnMarkedListLevel;
112
};
113
#endif // INCLUDED_SW_INC_LIST_HXX
114
115
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */