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)
, mnElementID(0)
, mnElementSize(0)
{
pElement = new CGMElements;
pCopyOfE = new CGMElements;
pElement.reset( new CGMElements );
pCopyOfE.reset( new CGMElements );
}
CGM::~CGM()
{
for(sal_uInt8* i : maDefRepList)
delete [] i;
maDefRepList.clear();
maDefRepSizeList.clear();
delete mpBitmapInUse;
delete mpChart;
delete mpOutAct;
delete pCopyOfE;
delete pElement;
};
sal_uInt32 CGM::GetBackGroundColor()
{
return ( pElement ) ? pElement->aColorTable[ 0 ] : 0;
return pElement ? pElement->aColorTable[ 0 ] : 0;
}
sal_uInt32 CGM::ImplGetUI16()
......@@ -615,7 +608,7 @@ void CGM::ImplDefaultReplacement()
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 ];
mpEndValidSource = pBuf + nElementSize;
sal_uInt32 nCount = 0;
......
......@@ -65,14 +65,14 @@ class CGM
bool mbFirstOutPut;
bool mbInDefaultReplacement;
sal_uInt32 mnAct4PostReset;
CGMBitmap* mpBitmapInUse;
CGMChart* mpChart; // if sal_True->"SHWSLIDEREC"
std::unique_ptr<CGMBitmap> mpBitmapInUse;
std::unique_ptr<CGMChart> mpChart; // if sal_True->"SHWSLIDEREC"
// otherwise "BEGINPIC" commands
// controls page inserting
CGMElements* pElement;
CGMElements* pCopyOfE;
CGMImpressOutAct* mpOutAct;
::std::vector< sal_uInt8 * > maDefRepList;
std::unique_ptr<CGMElements> pElement;
std::unique_ptr<CGMElements> pCopyOfE;
std::unique_ptr<CGMImpressOutAct> mpOutAct;
::std::vector< std::unique_ptr<sal_uInt8[]> > maDefRepList;
::std::vector< sal_uInt32 > maDefRepSizeList;
sal_uInt8* mpSource; // start of source buffer that is not increased
......
......@@ -38,8 +38,7 @@ void CGM::ImplDoClass0()
CGMBitmapDescriptor* pBmpDesc = mpBitmapInUse->GetBitmap();
// do anything with the bitmap
mpOutAct->DrawBitmap( pBmpDesc );
delete mpBitmapInUse;
mpBitmapInUse = nullptr;
mpBitmapInUse.reset();
}
mbIsFinished = true;
mbPictureBody = false;
......@@ -75,8 +74,7 @@ void CGM::ImplDoClass0()
CGMBitmapDescriptor* pBmpDesc = mpBitmapInUse->GetBitmap();
// do anything with the bitmap
mpOutAct->DrawBitmap( pBmpDesc );
delete mpBitmapInUse;
mpBitmapInUse = nullptr;
mpBitmapInUse.reset();
}
mpOutAct->EndFigure(); // close potential figures
mpOutAct->EndGrouping(); // finish potential groups
......
......@@ -164,9 +164,9 @@ void CGM::ImplDoClass1()
{
if ( mnElementSize > 1 )
{
sal_uInt8* pBuf = new sal_uInt8[ mnElementSize ];
memcpy( pBuf, mpSource, mnElementSize );
maDefRepList.push_back( pBuf );
std::unique_ptr<sal_uInt8[]> pBuf(new sal_uInt8[ mnElementSize ]);
memcpy( pBuf.get(), mpSource, mnElementSize );
maDefRepList.push_back( std::move(pBuf) );
maDefRepSizeList.push_back( mnElementSize );
}
mnParaSize = mnElementSize;
......
......@@ -112,8 +112,7 @@ void CGM::ImplDoClass4()
CGMBitmapDescriptor* pBmpDesc = mpBitmapInUse->GetBitmap();
// do anything with the bitmap
mpOutAct->DrawBitmap( pBmpDesc );
delete mpBitmapInUse;
mpBitmapInUse = nullptr;
mpBitmapInUse.reset();
}
if ( ( mpChart == nullptr ) || mpChart->IsAnnotation() )
......@@ -316,7 +315,7 @@ void CGM::ImplDoClass4()
}
else
{
mpBitmapInUse = new CGMBitmap( *this );
mpBitmapInUse.reset( new CGMBitmap( *this ) );
}
}
break;
......
......@@ -48,7 +48,7 @@ void CGM::ImplDoClass7()
throw css::uno::Exception("attempt to read past end of input", nullptr);
if ( mpChart == nullptr )
mpChart = new CGMChart;
mpChart.reset( new CGMChart );
mpChart->mnCurrentFileType = pAppData[ 3 ];
}
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