sw/inc/ftnidx.hxx | 2 +- sw/source/core/doc/DocumentRedlineManager.cxx | 4 ++-- sw/source/core/doc/doclay.cxx | 2 +- sw/source/core/doc/ftnidx.cxx | 6 +++--- sw/source/core/docnode/ndsect.cxx | 8 ++++---- sw/source/core/docnode/section.cxx | 2 +- sw/source/core/txtnode/atrftn.cxx | 3 +-- sw/source/core/txtnode/ndtxt.cxx | 4 +--- sw/source/core/txtnode/thints.cxx | 3 +-- sw/source/core/undo/unsect.cxx | 4 ++-- sw/source/uibase/app/docsh.cxx | 2 +- 11 files changed, 18 insertions(+), 22 deletions(-)
New commits: commit c186b552d2b4d9c21f064c77a4d28b9f9abf0667 Author: Noel Grandin <noelgran...@gmail.com> AuthorDate: Sat Aug 6 15:58:54 2022 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Sun Aug 7 11:19:19 2022 +0200 make UpdateFootnote take a SwNode, not an SwNodeIndex as part of the process of hiding the internals of SwPosition Change-Id: I118c684c30f5f1be5037db09c8f7377cc738d219 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137908 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/sw/inc/ftnidx.hxx b/sw/inc/ftnidx.hxx index 7d5a22a01359..79766f22c7da 100644 --- a/sw/inc/ftnidx.hxx +++ b/sw/inc/ftnidx.hxx @@ -44,7 +44,7 @@ class SwFootnoteIdxs : public o3tl::sorted_vector<SwTextFootnote*, CompareSwFoot public: SwFootnoteIdxs() {} - void UpdateFootnote( const SwNodeIndex& rStt ); // Update all from pos. + void UpdateFootnote( const SwNode& rStt ); // Update all from pos. void UpdateAllFootnote(); // Update all footnotes. SwTextFootnote* SeekEntry( const SwNode& rNd, size_t* pPos = nullptr ) const; diff --git a/sw/source/core/doc/DocumentRedlineManager.cxx b/sw/source/core/doc/DocumentRedlineManager.cxx index 303b7d01dc8b..f46135f56c6c 100644 --- a/sw/source/core/doc/DocumentRedlineManager.cxx +++ b/sw/source/core/doc/DocumentRedlineManager.cxx @@ -145,7 +145,7 @@ void UpdateFramesForAddDeleteRedline(SwDoc & rDoc, SwPaM const& rPam) } // no need to call UpdateFootnoteNums for FTNNUM_PAGE: // the AppendFootnote/RemoveFootnote will do it by itself! - rDoc.GetFootnoteIdxs().UpdateFootnote(rPam.Start()->nNode); + rDoc.GetFootnoteIdxs().UpdateFootnote(rPam.Start()->GetNode()); SwPosition currentStart(*rPam.Start()); SwTextNode * pStartNode(rPam.Start()->GetNode().GetTextNode()); while (!pStartNode) @@ -257,7 +257,7 @@ void UpdateFramesForRemoveDeleteRedline(SwDoc & rDoc, SwPaM const& rPam) return; } bool isAppendObjsCalled(false); - rDoc.GetFootnoteIdxs().UpdateFootnote(rPam.Start()->nNode); + rDoc.GetFootnoteIdxs().UpdateFootnote(rPam.Start()->GetNode()); SwPosition currentStart(*rPam.Start()); SwTextNode * pStartNode(rPam.Start()->GetNode().GetTextNode()); while (!pStartNode) diff --git a/sw/source/core/doc/doclay.cxx b/sw/source/core/doc/doclay.cxx index d0d480ff5fd6..8d4d8017554f 100644 --- a/sw/source/core/doc/doclay.cxx +++ b/sw/source/core/doc/doclay.cxx @@ -1543,7 +1543,7 @@ void SwDoc::SetAllUniqueFlyNames() else { SwNodeIndex aTmp( GetNodes() ); - GetFootnoteIdxs().UpdateFootnote( aTmp ); + GetFootnoteIdxs().UpdateFootnote( aTmp.GetNode() ); } } diff --git a/sw/source/core/doc/ftnidx.cxx b/sw/source/core/doc/ftnidx.cxx index 7a1fb7d89f12..81f6378c5a49 100644 --- a/sw/source/core/doc/ftnidx.cxx +++ b/sw/source/core/doc/ftnidx.cxx @@ -56,13 +56,13 @@ bool CompareSwFootnoteIdxs::operator()(SwTextFootnote* const& lhs, SwTextFootnot return ( nIdxLHS == nIdxRHS && lhs->GetStart() < rhs->GetStart() ) || nIdxLHS < nIdxRHS; } -void SwFootnoteIdxs::UpdateFootnote( const SwNodeIndex& rStt ) +void SwFootnoteIdxs::UpdateFootnote( const SwNode& rStt ) { if( empty() ) return; // Get the NodesArray using the first foot note's StartIndex - SwDoc& rDoc = rStt.GetNode().GetDoc(); + SwDoc& rDoc = const_cast<SwDoc&>(rStt.GetDoc()); if( rDoc.IsInReading() ) return ; SwTextFootnote* pTextFootnote; @@ -134,7 +134,7 @@ void SwFootnoteIdxs::UpdateFootnote( const SwNodeIndex& rStt ) if (SeekEntry( *pChapterStartHidden, &nPos ) && nPos) { // Step forward until the Index is not the same anymore - const SwNode* pCmpNd = &rStt.GetNode(); + const SwNode* pCmpNd = &rStt; while( nPos && pCmpNd == &((*this)[ --nPos ]->GetTextNode()) ) ; ++nPos; diff --git a/sw/source/core/docnode/ndsect.cxx b/sw/source/core/docnode/ndsect.cxx index a9fa873e7748..538dcd3beef4 100644 --- a/sw/source/core/docnode/ndsect.cxx +++ b/sw/source/core/docnode/ndsect.cxx @@ -380,7 +380,7 @@ SwDoc::InsertSwSection(SwPaM const& rRange, SwSectionData & rNewData, if( bUpdateFootnote ) { - GetFootnoteIdxs().UpdateFootnote( SwNodeIndex( *pNewSectNode )); + GetFootnoteIdxs().UpdateFootnote( *pNewSectNode ); } getIDocumentState().SetModified(); @@ -539,7 +539,7 @@ void SwDoc::DelSectionFormat( SwSectionFormat *pFormat, bool bDelNodes ) SwPaM aPaM( *pSectNd->EndOfSectionNode(), *pSectNd ); GetIDocumentUndoRedo().AppendUndo(std::make_unique<SwUndoDelete>(aPaM, SwDeleteFlags::Default)); if( pFootnoteEndAtTextEnd ) - GetFootnoteIdxs().UpdateFootnote( aUpdIdx ); + GetFootnoteIdxs().UpdateFootnote( aUpdIdx.GetNode() ); getIDocumentState().SetModified(); //#126178# start/end undo have to be pairs! GetIDocumentUndoRedo().EndUndo(SwUndoId::DELSECTION, nullptr); @@ -553,7 +553,7 @@ void SwDoc::DelSectionFormat( SwSectionFormat *pFormat, bool bDelNodes ) SwNodeIndex aUpdIdx( *pIdx ); getIDocumentContentOperations().DeleteSection( const_cast<SwNode*>(static_cast<SwNode const *>(pSectNd)) ); if( pFootnoteEndAtTextEnd ) - GetFootnoteIdxs().UpdateFootnote( aUpdIdx ); + GetFootnoteIdxs().UpdateFootnote( aUpdIdx.GetNode() ); getIDocumentState().SetModified(); //#126178# start/end undo have to be pairs! GetIDocumentUndoRedo().EndUndo(SwUndoId::DELSECTION, nullptr); @@ -584,7 +584,7 @@ void SwDoc::DelSectionFormat( SwSectionFormat *pFormat, bool bDelNodes ) if( nSttNd && pFootnoteEndAtTextEnd ) { SwNodeIndex aUpdIdx( GetNodes(), nSttNd ); - GetFootnoteIdxs().UpdateFootnote( aUpdIdx ); + GetFootnoteIdxs().UpdateFootnote( aUpdIdx.GetNode() ); } //FEATURE::CONDCOLL diff --git a/sw/source/core/docnode/section.cxx b/sw/source/core/docnode/section.cxx index ff6edad6cf1b..b112595a84c1 100644 --- a/sw/source/core/docnode/section.cxx +++ b/sw/source/core/docnode/section.cxx @@ -491,7 +491,7 @@ void SwSection::Notify(SfxHint const& rHint) { SwSectionNode* pSectNd = GetFormat()->GetSectionNode(); if( pSectNd ) - pSectNd->GetDoc().GetFootnoteIdxs().UpdateFootnote(SwNodeIndex( *pSectNd )); + pSectNd->GetDoc().GetFootnoteIdxs().UpdateFootnote(*pSectNd); } } diff --git a/sw/source/core/txtnode/atrftn.cxx b/sw/source/core/txtnode/atrftn.cxx index 9abd514588d3..a9c2fc9036f1 100644 --- a/sw/source/core/txtnode/atrftn.cxx +++ b/sw/source/core/txtnode/atrftn.cxx @@ -354,8 +354,7 @@ void SwTextFootnote::SetStartNode( const SwNodeIndex *pNewNode, bool bDelNode ) // if necessary, update following footnotes if( !pDoc->IsInDtor() && n < pDoc->GetFootnoteIdxs().size() ) { - SwNodeIndex aTmp( pDoc->GetFootnoteIdxs()[n]->GetTextNode() ); - pDoc->GetFootnoteIdxs().UpdateFootnote( aTmp ); + pDoc->GetFootnoteIdxs().UpdateFootnote( pDoc->GetFootnoteIdxs()[n]->GetTextNode() ); } break; } diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx index 37ab4ecf8799..bab4ace59de8 100644 --- a/sw/source/core/txtnode/ndtxt.cxx +++ b/sw/source/core/txtnode/ndtxt.cxx @@ -1628,9 +1628,7 @@ void SwTextNode::ChgTextCollUpdateNum( const SwTextFormatColl *pOldColl, FTNNUM_CHAPTER == rDoc.GetFootnoteInfo().m_eNum && rNds.IsDocNodes() ) { - SwNodeIndex aTmpIndex( rNds, GetIndex()); - - rDoc.GetFootnoteIdxs().UpdateFootnote( aTmpIndex); + rDoc.GetFootnoteIdxs().UpdateFootnote( *rNds[GetIndex()] ); } if( pNewColl && RES_CONDTXTFMTCOLL == pNewColl->Which() ) diff --git a/sw/source/core/txtnode/thints.cxx b/sw/source/core/txtnode/thints.cxx index 65a6dba259c7..3c189cbb55e9 100644 --- a/sw/source/core/txtnode/thints.cxx +++ b/sw/source/core/txtnode/thints.cxx @@ -1533,8 +1533,7 @@ bool SwTextNode::InsertHint( SwTextAttr * const pAttr, const SetAttrMode nMode ) const bool bSuccess = rDoc.GetFootnoteIdxs().insert(pTextFootnote).second; OSL_ENSURE( bSuccess, "FootnoteIdx not inserted." ); } - SwNodeIndex aTmpIndex( *this ); - rDoc.GetFootnoteIdxs().UpdateFootnote( aTmpIndex); + rDoc.GetFootnoteIdxs().UpdateFootnote( *this ); static_cast<SwTextFootnote*>(pAttr)->SetSeqRefNo(); } break; diff --git a/sw/source/core/undo/unsect.cxx b/sw/source/core/undo/unsect.cxx index c0b61815f4ff..da774cbe8561 100644 --- a/sw/source/core/undo/unsect.cxx +++ b/sw/source/core/undo/unsect.cxx @@ -167,7 +167,7 @@ void SwUndoInsSection::UndoImpl(::sw::UndoRedoContext & rContext) if (m_bUpdateFootnote) { - rDoc.GetFootnoteIdxs().UpdateFootnote( aIdx ); + rDoc.GetFootnoteIdxs().UpdateFootnote( aIdx.GetNode() ); } AddUndoRedoPaM(rContext); @@ -385,7 +385,7 @@ void SwUndoDelSection::UndoImpl(::sw::UndoRedoContext & rContext) if( SfxItemState::SET == pFormat->GetItemState( RES_FTN_AT_TXTEND ) || SfxItemState::SET == pFormat->GetItemState( RES_END_AT_TXTEND )) { - rDoc.GetFootnoteIdxs().UpdateFootnote( aStt ); + rDoc.GetFootnoteIdxs().UpdateFootnote( aStt.GetNode() ); } /// OD 04.10.2002 #102894# diff --git a/sw/source/uibase/app/docsh.cxx b/sw/source/uibase/app/docsh.cxx index 789a221ff090..ccd318a39828 100644 --- a/sw/source/uibase/app/docsh.cxx +++ b/sw/source/uibase/app/docsh.cxx @@ -1286,7 +1286,7 @@ void SwDocShell::UpdateLinks() // #i50703# Update footnote numbers SwTextFootnote::SetUniqueSeqRefNo( *GetDoc() ); SwNodeIndex aTmp( GetDoc()->GetNodes() ); - GetDoc()->GetFootnoteIdxs().UpdateFootnote( aTmp ); + GetDoc()->GetFootnoteIdxs().UpdateFootnote( aTmp.GetNode() ); } uno::Reference< frame::XController >