android: Update app-specific/MIME type icons
[LibreOffice.git] / sw / source / core / docnode / ndnum.cxx
blobaf17a2a68e15e9f027ac4dd6876fbf21b19a0484
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
20 #include <node.hxx>
21 #include <doc.hxx>
22 #include <IDocumentFieldsAccess.hxx>
23 #include <ndtxt.hxx>
24 #include <fldbas.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())
46 return;
48 bool bFound = m_aOutlineNodes.find(pTextNd) != m_aOutlineNodes.end();
50 if (pTextNd->IsOutline())
52 if (! bFound)
54 // assure that text is in the correct nodes array
55 if ( &(pTextNd->GetNodes()) == this )
57 m_aOutlineNodes.insert(pTextNd);
59 else
61 OSL_FAIL( "<SwNodes::UpdateOutlineNode(..)> - given text node isn't in the correct nodes array. This is a serious defect" );
65 else
67 if (bFound)
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 ?
80 return;
82 SwNode* const pSrch = const_cast<SwNode*>(&rNd);
84 SwOutlineNodes::size_type nPos;
85 if (!m_aOutlineNodes.Seek_Entry(pSrch, &nPos))
86 return;
87 if( nPos == m_aOutlineNodes.size() ) // none present for updating ?
88 return;
90 if( nPos )
91 --nPos;
93 if( !GetDoc().IsInDtor() && IsDocNodes() )
94 UpdateOutlineNode( *m_aOutlineNodes[ nPos ]);
98 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */