sw/source/core/doc/DocumentContentOperationsManager.cxx | 25 ++++------ sw/source/core/doc/dbgoutsw.cxx | 9 +-- sw/source/core/doc/docedt.cxx | 7 -- sw/source/core/doc/docfly.cxx | 40 +++++++--------- sw/source/core/doc/docfmt.cxx | 29 +++++------ sw/source/core/doc/doclay.cxx | 12 +--- sw/source/core/doc/fmtcol.cxx | 33 ++++--------- sw/source/core/doc/gctable.cxx | 36 ++++++-------- sw/source/core/doc/notxtfrm.cxx | 7 +- sw/source/core/doc/tblafmt.cxx | 3 - sw/source/core/doc/tblcpy.cxx | 8 +-- sw/source/core/doc/tblrwcl.cxx | 8 +-- 12 files changed, 92 insertions(+), 125 deletions(-)
New commits: commit aa90836808d0a071e544554a39724fc0dfc3c846 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Wed Mar 2 13:07:53 2022 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Wed Mar 2 16:54:08 2022 +0100 use SfxItemSet::GetItemIfSet in sw/source/core/doc Change-Id: Ia56daf87140680a83d783e995ea220134a8be4c8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130838 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx b/sw/source/core/doc/DocumentContentOperationsManager.cxx index e889a6bcd419..d94632d3b92a 100644 --- a/sw/source/core/doc/DocumentContentOperationsManager.cxx +++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx @@ -1604,9 +1604,8 @@ namespace //local functions originally from docfmt.cxx if( pOtherSet && pOtherSet->Count() ) { SwTableNode* pTableNd; - const SwFormatPageDesc* pDesc; - if( SfxItemState::SET == pOtherSet->GetItemState( RES_PAGEDESC, - false, reinterpret_cast<const SfxPoolItem**>(&pDesc) )) + const SwFormatPageDesc* pDesc = pOtherSet->GetItemIfSet( RES_PAGEDESC, false ); + if( pDesc ) { if( pNode ) { @@ -1657,8 +1656,7 @@ namespace //local functions originally from docfmt.cxx const SvxFormatBreakItem* pBreak; if( pNode && !(nFlags & SetAttrMode::APICALL) && nullptr != (pTableNd = pNode->FindTableNode() ) && - SfxItemState::SET == pOtherSet->GetItemState( RES_BREAK, - false, reinterpret_cast<const SfxPoolItem**>(&pBreak) ) ) + (pBreak = pOtherSet->GetItemIfSet( RES_BREAK, false )) ) { SwTableNode* pCurTableNd = pTableNd; while ( nullptr != ( pCurTableNd = pCurTableNd->StartOfSectionNode()->FindTableNode() ) ) @@ -1686,10 +1684,9 @@ namespace //local functions originally from docfmt.cxx { // If we have a PoolNumRule, create it if needed - const SwNumRuleItem* pRule; sal_uInt16 nPoolId=0; - if( SfxItemState::SET == pOtherSet->GetItemState( RES_PARATR_NUMRULE, - false, reinterpret_cast<const SfxPoolItem**>(&pRule) ) && + const SwNumRuleItem* pRule = pOtherSet->GetItemIfSet( RES_PARATR_NUMRULE, false ); + if( pRule && !rDoc.FindNumRulePtr( pRule->GetValue() ) && USHRT_MAX != (nPoolId = SwStyleNameMapper::GetPoolIdFromUIName ( pRule->GetValue(), SwGetPoolIdFromName::NumRule )) ) @@ -3152,8 +3149,7 @@ SwDrawFrameFormat* DocumentContentOperationsManager::InsertDrawObj( { SwDrawFrameFormat* pFormat = m_rDoc.MakeDrawFrameFormat( OUString(), m_rDoc.GetDfltFrameFormat() ); - const SwFormatAnchor* pAnchor = nullptr; - rFlyAttrSet.GetItemState( RES_ANCHOR, false, reinterpret_cast<const SfxPoolItem**>(&pAnchor) ); + const SwFormatAnchor* pAnchor = rFlyAttrSet.GetItemIfSet( RES_ANCHOR, false ); pFormat->SetFormatAttr( rFlyAttrSet ); // Didn't set the Anchor yet? @@ -4739,15 +4735,14 @@ static void lcl_PushNumruleState( if (pAttrSet == nullptr) return; - const SfxPoolItem* pItem(nullptr); - if (SfxItemState::SET == pAttrSet->GetItemState(RES_PARATR_NUMRULE, false, &pItem)) + if (const SwNumRuleItem* pItem = pAttrSet->GetItemIfSet(RES_PARATR_NUMRULE, false)) { - aNumRuleItemHolderIfSet.reset(&pItem->Clone()->StaticWhichCast(RES_PARATR_NUMRULE)); + aNumRuleItemHolderIfSet.reset(pItem->Clone()); } - if (SfxItemState::SET == pAttrSet->GetItemState(RES_PARATR_LIST_ID, false, &pItem)) + if (const SfxStringItem* pItem = pAttrSet->GetItemIfSet(RES_PARATR_LIST_ID, false)) { - aListIdItemHolderIfSet.reset(&pItem->Clone()->StaticWhichCast(RES_PARATR_LIST_ID)); + aListIdItemHolderIfSet.reset(pItem->Clone()); } } diff --git a/sw/source/core/doc/dbgoutsw.cxx b/sw/source/core/doc/dbgoutsw.cxx index 0d294863dbed..dfed2005eaa9 100644 --- a/sw/source/core/doc/dbgoutsw.cxx +++ b/sw/source/core/doc/dbgoutsw.cxx @@ -524,13 +524,12 @@ static OUString lcl_dbg_out(const SwNode & rNode) aTmpStr += "</number><rule>" + pNumRule->GetName(); - const SfxPoolItem * pItem = nullptr; + const SwNumRuleItem * pItem = nullptr; - if (pAttrSet && SfxItemState::SET == - pAttrSet->GetItemState(RES_PARATR_NUMRULE, false, &pItem)) + if (pAttrSet && + (pItem = pAttrSet->GetItemIfSet(RES_PARATR_NUMRULE, false))) { - aTmpStr += "(" + - static_cast<const SwNumRuleItem *>(pItem)->GetValue() + ")*"; + aTmpStr += "(" + pItem->GetValue() + ")*"; } const SwNumFormat * pNumFormat = nullptr; diff --git a/sw/source/core/doc/docedt.cxx b/sw/source/core/doc/docedt.cxx index 57fffff87b18..a325c487702b 100644 --- a/sw/source/core/doc/docedt.cxx +++ b/sw/source/core/doc/docedt.cxx @@ -380,13 +380,10 @@ bool sw_JoinText( SwPaM& rPam, bool bJoinPrev ) pTextNd = aIdx.GetNode().GetTextNode(); if (pTextNd->HasSwAttrSet()) { - const SfxPoolItem* pItem; - if( SfxItemState::SET == pTextNd->GetpSwAttrSet()->GetItemState( - RES_BREAK, false, &pItem ) ) + if( SfxItemState::SET == pTextNd->GetpSwAttrSet()->GetItemState( RES_BREAK, false) ) pTextNd->ResetAttr( RES_BREAK ); if( pTextNd->HasSwAttrSet() && - SfxItemState::SET == pTextNd->GetpSwAttrSet()->GetItemState( - RES_PAGEDESC, false, &pItem ) ) + SfxItemState::SET == pTextNd->GetpSwAttrSet()->GetItemState( RES_PAGEDESC, false ) ) pTextNd->ResetAttr( RES_PAGEDESC ); } diff --git a/sw/source/core/doc/docfly.cxx b/sw/source/core/doc/docfly.cxx index 6b73f1f756b5..f34b78141fb1 100644 --- a/sw/source/core/doc/docfly.cxx +++ b/sw/source/core/doc/docfly.cxx @@ -327,7 +327,6 @@ sal_Int8 SwDoc::SetFlyFrameAnchor( SwFrameFormat& rFormat, SfxItemSet& rSet, boo rFormat.SetFormatAttr( aNewAnch ); // Correct the position - const SfxPoolItem* pItem; switch( nNew ) { case RndStdIds::FLY_AS_CHAR: @@ -342,7 +341,7 @@ sal_Int8 SwDoc::SetFlyFrameAnchor( SwFrameFormat& rFormat, SfxItemSet& rSet, boo pNd->InsertItem( aFormat, pPos->nContent.GetIndex(), 0 ); } - if( SfxItemState::SET != rSet.GetItemState( RES_VERT_ORIENT, false, &pItem )) + if( SfxItemState::SET != rSet.GetItemState( RES_VERT_ORIENT, false )) { SwFormatVertOrient aOldV( rFormat.GetVertOrient() ); bool bSet = true; @@ -369,31 +368,29 @@ sal_Int8 SwDoc::SetFlyFrameAnchor( SwFrameFormat& rFormat, SfxItemSet& rSet, boo // such that the fly's document coordinates are preserved. // If only the alignment changes in the position attributes (text::RelOrientation::FRAME // vs. text::RelOrientation::PRTAREA), we also correct the position. - if( SfxItemState::SET != rSet.GetItemState( RES_HORI_ORIENT, false, &pItem )) - pItem = nullptr; + const SwFormatHoriOrient* pHoriOrientItem = rSet.GetItemIfSet( RES_HORI_ORIENT, false ); SwFormatHoriOrient aOldH( rFormat.GetHoriOrient() ); bool bPutOldH(false); - if( text::HoriOrientation::NONE == aOldH.GetHoriOrient() && ( !pItem || - aOldH.GetPos() == pItem->StaticWhichCast(RES_HORI_ORIENT).GetPos() )) + if( text::HoriOrientation::NONE == aOldH.GetHoriOrient() && ( !pHoriOrientItem || + aOldH.GetPos() == pHoriOrientItem->GetPos() )) { SwTwips nPos = (RndStdIds::FLY_AS_CHAR == nOld) ? 0 : aOldH.GetPos(); nPos += aOldAnchorPos.getX() - aNewAnchorPos.getX(); - if( pItem ) + if( pHoriOrientItem ) { - SwFormatHoriOrient& rH = const_cast<SwFormatHoriOrient&>(pItem->StaticWhichCast(RES_HORI_ORIENT)); - aOldH.SetHoriOrient( rH.GetHoriOrient() ); - aOldH.SetRelationOrient( rH.GetRelationOrient() ); + aOldH.SetHoriOrient( pHoriOrientItem->GetHoriOrient() ); + aOldH.SetRelationOrient( pHoriOrientItem->GetRelationOrient() ); } aOldH.SetPos( nPos ); bPutOldH = true; } if (nNew == RndStdIds::FLY_AT_PAGE) { - sal_Int16 nRelOrient(pItem - ? pItem->StaticWhichCast(RES_HORI_ORIENT).GetRelationOrient() + sal_Int16 nRelOrient(pHoriOrientItem + ? pHoriOrientItem->GetRelationOrient() : aOldH.GetRelationOrient()); if (sw::GetAtPageRelOrientation(nRelOrient, false)) { @@ -407,20 +404,19 @@ sal_Int8 SwDoc::SetFlyFrameAnchor( SwFrameFormat& rFormat, SfxItemSet& rSet, boo rSet.Put( aOldH ); } - if( SfxItemState::SET != rSet.GetItemState( RES_VERT_ORIENT, false, &pItem )) - pItem = nullptr; + const SwFormatVertOrient* pVertOrientItem = rSet.GetItemIfSet( RES_VERT_ORIENT, false ); SwFormatVertOrient aOldV( rFormat.GetVertOrient() ); // #i28922# - correction: compare <aOldV.GetVertOrient() with // <text::VertOrientation::NONE> - if( text::VertOrientation::NONE == aOldV.GetVertOrient() && (!pItem || - aOldV.GetPos() == pItem->StaticWhichCast(RES_VERT_ORIENT).GetPos() ) ) + if( text::VertOrientation::NONE == aOldV.GetVertOrient() && (!pVertOrientItem || + aOldV.GetPos() == pVertOrientItem->GetPos() ) ) { SwTwips nPos = (RndStdIds::FLY_AS_CHAR == nOld) ? 0 : aOldV.GetPos(); nPos += aOldAnchorPos.getY() - aNewAnchorPos.getY(); - if( pItem ) + if( pVertOrientItem ) { - SwFormatVertOrient& rV = const_cast<SwFormatVertOrient&>(pItem->StaticWhichCast(RES_VERT_ORIENT)); + SwFormatVertOrient& rV = const_cast<SwFormatVertOrient&>(*pVertOrientItem); aOldV.SetVertOrient( rV.GetVertOrient() ); aOldV.SetRelationOrient( rV.GetRelationOrient() ); } @@ -650,7 +646,6 @@ bool SwDoc::SetFrameFormatToFly( SwFrameFormat& rFormat, SwFrameFormat& rNewForm // Set the column first, or we'll have trouble with //Set/Reset/Synch. and so on - const SfxPoolItem* pItem; if( SfxItemState::SET != rNewFormat.GetAttrSet().GetItemState( RES_COL )) rFormat.ResetFormatAttr( RES_COL ); @@ -668,8 +663,9 @@ bool SwDoc::SetFrameFormatToFly( SwFrameFormat& rFormat, SwFrameFormat& rNewForm const SfxItemSet* pAsk = pSet; if( !pAsk ) pAsk = &rNewFormat.GetAttrSet(); - if( SfxItemState::SET == pAsk->GetItemState( RES_ANCHOR, false, &pItem ) - && pItem->StaticWhichCast(RES_ANCHOR).GetAnchorId() != + const SwFormatAnchor* pFormatAnchor = pAsk->GetItemIfSet( RES_ANCHOR, false ); + if( pFormatAnchor + && pFormatAnchor->GetAnchorId() != rFormat.GetAnchor().GetAnchorId() ) { if( pSet ) @@ -680,7 +676,7 @@ bool SwDoc::SetFrameFormatToFly( SwFrameFormat& rFormat, SwFrameFormat& rNewForm // in SetFlyFrameAnchor. SfxItemSet aFlySet( *rNewFormat.GetAttrSet().GetPool(), rNewFormat.GetAttrSet().GetRanges() ); - aFlySet.Put( *pItem ); + aFlySet.Put( *pFormatAnchor ); bChgAnchor = MAKEFRMS == SetFlyFrameAnchor( rFormat, aFlySet, false); } } diff --git a/sw/source/core/doc/docfmt.cxx b/sw/source/core/doc/docfmt.cxx index 42dfd707c556..257e5707cff4 100644 --- a/sw/source/core/doc/docfmt.cxx +++ b/sw/source/core/doc/docfmt.cxx @@ -616,16 +616,14 @@ void SwDoc::SetDefault( const SfxItemSet& rSet ) GetIDocumentUndoRedo().AppendUndo( std::make_unique<SwUndoDefaultAttr>( aOld, *this ) ); } - const SfxPoolItem* pTmpItem; - if( ( SfxItemState::SET == - aNew.GetItemState( RES_PARATR_TABSTOP, false, &pTmpItem ) ) && - pTmpItem->StaticWhichCast(RES_PARATR_TABSTOP).Count() ) + const SvxTabStopItem* pTmpItem = aNew.GetItemIfSet( RES_PARATR_TABSTOP, false ); + if( pTmpItem && pTmpItem->Count() ) { // Set the default values of all TabStops to the new value. // Attention: we always work with the PoolAttribute here, so that // we don't calculate the same value on the same TabStop (pooled!) for all sets. // We send a FormatChg to modify. - SwTwips nNewWidth = pTmpItem->StaticWhichCast(RES_PARATR_TABSTOP)[ 0 ].GetTabPos(), + SwTwips nNewWidth = (*pTmpItem)[ 0 ].GetTabPos(), nOldWidth = aOld.Get(RES_PARATR_TABSTOP)[ 0 ].GetTabPos(); bool bChg = false; @@ -1219,11 +1217,11 @@ SwTextFormatColl* SwDoc::CopyTextColl( const SwTextFormatColl& rColl ) // create the NumRule if necessary if( this != rColl.GetDoc() ) { - const SfxPoolItem* pItem; - if( SfxItemState::SET == pNewColl->GetItemState( RES_PARATR_NUMRULE, - false, &pItem )) + const SwNumRuleItem* pItem = pNewColl->GetItemIfSet( RES_PARATR_NUMRULE, + false ); + if( pItem ) { - const OUString& rName = pItem->StaticWhichCast(RES_PARATR_NUMRULE).GetValue(); + const OUString& rName = pItem->GetValue(); if( !rName.isEmpty() ) { const SwNumRule* pRule = rColl.GetDoc()->FindNumRulePtr( rName ); @@ -1304,12 +1302,12 @@ void SwDoc::CopyFormatArr( const SwFormatsBase& rSourceArr, pDest->DelDiffs( *pSrc ); // #i94285#: existing <SwFormatPageDesc> instance, before copying attributes - const SfxPoolItem* pItem; + const SwFormatPageDesc* pItem; if( &GetAttrPool() != pSrc->GetAttrSet().GetPool() - && SfxItemState::SET == pSrc->GetAttrSet().GetItemState( RES_PAGEDESC, false, &pItem ) - && pItem->StaticWhichCast(RES_PAGEDESC).GetPageDesc() ) + && (pItem = pSrc->GetAttrSet().GetItemIfSet( RES_PAGEDESC, false )) + && pItem->GetPageDesc() ) { - SwFormatPageDesc aPageDesc( pItem->StaticWhichCast(RES_PAGEDESC) ); + SwFormatPageDesc aPageDesc( *pItem ); const OUString& rNm = aPageDesc.GetPageDesc()->GetName(); SwPageDesc* pPageDesc = FindPageDesc( rNm ); if( !pPageDesc ) @@ -1392,10 +1390,9 @@ void SwDoc::CopyPageDescHeaderFooterImpl( bool bCpyHeader, GetDfltFrameFormat() ); pNewFormat->CopyAttrs( *pOldFormat ); - if( SfxItemState::SET == pNewFormat->GetAttrSet().GetItemState( - RES_CNTNT, false, &pItem )) + if( const SwFormatContent* pContent = pNewFormat->GetAttrSet().GetItemIfSet( + RES_CNTNT, false ) ) { - const SwFormatContent* pContent = &pItem->StaticWhichCast(RES_CNTNT); if( pContent->GetContentIdx() ) { SwNodeIndex aTmpIdx( GetNodes().GetEndOfAutotext() ); diff --git a/sw/source/core/doc/doclay.cxx b/sw/source/core/doc/doclay.cxx index 34bf4fabbcac..128c2dcd925e 100644 --- a/sw/source/core/doc/doclay.cxx +++ b/sw/source/core/doc/doclay.cxx @@ -182,8 +182,7 @@ SwFlyFrameFormat* SwDoc::MakeFlySection_( const SwPosition& rAnchPos, const SwFormatAnchor* pAnchor = nullptr; if( pFlySet ) { - pFlySet->GetItemState( RES_ANCHOR, false, - reinterpret_cast<const SfxPoolItem**>(&pAnchor) ); + pAnchor = pFlySet->GetItemIfSet( RES_ANCHOR, false ); if( SfxItemState::SET == pFlySet->GetItemState( RES_CNTNT, false )) { SfxItemSet aTmpSet( *pFlySet ); @@ -295,10 +294,8 @@ SwFlyFrameFormat* SwDoc::MakeFlySection( RndStdIds eAnchorType, if ( !pAnchorPos && (RndStdIds::FLY_AT_PAGE != eAnchorType) ) { const SwFormatAnchor* pAnch; - if( (pFlySet && SfxItemState::SET == pFlySet->GetItemState( - RES_ANCHOR, false, reinterpret_cast<const SfxPoolItem**>(&pAnch) )) || - ( pFrameFormat && SfxItemState::SET == pFrameFormat->GetItemState( - RES_ANCHOR, true, reinterpret_cast<const SfxPoolItem**>(&pAnch) )) ) + if( (pFlySet && (pAnch = pFlySet->GetItemIfSet( RES_ANCHOR, false ))) || + ( pFrameFormat && (pAnch = pFrameFormat->GetItemIfSet(RES_ANCHOR)) ) ) { if ( RndStdIds::FLY_AT_PAGE != pAnch->GetAnchorId() ) { @@ -329,8 +326,7 @@ SwFlyFrameFormat* SwDoc::MakeFlySection( RndStdIds eAnchorType, const SfxPoolItem * pItem = nullptr; if (bCalledFromShell && !lcl_IsItemSet(*pNewTextNd, RES_PARATR_ADJUST) && - SfxItemState::SET == pAnchorNode->GetSwAttrSet(). - GetItemState(RES_PARATR_ADJUST, true, &pItem)) + SfxItemState::SET == pAnchorNode->GetSwAttrSet().GetItemState(RES_PARATR_ADJUST, true, &pItem)) { pNewTextNd->SetAttr(*pItem); } diff --git a/sw/source/core/doc/fmtcol.cxx b/sw/source/core/doc/fmtcol.cxx index e35e523b6a92..9cc951b52a0c 100644 --- a/sw/source/core/doc/fmtcol.cxx +++ b/sw/source/core/doc/fmtcol.cxx @@ -59,7 +59,7 @@ namespace TextFormatCollFunc if (!pNewNumRuleItem) { - (void)pTextFormatColl->GetItemState(RES_PARATR_NUMRULE, false, reinterpret_cast<const SfxPoolItem**>(&pNewNumRuleItem)); + pNewNumRuleItem = pTextFormatColl->GetItemIfSet(RES_PARATR_NUMRULE, false); } if (pNewNumRuleItem) { @@ -77,8 +77,7 @@ namespace TextFormatCollFunc { SwNumRule* pNumRule( nullptr ); - const SwNumRuleItem* pNumRuleItem(nullptr); - (void)rTextFormatColl.GetItemState(RES_PARATR_NUMRULE, false, reinterpret_cast<const SfxPoolItem**>(&pNumRuleItem)); + const SwNumRuleItem* pNumRuleItem = rTextFormatColl.GetItemIfSet(RES_PARATR_NUMRULE, false); if (pNumRuleItem) { const OUString& sNumRuleName = pNumRuleItem->GetValue(); @@ -142,23 +141,17 @@ void SwTextFormatColl::SwClientNotify(const SwModify& rModify, const SfxHint& rH // Only recalculate if we're not the sender! pNewChgSet = &pNew->StaticWhichCast(RES_ATTRSET_CHG); pOldChgSet = &pOld->StaticWhichCast(RES_ATTRSET_CHG); - pNewChgSet->GetChgSet()->GetItemState( - RES_LR_SPACE, false, reinterpret_cast<const SfxPoolItem**>(&pNewLRSpace) ); - pNewChgSet->GetChgSet()->GetItemState( - RES_UL_SPACE, false, reinterpret_cast<const SfxPoolItem**>(&pNewULSpace) ); - pNewChgSet->GetChgSet()->GetItemState( RES_CHRATR_FONTSIZE, - false, reinterpret_cast<const SfxPoolItem**>(&(aFontSizeArr[0])) ); - pNewChgSet->GetChgSet()->GetItemState( RES_CHRATR_CJK_FONTSIZE, - false, reinterpret_cast<const SfxPoolItem**>(&(aFontSizeArr[1])) ); - pNewChgSet->GetChgSet()->GetItemState( RES_CHRATR_CTL_FONTSIZE, - false, reinterpret_cast<const SfxPoolItem**>(&(aFontSizeArr[2])) ); + pNewLRSpace = pNewChgSet->GetChgSet()->GetItemIfSet( RES_LR_SPACE, false ); + pNewULSpace = pNewChgSet->GetChgSet()->GetItemIfSet( RES_UL_SPACE, false ); + aFontSizeArr[0] = pNewChgSet->GetChgSet()->GetItemIfSet( RES_CHRATR_FONTSIZE, false ); + aFontSizeArr[1] = pNewChgSet->GetChgSet()->GetItemIfSet( RES_CHRATR_CJK_FONTSIZE, false ); + aFontSizeArr[2] = pNewChgSet->GetChgSet()->GetItemIfSet( RES_CHRATR_CTL_FONTSIZE, false ); // #i70223#, #i84745# // check, if attribute set is applied to this paragraph style if ( bAssignedToListLevelOfOutlineStyle && pNewChgSet->GetTheChgdSet() == &GetAttrSet() ) { - pNewChgSet->GetChgSet()->GetItemState( RES_PARATR_NUMRULE, false, - reinterpret_cast<const SfxPoolItem**>(&pNewNumRuleItem) ); + pNewNumRuleItem = pNewChgSet->GetChgSet()->GetItemIfSet( RES_PARATR_NUMRULE, false ); } break; @@ -213,8 +206,7 @@ void SwTextFormatColl::SwClientNotify(const SwModify& rModify, const SfxHint& rH bool bContinue = true; // Check against the own attributes - if( pNewLRSpace && SfxItemState::SET == GetItemState( RES_LR_SPACE, false, - reinterpret_cast<const SfxPoolItem**>(&pOldLRSpace) )) + if( pNewLRSpace && (pOldLRSpace = GetItemIfSet( RES_LR_SPACE, false)) ) { if( pOldLRSpace != pNewLRSpace ) // Avoid recursion (SetAttr!) { @@ -254,8 +246,7 @@ void SwTextFormatColl::SwClientNotify(const SwModify& rModify, const SfxHint& rH } } - if( pNewULSpace && SfxItemState::SET == GetItemState( - RES_UL_SPACE, false, reinterpret_cast<const SfxPoolItem**>(&pOldULSpace) ) && + if( pNewULSpace && (pOldULSpace = GetItemIfSet(RES_UL_SPACE, false)) && pOldULSpace != pNewULSpace ) // Avoid recursion (SetAttr!) { SvxULSpaceItem aNew( *pOldULSpace ); @@ -288,8 +279,8 @@ void SwTextFormatColl::SwClientNotify(const SwModify& rModify, const SfxHint& rH for( int nC = 0; nC < int(SAL_N_ELEMENTS(aFontSizeArr)); ++nC ) { const SvxFontHeightItem *pFSize = aFontSizeArr[ nC ], *pOldFSize; - if( pFSize && SfxItemState::SET == GetItemState( - pFSize->Which(), false, reinterpret_cast<const SfxPoolItem**>(&pOldFSize) ) && + if( pFSize && (SfxItemState::SET == GetItemState( + pFSize->Which(), false, reinterpret_cast<const SfxPoolItem**>(&pOldFSize) )) && // Avoid recursion (SetAttr!) pFSize != pOldFSize ) { diff --git a/sw/source/core/doc/gctable.cxx b/sw/source/core/doc/gctable.cxx index 7f428dee033c..30937cadd541 100644 --- a/sw/source/core/doc/gctable.cxx +++ b/sw/source/core/doc/gctable.cxx @@ -33,10 +33,9 @@ static const SvxBorderLine* GetLineTB( const SvxBoxItem* pBox, bool bTop ) bool SwGCBorder_BoxBrd::CheckLeftBorderOfFormat( const SwFrameFormat& rFormat ) { - const SfxPoolItem* pItem; - if( SfxItemState::SET == rFormat.GetItemState( RES_BOX, true, &pItem ) ) + if( const SvxBoxItem* pItem = rFormat.GetItemIfSet( RES_BOX ) ) { - const SvxBorderLine* pBrd = static_cast<const SvxBoxItem*>(pItem)->GetLeft(); + const SvxBorderLine* pBrd = pItem->GetLeft(); if( pBrd ) { if( *m_pBorderLine == *pBrd ) @@ -100,13 +99,13 @@ static sal_uInt16 lcl_FindEndPosOfBorder( const SwCollectTableLineBoxes& rCollTL sal_uInt16 nPos, nLastPos = 0; for( size_t nEnd = rCollTLB.Count(); rStt < nEnd; ++rStt ) { - const SfxPoolItem* pItem; const SvxBorderLine* pBrd; const SwTableBox& rBox = rCollTLB.GetBox( rStt, &nPos ); + const SvxBoxItem* pItem = rBox.GetFrameFormat()->GetItemIfSet(RES_BOX); - if( SfxItemState::SET != rBox.GetFrameFormat()->GetItemState(RES_BOX,true, &pItem ) ) + if( !pItem ) break; - pBrd = GetLineTB( static_cast<const SvxBoxItem*>(pItem), bTop ); + pBrd = GetLineTB( pItem, bTop ); if( !pBrd || *pBrd != rBrdLn ) break; nLastPos = nPos; @@ -116,17 +115,18 @@ static sal_uInt16 lcl_FindEndPosOfBorder( const SwCollectTableLineBoxes& rCollTL static const SvxBorderLine* lcl_GCBorder_GetBorder( const SwTableBox& rBox, bool bTop, - const SfxPoolItem** ppItem ) + const SvxBoxItem** ppItem ) { - return SfxItemState::SET == rBox.GetFrameFormat()->GetItemState( RES_BOX, true, ppItem ) - ? GetLineTB( static_cast<const SvxBoxItem*>(*ppItem), bTop ) - : nullptr; + *ppItem = rBox.GetFrameFormat()->GetItemIfSet( RES_BOX ); + if (*ppItem) + return GetLineTB( *ppItem, bTop ); + return nullptr; } static void lcl_GCBorder_DelBorder( const SwCollectTableLineBoxes& rCollTLB, size_t& rStt, bool bTop, const SvxBorderLine& rLine, - const SfxPoolItem* pItem, + const SvxBoxItem* pItem, sal_uInt16 nEndPos, SwShareBoxFormats* pShareFormats ) { @@ -137,7 +137,7 @@ static void lcl_GCBorder_DelBorder( const SwCollectTableLineBoxes& rCollTLB, do { if( pLn && *pLn == rLine ) { - SvxBoxItem aBox( *static_cast<const SvxBoxItem*>(pItem) ); + SvxBoxItem aBox( *pItem ); if( bTop ) aBox.SetLine( nullptr, SvxBoxItemLine::TOP ); else @@ -169,7 +169,6 @@ void sw_GC_Line_Border( const SwTableLine* pLine, SwGCLineBorder* pGCPara ) { SwGCBorder_BoxBrd aBPara; const SvxBorderLine* pBrd; - const SfxPoolItem* pItem; const SwTableBoxes& rBoxes = pLine->GetTabBoxes(); for( SwTableBoxes::size_type n = 0, nBoxes = rBoxes.size() - 1; n < nBoxes; ++n ) { @@ -185,9 +184,9 @@ void sw_GC_Line_Border( const SwTableLine* pLine, SwGCLineBorder* pGCPara ) for( SwTableBoxes::size_type i = aBoxes.size(); i; ) { SwTableBox* pBox = aBoxes[ --i ]; - if( SfxItemState::SET == pBox->GetFrameFormat()->GetItemState( RES_BOX, true, &pItem ) ) + if( const SvxBoxItem* pItem = pBox->GetFrameFormat()->GetItemIfSet( RES_BOX ) ) { - pBrd = static_cast<const SvxBoxItem*>(pItem)->GetRight(); + pBrd = pItem->GetRight(); if( pBrd ) { aBPara.SetBorder( *pBrd ); @@ -195,7 +194,7 @@ void sw_GC_Line_Border( const SwTableLine* pLine, SwGCLineBorder* pGCPara ) if( lcl_GCBorder_ChkBoxBrd_B( pNextBox, &aBPara ) && aBPara.IsAnyBorderFound() ) { - SvxBoxItem aBox( *static_cast<const SvxBoxItem*>(pItem) ); + SvxBoxItem aBox( *pItem ); aBox.SetLine( nullptr, SvxBoxItemLine::RIGHT ); if( pGCPara->pShareFormats ) pGCPara->pShareFormats->SetAttr( *pBox, aBox ); @@ -231,7 +230,7 @@ void sw_GC_Line_Border( const SwTableLine* pLine, SwGCLineBorder* pGCPara ) const SwTableBox *pBtmBox = &aBottom.GetBox( nSttBtm++, &nBtmPos ); const SwTableBox *pTopBox = &aTop.GetBox( nSttTop++, &nTopPos ); - const SfxPoolItem *pBtmItem = nullptr, *pTopItem = nullptr; + const SvxBoxItem *pBtmItem = nullptr, *pTopItem = nullptr; const SvxBorderLine *pBtmLine(nullptr), *pTopLine(nullptr); bool bGetTopItem = true, bGetBtmItem = true; @@ -366,8 +365,7 @@ static bool lcl_MergeGCBox(SwTableBox* pTableBox, GCLinePara* pPara) { for (auto pBox : pCpyLine->GetTabBoxes()) { - SfxPoolItem const* pCellBrush(nullptr); - if (pBox->GetFrameFormat()->GetItemState(RES_BACKGROUND, true, &pCellBrush) != SfxItemState::SET) + if (pBox->GetFrameFormat()->GetItemState(RES_BACKGROUND) != SfxItemState::SET) { // set inner row background on inner cell pBox->ClaimFrameFormat(); pBox->GetFrameFormat()->SetFormatAttr(*pRowBrush); diff --git a/sw/source/core/doc/notxtfrm.cxx b/sw/source/core/doc/notxtfrm.cxx index 390aa6ecdbda..96ed231f8ab7 100644 --- a/sw/source/core/doc/notxtfrm.cxx +++ b/sw/source/core/doc/notxtfrm.cxx @@ -281,11 +281,10 @@ void SwNoTextFrame::PaintSwFrame(vcl::RenderContext& rRenderContext, SwRect cons { const SwFlyFreeFrame *pFly = static_cast< const SwFlyFreeFrame* >( pFindFly ); bool bGetUnclippedFrame=true; - const SfxPoolItem* pItem; - if( pFly->GetFormat() && SfxItemState::SET == pFly->GetFormat()->GetItemState(RES_BOX, false, &pItem) ) + const SvxBoxItem* pBoxItem; + if( pFly->GetFormat() && (pBoxItem = pFly->GetFormat()->GetItemIfSet(RES_BOX, false)) ) { - const SvxBoxItem& rBox = *static_cast<const SvxBoxItem*>(pItem); - if( rBox.HasBorder( /*bTreatPaddingAsBorder*/true) ) + if( pBoxItem->HasBorder( /*bTreatPaddingAsBorder*/true) ) bGetUnclippedFrame = false; } diff --git a/sw/source/core/doc/tblafmt.cxx b/sw/source/core/doc/tblafmt.cxx index d6807fb416dd..4504af19bdb7 100644 --- a/sw/source/core/doc/tblafmt.cxx +++ b/sw/source/core/doc/tblafmt.cxx @@ -532,8 +532,7 @@ void SwTableAutoFormat::UpdateFromSet( sal_uInt8 nPos, const SwTableBoxNumFormat* pNumFormatItem; const SvNumberformat* pNumFormat = nullptr; - if( SfxItemState::SET == rSet.GetItemState( RES_BOXATR_FORMAT, true, - reinterpret_cast<const SfxPoolItem**>(&pNumFormatItem) ) && pNFormatr && + if( pNFormatr && (pNumFormatItem = rSet.GetItemIfSet( RES_BOXATR_FORMAT )) && nullptr != (pNumFormat = pNFormatr->GetEntry( pNumFormatItem->GetValue() )) ) pFormat->SetValueFormat( pNumFormat->GetFormatstring(), pNumFormat->GetLanguage(), diff --git a/sw/source/core/doc/tblcpy.cxx b/sw/source/core/doc/tblcpy.cxx index 52d3348f2408..b685c265ddd5 100644 --- a/sw/source/core/doc/tblcpy.cxx +++ b/sw/source/core/doc/tblcpy.cxx @@ -623,12 +623,12 @@ static void lcl_CpyBox( const SwTable& rCpyTable, const SwTableBox* pCpyBox, if( !aBoxAttrSet.Count() ) return; - const SfxPoolItem* pItem; + const SwTableBoxNumFormat* pItem; SvNumberFormatter* pN = pDoc->GetNumberFormatter( false ); - if( pN && pN->HasMergeFormatTable() && SfxItemState::SET == aBoxAttrSet. - GetItemState( RES_BOXATR_FORMAT, false, &pItem ) ) + if( pN && pN->HasMergeFormatTable() && + (pItem = aBoxAttrSet.GetItemIfSet( RES_BOXATR_FORMAT, false )) ) { - sal_uLong nOldIdx = static_cast<const SwTableBoxNumFormat*>(pItem)->GetValue(); + sal_uLong nOldIdx = pItem->GetValue(); sal_uLong nNewIdx = pN->GetMergeFormatIndex( nOldIdx ); if( nNewIdx != nOldIdx ) aBoxAttrSet.Put( SwTableBoxNumFormat( nNewIdx )); diff --git a/sw/source/core/doc/tblrwcl.cxx b/sw/source/core/doc/tblrwcl.cxx index 8a825ff1f285..d92d7726f7b8 100644 --- a/sw/source/core/doc/tblrwcl.cxx +++ b/sw/source/core/doc/tblrwcl.cxx @@ -1908,12 +1908,12 @@ static void lcl_CopyBoxToDoc(FndBox_ const& rFndBox, CpyPara *const pCpyPara) aBoxAttrSet.Put(rFndBox.GetBox()->GetFrameFormat()->GetAttrSet()); if( aBoxAttrSet.Count() ) { - const SfxPoolItem* pItem; + const SwTableBoxNumFormat* pItem; SvNumberFormatter* pN = pCpyPara->rDoc.GetNumberFormatter( false ); - if( pN && pN->HasMergeFormatTable() && SfxItemState::SET == aBoxAttrSet. - GetItemState( RES_BOXATR_FORMAT, false, &pItem ) ) + if( pN && pN->HasMergeFormatTable() && (pItem = aBoxAttrSet. + GetItemIfSet( RES_BOXATR_FORMAT, false )) ) { - sal_uLong nOldIdx = static_cast<const SwTableBoxNumFormat*>(pItem)->GetValue(); + sal_uLong nOldIdx = pItem->GetValue(); sal_uLong nNewIdx = pN->GetMergeFormatIndex( nOldIdx ); if( nNewIdx != nOldIdx ) aBoxAttrSet.Put( SwTableBoxNumFormat( nNewIdx ));