sw/inc/ndtxt.hxx                                        |    5 +++++
 sw/source/core/doc/DocumentContentOperationsManager.cxx |    6 +++---
 sw/source/core/docnode/ndtbl.cxx                        |    2 +-
 sw/source/core/txtnode/ndtxt.cxx                        |   12 ++++++++++++
 sw/source/core/undo/undel.cxx                           |    6 +++---
 sw/source/core/undo/unins.cxx                           |    4 ++--
 sw/source/core/undo/unovwr.cxx                          |    5 ++---
 7 files changed, 28 insertions(+), 12 deletions(-)

New commits:
commit ee003ca99f94c9a5517ebba67ed02abb2a60dae8
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Mon Sep 5 12:42:28 2022 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Mon Sep 5 14:06:02 2022 +0200

    add InsertText and EraseText overloads that take SwPosition
    
    part of the process of hiding the internals of SwPosition
    
    Change-Id: I7affb1ee002869ea3ed8c7da0c79b1a3750e5c97
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139411
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/sw/inc/ndtxt.hxx b/sw/inc/ndtxt.hxx
index 8715f0e7e98e..ecd24ca55ba0 100644
--- a/sw/inc/ndtxt.hxx
+++ b/sw/inc/ndtxt.hxx
@@ -253,6 +253,9 @@ public:
     OUString InsertText( const OUString & rStr, const SwContentIndex & rIdx,
                      const SwInsertFlags nMode
                          = SwInsertFlags::DEFAULT );
+    OUString InsertText( const OUString & rStr, const SwPosition & rIdx,
+                     const SwInsertFlags nMode
+                         = SwInsertFlags::DEFAULT );
 
     /** delete text content
         ATTENTION: must not be called with a range that overlaps the start of
@@ -260,6 +263,8 @@ public:
      */
     void EraseText ( const SwContentIndex &rIdx, const sal_Int32 nCount = 
SAL_MAX_INT32,
                      const SwInsertFlags nMode = SwInsertFlags::DEFAULT );
