summaryrefslogtreecommitdiff
path: root/sw/source/ui/frmdlg
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2022-01-25 10:44:57 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-03-11 19:26:45 +0100
commit7b634028cec2df4136017be483ebc3c32bc8d9ec (patch)
tree6749050a173cbd9c464c98b9f241fb2b0689a4b9 /sw/source/ui/frmdlg
parent0234ddcac3acfd00f3a0a7ff89d943cd0b36e34c (diff)
use more SfxItemSet::GetItemIfSet
Change-Id: I58af59d82d92c89ca1939d35f9fb4121b6815559 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131336 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw/source/ui/frmdlg')
-rw-r--r--sw/source/ui/frmdlg/column.cxx5
-rw-r--r--sw/source/ui/frmdlg/frmpage.cxx46
2 files changed, 22 insertions, 29 deletions
diff --git a/sw/source/ui/frmdlg/column.cxx b/sw/source/ui/frmdlg/column.cxx
index f12ae77f4180..e03eb2945999 100644
--- a/sw/source/ui/frmdlg/column.cxx
+++ b/sw/source/ui/frmdlg/column.cxx
@@ -562,9 +562,8 @@ void SwColumnPage::Reset(const SfxItemSet *rSet)
}
if (m_xBalanceColsCB->get_visible())
{
- const SfxPoolItem* pItem;
- if( SfxItemState::SET == rSet->GetItemState( RES_COLUMNBALANCE, false, &pItem ))
- m_xBalanceColsCB->set_active(!static_cast<const SwFormatNoBalancedColumns*>(pItem)->GetValue());
+ if( const SwFormatNoBalancedColumns* pItem = rSet->GetItemIfSet( RES_COLUMNBALANCE, false ) )
+ m_xBalanceColsCB->set_active(!pItem->GetValue());
else
m_xBalanceColsCB->set_active(true);
}
diff --git a/sw/source/ui/frmdlg/frmpage.cxx b/sw/source/ui/frmdlg/frmpage.cxx
index 66837f87fe43..a48a939dfbeb 100644
--- a/sw/source/ui/frmdlg/frmpage.cxx
+++ b/sw/source/ui/frmdlg/frmpage.cxx
@@ -870,13 +870,12 @@ void SwFramePage::Reset( const SfxItemSet *rSet )
::SetFieldUnit(*m_xAtHorzPosED, aMetric);
::SetFieldUnit(*m_xAtVertPosED, aMetric);
- const SfxPoolItem* pItem = nullptr;
const SwFormatAnchor& rAnchor = rSet->Get(RES_ANCHOR);
- if (SfxItemState::SET == rSet->GetItemState(FN_OLE_IS_MATH, false, &pItem))
- m_bIsMathOLE = static_cast<const SfxBoolItem*>(pItem)->GetValue();
- if (SfxItemState::SET == rSet->GetItemState(FN_MATH_BASELINE_ALIGNMENT, false, &pItem))
- m_bIsMathBaselineAlignment = static_cast<const SfxBoolItem*>(pItem)->GetValue();
+ if (const SfxBoolItem* pMathItem = rSet->GetItemIfSet(FN_OLE_IS_MATH, false))
+ m_bIsMathOLE = pMathItem->GetValue();
+ if (const SfxBoolItem* pAlignItem = rSet->GetItemIfSet(FN_MATH_BASELINE_ALIGNMENT, false))
+ m_bIsMathBaselineAlignment = pAlignItem->GetValue();
EnableVerticalPositioning( !(m_bIsMathOLE && m_bIsMathBaselineAlignment
&& RndStdIds::FLY_AS_CHAR == rAnchor.GetAnchorId()) );
@@ -2341,21 +2340,20 @@ std::unique_ptr<SfxTabPage> SwGrfExtPage::Create(weld::Container* pPage, weld::D
void SwGrfExtPage::Reset(const SfxItemSet *rSet)
{
- const SfxPoolItem* pItem;
const sal_uInt16 nHtmlMode = ::GetHtmlMode(static_cast<const SwDocShell*>(SfxObjectShell::Current()));
m_bHtmlMode = (nHtmlMode & HTMLMODE_ON) != 0;
- if( SfxItemState::SET == rSet->GetItemState( FN_PARAM_GRF_CONNECT, true, &pItem)
- && static_cast<const SfxBoolItem *>(pItem)->GetValue() )
+ const SfxBoolItem* pConnectItem = rSet->GetItemIfSet( FN_PARAM_GRF_CONNECT );
+ if( pConnectItem && pConnectItem->GetValue() )
{
m_xBrowseBT->set_sensitive(true);
m_xConnectED->set_editable(true);
}
// RotGrfFlyFrame: Get RotationAngle and set at control
- if(SfxItemState::SET == rSet->GetItemState( SID_ATTR_TRANSFORM_ANGLE, false, &pItem))
+ if(const SdrAngleItem* pAngleItem = rSet->GetItemIfSet( SID_ATTR_TRANSFORM_ANGLE, false))
{
- m_xCtlAngle->SetRotation(static_cast<const SdrAngleItem*>(pItem)->GetValue());
+ m_xCtlAngle->SetRotation(pAngleItem->GetValue());
}
else
{
@@ -2419,12 +2417,11 @@ void SwGrfExtPage::ActivatePage(const SfxItemSet& rSet)
}
}
- if( SfxItemState::SET == rSet.GetItemState( SID_ATTR_GRAF_GRAPHIC, false, &pItem ) )
+ if( const SvxBrushItem* pGraphicBrushItem = rSet.GetItemIfSet( SID_ATTR_GRAF_GRAPHIC, false ) )
{
- const SvxBrushItem& rBrush = *static_cast<const SvxBrushItem*>(pItem);
- if( !rBrush.GetGraphicLink().isEmpty() )
+ if( !pGraphicBrushItem->GetGraphicLink().isEmpty() )
{
- aGrfName = aNewGrfName = rBrush.GetGraphicLink();
+ aGrfName = aNewGrfName = pGraphicBrushItem->GetGraphicLink();
m_xConnectED->set_text(aNewGrfName);
}
OUString referer;
@@ -2433,7 +2430,7 @@ void SwGrfExtPage::ActivatePage(const SfxItemSet& rSet)
if (it != nullptr) {
referer = it->GetValue();
}
- const Graphic* pGrf = rBrush.GetGraphic(referer);
+ const Graphic* pGrf = pGraphicBrushItem->GetGraphic(referer);
if( pGrf )
{
m_aBmpWin.SetGraphic( *pGrf );
@@ -2691,8 +2688,7 @@ SwFrameURLPage::~SwFrameURLPage()
void SwFrameURLPage::Reset( const SfxItemSet *rSet )
{
- const SfxPoolItem* pItem;
- if ( SfxItemState::SET == rSet->GetItemState( SID_DOCFRAME, true, &pItem))
+ if ( SfxItemState::SET == rSet->GetItemState( SID_DOCFRAME ))
{
TargetList aList;
SfxFrame::GetDefaultTargetList(aList);
@@ -2703,9 +2699,8 @@ void SwFrameURLPage::Reset( const SfxItemSet *rSet )
}
}
- if ( SfxItemState::SET == rSet->GetItemState( RES_URL, true, &pItem ) )
+ if ( const SwFormatURL* pFormatURL = rSet->GetItemIfSet( RES_URL ) )
{
- const SwFormatURL* pFormatURL = static_cast<const SwFormatURL*>(pItem);
m_xURLED->set_text(INetURLObject::decode(pFormatURL->GetURL(),
INetURLObject::DecodeMechanism::Unambiguous));
m_xNameED->set_text(pFormatURL->GetName());
@@ -2836,7 +2831,6 @@ std::unique_ptr<SfxTabPage> SwFrameAddPage::Create(weld::Container* pPage, weld:
void SwFrameAddPage::Reset(const SfxItemSet *rSet )
{
- const SfxPoolItem* pItem;
sal_uInt16 nHtmlMode = ::GetHtmlMode(static_cast<const SwDocShell*>(SfxObjectShell::Current()));
m_bHtmlMode = (nHtmlMode & HTMLMODE_ON) != 0;
if (m_bHtmlMode)
@@ -2855,15 +2849,15 @@ void SwFrameAddPage::Reset(const SfxItemSet *rSet )
m_xContentAlignFrame->hide();
}
- if(SfxItemState::SET == rSet->GetItemState(FN_SET_FRM_ALT_NAME, false, &pItem))
+ if(const SfxStringItem* pNameItem = rSet->GetItemIfSet(FN_SET_FRM_ALT_NAME, false))
{
- m_xAltNameED->set_text(static_cast<const SfxStringItem*>(pItem)->GetValue());
+ m_xAltNameED->set_text(pNameItem->GetValue());
m_xAltNameED->save_value();
}
- if(SfxItemState::SET == rSet->GetItemState(FN_UNO_DESCRIPTION, false, &pItem))
+ if(const SfxStringItem* pDescriptionItem = rSet->GetItemIfSet(FN_UNO_DESCRIPTION, false))
{
- m_xDescriptionED->set_text(static_cast<const SfxStringItem*>(pItem)->GetValue());
+ m_xDescriptionED->set_text(pDescriptionItem->GetValue());
m_xDescriptionED->save_value();
}
@@ -2872,9 +2866,9 @@ void SwFrameAddPage::Reset(const SfxItemSet *rSet )
// insert graphic - properties
// bNew is not set, so recognise by selection
OUString aTmpName1;
- if(SfxItemState::SET == rSet->GetItemState(FN_SET_FRM_NAME, false, &pItem))
+ if(const SfxStringItem* pNameItem = rSet->GetItemIfSet(FN_SET_FRM_NAME, false))
{
- aTmpName1 = static_cast<const SfxStringItem*>(pItem)->GetValue();
+ aTmpName1 = pNameItem->GetValue();
}
OSL_ENSURE(m_pWrtSh, "no Shell?");