sw/source/core/doc/doccomp.cxx | 20 ++++++++++---------- sw/source/core/doc/doccorr.cxx | 12 +++++++----- sw/source/core/doc/docedt.cxx | 6 +++--- sw/source/core/doc/docfly.cxx | 22 +++++++++++----------- sw/source/core/doc/docfmt.cxx | 2 +- sw/source/core/doc/docglos.cxx | 8 ++++---- sw/source/core/doc/doclay.cxx | 3 +-- 7 files changed, 37 insertions(+), 36 deletions(-)
New commits: commit d7234feac18dbb94fef310e8c241428426b27717 Author: Noel Grandin <noelgran...@gmail.com> AuthorDate: Thu Aug 25 18:45:33 2022 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Thu Aug 25 20:21:54 2022 +0200 use more SwPosition::Assign as part of the process of hiding the internals of SwPosition Change-Id: I86da72d648ba006f55fcec86854e5188720a1156 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138841 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/sw/source/core/doc/doccomp.cxx b/sw/source/core/doc/doccomp.cxx index 7cb4a640173e..e29ea7d87f1c 100644 --- a/sw/source/core/doc/doccomp.cxx +++ b/sw/source/core/doc/doccomp.cxx @@ -1672,10 +1672,10 @@ void CompareData::SetRedlinesToDoc( bool bUseDocInfo ) if (& GetEndOfContent() == & pTmp->GetPoint()->GetNode()) { - --pTmp->GetPoint()->nNode; + pTmp->GetPoint()->Adjust(SwNodeOffset(-1)); SwContentNode *const pContentNode( pTmp->GetPointContentNode() ); - pTmp->GetPoint()->nContent.Assign( pContentNode, - pContentNode ? pContentNode->Len() : 0 ); + if( pContentNode ) + pTmp->GetPoint()->SetContent( pContentNode->Len() ); // tdf#106218 try to avoid losing a paragraph break here: if (pTmp->GetMark()->GetContentIndex() == 0) { @@ -1715,10 +1715,10 @@ void CompareData::SetRedlinesToDoc( bool bUseDocInfo ) if (& GetEndOfContent() == & pTmp->GetPoint()->GetNode()) { - --pTmp->GetPoint()->nNode; + pTmp->GetPoint()->Adjust(SwNodeOffset(-1)); SwContentNode *const pContentNode( pTmp->GetPointContentNode() ); - pTmp->GetPoint()->nContent.Assign( pContentNode, - pContentNode ? pContentNode->Len() : 0 ); + if( pContentNode ) + pTmp->GetPoint()->SetContent( pContentNode->Len() ); // tdf#106218 try to avoid losing a paragraph break here: if (pTmp->GetMark()->GetContentIndex() == 0) { @@ -1929,10 +1929,10 @@ SaveMergeRedline::SaveMergeRedline( const SwNode& rDstNd, const SwPosition* pEnd = rSrcRedl.End(); pDestRedl->SetMark(); - pDestRedl->GetPoint()->nNode += pEnd->GetNodeIndex() - - pStt->GetNodeIndex(); - pDestRedl->GetPoint()->nContent.Assign( pDestRedl->GetPointContentNode(), - pEnd->GetContentIndex() ); + pDestRedl->GetPoint()->Adjust( pEnd->GetNodeIndex() - + pStt->GetNodeIndex() ); + if( pDestRedl->GetPointContentNode() ) + pDestRedl->GetPoint()->SetContent( pEnd->GetContentIndex() ); } sal_uInt16 SaveMergeRedline::InsertRedline(SwPaM* pLastDestRedline) diff --git a/sw/source/core/doc/doccorr.cxx b/sw/source/core/doc/doccorr.cxx index 2af89d1cdf37..b4167611f8e9 100644 --- a/sw/source/core/doc/doccorr.cxx +++ b/sw/source/core/doc/doccorr.cxx @@ -73,13 +73,15 @@ namespace const sal_Int32 nCntIdx) { for(int nb = 0; nb < 2; ++nb) - if(&(pPam->GetBound(bool(nb)).GetNode()) == pOldNode) + { + SwPosition & rPos = pPam->GetBound(bool(nb)); + if(&rPos.GetNode() == pOldNode) { - pPam->GetBound(bool(nb)).nNode = rNewPos.nNode; - pPam->GetBound(bool(nb)).nContent.Assign( - rNewPos.GetNode().GetContentNode(), - nCntIdx + pPam->GetBound(bool(nb)).GetContentIndex()); + rPos.Assign( rNewPos.GetNode() ); + if(rNewPos.GetNode().GetContentNode()) + rPos.AdjustContent(nCntIdx); } + } } } diff --git a/sw/source/core/doc/docedt.cxx b/sw/source/core/doc/docedt.cxx index 9be8bcccae63..b20789b60bc8 100644 --- a/sw/source/core/doc/docedt.cxx +++ b/sw/source/core/doc/docedt.cxx @@ -141,7 +141,7 @@ void SaveFlyInRange( const SwPaM& rPam, const SwPosition& rInsPos, const SwFormatAnchor* pAnchor; const SwPosition* pPos = rPam.Start(); - const SwNodeIndex& rSttNdIdx = pPos->nNode; + const SwNode& rSttNd = pPos->GetNode(); SwPosition atParaEnd(*rPam.End()); if (bMoveAllFlys) @@ -183,9 +183,9 @@ void SaveFlyInRange( const SwPaM& rPam, const SwPosition& rInsPos, { pHistory->AddChangeFlyAnchor(*pFormat); } - SaveFly aSave( pAPos->GetNodeIndex() - rSttNdIdx.GetIndex(), + SaveFly aSave( pAPos->GetNodeIndex() - rSttNd.GetIndex(), (RndStdIds::FLY_AT_CHAR == pAnchor->GetAnchorId()) - ? (pAPos->GetNode() == rSttNdIdx.GetNode()) + ? (pAPos->GetNode() == rSttNd) ? pAPos->GetContentIndex() - rPam.Start()->GetContentIndex() : pAPos->GetContentIndex() : 0, diff --git a/sw/source/core/doc/docfly.cxx b/sw/source/core/doc/docfly.cxx index 54d976f40677..aeb871c817c3 100644 --- a/sw/source/core/doc/docfly.cxx +++ b/sw/source/core/doc/docfly.cxx @@ -1078,21 +1078,21 @@ SwChainRet SwDoc::Chainable( const SwFrameFormat &rSource, const SwFrameFormat & } else if( rSrcAnchor.GetContentAnchor() && rDstAnchor.GetContentAnchor() ) { - const SwNodeIndex &rSrcIdx = rSrcAnchor.GetContentAnchor()->nNode, - &rDstIdx = rDstAnchor.GetContentAnchor()->nNode; + const SwNode &rSrcNd = rSrcAnchor.GetContentAnchor()->GetNode(), + &rDstNd = rDstAnchor.GetContentAnchor()->GetNode(); const SwStartNode* pSttNd = nullptr; - if( rSrcIdx == rDstIdx || + if( rSrcNd == rDstNd || ( !pSttNd && - nullptr != ( pSttNd = rSrcIdx.GetNode().FindFlyStartNode() ) && - pSttNd == rDstIdx.GetNode().FindFlyStartNode() ) || + nullptr != ( pSttNd = rSrcNd.FindFlyStartNode() ) && + pSttNd == rDstNd.FindFlyStartNode() ) || ( !pSttNd && - nullptr != ( pSttNd = rSrcIdx.GetNode().FindFooterStartNode() ) && - pSttNd == rDstIdx.GetNode().FindFooterStartNode() ) || + nullptr != ( pSttNd = rSrcNd.FindFooterStartNode() ) && + pSttNd == rDstNd.FindFooterStartNode() ) || ( !pSttNd && - nullptr != ( pSttNd = rSrcIdx.GetNode().FindHeaderStartNode() ) && - pSttNd == rDstIdx.GetNode().FindHeaderStartNode() ) || - ( !pSttNd && rDstIdx.GetIndex() > nEndOfExtras && - rSrcIdx.GetIndex() > nEndOfExtras )) + nullptr != ( pSttNd = rSrcNd.FindHeaderStartNode() ) && + pSttNd == rDstNd.FindHeaderStartNode() ) || + ( !pSttNd && rDstNd.GetIndex() > nEndOfExtras && + rSrcNd.GetIndex() > nEndOfExtras )) bAllowed = true; } diff --git a/sw/source/core/doc/docfmt.cxx b/sw/source/core/doc/docfmt.cxx index 91091116aad1..cc53bc815e82 100644 --- a/sw/source/core/doc/docfmt.cxx +++ b/sw/source/core/doc/docfmt.cxx @@ -362,7 +362,7 @@ void SwDoc::ResetAttrs( const SwPaM &rRg, ++aTmpEnd; bAdd = false; } - else if( pStt->nNode != pEnd->nNode || !pStt->GetContentIndex() ) + else if( pStt->GetNode() != pEnd->GetNode() || !pStt->GetContentIndex() ) { SwTextNode* pTNd = aTmpEnd.GetNode().GetTextNode(); if( pTNd && pTNd->HasSwAttrSet() && pTNd->GetpSwAttrSet()->Count() ) diff --git a/sw/source/core/doc/docglos.cxx b/sw/source/core/doc/docglos.cxx index 96f40fa8c8f4..306564c2a1f5 100644 --- a/sw/source/core/doc/docglos.cxx +++ b/sw/source/core/doc/docglos.cxx @@ -164,10 +164,10 @@ bool SwDoc::InsertGlossary( SwTextBlocks& rBlock, const OUString& rEntry, aCpyPam.SetMark(); // till the nodes array's end - aCpyPam.GetPoint()->nNode = pGDoc->GetNodes().GetEndOfContent().GetIndex()-SwNodeOffset(1); + aCpyPam.GetPoint()->Assign( pGDoc->GetNodes().GetEndOfContent().GetIndex()-SwNodeOffset(1) ); pContentNd = aCpyPam.GetPointContentNode(); - aCpyPam.GetPoint()->nContent.Assign( - pContentNd, pContentNd ? pContentNd->Len() : 0 ); + if (pContentNd) + aCpyPam.GetPoint()->SetContent( pContentNd->Len() ); GetIDocumentUndoRedo().StartUndo( SwUndoId::INSGLOSSARY, nullptr ); SwPaM *_pStartCursor = &rPaM, *_pStartCursor2 = _pStartCursor; @@ -179,7 +179,7 @@ bool SwDoc::InsertGlossary( SwTextBlocks& rBlock, const OUString& rEntry, if( pBoxSttNd && SwNodeOffset(2) == pBoxSttNd->EndOfSectionIndex() - pBoxSttNd->GetIndex() && - aCpyPam.GetPoint()->nNode != aCpyPam.GetMark()->nNode ) + aCpyPam.GetPoint()->GetNode() != aCpyPam.GetMark()->GetNode() ) { // We copy more than one Node to the current Box. // However, we have to remove the BoxAttributes then. diff --git a/sw/source/core/doc/doclay.cxx b/sw/source/core/doc/doclay.cxx index 7065d20b214a..65c1a56f80af 100644 --- a/sw/source/core/doc/doclay.cxx +++ b/sw/source/core/doc/doclay.cxx @@ -1635,8 +1635,7 @@ SvxFrameDirection SwDoc::GetTextDirection( const SwPosition& rPos, if ((RndStdIds::FLY_AT_PAGE != pAnchor->GetAnchorId()) && pAnchor->GetContentAnchor()) { - pFlyFormat = pAnchor->GetContentAnchor()->nNode. - GetNode().GetFlyFormat(); + pFlyFormat = pAnchor->GetContentAnchor()->GetNode().GetFlyFormat(); } else pFlyFormat = nullptr;