sd/inc/undo/undoobjects.hxx | 2 +- sd/source/core/undo/undoobjects.cxx | 3 +-- sd/source/filter/eppt/eppt.hxx | 7 +------ sd/source/filter/eppt/epptbase.hxx | 3 ++- sd/source/filter/eppt/epptso.cxx | 13 +++++++------ sd/source/filter/ppt/pptin.cxx | 3 +-- sd/source/filter/ppt/pptin.hxx | 2 +- sd/source/filter/ppt/propread.cxx | 13 ++++++------- sd/source/filter/ppt/propread.hxx | 8 ++++---- sd/source/ui/func/fupage.cxx | 12 +++++------- sd/source/ui/inc/fupage.hxx | 3 ++- sd/source/ui/inc/unosrch.hxx | 2 +- sd/source/ui/unoidl/unosrch.cxx | 3 +-- 13 files changed, 33 insertions(+), 41 deletions(-)
New commits: commit f3a90d13056ca23708cc4fd9562c99d0b41a4b6f Author: Noel Grandin <noel.gran...@collabora.co.uk> Date: Tue Jan 17 10:12:10 2017 +0200 new loplugin: useuniqueptr: sd Change-Id: I2fc8a2fa57cc00edf2edab9e3722c824e75cb7e5 Reviewed-on: https://gerrit.libreoffice.org/33204 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/sd/inc/undo/undoobjects.hxx b/sd/inc/undo/undoobjects.hxx index ee2d3bf..a1d208c 100644 --- a/sd/inc/undo/undoobjects.hxx +++ b/sd/inc/undo/undoobjects.hxx @@ -92,7 +92,7 @@ public: virtual void Redo() override; private: - SfxUndoAction* mpUndoAnimation; + std::unique_ptr<SfxUndoAction> mpUndoAnimation; bool mbNewEmptyPresObj; SdrObjectWeakRef mxSdrObject; }; diff --git a/sd/source/core/undo/undoobjects.cxx b/sd/source/core/undo/undoobjects.cxx index d4e7d63..101fd27 100644 --- a/sd/source/core/undo/undoobjects.cxx +++ b/sd/source/core/undo/undoobjects.cxx @@ -186,14 +186,13 @@ UndoObjectSetText::UndoObjectSetText( SdrObject& rObject, sal_Int32 nText ) css::uno::Reference< css::drawing::XShape > xShape( rObject.getUnoShape(), css::uno::UNO_QUERY ); if( pPage->getMainSequence()->hasEffect( xShape ) ) { - mpUndoAnimation = new UndoAnimation( static_cast< SdDrawDocument* >( pPage->GetModel() ), pPage ); + mpUndoAnimation.reset( new UndoAnimation( static_cast< SdDrawDocument* >( pPage->GetModel() ), pPage ) ); } } } UndoObjectSetText::~UndoObjectSetText() { - delete mpUndoAnimation; } void UndoObjectSetText::Undo() diff --git a/sd/source/filter/eppt/eppt.hxx b/sd/source/filter/eppt/eppt.hxx index 98718fe..0447c25 100644 --- a/sd/source/filter/eppt/eppt.hxx +++ b/sd/source/filter/eppt/eppt.hxx @@ -135,12 +135,7 @@ struct PPTExOleObjEntry struct TextRuleEntry { - SvMemoryStream* pOut; - - explicit TextRuleEntry() : - pOut ( nullptr ){}; - - ~TextRuleEntry() { delete pOut; }; + std::unique_ptr<SvMemoryStream> pOut; }; class TextObjBinary : public TextObj diff --git a/sd/source/filter/eppt/epptbase.hxx b/sd/source/filter/eppt/epptbase.hxx index af03a99..8925ff2 100644 --- a/sd/source/filter/eppt/epptbase.hxx +++ b/sd/source/filter/eppt/epptbase.hxx @@ -120,7 +120,8 @@ class PPTExBulletProvider SvMemoryStream aBuExOutlineStream; SvMemoryStream aBuExMasterStream; - EscherGraphicProvider* pGraphicProv; + std::unique_ptr<EscherGraphicProvider> + pGraphicProv; public: diff --git a/sd/source/filter/eppt/epptso.cxx b/sd/source/filter/eppt/epptso.cxx index aa1ffcb0..8be0b03 100644 --- a/sd/source/filter/eppt/epptso.cxx +++ b/sd/source/filter/eppt/epptso.cxx @@ -97,13 +97,12 @@ using namespace ::com::sun::star; #define FIXED_PITCH 0x01 PPTExBulletProvider::PPTExBulletProvider() + : pGraphicProv( new EscherGraphicProvider( EscherGraphicProviderFlags::UseInstances ) ) { - pGraphicProv = new EscherGraphicProvider( EscherGraphicProviderFlags::UseInstances ); } PPTExBulletProvider::~PPTExBulletProvider() { - delete pGraphicProv; } sal_uInt16 PPTExBulletProvider::GetId( const OString& rUniqueId, Size& rGraphicSize ) @@ -1266,7 +1265,10 @@ void PPTWriter::ImplWriteTextStyleAtom( SvStream& rOut, int nTextInstance, sal_u { SvStream* pRuleOut = &rOut; if ( pTextRule ) - pRuleOut = pTextRule->pOut = new SvMemoryStream( 0x100, 0x100 ); + { + pTextRule->pOut.reset( new SvMemoryStream( 0x100, 0x100 ) ); + pRuleOut = pTextRule->pOut.get(); + } sal_uInt32 nRulePos = pRuleOut->Tell(); pRuleOut->WriteUInt32( EPP_TextRulerAtom << 16 ).WriteUInt32( 0 ); @@ -2763,12 +2765,11 @@ void PPTWriter::ImplWritePage( const PHLayout& rLayout, EscherSolverContainer& a ImplGetText(); ImplWriteTextStyleAtom( *pClientTextBox, nTextType, nPObjects, &aTextRule, aExtBu, nullptr ); ImplWriteExtParaHeader( aExtBu, nPObjects++, nTextType, nPageNumber + 0x100 ); - SvMemoryStream* pOut = aTextRule.pOut; + SvMemoryStream* pOut = aTextRule.pOut.get(); if ( pOut ) { pClientTextBox->WriteBytes(pOut->GetData(), pOut->Tell()); - delete pOut; - aTextRule.pOut = nullptr; + aTextRule.pOut.reset(); } if ( aExtBu.Tell() ) { diff --git a/sd/source/filter/ppt/pptin.cxx b/sd/source/filter/ppt/pptin.cxx index c530499..c7f443c 100644 --- a/sd/source/filter/ppt/pptin.cxx +++ b/sd/source/filter/ppt/pptin.cxx @@ -155,7 +155,7 @@ SdPPTImport::SdPPTImport( SdDrawDocument* pDocument, SvStream& rDocStream, SotSt } } - pFilter = new ImplSdPPTImport( pDocument, rStorage, rMedium, aParam ); + pFilter.reset( new ImplSdPPTImport( pDocument, rStorage, rMedium, aParam ) ); } bool SdPPTImport::Import() @@ -165,7 +165,6 @@ bool SdPPTImport::Import() SdPPTImport::~SdPPTImport() { - delete pFilter; } ImplSdPPTImport::ImplSdPPTImport( SdDrawDocument* pDocument, SotStorage& rStorage_, SfxMedium& rMedium, PowerPointImportParam& rParam ) diff --git a/sd/source/filter/ppt/pptin.hxx b/sd/source/filter/ppt/pptin.hxx index f943592..ac5eb28 100644 --- a/sd/source/filter/ppt/pptin.hxx +++ b/sd/source/filter/ppt/pptin.hxx @@ -82,7 +82,7 @@ public: class SdPPTImport { - ImplSdPPTImport* pFilter; + std::unique_ptr<ImplSdPPTImport> pFilter; public: diff --git a/sd/source/filter/ppt/propread.cxx b/sd/source/filter/ppt/propread.cxx index 383f403..2167bda 100644 --- a/sd/source/filter/ppt/propread.cxx +++ b/sd/source/filter/ppt/propread.cxx @@ -28,7 +28,7 @@ PropEntry::PropEntry( sal_uInt32 nId, const sal_uInt8* pBuf, sal_uInt32 nBufSize mnSize ( nBufSize ), mpBuf ( new sal_uInt8[ nBufSize ] ) { - memcpy( static_cast<void*>(mpBuf), static_cast<void const *>(pBuf), nBufSize ); + memcpy( mpBuf.get(), pBuf, nBufSize ); }; PropEntry::PropEntry( const PropEntry& rProp ) : @@ -36,18 +36,17 @@ PropEntry::PropEntry( const PropEntry& rProp ) : mnSize ( rProp.mnSize ), mpBuf ( new sal_uInt8[ mnSize ] ) { - memcpy( static_cast<void*>(mpBuf), static_cast<void const *>(rProp.mpBuf), mnSize ); + memcpy( mpBuf.get(), rProp.mpBuf.get(), mnSize ); }; PropEntry& PropEntry::operator=(const PropEntry& rPropEntry) { if ( this != &rPropEntry ) { - delete[] mpBuf; mnId = rPropEntry.mnId; mnSize = rPropEntry.mnSize; - mpBuf = new sal_uInt8[ mnSize ]; - memcpy( static_cast<void*>(mpBuf), static_cast<void const *>(rPropEntry.mpBuf), mnSize ); + mpBuf.reset( new sal_uInt8[ mnSize ] ); + memcpy( mpBuf.get(), rPropEntry.mpBuf.get(), mnSize ); } return *this; } @@ -235,7 +234,7 @@ bool Section::GetProperty( sal_uInt32 nId, PropItem& rPropItem ) { rPropItem.Clear(); rPropItem.SetTextEncoding( mnTextEnc ); - rPropItem.WriteBytes( (*iter)->mpBuf, (*iter)->mnSize ); + rPropItem.WriteBytes( (*iter)->mpBuf.get(), (*iter)->mnSize ); rPropItem.Seek( STREAM_SEEK_TO_BEGIN ); return true; } @@ -280,7 +279,7 @@ void Section::GetDictionary(Dictionary& rDict) if (iter == maEntries.end()) return; - SvMemoryStream aStream( (*iter)->mpBuf, (*iter)->mnSize, StreamMode::READ ); + SvMemoryStream aStream( (*iter)->mpBuf.get(), (*iter)->mnSize, StreamMode::READ ); aStream.Seek( STREAM_SEEK_TO_BEGIN ); sal_uInt32 nDictCount(0); aStream.ReadUInt32( nDictCount ); diff --git a/sd/source/filter/ppt/propread.hxx b/sd/source/filter/ppt/propread.hxx index 04c619a..c874eeb 100644 --- a/sd/source/filter/ppt/propread.hxx +++ b/sd/source/filter/ppt/propread.hxx @@ -85,13 +85,13 @@ typedef std::map<OUString,sal_uInt32> Dictionary; struct PropEntry { - sal_uInt32 mnId; - sal_uInt32 mnSize; - sal_uInt8* mpBuf; + sal_uInt32 mnId; + sal_uInt32 mnSize; + std::unique_ptr<sal_uInt8[]> mpBuf; PropEntry( sal_uInt32 nId, const sal_uInt8* pBuf, sal_uInt32 nBufSize ); PropEntry( const PropEntry& rProp ); - ~PropEntry() { delete[] mpBuf; } ; + ~PropEntry() {} PropEntry& operator=(const PropEntry& rPropEntry); }; diff --git a/sd/source/ui/func/fupage.cxx b/sd/source/ui/func/fupage.cxx index 6bf77d4..59c7cf2 100644 --- a/sd/source/ui/func/fupage.cxx +++ b/sd/source/ui/func/fupage.cxx @@ -159,7 +159,6 @@ void FuPage::DoExecute( SfxRequest& ) FuPage::~FuPage() { - delete mpBackgroundObjUndoAction; } void FuPage::Activate() @@ -386,8 +385,8 @@ const SfxItemSet* FuPage::ExecuteDialog( vcl::Window* pParent ) if( mbPageBckgrdDeleted ) { - mpBackgroundObjUndoAction = new SdBackgroundObjUndoAction( - *mpDoc, *mpPage, mpPage->getSdrPageProperties().GetItemSet()); + mpBackgroundObjUndoAction.reset( new SdBackgroundObjUndoAction( + *mpDoc, *mpPage, mpPage->getSdrPageProperties().GetItemSet()) ); if(!mpPage->IsMasterPage()) { @@ -609,9 +608,8 @@ void FuPage::ApplyItemSet( const SfxItemSet* pArgs ) if( !mbMasterPage && !mbPageBckgrdDeleted ) { // Only this page - delete mpBackgroundObjUndoAction; - mpBackgroundObjUndoAction = new SdBackgroundObjUndoAction( - *mpDoc, *mpPage, mpPage->getSdrPageProperties().GetItemSet()); + mpBackgroundObjUndoAction.reset( new SdBackgroundObjUndoAction( + *mpDoc, *mpPage, mpPage->getSdrPageProperties().GetItemSet()) ); SfxItemSet aSet( *pArgs ); sdr::properties::CleanupFillProperties(aSet); mpPage->getSdrPageProperties().ClearItem(); @@ -623,7 +621,7 @@ void FuPage::ApplyItemSet( const SfxItemSet* pArgs ) if( mpBackgroundObjUndoAction ) { // set merge flag, because a SdUndoGroupAction could have been inserted before - mpDocSh->GetUndoManager()->AddUndoAction( mpBackgroundObjUndoAction, true ); + mpDocSh->GetUndoManager()->AddUndoAction( mpBackgroundObjUndoAction.get(), true ); mpBackgroundObjUndoAction = nullptr; } diff --git a/sd/source/ui/inc/fupage.hxx b/sd/source/ui/inc/fupage.hxx index fe17d2a..a4aead4 100644 --- a/sd/source/ui/inc/fupage.hxx +++ b/sd/source/ui/inc/fupage.hxx @@ -57,7 +57,8 @@ private: SfxRequest& mrReq; const SfxItemSet* mpArgs; - SdBackgroundObjUndoAction* mpBackgroundObjUndoAction; + std::unique_ptr<SdBackgroundObjUndoAction> + mpBackgroundObjUndoAction; Size maSize; bool mbPageBckgrdDeleted; bool mbMasterPage; diff --git a/sd/source/ui/inc/unosrch.hxx b/sd/source/ui/inc/unosrch.hxx index 8487993..342b010 100644 --- a/sd/source/ui/inc/unosrch.hxx +++ b/sd/source/ui/inc/unosrch.hxx @@ -77,7 +77,7 @@ public: class SdUnoSearchReplaceDescriptor : public ::cppu::WeakImplHelper< css::lang::XUnoTunnel, css::util::XReplaceDescriptor > // public css::util::XSearchDescriptor, css::beans::XPropertySet { protected: - SvxItemPropertySet* mpPropSet; + std::unique_ptr<SvxItemPropertySet> mpPropSet; bool mbBackwards; bool mbCaseSensitive; diff --git a/sd/source/ui/unoidl/unosrch.cxx b/sd/source/ui/unoidl/unosrch.cxx index f043d04..f48ce25 100644 --- a/sd/source/ui/unoidl/unosrch.cxx +++ b/sd/source/ui/unoidl/unosrch.cxx @@ -704,7 +704,7 @@ UNO3_GETIMPLEMENTATION_IMPL( SdUnoSearchReplaceDescriptor ); SdUnoSearchReplaceDescriptor::SdUnoSearchReplaceDescriptor( bool bReplace ) throw (css::uno::RuntimeException) { - mpPropSet = new SvxItemPropertySet(ImplGetSearchPropertyMap(), SdrObject::GetGlobalDrawObjectItemPool()); + mpPropSet.reset( new SvxItemPropertySet(ImplGetSearchPropertyMap(), SdrObject::GetGlobalDrawObjectItemPool()) ); mbBackwards = false; mbCaseSensitive = false; @@ -715,7 +715,6 @@ SdUnoSearchReplaceDescriptor::SdUnoSearchReplaceDescriptor( bool bReplace ) thro SdUnoSearchReplaceDescriptor::~SdUnoSearchReplaceDescriptor() throw() { - delete mpPropSet; } // XSearchDescriptor _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits