2010-10-14 08:30:41 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2011-03-31 10:05:04 +02:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
#include <node.hxx>
|
|
|
|
#include <doc.hxx>
|
2014-07-24 16:46:12 +02:00
|
|
|
#include <IDocumentFieldsAccess.hxx>
|
2000-09-18 23:08:29 +00:00
|
|
|
#include <pam.hxx>
|
|
|
|
#include <ndtxt.hxx>
|
2013-10-22 15:58:57 +03:00
|
|
|
#include <fldbas.hxx>
|
2005-02-21 15:04:41 +00:00
|
|
|
#include <docary.hxx>
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2012-07-19 13:12:17 +02:00
|
|
|
bool CompareSwOutlineNodes::operator()( SwNode* const& lhs, SwNode* const& rhs) const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2012-07-19 13:12:17 +02:00
|
|
|
return lhs->GetIndex() < rhs->GetIndex();
|
|
|
|
}
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2017-03-16 09:30:20 +01:00
|
|
|
bool SwOutlineNodes::Seek_Entry(SwNode* rP, size_type* pnPos) const
|
2012-07-19 13:12:17 +02:00
|
|
|
{
|
|
|
|
const_iterator it = lower_bound(rP);
|
|
|
|
*pnPos = it - begin();
|
|
|
|
return it != end() && rP->GetIndex() == (*it)->GetIndex();
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
2005-07-18 12:34:41 +00:00
|
|
|
void SwNodes::UpdateOutlineNode(SwNode & rNd)
|
|
|
|
{
|
2015-05-20 13:05:49 +02:00
|
|
|
SwTextNode * pTextNd = rNd.GetTextNode();
|
2005-07-18 12:34:41 +00:00
|
|
|
|
2015-05-20 13:05:49 +02:00
|
|
|
if (pTextNd && pTextNd->IsOutlineStateChanged())
|
2005-07-18 12:34:41 +00:00
|
|
|
{
|
2015-10-29 08:38:06 +01:00
|
|
|
bool bFound = m_pOutlineNodes->find(pTextNd) != m_pOutlineNodes->end();
|
2005-07-18 12:34:41 +00:00
|
|
|
|
2015-05-20 13:05:49 +02:00
|
|
|
if (pTextNd->IsOutline())
|
2005-07-18 12:34:41 +00:00
|
|
|
{
|
|
|
|
if (! bFound)
|
2005-11-09 09:07:13 +00:00
|
|
|
{
|
|
|
|
// assure that text is in the correct nodes array
|
2015-05-20 13:05:49 +02:00
|
|
|
if ( &(pTextNd->GetNodes()) == this )
|
2005-11-09 09:07:13 +00:00
|
|
|
{
|
2015-10-29 08:38:06 +01:00
|
|
|
m_pOutlineNodes->insert(pTextNd);
|
2005-11-09 09:07:13 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-09-29 09:54:41 +02:00
|
|
|
OSL_FAIL( "<SwNodes::UpdateOutlineNode(..)> - given text node isn't in the correct nodes array. This is a serious defect" );
|
2005-11-09 09:07:13 +00:00
|
|
|
}
|
|
|
|
}
|
2005-07-18 12:34:41 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (bFound)
|
2015-10-29 08:38:06 +01:00
|
|
|
m_pOutlineNodes->erase(pTextNd);
|
2005-07-18 12:34:41 +00:00
|
|
|
}
|
|
|
|
|
2015-05-20 13:05:49 +02:00
|
|
|
pTextNd->UpdateOutlineState();
|
2005-07-18 12:34:41 +00:00
|
|
|
|
2013-02-13 19:39:39 +01:00
|
|
|
// update the structure fields
|
2017-03-06 13:33:15 +02:00
|
|
|
GetDoc()->getIDocumentFieldsAccess().GetSysFieldType( SwFieldIds::Chapter )->UpdateFields();
|
2005-07-18 12:34:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-20 13:05:49 +02:00
|
|
|
void SwNodes::UpdateOutlineIdx( const SwNode& rNd )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2015-10-29 08:38:06 +01:00
|
|
|
if( m_pOutlineNodes->empty() ) // no OutlineNodes present ?
|
2000-09-18 23:08:29 +00:00
|
|
|
return;
|
|
|
|
|
2015-03-26 15:31:55 +01:00
|
|
|
const SwNodePtr pSrch = const_cast<SwNodePtr>(&rNd);
|
2014-10-13 09:27:24 +01:00
|
|
|
|
2017-03-16 09:30:20 +01:00
|
|
|
SwOutlineNodes::size_type nPos;
|
2015-10-29 08:38:06 +01:00
|
|
|
if (!m_pOutlineNodes->Seek_Entry(pSrch, &nPos))
|
2014-10-13 09:27:24 +01:00
|
|
|
return;
|
2015-10-29 08:38:06 +01:00
|
|
|
if( nPos == m_pOutlineNodes->size() ) // none present for updating ?
|
2000-09-18 23:08:29 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
if( nPos )
|
|
|
|
--nPos;
|
|
|
|
|
|
|
|
if( !GetDoc()->IsInDtor() && IsDocNodes() )
|
2015-10-29 08:38:06 +01:00
|
|
|
UpdateOutlineNode( *(*m_pOutlineNodes)[ nPos ]);
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
2005-02-21 15:04:41 +00:00
|
|
|
|
2010-10-14 08:30:41 +02:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|