loplugin:useuniqueptr in SwTableNode
Change-Id: I28bca27b6841ba9b263392b2e30f8684a8e2c4e5 Reviewed-on: https://gerrit.libreoffice.org/56622 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
parent
c0241bad4e
commit
b75d084f67
@ -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();
|
||||
|
@ -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() );
|
||||
|
@ -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
|
||||
|
@ -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());
|
||||
|
@ -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 );
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user