sc/qa/unit/ucalc.cxx              |    8 ++++----
 sc/source/ui/docshell/docfunc.cxx |   25 +++++++++----------------
 sc/source/ui/docshell/impex.cxx   |    1 +
 sc/source/ui/inc/undobase.hxx     |    2 +-
 sc/source/ui/inc/undoblk.hxx      |    8 ++++----
 sc/source/ui/inc/undodat.hxx      |    2 +-
 sc/source/ui/inc/undotab.hxx      |    2 +-
 sc/source/ui/undo/undobase.cxx    |    4 ++--
 sc/source/ui/undo/undoblk.cxx     |   16 ++++++++--------
 sc/source/ui/undo/undodat.cxx     |    4 ++--
 sc/source/ui/undo/undotab.cxx     |    5 +++--
 sc/source/ui/unoobj/cellsuno.cxx  |    1 +
 sc/source/ui/view/viewfun2.cxx    |   10 +++-------
 sc/source/ui/view/viewfun3.cxx    |   10 +++++-----
 sc/source/ui/view/viewfun4.cxx    |    1 +
 sc/source/ui/view/viewfunc.cxx    |    6 +++---
 16 files changed, 49 insertions(+), 56 deletions(-)

New commits:
commit 1f9f35177aca7000edd0ec5e68e4045e04cce535
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Thu Aug 30 09:47:24 2018 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Thu Aug 30 12:53:56 2018 +0200

    pass ScRefUndoData around by std::unique_ptr
    
    Change-Id: I317a0c7665f4c146fc34bcffdae8835cf674ff61
    Reviewed-on: https://gerrit.libreoffice.org/59787
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 791b25ab85b2..193522887b8b 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -3748,8 +3748,8 @@ void Test::testCopyPasteSkipEmpty()
     m_pDoc->CopyToDocument(aDestRange, InsertDeleteFlags::ALL, false, 
*pRedoDoc, &aMark);
 
     // Create an undo object for this.
-    ScRefUndoData* pRefUndoData = new ScRefUndoData(m_pDoc);
-    ScUndoPaste aUndo(&getDocShell(), aDestRange, aMark, std::move(pUndoDoc), 
std::move(pRedoDoc), InsertDeleteFlags::ALL, pRefUndoData);
+    std::unique_ptr<ScRefUndoData> pRefUndoData(new ScRefUndoData(m_pDoc));
+    ScUndoPaste aUndo(&getDocShell(), aDestRange, aMark, std::move(pUndoDoc), 
std::move(pRedoDoc), InsertDeleteFlags::ALL, std::move(pRefUndoData));
 
     // Check the content after the paste.
     {
@@ -6741,10 +6741,10 @@ ScUndoPaste* Test::createUndoPaste(ScDocShell& rDocSh, 
const ScRange& rRange, Sc
     ScDocument& rDoc = rDocSh.GetDocument();
     ScMarkData aMarkData;
     aMarkData.SetMarkArea(rRange);
-    ScRefUndoData* pRefUndoData = new ScRefUndoData(&rDoc);
+    std::unique_ptr<ScRefUndoData> pRefUndoData(new ScRefUndoData(&rDoc));
 
     return new ScUndoPaste(
-        &rDocSh, rRange, aMarkData, std::move(pUndoDoc), nullptr, 
InsertDeleteFlags::ALL, pRefUndoData, false);
+        &rDocSh, rRange, aMarkData, std::move(pUndoDoc), nullptr, 
InsertDeleteFlags::ALL, std::move(pRefUndoData), false);
 }
 
 void Test::setExpandRefs(bool bExpand)
diff --git a/sc/source/ui/docshell/docfunc.cxx 
b/sc/source/ui/docshell/docfunc.cxx
index f995de081037..a49e78d89f65 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -1799,7 +1799,7 @@ bool ScDocFunc::InsertCells( const ScRange& rRange, const 
ScMarkData* pTabMark,
     WaitObject aWait( ScDocShell::GetActiveDialogParent() );      // important 
due to TrackFormulas at UpdateReference
 
     ScDocumentUniquePtr pRefUndoDoc;
-    ScRefUndoData* pUndoData = nullptr;
+    std::unique_ptr<ScRefUndoData> pUndoData;
     if ( bRecord )
     {
         pRefUndoDoc.reset(new ScDocument( SCDOCMODE_UNDO ));
@@ -1807,7 +1807,7 @@ bool ScDocFunc::InsertCells( const ScRange& rRange, const 
ScMarkData* pTabMark,
 
         // pRefUndoDoc is filled in InsertCol / InsertRow
 
-        pUndoData = new ScRefUndoData( &rDoc );
+        pUndoData.reset(new ScRefUndoData( &rDoc ));
 
         rDoc.BeginDrawUndo();
     }
@@ -1849,7 +1849,6 @@ bool ScDocFunc::InsertCells( const ScRange& rRange, const 
ScMarkData* pTabMark,
                 if (!bApi)
                     rDocShell.ErrorMessage(STR_MSSG_INSERTCELLS_0);
                 rDocShell.GetUndoManager()->LeaveListAction();
-                delete pUndoData;
                 return false;
             }
 
@@ -1954,7 +1953,6 @@ bool ScDocFunc::InsertCells( const ScRange& rRange, const 
ScMarkData* pTabMark,
                 if (!bApi)
                     rDocShell.ErrorMessage(STR_MSSG_INSERTCELLS_0);
                 rDocShell.GetUndoManager()->LeaveListAction();
-                delete pUndoData;
                 return false;
             }
         }
@@ -2025,7 +2023,7 @@ bool ScDocFunc::InsertCells( const ScRange& rRange, const 
ScMarkData* pTabMark,
 
             rDocShell.GetUndoManager()->AddUndoAction( new ScUndoInsertCells(
                 &rDocShell, ScRange( nStartCol, nStartRow, nStartTab, nEndCol, 
nEndRow, nEndTab ),
-                nUndoPos, pTabs, pScenarios, eCmd, std::move(pRefUndoDoc), 
pUndoData, bPartOfPaste ) );
+                nUndoPos, pTabs, pScenarios, eCmd, std::move(pRefUndoDoc), 
std::move(pUndoData), bPartOfPaste ) );
         }
 
         // #i8302 : we remerge growing ranges, with the new part inserted
@@ -2122,7 +2120,6 @@ bool ScDocFunc::InsertCells( const ScRange& rRange, const 
ScMarkData* pTabMark,
         rDocShell.GetUndoManager()->RemoveLastUndoAction();
 
         pRefUndoDoc.reset();
-        delete pUndoData;
         if (!bApi)
             rDocShell.ErrorMessage(STR_INSERT_FULL);        // column/row full
     }
@@ -2453,7 +2450,7 @@ bool ScDocFunc::DeleteCells( const ScRange& rRange, const 
ScMarkData* pTabMark,
 
     ScDocumentUniquePtr pUndoDoc;
     ScDocument* pRefUndoDoc = nullptr;
-    ScRefUndoData* pUndoData = nullptr;
+    std::unique_ptr<ScRefUndoData> pUndoData;
     if ( bRecord )
     {
         // With the fix for #101329#, UpdateRef always puts cells into 
pRefUndoDoc at their old position,
@@ -2476,7 +2473,7 @@ bool ScDocFunc::DeleteCells( const ScRange& rRange, const 
ScMarkData* pTabMark,
         pRefUndoDoc = new ScDocument( SCDOCMODE_UNDO );
         pRefUndoDoc->InitUndo( &rDoc, 0, nTabCount-1 );
 
-        pUndoData = new ScRefUndoData( &rDoc );
+        pUndoData.reset(new ScRefUndoData( &rDoc ));
 
         rDoc.BeginDrawUndo();
     }
@@ -2558,7 +2555,7 @@ bool ScDocFunc::DeleteCells( const ScRange& rRange, const 
ScMarkData* pTabMark,
 
         rDocShell.GetUndoManager()->AddUndoAction( new ScUndoDeleteCells(
             &rDocShell, ScRange( nStartCol, nStartRow, nStartTab, nEndCol, 
nEndRow, nEndTab ),nUndoPos, pTabs, pScenarios,
-            eCmd, std::move(pUndoDoc), pUndoData ) );
+            eCmd, std::move(pUndoDoc), std::move(pUndoData) ) );
     }
 
     // #i8302 want to be able to insert into the middle of merged cells
@@ -3181,7 +3178,7 @@ bool ScDocFunc::DeleteTable( SCTAB nTab, bool bRecord )
         bRecord = false;
     bool bWasLinked = rDoc.IsLinked(nTab);
     ScDocumentUniquePtr pUndoDoc;
-    ScRefUndoData* pUndoData = nullptr;
+    std::unique_ptr<ScRefUndoData> pUndoData;
     if (bRecord)
     {
         pUndoDoc.reset(new ScDocument( SCDOCMODE_UNDO ));
@@ -3219,7 +3216,7 @@ bool ScDocFunc::DeleteTable( SCTAB nTab, bool bRecord )
         //  Drawing-Layer has to take care of its own undo!!!
         rDoc.BeginDrawUndo();                          //  DeleteTab generates 
SdrUndoDelPage
 
-        pUndoData = new ScRefUndoData( &rDoc );
+        pUndoData.reset(new ScRefUndoData( &rDoc ));
     }
 
     if (rDoc.DeleteTab(nTab))
@@ -3229,7 +3226,7 @@ bool ScDocFunc::DeleteTable( SCTAB nTab, bool bRecord )
             vector<SCTAB> theTabs;
             theTabs.push_back(nTab);
             rDocShell.GetUndoManager()->AddUndoAction(
-                        new ScUndoDeleteTab( &rDocShell, theTabs, 
std::move(pUndoDoc), pUndoData ));
+                        new ScUndoDeleteTab( &rDocShell, theTabs, 
std::move(pUndoDoc), std::move(pUndoData) ));
         }
         //  Update views:
         if( bVbaEnabled )
@@ -3260,10 +3257,6 @@ bool ScDocFunc::DeleteTable( SCTAB nTab, bool bRecord )
 
         bSuccess = true;
     }
-    else
-    {
-        delete pUndoData;
-    }
     return bSuccess;
 }
 
diff --git a/sc/source/ui/docshell/impex.cxx b/sc/source/ui/docshell/impex.cxx
index 8a36dded1fe2..e30139cf11b9 100644
--- a/sc/source/ui/docshell/impex.cxx
+++ b/sc/source/ui/docshell/impex.cxx
@@ -52,6 +52,7 @@
 #include <cellvalue.hxx>
 #include <tokenarray.hxx>
 #include <documentimport.hxx>
+#include <refundo.hxx>
 
 #include <globstr.hrc>
 #include <scresid.hxx>
diff --git a/sc/source/ui/inc/undobase.hxx b/sc/source/ui/inc/undobase.hxx
index 86da282b3f8b..5c33cbf9800a 100644
--- a/sc/source/ui/inc/undobase.hxx
+++ b/sc/source/ui/inc/undobase.hxx
@@ -142,7 +142,7 @@ class ScMoveUndo: public ScSimpleUndo               // with 
references
 {
 public:
                     ScMoveUndo( ScDocShell* pDocSh,
-                                ScDocumentUniquePtr pRefDoc, ScRefUndoData* 
pRefData,
+                                ScDocumentUniquePtr pRefDoc, 
std::unique_ptr<ScRefUndoData> pRefData,
                                 ScMoveUndoMode eRefMode );
     virtual         ~ScMoveUndo() override;
 
diff --git a/sc/source/ui/inc/undoblk.hxx b/sc/source/ui/inc/undoblk.hxx
index c0c5963c97d8..399c7efde0e0 100644
--- a/sc/source/ui/inc/undoblk.hxx
+++ b/sc/source/ui/inc/undoblk.hxx
@@ -44,7 +44,7 @@ class ScUndoInsertCells: public ScMoveUndo
 public:
                     ScUndoInsertCells( ScDocShell* pNewDocShell,
                                        const ScRange& rRange, SCTAB nNewCount, 
SCTAB* pNewTabs, SCTAB* pNewScenarios,
-                                       InsCellCmd eNewCmd, ScDocumentUniquePtr 
pUndoDocument, ScRefUndoData* pRefData,
+                                       InsCellCmd eNewCmd, ScDocumentUniquePtr 
pUndoDocument, std::unique_ptr<ScRefUndoData> pRefData,
                                        bool bNewPartOfPaste );
     virtual         ~ScUndoInsertCells() override;
 
@@ -79,7 +79,7 @@ class ScUndoDeleteCells: public ScMoveUndo
 public:
                     ScUndoDeleteCells( ScDocShell* pNewDocShell,
                                        const ScRange& rRange, SCTAB nNewCount, 
SCTAB* pNewTabs, SCTAB* pNewScenarios,
-                                       DelCellCmd eNewCmd, ScDocumentUniquePtr 
pUndoDocument, ScRefUndoData* pRefData );
+                                       DelCellCmd eNewCmd, ScDocumentUniquePtr 
pUndoDocument, std::unique_ptr<ScRefUndoData> pRefData );
     virtual         ~ScUndoDeleteCells() override;
 
     virtual void    Undo() override;
