summaryrefslogtreecommitdiff
path: root/sc/source/ui/view
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2022-03-01 11:09:12 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-03-01 11:26:17 +0100
commitfc8e5f91fcf3a63d6bcd29c498e58a67e9abe67f (patch)
tree9286227494e4c694446474be3d85d77d418d8440 /sc/source/ui/view
parent1e157252a2074729d1d89d6b49054dfd74ffe789 (diff)
use SfxItemSet::GetItemIfSet in sc/source/ui/view/
Change-Id: I6c1c3ee4fbb6b105ad67c051ce1fa2dae258df85 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130746 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sc/source/ui/view')
-rw-r--r--sc/source/ui/view/auditsh.cxx13
-rw-r--r--sc/source/ui/view/cellsh1.cxx35
-rw-r--r--sc/source/ui/view/cellsh2.cxx112
-rw-r--r--sc/source/ui/view/cellsh3.cxx29
-rw-r--r--sc/source/ui/view/editsh.cxx10
-rw-r--r--sc/source/ui/view/formatsh.cxx72
-rw-r--r--sc/source/ui/view/output2.cxx20
-rw-r--r--sc/source/ui/view/preview.cxx10
-rw-r--r--sc/source/ui/view/prevwsh.cxx12
-rw-r--r--sc/source/ui/view/printfun.cxx8
-rw-r--r--sc/source/ui/view/tabvwsha.cxx6
-rw-r--r--sc/source/ui/view/tabvwshe.cxx16
12 files changed, 152 insertions, 191 deletions
diff --git a/sc/source/ui/view/auditsh.cxx b/sc/source/ui/view/auditsh.cxx
index 1caea374fb71..2ea903f59e75 100644
--- a/sc/source/ui/view/auditsh.cxx
+++ b/sc/source/ui/view/auditsh.cxx
@@ -85,15 +85,12 @@ void ScAuditingShell::Execute( const SfxRequest& rReq )
const SfxItemSet* pReqArgs = rReq.GetArgs();
if ( pReqArgs )
{
- const SfxPoolItem* pXItem;
- const SfxPoolItem* pYItem;
- if ( pReqArgs->GetItemState( SID_RANGE_COL, true, &pXItem ) == SfxItemState::SET
- && pReqArgs->GetItemState( SID_RANGE_ROW, true, &pYItem ) == SfxItemState::SET )
+ const SfxInt16Item* pXItem = pReqArgs->GetItemIfSet( SID_RANGE_COL );
+ const SfxInt32Item* pYItem = pReqArgs->GetItemIfSet( SID_RANGE_ROW );
+ if ( pXItem && pYItem )
{
- assert( dynamic_cast<const SfxInt16Item*>( pXItem) && dynamic_cast<const SfxInt32Item*>( pYItem) &&
- "wrong items" );
- SCCOL nCol = static_cast<SCCOL>(static_cast<const SfxInt16Item*>(pXItem)->GetValue());
- SCROW nRow = static_cast<SCROW>(static_cast<const SfxInt32Item*>(pYItem)->GetValue());
+ SCCOL nCol = static_cast<SCCOL>(pXItem->GetValue());
+ SCROW nRow = static_cast<SCROW>(pYItem->GetValue());
ScViewFunc* pView = rViewData.GetView();
pView->MoveCursorAbs( nCol, nRow, SC_FOLLOW_LINE, false, false );
switch ( nFunction )
diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx
index 9bf7099b9d34..a3d4b0125437 100644
--- a/sc/source/ui/view/cellsh1.cxx
+++ b/sc/source/ui/view/cellsh1.cxx
@@ -809,12 +809,10 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
if( pReqArgs != nullptr )
{
- const SfxPoolItem* pItem;
-
- if( pReqArgs->HasItem( FID_FILL_AUTO, &pItem ) )
+ if( const SfxStringItem* pItem = pReqArgs->GetItemIfSet( FID_FILL_AUTO ) )
{
ScAddress aScAddress;
- OUString aArg = static_cast<const SfxStringItem*>(pItem)->GetValue();
+ OUString aArg = pItem->GetValue();
if( aScAddress.Parse( aArg, rDoc, rDoc.GetAddressConvention() ) & ScRefFlags::VALID )
{
@@ -1927,12 +1925,11 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
case SID_CONSOLIDATE:
{
- const SfxPoolItem* pItem;
- if ( pReqArgs && SfxItemState::SET ==
- pReqArgs->GetItemState( SCITEM_CONSOLIDATEDATA, true, &pItem ) )
+ const ScConsolidateItem* pItem;
+ if ( pReqArgs && (pItem =
+ pReqArgs->GetItemIfSet( SCITEM_CONSOLIDATEDATA )) )
{
- const ScConsolidateParam& rParam =
- static_cast<const ScConsolidateItem*>(pItem)->GetData();
+ const ScConsolidateParam& rParam = pItem->GetData();
pTabViewShell->Consolidate( rParam );
GetViewData().GetDocument().SetConsolidateDlgData( std::unique_ptr<ScConsolidateParam>(new ScConsolidateParam(rParam)) );
@@ -2305,16 +2302,14 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
case SID_INSERT_POSTIT:
case SID_EDIT_POSTIT:
{
- const SfxPoolItem* pText;
- if ( pReqArgs && pReqArgs->HasItem( SID_ATTR_POSTIT_TEXT, &pText) )
+ const SvxPostItTextItem* pTextItem;
+ if ( pReqArgs && (pTextItem = pReqArgs->GetItemIfSet( SID_ATTR_POSTIT_TEXT )) )
{
- const SfxPoolItem* pCellId;
OUString aCellId;
// SID_ATTR_POSTIT_ID only argument for SID_EDIT_POSTIT
- if (pReqArgs->HasItem( SID_ATTR_POSTIT_ID, &pCellId ))
- aCellId = static_cast<const SvxPostItIdItem*>(pCellId)->GetValue();
+ if (const SvxPostItIdItem* pCellId = pReqArgs->GetItemIfSet( SID_ATTR_POSTIT_ID ))
+ aCellId = pCellId->GetValue();
- const SvxPostItTextItem* pTextItem = static_cast<const SvxPostItTextItem*>( pText );
const SvxPostItAuthorItem* pAuthorItem = pReqArgs->GetItem( SID_ATTR_POSTIT_AUTHOR );
const SvxPostItDateItem* pDateItem = pReqArgs->GetItem( SID_ATTR_POSTIT_DATE );
@@ -2491,11 +2486,10 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
case SID_DELETE_NOTE:
{
- const SfxPoolItem* pId;
+ const SvxPostItIdItem* pIdItem;
// If Id is mentioned, select the appropriate cell first
- if ( pReqArgs && pReqArgs->HasItem( SID_ATTR_POSTIT_ID, &pId) )
+ if ( pReqArgs && (pIdItem = pReqArgs->GetItemIfSet( SID_ATTR_POSTIT_ID )) )
{
- const SvxPostItIdItem* pIdItem = static_cast<const SvxPostItIdItem*>(pId);
const OUString& aCellId = pIdItem->GetValue();
if (!aCellId.isEmpty())
{
@@ -2539,9 +2533,8 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
const SfxStringItem* pStringItem = dynamic_cast<const SfxStringItem*>( pItem );
if ( pStringItem )
aChars = pStringItem->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 )
aFontName = pFontItem->GetValue();
}
diff --git a/sc/source/ui/view/cellsh2.cxx b/sc/source/ui/view/cellsh2.cxx
index 0269c5e9f7dd..c9b13c3503d2 100644
--- a/sc/source/ui/view/cellsh2.cxx
+++ b/sc/source/ui/view/cellsh2.cxx
@@ -440,30 +440,30 @@ void ScCellShell::ExecuteDB( SfxRequest& rReq )
aSortParam.bInplace = true; // from Basic always
- const SfxPoolItem* pItem;
- if ( pArgs->GetItemState( SID_SORT_BYROW, true, &pItem ) == SfxItemState::SET )
- aSortParam.bByRow = static_cast<const SfxBoolItem*>(pItem)->GetValue();
- if ( pArgs->GetItemState( SID_SORT_HASHEADER, true, &pItem ) == SfxItemState::SET )
- aSortParam.bHasHeader = static_cast<const SfxBoolItem*>(pItem)->GetValue();
- if ( pArgs->GetItemState( SID_SORT_CASESENS, true, &pItem ) == SfxItemState::SET )
- aSortParam.bCaseSens = static_cast<const SfxBoolItem*>(pItem)->GetValue();
- if ( pArgs->GetItemState( SID_SORT_NATURALSORT, true, &pItem ) == SfxItemState::SET )
- aSortParam.bNaturalSort = static_cast<const SfxBoolItem*>(pItem)->GetValue();
- if ( pArgs->GetItemState( SID_SORT_INCCOMMENTS, true, &pItem ) == SfxItemState::SET )
- aSortParam.aDataAreaExtras.mbCellNotes = static_cast<const SfxBoolItem*>(pItem)->GetValue();
- if ( pArgs->GetItemState( SID_SORT_INCIMAGES, true, &pItem ) == SfxItemState::SET )
- aSortParam.aDataAreaExtras.mbCellDrawObjects = static_cast<const SfxBoolItem*>(pItem)->GetValue();
- if ( pArgs->GetItemState( SID_SORT_ATTRIBS, true, &pItem ) == SfxItemState::SET )
- aSortParam.aDataAreaExtras.mbCellFormats = static_cast<const SfxBoolItem*>(pItem)->GetValue();
- if ( pArgs->GetItemState( SID_SORT_USERDEF, true, &pItem ) == SfxItemState::SET )
+ if ( const SfxBoolItem* pItem = pArgs->GetItemIfSet( SID_SORT_BYROW ) )
+ aSortParam.bByRow = pItem->GetValue();
+ if ( const SfxBoolItem* pItem = pArgs->GetItemIfSet( SID_SORT_HASHEADER ) )
+ aSortParam.bHasHeader = pItem->GetValue();
+ if ( const SfxBoolItem* pItem = pArgs->GetItemIfSet( SID_SORT_CASESENS ) )
+ aSortParam.bCaseSens = pItem->GetValue();
+ if ( const SfxBoolItem* pItem = pArgs->GetItemIfSet( SID_SORT_NATURALSORT ) )
+ aSortParam.bNaturalSort = pItem->GetValue();
+ if ( const SfxBoolItem* pItem = pArgs->GetItemIfSet( SID_SORT_INCCOMMENTS ) )
+ aSortParam.aDataAreaExtras.mbCellNotes = pItem->GetValue();
+ if ( const SfxBoolItem* pItem = pArgs->GetItemIfSet( SID_SORT_INCIMAGES ) )
+ aSortParam.aDataAreaExtras.mbCellDrawObjects = pItem->GetValue();
+ if ( const SfxBoolItem* pItem = pArgs->GetItemIfSet( SID_SORT_ATTRIBS ) )
+ aSortParam.aDataAreaExtras.mbCellFormats = pItem->GetValue();
+ if ( const SfxUInt16Item* pItem = pArgs->GetItemIfSet( SID_SORT_USERDEF ) )
{
- sal_uInt16 nUserIndex = static_cast<const SfxUInt16Item*>(pItem)->GetValue();
+ sal_uInt16 nUserIndex = pItem->GetValue();
aSortParam.bUserDef = ( nUserIndex != 0 );
if ( nUserIndex )
aSortParam.nUserIndex = nUserIndex - 1; // Basic: 1-based
}
SCCOLROW nField0 = 0;
+ const SfxPoolItem* pItem = nullptr;
if ( pArgs->GetItemState( FN_PARAM_1, true, &pItem ) == SfxItemState::SET )
nField0 = static_cast<const SfxInt32Item*>(pItem)->GetValue();
aSortParam.maKeyState[0].bDoSort = ( nField0 != 0 );
@@ -583,12 +583,10 @@ void ScCellShell::ExecuteDB( SfxRequest& rReq )
case FID_FILTER_OK:
{
- const SfxPoolItem* pItem;
- if ( pReqArgs && SfxItemState::SET ==
- pReqArgs->GetItemState( SCITEM_QUERYDATA, true, &pItem ) )
+ const ScQueryItem* pQueryItem;
+ if ( pReqArgs && (pQueryItem =
+ pReqArgs->GetItemIfSet( SCITEM_QUERYDATA )) )
{
- const ScQueryItem& rQueryItem = static_cast<const ScQueryItem&>(*pItem);
-
SCTAB nCurTab = GetViewData().GetTabNo();
SCTAB nRefTab = GetViewData().GetRefTabNo();
@@ -602,10 +600,10 @@ void ScCellShell::ExecuteDB( SfxRequest& rReq )
}
ScRange aAdvSource;
- if (rQueryItem.GetAdvancedQuerySource(aAdvSource))
- pTabViewShell->Query( rQueryItem.GetQueryData(), &aAdvSource, true );
+ if (pQueryItem->GetAdvancedQuerySource(aAdvSource))
+ pTabViewShell->Query( pQueryItem->GetQueryData(), &aAdvSource, true );
else
- pTabViewShell->Query( rQueryItem.GetQueryData(), nullptr, true );
+ pTabViewShell->Query( pQueryItem->GetQueryData(), nullptr, true );
rReq.Done( *pReqArgs );
}
}
@@ -638,9 +636,9 @@ void ScCellShell::ExecuteDB( SfxRequest& rReq )
case SID_PIVOT_TABLE:
{
- const SfxPoolItem* pItem;
- if ( pReqArgs && SfxItemState::SET ==
- pReqArgs->GetItemState( SCITEM_PIVOTDATA, true, &pItem ) )
+ const ScPivotItem* pPItem;
+ if ( pReqArgs && (pPItem =
+ pReqArgs->GetItemIfSet( SCITEM_PIVOTDATA )) )
{
SCTAB nCurTab = GetViewData().GetTabNo();
SCTAB nRefTab = GetViewData().GetRefTabNo();
@@ -657,7 +655,6 @@ void ScCellShell::ExecuteDB( SfxRequest& rReq )
const ScDPObject* pDPObject = pTabViewShell->GetDialogDPObject();
if ( pDPObject )
{
- const ScPivotItem* pPItem = static_cast<const ScPivotItem*>(pItem);
bool bSuccess = pTabViewShell->MakePivotTable(
pPItem->GetData(), pPItem->GetDestRange(), pPItem->IsNewSheet(), *pDPObject );
SfxBoolItem aRet(0, bSuccess);
@@ -781,7 +778,6 @@ void ScCellShell::ExecuteDB( SfxRequest& rReq )
case FID_VALIDATION:
case FID_CURRENTVALIDATION:
{
- const SfxPoolItem* pItem;
const SfxItemSet* pArgs = rReq.GetArgs();
if ( pArgs )
{
@@ -858,13 +854,13 @@ void ScCellShell::ExecuteDB( SfxRequest& rReq )
{
const SfxItemSet* pOutSet = xDlg->GetOutputItemSet();
- if ( pOutSet->GetItemState( FID_VALID_MODE, true, &pItem ) == SfxItemState::SET )
- eMode = static_cast<ScValidationMode>(static_cast<const SfxUInt16Item*>(pItem)->GetValue());
- if ( pOutSet->GetItemState( FID_VALID_CONDMODE, true, &pItem ) == SfxItemState::SET )
- eOper = static_cast<ScConditionMode>(static_cast<const SfxUInt16Item*>(pItem)->GetValue());
- if ( pOutSet->GetItemState( FID_VALID_VALUE1, true, &pItem ) == SfxItemState::SET )
+ if ( const SfxUInt16Item* pItem = pOutSet->GetItemIfSet( FID_VALID_MODE ) )
+ eMode = static_cast<ScValidationMode>(pItem->GetValue());
+ if ( const SfxUInt16Item* pItem = pOutSet->GetItemIfSet( FID_VALID_CONDMODE ) )
+ eOper = static_cast<ScConditionMode>(pItem->GetValue());
+ if ( const SfxStringItem* pItem = pOutSet->GetItemIfSet( FID_VALID_VALUE1 ) )
{
- OUString aTemp1 = static_cast<const SfxStringItem*>(pItem)->GetValue();
+ OUString aTemp1 = pItem->GetValue();
if (eMode == SC_VALID_DATE || eMode == SC_VALID_TIME)
{
sal_uInt32 nNumIndex = 0;
@@ -879,9 +875,9 @@ void ScCellShell::ExecuteDB( SfxRequest& rReq )
else
aExpr1 = aTemp1;
}
- if ( pOutSet->GetItemState( FID_VALID_VALUE2, true, &pItem ) == SfxItemState::SET )
+ if ( const SfxStringItem* pItem = pOutSet->GetItemIfSet( FID_VALID_VALUE2 ) )
{
- OUString aTemp2 = static_cast<const SfxStringItem*>(pItem)->GetValue();
+ OUString aTemp2 = pItem->GetValue();
if (eMode == SC_VALID_DATE || eMode == SC_VALID_TIME)
{
sal_uInt32 nNumIndex = 0;
@@ -913,26 +909,26 @@ void ScCellShell::ExecuteDB( SfxRequest& rReq )
else
aExpr2 = aTemp2;
}
- if ( pOutSet->GetItemState( FID_VALID_BLANK, true, &pItem ) == SfxItemState::SET )
- bBlank = static_cast<const SfxBoolItem*>(pItem)->GetValue();
- if ( pOutSet->GetItemState( FID_VALID_LISTTYPE, true, &pItem ) == SfxItemState::SET )
- nListType = static_cast<const SfxInt16Item*>(pItem)->GetValue();
-
- if ( pOutSet->GetItemState( FID_VALID_SHOWHELP, true, &pItem ) == SfxItemState::SET )
- bShowHelp = static_cast<const SfxBoolItem*>(pItem)->GetValue();
- if ( pOutSet->GetItemState( FID_VALID_HELPTITLE, true, &pItem ) == SfxItemState::SET )
- aHelpTitle = static_cast<const SfxStringItem*>(pItem)->GetValue();
- if ( pOutSet->GetItemState( FID_VALID_HELPTEXT, true, &pItem ) == SfxItemState::SET )
- aHelpText = static_cast<const SfxStringItem*>(pItem)->GetValue();
-
- if ( pOutSet->GetItemState( FID_VALID_SHOWERR, true, &pItem ) == SfxItemState::SET )
- bShowError = static_cast<const SfxBoolItem*>(pItem)->GetValue();
- if ( pOutSet->GetItemState( FID_VALID_ERRSTYLE, true, &pItem ) == SfxItemState::SET )
- eErrStyle = static_cast<ScValidErrorStyle>(static_cast<const SfxUInt16Item*>(pItem)->GetValue());
- if ( pOutSet->GetItemState( FID_VALID_ERRTITLE, true, &pItem ) == SfxItemState::SET )
- aErrTitle = static_cast<const SfxStringItem*>(pItem)->GetValue();
- if ( pOutSet->GetItemState( FID_VALID_ERRTEXT, true, &pItem ) == SfxItemState::SET )
- aErrText = static_cast<const SfxStringItem*>(pItem)->GetValue();
+ if ( const SfxBoolItem* pItem = pOutSet->GetItemIfSet( FID_VALID_BLANK ) )
+ bBlank = pItem->GetValue();
+ if ( const SfxInt16Item* pItem = pOutSet->GetItemIfSet( FID_VALID_LISTTYPE ) )
+ nListType = pItem->GetValue();
+
+ if ( const SfxBoolItem* pItem = pOutSet->GetItemIfSet( FID_VALID_SHOWHELP ) )
+ bShowHelp = pItem->GetValue();
+ if ( const SfxStringItem* pItem = pOutSet->GetItemIfSet( FID_VALID_HELPTITLE ) )
+ aHelpTitle = pItem->GetValue();
+ if ( const SfxStringItem* pItem = pOutSet->GetItemIfSet( FID_VALID_HELPTEXT ) )
+ aHelpText = pItem->GetValue();
+
+ if ( const SfxBoolItem* pItem = pOutSet->GetItemIfSet( FID_VALID_SHOWERR ) )
+ bShowError = pItem->GetValue();
+ if ( const SfxUInt16Item* pItem = pOutSet->GetItemIfSet( FID_VALID_ERRSTYLE ) )
+ eErrStyle = static_cast<ScValidErrorStyle>(pItem->GetValue());
+ if ( const SfxStringItem* pItem = pOutSet->GetItemIfSet( FID_VALID_ERRTITLE ) )
+ aErrTitle = pItem->GetValue();
+ if ( const SfxStringItem* pItem = pOutSet->GetItemIfSet( FID_VALID_ERRTEXT ) )
+ aErrText = pItem->GetValue();
ScValidationData aData( eMode, eOper, aExpr1, aExpr2, rDoc, aCursorPos );
aData.SetIgnoreBlank( bBlank );
diff --git a/sc/source/ui/view/cellsh3.cxx b/sc/source/ui/view/cellsh3.cxx
index b373fd4561bd..57299cdaa45b 100644
--- a/sc/source/ui/view/cellsh3.cxx
+++ b/sc/source/ui/view/cellsh3.cxx
@@ -597,11 +597,10 @@ void ScCellShell::Execute( SfxRequest& rReq )
{
OUString aArgName;
OUString aArgComment;
- const SfxPoolItem* pItem;
- if ( pReqArgs->GetItemState( SID_SCENARIOS, true, &pItem ) == SfxItemState::SET )
- aArgName = static_cast<const SfxStringItem*>(pItem)->GetValue();
- if ( pReqArgs->GetItemState( SID_NEW_TABLENAME, true, &pItem ) == SfxItemState::SET )
- aArgComment = static_cast<const SfxStringItem*>(pItem)->GetValue();
+ if ( const SfxStringItem* pItem = pReqArgs->GetItemIfSet( SID_SCENARIOS ) )
+ aArgName = pItem->GetValue();
+ if ( const SfxStringItem* pItem = pReqArgs->GetItemIfSet( SID_NEW_TABLENAME ) )
+ aArgComment = pItem->GetValue();
aColor = COL_LIGHTGRAY; // Default
nFlags = ScScenarioFlags::NONE; // not TwoWay
@@ -646,15 +645,15 @@ void ScCellShell::Execute( SfxRequest& rReq )
case FID_ROW_HEIGHT:
{
const SfxPoolItem* pRow;
- const SfxPoolItem* pHeight;
+ const SfxUInt16Item* pHeight;
sal_uInt16 nHeight;
- if ( pReqArgs && pReqArgs->HasItem( FID_ROW_HEIGHT, &pHeight ) &&
+ if ( pReqArgs && (pHeight = pReqArgs->GetItemIfSet( FID_ROW_HEIGHT )) &&
pReqArgs->HasItem( FN_PARAM_1, &pRow ) )
{
std::vector<sc::ColRowSpan> aRanges;
SCCOLROW nRow = static_cast<const SfxInt32Item*>(pRow)->GetValue() - 1;
- nHeight = static_cast<const SfxUInt16Item*>(pHeight)->GetValue();
+ nHeight = pHeight->GetValue();
ScMarkData& rMark = GetViewData().GetMarkData();
if ( rMark.IsRowMarked( static_cast<SCROW>(nRow) ) )
@@ -668,9 +667,9 @@ void ScCellShell::Execute( SfxRequest& rReq )
pTabViewShell->SetWidthOrHeight(false, aRanges, SC_SIZE_DIRECT, o3tl::toTwips(nHeight, o3tl::Length::mm100));
}
- else if ( pReqArgs && pReqArgs->HasItem( FID_ROW_HEIGHT, &pHeight ) )
+ else if ( pReqArgs && (pHeight = pReqArgs->GetItemIfSet( FID_ROW_HEIGHT )) )
{
- nHeight = static_cast<const SfxUInt16Item*>(pHeight)->GetValue();
+ nHeight = pHeight->GetValue();
// #101390#; the value of the macro is in HMM so use convertMm100ToTwip to convert
pTabViewShell->SetMarkedWidthOrHeight( false, SC_SIZE_DIRECT,
@@ -745,15 +744,15 @@ void ScCellShell::Execute( SfxRequest& rReq )
case FID_COL_WIDTH:
{
const SfxPoolItem* pColumn;
- const SfxPoolItem* pWidth;
+ const SfxUInt16Item* pWidth;
sal_uInt16 nWidth;
- if ( pReqArgs && pReqArgs->HasItem( FID_COL_WIDTH, &pWidth ) &&
+ if ( pReqArgs && (pWidth = pReqArgs->GetItemIfSet( FID_COL_WIDTH )) &&
pReqArgs->HasItem( FN_PARAM_1, &pColumn ) )
{
std::vector<sc::ColRowSpan> aRanges;
SCCOLROW nColumn = static_cast<const SfxUInt16Item*>(pColumn)->GetValue() - 1;
- nWidth = static_cast<const SfxUInt16Item*>(pWidth)->GetValue();
+ nWidth = pWidth->GetValue();
ScMarkData& rMark = GetViewData().GetMarkData();
if ( rMark.IsColumnMarked( static_cast<SCCOL>(nColumn) ) )
@@ -767,9 +766,9 @@ void ScCellShell::Execute( SfxRequest& rReq )
pTabViewShell->SetWidthOrHeight(true, aRanges, SC_SIZE_DIRECT, o3tl::toTwips(nWidth, o3tl::Length::mm100));
}
- else if ( pReqArgs && pReqArgs->HasItem( FID_COL_WIDTH, &pWidth ) )
+ else if ( pReqArgs && (pWidth = pReqArgs->GetItemIfSet( FID_COL_WIDTH )) )
{
- nWidth = static_cast<const SfxUInt16Item*>(pWidth)->GetValue();
+ nWidth = pWidth->GetValue();
// #101390#; the value of the macro is in HMM so use convertMm100ToTwip to convert
pTabViewShell->SetMarkedWidthOrHeight( true, SC_SIZE_DIRECT,
diff --git a/sc/source/ui/view/editsh.cxx b/sc/source/ui/view/editsh.cxx
index 14f21eb2190a..dbfd28404fd7 100644
--- a/sc/source/ui/view/editsh.cxx
+++ b/sc/source/ui/view/editsh.cxx
@@ -397,9 +397,7 @@ void ScEditShell::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());
@@ -969,12 +967,10 @@ void ScEditShell::ExecuteAttr(SfxRequest& rReq)
{
if (pArgs)
{
- const SfxPoolItem* pColorStringItem = nullptr;
-
- if ( pArgs && SfxItemState::SET == pArgs->GetItemState( SID_ATTR_COLOR_STR, false, &pColorStringItem ) )
+ if ( const SfxStringItem* pColorStringItem = pArgs->GetItemIfSet( SID_ATTR_COLOR_STR, false ) )
{
Color aColor;
- OUString sColor = static_cast<const SfxStringItem*>( pColorStringItem )->GetValue();
+ OUString sColor = pColorStringItem->GetValue();
if ( sColor == "transparent" )
aColor = COL_TRANSPARENT;
else
diff --git a/sc/source/ui/view/formatsh.cxx b/sc/source/ui/view/formatsh.cxx
index a4f9fc4738d8..598a5879a1e3 100644
--- a/sc/source/ui/view/formatsh.cxx
+++ b/sc/source/ui/view/formatsh.cxx
@@ -276,9 +276,9 @@ void ScFormatShell::ExecuteStyle( SfxRequest& rReq )
if (nSlotId == SID_STYLE_PREVIEW)
{
SfxStyleFamily eFamily = SfxStyleFamily::Para;
- const SfxPoolItem* pFamItem;
- if ( pArgs && SfxItemState::SET == pArgs->GetItemState( SID_STYLE_FAMILY, true, &pFamItem ) )
- eFamily = static_cast<SfxStyleFamily>(static_cast<const SfxUInt16Item*>(pFamItem)->GetValue());
+ const SfxUInt16Item* pFamItem;
+ if ( pArgs && (pFamItem = pArgs->GetItemIfSet( SID_STYLE_FAMILY )) )
+ eFamily = static_cast<SfxStyleFamily>(pFamItem->GetValue());
const SfxPoolItem* pNameItem;
OUString aStyleName;
if (pArgs && SfxItemState::SET == pArgs->GetItemState( nSlotId, true, &pNameItem ))
@@ -356,12 +356,13 @@ void ScFormatShell::ExecuteStyle( SfxRequest& rReq )
ScStyleSaveData aNewData;
SfxStyleFamily eFamily = SfxStyleFamily::Para;
- const SfxPoolItem* pFamItem;
- if ( pArgs && SfxItemState::SET == pArgs->GetItemState( SID_STYLE_FAMILY, true, &pFamItem ) )
- eFamily = static_cast<SfxStyleFamily>(static_cast<const SfxUInt16Item*>(pFamItem)->GetValue());
- else if ( pArgs && SfxItemState::SET == pArgs->GetItemState( SID_STYLE_FAMILYNAME, true, &pFamItem ) )
+ const SfxUInt16Item* pFamItem;
+ const SfxStringItem* pFamilyNameItem;
+ if ( pArgs && (pFamItem = pArgs->GetItemIfSet( SID_STYLE_FAMILY )) )
+ eFamily = static_cast<SfxStyleFamily>(pFamItem->GetValue());
+ else if ( pArgs && (pFamilyNameItem = pArgs->GetItemIfSet( SID_STYLE_FAMILYNAME )) )
{
- OUString sFamily = static_cast<const SfxStringItem*>(pFamItem)->GetValue();
+ OUString sFamily = pFamilyNameItem->GetValue();
if (sFamily == "CellStyles")
eFamily = SfxStyleFamily::Para;
else if (sFamily == "PageStyles")
@@ -379,11 +380,10 @@ void ScFormatShell::ExecuteStyle( SfxRequest& rReq )
if (pArgs && SfxItemState::SET == pArgs->GetItemState( nSlotId, true, &pNameItem ))
aStyleName = static_cast<const SfxStringItem*>(pNameItem)->GetValue();
- const SfxPoolItem* pRefItem=nullptr;
- if (pArgs && SfxItemState::SET == pArgs->GetItemState( SID_STYLE_REFERENCE, true, &pRefItem ))
+ const SfxStringItem* pRefItem=nullptr;
+ if (pArgs && (pRefItem = pArgs->GetItemIfSet( SID_STYLE_REFERENCE )))
{
- if(pRefItem!=nullptr)
- aRefName = static_cast<const SfxStringItem*>(pRefItem)->GetValue();
+ aRefName = pRefItem->GetValue();
}
pStyleSheet = &(pStylePool->Make( aStyleName, eFamily,
@@ -798,13 +798,11 @@ void ScFormatShell::ExecuteStyle( SfxRequest& rReq )
{
SfxItemSet& rSet = pStyleSheet->GetItemSet();
- const SfxPoolItem* pItem;
- if ( rSet.GetItemState( ATTR_VALUE_FORMAT,
- false, &pItem ) == SfxItemState::SET )
+ if ( const SfxUInt32Item* pItem = rSet.GetItemIfSet( ATTR_VALUE_FORMAT,
+ false ) )
{
// Produce and format NumberFormat Value from Value and Language
- sal_uLong nFormat =
- static_cast<const SfxUInt32Item*>(pItem)->GetValue();
+ sal_uLong nFormat = pItem->GetValue();
LanguageType eLang =
rSet.Get(ATTR_LANGUAGE_FORMAT ).GetLanguage();
sal_uLong nLangFormat = rDoc.GetFormatTable()->
@@ -960,9 +958,9 @@ void ScFormatShell::ExecuteStyle( SfxRequest& rReq )
const OUString& rName = static_cast<const SfxStringItem*>(pItem)->GetValue();
SfxClassificationHelper aHelper(pDocSh->getDocProperties());
auto eType = SfxClassificationPolicyType::IntellectualProperty;
- if (pArgs->GetItemState(SID_TYPE_NAME, false, &pItem) == SfxItemState::SET)
+ if (const SfxStringItem* pNameItem = pArgs->GetItemIfSet(SID_TYPE_NAME, false))
{
- const OUString& rType = static_cast<const SfxStringItem*>(pItem)->GetValue();
+ const OUString& rType = pNameItem->GetValue();
eType = SfxClassificationHelper::stringToPolicyType(rType);
}
aHelper.SetBACName(rName, eType);
@@ -1227,8 +1225,7 @@ void ScFormatShell::ExecuteNumFormat( SfxRequest& rReq )
case SID_ATTR_NUMBERFORMAT_VALUE:
if ( pReqArgs )
{
- const SfxPoolItem* pItem;
- if ( pReqArgs->GetItemState( ATTR_VALUE_FORMAT, true, &pItem ) == SfxItemState::SET )
+ if ( const SfxUInt32Item* pItem = pReqArgs->GetItemIfSet( ATTR_VALUE_FORMAT ) )
{
// We have to accomplish this using ApplyAttributes()
// because we also need the language information to be
@@ -1538,20 +1535,17 @@ void ScFormatShell::ExecuteTextAttr( SfxRequest& rReq )
*/
const SfxItemSet& rAttrSet = pTabViewShell->GetSelectionPattern()->GetItemSet();
- const SfxPoolItem* pItem = nullptr;
- const SvxHorJustifyItem* pHorJustify = nullptr;
- const SvxVerJustifyItem* pVerJustify = nullptr;
+ const SvxHorJustifyItem* pHorJustify = rAttrSet.GetItemIfSet(ATTR_HOR_JUSTIFY);
+ const SvxVerJustifyItem* pVerJustify = rAttrSet.GetItemIfSet(ATTR_VER_JUSTIFY );
SvxCellHorJustify eHorJustify = SvxCellHorJustify::Standard;
SvxCellVerJustify eVerJustify = SvxCellVerJustify::Standard;
- if (rAttrSet.GetItemState(ATTR_HOR_JUSTIFY, true,&pItem ) == SfxItemState::SET)
+ if (pHorJustify)
{
- pHorJustify = static_cast<const SvxHorJustifyItem*>(pItem);
eHorJustify = pHorJustify->GetValue();
}
- if (rAttrSet.GetItemState(ATTR_VER_JUSTIFY, true,&pItem ) == SfxItemState::SET)
+ if (pVerJustify)
{
- pVerJustify = static_cast<const SvxVerJustifyItem*>(pItem);
eVerJustify = pVerJustify->GetValue();
}
@@ -1637,12 +1631,12 @@ namespace
{
bool lcl_getColorFromStr(const SfxItemSet *pArgs, Color &rColor)
{
- const SfxPoolItem* pColorStringItem = nullptr;
+ const SfxStringItem* pColorStringItem = nullptr;
- if (pArgs && SfxItemState::SET == pArgs->GetItemState(SID_ATTR_COLOR_STR, false, &pColorStringItem) && pColorStringItem)
+ if (pArgs && (pColorStringItem = pArgs->GetItemIfSet(SID_ATTR_COLOR_STR, false)))
{
OUString sColor;
- sColor = static_cast<const SfxStringItem*>(pColorStringItem)->GetValue();
+ sColor = pColorStringItem->GetValue();
if (sColor == "transparent")
rColor = COL_TRANSPARENT;
@@ -1907,17 +1901,15 @@ void ScFormatShell::ExecuteAttr( SfxRequest& rReq )
Get( ATTR_BORDER );
// Evaluate border items from controller:
- const SfxPoolItem* pItem = nullptr;
- if ( pNewAttrs->GetItemState( ATTR_BORDER, true, &pItem )
- == SfxItemState::SET )
+ if ( const SvxBoxItem* pBoxItem = pNewAttrs->GetItemIfSet( ATTR_BORDER ) )
{
// The SvxFrameToolBoxControl toolbox controller uses a default
// SvxBorderLine (all widths 0) to mark the lines that should be set.
// Macro recording uses a SvxBoxItem with the real values (OutWidth > 0)
// or NULL pointers for no lines.
// -> Substitute existing lines with pDefLine only if widths are 0.
- SvxBoxItem aBoxItem ( *static_cast<const SvxBoxItem*>(pItem ));
+ SvxBoxItem aBoxItem ( *pBoxItem );
if ( aBoxItem.GetTop() && aBoxItem.GetTop()->GetOutWidth() == 0 )
aBoxItem.SetLine( pDefLine, SvxBoxItemLine::TOP );
if ( aBoxItem.GetBottom() && aBoxItem.GetBottom()->GetOutWidth() == 0 )
@@ -1930,10 +1922,9 @@ void ScFormatShell::ExecuteAttr( SfxRequest& rReq )
rReq.AppendItem( aBoxItem );
}
- if ( pNewAttrs->GetItemState( ATTR_BORDER_INNER, true, &pItem )
- == SfxItemState::SET )
+ if ( const SvxBoxInfoItem* pBoxInfoItem = pNewAttrs->GetItemIfSet( ATTR_BORDER_INNER ) )
{
- SvxBoxInfoItem aBoxInfoItem( *static_cast<const SvxBoxInfoItem*>(pItem) );
+ SvxBoxInfoItem aBoxInfoItem( *pBoxInfoItem );
if ( aBoxInfoItem.GetHori() && aBoxInfoItem.GetHori()->GetOutWidth() == 0 )
aBoxInfoItem.SetLine( pDefLine, SvxBoxInfoItemLine::HORI );
if ( aBoxInfoItem.GetVert() && aBoxInfoItem.GetVert()->GetOutWidth() == 0 )
@@ -1960,11 +1951,10 @@ void ScFormatShell::ExecuteAttr( SfxRequest& rReq )
const ScPatternAttr* pOldAttrs = pTabViewShell->GetSelectionPattern();
SfxItemSet aOldSet(pOldAttrs->GetItemSet());
SfxItemSet aNewSet(pOldAttrs->GetItemSet());
- const SfxPoolItem* pItem = nullptr;
if(SID_ATTR_BORDER_DIAG_TLBR == nSlot)
{
- if(SfxItemState::SET == pNewAttrs->GetItemState(ATTR_BORDER_TLBR, true, &pItem))
+ if(SfxItemState::SET == pNewAttrs->GetItemState(ATTR_BORDER_TLBR))
{
SvxLineItem aItem(ATTR_BORDER_TLBR);
aItem.SetLine(pNewAttrs->Get(ATTR_BORDER_TLBR).GetLine());
@@ -1975,7 +1965,7 @@ void ScFormatShell::ExecuteAttr( SfxRequest& rReq )
}
else // if( nSlot == SID_ATTR_BORDER_DIAG_BLTR )
{
- if(SfxItemState::SET == pNewAttrs->GetItemState(ATTR_BORDER_BLTR, true, &pItem ))
+ if(SfxItemState::SET == pNewAttrs->GetItemState(ATTR_BORDER_BLTR ))
{
SvxLineItem aItem(ATTR_BORDER_BLTR);
aItem.SetLine(pNewAttrs->Get(ATTR_BORDER_BLTR).GetLine());
diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx
index ba999ad98580..ab8e08c9d06f 100644
--- a/sc/source/ui/view/output2.cxx
+++ b/sc/source/ui/view/output2.cxx
@@ -1706,13 +1706,12 @@ tools::Rectangle ScOutputData::LayoutStrings(bool bPixelToLogic, bool bPaint, co
}
else if ( SfxItemSet* pFontSet = mpDoc->GetPreviewFont( nCellX, nCellY, nTab ) )
{
- const SfxPoolItem* pItem;
- if ( pFontSet->GetItemState( ATTR_FONT, true, &pItem ) == SfxItemState::SET )
- pAltPattern->GetItemSet().Put( static_cast<const SvxFontItem&>(*pItem) );
- if ( pFontSet->GetItemState( ATTR_CJK_FONT, true, &pItem ) == SfxItemState::SET )
- pAltPattern->GetItemSet().Put( static_cast<const SvxFontItem&>(*pItem) );
- if ( pFontSet->GetItemState( ATTR_CTL_FONT, true, &pItem ) == SfxItemState::SET )
- pAltPattern->GetItemSet().Put( static_cast<const SvxFontItem&>(*pItem) );
+ if ( const SvxFontItem* pItem = pFontSet->GetItemIfSet( ATTR_FONT ) )
+ pAltPattern->GetItemSet().Put( *pItem );
+ if ( const SvxFontItem* pItem = pFontSet->GetItemIfSet( ATTR_CJK_FONT ) )
+ pAltPattern->GetItemSet().Put( *pItem );
+ if ( const SvxFontItem* pItem = pFontSet->GetItemIfSet( ATTR_CTL_FONT ) )
+ pAltPattern->GetItemSet().Put( *pItem );
}
pPattern = pAltPattern;
}
@@ -2472,18 +2471,17 @@ void ScOutputData::DrawEditParam::setPatternToEngine(bool bUseStyleColor)
mpPattern->FillEditItemSet( pSet.get(), mpCondSet );
if ( mpPreviewFontSet )
{
- const SfxPoolItem* pItem;
- if ( mpPreviewFontSet->GetItemState( ATTR_FONT, true, &pItem ) == SfxItemState::SET )
+ if ( const SvxFontItem* pItem = mpPreviewFontSet->GetItemIfSet( ATTR_FONT ) )
{
// tdf#125054 adapt WhichID
pSet->Put(*pItem, EE_CHAR_FONTINFO);
}
- if ( mpPreviewFontSet->GetItemState( ATTR_CJK_FONT, true, &pItem ) == SfxItemState::SET )
+ if ( const SvxFontItem* pItem = mpPreviewFontSet->GetItemIfSet( ATTR_CJK_FONT ) )
{
// tdf#125054 adapt WhichID
pSet->Put(*pItem, EE_CHAR_FONTINFO_CJK);
}
- if ( mpPreviewFontSet->GetItemState( ATTR_CTL_FONT, true, &pItem ) == SfxItemState::SET )
+ if ( const SvxFontItem* pItem = mpPreviewFontSet->GetItemIfSet( ATTR_CTL_FONT ) )
{
// tdf#125054 adapt WhichID
pSet->Put(*pItem, EE_CHAR_FONTINFO_CTL);
diff --git a/sc/source/ui/view/preview.cxx b/sc/source/ui/view/preview.cxx
index 5109b710b5fc..a122544f1110 100644
--- a/sc/source/ui/view/preview.cxx
+++ b/sc/source/ui/view/preview.cxx
@@ -1177,10 +1177,9 @@ void ScPreview::MouseButtonUp( const MouseEvent& rMEvt )
}
else if( bHeaderRulerMove && bHeaderRulerChange )
{
- const SfxPoolItem* pItem = nullptr;
- if ( rStyleSet.GetItemState( ATTR_PAGE_HEADERSET, false, &pItem ) == SfxItemState::SET )
+ if ( const SvxSetItem* pSetItem = rStyleSet.GetItemIfSet( ATTR_PAGE_HEADERSET, false ) )
{
- const SfxItemSet& rHeaderSet = static_cast<const SvxSetItem*>(pItem)->GetItemSet();
+ const SfxItemSet& rHeaderSet = pSetItem->GetItemSet();
Size aHeaderSize = rHeaderSet.Get(ATTR_PAGE_SIZE).GetSize();
aHeaderSize.setHeight(o3tl::convert( aButtonUpPt.Y(), o3tl::Length::mm100, o3tl::Length::twip) + o3tl::convert(aOffset.Y(), o3tl::Length::mm100, o3tl::Length::twip) - aULItem.GetUpper());
aHeaderSize.setHeight( aHeaderSize.Height() * 100 / mnScale );
@@ -1192,10 +1191,9 @@ void ScPreview::MouseButtonUp( const MouseEvent& rMEvt )
}
else if( bFooterRulerMove && bFooterRulerChange )
{
- const SfxPoolItem* pItem = nullptr;
- if( rStyleSet.GetItemState( ATTR_PAGE_FOOTERSET, false, &pItem ) == SfxItemState::SET )
+ if( const SvxSetItem* pSetItem = rStyleSet.GetItemIfSet( ATTR_PAGE_FOOTERSET, false ) )
{
- const SfxItemSet& rFooterSet = static_cast<const SvxSetItem*>(pItem)->GetItemSet();
+ const SfxItemSet& rFooterSet = pSetItem->GetItemSet();
Size aFooterSize = rFooterSet.Get(ATTR_PAGE_SIZE).GetSize();
aFooterSize.setHeight(nHeight - o3tl::convert(aButtonUpPt.Y(), o3tl::Length::mm100, o3tl::Length::twip) - o3tl::convert(aOffset.Y(), o3tl::Length::mm100, o3tl::Length::twip) - aULItem.GetLower());
aFooterSize.setHeight( aFooterSize.Height() * 100 / mnScale );
diff --git a/sc/source/ui/view/prevwsh.cxx b/sc/source/ui/view/prevwsh.cxx
index 58026e22926e..7604fadb0882 100644
--- a/sc/source/ui/view/prevwsh.cxx
+++ b/sc/source/ui/view/prevwsh.cxx
@@ -705,11 +705,11 @@ void ScPreviewShell::Execute( SfxRequest& rReq )
break;
case SID_ATTR_ZOOMSLIDER:
{
- const SfxPoolItem* pItem;
+ const SvxZoomSliderItem* pItem;
eZoom = SvxZoomType::PERCENT;
- if( pReqArgs && SfxItemState::SET == pReqArgs->GetItemState( SID_ATTR_ZOOMSLIDER, true, &pItem ) )
+ if( pReqArgs && (pItem = pReqArgs->GetItemIfSet( SID_ATTR_ZOOMSLIDER )) )
{
- const sal_uInt16 nCurrentZoom = static_cast<const SvxZoomSliderItem*>(pItem)->GetValue();
+ const sal_uInt16 nCurrentZoom = pItem->GetValue();
if( nCurrentZoom )
{
pPreview->SetZoom( nCurrentZoom );
@@ -720,16 +720,16 @@ void ScPreviewShell::Execute( SfxRequest& rReq )
break;
case SID_PREVIEW_SCALINGFACTOR:
{
- const SfxPoolItem* pItem;
+ const SvxZoomSliderItem* pItem;
SCTAB nTab = pPreview->GetTab();
OUString aOldName = pDocShell->GetDocument().GetPageStyle( pPreview->GetTab() );
ScStyleSheetPool* pStylePool = pDocShell->GetDocument().GetStyleSheetPool();
SfxStyleSheetBase* pStyleSheet = pStylePool->Find( aOldName, SfxStyleFamily::Page );
OSL_ENSURE( pStyleSheet, "PageStyle not found! :-/" );
- if ( pReqArgs && pStyleSheet && SfxItemState::SET == pReqArgs->GetItemState( SID_PREVIEW_SCALINGFACTOR, true, &pItem ) )
+ if ( pReqArgs && pStyleSheet && (pItem = pReqArgs->GetItemIfSet( SID_PREVIEW_SCALINGFACTOR )) )
{
- const sal_uInt16 nCurrentZoom = static_cast<const SvxZoomSliderItem *>(pItem)->GetValue();
+ const sal_uInt16 nCurrentZoom = pItem->GetValue();
SfxItemSet& rSet = pStyleSheet->GetItemSet();
rSet.Put( SfxUInt16Item( ATTR_PAGE_SCALE, nCurrentZoom ) );
ScPrintFunc aPrintFunc( pDocShell, pDocShell->GetPrinter(), nTab );
diff --git a/sc/source/ui/view/printfun.cxx b/sc/source/ui/view/printfun.cxx
index f01892b1818b..d0fdb87edc12 100644
--- a/sc/source/ui/view/printfun.cxx
+++ b/sc/source/ui/view/printfun.cxx
@@ -896,10 +896,8 @@ void ScPrintFunc::InitParam( const ScPrintOptions* pOptions )
aHdr.pRight = &pParamSet->Get(ATTR_PAGE_HEADERRIGHT);
aHdr.pFirst = &pParamSet->Get(ATTR_PAGE_HEADERFIRST);
- const SvxSetItem* pHeaderSetItem;
const SfxItemSet* pHeaderSet = nullptr;
- if ( pParamSet->GetItemState( ATTR_PAGE_HEADERSET, false,
- reinterpret_cast<const SfxPoolItem**>(&pHeaderSetItem) ) == SfxItemState::SET )
+ if ( const SvxSetItem* pHeaderSetItem = pParamSet->GetItemIfSet( ATTR_PAGE_HEADERSET, false ) )
{
pHeaderSet = &pHeaderSetItem->GetItemSet();
// Headline has space below
@@ -913,10 +911,8 @@ void ScPrintFunc::InitParam( const ScPrintOptions* pOptions )
aFtr.pRight = &pParamSet->Get(ATTR_PAGE_FOOTERRIGHT);
aFtr.pFirst = &pParamSet->Get(ATTR_PAGE_FOOTERFIRST);
- const SvxSetItem* pFooterSetItem;
const SfxItemSet* pFooterSet = nullptr;
- if ( pParamSet->GetItemState( ATTR_PAGE_FOOTERSET, false,
- reinterpret_cast<const SfxPoolItem**>(&pFooterSetItem) ) == SfxItemState::SET )
+ if ( const SvxSetItem* pFooterSetItem = pParamSet->GetItemIfSet( ATTR_PAGE_FOOTERSET, false ) )
{
pFooterSet = &pFooterSetItem->GetItemSet();
// Footline has space above
diff --git a/sc/source/ui/view/tabvwsha.cxx b/sc/source/ui/view/tabvwsha.cxx
index 06e8e0afe218..734ccd915941 100644
--- a/sc/source/ui/view/tabvwsha.cxx
+++ b/sc/source/ui/view/tabvwsha.cxx
@@ -589,11 +589,9 @@ void ScTabViewShell::ExecuteCellFormatDlg(SfxRequest& rReq, const OString &rName
if ( nResult == RET_OK )
{
const SfxItemSet* pOutSet = pDlg->GetOutputItemSet();
-
- const SfxPoolItem* pItem=nullptr;
- if(pOutSet->GetItemState(SID_ATTR_NUMBERFORMAT_INFO,true,&pItem)==SfxItemState::SET)
+ if(const SvxNumberInfoItem* pItem = pOutSet->GetItemIfSet(SID_ATTR_NUMBERFORMAT_INFO))
{
- UpdateNumberFormatter(static_cast<const SvxNumberInfoItem&>(*pItem));
+ UpdateNumberFormatter(*pItem);
}
ApplyAttributes(pOutSet, pOldSet.get());
diff --git a/sc/source/ui/view/tabvwshe.cxx b/sc/source/ui/view/tabvwshe.cxx
index ab3f0c2f18eb..da03923d46e2 100644
--- a/sc/source/ui/view/tabvwshe.cxx
+++ b/sc/source/ui/view/tabvwshe.cxx
@@ -258,12 +258,10 @@ void ScTabViewShell::ExecSearch( SfxRequest& rReq )
{
case FID_SEARCH_NOW:
{
+ const SvxSearchItem* pSearchItem;
if ( pReqArgs &&
- SfxItemState::SET == pReqArgs->GetItemState(SID_SEARCH_ITEM, false, &pItem) )
+ (pSearchItem = pReqArgs->GetItemIfSet(SID_SEARCH_ITEM, false)) )
{
- assert( dynamic_cast<const SvxSearchItem*>( pItem) && "wrong Item" );
- const SvxSearchItem* pSearchItem = static_cast<const SvxSearchItem*>(pItem);
-
ScGlobal::SetSearchItem( *pSearchItem );
SearchAndReplace( pSearchItem, true, rReq.IsAPI() );
rReq.Done();
@@ -272,18 +270,20 @@ void ScTabViewShell::ExecSearch( SfxRequest& rReq )
break;
case SID_SEARCH_ITEM:
- if (pReqArgs && SfxItemState::SET ==
- pReqArgs->GetItemState(SID_SEARCH_ITEM, false, &pItem))
+ {
+ const SvxSearchItem* pSearchItem;
+ if (pReqArgs && (pSearchItem =
+ pReqArgs->GetItemIfSet(SID_SEARCH_ITEM, false)))
{
// remember search item
- assert( dynamic_cast<const SvxSearchItem*>( pItem) && "wrong Item" );
- ScGlobal::SetSearchItem( *static_cast<const SvxSearchItem*>(pItem ));
+ ScGlobal::SetSearchItem( *pSearchItem );
}
else
{
OSL_FAIL("SID_SEARCH_ITEM without Parameter");
}
break;
+ }
case FID_SEARCH:
case FID_REPLACE:
case FID_REPLACE_ALL: