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