@@ -111,7 +111,7 @@ public:
     ScUndoDeleteMulti( ScDocShell* pNewDocShell,
                        bool bNewRows, bool bNeedsRefresh, SCTAB nNewTab,
                        const std::vector<sc::ColRowSpan>& rSpans,
-                       ScDocumentUniquePtr pUndoDocument, ScRefUndoData* 
pRefData );
+                       ScDocumentUniquePtr pUndoDocument, 
std::unique_ptr<ScRefUndoData> pRefData );
 
     virtual         ~ScUndoDeleteMulti() override;
 
@@ -187,7 +187,7 @@ public:
                 const ScMarkData& rMark,
                 ScDocumentUniquePtr pNewUndoDoc, ScDocumentUniquePtr 
pNewRedoDoc,
                 InsertDeleteFlags nNewFlags,
-                ScRefUndoData* pRefData,
+                std::unique_ptr<ScRefUndoData> pRefData,
                 bool bRedoIsFilled = true,
                 const ScUndoPasteOptions* pOptions = nullptr);
     virtual ~ScUndoPaste() override;
diff --git a/sc/source/ui/inc/undodat.hxx b/sc/source/ui/inc/undodat.hxx
index 77d51e356825..edb6599f6319 100644
--- a/sc/source/ui/inc/undodat.hxx
+++ b/sc/source/ui/inc/undodat.hxx
@@ -431,7 +431,7 @@ public:
                    SCCOL nEndX, SCROW nEndY, SCTAB nEndZ,
                    const ScMarkData& rMark,
                    ScDocument* pNewUndoDoc, ScDocument* pNewRedoDoc,
-                   ScRefUndoData* pRefData);
+                   std::unique_ptr<ScRefUndoData> pRefData);
     virtual void    Undo() override;
     virtual void    Redo() override;
     virtual void    Repeat(SfxRepeatTarget& rTarget) override;
diff --git a/sc/source/ui/inc/undotab.hxx b/sc/source/ui/inc/undotab.hxx
index 8471814c03bd..468e70d84c1d 100644
--- a/sc/source/ui/inc/undotab.hxx
+++ b/sc/source/ui/inc/undotab.hxx
@@ -98,7 +98,7 @@ public:
                             ScDocShell* pNewDocShell,
                             const std::vector<SCTAB> &theTabs,      //SCTAB 
nNewTab,
                             ScDocumentUniquePtr pUndoDocument,
-                            ScRefUndoData* pRefData );
+                            std::unique_ptr<ScRefUndoData> pRefData );
     virtual         ~ScUndoDeleteTab() override;
 
     virtual void    Undo() override;
diff --git a/sc/source/ui/undo/undobase.cxx b/sc/source/ui/undo/undobase.cxx
index 7285d48af446..4d041ac4ad5b 100644
--- a/sc/source/ui/undo/undobase.cxx
+++ b/sc/source/ui/undo/undobase.cxx
@@ -406,11 +406,11 @@ void ScMultiBlockUndo::ShowBlock()
     }
 }
 
-ScMoveUndo::ScMoveUndo( ScDocShell* pDocSh, ScDocumentUniquePtr pRefDoc, 
ScRefUndoData* pRefData,
+ScMoveUndo::ScMoveUndo( ScDocShell* pDocSh, ScDocumentUniquePtr pRefDoc, 
std::unique_ptr<ScRefUndoData> pRefData,
                                                 ScMoveUndoMode eRefMode ) :
     ScSimpleUndo( pDocSh ),
     pRefUndoDoc( std::move(pRefDoc) ),
-    pRefUndoData( pRefData ),
+    pRefUndoData( std::move(pRefData) ),
     eMode( eRefMode )
 {
     ScDocument& rDoc = pDocShell->GetDocument();
diff --git a/sc/source/ui/undo/undoblk.cxx b/sc/source/ui/undo/undoblk.cxx
index 480c04d8e2ea..1826896cf3fa 100644
--- a/sc/source/ui/undo/undoblk.cxx
+++ b/sc/source/ui/undo/undoblk.cxx
@@ -69,9 +69,9 @@
 
 ScUndoInsertCells::ScUndoInsertCells( ScDocShell* pNewDocShell,
                                 const ScRange& rRange, SCTAB nNewCount, SCTAB* 
pNewTabs, SCTAB* pNewScenarios,
-                                InsCellCmd eNewCmd, ScDocumentUniquePtr 
pUndoDocument, ScRefUndoData* pRefData,
+                                InsCellCmd eNewCmd, ScDocumentUniquePtr 
pUndoDocument, std::unique_ptr<ScRefUndoData> pRefData,
                                 bool bNewPartOfPaste ) :
-    ScMoveUndo( pNewDocShell, std::move(pUndoDocument), pRefData, 
SC_UNDO_REFLAST ),
+    ScMoveUndo( pNewDocShell, std::move(pUndoDocument), std::move(pRefData), 
SC_UNDO_REFLAST ),
     aEffRange( rRange ),
     nCount( nNewCount ),
     pTabs( pNewTabs ),
@@ -338,8 +338,8 @@ bool ScUndoInsertCells::CanRepeat(SfxRepeatTarget& rTarget) 
const
 
 ScUndoDeleteCells::ScUndoDeleteCells( ScDocShell* pNewDocShell,
                                 const ScRange& rRange, SCTAB nNewCount, SCTAB* 
pNewTabs, SCTAB* pNewScenarios,
-                                DelCellCmd eNewCmd, ScDocumentUniquePtr 
pUndoDocument, ScRefUndoData* pRefData ) :
-    ScMoveUndo( pNewDocShell, std::move(pUndoDocument), pRefData, 
SC_UNDO_REFLAST ),
+                                DelCellCmd eNewCmd, ScDocumentUniquePtr 
pUndoDocument, std::unique_ptr<ScRefUndoData> pRefData ) :
+    ScMoveUndo( pNewDocShell, std::move(pUndoDocument), std::move(pRefData), 
SC_UNDO_REFLAST ),
     aEffRange( rRange ),
     nCount( nNewCount ),
     pTabs( pNewTabs ),
@@ -623,8 +623,8 @@ ScUndoDeleteMulti::ScUndoDeleteMulti(
     ScDocShell* pNewDocShell,
     bool bNewRows, bool bNeedsRefresh, SCTAB nNewTab,
     const std::vector<sc::ColRowSpan>& rSpans,
-    ScDocumentUniquePtr pUndoDocument, ScRefUndoData* pRefData ) :
-    ScMoveUndo( pNewDocShell, std::move(pUndoDocument), pRefData, 
SC_UNDO_REFLAST ),
+    ScDocumentUniquePtr pUndoDocument, std::unique_ptr<ScRefUndoData> pRefData 
) :
+    ScMoveUndo( pNewDocShell, std::move(pUndoDocument), std::move(pRefData), 
SC_UNDO_REFLAST ),
     mbRows(bNewRows),
     mbRefresh(bNeedsRefresh),
     nTab( nNewTab ),
@@ -901,14 +901,14 @@ ScUndoPaste::ScUndoPaste( ScDocShell* pNewDocShell, const 
ScRangeList& rRanges,
                 const ScMarkData& rMark,
                 ScDocumentUniquePtr pNewUndoDoc, ScDocumentUniquePtr 
pNewRedoDoc,
                 InsertDeleteFlags nNewFlags,
-                ScRefUndoData* pRefData,
+                std::unique_ptr<ScRefUndoData> pRefData,
                 bool bRedoIsFilled, const ScUndoPasteOptions* pOptions ) :
     ScMultiBlockUndo( pNewDocShell, rRanges ),
     aMarkData( rMark ),
     pUndoDoc( std::move(pNewUndoDoc) ),
     pRedoDoc( std::move(pNewRedoDoc) ),
     nFlags( nNewFlags ),
-    pRefUndoData( pRefData ),
+    pRefUndoData( std::move(pRefData) ),
     pRefRedoData( nullptr ),
     bRedoFilled( bRedoIsFilled )
 {
diff --git a/sc/source/ui/undo/undodat.cxx b/sc/source/ui/undo/undodat.cxx
index d0dec03b7fd8..9f2a204e6b5b 100644
--- a/sc/source/ui/undo/undodat.cxx
+++ b/sc/source/ui/undo/undodat.cxx
@@ -1733,12 +1733,12 @@ ScUndoDataForm::ScUndoDataForm( ScDocShell* 
pNewDocShell,
                                 SCCOL nEndX, SCROW nEndY, SCTAB nEndZ,
                                 const ScMarkData& rMark,
                                 ScDocument* pNewUndoDoc, ScDocument* 
pNewRedoDoc,
-                                ScRefUndoData* pRefData )
+                                std::unique_ptr<ScRefUndoData> pRefData )
     : ScBlockUndo(pNewDocShell, ScRange( nStartX, nStartY, nStartZ, nEndX, 
nEndY, nEndZ ), SC_UNDO_SIMPLE)
     , mxMarkData(new ScMarkData(rMark))
     , xUndoDoc(pNewUndoDoc)
     , xRedoDoc(pNewRedoDoc)
