sw/inc/pam.hxx                                          |    4 ++--
 sw/source/core/crsr/pam.cxx                             |    6 ++++++
 sw/source/core/doc/DocumentContentOperationsManager.cxx |    2 +-
 sw/source/core/doc/docedt.cxx                           |   16 ++++++++--------
 sw/source/core/inc/mvsave.hxx                           |    4 ++--
 5 files changed, 19 insertions(+), 13 deletions(-)

New commits:
commit 28a3f31e8cf8b7b7b3900b12de1a24dc88f2854a
Author:     Noel Grandin <noelgran...@gmail.com>
AuthorDate: Mon Aug 15 16:13:57 2022 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Tue Aug 16 13:28:10 2022 +0200

    pass SwNode and sal_Int32 to DelFlyInRange
    
    instead of SwNodeIndex and SwContentIndex. Part of the process
    of hiding the implementation of SwPosition.
    
    And fix a missing SwPosition constructor.
    
    Change-Id: Idc4d2675a53596e6f2ea53043dc7109b9c7bc2e1
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138317
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/sw/inc/pam.hxx b/sw/inc/pam.hxx
index 90b6b8d00e71..a56677cfaa5a 100644
--- a/sw/inc/pam.hxx
+++ b/sw/inc/pam.hxx
@@ -44,8 +44,8 @@ struct SAL_WARN_UNUSED SW_DLLPUBLIC SwPosition
     explicit SwPosition( const SwNodeIndex &rNode, SwNodeOffset nDiff = 
SwNodeOffset(0) );
     explicit SwPosition( const SwNode& rNode, SwNodeOffset nDiff = 
SwNodeOffset(0) );
     explicit SwPosition( const SwContentNode& rNode, sal_Int32 nContentOffset 
= 0 );
-    SwPosition( const SwNodeIndex &rNode, const SwContentNode*, const 
sal_Int32 nContentOffset );
-    SwPosition( const SwNode &rNode, const SwContentNode*, const sal_Int32 
nContentOffset );
+    SwPosition( const SwNodeIndex &rNode, const SwContentNode*, sal_Int32 
nContentOffset );
+    SwPosition( const SwNode &rNode, const SwContentNode*, sal_Int32 
nContentOffset );
     SwPosition( const SwNodeIndex &rNode, SwNodeOffset nDiff, const 
SwContentNode*, sal_Int32 nContentOffset );
     SwPosition( const SwNode &rNode, SwNodeOffset nDiff, const SwContentNode*, 
sal_Int32 nContentOffset );
     SwPosition( const SwContentIndex &, short nDiff );
diff --git a/sw/source/core/crsr/pam.cxx b/sw/source/core/crsr/pam.cxx
index b1c81de2f8f5..d9076608774d 100644
--- a/sw/source/core/crsr/pam.cxx
+++ b/sw/source/core/crsr/pam.cxx
@@ -74,6 +74,12 @@ SwPosition::SwPosition( const SwNodeIndex & rNodeIndex, 
const SwContentNode* pCo
     assert(!pContentNode || pContentNode == &rNodeIndex.GetNode());
 }
 
