LibreOffice Module sw (master) 1
DocumentOutlineNodesManager.cxx
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 */
20#include <doc.hxx>
21#include <ndtxt.hxx>
22#include <txtfrm.hxx>
23#include <rootfrm.hxx>
24#include <modeltoviewhelper.hxx>
25#include <rtl/ustrbuf.hxx>
26
27namespace sw
28{
29
31{
32}
33
34IDocumentOutlineNodes::tSortedOutlineNodeList::size_type DocumentOutlineNodesManager::getOutlineNodesCount() const
35{
36 return m_rDoc.GetNodes().GetOutLineNds().size();
37}
38
39int DocumentOutlineNodesManager::getOutlineLevel( const tSortedOutlineNodeList::size_type nIdx ) const
40{
41 return m_rDoc.GetNodes().GetOutLineNds()[ nIdx ]->
42 GetTextNode()->GetAttrOutlineLevel()-1;
43}
44
45OUString GetExpandTextMerged(SwRootFrame const*const pLayout,
46 SwTextNode const& rNode, bool const bWithNumber,
47 bool const bWithSpacesForLevel, ExpandMode const i_mode)
48{
49 if (pLayout && pLayout->HasMergedParas())
50 {
51 SwTextFrame const*const pFrame(static_cast<SwTextFrame*>(rNode.getLayoutFrame(pLayout)));
52 if (pFrame)
53 {
54 sw::MergedPara const*const pMerged = pFrame->GetMergedPara();
55 if (pMerged)
56 {
57 if (&rNode != pMerged->pParaPropsNode)
58 {
59 return OUString();
60 }
61 else
62 {
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)
68 {
69 SwNode *const pTmp(rNode.GetNodes()[i]);
71 {
72 ret.append(pTmp->GetTextNode()->GetExpandText(
73 pLayout, 0, -1, false, false, false, mode));
74 }
75 }
76 return ret.makeStringAndClear();
77 }
78 }
79 }
80 }
81 return rNode.GetExpandText(pLayout, 0, -1, bWithNumber,
82 bWithNumber, bWithSpacesForLevel, i_mode);
83}
84
86 const tSortedOutlineNodeList::size_type nIdx,
87 SwRootFrame const*const pLayout,
88 const bool bWithNumber,
89 const bool bWithSpacesForLevel,
90 const bool bWithFootnote ) const
91{
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)));
96}
97
98SwTextNode* DocumentOutlineNodesManager::getOutlineNode( const tSortedOutlineNodeList::size_type nIdx ) const
99{
100 return m_rDoc.GetNodes().GetOutLineNds()[ nIdx ]->GetTextNode();
101}
102
104 const tSortedOutlineNodeList::size_type nIdx,
105 SwRootFrame const& rLayout) const
106{
107 auto const pNode(m_rDoc.GetNodes().GetOutLineNds()[ nIdx ]->GetTextNode());
108 return sw::IsParaPropsNode(rLayout, *pNode);
109}
110
112{
113 orOutlineNodeList.clear();
114 orOutlineNodeList.reserve( getOutlineNodesCount() );
115
116 const tSortedOutlineNodeList::size_type nOutlCount = getOutlineNodesCount();
117 for ( tSortedOutlineNodeList::size_type i = 0; i < nOutlCount; ++i )
118 {
119 orOutlineNodeList.push_back(
120 m_rDoc.GetNodes().GetOutLineNds()[i]->GetTextNode() );
121 }
122}
123
125{
126}
127
128
129}
130
131/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::vector< const SwTextNode * > tSortedOutlineNodeList
SwContentFrame * getLayoutFrame(const SwRootFrame *, const SwPosition *pPos=nullptr, std::pair< Point, bool > const *pViewPosAndCalcFrame=nullptr) const
Definition: node.cxx:1223
Definition: doc.hxx:197
SwNodes & GetNodes()
Definition: doc.hxx:422
Base class of the Writer document model elements.
Definition: node.hxx:98
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
Definition: ndtxt.hxx:901
SwNodeOffset GetIndex() const
Definition: node.hxx:312
SwNodes & GetNodes()
Node is in which nodes-array/doc?
Definition: node.hxx:706
Merge GetRedlineMergeFlag() const
Definition: node.hxx:116
const SwOutlineNodes & GetOutLineNds() const
Array of all OutlineNodes.
Definition: ndarr.hxx:236
The root element of a Writer document layout.
Definition: rootfrm.hxx:85
bool HasMergedParas() const
Definition: wsfrm.cxx:4773
Represents the visualization of a paragraph.
Definition: txtfrm.hxx:168
sw::MergedPara * GetMergedPara()
Definition: txtfrm.hxx:465
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:112
OUString GetExpandText(SwRootFrame const *pLayout, const sal_Int32 nIdx=0, const sal_Int32 nLen=-1, const bool bWithNum=false, const bool bAddSpaceAfterListLabelStr=false, const bool bWithSpacesForLevel=false, const ExpandMode eAdditionalMode=ExpandMode::ExpandFootnote|ExpandMode::HideFieldmarkCommands) const
add 4th optional parameter <bAddSpaceAfterListLabelStr> indicating, when <bWithNum = true> that a spa...
Definition: ndtxt.cxx:3505
size_type size() const
tSortedOutlineNodeList::size_type getOutlineNodesCount() const override
void getOutlineNodes(IDocumentOutlineNodes::tSortedOutlineNodeList &orOutlineNodeList) const override
OUString getOutlineText(const tSortedOutlineNodeList::size_type nIdx, SwRootFrame const *pLayout, const bool bWithNumber=true, const bool bWithSpacesForLevel=false, const bool bWithFootnote=true) const override
SwTextNode * getOutlineNode(const tSortedOutlineNodeList::size_type nIdx) const override
int getOutlineLevel(const tSortedOutlineNodeList::size_type nIdx) const override
bool isOutlineInLayout(tSortedOutlineNodeList::size_type nIdx, SwRootFrame const &rLayout) const override
SwDoc & m_rDoc
Definition: docbm.cxx:1228
ExpandMode
Some helpers for converting model strings to view strings.
int i
Dialog to specify the properties of date form field.
bool IsParaPropsNode(SwRootFrame const &rLayout, SwTextNode const &rNode)
Definition: txtfrm.cxx:313
OUString GetExpandTextMerged(SwRootFrame const *const pLayout, SwTextNode const &rNode, bool const bWithNumber, bool const bWithSpacesForLevel, ExpandMode const i_mode)
ConversionMode mode
Describes parts of multiple text nodes, which will form a text frame, even when redlines are hidden a...
Definition: txtfrm.hxx:991
SwTextNode * pParaPropsNode
most paragraph properties are taken from the first non-empty node
Definition: txtfrm.hxx:998