From 0a1031a9ecd1502b1841bde26dde7ad51358c638 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Thu, 3 Mar 2022 09:56:09 +0200 Subject: use SfxItemSet::GetItemIfSet in sw/source/uibase Change-Id: Ic82df8d321ba2eb94957236264c71c5eb9a940a7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130905 Tested-by: Jenkins Reviewed-by: Noel Grandin --- sw/source/uibase/shells/textsh.cxx | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) (limited to 'sw/source/uibase/shells/textsh.cxx') diff --git a/sw/source/uibase/shells/textsh.cxx b/sw/source/uibase/shells/textsh.cxx index 8fe5862e3479..879bb4809efa 100644 --- a/sw/source/uibase/shells/textsh.cxx +++ b/sw/source/uibase/shells/textsh.cxx @@ -386,11 +386,12 @@ void SwTextShell::ExecInsert(SfxRequest &rReq) bool bModifier1 = rReq.GetModifier() == KEY_MOD1; if(pArgs) { + const SfxUInt16Item* pColsItem = nullptr; if(FN_INSERT_FRAME_INTERACT_NOCOL != nSlot && - pArgs->GetItemState(SID_ATTR_COLUMNS, false, &pItem) == SfxItemState::SET) - nCols = static_cast(pItem)->GetValue(); - if(pArgs->GetItemState(SID_MODIFIER, false, &pItem) == SfxItemState::SET) - bModifier1 |= KEY_MOD1 == static_cast(pItem)->GetValue(); + (pColsItem = pArgs->GetItemIfSet(SID_ATTR_COLUMNS, false))) + nCols = pColsItem->GetValue(); + if(const SfxUInt16Item* pModifierItem = pArgs->GetItemIfSet(SID_MODIFIER, false)) + bModifier1 |= KEY_MOD1 == pModifierItem->GetValue(); } if(bModifier1 ) { @@ -448,9 +449,9 @@ void SwTextShell::ExecInsert(SfxRequest &rReq) aPos = static_cast(pItem)->GetValue(); if(pArgs->GetItemState(FN_PARAM_2, false, &pItem) == SfxItemState::SET) aSize = static_cast(pItem)->GetSize(); - if(pArgs->GetItemState(SID_ATTR_COLUMNS, false, &pItem) == SfxItemState::SET) + if(const SfxUInt16Item* pColsItem = pArgs->GetItemIfSet(SID_ATTR_COLUMNS, false)) { - const sal_uInt16 nCols = static_cast(pItem)->GetValue(); + const sal_uInt16 nCols = pColsItem->GetValue(); if( !bSingleCol && 1 < nCols ) { SwFormatCol aFormatCol; @@ -637,10 +638,8 @@ void SwTextShell::StateInsert( SfxItemSet &rSet ) rSh.GetCurAttr( aSet ); SvxHyperlinkItem aHLinkItem; - const SfxPoolItem* pItem; - if(SfxItemState::SET == aSet.GetItemState(RES_TXTATR_INETFMT, false, &pItem)) + if(const SwFormatINetFormat* pINetFormat = aSet.GetItemIfSet(RES_TXTATR_INETFMT, false)) { - const SwFormatINetFormat* pINetFormat = static_cast(pItem); aHLinkItem.SetURL(pINetFormat->GetValue()); aHLinkItem.SetTargetFrame(pINetFormat->GetTargetFrame()); aHLinkItem.SetIntName(pINetFormat->GetName()); @@ -876,17 +875,15 @@ SfxItemSet SwTextShell::CreateInsertFrameItemSet(SwFlyFrameAttrMgr& rMgr) void SwTextShell::InsertSymbol( SfxRequest& rReq ) { const SfxItemSet *pArgs = rReq.GetArgs(); - const SfxPoolItem* pItem = nullptr; + const SfxStringItem* pItem = nullptr; if( pArgs ) - pArgs->GetItemState(SID_CHARMAP, false, &pItem); + pItem = pArgs->GetItemIfSet(SID_CHARMAP, false); OUString aChars, aFontName; if ( pItem ) { - aChars = static_cast(pItem)->GetValue(); - const SfxPoolItem* pFtItem = nullptr; - pArgs->GetItemState( SID_ATTR_SPECIALCHAR, false, &pFtItem); - const SfxStringItem* pFontItem = dynamic_cast( pFtItem ); + aChars = pItem->GetValue(); + const SfxStringItem* pFontItem = pArgs->GetItemIfSet( SID_ATTR_SPECIALCHAR, false ); if ( pFontItem ) aFontName = pFontItem->GetValue(); } -- cgit