1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
22 #include <IDocumentFieldsAccess.hxx>
25 #include <osl/diagnose.h>
27 bool CompareSwOutlineNodes::operator()( SwNode
* const& lhs
, SwNode
* const& rhs
) const
29 return lhs
->GetIndex() < rhs
->GetIndex();
32 bool SwOutlineNodes::Seek_Entry(SwNode
* rP
, size_type
* pnPos
) const
34 const_iterator it
= lower_bound(rP
);
35 *pnPos
= it
- begin();
36 return it
!= end() && rP
->GetIndex() == (*it
)->GetIndex();
39 void SwNodes::UpdateOutlineNode(SwNode
& rNd
)
41 assert(IsDocNodes()); // no point in m_pOutlineNodes for undo nodes
43 SwTextNode
* pTextNd
= rNd
.GetTextNode();
45 if (!pTextNd
|| !pTextNd
->IsOutlineStateChanged())
48 bool bFound
= m_aOutlineNodes
.find(pTextNd
) != m_aOutlineNodes
.end();
50 if (pTextNd
->IsOutline())
54 // assure that text is in the correct nodes array
55 if ( &(pTextNd
->GetNodes()) == this )
57 m_aOutlineNodes
.insert(pTextNd
);
61 OSL_FAIL( "<SwNodes::UpdateOutlineNode(..)> - given text node isn't in the correct nodes array. This is a serious defect" );
68 m_aOutlineNodes
.erase(pTextNd
);
71 pTextNd
->UpdateOutlineState();
73 // update the structure fields
74 GetDoc().getIDocumentFieldsAccess().GetSysFieldType( SwFieldIds::Chapter
)->UpdateFields();
77 void SwNodes::UpdateOutlineIdx( const SwNode
& rNd
)
79 if( m_aOutlineNodes
.empty() ) // no OutlineNodes present ?
82 SwNode
* const pSrch
= const_cast<SwNode
*>(&rNd
);
84 SwOutlineNodes::size_type nPos
;
85 if (!m_aOutlineNodes
.Seek_Entry(pSrch
, &nPos
))
87 if( nPos
== m_aOutlineNodes
.size() ) // none present for updating ?
93 if( !GetDoc().IsInDtor() && IsDocNodes() )
94 UpdateOutlineNode( *m_aOutlineNodes
[ nPos
]);
98 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */