diff options
author | Jan Holesovsky <kendy@collabora.com> | 2015-10-19 09:54:12 +0200 |
---|---|---|
committer | Jan Holesovsky <kendy@collabora.com> | 2015-10-19 10:14:03 +0200 |
commit | 25d1447fcfe7d3fcdf8792d1cf426aaa2e578875 (patch) | |
tree | 16519edb28750e5910b0b57b19a9b3098a1a5ed2 /sfx2 | |
parent | f6f32e8eabb2e09fbe2b70dfb540bb1ea1ee75a9 (diff) |
sfx items: Some cleanup.
Change-Id: I8fdd710b4248de03db6591665489146cb2674aab
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/doc/objserv.cxx | 20 | ||||
-rw-r--r-- | sfx2/source/doc/objstor.cxx | 52 | ||||
-rw-r--r-- | sfx2/source/doc/sfxbasemodel.cxx | 20 |
3 files changed, 33 insertions, 59 deletions
diff --git a/sfx2/source/doc/objserv.cxx b/sfx2/source/doc/objserv.cxx index f263356b92d1..fd16f1bb7317 100644 --- a/sfx2/source/doc/objserv.cxx +++ b/sfx2/source/doc/objserv.cxx @@ -263,13 +263,7 @@ void SfxObjectShell::PrintState_Impl(SfxItemSet &rSet) rSet.Put( SfxBoolItem( SID_PRINTOUT, bPrinting ) ); } - - -bool SfxObjectShell::APISaveAs_Impl -( - const OUString& aFileName, - SfxItemSet* aParams -) +bool SfxObjectShell::APISaveAs_Impl(const OUString& aFileName, SfxItemSet& rItemSet) { bool bOk = false; @@ -277,14 +271,14 @@ bool SfxObjectShell::APISaveAs_Impl if ( GetMedium() ) { OUString aFilterName; - const SfxStringItem* pFilterNameItem = SfxItemSet::GetItem<SfxStringItem>(aParams, SID_FILTER_NAME, false); + const SfxStringItem* pFilterNameItem = rItemSet.GetItem<SfxStringItem>(SID_FILTER_NAME, false); if( pFilterNameItem ) { aFilterName = pFilterNameItem->GetValue(); } else { - const SfxStringItem* pContentTypeItem = SfxItemSet::GetItem<SfxStringItem>(aParams, SID_CONTENTTYPE, false); + const SfxStringItem* pContentTypeItem = rItemSet.GetItem<SfxStringItem>(SID_CONTENTTYPE, false); if ( pContentTypeItem ) { const SfxFilter* pFilter = SfxFilterMatcher( OUString::createFromAscii(GetFactory().GetShortName()) ).GetFilter4Mime( pContentTypeItem->GetValue(), SfxFilterFlags::EXPORT ); @@ -302,7 +296,7 @@ bool SfxObjectShell::APISaveAs_Impl if( pFilt ) aFilterName = pFilt->GetFilterName(); - aParams->Put(SfxStringItem( SID_FILTER_NAME, aFilterName)); + rItemSet.Put(SfxStringItem(SID_FILTER_NAME, aFilterName)); } @@ -310,13 +304,11 @@ bool SfxObjectShell::APISaveAs_Impl SfxObjectShellRef xLock( this ); // ??? // use the title that is provided in the media descriptor - const SfxStringItem* pDocTitleItem = SfxItemSet::GetItem<SfxStringItem>(aParams, SID_DOCINFO_TITLE, false); + const SfxStringItem* pDocTitleItem = rItemSet.GetItem<SfxStringItem>(SID_DOCINFO_TITLE, false); if ( pDocTitleItem ) getDocProperties()->setTitle( pDocTitleItem->GetValue() ); - bOk = CommonSaveAs_Impl( INetURLObject(aFileName), aFilterName, - aParams ); - + bOk = CommonSaveAs_Impl(INetURLObject(aFileName), aFilterName, rItemSet); } } diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx index e97bd2e083cb..190b733c150c 100644 --- a/sfx2/source/doc/objstor.cxx +++ b/sfx2/source/doc/objstor.cxx @@ -2606,14 +2606,7 @@ bool SfxObjectShell::Save_Impl( const SfxItemSet* pSet ) return bSaved; } - - -bool SfxObjectShell::CommonSaveAs_Impl -( - const INetURLObject& aURL, - const OUString& aFilterName, - SfxItemSet* aParams -) +bool SfxObjectShell::CommonSaveAs_Impl(const INetURLObject& aURL, const OUString& aFilterName, SfxItemSet& rItemSet) { if( aURL.HasError() ) { @@ -2645,9 +2638,9 @@ bool SfxObjectShell::CommonSaveAs_Impl } DBG_ASSERT( aURL.GetProtocol() != INetProtocol::NotValid, "Illegal URL!" ); - DBG_ASSERT( aParams->Count() != 0, "Incorrect Parameter"); + DBG_ASSERT( rItemSet.Count() != 0, "Incorrect Parameter"); - const SfxBoolItem* pSaveToItem = SfxItemSet::GetItem<SfxBoolItem>(aParams, SID_SAVETO, false); + const SfxBoolItem* pSaveToItem = rItemSet.GetItem<SfxBoolItem>(SID_SAVETO, false); bool bSaveTo = pSaveToItem && pSaveToItem->GetValue(); const SfxFilter* pFilter = GetFactory().GetFilterContainer()->GetFilter4FilterName( aFilterName ); @@ -2659,15 +2652,15 @@ bool SfxObjectShell::CommonSaveAs_Impl return false; } - const SfxBoolItem* pCopyStreamItem = SfxItemSet::GetItem<SfxBoolItem>(aParams, SID_COPY_STREAM_IF_POSSIBLE, false); + const SfxBoolItem* pCopyStreamItem = rItemSet.GetItem<SfxBoolItem>(SID_COPY_STREAM_IF_POSSIBLE, false); if ( bSaveTo && pCopyStreamItem && pCopyStreamItem->GetValue() && !IsModified() ) { - if ( pMedium->TryDirectTransfer( aURL.GetMainURL( INetURLObject::NO_DECODE ), *aParams ) ) + if (pMedium->TryDirectTransfer(aURL.GetMainURL(INetURLObject::NO_DECODE), rItemSet)) return true; } - aParams->ClearItem( SID_COPY_STREAM_IF_POSSIBLE ); + rItemSet.ClearItem( SID_COPY_STREAM_IF_POSSIBLE ); - pImp->bPasswd = SfxItemState::SET == aParams->GetItemState(SID_PASSWORD); + pImp->bPasswd = SfxItemState::SET == rItemSet.GetItemState(SID_PASSWORD); SfxMedium *pActMed = GetMedium(); const INetURLObject aActName(pActMed->GetName()); @@ -2681,14 +2674,14 @@ bool SfxObjectShell::CommonSaveAs_Impl return false; } - if( SfxItemState::SET != aParams->GetItemState(SID_UNPACK) && SvtSaveOptions().IsSaveUnpacked() ) - aParams->Put( SfxBoolItem( SID_UNPACK, false ) ); + if (SfxItemState::SET != rItemSet.GetItemState(SID_UNPACK) && SvtSaveOptions().IsSaveUnpacked()) + rItemSet.Put(SfxBoolItem(SID_UNPACK, false)); OUString aTempFileURL; if ( IsDocShared() ) aTempFileURL = pMedium->GetURLObject().GetMainURL( INetURLObject::NO_DECODE ); - if ( PreDoSaveAs_Impl(aURL.GetMainURL( INetURLObject::NO_DECODE ),aFilterName,aParams)) + if (PreDoSaveAs_Impl(aURL.GetMainURL(INetURLObject::NO_DECODE), aFilterName, rItemSet)) { // Update Data on media SfxItemSet *pSet = GetMedium()->GetItemSet(); @@ -2713,15 +2706,15 @@ bool SfxObjectShell::CommonSaveAs_Impl pSet->ClearItem( SID_DEFAULTFILEPATH ); pSet->ClearItem( SID_DEFAULTFILENAME ); - const SfxStringItem* pFilterItem = aParams->GetItem<SfxStringItem>(SID_FILTER_NAME, false); + const SfxStringItem* pFilterItem = rItemSet.GetItem<SfxStringItem>(SID_FILTER_NAME, false); if ( pFilterItem ) pSet->Put( *pFilterItem ); - const SfxStringItem* pOptionsItem = aParams->GetItem<SfxStringItem>(SID_OPTIONS, false); + const SfxStringItem* pOptionsItem = rItemSet.GetItem<SfxStringItem>(SID_OPTIONS, false); if ( pOptionsItem ) pSet->Put( *pOptionsItem ); - const SfxStringItem* pFilterOptItem = aParams->GetItem<SfxStringItem>(SID_FILE_FILTEROPTIONS, false); + const SfxStringItem* pFilterOptItem = rItemSet.GetItem<SfxStringItem>(SID_FILE_FILTEROPTIONS, false); if ( pFilterOptItem ) pSet->Put( *pFilterOptItem ); @@ -2752,14 +2745,7 @@ bool SfxObjectShell::CommonSaveAs_Impl return false; } - - -bool SfxObjectShell::PreDoSaveAs_Impl -( - const OUString& rFileName, - const OUString& aFilterName, - SfxItemSet* pParams -) +bool SfxObjectShell::PreDoSaveAs_Impl(const OUString& rFileName, const OUString& aFilterName, SfxItemSet& rItemSet) { // copy all items stored in the itemset of the current medium SfxAllItemSet* pMergedParams = new SfxAllItemSet( *pMedium->GetItemSet() ); @@ -2785,8 +2771,7 @@ bool SfxObjectShell::PreDoSaveAs_Impl // merge the new parameters into the copy // all values present in both itemsets will be overwritten by the new parameters - if( pParams ) - pMergedParams->Put( *pParams ); + pMergedParams->Put(rItemSet); #ifdef DBG_UTIL if ( pMergedParams->GetItemState( SID_DOC_SALVAGE) >= SfxItemState::SET ) @@ -2796,11 +2781,8 @@ bool SfxObjectShell::PreDoSaveAs_Impl // should be unnecessary - too hot to handle! pMergedParams->ClearItem( SID_DOC_SALVAGE ); - // take over the new merged itemset - pParams = pMergedParams; - // create a medium for the target URL - SfxMedium *pNewFile = new SfxMedium( rFileName, STREAM_READWRITE | StreamMode::SHARE_DENYWRITE | StreamMode::TRUNC, 0, pParams ); + SfxMedium *pNewFile = new SfxMedium( rFileName, STREAM_READWRITE | StreamMode::SHARE_DENYWRITE | StreamMode::TRUNC, 0, pMergedParams ); // set filter; if no filter is given, take the default filter of the factory if ( !aFilterName.isEmpty() ) @@ -2817,7 +2799,7 @@ bool SfxObjectShell::PreDoSaveAs_Impl } // check if a "SaveTo" is wanted, no "SaveAs" - const SfxBoolItem* pSaveToItem = SfxItemSet::GetItem<SfxBoolItem>(pParams, SID_SAVETO, false); + const SfxBoolItem* pSaveToItem = pMergedParams->GetItem<SfxBoolItem>(SID_SAVETO, false); bool bCopyTo = GetCreateMode() == SfxObjectCreateMode::EMBEDDED || (pSaveToItem && pSaveToItem->GetValue()); // distinguish between "Save" and "SaveAs" diff --git a/sfx2/source/doc/sfxbasemodel.cxx b/sfx2/source/doc/sfxbasemodel.cxx index ed11d795dcdf..c6dbe54b0cd6 100644 --- a/sfx2/source/doc/sfxbasemodel.cxx +++ b/sfx2/source/doc/sfxbasemodel.cxx @@ -3012,14 +3012,14 @@ void SfxBaseModel::impl_store( const OUString& sURL SfxGetpApp()->NotifyEvent( SfxEventHint( bSaveTo ? SFX_EVENT_SAVETODOC : SFX_EVENT_SAVEASDOC, GlobalEventConfig::GetEventName( bSaveTo ? GlobalEventId::SAVETODOC : GlobalEventId::SAVEASDOC ), m_pData->m_pObjectShell ) ); - SfxAllItemSet *aParams = new SfxAllItemSet( SfxGetpApp()->GetPool() ); - aParams->Put( SfxStringItem( SID_FILE_NAME, sURL ) ); + std::unique_ptr<SfxAllItemSet> pItemSet(new SfxAllItemSet(SfxGetpApp()->GetPool())); + pItemSet->Put(SfxStringItem(SID_FILE_NAME, sURL)); if ( bSaveTo ) - aParams->Put( SfxBoolItem( SID_SAVETO, true ) ); + pItemSet->Put(SfxBoolItem(SID_SAVETO, true)); - TransformParameters( SID_SAVEASDOC, seqArguments, *aParams ); + TransformParameters(SID_SAVEASDOC, seqArguments, *pItemSet); - const SfxBoolItem* pCopyStreamItem = SfxItemSet::GetItem<SfxBoolItem>(aParams, SID_COPY_STREAM_IF_POSSIBLE, false); + const SfxBoolItem* pCopyStreamItem = pItemSet->GetItem<SfxBoolItem>(SID_COPY_STREAM_IF_POSSIBLE, false); if ( pCopyStreamItem && pCopyStreamItem->GetValue() && !bSaveTo ) { @@ -3032,7 +3032,7 @@ void SfxBaseModel::impl_store( const OUString& sURL sal_uInt32 nModifyPasswordHash = 0; Sequence< beans::PropertyValue > aModifyPasswordInfo; - const SfxUnoAnyItem* pModifyPasswordInfoItem = SfxItemSet::GetItem<SfxUnoAnyItem>(aParams, SID_MODIFYPASSWORDINFO, false); + const SfxUnoAnyItem* pModifyPasswordInfoItem = pItemSet->GetItem<SfxUnoAnyItem>(SID_MODIFYPASSWORDINFO, false); if ( pModifyPasswordInfoItem ) { // it contains either a simple hash or a set of PropertyValues @@ -3042,7 +3042,7 @@ void SfxBaseModel::impl_store( const OUString& sURL nModifyPasswordHash = (sal_uInt32)nMPHTmp; pModifyPasswordInfoItem->GetValue() >>= aModifyPasswordInfo; } - aParams->ClearItem( SID_MODIFYPASSWORDINFO ); + pItemSet->ClearItem(SID_MODIFYPASSWORDINFO); sal_uInt32 nOldModifyPasswordHash = m_pData->m_pObjectShell->GetModifyPasswordHash(); m_pData->m_pObjectShell->SetModifyPasswordHash( nModifyPasswordHash ); Sequence< beans::PropertyValue > aOldModifyPasswordInfo = m_pData->m_pObjectShell->GetModifyPasswordInfo(); @@ -3064,7 +3064,7 @@ void SfxBaseModel::impl_store( const OUString& sURL m_pData->m_xDocumentProperties = xNewDocProps; } - bool bRet = m_pData->m_pObjectShell->APISaveAs_Impl( sURL, aParams ); + bool bRet = m_pData->m_pObjectShell->APISaveAs_Impl(sURL, *pItemSet); if ( bCopyTo ) { @@ -3073,11 +3073,11 @@ void SfxBaseModel::impl_store( const OUString& sURL } Reference < task::XInteractionHandler > xHandler; - const SfxUnoAnyItem* pItem = SfxItemSet::GetItem<SfxUnoAnyItem>(aParams, SID_INTERACTIONHANDLER, false); + const SfxUnoAnyItem* pItem = pItemSet->GetItem<SfxUnoAnyItem>(SID_INTERACTIONHANDLER, false); if ( pItem ) pItem->GetValue() >>= xHandler; - DELETEZ( aParams ); + pItemSet.reset(); sal_uInt32 nErrCode = m_pData->m_pObjectShell->GetErrorCode(); if ( !bRet && !nErrCode ) |