diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-03-03 09:56:09 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-03-03 19:19:39 +0100 |
commit | 0a1031a9ecd1502b1841bde26dde7ad51358c638 (patch) | |
tree | 564e854741e6307d5be08afcad395bca5ce30c16 /sw/source/uibase/shells/textsh.cxx | |
parent | c1ac79906bde5c902be5cb0ae6b530da96e52169 (diff) |
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 <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw/source/uibase/shells/textsh.cxx')
-rw-r--r-- | sw/source/uibase/shells/textsh.cxx | 27 |
1 files changed, 12 insertions, 15 deletions
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<const SfxUInt16Item *>(pItem)->GetValue(); - if(pArgs->GetItemState(SID_MODIFIER, false, &pItem) == SfxItemState::SET) - bModifier1 |= KEY_MOD1 == static_cast<const SfxUInt16Item *>(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<const SfxPointItem *>(pItem)->GetValue(); if(pArgs->GetItemState(FN_PARAM_2, false, &pItem) == SfxItemState::SET) aSize = static_cast<const SvxSizeItem *>(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<const SfxUInt16Item *>(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<const SwFormatINetFormat*>(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<const SfxStringItem*>(pItem)->GetValue(); - const SfxPoolItem* pFtItem = nullptr; - pArgs->GetItemState( SID_ATTR_SPECIALCHAR, false, &pFtItem); - const SfxStringItem* pFontItem = dynamic_cast<const SfxStringItem*>( pFtItem ); + aChars = pItem->GetValue(); + const SfxStringItem* pFontItem = pArgs->GetItemIfSet( SID_ATTR_SPECIALCHAR, false ); if ( pFontItem ) aFontName = pFontItem->GetValue(); } |