[Libreoffice-commits] core.git: include/sfx2 sfx2/inc sfx2/source

Noel Grandin noel.grandin at collabora.co.uk
Tue Jan 17 10:48:51 UTC 2017


 include/sfx2/childwin.hxx              |    2 -
 include/sfx2/docinsert.hxx             |    3 +-
 include/sfx2/mieclip.hxx               |    6 ++--
 include/sfx2/sfxbasecontroller.hxx     |    2 -
 sfx2/inc/bitset.hxx                    |    8 ++++--
 sfx2/source/appl/appcfg.cxx            |   13 ++--------
 sfx2/source/appl/appchild.cxx          |    2 -
 sfx2/source/appl/childwin.cxx          |    1 
 sfx2/source/appl/linksrc.cxx           |   40 +++++++++++----------------------
 sfx2/source/appl/lnkbase2.cxx          |   11 ++++-----
 sfx2/source/bastyp/bitset.cxx          |   17 +++++---------
 sfx2/source/bastyp/mieclip.cxx         |   17 ++++----------
 sfx2/source/control/request.cxx        |   16 +++++--------
 sfx2/source/doc/docinsert.cxx          |    9 +++----
 sfx2/source/doc/doctemplates.cxx       |   10 +-------
 sfx2/source/doc/printhelper.cxx        |    3 --
 sfx2/source/doc/printhelper.hxx        |    2 -
 sfx2/source/view/sfxbasecontroller.cxx |    1 
 sfx2/source/view/viewprn.cxx           |   14 ++++-------
 19 files changed, 69 insertions(+), 108 deletions(-)

New commits:
commit 49bfc59272f8482ca37abc631d2c3777518fd1d5
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Tue Jan 17 10:13:14 2017 +0200

    new loplugin: useuniqueptr: sfx2
    
    Change-Id: I544c615105d14fa258fed7f30790d305e987f523
    Reviewed-on: https://gerrit.libreoffice.org/33206
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/include/sfx2/childwin.hxx b/include/sfx2/childwin.hxx
index 3068d00..a8c1b23 100644
--- a/include/sfx2/childwin.hxx
+++ b/include/sfx2/childwin.hxx
@@ -108,7 +108,7 @@ struct SFX2_DLLPUBLIC SfxChildWinFactory
     sal_uInt16                  nId;    // ChildWindow-Id ( SlotId )
     SfxChildWinInfo             aInfo;  // Configuration
     sal_uInt16                  nPos;   // Position in UI
-    SfxChildWinContextArr_Impl *pArr;   // Array for Contexts
+    std::unique_ptr<SfxChildWinContextArr_Impl> pArr;   // Array for Contexts
 
     SfxChildWinFactory( SfxChildWinCtor pTheCtor, sal_uInt16 nID, sal_uInt16 n );
     ~SfxChildWinFactory();
diff --git a/include/sfx2/docinsert.hxx b/include/sfx2/docinsert.hxx
index a18b6fd..4f47a79 100644
--- a/include/sfx2/docinsert.hxx
+++ b/include/sfx2/docinsert.hxx
@@ -45,7 +45,8 @@ private:
     FileDialogFlags const m_nDlgFlags;
     ErrCode                 m_nError;
 
-    sfx2::FileDialogHelper* m_pFileDlg;
+    std::unique_ptr<sfx2::FileDialogHelper>
+                            m_pFileDlg;
     SfxItemSet*             m_pItemSet;
     std::vector<OUString>   m_pURLList;
 
diff --git a/include/sfx2/mieclip.hxx b/include/sfx2/mieclip.hxx
index e8ce8e9..365b8ed 100644
--- a/include/sfx2/mieclip.hxx
+++ b/include/sfx2/mieclip.hxx
@@ -31,11 +31,11 @@ class SvData;
 
 class SFX2_DLLPUBLIC MSE40HTMLClipFormatObj
 {
-    SvStream* pStrm;
-    OUString  sBaseURL;
+    std::unique_ptr<SvStream> pStrm;
+    OUString                  sBaseURL;
 
 public:
-    MSE40HTMLClipFormatObj() : pStrm(nullptr)         {}
+    MSE40HTMLClipFormatObj() {}
     ~MSE40HTMLClipFormatObj();
 
     SvStream* IsValid( SvStream& );
diff --git a/include/sfx2/sfxbasecontroller.hxx b/include/sfx2/sfxbasecontroller.hxx
index af32849..a8d979e 100644
--- a/include/sfx2/sfxbasecontroller.hxx
+++ b/include/sfx2/sfxbasecontroller.hxx
@@ -196,7 +196,7 @@ private:
 
     DECL_LINK( CheckOutHandler, Button*, void );
 
-    IMPL_SfxBaseController_DataContainer*   m_pData ;
+    std::unique_ptr<IMPL_SfxBaseController_DataContainer>   m_pData ;
 
 } ; // class SfxBaseController
 
diff --git a/sfx2/inc/bitset.hxx b/sfx2/inc/bitset.hxx
index d3f3b28..d33ccf5 100644
--- a/sfx2/inc/bitset.hxx
+++ b/sfx2/inc/bitset.hxx
@@ -19,12 +19,14 @@
 #ifndef INCLUDED_SFX2_INC_BITSET_HXX
 #define INCLUDED_SFX2_INC_BITSET_HXX
 
+#include <memory>
+
 class IndexBitSet
 {
 private:
-    sal_uInt16 nBlocks;
-    sal_uInt16 nCount;
-    sal_uInt32* pBitmap;
+    sal_uInt16                    nBlocks;
+    sal_uInt16                    nCount;
+    std::unique_ptr<sal_uInt32[]> pBitmap;
 
     IndexBitSet& operator|=( sal_uInt16 nBit );
     IndexBitSet& operator-=( sal_uInt16 nBit );
diff --git a/sfx2/source/appl/appcfg.cxx b/sfx2/source/appl/appcfg.cxx
index a430396..b7e89dc 100644
--- a/sfx2/source/appl/appcfg.cxx
+++ b/sfx2/source/appl/appcfg.cxx
@@ -81,14 +81,13 @@ using namespace ::com::sun::star::beans;
 
 class SfxEventAsyncer_Impl : public SfxListener
 {
-    SfxEventHint        aHint;
-    Idle*               pIdle;
+    SfxEventHint           aHint;
+    std::unique_ptr<Idle>  pIdle;
 
 public:
 
     virtual void        Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
     explicit SfxEventAsyncer_Impl(const SfxEventHint& rHint);
-    virtual ~SfxEventAsyncer_Impl() override;
     DECL_LINK( IdleHdl, Idle*, void );
 };
 
@@ -108,19 +107,13 @@ SfxEventAsyncer_Impl::SfxEventAsyncer_Impl( const SfxEventHint& rHint )
 {
     if( rHint.GetObjShell() )
         StartListening( *rHint.GetObjShell() );
-    pIdle = new Idle("SfxEventASyncer");
+    pIdle.reset( new Idle("SfxEventASyncer") );
     pIdle->SetIdleHdl( LINK(this, SfxEventAsyncer_Impl, IdleHdl) );
     pIdle->SetPriority( SchedulerPriority::HIGHEST );
     pIdle->Start();
 }
 
 
-SfxEventAsyncer_Impl::~SfxEventAsyncer_Impl()
-{
-    delete pIdle;
-}
-
-
 IMPL_LINK(SfxEventAsyncer_Impl, IdleHdl, Idle*, pAsyncIdle, void)
 {
     SfxObjectShellRef xRef( aHint.GetObjShell() );
diff --git a/sfx2/source/appl/appchild.cxx b/sfx2/source/appl/appchild.cxx
index 2669ab9..1c36be3 100644
--- a/sfx2/source/appl/appchild.cxx
+++ b/sfx2/source/appl/appchild.cxx
@@ -115,7 +115,7 @@ void SfxApplication::RegisterChildWindowContext_Impl( SfxModule *pMod, sal_uInt1
     if ( pF )
     {
         if ( !pF->pArr )
-            pF->pArr = new SfxChildWinContextArr_Impl;
+            pF->pArr.reset( new SfxChildWinContextArr_Impl );
         pF->pArr->push_back( pFact );
         return;
     }
diff --git a/sfx2/source/appl/childwin.cxx b/sfx2/source/appl/childwin.cxx
index a637818..54a581c 100644
--- a/sfx2/source/appl/childwin.cxx
+++ b/sfx2/source/appl/childwin.cxx
@@ -51,7 +51,6 @@ SfxChildWinFactory::SfxChildWinFactory( SfxChildWinCtor pTheCtor, sal_uInt16 nID
 
 SfxChildWinFactory::~SfxChildWinFactory()
 {
-    delete pArr;
 }
 
 struct SfxChildWindow_Impl
diff --git a/sfx2/source/appl/linksrc.cxx b/sfx2/source/appl/linksrc.cxx
index d146fe9..e7c5a38 100644
--- a/sfx2/source/appl/linksrc.cxx
+++ b/sfx2/source/appl/linksrc.cxx
@@ -53,14 +53,14 @@ void SvLinkSourceTimer::Invoke()
     pOwner->SendDataChanged();
 }
 
-static void StartTimer( SvLinkSourceTimer ** ppTimer, SvLinkSource * pOwner,
+static void StartTimer( std::unique_ptr<SvLinkSourceTimer>& pTimer, SvLinkSource * pOwner,
                         sal_uIntPtr nTimeout )
 {
-    if( !*ppTimer )
+    if( !pTimer )
     {
-        *ppTimer = new SvLinkSourceTimer( pOwner );
-        (*ppTimer)->SetTimeout( nTimeout );
-        (*ppTimer)->Start();
+        pTimer.reset( new SvLinkSourceTimer( pOwner ) );
+        pTimer->SetTimeout( nTimeout );
+        pTimer->Start();
     }
 }
 
@@ -182,11 +182,12 @@ struct SvLinkSource_Impl
 {
     SvLinkSource_Array_Impl aArr;
     OUString                aDataMimeType;
-    SvLinkSourceTimer *     pTimer;
+    std::unique_ptr<SvLinkSourceTimer>
+                            pTimer;
     sal_uIntPtr             nTimeout;
     css::uno::Reference<css::io::XInputStream>
-                           m_xInputStreamToLoadFrom;
-    bool               m_bIsReadOnly;
+                            m_xInputStreamToLoadFrom;
+    bool                    m_bIsReadOnly;
 
     SvLinkSource_Impl()
         : pTimer(nullptr)
@@ -199,7 +200,6 @@ struct SvLinkSource_Impl
 
 SvLinkSource_Impl::~SvLinkSource_Impl()
 {
-    delete pTimer;
 }
 
 SvLinkSource::SvLinkSource()
@@ -279,18 +279,14 @@ void SvLinkSource::SendDataChanged()
             }
         }
     }
-    if( pImpl->pTimer )
-    {
-        delete pImpl->pTimer;
-        pImpl->pTimer = nullptr;
-    }
+    pImpl->pTimer.reset();
     pImpl->aDataMimeType.clear();
 }
 
 void SvLinkSource::NotifyDataChanged()
 {
     if( pImpl->nTimeout )
-        StartTimer( &pImpl->pTimer, this, pImpl->nTimeout ); // New timeout
+        StartTimer( pImpl->pTimer, this, pImpl->nTimeout ); // New timeout
     else
     {
         SvLinkSource_EntryIter_Impl aIter( pImpl->aArr );
@@ -313,11 +309,7 @@ void SvLinkSource::NotifyDataChanged()
                 }
             }
 
-        if( pImpl->pTimer )
-        {
-            delete pImpl->pTimer;
-            pImpl->pTimer = nullptr;
-        }
+        pImpl->pTimer.reset();
     }
 }
 
