sw/inc/ndarr.hxx | 17 sw/qa/extras/odfimport/odfimport.cxx | 2 sw/qa/extras/uiwriter/uiwriter3.cxx | 4 sw/qa/extras/uiwriter/uiwriter6.cxx | 14 sw/qa/extras/uiwriter/uiwriter8.cxx | 2 sw/source/core/crsr/crsrsh.cxx | 25 - sw/source/core/crsr/crstrvl.cxx | 12 sw/source/core/crsr/pam.cxx | 9 sw/source/core/crsr/swcrsr.cxx | 32 - sw/source/core/crsr/trvlfnfl.cxx | 2 sw/source/core/crsr/trvlreg.cxx | 8 sw/source/core/crsr/trvltbl.cxx | 5 sw/source/core/crsr/viscrs.cxx | 8 sw/source/core/doc/DocumentContentOperationsManager.cxx | 2 sw/source/core/doc/DocumentFieldsManager.cxx | 2 sw/source/core/doc/DocumentRedlineManager.cxx | 10 sw/source/core/doc/doc.cxx | 2 sw/source/core/doc/docbm.cxx | 6 sw/source/core/doc/docfld.cxx | 8 sw/source/core/doc/docglos.cxx | 2 sw/source/core/doc/docredln.cxx | 4 sw/source/core/doc/docsort.cxx | 4 sw/source/core/doc/doctxm.cxx | 15 sw/source/core/doc/tblcpy.cxx | 2 sw/source/core/docnode/ndsect.cxx | 27 - sw/source/core/docnode/ndtbl.cxx | 12 sw/source/core/docnode/node.cxx | 7 sw/source/core/docnode/nodes.cxx | 394 +++++----------- sw/source/core/docnode/section.cxx | 2 sw/source/core/draw/dcontact.cxx | 2 sw/source/core/edit/acorrect.cxx | 2 sw/source/core/edit/edatmisc.cxx | 2 sw/source/core/edit/edattr.cxx | 2 sw/source/core/edit/edglbldc.cxx | 3 sw/source/core/edit/edglss.cxx | 6 sw/source/core/edit/editsh.cxx | 2 sw/source/core/fields/cellfml.cxx | 2 sw/source/core/fields/expfld.cxx | 2 sw/source/core/fields/reffld.cxx | 5 sw/source/core/frmedt/fecopy.cxx | 4 sw/source/core/frmedt/fetab.cxx | 4 sw/source/core/frmedt/tblsel.cxx | 4 sw/source/core/layout/atrfrm.cxx | 2 sw/source/core/layout/flylay.cxx | 2 sw/source/core/layout/ftnfrm.cxx | 6 sw/source/core/layout/newfrm.cxx | 2 sw/source/core/table/swtable.cxx | 2 sw/source/core/txtnode/atrflyin.cxx | 2 sw/source/core/txtnode/atrftn.cxx | 4 sw/source/core/txtnode/ndtxt.cxx | 3 sw/source/core/undo/undobj.cxx | 3 sw/source/core/undo/untbl.cxx | 8 sw/source/core/unocore/unochart.cxx | 2 sw/source/core/unocore/unocrsr.cxx | 2 sw/source/core/unocore/unoframe.cxx | 2 sw/source/core/unocore/unoobj.cxx | 4 sw/source/core/unocore/unoredline.cxx | 4 sw/source/core/unocore/unotext.cxx | 4 sw/source/core/view/vprint.cxx | 4 sw/source/filter/basflt/fltshell.cxx | 47 - sw/source/filter/basflt/shellio.cxx | 4 sw/source/filter/html/htmltab.cxx | 2 sw/source/filter/html/swhtml.cxx | 2 sw/source/filter/inc/fltshell.hxx | 4 sw/source/filter/writer/writer.cxx | 2 sw/source/filter/ww8/writerhelper.cxx | 2 sw/source/filter/ww8/wrtw8nds.cxx | 2 sw/source/filter/ww8/wrtww8.cxx | 2 sw/source/filter/ww8/ww8atr.cxx | 2 sw/source/filter/ww8/ww8glsy.cxx | 2 sw/source/filter/ww8/ww8par.cxx | 4 sw/source/filter/ww8/ww8par6.cxx | 2 sw/source/uibase/app/docsh.cxx | 2 sw/source/uibase/dochdl/swdtflvr.cxx | 2 sw/source/uibase/utlui/content.cxx | 10 75 files changed, 335 insertions(+), 491 deletions(-)
New commits: commit 9bb7d239258133020dea5fb8cd8c3b18f706d4e2 Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Thu Feb 15 20:00:16 2024 +0600 Commit: Mike Kaganski <mike.kagan...@collabora.com> CommitDate: Fri Feb 16 08:37:33 2024 +0100 Deduplicate and unify SwNodes::Go(Next|Prev)(Section) The "Next" methods are made static, just as "Prev" ones. Overloads taking SwNodeIndex and SwPosition are implemented using a common implementation function, to avoid code duplication. Change-Id: I4035188b5c29d19824cd6d031e05d668d5cf1e86 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163443 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> diff --git a/sw/inc/ndarr.hxx b/sw/inc/ndarr.hxx index 7383c253a2e8..64149366d63c 100644 --- a/sw/inc/ndarr.hxx +++ b/sw/inc/ndarr.hxx @@ -131,11 +131,6 @@ class SW_DLLPUBLIC SwNodes final SwNodes(SwDoc& rDoc); - // Returns start of the document section (PostIts/Inserts/Autotext/Redlines/Content), - // or of a specific fly / header / footer / footnote, where this node is, which must not - // be crossed when moving backwards - SwNodeOffset StartOfGlobalSection(const SwNode& node) const; - public: ~SwNodes(); @@ -191,17 +186,17 @@ public: static void GoStartOfSection(SwNodeIndex *); static void GoEndOfSection(SwNodeIndex *); - SwContentNode* GoNext(SwNodeIndex *) const; - SwContentNode* GoNext(SwPosition *) const; + static SwContentNode* GoNext(SwNodeIndex*); + static SwContentNode* GoNext(SwPosition*); static SwContentNode* GoPrevious(SwNodeIndex *, bool canCrossBoundary = false); static SwContentNode* GoPrevious(SwPosition *, bool canCrossBoundary = false); /** Go to next content-node that is not protected or hidden (Both set FALSE ==> GoNext/GoPrevious!!!). */ - SwContentNode* GoNextSection( SwNodeIndex *, bool bSkipHidden = true, - bool bSkipProtect = true ) const; - SwContentNode* GoNextSection( SwPosition *, bool bSkipHidden = true, - bool bSkipProtect = true ) const; + static SwContentNode* GoNextSection( SwNodeIndex *, bool bSkipHidden = true, + bool bSkipProtect = true ); + static SwContentNode* GoNextSection( SwPosition *, bool bSkipHidden = true, + bool bSkipProtect = true ); static SwContentNode* GoPrevSection( SwNodeIndex *, bool bSkipHidden = true, bool bSkipProtect = true ); static SwContentNode* GoPrevSection( SwPosition *, bool bSkipHidden = true, diff --git a/sw/qa/extras/odfimport/odfimport.cxx b/sw/qa/extras/odfimport/odfimport.cxx index 115e30b61368..355f4611686b 100644 --- a/sw/qa/extras/odfimport/odfimport.cxx +++ b/sw/qa/extras/odfimport/odfimport.cxx @@ -760,7 +760,7 @@ CPPUNIT_TEST_FIXTURE(Test, testFdo37606) // And make sure the table got deleted as well. SwNodes& rNodes = pWrtShell->GetDoc()->GetNodes(); SwNodeIndex nNode(rNodes.GetEndOfExtras()); - SwContentNode* pContentNode = rNodes.GoNext(&nNode); + SwContentNode* pContentNode = SwNodes::GoNext(&nNode); // First content node was in a table -> table wasn't deleted. CPPUNIT_ASSERT(!pContentNode->FindTableNode()); } diff --git a/sw/qa/extras/uiwriter/uiwriter3.cxx b/sw/qa/extras/uiwriter/uiwriter3.cxx index db19c52facbf..38b08122c32e 100644 --- a/sw/qa/extras/uiwriter/uiwriter3.cxx +++ b/sw/qa/extras/uiwriter/uiwriter3.cxx @@ -1014,7 +1014,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf61154) // table of contents node shouldn't contain tracked deletion // This was "Text InsertedDeleted 1" - SwTextNode* pNext = static_cast<SwTextNode*>(pDoc->GetNodes().GoNext(&aIdx)); + SwTextNode* pNext = static_cast<SwTextNode*>(SwNodes::GoNext(&aIdx)); CPPUNIT_ASSERT_EQUAL(OUString("Text Inserted 1"), pNext->GetText()); } @@ -1063,7 +1063,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf100691) // table of contents node shouldn't contain invisible text // This was "Text Hidden 1" - SwTextNode* pNext = static_cast<SwTextNode*>(pDoc->GetNodes().GoNext(&aIdx)); + SwTextNode* pNext = static_cast<SwTextNode*>(SwNodes::GoNext(&aIdx)); CPPUNIT_ASSERT_EQUAL(OUString("Text 1"), pNext->GetText()); } diff --git a/sw/qa/extras/uiwriter/uiwriter6.cxx b/sw/qa/extras/uiwriter/uiwriter6.cxx index 5b4140e02967..88c8a354d98d 100644 --- a/sw/qa/extras/uiwriter/uiwriter6.cxx +++ b/sw/qa/extras/uiwriter/uiwriter6.cxx @@ -579,17 +579,17 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testTdf99689TableOfContents) SwTextNode* pTitleNode = pShell->GetCursor()->GetPointNode().GetTextNode(); SwNodeIndex aIdx(*pTitleNode); // skip the title - pDoc->GetNodes().GoNext(&aIdx); + SwNodes::GoNext(&aIdx); // skip the first header. No attributes there. // next node should contain superscript - SwTextNode* pNext = static_cast<SwTextNode*>(pDoc->GetNodes().GoNext(&aIdx)); + SwTextNode* pNext = static_cast<SwTextNode*>(SwNodes::GoNext(&aIdx)); CPPUNIT_ASSERT(pNext->HasHints()); sal_uInt16 nAttrType = lcl_getAttributeIDFromHints(pNext->GetSwpHints()); CPPUNIT_ASSERT_EQUAL(sal_uInt16(RES_CHRATR_ESCAPEMENT), nAttrType); // next node should contain subscript - pNext = static_cast<SwTextNode*>(pDoc->GetNodes().GoNext(&aIdx)); + pNext = static_cast<SwTextNode*>(SwNodes::GoNext(&aIdx)); CPPUNIT_ASSERT(pNext->HasHints()); nAttrType = lcl_getAttributeIDFromHints(pNext->GetSwpHints()); CPPUNIT_ASSERT_EQUAL(sal_uInt16(RES_CHRATR_ESCAPEMENT), nAttrType); @@ -609,13 +609,13 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testTdf99689TableOfFigures) // skip the title // next node should contain subscript - SwTextNode* pNext = static_cast<SwTextNode*>(pDoc->GetNodes().GoNext(&aIdx)); + SwTextNode* pNext = static_cast<SwTextNode*>(SwNodes::GoNext(&aIdx)); CPPUNIT_ASSERT(pNext->HasHints()); sal_uInt16 nAttrType = lcl_getAttributeIDFromHints(pNext->GetSwpHints()); CPPUNIT_ASSERT_EQUAL(sal_uInt16(RES_CHRATR_ESCAPEMENT), nAttrType); // next node should contain superscript - pNext = static_cast<SwTextNode*>(pDoc->GetNodes().GoNext(&aIdx)); + pNext = static_cast<SwTextNode*>(SwNodes::GoNext(&aIdx)); CPPUNIT_ASSERT(pNext->HasHints()); nAttrType = lcl_getAttributeIDFromHints(pNext->GetSwpHints()); CPPUNIT_ASSERT_EQUAL(sal_uInt16(RES_CHRATR_ESCAPEMENT), nAttrType); @@ -635,13 +635,13 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testTdf99689TableOfTables) // skip the title // next node should contain superscript - SwTextNode* pNext = static_cast<SwTextNode*>(pDoc->GetNodes().GoNext(&aIdx)); + SwTextNode* pNext = static_cast<SwTextNode*>(SwNodes::GoNext(&aIdx)); CPPUNIT_ASSERT(pNext->HasHints()); sal_uInt16 nAttrType = lcl_getAttributeIDFromHints(pNext->GetSwpHints()); CPPUNIT_ASSERT_EQUAL(sal_uInt16(RES_CHRATR_ESCAPEMENT), nAttrType); // next node should contain subscript - pNext = static_cast<SwTextNode*>(pDoc->GetNodes().GoNext(&aIdx)); + pNext = static_cast<SwTextNode*>(SwNodes::GoNext(&aIdx)); CPPUNIT_ASSERT(pNext->HasHints()); nAttrType = lcl_getAttributeIDFromHints(pNext->GetSwpHints()); CPPUNIT_ASSERT_EQUAL(sal_uInt16(RES_CHRATR_ESCAPEMENT), nAttrType); diff --git a/sw/qa/extras/uiwriter/uiwriter8.cxx b/sw/qa/extras/uiwriter/uiwriter8.cxx index 269937141682..e0c97099e1b7 100644 --- a/sw/qa/extras/uiwriter/uiwriter8.cxx +++ b/sw/qa/extras/uiwriter/uiwriter8.cxx @@ -2896,7 +2896,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testTdf158459) SwNodes& rNodes = pDoc->GetNodes(); SwNodeIndex aIdx(rNodes.GetEndOfExtras()); - SwContentNode* pContentNode = rNodes.GoNext(&aIdx); + SwContentNode* pContentNode = SwNodes::GoNext(&aIdx); CPPUNIT_ASSERT(pContentNode); SwTextNode* pTextNode = pContentNode->GetTextNode(); CPPUNIT_ASSERT(pTextNode); diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx index 06cc3a4fd64a..04c904f13905 100644 --- a/sw/source/core/crsr/crsrsh.cxx +++ b/sw/source/core/crsr/crsrsh.cxx @@ -682,7 +682,7 @@ bool SwCursorShell::TrySelectOuterTable() pOuterTable->GetTable().CreateSelection(&firstCell.GetNode(), &lastCell.GetNode(), aNew, SwTable::SEARCH_NONE, false); // set table cursor to 1st / last content which may be in inner table - SwContentNode *const pStart = rNodes.GoNext(&firstCell); + SwContentNode* const pStart = SwNodes::GoNext(&firstCell); assert(pStart); // must at least find the previous point node lastCell = *lastCell.GetNode().EndOfSectionNode(); SwContentNode *const pEnd = SwNodes::GoPrevious(&lastCell); @@ -737,7 +737,7 @@ bool SwCursorShell::MoveStartText() assert(pStartNode); SwTableNode const*const pTable(pStartNode->FindTableNode()); m_pCurrentCursor->GetPoint()->Assign(*pStartNode); - GetDoc()->GetNodes().GoNext(m_pCurrentCursor->GetPoint()); + SwNodes::GoNext(m_pCurrentCursor->GetPoint()); while (m_pCurrentCursor->GetPoint()->GetNode().FindTableNode() != pTable && (!pTable || pTable->GetIndex() < m_pCurrentCursor->GetPoint()->GetNode().FindTableNode()->GetIndex()) && MoveOutOfTable()); @@ -759,7 +759,7 @@ void SwCursorShell::ExtendedSelectAll(bool bFootnotes) m_pCurrentCursor->Normalize(true); SwPosition* pPos = m_pCurrentCursor->GetPoint(); pPos->Assign(bFootnotes ? rNodes.GetEndOfPostIts() : static_cast<SwNode const&>(*pStartNode)); - rNodes.GoNext( pPos ); + SwNodes::GoNext(pPos); pPos = m_pCurrentCursor->GetMark(); pPos->Assign(bFootnotes ? rNodes.GetEndOfContent() : static_cast<SwNode const&>(*pStartNode->EndOfSectionNode())); SwContentNode* pCNd = SwNodes::GoPrevious( pPos ); @@ -840,7 +840,7 @@ SwCursorShell::ExtendedSelectedAll() const SwStartNode const* pStartNode(FindParentText(*pShellCursor)); SwNodeIndex nNode(*pStartNode); - SwContentNode* pStart = rNodes.GoNext(&nNode); + SwContentNode* pStart = SwNodes::GoNext(&nNode); if (!pStart) { return {}; @@ -1865,7 +1865,7 @@ static void lcl_CheckHiddenPara( SwPosition& rPos ) SwTextNode* pTextNd = aTmp.GetNode().GetTextNode(); while( pTextNd && pTextNd->HasHiddenCharAttribute( true ) ) { - SwContentNode* pContent = aTmp.GetNodes().GoNext( &aTmp ); + SwContentNode* pContent = SwNodes::GoNext(&aTmp); if ( pContent && pContent->IsTextNode() ) pTextNd = pContent->GetTextNode(); else @@ -3117,7 +3117,7 @@ bool SwCursorShell::IsStartOfDoc() const // after EndOfIcons comes the content selection (EndNd+StNd+ContentNd) SwNodeIndex aIdx( GetDoc()->GetNodes().GetEndOfExtras(), 2 ); if( !aIdx.GetNode().IsContentNode() ) - GetDoc()->GetNodes().GoNext( &aIdx ); + SwNodes::GoNext(&aIdx); return aIdx == m_pCurrentCursor->GetPoint()->GetNode(); } @@ -3345,7 +3345,7 @@ SwCursorShell::SwCursorShell( SwDoc& rDoc, vcl::Window *pInitWin, SwNodes& rNds = rDoc.GetNodes(); SwNodeIndex aNodeIdx( *rNds.GetEndOfContent().StartOfSectionNode() ); - SwContentNode* pCNd = rNds.GoNext( &aNodeIdx ); // go to the first ContentNode + SwContentNode* pCNd = SwNodes::GoNext(&aNodeIdx); // go to the first ContentNode m_pCurrentCursor = new SwShellCursor( *this, SwPosition( aNodeIdx, pCNd, 0 ) ); @@ -3518,7 +3518,7 @@ bool SwCursorShell::FindValidContentNode( bool bOnlyText ) { // set to beginning of document rNdPos.Assign( mxDoc->GetNodes().GetEndOfExtras() ); - mxDoc->GetNodes().GoNext( &rNdPos ); + SwNodes::GoNext(&rNdPos); nNdIdx = rNdPos.GetNodeIndex(); } @@ -3572,7 +3572,7 @@ bool SwCursorShell::FindValidContentNode( bool bOnlyText ) for (;;) { if (bGoNextSection) - pCNd = rNds.GoNextSection( &rNdPos, + pCNd = SwNodes::GoNextSection( &rNdPos, true, !IsReadOnlyAvailable() ); else pCNd = SwNodes::GoPrevSection( &rNdPos, @@ -4002,9 +4002,8 @@ void SwCursorShell::ClearUpCursors() { // tdf#106959: When cursor points to start of a table, the proper content // node is the first one inside the table, not the previous one - SwNodes& aNodes = GetDoc()->GetNodes(); SwNodeIndex aIdx(pStartCursor->GetPoint()->GetNode()); - if (SwNode* pNode = aNodes.GoNext(&aIdx)) + if (SwNode* pNode = SwNodes::GoNext(&aIdx)) { SwPaM aTmpPam(*pNode); *pStartCursor = aTmpPam; @@ -4019,14 +4018,14 @@ void SwCursorShell::ClearUpCursors() SwNode * pNode = SwNodes::GoPrevious(&aIdx); if( pNode == nullptr || lcl_NodeContext( *pNode ) != pStart ) { - pNode = aNodes.GoNext( &aIdx ); + pNode = SwNodes::GoNext(&aIdx); if( pNode == nullptr || lcl_NodeContext( *pNode ) != pStart ) { // If the start entry of the ring is invalid replace it with a // cursor pointing to the beginning of the first content node in the // document. aIdx = *(aNodes.GetEndOfContent().StartOfSectionNode()); - pNode = aNodes.GoNext( &aIdx ); + pNode = SwNodes::GoNext(&aIdx); } } bool bFound = (pNode != nullptr); diff --git a/sw/source/core/crsr/crstrvl.cxx b/sw/source/core/crsr/crstrvl.cxx index 9fa8c76adf09..0a2c404ce399 100644 --- a/sw/source/core/crsr/crstrvl.cxx +++ b/sw/source/core/crsr/crstrvl.cxx @@ -237,7 +237,7 @@ bool SwCursorShell::SetCursorInHdFt(size_t nDescNo, bool bInHeader, bool bEven, SwNodeIndex aIdx( *pCnt->GetContentIdx(), 1 ); SwContentNode* pCNd = aIdx.GetNode().GetContentNode(); if( !pCNd ) - pCNd = pMyDoc->GetNodes().GoNext( &aIdx ); + pCNd = SwNodes::GoNext(&aIdx); Point aPt( m_pCurrentCursor->GetPtPos() ); @@ -283,7 +283,7 @@ bool SwCursorShell::GotoNextTOXBase( const OUString* pName ) SwNodeIndex aIdx(*pSectNd, 1); SwContentNode* pCNd = aIdx.GetNode().GetContentNode(); if (!pCNd) - pCNd = GetDoc()->GetNodes().GoNext( &aIdx ); + pCNd = SwNodes::GoNext(&aIdx); if (pCNd && pCNd->EndOfSectionIndex() <= pSectNd->EndOfSectionIndex()) { @@ -330,7 +330,7 @@ bool SwCursorShell::GotoPrevTOXBase( const OUString* pName ) SwNodeIndex aIdx(*pSectNd, 1); SwContentNode* pCNd = aIdx.GetNode().GetContentNode(); if (!pCNd) - pCNd = GetDoc()->GetNodes().GoNext( &aIdx ); + pCNd = SwNodes::GoNext(&aIdx); if (pCNd && pCNd->EndOfSectionIndex() <= pSectNd->EndOfSectionIndex()) { @@ -437,7 +437,7 @@ bool SwCursorShell::GotoNxtPrvTableFormula( bool bNext, bool bOnlyErrors ) !pFormulaItem->HasValidBoxes() ) ) { SwNodeIndex aIdx( *pTBox->GetSttNd() ); - const SwContentNode* pCNd = GetDoc()->GetNodes().GoNext( &aIdx ); + const SwContentNode* pCNd = SwNodes::GoNext(&aIdx); std::pair<Point, bool> const tmp(aPt, false); if (pCNd) { @@ -1693,7 +1693,7 @@ bool SwCursorShell::GetContentAtPos( const Point& rPt, SwCallLink aLk( *this ); // watch Cursor-Moves SwCursorSaveState aSaveState( *m_pCurrentCursor ); m_pCurrentCursor->GetPoint()->Assign( *static_cast<SwTextFootnote*>(pTextAttr)->GetStartNode() ); - SwContentNode* pCNd = GetDoc()->GetNodes().GoNextSection( + SwContentNode* pCNd = SwNodes::GoNextSection( m_pCurrentCursor->GetPoint(), true, !IsReadOnlyAvailable() ); @@ -2563,7 +2563,7 @@ const SwRangeRedline* SwCursorShell::GotoRedline_( SwRedlineTable::size_type nAr SwPosition* pPtPos = m_pCurrentCursor->GetPoint(); if( !pPtPos->GetNode().IsContentNode() ) { - SwContentNode* pCNd = GetDoc()->GetNodes().GoNextSection( pPtPos, + SwContentNode* pCNd = SwNodes::GoNextSection(pPtPos, true, IsReadOnlyAvailable() ); if( pCNd ) { diff --git a/sw/source/core/crsr/pam.cxx b/sw/source/core/crsr/pam.cxx index 92f17cbbd24d..79d9718b59fd 100644 --- a/sw/source/core/crsr/pam.cxx +++ b/sw/source/core/crsr/pam.cxx @@ -395,7 +395,7 @@ bool GoPrevious( SwNode* pNd, SwContentIndex * pIdx, SwCursorSkipMode nMode ) SwContentNode* GoNextNds( SwNodeIndex* pIdx, bool bChk ) { SwNodeIndex aIdx( *pIdx ); - SwContentNode* pNd = aIdx.GetNodes().GoNext( &aIdx ); + SwContentNode* pNd = SwNodes::GoNext(&aIdx); if( pNd ) { if( bChk && SwNodeOffset(1) != aIdx.GetIndex() - pIdx->GetIndex() && @@ -425,7 +425,7 @@ SwContentNode* GoPreviousNds( SwNodeIndex * pIdx, bool bChk ) SwContentNode* GoNextPos( SwPosition* pIdx, bool bChk ) { SwNodeIndex aIdx( pIdx->GetNode() ); - SwContentNode* pNd = aIdx.GetNodes().GoNext( &aIdx ); + SwContentNode* pNd = SwNodes::GoNext(&aIdx); if( pNd ) { if( bChk && SwNodeOffset(1) != aIdx.GetIndex() - pIdx->GetNodeIndex() && @@ -1076,7 +1076,6 @@ SwContentNode* GetNode( SwPaM & rPam, bool& rbFirst, SwMoveFnCollection const & { SwPosition aPos( *rPam.GetPoint() ); bool bSrchForward = &fnMove == &fnMoveForward; - SwNodes& rNodes = aPos.GetNodes(); // go to next/previous ContentNode while( true ) @@ -1088,7 +1087,7 @@ SwContentNode* GetNode( SwPaM & rPam, bool& rbFirst, SwMoveFnCollection const & } pNd = bSrchForward - ? rNodes.GoNextSection( &aPos, true, !bInReadOnly ) + ? SwNodes::GoNextSection( &aPos, true, !bInReadOnly ) : SwNodes::GoPrevSection( &aPos, true, !bInReadOnly ); if( pNd ) { @@ -1124,7 +1123,7 @@ void GoStartDoc( SwPosition * pPos ) SwNodes& rNodes = pPos->GetNodes(); pPos->Assign( *rNodes.GetEndOfContent().StartOfSectionNode() ); // we always need to find a ContentNode! - rNodes.GoNext( pPos ); + SwNodes::GoNext(pPos); } void GoEndDoc( SwPosition * pPos ) diff --git a/sw/source/core/crsr/swcrsr.cxx b/sw/source/core/crsr/swcrsr.cxx index 1c29c2328467..3f31fd037a5c 100644 --- a/sw/source/core/crsr/swcrsr.cxx +++ b/sw/source/core/crsr/swcrsr.cxx @@ -255,12 +255,12 @@ bool SwCursor::IsSelOvr(SwCursorSelOverFlags const eFlags) sal_Int32 nContentPos = m_vSavePos.back().nContent; bool bGoNxt = m_vSavePos.back().nNode < rPtPos.GetNodeIndex(); SwContentNode* pCNd = bGoNxt - ? rNds.GoNextSection( &rPtPos, bSkipOverHiddenSections, bSkipOverProtectSections) + ? SwNodes::GoNextSection( &rPtPos, bSkipOverHiddenSections, bSkipOverProtectSections) : SwNodes::GoPrevSection( &rPtPos, bSkipOverHiddenSections, bSkipOverProtectSections); if( !pCNd && ( SwCursorSelOverFlags::EnableRevDirection & eFlags )) { bGoNxt = !bGoNxt; - pCNd = bGoNxt ? rNds.GoNextSection( &rPtPos, bSkipOverHiddenSections, bSkipOverProtectSections) + pCNd = bGoNxt ? SwNodes::GoNextSection( &rPtPos, bSkipOverHiddenSections, bSkipOverProtectSections) : SwNodes::GoPrevSection( &rPtPos, bSkipOverHiddenSections, bSkipOverProtectSections); } @@ -281,7 +281,7 @@ bool SwCursor::IsSelOvr(SwCursorSelOverFlags const eFlags) { // then to the beginning of the document rPtPos.Assign( rNds.GetEndOfExtras() ); - pCNd = rNds.GoNext( &rPtPos ); + pCNd = SwNodes::GoNext(&rPtPos); } } } @@ -517,7 +517,7 @@ bool SwCursor::IsSelOvr(SwCursorSelOverFlags const eFlags) { pMyNd = bSelTop ? SwNodes::GoPrevSection( GetPoint(),true,false ) - : rNds.GoNextSection( GetPoint(),true,false ); + : SwNodes::GoNextSection( GetPoint(),true,false ); /* #i12312# Handle failure of Go{Prev|Next}Section */ if ( nullptr == pMyNd) @@ -623,7 +623,7 @@ GoNextCell: ++aCellStt; pCNd = aCellStt.GetNode().GetContentNode(); if( !pCNd ) - pCNd = aCellStt.GetNodes().GoNext( &aCellStt ); + pCNd = SwNodes::GoNext(&aCellStt); bProt = pCNd->IsProtect(); if( !bProt ) break; @@ -678,7 +678,7 @@ GoPrevCell: aCellStt.Assign( *pNd->StartOfSectionNode(), +1 ); pCNd = aCellStt.GetNode().GetContentNode(); if( !pCNd ) - pCNd = pNd->GetNodes().GoNext( &aCellStt ); + pCNd = SwNodes::GoNext(&aCellStt); bProt = pCNd->IsProtect(); if( !bProt ) break; @@ -895,13 +895,12 @@ static bool lcl_MakeSelFwrd( const SwNode& rSttNd, const SwNode& rEndNd, if( rSttNd.GetIndex() + 1 == rEndNd.GetIndex() ) return false; - SwNodes& rNds = rPam.GetDoc().GetNodes(); rPam.DeleteMark(); SwContentNode* pCNd; if( !bFirst ) { rPam.GetPoint()->Assign(rSttNd); - pCNd = rNds.GoNext( rPam.GetPoint() ); + pCNd = SwNodes::GoNext(rPam.GetPoint()); if( !pCNd ) return false; rPam.GetPoint()->AssignStartIndex(*pCNd); @@ -927,7 +926,6 @@ static bool lcl_MakeSelBkwrd( const SwNode& rSttNd, const SwNode& rEndNd, if( rEndNd.GetIndex() + 1 == rSttNd.GetIndex() ) return false; - SwNodes& rNds = rPam.GetDoc().GetNodes(); rPam.DeleteMark(); SwContentNode* pCNd; if( !bFirst ) @@ -944,7 +942,7 @@ static bool lcl_MakeSelBkwrd( const SwNode& rSttNd, const SwNode& rEndNd, rPam.SetMark(); rPam.GetPoint()->Assign(rEndNd); - pCNd = rNds.GoNext( rPam.GetPoint() ); + pCNd = SwNodes::GoNext(rPam.GetPoint()); if( !pCNd ) return false; rPam.GetPoint()->SetContent(0); @@ -1117,7 +1115,7 @@ void SwCursor::FillFindPos( SwDocPositions ePos, SwPosition& rPos ) const { case SwDocPositions::Start: rPos.Assign(*rNds.GetEndOfContent().StartOfSectionNode()); - pCNd = rNds.GoNext( &rPos ); + pCNd = SwNodes::GoNext(&rPos); break; case SwDocPositions::End: rPos.Assign(rNds.GetEndOfContent()); @@ -1126,7 +1124,7 @@ void SwCursor::FillFindPos( SwDocPositions ePos, SwPosition& rPos ) const break; case SwDocPositions::OtherStart: rPos.Assign( *rNds[ SwNodeOffset(0) ] ); - pCNd = rNds.GoNext( &rPos ); + pCNd = SwNodes::GoNext(&rPos); break; case SwDocPositions::OtherEnd: rPos.Assign( *rNds.GetEndOfContent().StartOfSectionNode() ); @@ -1890,7 +1888,7 @@ bool SwCursor::LeftRight( bool bLeft, sal_uInt16 nCnt, SwCursorSkipMode nMode, SwNodeIndex aNewIdx( *pTableBox->GetSttNd() ); rPtPos.Assign( aNewIdx ); - GetDoc().GetNodes().GoNextSection( &rPtPos, false, false ); + SwNodes::GoNextSection(&rPtPos, false, false); SwContentNode* pContentNode = GetPointContentNode(); if ( pContentNode ) { @@ -1923,7 +1921,7 @@ bool SwCursor::LeftRight( bool bLeft, sal_uInt16 nCnt, SwCursorSkipMode nMode, SwNodeIndex aNewIdx( *pTableBox->GetSttNd() ); rPtPos.Assign( aNewIdx ); - GetDoc().GetNodes().GoNextSection( &rPtPos, false, false ); + SwNodes::GoNextSection(&rPtPos, false, false); SwContentNode* pContentNode = GetPointContentNode(); if ( pContentNode ) { @@ -2244,7 +2242,7 @@ bool SwCursor::GoPrevNextCell( bool bNext, sal_uInt16 nCnt ) rPtPos.Adjust(SwNodeOffset(1)); if( !rPtPos.GetNode().IsContentNode() ) - GetDoc().GetNodes().GoNextSection( &rPtPos, true, false ); + SwNodes::GoNextSection(&rPtPos, true, false); GetPoint()->SetContent( 0 ); return !IsInProtectTable( true ); @@ -2451,7 +2449,7 @@ SwCursor* SwTableCursor::MakeBoxSels( SwCursor* pCurrentCursor ) SwNodeIndex aIdx( *pSttNd, 1 ); const SwNode* pNd = &aIdx.GetNode(); if( !pNd->IsContentNode() ) - pNd = rNds.GoNextSection( &aIdx, true, false ); + pNd = SwNodes::GoNextSection(&aIdx, true, false); SwPosition* pPos = pCur->GetMark(); if( pNd != &pPos->GetNode() ) @@ -2496,7 +2494,7 @@ SwCursor* SwTableCursor::MakeBoxSels( SwCursor* pCurrentCursor ) break; SwNode* pNd = &aIdx.GetNode(); if( !pNd->IsContentNode() ) - pNd = rNds.GoNextSection( &aIdx, true, false ); + pNd = SwNodes::GoNextSection(&aIdx, true, false); SwPaM *const pNew = (!pCurrentCursor->IsMultiSelection() && !pCurrentCursor->HasMark()) ? pCurrentCursor diff --git a/sw/source/core/crsr/trvlfnfl.cxx b/sw/source/core/crsr/trvlfnfl.cxx index 369e6041340f..8cdf807acc55 100644 --- a/sw/source/core/crsr/trvlfnfl.cxx +++ b/sw/source/core/crsr/trvlfnfl.cxx @@ -74,7 +74,7 @@ bool SwCursor::GotoFootnoteText() SwCursorSaveState aSaveState( *this ); GetPoint()->Assign( *static_cast<SwTextFootnote*>(pFootnote)->GetStartNode() ); - SwContentNode* pCNd = GetDoc().GetNodes().GoNextSection( + SwContentNode* pCNd = SwNodes::GoNextSection( GetPoint(), true, !IsReadOnlyAvailable() ); if( pCNd ) diff --git a/sw/source/core/crsr/trvlreg.cxx b/sw/source/core/crsr/trvlreg.cxx index 6ae638bd040a..1bcc4e81ea33 100644 --- a/sw/source/core/crsr/trvlreg.cxx +++ b/sw/source/core/crsr/trvlreg.cxx @@ -73,8 +73,7 @@ bool GotoPrevRegion( SwPaM& rCurrentCursor, SwMoveFnCollection const & fnPosRegi else if( &fnPosRegion == &fnMoveForward ) { aIdx = *pNd; - SwContentNode* pCNd = pNd->GetNodes().GoNextSection( &aIdx, - true, !bInReadOnly ); + SwContentNode* pCNd = SwNodes::GoNextSection(&aIdx, true, !bInReadOnly); if( !pCNd ) { --aIdx; @@ -148,8 +147,7 @@ bool GotoNextRegion( SwPaM& rCurrentCursor, SwMoveFnCollection const & fnPosRegi else if( &fnPosRegion == &fnMoveForward ) { aIdx = *pNd; - SwContentNode* pCNd = pNd->GetNodes().GoNextSection( &aIdx, - true, !bInReadOnly ); + SwContentNode* pCNd = SwNodes::GoNextSection(&aIdx, true, !bInReadOnly); if( !pCNd ) { aIdx.Assign( *pNd->EndOfSectionNode(), +1 ); @@ -203,7 +201,7 @@ bool GotoCurrRegionAndSkip( SwPaM& rCurrentCursor, SwMoveFnCollection const & fn else { SwNodeIndex aIdx( *pNd ); - pCNd = pNd->GetNodes().GoNextSection( &aIdx, true, !bInReadOnly ); + pCNd = SwNodes::GoNextSection(&aIdx, true, !bInReadOnly); if( !pCNd ) return false; pPos->Assign( aIdx ); diff --git a/sw/source/core/crsr/trvltbl.cxx b/sw/source/core/crsr/trvltbl.cxx index 689457d02863..b16b40122a26 100644 --- a/sw/source/core/crsr/trvltbl.cxx +++ b/sw/source/core/crsr/trvltbl.cxx @@ -359,12 +359,11 @@ static bool lcl_FindNextCell( SwNodeIndex& rIdx, bool bInReadOnly ) const SwNode* pTableEndNode = pTableNd->EndOfSectionNode(); - SwNodes& rNds = aTmp.GetNode().GetNodes(); SwContentNode* pCNd = aTmp.GetNode().GetContentNode(); // no content node => go to next content node if( !pCNd ) - pCNd = rNds.GoNext( &aTmp ); + pCNd = SwNodes::GoNext(&aTmp); // robust if ( !pCNd ) @@ -395,7 +394,7 @@ static bool lcl_FindNextCell( SwNodeIndex& rIdx, bool bInReadOnly ) // ok, get the next content node: pCNd = aTmp.GetNode().GetContentNode(); if( nullptr == pCNd ) - pCNd = rNds.GoNext( &aTmp ); + pCNd = SwNodes::GoNext(&aTmp); // robust: if ( !pCNd ) diff --git a/sw/source/core/crsr/viscrs.cxx b/sw/source/core/crsr/viscrs.cxx index 2dd958b0c42b..0a0f5f186d93 100644 --- a/sw/source/core/crsr/viscrs.cxx +++ b/sw/source/core/crsr/viscrs.cxx @@ -1159,7 +1159,6 @@ void SwShellTableCursor::FillRects() SwRegionRects aReg( comphelper::LibreOfficeKit::isActive() ? GetShell()->getIDocumentLayoutAccess().GetCurrentLayout()->getFrameArea() : GetShell()->VisArea() ); - SwNodes& rNds = GetDoc().GetNodes(); SwFrame* pEndFrame = nullptr; for (size_t n = 0; n < m_SelectedBoxes.size(); ++n) { @@ -1167,7 +1166,7 @@ void SwShellTableCursor::FillRects() const SwTableNode* pSelTableNd = pSttNd->FindTableNode(); SwNodeIndex aIdx( *pSttNd ); - SwContentNode* pCNd = rNds.GoNextSection( &aIdx, true, false ); + SwContentNode* pCNd = SwNodes::GoNextSection(&aIdx, true, false); // table in table // (see also lcl_FindTopLevelTable in unoobj2.cxx for a different @@ -1176,7 +1175,7 @@ void SwShellTableCursor::FillRects() while ( pSelTableNd != pCurTableNd && pCurTableNd ) { aIdx = pCurTableNd->EndOfSectionIndex(); - pCNd = rNds.GoNextSection( &aIdx, true, false ); + pCNd = SwNodes::GoNextSection(&aIdx, true, false); pCurTableNd = pCNd->FindTableNode(); } @@ -1225,11 +1224,10 @@ bool SwShellTableCursor::Contains( const Point& rPt ) const if (m_SelectedBoxes.empty() || m_bParked || !GetPoint()->GetNodeIndex()) return false; - SwNodes& rNds = GetDoc().GetNodes(); for (size_t n = 0; n < m_SelectedBoxes.size(); ++n) { SwNodeIndex aIdx( *m_SelectedBoxes[n]->GetSttNd() ); - SwContentNode* pCNd = rNds.GoNextSection( &aIdx, true, false ); + SwContentNode* pCNd = SwNodes::GoNextSection(&aIdx, true, false); if( !pCNd ) continue; diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx b/sw/source/core/doc/DocumentContentOperationsManager.cxx index b78b6b66daef..4c6de6aed92f 100644 --- a/sw/source/core/doc/DocumentContentOperationsManager.cxx +++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx @@ -2253,7 +2253,7 @@ bool DocumentContentOperationsManager::DelFullPara( SwPaM& rPam ) SwPosition aTmpPos( *aDelPam.GetPoint() ); if( bGoNext ) { - m_rDoc.GetNodes().GoNext( &aTmpPos ); + SwNodes::GoNext(&aTmpPos); } ::PaMCorrAbs( aDelPam, aTmpPos ); } diff --git a/sw/source/core/doc/DocumentFieldsManager.cxx b/sw/source/core/doc/DocumentFieldsManager.cxx index aaf26ce9eb46..3b5888b34122 100644 --- a/sw/source/core/doc/DocumentFieldsManager.cxx +++ b/sw/source/core/doc/DocumentFieldsManager.cxx @@ -742,7 +742,7 @@ void DocumentFieldsManager::UpdateTableFields(const SwTable* pTable) SwNodeIndex aCNdIdx( *pTableNd, +2 ); SwContentNode* pCNd = aCNdIdx.GetNode().GetContentNode(); if( !pCNd ) - pCNd = m_rDoc.GetNodes().GoNext( &aCNdIdx ); + pCNd = SwNodes::GoNext(&aCNdIdx); if (pCNd) { diff --git a/sw/source/core/doc/DocumentRedlineManager.cxx b/sw/source/core/doc/DocumentRedlineManager.cxx index fe7b22049a4c..3f5ccfc0ec5c 100644 --- a/sw/source/core/doc/DocumentRedlineManager.cxx +++ b/sw/source/core/doc/DocumentRedlineManager.cxx @@ -238,7 +238,7 @@ void UpdateFramesForAddDeleteRedline(SwDoc & rDoc, SwPaM const& rPam) } SwNodeIndex tmp(*pLast); // skip over hidden sections! - pNode = static_cast<SwTextNode*>(pLast->GetNodes().GoNextSection(&tmp, /*bSkipHidden=*/true, /*bSkipProtect=*/false)); + pNode = static_cast<SwTextNode*>(SwNodes::GoNextSection(&tmp, /*bSkipHidden=*/true, /*bSkipProtect=*/false)); } while (pNode && pNode->GetIndex() <= rPam.End()->GetNodeIndex()); } @@ -364,7 +364,7 @@ void UpdateFramesForRemoveDeleteRedline(SwDoc & rDoc, SwPaM const& rPam) } SwNodeIndex tmp(*pLast); // skip over hidden sections! - pNode = static_cast<SwTextNode*>(pLast->GetNodes().GoNextSection(&tmp, /*bSkipHidden=*/true, /*bSkipProtect=*/false)); + pNode = static_cast<SwTextNode*>(SwNodes::GoNextSection(&tmp, /*bSkipHidden=*/true, /*bSkipProtect=*/false)); } while (pNode && pNode->GetIndex() <= rPam.End()->GetNodeIndex()); } @@ -3624,7 +3624,7 @@ const SwRangeRedline* DocumentRedlineManager::SelNextRedline( SwPaM& rPam ) cons SwPosition* pPos = rPam.GetMark(); if( !pPos->GetNode().IsContentNode() ) { - pCNd = m_rDoc.GetNodes().GoNextSection( pPos ); + pCNd = SwNodes::GoNextSection(pPos); if( pCNd ) { if( pPos->GetNode() <= rPam.GetPoint()->GetNode() ) @@ -3691,7 +3691,7 @@ const SwRangeRedline* DocumentRedlineManager::SelPrevRedline( SwPaM& rPam ) cons if( !pStt->GetNode().IsContentNode() ) { SwNodeIndex aTmp( pStt->GetNode() ); - SwContentNode* pCNd = m_rDoc.GetNodes().GoNextSection( &aTmp ); + SwContentNode* pCNd = SwNodes::GoNextSection(&aTmp); if( !pCNd || ( aTmp == rSttPos.GetNode() && !rSttPos.GetContentIndex() )) pFnd = nullptr; @@ -3766,7 +3766,7 @@ const SwRangeRedline* DocumentRedlineManager::SelPrevRedline( SwPaM& rPam ) cons pPos = rPam.GetPoint(); if( !pPos->GetNode().IsContentNode() ) { - pCNd = m_rDoc.GetNodes().GoNextSection( pPos ); + pCNd = SwNodes::GoNextSection(pPos); if( pCNd ) { if( pPos->GetNode() <= rPam.GetMark()->GetNode() ) diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx index 048478f194d4..62add1d5bae5 100644 --- a/sw/source/core/doc/doc.cxx +++ b/sw/source/core/doc/doc.cxx @@ -1559,7 +1559,7 @@ bool SwDoc::RemoveInvisibleContent() pSectNd->EndOfSectionIndex() + 1 ) { // only delete the content - SwContentNode* pCNd = GetNodes().GoNext( aPam.GetPoint() ); + SwContentNode* pCNd = SwNodes::GoNext(aPam.GetPoint()); aPam.SetMark(); aPam.GetPoint()->Assign( *pSectNd->EndOfSectionNode() ); pCNd = SwNodes::GoPrevious( aPam.GetPoint() ); diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx index 730da32625d4..fb741e749fb5 100644 --- a/sw/source/core/doc/docbm.cxx +++ b/sw/source/core/doc/docbm.cxx @@ -281,7 +281,7 @@ namespace if ( pNode == nullptr) { SwNodeIndex aEnd(rEnd); - pNode = rEnd.GetNodes().GoNext( &aEnd ); + pNode = SwNodes::GoNext(&aEnd); bPosAtEndOfNode = false; } if ( pNode == nullptr ) @@ -2058,7 +2058,7 @@ void DelBookmarks( bool bStt = true; SwContentNode* pCNd = pRStt->GetNode().GetContentNode(); if( !pCNd ) - pCNd = rDoc.GetNodes().GoNext( pRStt ); + pCNd = SwNodes::GoNext(pRStt); if (!pCNd) { bStt = false; @@ -2089,7 +2089,7 @@ void DelBookmarks( { bStt = true; pREnd->Assign(rEnd); - pCNd = rDoc.GetNodes().GoNext( pREnd ); + pCNd = SwNodes::GoNext(pREnd); if( !pCNd ) { *pREnd = *pRStt; diff --git a/sw/source/core/doc/docfld.cxx b/sw/source/core/doc/docfld.cxx index be30bb34bc30..c3ee9cfbf17b 100644 --- a/sw/source/core/doc/docfld.cxx +++ b/sw/source/core/doc/docfld.cxx @@ -144,7 +144,7 @@ SetGetExpField::SetGetExpField( const SwTableBox& rTBox ) if( rTBox.GetSttNd() ) { SwNodeIndex aIdx( *rTBox.GetSttNd() ); - const SwContentNode* pNd = aIdx.GetNode().GetNodes().GoNext( &aIdx ); + const SwContentNode* pNd = SwNodes::GoNext(&aIdx); if( pNd ) m_nNode = pNd->GetIndex(); } @@ -326,14 +326,14 @@ const SwNode* SetGetExpField::GetNodeFromContent() const if( m_CNTNT.pTBox->GetSttNd() ) { SwNodeIndex aIdx( *m_CNTNT.pTBox->GetSttNd() ); - pRet = aIdx.GetNode().GetNodes().GoNext( &aIdx ); + pRet = SwNodes::GoNext(&aIdx); } break; case FLYFRAME: { SwNodeIndex aIdx( *m_CNTNT.pFlyFormat->GetContent().GetContentIdx() ); - pRet = aIdx.GetNode().GetNodes().GoNext( &aIdx ); + pRet = SwNodes::GoNext(&aIdx); } break; } @@ -1138,7 +1138,7 @@ void SwDocUpdateField::GetBodyNodeGeneric(SwNode const& rNode, T const& rCond) // create index to determine the TextNode SwPosition aPos(rNode); SwContentNode const*const pCNd = rNode.IsSectionNode() - ? rDoc.GetNodes().GoNext(&aPos.nNode) // to the next ContentNode + ? SwNodes::GoNext(&aPos.nNode) // to the next ContentNode : rNode.GetContentNode(); if( !pCNd || !pCNd->IsTextNode() ) diff --git a/sw/source/core/doc/docglos.cxx b/sw/source/core/doc/docglos.cxx index 2993a774ad25..dae24d1cdfd6 100644 --- a/sw/source/core/doc/docglos.cxx +++ b/sw/source/core/doc/docglos.cxx @@ -165,7 +165,7 @@ bool SwDoc::InsertGlossary( SwTextBlocks& rBlock, const OUString& rEntry, getIDocumentFieldsAccess().LockExpFields(); SwNodeIndex aStt( pGDoc->GetNodes().GetEndOfExtras(), 1 ); - SwContentNode* pContentNd = pGDoc->GetNodes().GoNext( &aStt ); + SwContentNode* pContentNd = SwNodes::GoNext(&aStt); const SwTableNode* pTableNd = pContentNd->FindTableNode(); SwPaM aCpyPam( pTableNd ? *const_cast<SwNode*>(static_cast<SwNode const *>(pTableNd)) : *static_cast<SwNode*>(pContentNd) ); aCpyPam.SetMark(); diff --git a/sw/source/core/doc/docredln.cxx b/sw/source/core/doc/docredln.cxx index 45af1e8e3f85..2c4ba6096c48 100644 --- a/sw/source/core/doc/docredln.cxx +++ b/sw/source/core/doc/docredln.cxx @@ -497,7 +497,7 @@ std::vector<std::unique_ptr<SwRangeRedline>> GetAllValidRanges(std::unique_ptr<S if( !aNewStt.GetNode().IsContentNode() ) { - pC = rNds.GoNext( &aNewStt ); + pC = SwNodes::GoNext(&aNewStt); if( !pC ) aNewStt.Assign(rNds.GetEndOfContent()); } @@ -588,7 +588,7 @@ std::vector<std::unique_ptr<SwRangeRedline>> GetAllValidRanges(std::unique_ptr<S if( aNewStt >= *pEnd ) break; - pC = rNds.GoNext( &aNewStt ); + pC = SwNodes::GoNext(&aNewStt); if( !pC ) break; } while( aNewStt < *pEnd ); diff --git a/sw/source/core/doc/docsort.cxx b/sw/source/core/doc/docsort.cxx index d22ab372e323..ed1ffdad0d3b 100644 --- a/sw/source/core/doc/docsort.cxx +++ b/sw/source/core/doc/docsort.cxx @@ -684,7 +684,7 @@ void MoveCell(SwDoc* pDoc, const SwTableBox* pSource, const SwTableBox* pTar, // Set Pam source to the first ContentNode SwNodeRange aRg( *pSource->GetSttNd(), SwNodeOffset(0), *pSource->GetSttNd() ); - SwNode* pNd = pDoc->GetNodes().GoNext( &aRg.aStart ); + SwNode* pNd = SwNodes::GoNext(&aRg.aStart); // If the Cell (Source) wasn't moved // -> insert an empty Node and move the rest or the Mark @@ -697,7 +697,7 @@ void MoveCell(SwDoc* pDoc, const SwTableBox* pSource, const SwTableBox* pTar, // If the Target is empty (there is one empty Node) // -> move and delete it SwNodeIndex aTar( *pTar->GetSttNd() ); - pNd = pDoc->GetNodes().GoNext( &aTar ); // next ContentNode + pNd = SwNodes::GoNext(&aTar); // next ContentNode SwNodeOffset nCount = pNd->EndOfSectionIndex() - pNd->StartOfSectionIndex(); bool bDelFirst = false; diff --git a/sw/source/core/doc/doctxm.cxx b/sw/source/core/doc/doctxm.cxx index 746da06379df..4b0ca5d323f1 100644 --- a/sw/source/core/doc/doctxm.cxx +++ b/sw/source/core/doc/doctxm.cxx @@ -846,7 +846,7 @@ bool SwTOXBaseSection::SetPosAtStartEnd( SwPosition& rPos ) const if( pSectNd ) { rPos.Assign(*pSectNd); - pSectNd->GetDoc().GetNodes().GoNext( &rPos ); + SwNodes::GoNext(&rPos); bRet = true; } return bRet; @@ -903,7 +903,7 @@ void SwTOXBaseSection::Update(const SfxItemSet* pAttr, { // determine page description of content after table-of-content SwNodeIndex aIdx( *(pSectNd->EndOfSectionNode()) ); - const SwContentNode* pNdAfterTOX = pSectNd->GetNodes().GoNext( &aIdx ); + const SwContentNode* pNdAfterTOX = SwNodes::GoNext(&aIdx); const SwAttrSet& aNdAttrSet = pNdAfterTOX->GetSwAttrSet(); const SvxBreak eBreak = aNdAttrSet.GetBreak().GetBreak(); if ( eBreak != SvxBreak::PageBefore && eBreak != SvxBreak::PageBoth ) @@ -1008,7 +1008,7 @@ void SwTOXBaseSection::Update(const SfxItemSet* pAttr, SwNodeIndex aNxtIdx( aSttIdx ); const SwContentNode* pCNd = aNxtIdx.GetNode().GetContentNode(); if( !pCNd ) - pCNd = rDoc.GetNodes().GoNext( &aNxtIdx ); + pCNd = SwNodes::GoNext(&aNxtIdx); assert(pCNd != pFirstEmptyNd); assert(pCNd->GetIndex() < pFirstEmptyNd->GetIndex()); if( pCNd->HasSwAttrSet() ) @@ -1141,7 +1141,7 @@ void SwTOXBaseSection::Update(const SfxItemSet* pAttr, aEndIdx = *pSectNd; else aEndIdx = *pFirstEmptyNd; - SwContentNode* pCNd = rDoc.GetNodes().GoNext( &aEndIdx ); + SwContentNode* pCNd = SwNodes::GoNext(&aEndIdx); if( pCNd ) // Robust against defect documents, e.g. i60336 pCNd->SetAttr( *pFirstEmptyNd->GetpSwAttrSet() ); } @@ -1270,7 +1270,7 @@ void SwTOXBaseSection::SwClientNotify(const SwModify& rModify, const SfxHint& rH SwNodeIndex aIdx(*pSectNd, 1); SwContentNode* pCNd = aIdx.GetNode().GetContentNode(); if(!pCNd) - pCNd = pFindHint->m_rDoc.GetNodes().GoNext(&aIdx); + pCNd = SwNodes::GoNext(&aIdx); if(!pCNd) return; if(pCNd->EndOfSectionIndex() >= pSectNd->EndOfSectionIndex()) @@ -1537,7 +1537,7 @@ void SwTOXBaseSection::UpdateContent( SwTOXElement eMyType, if( !pCNd ) { SwNodeIndex aTmp( *pNd ); - pCNd = rNds.GoNext( &aTmp ); + pCNd = SwNodes::GoNext(&aTmp); } } break; @@ -1621,7 +1621,6 @@ void SwTOXBaseSection::UpdateTable(const SwTextNode* pOwnChapterNode, SwRootFrame const*const pLayout) { SwDoc* pDoc = GetFormat()->GetDoc(); - SwNodes& rNds = pDoc->GetNodes(); for(SwTableFormat* pFrameFormat: *pDoc->GetTableFrameFormats()) { @@ -1636,7 +1635,7 @@ void SwTOXBaseSection::UpdateTable(const SwTextNode* pOwnChapterNode, SwNodeIndex aContentIdx( *pTableNd, 1 ); SwContentNode* pCNd; - while( nullptr != ( pCNd = rNds.GoNext( &aContentIdx ) ) && + while( nullptr != ( pCNd = SwNodes::GoNext( &aContentIdx ) ) && aContentIdx.GetIndex() < pTableNd->EndOfSectionIndex() ) { if (pCNd->getLayoutFrame(pLayout) diff --git a/sw/source/core/doc/tblcpy.cxx b/sw/source/core/doc/tblcpy.cxx index 0b11ea6c80d2..f1ff236fd60c 100644 --- a/sw/source/core/doc/tblcpy.cxx +++ b/sw/source/core/doc/tblcpy.cxx @@ -562,7 +562,7 @@ static void lcl_CpyBox( const SwTable& rCpyTable, const SwTableBox* pCpyBox, if( !pCNd ) { SwNodeIndex aTmp( aInsIdx ); - pCNd = pDoc->GetNodes().GoNext( &aTmp ); + pCNd = SwNodes::GoNext(&aTmp); } if( pCNd && diff --git a/sw/source/core/docnode/ndsect.cxx b/sw/source/core/docnode/ndsect.cxx index 1da9ecb43ed6..856447d4d8d2 100644 --- a/sw/source/core/docnode/ndsect.cxx +++ b/sw/source/core/docnode/ndsect.cxx @@ -63,9 +63,7 @@ // #i21457# - new implementation of local method <lcl_IsInSameTableBox(..)>. // Method now determines the previous/next on its own. Thus, it can be controlled, // for which previous/next is checked, if it's visible. -static bool lcl_IsInSameTableBox( SwNodes const & _rNds, - const SwNode& _rNd, - const bool _bPrev ) +static bool lcl_IsInSameTableBox(const SwNode& _rNd, const bool _bPrev) { const SwTableNode* pTableNd = _rNd.FindTableNode(); if ( !pTableNd ) @@ -84,7 +82,7 @@ static bool lcl_IsInSameTableBox( SwNodes const & _rNds, { if ( _bPrev ? !SwNodes::GoPrevSection( &aChkIdx, false, false ) - : !_rNds.GoNextSection( &aChkIdx, false, false ) ) + : !SwNodes::GoNextSection( &aChkIdx, false, false ) ) { OSL_FAIL( "<lcl_IsInSameTableBox(..)> - no previous/next!" ); return false; @@ -124,20 +122,20 @@ static bool lcl_IsInSameTableBox( SwNodes const & _rNds, return true; } -static void lcl_CheckEmptyLayFrame( SwNodes const & rNds, SwSectionData& rSectionData, +static void lcl_CheckEmptyLayFrame( SwSectionData& rSectionData, const SwNode& rStt, const SwNode& rEnd ) { SwNodeIndex aIdx( rStt ); if( !SwNodes::GoPrevSection( &aIdx, true, false ) || !CheckNodesRange( rStt, aIdx.GetNode(), true ) || // #i21457# - !lcl_IsInSameTableBox( rNds, rStt, true )) + !lcl_IsInSameTableBox( rStt, true )) { aIdx = rEnd; - if( !rNds.GoNextSection( &aIdx, true, false ) || + if( !SwNodes::GoNextSection( &aIdx, true, false ) || !CheckNodesRange( rEnd, aIdx.GetNode(), true ) || // #i21457# - !lcl_IsInSameTableBox( rNds, rEnd, false )) + !lcl_IsInSameTableBox( rEnd, false )) { rSectionData.SetHidden( false ); } @@ -171,7 +169,7 @@ SwDoc::InsertSwSection(SwPaM const& rRange, SwSectionData & rNewData, pEnd->GetNode().GetContentNode()->Len() == pEnd->GetContentIndex() ) { - ::lcl_CheckEmptyLayFrame( GetNodes(), + ::lcl_CheckEmptyLayFrame( rNewData, pStt->GetNode(), pEnd->GetNode() ); @@ -650,7 +648,7 @@ void SwDoc::UpdateSection( size_t const nPos, SwSectionData & rNewData, pIdx->GetNode().GetSectionNode(); if (pSectNd) { - ::lcl_CheckEmptyLayFrame( GetNodes(), rNewData, + ::lcl_CheckEmptyLayFrame( rNewData, *pSectNd, *pSectNd->EndOfSectionNode() ); } } @@ -1040,7 +1038,7 @@ void SwSectionNode::MakeFramesForAdjacentContentNode(const SwNodeIndex & rIdx) if (GetSection().IsHiddenFlag() || IsContentHidden()) { SwNodeIndex aIdx( *EndOfSectionNode() ); - SwContentNode* pCNd = rNds.GoNextSection( &aIdx, true, false ); + SwContentNode* pCNd = SwNodes::GoNextSection(&aIdx, true, false); if( !pCNd ) { aIdx = *this; @@ -1180,7 +1178,6 @@ void SwSectionNode::DelFrames(SwRootFrame const*const /*FIXME TODO*/, bool const return ; } - SwNodes& rNds = GetNodes(); m_pSection->GetFormat()->DelFrames(); // Update our Flag @@ -1196,13 +1193,13 @@ void SwSectionNode::DelFrames(SwRootFrame const*const /*FIXME TODO*/, bool const if( !SwNodes::GoPrevSection( &aIdx, true, false ) || !CheckNodesRange( *this, aIdx.GetNode(), true ) || // #i21457# - !lcl_IsInSameTableBox( rNds, *this, true )) + !lcl_IsInSameTableBox( *this, true )) { aIdx = *EndOfSectionNode(); - if( !rNds.GoNextSection( &aIdx, true, false ) || + if( !SwNodes::GoNextSection( &aIdx, true, false ) || !CheckNodesRange( *EndOfSectionNode(), aIdx.GetNode(), true ) || // #i21457# - !lcl_IsInSameTableBox( rNds, *EndOfSectionNode(), false )) + !lcl_IsInSameTableBox( *EndOfSectionNode(), false )) { m_pSection->m_Data.SetHiddenFlag(false); } diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx index a7a2bee478da..592e8914ae8c 100644 --- a/sw/source/core/docnode/ndtbl.cxx +++ b/sw/source/core/docnode/ndtbl.cxx @@ -874,7 +874,7 @@ const SwTable* SwDoc::TextToTable( const SwInsertTableOptions& rInsTableOpts, SwPaM& rTmp = const_cast<SwPaM&>(rRange); // Point always at the Start rTmp.DeleteMark(); rTmp.GetPoint()->Assign( *pTableNd ); - GetNodes().GoNext( rTmp.GetPoint() ); + SwNodes::GoNext(rTmp.GetPoint()); } if( pUndo ) @@ -1883,7 +1883,7 @@ void SwDoc::DeleteRow( const SwCursor& rCursor ) SwNodeIndex aIdx( GetNodes(), nIdx ); SwContentNode* pCNd = aIdx.GetNode().GetContentNode(); if( !pCNd ) - pCNd = GetNodes().GoNext( &aIdx ); + pCNd = SwNodes::GoNext(&aIdx); if( pCNd ) { @@ -3098,9 +3098,9 @@ void sw_BoxSetSplitBoxFormats( SwTableBox* pBox, SwCollectTableLineBoxes* pSplPa SwNodeIndex aIdx( *pSrcBox->GetSttNd(), 1 ); SwContentNode* pCNd = aIdx.GetNode().GetContentNode(); if( !pCNd ) - pCNd = aIdx.GetNodes().GoNext( &aIdx ); + pCNd = SwNodes::GoNext(&aIdx); aIdx = *pBox->GetSttNd(); - SwContentNode* pDNd = aIdx.GetNodes().GoNext( &aIdx ); + SwContentNode* pDNd = SwNodes::GoNext(&aIdx); // If the Node is alone in the Section if( SwNodeOffset(2) == pDNd->EndOfSectionIndex() - @@ -3880,7 +3880,7 @@ bool SwDoc::GetTableAutoFormat( const SwSelBoxes& rBoxes, SwTableAutoFormat& rGe SwNodeIndex aIdx( *pFBox->GetSttNd(), 1 ); SwContentNode* pCNd = aIdx.GetNode().GetContentNode(); if( !pCNd ) - pCNd = GetNodes().GoNext( &aIdx ); + pCNd = SwNodes::GoNext(&aIdx); if( pCNd ) rGet.UpdateFromSet( nPos, pCNd->GetSwAttrSet(), @@ -4402,7 +4402,7 @@ bool SwDoc::InsCopyOfTable( SwPosition& rInsPos, const SwSelBoxes& rBoxes, if( bCorrPos ) { rInsPos.Assign( *pSttNd ); - GetNodes().GoNext( &rInsPos ); + SwNodes::GoNext(&rInsPos); } getIDocumentRedlineAccess().SetRedlineFlags( eOld ); } diff --git a/sw/source/core/docnode/node.cxx b/sw/source/core/docnode/node.cxx index dd4ffbcec57c..8338fd001f52 100644 --- a/sw/source/core/docnode/node.cxx +++ b/sw/source/core/docnode/node.cxx @@ -394,7 +394,7 @@ bool SwNode::IsInVisibleArea( SwViewShell const * pSh ) const if( SwNodeType::Start & m_nNodeType ) { SwNodeIndex aIdx( *this ); - pNd = GetNodes().GoNext( &aIdx ); + pNd = SwNodes::GoNext(&aIdx); } else if( SwNodeType::End & m_nNodeType ) { @@ -504,7 +504,7 @@ const SwPageDesc* SwNode::FindPageDesc( SwNodeOffset* pPgDescNdIdx ) const if( SwNodeType::Start & m_nNodeType ) { SwNodeIndex aIdx( *this ); - pNode = GetNodes().GoNext( &aIdx ); + pNode = SwNodes::GoNext(&aIdx); } else if( SwNodeType::End & m_nNodeType ) { @@ -994,9 +994,8 @@ void SwStartNode::CheckSectionCondColl() const { SwNodeIndex aIdx( *this ); SwNodeOffset nEndIdx = EndOfSectionIndex(); - const SwNodes& rNds = GetNodes(); SwContentNode* pCNd; - while( nullptr != ( pCNd = rNds.GoNext( &aIdx )) && pCNd->GetIndex() < nEndIdx ) + while (nullptr != (pCNd = SwNodes::GoNext(&aIdx)) && pCNd->GetIndex() < nEndIdx) pCNd->ChkCondColl(); } diff --git a/sw/source/core/docnode/nodes.cxx b/sw/source/core/docnode/nodes.cxx index f61a2c0be77d..d180a3a584c6 100644 --- a/sw/source/core/docnode/nodes.cxx +++ b/sw/source/core/docnode/nodes.cxx @@ -1302,50 +1302,44 @@ void SwNodes::GoEndOfSection(SwNodeIndex *pIdx) (*pIdx) = *pIdx->GetNode().EndOfSectionNode(); } -SwContentNode* SwNodes::GoNext(SwNodeIndex *pIdx) const +static SwContentNode* goNext(const SwNodeIndex& rIdx) { - if( pIdx->GetIndex() >= Count() - 1 ) - return nullptr; - - SwNodeIndex aTmp(*pIdx, +1); - SwNode* pNd = nullptr; - while( aTmp < Count()-1 && !( pNd = &aTmp.GetNode())->IsContentNode() ) - ++aTmp; + const SwNodes& rNodes = rIdx.GetNodes(); + const SwNodeOffset last = rNodes.Count() - 1; + for (SwNodeOffset i(rIdx.GetIndex() + 1); i < last; ++i) + if (SwContentNode* pNd = rNodes[i]->GetContentNode()) + return pNd; - if( aTmp == Count()-1 ) - pNd = nullptr; - else - (*pIdx) = aTmp; - return static_cast<SwContentNode*>(pNd); + return nullptr; } -SwContentNode* SwNodes::GoNext(SwPosition *pIdx) const +SwContentNode* SwNodes::GoNext(SwNodeIndex *pIdx) { - if( pIdx->GetNodeIndex() >= Count() - 1 ) - return nullptr; - - SwNodeIndex aTmp(pIdx->GetNode(), +1); - SwNode* pNd = nullptr; - while( aTmp < Count()-1 && !( pNd = &aTmp.GetNode())->IsContentNode() ) - ++aTmp; + SwContentNode* pNd = goNext(*pIdx); + if (pNd) + *pIdx = *pNd; + return pNd; +} - if( aTmp == Count()-1 ) - pNd = nullptr; - else - pIdx->Assign(aTmp); - return static_cast<SwContentNode*>(pNd); +SwContentNode* SwNodes::GoNext(SwPosition *pIdx) +{ + SwContentNode* pNd = goNext(pIdx->nNode); + if (pNd) + pIdx->AssignStartIndex(*pNd); + return pNd; } -SwNodeOffset SwNodes::StartOfGlobalSection(const SwNode& node) const +static SwNodeOffset startOfGlobalSection(const SwNode& node) { + const SwNodes& rNodes = node.GetNodes(); const SwNodeOffset pos = node.GetIndex(); - if (GetEndOfExtras().GetIndex() < pos) + if (rNodes.GetEndOfExtras().GetIndex() < pos) // Regular ContentSection - return GetEndOfExtras().GetIndex() + SwNodeOffset(1); - if (GetEndOfAutotext().GetIndex() < pos) + return rNodes.GetEndOfExtras().GetIndex() + SwNodeOffset(1); + if (rNodes.GetEndOfAutotext().GetIndex() < pos) // Redlines - return GetEndOfAutotext().GetIndex() + SwNodeOffset(1); - if (GetEndOfInserts().GetIndex() < pos) + return rNodes.GetEndOfAutotext().GetIndex() + SwNodeOffset(1); + if (rNodes.GetEndOfInserts().GetIndex() < pos) { // Flys/Headers/Footers if (auto* p = node.FindFlyStartNode()) @@ -1354,54 +1348,44 @@ SwNodeOffset SwNodes::StartOfGlobalSection(const SwNode& node) const return p->GetIndex(); if (auto* p = node.FindFooterStartNode()) return p->GetIndex(); - return GetEndOfInserts().GetIndex() + SwNodeOffset(1); + return rNodes.GetEndOfInserts().GetIndex() + SwNodeOffset(1); } - if (GetEndOfPostIts().GetIndex() < pos) + if (rNodes.GetEndOfPostIts().GetIndex() < pos) { // Footnotes if (auto* p = node.FindFootnoteStartNode()) return p->GetIndex(); - return GetEndOfPostIts().GetIndex() + SwNodeOffset(1); + return rNodes.GetEndOfPostIts().GetIndex() + SwNodeOffset(1); } return SwNodeOffset(0); } -SwContentNode* SwNodes::GoPrevious(SwNodeIndex* pIdx, bool canCrossBoundary) +static SwContentNode* goPrevious(const SwNodeIndex& rIdx, bool canCrossBoundary) { - if( !pIdx->GetIndex() ) - return nullptr; + const SwNodes& rNodes = rIdx.GetNodes(); + const SwNodeOffset first(canCrossBoundary ? SwNodeOffset(0) + : startOfGlobalSection(rIdx.GetNode())); + for (SwNodeOffset i(rIdx.GetIndex() - 1); i > first; --i) + if (SwContentNode* pNd = rNodes[i]->GetContentNode()) + return pNd; - SwNodeIndex aTmp( *pIdx, -1 ); - SwNodeOffset aGlobalStart( - canCrossBoundary ? SwNodeOffset(0) : aTmp.GetNodes().StartOfGlobalSection(pIdx->GetNode())); - SwNode* pNd = nullptr; - while (aTmp > aGlobalStart && !(pNd = &aTmp.GetNode())->IsContentNode()) - --aTmp; + return nullptr; +} - if (aTmp <= aGlobalStart) - pNd = nullptr; - else - (*pIdx) = aTmp; - return static_cast<SwContentNode*>(pNd); +SwContentNode* SwNodes::GoPrevious(SwNodeIndex* pIdx, bool canCrossBoundary) +{ + SwContentNode* pNd = goPrevious(*pIdx, canCrossBoundary); + if (pNd) + *pIdx = *pNd; + return pNd; } SwContentNode* SwNodes::GoPrevious(SwPosition* pIdx, bool canCrossBoundary) { - if( !pIdx->GetNodeIndex() ) - return nullptr; - - SwNodeIndex aTmp( pIdx->GetNode(), -1 ); - SwNodeOffset aGlobalStart( - canCrossBoundary ? SwNodeOffset(0) : aTmp.GetNodes().StartOfGlobalSection(pIdx->GetNode())); - SwNode* pNd = nullptr; - while( aTmp > aGlobalStart && !( pNd = &aTmp.GetNode())->IsContentNode() ) - --aTmp; - - if (aTmp <= aGlobalStart) - pNd = nullptr; - else - pIdx->Assign(aTmp); - return static_cast<SwContentNode*>(pNd); + SwContentNode* pNd = goPrevious(pIdx->nNode, canCrossBoundary); + if (pNd) + pIdx->AssignStartIndex(*pNd); + return pNd; } /** Delete a number of nodes @@ -1972,6 +1956,47 @@ SwStartNode* SwNodes::MakeTextSection( const SwNode & rWhere, return pSttNd; } +static bool shouldSkipSection(const SwSectionNode& rSectNode, bool bSkipHidden, bool bSkipProtect) +{ + const SwSection& rSect = rSectNode.GetSection(); + return (bSkipHidden && rSect.CalcHiddenFlag()) || (bSkipProtect && rSect.IsProtectFlag()); +} + +static SwContentNode* goNextSection(const SwNode& rNode, bool bSkipHidden, bool bSkipProtect) +{ + const SwNodes& rNodes = rNode.GetNodes(); + const SwNodeOffset last = rNodes.Count() - 1; + for (SwNodeOffset i(rNode.GetIndex()); i < last; ++i) + { + SwNode* pNd = rNodes[i]; + if (SwSectionNode* pSectNd = pNd->GetSectionNode()) + { + if (shouldSkipSection(*pSectNd, bSkipHidden, bSkipProtect)) + // than skip the section + i = pSectNd->EndOfSectionIndex(); + } + else if (i == rNode.GetIndex()) // The first iteration + { + if ((pSectNd = pNd->StartOfSectionNode()->GetSectionNode())) + if (shouldSkipSection(*pSectNd, bSkipHidden, bSkipProtect)) + // than skip the section + i = pSectNd->EndOfSectionIndex(); + } + else if (SwContentNode* pContentNode = pNd->GetContentNode()) + { + if (bSkipHidden || bSkipProtect) + if ((pSectNd = pNd->FindSectionNode())) + if (shouldSkipSection(*pSectNd, bSkipHidden, bSkipProtect)) + { + i = pSectNd->EndOfSectionIndex(); + continue; + } + return pContentNode; + } + } + return nullptr; +} + //TODO: provide better documentation /** go to next section that is not protected nor hidden * @@ -1985,55 +2010,12 @@ SwStartNode* SwNodes::MakeTextSection( const SwNode & rWhere, * @see SwNodes::GoPrevious * @see SwNodes::GoNextSection (TODO: seems to be C&P programming here) */ -SwContentNode* SwNodes::GoNextSection( SwNodeIndex * pIdx, - bool bSkipHidden, bool bSkipProtect ) const +SwContentNode* SwNodes::GoNextSection(SwNodeIndex* pIdx, bool bSkipHidden, bool bSkipProtect) { - bool bFirst = true; - SwNodeIndex aTmp( *pIdx ); - const SwNode* pNd; - while( aTmp < Count() - 1 ) - { - pNd = & aTmp.GetNode(); - if (SwNodeType::Section == pNd->GetNodeType()) - { - const SwSection& rSect = static_cast<const SwSectionNode*>(pNd)->GetSection(); - if( (bSkipHidden && rSect.CalcHiddenFlag()) || - (bSkipProtect && rSect.IsProtectFlag()) ) - // than skip the section - aTmp = *pNd->EndOfSectionNode(); - } - else if( bFirst ) - { - if( pNd->m_pStartOfSection->IsSectionNode() ) - { - const SwSection& rSect = static_cast<SwSectionNode*>(pNd-> - m_pStartOfSection)->GetSection(); - if( (bSkipHidden && rSect.CalcHiddenFlag()) || - (bSkipProtect && rSect.IsProtectFlag()) ) - // than skip the section - aTmp = *pNd->EndOfSectionNode(); - } - } - else if( SwNodeType::ContentMask & pNd->GetNodeType() ) - { - const SwSectionNode* pSectNd; - if( ( bSkipHidden || bSkipProtect ) && - nullptr != (pSectNd = pNd->FindSectionNode() ) && - ( ( bSkipHidden && pSectNd->GetSection().CalcHiddenFlag() ) || - ( bSkipProtect && pSectNd->GetSection().IsProtectFlag() )) ) - { - aTmp = *pSectNd->EndOfSectionNode(); - } - else - { - (*pIdx) = aTmp; - return const_cast<SwContentNode*>(static_cast<const SwContentNode*>(pNd)); - } - } - ++aTmp; - bFirst = false; - } - return nullptr; + SwContentNode* pNd = goNextSection(pIdx->GetNode(), bSkipHidden, bSkipProtect); + if (pNd) + *pIdx = *pNd; + return pNd; } //TODO: provide better documentation @@ -2049,171 +2031,61 @@ SwContentNode* SwNodes::GoNextSection( SwNodeIndex * pIdx, * @see SwNodes::GoPrevious * @see SwNodes::GoNextSection (TODO: seems to be C&P programming here) */ -SwContentNode* SwNodes::GoNextSection( SwPosition * pIdx, - bool bSkipHidden, bool bSkipProtect ) const +SwContentNode* SwNodes::GoNextSection(SwPosition* pIdx, bool bSkipHidden, bool bSkipProtect) { - bool bFirst = true; - SwNodeIndex aTmp( pIdx->GetNode() ); - const SwNode* pNd; - while( aTmp < Count() - 1 ) - { - pNd = & aTmp.GetNode(); - if (SwNodeType::Section == pNd->GetNodeType()) - { - const SwSection& rSect = static_cast<const SwSectionNode*>(pNd)->GetSection(); - if( (bSkipHidden && rSect.IsHiddenFlag()) || - (bSkipProtect && rSect.IsProtectFlag()) ) - // than skip the section - aTmp = *pNd->EndOfSectionNode(); - } - else if( bFirst ) - { - if( pNd->m_pStartOfSection->IsSectionNode() ) - { - const SwSection& rSect = static_cast<SwSectionNode*>(pNd-> - m_pStartOfSection)->GetSection(); - if( (bSkipHidden && rSect.IsHiddenFlag()) || - (bSkipProtect && rSect.IsProtectFlag()) ) - // than skip the section - aTmp = *pNd->EndOfSectionNode(); - } - } - else if( SwNodeType::ContentMask & pNd->GetNodeType() ) - { - const SwSectionNode* pSectNd; - if( ( bSkipHidden || bSkipProtect ) && - nullptr != (pSectNd = pNd->FindSectionNode() ) && - ( ( bSkipHidden && pSectNd->GetSection().IsHiddenFlag() ) || - ( bSkipProtect && pSectNd->GetSection().IsProtectFlag() )) ) - { - aTmp = *pSectNd->EndOfSectionNode(); - } - else - { - pIdx->Assign(aTmp); - return const_cast<SwContentNode*>(static_cast<const SwContentNode*>(pNd)); - } - } - ++aTmp; - bFirst = false; - } - return nullptr; + SwContentNode* pNd = goNextSection(pIdx->GetNode(), bSkipHidden, bSkipProtect); + if (pNd) + pIdx->AssignStartIndex(*pNd); + return pNd; } -///@see SwNodes::GoNextSection (TODO: seems to be C&P programming here) -SwContentNode* SwNodes::GoPrevSection( SwNodeIndex * pIdx, - bool bSkipHidden, bool bSkipProtect ) +static SwContentNode* goPrevSection(const SwNode& rNode, bool bSkipHidden, bool bSkipProtect) { - bool bFirst = true; - SwNodeIndex aTmp( *pIdx ); - SwNodeOffset aGlobalStart(aTmp.GetNodes().StartOfGlobalSection(pIdx->GetNode())); - const SwNode* pNd; - while (aTmp > aGlobalStart) + const SwNodes& rNodes = rNode.GetNodes(); + SwNodeOffset first(startOfGlobalSection(rNode)); + for (SwNodeOffset i(rNode.GetIndex()); i > first; --i) { - pNd = & aTmp.GetNode(); - if (SwNodeType::End == pNd->GetNodeType()) + SwNode* pNd = rNodes[i]; + if (pNd->IsEndNode() || i == rNode.GetIndex() /* the first iteration */) { - if( pNd->m_pStartOfSection->IsSectionNode() ) + if (SwSectionNode* pSectNd = pNd->StartOfSectionNode()->GetSectionNode()) { - const SwSection& rSect = static_cast<SwSectionNode*>(pNd-> - m_pStartOfSection)->GetSection(); - if( (bSkipHidden && rSect.IsHiddenFlag()) || - (bSkipProtect && rSect.IsProtectFlag()) ) - // than skip section - aTmp = *pNd->StartOfSectionNode(); + if (shouldSkipSection(*pSectNd, bSkipHidden, bSkipProtect)) + // then skip section + i = pSectNd->GetIndex(); } - bFirst = false; } - else if( bFirst ) + else if (SwContentNode* pContentNode = pNd->GetContentNode()) { - bFirst = false; - if( pNd->m_pStartOfSection->IsSectionNode() ) - { - const SwSection& rSect = static_cast<SwSectionNode*>(pNd-> - m_pStartOfSection)->GetSection(); - if( (bSkipHidden && rSect.IsHiddenFlag()) || - (bSkipProtect && rSect.IsProtectFlag()) ) - // than skip section - aTmp = *pNd->StartOfSectionNode(); - } - } - else if( SwNodeType::ContentMask & pNd->GetNodeType() ) - { - const SwSectionNode* pSectNd; - if( ( bSkipHidden || bSkipProtect ) && - nullptr != (pSectNd = pNd->FindSectionNode() ) && - ( ( bSkipHidden && pSectNd->GetSection().IsHiddenFlag() ) || - ( bSkipProtect && pSectNd->GetSection().IsProtectFlag() )) ) - { - aTmp = *pSectNd; - } - else - { - (*pIdx) = aTmp; - return const_cast<SwContentNode*>(static_cast<const SwContentNode*>(pNd)); - } + if (bSkipHidden || bSkipProtect) + if (const SwSectionNode* pSectNd = pNd->FindSectionNode()) + if (shouldSkipSection(*pSectNd, bSkipHidden, bSkipProtect)) + { + i = pSectNd->GetIndex(); + continue; + } + return pContentNode; } - --aTmp; } return nullptr; } -///@see SwNodes::GoNextSection (TODO: seems to be C&P programming here) -SwContentNode* SwNodes::GoPrevSection( SwPosition * pIdx, - bool bSkipHidden, bool bSkipProtect ) +///@see SwNodes::GoNextSection +SwContentNode* SwNodes::GoPrevSection(SwNodeIndex* pIdx, bool bSkipHidden, bool bSkipProtect) { - bool bFirst = true; - SwNodeIndex aTmp( pIdx->GetNode() ); - SwNodeOffset aGlobalStart(aTmp.GetNodes().StartOfGlobalSection(pIdx->GetNode())); - const SwNode* pNd; - while (aTmp > aGlobalStart) - { - pNd = & aTmp.GetNode(); - if (SwNodeType::End == pNd->GetNodeType()) - { - if( pNd->m_pStartOfSection->IsSectionNode() ) - { - const SwSection& rSect = static_cast<SwSectionNode*>(pNd-> - m_pStartOfSection)->GetSection(); - if( (bSkipHidden && rSect.IsHiddenFlag()) || - (bSkipProtect && rSect.IsProtectFlag()) ) - // than skip section - aTmp = *pNd->StartOfSectionNode(); - } - bFirst = false; - } - else if( bFirst ) - { - bFirst = false; - if( pNd->m_pStartOfSection->IsSectionNode() ) - { - const SwSection& rSect = static_cast<SwSectionNode*>(pNd-> - m_pStartOfSection)->GetSection(); - if( (bSkipHidden && rSect.IsHiddenFlag()) || - (bSkipProtect && rSect.IsProtectFlag()) ) - // than skip section - aTmp = *pNd->StartOfSectionNode(); - } - } - else if( SwNodeType::ContentMask & pNd->GetNodeType() ) - { - const SwSectionNode* pSectNd; - if( ( bSkipHidden || bSkipProtect ) && - nullptr != (pSectNd = pNd->FindSectionNode() ) && - ( ( bSkipHidden && pSectNd->GetSection().IsHiddenFlag() ) || - ( bSkipProtect && pSectNd->GetSection().IsProtectFlag() )) ) - { - aTmp = *pSectNd; - } - else - { - pIdx->Assign(aTmp); - return const_cast<SwContentNode*>(static_cast<const SwContentNode*>(pNd)); - } - } - --aTmp; - } - return nullptr; + SwContentNode* pNd = goPrevSection(pIdx->GetNode(), bSkipHidden, bSkipProtect); + if (pNd) + *pIdx = *pNd; + return pNd; +} + +///@see SwNodes::GoNextSection +SwContentNode* SwNodes::GoPrevSection(SwPosition* pIdx, bool bSkipHidden, bool bSkipProtect) +{ + SwContentNode* pNd = goPrevSection(pIdx->GetNode(), bSkipHidden, bSkipProtect); + if (pNd) + pIdx->AssignStartIndex(*pNd); + return pNd; } //TODO: The inventor of the "single responsibility principle" will be crying if you ever show this code to him! diff --git a/sw/source/core/docnode/section.cxx b/sw/source/core/docnode/section.cxx index d655cf4acc8a..dd3dcdb9e98c 100644 --- a/sw/source/core/docnode/section.cxx +++ b/sw/source/core/docnode/section.cxx @@ -676,7 +676,7 @@ void SwSectionFormat::DelFrames() // Paste of the Frame itself would need to do this. But that leads // to subsequent errors, which we'd need to solve at run-time. SwNodeIndex aNextNd( *pIdx ); - SwContentNode* pCNd = GetDoc()->GetNodes().GoNextSection( &aNextNd, true, false ); + SwContentNode* pCNd = SwNodes::GoNextSection(&aNextNd, true, false); if( pCNd ) { const SfxPoolItem& rItem = pCNd->GetSwAttrSet().Get(RES_PAGEDESC); diff --git a/sw/source/core/draw/dcontact.cxx b/sw/source/core/draw/dcontact.cxx index 67af9dc54b5e..9ccd019181ea 100644 --- a/sw/source/core/draw/dcontact.cxx +++ b/sw/source/core/draw/dcontact.cxx @@ -1874,7 +1874,7 @@ void SwDrawContact::ConnectToLayout( const SwFormatAnchor* pAnch ) if ( pAnch->GetAnchorId() == RndStdIds::FLY_AT_FLY ) { SwNodeIndex aIdx( *pAnch->GetAnchorNode() ); - SwContentNode* pCNd = pDrawFrameFormat->GetDoc()->GetNodes().GoNext( &aIdx ); + SwContentNode* pCNd = SwNodes::GoNext(&aIdx); if (SwIterator<SwFrame, SwContentNode, sw::IteratorMode::UnwrapMulti>(*pCNd).First()) pModify = pCNd; else diff --git a/sw/source/core/edit/acorrect.cxx b/sw/source/core/edit/acorrect.cxx index 06ab1231ff40..75eaf62ee8e0 100644 --- a/sw/source/core/edit/acorrect.cxx +++ b/sw/source/core/edit/acorrect.cxx @@ -465,7 +465,7 @@ bool SwAutoCorrDoc::ChgAutoCorrWord( sal_Int32& rSttPos, sal_Int32 nEndPos, SwDoc* pAutoDoc = aTBlks.GetDoc(); SwNodeIndex aSttIdx( pAutoDoc->GetNodes().GetEndOfExtras(), 1 ); - SwContentNode* pContentNd = pAutoDoc->GetNodes().GoNext( &aSttIdx ); + SwContentNode* pContentNd = SwNodes::GoNext(&aSttIdx); SwPaM aCpyPam( aSttIdx ); const SwTableNode* pTableNd = pContentNd->FindTableNode(); diff --git a/sw/source/core/edit/edatmisc.cxx b/sw/source/core/edit/edatmisc.cxx index cfc465fce837..7cdd4c228546 100644 --- a/sw/source/core/edit/edatmisc.cxx +++ b/sw/source/core/edit/edatmisc.cxx @@ -74,7 +74,7 @@ void SwEditShell::GCAttr() if( pNd->IsTextNode() ) static_cast<SwTextNode*>(pNd)->GCAttr(); } - while( nullptr != ( pNd = GetDoc()->GetNodes().GoNext( &aIdx )) && + while( nullptr != ( pNd = SwNodes::GoNext( &aIdx )) && aIdx <= rEnd ); } } diff --git a/sw/source/core/edit/edattr.cxx b/sw/source/core/edit/edattr.cxx index c1137b499471..dc79e9c3c9d0 100644 --- a/sw/source/core/edit/edattr.cxx +++ b/sw/source/core/edit/edattr.cxx @@ -461,7 +461,7 @@ size_t SwEditShell::GetSeqFootnoteList( SwSeqFieldList& rList, bool bEndNotes ) SwNodeIndex aIdx( *pIdx, 1 ); SwTextNode* pTextNd = aIdx.GetNode().GetTextNode(); if( !pTextNd ) - pTextNd = static_cast<SwTextNode*>(mxDoc->GetNodes().GoNext( &aIdx )); + pTextNd = static_cast<SwTextNode*>(SwNodes::GoNext(&aIdx)); if( pTextNd ) { diff --git a/sw/source/core/edit/edglbldc.cxx b/sw/source/core/edit/edglbldc.cxx index 9e71db2fd62d..4f186680d049 100644 --- a/sw/source/core/edit/edglbldc.cxx +++ b/sw/source/core/edit/edglbldc.cxx @@ -338,10 +338,9 @@ void SwEditShell::GotoGlobalDocContent( const SwGlblDocContent& rPos ) SwPosition& rCursorPos = *pCursor->GetPoint(); rCursorPos.Assign(rPos.GetDocPos()); - SwDoc* pMyDoc = GetDoc(); SwContentNode * pCNd = rCursorPos.GetNode().GetContentNode(); if( !pCNd ) - pCNd = pMyDoc->GetNodes().GoNext( &rCursorPos ); + pCNd = SwNodes::GoNext(&rCursorPos); EndCursorMove(); } diff --git a/sw/source/core/edit/edglss.cxx b/sw/source/core/edit/edglss.cxx index 80310bab4f47..ea82906b18d2 100644 --- a/sw/source/core/edit/edglss.cxx +++ b/sw/source/core/edit/edglss.cxx @@ -99,7 +99,7 @@ sal_uInt16 SwEditShell::SaveGlossaryDoc( SwTextBlocks& rBlock, SwPaM* pCursor = GetCursor(); SwNodeIndex aStt( pMyDoc->GetNodes().GetEndOfExtras(), 1 ); - SwContentNode* pContentNd = pMyDoc->GetNodes().GoNext( &aStt ); + SwContentNode* pContentNd = SwNodes::GoNext(&aStt); const SwNode* pNd = pContentNd->FindTableNode(); if( !pNd ) pNd = pContentNd; @@ -124,7 +124,7 @@ sal_uInt16 SwEditShell::SaveGlossaryDoc( SwTextBlocks& rBlock, if( rBlock.BeginPutDoc( rShortName, rName ) ) { SwNodeIndex aStt( pMyDoc->GetNodes().GetEndOfExtras(), 1 ); - SwContentNode* pContentNd = pMyDoc->GetNodes().GoNext( &aStt ); + SwContentNode* pContentNd = SwNodes::GoNext(&aStt); const SwNode* pNd = pContentNd->FindTableNode(); if( !pNd ) pNd = pContentNd; SwPaM aCpyPam( *pNd ); @@ -137,7 +137,7 @@ sal_uInt16 SwEditShell::SaveGlossaryDoc( SwTextBlocks& rBlock, aCpyPam.GetPoint()->SetContent( pContentNd->Len() ); aStt = pGDoc->GetNodes().GetEndOfExtras(); - pContentNd = pGDoc->GetNodes().GoNext( &aStt ); + pContentNd = SwNodes::GoNext(&aStt); SwPosition aInsPos( aStt ); pMyDoc->getIDocumentContentOperations().CopyRange(aCpyPam, aInsPos, SwCopyFlags::CheckPosInFly); diff --git a/sw/source/core/edit/editsh.cxx b/sw/source/core/edit/editsh.cxx index 0400dc887169..5927681128f2 100644 --- a/sw/source/core/edit/editsh.cxx +++ b/sw/source/core/edit/editsh.cxx @@ -863,7 +863,7 @@ sal_Int32 SwEditShell::GetLineCount() aStart = SwNodeOffset(0); - while( nullptr != ( pCNd = GetDoc()->GetNodes().GoNextSection( + while (nullptr != (pCNd = SwNodes::GoNextSection( &aStart, true, false )) ) { if( nullptr != ( pContentFrame = pCNd->getLayoutFrame( GetLayout() ) ) && pContentFrame->IsTextFrame() ) diff --git a/sw/source/core/fields/cellfml.cxx b/sw/source/core/fields/cellfml.cxx index 7c8179f672cb..7a43f9a5e7cc 100644 --- a/sw/source/core/fields/cellfml.cxx +++ b/sw/source/core/fields/cellfml.cxx @@ -772,7 +772,7 @@ const SwTable* SwTableFormula::FindTable( SwDoc& rDoc, std::u16string_view rNm ) static const SwFrame* lcl_GetBoxFrame( const SwTableBox& rBox ) { SwNodeIndex aIdx( *rBox.GetSttNd() ); - SwContentNode* pCNd = aIdx.GetNodes().GoNext( &aIdx ); + SwContentNode* pCNd = SwNodes::GoNext(&aIdx); OSL_ENSURE( pCNd, "Box has no TextNode" ); Point aPt; // get the first frame of the layout - table headline std::pair<Point, bool> const tmp(aPt, false); diff --git a/sw/source/core/fields/expfld.cxx b/sw/source/core/fields/expfld.cxx index 6ed4cdb7c125..c764f898d93f 100644 --- a/sw/source/core/fields/expfld.cxx +++ b/sw/source/core/fields/expfld.cxx @@ -142,7 +142,7 @@ static SwTextNode* GetFirstTextNode( const SwDoc& rDoc, SwPosition& rPos, const SwNodes& rNodes = rDoc.GetNodes(); rPos.Assign( *rNodes.GetEndOfContent().StartOfSectionNode() ); SwContentNode* pCNd; - while( nullptr != (pCNd = rNodes.GoNext( &rPos ) ) && + while( nullptr != (pCNd = SwNodes::GoNext( &rPos ) ) && nullptr == ( pTextNode = pCNd->GetTextNode() ) ) ; OSL_ENSURE( pTextNode, "Where is the 1. TextNode?" ); diff --git a/sw/source/core/fields/reffld.cxx b/sw/source/core/fields/reffld.cxx index 0ee26771bb2c..0ee5b7c9fb62 100644 --- a/sw/source/core/fields/reffld.cxx +++ b/sw/source/core/fields/reffld.cxx @@ -1360,7 +1360,7 @@ SwTextNode* SwGetRefFieldType::FindAnchor(SwDoc* pDoc, const OUString& rRefMark, SwNodeIndex aIdx( *pIdx, 1 ); pTextNd = aIdx.GetNode().GetTextNode(); if( nullptr == pTextNd ) - pTextNd = static_cast<SwTextNode*>(pDoc->GetNodes().GoNext( &aIdx )); + pTextNd = static_cast<SwTextNode*>(SwNodes::GoNext(&aIdx)); } *pStt = 0; if( pEnd ) @@ -1391,8 +1391,7 @@ SwTextNode* SwGetRefFieldType::FindAnchor(SwDoc* pDoc, const OUString& rRefMark, SwNodeIndex aIdx(*pIdx, 1); SwTextNode* pFootnoteNode = aIdx.GetNode().GetTextNode(); if (nullptr == pFootnoteNode) - pFootnoteNode - = static_cast<SwTextNode*>(pDoc->GetNodes().GoNext(&aIdx)); + pFootnoteNode = static_cast<SwTextNode*>(SwNodes::GoNext(&aIdx)); if (*pSelf == *pFootnoteNode) { diff --git a/sw/source/core/frmedt/fecopy.cxx b/sw/source/core/frmedt/fecopy.cxx index b8f6c45c5bb6..784c6bf84023 100644 --- a/sw/source/core/frmedt/fecopy.cxx +++ b/sw/source/core/frmedt/fecopy.cxx @@ -1009,7 +1009,7 @@ bool SwFEShell::Paste(SwDoc& rClpDoc, bool bNestedTable) { // exit first the complete table // ???? what about only table in a frame ????? - SwContentNode* pCNd = GetDoc()->GetNodes().GoNext( &aNdIdx ); + SwContentNode* pCNd = SwNodes::GoNext(&aNdIdx); SwPosition aPos( aNdIdx, pCNd, 0 ); // #i59539: Don't remove all redline SwPaM const tmpPaM(*pDestNd, *pDestNd->EndOfSectionNode()); @@ -1024,7 +1024,7 @@ bool SwFEShell::Paste(SwDoc& rClpDoc, bool bNestedTable) { // return to the box aNdIdx = *pSttNd; - SwContentNode* pCNd = GetDoc()->GetNodes().GoNext( &aNdIdx ); + SwContentNode* pCNd = SwNodes::GoNext(&aNdIdx); SwPosition aPos( aNdIdx, pCNd, 0 ); // #i59539: Don't remove all redline SwNode & rNode(rPaM.GetPoint()->GetNode()); diff --git a/sw/source/core/frmedt/fetab.cxx b/sw/source/core/frmedt/fetab.cxx index 33b9c9327b6d..7bf0ccc7fa72 100644 --- a/sw/source/core/frmedt/fetab.cxx +++ b/sw/source/core/frmedt/fetab.cxx @@ -583,7 +583,7 @@ bool SwFEShell::DeleteRow(bool bCompleteTable) SwNodeIndex aIdx( GetDoc()->GetNodes(), nIdx ); SwContentNode* pCNd = aIdx.GetNode().GetContentNode(); if( !pCNd ) - pCNd = GetDoc()->GetNodes().GoNext( &aIdx ); + pCNd = SwNodes::GoNext(&aIdx); // remove row frames in Hide Changes mode (and table frames, if needed) if ( bRecordAndHideChanges ) @@ -1361,7 +1361,7 @@ bool SwFEShell::IsAdjustCellWidthAllowed( bool bBalance ) const SwNodeIndex aIdx( *pBox->GetSttNd(), 1 ); SwTextNode* pCNd = aIdx.GetNode().GetTextNode(); if( !pCNd ) - pCNd = static_cast<SwTextNode*>(GetDoc()->GetNodes().GoNext( &aIdx )); + pCNd = static_cast<SwTextNode*>(SwNodes::GoNext(&aIdx)); while ( pCNd ) { diff --git a/sw/source/core/frmedt/tblsel.cxx b/sw/source/core/frmedt/tblsel.cxx index 095fc767224c..669762ffacc3 100644 --- a/sw/source/core/frmedt/tblsel.cxx +++ b/sw/source/core/frmedt/tblsel.cxx @@ -433,7 +433,7 @@ bool ChkChartSel( const SwNode& rSttNd, const SwNode& rEndNd ) SwNodeIndex aIdx( rSttNd ); const SwContentNode* pCNd = aIdx.GetNode().GetContentNode(); if( !pCNd ) - pCNd = aIdx.GetNodes().GoNextSection( &aIdx, false, false ); + pCNd = SwNodes::GoNextSection(&aIdx, false, false); // if table is invisible, return // (layout needed for forming table selection further down, so we can't @@ -453,7 +453,7 @@ bool ChkChartSel( const SwNode& rSttNd, const SwNode& rEndNd ) aIdx = rEndNd; pCNd = aIdx.GetNode().GetContentNode(); if( !pCNd ) - pCNd = aIdx.GetNodes().GoNextSection( &aIdx, false, false ); + pCNd = SwNodes::GoNextSection(&aIdx, false, false); // #i22135# - Robust: check, if content was found and if it's visible if ( !pCNd || pCNd->getLayoutFrame( pCNd->GetDoc().getIDocumentLayoutAccess().GetCurrentLayout() ) == nullptr ) diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx index f657aa195066..663da028cb15 100644 --- a/sw/source/core/layout/atrfrm.cxx +++ b/sw/source/core/layout/atrfrm.cxx @@ -3014,7 +3014,7 @@ void SwFlyFrameFormat::MakeFrames() //In such a situation we also need to search from StartNode to //FrameFormat. SwNodeIndex aIdx( *aAnchorAttr.GetAnchorNode() ); - SwContentNode *pCNd = GetDoc()->GetNodes().GoNext( &aIdx ); + SwContentNode* pCNd = SwNodes::GoNext(&aIdx); // #i105535# if ( pCNd == nullptr ) { diff --git a/sw/source/core/layout/flylay.cxx b/sw/source/core/layout/flylay.cxx index 7ac95d65e0d8..11d40892ab35 100644 --- a/sw/source/core/layout/flylay.cxx +++ b/sw/source/core/layout/flylay.cxx @@ -787,7 +787,7 @@ void SwFlyLayFrame::SwClientNotify(const SwModify& rMod, const SfxHint& rHint) else { SwNodeIndex aIdx(*pAnch->GetAnchorNode()); - SwContentFrame* pContent = GetFormat()->GetDoc()->GetNodes().GoNext(&aIdx)-> + SwContentFrame* pContent = SwNodes::GoNext(&aIdx)-> GetContentNode()->getLayoutFrame(getRootFrame(), nullptr, nullptr); if(pContent) { diff --git a/sw/source/core/layout/ftnfrm.cxx b/sw/source/core/layout/ftnfrm.cxx index 2c8583f85b65..e3b3adf819eb 100644 --- a/sw/source/core/layout/ftnfrm.cxx +++ b/sw/source/core/layout/ftnfrm.cxx @@ -1235,8 +1235,7 @@ void SwFootnoteBossFrame::ResetFootnote( const SwFootnoteFrame *pCheck ) SwNodeIndex aIdx( *pCheck->GetAttr()->GetStartNode(), 1 ); SwContentNode *pNd = aIdx.GetNode().GetContentNode(); if ( !pNd ) - pNd = pCheck->GetFormat()->GetDoc()-> - GetNodes().GoNextSection( &aIdx, true, false ); + pNd = SwNodes::GoNextSection(&aIdx, true, false); SwIterator<SwFrame, SwContentNode, sw::IteratorMode::UnwrapMulti> aIter(*pNd); SwFrame* pFrame = aIter.First(); while( pFrame ) @@ -1735,8 +1734,7 @@ SwFootnoteFrame *SwFootnoteBossFrame::FindFootnote( const SwContentFrame *pRef, SwNodeIndex aIdx( *pAttr->GetStartNode(), 1 ); SwContentNode *pNd = aIdx.GetNode().GetContentNode(); if ( !pNd ) - pNd = pRef->GetAttrSet()->GetDoc()-> - GetNodes().GoNextSection( &aIdx, true, false ); + pNd = SwNodes::GoNextSection(&aIdx, true, false); if ( !pNd ) return nullptr; SwIterator<SwFrame, SwContentNode, sw::IteratorMode::UnwrapMulti> aIter(*pNd); diff --git a/sw/source/core/layout/newfrm.cxx b/sw/source/core/layout/newfrm.cxx index 8965441cc068..ef0701bf7e1e 100644 --- a/sw/source/core/layout/newfrm.cxx +++ b/sw/source/core/layout/newfrm.cxx @@ -465,7 +465,7 @@ void SwRootFrame::Init( SwFrameFormat* pFormat ) SwDoc* pDoc = pFormat->GetDoc(); SwNodeIndex aIndex( *pDoc->GetNodes().GetEndOfContent().StartOfSectionNode() ); - SwContentNode *pNode = pDoc->GetNodes().GoNextSection( &aIndex, true, false ); + SwContentNode* pNode = SwNodes::GoNextSection(&aIndex, true, false); // #123067# pNode = 0 can really happen SwTableNode *pTableNd= pNode ? pNode->FindTableNode() : nullptr; diff --git a/sw/source/core/table/swtable.cxx b/sw/source/core/table/swtable.cxx index 6646737aeb03..bc32a108d792 100644 --- a/sw/source/core/table/swtable.cxx +++ b/sw/source/core/table/swtable.cxx @@ -137,7 +137,7 @@ void InsTableBox( SwDoc& rDoc, SwTableNode* pTableNd, SwNodeIndex aIdx( *pBox->GetSttNd(), +1 ); SwContentNode* pCNd = aIdx.GetNode().GetContentNode(); if( !pCNd ) - pCNd = rDoc.GetNodes().GoNext( &aIdx ); + pCNd = SwNodes::GoNext(&aIdx); OSL_ENSURE( pCNd, "Box with no content node" ); if( pCNd->IsTextNode() ) diff --git a/sw/source/core/txtnode/atrflyin.cxx b/sw/source/core/txtnode/atrflyin.cxx index 8b5d1b6352f9..46eadd373506 100644 --- a/sw/source/core/txtnode/atrflyin.cxx +++ b/sw/source/core/txtnode/atrflyin.cxx @@ -124,7 +124,7 @@ void SwTextFlyCnt::CopyFlyFormat( SwDoc& rDoc ) SwNodeIndex aIdx( rDoc.GetNodes().GetEndOfExtras(), +2 ); SwContentNode* pCNd = aIdx.GetNode().GetContentNode(); if( !pCNd ) - pCNd = rDoc.GetNodes().GoNext( &aIdx ); + pCNd = SwNodes::GoNext(&aIdx); SwPosition pos(aIdx.GetNode()); aAnchor.SetAnchor( &pos ); diff --git a/sw/source/core/txtnode/atrftn.cxx b/sw/source/core/txtnode/atrftn.cxx index a4c9e05fc063..abc7ba89d114 100644 --- a/sw/source/core/txtnode/atrftn.cxx +++ b/sw/source/core/txtnode/atrftn.cxx @@ -197,7 +197,7 @@ OUString SwFormatFootnote::GetFootnoteText(SwRootFrame const& rLayout) const SwNodeIndex aIdx( *m_pTextAttr->GetStartNode(), 1 ); SwContentNode* pCNd = aIdx.GetNode().GetTextNode(); if( !pCNd ) - pCNd = aIdx.GetNodes().GoNext( &aIdx ); + pCNd = SwNodes::GoNext(&aIdx); if( pCNd->IsTextNode() ) { buf.append(static_cast<SwTextNode*>(pCNd)->GetExpandText(&rLayout)); @@ -508,7 +508,7 @@ void SwTextFootnote::DelFrames(SwRootFrame const*const pRoot) return; SwNodeIndex aIdx( *m_oStartNode ); - SwContentNode* pCNd = m_pTextNode->GetNodes().GoNext( &aIdx ); + SwContentNode* pCNd = SwNodes::GoNext(&aIdx); if( !pCNd ) return; diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx index 45a4177fc67c..0a54b140b68c 100644 --- a/sw/source/core/txtnode/ndtxt.cxx +++ b/sw/source/core/txtnode/ndtxt.cxx @@ -324,8 +324,7 @@ static void lcl_ChangeFootnoteRef( SwTextNode &rNode ) SwNodeIndex aIdx( *pAttr->GetStartNode(), 1 ); SwContentNode *pNd = aIdx.GetNode().GetContentNode(); if ( !pNd ) - pNd = pFrame->GetAttrSet()->GetDoc()-> - GetNodes().GoNextSection( &aIdx, true, false ); + pNd = SwNodes::GoNextSection(&aIdx, true, false); if ( !pNd ) continue; diff --git a/sw/source/core/undo/undobj.cxx b/sw/source/core/undo/undobj.cxx index ce27962aa3ec..9e057d73e256 100644 --- a/sw/source/core/undo/undobj.cxx +++ b/sw/source/core/undo/undobj.cxx @@ -1617,9 +1617,8 @@ static bool IsAtEndOfSection(SwPosition const& rAnchorPos) static bool IsAtStartOfSection(SwPosition const& rAnchorPos) { - SwNodes const& rNodes(rAnchorPos.GetNodes()); SwNodeIndex node(*rAnchorPos.GetNode().StartOfSectionNode()); - SwContentNode *const pNode(rNodes.GoNext(&node)); + SwContentNode* const pNode(SwNodes::GoNext(&node)); assert(pNode); (void) pNode; assert(node <= rAnchorPos.GetNode()); diff --git a/sw/source/core/undo/untbl.cxx b/sw/source/core/undo/untbl.cxx index 72f1c809e227..e38abcecd000 100644 --- a/sw/source/core/undo/untbl.cxx +++ b/sw/source/core/undo/untbl.cxx @@ -674,7 +674,7 @@ void SwUndoTableToText::RedoImpl(::sw::UndoRedoContext & rContext) ++aSaveIdx; SwContentNode* pCNd = aSaveIdx.GetNode().GetContentNode(); - if( !pCNd && nullptr == ( pCNd = rDoc.GetNodes().GoNext( &aSaveIdx ) ) && + if( !pCNd && nullptr == ( pCNd = SwNodes::GoNext( &aSaveIdx ) ) && nullptr == ( pCNd = SwNodes::GoPrevious( &aSaveIdx )) ) { OSL_FAIL( "Where is the TextNode now?" ); @@ -2041,7 +2041,7 @@ void SwUndoTableMerge::SaveCollection( const SwTableBox& rBox ) SwNodeIndex aIdx( *rBox.GetSttNd(), 1 ); SwContentNode* pCNd = aIdx.GetNode().GetContentNode(); if( !pCNd ) - pCNd = aIdx.GetNodes().GoNext( &aIdx ); + pCNd = SwNodes::GoNext(&aIdx); m_pHistory->AddColl(pCNd->GetFormatColl(), aIdx.GetIndex(), pCNd->GetNodeType()); if( pCNd->HasSwAttrSet() ) @@ -2300,7 +2300,7 @@ void SwUndoTableNumFormat::RedoImpl(::sw::UndoRedoContext & rContext) } if( !pNd->IsContentNode() ) - pNd = rDoc.GetNodes().GoNext( pPam->GetPoint() ); + pNd = SwNodes::GoNext(pPam->GetPoint()); } void SwUndoTableNumFormat::SetBox( const SwTableBox& rBox ) @@ -3002,7 +3002,7 @@ void SwUndoMergeTable::UndoImpl(::sw::UndoRedoContext & rContext) pNew->MakeOwnFrames(); // position cursor somewhere in content - pDoc->GetNodes().GoNext( &rPtPos ); + SwNodes::GoNext(&rPtPos); ClearFEShellTabCols(*pDoc, nullptr); diff --git a/sw/source/core/unocore/unochart.cxx b/sw/source/core/unocore/unochart.cxx index cf75c108c83d..0d2b2614d788 100644 --- a/sw/source/core/unocore/unochart.cxx +++ b/sw/source/core/unocore/unochart.cxx @@ -2352,7 +2352,7 @@ bool SwChartDataSequence::DeleteBox( const SwTableBox &rBox ) // therefore call GoNext SwContentNode *pCNd = aIdx.GetNode().GetContentNode(); if (!pCNd) - pCNd = GetFrameFormat()->GetDoc()->GetNodes().GoNext( &aIdx ); + pCNd = SwNodes::GoNext(&aIdx); // and then one can e.g. create a SwPosition: SwPosition aNewPos( *pCNd ); // new position to be used with cursor diff --git a/sw/source/core/unocore/unocrsr.cxx b/sw/source/core/unocore/unocrsr.cxx index 6c1006673283..c5258b5790c7 100644 --- a/sw/source/core/unocore/unocrsr.cxx +++ b/sw/source/core/unocore/unocrsr.cxx @@ -118,7 +118,7 @@ bool SwUnoCursor::IsSelOvr( SwCursorSelOverFlags eFlags ) rPtPos.Assign( *pInvalidNode->EndOfSectionNode(), 1 ); if( !rPtPos.GetNode().IsContentNode() && - ( !rDoc.GetNodes().GoNextSection( &rPtPos ) || + ( !SwNodes::GoNextSection( &rPtPos ) || rPtPos.GetNode() > *pOldSttNd->EndOfSectionNode() ) ) break; } diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx index e2b8930fa889..8e3132d2e8b8 100644 --- a/sw/source/core/unocore/unoframe.cxx +++ b/sw/source/core/unocore/unoframe.cxx @@ -3309,7 +3309,7 @@ rtl::Reference<SwXTextCursor> SwXTextFrame::createXTextCursor() while( pTableNode ) { aPam.GetPoint()->Assign( *pTableNode->EndOfSectionNode() ); - SwContentNode* pCont = GetDoc()->GetNodes().GoNext(aPam.GetPoint()); + SwContentNode* pCont = SwNodes::GoNext(aPam.GetPoint()); pTableNode = pCont->FindTableNode(); } diff --git a/sw/source/core/unocore/unoobj.cxx b/sw/source/core/unocore/unoobj.cxx index 878f4765dd70..3c5f34f1940a 100644 --- a/sw/source/core/unocore/unoobj.cxx +++ b/sw/source/core/unocore/unoobj.cxx @@ -1075,7 +1075,7 @@ SwXTextCursor::gotoStart(sal_Bool Expand) while (pTableNode) { rUnoCursor.GetPoint()->Assign( *pTableNode->EndOfSectionNode() ); - SwContentNode* pCNode = GetDoc()->GetNodes().GoNext(rUnoCursor.GetPoint()); + SwContentNode* pCNode = SwNodes::GoNext(rUnoCursor.GetPoint()); pTableNode = pCNode ? pCNode->FindTableNode() : nullptr; } SwStartNode const*const pTmp = @@ -1086,7 +1086,7 @@ SwXTextCursor::gotoStart(sal_Bool Expand) static_cast<SwSectionNode const*>(pTmp); if (pSectionStartNode->GetSection().IsHiddenFlag()) { - GetDoc()->GetNodes().GoNextSection( + SwNodes::GoNextSection( rUnoCursor.GetPoint(), true, false); } } diff --git a/sw/source/core/unocore/unoredline.cxx b/sw/source/core/unocore/unoredline.cxx index 2ac7eebf5695..86c7d3da1154 100644 --- a/sw/source/core/unocore/unoredline.cxx +++ b/sw/source/core/unocore/unoredline.cxx @@ -111,7 +111,7 @@ rtl::Reference< SwXTextCursor > SwXRedlineText::createXTextCursor() while( pTableNode != nullptr ) { rUnoCursor.GetPoint()->Assign( *pTableNode->EndOfSectionNode() ); - SwContentNode* pContentNode = GetDoc()->GetNodes().GoNext(rUnoCursor.GetPoint()); + SwContentNode* pContentNode = SwNodes::GoNext(rUnoCursor.GetPoint()); pTableNode = pContentNode->FindTableNode(); } if( bTable && rUnoCursor.GetPointNode().FindSttNodeByType( SwNormalStartNode ) @@ -544,7 +544,7 @@ rtl::Reference< SwXTextCursor > SwXRedline::createXTextCursor() while( pTableNode ) { rUnoCursor.GetPoint()->Assign( *pTableNode->EndOfSectionNode() ); - SwContentNode* pCont = GetDoc()->GetNodes().GoNext(rUnoCursor.GetPoint()); + SwContentNode* pCont = SwNodes::GoNext(rUnoCursor.GetPoint()); pTableNode = pCont->FindTableNode(); } diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx index 93603d6d407d..1d2da4140eab 100644 --- a/sw/source/core/unocore/unotext.cxx +++ b/sw/source/core/unocore/unotext.cxx @@ -2410,7 +2410,7 @@ rtl::Reference<SwXTextCursor> SwXBodyText::CreateTextCursor(const bool bIgnoreTa while (pTableNode) { aPam.GetPoint()->Assign( *pTableNode->EndOfSectionNode() ); - SwContentNode* pCont = GetDoc()->GetNodes().GoNext(aPam.GetPoint()); + SwContentNode* pCont = SwNodes::GoNext(aPam.GetPoint()); pTableNode = pCont->FindTableNode(); } } @@ -2633,7 +2633,7 @@ rtl::Reference<SwXTextCursor> SwXHeadFootText::CreateTextCursor(const bool bIgno while (pTableNode) { rUnoCursor.GetPoint()->Assign(*pTableNode->EndOfSectionNode()); - SwContentNode* pCont = GetDoc()->GetNodes().GoNext(rUnoCursor.GetPoint()); + SwContentNode* pCont = SwNodes::GoNext(rUnoCursor.GetPoint()); pTableNode = pCont->FindTableNode(); } } diff --git a/sw/source/core/view/vprint.cxx b/sw/source/core/view/vprint.cxx index 5975cf498b9b..f59273799ca7 100644 --- a/sw/source/core/view/vprint.cxx +++ b/sw/source/core/view/vprint.cxx @@ -366,7 +366,7 @@ void SwViewShell::FillPrtDoc( SwDoc& rPrtDoc, const SfxPrinter* pPrt) if( !pFESh->IsTableMode() && pActCursor && pActCursor->HasMark() ) { // Tweak paragraph attributes of last paragraph SwNodeIndex aNodeIdx( *rPrtDoc.GetNodes().GetEndOfContent().StartOfSectionNode() ); - SwTextNode* pTextNd = rPrtDoc.GetNodes().GoNext( &aNodeIdx )->GetTextNode(); + SwTextNode* pTextNd = SwNodes::GoNext(&aNodeIdx)->GetTextNode(); SwContentNode *pLastNd = (*pActCursor->GetMark()) <= (*pActCursor->GetPoint()) ? pActCursor->GetPointContentNode() @@ -382,7 +382,7 @@ void SwViewShell::FillPrtDoc( SwDoc& rPrtDoc, const SfxPrinter* pPrt) // set the page style at the first paragraph { SwNodeIndex aNodeIdx( *rPrtDoc.GetNodes().GetEndOfContent().StartOfSectionNode() ); - SwContentNode* pCNd = rPrtDoc.GetNodes().GoNext( &aNodeIdx ); // go to 1st ContentNode + SwContentNode* pCNd = SwNodes::GoNext(&aNodeIdx); // go to 1st ContentNode if( pFESh->IsTableMode() ) { SwTableNode* pTNd = pCNd->FindTableNode(); diff --git a/sw/source/filter/basflt/fltshell.cxx b/sw/source/filter/basflt/fltshell.cxx index 901614897f18..aa11df926e9e 100644 --- a/sw/source/filter/basflt/fltshell.cxx +++ b/sw/source/filter/basflt/fltshell.cxx @@ -51,14 +51,13 @@ using namespace com::sun::star; -e ... etc. - the rest is truncated