+SwPosition::SwPosition( const SwNode & rNode, const SwContentNode* 
pContentNode, sal_Int32 nContentOffset )
+    : nNode( rNode ), nContent( pContentNode, nContentOffset )
+{
+    assert(!pContentNode || pContentNode == &rNode);
+}
+
 SwPosition::SwPosition( const SwNodeIndex & rNodeIndex, SwNodeOffset nDiff, 
const SwContentNode* pContentNode, sal_Int32 nContentOffset )
     : nNode( rNodeIndex, nDiff ), nContent( pContentNode, nContentOffset )
 {
diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx 
b/sw/source/core/doc/DocumentContentOperationsManager.cxx
index 4987959d84f9..fb33ec5103f4 100644
--- a/sw/source/core/doc/DocumentContentOperationsManager.cxx
+++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx
@@ -4342,7 +4342,7 @@ bool 
DocumentContentOperationsManager::DeleteRangeImplImpl(SwPaM & rPam, SwDelet
     if (!(flags & SwDeleteFlags::ArtificialSelection))
     {
         DelFlyInRange(rPam.GetMark()->GetNode(), rPam.GetPoint()->GetNode(),
-            &rPam.GetMark()->nContent, &rPam.GetPoint()->nContent);
+            rPam.GetMark()->GetContentIndex(), 
rPam.GetPoint()->GetContentIndex());
     }
     DelBookmarks(
         pStt->GetNode(),
diff --git a/sw/source/core/doc/docedt.cxx b/sw/source/core/doc/docedt.cxx
index 77a8b1245d70..f12efa7f56f3 100644
--- a/sw/source/core/doc/docedt.cxx
+++ b/sw/source/core/doc/docedt.cxx
@@ -207,14 +207,14 @@ void SaveFlyInRange( const SwPaM& rPam, const SwPosition& 
rInsPos,
 /// If there is a Fly at the SPoint, it is moved onto the Mark.
 void DelFlyInRange( SwNode& rMkNd,
                     SwNode& rPtNd,
-                    SwContentIndex const*const pMkIdx, SwContentIndex 
const*const pPtIdx)
+                    std::optional<sal_Int32> oMkContentIdx, 
std::optional<sal_Int32> oPtContentIdx)
 {
-    assert((pMkIdx == nullptr) == (pPtIdx == nullptr));
-    SwPosition const point(pPtIdx
-                            ? SwPosition(rPtNd, *pPtIdx)
+    assert(oMkContentIdx.has_value() == oPtContentIdx.has_value());
+    SwPosition const point(oPtContentIdx
+                            ? SwPosition(rPtNd, rPtNd.GetContentNode(), 
*oPtContentIdx)
                             : SwPosition(rPtNd));
-    SwPosition const mark(pPtIdx
-                            ? SwPosition(rMkNd, *pMkIdx)
+    SwPosition const mark(oPtContentIdx
+                            ? SwPosition(rMkNd, rMkNd.GetContentNode(), 
*oMkContentIdx)
                             : SwPosition(rMkNd));
     SwPosition const& rStart = mark <= point ? mark : point;
     SwPosition const& rEnd   = mark <= point ? point : mark;
@@ -228,11 +228,11 @@ void DelFlyInRange( SwNode& rMkNd,
         SwPosition const*const pAPos = rAnch.GetContentAnchor();
         if (pAPos &&
             (((rAnch.GetAnchorId() == RndStdIds::FLY_AT_PARA)
-                && IsSelectFrameAnchoredAtPara(*pAPos, rStart, rEnd, pPtIdx
+                && IsSelectFrameAnchoredAtPara(*pAPos, rStart, rEnd, 
oPtContentIdx
                     ? DelContentType::AllMask|DelContentType::WriterfilterHack
                     : 
DelContentType::AllMask|DelContentType::WriterfilterHack|DelContentType::CheckNoCntnt))
             || ((rAnch.GetAnchorId() == RndStdIds::FLY_AT_CHAR)
-                && IsDestroyFrameAnchoredAtChar(*pAPos, rStart, rEnd, pPtIdx
+                && IsDestroyFrameAnchoredAtChar(*pAPos, rStart, rEnd, 
oPtContentIdx
                     ? DelContentType::AllMask|DelContentType::WriterfilterHack
                     : 
DelContentType::AllMask|DelContentType::WriterfilterHack|DelContentType::CheckNoCntnt))))
         {
diff --git a/sw/source/core/inc/mvsave.hxx b/sw/source/core/inc/mvsave.hxx
index 4b553d270c8f..8376252e7703 100644
--- a/sw/source/core/inc/mvsave.hxx
+++ b/sw/source/core/inc/mvsave.hxx
@@ -124,8 +124,8 @@ void SaveFlyInRange( const SwPaM& rPam, const SwPosition& 
rInsPos,
 
 void DelFlyInRange( SwNode& rMkNd,
                     SwNode& rPtNd,
-                    SwContentIndex const* pMkIdx = nullptr,
-                    SwContentIndex const* pPtIdx = nullptr);
+                    std::optional<sal_Int32> nMkContentIdx = std::nullopt,
+                    std::optional<sal_Int32> pPtContentIdx = std::nullopt);
 
 class SwDataChanged
 {

Reply via email to