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 
26 namespace sw
27 {
28 
30 {
31 }
32 
33 IDocumentOutlineNodes::tSortedOutlineNodeList::size_type DocumentOutlineNodesManager::getOutlineNodesCount() const
34 {
35  return m_rDoc.GetNodes().GetOutLineNds().size();
36 }
37 
38 int DocumentOutlineNodesManager::getOutlineLevel( const tSortedOutlineNodeList::size_type nIdx ) const
39 {
40  return m_rDoc.GetNodes().GetOutLineNds()[ nIdx ]->
41  GetTextNode()->GetAttrOutlineLevel()-1;
42 }
43 
44 OUString GetExpandTextMerged(SwRootFrame const*const pLayout,
45  SwTextNode const& rNode, bool const bWithNumber,
46  bool const bWithSpacesForLevel, ExpandMode const i_mode)
47 {
48  if (pLayout && pLayout->IsHideRedlines())
49  {
50  SwTextFrame const*const pFrame(static_cast<SwTextFrame*>(rNode.getLayoutFrame(pLayout)));
51  if (pFrame)
52  {
53  sw::MergedPara const*const pMerged = pFrame->GetMergedPara();
54  if (pMerged)
55  {
56  if (&rNode != pMerged->pParaPropsNode)
57  {
58  return OUString();
59  }
60  else
61  {
62  ExpandMode const mode(ExpandMode::HideDeletions | i_mode);
63  OUStringBuffer ret(rNode.GetExpandText(pLayout, 0, -1,
64  bWithNumber, bWithNumber, bWithSpacesForLevel, mode));
65  for (sal_uLong i = rNode.GetIndex() + 1;
66  i <= pMerged->pLastNode->GetIndex(); ++i)
67  {
68  SwNode *const pTmp(rNode.GetNodes()[i]);
69  if (pTmp->GetRedlineMergeFlag() == SwNode::Merge::NonFirst)
70  {
71  ret.append(pTmp->GetTextNode()->GetExpandText(
72  pLayout, 0, -1, false, false, false, mode));
73  }
74  }
75  return ret.makeStringAndClear();
76  }
77  }
78  }
79  }
80  return rNode.GetExpandText(pLayout, 0, -1, bWithNumber,
81  bWithNumber, bWithSpacesForLevel, i_mode);
82 }
83 
85  const tSortedOutlineNodeList::size_type nIdx,
86  SwRootFrame const*const pLayout,
87  const bool bWithNumber,
88  const bool bWithSpacesForLevel,
89  const bool bWithFootnote ) const
90 {
91  SwTextNode const*const pNode(m_rDoc.GetNodes().GetOutLineNds()[ nIdx ]->GetTextNode());
92  return GetExpandTextMerged(pLayout, *pNode,
93  bWithNumber, bWithSpacesForLevel,
94  (bWithFootnote ? ExpandMode::ExpandFootnote : ExpandMode(0)));
95 }
96 
97 SwTextNode* DocumentOutlineNodesManager::getOutlineNode( const tSortedOutlineNodeList::size_type nIdx ) const
98 {
99  return m_rDoc.GetNodes().GetOutLineNds()[ nIdx ]->GetTextNode();
100 }
101 
103  const tSortedOutlineNodeList::size_type nIdx,
104  SwRootFrame const& rLayout) const
105 {
106  auto const pNode(m_rDoc.GetNodes().GetOutLineNds()[ nIdx ]->GetTextNode());
107  return sw::IsParaPropsNode(rLayout, *pNode);
108 }
109 
111 {
112  orOutlineNodeList.clear();
113  orOutlineNodeList.reserve( getOutlineNodesCount() );
114 
115  const tSortedOutlineNodeList::size_type nOutlCount = getOutlineNodesCount();
116  for ( tSortedOutlineNodeList::size_type i = 0; i < nOutlCount; ++i )
117  {
118  orOutlineNodeList.push_back(
119  m_rDoc.GetNodes().GetOutLineNds()[i]->GetTextNode() );
120  }
121 }
122 
124 {
125 }
126 
127 
128 }
129 
130 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OUString getOutlineText(const tSortedOutlineNodeList::size_type nIdx, SwRootFrame const *pLayout, const bool bWithNumber=true, const bool bWithSpacesForLevel=false, const bool bWithFootnote=true) const override
Represents the visualization of a paragraph.
Definition: txtfrm.hxx:149
sal_uLong GetIndex() const
Definition: node.hxx:282
tSortedOutlineNodeList::size_type getOutlineNodesCount() const override
sal_uIntPtr sal_uLong
sw::MergedPara * GetMergedPara()
Definition: txtfrm.hxx:438
SwContentFrame * getLayoutFrame(const SwRootFrame *, const SwPosition *pPos=nullptr, std::pair< Point, bool > const *pViewPosAndCalcFrame=nullptr) const
Definition: node.cxx:1148
Definition: doc.hxx:185
Dialog to specify the properties of date form field.
Definition: accfrmobj.cxx:38
The root element of a Writer document layout.
Definition: rootfrm.hxx:79
Describes parts of multiple text nodes, which will form a text frame, even when redlines are hidden a...
Definition: txtfrm.hxx:954
size_type size() const
OUString GetExpandTextMerged(SwRootFrame const *const pLayout, SwTextNode const &rNode, bool const bWithNumber, bool const bWithSpacesForLevel, ExpandMode const i_mode)
int i
SwTextNode * pParaPropsNode
most paragraph properties are taken from the first non-empty node
Definition: txtfrm.hxx:962
bool isOutlineInLayout(tSortedOutlineNodeList::size_type nIdx, SwRootFrame const &rLayout) const override
void getOutlineNodes(IDocumentOutlineNodes::tSortedOutlineNodeList &orOutlineNodeList) const override
SwNodes & GetNodes()
Node is in which nodes-array/doc?
Definition: node.hxx:693
const SwOutlineNodes & GetOutLineNds() const
Array of all OutlineNodes.
Definition: ndarr.hxx:234
int getOutlineLevel(const tSortedOutlineNodeList::size_type nIdx) const override
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:79
ExpandMode
Some helpers for converting model strings to view strings.
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) const
add 4th optional parameter indicating, when that a spa...
Definition: ndtxt.cxx:3383
SwNodes & GetNodes()
Definition: doc.hxx:402
std::vector< const SwTextNode * > tSortedOutlineNodeList
bool IsParaPropsNode(SwRootFrame const &rLayout, SwTextNode const &rNode)
Definition: txtfrm.cxx:319
bool IsHideRedlines() const
Replacement for sw::DocumentRedlineManager::GetRedlineFlags() (this is layout-level redline hiding)...
Definition: rootfrm.hxx:416
SwTextNode const * pLastNode
mainly for sanity checks
Definition: txtfrm.hxx:966
SwTextNode * getOutlineNode(const tSortedOutlineNodeList::size_type nIdx) const override
Base class of the Writer document model elements.
Definition: node.hxx:79