Coverage Report

Created: 2026-02-14 09:37

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/editeng/source/outliner/paralist.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 <sal/config.h>
23
#include <sal/log.hxx>
24
25
#include <memory>
26
#include <vector>
27
28
#include <editeng/outliner.hxx>
29
#include <o3tl/safeint.hxx>
30
#include <tools/link.hxx>
31
32
typedef struct _xmlTextWriter* xmlTextWriterPtr;
33
34
class ParagraphList
35
{
36
public:
37
    void            Clear();
38
39
    sal_Int32       GetParagraphCount() const
40
35.9M
    {
41
35.9M
        size_t nSize = maEntries.size();
42
35.9M
        if (nSize > SAL_MAX_INT32)
43
0
        {
44
0
            SAL_WARN( "editeng", "ParagraphList::GetParagraphCount - overflow " << nSize);
45
0
            return SAL_MAX_INT32;
46
0
        }
47
35.9M
        return nSize;
48
35.9M
    }
49
50
    Paragraph*      GetParagraph( sal_Int32 nPos ) const
51
1.70G
    {
52
1.70G
        return 0 <= nPos && o3tl::make_unsigned(nPos) < maEntries.size() ? maEntries[nPos].get() : nullptr;
53
1.70G
    }
54
55
    sal_Int32       GetAbsPos( Paragraph const * pParent ) const;
56
57
    void            Append( std::unique_ptr<Paragraph> pPara);
58
    void            Insert( std::unique_ptr<Paragraph> pPara, sal_Int32 nAbsPos);
59
    void            Remove( sal_Int32 nPara );
60
    void            MoveParagraphs( sal_Int32 nStart, sal_Int32 nDest, sal_Int32 nCount );
61
62
    Paragraph*      GetParent( Paragraph const * pParagraph ) const;
63
    bool            HasChildren( Paragraph const * pParagraph ) const;
64
    bool            HasHiddenChildren( Paragraph const * pParagraph ) const;
65
    bool            HasVisibleChildren( Paragraph const * pParagraph ) const;
66
    sal_Int32       GetChildCount( Paragraph const * pParagraph ) const;
67
68
    void            Expand( Paragraph const * pParent );
69
    void            Collapse( Paragraph const * pParent );
70
71
572k
    void            SetVisibleStateChangedHdl( const Link<Paragraph&,void>& rLink ) { aVisibleStateChangedHdl = rLink; }
72
73
    void            dumpAsXml(xmlTextWriterPtr pWriter) const;
74
75
private:
76
77
    Link<Paragraph&,void> aVisibleStateChangedHdl;
78
    std::vector<std::unique_ptr<Paragraph>> maEntries;
79
};
80
81
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */