diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-09-05 14:16:28 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-09-06 08:56:24 +0200 |
commit | 3a8c74efa2da18f16af4f395e46ee13bfdfa76cc (patch) | |
tree | d0da143945d8773aa8375ad14aefb497756d41ad | |
parent | 33ad73f3214d895f438d3e15c5099a4d878d5041 (diff) |
use more SwPosition::Assign
part of hiding the internals of SwPosition
Change-Id: If16a9bd3f01afd57dbb44d80dd14a0f5f9bde9d9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139436
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | sw/source/core/undo/unins.cxx | 34 | ||||
-rw-r--r-- | sw/source/core/undo/unovwr.cxx | 8 |
2 files changed, 19 insertions, 23 deletions
diff --git a/sw/source/core/undo/unins.cxx b/sw/source/core/undo/unins.cxx index 579d67883e4e..4ced606b27ff 100644 --- a/sw/source/core/undo/unins.cxx +++ b/sw/source/core/undo/unins.cxx @@ -208,11 +208,10 @@ void SwUndoInsert::UndoImpl(::sw::UndoRedoContext & rContext) if( m_bIsAppend ) { - pPam->GetPoint()->nNode = m_nNode; + pPam->GetPoint()->Assign(m_nNode); if( IDocumentRedlineAccess::IsRedlineOn( GetRedlineFlags() )) { - pPam->GetPoint()->nContent.Assign( pPam->GetPointContentNode(), 0 ); pPam->SetMark(); pPam->Move( fnMoveBackward ); pPam->Exchange(); @@ -220,7 +219,7 @@ void SwUndoInsert::UndoImpl(::sw::UndoRedoContext & rContext) } pPam->DeleteMark(); pTmpDoc->getIDocumentContentOperations().DelFullPara( *pPam ); - pPam->GetPoint()->nContent.Assign( pPam->GetPointContentNode(), 0 ); + pPam->GetPoint()->SetContent( 0 ); } else { @@ -237,7 +236,7 @@ void SwUndoInsert::UndoImpl(::sw::UndoRedoContext & rContext) SwTextNode * const pTextNode( pCNd->GetTextNode() ); if ( pTextNode ) { - aPaM.GetPoint()->nContent -= m_nLen; + aPaM.GetPoint()->AdjustContent( - m_nLen ); if( IDocumentRedlineAccess::IsRedlineOn( GetRedlineFlags() )) pTmpDoc->getIDocumentRedlineAccess().DeleteRedline( aPaM, true, RedlineType::Any ); if (m_bWithRsid) @@ -293,7 +292,7 @@ void SwUndoInsert::RedoImpl(::sw::UndoRedoContext & rContext) if( m_bIsAppend ) { - pPam->GetPoint()->nNode = m_nNode - 1; + pPam->GetPoint()->Assign( m_nNode - 1 ); pTmpDoc->getIDocumentContentOperations().AppendTextNode( *pPam->GetPoint() ); pPam->SetMark(); @@ -315,10 +314,10 @@ void SwUndoInsert::RedoImpl(::sw::UndoRedoContext & rContext) } else { - pPam->GetPoint()->nNode = m_nNode; + pPam->GetPoint()->Assign( m_nNode ); SwContentNode *const pCNd = pPam->GetPoint()->GetNode().GetContentNode(); - pPam->GetPoint()->nContent.Assign( pCNd, m_nContent ); + pPam->GetPoint()->SetContent( m_nContent ); if( m_nLen ) { @@ -652,7 +651,7 @@ void SwUndoReplace::Impl::UndoImpl(::sw::UndoRedoContext & rContext) { if ((1 == m_sIns.getLength()) && (1 == m_sOld.getLength())) { - SwPosition aPos( *pNd ); aPos.nContent.Assign( pNd, m_nSttCnt ); + SwPosition aPos( *pNd, m_nSttCnt ); pACEWord->CheckChar( aPos, m_sOld[ 0 ] ); } pDoc->SetAutoCorrExceptWord( nullptr ); @@ -662,8 +661,7 @@ void SwUndoReplace::Impl::UndoImpl(::sw::UndoRedoContext & rContext) { rPam.GetPoint()->Assign(*pNd, m_nSttCnt ); rPam.SetMark(); - rPam.GetPoint()->nNode = m_nSttNd - m_nOffset; - rPam.GetPoint()->nContent.Assign(rPam.GetPointContentNode(), m_nSttNd == m_nEndNd ? m_nEndCnt : pNd->Len()); + rPam.GetPoint()->Assign( m_nSttNd - m_nOffset, m_nSttNd == m_nEndNd ? m_nEndCnt : pNd->Len()); // replace only in start node, without regex bool const ret = pDoc->getIDocumentContentOperations().ReplaceRange(rPam, m_sOld, false); @@ -723,18 +721,16 @@ void SwUndoReplace::Impl::RedoImpl(::sw::UndoRedoContext & rContext) SwDoc & rDoc = rContext.GetDoc(); SwCursor & rPam(rContext.GetCursorSupplier().CreateNewShellCursor()); rPam.DeleteMark(); - rPam.GetPoint()->nNode = m_nSttNd; + rPam.GetPoint()->Assign( m_nSttNd, m_nSttCnt ); - SwTextNode* pNd = rPam.GetPoint()->GetNode().GetTextNode(); - OSL_ENSURE( pNd, "Dude, where's my TextNode?" ); - rPam.GetPoint()->nContent.Assign( pNd, m_nSttCnt ); + rPam.GetPoint()->GetNode().GetTextNode(); rPam.SetMark(); if( m_bSplitNext ) { - rPam.GetPoint()->nNode = m_nSttNd + 1; - pNd = rPam.GetPoint()->GetNode().GetTextNode(); + rPam.GetPoint()->Assign( m_nSttNd + 1 ); + rPam.GetPoint()->GetNode().GetTextNode(); } - rPam.GetPoint()->nContent.Assign( pNd, m_nSelEnd ); + rPam.GetPoint()->SetContent( m_nSelEnd ); if( m_pHistory ) { @@ -905,9 +901,9 @@ void SwUndoInsertLabel::UndoImpl(::sw::UndoRedoContext & rContext) pNd->GetTable().GetFrameFormat()->ResetFormatAttr( RES_KEEP ); } SwPaM aPam( rDoc.GetNodes().GetEndOfContent() ); - aPam.GetPoint()->nNode = NODE.nNode; + aPam.GetPoint()->Assign( NODE.nNode ); aPam.SetMark(); - aPam.GetPoint()->nNode = NODE.nNode + 1; + aPam.GetPoint()->Assign( NODE.nNode + 1 ); NODE.pUndoInsNd = new SwUndoDelete(aPam, SwDeleteFlags::Default, true); } } diff --git a/sw/source/core/undo/unovwr.cxx b/sw/source/core/undo/unovwr.cxx index b585ac6a5d13..5f93bab0b62b 100644 --- a/sw/source/core/undo/unovwr.cxx +++ b/sw/source/core/undo/unovwr.cxx @@ -54,8 +54,8 @@ SwUndoOverwrite::SwUndoOverwrite( SwDoc& rDoc, SwPosition& rPos, if( !rDoc.getIDocumentRedlineAccess().IsIgnoreRedline() && !rDoc.getIDocumentRedlineAccess().GetRedlineTable().empty() ) { - SwPaM aPam( rPos.nNode, rPos.GetContentIndex(), - rPos.nNode, rPos.GetContentIndex()+1 ); + SwPaM aPam( rPos.GetNode(), rPos.GetContentIndex(), + rPos.GetNode(), rPos.GetContentIndex()+1 ); m_pRedlSaveData.reset( new SwRedlineSaveDatas ); if( !FillSaveData( aPam, *m_pRedlSaveData, false )) { @@ -76,7 +76,7 @@ SwUndoOverwrite::SwUndoOverwrite( SwDoc& rDoc, SwPosition& rPos, SwRegHistory aRHst( *pTextNd, m_pHistory.get() ); m_pHistory->CopyAttr( pTextNd->GetpSwpHints(), m_nStartNode, 0, nTextNdLen, false ); - ++rPos.nContent; + rPos.AdjustContent(+1); m_bInsChar = false; } @@ -88,7 +88,7 @@ SwUndoOverwrite::SwUndoOverwrite( SwDoc& rDoc, SwPosition& rPos, if( !m_bInsChar ) { - const SwContentIndex aTmpIndex( rPos.nContent, -2 ); + const SwContentIndex aTmpIndex( rPos.GetContentNode(), rPos.GetContentIndex() - 2 ); pTextNd->EraseText( aTmpIndex, 1 ); } pTextNd->SetIgnoreDontExpand( bOldExpFlg ); |