-    , xRefUndoData(pRefData)
+    , xRefUndoData(std::move(pRefData))
     , bRedoFilled(false)
 {
     //      pFill1,pFill2,pFill3 are there so the ctor calls for simple paste 
(without cutting)
diff --git a/sc/source/ui/undo/undotab.cxx b/sc/source/ui/undo/undotab.cxx
index 689eb309ceb1..bec64334f973 100644
--- a/sc/source/ui/undo/undotab.cxx
+++ b/sc/source/ui/undo/undotab.cxx
@@ -40,6 +40,7 @@
 #include <viewdata.hxx>
 #include <progress.hxx>
 #include <markdata.hxx>
+#include <refundo.hxx>
 
 // for ScUndoRenameObject - might me moved to another file later
 #include <svx/svditer.hxx>
@@ -247,8 +248,8 @@ bool ScUndoInsertTables::CanRepeat(SfxRepeatTarget& 
rTarget) const
 }
 
 ScUndoDeleteTab::ScUndoDeleteTab( ScDocShell* pNewDocShell, const 
vector<SCTAB> &aTab,
-                                    ScDocumentUniquePtr pUndoDocument, 
ScRefUndoData* pRefData ) :
-    ScMoveUndo( pNewDocShell, std::move(pUndoDocument), pRefData, 
SC_UNDO_REFLAST )
+                                    ScDocumentUniquePtr pUndoDocument, 
std::unique_ptr<ScRefUndoData> pRefData ) :
+    ScMoveUndo( pNewDocShell, std::move(pUndoDocument), std::move(pRefData), 
SC_UNDO_REFLAST )
 {
     theTabs.insert(theTabs.end(), aTab.begin(), aTab.end() );
     SetChangeTrack();
diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx
index 4d31248c34e9..40386f297348 100644
--- a/sc/source/ui/unoobj/cellsuno.cxx
+++ b/sc/source/ui/unoobj/cellsuno.cxx
@@ -134,6 +134,7 @@
 #include <condformatuno.hxx>
 #include <TablePivotCharts.hxx>
 #include <table.hxx>
+#include <refundo.hxx>
 
 #include <list>
 #include <memory>
diff --git a/sc/source/ui/view/viewfun2.cxx b/sc/source/ui/view/viewfun2.cxx
index 3f343b6d69e3..94b01f2f420b 100644
--- a/sc/source/ui/view/viewfun2.cxx
+++ b/sc/source/ui/view/viewfun2.cxx
@@ -2331,7 +2331,7 @@ bool ScViewFunc::DeleteTables(const vector<SCTAB> 
&TheTabs, bool bRecord )
 
     bool bWasLinked = false;
     ScDocumentUniquePtr pUndoDoc;
-    ScRefUndoData* pUndoData = nullptr;
+    std::unique_ptr<ScRefUndoData> pUndoData;
     if (bRecord)
     {
         pUndoDoc.reset(new ScDocument( SCDOCMODE_UNDO ));
@@ -2385,7 +2385,7 @@ bool ScViewFunc::DeleteTables(const vector<SCTAB> 
&TheTabs, bool bRecord )
 
         rDoc.BeginDrawUndo();                          //  DeleteTab creates a 
SdrUndoDelPage
 
-        pUndoData = new ScRefUndoData( &rDoc );
+        pUndoData.reset(new ScRefUndoData( &rDoc ));
     }
 
     bool bDelDone = false;
@@ -2411,7 +2411,7 @@ bool ScViewFunc::DeleteTables(const vector<SCTAB> 
&TheTabs, bool bRecord )
     {
         pDocSh->GetUndoManager()->AddUndoAction(
                     new ScUndoDeleteTab( GetViewData().GetDocShell(), TheTabs,
-                                            std::move(pUndoDoc), pUndoData ));
+                                            std::move(pUndoDoc), 
std::move(pUndoData) ));
     }
 
     if (bDelDone)
@@ -2435,10 +2435,6 @@ bool ScViewFunc::DeleteTables(const vector<SCTAB> 
&TheTabs, bool bRecord )
         pSfxApp->Broadcast( SfxHint( SfxHintId::ScDbAreasChanged ) );
         pSfxApp->Broadcast( SfxHint( SfxHintId::ScAreaLinksChanged ) );
     }
-    else
-    {
-        delete pUndoData;
-    }
     return bDelDone;
 }
 
diff --git a/sc/source/ui/view/viewfun3.cxx b/sc/source/ui/view/viewfun3.cxx
index 0453c0c0bd85..c633df4e82ee 100644
--- a/sc/source/ui/view/viewfun3.cxx
+++ b/sc/source/ui/view/viewfun3.cxx
@@ -1243,7 +1243,7 @@ bool ScViewFunc::PasteFromClip( InsertDeleteFlags nFlags, 
ScDocument* pClipDoc,
 
     ScDocumentUniquePtr pUndoDoc;
     ScDocument* pRefUndoDoc = nullptr;
-    ScRefUndoData* pUndoData = nullptr;
+    std::unique_ptr<ScRefUndoData> pUndoData;
 
     if ( bRecord )
     {
@@ -1260,7 +1260,7 @@ bool ScViewFunc::PasteFromClip( InsertDeleteFlags nFlags, 
ScDocument* pClipDoc,
             pRefUndoDoc = new ScDocument( SCDOCMODE_UNDO );
             pRefUndoDoc->InitUndo( pDoc, 0, nTabCount-1 );
 
-            pUndoData = new ScRefUndoData( pDoc );
+            pUndoData.reset(new ScRefUndoData( pDoc ));
         }
     }
 
@@ -1413,7 +1413,7 @@ bool ScViewFunc::PasteFromClip( InsertDeleteFlags nFlags, 
ScDocument* pClipDoc,
 
         SfxUndoAction* pUndo = new ScUndoPaste(
             pDocSh, ScRange(nStartCol, nStartRow, nStartTab, nUndoEndCol, 
nUndoEndRow, nEndTab),
-            aFilteredMark, std::move(pUndoDoc), std::move(pRedoDoc), nFlags | 
nUndoFlags, pUndoData,
+            aFilteredMark, std::move(pUndoDoc), std::move(pRedoDoc), nFlags | 
nUndoFlags, std::move(pUndoData),
             false, &aOptions );     // false = Redo data not yet copied
 
         if ( bInsertCells )
@@ -1959,7 +1959,7 @@ void ScViewFunc::DataFormPutData( SCROW nCurrentRow ,
         const bool bRecord( pDoc->IsUndoEnabled());
         ScDocument* pUndoDoc = nullptr;
         ScDocument* pRedoDoc = nullptr;
-        ScRefUndoData* pUndoData = nullptr;
+        std::unique_ptr<ScRefUndoData> pUndoData;
         SCTAB nTab = GetViewData().GetTabNo();
         SCTAB nStartTab = nTab;
         SCTAB nEndTab = nTab;
@@ -1998,7 +1998,7 @@ void ScViewFunc::DataFormPutData( SCROW nCurrentRow ,
                                                    nStartCol, nCurrentRow, 
nStartTab,
                                                    nUndoEndCol, nUndoEndRow, 
nEndTab, rMark,
                                                    pUndoDoc, pRedoDoc,
-                                                   pUndoData );
+                                                   std::move(pUndoData) );
         pUndoMgr->AddUndoAction( new ScUndoWrapper( pUndo ), true );
 
         PaintPartFlags nPaint = PaintPartFlags::Grid;
diff --git a/sc/source/ui/view/viewfun4.cxx b/sc/source/ui/view/viewfun4.cxx
index df21a4940e50..daa553c1d204 100644
--- a/sc/source/ui/view/viewfun4.cxx
+++ b/sc/source/ui/view/viewfun4.cxx
@@ -70,6 +70,7 @@
 #include <tokenarray.hxx>
 #include <refupdatecontext.hxx>
 #include <gridwin.hxx>
+#include <refundo.hxx>
 
 using namespace com::sun::star;
 
diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx
index 7ba426a61828..7aa6fc9a65d9 100644
--- a/sc/source/ui/view/viewfunc.cxx
+++ b/sc/source/ui/view/viewfunc.cxx
@@ -1821,7 +1821,7 @@ void ScViewFunc::DeleteMulti( bool bRows )
     WaitObject aWait( GetFrameWin() );      // important for TrackFormulas in 
UpdateReference
 
     ScDocumentUniquePtr pUndoDoc;
-    ScRefUndoData* pUndoData = nullptr;
+    std::unique_ptr<ScRefUndoData> pUndoData;
     if (bRecord)
     {
         pUndoDoc.reset(new ScDocument( SCDOCMODE_UNDO ));
@@ -1844,7 +1844,7 @@ void ScViewFunc::DeleteMulti( bool bRows )
         pUndoDoc->AddUndoTab( 0, nTabCount-1 );
         rDoc.CopyToDocument( 0,0,0, MAXCOL,MAXROW,MAXTAB, 
InsertDeleteFlags::FORMULA,false,*pUndoDoc );
 
-        pUndoData = new ScRefUndoData( &rDoc );
+        pUndoData.reset(new ScRefUndoData( &rDoc ));
 
         rDoc.BeginDrawUndo();
     }
@@ -1877,7 +1877,7 @@ void ScViewFunc::DeleteMulti( bool bRows )
     {
         pDocSh->GetUndoManager()->AddUndoAction(
             new ScUndoDeleteMulti(
-                pDocSh, bRows, bNeedRefresh, nTab, aSpans, 
std::move(pUndoDoc), pUndoData));
+                pDocSh, bRows, bNeedRefresh, nTab, aSpans, 
std::move(pUndoDoc), std::move(pUndoData)));
     }
 
     if (!AdjustRowHeight(0, MAXROW))
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to