diff options
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/appl/appopen.cxx | 8 | ||||
-rw-r--r-- | sfx2/source/doc/docfile.cxx | 8 | ||||
-rw-r--r-- | sfx2/source/doc/docinsert.cxx | 4 | ||||
-rw-r--r-- | sfx2/source/doc/new.cxx | 4 | ||||
-rw-r--r-- | sfx2/source/doc/objstor.cxx | 15 |
5 files changed, 18 insertions, 21 deletions
diff --git a/sfx2/source/appl/appopen.cxx b/sfx2/source/appl/appopen.cxx index 60f2c508ebbb..432db5e18ebb 100644 --- a/sfx2/source/appl/appopen.cxx +++ b/sfx2/source/appl/appopen.cxx @@ -281,7 +281,7 @@ ErrCode CheckPasswd_Impl } -ErrCode SfxApplication::LoadTemplate( SfxObjectShellLock& xDoc, const OUString &rFileName, SfxItemSet* pSet ) +ErrCode SfxApplication::LoadTemplate( SfxObjectShellLock& xDoc, const OUString &rFileName, std::unique_ptr<SfxItemSet> pSet ) { std::shared_ptr<const SfxFilter> pFilter; SfxMedium aMedium( rFileName, ( StreamMode::READ | StreamMode::SHARE_DENYNONE ) ); @@ -291,7 +291,6 @@ ErrCode SfxApplication::LoadTemplate( SfxObjectShellLock& xDoc, const OUString & if ( aMedium.GetError() ) { - delete pSet; return aMedium.GetErrorCode(); } @@ -299,20 +298,17 @@ ErrCode SfxApplication::LoadTemplate( SfxObjectShellLock& xDoc, const OUString & ErrCode nErr = GetFilterMatcher().GuessFilter( aMedium, pFilter, SfxFilterFlags::TEMPLATE, SfxFilterFlags::NONE ); if ( ERRCODE_NONE != nErr) { - delete pSet; return ERRCODE_SFX_NOTATEMPLATE; } if( !pFilter || !pFilter->IsAllowedAsTemplate() ) { - delete pSet; return ERRCODE_SFX_NOTATEMPLATE; } if ( pFilter->GetFilterFlags() & SfxFilterFlags::STARONEFILTER ) { DBG_ASSERT( !xDoc.Is(), "Sorry, not implemented!" ); - delete pSet; SfxStringItem aName( SID_FILE_NAME, rFileName ); SfxStringItem aReferer( SID_REFERER, OUString("private:user") ); SfxStringItem aFlags( SID_OPTIONS, OUString("T") ); @@ -343,7 +339,7 @@ ErrCode SfxApplication::LoadTemplate( SfxObjectShellLock& xDoc, const OUString & xDoc = SfxObjectShell::CreateObject( pFilter->GetServiceName() ); //pMedium takes ownership of pSet - SfxMedium *pMedium = new SfxMedium( rFileName, StreamMode::STD_READ, pFilter, pSet ); + SfxMedium *pMedium = new SfxMedium( rFileName, StreamMode::STD_READ, pFilter, std::move(pSet) ); if(!xDoc->DoLoad(pMedium)) { ErrCode nErrCode = xDoc->GetErrorCode(); diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx index d532ede31a0b..638ecb5fc2f0 100644 --- a/sfx2/source/doc/docfile.cxx +++ b/sfx2/source/doc/docfile.cxx @@ -3081,20 +3081,20 @@ void SfxMedium::CompleteReOpen() pImpl->bUseInteractionHandler = bUseInteractionHandler; } -SfxMedium::SfxMedium(const OUString &rName, StreamMode nOpenMode, std::shared_ptr<const SfxFilter> pFilter, SfxItemSet *pInSet) : +SfxMedium::SfxMedium(const OUString &rName, StreamMode nOpenMode, std::shared_ptr<const SfxFilter> pFilter, std::unique_ptr<SfxItemSet> pInSet) : pImpl(new SfxMedium_Impl) { - pImpl->m_pSet.reset( pInSet ); + pImpl->m_pSet = std::move( pInSet ); pImpl->m_pFilter = std::move(pFilter); pImpl->m_aLogicName = rName; pImpl->m_nStorOpenMode = nOpenMode; Init_Impl(); } -SfxMedium::SfxMedium(const OUString &rName, const OUString &rReferer, StreamMode nOpenMode, std::shared_ptr<const SfxFilter> pFilter, SfxItemSet *pInSet) : +SfxMedium::SfxMedium(const OUString &rName, const OUString &rReferer, StreamMode nOpenMode, std::shared_ptr<const SfxFilter> pFilter, std::unique_ptr<SfxItemSet> pInSet) : pImpl(new SfxMedium_Impl) { - pImpl->m_pSet.reset( pInSet ); + pImpl->m_pSet = std::move(pInSet); SfxItemSet * s = GetItemSet(); if (s->GetItem(SID_REFERER) == nullptr) { s->Put(SfxStringItem(SID_REFERER, rReferer)); diff --git a/sfx2/source/doc/docinsert.cxx b/sfx2/source/doc/docinsert.cxx index ad262468313e..ca63af89aa8a 100644 --- a/sfx2/source/doc/docinsert.cxx +++ b/sfx2/source/doc/docinsert.cxx @@ -108,7 +108,7 @@ SfxMedium* DocumentInserter::CreateMedium(char const*const pFallbackHack) DBG_ASSERT( m_pURLList.size() == 1, "DocumentInserter::CreateMedium(): invalid URL list count" ); pMedium.reset(new SfxMedium( m_pURLList[0], SFX_STREAM_READONLY, - SfxGetpApp()->GetFilterMatcher().GetFilter4FilterName( m_sFilter ), m_pItemSet )); + SfxGetpApp()->GetFilterMatcher().GetFilter4FilterName( m_sFilter ), std::unique_ptr<SfxItemSet>(m_pItemSet) )); pMedium->UseInteractionHandler( true ); std::unique_ptr<SfxFilterMatcher> pMatcher; if ( !m_sDocFactory.isEmpty() ) @@ -145,7 +145,7 @@ SfxMediumList* DocumentInserter::CreateMediumList() { SfxMedium* pMedium = new SfxMedium( url, SFX_STREAM_READONLY, - SfxGetpApp()->GetFilterMatcher().GetFilter4FilterName( m_sFilter ), m_pItemSet ); + SfxGetpApp()->GetFilterMatcher().GetFilter4FilterName( m_sFilter ), std::unique_ptr<SfxItemSet>(m_pItemSet) ); pMedium->UseInteractionHandler( true ); diff --git a/sfx2/source/doc/new.cxx b/sfx2/source/doc/new.cxx index 36d91c3bb379..b6a78c03bf7a 100644 --- a/sfx2/source/doc/new.cxx +++ b/sfx2/source/doc/new.cxx @@ -147,10 +147,10 @@ IMPL_LINK_NOARG(SfxNewFileDialog, Update, Timer*, void) { SfxErrorContext eEC(ERRCTX_SFX_LOADTEMPLATE, m_xDialog.get()); SfxApplication *pSfxApp = SfxGetpApp(); - SfxItemSet* pSet = new SfxAllItemSet(pSfxApp->GetPool()); + std::unique_ptr<SfxItemSet> pSet(new SfxAllItemSet(pSfxApp->GetPool())); pSet->Put(SfxBoolItem(SID_TEMPLATE, true)); pSet->Put(SfxBoolItem(SID_PREVIEW, true)); - ErrCode lErr = pSfxApp->LoadTemplate(m_xDocShell, aFileName, pSet); + ErrCode lErr = pSfxApp->LoadTemplate(m_xDocShell, aFileName, std::move(pSet)); if (lErr) ErrorHandler::HandleError(lErr); if (!m_xDocShell.Is()) diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx index 2779a5a9b9d9..3eba938736ab 100644 --- a/sfx2/source/doc/objstor.cxx +++ b/sfx2/source/doc/objstor.cxx @@ -2512,7 +2512,7 @@ bool SfxObjectShell::DoSave_Impl( const SfxItemSet* pArgs ) // copy the original itemset, but remove the "version" item, because pMediumTmp // is a new medium "from scratch", so no version should be stored into it - SfxItemSet* pSet = new SfxAllItemSet(*pRetrMedium->GetItemSet()); + std::unique_ptr<SfxItemSet> pSet(new SfxAllItemSet(*pRetrMedium->GetItemSet())); pSet->ClearItem( SID_VERSION ); pSet->ClearItem( SID_DOC_BASEURL ); @@ -2531,7 +2531,7 @@ bool SfxObjectShell::DoSave_Impl( const SfxItemSet* pArgs ) // create a medium as a copy; this medium is only for writing, because it // uses the same name as the original one writing is done through a copy, // that will be transferred to the target (of course after calling HandsOff) - SfxMedium* pMediumTmp = new SfxMedium( pRetrMedium->GetName(), pRetrMedium->GetOpenMode(), pFilter, pSet ); + SfxMedium* pMediumTmp = new SfxMedium( pRetrMedium->GetName(), pRetrMedium->GetOpenMode(), pFilter, std::move(pSet) ); pMediumTmp->SetInCheckIn( pRetrMedium->IsInCheckIn( ) ); pMediumTmp->SetLongName( pRetrMedium->GetLongName() ); if ( pMediumTmp->GetErrorCode() != ERRCODE_NONE ) @@ -2771,7 +2771,7 @@ bool SfxObjectShell::CommonSaveAs_Impl(const INetURLObject& aURL, const OUString bool SfxObjectShell::PreDoSaveAs_Impl(const OUString& rFileName, const OUString& aFilterName, SfxItemSet const & rItemSet) { // copy all items stored in the itemset of the current medium - SfxAllItemSet* pMergedParams = new SfxAllItemSet( *pMedium->GetItemSet() ); + std::unique_ptr<SfxAllItemSet> pMergedParams(new SfxAllItemSet( *pMedium->GetItemSet() )); // in "SaveAs" title and password will be cleared ( maybe the new itemset contains new values, otherwise they will be empty ) pMergedParams->ClearItem( SID_ENCRYPTIONDATA ); @@ -2803,16 +2803,17 @@ bool SfxObjectShell::PreDoSaveAs_Impl(const OUString& rFileName, const OUString& pMergedParams->ClearItem( SID_DOC_SALVAGE ); // create a medium for the target URL - SfxMedium *pNewFile = new SfxMedium( rFileName, StreamMode::READWRITE | StreamMode::SHARE_DENYWRITE | StreamMode::TRUNC, nullptr, pMergedParams ); + auto pMergedParamsTmp = pMergedParams.get(); + SfxMedium *pNewFile = new SfxMedium( rFileName, StreamMode::READWRITE | StreamMode::SHARE_DENYWRITE | StreamMode::TRUNC, nullptr, std::move(pMergedParams) ); - const SfxBoolItem* pNoFileSync = pMergedParams->GetItem<SfxBoolItem>(SID_NO_FILE_SYNC, false); + const SfxBoolItem* pNoFileSync = pMergedParamsTmp->GetItem<SfxBoolItem>(SID_NO_FILE_SYNC, false); if (pNoFileSync && pNoFileSync->GetValue()) pNewFile->DisableFileSync(true); bool bUseThumbnailSave = IsUseThumbnailSave(); comphelper::ScopeGuard aThumbnailGuard( [this, bUseThumbnailSave] { this->SetUseThumbnailSave(bUseThumbnailSave); }); - const SfxBoolItem* pNoThumbnail = pMergedParams->GetItem<SfxBoolItem>(SID_NO_THUMBNAIL, false); + const SfxBoolItem* pNoThumbnail = pMergedParamsTmp->GetItem<SfxBoolItem>(SID_NO_THUMBNAIL, false); if (pNoThumbnail) // Thumbnail generation should be avoided just for this save. SetUseThumbnailSave(!pNoThumbnail->GetValue()); @@ -2834,7 +2835,7 @@ bool SfxObjectShell::PreDoSaveAs_Impl(const OUString& rFileName, const OUString& } // check if a "SaveTo" is wanted, no "SaveAs" - const SfxBoolItem* pSaveToItem = pMergedParams->GetItem<SfxBoolItem>(SID_SAVETO, false); + const SfxBoolItem* pSaveToItem = pMergedParamsTmp->GetItem<SfxBoolItem>(SID_SAVETO, false); bool bCopyTo = GetCreateMode() == SfxObjectCreateMode::EMBEDDED || (pSaveToItem && pSaveToItem->GetValue()); // distinguish between "Save" and "SaveAs" |