/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * 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 .
*/
// Get the NodesArray using the first foot note's StartIndex
SwDoc& rDoc = const_cast<SwDoc&>(rStt.GetDoc()); if( rDoc.IsInReading() ) return ;
SwTextFootnote* pTextFootnote;
// For normal foot notes we treat per-chapter and per-document numbering // separately. For Endnotes we only have per-document numbering. if( FTNNUM_CHAPTER == rFootnoteInfo.m_eNum )
{
SwRootFrame const* pLayout(nullptr);
o3tl::sorted_vector<SwRootFrame*> layouts = rDoc.GetAllLayouts(); // sw_redlinehide: here we need to know if there's *any* layout with // IsHideRedlines(), because then the hidden-numbers have to be updated for (SwRootFrame const* pTmp : layouts)
{ if (pTmp->IsHideRedlines())
{
pLayout = pTmp;
}
}
const SwOutlineNodes& rOutlNds = rDoc.GetNodes().GetOutLineNds(); const SwNode *pChapterStartHidden(&rDoc.GetNodes().GetEndOfExtras());
SwNodeOffset nChapterStart(pChapterStartHidden->GetIndex());
SwNodeOffset nChapterEnd(rDoc.GetNodes().GetEndOfContent().GetIndex());
SwNodeOffset nChapterEndHidden(nChapterEnd); if( !rOutlNds.empty() )
{ // Find the Chapter's start, which contains rStt
size_t n = 0;
for( ; n < rOutlNds.size(); ++n ) if( rOutlNds[ n ]->GetIndex() > rStt.GetIndex() ) break; // found it! elseif ( rOutlNds[ n ]->GetTextNode()->GetAttrOutlineLevel() == 1 )
{
nChapterStart = rOutlNds[ n ]->GetIndex(); if (!pLayout || sw::IsParaPropsNode(*pLayout, *rOutlNds[n]->GetTextNode()))
{
pChapterStartHidden = rOutlNds[ n ];
}
} // now find the end of the range for( ; n < rOutlNds.size(); ++n ) if ( rOutlNds[ n ]->GetTextNode()->GetAttrOutlineLevel() == 1 )
{
nChapterEnd = rOutlNds[ n ]->GetIndex(); break;
}
// continue to find end of hidden-chapter for ( ; n < rOutlNds.size(); ++n)
{ if (rOutlNds[n]->GetTextNode()->GetAttrOutlineLevel() == 1
&& (!pLayout || sw::IsParaPropsNode(*pLayout, *rOutlNds[n]->GetTextNode())))
{
nChapterEndHidden = rOutlNds[n]->GetIndex(); break;
}
}
}
size_t nPos = 0;
size_t nFootnoteNo = 1;
size_t nFootnoteNoHidden = 1; if (SeekEntry( *pChapterStartHidden, &nPos ) && nPos)
{ // Step forward until the Index is not the same anymore const SwNode* pCmpNd = &rStt; while (nPos > 0)
{
--nPos; if (pCmpNd != &((*this)[nPos]->GetTextNode())) break;
}
++nPos;
}
// Get the NodesArray via the StartIndex of the first Footnote
SwDoc& rDoc = const_cast<SwDoc&>((*this)[ 0 ]->GetTextNode().GetDoc());
SwTextFootnote* pTextFootnote; const SwEndNoteInfo& rEndInfo = rDoc.GetEndNoteInfo(); const SwFootnoteInfo& rFootnoteInfo = rDoc.GetFootnoteInfo();
IDocumentRedlineAccess const& rIDRA(rDoc.getIDocumentRedlineAccess());
SwUpdFootnoteEndNtAtEnd aNumArr;
SwRootFrame const* pLayout = rDoc.getIDocumentLayoutAccess().GetCurrentLayout();
o3tl::sorted_vector<SwRootFrame*> aAllLayouts = rDoc.GetAllLayouts(); // For normal Footnotes per-chapter and per-document numbering are treated separately. // For Endnotes we only have document-wise numbering. if( FTNNUM_CHAPTER == rFootnoteInfo.m_eNum )
{ // sw_redlinehide: here we need to know if there's *any* layout with // IsHideRedlines(), because then the hidden-numbers have to be updated for (SwRootFrame const* pTmp : aAllLayouts)
{ if (pTmp->IsHideRedlines())
{
pLayout = pTmp;
}
}
const SwOutlineNodes& rOutlNds = rDoc.GetNodes().GetOutLineNds();
sal_uInt16 nNo = 1; // Number for the Footnotes
sal_uInt16 nNoNo = 1;
size_t nFootnoteIdx = 0; // Index into theFootnoteIdx array for( size_t n = 0; n < rOutlNds.size(); ++n )
{ if ( rOutlNds[ n ]->GetTextNode()->GetAttrOutlineLevel() == 1 )
{
SwNodeOffset nCapStt = rOutlNds[ n ]->GetIndex(); // Start of a new chapter for( ; nFootnoteIdx < size(); ++nFootnoteIdx )
{
pTextFootnote = (*this)[ nFootnoteIdx ]; if( pTextFootnote->GetTextNode().GetIndex() >= nCapStt ) break;
// Endnotes are per-document only const SwFormatFootnote &rFootnote = pTextFootnote->GetFootnote(); if( !rFootnote.IsEndNote() && rFootnote.GetNumStr().isEmpty() &&
!SwUpdFootnoteEndNtAtEnd::FindSectNdWithEndAttr( *pTextFootnote ))
{
pTextFootnote->SetNumber(
rFootnoteInfo.m_nFootnoteOffset + nNo,
rFootnoteInfo.m_nFootnoteOffset + nNoNo,
rFootnote.GetNumStr() );
++nNo; if (!IsFootnoteDeleted(rIDRA, *pTextFootnote))
{
++nNoNo;
}
}
} if( nFootnoteIdx >= size() ) break; // ok, everything is updated
nNo = 1; // sw_redlinehide: this means the numbers are layout dependent in chapter case if (!pLayout || sw::IsParaPropsNode(*pLayout, *rOutlNds[ n ]->GetTextNode()))
{
nNoNo = 1;
}
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.