sw/source/filter/ww8/ww8glsy.cxx |   33 +++++++++++++++------------------
 sw/source/filter/ww8/ww8glsy.hxx |    2 +-
 sw/source/filter/ww8/ww8par.cxx  |   18 +++++-------------
 3 files changed, 21 insertions(+), 32 deletions(-)

New commits:
commit 55c638eb0d6aeacb7b5a8b0345add9b44aa6c889
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Wed Aug 24 11:04:48 2022 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Wed Aug 24 14:29:41 2022 +0200

    use SwNode instead of SwNodeIndex in HasBareGraphicEnd method
    
    part of the process of hiding the internals of SwPosition
    
    Change-Id: I89f5bc1a70a8cf54052eebdda9830f8ed634ce45
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138759
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/sw/source/filter/ww8/ww8glsy.cxx b/sw/source/filter/ww8/ww8glsy.cxx
index 8b8c92482510..2ad84960dcb1 100644
--- a/sw/source/filter/ww8/ww8glsy.cxx
+++ b/sw/source/filter/ww8/ww8glsy.cxx
@@ -56,7 +56,7 @@ WW8Glossary::WW8Glossary(tools::SvRef<SotStorageStream> 
&refStrm, sal_uInt8 nVer
     }
 }
 
-bool WW8Glossary::HasBareGraphicEnd(SwDoc *pDoc,SwNodeIndex const &rIdx)
+bool WW8Glossary::HasBareGraphicEnd(SwDoc *pDoc, SwNode const &rIdx)
 {
     bool bRet=false;
     for( sal_uInt16 nCnt = pDoc->GetSpzFrameFormats()->size(); nCnt; )
@@ -70,7 +70,7 @@ bool WW8Glossary::HasBareGraphicEnd(SwDoc *pDoc,SwNodeIndex 
const &rIdx)
         if (pAPos &&
             ((RndStdIds::FLY_AT_PARA == rAnchor.GetAnchorId()) ||
              (RndStdIds::FLY_AT_CHAR == rAnchor.GetAnchorId())) &&
-            rIdx == pAPos->GetNodeIndex() )
+            rIdx == pAPos->GetNode() )
         {
             bRet=true;
             break;
@@ -115,29 +115,28 @@ bool WW8Glossary::MakeEntries(SwDoc *pD, SwTextBlocks 
&rBlocks,
         do {
             SwPaM aPam( aStart );
             {
-                SwNodeIndex& rIdx = aPam.GetPoint()->nNode;
-                ++rIdx;
-                pCNd = rIdx.GetNode().GetTextNode();
+                SwPosition& rPos = *aPam.GetPoint();
+                rPos.Adjust(SwNodeOffset(1));
+                pCNd = rPos.GetNode().GetTextNode();
                 if( nullptr == pCNd )
                 {
-                    pCNd = pD->GetNodes().MakeTextNode( rIdx.GetNode(), pColl 
);
-                    rIdx = *pCNd;
+                    pCNd = pD->GetNodes().MakeTextNode( rPos.GetNode(), pColl 
);
+                    rPos.Assign(*pCNd);
                 }
             }
-            aPam.GetPoint()->nContent.Assign( pCNd, 0 );
             aPam.SetMark();
             {
-                SwNodeIndex& rIdx = aPam.GetPoint()->nNode;
-                rIdx = aStart.GetNode().EndOfSectionIndex() - 1;
-                if(( nullptr == ( pCNd = rIdx.GetNode().GetContentNode() ) )
-                        || HasBareGraphicEnd(pD,rIdx))
+                SwPosition& rPos = *aPam.GetPoint();
+                rPos.Assign(aStart.GetNode().EndOfSectionIndex() - 1);
+                if(( nullptr == ( pCNd = rPos.GetNode().GetContentNode() ) )
+                        || HasBareGraphicEnd(pD,rPos.GetNode()))
                 {
-                    ++rIdx;
-                    pCNd = pD->GetNodes().MakeTextNode( rIdx.GetNode(), pColl 
);
-                    rIdx = *pCNd;
+                    rPos.Adjust(SwNodeOffset(1));
+                    pCNd = pD->GetNodes().MakeTextNode( rPos.GetNode(), pColl 
);
+                    rPos.Assign(*pCNd);
                 }
             }
-            aPam.GetPoint()->nContent.Assign( pCNd, pCNd->Len() );
+            aPam.GetPoint()->SetContent( pCNd->Len() );
 
             // now we have the right selection for one entry.  Copy this to
             // the defined TextBlock, but only if it is not an autocorrection
@@ -221,8 +220,6 @@ bool WW8Glossary::Load( SwTextBlocks &rBlocks, bool 
bSaveRelFile )
                     pD->GetNodes().GoNext( &aIdx );
                 }
                 SwPaM aPamo( aIdx );
-                
aPamo.GetPoint()->nContent.Assign(aIdx.GetNode().GetContentNode(),
-                    0);
                 std::unique_ptr<SwWW8ImplReader> xRdr(new SwWW8ImplReader(
                     m_xGlossary->m_nVersion, m_xStg.get(), m_rStrm.get(), *pD, 
rBlocks.GetBaseURL(),
                     true, false, *aPamo.GetPoint()));
diff --git a/sw/source/filter/ww8/ww8glsy.hxx b/sw/source/filter/ww8/ww8glsy.hxx
index bff76efedecd..35babac1d07f 100644
--- a/sw/source/filter/ww8/ww8glsy.hxx
+++ b/sw/source/filter/ww8/ww8glsy.hxx
@@ -81,7 +81,7 @@ private:
     static bool MakeEntries(SwDoc *pD, SwTextBlocks &rBlocks, bool 
bSaveRelFile,
                             const std::vector<OUString>& rStrings,
                             const std::vector<ww::bytes>& rExtra);
-    static bool HasBareGraphicEnd(SwDoc *pD,SwNodeIndex const &rIdx);
+    static bool HasBareGraphicEnd(SwDoc *pD, SwNode const &rIdx);
 
     WW8Glossary(const WW8Glossary&) = delete;
     WW8Glossary& operator=(const WW8Glossary&) = delete;
commit f067bfebf6fbdfb66d545585fea9fe6cec559038
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Wed Aug 24 11:01:51 2022 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Wed Aug 24 14:29:26 2022 +0200

    Use more SwPosition::Adjust
    
    to keep the internal fields of SwPosition in sync.
    
    Change-Id: I8a418c2806eefada74471c28aa23189950d2e7ea
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138758
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index e18ab2e655c7..18610cc41f5a 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -2503,9 +2503,9 @@ bool SwWW8ImplReader::SetSpacing(SwPaM &rMyPam, int 
nSpace, bool bIsUpper )
                 aUL.SetLower( static_cast< sal_uInt16 >(nSpace) );
 
             const sal_Int32 nEnd = pSpacingPos->GetContentIndex();
-            rMyPam.GetPoint()->nContent.Assign(rMyPam.GetPointContentNode(), 
0);
+            rMyPam.GetPoint()->SetContent(0);
             m_xCtrlStck->NewAttr(*pSpacingPos, aUL);
-            rMyPam.GetPoint()->nContent.Assign(rMyPam.GetPointContentNode(), 
nEnd);
+            rMyPam.GetPoint()->SetContent(nEnd);
             m_xCtrlStck->SetAttr(*pSpacingPos, RES_UL_SPACE);
             bRet = true;
         }
@@ -4454,11 +4454,7 @@ static void GiveNodePageDesc(SwNodeIndex const &rIdx, 
const SwFormatPageDesc &rP
     }
     else
     {
-        SwPosition aPamStart(rIdx);
-        aPamStart.nContent.Assign(
-            rIdx.GetNode().GetContentNode(), 0);
-        SwPaM aPage(aPamStart);
-
+        SwPaM aPage(rIdx);
         rDoc.getIDocumentContentOperations().InsertPoolItem(aPage, rPgDesc);
     }
 }
@@ -4620,9 +4616,7 @@ void wwSectionManager::InsertSegments()
                     mrReader.m_rDoc.GetNodes().MakeTextNode(aAnchor.GetNode(),
                     
mrReader.m_rDoc.getIDocumentStylePoolAccess().GetTextCollFromPool( 
RES_POOLCOLL_TEXT ));
 
-                aSectPaM.GetPoint()->Assign(*pTextNd);
-                aSectPaM.GetPoint()->nContent.Assign(
-                    aSectPaM.GetPointContentNode(), 0);
+                aSectPaM.GetPoint()->Assign(*pTextNd, 0);
             }
 
             aSectPaM.SetMark();
@@ -6726,9 +6720,7 @@ namespace sw::hack
 
         Position::operator SwPosition() const
         {
-            SwPosition aRet(maPtNode);
-            aRet.nContent.Assign(maPtNode.GetNode().GetContentNode(), 
mnPtContent);
-            return aRet;
+            return SwPosition(maPtNode, maPtNode.GetNode().GetContentNode(), 
mnPtContent);
         }
 }
 

Reply via email to