diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-08-14 16:20:34 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-08-16 12:09:05 +0200 |
commit | 13c78ceb25151b971e28f64d2ab931016eea7408 (patch) | |
tree | 1269857b73a80fb2336152d9f989feff52a9d7e3 /sw/source/uibase | |
parent | 899fbd617b32771bc8c14effc52a7153465adf5d (diff) |
pass SfxMedium around by std::unique_ptr
Change-Id: Ibde7b68d9248f80d5304991390a80742265f37b3
Reviewed-on: https://gerrit.libreoffice.org/59031
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw/source/uibase')
-rw-r--r-- | sw/source/uibase/inc/uivwimp.hxx | 2 | ||||
-rw-r--r-- | sw/source/uibase/uiview/uivwimp.cxx | 2 | ||||
-rw-r--r-- | sw/source/uibase/uiview/view2.cxx | 20 |
3 files changed, 11 insertions, 13 deletions
diff --git a/sw/source/uibase/inc/uivwimp.hxx b/sw/source/uibase/inc/uivwimp.hxx index 67c90d732ea9..44b7b3f5cca5 100644 --- a/sw/source/uibase/inc/uivwimp.hxx +++ b/sw/source/uibase/inc/uivwimp.hxx @@ -159,7 +159,7 @@ public: const Link<sfx2::FileDialogHelper*,void>& rEndDialogHdl, const sal_uInt16 nSlotId ); - SfxMedium* CreateMedium(); + std::unique_ptr<SfxMedium> CreateMedium(); void InitRequest( const SfxRequest& rRequest ); SfxRequest* GetRequest() const { return m_pRequest.get(); } diff --git a/sw/source/uibase/uiview/uivwimp.cxx b/sw/source/uibase/uiview/uivwimp.cxx index f626480715e1..e36cbc5c963d 100644 --- a/sw/source/uibase/uiview/uivwimp.cxx +++ b/sw/source/uibase/uiview/uivwimp.cxx @@ -265,7 +265,7 @@ void SwView_Impl::StartDocumentInserter( m_pDocInserter->StartExecuteModal( rEndDialogHdl ); } -SfxMedium* SwView_Impl::CreateMedium() +std::unique_ptr<SfxMedium> SwView_Impl::CreateMedium() { return m_pDocInserter->CreateMedium(); } diff --git a/sw/source/uibase/uiview/view2.cxx b/sw/source/uibase/uiview/view2.cxx index f1866fc3ee16..06e3e8cc6bf0 100644 --- a/sw/source/uibase/uiview/view2.cxx +++ b/sw/source/uibase/uiview/view2.cxx @@ -2074,7 +2074,7 @@ void SwView::ExecuteInsertDoc( SfxRequest& rRequest, const SfxPoolItem* pItem ) long SwView::InsertDoc( sal_uInt16 nSlotId, const OUString& rFileName, const OUString& rFilterName, sal_Int16 nVersion ) { - SfxMedium* pMed = nullptr; + std::unique_ptr<SfxMedium> pMed; SwDocShell* pDocSh = GetDocShell(); if( !rFileName.isEmpty() ) @@ -2083,17 +2083,17 @@ long SwView::InsertDoc( sal_uInt16 nSlotId, const OUString& rFileName, const OUS std::shared_ptr<const SfxFilter> pFilter = rFact.GetFilterContainer()->GetFilter4FilterName( rFilterName ); if ( !pFilter ) { - pMed = new SfxMedium(rFileName, StreamMode::READ, nullptr, nullptr ); + pMed.reset(new SfxMedium(rFileName, StreamMode::READ, nullptr, nullptr )); SfxFilterMatcher aMatcher( rFact.GetFilterContainer()->GetName() ); pMed->UseInteractionHandler( true ); ErrCode nErr = aMatcher.GuessFilter(*pMed, pFilter, SfxFilterFlags::NONE); if ( nErr ) - DELETEZ(pMed); + pMed.reset(); else pMed->SetFilter( pFilter ); } else - pMed = new SfxMedium(rFileName, StreamMode::READ, pFilter, nullptr); + pMed.reset(new SfxMedium(rFileName, StreamMode::READ, pFilter, nullptr)); } else { @@ -2109,10 +2109,10 @@ long SwView::InsertDoc( sal_uInt16 nSlotId, const OUString& rFileName, const OUS if( !pMed ) return -1; - return InsertMedium( nSlotId, pMed, nVersion ); + return InsertMedium( nSlotId, std::move(pMed), nVersion ); } -long SwView::InsertMedium( sal_uInt16 nSlotId, SfxMedium* pMedium, sal_Int16 nVersion ) +long SwView::InsertMedium( sal_uInt16 nSlotId, std::unique_ptr<SfxMedium> pMedium, sal_Int16 nVersion ) { bool bInsert = false, bCompare = false; long nFound = 0; @@ -2145,11 +2145,10 @@ long SwView::InsertMedium( sal_uInt16 nSlotId, SfxMedium* pMedium, sal_Int16 nVe SfxObjectShellRef aRef( pDocSh ); - ErrCode nError = SfxObjectShell::HandleFilter( pMedium, pDocSh ); + ErrCode nError = SfxObjectShell::HandleFilter( pMedium.get(), pDocSh ); // #i16722# aborted? if(nError != ERRCODE_NONE) { - delete pMedium; return -1; } @@ -2250,7 +2249,6 @@ long SwView::InsertMedium( sal_uInt16 nSlotId, SfxMedium* pMedium, sal_Int16 nVe } } - delete pMedium; return nFound; } @@ -2418,12 +2416,12 @@ IMPL_LINK( SwView, DialogClosedHdl, sfx2::FileDialogHelper*, _pFileDlg, void ) if ( ERRCODE_NONE != _pFileDlg->GetError() ) return; - SfxMedium* pMed = m_pViewImpl->CreateMedium(); + std::unique_ptr<SfxMedium> pMed = m_pViewImpl->CreateMedium(); if ( !pMed ) return; const sal_uInt16 nSlot = m_pViewImpl->GetRequest()->GetSlot(); - long nFound = InsertMedium( nSlot, pMed, m_pViewImpl->GetParam() ); + long nFound = InsertMedium( nSlot, std::move(pMed), m_pViewImpl->GetParam() ); if ( SID_INSERTDOC == nSlot ) { |