diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-02-28 14:59:35 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-03-01 07:46:47 +0100 |
commit | 51b995b9861c3415c44f59fa5367347fd7eee255 (patch) | |
tree | 166602d53bd09dd5f2afe2af1b76c639f3f2a58e /sfx2/source | |
parent | e13a8c7df2d11814a0a4669aad88e68e27835934 (diff) |
use SfxItemSet::GetItemIfSet in sfx2
Change-Id: I241b038953f61228b6667014a4096bfe8dcc9c2d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130709
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sfx2/source')
-rw-r--r-- | sfx2/source/appl/appcfg.cxx | 136 | ||||
-rw-r--r-- | sfx2/source/appl/appserv.cxx | 32 | ||||
-rw-r--r-- | sfx2/source/appl/appuno.cxx | 239 | ||||
-rw-r--r-- | sfx2/source/dialog/dinfdlg.cxx | 44 | ||||
-rw-r--r-- | sfx2/source/dialog/mgetempl.cxx | 7 | ||||
-rw-r--r-- | sfx2/source/doc/docfile.cxx | 10 | ||||
-rw-r--r-- | sfx2/source/doc/guisaveas.cxx | 3 | ||||
-rw-r--r-- | sfx2/source/view/viewfrm.cxx | 6 | ||||
-rw-r--r-- | sfx2/source/view/viewprn.cxx | 3 |
9 files changed, 221 insertions, 259 deletions
diff --git a/sfx2/source/appl/appcfg.cxx b/sfx2/source/appl/appcfg.cxx index 8bcc6c0232fc..74e157bc9e16 100644 --- a/sfx2/source/appl/appcfg.cxx +++ b/sfx2/source/appl/appcfg.cxx @@ -401,17 +401,15 @@ void SfxApplication::GetOptions( SfxItemSet& rSet ) // TODO/CLEANUP: Why two SetOptions Methods? void SfxApplication::SetOptions_Impl( const SfxItemSet& rSet ) { - const SfxPoolItem *pItem = nullptr; SfxItemPool &rPool = GetPool(); SvtMiscOptions aMiscOptions; std::shared_ptr< comphelper::ConfigurationChanges > batch( comphelper::ConfigurationChanges::create()); - if ( SfxItemState::SET == rSet.GetItemState(SID_ATTR_BUTTON_BIGSIZE, true, &pItem) ) + if ( const SfxBoolItem *pItem = rSet.GetItemIfSet(SID_ATTR_BUTTON_BIGSIZE) ) { - DBG_ASSERT(dynamic_cast< const SfxBoolItem *>( pItem ) != nullptr, "BoolItem expected"); - bool bBigSize = static_cast<const SfxBoolItem*>(pItem)->GetValue(); + bool bBigSize = pItem->GetValue(); aMiscOptions.SetSymbolsSize( sal::static_int_cast< sal_Int16 >( bBigSize ? SFX_SYMBOLS_SIZE_LARGE : SFX_SYMBOLS_SIZE_SMALL ) ); @@ -425,147 +423,132 @@ void SfxApplication::SetOptions_Impl( const SfxItemSet& rSet ) } // Backup - if ( SfxItemState::SET == rSet.GetItemState(SID_ATTR_BACKUP, true, &pItem) ) + if ( const SfxBoolItem *pItem = rSet.GetItemIfSet(SID_ATTR_BACKUP) ) { - DBG_ASSERT(dynamic_cast< const SfxBoolItem *>( pItem ) != nullptr, "BoolItem expected"); officecfg::Office::Common::Save::Document::CreateBackup::set( - static_cast<const SfxBoolItem*>(pItem)->GetValue(), + pItem->GetValue(), batch ); } // PrettyPrinting - if ( SfxItemState::SET == rSet.GetItemState( SID_ATTR_PRETTYPRINTING, true, &pItem ) ) + if ( const SfxBoolItem *pItem = rSet.GetItemIfSet( SID_ATTR_PRETTYPRINTING ) ) { - DBG_ASSERT( dynamic_cast< const SfxBoolItem *>( pItem ) != nullptr, "BoolItem expected" ); officecfg::Office::Common::Save::Document::PrettyPrinting::set( - static_cast< const SfxBoolItem*> ( pItem )->GetValue(), + pItem->GetValue(), batch ); } // WarnAlienFormat - if ( SfxItemState::SET == rSet.GetItemState( SID_ATTR_WARNALIENFORMAT, true, &pItem ) ) + if ( const SfxBoolItem *pItem = rSet.GetItemIfSet( SID_ATTR_WARNALIENFORMAT ) ) { - DBG_ASSERT( dynamic_cast< const SfxBoolItem *>( pItem ) != nullptr, "BoolItem expected" ); officecfg::Office::Common::Save::Document::WarnAlienFormat::set( - static_cast< const SfxBoolItem*> ( pItem )->GetValue(), + pItem->GetValue(), batch); } // AutoSave - if ( SfxItemState::SET == rSet.GetItemState( SID_ATTR_AUTOSAVE, true, &pItem)) + if ( const SfxBoolItem *pItem = rSet.GetItemIfSet( SID_ATTR_AUTOSAVE )) { - DBG_ASSERT(dynamic_cast< const SfxBoolItem *>( pItem ) != nullptr, "BoolItem expected"); officecfg::Office::Common::Save::Document::AutoSave::set( - static_cast<const SfxBoolItem*>(pItem)->GetValue(), + pItem->GetValue(), batch); } // AutoSave-Prompt - if ( SfxItemState::SET == rSet.GetItemState( SID_ATTR_AUTOSAVEPROMPT, true, &pItem)) + if ( const SfxBoolItem *pItem = rSet.GetItemIfSet( SID_ATTR_AUTOSAVEPROMPT )) { - DBG_ASSERT(dynamic_cast< const SfxBoolItem *>( pItem ) != nullptr, "BoolItem expected"); officecfg::Office::Common::Save::Document::AutoSavePrompt::set( - static_cast<const SfxBoolItem *>(pItem)->GetValue(), + pItem->GetValue(), batch); } // AutoSave-Time - if ( SfxItemState::SET == rSet.GetItemState(SID_ATTR_AUTOSAVEMINUTE, true, &pItem)) + if ( const SfxUInt16Item *pItem = rSet.GetItemIfSet(SID_ATTR_AUTOSAVEMINUTE )) { - DBG_ASSERT(dynamic_cast< const SfxUInt16Item *>( pItem ) != nullptr, "UInt16Item expected"); officecfg::Office::Common::Save::Document::AutoSaveTimeIntervall::set( - static_cast<const SfxUInt16Item *>(pItem)->GetValue(), + pItem->GetValue(), batch); } // UserAutoSave - if ( SfxItemState::SET == rSet.GetItemState(SID_ATTR_USERAUTOSAVE, true, &pItem)) + if ( const SfxBoolItem *pItem = rSet.GetItemIfSet(SID_ATTR_USERAUTOSAVE)) { - DBG_ASSERT(dynamic_cast< const SfxBoolItem *>( pItem ) != nullptr, "BoolItem expected"); officecfg::Office::Recovery::AutoSave::UserAutoSaveEnabled::set( - static_cast<const SfxBoolItem*>(pItem)->GetValue(), + pItem->GetValue(), batch); } // DocInfo - if ( SfxItemState::SET == rSet.GetItemState(SID_ATTR_DOCINFO, true, &pItem)) + if ( const SfxBoolItem *pItem = rSet.GetItemIfSet(SID_ATTR_DOCINFO) ) { - DBG_ASSERT(dynamic_cast< const SfxBoolItem *>( pItem ) != nullptr, "BoolItem expected"); officecfg::Office::Common::Save::Document::EditProperty::set( - static_cast<const SfxBoolItem *>(pItem)->GetValue(), + pItem->GetValue(), batch); } // Mark open Documents - if ( SfxItemState::SET == rSet.GetItemState(SID_ATTR_WORKINGSET, true, &pItem)) + if ( const SfxBoolItem *pItem = rSet.GetItemIfSet(SID_ATTR_WORKINGSET)) { - DBG_ASSERT(dynamic_cast< const SfxBoolItem *>( pItem ) != nullptr, "BoolItem expected"); officecfg::Office::Common::Save::WorkingSet::set( - static_cast<const SfxBoolItem *>(pItem)->GetValue(), + pItem->GetValue(), batch); } // Save window settings - if ( SfxItemState::SET == rSet.GetItemState(SID_ATTR_SAVEDOCVIEW, true, &pItem)) + if ( const SfxBoolItem *pItem = rSet.GetItemIfSet(SID_ATTR_SAVEDOCVIEW)) { - DBG_ASSERT(dynamic_cast< const SfxBoolItem *>( pItem ) != nullptr, "BoolItem expected"); - officecfg::Office::Common::Save::Document::ViewInfo::set(static_cast<const SfxBoolItem *>(pItem)->GetValue(), batch); + officecfg::Office::Common::Save::Document::ViewInfo::set(pItem->GetValue(), batch); } // Metric - if ( SfxItemState::SET == rSet.GetItemState(rPool.GetWhich(SID_ATTR_METRIC), true, &pItem)) + const SfxPoolItem* pItem1 = nullptr; + if ( SfxItemState::SET == rSet.GetItemState(rPool.GetWhich(SID_ATTR_METRIC), true, &pItem1)) { - DBG_ASSERT(dynamic_cast< const SfxUInt16Item *>( pItem ) != nullptr, "UInt16Item expected"); + DBG_ASSERT(dynamic_cast< const SfxUInt16Item *>( pItem1 ) != nullptr, "UInt16Item expected"); } // HelpBalloons - if ( SfxItemState::SET == rSet.GetItemState(SID_HELPBALLOONS, true, &pItem)) + if ( const SfxBoolItem *pItem = rSet.GetItemIfSet(SID_HELPBALLOONS)) { - DBG_ASSERT(dynamic_cast< const SfxBoolItem *>( pItem ) != nullptr, "BoolItem expected"); officecfg::Office::Common::Help::ExtendedTip::set( - static_cast<const SfxBoolItem *>(pItem)->GetValue(), + pItem->GetValue(), batch); } // HelpTips - if ( SfxItemState::SET == rSet.GetItemState(SID_HELPTIPS, true, &pItem)) + if ( const SfxBoolItem *pItem = rSet.GetItemIfSet(SID_HELPTIPS)) { - DBG_ASSERT(dynamic_cast< const SfxBoolItem *>( pItem ) != nullptr, "BoolItem expected"); officecfg::Office::Common::Help::Tip::set( - static_cast<const SfxBoolItem *>(pItem)->GetValue(), + pItem->GetValue(), batch); } - if ( SfxItemState::SET == rSet.GetItemState(SID_HELP_STYLESHEET, true, &pItem)) + if ( const SfxStringItem *pItem = rSet.GetItemIfSet(SID_HELP_STYLESHEET)) { - DBG_ASSERT(dynamic_cast< const SfxStringItem *>( pItem ) != nullptr, "StringItem expected"); - OUString sStyleSheet = static_cast<const SfxStringItem *>(pItem)->GetValue(); + OUString sStyleSheet = pItem->GetValue(); officecfg::Office::Common::Help::HelpStyleSheet::set(sStyleSheet, batch); } // SaveRelINet - if ( SfxItemState::SET == rSet.GetItemState(SID_SAVEREL_INET, true, &pItem)) + if ( const SfxBoolItem *pItem = rSet.GetItemIfSet(SID_SAVEREL_INET)) { - DBG_ASSERT(dynamic_cast< const SfxBoolItem *>( pItem ) != nullptr, "BoolItem expected"); officecfg::Office::Common::Save::URL::Internet::set( - static_cast<const SfxBoolItem *>(pItem)->GetValue(), + pItem->GetValue(), batch); } // SaveRelFSys - if ( SfxItemState::SET == rSet.GetItemState(SID_SAVEREL_FSYS, true, &pItem)) + if ( const SfxBoolItem *pItem = rSet.GetItemIfSet(SID_SAVEREL_FSYS)) { - DBG_ASSERT(dynamic_cast< const SfxBoolItem *>( pItem ) != nullptr, "BoolItem expected"); officecfg::Office::Common::Save::URL::FileSystem::set( - static_cast<const SfxBoolItem *>(pItem)->GetValue(), + pItem->GetValue(), batch); } // Undo-Count - if ( SfxItemState::SET == rSet.GetItemState(SID_ATTR_UNDO_COUNT, true, &pItem)) + if ( const SfxUInt16Item *pItem = rSet.GetItemIfSet(SID_ATTR_UNDO_COUNT)) { - DBG_ASSERT(dynamic_cast< const SfxUInt16Item *>( pItem ) != nullptr, "UInt16Item expected"); - sal_uInt16 nUndoCount = static_cast<const SfxUInt16Item*>(pItem)->GetValue(); + sal_uInt16 nUndoCount = pItem->GetValue(); officecfg::Office::Common::Undo::Steps::set(nUndoCount, batch); // To catch all Undo-Managers: Iterate over all Frames @@ -591,55 +574,47 @@ void SfxApplication::SetOptions_Impl( const SfxItemSet& rSet ) } // Office autostart - if ( SfxItemState::SET == rSet.GetItemState(SID_ATTR_QUICKLAUNCHER, true, &pItem)) + if ( const SfxBoolItem *pItem = rSet.GetItemIfSet(SID_ATTR_QUICKLAUNCHER)) { - DBG_ASSERT(dynamic_cast< const SfxBoolItem *>( pItem ) != nullptr, "BoolItem expected"); - ShutdownIcon::SetAutostart( static_cast<const SfxBoolItem*>( pItem )->GetValue() ); + ShutdownIcon::SetAutostart( pItem->GetValue() ); } - if ( SfxItemState::SET == rSet.GetItemState(SID_INET_PROXY_TYPE, true, &pItem)) + if ( const SfxUInt16Item *pItem = rSet.GetItemIfSet(SID_INET_PROXY_TYPE)) { - DBG_ASSERT( dynamic_cast< const SfxUInt16Item *>( pItem ) != nullptr, "UInt16Item expected" ); officecfg::Inet::Settings::ooInetProxyType::set( - static_cast< SfxUInt16Item const * >(pItem)->GetValue(), batch); + pItem->GetValue(), batch); } - if ( SfxItemState::SET == rSet.GetItemState( SID_INET_HTTP_PROXY_NAME, true, &pItem ) ) + if ( const SfxStringItem *pItem = rSet.GetItemIfSet( SID_INET_HTTP_PROXY_NAME ) ) { - DBG_ASSERT( dynamic_cast< const SfxStringItem *>( pItem ) != nullptr, "StringItem expected" ); officecfg::Inet::Settings::ooInetHTTPProxyName::set( - static_cast< SfxStringItem const * >(pItem)->GetValue(), batch); + pItem->GetValue(), batch); } - if ( SfxItemState::SET == rSet.GetItemState( SID_INET_HTTP_PROXY_PORT, true, &pItem ) ) + if ( const SfxInt32Item *pItem = rSet.GetItemIfSet( SID_INET_HTTP_PROXY_PORT ) ) { - DBG_ASSERT( dynamic_cast< const SfxInt32Item *>( pItem ) != nullptr, "Int32Item expected" ); officecfg::Inet::Settings::ooInetHTTPProxyPort::set( - static_cast< SfxInt32Item const * >(pItem)->GetValue(), batch); + pItem->GetValue(), batch); } - if ( SfxItemState::SET == rSet.GetItemState( SID_INET_FTP_PROXY_NAME, true, &pItem ) ) + if ( const SfxStringItem *pItem = rSet.GetItemIfSet( SID_INET_FTP_PROXY_NAME ) ) { - DBG_ASSERT( dynamic_cast< const SfxStringItem *>( pItem ) != nullptr, "StringItem expected" ); officecfg::Inet::Settings::ooInetFTPProxyName::set( - static_cast< SfxStringItem const * >(pItem)->GetValue(), batch); + pItem->GetValue(), batch); } - if ( SfxItemState::SET == rSet.GetItemState( SID_INET_FTP_PROXY_PORT, true, &pItem ) ) + if (const SfxInt32Item *pItem = rSet.GetItemIfSet( SID_INET_FTP_PROXY_PORT ) ) { - DBG_ASSERT( dynamic_cast< const SfxInt32Item *>( pItem ) != nullptr, "Int32Item expected" ); officecfg::Inet::Settings::ooInetFTPProxyPort::set( - static_cast< SfxInt32Item const * >(pItem)->GetValue(), batch); + pItem->GetValue(), batch); } - if ( SfxItemState::SET == rSet.GetItemState(SID_INET_NOPROXY, true, &pItem)) + if ( const SfxStringItem* pStringItem = rSet.GetItemIfSet(SID_INET_NOPROXY)) { - DBG_ASSERT(dynamic_cast< const SfxStringItem *>( pItem ) != nullptr, "StringItem expected"); officecfg::Inet::Settings::ooInetNoProxy::set( - static_cast< SfxStringItem const * >(pItem)->GetValue(), batch); + pStringItem->GetValue(), batch); } // Secure-Referrer - if ( SfxItemState::SET == rSet.GetItemState(SID_SECURE_URL, true, &pItem)) + if ( const SfxStringListItem *pListItem = rSet.GetItemIfSet(SID_SECURE_URL)) { - DBG_ASSERT(dynamic_cast< const SfxStringListItem *>( pItem ) != nullptr, "StringListItem expected"); - SvtSecurityOptions::SetSecureURLs( std::vector(static_cast<const SfxStringListItem*>(pItem)->GetList()) ); + SvtSecurityOptions::SetSecureURLs( std::vector(pListItem->GetList()) ); } // Store changed data @@ -652,15 +627,12 @@ void SfxApplication::SetOptions(const SfxItemSet &rSet) SvtPathOptions aPathOptions; // Data is saved in DocInfo and IniManager - const SfxPoolItem *pItem = nullptr; SfxAllItemSet aSendSet( rSet ); // PathName - if ( SfxItemState::SET == rSet.GetItemState(SID_ATTR_PATHNAME, true, &pItem)) + if ( const SfxAllEnumItem* pEnumItem = rSet.GetItemIfSet(SID_ATTR_PATHNAME)) { - DBG_ASSERT(dynamic_cast< const SfxAllEnumItem *>( pItem ) != nullptr, "AllEnumItem expected"); - const SfxAllEnumItem* pEnumItem = static_cast<const SfxAllEnumItem *>(pItem); sal_uInt32 nCount = pEnumItem->GetTextCount(); OUString aNoChangeStr( ' ' ); for( sal_uInt32 nPath=0; nPath<nCount; ++nPath ) diff --git a/sfx2/source/appl/appserv.cxx b/sfx2/source/appl/appserv.cxx index eeb47762611d..4c0aa1b85e46 100644 --- a/sfx2/source/appl/appserv.cxx +++ b/sfx2/source/appl/appserv.cxx @@ -244,12 +244,11 @@ namespace Reference<XFrame> GetRequestFrame(const SfxRequest& rReq) { const SfxItemSet* pArgs = rReq.GetInternalArgs_Impl(); - const SfxPoolItem* pItem = nullptr; + const SfxUnoFrameItem* pItem = nullptr; Reference <XFrame> xFrame; - if (pArgs && pArgs->GetItemState(SID_FILLFRAME, false, &pItem) == SfxItemState::SET) + if (pArgs && (pItem = pArgs->GetItemIfSet(SID_FILLFRAME, false))) { - assert( dynamic_cast< const SfxUnoFrameItem *>( pItem ) && "SfxApplication::OfaExec_Impl: XFrames are to be transported via SfxUnoFrameItem by now!" ); - xFrame = static_cast< const SfxUnoFrameItem*>( pItem )->GetFrame(); + xFrame = pItem->GetFrame(); } return xFrame; } @@ -297,11 +296,10 @@ namespace weld::Window* SfxRequest::GetFrameWeld() const { const SfxItemSet* pIntArgs = GetInternalArgs_Impl(); - const SfxPoolItem* pItem = nullptr; - if (pIntArgs && pIntArgs->GetItemState(SID_DIALOG_PARENT, false, &pItem) == SfxItemState::SET) + const SfxUnoAnyItem* pItem = nullptr; + if (pIntArgs && (pItem = pIntArgs->GetItemIfSet(SID_DIALOG_PARENT, false))) { - assert(dynamic_cast<const SfxUnoAnyItem*>(pItem)); - auto aAny = static_cast<const SfxUnoAnyItem*>(pItem)->GetValue(); + auto aAny = pItem->GetValue(); Reference<awt::XWindow> xWindow; aAny >>= xWindow; return Application::GetFrameWeld(xWindow); @@ -1481,12 +1479,12 @@ void SfxApplication::OfaExec_Impl( SfxRequest& rReq ) case SID_BASICCHOOSER: { const SfxItemSet* pArgs = rReq.GetArgs(); - const SfxPoolItem* pItem; + const SfxBoolItem* pItem; bool bChooseOnly = false; Reference< XModel > xLimitToModel; - if(pArgs && SfxItemState::SET == pArgs->GetItemState(SID_RECORDMACRO, false, &pItem) ) + if(pArgs && (pItem = pArgs->GetItemIfSet(SID_RECORDMACRO, false)) ) { - bool bRecord = static_cast<const SfxBoolItem*>(pItem)->GetValue(); + bool bRecord = pItem->GetValue(); if ( bRecord ) { // !Hack @@ -1508,11 +1506,11 @@ void SfxApplication::OfaExec_Impl( SfxRequest& rReq ) { SAL_INFO("sfx.appl", "handling SID_MACROORGANIZER"); const SfxItemSet* pArgs = rReq.GetArgs(); - const SfxPoolItem* pItem; + const SfxUInt16Item* pItem; sal_Int16 nTabId = 0; - if(pArgs && SfxItemState::SET == pArgs->GetItemState(SID_MACROORGANIZER, false, &pItem) ) + if(pArgs && (pItem = pArgs->GetItemIfSet(SID_MACROORGANIZER, false) )) { - nTabId = static_cast<const SfxUInt16Item*>(pItem)->GetValue(); + nTabId = pItem->GetValue(); } SfxApplication::MacroOrganizer(rReq.GetFrameWeld(), nTabId); @@ -1577,11 +1575,11 @@ void SfxApplication::OfaExec_Impl( SfxRequest& rReq ) SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create(); SAL_INFO("sfx.appl", "SfxApplication::OfaExec_Impl: case ScriptOrg"); const SfxItemSet* pArgs = rReq.GetArgs(); - const SfxPoolItem* pItem; + const SfxScriptOrganizerItem* pItem; OUString aLanguage; - if(pArgs && SfxItemState::SET == pArgs->GetItemState(SID_SCRIPTORGANIZER, false, &pItem) ) + if(pArgs && (pItem = pArgs->GetItemIfSet(SID_SCRIPTORGANIZER, false) )) { - aLanguage = static_cast<const SfxScriptOrganizerItem*>(pItem)->getLanguage(); + aLanguage = pItem->getLanguage(); } OUString aLang( aLanguage ); diff --git a/sfx2/source/appl/appuno.cxx b/sfx2/source/appl/appuno.cxx index 2373035dacf8..1c4994f93929 100644 --- a/sfx2/source/appl/appuno.cxx +++ b/sfx2/source/appl/appuno.cxx @@ -1380,68 +1380,67 @@ void TransformItems( sal_uInt16 nSlotId, const SfxItemSet& rSet, uno::Sequence<b nSlotId == SID_EXPORTDOCASEPUB || nSlotId == SID_DIRECTEXPORTDOCASEPUB || nSlotId == SID_REDACTDOC || nSlotId == SID_AUTOREDACTDOC || nSlotId == SID_SAVEACOPY ) { - const SfxPoolItem *pItem=nullptr; - if ( rSet.GetItemState( SID_COMPONENTDATA, false, &pItem ) == SfxItemState::SET ) + if ( const SfxUnoAnyItem *pItem = rSet.GetItemIfSet( SID_COMPONENTDATA, false) ) { pValue[nActProp].Name = sComponentData; - pValue[nActProp++].Value = static_cast<const SfxUnoAnyItem*>(pItem)->GetValue(); + pValue[nActProp++].Value = pItem->GetValue(); } - if ( rSet.GetItemState( SID_COMPONENTCONTEXT, false, &pItem ) == SfxItemState::SET ) + if ( const SfxUnoAnyItem *pItem = rSet.GetItemIfSet( SID_COMPONENTCONTEXT, false) ) { pValue[nActProp].Name = sComponentContext; - pValue[nActProp++].Value = static_cast<const SfxUnoAnyItem*>(pItem)->GetValue(); + pValue[nActProp++].Value = pItem->GetValue(); } - if ( rSet.GetItemState( SID_PROGRESS_STATUSBAR_CONTROL, false, &pItem ) == SfxItemState::SET ) + if ( const SfxUnoAnyItem *pItem = rSet.GetItemIfSet( SID_PROGRESS_STATUSBAR_CONTROL, false) ) { pValue[nActProp].Name = sStatusInd; - pValue[nActProp++].Value = static_cast<const SfxUnoAnyItem*>(pItem)->GetValue(); + pValue[nActProp++].Value = pItem->GetValue(); } - if ( rSet.GetItemState( SID_INTERACTIONHANDLER, false, &pItem ) == SfxItemState::SET ) + if ( const SfxUnoAnyItem *pItem = rSet.GetItemIfSet( SID_INTERACTIONHANDLER, false) ) { pValue[nActProp].Name = sInteractionHdl; - pValue[nActProp++].Value = static_cast<const SfxUnoAnyItem*>(pItem)->GetValue(); + pValue[nActProp++].Value = pItem->GetValue(); } - if ( rSet.GetItemState( SID_VIEW_DATA, false, &pItem ) == SfxItemState::SET ) + if ( const SfxUnoAnyItem *pItem = rSet.GetItemIfSet( SID_VIEW_DATA, false) ) { pValue[nActProp].Name = sViewData; - pValue[nActProp++].Value = static_cast<const SfxUnoAnyItem*>(pItem)->GetValue(); + pValue[nActProp++].Value = pItem->GetValue(); } - if ( rSet.GetItemState( SID_FILTER_DATA, false, &pItem ) == SfxItemState::SET ) + if ( const SfxUnoAnyItem *pItem = rSet.GetItemIfSet( SID_FILTER_DATA, false) ) { pValue[nActProp].Name = sFilterData; - pValue[nActProp++].Value = static_cast<const SfxUnoAnyItem*>(pItem)->GetValue(); + pValue[nActProp++].Value = pItem->GetValue(); } - if ( rSet.GetItemState( SID_DOCUMENT, false, &pItem ) == SfxItemState::SET ) + if ( const SfxUnoAnyItem *pItem = rSet.GetItemIfSet( SID_DOCUMENT, false) ) { pValue[nActProp].Name = sModel; - pValue[nActProp++].Value = static_cast<const SfxUnoAnyItem*>(pItem)->GetValue(); + pValue[nActProp++].Value = pItem->GetValue(); } - if ( rSet.GetItemState( SID_CONTENT, false, &pItem ) == SfxItemState::SET ) + if ( const SfxUnoAnyItem *pItem = rSet.GetItemIfSet( SID_CONTENT, false) ) { pValue[nActProp].Name = sUCBContent; - pValue[nActProp++].Value = static_cast<const SfxUnoAnyItem*>(pItem)->GetValue(); + pValue[nActProp++].Value = pItem->GetValue(); } - if ( rSet.GetItemState( SID_INPUTSTREAM, false, &pItem ) == SfxItemState::SET ) + if ( const SfxUnoAnyItem *pItem = rSet.GetItemIfSet( SID_INPUTSTREAM, false) ) { pValue[nActProp].Name = sInputStream; - pValue[nActProp++].Value = static_cast<const SfxUnoAnyItem*>(pItem)->GetValue(); + pValue[nActProp++].Value = pItem->GetValue(); } - if ( rSet.GetItemState( SID_STREAM, false, &pItem ) == SfxItemState::SET ) + if ( const SfxUnoAnyItem *pItem = rSet.GetItemIfSet( SID_STREAM, false) ) { pValue[nActProp].Name = sStream; - pValue[nActProp++].Value = static_cast<const SfxUnoAnyItem*>(pItem)->GetValue(); + pValue[nActProp++].Value = pItem->GetValue(); } - if ( rSet.GetItemState( SID_OUTPUTSTREAM, false, &pItem ) == SfxItemState::SET ) + if ( const SfxUnoAnyItem *pItem = rSet.GetItemIfSet( SID_OUTPUTSTREAM, false) ) { pValue[nActProp].Name = sOutputStream; - pValue[nActProp++].Value = static_cast<const SfxUnoAnyItem*>(pItem)->GetValue(); + pValue[nActProp++].Value = pItem->GetValue(); } - if ( rSet.GetItemState( SID_POSTDATA, false, &pItem ) == SfxItemState::SET ) + if ( const SfxUnoAnyItem *pItem = rSet.GetItemIfSet( SID_POSTDATA, false) ) { pValue[nActProp].Name = sPostData; - pValue[nActProp++].Value = static_cast<const SfxUnoAnyItem*>(pItem)->GetValue(); + pValue[nActProp++].Value = pItem->GetValue(); } - if ( rSet.GetItemState( SID_FILLFRAME, false, &pItem ) == SfxItemState::SET ) + if ( const SfxPoolItem *pItem = nullptr; SfxItemState::SET == rSet.GetItemState( SID_FILLFRAME, false, &pItem) ) { pValue[nActProp].Name = sFrame; if ( auto pUsrAnyItem = dynamic_cast< const SfxUnoAnyItem *>( pItem ) ) @@ -1454,244 +1453,244 @@ void TransformItems( sal_uInt16 nSlotId, const SfxItemSet& rSet, uno::Sequence<b else OSL_FAIL( "TransformItems: invalid item type for SID_FILLFRAME!" ); } - if ( rSet.GetItemState( SID_TEMPLATE, false, &pItem ) == SfxItemState::SET ) + if ( const SfxBoolItem *pItem = rSet.GetItemIfSet( SID_TEMPLATE, false) ) { pValue[nActProp].Name = sAsTemplate; - pValue[nActProp++].Value <<= static_cast<const SfxBoolItem*>(pItem)->GetValue(); + pValue[nActProp++].Value <<= pItem->GetValue(); } - if ( rSet.GetItemState( SID_OPEN_NEW_VIEW, false, &pItem ) == SfxItemState::SET ) + if ( const SfxBoolItem *pItem = rSet.GetItemIfSet( SID_OPEN_NEW_VIEW, false) ) { pValue[nActProp].Name = sOpenNewView; - pValue[nActProp++].Value <<= static_cast<const SfxBoolItem*>(pItem)->GetValue(); + pValue[nActProp++].Value <<= pItem->GetValue(); } - if ( rSet.GetItemState( SID_FAIL_ON_WARNING, false, &pItem ) == SfxItemState::SET ) + if ( const SfxBoolItem *pItem = rSet.GetItemIfSet( SID_FAIL_ON_WARNING, false) ) { pValue[nActProp].Name = sFailOnWarning; - pValue[nActProp++].Value <<= static_cast<const SfxBoolItem*>(pItem)->GetValue(); + pValue[nActProp++].Value <<= pItem->GetValue(); } - if ( rSet.GetItemState( SID_VIEW_ID, false, &pItem ) == SfxItemState::SET ) + if ( const SfxUInt16Item *pItem = rSet.GetItemIfSet( SID_VIEW_ID, false) ) { pValue[nActProp].Name = sViewId; - pValue[nActProp++].Value <<= static_cast<sal_Int16>(static_cast<const SfxUInt16Item*>(pItem)->GetValue()); + pValue[nActProp++].Value <<= static_cast<sal_Int16>(pItem->GetValue()); } - if ( rSet.GetItemState( SID_PLUGIN_MODE, false, &pItem ) == SfxItemState::SET ) + if ( const SfxUInt16Item *pItem = rSet.GetItemIfSet( SID_PLUGIN_MODE, false) ) { pValue[nActProp].Name = sPluginMode; - pValue[nActProp++].Value <<= static_cast<sal_Int16>(static_cast<const SfxUInt16Item*>(pItem)->GetValue()); + pValue[nActProp++].Value <<= static_cast<sal_Int16>(pItem->GetValue()); } - if ( rSet.GetItemState( SID_DOC_READONLY, false, &pItem ) == SfxItemState::SET ) + if ( const SfxBoolItem *pItem = rSet.GetItemIfSet( SID_DOC_READONLY, false) ) { pValue[nActProp].Name = sReadOnly; - pValue[nActProp++].Value <<= static_cast<const SfxBoolItem*>(pItem)->GetValue(); + pValue[nActProp++].Value <<= pItem->GetValue(); } - if ( rSet.GetItemState( SID_DDE_RECONNECT_ONLOAD, false, &pItem ) == SfxItemState::SET ) + if ( const SfxBoolItem *pItem = rSet.GetItemIfSet( SID_DDE_RECONNECT_ONLOAD, false) ) { pValue[nActProp].Name = sDdeReconnect; - pValue[nActProp++].Value <<= static_cast<const SfxBoolItem*>(pItem)->GetValue(); + pValue[nActProp++].Value <<= pItem->GetValue(); } - if ( rSet.GetItemState( SID_DOC_STARTPRESENTATION, false, &pItem ) == SfxItemState::SET ) + if ( const SfxBoolItem *pItem = rSet.GetItemIfSet( SID_DOC_STARTPRESENTATION, false) ) { pValue[nActProp].Name = sStartPresentation; - pValue[nActProp++].Value <<= static_cast<const SfxBoolItem*>(pItem)->GetValue(); + pValue[nActProp++].Value <<= pItem->GetValue(); } - if ( rSet.GetItemState( SID_SELECTION, false, &pItem ) == SfxItemState::SET ) + if ( const SfxBoolItem *pItem = rSet.GetItemIfSet( SID_SELECTION, false) ) { pValue[nActProp].Name = sSelectionOnly; - pValue[nActProp++].Value <<= static_cast<const SfxBoolItem*>(pItem)->GetValue(); + pValue[nActProp++].Value <<= pItem->GetValue(); } - if ( rSet.GetItemState( SID_HIDDEN, false, &pItem ) == SfxItemState::SET ) + if ( const SfxBoolItem *pItem = rSet.GetItemIfSet( SID_HIDDEN, false) ) { pValue[nActProp].Name = sHidden; - pValue[nActProp++].Value <<= static_cast<const SfxBoolItem*>(pItem)->GetValue(); + pValue[nActProp++].Value <<= pItem->GetValue(); } - if ( rSet.GetItemState( SID_MINIMIZED, false, &pItem ) == SfxItemState::SET ) + if ( const SfxBoolItem *pItem = rSet.GetItemIfSet( SID_MINIMIZED, false) ) { pValue[nActProp].Name = sMinimized; - pValue[nActProp++].Value <<= static_cast<const SfxBoolItem*>(pItem)->GetValue(); + pValue[nActProp++].Value <<= pItem->GetValue(); } - if ( rSet.GetItemState( SID_SILENT, false, &pItem ) == SfxItemState::SET ) + if ( const SfxBoolItem *pItem = rSet.GetItemIfSet( SID_SILENT, false) ) { pValue[nActProp].Name = sSilent; - pValue[nActProp++].Value <<= static_cast<const SfxBoolItem*>(pItem)->GetValue(); + pValue[nActProp++].Value <<= pItem->GetValue(); } - if ( rSet.GetItemState( SID_PREVIEW, false, &pItem ) == SfxItemState::SET ) + if ( const SfxBoolItem *pItem = rSet.GetItemIfSet( SID_PREVIEW, false) ) { pValue[nActProp].Name = sPreview; - pValue[nActProp++].Value <<= static_cast<const SfxBoolItem*>(pItem)->GetValue(); + pValue[nActProp++].Value <<= pItem->GetValue(); } - if ( rSet.GetItemState( SID_VIEWONLY, false, &pItem ) == SfxItemState::SET ) + if ( const SfxBoolItem *pItem = rSet.GetItemIfSet( SID_VIEWONLY, false) ) { pValue[nActProp].Name = sViewOnly; - pValue[nActProp++].Value <<= static_cast<const SfxBoolItem*>(pItem)->GetValue(); + pValue[nActProp++].Value <<= pItem->GetValue(); } - if ( rSet.GetItemState( SID_EDITDOC, false, &pItem ) == SfxItemState::SET ) + if ( const SfxBoolItem *pItem = rSet.GetItemIfSet( SID_EDITDOC, false) ) { pValue[nActProp].Name = sDontEdit; - pValue[nActProp++].Value <<= !static_cast<const SfxBoolItem*>(pItem)->GetValue(); + pValue[nActProp++].Value <<= !pItem->GetValue(); } - if ( rSet.GetItemState( SID_FILE_DIALOG, false, &pItem ) == SfxItemState::SET ) + if ( const SfxBoolItem *pItem = rSet.GetItemIfSet( SID_FILE_DIALOG, false) ) { pValue[nActProp].Name = sUseSystemDialog; - pValue[nActProp++].Value <<= static_cast<const SfxBoolItem*>(pItem)->GetValue(); + pValue[nActProp++].Value <<= pItem->GetValue(); } - if ( rSet.GetItemState( SID_STANDARD_DIR, false, &pItem ) == SfxItemState::SET ) + if ( const SfxStringItem *pItem = rSet.GetItemIfSet( SID_STANDARD_DIR, false) ) { pValue[nActProp].Name = sStandardDir; - pValue[nActProp++].Value <<= static_cast<const SfxStringItem*>(pItem)->GetValue(); + pValue[nActProp++].Value <<= pItem->GetValue(); } - if ( rSet.GetItemState( SID_DENY_LIST, false, &pItem ) == SfxItemState::SET ) + if ( const SfxStringListItem *pItem = rSet.GetItemIfSet( SID_DENY_LIST, false) ) { pValue[nActProp].Name = sDenyList; css::uno::Sequence< OUString > aList; - static_cast<const SfxStringListItem*>(pItem)->GetStringList( aList ); + pItem->GetStringList( aList ); pValue[nActProp++].Value <<= aList ; } - if ( rSet.GetItemState( SID_TARGETNAME, false, &pItem ) == SfxItemState::SET ) + if ( const SfxStringItem *pItem = rSet.GetItemIfSet( SID_TARGETNAME, false) ) { pValue[nActProp].Name = sFrameName; - pValue[nActProp++].Value <<= static_cast<const SfxStringItem*>(pItem)->GetValue(); + pValue[nActProp++].Value <<= pItem->GetValue(); } - if ( rSet.GetItemState( SID_DOC_SALVAGE, false, &pItem ) == SfxItemState::SET ) + if ( const SfxStringItem *pItem = rSet.GetItemIfSet( SID_DOC_SALVAGE, false) ) { pValue[nActProp].Name = sSalvagedFile; - pValue[nActProp++].Value <<= static_cast<const SfxStringItem*>(pItem)->GetValue(); + pValue[nActProp++].Value <<= pItem->GetValue(); } - if ( rSet.GetItemState( SID_PATH, false, &pItem ) == SfxItemState::SET ) + if ( const SfxStringItem *pItem = rSet.GetItemIfSet( SID_PATH, false) ) { pValue[nActProp].Name = sFolderName; - pValue[nActProp++].Value <<= static_cast<const SfxStringItem*>(pItem)->GetValue(); + pValue[nActProp++].Value <<= pItem->GetValue(); } - if ( rSet.GetItemState( SID_CONTENTTYPE, false, &pItem ) == SfxItemState::SET ) + if ( const SfxStringItem *pItem = rSet.GetItemIfSet( SID_CONTENTTYPE, false) ) { pValue[nActProp].Name = sMediaType; - pValue[nActProp++].Value <<= static_cast<const SfxStringItem*>(pItem)->GetValue(); + pValue[nActProp++].Value <<= pItem->GetValue(); } - if ( rSet.GetItemState( SID_TEMPLATE_NAME, false, &pItem ) == SfxItemState::SET ) + if ( const SfxStringItem *pItem = rSet.GetItemIfSet( SID_TEMPLATE_NAME, false) ) { pValue[nActProp].Name = sTemplateName; - pValue[nActProp++].Value <<= static_cast<const SfxStringItem*>(pItem)->GetValue(); + pValue[nActProp++].Value <<= pItem->GetValue(); } - if ( rSet.GetItemState( SID_TEMPLATE_REGIONNAME, false, &pItem ) == SfxItemState::SET ) + if ( const SfxStringItem *pItem = rSet.GetItemIfSet( SID_TEMPLATE_REGIONNAME, false) ) { pValue[nActProp].Name = sTemplateRegionName; - pValue[nActProp++].Value <<= static_cast<const SfxStringItem*>(pItem)->GetValue(); + pValue[nActProp++].Value <<= pItem->GetValue(); } - if ( rSet.GetItemState( SID_JUMPMARK, false, &pItem ) == SfxItemState::SET ) + if ( const SfxStringItem *pItem = rSet.GetItemIfSet( SID_JUMPMARK, false) ) { pValue[nActProp].Name = sJumpMark; - pValue[nActProp++].Value <<= static_cast<const SfxStringItem*>(pItem)->GetValue(); + pValue[nActProp++].Value <<= pItem->GetValue(); } - if ( rSet.GetItemState( SID_CHARSET, false, &pItem ) == SfxItemState::SET ) + if ( const SfxStringItem *pItem = rSet.GetItemIfSet( SID_CHARSET, false) ) { pValue[nActProp].Name = sCharacterSet; - pValue[nActProp++].Value <<= static_cast<const SfxStringItem*>(pItem)->GetValue(); + pValue[nActProp++].Value <<= pItem->GetValue(); } - if ( rSet.GetItemState( SID_MACROEXECMODE, false, &pItem ) == SfxItemState::SET ) + if ( const SfxUInt16Item *pItem = rSet.GetItemIfSet( SID_MACROEXECMODE, false) ) { pValue[nActProp].Name = sMacroExecMode; - pValue[nActProp++].Value <<= static_cast<sal_Int16>(static_cast<const SfxUInt16Item*>(pItem)->GetValue()); + pValue[nActProp++].Value <<= static_cast<sal_Int16>(pItem->GetValue()); } - if ( rSet.GetItemState( SID_UPDATEDOCMODE, false, &pItem ) == SfxItemState::SET ) + if ( const SfxUInt16Item *pItem = rSet.GetItemIfSet( SID_UPDATEDOCMODE, false) ) { pValue[nActProp].Name = sUpdateDocMode; - pValue[nActProp++].Value <<= static_cast<sal_Int16>(static_cast<const SfxUInt16Item*>(pItem)->GetValue()); + pValue[nActProp++].Value <<= static_cast<sal_Int16>(pItem->GetValue()); } - if ( rSet.GetItemState( SID_REPAIRPACKAGE, false, &pItem ) == SfxItemState::SET ) + if ( const SfxBoolItem *pItem = rSet.GetItemIfSet( SID_REPAIRPACKAGE, false) ) { pValue[nActProp].Name = sRepairPackage; - pValue[nActProp++].Value <<= static_cast<const SfxBoolItem*>(pItem)->GetValue() ; + pValue[nActProp++].Value <<= pItem->GetValue() ; } - if ( rSet.GetItemState( SID_DOCINFO_TITLE, false, &pItem ) == SfxItemState::SET ) + if ( const SfxStringItem *pItem = rSet.GetItemIfSet( SID_DOCINFO_TITLE, false) ) { pValue[nActProp].Name = sDocumentTitle; - pValue[nActProp++].Value <<= static_cast<const SfxStringItem*>(pItem)->GetValue(); + pValue[nActProp++].Value <<= pItem->GetValue(); } - if ( rSet.GetItemState( SID_DOC_BASEURL, false, &pItem ) == SfxItemState::SET ) + if ( const SfxStringItem *pItem = rSet.GetItemIfSet( SID_DOC_BASEURL, false) ) { pValue[nActProp].Name = sDocumentBaseURL; - pValue[nActProp++].Value <<= static_cast<const SfxStringItem*>(pItem)->GetValue(); + pValue[nActProp++].Value <<= pItem->GetValue(); } - if ( rSet.GetItemState( SID_DOC_HIERARCHICALNAME, false, &pItem ) == SfxItemState::SET ) + if ( const SfxStringItem *pItem = rSet.GetItemIfSet( SID_DOC_HIERARCHICALNAME, false) ) { pValue[nActProp].Name = sHierarchicalDocumentName; - pValue[nActProp++].Value <<= static_cast<const SfxStringItem*>(pItem)->GetValue(); + pValue[nActProp++].Value <<= pItem->GetValue(); } - if ( rSet.GetItemState( SID_COPY_STREAM_IF_POSSIBLE, false, &pItem ) == SfxItemState::SET ) + if ( const SfxBoolItem *pItem = rSet.GetItemIfSet( SID_COPY_STREAM_IF_POSSIBLE, false) ) { pValue[nActProp].Name = sCopyStreamIfPossible; - pValue[nActProp++].Value <<= static_cast<const SfxBoolItem*>(pItem)->GetValue(); + pValue[nActProp++].Value <<= pItem->GetValue(); } - if ( rSet.GetItemState( SID_NOAUTOSAVE, false, &pItem ) == SfxItemState::SET ) + if ( const SfxBoolItem *pItem = rSet.GetItemIfSet( SID_NOAUTOSAVE, false) ) { pValue[nActProp].Name = sNoAutoSave; - pValue[nActProp++].Value <<= static_cast<const SfxBoolItem*>(pItem)->GetValue() ; + pValue[nActProp++].Value <<= pItem->GetValue() ; } - if ( rSet.GetItemState( SID_MODIFYPASSWORDINFO, false, &pItem ) == SfxItemState::SET ) + if ( const SfxUnoAnyItem *pItem = rSet.GetItemIfSet( SID_MODIFYPASSWORDINFO, false) ) { pValue[nActProp].Name = sModifyPasswordInfo; - pValue[nActProp++].Value = static_cast<const SfxUnoAnyItem*>(pItem)->GetValue(); + pValue[nActProp++].Value = pItem->GetValue(); } - if ( rSet.GetItemState( SID_ENCRYPTIONDATA, false, &pItem ) == SfxItemState::SET ) + if ( const SfxUnoAnyItem *pItem = rSet.GetItemIfSet( SID_ENCRYPTIONDATA, false) ) { pValue[nActProp].Name = sEncryptionData; - pValue[nActProp++].Value = static_cast<const SfxUnoAnyItem*>(pItem)->GetValue(); + pValue[nActProp++].Value = pItem->GetValue(); } - if ( rSet.GetItemState( SID_SUGGESTEDSAVEASDIR, false, &pItem ) == SfxItemState::SET ) + if ( const SfxStringItem *pItem = rSet.GetItemIfSet( SID_SUGGESTEDSAVEASDIR, false) ) { pValue[nActProp].Name = sSuggestedSaveAsDir; - pValue[nActProp++].Value <<= static_cast<const SfxStringItem*>(pItem)->GetValue(); + pValue[nActProp++].Value <<= pItem->GetValue(); } - if ( rSet.GetItemState( SID_SUGGESTEDSAVEASNAME, false, &pItem ) == SfxItemState::SET ) + if ( const SfxStringItem *pItem = rSet.GetItemIfSet( SID_SUGGESTEDSAVEASNAME, false) ) { pValue[nActProp].Name = sSuggestedSaveAsName; - pValue[nActProp++].Value <<= static_cast<const SfxStringItem*>(pItem)->GetValue(); + pValue[nActProp++].Value <<= pItem->GetValue(); } - if ( rSet.GetItemState( SID_DOC_SERVICE, false, &pItem ) == SfxItemState::SET ) + if ( const SfxStringItem *pItem = rSet.GetItemIfSet( SID_DOC_SERVICE, false) ) { pValue[nActProp].Name = sDocumentService; - pValue[nActProp++].Value <<= static_cast<const SfxStringItem*>(pItem)->GetValue(); + pValue[nActProp++].Value <<= pItem->GetValue(); } - if (rSet.HasItem(SID_FILTER_PROVIDER, &pItem)) + if (const SfxStringItem *pItem = rSet.GetItemIfSet(SID_FILTER_PROVIDER)) { pValue[nActProp].Name = sFilterProvider; - pValue[nActProp++].Value <<= static_cast<const SfxStringItem*>(pItem)->GetValue(); + pValue[nActProp++].Value <<= pItem->GetValue(); } - if (rSet.HasItem(SID_CONVERT_IMAGES, &pItem)) + if (const SfxStringItem *pItem = rSet.GetItemIfSet(SID_CONVERT_IMAGES)) { pValue[nActProp].Name = sImageFilter; - pValue[nActProp++].Value <<= static_cast<const SfxStringItem*>(pItem)->GetValue(); + pValue[nActProp++].Value <<= pItem->GetValue(); } - if ( rSet.GetItemState( SID_LOCK_CONTENT_EXTRACTION, false, &pItem ) == SfxItemState::SET ) + if ( const SfxBoolItem *pItem = rSet.GetItemIfSet( SID_LOCK_CONTENT_EXTRACTION, false) ) { pValue[nActProp].Name = sLockContentExtraction; - pValue[nActProp++].Value <<= static_cast<const SfxBoolItem*>(pItem)->GetValue() ; + pValue[nActProp++].Value <<= pItem->GetValue() ; } - if ( rSet.GetItemState( SID_LOCK_EXPORT, false, &pItem ) == SfxItemState::SET ) + if ( const SfxBoolItem *pItem = rSet.GetItemIfSet( SID_LOCK_EXPORT, false) ) { pValue[nActProp].Name = sLockExport; - pValue[nActProp++].Value <<= static_cast<const SfxBoolItem*>(pItem)->GetValue() ; + pValue[nActProp++].Value <<= pItem->GetValue() ; } - if ( rSet.GetItemState( SID_LOCK_PRINT, false, &pItem ) == SfxItemState::SET ) + if ( const SfxBoolItem *pItem = rSet.GetItemIfSet( SID_LOCK_PRINT, false) ) { pValue[nActProp].Name = sLockPrint; - pValue[nActProp++].Value <<= static_cast<const SfxBoolItem*>(pItem)->GetValue() ; + pValue[nActProp++].Value <<= pItem->GetValue() ; } - if ( rSet.GetItemState( SID_LOCK_SAVE, false, &pItem ) == SfxItemState::SET ) + if ( const SfxBoolItem *pItem = rSet.GetItemIfSet( SID_LOCK_SAVE, false) ) { pValue[nActProp].Name = sLockSave; - pValue[nActProp++].Value <<= static_cast<const SfxBoolItem*>(pItem)->GetValue() ; + pValue[nActProp++].Value <<= pItem->GetValue() ; } - if ( rSet.GetItemState( SID_LOCK_EDITDOC, false, &pItem ) == SfxItemState::SET ) + if ( const SfxBoolItem *pItem = rSet.GetItemIfSet( SID_LOCK_EDITDOC, false) ) { pValue[nActProp].Name = sLockEditDoc; - pValue[nActProp++].Value <<= static_cast<const SfxBoolItem*>(pItem)->GetValue(); + pValue[nActProp++].Value <<= pItem->GetValue(); } - if (rSet.GetItemState(SID_REPLACEABLE, false, &pItem) == SfxItemState::SET) + if (const SfxBoolItem *pItem = rSet.GetItemIfSet(SID_REPLACEABLE, false)) { pValue[nActProp].Name = sReplaceable; - pValue[nActProp++].Value <<= static_cast<const SfxBoolItem*>(pItem)->GetValue(); + pValue[nActProp++].Value <<= pItem->GetValue(); } } diff --git a/sfx2/source/dialog/dinfdlg.cxx b/sfx2/source/dialog/dinfdlg.cxx index 2a32e9c03dc9..41283d26d31f 100644 --- a/sfx2/source/dialog/dinfdlg.cxx +++ b/sfx2/source/dialog/dinfdlg.cxx @@ -606,14 +606,14 @@ bool SfxDocumentDescPage::FillItemSet(SfxItemSet *rSet) } // Generating the output data - const SfxPoolItem* pItem = nullptr; + const SfxDocumentInfoItem* pItem = nullptr; SfxDocumentInfoItem* pInfo = nullptr; const SfxItemSet* pExSet = GetDialogExampleSet(); - if ( pExSet && SfxItemState::SET != pExSet->GetItemState( SID_DOCINFO, true, &pItem ) ) + if ( pExSet && !(pItem = pExSet->GetItemIfSet( SID_DOCINFO )) ) pInfo = m_pInfoItem; else if ( pItem ) - pInfo = new SfxDocumentInfoItem( *static_cast<const SfxDocumentInfoItem *>(pItem) ); + pInfo = new SfxDocumentInfoItem( *pItem ); if ( !pInfo ) { @@ -855,11 +855,10 @@ bool SfxDocumentPage::FillItemSet( SfxItemSet* rSet ) m_xUseUserDataCB->get_state_changed_from_saved() ) { const SfxItemSet* pExpSet = GetDialogExampleSet(); - const SfxPoolItem* pItem; + const SfxDocumentInfoItem* pInfoItem; - if ( pExpSet && SfxItemState::SET == pExpSet->GetItemState( SID_DOCINFO, true, &pItem ) ) + if ( pExpSet && (pInfoItem = pExpSet->GetItemIfSet( SID_DOCINFO ) ) ) { - const SfxDocumentInfoItem* pInfoItem = static_cast<const SfxDocumentInfoItem*>(pItem); bool bUseData = ( TRISTATE_TRUE == m_xUseUserDataCB->get_state() ); const_cast<SfxDocumentInfoItem*>(pInfoItem)->SetUseUserData( bUseData ); rSet->Put( *pInfoItem ); @@ -870,10 +869,9 @@ bool SfxDocumentPage::FillItemSet( SfxItemSet* rSet ) if ( bHandleDelete ) { const SfxItemSet* pExpSet = GetDialogExampleSet(); - const SfxPoolItem* pItem; - if ( pExpSet && SfxItemState::SET == pExpSet->GetItemState( SID_DOCINFO, true, &pItem ) ) + const SfxDocumentInfoItem* pInfoItem; + if ( pExpSet && (pInfoItem = pExpSet->GetItemIfSet( SID_DOCINFO )) ) { - const SfxDocumentInfoItem* pInfoItem = static_cast<const SfxDocumentInfoItem*>(pItem); bool bUseAuthor = bEnableUseUserData && m_xUseUserDataCB->get_active(); SfxDocumentInfoItem newItem( *pInfoItem ); newItem.resetUserData( bUseAuthor @@ -891,11 +889,10 @@ bool SfxDocumentPage::FillItemSet( SfxItemSet* rSet ) if ( m_xUseThumbnailSaveCB->get_state_changed_from_saved() ) { const SfxItemSet* pExpSet = GetDialogExampleSet(); - const SfxPoolItem* pItem; + const SfxDocumentInfoItem* pInfoItem; - if ( pExpSet && SfxItemState::SET == pExpSet->GetItemState( SID_DOCINFO, true, &pItem ) ) + if ( pExpSet && (pInfoItem = pExpSet->GetItemIfSet( SID_DOCINFO )) ) { - const SfxDocumentInfoItem* pInfoItem = static_cast<const SfxDocumentInfoItem*>(pItem); bool bUseThumbnail = ( TRISTATE_TRUE == m_xUseThumbnailSaveCB->get_state() ); const_cast<SfxDocumentInfoItem*>(pInfoItem)->SetUseThumbnailSave( bUseThumbnail ); rSet->Put( *pInfoItem ); @@ -1126,10 +1123,9 @@ SfxDocumentInfoDialog::SfxDocumentInfoDialog(weld::Window* pParent, const SfxIte #endif // Determine the Titles - const SfxPoolItem* pItem = nullptr; OUString aTitle(m_xDialog->get_title()); - if ( SfxItemState::SET != - rItemSet.GetItemState( SID_EXPLORER_PROPS_START, false, &pItem ) ) + const SfxStringItem* pItem = rItemSet.GetItemIfSet( SID_EXPLORER_PROPS_START, false ); + if ( !pItem ) { // File name const OUString& aFile( rInfoItem.GetValue() ); @@ -1150,9 +1146,7 @@ SfxDocumentInfoDialog::SfxDocumentInfoDialog(weld::Window* pParent, const SfxIte } else { - DBG_ASSERT( dynamic_cast<const SfxStringItem *>(pItem) != nullptr, - "SfxDocumentInfoDialog:<SfxStringItem> expected" ); - aTitle = aTitle.replaceFirst("%1", static_cast<const SfxStringItem*>(pItem)->GetValue()); + aTitle = aTitle.replaceFirst("%1", pItem->GetValue()); } m_xDialog->set_title(aTitle); @@ -1970,18 +1964,19 @@ IMPL_LINK_NOARG(SfxCustomPropertiesPage, AddHdl, weld::Button&, void) bool SfxCustomPropertiesPage::FillItemSet( SfxItemSet* rSet ) { - const SfxPoolItem* pItem = nullptr; + const SfxDocumentInfoItem* pItem = nullptr; SfxDocumentInfoItem* pInfo = nullptr; bool bMustDelete = false; if (const SfxItemSet* pItemSet = GetDialogExampleSet()) { - if (SfxItemState::SET != pItemSet->GetItemState(SID_DOCINFO, true, &pItem)) + pItem = pItemSet->GetItemIfSet(SID_DOCINFO); + if (!pItem) pInfo = const_cast<SfxDocumentInfoItem*>(&rSet->Get( SID_DOCINFO )); else { bMustDelete = true; - pInfo = new SfxDocumentInfoItem( *static_cast<const SfxDocumentInfoItem*>(pItem) ); + pInfo = new SfxDocumentInfoItem( *pItem ); } } @@ -2354,18 +2349,19 @@ SfxCmisPropertiesPage::~SfxCmisPropertiesPage() bool SfxCmisPropertiesPage::FillItemSet( SfxItemSet* rSet ) { - const SfxPoolItem* pItem = nullptr; + const SfxDocumentInfoItem* pItem = nullptr; SfxDocumentInfoItem* pInfo = nullptr; bool bMustDelete = false; if (const SfxItemSet* pItemSet = GetDialogExampleSet()) { - if (SfxItemState::SET != pItemSet->GetItemState(SID_DOCINFO, true, &pItem)) + pItem = pItemSet->GetItemIfSet(SID_DOCINFO); + if (!pItem) pInfo = const_cast<SfxDocumentInfoItem*>(&rSet->Get( SID_DOCINFO )); else { bMustDelete = true; - pInfo = new SfxDocumentInfoItem( *static_cast<const SfxDocumentInfoItem*>(pItem) ); + pInfo = new SfxDocumentInfoItem( *pItem ); } } diff --git a/sfx2/source/dialog/mgetempl.cxx b/sfx2/source/dialog/mgetempl.cxx index de570eb24228..3b683b743bfd 100644 --- a/sfx2/source/dialog/mgetempl.cxx +++ b/sfx2/source/dialog/mgetempl.cxx @@ -556,11 +556,10 @@ void SfxManageStyleSheetPage::ActivatePage( const SfxItemSet& rSet) SetDescriptionText_Impl(); // It is a style with auto update? (SW only) - const SfxPoolItem* pPoolItem; + const SfxBoolItem* pPoolItem; - if ( SfxItemState::SET == - rSet.GetItemState( SID_ATTR_AUTO_STYLE_UPDATE, false, &pPoolItem ) ) - m_xAutoCB->set_active(static_cast<const SfxBoolItem*>(pPoolItem)->GetValue()); + if ( (pPoolItem = rSet.GetItemIfSet( SID_ATTR_AUTO_STYLE_UPDATE, false )) ) + m_xAutoCB->set_active(pPoolItem->GetValue()); m_xAutoCB->save_state(); m_xName->save_value(); } diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx index cfa203a85b44..a064bee327ce 100644 --- a/sfx2/source/doc/docfile.cxx +++ b/sfx2/source/doc/docfile.cxx @@ -3390,12 +3390,12 @@ SfxMedium::SfxMedium( const uno::Sequence<beans::PropertyValue>& aArgs ) : OUString aFilterProvider, aFilterName; { - const SfxPoolItem* pItem = nullptr; - if (pImpl->m_pSet->HasItem(SID_FILTER_PROVIDER, &pItem)) - aFilterProvider = static_cast<const SfxStringItem*>(pItem)->GetValue(); + const SfxStringItem* pItem = nullptr; + if ((pItem = pImpl->m_pSet->GetItemIfSet(SID_FILTER_PROVIDER))) + aFilterProvider = pItem->GetValue(); - if (pImpl->m_pSet->HasItem(SID_FILTER_NAME, &pItem)) - aFilterName = static_cast<const SfxStringItem*>(pItem)->GetValue(); + if ((pItem = pImpl->m_pSet->GetItemIfSet(SID_FILTER_NAME))) + aFilterName = pItem->GetValue(); } if (aFilterProvider.isEmpty()) diff --git a/sfx2/source/doc/guisaveas.cxx b/sfx2/source/doc/guisaveas.cxx index 3d8a2276c4f1..bc289ebb2ff5 100644 --- a/sfx2/source/doc/guisaveas.cxx +++ b/sfx2/source/doc/guisaveas.cxx @@ -986,8 +986,7 @@ bool ModelData_Impl::OutputFileDialog( sal_Int16 nStoreMode, GetMediaDescr().getAsConstPropertyValueList(), *pDialogParams ); - const SfxPoolItem* pItem = nullptr; - if ( bPreselectPassword && pDialogParams->GetItemState( SID_ENCRYPTIONDATA, true, &pItem ) != SfxItemState::SET ) + if ( bPreselectPassword && !pDialogParams->HasItem( SID_ENCRYPTIONDATA ) ) { // the file dialog preselects the password checkbox if the provided mediadescriptor has encryption data entry // after dialog execution the password interaction flag will be either removed or not diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx index 0c9a742158d2..2d1faf2a5ced 100644 --- a/sfx2/source/view/viewfrm.cxx +++ b/sfx2/source/view/viewfrm.cxx @@ -2428,12 +2428,12 @@ void SfxViewFrame::ExecView_Impl case SID_VIEWSHELL: { - const SfxPoolItem *pItem = nullptr; + const SfxUInt16Item *pItem = nullptr; if ( rReq.GetArgs() - && SfxItemState::SET == rReq.GetArgs()->GetItemState( SID_VIEWSHELL, false, &pItem ) + && (pItem = rReq.GetArgs()->GetItemIfSet( SID_VIEWSHELL, false )) ) { - const sal_uInt16 nViewId = static_cast< const SfxUInt16Item* >( pItem )->GetValue(); + const sal_uInt16 nViewId = pItem->GetValue(); bool bSuccess = SwitchToViewShell_Impl( nViewId ); rReq.SetReturnValue( SfxBoolItem( 0, bSuccess ) ); } diff --git a/sfx2/source/view/viewprn.cxx b/sfx2/source/view/viewprn.cxx index 6b0b1812683e..77a9c40cd074 100644 --- a/sfx2/source/view/viewprn.cxx +++ b/sfx2/source/view/viewprn.cxx @@ -470,8 +470,7 @@ void SfxViewShell::SetPrinter_Impl( VclPtr<SfxPrinter>& pNewPrinter ) SfxPrinter *pDocPrinter = GetPrinter(); // Evaluate Printer Options - const SfxFlagItem *pFlagItem = nullptr; - pDocPrinter->GetOptions().GetItemState( SID_PRINTER_CHANGESTODOC, false, reinterpret_cast<const SfxPoolItem**>(&pFlagItem) ); + const SfxFlagItem *pFlagItem = pDocPrinter->GetOptions().GetItemIfSet( SID_PRINTER_CHANGESTODOC, false ); bool bOriToDoc = pFlagItem && (static_cast<SfxPrinterChangeFlags>(pFlagItem->GetValue()) & SfxPrinterChangeFlags::CHG_ORIENTATION); bool bSizeToDoc = pFlagItem && (static_cast<SfxPrinterChangeFlags>(pFlagItem->GetValue()) & SfxPrinterChangeFlags::CHG_SIZE); |