LibreOffice Module sw (master)  1
ndnum.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  */
19 
20 #include <node.hxx>
21 #include <doc.hxx>
23 #include <pam.hxx>
24 #include <ndtxt.hxx>
25 #include <fldbas.hxx>
26 #include <docary.hxx>
27 #include <osl/diagnose.h>
28 
29 bool CompareSwOutlineNodes::operator()( SwNode* const& lhs, SwNode* const& rhs) const
30 {
31  return lhs->GetIndex() < rhs->GetIndex();
32 }
33 
35 {
36  const_iterator it = lower_bound(rP);
37  *pnPos = it - begin();
38  return it != end() && rP->GetIndex() == (*it)->GetIndex();
39 }
40 
42 {
43  SwTextNode * pTextNd = rNd.GetTextNode();
44 
45  if (pTextNd && pTextNd->IsOutlineStateChanged())
46  {
47  bool bFound = m_pOutlineNodes->find(pTextNd) != m_pOutlineNodes->end();
48 
49  if (pTextNd->IsOutline())
50  {
51  if (! bFound)
52  {
53  // assure that text is in the correct nodes array
54  if ( &(pTextNd->GetNodes()) == this )
55  {
56  m_pOutlineNodes->insert(pTextNd);
57  }
58  else
59  {
60  OSL_FAIL( "<SwNodes::UpdateOutlineNode(..)> - given text node isn't in the correct nodes array. This is a serious defect" );
61  }
62  }
63  }
64  else
65  {
66  if (bFound)
67  m_pOutlineNodes->erase(pTextNd);
68  }
69 
70  pTextNd->UpdateOutlineState();
71 
72  // update the structure fields
74  }
75 }
76 
78 {
79  if( m_pOutlineNodes->empty() ) // no OutlineNodes present ?
80  return;
81 
82  const SwNodePtr pSrch = const_cast<SwNodePtr>(&rNd);
83 
85  if (!m_pOutlineNodes->Seek_Entry(pSrch, &nPos))
86  return;
87  if( nPos == m_pOutlineNodes->size() ) // none present for updating ?
88  return;
89 
90  if( nPos )
91  --nPos;
92 
93  if( !GetDoc()->IsInDtor() && IsDocNodes() )
94  UpdateOutlineNode( *(*m_pOutlineNodes)[ nPos ]);
95 }
96 
97 
98 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const_iterator lower_bound(const SwNode * &x) const
sal_uLong GetIndex() const
Definition: node.hxx:282
bool IsOutline() const
Returns if this text node is an outline.
Definition: ndtxt.cxx:4000
void UpdateOutlineIdx(const SwNode &)
Update all OutlineNodes starting from Node.
Definition: ndnum.cxx:77
void UpdateFields() const
Definition: fldbas.hxx:271
IDocumentFieldsAccess const & getIDocumentFieldsAccess() const
Definition: doc.cxx:389
bool operator()(SwNode *const &lhs, SwNode *const &rhs) const
Definition: ndnum.cxx:29
std::unique_ptr< SwOutlineNodes > m_pOutlineNodes
Array of all outline nodes.
Definition: ndarr.hxx:111
bool IsOutlineStateChanged() const
Definition: ndtxt.cxx:4020
void UpdateOutlineNode(SwNode &rNd)
Update all Nodes - Rule/Format-Change.
Definition: ndnum.cxx:41
SwNodes & GetNodes()
Node is in which nodes-array/doc?
Definition: node.hxx:693
SwDoc * GetDoc()
Which Doc contains the nodes-array?
Definition: ndarr.hxx:305
void UpdateOutlineState()
Definition: ndtxt.cxx:4025
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:79
bool IsInDtor() const
Definition: doc.hxx:398
bool IsDocNodes() const
Is the NodesArray the regular one of Doc? (and not the UndoNds, ...) Implementation in doc...
Definition: nodes.cxx:2336
virtual SwFieldType * GetSysFieldType(const SwFieldIds eWhich) const =0
bool Seek_Entry(SwNode *rP, size_type *pnPos) const
Definition: ndnum.cxx:34
std::vector< SwNode * >::size_type size_type
sal_Int32 nPos
std::vector< SwNode * >::const_iterator const_iterator
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
Definition: ndtxt.hxx:843
Base class of the Writer document model elements.
Definition: node.hxx:79