[Libreoffice-commits] core.git: sd/source
Noel Grandin
noel.grandin at collabora.co.uk
Fri Mar 23 10:31:59 UTC 2018
sd/source/filter/eppt/eppt.cxx | 40 +++++++++++++-------------------
sd/source/filter/eppt/eppt.hxx | 12 ++++-----
sd/source/filter/eppt/epptbase.hxx | 2 -
sd/source/filter/eppt/epptso.cxx | 26 ++++++++++----------
sd/source/filter/eppt/pptx-epptbase.cxx | 4 +--
5 files changed, 39 insertions(+), 45 deletions(-)
New commits:
commit 400a70303aae6e98d2d5b1d1eb484149a70f9121
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date: Thu Mar 22 15:32:39 2018 +0200
loplugin:useuniqueptr in PPTWriter
Change-Id: I5c099e97d51808d2dcaf6d1385d1e3cab2e2ddf2
Reviewed-on: https://gerrit.libreoffice.org/51762
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/sd/source/filter/eppt/eppt.cxx b/sd/source/filter/eppt/eppt.cxx
index eddc6edbda6b..f906b99af1f8 100644
--- a/sd/source/filter/eppt/eppt.cxx
+++ b/sd/source/filter/eppt/eppt.cxx
@@ -119,12 +119,12 @@ void PPTWriter::exportPPTPre( const std::vector< css::beans::PropertyValue >& rM
if ( !ImplCreateCurrentUserStream() )
return;
- mpStrm = mrStg->OpenSotStream( "PowerPoint Document" );
+ mpStrm.reset( mrStg->OpenSotStream( "PowerPoint Document" ) );
if ( !mpStrm )
return;
if ( !mpPicStrm )
- mpPicStrm = mrStg->OpenSotStream( "Pictures" );
+ mpPicStrm.reset( mrStg->OpenSotStream( "Pictures" ) );
for (std::vector< css::beans::PropertyValue >::const_iterator aIter( rMediaData.begin() ), aEnd( rMediaData.end() );
aIter != aEnd ; ++aIter)
@@ -135,7 +135,7 @@ void PPTWriter::exportPPTPre( const std::vector< css::beans::PropertyValue >& rM
break;
}
}
- mpPptEscherEx = new PptEscherEx( *mpStrm, maBaseURI );
+ mpPptEscherEx.reset( new PptEscherEx( *mpStrm, maBaseURI ) );
}
void PPTWriter::exportPPTPost( )
@@ -457,33 +457,27 @@ void PPTWriter::ImplWriteSlideMaster( sal_uInt32 nPageNum, Reference< XPropertyS
if ( aBuExMasterStream.Tell() )
{
- ImplProgTagContainer( mpStrm, &aBuExMasterStream );
+ ImplProgTagContainer( mpStrm.get(), &aBuExMasterStream );
}
mpPptEscherEx->CloseContainer(); // EPP_MainMaster
};
PPTWriter::~PPTWriter()
{
- delete mpExEmbed;
- delete mpPptEscherEx;
- delete mpCurUserStrm;
- delete mpPicStrm;
- delete mpStrm;
-
- std::vector< PPTExStyleSheet* >::iterator aStyleSheetIter( maStyleSheetList.begin() );
- while( aStyleSheetIter < maStyleSheetList.end() )
- delete *aStyleSheetIter++;
-
- for ( std::vector<PPTExOleObjEntry*>::const_iterator it = maExOleObj.begin(); it != maExOleObj.end(); ++it )
- delete *it;
-
+ mpExEmbed.reset();
+ mpPptEscherEx.reset();
+ mpCurUserStrm.reset();
+ mpPicStrm.reset();
+ mpStrm.reset();
+ maStyleSheetList.clear();
+ maExOleObj.clear();
if ( mbStatusIndicator )
mXStatusIndicator->end();
}
bool PPTWriter::ImplCreateCurrentUserStream()
{
- mpCurUserStrm = mrStg->OpenSotStream( "Current User" );
+ mpCurUserStrm.reset( mrStg->OpenSotStream( "Current User" ) );
if ( !mpCurUserStrm )
return false;
char pUserName[] = "Current User";
@@ -1190,7 +1184,7 @@ void PPTWriter::ImplWriteBackground( css::uno::Reference< css::beans::XPropertyS
// #i121183# Use real PageSize in 100th mm
::tools::Rectangle aRect(Point(0, 0), Size(maPageSize.Width, maPageSize.Height));
- EscherPropertyContainer aPropOpt( mpPptEscherEx->GetGraphicProvider(), mpPicStrm, aRect );
+ EscherPropertyContainer aPropOpt( mpPptEscherEx->GetGraphicProvider(), mpPicStrm.get(), aRect );
aPropOpt.AddOpt( ESCHER_Prop_fillType, ESCHER_FillSolid );
css::drawing::FillStyle aFS( css::drawing::FillStyle_NONE );
if ( ImplGetPropertyValue( rXPropSet, "FillStyle" ) )
@@ -1262,9 +1256,9 @@ void PPTWriter::ImplWriteOLE( )
SvxMSExportOLEObjects aOleExport( mnCnvrtFlags );
- for ( std::vector<PPTExOleObjEntry*>::const_iterator it = maExOleObj.begin(); it != maExOleObj.end(); ++it )
+ for ( auto it = maExOleObj.begin(); it != maExOleObj.end(); ++it )
{
- PPTExOleObjEntry* pPtr = *it;
+ PPTExOleObjEntry* pPtr = it->get();
SvMemoryStream* pStrm = nullptr;
pPtr->nOfsB = mpStrm->Tell();
switch ( pPtr->eType )
@@ -1386,9 +1380,9 @@ bool PPTWriter::ImplWriteAtomEnding()
}
}
// Ole persists
- for ( std::vector<PPTExOleObjEntry*>::const_iterator it = maExOleObj.begin(); it != maExOleObj.end(); ++it )
+ for ( auto it = maExOleObj.begin(); it != maExOleObj.end(); ++it )
{
- PPTExOleObjEntry* pPtr = *it;
+ PPTExOleObjEntry* pPtr = it->get();
nOfs = mpPptEscherEx->PtGetOffsetByID( EPP_Persist_ExObj );
if ( nOfs )
{
diff --git a/sd/source/filter/eppt/eppt.hxx b/sd/source/filter/eppt/eppt.hxx
index af9f8d37e301..749b74123900 100644
--- a/sd/source/filter/eppt/eppt.hxx
+++ b/sd/source/filter/eppt/eppt.hxx
@@ -161,16 +161,16 @@ class PPTWriter final : public PPTWriterBase, public PPTExBulletProvider
sal_uInt32 mnTextSize;
tools::SvRef<SotStorage> mrStg;
- SvStream* mpCurUserStrm;
- SvStream* mpStrm;
- SvStream* mpPicStrm;
- PptEscherEx* mpPptEscherEx;
+ std::unique_ptr<SvStream> mpCurUserStrm;
+ std::unique_ptr<SvStream> mpStrm;
+ std::unique_ptr<SvStream> mpPicStrm;
+ std::unique_ptr<PptEscherEx> mpPptEscherEx;
- std::vector<PPTExOleObjEntry*> maExOleObj;
+ std::vector<std::unique_ptr<PPTExOleObjEntry>> maExOleObj;
sal_uInt32 mnVBAOleOfs;
SvMemoryStream* mpVBA;
sal_uInt32 mnExEmbed;
- SvMemoryStream* mpExEmbed;
+ std::unique_ptr<SvMemoryStream> mpExEmbed;
sal_uInt32 mnPagesWritten;
sal_uInt32 mnTxId; // Identifier determined by the HOST (PP) ????
diff --git a/sd/source/filter/eppt/epptbase.hxx b/sd/source/filter/eppt/epptbase.hxx
index 463067087503..b0b391697f5a 100644
--- a/sd/source/filter/eppt/epptbase.hxx
+++ b/sd/source/filter/eppt/epptbase.hxx
@@ -344,7 +344,7 @@ protected:
css::awt::Size maNotesPageSize;
PageType meLatestPageType;
- std::vector< PPTExStyleSheet* > maStyleSheetList;
+ std::vector< std::unique_ptr<PPTExStyleSheet> > maStyleSheetList;
PPTExStyleSheet* mpStyleSheet;
FontCollection maFontCollection;
diff --git a/sd/source/filter/eppt/epptso.cxx b/sd/source/filter/eppt/epptso.cxx
index 7f9ab18f795a..c6a1dad60b95 100644
--- a/sd/source/filter/eppt/epptso.cxx
+++ b/sd/source/filter/eppt/epptso.cxx
@@ -535,8 +535,8 @@ bool PPTWriter::ImplCloseDocument()
mpStrm->WriteBytes(aTxMasterStyleAtomStrm.GetData(), aTxMasterStyleAtomStrm.Tell());
maSoundCollection.Write( *mpStrm );
mpPptEscherEx->WriteDrawingGroupContainer( *mpStrm );
- ImplMasterSlideListContainer( mpStrm );
- ImplDocumentListContainer( mpStrm );
+ ImplMasterSlideListContainer( mpStrm.get() );
+ ImplDocumentListContainer( mpStrm.get() );
sal_uInt32 nOldPos = mpPptEscherEx->PtGetOffsetByID( EPP_Persist_CurrentPos );
if ( nOldPos )
@@ -828,7 +828,7 @@ void PPTWriter::ImplWritePortions( SvStream& rOut, TextObj& rTextObj )
case css::drawing::FillStyle_GRADIENT :
{
::tools::Rectangle aRect( Point(), Size( 28000, 21000 ) );
- EscherPropertyContainer aPropOpt( mpPptEscherEx->GetGraphicProvider(), mpPicStrm, aRect );
+ EscherPropertyContainer aPropOpt( mpPptEscherEx->GetGraphicProvider(), mpPicStrm.get(), aRect );
aPropOpt.CreateGradientProperties( mXPropSet );
aPropOpt.GetOpt( ESCHER_Prop_fillColor, nBackgroundColor );
}
@@ -850,7 +850,7 @@ void PPTWriter::ImplWritePortions( SvStream& rOut, TextObj& rTextObj )
case css::drawing::FillStyle_GRADIENT :
{
::tools::Rectangle aRect( Point(), Size( 28000, 21000 ) );
- EscherPropertyContainer aPropOpt( mpPptEscherEx->GetGraphicProvider(), mpPicStrm, aRect );
+ EscherPropertyContainer aPropOpt( mpPptEscherEx->GetGraphicProvider(), mpPicStrm.get(), aRect );
aPropOpt.CreateGradientProperties( mXBackgroundPropSet );
aPropOpt.GetOpt( ESCHER_Prop_fillColor, nBackgroundColor );
}
@@ -1693,7 +1693,7 @@ void PPTWriter::ImplWritePage( const PHLayout& rLayout, EscherSolverContainer& a
const css::awt::Size aSize100thmm( mXShape->getSize() );
const css::awt::Point aPoint100thmm( mXShape->getPosition() );
::tools::Rectangle aRect100thmm( Point( aPoint100thmm.X, aPoint100thmm.Y ), Size( aSize100thmm.Width, aSize100thmm.Height ) );
- EscherPropertyContainer aPropOpt( mpPptEscherEx->GetGraphicProvider(), mpPicStrm, aRect100thmm );
+ EscherPropertyContainer aPropOpt( mpPptEscherEx->GetGraphicProvider(), mpPicStrm.get(), aRect100thmm );
if ( bGroup )
{
@@ -1957,10 +1957,10 @@ void PPTWriter::ImplWritePage( const PHLayout& rLayout, EscherSolverContainer& a
mpExEmbed->WriteUInt32( EPP_ExControlAtom << 16 )
.WriteUInt32( 4 )
.WriteUInt32( nPageId );
- PPTExOleObjEntry* pEntry = new PPTExOleObjEntry( OCX_CONTROL, mpExEmbed->Tell() );
+ std::unique_ptr<PPTExOleObjEntry> pEntry( new PPTExOleObjEntry( OCX_CONTROL, mpExEmbed->Tell() ) );
pEntry->xControlModel = aXControlModel;
pEntry->xShape = mXShape;
- maExOleObj.push_back( pEntry );
+ maExOleObj.push_back( std::move(pEntry) );
mnExEmbed++;
@@ -2409,7 +2409,7 @@ void PPTWriter::ImplWritePage( const PHLayout& rLayout, EscherSolverContainer& a
else
mpStrm->WriteUInt32( EPP_TEXTTYPE_Body );
mnTextSize = aTextObj.Count();
- aTextObj.Write( mpStrm );
+ aTextObj.Write( mpStrm.get() );
mpPptEscherEx->BeginAtom();
for ( sal_uInt32 i = 0; i < aTextObj.ParagraphCount() ; ++i )
{
@@ -2516,9 +2516,9 @@ void PPTWriter::ImplWritePage( const PHLayout& rLayout, EscherSolverContainer& a
.WriteUChar( 0 ) // (bool)is object a world table
.WriteUChar( 0 ); // pad byte
- PPTExOleObjEntry* pE = new PPTExOleObjEntry( NORMAL_OLE_OBJECT, mpExEmbed->Tell() );
+ std::unique_ptr<PPTExOleObjEntry> pE( new PPTExOleObjEntry( NORMAL_OLE_OBJECT, mpExEmbed->Tell() ) );
pE->xShape = mXShape;
- maExOleObj.push_back( pE );
+ maExOleObj.push_back( std::move(pE) );
mnExEmbed++;
@@ -3105,8 +3105,8 @@ void PPTWriter::ImplCreateTable( uno::Reference< drawing::XShape > const & rXSha
if ( y == nRowCount - 1 && nPosition != maRect.Bottom())
maRect.SetBottom( nPosition );
}
- std::unique_ptr<ContainerGuard> xSpgrContainer(new ContainerGuard(mpPptEscherEx, ESCHER_SpgrContainer));
- std::unique_ptr<ContainerGuard> xSpContainer(new ContainerGuard(mpPptEscherEx, ESCHER_SpContainer));
+ std::unique_ptr<ContainerGuard> xSpgrContainer(new ContainerGuard(mpPptEscherEx.get(), ESCHER_SpgrContainer));
+ std::unique_ptr<ContainerGuard> xSpContainer(new ContainerGuard(mpPptEscherEx.get(), ESCHER_SpContainer));
mpPptEscherEx->AddAtom( 16, ESCHER_Spgr, 1 );
mpStrm ->WriteInt32( maRect.Left() ) // Bounding box for the grouped shapes to which they are attached
.WriteInt32( maRect.Top() )
@@ -3164,7 +3164,7 @@ void PPTWriter::ImplCreateTable( uno::Reference< drawing::XShape > const & rXSha
aAny >>= mbFontIndependentLineSpacing;
EscherPropertyContainer aPropOptSp;
- std::unique_ptr<ContainerGuard> xCellContainer(new ContainerGuard(mpPptEscherEx, ESCHER_SpContainer));
+ std::unique_ptr<ContainerGuard> xCellContainer(new ContainerGuard(mpPptEscherEx.get(), ESCHER_SpContainer));
ImplCreateShape( ESCHER_ShpInst_Rectangle,
ShapeFlag::HaveAnchor | ShapeFlag::HaveShapeProperty | ShapeFlag::Child,
aSolverContainer );
diff --git a/sd/source/filter/eppt/pptx-epptbase.cxx b/sd/source/filter/eppt/pptx-epptbase.cxx
index 84bbcc53dc28..b3e1c4787645 100644
--- a/sd/source/filter/eppt/pptx-epptbase.cxx
+++ b/sd/source/filter/eppt/pptx-epptbase.cxx
@@ -499,7 +499,7 @@ void PPTWriterBase::SetCurrentStyleSheet( sal_uInt32 nPageNum )
{
if ( nPageNum >= maStyleSheetList.size() )
nPageNum = 0;
- mpStyleSheet = maStyleSheetList[ nPageNum ];
+ mpStyleSheet = maStyleSheetList[ nPageNum ].get();
}
bool PPTWriterBase::GetStyleSheets()
@@ -526,7 +526,7 @@ bool PPTWriterBase::GetStyleSheets()
? static_cast<sal_uInt16>( *o3tl::doAccess<sal_Int32>(mAny) / 4.40972 )
: 1250;
- maStyleSheetList.push_back( new PPTExStyleSheet( nDefaultTab, dynamic_cast<PPTExBulletProvider*>(this) ) );
+ maStyleSheetList.emplace_back( new PPTExStyleSheet( nDefaultTab, dynamic_cast<PPTExBulletProvider*>(this) ) );
SetCurrentStyleSheet( nPageNum );
if ( GetPageByIndex( nPageNum, MASTER ) )
aXNamed.set( mXDrawPage, UNO_QUERY );
More information about the Libreoffice-commits
mailing list