sw/source/core/inc/UndoInsert.hxx |    2 +-
 sw/source/core/undo/unins.cxx     |   24 +++++++++++++-----------
 2 files changed, 14 insertions(+), 12 deletions(-)

New commits:
commit 0b574c7315b2ea6f1401502e0a8ae4f0c2a41457
Author: Michael Stahl <mst...@redhat.com>
Date:   Tue Feb 13 17:46:44 2018 +0100

    sw: replace DELETEZ with unique_ptr in SwUndoInsert
    
    Change-Id: I127eba390068ba241ff2b67e2bc99f3b907195db
    Reviewed-on: https://gerrit.libreoffice.org/49675
    Tested-by: Jenkins <c...@libreoffice.org>
    Reviewed-by: Michael Stahl <mst...@redhat.com>

diff --git a/sw/source/core/inc/UndoInsert.hxx 
b/sw/source/core/inc/UndoInsert.hxx
index 35a1a6b62c13..d16b2c07aa91 100644
--- a/sw/source/core/inc/UndoInsert.hxx
+++ b/sw/source/core/inc/UndoInsert.hxx
@@ -41,7 +41,7 @@ class SwUndoInsert: public SwUndo, private SwUndoSaveContent
 {
     /// start of Content in UndoNodes for Redo
     std::unique_ptr<SwNodeIndex> m_pUndoNodeIndex;
-    OUString *pText;
+    std::unique_ptr<OUString> m_pText;
     std::unique_ptr<OUString> pUndoText;
     SwRedlineData* pRedlData;
     sal_uLong nNode;
diff --git a/sw/source/core/undo/unins.cxx b/sw/source/core/undo/unins.cxx
index 23723aff8a69..af2f8c718a89 100644
--- a/sw/source/core/undo/unins.cxx
+++ b/sw/source/core/undo/unins.cxx
@@ -111,7 +111,7 @@ SwUndoInsert::SwUndoInsert( const SwNodeIndex& rNd, 
sal_Int32 nCnt,
             sal_Int32 nL,
             const SwInsertFlags nInsertFlags,
             bool bWDelim )
-    : SwUndo(SwUndoId::TYPING, rNd.GetNode().GetDoc()), pText( nullptr ), 
pRedlData( nullptr ),
+    : SwUndo(SwUndoId::TYPING, rNd.GetNode().GetDoc()), pRedlData( nullptr ),
         nNode( rNd.GetIndex() ), nContent(nCnt), nLen(nL),
         bIsWordDelim( bWDelim ), bIsAppend( false )
     , m_bWithRsid(false)
@@ -121,7 +121,7 @@ SwUndoInsert::SwUndoInsert( const SwNodeIndex& rNd, 
sal_Int32 nCnt,
 }
 
 SwUndoInsert::SwUndoInsert( const SwNodeIndex& rNd )
-    : SwUndo(SwUndoId::SPLITNODE, rNd.GetNode().GetDoc()), pText( nullptr ),
+    : SwUndo(SwUndoId::SPLITNODE, rNd.GetNode().GetDoc()),
         pRedlData( nullptr ), nNode( rNd.GetIndex() ), nContent(0), nLen(1),
         bIsWordDelim( false ), bIsAppend( true )
     , m_bWithRsid(false)
@@ -202,7 +202,9 @@ SwUndoInsert::~SwUndoInsert()
         m_pUndoNodeIndex.reset();
     }
     else     // the inserted text
-        delete pText;
+    {
+        m_pText.reset();
+    }
     delete pRedlData;
 }
 
@@ -258,7 +260,7 @@ void SwUndoInsert::UndoImpl(::sw::UndoRedoContext & 
rContext)
                         aPaM.GetMark()->nContent.GetIndex());
                 }
                 RemoveIdxFromRange( aPaM, false );
-                pText = new OUString( pTextNode->GetText().copy(nContent-nLen, 
nLen) );
+                m_pText.reset(new 
OUString(pTextNode->GetText().copy(nContent-nLen, nLen)));
                 pTextNode->EraseText( aPaM.GetPoint()->nContent, nLen );
             }
             else                // otherwise Graphics/OLE/Text/...
@@ -272,7 +274,7 @@ void SwUndoInsert::UndoImpl(::sw::UndoRedoContext & 
rContext)
             nNd = aPaM.GetPoint()->nNode.GetIndex();
             nCnt = aPaM.GetPoint()->nContent.GetIndex();
 
-            if( !pText )
+            if (!m_pText)
             {
                 m_pUndoNodeIndex.reset(
                         new SwNodeIndex(pDoc->GetNodes().GetEndOfContent()));
@@ -332,15 +334,15 @@ void SwUndoInsert::RedoImpl(::sw::UndoRedoContext & 
rContext)
         {
             const bool bMvBkwrd = MovePtBackward( *pPam );
 
-            if( pText )
+            if (m_pText)
             {
                 SwTextNode *const pTextNode = pCNd->GetTextNode();
                 OSL_ENSURE( pTextNode, "where is my textnode ?" );
                 OUString const ins(
-                    pTextNode->InsertText( *pText, pPam->GetMark()->nContent,
+                    pTextNode->InsertText( *m_pText, pPam->GetMark()->nContent,
                     m_nInsertFlags) );
-                assert(ins.getLength() == pText->getLength()); // must succeed
-                DELETEZ( pText );
+                assert(ins.getLength() == m_pText->getLength()); // must 
succeed
+                m_pText.reset();
                 if (m_bWithRsid) // re-insert RSID
                 {
                     SwPaM pam(*pPam->GetMark(), nullptr); // mark -> point
@@ -459,8 +461,8 @@ SwRewriter SwUndoInsert::GetRewriter() const
     OUString * pStr = nullptr;
     bool bDone = false;
 
-    if (pText)
-        pStr = pText;
+    if (m_pText)
+        pStr = m_pText.get();
     else if (pUndoText)
         pStr = pUndoText.get();
 
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to