summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2022-03-02 17:56:27 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-03-03 08:53:07 +0100
commitc35a59ae2e26ee30b036d3946a9be26e981838b7 (patch)
treed725c5f49d5bf02aaf741b9702187aca3fc7ddfe /sw
parent9a44807ff3a11afa8f7ce9857ae6a6144a61d481 (diff)
use SfxItemSet::GetItemIfSet in sw/source/core/firlds
Change-Id: I25d46d8435b8a95ac8809b9f67a6c3a9b14dd26e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130878 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw')
-rw-r--r--sw/source/core/draw/dcontact.cxx4
-rw-r--r--sw/source/core/edit/autofmt.cxx27
-rw-r--r--sw/source/core/edit/edfcol.cxx12
-rw-r--r--sw/source/core/edit/edfmt.cxx8
-rw-r--r--sw/source/core/edit/edtab.cxx7
-rw-r--r--sw/source/core/fields/cellfml.cxx15
-rw-r--r--sw/source/core/frmedt/fefly1.cxx26
-rw-r--r--sw/source/core/frmedt/tblsel.cxx9
8 files changed, 47 insertions, 61 deletions
diff --git a/sw/source/core/draw/dcontact.cxx b/sw/source/core/draw/dcontact.cxx
index 7040a741076c..f698309e4775 100644
--- a/sw/source/core/draw/dcontact.cxx
+++ b/sw/source/core/draw/dcontact.cxx
@@ -1404,8 +1404,8 @@ namespace
const SwFormatAnchor* pAnchorFormat = nullptr;
if ( RES_ATTRSET_CHG == nWhich )
{
- static_cast<const SwAttrSetChg&>(_rItem).GetChgSet()->
- GetItemState( RES_ANCHOR, false, reinterpret_cast<const SfxPoolItem**>(&pAnchorFormat) );
+ pAnchorFormat = static_cast<const SwAttrSetChg&>(_rItem).GetChgSet()->
+ GetItemIfSet( RES_ANCHOR, false );
}
else if ( RES_ANCHOR == nWhich )
{
diff --git a/sw/source/core/edit/autofmt.cxx b/sw/source/core/edit/autofmt.cxx
index 6df314ae55c2..60c14ad81d17 100644
--- a/sw/source/core/edit/autofmt.cxx
+++ b/sw/source/core/edit/autofmt.cxx
@@ -1012,9 +1012,7 @@ void SwAutoFormat::SetColl( sal_uInt16 nId, bool bHdLineOrText )
{
aSet.Put(*m_aDelPam.GetPoint()->nNode.GetNode().GetTextNode()->GetpSwAttrSet());
// take HeaderLine/TextBody only if centered or right aligned, otherwise only justification
- SvxAdjustItem const * pAdj;
- if( SfxItemState::SET == aSet.GetItemState( RES_PARATR_ADJUST,
- false, reinterpret_cast<const SfxPoolItem**>(&pAdj) ))
+ if( SvxAdjustItem const * pAdj = aSet.GetItemIfSet( RES_PARATR_ADJUST, false) )
{
SvxAdjust eAdj = pAdj->GetAdjust();
if( bHdLineOrText ? (SvxAdjust::Right != eAdj &&
@@ -1053,14 +1051,13 @@ bool SwAutoFormat::HasBreakAttr(const SwTextFrame& rTextFrame)
if( !pSet )
return false;
- const SfxPoolItem* pItem;
- if( SfxItemState::SET == pSet->GetItemState( RES_BREAK, false, &pItem )
- && SvxBreak::NONE != static_cast<const SvxFormatBreakItem*>(pItem)->GetBreak() )
+ const SvxFormatBreakItem* pBreakItem = pSet->GetItemIfSet( RES_BREAK, false );
+ if( pBreakItem && SvxBreak::NONE != pBreakItem->GetBreak() )
return true;
- if( SfxItemState::SET == pSet->GetItemState( RES_PAGEDESC, false, &pItem )
- && static_cast<const SwFormatPageDesc*>(pItem)->GetPageDesc()
- && UseOnPage::NONE != static_cast<const SwFormatPageDesc*>(pItem)->GetPageDesc()->GetUseOn() )
+ const SwFormatPageDesc* pItem = pSet->GetItemIfSet( RES_PAGEDESC, false );
+ if( pItem && pItem->GetPageDesc()
+ && UseOnPage::NONE != pItem->GetPageDesc()->GetUseOn() )
return true;
return false;
}
@@ -2427,10 +2424,9 @@ SwAutoFormat::SwAutoFormat( SwEditShell* pEdShell, SvxSwAutoFormatFlags const &
RES_POOLCOLL_STANDARD == nPoolId )
{
short nSz;
- SvxLRSpaceItem const * pLRSpace;
- if (SfxItemState::SET == m_pCurTextFrame->GetTextNodeForParaProps()->GetSwAttrSet().
- GetItemState( RES_LR_SPACE, true,
- reinterpret_cast<const SfxPoolItem**>(&pLRSpace) ) &&
+ SvxLRSpaceItem const * pLRSpace = m_pCurTextFrame->GetTextNodeForParaProps()->GetSwAttrSet().
+ GetItemIfSet( RES_LR_SPACE );
+ if (pLRSpace &&
( 0 != (nSz = pLRSpace->GetTextFirstLineOffset()) ||
0 != pLRSpace->GetTextLeft() ) )
{
@@ -2663,9 +2659,8 @@ SwAutoFormat::SwAutoFormat( SwEditShell* pEdShell, SvxSwAutoFormatFlags const &
short nSz;
SvxLRSpaceItem const * pLRSpace;
if( bReplaceStyles &&
- SfxItemState::SET == m_pCurTextFrame->GetTextNodeForParaProps()->GetSwAttrSet().
- GetItemState( RES_LR_SPACE, false,
- reinterpret_cast<const SfxPoolItem**>(&pLRSpace) ) &&
+ (pLRSpace = m_pCurTextFrame->GetTextNodeForParaProps()->GetSwAttrSet().
+ GetItemIfSet( RES_LR_SPACE, false )) &&
( 0 != (nSz = pLRSpace->GetTextFirstLineOffset()) ||
0 != pLRSpace->GetTextLeft() ) )
{
diff --git a/sw/source/core/edit/edfcol.cxx b/sw/source/core/edit/edfcol.cxx
index f42df251b21c..61cfd7d9a923 100644
--- a/sw/source/core/edit/edfcol.cxx
+++ b/sw/source/core/edit/edfcol.cxx
@@ -2309,13 +2309,12 @@ void SwEditShell::FillByEx(SwTextFormatColl* pColl)
// Bug 57568
// Do NOT copy AutoNumRules into the template
- const SfxPoolItem* pItem;
+ const SwNumRuleItem* pItem;
const SwNumRule* pRule = nullptr;
if (SfxItemState::SET == pSet->GetItemState(RES_BREAK, false)
|| SfxItemState::SET == pSet->GetItemState(RES_PAGEDESC, false)
- || (SfxItemState::SET == pSet->GetItemState(RES_PARATR_NUMRULE, false, &pItem)
- && nullptr != (pRule = GetDoc()->FindNumRulePtr(
- static_cast<const SwNumRuleItem*>(pItem)->GetValue()))
+ || ((pItem = pSet->GetItemIfSet(RES_PARATR_NUMRULE, false))
+ && nullptr != (pRule = GetDoc()->FindNumRulePtr(pItem->GetValue()))
&& pRule->IsAutoRule()))
{
SfxItemSet aSet( *pSet );
@@ -2323,9 +2322,8 @@ void SwEditShell::FillByEx(SwTextFormatColl* pColl)
aSet.ClearItem( RES_PAGEDESC );
if (pRule
- || (SfxItemState::SET == pSet->GetItemState(RES_PARATR_NUMRULE, false, &pItem)
- && nullptr != (pRule = GetDoc()->FindNumRulePtr(
- static_cast<const SwNumRuleItem*>(pItem)->GetValue()))
+ || ((pItem = pSet->GetItemIfSet(RES_PARATR_NUMRULE, false))
+ && nullptr != (pRule = GetDoc()->FindNumRulePtr(pItem->GetValue()))
&& pRule->IsAutoRule()))
aSet.ClearItem( RES_PARATR_NUMRULE );
diff --git a/sw/source/core/edit/edfmt.cxx b/sw/source/core/edit/edfmt.cxx
index ea9bd667110f..f43fa05cd670 100644
--- a/sw/source/core/edit/edfmt.cxx
+++ b/sw/source/core/edit/edfmt.cxx
@@ -41,10 +41,10 @@ SwCharFormat* SwEditShell::GetCurCharFormat() const
{
SwCharFormat *pFormat = nullptr;
SfxItemSetFixed<RES_TXTATR_CHARFMT, RES_TXTATR_CHARFMT> aSet( GetDoc()->GetAttrPool() );
- const SfxPoolItem* pItem;
- if( GetCurAttr( aSet ) && SfxItemState::SET ==
- aSet.GetItemState( RES_TXTATR_CHARFMT, false, &pItem ) )
- pFormat = static_cast<const SwFormatCharFormat*>(pItem)->GetCharFormat();
+ const SwFormatCharFormat* pItem;
+ if( GetCurAttr( aSet ) &&
+ (pItem = aSet.GetItemIfSet( RES_TXTATR_CHARFMT, false ) ) )
+ pFormat = pItem->GetCharFormat();
return pFormat;
}
diff --git a/sw/source/core/edit/edtab.cxx b/sw/source/core/edit/edtab.cxx
index 3ac95530292f..30cb3b412063 100644
--- a/sw/source/core/edit/edtab.cxx
+++ b/sw/source/core/edit/edtab.cxx
@@ -396,11 +396,10 @@ bool SwEditShell::IsTableBoxTextFormat() const
return false;
sal_uInt32 nFormat = 0;
- const SfxPoolItem* pItem;
- if( SfxItemState::SET == pBox->GetFrameFormat()->GetAttrSet().GetItemState(
- RES_BOXATR_FORMAT, true, &pItem ))
+ if( const SwTableBoxNumFormat* pItem = pBox->GetFrameFormat()->GetAttrSet().GetItemIfSet(
+ RES_BOXATR_FORMAT ))
{
- nFormat = static_cast<const SwTableBoxNumFormat*>(pItem)->GetValue();
+ nFormat = pItem->GetValue();
return GetDoc()->GetNumberFormatter()->IsTextFormat( nFormat );
}
diff --git a/sw/source/core/fields/cellfml.cxx b/sw/source/core/fields/cellfml.cxx
index f74b80401596..5c9632a7fb96 100644
--- a/sw/source/core/fields/cellfml.cxx
+++ b/sw/source/core/fields/cellfml.cxx
@@ -109,17 +109,16 @@ double SwTableBox::GetValue( SwTableCalcPara& rCalcPara ) const
// will be removed from stack at the end.
SwDoc* pDoc = GetFrameFormat()->GetDoc();
- const SfxPoolItem* pItem;
- if( SfxItemState::SET == GetFrameFormat()->GetItemState(
- RES_BOXATR_FORMULA, false, &pItem ) )
+ if( const SwTableBoxFormula* pFormulaItem = GetFrameFormat()->GetItemIfSet(
+ RES_BOXATR_FORMULA, false ) )
{
rCalcPara.m_rCalc.SetCalcError( SwCalcError::NONE ); // reset status
- if( !static_cast<const SwTableBoxFormula*>(pItem)->IsValid() )
+ if( !pFormulaItem->IsValid() )
{
// calculate
const SwTable* pTmp = rCalcPara.m_pTable;
rCalcPara.m_pTable = &pBox->GetSttNd()->FindTableNode()->GetTable();
- const_cast<SwTableBoxFormula*>(static_cast<const SwTableBoxFormula*>(pItem))->Calc( rCalcPara, nRet );
+ const_cast<SwTableBoxFormula*>(pFormulaItem)->Calc( rCalcPara, nRet );
if( !rCalcPara.IsStackOverflow() )
{
@@ -136,11 +135,11 @@ double SwTableBox::GetValue( SwTableCalcPara& rCalcPara ) const
nRet = GetFrameFormat()->GetTableBoxValue().GetValue();
break;
}
- else if( SfxItemState::SET == pBox->GetFrameFormat()->GetItemState(
- RES_BOXATR_VALUE, false, &pItem ) )
+ else if( const SwTableBoxValue* pBoxValueItem = pBox->GetFrameFormat()->GetItemIfSet(
+ RES_BOXATR_VALUE, false ) )
{
rCalcPara.m_rCalc.SetCalcError( SwCalcError::NONE ); // reset status
- nRet = static_cast<const SwTableBoxValue*>(pItem)->GetValue();
+ nRet = pBoxValueItem->GetValue();
break;
}
diff --git a/sw/source/core/frmedt/fefly1.cxx b/sw/source/core/frmedt/fefly1.cxx
index e5d66afd9f73..b6d7016dd8bc 100644
--- a/sw/source/core/frmedt/fefly1.cxx
+++ b/sw/source/core/frmedt/fefly1.cxx
@@ -741,19 +741,20 @@ const SwFrameFormat *SwFEShell::NewFlyFrame( const SfxItemSet& rSet, bool bAnchV
pOldAnchor.reset(new SwFormatAnchor( rAnch ));
const_cast<SfxItemSet&>(rSet).Put( SwFormatAnchor( RndStdIds::FLY_AT_PAGE, 1 ) );
- const SfxPoolItem* pItem;
- if( SfxItemState::SET == rSet.GetItemState( RES_HORI_ORIENT, false, &pItem )
- && text::HoriOrientation::NONE == static_cast<const SwFormatHoriOrient*>(pItem)->GetHoriOrient() )
+ const SwFormatHoriOrient* pHoriOrientItem;
+ if( (pHoriOrientItem = rSet.GetItemIfSet( RES_HORI_ORIENT, false ))
+ && text::HoriOrientation::NONE == pHoriOrientItem->GetHoriOrient() )
{
bHOriChgd = true;
- aOldH.reset(static_cast<SwFormatHoriOrient*>(pItem->Clone()));
+ aOldH.reset(pHoriOrientItem->Clone());
const_cast<SfxItemSet&>(rSet).Put( SwFormatHoriOrient( 0, text::HoriOrientation::LEFT ) );
}
- if( SfxItemState::SET == rSet.GetItemState( RES_VERT_ORIENT, false, &pItem )
- && text::VertOrientation::NONE == static_cast<const SwFormatVertOrient*>(pItem)->GetVertOrient() )
+ const SwFormatVertOrient* pVertOrientItem;
+ if( (pVertOrientItem = rSet.GetItemIfSet( RES_VERT_ORIENT, false ))
+ && text::VertOrientation::NONE == pVertOrientItem->GetVertOrient() )
{
bVOriChgd = true;
- aOldV.reset(static_cast<SwFormatVertOrient*>(pItem->Clone()));
+ aOldV.reset(pVertOrientItem->Clone());
const_cast<SfxItemSet&>(rSet).Put( SwFormatVertOrient( 0, text::VertOrientation::TOP ) );
}
}
@@ -850,11 +851,9 @@ void SwFEShell::Insert( const OUString& rGrfName, const OUString& rFltName,
// Has the anchor not been set or been set incompletely?
if( pFlyAttrSet )
{
- const SfxPoolItem* pItem;
- if( SfxItemState::SET == pFlyAttrSet->GetItemState( RES_ANCHOR, false,
- &pItem ) )
+ if( const SwFormatAnchor* pItem = pFlyAttrSet->GetItemIfSet( RES_ANCHOR, false ) )
{
- SwFormatAnchor* pAnchor = const_cast<SwFormatAnchor*>(static_cast<const SwFormatAnchor*>(pItem));
+ SwFormatAnchor* pAnchor = const_cast<SwFormatAnchor*>(pItem);
switch( pAnchor->GetAnchorId())
{
case RndStdIds::FLY_AT_PARA:
@@ -1075,10 +1074,9 @@ bool SwFEShell::GetFlyFrameAttr( SfxItemSet &rSet ) const
// now examine all attributes. Remove forbidden attributes, then
// get all remaining attributes and enter them
- const SfxPoolItem* pItem;
- if( SfxItemState::SET == rSet.GetItemState( RES_ANCHOR, false, &pItem ) )
+
+ if( const SwFormatAnchor* pAnchor = rSet.GetItemIfSet( RES_ANCHOR, false ) )
{
- const SwFormatAnchor* pAnchor = static_cast<const SwFormatAnchor*>(pItem);
RndStdIds eType = pAnchor->GetAnchorId();
if ( RndStdIds::FLY_AT_PAGE != eType )
diff --git a/sw/source/core/frmedt/tblsel.cxx b/sw/source/core/frmedt/tblsel.cxx
index 80b797384859..984b59186109 100644
--- a/sw/source/core/frmedt/tblsel.cxx
+++ b/sw/source/core/frmedt/tblsel.cxx
@@ -1054,16 +1054,13 @@ void GetMergeSel( const SwPaM& rPam, SwSelBoxes& rBoxes,
aNew.SetWidth( nLeft );
pBox->GetFrameFormat()->SetFormatAttr( aNew );
+ if( const SvxBoxItem* pItem = pBox->GetFrameFormat()->GetAttrSet()
+ .GetItemIfSet( RES_BOX, false ))
{
- const SfxPoolItem* pItem;
- if( SfxItemState::SET == pBox->GetFrameFormat()->GetAttrSet()
- .GetItemState( RES_BOX, false, &pItem ))
- {
- SvxBoxItem aBox( *static_cast<const SvxBoxItem*>(pItem) );
+ SvxBoxItem aBox( *pItem );
aBox.SetLine( nullptr, SvxBoxItemLine::RIGHT );
pBox->GetFrameFormat()->SetFormatAttr( aBox );
}
- }
pBox = pBox->GetUpper()->GetTabBoxes()[ nInsPos ];
aNew.SetWidth( nWidth );