summaryrefslogtreecommitdiff
path: root/svx/source/dialog
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2022-03-01 08:55:54 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-03-01 09:54:18 +0100
commit535359269ed23e2faead8e9e905d57cc6121e269 (patch)
treeae4834fdb175b1764ff656687f0276ed347d3bac /svx/source/dialog
parentca3e12d5b560d27615aeac986f9dbc1258993e65 (diff)
use SfxItemSet::GetItemIfSet in svx
Change-Id: I7a56c9452102cf7f6524296219209aef05383d81 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130736 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svx/source/dialog')
-rw-r--r--svx/source/dialog/dlgutil.cxx12
-rw-r--r--svx/source/dialog/hdft.cxx6
-rw-r--r--svx/source/dialog/optgrid.cxx17
3 files changed, 14 insertions, 21 deletions
diff --git a/svx/source/dialog/dlgutil.cxx b/svx/source/dialog/dlgutil.cxx
index 3d40889a839f..a33e1ca9476c 100644
--- a/svx/source/dialog/dlgutil.cxx
+++ b/svx/source/dialog/dlgutil.cxx
@@ -30,9 +30,8 @@
FieldUnit GetModuleFieldUnit( const SfxItemSet& rSet )
{
- if (const SfxPoolItem* pItem = nullptr;
- SfxItemState::SET == rSet.GetItemState(SID_ATTR_METRIC, false, &pItem))
- return static_cast<FieldUnit>(static_cast<const SfxUInt16Item*>(pItem)->GetValue());
+ if (const SfxUInt16Item* pItem = rSet.GetItemIfSet(SID_ATTR_METRIC, false))
+ return static_cast<FieldUnit>(pItem->GetValue());
return SfxModule::GetCurrentFieldUnit();
}
@@ -40,9 +39,8 @@ FieldUnit GetModuleFieldUnit( const SfxItemSet& rSet )
bool GetApplyCharUnit( const SfxItemSet& rSet )
{
bool bUseCharUnit = false;
- const SfxPoolItem* pItem = nullptr;
- if ( SfxItemState::SET == rSet.GetItemState( SID_ATTR_APPLYCHARUNIT, false, &pItem ) )
- bUseCharUnit = static_cast<const SfxBoolItem*>(pItem)->GetValue();
+ if ( const SfxBoolItem* pItem = rSet.GetItemIfSet( SID_ATTR_APPLYCHARUNIT, false ) )
+ bUseCharUnit = pItem->GetValue();
else
{
// FIXME - this might be wrong, cf. the DEV300 changes in GetModuleFieldUnit()
@@ -57,7 +55,7 @@ bool GetApplyCharUnit( const SfxItemSet& rSet )
{
pItem = pModule->GetItem( SID_ATTR_APPLYCHARUNIT );
if ( pItem )
- bUseCharUnit = static_cast<const SfxBoolItem*>(pItem)->GetValue();
+ bUseCharUnit = pItem->GetValue();
}
else
{
diff --git a/svx/source/dialog/hdft.cxx b/svx/source/dialog/hdft.cxx
index f3bb4eccfd38..9f0985ad1057 100644
--- a/svx/source/dialog/hdft.cxx
+++ b/svx/source/dialog/hdft.cxx
@@ -416,13 +416,13 @@ void SvxHFPage::Reset( const SfxItemSet* rSet )
m_xCntSharedBox->save_state();
RangeHdl();
- const SfxPoolItem* pItem = nullptr;
SfxObjectShell* pShell;
- if(SfxItemState::SET == rSet->GetItemState(SID_HTML_MODE, false, &pItem) ||
+ const SfxUInt16Item* pItem = rSet->GetItemIfSet(SID_HTML_MODE, false);
+ if(pItem ||
( nullptr != (pShell = SfxObjectShell::Current()) &&
nullptr != (pItem = pShell->GetItem(SID_HTML_MODE))))
{
- sal_uInt16 nHtmlMode = static_cast<const SfxUInt16Item*>(pItem)->GetValue();
+ sal_uInt16 nHtmlMode = pItem->GetValue();
if (nHtmlMode & HTMLMODE_ON)
{
m_xCntSharedBox->hide();
diff --git a/svx/source/dialog/optgrid.cxx b/svx/source/dialog/optgrid.cxx
index 06cedb798ca4..3cd12b48d1ae 100644
--- a/svx/source/dialog/optgrid.cxx
+++ b/svx/source/dialog/optgrid.cxx
@@ -175,12 +175,10 @@ bool SvxGridTabPage::FillItemSet( SfxItemSet* rCoreSet )
void SvxGridTabPage::Reset( const SfxItemSet* rSet )
{
- const SfxPoolItem* pAttr = nullptr;
+ const SvxGridItem* pGridAttr = nullptr;
- if( SfxItemState::SET == rSet->GetItemState( SID_ATTR_GRID_OPTIONS , false,
- &pAttr ))
+ if( (pGridAttr = rSet->GetItemIfSet( SID_ATTR_GRID_OPTIONS , false )) )
{
- const SvxGridItem* pGridAttr = static_cast<const SvxGridItem*>(pAttr);
m_xCbxUseGridsnap->set_active(pGridAttr->bUseGridsnap);
m_xCbxSynchronize->set_active(pGridAttr->bSynchronize);
m_xCbxGridVisible->set_active(pGridAttr->bGridVisible);
@@ -199,11 +197,9 @@ void SvxGridTabPage::Reset( const SfxItemSet* rSet )
void SvxGridTabPage::ActivatePage( const SfxItemSet& rSet )
{
- const SfxPoolItem* pAttr = nullptr;
- if( SfxItemState::SET == rSet.GetItemState( SID_ATTR_GRID_OPTIONS , false,
- &pAttr ))
+ const SvxGridItem* pGridAttr = nullptr;
+ if( (pGridAttr = rSet.GetItemIfSet( SID_ATTR_GRID_OPTIONS , false )) )
{
- const SvxGridItem* pGridAttr = static_cast<const SvxGridItem*>(pAttr);
m_xCbxUseGridsnap->set_active(pGridAttr->bUseGridsnap);
ChangeGridsnapHdl_Impl(*m_xCbxUseGridsnap);
@@ -211,11 +207,10 @@ void SvxGridTabPage::ActivatePage( const SfxItemSet& rSet )
// Metric Change if necessary (as TabPage is in the dialog, where the
// metric can be set
- if( SfxItemState::SET != rSet.GetItemState( SID_ATTR_METRIC , false,
- &pAttr ))
+ const SfxUInt16Item* pItem = rSet.GetItemIfSet( SID_ATTR_METRIC , false );
+ if( !pItem )
return;
- const SfxUInt16Item* pItem = static_cast<const SfxUInt16Item*>(pAttr);
FieldUnit eFUnit = static_cast<FieldUnit>(static_cast<tools::Long>(pItem->GetValue()));