summaryrefslogtreecommitdiff
path: root/sc/source/ui
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2022-03-01 11:08:05 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-03-01 19:17:09 +0100
commite50f13c9947332639f455739c87213a954067299 (patch)
tree85d98a501258a9734c550f997f833c3c353ceee9 /sc/source/ui
parent05db887bc226b85befe2c2b9e84b796020a6ca05 (diff)
use SfxItemSet::GetItemIfSet in sc/source/ui/
Change-Id: Ia360a0bbc57f2d50dc26ae670d6e953d3f2d8a8e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130745 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sc/source/ui')
-rw-r--r--sc/source/ui/app/inputhdl.cxx9
-rw-r--r--sc/source/ui/app/scmod.cxx99
-rw-r--r--sc/source/ui/dbgui/tpsort.cxx22
-rw-r--r--sc/source/ui/dbgui/tpsubt.cxx26
-rw-r--r--sc/source/ui/dbgui/validate.cxx60
-rw-r--r--sc/source/ui/docshell/docfunc.cxx7
-rw-r--r--sc/source/ui/docshell/docsh.cxx72
-rw-r--r--sc/source/ui/docshell/docsh4.cxx34
-rw-r--r--sc/source/ui/docshell/docsh6.cxx9
-rw-r--r--sc/source/ui/docshell/externalrefmgr.cxx6
-rw-r--r--sc/source/ui/docshell/tablink.cxx6
-rw-r--r--sc/source/ui/drawfunc/drawsh.cxx27
-rw-r--r--sc/source/ui/drawfunc/drtxtob.cxx8
-rw-r--r--sc/source/ui/drawfunc/fuins1.cxx11
-rw-r--r--sc/source/ui/inc/scuitphfedit.hxx4
-rw-r--r--sc/source/ui/inc/tpsort.hxx5
-rw-r--r--sc/source/ui/inc/tpsubt.hxx5
-rw-r--r--sc/source/ui/optdlg/tpcompatibility.cxx4
-rw-r--r--sc/source/ui/optdlg/tpdefaults.cxx5
-rw-r--r--sc/source/ui/optdlg/tpformula.cxx6
-rw-r--r--sc/source/ui/optdlg/tpprint.cxx9
-rw-r--r--sc/source/ui/optdlg/tpview.cxx68
-rw-r--r--sc/source/ui/pagedlg/scuitphfedit.cxx14
-rw-r--r--sc/source/ui/vba/vbaapplication.cxx5
24 files changed, 233 insertions, 288 deletions
diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx
index 9bcc6bbe71be..4d5d1a1d8ac2 100644
--- a/sc/source/ui/app/inputhdl.cxx
+++ b/sc/source/ui/app/inputhdl.cxx
@@ -2472,11 +2472,10 @@ bool ScInputHandler::StartTable( sal_Unicode cTyped, bool bFromCommand, bool bIn
{
// Percent format?
const SfxItemSet& rAttrSet = pPattern->GetItemSet();
- const SfxPoolItem* pItem;
- if ( SfxItemState::SET == rAttrSet.GetItemState( ATTR_VALUE_FORMAT, true, &pItem ) )
+ if ( const SfxUInt32Item* pItem = rAttrSet.GetItemIfSet( ATTR_VALUE_FORMAT ) )
{
- sal_uInt32 nFormat = static_cast<const SfxUInt32Item*>(pItem)->GetValue();
+ sal_uInt32 nFormat = pItem->GetValue();
if (SvNumFormatType::PERCENT == rDoc.GetFormatTable()->GetType( nFormat ))
nCellPercentFormatDecSep = rDoc.GetFormatTable()->GetFormatDecimalSep( nFormat).toChar();
else
@@ -2486,8 +2485,8 @@ bool ScInputHandler::StartTable( sal_Unicode cTyped, bool bFromCommand, bool bIn
nCellPercentFormatDecSep = 0; // Default: no percent
// Validity specified?
- if ( SfxItemState::SET == rAttrSet.GetItemState( ATTR_VALIDDATA, true, &pItem ) )
- nValidation = static_cast<const SfxUInt32Item*>(pItem)->GetValue();
+ if ( const SfxUInt32Item* pItem = rAttrSet.GetItemIfSet( ATTR_VALIDDATA ) )
+ nValidation = pItem->GetValue();
else
nValidation = 0;
diff --git a/sc/source/ui/app/scmod.cxx b/sc/source/ui/app/scmod.cxx
index b48f81192ac7..c4c0584eb6a9 100644
--- a/sc/source/ui/app/scmod.cxx
+++ b/sc/source/ui/app/scmod.cxx
@@ -336,7 +336,7 @@ void ScModule::Execute( SfxRequest& rReq )
{
bool bSet;
const SfxPoolItem* pItem;
- if (pReqArgs && pReqArgs->HasItem(FN_PARAM_1, &pItem))
+ if (pReqArgs && SfxItemState::SET == pReqArgs->GetItemState( FN_PARAM_1, true, &pItem ))
bSet = static_cast<const SfxBoolItem*>(pItem)->GetValue();
else if ( pReqArgs && SfxItemState::SET == pReqArgs->GetItemState( nSlot, true, &pItem ) )
bSet = static_cast<const SfxBoolItem*>(pItem)->GetValue();
@@ -934,7 +934,6 @@ void ScModule::ModifyOptions( const SfxItemSet& rOptSet )
ScTabViewShell* pViewSh = dynamic_cast<ScTabViewShell*>( SfxViewShell::Current() );
ScDocShell* pDocSh = dynamic_cast<ScDocShell*>( SfxObjectShell::Current() );
ScDocument* pDoc = pDocSh ? &pDocSh->GetDocument() : nullptr;
- const SfxPoolItem* pItem = nullptr;
bool bRepaint = false;
bool bUpdateMarks = false;
bool bUpdateRefDev = false;
@@ -948,28 +947,28 @@ void ScModule::ModifyOptions( const SfxItemSet& rOptSet )
ScAppOptions aAppOptions = m_pAppCfg->GetOptions();
// No more linguistics
- if (rOptSet.HasItem(SID_ATTR_METRIC, &pItem))
+ if (const SfxUInt16Item* pItem = rOptSet.GetItemIfSet(SID_ATTR_METRIC))
{
PutItem( *pItem );
- aAppOptions.SetAppMetric( static_cast<FieldUnit>(static_cast<const SfxUInt16Item*>(pItem)->GetValue()) );
+ aAppOptions.SetAppMetric( static_cast<FieldUnit>(pItem->GetValue()) );
bSaveAppOptions = true;
}
- if (rOptSet.HasItem(SCITEM_USERLIST, &pItem))
+ if (const ScUserListItem* pItem = rOptSet.GetItemIfSet(SCITEM_USERLIST))
{
- ScGlobal::SetUserList( static_cast<const ScUserListItem*>(pItem)->GetUserList() );
+ ScGlobal::SetUserList( pItem->GetUserList() );
bSaveAppOptions = true;
}
- if (rOptSet.HasItem(SID_SC_OPT_SYNCZOOM, &pItem))
+ if (const SfxBoolItem* pItem = rOptSet.GetItemIfSet(SID_SC_OPT_SYNCZOOM))
{
- aAppOptions.SetSynchronizeZoom( static_cast<const SfxBoolItem*>(pItem)->GetValue() );
+ aAppOptions.SetSynchronizeZoom( pItem->GetValue() );
bSaveAppOptions = true;
}
- if (rOptSet.HasItem(SID_SC_OPT_KEY_BINDING_COMPAT, &pItem))
+ if (const SfxUInt16Item* pItem = rOptSet.GetItemIfSet(SID_SC_OPT_KEY_BINDING_COMPAT))
{
- sal_uInt16 nVal = static_cast<const SfxUInt16Item*>(pItem)->GetValue();
+ sal_uInt16 nVal = pItem->GetValue();
ScOptionsUtil::KeyBindingType eOld = aAppOptions.GetKeyBindingType();
ScOptionsUtil::KeyBindingType eNew = static_cast<ScOptionsUtil::KeyBindingType>(nVal);
if (eOld != eNew)
@@ -981,16 +980,16 @@ void ScModule::ModifyOptions( const SfxItemSet& rOptSet )
}
// DefaultsOptions
- if (rOptSet.HasItem(SID_SCDEFAULTSOPTIONS, &pItem))
+ if (const ScTpDefaultsItem* pItem = rOptSet.GetItemIfSet(SID_SCDEFAULTSOPTIONS))
{
- const ScDefaultsOptions& rOpt = static_cast<const ScTpDefaultsItem*>(pItem)->GetDefaultsOptions();
+ const ScDefaultsOptions& rOpt = pItem->GetDefaultsOptions();
SetDefaultsOptions( rOpt );
}
// FormulaOptions
- if (rOptSet.HasItem(SID_SCFORMULAOPTIONS, &pItem))
+ if (const ScTpFormulaItem* pItem = rOptSet.GetItemIfSet(SID_SCFORMULAOPTIONS))
{
- const ScFormulaOptions& rOpt = static_cast<const ScTpFormulaItem*>(pItem)->GetFormulaOptions();
+ const ScFormulaOptions& rOpt = pItem->GetFormulaOptions();
if (!m_pFormulaCfg || (*m_pFormulaCfg != rOpt))
// Formula options have changed. Repaint the column headers.
@@ -1031,9 +1030,9 @@ void ScModule::ModifyOptions( const SfxItemSet& rOptSet )
}
// ViewOptions
- if (rOptSet.HasItem(SID_SCVIEWOPTIONS, &pItem))
+ if (const ScTpViewItem* pItem = rOptSet.GetItemIfSet(SID_SCVIEWOPTIONS))
{
- const ScViewOptions& rNewOpt = static_cast<const ScTpViewItem*>(pItem)->GetViewOptions();
+ const ScViewOptions& rNewOpt = pItem->GetViewOptions();
if ( pViewSh )
{
@@ -1063,9 +1062,9 @@ void ScModule::ModifyOptions( const SfxItemSet& rOptSet )
// GridOptions
// Evaluate after ViewOptions, as GridOptions is a member of ViewOptions
- if ( rOptSet.HasItem(SID_ATTR_GRID_OPTIONS,&pItem) )
+ if ( const SvxGridItem* pItem = rOptSet.GetItemIfSet(SID_ATTR_GRID_OPTIONS) )
{
- ScGridOptions aNewGridOpt( static_cast<const SvxGridItem&>(*pItem ));
+ ScGridOptions aNewGridOpt( *pItem );
if ( pViewSh )
{
@@ -1094,9 +1093,9 @@ void ScModule::ModifyOptions( const SfxItemSet& rOptSet )
}
// DocOptions
- if ( rOptSet.HasItem(SID_SCDOCOPTIONS,&pItem) )
+ if ( const ScTpCalcItem* pItem = rOptSet.GetItemIfSet(SID_SCDOCOPTIONS) )
{
- const ScDocOptions& rNewOpt = static_cast<const ScTpCalcItem*>(pItem)->GetDocOptions();
+ const ScDocOptions& rNewOpt = pItem->GetDocOptions();
if ( pDoc )
{
@@ -1123,9 +1122,9 @@ void ScModule::ModifyOptions( const SfxItemSet& rOptSet )
}
// Set TabDistance after the actual DocOptions
- if ( rOptSet.HasItem(SID_ATTR_DEFTABSTOP,&pItem) )
+ if ( const SfxUInt16Item* pItem = rOptSet.GetItemIfSet(SID_ATTR_DEFTABSTOP) )
{
- sal_uInt16 nTabDist = static_cast<const SfxUInt16Item*>(pItem)->GetValue();
+ sal_uInt16 nTabDist = pItem->GetValue();
ScDocOptions aOpt(GetDocOptions());
aOpt.SetTabDistance(nTabDist);
SetDocOptions( aOpt );
@@ -1142,9 +1141,9 @@ void ScModule::ModifyOptions( const SfxItemSet& rOptSet )
}
// AutoSpell after the DocOptions (due to being a member)
- if ( rOptSet.HasItem(SID_AUTOSPELL_CHECK,&pItem) ) // At DocOptions
+ if ( const SfxBoolItem* pItem = rOptSet.GetItemIfSet(SID_AUTOSPELL_CHECK) ) // At DocOptions
{
- bool bDoAutoSpell = static_cast<const SfxBoolItem*>(pItem)->GetValue();
+ bool bDoAutoSpell = pItem->GetValue();
if (pDoc)
{
@@ -1178,51 +1177,51 @@ void ScModule::ModifyOptions( const SfxItemSet& rOptSet )
// InputOptions
ScInputOptions aInputOptions = m_pInputCfg->GetOptions();
- if ( rOptSet.HasItem(SID_SC_INPUT_SELECTIONPOS,&pItem) )
+ if ( const SfxUInt16Item* pItem = rOptSet.GetItemIfSet(SID_SC_INPUT_SELECTIONPOS) )
{
- aInputOptions.SetMoveDir( static_cast<const SfxUInt16Item*>(pItem)->GetValue() );
+ aInputOptions.SetMoveDir( pItem->GetValue() );
bSaveInputOptions = true;
}
- if ( rOptSet.HasItem(SID_SC_INPUT_SELECTION,&pItem) )
+ if ( const SfxBoolItem* pItem = rOptSet.GetItemIfSet(SID_SC_INPUT_SELECTION) )
{
- aInputOptions.SetMoveSelection( static_cast<const SfxBoolItem*>(pItem)->GetValue() );
+ aInputOptions.SetMoveSelection( pItem->GetValue() );
bSaveInputOptions = true;
}
- if ( rOptSet.HasItem(SID_SC_INPUT_EDITMODE,&pItem) )
+ if ( const SfxBoolItem* pItem = rOptSet.GetItemIfSet(SID_SC_INPUT_EDITMODE) )
{
- aInputOptions.SetEnterEdit( static_cast<const SfxBoolItem*>(pItem)->GetValue() );
+ aInputOptions.SetEnterEdit( pItem->GetValue() );
bSaveInputOptions = true;
}
- if ( rOptSet.HasItem(SID_SC_INPUT_FMT_EXPAND,&pItem) )
+ if ( const SfxBoolItem* pItem = rOptSet.GetItemIfSet(SID_SC_INPUT_FMT_EXPAND) )
{
- aInputOptions.SetExtendFormat( static_cast<const SfxBoolItem*>(pItem)->GetValue() );
+ aInputOptions.SetExtendFormat( pItem->GetValue() );
bSaveInputOptions = true;
}
- if ( rOptSet.HasItem(SID_SC_INPUT_RANGEFINDER,&pItem) )
+ if ( const SfxBoolItem* pItem = rOptSet.GetItemIfSet(SID_SC_INPUT_RANGEFINDER) )
{
- aInputOptions.SetRangeFinder( static_cast<const SfxBoolItem*>(pItem)->GetValue() );
+ aInputOptions.SetRangeFinder( pItem->GetValue() );
bSaveInputOptions = true;
}
- if ( rOptSet.HasItem(SID_SC_INPUT_REF_EXPAND,&pItem) )
+ if ( const SfxBoolItem* pItem = rOptSet.GetItemIfSet(SID_SC_INPUT_REF_EXPAND) )
{
- aInputOptions.SetExpandRefs( static_cast<const SfxBoolItem*>(pItem)->GetValue() );
+ aInputOptions.SetExpandRefs( pItem->GetValue() );
bSaveInputOptions = true;
}
- if (rOptSet.HasItem(SID_SC_OPT_SORT_REF_UPDATE, &pItem))
+ if (const SfxBoolItem* pItem = rOptSet.GetItemIfSet(SID_SC_OPT_SORT_REF_UPDATE))
{
- aInputOptions.SetSortRefUpdate(static_cast<const SfxBoolItem*>(pItem)->GetValue());
+ aInputOptions.SetSortRefUpdate( pItem->GetValue());
bSaveInputOptions = true;
}
- if ( rOptSet.HasItem(SID_SC_INPUT_MARK_HEADER,&pItem) )
+ if ( const SfxBoolItem* pItem = rOptSet.GetItemIfSet(SID_SC_INPUT_MARK_HEADER) )
{
- aInputOptions.SetMarkHeader( static_cast<const SfxBoolItem*>(pItem)->GetValue() );
+ aInputOptions.SetMarkHeader( pItem->GetValue() );
bSaveInputOptions = true;
bUpdateMarks = true;
}
- if ( rOptSet.HasItem(SID_SC_INPUT_TEXTWYSIWYG,&pItem) )
+ if ( const SfxBoolItem* pItem = rOptSet.GetItemIfSet(SID_SC_INPUT_TEXTWYSIWYG) )
{
- bool bNew = static_cast<const SfxBoolItem*>(pItem)->GetValue();
+ bool bNew = pItem->GetValue();
if ( bNew != aInputOptions.GetTextWysiwyg() )
{
aInputOptions.SetTextWysiwyg( bNew );
@@ -1230,28 +1229,28 @@ void ScModule::ModifyOptions( const SfxItemSet& rOptSet )
bUpdateRefDev = true;
}
}
- if( rOptSet.HasItem( SID_SC_INPUT_REPLCELLSWARN, &pItem ) )
+ if( const SfxBoolItem* pItem = rOptSet.GetItemIfSet( SID_SC_INPUT_REPLCELLSWARN ) )
{
- aInputOptions.SetReplaceCellsWarn( static_cast<const SfxBoolItem*>(pItem)->GetValue() );
+ aInputOptions.SetReplaceCellsWarn( pItem->GetValue() );
bSaveInputOptions = true;
}
- if( rOptSet.HasItem( SID_SC_INPUT_LEGACY_CELL_SELECTION, &pItem ) )
+ if( const SfxBoolItem* pItem = rOptSet.GetItemIfSet( SID_SC_INPUT_LEGACY_CELL_SELECTION ) )
{
- aInputOptions.SetLegacyCellSelection( static_cast<const SfxBoolItem*>(pItem)->GetValue() );
+ aInputOptions.SetLegacyCellSelection( pItem->GetValue() );
bSaveInputOptions = true;
}
- if( rOptSet.HasItem( SID_SC_INPUT_ENTER_PASTE_MODE, &pItem ) )
+ if( const SfxBoolItem* pItem = rOptSet.GetItemIfSet( SID_SC_INPUT_ENTER_PASTE_MODE ) )
{
- aInputOptions.SetEnterPasteMode( static_cast<const SfxBoolItem*>(pItem)->GetValue() );
+ aInputOptions.SetEnterPasteMode( pItem->GetValue() );
bSaveInputOptions = true;
}
// PrintOptions
- if ( rOptSet.HasItem(SID_SCPRINTOPTIONS,&pItem) )
+ if ( const ScTpPrintItem* pItem = rOptSet.GetItemIfSet(SID_SCPRINTOPTIONS) )
{
- const ScPrintOptions& rNewOpt = static_cast<const ScTpPrintItem*>(pItem)->GetPrintOptions();
+ const ScPrintOptions& rNewOpt = pItem->GetPrintOptions();
SetPrintOptions( rNewOpt );
// broadcast causes all previews to recalc page numbers
diff --git a/sc/source/ui/dbgui/tpsort.cxx b/sc/source/ui/dbgui/tpsort.cxx
index 84032ea264ce..51f8b64caf34 100644
--- a/sc/source/ui/dbgui/tpsort.cxx
+++ b/sc/source/ui/dbgui/tpsort.cxx
@@ -79,9 +79,7 @@ ScTabPageSortFields::ScTabPageSortFields(weld::Container* pPage, weld::DialogCon
nWhichSort ( rArgSet.GetPool()->GetWhich( SID_SORT ) ),
pViewData ( nullptr ),
- aSortData ( static_cast<const ScSortItem&>(
- rArgSet.Get( nWhichSort )).
- GetSortData() ),
+ aSortData ( rArgSet.Get( nWhichSort ).GetSortData() ),
nFieldCount ( 0 ),
// show actual size of the sorting keys without limiting them to the default size
nSortKeyCount(std::max(aSortData.GetSortKeyCount(), static_cast<sal_uInt16>(DEFSORT))),
@@ -108,8 +106,7 @@ ScTabPageSortFields::~ScTabPageSortFields()
void ScTabPageSortFields::Init()
{
- const ScSortItem& rSortItem = static_cast<const ScSortItem&>(
- GetItemSet().Get( nWhichSort ));
+ const ScSortItem& rSortItem = GetItemSet().Get( nWhichSort );
pViewData = rSortItem.GetViewData();
OSL_ENSURE( pViewData, "ViewData not found!" );
@@ -217,10 +214,9 @@ bool ScTabPageSortFields::FillItemSet( SfxItemSet* rArgSet )
const SfxItemSet* pExample = GetDialogExampleSet();
if (pExample)
{
- const SfxPoolItem* pItem;
- if (pExample->GetItemState(nWhichSort, true, &pItem) == SfxItemState::SET)
+ if (const ScSortItem* pItem = pExample->GetItemIfSet(nWhichSort))
{
- ScSortParam aTempData = static_cast<const ScSortItem*>(pItem)->GetSortData();
+ ScSortParam aTempData = pItem->GetSortData();
aTempData.maKeyState = aNewSortData.maKeyState;
aNewSortData = aTempData;
}
@@ -481,7 +477,7 @@ ScTabPageSortOptions::ScTabPageSortOptions(weld::Container* pPage, weld::DialogC
, aStrColLabel(ScResId(SCSTR_COL_LABEL))
, aStrUndefined(ScResId(SCSTR_UNDEFINED))
, nWhichSort(rArgSet.GetPool()->GetWhich(SID_SORT))
- , aSortData(static_cast<const ScSortItem&>(rArgSet.Get(nWhichSort)).GetSortData())
+ , aSortData(rArgSet.Get(nWhichSort).GetSortData())
, pViewData(nullptr)
, pDoc(nullptr)
, m_xBtnCase(m_xBuilder->weld_check_button("case"))
@@ -514,8 +510,7 @@ void ScTabPageSortOptions::Init()
//! use CollatorWrapper from document?
m_xColWrap.reset(new CollatorWrapper(comphelper::getProcessComponentContext()));
- const ScSortItem& rSortItem = static_cast<const ScSortItem&>(
- GetItemSet().Get( nWhichSort ));
+ const ScSortItem& rSortItem = GetItemSet().Get( nWhichSort );
m_xLbOutPos->connect_changed( LINK( this, ScTabPageSortOptions, SelOutPosHdl ) );
m_xBtnCopyResult->connect_toggled( LINK( this, ScTabPageSortOptions, EnableHdl ) );
@@ -658,9 +653,8 @@ bool ScTabPageSortOptions::FillItemSet( SfxItemSet* rArgSet )
const SfxItemSet* pExample = GetDialogExampleSet();
if (pExample)
{
- const SfxPoolItem* pItem;
- if (pExample->GetItemState(nWhichSort, true, &pItem) == SfxItemState::SET)
- aNewSortData = static_cast<const ScSortItem*>(pItem)->GetSortData();
+ if (const ScSortItem* pSortItem = pExample->GetItemIfSet(nWhichSort))
+ aNewSortData = pSortItem->GetSortData();
}
aNewSortData.bByRow = m_xBtnTopDown->get_active();
aNewSortData.bHasHeader = m_xBtnHeader->get_active();
diff --git a/sc/source/ui/dbgui/tpsubt.cxx b/sc/source/ui/dbgui/tpsubt.cxx
index 020203c4c607..439ee359f203 100644
--- a/sc/source/ui/dbgui/tpsubt.cxx
+++ b/sc/source/ui/dbgui/tpsubt.cxx
@@ -45,7 +45,7 @@ ScTpSubTotalGroup::ScTpSubTotalGroup(weld::Container* pPage, weld::DialogControl
, pViewData(nullptr)
, pDoc(nullptr)
, nWhichSubTotals(rArgSet.GetPool()->GetWhich(SID_SUBTOTALS))
- , rSubTotalData(static_cast<const ScSubTotalItem&>(rArgSet.Get(nWhichSubTotals)).GetSubTotalData())
+ , rSubTotalData(rArgSet.Get(nWhichSubTotals).GetSubTotalData())
, nFieldCount(0)
, mxLbGroup(m_xBuilder->weld_combo_box("group_by"))
, mxLbColumns(m_xBuilder->weld_tree_view("columns"))
@@ -74,8 +74,7 @@ ScTpSubTotalGroup::~ScTpSubTotalGroup()
void ScTpSubTotalGroup::Init()
{
- const ScSubTotalItem& rSubTotalItem = static_cast<const ScSubTotalItem&>(
- GetItemSet().Get( nWhichSubTotals ));
+ const ScSubTotalItem& rSubTotalItem = GetItemSet().Get( nWhichSubTotals );
pViewData = rSubTotalItem.GetViewData();
assert(pViewData && "CreateScSubTotalDlg aArgSet must contain a ScSubTotalItem with ViewData set");
@@ -129,9 +128,7 @@ bool ScTpSubTotalGroup::DoReset( sal_uInt16 nGroupNo,
}
mxLbFunctions->select(0);
- ScSubTotalParam theSubTotalData( static_cast<const ScSubTotalItem&>(
- rArgSet.Get( nWhichSubTotals )).
- GetSubTotalData() );
+ const ScSubTotalParam & theSubTotalData( rArgSet.Get( nWhichSubTotals ).GetSubTotalData() );
if ( theSubTotalData.bGroupActive[nGroupIdx] )
{
@@ -195,9 +192,8 @@ bool ScTpSubTotalGroup::DoFillItemSet( sal_uInt16 nGroupNo,
const SfxItemSet* pExample = GetDialogExampleSet();
if (pExample)
{
- const SfxPoolItem* pItem;
- if (pExample->GetItemState(nWhichSubTotals, true, &pItem) == SfxItemState::SET)
- theSubTotalData = static_cast<const ScSubTotalItem*>(pItem)->GetSubTotalData();
+ if (const ScSubTotalItem* pItem = pExample->GetItemIfSet(nWhichSubTotals))
+ theSubTotalData = pItem->GetSubTotalData();
}
std::unique_ptr<ScSubTotalFunc[]> pFunctions;
@@ -444,9 +440,7 @@ ScTpSubTotalOptions::ScTpSubTotalOptions(weld::Container* pPage, weld::DialogCon
pViewData ( nullptr ),
pDoc ( nullptr ),
nWhichSubTotals ( rArgSet.GetPool()->GetWhich( SID_SUBTOTALS ) ),
- rSubTotalData ( static_cast<const ScSubTotalItem&>(
- rArgSet.Get( nWhichSubTotals )).
- GetSubTotalData() )
+ rSubTotalData ( rArgSet.Get( nWhichSubTotals ).GetSubTotalData() )
, m_xBtnPagebreak(m_xBuilder->weld_check_button("pagebreak"))
, m_xBtnCase(m_xBuilder->weld_check_button("case"))
, m_xBtnSort(m_xBuilder->weld_check_button("sort"))
@@ -466,8 +460,7 @@ ScTpSubTotalOptions::~ScTpSubTotalOptions()
void ScTpSubTotalOptions::Init()
{
- const ScSubTotalItem& rSubTotalItem = static_cast<const ScSubTotalItem&>(
- GetItemSet().Get( nWhichSubTotals ));
+ const ScSubTotalItem& rSubTotalItem = GetItemSet().Get( nWhichSubTotals );
pViewData = rSubTotalItem.GetViewData();
assert(pViewData && "CreateScSubTotalDlg aArgSet must contain a ScSubTotalItem with ViewData set");
@@ -517,9 +510,8 @@ bool ScTpSubTotalOptions::FillItemSet( SfxItemSet* rArgSet )
const SfxItemSet* pExample = GetDialogExampleSet();
if (pExample)
{
- const SfxPoolItem* pItem;
- if (pExample->GetItemState(nWhichSubTotals, true, &pItem) == SfxItemState::SET)
- theSubTotalData = static_cast<const ScSubTotalItem*>(pItem)->GetSubTotalData();
+ if (const ScSubTotalItem* pItem = pExample->GetItemIfSet(nWhichSubTotals))
+ theSubTotalData = pItem->GetSubTotalData();
}
theSubTotalData.bPagebreak = m_xBtnPagebreak->get_active();
diff --git a/sc/source/ui/dbgui/validate.cxx b/sc/source/ui/dbgui/validate.cxx
index ac75d90fd8a2..4840e3e2810e 100644
--- a/sc/source/ui/dbgui/validate.cxx
+++ b/sc/source/ui/dbgui/validate.cxx
@@ -424,41 +424,37 @@ std::unique_ptr<SfxTabPage> ScTPValidationValue::Create(weld::Container* pPage,
void ScTPValidationValue::Reset( const SfxItemSet* rArgSet )
{
- const SfxPoolItem* pItem;
-
sal_uInt16 nLbPos = SC_VALIDDLG_ALLOW_ANY;
- if( rArgSet->GetItemState( FID_VALID_MODE, true, &pItem ) == SfxItemState::SET )
- nLbPos = lclGetPosFromValMode( static_cast< ScValidationMode >(
- static_cast< const SfxUInt16Item* >( pItem )->GetValue() ) );
+ if( const SfxUInt16Item* pItem = rArgSet->GetItemIfSet( FID_VALID_MODE ) )
+ nLbPos = lclGetPosFromValMode( static_cast< ScValidationMode >( pItem->GetValue() ) );
m_xLbAllow->set_active( nLbPos );
nLbPos = SC_VALIDDLG_DATA_EQUAL;
- if( rArgSet->GetItemState( FID_VALID_CONDMODE, true, &pItem ) == SfxItemState::SET )
- nLbPos = lclGetPosFromCondMode( static_cast< ScConditionMode >(
- static_cast< const SfxUInt16Item* >( pItem )->GetValue() ) );
+ if( const SfxUInt16Item* pItem = rArgSet->GetItemIfSet( FID_VALID_CONDMODE ) )
+ nLbPos = lclGetPosFromCondMode( static_cast< ScConditionMode >( pItem->GetValue() ) );
m_xLbValue->set_active( nLbPos );
// *** check boxes ***
bool bCheck = true;
- if( rArgSet->GetItemState( FID_VALID_BLANK, true, &pItem ) == SfxItemState::SET )
- bCheck = static_cast< const SfxBoolItem* >( pItem )->GetValue();
+ if( const SfxBoolItem* pItem = rArgSet->GetItemIfSet( FID_VALID_BLANK ) )
+ bCheck = pItem->GetValue();
m_xCbAllow->set_active( bCheck );
sal_Int32 nListType = ValidListType::UNSORTED;
- if( rArgSet->GetItemState( FID_VALID_LISTTYPE, true, &pItem ) == SfxItemState::SET )
- nListType = static_cast< const SfxInt16Item* >( pItem )->GetValue();
+ if( const SfxInt16Item* pItem = rArgSet->GetItemIfSet( FID_VALID_LISTTYPE ) )
+ nListType = pItem->GetValue();
m_xCbShow->set_active( nListType != ValidListType::INVISIBLE );
m_xCbSort->set_active( nListType == ValidListType::SORTEDASCENDING );
// *** formulas ***
OUString aFmlaStr;
- if ( rArgSet->GetItemState( FID_VALID_VALUE1, true, &pItem ) == SfxItemState::SET )
- aFmlaStr = static_cast< const SfxStringItem* >( pItem )->GetValue();
+ if ( const SfxStringItem* pItem = rArgSet->GetItemIfSet( FID_VALID_VALUE1 ) )
+ aFmlaStr = pItem->GetValue();
SetFirstFormula( aFmlaStr );
aFmlaStr.clear();
- if ( rArgSet->GetItemState( FID_VALID_VALUE2, true, &pItem ) == SfxItemState::SET )
- aFmlaStr = static_cast< const SfxStringItem* >( pItem )->GetValue();
+ if ( const SfxStringItem* pItem = rArgSet->GetItemIfSet( FID_VALID_VALUE2 ) )
+ aFmlaStr = pItem->GetValue();
SetSecondFormula( aFmlaStr );
SelectHdl( *m_xLbAllow );
@@ -715,20 +711,18 @@ std::unique_ptr<SfxTabPage> ScTPValidationHelp::Create(weld::Container* pPage, w
void ScTPValidationHelp::Reset( const SfxItemSet* rArgSet )
{
- const SfxPoolItem* pItem;
-
- if ( rArgSet->GetItemState( FID_VALID_SHOWHELP, true, &pItem ) == SfxItemState::SET )
- m_xTsbHelp->set_state( static_cast<const SfxBoolItem*>(pItem)->GetValue() ? TRISTATE_TRUE : TRISTATE_FALSE );
+ if ( const SfxBoolItem* pItem = rArgSet->GetItemIfSet( FID_VALID_SHOWHELP ) )
+ m_xTsbHelp->set_state( pItem->GetValue() ? TRISTATE_TRUE : TRISTATE_FALSE );
else
m_xTsbHelp->set_state( TRISTATE_FALSE );
- if ( rArgSet->GetItemState( FID_VALID_HELPTITLE, true, &pItem ) == SfxItemState::SET )
- m_xEdtTitle->set_text( static_cast<const SfxStringItem*>(pItem)->GetValue() );
+ if ( const SfxStringItem* pItem = rArgSet->GetItemIfSet( FID_VALID_HELPTITLE ) )
+ m_xEdtTitle->set_text( pItem->GetValue() );
else
m_xEdtTitle->set_text( OUString() );
- if ( rArgSet->GetItemState( FID_VALID_HELPTEXT, true, &pItem ) == SfxItemState::SET )
- m_xEdInputHelp->set_text( static_cast<const SfxStringItem*>(pItem)->GetValue() );
+ if ( const SfxStringItem* pItem = rArgSet->GetItemIfSet( FID_VALID_HELPTEXT ) )
+ m_xEdInputHelp->set_text( pItem->GetValue() );
else
m_xEdInputHelp->set_text( OUString() );
}
@@ -784,25 +778,23 @@ std::unique_ptr<SfxTabPage> ScTPValidationError::Create(weld::Container* pPage,
void ScTPValidationError::Reset( const SfxItemSet* rArgSet )
{
- const SfxPoolItem* pItem;
-
- if ( rArgSet->GetItemState( FID_VALID_SHOWERR, true, &pItem ) == SfxItemState::SET )
- m_xTsbShow->set_state( static_cast<const SfxBoolItem*>(pItem)->GetValue() ? TRISTATE_TRUE : TRISTATE_FALSE );
+ if ( const SfxBoolItem* pItem = rArgSet->GetItemIfSet( FID_VALID_SHOWERR ) )
+ m_xTsbShow->set_state( pItem->GetValue() ? TRISTATE_TRUE : TRISTATE_FALSE );
else
m_xTsbShow->set_state( TRISTATE_TRUE ); // check by default
- if ( rArgSet->GetItemState( FID_VALID_ERRSTYLE, true, &pItem ) == SfxItemState::SET )
- m_xLbAction->set_active( static_cast<const SfxUInt16Item*>(pItem)->GetValue() );
+ if ( const SfxUInt16Item* pItem = rArgSet->GetItemIfSet( FID_VALID_ERRSTYLE ) )
+ m_xLbAction->set_active( pItem->GetValue() );
else
m_xLbAction->set_active( 0 );
- if ( rArgSet->GetItemState( FID_VALID_ERRTITLE, true, &pItem ) == SfxItemState::SET )
- m_xEdtTitle->set_text( static_cast<const SfxStringItem*>(pItem)->GetValue() );
+ if ( const SfxStringItem* pItem = rArgSet->GetItemIfSet( FID_VALID_ERRTITLE ) )
+ m_xEdtTitle->set_text( pItem->GetValue() );
else
m_xEdtTitle->set_text( OUString() );
- if ( rArgSet->GetItemState( FID_VALID_ERRTEXT, true, &pItem ) == SfxItemState::SET )
- m_xEdError->set_text( static_cast<const SfxStringItem*>(pItem)->GetValue() );
+ if ( const SfxStringItem* pItem = rArgSet->GetItemIfSet( FID_VALID_ERRTEXT ) )
+ m_xEdError->set_text( pItem->GetValue() );
else
m_xEdError->set_text( OUString() );
diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx
index dac09e465ae3..33936761a761 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -812,13 +812,12 @@ bool ScDocFunc::SetNormalString( bool& o_rbNumFmtSet, const ScAddress& rPos, con
aOldValue.mnTab = rPos.Tab();
aOldValue.maCell.assign(rDoc, rPos);
- const SfxPoolItem* pItem;
const ScPatternAttr* pPattern = rDoc.GetPattern( rPos.Col(),rPos.Row(),rPos.Tab() );
- if ( SfxItemState::SET == pPattern->GetItemSet().GetItemState(
- ATTR_VALUE_FORMAT,false,&pItem) )
+ if ( const SfxUInt32Item* pItem = pPattern->GetItemSet().GetItemIfSet(
+ ATTR_VALUE_FORMAT,false) )
{
aOldValue.mbHasFormat = true;
- aOldValue.mnFormat = static_cast<const SfxUInt32Item*>(pItem)->GetValue();
+ aOldValue.mnFormat = pItem->GetValue();
}
else
aOldValue.mbHasFormat = false;
diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx
index 5cfe7ee0b78b..a0159d0c6628 100644
--- a/sc/source/ui/docshell/docsh.cxx
+++ b/sc/source/ui/docshell/docsh.cxx
@@ -1164,11 +1164,11 @@ bool ScDocShell::ConvertFrom( SfxMedium& rMedium )
{
OUString sItStr;
SfxItemSet* pSet = rMedium.GetItemSet();
- const SfxPoolItem* pItem;
- if ( pSet && SfxItemState::SET ==
- pSet->GetItemState( SID_FILE_FILTEROPTIONS, true, &pItem ) )
+ const SfxStringItem* pOptionsItem;
+ if ( pSet &&
+ (pOptionsItem = pSet->GetItemIfSet( SID_FILE_FILTEROPTIONS, true )) )
{
- sItStr = static_cast<const SfxStringItem*>(pItem)->GetValue();
+ sItStr = pOptionsItem->GetValue();
}
if (sItStr.isEmpty())
@@ -1246,14 +1246,14 @@ bool ScDocShell::ConvertFrom( SfxMedium& rMedium )
else if (aFltName == SC_TEXT_CSV_FILTER_NAME)
{
SfxItemSet* pSet = rMedium.GetItemSet();
- const SfxPoolItem* pItem;
+ const SfxStringItem* pOptionsItem;
ScAsciiOptions aOptions;
bool bOptInit = false;
- if ( pSet && SfxItemState::SET ==
- pSet->GetItemState( SID_FILE_FILTEROPTIONS, true, &pItem ) )
+ if ( pSet &&
+ (pOptionsItem = pSet->GetItemIfSet( SID_FILE_FILTEROPTIONS )) )
{
- aOptions.ReadFromString( static_cast<const SfxStringItem*>(pItem)->GetValue() );
+ aOptions.ReadFromString( pOptionsItem->GetValue() );
bOptInit = true;
}
@@ -1331,11 +1331,11 @@ bool ScDocShell::ConvertFrom( SfxMedium& rMedium )
{
OUString sItStr;
SfxItemSet* pSet = rMedium.GetItemSet();
- const SfxPoolItem* pItem;
- if ( pSet && SfxItemState::SET ==
- pSet->GetItemState( SID_FILE_FILTEROPTIONS, true, &pItem ) )
+ const SfxStringItem* pOptionsItem;
+ if ( pSet &&
+ (pOptionsItem = pSet->GetItemIfSet( SID_FILE_FILTEROPTIONS )) )
{
- sItStr = static_cast<const SfxStringItem*>(pItem)->GetValue();
+ sItStr = pOptionsItem->GetValue();
}
if (sItStr.isEmpty())
@@ -1373,11 +1373,11 @@ bool ScDocShell::ConvertFrom( SfxMedium& rMedium )
ErrCode eError;
OUString sItStr;
SfxItemSet* pSet = rMedium.GetItemSet();
- const SfxPoolItem* pItem;
- if ( pSet && SfxItemState::SET ==
- pSet->GetItemState( SID_FILE_FILTEROPTIONS, true, &pItem ) )
+ const SfxStringItem* pOptionsItem;
+ if ( pSet &&
+ (pOptionsItem = pSet->GetItemIfSet( SID_FILE_FILTEROPTIONS )) )
{
- sItStr = static_cast<const SfxStringItem*>(pItem)->GetValue();
+ sItStr = pOptionsItem->GetValue();
}
if (sItStr.isEmpty())
@@ -1524,11 +1524,11 @@ bool ScDocShell::ConvertFrom( SfxMedium& rMedium )
LanguageType eLang = LANGUAGE_SYSTEM;
bool bDateConvert = false;
SfxItemSet* pSet = rMedium.GetItemSet();
- const SfxPoolItem* pItem;
- if ( pSet && SfxItemState::SET ==
- pSet->GetItemState( SID_FILE_FILTEROPTIONS, true, &pItem ) )
+ const SfxStringItem* pOptionsItem;
+ if ( pSet &&
+ (pOptionsItem = pSet->GetItemIfSet( SID_FILE_FILTEROPTIONS )) )
{
- OUString aFilterOption = static_cast<const SfxStringItem*>(pItem)->GetValue();
+ OUString aFilterOption = pOptionsItem->GetValue();
lcl_parseHtmlFilterOption(aFilterOption, eLang, bDateConvert);
}
@@ -2381,8 +2381,7 @@ bool ScDocShell::ConvertTo( SfxMedium &rMed )
if( (rMed.GetFilter()->GetFilterFlags() & SfxFilterFlags::ENCRYPTION) == SfxFilterFlags::NONE )
{
SfxItemSet* pItemSet = rMed.GetItemSet();
- const SfxPoolItem* pItem = nullptr;
- if( pItemSet && pItemSet->GetItemState( SID_PASSWORD, true, &pItem ) == SfxItemState::SET )
+ if( pItemSet && pItemSet->GetItemState( SID_PASSWORD ) == SfxItemState::SET )
{
bDoSave = ScWarnPassword::WarningOnPassword( rMed );
// #i42858# remove password from medium (warn only one time)
@@ -2421,11 +2420,11 @@ bool ScDocShell::ConvertTo( SfxMedium &rMed )
{
OUString sItStr;
SfxItemSet* pSet = rMed.GetItemSet();
- const SfxPoolItem* pItem;
- if ( pSet && SfxItemState::SET ==
- pSet->GetItemState( SID_FILE_FILTEROPTIONS, true, &pItem ) )
+ const SfxStringItem* pOptionsItem;
+ if ( pSet &&
+ (pOptionsItem = pSet->GetItemIfSet( SID_FILE_FILTEROPTIONS )) )
{
- sItStr = static_cast<const SfxStringItem*>(pItem)->GetValue();
+ sItStr = pOptionsItem->GetValue();
}
if ( sItStr.isEmpty() )
@@ -2548,11 +2547,11 @@ bool ScDocShell::ConvertTo( SfxMedium &rMed )
{
OUString sCharSet;
SfxItemSet* pSet = rMed.GetItemSet();
- const SfxPoolItem* pItem;
- if ( pSet && SfxItemState::SET ==
- pSet->GetItemState( SID_FILE_FILTEROPTIONS, true, &pItem ) )
+ const SfxStringItem* pOptionsItem;
+ if ( pSet &&
+ (pOptionsItem = pSet->GetItemIfSet( SID_FILE_FILTEROPTIONS )) )
{
- sCharSet = static_cast<const SfxStringItem*>(pItem)->GetValue();
+ sCharSet = pOptionsItem->GetValue();
}
if (sCharSet.isEmpty())
@@ -2622,11 +2621,11 @@ bool ScDocShell::ConvertTo( SfxMedium &rMed )
{
OUString sItStr;
SfxItemSet* pSet = rMed.GetItemSet();
- const SfxPoolItem* pItem;
- if ( pSet && SfxItemState::SET ==
- pSet->GetItemState( SID_FILE_FILTEROPTIONS, true, &pItem ) )
+ const SfxStringItem* pOptionsItem;
+ if ( pSet &&
+ (pOptionsItem = pSet->GetItemIfSet( SID_FILE_FILTEROPTIONS )) )
{
- sItStr = static_cast<const SfxStringItem*>(pItem)->GetValue();
+ sItStr = pOptionsItem->GetValue();
}
if (sItStr.isEmpty())
@@ -2670,11 +2669,10 @@ bool ScDocShell::ConvertTo( SfxMedium &rMed )
if ( pStream )
{
SfxItemSet* pSet = rMed.GetItemSet();
- const SfxPoolItem* pItem;
OUString sFilterOptions;
- if (pSet->GetItemState(SID_FILE_FILTEROPTIONS, true, &pItem) == SfxItemState::SET)
- sFilterOptions = static_cast<const SfxStringItem*>(pItem)->GetValue();
+ if (const SfxStringItem* pOptionsItem = pSet->GetItemIfSet(SID_FILE_FILTEROPTIONS))
+ sFilterOptions = pOptionsItem->GetValue();
weld::WaitObject aWait(GetActiveDialogParent());
ScImportExport aImExport(m_aDocument);
diff --git a/sc/source/ui/docshell/docsh4.cxx b/sc/source/ui/docshell/docsh4.cxx
index dd1943620193..3d69269d5a36 100644
--- a/sc/source/ui/docshell/docsh4.cxx
+++ b/sc/source/ui/docshell/docsh4.cxx
@@ -363,11 +363,11 @@ void ScDocShell::Execute( SfxRequest& rReq )
bool bRowInit = false;
bool bAddRange = (nSlot == SID_CHART_ADDSOURCE);
- if( pReqArgs->HasItem( SID_CHART_NAME, &pItem ) )
- aChartName = static_cast<const SfxStringItem*>(pItem)->GetValue();
+ if( const SfxStringItem* pChartItem = pReqArgs->GetItemIfSet( SID_CHART_NAME ) )
+ aChartName = pChartItem->GetValue();
- if( pReqArgs->HasItem( SID_CHART_SOURCE, &pItem ) )
- aRangeName = static_cast<const SfxStringItem*>(pItem)->GetValue();
+ if( const SfxStringItem* pChartItem = pReqArgs->GetItemIfSet( SID_CHART_SOURCE ) )
+ aRangeName = pChartItem->GetValue();
if( pReqArgs->HasItem( FN_PARAM_1, &pItem ) )
{
@@ -728,31 +728,23 @@ void ScDocShell::Execute( SfxRequest& rReq )
}
SfxApplication* pApp = SfxGetpApp();
const SfxPoolItem* pItem;
- const SfxStringItem* pStringItem(nullptr);
+ const SfxStringItem* pFileNameItem(nullptr);
SfxMedium* pMed = nullptr;
- if (pReqArgs && pReqArgs->GetItemState(SID_FILE_NAME, true, &pItem) == SfxItemState::SET)
+ if (pReqArgs)
+ pFileNameItem = pReqArgs->GetItemIfSet(SID_FILE_NAME);
+ if (pFileNameItem)
{
- pStringItem = dynamic_cast<const SfxStringItem*>(pItem);
- }
- if (pStringItem)
- {
- OUString aFileName = pStringItem->GetValue();
+ OUString aFileName = pFileNameItem->GetValue();
OUString aFilterName;
- pStringItem = nullptr;
- if (pReqArgs->GetItemState(SID_FILTER_NAME, true, &pItem) == SfxItemState::SET)
- pStringItem = dynamic_cast<const SfxStringItem*>(pItem);
- if (pStringItem)
+ if (const SfxStringItem* pFilterItem = pReqArgs->GetItemIfSet(SID_FILTER_NAME))
{
- aFilterName = pStringItem->GetValue();
+ aFilterName = pFilterItem->GetValue();
}
OUString aOptions;
- pStringItem = nullptr;
- if (pReqArgs->GetItemState(SID_FILE_FILTEROPTIONS, true, &pItem) == SfxItemState::SET)
- pStringItem = dynamic_cast<const SfxStringItem*>(pItem);
- if (pStringItem)
+ if (const SfxStringItem* pOptionsItem = pReqArgs->GetItemIfSet(SID_FILE_FILTEROPTIONS))
{
- aOptions = pStringItem->GetValue();
+ aOptions = pOptionsItem->GetValue();
}
short nVersion = 0;
const SfxInt16Item* pInt16Item(nullptr);
diff --git a/sc/source/ui/docshell/docsh6.cxx b/sc/source/ui/docshell/docsh6.cxx
index 8b84ae64da34..ce4d03f26b05 100644
--- a/sc/source/ui/docshell/docsh6.cxx
+++ b/sc/source/ui/docshell/docsh6.cxx
@@ -207,17 +207,16 @@ static void lcl_AdjustPool( SfxStyleSheetBasePool* pStylePool )
{
SfxItemSet& rStyleSet = pStyle->GetItemSet();
- const SfxPoolItem* pItem;
- if (rStyleSet.GetItemState(ATTR_PAGE_HEADERSET,false,&pItem) == SfxItemState::SET)
+ if (const SvxSetItem* pItem = rStyleSet.GetItemIfSet(ATTR_PAGE_HEADERSET,false))
{
- const SfxItemSet& rSrcSet = static_cast<const SvxSetItem*>(pItem)->GetItemSet();
+ const SfxItemSet& rSrcSet = pItem->GetItemSet();
SfxItemSet aDestSet(*rStyleSet.GetPool(),rSrcSet.GetRanges());
aDestSet.Put(rSrcSet);
rStyleSet.Put(SvxSetItem(ATTR_PAGE_HEADERSET, std::move(aDestSet)));
}
- if (rStyleSet.GetItemState(ATTR_PAGE_FOOTERSET,false,&pItem) == SfxItemState::SET)
+ if (const SvxSetItem* pItem = rStyleSet.GetItemIfSet(ATTR_PAGE_FOOTERSET,false))
{
- const SfxItemSet& rSrcSet = static_cast<const SvxSetItem*>(pItem)->GetItemSet();
+ const SfxItemSet& rSrcSet = pItem->GetItemSet();
SfxItemSet aDestSet(*rStyleSet.GetPool(),rSrcSet.GetRanges());
aDestSet.Put(rSrcSet);
rStyleSet.Put(SvxSetItem(ATTR_PAGE_FOOTERSET, std::move(aDestSet)));
diff --git a/sc/source/ui/docshell/externalrefmgr.cxx b/sc/source/ui/docshell/externalrefmgr.cxx
index 2f2bf13bd2fc..1fac22e41861 100644
--- a/sc/source/ui/docshell/externalrefmgr.cxx
+++ b/sc/source/ui/docshell/externalrefmgr.cxx
@@ -2571,9 +2571,9 @@ SfxObjectShellRef ScExternalRefManager::loadSrcDocument(sal_uInt16 nFileId, OUSt
SfxMedium* pMedium = pShell->GetMedium();
if (pMedium)
{
- const SfxPoolItem* pItem;
- if (pMedium->GetItemSet()->GetItemState( SID_MACROEXECMODE, false, &pItem ) == SfxItemState::SET &&
- static_cast<const SfxUInt16Item*>(pItem)->GetValue() != css::document::MacroExecMode::NEVER_EXECUTE)
+ const SfxUInt16Item* pItem = pMedium->GetItemSet()->GetItemIfSet( SID_MACROEXECMODE, false );
+ if (pItem &&
+ pItem->GetValue() != css::document::MacroExecMode::NEVER_EXECUTE)
pSet->Put( SfxUInt16Item( SID_MACROEXECMODE, css::document::MacroExecMode::USE_CONFIG));
}
diff --git a/sc/source/ui/docshell/tablink.cxx b/sc/source/ui/docshell/tablink.cxx
index a6b9a81d6295..871353c84768 100644
--- a/sc/source/ui/docshell/tablink.cxx
+++ b/sc/source/ui/docshell/tablink.cxx
@@ -422,9 +422,9 @@ IMPL_LINK( ScTableLink, TableEndEditHdl, ::sfx2::SvBaseLink&, rLink, void )
OUString ScDocumentLoader::GetOptions( const SfxMedium& rMedium )
{
SfxItemSet* pSet = rMedium.GetItemSet();
- const SfxPoolItem* pItem;
- if ( pSet && SfxItemState::SET == pSet->GetItemState( SID_FILE_FILTEROPTIONS, true, &pItem ) )
- return static_cast<const SfxStringItem*>(pItem)->GetValue();
+ const SfxStringItem* pItem;
+ if ( pSet && (pItem = pSet->GetItemIfSet( SID_FILE_FILTEROPTIONS )) )
+ return pItem->GetValue();
return OUString();
}
diff --git a/sc/source/ui/drawfunc/drawsh.cxx b/sc/source/ui/drawfunc/drawsh.cxx
index 760974b95ffe..a92c49b8b030 100644
--- a/sc/source/ui/drawfunc/drawsh.cxx
+++ b/sc/source/ui/drawfunc/drawsh.cxx
@@ -71,11 +71,10 @@ namespace
void lcl_convertStringArguments(sal_uInt16 nSlot, SfxItemSet& rArgs)
{
Color aColor;
- const SfxPoolItem* pItem = nullptr;
- if (SfxItemState::SET == rArgs.GetItemState(SID_ATTR_LINE_WIDTH_ARG, false, &pItem))
+ if (const SvxDoubleItem* pWidthItem = rArgs.GetItemIfSet(SID_ATTR_LINE_WIDTH_ARG, false))
{
- double fValue = static_cast<const SvxDoubleItem*>(pItem)->GetValue();
+ double fValue = pWidthItem->GetValue();
// FIXME: different units...
int nPow = 100;
int nValue = fValue * nPow;
@@ -83,9 +82,9 @@ namespace
XLineWidthItem aItem(nValue);
rArgs.Put(aItem);
}
- else if (SfxItemState::SET == rArgs.GetItemState(SID_ATTR_COLOR_STR, false, &pItem))
+ else if (const SfxStringItem* pColorItem = rArgs.GetItemIfSet(SID_ATTR_COLOR_STR, false))
{
- OUString sColor = static_cast<const SfxStringItem*>(pItem)->GetValue();
+ OUString sColor = pColorItem->GetValue();
if (sColor == "transparent")
aColor = COL_TRANSPARENT;
@@ -116,15 +115,11 @@ namespace
}
}
}
- if (SfxItemState::SET == rArgs.GetItemState(SID_FILL_GRADIENT_JSON, false, &pItem))
+ if (const SfxStringItem* pJSON = rArgs.GetItemIfSet(SID_FILL_GRADIENT_JSON, false))
{
- const SfxStringItem* pJSON = static_cast<const SfxStringItem*>(pItem);
- if (pJSON)
- {
- XGradient aGradient = XGradient::fromJSON(pJSON->GetValue());
- XFillGradientItem aItem(aGradient);
- rArgs.Put(aItem);
- }
+ XGradient aGradient = XGradient::fromJSON(pJSON->GetValue());
+ XFillGradientItem aItem(aGradient);
+ rArgs.Put(aItem);
}
}
}
@@ -480,12 +475,12 @@ void ScDrawShell::ExecuteMacroAssign(SdrObject* pObj, weld::Window* pWin)
return;
const SfxItemSet* pOutSet = pMacroDlg->GetOutputItemSet();
- const SfxPoolItem* pItem;
- if( SfxItemState::SET != pOutSet->GetItemState( SID_ATTR_MACROITEM, false, &pItem ))
+ const SvxMacroItem* pItem = pOutSet->GetItemIfSet( SID_ATTR_MACROITEM, false );
+ if( !pItem )
return;
OUString sMacro;
- const SvxMacro* pMacro = static_cast<const SvxMacroItem*>(pItem)->GetMacroTable().Get( SvMacroItemId::OnClick );
+ const SvxMacro* pMacro = pItem->GetMacroTable().Get( SvMacroItemId::OnClick );
if ( pMacro )
sMacro = pMacro->GetMacName();
diff --git a/sc/source/ui/drawfunc/drtxtob.cxx b/sc/source/ui/drawfunc/drtxtob.cxx
index 065f08bdcdbd..3e8a7f975f23 100644
--- a/sc/source/ui/drawfunc/drtxtob.cxx
+++ b/sc/source/ui/drawfunc/drtxtob.cxx
@@ -218,9 +218,7 @@ void ScDrawTextObjectBar::Execute( SfxRequest &rReq )
if ( pItem )
{
aString = 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 );
+ const SfxStringItem* pFontItem = pArgs->GetItemIfSet( SID_ATTR_SPECIALCHAR, false);
if ( pFontItem )
{
const OUString& aFontName(pFontItem->GetValue());
@@ -262,10 +260,8 @@ void ScDrawTextObjectBar::Execute( SfxRequest &rReq )
case SID_HYPERLINK_SETLINK:
if( pReqArgs )
{
- const SfxPoolItem* pItem;
- if ( pReqArgs->GetItemState( SID_HYPERLINK_SETLINK, true, &pItem ) == SfxItemState::SET )
+ if ( const SvxHyperlinkItem* pHyper = pReqArgs->GetItemIfSet( SID_HYPERLINK_SETLINK) )
{
- const SvxHyperlinkItem* pHyper = static_cast<const SvxHyperlinkItem*>(pItem);
const OUString& rName = pHyper->GetName();
const OUString& rURL = pHyper->GetURL();
const OUString& rTarget = pHyper->GetTargetFrame();
diff --git a/sc/source/ui/drawfunc/fuins1.cxx b/sc/source/ui/drawfunc/fuins1.cxx
index cbc87373c467..c6f2f69daaa5 100644
--- a/sc/source/ui/drawfunc/fuins1.cxx
+++ b/sc/source/ui/drawfunc/fuins1.cxx
@@ -265,17 +265,18 @@ FuInsertGraphic::FuInsertGraphic( ScTabViewShell& rViewSh,
: FuPoor(rViewSh, pWin, pViewP, pDoc, rReq)
{
const SfxItemSet* pReqArgs = rReq.GetArgs();
- const SfxPoolItem* pItem;
+ const SfxStringItem* pGraphicItem;
if ( pReqArgs &&
- pReqArgs->GetItemState( SID_INSERT_GRAPHIC, true, &pItem ) == SfxItemState::SET )
+ (pGraphicItem = pReqArgs->GetItemIfSet( SID_INSERT_GRAPHIC, true )) )
{
- OUString aFileName = static_cast<const SfxStringItem*>(pItem)->GetValue();
+ OUString aFileName = pGraphicItem->GetValue();
OUString aFilterName;
- if ( pReqArgs->GetItemState( FN_PARAM_FILTER, true, &pItem ) == SfxItemState::SET )
- aFilterName = static_cast<const SfxStringItem*>(pItem)->GetValue();
+ if ( const SfxStringItem* pFilterItem = pReqArgs->GetItemIfSet( FN_PARAM_FILTER ) )
+ aFilterName = pFilterItem->GetValue();
bool bAsLink = false;
+ const SfxPoolItem* pItem;
if ( pReqArgs->GetItemState( FN_PARAM_1, true, &pItem ) == SfxItemState::SET )
bAsLink = static_cast<const SfxBoolItem*>(pItem)->GetValue();
diff --git a/sc/source/ui/inc/scuitphfedit.hxx b/sc/source/ui/inc/scuitphfedit.hxx
index 4d84365f85d6..79e1077d425f 100644
--- a/sc/source/ui/inc/scuitphfedit.hxx
+++ b/sc/source/ui/inc/scuitphfedit.hxx
@@ -56,12 +56,12 @@ public:
protected:
ScHFEditPage( weld::Container* pPage, weld::DialogController* pController,
const SfxItemSet& rCoreSet,
- sal_uInt16 nWhich,
+ TypedWhichId<ScPageHFItem> nWhich,
bool bHeader );
virtual ~ScHFEditPage() override;
private:
- sal_uInt16 nWhich;
+ TypedWhichId<ScPageHFItem> nWhich;
bool m_bDropDownActive;
sal_Int64 m_nTimeToggled;
diff --git a/sc/source/ui/inc/tpsort.hxx b/sc/source/ui/inc/tpsort.hxx
index 9f04aeafc23f..39043e0cc0a2 100644
--- a/sc/source/ui/inc/tpsort.hxx
+++ b/sc/source/ui/inc/tpsort.hxx
@@ -36,6 +36,7 @@
// +1 because one field is reserved for the "- undefined -" entry
inline SCCOL SC_MAXFIELDS(const ScSheetLimits& rLimits) { return rLimits.GetMaxColCount() + 1; }
+class ScSortItem;
class ScViewData;
// Sort Criteria
@@ -61,7 +62,7 @@ private:
OUString aStrColumn;
OUString aStrRow;
- const sal_uInt16 nWhichSort;
+ TypedWhichId<ScSortItem> nWhichSort;
ScViewData* pViewData;
ScSortParam aSortData;
std::vector<SCCOLROW> nFieldArr;
@@ -110,7 +111,7 @@ private:
OUString aStrColLabel;
OUString aStrUndefined;
- const sal_uInt16 nWhichSort;
+ TypedWhichId<ScSortItem> nWhichSort;
ScSortParam aSortData;
ScViewData* pViewData;
ScDocument* pDoc;
diff --git a/sc/source/ui/inc/tpsubt.hxx b/sc/source/ui/inc/tpsubt.hxx
index 76846f194bc4..a6dfc3cb5a02 100644
--- a/sc/source/ui/inc/tpsubt.hxx
+++ b/sc/source/ui/inc/tpsubt.hxx
@@ -25,6 +25,7 @@
class ScViewData;
class ScDocument;
struct ScSubTotalParam;
+class ScSubTotalItem;
class ScTpSubTotalGroup : public SfxTabPage
{
@@ -45,7 +46,7 @@ protected:
ScViewData* pViewData;
ScDocument* pDoc;
- const sal_uInt16 nWhichSubTotals;
+ const TypedWhichId<ScSubTotalItem> nWhichSubTotals;
const ScSubTotalParam& rSubTotalData;
std::vector<SCCOL> mnFieldArr;
sal_uInt16 nFieldCount;
@@ -129,7 +130,7 @@ private:
ScViewData* pViewData;
ScDocument* pDoc;
- const sal_uInt16 nWhichSubTotals;
+ const TypedWhichId<ScSubTotalItem> nWhichSubTotals;
const ScSubTotalParam& rSubTotalData;
std::unique_ptr<weld::CheckButton> m_xBtnPagebreak;
diff --git a/sc/source/ui/optdlg/tpcompatibility.cxx b/sc/source/ui/optdlg/tpcompatibility.cxx
index 65d1b80b4ddb..f468a68f679e 100644
--- a/sc/source/ui/optdlg/tpcompatibility.cxx
+++ b/sc/source/ui/optdlg/tpcompatibility.cxx
@@ -45,10 +45,8 @@ bool ScTpCompatOptions::FillItemSet(SfxItemSet *rCoreAttrs)
void ScTpCompatOptions::Reset(const SfxItemSet *rCoreAttrs)
{
- const SfxPoolItem* pItem;
- if (rCoreAttrs->HasItem(SID_SC_OPT_KEY_BINDING_COMPAT, &pItem))
+ if (const SfxUInt16Item* p16Item = rCoreAttrs->GetItemIfSet(SID_SC_OPT_KEY_BINDING_COMPAT))
{
- const SfxUInt16Item* p16Item = static_cast<const SfxUInt16Item*>(pItem);
ScOptionsUtil::KeyBindingType eKeyB =
static_cast<ScOptionsUtil::KeyBindingType>(p16Item->GetValue());
diff --git a/sc/source/ui/optdlg/tpdefaults.cxx b/sc/source/ui/optdlg/tpdefaults.cxx
index 7aad4501b254..7a47f3dbc23a 100644
--- a/sc/source/ui/optdlg/tpdefaults.cxx
+++ b/sc/source/ui/optdlg/tpdefaults.cxx
@@ -67,10 +67,9 @@ bool ScTpDefaultsOptions::FillItemSet(SfxItemSet *rCoreSet)
void ScTpDefaultsOptions::Reset(const SfxItemSet* rCoreSet)
{
ScDefaultsOptions aOpt;
- const SfxPoolItem* pItem = nullptr;
- if(SfxItemState::SET == rCoreSet->GetItemState(SID_SCDEFAULTSOPTIONS, false , &pItem))
- aOpt = static_cast<const ScTpDefaultsItem*>(pItem)->GetDefaultsOptions();
+ if(const ScTpDefaultsItem* pDefaultsItem = rCoreSet->GetItemIfSet(SID_SCDEFAULTSOPTIONS, false))
+ aOpt = pDefaultsItem->GetDefaultsOptions();
m_xEdNSheets->set_value(aOpt.GetInitTabCount());
m_xEdSheetPrefix->set_text( aOpt.GetInitTabPrefix() );
diff --git a/sc/source/ui/optdlg/tpformula.cxx b/sc/source/ui/optdlg/tpformula.cxx
index 656097cf1c5f..f4815d17cc49 100644
--- a/sc/source/ui/optdlg/tpformula.cxx
+++ b/sc/source/ui/optdlg/tpformula.cxx
@@ -325,10 +325,8 @@ bool ScTpFormulaOptions::FillItemSet(SfxItemSet* rCoreSet)
void ScTpFormulaOptions::Reset(const SfxItemSet* rCoreSet)
{
ScFormulaOptions aOpt;
- const SfxPoolItem* pItem = nullptr;
-
- if(SfxItemState::SET == rCoreSet->GetItemState(SID_SCFORMULAOPTIONS, false , &pItem))
- aOpt = static_cast<const ScTpFormulaItem*>(pItem)->GetFormulaOptions();
+ if(const ScTpFormulaItem* pItem = rCoreSet->GetItemIfSet(SID_SCFORMULAOPTIONS, false))
+ aOpt = pItem->GetFormulaOptions();
// formula grammar.
::formula::FormulaGrammar::Grammar eGram = aOpt.GetFormulaSyntax();
diff --git a/sc/source/ui/optdlg/tpprint.cxx b/sc/source/ui/optdlg/tpprint.cxx
index e8294c92f196..c257f6f3da91 100644
--- a/sc/source/ui/optdlg/tpprint.cxx
+++ b/sc/source/ui/optdlg/tpprint.cxx
@@ -56,18 +56,17 @@ void ScTpPrintOptions::Reset( const SfxItemSet* rCoreSet )
{
ScPrintOptions aOptions;
- const SfxPoolItem* pItem;
- if(SfxItemState::SET == rCoreSet->GetItemState(SID_SCPRINTOPTIONS, false , &pItem))
- aOptions = static_cast<const ScTpPrintItem*>(pItem)->GetPrintOptions();
+ if(const ScTpPrintItem* pItem = rCoreSet->GetItemIfSet(SID_SCPRINTOPTIONS, false))
+ aOptions = pItem->GetPrintOptions();
else
{
// when called from print dialog and no options set, use configuration
aOptions = SC_MOD()->GetPrintOptions();
}
- if ( SfxItemState::SET == rCoreSet->GetItemState( SID_PRINT_SELECTEDSHEET, false , &pItem ) )
+ if ( const SfxBoolItem* pItem = rCoreSet->GetItemIfSet( SID_PRINT_SELECTEDSHEET, false))
{
- bool bChecked = static_cast<const SfxBoolItem*>(pItem)->GetValue();
+ bool bChecked = pItem->GetValue();
m_xSelectedSheetsCB->set_active( bChecked );
}
else
diff --git a/sc/source/ui/optdlg/tpview.cxx b/sc/source/ui/optdlg/tpview.cxx
index 9af4e81d87e7..4809061b4005 100644
--- a/sc/source/ui/optdlg/tpview.cxx
+++ b/sc/source/ui/optdlg/tpview.cxx
@@ -150,10 +150,8 @@ bool ScTpContentOptions::FillItemSet( SfxItemSet* rCoreSet )
void ScTpContentOptions::Reset( const SfxItemSet* rCoreSet )
{
- const SfxPoolItem* pItem;
- if(SfxItemState::SET == rCoreSet->GetItemState(SID_SCVIEWOPTIONS, false , &pItem))
- m_xLocalOptions.reset( new ScViewOptions(
- static_cast<const ScTpViewItem*>(pItem)->GetViewOptions() ) );
+ if(const ScTpViewItem* pViewItem = rCoreSet->GetItemIfSet(SID_SCVIEWOPTIONS, false))
+ m_xLocalOptions.reset( new ScViewOptions( pViewItem->GetViewOptions() ) );
else
m_xLocalOptions.reset( new ScViewOptions );
m_xFormulaCB ->set_active(m_xLocalOptions->GetOption(VOPT_FORMULAS));
@@ -183,10 +181,10 @@ void ScTpContentOptions::Reset( const SfxItemSet* rCoreSet )
m_xBreakCB->set_active( m_xLocalOptions->GetOption(VOPT_PAGEBREAKS) );
m_xGuideLineCB->set_active( m_xLocalOptions->GetOption(VOPT_HELPLINES) );
- if(SfxItemState::SET == rCoreSet->GetItemState(SID_SC_INPUT_RANGEFINDER, false, &pItem))
- m_xRangeFindCB->set_active(static_cast<const SfxBoolItem*>(pItem)->GetValue());
- if(SfxItemState::SET == rCoreSet->GetItemState(SID_SC_OPT_SYNCZOOM, false, &pItem))
- m_xSyncZoomCB->set_active(static_cast<const SfxBoolItem*>(pItem)->GetValue());
+ if(const SfxBoolItem* pFinderItem = rCoreSet->GetItemIfSet(SID_SC_INPUT_RANGEFINDER, false))
+ m_xRangeFindCB->set_active(pFinderItem->GetValue());
+ if(const SfxBoolItem* pZoomItem = rCoreSet->GetItemIfSet(SID_SC_OPT_SYNCZOOM, false))
+ m_xSyncZoomCB->set_active(pZoomItem->GetValue());
m_xRangeFindCB->save_state();
m_xSyncZoomCB->save_state();
@@ -215,9 +213,8 @@ void ScTpContentOptions::Reset( const SfxItemSet* rCoreSet )
void ScTpContentOptions::ActivatePage( const SfxItemSet& rSet)
{
- const SfxPoolItem* pItem;
- if(SfxItemState::SET == rSet.GetItemState(SID_SCVIEWOPTIONS, false , &pItem))
- *m_xLocalOptions = static_cast<const ScTpViewItem*>(pItem)->GetViewOptions();
+ if(const ScTpViewItem* pViewItem = rSet.GetItemIfSet(SID_SCVIEWOPTIONS, false))
+ *m_xLocalOptions = pViewItem->GetViewOptions();
}
DeactivateRC ScTpContentOptions::DeactivatePage( SfxItemSet* pSetP )
@@ -504,9 +501,8 @@ void ScTpLayoutOptions::Reset( const SfxItemSet* rCoreSet )
}
m_xUnitLB->save_value();
- const SfxPoolItem* pItem;
- if(SfxItemState::SET == rCoreSet->GetItemState(SID_ATTR_DEFTABSTOP, false, &pItem))
- m_xTabMF->set_value(m_xTabMF->normalize(static_cast<const SfxUInt16Item*>(pItem)->GetValue()), FieldUnit::TWIP);
+ if(const SfxUInt16Item* pTabStopItem = rCoreSet->GetItemIfSet(SID_ATTR_DEFTABSTOP, false))
+ m_xTabMF->set_value(m_xTabMF->normalize(pTabStopItem->GetValue()), FieldUnit::TWIP);
m_xTabMF->save_value();
m_xUnitLB->save_value();
@@ -535,38 +531,38 @@ void ScTpLayoutOptions::Reset( const SfxItemSet* rCoreSet )
// added to avoid warnings
}
}
- if(SfxItemState::SET == rCoreSet->GetItemState(SID_SC_INPUT_SELECTION, false, &pItem))
- m_xAlignCB->set_active(static_cast<const SfxBoolItem*>(pItem)->GetValue());
+ if(const SfxBoolItem* pSelectionItem = rCoreSet->GetItemIfSet(SID_SC_INPUT_SELECTION, false))
+ m_xAlignCB->set_active(pSelectionItem->GetValue());
- if(SfxItemState::SET == rCoreSet->GetItemState(SID_SC_INPUT_SELECTIONPOS, false, &pItem))
- m_xAlignLB->set_active(static_cast<const SfxUInt16Item*>(pItem)->GetValue());
+ if(const SfxUInt16Item* pPosItem = rCoreSet->GetItemIfSet(SID_SC_INPUT_SELECTIONPOS, false))
+ m_xAlignLB->set_active(pPosItem->GetValue());
- if(SfxItemState::SET == rCoreSet->GetItemState(SID_SC_INPUT_EDITMODE, false, &pItem))
- m_xEditModeCB->set_active(static_cast<const SfxBoolItem*>(pItem)->GetValue());
+ if(const SfxBoolItem* pEditModeItem = rCoreSet->GetItemIfSet(SID_SC_INPUT_EDITMODE, false))
+ m_xEditModeCB->set_active(pEditModeItem->GetValue());
- if(SfxItemState::SET == rCoreSet->GetItemState(SID_SC_INPUT_FMT_EXPAND, false, &pItem))
- m_xFormatCB->set_active(static_cast<const SfxBoolItem*>(pItem)->GetValue());
+ if(const SfxBoolItem* pExpandItem = rCoreSet->GetItemIfSet(SID_SC_INPUT_FMT_EXPAND, false))
+ m_xFormatCB->set_active(pExpandItem->GetValue());
- if(SfxItemState::SET == rCoreSet->GetItemState(SID_SC_INPUT_REF_EXPAND, false, &pItem))
- m_xExpRefCB->set_active(static_cast<const SfxBoolItem*>(pItem)->GetValue());
+ if(const SfxBoolItem* pExpandItem = rCoreSet->GetItemIfSet(SID_SC_INPUT_REF_EXPAND, false))
+ m_xExpRefCB->set_active(pExpandItem->GetValue());
- if (rCoreSet->HasItem(SID_SC_OPT_SORT_REF_UPDATE, &pItem))
- m_xSortRefUpdateCB->set_active(static_cast<const SfxBoolItem*>(pItem)->GetValue());
+ if (const SfxBoolItem* pUpdateItem = rCoreSet->GetItemIfSet(SID_SC_OPT_SORT_REF_UPDATE))
+ m_xSortRefUpdateCB->set_active(pUpdateItem->GetValue());
- if(SfxItemState::SET == rCoreSet->GetItemState(SID_SC_INPUT_MARK_HEADER, false, &pItem))
- m_xMarkHdrCB->set_active(static_cast<const SfxBoolItem*>(pItem)->GetValue());
+ if(const SfxBoolItem* pHeaderItem = rCoreSet->GetItemIfSet(SID_SC_INPUT_MARK_HEADER, false))
+ m_xMarkHdrCB->set_active(pHeaderItem->GetValue());
- if(SfxItemState::SET == rCoreSet->GetItemState(SID_SC_INPUT_TEXTWYSIWYG, false, &pItem))
- m_xTextFmtCB->set_active(static_cast<const SfxBoolItem*>(pItem)->GetValue());
+ if(const SfxBoolItem* pWysiItem = rCoreSet->GetItemIfSet(SID_SC_INPUT_TEXTWYSIWYG, false))
+ m_xTextFmtCB->set_active(pWysiItem->GetValue());
- if( SfxItemState::SET == rCoreSet->GetItemState( SID_SC_INPUT_REPLCELLSWARN, false, &pItem ) )
- m_xReplWarnCB->set_active( static_cast<const SfxBoolItem*>(pItem)->GetValue() );
+ if( const SfxBoolItem* pWarnItem = rCoreSet->GetItemIfSet( SID_SC_INPUT_REPLCELLSWARN, false ) )
+ m_xReplWarnCB->set_active( pWarnItem->GetValue() );
- if( SfxItemState::SET == rCoreSet->GetItemState( SID_SC_INPUT_LEGACY_CELL_SELECTION, false, &pItem ) )
- m_xLegacyCellSelectionCB->set_active( static_cast<const SfxBoolItem*>(pItem)->GetValue() );
+ if( const SfxBoolItem* pSelectionItem = rCoreSet->GetItemIfSet( SID_SC_INPUT_LEGACY_CELL_SELECTION, false ) )
+ m_xLegacyCellSelectionCB->set_active( pSelectionItem->GetValue() );
- if( SfxItemState::SET == rCoreSet->GetItemState( SID_SC_INPUT_ENTER_PASTE_MODE, false, &pItem ) )
- m_xEnterPasteModeCB->set_active( static_cast<const SfxBoolItem*>(pItem)->GetValue() );
+ if( const SfxBoolItem* pPasteModeItem = rCoreSet->GetItemIfSet( SID_SC_INPUT_ENTER_PASTE_MODE, false ) )
+ m_xEnterPasteModeCB->set_active( pPasteModeItem->GetValue() );
m_xAlignCB->save_state();
m_xAlignLB->save_value();
diff --git a/sc/source/ui/pagedlg/scuitphfedit.cxx b/sc/source/ui/pagedlg/scuitphfedit.cxx
index ddec413e9dc9..a4c7a1387868 100644
--- a/sc/source/ui/pagedlg/scuitphfedit.cxx
+++ b/sc/source/ui/pagedlg/scuitphfedit.cxx
@@ -40,7 +40,7 @@
ScHFEditPage::ScHFEditPage(weld::Container* pPage, weld::DialogController* pController,
const SfxItemSet& rCoreAttrs,
- sal_uInt16 nWhichId,
+ TypedWhichId<ScPageHFItem> nWhichId,
bool bHeader)
: SfxTabPage(pPage, pController, "modules/scalc/ui/headerfootercontent.ui", "HeaderFooterContent", &rCoreAttrs)
, nWhich( nWhichId )
@@ -146,17 +146,15 @@ void ScHFEditPage::SetNumType(SvxNumType eNumType)
void ScHFEditPage::Reset( const SfxItemSet* rCoreSet )
{
- const SfxPoolItem* pItem = nullptr;
- if ( !rCoreSet->HasItem(nWhich, &pItem) )
+ const ScPageHFItem* pItem = rCoreSet->GetItemIfSet(nWhich);
+ if ( !pItem )
return;
- const ScPageHFItem& rItem = static_cast<const ScPageHFItem&>(*pItem);
-
- if( const EditTextObject* pLeft = rItem.GetLeftArea() )
+ if( const EditTextObject* pLeft = pItem->GetLeftArea() )
m_xWndLeft->SetText( *pLeft );
- if( const EditTextObject* pCenter = rItem.GetCenterArea() )
+ if( const EditTextObject* pCenter = pItem->GetCenterArea() )
m_xWndCenter->SetText( *pCenter );
- if( const EditTextObject* pRight = rItem.GetRightArea() )
+ if( const EditTextObject* pRight = pItem->GetRightArea() )
m_xWndRight->SetText( *pRight );
SetSelectDefinedList();
diff --git a/sc/source/ui/vba/vbaapplication.cxx b/sc/source/ui/vba/vbaapplication.cxx
index 7b68047d0b80..f9ceb7d930be 100644
--- a/sc/source/ui/vba/vbaapplication.cxx
+++ b/sc/source/ui/vba/vbaapplication.cxx
@@ -1363,9 +1363,8 @@ ScVbaApplication::getDisplayFormulaBar()
reqList.Put( sfxFormBar );
pViewShell->GetState( reqList );
- const SfxPoolItem *pItem=nullptr;
- if ( reqList.GetItemState( FID_TOGGLEINPUTLINE, false, &pItem ) == SfxItemState::SET )
- bRes = static_cast<const SfxBoolItem*>(pItem)->GetValue();
+ if ( const SfxBoolItem *pItem = reqList.GetItemIfSet( FID_TOGGLEINPUTLINE, false ) )
+ bRes = pItem->GetValue();
}
return bRes;
}