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 
27 namespace sw
28 {
29 
31 {
32 }
33 
34 IDocumentOutlineNodes::tSortedOutlineNodeList::size_type DocumentOutlineNodesManager::getOutlineNodesCount() const
35 {
36  return m_rDoc.GetNodes().GetOutLineNds().size();
37 }
38 
39 int DocumentOutlineNodesManager::getOutlineLevel( const tSortedOutlineNodeList::size_type nIdx ) const
40 {
41  return m_rDoc.GetNodes().GetOutLineNds()[ nIdx ]->
42  GetTextNode()->GetAttrOutlineLevel()-1;
43 }
44 
45 OUString 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->IsHideRedlines())
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 (sal_uLong i = rNode.GetIndex() + 1;
67  i <= pMerged->pLastNode->GetIndex(); ++i)
68  {
69  SwNode *const pTmp(rNode.GetNodes()[i]);
70  if (pTmp->GetRedlineMergeFlag() == SwNode::Merge::NonFirst)
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 
98 SwTextNode* 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: */
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:151
sal_uLong GetIndex() const
Definition: node.hxx:282
tSortedOutlineNodeList::size_type getOutlineNodesCount() const override
sal_uIntPtr sal_uLong
sw::MergedPara * GetMergedPara()
Definition: txtfrm.hxx:441
SwContentFrame * getLayoutFrame(const SwRootFrame *, const SwPosition *pPos=nullptr, std::pair< Point, bool > const *pViewPosAndCalcFrame=nullptr) const
Definition: node.cxx:1190
Definition: doc.hxx:184
Dialog to specify the properties of date form field.
The root element of a Writer document layout.
Definition: rootfrm.hxx:80
Describes parts of multiple text nodes, which will form a text frame, even when redlines are hidden a...
Definition: txtfrm.hxx:947
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:955
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:231
PDFDocument & m_rDoc
int getOutlineLevel(const tSortedOutlineNodeList::size_type nIdx) const override
ConversionMode mode
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:80
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:3376
SwNodes & GetNodes()
Definition: doc.hxx:403
std::vector< const SwTextNode * > tSortedOutlineNodeList
bool IsParaPropsNode(SwRootFrame const &rLayout, SwTextNode const &rNode)
Definition: txtfrm.cxx:307
bool IsHideRedlines() const
Replacement for sw::DocumentRedlineManager::GetRedlineFlags() (this is layout-level redline hiding)...
Definition: rootfrm.hxx:417
SwTextNode const * pLastNode
mainly for sanity checks
Definition: txtfrm.hxx:959
SwTextNode * getOutlineNode(const tSortedOutlineNodeList::size_type nIdx) const override
Base class of the Writer document model elements.
Definition: node.hxx:79