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

loplugin:useuniqueptr in CGM

Change-Id: Iecd9251f68cd894a14fb6824151768d4cb663e0f
Reviewed-on: https://gerrit.libreoffice.org/49944Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst ccd316d1
...@@ -64,26 +64,19 @@ CGM::CGM(uno::Reference< frame::XModel > const & rModel) ...@@ -64,26 +64,19 @@ CGM::CGM(uno::Reference< frame::XModel > const & rModel)
, mnElementID(0) , mnElementID(0)
, mnElementSize(0) , mnElementSize(0)
{ {
pElement = new CGMElements; pElement.reset( new CGMElements );
pCopyOfE = new CGMElements; pCopyOfE.reset( new CGMElements );
} }
CGM::~CGM() CGM::~CGM()
{ {
for(sal_uInt8* i : maDefRepList)
delete [] i;
maDefRepList.clear(); maDefRepList.clear();
maDefRepSizeList.clear(); maDefRepSizeList.clear();
delete mpBitmapInUse;
delete mpChart;
delete mpOutAct;
delete pCopyOfE;
delete pElement;
}; };
sal_uInt32 CGM::GetBackGroundColor() sal_uInt32 CGM::GetBackGroundColor()
{ {
return ( pElement ) ? pElement->aColorTable[ 0 ] : 0; return pElement ? pElement->aColorTable[ 0 ] : 0;
} }
sal_uInt32 CGM::ImplGetUI16() sal_uInt32 CGM::ImplGetUI16()
...@@ -615,7 +608,7 @@ void CGM::ImplDefaultReplacement() ...@@ -615,7 +608,7 @@ void CGM::ImplDefaultReplacement()
for ( size_t i = 0, n = maDefRepList.size(); i < n; ++i ) for ( size_t i = 0, n = maDefRepList.size(); i < n; ++i )
{ {
sal_uInt8* pBuf = maDefRepList[ i ]; sal_uInt8* pBuf = maDefRepList[ i ].get();
sal_uInt32 nElementSize = maDefRepSizeList[ i ]; sal_uInt32 nElementSize = maDefRepSizeList[ i ];
mpEndValidSource = pBuf + nElementSize; mpEndValidSource = pBuf + nElementSize;
sal_uInt32 nCount = 0; sal_uInt32 nCount = 0;
......
...@@ -65,14 +65,14 @@ class CGM ...@@ -65,14 +65,14 @@ class CGM
bool mbFirstOutPut; bool mbFirstOutPut;
bool mbInDefaultReplacement; bool mbInDefaultReplacement;
sal_uInt32 mnAct4PostReset; sal_uInt32 mnAct4PostReset;
CGMBitmap* mpBitmapInUse; std::unique_ptr<CGMBitmap> mpBitmapInUse;
CGMChart* mpChart; // if sal_True->"SHWSLIDEREC" std::unique_ptr<CGMChart> mpChart; // if sal_True->"SHWSLIDEREC"
// otherwise "BEGINPIC" commands // otherwise "BEGINPIC" commands
// controls page inserting // controls page inserting
CGMElements* pElement; std::unique_ptr<CGMElements> pElement;
CGMElements* pCopyOfE; std::unique_ptr<CGMElements> pCopyOfE;
CGMImpressOutAct* mpOutAct; std::unique_ptr<CGMImpressOutAct> mpOutAct;
::std::vector< sal_uInt8 * > maDefRepList; ::std::vector< std::unique_ptr<sal_uInt8[]> > maDefRepList;
::std::vector< sal_uInt32 > maDefRepSizeList; ::std::vector< sal_uInt32 > maDefRepSizeList;
sal_uInt8* mpSource; // start of source buffer that is not increased sal_uInt8* mpSource; // start of source buffer that is not increased
......
...@@ -38,8 +38,7 @@ void CGM::ImplDoClass0() ...@@ -38,8 +38,7 @@ void CGM::ImplDoClass0()
CGMBitmapDescriptor* pBmpDesc = mpBitmapInUse->GetBitmap(); CGMBitmapDescriptor* pBmpDesc = mpBitmapInUse->GetBitmap();
// do anything with the bitmap // do anything with the bitmap
mpOutAct->DrawBitmap( pBmpDesc ); mpOutAct->DrawBitmap( pBmpDesc );
delete mpBitmapInUse; mpBitmapInUse.reset();
mpBitmapInUse = nullptr;
} }
mbIsFinished = true; mbIsFinished = true;
mbPictureBody = false; mbPictureBody = false;
...@@ -75,8 +74,7 @@ void CGM::ImplDoClass0() ...@@ -75,8 +74,7 @@ void CGM::ImplDoClass0()
CGMBitmapDescriptor* pBmpDesc = mpBitmapInUse->GetBitmap(); CGMBitmapDescriptor* pBmpDesc = mpBitmapInUse->GetBitmap();
// do anything with the bitmap // do anything with the bitmap
mpOutAct->DrawBitmap( pBmpDesc ); mpOutAct->DrawBitmap( pBmpDesc );
delete mpBitmapInUse; mpBitmapInUse.reset();
mpBitmapInUse = nullptr;
} }
mpOutAct->EndFigure(); // close potential figures mpOutAct->EndFigure(); // close potential figures
mpOutAct->EndGrouping(); // finish potential groups mpOutAct->EndGrouping(); // finish potential groups
......
...@@ -164,9 +164,9 @@ void CGM::ImplDoClass1() ...@@ -164,9 +164,9 @@ void CGM::ImplDoClass1()
{ {
if ( mnElementSize > 1 ) if ( mnElementSize > 1 )
{ {
sal_uInt8* pBuf = new sal_uInt8[ mnElementSize ]; std::unique_ptr<sal_uInt8[]> pBuf(new sal_uInt8[ mnElementSize ]);
memcpy( pBuf, mpSource, mnElementSize ); memcpy( pBuf.get(), mpSource, mnElementSize );
maDefRepList.push_back( pBuf ); maDefRepList.push_back( std::move(pBuf) );
maDefRepSizeList.push_back( mnElementSize ); maDefRepSizeList.push_back( mnElementSize );
} }
mnParaSize = mnElementSize; mnParaSize = mnElementSize;
......
...@@ -112,8 +112,7 @@ void CGM::ImplDoClass4() ...@@ -112,8 +112,7 @@ void CGM::ImplDoClass4()
CGMBitmapDescriptor* pBmpDesc = mpBitmapInUse->GetBitmap(); CGMBitmapDescriptor* pBmpDesc = mpBitmapInUse->GetBitmap();
// do anything with the bitmap // do anything with the bitmap
mpOutAct->DrawBitmap( pBmpDesc ); mpOutAct->DrawBitmap( pBmpDesc );
delete mpBitmapInUse; mpBitmapInUse.reset();
mpBitmapInUse = nullptr;
} }
if ( ( mpChart == nullptr ) || mpChart->IsAnnotation() ) if ( ( mpChart == nullptr ) || mpChart->IsAnnotation() )
...@@ -316,7 +315,7 @@ void CGM::ImplDoClass4() ...@@ -316,7 +315,7 @@ void CGM::ImplDoClass4()
} }
else else
{ {
mpBitmapInUse = new CGMBitmap( *this ); mpBitmapInUse.reset( new CGMBitmap( *this ) );
} }
} }
break; break;
......
...@@ -48,7 +48,7 @@ void CGM::ImplDoClass7() ...@@ -48,7 +48,7 @@ void CGM::ImplDoClass7()
throw css::uno::Exception("attempt to read past end of input", nullptr); throw css::uno::Exception("attempt to read past end of input", nullptr);
if ( mpChart == nullptr ) if ( mpChart == nullptr )
mpChart = new CGMChart; mpChart.reset( new CGMChart );
mpChart->mnCurrentFileType = pAppData[ 3 ]; mpChart->mnCurrentFileType = pAppData[ 3 ];
} }
break; 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