@@ -330,7 +322,7 @@ void SvLinkSource::DataChanged( const OUString & rMimeType,
     {   // only when no data was included
         // fire all data to the sink, independent of the requested format
         pImpl->aDataMimeType = rMimeType;
-        StartTimer( &pImpl->pTimer, this, pImpl->nTimeout ); // New timeout
+        StartTimer( pImpl->pTimer, this, pImpl->nTimeout ); // New timeout
     }
     else
     {
@@ -351,11 +343,7 @@ void SvLinkSource::DataChanged( const OUString & rMimeType,
             }
         }
 
-        if( pImpl->pTimer )
-        {
-            delete pImpl->pTimer;
-            pImpl->pTimer = nullptr;
-        }
+        pImpl->pTimer.reset();
     }
 }
 
diff --git a/sfx2/source/appl/lnkbase2.cxx b/sfx2/source/appl/lnkbase2.cxx
index fd0d8fb..44f7e5e 100644
--- a/sfx2/source/appl/lnkbase2.cxx
+++ b/sfx2/source/appl/lnkbase2.cxx
@@ -46,7 +46,8 @@ struct BaseLink_Impl
     Link<SvBaseLink&,void> m_aEndEditLink;
     LinkManager*        m_pLinkMgr;
     VclPtr<vcl::Window> m_pParentWin;
-    FileDialogHelper*   m_pFileDlg;
+    std::unique_ptr<FileDialogHelper>
+                        m_pFileDlg;
     bool                m_bIsConnect;
 
     BaseLink_Impl() :
@@ -57,7 +58,7 @@ struct BaseLink_Impl
         {}
 
     ~BaseLink_Impl()
-        { delete m_pFileDlg; }
+        {}
 };
 
 // only for internal management
@@ -535,11 +536,9 @@ void SvBaseLink::Closed()
 
 FileDialogHelper & SvBaseLink::GetInsertFileDialog(const OUString& rFactory) const
 {
-    if ( pImpl->m_pFileDlg )
-        delete pImpl->m_pFileDlg;
-    pImpl->m_pFileDlg = new FileDialogHelper(
+    pImpl->m_pFileDlg.reset( new FileDialogHelper(
             ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE,
-            FileDialogFlags::Insert, rFactory);
+            FileDialogFlags::Insert, rFactory) );
     return *pImpl->m_pFileDlg;
 }
 
diff --git a/sfx2/source/bastyp/bitset.cxx b/sfx2/source/bastyp/bitset.cxx
index d03a7d2..ac113cf 100644
--- a/sfx2/source/bastyp/bitset.cxx
+++ b/sfx2/source/bastyp/bitset.cxx
@@ -35,9 +35,9 @@ IndexBitSet& IndexBitSet::operator-=(sal_uInt16 nBit)
     if ( nBlock >= nBlocks )
       return *this;
 
-    if ( (*(pBitmap+nBlock) & nBitVal) )
+    if ( pBitmap[nBlock] & nBitVal )
     {
-        *(pBitmap+nBlock) &= ~nBitVal;
+        pBitmap[nBlock] &= ~nBitVal;
         --nCount;
     }
 
@@ -58,16 +58,15 @@ IndexBitSet& IndexBitSet::operator|=( sal_uInt16 nBit )
 
         if ( pBitmap )
         {
-            memcpy( pNewMap, pBitmap, 4 * nBlocks );
-            delete [] pBitmap;
+            memcpy( pNewMap, pBitmap.get(), 4 * nBlocks );
         }
-        pBitmap = pNewMap;
+        pBitmap.reset(pNewMap);
         nBlocks = nBlock+1;
     }
 
-    if ( (*(pBitmap+nBlock) & nBitVal) == 0 )
+    if ( (pBitmap[nBlock] & nBitVal) == 0 )
     {
-        *(pBitmap+nBlock) |= nBitVal;
+        pBitmap[nBlock] |= nBitVal;
         ++nCount;
     }
 
@@ -84,19 +83,17 @@ bool IndexBitSet::Contains( sal_uInt16 nBit ) const
 
     if ( nBlock >= nBlocks )
         return false;
-    return ( nBitVal & *(pBitmap+nBlock) ) == nBitVal;
+    return ( nBitVal & pBitmap[nBlock] ) == nBitVal;
 }
 
 IndexBitSet::IndexBitSet()
 {
     nCount = 0;
     nBlocks = 0;
-    pBitmap = nullptr;
 }
 
 IndexBitSet::~IndexBitSet()
 {
-    delete [] pBitmap;
 }
 
 sal_uInt16 IndexBitSet::GetFreeIndex()
diff --git a/sfx2/source/bastyp/mieclip.cxx b/sfx2/source/bastyp/mieclip.cxx
index 65c2fee..b9680af 100644
--- a/sfx2/source/bastyp/mieclip.cxx
+++ b/sfx2/source/bastyp/mieclip.cxx
@@ -27,17 +27,12 @@
 
 MSE40HTMLClipFormatObj::~MSE40HTMLClipFormatObj()
 {
-    delete pStrm;
 }
 
 SvStream* MSE40HTMLClipFormatObj::IsValid( SvStream& rStream )
 {
     bool bRet = false;
-    if( pStrm )
-    {
-        delete pStrm;
-        pStrm = nullptr;
-    }
+    pStrm.reset();
 
     OString sLine, sVersion;
     sal_Int32 nStt = -1, nEnd = -1, nFragStart = -1, nFragEnd = -1;
@@ -78,13 +73,13 @@ SvStream* MSE40HTMLClipFormatObj::IsValid( SvStream& rStream )
     {
         rStream.Seek( nStt );
 
-        pStrm = new SvMemoryStream( ( nEnd - nStt < 0x10000l
+        pStrm.reset( new SvMemoryStream( ( nEnd - nStt < 0x10000l
                                         ? nEnd - nStt + 32
-                                        : 0 ));
+                                        : 0 )) );
         pStrm->WriteStream( rStream );
         pStrm->SetStreamSize( nEnd - nStt + 1L );
         pStrm->Seek( STREAM_SEEK_TO_BEGIN );
-        return pStrm;
+        return pStrm.get();
     }
 
     if (nFragStart > 0 && nFragEnd > 0 && nFragEnd > nFragStart)
@@ -93,11 +88,11 @@ SvStream* MSE40HTMLClipFormatObj::IsValid( SvStream& rStream )
         if (nSize < 0x10000L)
         {
             rStream.Seek(nFragStart);
-            pStrm = new SvMemoryStream(nSize);
+            pStrm.reset( new SvMemoryStream(nSize) );
             pStrm->WriteStream( rStream );
             pStrm->SetStreamSize(nSize);
             pStrm->Seek(STREAM_SEEK_TO_BEGIN);
-            return pStrm;
+            return pStrm.get();
         }
     }
 
diff --git a/sfx2/source/control/request.cxx b/sfx2/source/control/request.cxx
index de254f1..a7785cf 100644
--- a/sfx2/source/control/request.cxx
+++ b/sfx2/source/control/request.cxx
@@ -64,7 +64,8 @@ struct SfxRequest_Impl: public SfxListener
     bool            bCancelled;  // no longer notify
     SfxCallMode     nCallMode;   // Synch/Asynch/API/Record
     bool            bAllowRecording;
-    SfxAllItemSet*  pInternalArgs;
+    std::unique_ptr<SfxAllItemSet>
+                    pInternalArgs;
     SfxViewFrame*   pViewFrame;
 
     css::uno::Reference< css::frame::XDispatchRecorder > xRecorder;
@@ -81,10 +82,8 @@ struct SfxRequest_Impl: public SfxListener
         , bCancelled(false)
         , nCallMode( SfxCallMode::SYNCHRON )
         , bAllowRecording( false )
-        , pInternalArgs( nullptr )
         , pViewFrame(nullptr)
         {}
-    virtual ~SfxRequest_Impl() override { delete pInternalArgs; }
 
 
     void                SetPool( SfxItemPool *pNewPool );
@@ -146,7 +145,7 @@ SfxRequest::SfxRequest
     pImpl->nModifier = rOrig.pImpl->nModifier;
 
     // deep copy needed !
-    pImpl->pInternalArgs = (rOrig.pImpl->pInternalArgs ? new SfxAllItemSet(*rOrig.pImpl->pInternalArgs) : nullptr);
+    pImpl->pInternalArgs.reset( rOrig.pImpl->pInternalArgs ? new SfxAllItemSet(*rOrig.pImpl->pInternalArgs) : nullptr);
 
     if ( pArgs )
         pImpl->SetPool( pArgs->GetPool() );
@@ -301,13 +300,12 @@ void SfxRequest::SetSynchronCall( bool bSynchron )
 
 void SfxRequest::SetInternalArgs_Impl( const SfxAllItemSet& rArgs )
 {
-    delete pImpl->pInternalArgs;
-    pImpl->pInternalArgs = new SfxAllItemSet( rArgs );
+    pImpl->pInternalArgs.reset( new SfxAllItemSet( rArgs ) );
 }
 
 const SfxItemSet* SfxRequest::GetInternalArgs_Impl() const
 {
-    return pImpl->pInternalArgs;
+    return pImpl->pInternalArgs.get();
 }
 
 
@@ -495,7 +493,7 @@ void SfxRequest::Done( bool bRelease )
 void SfxRequest::ForgetAllArgs()
 {
     DELETEZ( pArgs );
-    DELETEZ( pImpl->pInternalArgs );
+    pImpl->pInternalArgs.reset();
 }
 
 
@@ -754,7 +752,7 @@ bool SfxRequest::AllowsRecording() const
 void SfxRequest::ReleaseArgs()
 {
     DELETEZ( pArgs );
-    DELETEZ( pImpl->pInternalArgs );
+    pImpl->pInternalArgs.reset();
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/doc/docinsert.cxx b/sfx2/source/doc/docinsert.cxx
index 36079f2..6288d5c 100644
--- a/sfx2/source/doc/docinsert.cxx
+++ b/sfx2/source/doc/docinsert.cxx
@@ -63,7 +63,6 @@ DocumentInserter::DocumentInserter(
 
 DocumentInserter::~DocumentInserter()
 {
-    delete m_pFileDlg;
 }
 
 void DocumentInserter::StartExecuteModal( const Link<sfx2::FileDialogHelper*,void>& _rDialogClosedLink )
@@ -72,9 +71,9 @@ void DocumentInserter::StartExecuteModal( const Link<sfx2::FileDialogHelper*,voi
     m_nError = ERRCODE_NONE;
     if ( !m_pFileDlg )
     {
-        m_pFileDlg = new FileDialogHelper(
+        m_pFileDlg.reset( new FileDialogHelper(
                 ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE,
-                m_nDlgFlags, m_sDocFactory );
+                m_nDlgFlags, m_sDocFactory ) );
     }
     m_pFileDlg->StartExecuteModal( LINK( this, DocumentInserter, DialogClosedHdl ) );
 }
@@ -171,7 +170,7 @@ IMPL_LINK_NOARG(DocumentInserter, DialogClosedHdl, sfx2::FileDialogHelper*, void
 
     m_nError = m_pFileDlg->GetError();
     if ( ERRCODE_NONE == m_nError )
-        impl_FillURLList( m_pFileDlg, m_pURLList );
+        impl_FillURLList( m_pFileDlg.get(), m_pURLList );
 
     Reference < XFilePicker2 > xFP = m_pFileDlg->GetFilePicker();
     Reference < XFilePickerControlAccess > xCtrlAccess( xFP, UNO_QUERY );
@@ -267,7 +266,7 @@ IMPL_LINK_NOARG(DocumentInserter, DialogClosedHdl, sfx2::FileDialogHelper*, void
 
     m_sFilter = m_pFileDlg->GetRealFilter();
 
-    m_aDialogClosedLink.Call( m_pFileDlg );
+    m_aDialogClosedLink.Call( m_pFileDlg.get() );
 }
 
 } // namespace sfx2
diff --git a/sfx2/source/doc/doctemplates.cxx b/sfx2/source/doc/doctemplates.cxx
index d0ecf88..48234d0 100644
--- a/sfx2/source/doc/doctemplates.cxx
+++ b/sfx2/source/doc/doctemplates.cxx
@@ -2165,11 +2165,10 @@ bool SfxDocTplService_Impl::renameTemplate( const OUString& rGroupName,
 
 class SfxDocTplService: public ::cppu::WeakImplHelper< css::lang::XLocalizable, css::frame::XDocumentTemplates, css::lang::XServiceInfo >
 {
-    SfxDocTplService_Impl       *pImp;
+    std::unique_ptr<SfxDocTplService_Impl>      pImp;
 
 public:
     explicit SfxDocTplService( const css::uno::Reference < uno::XComponentContext >& xContext );
-    virtual ~SfxDocTplService() override;
 
     virtual OUString SAL_CALL getImplementationName()
         throw (css::uno::RuntimeException, std::exception) override
@@ -2218,15 +2217,10 @@ public:
 
 SfxDocTplService::SfxDocTplService( const uno::Reference< XComponentContext >& xContext )
 {
-    pImp = new SfxDocTplService_Impl(xContext);
+    pImp.reset( new SfxDocTplService_Impl(xContext) );
 }
 
 
-SfxDocTplService::~SfxDocTplService()
-{
-    delete pImp;
-}
-
 
 //--- XLocalizable ---
 
diff --git a/sfx2/source/doc/printhelper.cxx b/sfx2/source/doc/printhelper.cxx
index 9da2bc2..8ed4984 100644
--- a/sfx2/source/doc/printhelper.cxx
+++ b/sfx2/source/doc/printhelper.cxx
@@ -145,7 +145,7 @@ void SAL_CALL SfxPrintJob_Impl::cancelJob() throw (RuntimeException, std::except
 
 SfxPrintHelper::SfxPrintHelper()
 {
-    m_pData = new IMPL_PrintListener_DataContainer(m_aMutex);
+    m_pData.reset(new IMPL_PrintListener_DataContainer(m_aMutex));
 }
 
 void SAL_CALL SfxPrintHelper::initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) throw (css::uno::Exception, css::uno::RuntimeException, std::exception)
@@ -167,7 +167,6 @@ void SAL_CALL SfxPrintHelper::initialize( const css::uno::Sequence< css::uno::An
 
 SfxPrintHelper::~SfxPrintHelper()
 {
-    delete m_pData;
 }
 
 namespace
diff --git a/sfx2/source/doc/printhelper.hxx b/sfx2/source/doc/printhelper.hxx
index a91e5b5..6faca49 100644
--- a/sfx2/source/doc/printhelper.hxx
+++ b/sfx2/source/doc/printhelper.hxx
@@ -60,7 +60,7 @@ public:
 private:
 
     osl::Mutex m_aMutex;
-    IMPL_PrintListener_DataContainer* m_pData ;
+    std::unique_ptr<IMPL_PrintListener_DataContainer> m_pData ;
     void impl_setPrinter(const css::uno::Sequence< css::beans::PropertyValue >& rPrinter,
                          VclPtr<SfxPrinter>& pPrinter,
                          SfxPrinterChangeFlags& nChangeFlags,
diff --git a/sfx2/source/view/sfxbasecontroller.cxx b/sfx2/source/view/sfxbasecontroller.cxx
index a7cd7cf..c68a851 100644
--- a/sfx2/source/view/sfxbasecontroller.cxx
+++ b/sfx2/source/view/sfxbasecontroller.cxx
@@ -474,7 +474,6 @@ SfxBaseController::SfxBaseController( SfxViewShell* pViewShell )
 
 SfxBaseController::~SfxBaseController()
 {
-    delete m_pData;
 }
 
 
diff --git a/sfx2/source/view/viewprn.cxx b/sfx2/source/view/viewprn.cxx
index 8ae4c73..b73e1c4 100644
--- a/sfx2/source/view/viewprn.cxx
+++ b/sfx2/source/view/viewprn.cxx
@@ -404,17 +404,17 @@ class SfxDialogExecutor_Impl
 private:
     SfxViewShell*           _pViewSh;
     VclPtr<PrinterSetupDialog>  _pSetupParent;
-    SfxItemSet*             _pOptions;
+    std::unique_ptr<SfxItemSet> _pOptions;
     bool                    _bHelpDisabled;
 
     DECL_LINK( Execute, Button*, void );
 
 public:
             SfxDialogExecutor_Impl( SfxViewShell* pViewSh, PrinterSetupDialog* pParent );
-            ~SfxDialogExecutor_Impl() { delete _pOptions; }
+            ~SfxDialogExecutor_Impl() {}
 
     Link<Button*, void> GetLink() const { return LINK(const_cast<SfxDialogExecutor_Impl*>(this), SfxDialogExecutor_Impl, Execute); }
-    const SfxItemSet*   GetOptions() const { return _pOptions; }
+    const SfxItemSet*   GetOptions() const { return _pOptions.get(); }
     void                DisableHelp() { _bHelpDisabled = true; }
 };
 
@@ -435,7 +435,7 @@ IMPL_LINK_NOARG(SfxDialogExecutor_Impl, Execute, Button*, void)
     {
         DBG_ASSERT( _pSetupParent, "no dialog parent" );
         if( _pSetupParent )
-            _pOptions = static_cast<SfxPrinter*>( _pSetupParent->GetPrinter() )->GetOptions().Clone();
+            _pOptions.reset( static_cast<SfxPrinter*>( _pSetupParent->GetPrinter() )->GetOptions().Clone() );
     }
 
     assert(_pOptions);
@@ -444,14 +444,12 @@ IMPL_LINK_NOARG(SfxDialogExecutor_Impl, Execute, Button*, void)
 
     // Create Dialog
     VclPtrInstance<SfxPrintOptionsDialog> pDlg( static_cast<vcl::Window*>(_pSetupParent),
-                                                _pViewSh, _pOptions );
+                                                _pViewSh, _pOptions.get() );
     if ( _bHelpDisabled )
         pDlg->DisableHelp();
     if ( pDlg->Execute() == RET_OK )
     {
-        delete _pOptions;
-        _pOptions = pDlg->GetOptions().Clone();
-
+        _pOptions.reset( pDlg->GetOptions().Clone() );
     }
 }
 


More information about the Libreoffice-commits mailing list