1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #include <DocumentOutlineNodesManager.hxx>
23 #include <rootfrm.hxx>
24 #include <modeltoviewhelper.hxx>
25 #include <rtl/ustrbuf.hxx>
30 DocumentOutlineNodesManager::DocumentOutlineNodesManager( SwDoc
& i_rSwdoc
) : m_rDoc( i_rSwdoc
)
34 IDocumentOutlineNodes::tSortedOutlineNodeList::size_type
DocumentOutlineNodesManager::getOutlineNodesCount() const
36 return m_rDoc
.GetNodes().GetOutLineNds().size();
39 int DocumentOutlineNodesManager::getOutlineLevel( const tSortedOutlineNodeList::size_type nIdx
) const
41 return m_rDoc
.GetNodes().GetOutLineNds()[ nIdx
]->
42 GetTextNode()->GetAttrOutlineLevel()-1;
45 OUString
GetExpandTextMerged(SwRootFrame
const*const pLayout
,
46 SwTextNode
const& rNode
, bool const bWithNumber
,
47 bool const bWithSpacesForLevel
, ExpandMode
const i_mode
)
49 if (pLayout
&& pLayout
->HasMergedParas())
51 SwTextFrame
const*const pFrame(static_cast<SwTextFrame
*>(rNode
.getLayoutFrame(pLayout
)));
54 sw::MergedPara
const*const pMerged
= pFrame
->GetMergedPara();
57 if (&rNode
!= pMerged
->pParaPropsNode
)
63 ExpandMode
const mode(ExpandMode::HideDeletions
| i_mode
);
64 OUStringBuffer
ret(rNode
.GetExpandText(pLayout
, 0, -1,
65 bWithNumber
, bWithNumber
, bWithSpacesForLevel
, mode
));
66 for (SwNodeOffset i
= rNode
.GetIndex() + 1;
67 i
<= pMerged
->pLastNode
->GetIndex(); ++i
)
69 SwNode
*const pTmp(rNode
.GetNodes()[i
]);
70 if (pTmp
->GetRedlineMergeFlag() == SwNode::Merge::NonFirst
)
72 ret
.append(pTmp
->GetTextNode()->GetExpandText(
73 pLayout
, 0, -1, false, false, false, mode
));
76 return ret
.makeStringAndClear();
81 return rNode
.GetExpandText(pLayout
, 0, -1, bWithNumber
,
82 bWithNumber
, bWithSpacesForLevel
, i_mode
);
85 OUString
DocumentOutlineNodesManager::getOutlineText(
86 const tSortedOutlineNodeList::size_type nIdx
,
87 SwRootFrame
const*const pLayout
,
88 const bool bWithNumber
,
89 const bool bWithSpacesForLevel
,
90 const bool bWithFootnote
) const
92 SwTextNode
const*const pNode(m_rDoc
.GetNodes().GetOutLineNds()[ nIdx
]->GetTextNode());
93 return GetExpandTextMerged(pLayout
, *pNode
,
94 bWithNumber
, bWithSpacesForLevel
,
95 (bWithFootnote
? ExpandMode::ExpandFootnote
: ExpandMode(0)));
98 SwTextNode
* DocumentOutlineNodesManager::getOutlineNode( const tSortedOutlineNodeList::size_type nIdx
) const
100 return m_rDoc
.GetNodes().GetOutLineNds()[ nIdx
]->GetTextNode();
103 bool DocumentOutlineNodesManager::isOutlineInLayout(
104 const tSortedOutlineNodeList::size_type nIdx
,
105 SwRootFrame
const& rLayout
) const
107 auto const pNode(m_rDoc
.GetNodes().GetOutLineNds()[ nIdx
]->GetTextNode());
108 return sw::IsParaPropsNode(rLayout
, *pNode
);
111 void DocumentOutlineNodesManager::getOutlineNodes( IDocumentOutlineNodes::tSortedOutlineNodeList
& orOutlineNodeList
) const
113 orOutlineNodeList
.clear();
114 orOutlineNodeList
.reserve( getOutlineNodesCount() );
116 const tSortedOutlineNodeList::size_type nOutlCount
= getOutlineNodesCount();
117 for ( tSortedOutlineNodeList::size_type i
= 0; i
< nOutlCount
; ++i
)
119 orOutlineNodeList
.push_back(
120 m_rDoc
.GetNodes().GetOutLineNds()[i
]->GetTextNode() );
124 DocumentOutlineNodesManager::~DocumentOutlineNodesManager()
131 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */