[Libreoffice-commits] core.git: sw/inc sw/source
Noel Grandin
noel.grandin at collabora.co.uk
Fri Jun 29 06:39:25 UTC 2018
sw/inc/node.hxx | 4 ++--
sw/source/core/doc/tblrwcl.cxx | 2 +-
sw/source/core/docnode/ndcopy.cxx | 4 ++--
sw/source/core/docnode/ndtbl.cxx | 9 ++++-----
sw/source/core/edit/edtab.cxx | 4 ++--
sw/source/core/fields/ddetbl.cxx | 4 ++--
sw/source/core/undo/untbl.cxx | 8 ++++----
sw/source/filter/xml/xmltbli.cxx | 6 +++---
8 files changed, 20 insertions(+), 21 deletions(-)
New commits:
commit b75d084f673d0a7e4845a59b5446a4bfafb37fd6
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date: Thu Jun 28 13:04:15 2018 +0200
loplugin:useuniqueptr in SwTableNode
Change-Id: I28bca27b6841ba9b263392b2e30f8684a8e2c4e5
Reviewed-on: https://gerrit.libreoffice.org/56622
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/sw/inc/node.hxx b/sw/inc/node.hxx
index 9198ec2c73b7..3e50db779aaa 100644
--- a/sw/inc/node.hxx
+++ b/sw/inc/node.hxx
@@ -492,7 +492,7 @@ private:
class SW_DLLPUBLIC SwTableNode : public SwStartNode, public SwModify
{
friend class SwNodes;
- SwTable* m_pTable;
+ std::unique_ptr<SwTable> m_pTable;
protected:
virtual ~SwTableNode() override;
@@ -515,7 +515,7 @@ public:
void MakeFrames( const SwNodeIndex & rIdx );
SwTableNode* MakeCopy( SwDoc*, const SwNodeIndex& ) const;
- void SetNewTable( SwTable* , bool bNewFrames=true );
+ void SetNewTable( std::unique_ptr<SwTable> , bool bNewFrames=true );
// Removes redline objects that relate to this table from the 'Extra Redlines' table
void RemoveRedlines();
diff --git a/sw/source/core/doc/tblrwcl.cxx b/sw/source/core/doc/tblrwcl.cxx
index c33b005e9a89..e9551ded7a87 100644
--- a/sw/source/core/doc/tblrwcl.cxx
+++ b/sw/source/core/doc/tblrwcl.cxx
@@ -2087,7 +2087,7 @@ bool SwTable::MakeCopy( SwDoc* pInsDoc, const SwPosition& rPos,
// Change the Table Pointer at the Node
pNewTable = new SwDDETable( *pNewTable,
static_cast<SwDDEFieldType*>(pFieldType) );
- pTableNd->SetNewTable( pNewTable, false );
+ pTableNd->SetNewTable( std::unique_ptr<SwTable>(pNewTable), false );
}
pNewTable->GetFrameFormat()->CopyAttrs( *GetFrameFormat() );
diff --git a/sw/source/core/docnode/ndcopy.cxx b/sw/source/core/docnode/ndcopy.cxx
index 0463edeaef2a..431a91e35055 100644
--- a/sw/source/core/docnode/ndcopy.cxx
+++ b/sw/source/core/docnode/ndcopy.cxx
@@ -283,8 +283,8 @@ SwTableNode* SwTableNode::MakeCopy( SwDoc* pDoc, const SwNodeIndex& rIdx ) const
OSL_ENSURE( pDDEType, "unknown FieldType" );
// Swap the table pointers in the node
- SwDDETable* pNewTable = new SwDDETable( pTableNd->GetTable(), pDDEType );
- pTableNd->SetNewTable( pNewTable, false );
+ std::unique_ptr<SwDDETable> pNewTable(new SwDDETable( pTableNd->GetTable(), pDDEType ));
+ pTableNd->SetNewTable( std::move(pNewTable), false );
}
// First copy the content of the tables, we will later assign the
// boxes/lines and create the frames
diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx
index 0ee58e56b96e..d0e177b48548 100644
--- a/sw/source/core/docnode/ndtbl.cxx
+++ b/sw/source/core/docnode/ndtbl.cxx
@@ -2337,7 +2337,7 @@ TableMergeErr SwDoc::MergeTable( SwPaM& rPam )
SwTableNode::SwTableNode( const SwNodeIndex& rIdx )
: SwStartNode( rIdx, SwNodeType::Table )
{
- m_pTable = new SwTable;
+ m_pTable.reset(new SwTable);
}
SwTableNode::~SwTableNode()
@@ -2349,7 +2349,7 @@ SwTableNode::~SwTableNode()
pTableFormat->ModifyNotification( &aMsgHint, &aMsgHint );
DelFrames();
m_pTable->SetTableNode(this); // set this so that ~SwDDETable can read it!
- delete m_pTable;
+ m_pTable.reset();
}
SwTabFrame *SwTableNode::MakeFrame( SwFrame* pSib )
@@ -2465,12 +2465,11 @@ void SwTableNode::DelFrames()
}
}
-void SwTableNode::SetNewTable( SwTable* pNewTable, bool bNewFrames )
+void SwTableNode::SetNewTable( std::unique_ptr<SwTable> pNewTable, bool bNewFrames )
{
DelFrames();
m_pTable->SetTableNode(this);
- delete m_pTable;
- m_pTable = pNewTable;
+ m_pTable = std::move(pNewTable);
if( bNewFrames )
{
SwNodeIndex aIdx( *EndOfSectionNode());
diff --git a/sw/source/core/edit/edtab.cxx b/sw/source/core/edit/edtab.cxx
index 4859b5efdcbb..28a5c05be494 100644
--- a/sw/source/core/edit/edtab.cxx
+++ b/sw/source/core/edit/edtab.cxx
@@ -232,8 +232,8 @@ void SwEditShell::InsertDDETable( const SwInsertTableOptions& rInsTableOpts,
SwTableNode* pTableNode = const_cast<SwTableNode*>(pTable->GetTabSortBoxes()[ 0 ]->
GetSttNd()->FindTableNode());
- SwDDETable* pDDETable = new SwDDETable( *pTable, pDDEType );
- pTableNode->SetNewTable( pDDETable ); // set the DDE table
+ std::unique_ptr<SwDDETable> pDDETable(new SwDDETable( *pTable, pDDEType ));
+ pTableNode->SetNewTable( std::move(pDDETable) ); // set the DDE table
if( bEndUndo )
EndUndo( SwUndoId::END );
diff --git a/sw/source/core/fields/ddetbl.cxx b/sw/source/core/fields/ddetbl.cxx
index 4ecf198ed0d0..f4abfdb55557 100644
--- a/sw/source/core/fields/ddetbl.cxx
+++ b/sw/source/core/fields/ddetbl.cxx
@@ -186,7 +186,7 @@ bool SwDDETable::NoDDETable()
SwTableNode* pTableNd = pNd->FindTableNode();
OSL_ENSURE( pTableNd, "Where is the table?");
- SwTable* pNewTable = new SwTable( *this );
+ std::unique_ptr<SwTable> pNewTable(new SwTable( *this ));
// copy the table data
pNewTable->GetTabSortBoxes().insert( GetTabSortBoxes() ); // move content boxes
@@ -199,7 +199,7 @@ bool SwDDETable::NoDDETable()
if( pDoc->getIDocumentLayoutAccess().GetCurrentViewShell() )
m_pDDEType->DecRefCnt();
- pTableNd->SetNewTable( pNewTable ); // replace table
+ pTableNd->SetNewTable( std::move(pNewTable) ); // replace table
return true;
}
diff --git a/sw/source/core/undo/untbl.cxx b/sw/source/core/undo/untbl.cxx
index 524ac22d08e8..1f03b2e57441 100644
--- a/sw/source/core/undo/untbl.cxx
+++ b/sw/source/core/undo/untbl.cxx
@@ -308,8 +308,8 @@ void SwUndoInsTable::RedoImpl(::sw::UndoRedoContext & rContext)
{
SwDDEFieldType* pNewType = static_cast<SwDDEFieldType*>(rDoc.getIDocumentFieldsAccess().InsertFieldType(
*pDDEFieldType));
- SwDDETable* pDDETable = new SwDDETable( pTableNode->GetTable(), pNewType );
- pTableNode->SetNewTable( pDDETable );
+ std::unique_ptr<SwDDETable> pDDETable(new SwDDETable( pTableNode->GetTable(), pNewType ));
+ pTableNode->SetNewTable( std::move(pDDETable) );
delete pDDEFieldType;
pDDEFieldType = nullptr;
}
@@ -476,8 +476,8 @@ void SwUndoTableToText::UndoImpl(::sw::UndoRedoContext & rContext)
{
SwDDEFieldType* pNewType = static_cast<SwDDEFieldType*>(rDoc.getIDocumentFieldsAccess().InsertFieldType(
*pDDEFieldType));
- SwDDETable* pDDETable = new SwDDETable( pTableNd->GetTable(), pNewType );
- pTableNd->SetNewTable( pDDETable, false );
+ std::unique_ptr<SwDDETable> pDDETable( new SwDDETable( pTableNd->GetTable(), pNewType ) );
+ pTableNd->SetNewTable( std::move(pDDETable), false );
delete pDDEFieldType;
pDDEFieldType = nullptr;
}
diff --git a/sw/source/filter/xml/xmltbli.cxx b/sw/source/filter/xml/xmltbli.cxx
index 6f75cf0ea7d7..4cda32f8938a 100644
--- a/sw/source/filter/xml/xmltbli.cxx
+++ b/sw/source/filter/xml/xmltbli.cxx
@@ -2774,11 +2774,11 @@ void SwXMLTableContext::MakeTable()
m_xDDESource.set(nullptr);
// 3) create new DDE table, and
- SwDDETable* pDDETable = new SwDDETable( m_pTableNode->GetTable(),
- pFieldType, false );
+ std::unique_ptr<SwDDETable> pDDETable( new SwDDETable( m_pTableNode->GetTable(),
+ pFieldType, false ) );
// 4) set new (DDE)table at node.
- m_pTableNode->SetNewTable(pDDETable, false);
+ m_pTableNode->SetNewTable(std::move(pDDETable), false);
}
// ??? this is always false: root frame is only created in SwViewShell::Init
More information about the Libreoffice-commits
mailing list