[Libreoffice-commits] core.git: sw/inc sw/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Thu Jul 19 09:57:48 UTC 2018
sw/inc/swtable.hxx | 2 +-
sw/source/core/docnode/ndtbl.cxx | 4 ++--
sw/source/core/inc/UndoTable.hxx | 10 +++++-----
sw/source/core/table/swnewtable.cxx | 12 ++++--------
sw/source/core/undo/untbl.cxx | 18 +++++++++---------
5 files changed, 21 insertions(+), 25 deletions(-)
New commits:
commit 8ee6e15080cd98c654e213d70f0b169ad541c56e
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Wed Jul 18 15:50:12 2018 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Thu Jul 19 11:57:22 2018 +0200
loplugin:useuniqueptr in SwUndoSplitTable
Change-Id: I364d57e30a3b8470d1b4739096f13248e1389a08
Reviewed-on: https://gerrit.libreoffice.org/57694
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/sw/inc/swtable.hxx b/sw/inc/swtable.hxx
index 4dc1e6831a1c..eea1f64fa53a 100644
--- a/sw/inc/swtable.hxx
+++ b/sw/inc/swtable.hxx
@@ -217,7 +217,7 @@ public:
// SwSavRowSpan is the structure needed by Undo to undo the split operation
// CleanUpRowSpan corrects the (top of the) second table and delivers the structure
// for Undo
- SwSaveRowSpan* CleanUpTopRowSpan( sal_uInt16 nSplitLine );
+ std::unique_ptr<SwSaveRowSpan> CleanUpTopRowSpan( sal_uInt16 nSplitLine );
// RestoreRowSpan is called by Undo to restore the old row span values
void RestoreRowSpan( const SwSaveRowSpan& );
// CleanUpBottomRowSpan corrects the overhanging row spans at the end of the first table
diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx
index d0e177b48548..936db89cd7e9 100644
--- a/sw/source/core/docnode/ndtbl.cxx
+++ b/sw/source/core/docnode/ndtbl.cxx
@@ -3134,12 +3134,12 @@ bool SwDoc::SplitTable( const SwPosition& rPos, SplitTable_HeadlineOption eHdlnM
if( pNew )
{
- SwSaveRowSpan* pSaveRowSp = pNew->GetTable().CleanUpTopRowSpan( rTable.GetTabLines().size() );
+ std::unique_ptr<SwSaveRowSpan> pSaveRowSp = pNew->GetTable().CleanUpTopRowSpan( rTable.GetTabLines().size() );
SwUndoSplitTable* pUndo = nullptr;
if (GetIDocumentUndoRedo().DoesUndo())
{
pUndo = new SwUndoSplitTable(
- *pNew, pSaveRowSp, eHdlnMode, bCalcNewSize);
+ *pNew, std::move(pSaveRowSp), eHdlnMode, bCalcNewSize);
GetIDocumentUndoRedo().AppendUndo(pUndo);
if( aHistory.Count() )
pUndo->SaveFormula( aHistory );
diff --git a/sw/source/core/inc/UndoTable.hxx b/sw/source/core/inc/UndoTable.hxx
index 95fe3cad5675..74bfedfecf2a 100644
--- a/sw/source/core/inc/UndoTable.hxx
+++ b/sw/source/core/inc/UndoTable.hxx
@@ -324,15 +324,15 @@ public:
class SwUndoSplitTable : public SwUndo
{
sal_uLong nTableNode, nOffset;
- SwSaveRowSpan* mpSaveRowSpan; // stores row span values at the splitting row
- SaveTable* pSavTable;
- SwHistory* pHistory;
+ std::unique_ptr<SwSaveRowSpan> mpSaveRowSpan; // stores row span values at the splitting row
+ std::unique_ptr<SaveTable> pSavTable;
+ std::unique_ptr<SwHistory> pHistory;
SplitTable_HeadlineOption nMode;
sal_uInt16 nFormulaEnd;
bool bCalcNewSize;
public:
- SwUndoSplitTable( const SwTableNode& rTableNd, SwSaveRowSpan* pRowSp,
+ SwUndoSplitTable( const SwTableNode& rTableNd, std::unique_ptr<SwSaveRowSpan> pRowSp,
SplitTable_HeadlineOption nMode, bool bCalcNewSize );
virtual ~SwUndoSplitTable() override;
@@ -342,7 +342,7 @@ public:
virtual void RepeatImpl( ::sw::RepeatContext & ) override;
void SetTableNodeOffset( sal_uLong nIdx ) { nOffset = nIdx - nTableNode; }
- SwHistory* GetHistory() { return pHistory; }
+ SwHistory* GetHistory() { return pHistory.get(); }
void SaveFormula( SwHistory& rHistory );
};
diff --git a/sw/source/core/table/swnewtable.cxx b/sw/source/core/table/swnewtable.cxx
index 30a64747182d..89da33af871c 100644
--- a/sw/source/core/table/swnewtable.cxx
+++ b/sw/source/core/table/swnewtable.cxx
@@ -2062,17 +2062,13 @@ void SwTable::RestoreRowSpan( const SwSaveRowSpan& rSave )
}
}
-SwSaveRowSpan* SwTable::CleanUpTopRowSpan( sal_uInt16 nSplitLine )
+std::unique_ptr<SwSaveRowSpan> SwTable::CleanUpTopRowSpan( sal_uInt16 nSplitLine )
{
- SwSaveRowSpan* pRet = nullptr;
if( !IsNewModel() )
- return pRet;
- pRet = new SwSaveRowSpan( GetTabLines()[0]->GetTabBoxes(), nSplitLine );
+ return nullptr;
+ std::unique_ptr<SwSaveRowSpan> pRet(new SwSaveRowSpan( GetTabLines()[0]->GetTabBoxes(), nSplitLine ));
if( pRet->mnRowSpans.empty() )
- {
- delete pRet;
- pRet = nullptr;
- }
+ return nullptr;
return pRet;
}
diff --git a/sw/source/core/undo/untbl.cxx b/sw/source/core/undo/untbl.cxx
index de4d29ffb07b..411d2d8ac1a9 100644
--- a/sw/source/core/undo/untbl.cxx
+++ b/sw/source/core/undo/untbl.cxx
@@ -2843,19 +2843,19 @@ void SwUndoCpyTable::RedoImpl(::sw::UndoRedoContext & rContext)
}
SwUndoSplitTable::SwUndoSplitTable( const SwTableNode& rTableNd,
- SwSaveRowSpan* pRowSp, SplitTable_HeadlineOption eMode, bool bNewSize )
+ std::unique_ptr<SwSaveRowSpan> pRowSp, SplitTable_HeadlineOption eMode, bool bNewSize )
: SwUndo( SwUndoId::SPLIT_TABLE, rTableNd.GetDoc() ),
- nTableNode( rTableNd.GetIndex() ), nOffset( 0 ), mpSaveRowSpan( pRowSp ), pSavTable( nullptr ),
- pHistory( nullptr ), nMode( eMode ), nFormulaEnd( 0 ), bCalcNewSize( bNewSize )
+ nTableNode( rTableNd.GetIndex() ), nOffset( 0 ), mpSaveRowSpan( std::move(pRowSp) ),
+ nMode( eMode ), nFormulaEnd( 0 ), bCalcNewSize( bNewSize )
{
switch( nMode )
{
case SplitTable_HeadlineOption::BoxAttrAllCopy:
- pHistory = new SwHistory;
+ pHistory.reset(new SwHistory);
SAL_FALLTHROUGH;
case SplitTable_HeadlineOption::BorderCopy:
case SplitTable_HeadlineOption::BoxAttrCopy:
- pSavTable = new SaveTable( rTableNd.GetTable(), 1, false );
+ pSavTable.reset(new SaveTable( rTableNd.GetTable(), 1, false ));
break;
default: break;
}
@@ -2863,9 +2863,9 @@ SwUndoSplitTable::SwUndoSplitTable( const SwTableNode& rTableNd,
SwUndoSplitTable::~SwUndoSplitTable()
{
- delete pSavTable;
- delete pHistory;
- delete mpSaveRowSpan;
+ pSavTable.reset();
+ pHistory.reset();
+ mpSaveRowSpan.reset();
}
void SwUndoSplitTable::UndoImpl(::sw::UndoRedoContext & rContext)
@@ -2968,7 +2968,7 @@ void SwUndoSplitTable::RepeatImpl(::sw::RepeatContext & rContext)
void SwUndoSplitTable::SaveFormula( SwHistory& rHistory )
{
if( !pHistory )
- pHistory = new SwHistory;
+ pHistory.reset(new SwHistory);
nFormulaEnd = rHistory.Count();
pHistory->Move( 0, &rHistory );
More information about the Libreoffice-commits
mailing list