LibreOffice Module editeng (master) 1
paralist.hxx
Go to the documentation of this file.
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
32class Paragraph;
33typedef struct _xmlTextWriter* xmlTextWriterPtr;
34
36{
37public:
38 void Clear();
39
40 sal_Int32 GetParagraphCount() const
41 {
42 size_t nSize = maEntries.size();
43 if (nSize > SAL_MAX_INT32)
44 {
45 SAL_WARN( "editeng", "ParagraphList::GetParagraphCount - overflow " << nSize);
46 return SAL_MAX_INT32;
47 }
48 return nSize;
49 }
50
51 Paragraph* GetParagraph( sal_Int32 nPos ) const
52 {
53 return 0 <= nPos && o3tl::make_unsigned(nPos) < maEntries.size() ? maEntries[nPos].get() : nullptr;
54 }
55
56 sal_Int32 GetAbsPos( Paragraph const * pParent ) const;
57
58 void Append( std::unique_ptr<Paragraph> pPara);
59 void Insert( std::unique_ptr<Paragraph> pPara, sal_Int32 nAbsPos);
60 void Remove( sal_Int32 nPara );
61 void MoveParagraphs( sal_Int32 nStart, sal_Int32 nDest, sal_Int32 nCount );
62
63 Paragraph* GetParent( Paragraph const * pParagraph ) const;
64 bool HasChildren( Paragraph const * pParagraph ) const;
65 bool HasHiddenChildren( Paragraph const * pParagraph ) const;
66 bool HasVisibleChildren( Paragraph const * pParagraph ) const;
67 sal_Int32 GetChildCount( Paragraph const * pParagraph ) const;
68
69 void Expand( Paragraph const * pParent );
70 void Collapse( Paragraph const * pParent );
71
73
74 void dumpAsXml(xmlTextWriterPtr pWriter) const;
75
76private:
77
79 std::vector<std::unique_ptr<Paragraph>> maEntries;
80};
81
82/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Paragraph * GetParagraph(sal_Int32 nPos) const
Definition: paralist.hxx:51
void Remove(sal_Int32 nPara)
Definition: paralist.cxx:116
Link< Paragraph &, void > aVisibleStateChangedHdl
Definition: paralist.hxx:78
void Insert(std::unique_ptr< Paragraph > pPara, sal_Int32 nAbsPos)
Definition: paralist.cxx:104
std::vector< std::unique_ptr< Paragraph > > maEntries
Definition: paralist.hxx:79
void MoveParagraphs(sal_Int32 nStart, sal_Int32 nDest, sal_Int32 nCount)
Definition: paralist.cxx:127
void dumpAsXml(xmlTextWriterPtr pWriter) const
Definition: paralist.cxx:248
void Clear()
Definition: paralist.cxx:93
void SetVisibleStateChangedHdl(const Link< Paragraph &, void > &rLink)
Definition: paralist.hxx:72
sal_Int32 GetParagraphCount() const
Definition: paralist.hxx:40
bool HasChildren(Paragraph const *pParagraph) const
Definition: paralist.cxx:157
bool HasVisibleChildren(Paragraph const *pParagraph) const
Definition: paralist.cxx:171
sal_Int32 GetChildCount(Paragraph const *pParagraph) const
Definition: paralist.cxx:178
void Append(std::unique_ptr< Paragraph > pPara)
Definition: paralist.cxx:98
void Expand(Paragraph const *pParent)
Definition: paralist.cxx:203
bool HasHiddenChildren(Paragraph const *pParagraph) const
Definition: paralist.cxx:164
void Collapse(Paragraph const *pParent)
Definition: paralist.cxx:219
sal_Int32 GetAbsPos(Paragraph const *pParent) const
Definition: paralist.cxx:235
Paragraph * GetParent(Paragraph const *pParagraph) const
Definition: paralist.cxx:191
struct _xmlTextWriter * xmlTextWriterPtr
sal_uInt16 nPos
#define SAL_WARN(area, stream)
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
struct _xmlTextWriter * xmlTextWriterPtr
Definition: paralist.hxx:33
#define SAL_MAX_INT32