+    void EraseText ( const SwPosition& rIdx, const sal_Int32 nCount = 
SAL_MAX_INT32,
+                     const SwInsertFlags nMode = SwInsertFlags::DEFAULT );
 
     /** delete all attributes.
         If neither pSet nor nWhich is given, delete all attributes (except
diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx 
b/sw/source/core/doc/DocumentContentOperationsManager.cxx
index 7aa04a808eaa..c642cde1c8c7 100644
--- a/sw/source/core/doc/DocumentContentOperationsManager.cxx
+++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx
@@ -2849,7 +2849,7 @@ bool DocumentContentOperationsManager::InsertString( 
const SwPaM &rRg, const OUS
 
     if (!bDoesUndo || !m_rDoc.GetIDocumentUndoRedo().DoesGroupUndo())
     {
-        OUString const ins(pNode->InsertText(rStr, rPos.nContent, 
nInsertMode));
+        OUString const ins(pNode->InsertText(rStr, rPos, nInsertMode));
         if (bDoesUndo)
         {
             m_rDoc.GetIDocumentUndoRedo().AppendUndo(
@@ -2883,7 +2883,7 @@ bool DocumentContentOperationsManager::InsertString( 
const SwPaM &rRg, const OUS
             m_rDoc.GetIDocumentUndoRedo().AppendUndo( 
std::unique_ptr<SwUndo>(pUndo) );
         }
 
-        OUString const ins(pNode->InsertText(rStr, rPos.nContent, 
nInsertMode));
+        OUString const ins(pNode->InsertText(rStr, rPos, nInsertMode));
 
         for (sal_Int32 i = 0; i < ins.getLength(); ++i)
         {
@@ -4371,7 +4371,7 @@ bool 
DocumentContentOperationsManager::DeleteRangeImplImpl(SwPaM & rPam, SwDelet
                 // Don't call again, if already empty
                 if( nLen )
                 {
-                    pStartTextNode->EraseText( pStt->nContent, nLen );
+                    pStartTextNode->EraseText( *pStt, nLen );
 
                     if( !pStartTextNode->Len() )
                     {
diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx
index 9efdf5628bb0..fc96ff692bc4 100644
--- a/sw/source/core/docnode/ndtbl.cxx
+++ b/sw/source/core/docnode/ndtbl.cxx
@@ -1078,7 +1078,7 @@ SwTableNode* SwNodes::TextToTable( const SwNodeRange& 
rRange, sal_Unicode cCh,
                         pTextNd->SplitContentNode(aCntPos, &restoreFunc);
 
                     // Delete separator and correct search string
-                    pTextNd->EraseText( aCntPos.nContent, 1 );
+                    pTextNd->EraseText( aCntPos, 1 );
                     nChPos = 0;
 
                     // Set the TableNode as StartNode for all TextNodes in the 
Table
diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx
index 27053fe2b99a..73804928508c 100644
--- a/sw/source/core/txtnode/ndtxt.cxx
+++ b/sw/source/core/txtnode/ndtxt.cxx
@@ -2313,6 +2313,12 @@ void SwTextNode::CopyText( SwTextNode *const pDest,
     CHECK_SWPHINTS(pDest);
 }
 
+OUString SwTextNode::InsertText( const OUString & rStr, const SwPosition & 
rIdx,
+        const SwInsertFlags nMode )
+{
+    return InsertText(rStr, rIdx.nContent, nMode);
+}
+
 OUString SwTextNode::InsertText( const OUString & rStr, const SwContentIndex & 
rIdx,
         const SwInsertFlags nMode )
 {
@@ -2709,6 +2715,12 @@ void SwTextNode::CutImpl( SwTextNode * const pDest, 
const SwContentIndex & rDest
     TryDeleteSwpHints();
 }
 
+void SwTextNode::EraseText(const SwPosition &rIdx, const sal_Int32 nCount,
+        const SwInsertFlags nMode )
+{
+    EraseText(rIdx.nContent, nCount, nMode);
+}
+
 void SwTextNode::EraseText(const SwContentIndex &rIdx, const sal_Int32 nCount,
         const SwInsertFlags nMode )
 {
diff --git a/sw/source/core/undo/undel.cxx b/sw/source/core/undo/undel.cxx
index fab3bb4bc323..0d62ed72a603 100644
--- a/sw/source/core/undo/undel.cxx
+++ b/sw/source/core/undo/undel.cxx
@@ -465,7 +465,7 @@ bool SwUndoDelete::SaveContent( const SwPosition* pStt, 
const SwPosition* pEnd,
         // delete now also the text (all attribute changes are added to
         // UNDO history)
         m_aSttStr = pSttTextNd->GetText().copy(m_nSttContent, nLen);
-        pSttTextNd->EraseText( pStt->nContent, nLen );
+        pSttTextNd->EraseText( *pStt, nLen );
         if( pSttTextNd->GetpSwpHints() )
             pSttTextNd->GetpSwpHints()->DeRegister();
 
@@ -594,7 +594,7 @@ bool SwUndoDelete::CanGrouping( SwDoc& rDoc, const SwPaM& 
rDelPam )
         nUChrPos++;
     }
     m_aSttStr = m_aSttStr->replaceAt( nUChrPos, 0, rtl::OUStringChar(cDelChar) 
);
-    pDelTextNd->EraseText( pStt->nContent, 1 );
+    pDelTextNd->EraseText( *pStt, 1 );
 
     m_bGroup = true;
     return true;
@@ -1018,7 +1018,7 @@ void SwUndoDelete::UndoImpl(::sw::UndoRedoContext & 
rContext)
                 //  -> in StartNode is still the rest of the Join => delete
                 aPos.nContent.Assign( pTextNd, m_nSttContent );
                 pTextNd->SetInSwUndo(true);
-                OUString const ins( pTextNd->InsertText(*m_aSttStr, 
aPos.nContent,
+                OUString const ins( pTextNd->InsertText(*m_aSttStr, aPos,
                         SwInsertFlags::NOHINTEXPAND) );
                 pTextNd->SetInSwUndo(false);
                 assert(ins.getLength() == m_aSttStr->getLength()); // must 
succeed
diff --git a/sw/source/core/undo/unins.cxx b/sw/source/core/undo/unins.cxx
index eef08382f53e..579d67883e4e 100644
--- a/sw/source/core/undo/unins.cxx
+++ b/sw/source/core/undo/unins.cxx
@@ -254,7 +254,7 @@ void SwUndoInsert::UndoImpl(::sw::UndoRedoContext & 
rContext)
                 }
                 RemoveIdxFromRange( aPaM, false );
                 maText = pTextNode->GetText().copy(m_nContent-m_nLen, m_nLen);
-                pTextNode->EraseText( aPaM.GetPoint()->nContent, m_nLen );
+                pTextNode->EraseText( *aPaM.GetPoint(), m_nLen );
             }
             else                // otherwise Graphics/OLE/Text/...
             {
@@ -329,7 +329,7 @@ void SwUndoInsert::RedoImpl(::sw::UndoRedoContext & 
rContext)
                 SwTextNode *const pTextNode = pCNd->GetTextNode();
                 OSL_ENSURE( pTextNode, "where is my textnode ?" );
                 OUString const ins(
-                    pTextNode->InsertText( *maText, pPam->GetMark()->nContent,
+                    pTextNode->InsertText( *maText, *pPam->GetMark(),
                     m_nInsertFlags) );
                 assert(ins.getLength() == maText->getLength()); // must succeed
                 maText.reset();
diff --git a/sw/source/core/undo/unovwr.cxx b/sw/source/core/undo/unovwr.cxx
index 64421faed72f..3f072fda262d 100644
--- a/sw/source/core/undo/unovwr.cxx
+++ b/sw/source/core/undo/unovwr.cxx
@@ -83,8 +83,7 @@ SwUndoOverwrite::SwUndoOverwrite( SwDoc& rDoc, SwPosition& 
rPos,
     bool bOldExpFlg = pTextNd->IsIgnoreDontExpand();
     pTextNd->SetIgnoreDontExpand( true );
 
-    pTextNd->InsertText( OUString(cIns), rPos.nContent,
-            SwInsertFlags::EMPTYEXPAND );
+    pTextNd->InsertText( OUString(cIns), rPos, SwInsertFlags::EMPTYEXPAND );
     m_aInsStr += OUStringChar( cIns );
 
     if( !m_bInsChar )
@@ -160,7 +159,7 @@ bool SwUndoOverwrite::CanGrouping( SwDoc& rDoc, SwPosition& 
rPos,
     bool bOldExpFlg = pDelTextNd->IsIgnoreDontExpand();
     pDelTextNd->SetIgnoreDontExpand( true );
 
-    OUString const ins( pDelTextNd->InsertText(OUString(cIns), rPos.nContent,
+    OUString const ins( pDelTextNd->InsertText(OUString(cIns), rPos,
             SwInsertFlags::EMPTYEXPAND) );
     assert(ins.getLength() == 1); // check in SwDoc::Overwrite => cannot fail
     (void) ins;

Reply via email to