Kaydet (Commit) 92f9fcc9 authored tarafından Noel Grandin's avatar Noel Grandin

loplugin:useuniqueptr in CGMChart

Change-Id: I55e11d158c50a76b0fad1da0e1adc3712990aa8f
Reviewed-on: https://gerrit.libreoffice.org/59028
Tested-by: Jenkins
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst aad3b3b0
...@@ -33,34 +33,16 @@ CGMChart::CGMChart() ...@@ -33,34 +33,16 @@ CGMChart::CGMChart()
CGMChart::~CGMChart() CGMChart::~CGMChart()
{ {
// delete the whole textentry structure // delete the whole textentry structure
for (auto & pTextEntry : maTextEntryList)
while( !maTextEntryList.empty() )
{
DeleteTextEntry( maTextEntryList[ 0 ] );
}
}
void CGMChart::DeleteTextEntry( TextEntry* pTextEntry )
{
if ( pTextEntry )
{ {
delete pTextEntry->pText; if ( pTextEntry )
::std::vector< TextEntry* >::iterator it; delete pTextEntry->pText;
for ( it = maTextEntryList.begin(); it != maTextEntryList.end(); ++it )
{
if ( *it == pTextEntry )
{
maTextEntryList.erase( it );
break;
}
}
delete pTextEntry;
} }
} }
void CGMChart::InsertTextEntry( TextEntry* pTextEntry ) void CGMChart::InsertTextEntry( std::unique_ptr<TextEntry> pTextEntry )
{ {
maTextEntryList.push_back( pTextEntry ); maTextEntryList.push_back( std::move(pTextEntry) );
} }
void CGMChart::ResetAnnotation() void CGMChart::ResetAnnotation()
......
...@@ -64,15 +64,14 @@ class CGMChart final ...@@ -64,15 +64,14 @@ class CGMChart final
friend class CGMImpressOutAct; friend class CGMImpressOutAct;
sal_Int8 mnCurrentFileType; sal_Int8 mnCurrentFileType;
::std::vector< TextEntry* > maTextEntryList; ::std::vector< std::unique_ptr<TextEntry> > maTextEntryList;
DataNode mDataNode[ 7 ]; DataNode mDataNode[ 7 ];
public: public:
CGMChart(); CGMChart();
~CGMChart(); ~CGMChart();
void DeleteTextEntry( TextEntry* ); void InsertTextEntry( std::unique_ptr<TextEntry> );
void InsertTextEntry( TextEntry* );
void ResetAnnotation(); void ResetAnnotation();
bool IsAnnotation(); bool IsAnnotation();
......
...@@ -117,7 +117,7 @@ void CGM::ImplDoClass7() ...@@ -117,7 +117,7 @@ void CGM::ImplDoClass7()
if (mpEndValidSource - pAppData < 9) if (mpEndValidSource - pAppData < 9)
throw css::uno::Exception("attempt to read past end of input", nullptr); throw css::uno::Exception("attempt to read past end of input", nullptr);
TextEntry* pTextEntry = new TextEntry; std::unique_ptr<TextEntry> pTextEntry(new TextEntry);
pTextEntry->nTypeOfText = *reinterpret_cast<sal_uInt16*>( pAppData ); pTextEntry->nTypeOfText = *reinterpret_cast<sal_uInt16*>( pAppData );
pTextEntry->nRowOrLineNum = *reinterpret_cast<sal_uInt16*>( pAppData + 2 ); pTextEntry->nRowOrLineNum = *reinterpret_cast<sal_uInt16*>( pAppData + 2 );
pTextEntry->nColumnNum = *reinterpret_cast<sal_uInt16*>( pAppData + 4 ); pTextEntry->nColumnNum = *reinterpret_cast<sal_uInt16*>( pAppData + 4 );
...@@ -132,7 +132,7 @@ void CGM::ImplDoClass7() ...@@ -132,7 +132,7 @@ void CGM::ImplDoClass7()
memcpy( pTextEntry->pText, pAppData, nLen ); memcpy( pTextEntry->pText, pAppData, nLen );
pAppData += nLen; pAppData += nLen;
mpChart->InsertTextEntry( pTextEntry ); mpChart->InsertTextEntry( std::move(pTextEntry) );
} }
break; break;
case 0x321 : /*AppData - IOC_TABS */break; case 0x321 : /*AppData - IOC_TABS */break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment