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:
@@ -492,7 +492,7 @@ private:
|
|||||||
class SW_DLLPUBLIC SwTableNode : public SwStartNode, public SwModify
|
class SW_DLLPUBLIC SwTableNode : public SwStartNode, public SwModify
|
||||||
{
|
{
|
||||||
friend class SwNodes;
|
friend class SwNodes;
|
||||||
SwTable* m_pTable;
|
std::unique_ptr<SwTable> m_pTable;
|
||||||
protected:
|
protected:
|
||||||
virtual ~SwTableNode() override;
|
virtual ~SwTableNode() override;
|
||||||
|
|
||||||
@@ -515,7 +515,7 @@ public:
|
|||||||
void MakeFrames( const SwNodeIndex & rIdx );
|
void MakeFrames( const SwNodeIndex & rIdx );
|
||||||
|
|
||||||
SwTableNode* MakeCopy( SwDoc*, const SwNodeIndex& ) const;
|
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
|
// Removes redline objects that relate to this table from the 'Extra Redlines' table
|
||||||
void RemoveRedlines();
|
void RemoveRedlines();
|
||||||
|
@@ -2087,7 +2087,7 @@ bool SwTable::MakeCopy( SwDoc* pInsDoc, const SwPosition& rPos,
|
|||||||
// Change the Table Pointer at the Node
|
// Change the Table Pointer at the Node
|
||||||
pNewTable = new SwDDETable( *pNewTable,
|
pNewTable = new SwDDETable( *pNewTable,
|
||||||
static_cast<SwDDEFieldType*>(pFieldType) );
|
static_cast<SwDDEFieldType*>(pFieldType) );
|
||||||
pTableNd->SetNewTable( pNewTable, false );
|
pTableNd->SetNewTable( std::unique_ptr<SwTable>(pNewTable), false );
|
||||||
}
|
}
|
||||||
|
|
||||||
pNewTable->GetFrameFormat()->CopyAttrs( *GetFrameFormat() );
|
pNewTable->GetFrameFormat()->CopyAttrs( *GetFrameFormat() );
|
||||||
|
@@ -283,8 +283,8 @@ SwTableNode* SwTableNode::MakeCopy( SwDoc* pDoc, const SwNodeIndex& rIdx ) const
|
|||||||
OSL_ENSURE( pDDEType, "unknown FieldType" );
|
OSL_ENSURE( pDDEType, "unknown FieldType" );
|
||||||
|
|
||||||
// Swap the table pointers in the node
|
// Swap the table pointers in the node
|
||||||
SwDDETable* pNewTable = new SwDDETable( pTableNd->GetTable(), pDDEType );
|
std::unique_ptr<SwDDETable> pNewTable(new SwDDETable( pTableNd->GetTable(), pDDEType ));
|
||||||
pTableNd->SetNewTable( pNewTable, false );
|
pTableNd->SetNewTable( std::move(pNewTable), false );
|
||||||
}
|
}
|
||||||
// First copy the content of the tables, we will later assign the
|
// First copy the content of the tables, we will later assign the
|
||||||
// boxes/lines and create the frames
|
// boxes/lines and create the frames
|
||||||
|
@@ -2337,7 +2337,7 @@ TableMergeErr SwDoc::MergeTable( SwPaM& rPam )
|
|||||||
SwTableNode::SwTableNode( const SwNodeIndex& rIdx )
|
SwTableNode::SwTableNode( const SwNodeIndex& rIdx )
|
||||||
: SwStartNode( rIdx, SwNodeType::Table )
|
: SwStartNode( rIdx, SwNodeType::Table )
|
||||||
{
|
{
|
||||||
m_pTable = new SwTable;
|
m_pTable.reset(new SwTable);
|
||||||
}
|
}
|
||||||
|
|
||||||
SwTableNode::~SwTableNode()
|
SwTableNode::~SwTableNode()
|
||||||
@@ -2349,7 +2349,7 @@ SwTableNode::~SwTableNode()
|
|||||||
pTableFormat->ModifyNotification( &aMsgHint, &aMsgHint );
|
pTableFormat->ModifyNotification( &aMsgHint, &aMsgHint );
|
||||||
DelFrames();
|
DelFrames();
|
||||||
m_pTable->SetTableNode(this); // set this so that ~SwDDETable can read it!
|
m_pTable->SetTableNode(this); // set this so that ~SwDDETable can read it!
|
||||||
delete m_pTable;
|
m_pTable.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
SwTabFrame *SwTableNode::MakeFrame( SwFrame* pSib )
|
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();
|
DelFrames();
|
||||||
m_pTable->SetTableNode(this);
|
m_pTable->SetTableNode(this);
|
||||||
delete m_pTable;
|
m_pTable = std::move(pNewTable);
|
||||||
m_pTable = pNewTable;
|
|
||||||
if( bNewFrames )
|
if( bNewFrames )
|
||||||
{
|
{
|
||||||
SwNodeIndex aIdx( *EndOfSectionNode());
|
SwNodeIndex aIdx( *EndOfSectionNode());
|
||||||
|
@@ -232,8 +232,8 @@ void SwEditShell::InsertDDETable( const SwInsertTableOptions& rInsTableOpts,
|
|||||||
|
|
||||||
SwTableNode* pTableNode = const_cast<SwTableNode*>(pTable->GetTabSortBoxes()[ 0 ]->
|
SwTableNode* pTableNode = const_cast<SwTableNode*>(pTable->GetTabSortBoxes()[ 0 ]->
|
||||||
GetSttNd()->FindTableNode());
|
GetSttNd()->FindTableNode());
|
||||||
SwDDETable* pDDETable = new SwDDETable( *pTable, pDDEType );
|
std::unique_ptr<SwDDETable> pDDETable(new SwDDETable( *pTable, pDDEType ));
|
||||||
pTableNode->SetNewTable( pDDETable ); // set the DDE table
|
pTableNode->SetNewTable( std::move(pDDETable) ); // set the DDE table
|
||||||
|
|
||||||
if( bEndUndo )
|
if( bEndUndo )
|
||||||
EndUndo( SwUndoId::END );
|
EndUndo( SwUndoId::END );
|
||||||
|
@@ -186,7 +186,7 @@ bool SwDDETable::NoDDETable()
|
|||||||
SwTableNode* pTableNd = pNd->FindTableNode();
|
SwTableNode* pTableNd = pNd->FindTableNode();
|
||||||
OSL_ENSURE( pTableNd, "Where is the table?");
|
OSL_ENSURE( pTableNd, "Where is the table?");
|
||||||
|
|
||||||
SwTable* pNewTable = new SwTable( *this );
|
std::unique_ptr<SwTable> pNewTable(new SwTable( *this ));
|
||||||
|
|
||||||
// copy the table data
|
// copy the table data
|
||||||
pNewTable->GetTabSortBoxes().insert( GetTabSortBoxes() ); // move content boxes
|
pNewTable->GetTabSortBoxes().insert( GetTabSortBoxes() ); // move content boxes
|
||||||
@@ -199,7 +199,7 @@ bool SwDDETable::NoDDETable()
|
|||||||
if( pDoc->getIDocumentLayoutAccess().GetCurrentViewShell() )
|
if( pDoc->getIDocumentLayoutAccess().GetCurrentViewShell() )
|
||||||
m_pDDEType->DecRefCnt();
|
m_pDDEType->DecRefCnt();
|
||||||
|
|
||||||
pTableNd->SetNewTable( pNewTable ); // replace table
|
pTableNd->SetNewTable( std::move(pNewTable) ); // replace table
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@@ -308,8 +308,8 @@ void SwUndoInsTable::RedoImpl(::sw::UndoRedoContext & rContext)
|
|||||||
{
|
{
|
||||||
SwDDEFieldType* pNewType = static_cast<SwDDEFieldType*>(rDoc.getIDocumentFieldsAccess().InsertFieldType(
|
SwDDEFieldType* pNewType = static_cast<SwDDEFieldType*>(rDoc.getIDocumentFieldsAccess().InsertFieldType(
|
||||||
*pDDEFieldType));
|
*pDDEFieldType));
|
||||||
SwDDETable* pDDETable = new SwDDETable( pTableNode->GetTable(), pNewType );
|
std::unique_ptr<SwDDETable> pDDETable(new SwDDETable( pTableNode->GetTable(), pNewType ));
|
||||||
pTableNode->SetNewTable( pDDETable );
|
pTableNode->SetNewTable( std::move(pDDETable) );
|
||||||
delete pDDEFieldType;
|
delete pDDEFieldType;
|
||||||
pDDEFieldType = nullptr;
|
pDDEFieldType = nullptr;
|
||||||
}
|
}
|
||||||
@@ -476,8 +476,8 @@ void SwUndoTableToText::UndoImpl(::sw::UndoRedoContext & rContext)
|
|||||||
{
|
{
|
||||||
SwDDEFieldType* pNewType = static_cast<SwDDEFieldType*>(rDoc.getIDocumentFieldsAccess().InsertFieldType(
|
SwDDEFieldType* pNewType = static_cast<SwDDEFieldType*>(rDoc.getIDocumentFieldsAccess().InsertFieldType(
|
||||||
*pDDEFieldType));
|
*pDDEFieldType));
|
||||||
SwDDETable* pDDETable = new SwDDETable( pTableNd->GetTable(), pNewType );
|
std::unique_ptr<SwDDETable> pDDETable( new SwDDETable( pTableNd->GetTable(), pNewType ) );
|
||||||
pTableNd->SetNewTable( pDDETable, false );
|
pTableNd->SetNewTable( std::move(pDDETable), false );
|
||||||
delete pDDEFieldType;
|
delete pDDEFieldType;
|
||||||
pDDEFieldType = nullptr;
|
pDDEFieldType = nullptr;
|
||||||
}
|
}
|
||||||
|
@@ -2774,11 +2774,11 @@ void SwXMLTableContext::MakeTable()
|
|||||||
m_xDDESource.set(nullptr);
|
m_xDDESource.set(nullptr);
|
||||||
|
|
||||||
// 3) create new DDE table, and
|
// 3) create new DDE table, and
|
||||||
SwDDETable* pDDETable = new SwDDETable( m_pTableNode->GetTable(),
|
std::unique_ptr<SwDDETable> pDDETable( new SwDDETable( m_pTableNode->GetTable(),
|
||||||
pFieldType, false );
|
pFieldType, false ) );
|
||||||
|
|
||||||
// 4) set new (DDE)table at node.
|
// 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
|
// ??? this is always false: root frame is only created in SwViewShell::Init
|
||||||
|
Reference in New Issue
Block a user