summaryrefslogtreecommitdiffstats
path: root/sw/inc/list.hxx
blob: 8055eb065dce738c28c93c572a850dcd47c29582 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * This file incorporates work covered by the following license notice:
 *
 *   Licensed to the Apache Software Foundation (ASF) under one or more
 *   contributor license agreements. See the NOTICE file distributed
 *   with this work for additional information regarding copyright
 *   ownership. The ASF licenses this file to you under the Apache
 *   License, Version 2.0 (the "License"); you may not use this file
 *   except in compliance with the License. You may obtain a copy of
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
 */

#ifndef INCLUDED_SW_INC_LIST_HXX
#define INCLUDED_SW_INC_LIST_HXX

#include <rtl/ustring.hxx>
#include "SwNodeNum.hxx"
#include "pam.hxx"
#include <memory>

class SwDoc;
class SwNumRule;
class SwNodes;

enum class SwListRedlineType
{
    SHOW,
    HIDDEN,
    ORIGTEXT,
};

class SwList
{
    public:
        SwList( OUString sListId,
                SwNumRule& rDefaultListStyle,
                const SwNodes& rNodes );
        ~SwList() COVERITY_NOEXCEPT_FALSE;

        const OUString & GetListId() const { return msListId; }

        const OUString & GetDefaultListStyleName() const { return msDefaultListStyleName; }

        void SetDefaultListStyleName(OUString const&);

        void InsertListItem(SwNodeNum& rNodeNum,
                            SwListRedlineType eRedlines,
                            const int nLevel,
                            const SwDoc& rDoc);
        static void RemoveListItem(SwNodeNum& rNodeNum, const SwDoc& rDoc);

        void InvalidateListTree();
        void ValidateListTree(const SwDoc& rDoc);

        void MarkListLevel( const int nListLevel,
                            const bool bValue );

        bool IsListLevelMarked( const int nListLevel ) const;

        bool HasNodes() const;

    private:
        SwList( const SwList& ) = delete;
        SwList& operator=( const SwList& ) = delete;

        void NotifyItemsOnListLevel( const int nLevel );

        // unique identifier of the list
        const OUString msListId;
        // default list style for the list items, identified by the list style name
        OUString msDefaultListStyleName;

        // list trees for certain document ranges
        struct tListTreeForRange
        {
            /// tree always corresponds to document model
            std::unique_ptr<SwNodeNum> pRoot;
            /// Tree that is missing those nodes that are merged or hidden
            /// by delete redlines; this is only used if there is a layout
            /// that has IsHideRedlines() enabled.
            /// A second tree is needed because not only are the numbers in
            /// the nodes different, the structure of the tree may be different
            /// as well, if a high-level node is hidden its children go under
            /// the previous node on the same level.
            /// The nodes of pRootRLHidden are a subset of the nodes of pRoot.
            std::unique_ptr<SwNodeNum> pRootRLHidden;
            /// Tree that is missing those nodes that are merged or hidden
            /// by insert redlines; this is only used if there is a layout
            /// that has IsHideRedlines() disabled, and the numbering of the
            /// original text is also shown.
            /// A third tree is needed because not only are the numbers in
            /// the nodes different, the structure of the tree may be different
            /// The nodes of pRootOrigText are a subset of the nodes of pRoot.
            std::unique_ptr<SwNodeNum> pRootOrigText;
            /// top-level SwNodes section
            std::unique_ptr<SwPaM> pSection;
            tListTreeForRange(std::unique_ptr<SwNodeNum> p1, std::unique_ptr<SwNodeNum> p2,
                                                std::unique_ptr<SwNodeNum> p3, std::unique_ptr<SwPaM> p4)
                : pRoot(std::move(p1)), pRootRLHidden(std::move(p2)),
                                                pRootOrigText(std::move(p3)), pSection(std::move(p4)) {}
        };
        std::vector<tListTreeForRange> maListTrees;

        int mnMarkedListLevel;
};
#endif // INCLUDED_SW_INC_LIST_HXX

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */