chart2/source/controller/dialogs/res_DataLabel.cxx                  |   57 
++----
 chart2/source/controller/dialogs/res_ErrorBar.cxx                   |   10 -
 chart2/source/controller/dialogs/res_LegendPosition.cxx             |   11 -
 chart2/source/controller/dialogs/res_Trendline.cxx                  |   39 ++--
 chart2/source/controller/dialogs/tp_AxisLabel.cxx                   |    9 -
 chart2/source/controller/dialogs/tp_AxisPositions.cxx               |   36 ++--
 chart2/source/controller/dialogs/tp_DataPointOption.cxx             |    8 
 chart2/source/controller/dialogs/tp_LegendPosition.cxx              |    9 -
 chart2/source/controller/dialogs/tp_PointGeometry.cxx               |    6 
 chart2/source/controller/dialogs/tp_PolarOptions.cxx                |   16 -
 chart2/source/controller/dialogs/tp_Scale.cxx                       |   83 
++++------
 chart2/source/controller/dialogs/tp_SeriesToAxis.cxx                |   44 
++---
 chart2/source/controller/dialogs/tp_TitleRotation.cxx               |    4 
 chart2/source/controller/itemsetwrapper/LegendItemConverter.cxx     |   15 -
 chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx |   10 -
 chart2/source/controller/main/ChartController_Position.cxx          |   21 +-
 chart2/source/controller/main/ChartController_TextEdit.cxx          |    7 
 17 files changed, 177 insertions(+), 208 deletions(-)

New commits:
commit 3e23161baf5a529d1006b320e9044e436827c764
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Mon Feb 28 10:32:24 2022 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Mon Feb 28 11:00:05 2022 +0100

    use SfxItemSet::GetItemIfSet in chart2
    
    Change-Id: I1e5eeb8b29d2139a9c3e72c645bae9a8fb5dffff
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130664
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/chart2/source/controller/dialogs/res_DataLabel.cxx 
b/chart2/source/controller/dialogs/res_DataLabel.cxx
index 5630e94baba2..3c6950e8ef0e 100644
--- a/chart2/source/controller/dialogs/res_DataLabel.cxx
+++ b/chart2/source/controller/dialogs/res_DataLabel.cxx
@@ -46,39 +46,28 @@ namespace
 
 const std::u16string_view our_aLBEntryMap[] = {u" ", u", ", u"; ", u"\n", u". 
"};
 
-bool lcl_ReadNumberFormatFromItemSet( const SfxItemSet& rSet, sal_uInt16 
nValueWhich, sal_uInt16 nSourceFormatWhich, sal_uInt32& rnFormatKeyOut, bool& 
rbSourceFormatOut, bool& rbSourceFormatMixedStateOut )
+bool lcl_ReadNumberFormatFromItemSet( const SfxItemSet& rSet, 
TypedWhichId<SfxUInt32Item> nValueWhich, TypedWhichId<SfxBoolItem> 
nSourceFormatWhich, sal_uInt32& rnFormatKeyOut, bool& rbSourceFormatOut, bool& 
rbSourceFormatMixedStateOut )
 {
     bool bSet = false;
-    const SfxPoolItem *pItem1 = nullptr;
-    if( rSet.GetItemState( nValueWhich, true, &pItem1 ) == SfxItemState::SET )
+    if( const SfxUInt32Item* pNumItem = rSet.GetItemIfSet( nValueWhich ) )
     {
-        const SfxUInt32Item * pNumItem = dynamic_cast< const SfxUInt32Item * 
>( pItem1 );
-        if( pNumItem )
-        {
-            rnFormatKeyOut = pNumItem->GetValue();
-            bSet = true;
-        }
+        rnFormatKeyOut = pNumItem->GetValue();
+        bSet = true;
     }
 
     rbSourceFormatMixedStateOut=true;
-    const SfxPoolItem *pItem2 = nullptr;
-    if( rSet.GetItemState( nSourceFormatWhich, true, &pItem2 ) == 
SfxItemState::SET )
+    if( const SfxBoolItem * pBoolItem = rSet.GetItemIfSet( nSourceFormatWhich 
) )
     {
-        const SfxBoolItem * pBoolItem = dynamic_cast< const SfxBoolItem * >( 
pItem2 );
-        if( pBoolItem )
-        {
-            rbSourceFormatOut = pBoolItem->GetValue();
-            rbSourceFormatMixedStateOut=false;
-        }
+        rbSourceFormatOut = pBoolItem->GetValue();
+        rbSourceFormatMixedStateOut=false;
     }
     return bSet;
 }
 
-void lcl_setBoolItemToCheckBox(const SfxItemSet& rInAttrs, sal_uInt16 
nWhichId, weld::CheckButton& rCheckbox)
+void lcl_setBoolItemToCheckBox(const SfxItemSet& rInAttrs, 
TypedWhichId<SfxBoolItem> nWhichId, weld::CheckButton& rCheckbox)
 {
-    const SfxPoolItem *pPoolItem = nullptr;
-    if( rInAttrs.GetItemState(nWhichId, true, &pPoolItem) == SfxItemState::SET 
)
-        rCheckbox.set_active(static_cast<const 
SfxBoolItem*>(pPoolItem)->GetValue());
+    if( const SfxBoolItem* pPoolItem = rInAttrs.GetItemIfSet(nWhichId) )
+        rCheckbox.set_active(pPoolItem->GetValue());
     else
         rCheckbox.set_state(TRISTATE_INDET);
 }
@@ -126,9 +115,8 @@ DataLabelResources::DataLabelResources(weld::Builder* 
pBuilder, weld::Window* pP
 
 
     std::vector< sal_Int32 > aAvailablePlacementList;
-    const SfxPoolItem *pPoolItem = nullptr;
-    if( rInAttrs.GetItemState(SCHATTR_DATADESCR_AVAILABLE_PLACEMENTS, true, 
&pPoolItem) == SfxItemState::SET )
-        aAvailablePlacementList = static_cast<const 
SfxIntegerListItem*>(pPoolItem)->GetList();
+    if( const SfxIntegerListItem* pPlacementsItem = 
rInAttrs.GetItemIfSet(SCHATTR_DATADESCR_AVAILABLE_PLACEMENTS) )
+        aAvailablePlacementList = pPlacementsItem->GetList();
 
     m_xLB_LabelPlacement->clear();
     for( size_t nN=0; nN<aAvailablePlacementList.size(); ++nN )
@@ -154,9 +142,9 @@ DataLabelResources::DataLabelResources(weld::Builder* 
pBuilder, weld::Window* pP
     m_bNumberFormatMixedState = !lcl_ReadNumberFormatFromItemSet( rInAttrs, 
SID_ATTR_NUMBERFORMAT_VALUE, SID_ATTR_NUMBERFORMAT_SOURCE, 
m_nNumberFormatForValue, m_bSourceFormatForValue, m_bSourceFormatMixedState );
     m_bPercentFormatMixedState = !lcl_ReadNumberFormatFromItemSet( rInAttrs, 
SCHATTR_PERCENT_NUMBERFORMAT_VALUE, SCHATTR_PERCENT_NUMBERFORMAT_SOURCE, 
m_nNumberFormatForPercent, m_bSourceFormatForPercent , 
m_bPercentSourceMixedState);
 
-    if( rInAttrs.GetItemState(SCHATTR_DATADESCR_NO_PERCENTVALUE, true, 
&pPoolItem) == SfxItemState::SET )
+    if( const SfxBoolItem* pNoPercentValueItem = 
rInAttrs.GetItemIfSet(SCHATTR_DATADESCR_NO_PERCENTVALUE) )
     {
-        bool bForbidPercentValue = rInAttrs.Get( 
SCHATTR_DATADESCR_NO_PERCENTVALUE ).GetValue();
+        bool bForbidPercentValue = pNoPercentValueItem->GetValue();
         if( bForbidPercentValue )
             m_xCBPercent->set_sensitive(false);
     }
@@ -331,19 +319,18 @@ void DataLabelResources::Reset(const SfxItemSet& rInAttrs)
     m_bNumberFormatMixedState = !lcl_ReadNumberFormatFromItemSet( rInAttrs, 
SID_ATTR_NUMBERFORMAT_VALUE, SID_ATTR_NUMBERFORMAT_SOURCE, 
m_nNumberFormatForValue, m_bSourceFormatForValue, m_bSourceFormatMixedState );
     m_bPercentFormatMixedState = !lcl_ReadNumberFormatFromItemSet( rInAttrs, 
SCHATTR_PERCENT_NUMBERFORMAT_VALUE, SCHATTR_PERCENT_NUMBERFORMAT_SOURCE, 
m_nNumberFormatForPercent, m_bSourceFormatForPercent ,  
m_bPercentSourceMixedState);
 
-    const SfxPoolItem *pPoolItem = nullptr;
-    if( rInAttrs.GetItemState(SCHATTR_DATADESCR_SEPARATOR, true, &pPoolItem) 
== SfxItemState::SET )
+    if( const SfxStringItem* pSeparatorItem = 
rInAttrs.GetItemIfSet(SCHATTR_DATADESCR_SEPARATOR) )
        for(size_t i=0; i < std::size(our_aLBEntryMap); ++i )
        {
-          if( our_aLBEntryMap[i] == static_cast<const 
SfxStringItem*>(pPoolItem)->GetValue())
+          if( our_aLBEntryMap[i] == pSeparatorItem->GetValue())
               m_xLB_Separator->set_active( i );
        }
     else
         m_xLB_Separator->set_active( 0 );
 
-    if( rInAttrs.GetItemState(SCHATTR_DATADESCR_PLACEMENT, true, &pPoolItem) 
== SfxItemState::SET )
+    if( const SfxInt32Item* pPlacementItem = 
rInAttrs.GetItemIfSet(SCHATTR_DATADESCR_PLACEMENT) )
     {
-        sal_Int32 nPlacement = static_cast<const 
SfxInt32Item*>(pPoolItem)->GetValue();
+        sal_Int32 nPlacement = pPlacementItem->GetValue();
         std::map< sal_Int32, sal_uInt16 >::const_iterator aIt( 
m_aPlacementToListBoxMap.find(nPlacement) );
         if(aIt!=m_aPlacementToListBoxMap.end())
         {
@@ -356,12 +343,12 @@ void DataLabelResources::Reset(const SfxItemSet& rInAttrs)
     else
         m_xLB_LabelPlacement->set_active(-1);
 
-    if( rInAttrs.GetItemState(EE_PARA_WRITINGDIR, true, &pPoolItem ) == 
SfxItemState::SET )
-        m_xLB_TextDirection->set_active_id( static_cast<const 
SvxFrameDirectionItem*>(pPoolItem)->GetValue() );
+    if( const SvxFrameDirectionItem* pDirectionItem = 
rInAttrs.GetItemIfSet(EE_PARA_WRITINGDIR) )
+        m_xLB_TextDirection->set_active_id( pDirectionItem->GetValue() );
 
-    if( rInAttrs.GetItemState( SCHATTR_TEXT_DEGREES, true, &pPoolItem ) == 
SfxItemState::SET )
+    if( const SdrAngleItem* pAngleItem = rInAttrs.GetItemIfSet( 
SCHATTR_TEXT_DEGREES ) )
     {
-        Degree100 nDegrees = static_cast< const SdrAngleItem * >( pPoolItem 
)->GetValue();
+        Degree100 nDegrees = pAngleItem->GetValue();
         m_xDC_Dial->SetRotation( nDegrees );
     }
     else
diff --git a/chart2/source/controller/dialogs/res_ErrorBar.cxx 
b/chart2/source/controller/dialogs/res_ErrorBar.cxx
index 1e5078a301fc..b0173dec46ba 100644
--- a/chart2/source/controller/dialogs/res_ErrorBar.cxx
+++ b/chart2/source/controller/dialogs/res_ErrorBar.cxx
@@ -516,16 +516,14 @@ void ErrorBarResources::Reset(const SfxItemSet& rInAttrs)
     }
 
     // parameters
-    aState = rInAttrs.GetItemState( SCHATTR_STAT_CONSTPLUS, true, &pPoolItem );
-    if( aState == SfxItemState::SET )
+    if( const SvxDoubleItem* pDoubleItem = rInAttrs.GetItemIfSet( 
SCHATTR_STAT_CONSTPLUS ) )
     {
-        m_fPlusValue = static_cast<const 
SvxDoubleItem*>(pPoolItem)->GetValue();
+        m_fPlusValue = pDoubleItem->GetValue();
     }
 
-    aState = rInAttrs.GetItemState( SCHATTR_STAT_CONSTMINUS, true, &pPoolItem 
);
-    if( aState == SfxItemState::SET )
+    if( const SvxDoubleItem* pStatItem = rInAttrs.GetItemIfSet( 
SCHATTR_STAT_CONSTMINUS ) )
     {
-        m_fMinusValue = static_cast<const 
SvxDoubleItem*>(pPoolItem)->GetValue();
+        m_fMinusValue = pStatItem->GetValue();
 
         if( m_eErrorKind != SvxChartKindError::Range &&
             m_fPlusValue == m_fMinusValue )
diff --git a/chart2/source/controller/dialogs/res_LegendPosition.cxx 
b/chart2/source/controller/dialogs/res_LegendPosition.cxx
index 0d16fba16df1..c461d20c5062 100644
--- a/chart2/source/controller/dialogs/res_LegendPosition.cxx
+++ b/chart2/source/controller/dialogs/res_LegendPosition.cxx
@@ -179,10 +179,9 @@ void LegendPositionResources::PositionEnable()
 
 void LegendPositionResources::initFromItemSet( const SfxItemSet& rInAttrs )
 {
-    const SfxPoolItem* pPoolItem = nullptr;
-    if( rInAttrs.GetItemState( SCHATTR_LEGEND_POS, true, &pPoolItem ) == 
SfxItemState::SET )
+    if( const SfxInt32Item* pPosItem = rInAttrs.GetItemIfSet( 
SCHATTR_LEGEND_POS ) )
     {
-        chart2::LegendPosition nLegendPosition = 
static_cast<chart2::LegendPosition>(static_cast<const 
SfxInt32Item*>(pPoolItem)->GetValue());
+        chart2::LegendPosition nLegendPosition = 
static_cast<chart2::LegendPosition>(pPosItem->GetValue());
         switch( nLegendPosition )
         {
             case chart2::LegendPosition_LINE_START:
@@ -202,10 +201,10 @@ void LegendPositionResources::initFromItemSet( const 
SfxItemSet& rInAttrs )
         }
     }
 
-    if( m_xCbxShow && rInAttrs.GetItemState( SCHATTR_LEGEND_SHOW, true, 
&pPoolItem ) == SfxItemState::SET )
+    const SfxBoolItem* pShowItem;
+    if( m_xCbxShow && (pShowItem = rInAttrs.GetItemIfSet( SCHATTR_LEGEND_SHOW 
)) )
     {
-        bool bShow = static_cast< const SfxBoolItem * >( pPoolItem 
)->GetValue();
-        m_xCbxShow->set_active(bShow);
+        m_xCbxShow->set_active(pShowItem->GetValue());
     }
 }
 
diff --git a/chart2/source/controller/dialogs/res_Trendline.cxx 
b/chart2/source/controller/dialogs/res_Trendline.cxx
index ca1fe7bcfb83..647c071b1040 100644
--- a/chart2/source/controller/dialogs/res_Trendline.cxx
+++ b/chart2/source/controller/dialogs/res_Trendline.cxx
@@ -126,29 +126,27 @@ IMPL_LINK_NOARG(TrendlineResources, SelectTrendLine, 
weld::Toggleable&, void)
 
 void TrendlineResources::Reset( const SfxItemSet& rInAttrs )
 {
-    const SfxPoolItem *pPoolItem = nullptr;
-
-    if( rInAttrs.GetItemState( SCHATTR_REGRESSION_CURVE_NAME, true, &pPoolItem 
) == SfxItemState::SET )
+    if( const SfxStringItem* pCurveNameItem = rInAttrs.GetItemIfSet( 
SCHATTR_REGRESSION_CURVE_NAME ) )
     {
-        OUString aName = static_cast< const SfxStringItem* 
>(pPoolItem)->GetValue();
+        OUString aName = pCurveNameItem->GetValue();
         m_xEE_Name->set_text(aName);
     }
     else
     {
         m_xEE_Name->set_text("");
     }
-    if( rInAttrs.GetItemState( SCHATTR_REGRESSION_XNAME, true, &pPoolItem ) == 
SfxItemState::SET )
+    if( const SfxStringItem* pRegressionXNameItem = rInAttrs.GetItemIfSet( 
SCHATTR_REGRESSION_XNAME ) )
     {
-        OUString aName = static_cast< const SfxStringItem* 
>(pPoolItem)->GetValue();
+        OUString aName = pRegressionXNameItem->GetValue();
         m_xEE_XName->set_text(aName);
     }
     else
     {
         m_xEE_XName->set_text("x");
     }
-    if( rInAttrs.GetItemState( SCHATTR_REGRESSION_YNAME, true, &pPoolItem ) == 
SfxItemState::SET )
+    if( const SfxStringItem* pRegressionYNameItem = rInAttrs.GetItemIfSet( 
SCHATTR_REGRESSION_YNAME ) )
     {
-        OUString aName = static_cast< const SfxStringItem* 
>(pPoolItem)->GetValue();
+        OUString aName = pRegressionYNameItem->GetValue();
         m_xEE_YName->set_text(aName);
     }
     else
@@ -156,6 +154,7 @@ void TrendlineResources::Reset( const SfxItemSet& rInAttrs )
         m_xEE_YName->set_text("f(x)");
     }
 
+    const SfxPoolItem* pPoolItem = nullptr;
     SfxItemState aState = rInAttrs.GetItemState( SCHATTR_REGRESSION_TYPE, 
true, &pPoolItem );
     m_bTrendLineUnique = ( aState != SfxItemState::DONTCARE );
     if( aState == SfxItemState::SET )
@@ -167,9 +166,9 @@ void TrendlineResources::Reset( const SfxItemSet& rInAttrs )
         }
     }
 
-    if( rInAttrs.GetItemState( SCHATTR_REGRESSION_DEGREE, true, &pPoolItem ) 
== SfxItemState::SET )
+    if( const SfxInt32Item* pDegreeItem = rInAttrs.GetItemIfSet( 
SCHATTR_REGRESSION_DEGREE ) )
     {
-        sal_Int32 nDegree = static_cast< const SfxInt32Item * >( pPoolItem 
)->GetValue();
+        sal_Int32 nDegree = pDegreeItem->GetValue();
         m_xNF_Degree->set_value( nDegree );
     }
     else
@@ -179,9 +178,9 @@ void TrendlineResources::Reset( const SfxItemSet& rInAttrs )
 
     m_xNF_Degree->save_value();
 
-    if( rInAttrs.GetItemState( SCHATTR_REGRESSION_PERIOD, true, &pPoolItem ) 
== SfxItemState::SET )
+    if( const SfxInt32Item* pPeriodItem = rInAttrs.GetItemIfSet( 
SCHATTR_REGRESSION_PERIOD ) )
     {
-        sal_Int32 nPeriod = static_cast< const SfxInt32Item * >( pPoolItem 
)->GetValue();
+        sal_Int32 nPeriod = pPeriodItem->GetValue();
         m_xNF_Period->set_value( nPeriod );
     }
     else
@@ -192,23 +191,23 @@ void TrendlineResources::Reset( const SfxItemSet& 
rInAttrs )
     m_xNF_Period->save_value();
 
     double nValue = 0.0;
-    if( rInAttrs.GetItemState( SCHATTR_REGRESSION_EXTRAPOLATE_FORWARD, true, 
&pPoolItem ) == SfxItemState::SET )
+    if( const SvxDoubleItem* pForwardItem = rInAttrs.GetItemIfSet( 
SCHATTR_REGRESSION_EXTRAPOLATE_FORWARD ) )
     {
-        nValue = static_cast<const SvxDoubleItem*>(pPoolItem)->GetValue() ;
+        nValue = pForwardItem->GetValue() ;
     }
     lcl_setValue(*m_xFmtFld_ExtrapolateForward, nValue);
 
     nValue = 0.0;
-    if( rInAttrs.GetItemState( SCHATTR_REGRESSION_EXTRAPOLATE_BACKWARD, true, 
&pPoolItem ) == SfxItemState::SET )
+    if( const SvxDoubleItem* pBackwardItem = rInAttrs.GetItemIfSet( 
SCHATTR_REGRESSION_EXTRAPOLATE_BACKWARD ) )
     {
-        nValue = static_cast<const SvxDoubleItem*>(pPoolItem)->GetValue() ;
+        nValue = pBackwardItem->GetValue() ;
     }
     lcl_setValue(*m_xFmtFld_ExtrapolateBackward, nValue);
 
     nValue = 0.0;
-    if( rInAttrs.GetItemState( SCHATTR_REGRESSION_INTERCEPT_VALUE, true, 
&pPoolItem ) == SfxItemState::SET )
+    if( const SvxDoubleItem* pValueItem = rInAttrs.GetItemIfSet( 
SCHATTR_REGRESSION_INTERCEPT_VALUE ) )
     {
-        nValue = static_cast<const SvxDoubleItem*>(pPoolItem)->GetValue() ;
+        nValue = pValueItem->GetValue() ;
     }
     lcl_setValue(*m_xFmtFld_InterceptValue, nValue);
 
@@ -245,9 +244,9 @@ void TrendlineResources::Reset( const SfxItemSet& rInAttrs )
             m_xCB_ShowCorrelationCoeff->set_active( static_cast< const 
SfxBoolItem * >( pPoolItem )->GetValue());
     }
 
-    if( rInAttrs.GetItemState( SCHATTR_REGRESSION_MOVING_TYPE, true, 
&pPoolItem ) == SfxItemState::SET )
+    if( const SfxInt32Item* pMovingTypeItem = rInAttrs.GetItemIfSet( 
SCHATTR_REGRESSION_MOVING_TYPE ) )
     {
-        sal_Int32 nMovingType = static_cast< const SfxInt32Item * >( pPoolItem 
)->GetValue();
+        sal_Int32 nMovingType = pMovingTypeItem->GetValue();
         if (nMovingType == MovingAverageType::Prior)
             m_xCB_RegressionMovingType->set_active(0);
         else if (nMovingType == MovingAverageType::Central)
diff --git a/chart2/source/controller/dialogs/tp_AxisLabel.cxx 
b/chart2/source/controller/dialogs/tp_AxisLabel.cxx
index 1ee392238141..2f7d0b743a32 100644
--- a/chart2/source/controller/dialogs/tp_AxisLabel.cxx
+++ b/chart2/source/controller/dialogs/tp_AxisLabel.cxx
@@ -178,8 +178,8 @@ void SchAxisLabelTabPage::Reset( const SfxItemSet* rInAttrs 
)
         m_xCbStacked->set_state(TRISTATE_INDET);
     StackedToggleHdl(*m_xCbStacked);
 
-    if( rInAttrs->GetItemState( EE_PARA_WRITINGDIR, true, &pPoolItem ) == 
SfxItemState::SET )
-        m_xLbTextDirection->set_active_id( static_cast<const 
SvxFrameDirectionItem*>(pPoolItem)->GetValue() );
+    if( const SvxFrameDirectionItem* pDirectionItem = rInAttrs->GetItemIfSet( 
EE_PARA_WRITINGDIR ) )
+        m_xLbTextDirection->set_active_id( pDirectionItem->GetValue() );
 
     // Text overlap ----------
     aState = rInAttrs->GetItemState( SCHATTR_AXIS_LABEL_OVERLAP, false, 
&pPoolItem );
@@ -222,10 +222,9 @@ void SchAxisLabelTabPage::Reset( const SfxItemSet* 
rInAttrs )
     // text order ----------
     if( m_bShowStaggeringControls )
     {
-        aState = rInAttrs->GetItemState( SCHATTR_AXIS_LABEL_ORDER, false, 
&pPoolItem );
-        if( aState == SfxItemState::SET )
+        if( const SvxChartTextOrderItem* pOrderItem = rInAttrs->GetItemIfSet( 
SCHATTR_AXIS_LABEL_ORDER, false ) )
         {
-            SvxChartTextOrder eOrder = static_cast< const 
SvxChartTextOrderItem * >( pPoolItem )->GetValue();
+            SvxChartTextOrder eOrder = pOrderItem->GetValue();
 
             switch( eOrder )
             {
diff --git a/chart2/source/controller/dialogs/tp_AxisPositions.cxx 
b/chart2/source/controller/dialogs/tp_AxisPositions.cxx
index 037bc3002567..75e662fbb504 100644
--- a/chart2/source/controller/dialogs/tp_AxisPositions.cxx
+++ b/chart2/source/controller/dialogs/tp_AxisPositions.cxx
@@ -142,13 +142,12 @@ void AxisPositionsTabPage::Reset(const SfxItemSet* 
rInAttrs)
     }
 
     //fill controls
-    const SfxPoolItem *pPoolItem = nullptr;
 
     //axis line
-    if(rInAttrs->GetItemState(SCHATTR_AXIS_POSITION,true, &pPoolItem)== 
SfxItemState::SET)
+    if(SfxInt32Item const * pPositionItem = 
rInAttrs->GetItemIfSet(SCHATTR_AXIS_POSITION))
     {
         bool bZero = false;
-        sal_Int32 nPos = static_cast< const SfxInt32Item * >( pPoolItem 
)->GetValue();
+        sal_Int32 nPos = pPositionItem->GetValue();
         if(nPos==0)
         {
             //switch to value
@@ -162,11 +161,12 @@ void AxisPositionsTabPage::Reset(const SfxItemSet* 
rInAttrs)
             m_xLB_CrossesAt->set_active( nPos );
         CrossesAtSelectHdl( *m_xLB_CrossesAt );
 
-        if( rInAttrs->GetItemState(SCHATTR_AXIS_POSITION_VALUE,true, 
&pPoolItem)== SfxItemState::SET || bZero )
+        const SvxDoubleItem* pPosValueItem;
+        if( (pPosValueItem = 
rInAttrs->GetItemIfSet(SCHATTR_AXIS_POSITION_VALUE)) || bZero )
         {
             double fCrossover = 0.0;
             if( !bZero )
-                fCrossover = static_cast<const 
SvxDoubleItem*>(pPoolItem)->GetValue();
+                fCrossover = pPosValueItem->GetValue();
             if( m_bCrossingAxisIsCategoryAxis )
                 m_xED_CrossesAtCategory->set_active( 
static_cast<sal_uInt16>(::rtl::math::round(fCrossover-1.0)) );
             else
@@ -188,9 +188,10 @@ void AxisPositionsTabPage::Reset(const SfxItemSet* 
rInAttrs)
     }
 
     // shifted category position
-    if (m_bSupportCategoryPositioning && 
rInAttrs->GetItemState(SCHATTR_AXIS_SHIFTED_CATEGORY_POSITION, true, 
&pPoolItem) == SfxItemState::SET)
+    const SfxBoolItem* pCatPosItem;
+    if (m_bSupportCategoryPositioning && (pCatPosItem = 
rInAttrs->GetItemIfSet(SCHATTR_AXIS_SHIFTED_CATEGORY_POSITION)))
     {
-        if (static_cast<const SfxBoolItem*>(pPoolItem)->GetValue())
+        if (pCatPosItem->GetValue())
             m_xRB_Between->set_active(true);
         else
             m_xRB_On->set_active(true);
@@ -199,9 +200,9 @@ void AxisPositionsTabPage::Reset(const SfxItemSet* rInAttrs)
         m_xFL_Position->hide();
 
     // Labels
-    if( rInAttrs->GetItemState( SCHATTR_AXIS_LABEL_POSITION, false, &pPoolItem 
) == SfxItemState::SET )
+    if( const SfxInt32Item* pLabelPosItem = rInAttrs->GetItemIfSet( 
SCHATTR_AXIS_LABEL_POSITION, false) )
     {
-        sal_Int32 nPos = static_cast< const SfxInt32Item * >( pPoolItem 
)->GetValue();
+        sal_Int32 nPos = pLabelPosItem->GetValue();
         if( nPos < m_xLB_PlaceLabels->get_count() )
             m_xLB_PlaceLabels->set_active( nPos );
     }
@@ -211,10 +212,10 @@ void AxisPositionsTabPage::Reset(const SfxItemSet* 
rInAttrs)
 
     // Tick marks
     tools::Long nTicks = 0, nMinorTicks = 0;
-    if (rInAttrs->GetItemState(SCHATTR_AXIS_TICKS,true, &pPoolItem)== 
SfxItemState::SET)
-        nTicks = static_cast<const SfxInt32Item*>(pPoolItem)->GetValue();
-    if (rInAttrs->GetItemState(SCHATTR_AXIS_HELPTICKS,true, &pPoolItem)== 
SfxItemState::SET)
-        nMinorTicks = static_cast<const SfxInt32Item*>(pPoolItem)->GetValue();
+    if (const SfxInt32Item* pTicksItem = 
rInAttrs->GetItemIfSet(SCHATTR_AXIS_TICKS))
+        nTicks = pTicksItem->GetValue();
+    if (const SfxInt32Item* pHelpTicksItem = 
rInAttrs->GetItemIfSet(SCHATTR_AXIS_HELPTICKS))
+        nMinorTicks = pHelpTicksItem->GetValue();
 
     m_xCB_TicksInner->set_active(bool(nTicks&CHAXIS_MARK_INNER));
     m_xCB_TicksOuter->set_active(bool(nTicks&CHAXIS_MARK_OUTER));
@@ -222,9 +223,9 @@ void AxisPositionsTabPage::Reset(const SfxItemSet* rInAttrs)
     m_xCB_MinorOuter->set_active(bool(nMinorTicks&CHAXIS_MARK_OUTER));
 
     // Tick position
-    if( rInAttrs->GetItemState( SCHATTR_AXIS_MARK_POSITION, false, &pPoolItem 
) == SfxItemState::SET )
+    if( const SfxInt32Item* pMarkPosItem = rInAttrs->GetItemIfSet( 
SCHATTR_AXIS_MARK_POSITION, false) )
     {
-        sal_Int32 nPos = static_cast< const SfxInt32Item * >( pPoolItem 
)->GetValue();
+        sal_Int32 nPos = pMarkPosItem->GetValue();
         if( nPos < m_xLB_PlaceTicks->get_count() )
             m_xLB_PlaceTicks->set_active( nPos );
     }
@@ -261,10 +262,9 @@ void AxisPositionsTabPage::SetNumFormatter( 
SvNumberFormatter* pFormatter )
     rCrossFormatter.SetFormatter(m_pNumFormatter);
     rCrossFormatter.UseInputStringForFormatting();
 
-    const SfxPoolItem *pPoolItem = nullptr;
-    if( GetItemSet().GetItemState( 
SCHATTR_AXIS_CROSSING_MAIN_AXIS_NUMBERFORMAT, true, &pPoolItem ) == 
SfxItemState::SET )
+    if( const SfxUInt32Item* pNumFormatItem = 
GetItemSet().GetItemIfSet(SCHATTR_AXIS_CROSSING_MAIN_AXIS_NUMBERFORMAT) )
     {
-        sal_uLong nFmt = static_cast<const 
SfxUInt32Item*>(pPoolItem)->GetValue();
+        sal_uLong nFmt = pNumFormatItem->GetValue();
         rCrossFormatter.SetFormatKey(nFmt);
     }
 }
diff --git a/chart2/source/controller/dialogs/tp_DataPointOption.cxx 
b/chart2/source/controller/dialogs/tp_DataPointOption.cxx
index 7fb9f230ed7e..4c824287206c 100644
--- a/chart2/source/controller/dialogs/tp_DataPointOption.cxx
+++ b/chart2/source/controller/dialogs/tp_DataPointOption.cxx
@@ -53,12 +53,10 @@ bool DataPointOptionTabPage::FillItemSet(SfxItemSet* 
rOutAttrs)
 
 void DataPointOptionTabPage::Reset(const SfxItemSet* rInAttrs)
 {
-    const SfxPoolItem* pPoolItem = nullptr;
-
-    if (rInAttrs->GetItemState(SCHATTR_HIDE_DATA_POINT_LEGEND_ENTRY, true, 
&pPoolItem)
-        == SfxItemState::SET)
+    if (const SfxBoolItem* pEntryItem
+        = rInAttrs->GetItemIfSet(SCHATTR_HIDE_DATA_POINT_LEGEND_ENTRY))
     {
-        bool bVal = static_cast<const SfxBoolItem*>(pPoolItem)->GetValue();
+        bool bVal = pEntryItem->GetValue();
         m_xCBHideLegendEntry->set_active(bVal);
     }
 }
diff --git a/chart2/source/controller/dialogs/tp_LegendPosition.cxx 
b/chart2/source/controller/dialogs/tp_LegendPosition.cxx
index 04697e75efc9..00a0d54b1f51 100644
--- a/chart2/source/controller/dialogs/tp_LegendPosition.cxx
+++ b/chart2/source/controller/dialogs/tp_LegendPosition.cxx
@@ -62,13 +62,12 @@ void SchLegendPosTabPage::Reset(const SfxItemSet* rInAttrs)
 {
     m_aLegendPositionResources.initFromItemSet(*rInAttrs);
 
-    const SfxPoolItem* pPoolItem = nullptr;
-    if( rInAttrs->GetItemState( EE_PARA_WRITINGDIR, true, &pPoolItem ) == 
SfxItemState::SET )
-        m_xLbTextDirection->set_active_id( static_cast<const 
SvxFrameDirectionItem*>(pPoolItem)->GetValue() );
+    if( const SvxFrameDirectionItem* pDirectionItem = rInAttrs->GetItemIfSet( 
EE_PARA_WRITINGDIR ) )
+        m_xLbTextDirection->set_active_id( pDirectionItem->GetValue() );
 
-    if (rInAttrs->GetItemState(SCHATTR_LEGEND_NO_OVERLAY, true, &pPoolItem) == 
SfxItemState::SET)
+    if (const SfxBoolItem* pNoOverlayItem = 
rInAttrs->GetItemIfSet(SCHATTR_LEGEND_NO_OVERLAY))
     {
-        bool bVal = static_cast<const SfxBoolItem*>(pPoolItem)->GetValue();
+        bool bVal = pNoOverlayItem->GetValue();
         m_xCBLegendNoOverlay->set_active(bVal);
     }
 }
diff --git a/chart2/source/controller/dialogs/tp_PointGeometry.cxx 
b/chart2/source/controller/dialogs/tp_PointGeometry.cxx
index 88116ee890e1..7c2c4d942e66 100644
--- a/chart2/source/controller/dialogs/tp_PointGeometry.cxx
+++ b/chart2/source/controller/dialogs/tp_PointGeometry.cxx
@@ -62,11 +62,9 @@ bool SchLayoutTabPage::FillItemSet(SfxItemSet* rOutAttrs)
 
 void SchLayoutTabPage::Reset(const SfxItemSet* rInAttrs)
 {
-    const SfxPoolItem *pPoolItem = nullptr;
-
-    if (rInAttrs->GetItemState(SCHATTR_STYLE_SHAPE,true, &pPoolItem) == 
SfxItemState::SET)
+    if (const SfxInt32Item* pShapeItem = 
rInAttrs->GetItemIfSet(SCHATTR_STYLE_SHAPE))
     {
-        tools::Long nVal = static_cast<const 
SfxInt32Item*>(pPoolItem)->GetValue();
+        tools::Long nVal = pShapeItem->GetValue();
         if(m_pGeometryResources)
         {
             m_pGeometryResources->select(static_cast<sal_uInt16>(nVal));
diff --git a/chart2/source/controller/dialogs/tp_PolarOptions.cxx 
b/chart2/source/controller/dialogs/tp_PolarOptions.cxx
index ed4172d68110..ad7b2b6f0f3e 100644
--- a/chart2/source/controller/dialogs/tp_PolarOptions.cxx
+++ b/chart2/source/controller/dialogs/tp_PolarOptions.cxx
@@ -69,11 +69,9 @@ bool PolarOptionsTabPage::FillItemSet( SfxItemSet* rOutAttrs 
)
 
 void PolarOptionsTabPage::Reset(const SfxItemSet* rInAttrs)
 {
-    const SfxPoolItem *pPoolItem = nullptr;
-
-    if (rInAttrs->GetItemState(SCHATTR_STARTING_ANGLE, true, &pPoolItem) == 
SfxItemState::SET)
+    if (const SdrAngleItem* pAngleItem = 
rInAttrs->GetItemIfSet(SCHATTR_STARTING_ANGLE))
     {
-        Degree100 nTmp = static_cast<const 
SdrAngleItem*>(pPoolItem)->GetValue();
+        Degree100 nTmp = pAngleItem->GetValue();
         m_xAngleDial->SetRotation( nTmp );
     }
     else
@@ -81,18 +79,20 @@ void PolarOptionsTabPage::Reset(const SfxItemSet* rInAttrs)
         m_xFL_StartingAngle->hide();
     }
     // tdf#108059 Hide clockwise orientation checkbox in OOXML-heavy 
environments it would be useless anyways
-    if 
(!officecfg::Office::Compatibility::View::ClockwisePieChartDirection::get() && 
rInAttrs->GetItemState(SCHATTR_CLOCKWISE, true, &pPoolItem) == 
SfxItemState::SET)
+    const SfxBoolItem* pClockWiseItem = nullptr;
+    if 
(!officecfg::Office::Compatibility::View::ClockwisePieChartDirection::get() &&
+        (pClockWiseItem = rInAttrs->GetItemIfSet(SCHATTR_CLOCKWISE)))
     {
-        bool bCheck = static_cast< const SfxBoolItem * >( pPoolItem 
)->GetValue();
+        bool bCheck = pClockWiseItem->GetValue();
         m_xCB_Clockwise->set_active(bCheck);
     }
     else
     {
         m_xCB_Clockwise->hide();
     }
-    if (rInAttrs->GetItemState(SCHATTR_INCLUDE_HIDDEN_CELLS, true, &pPoolItem) 
== SfxItemState::SET)
+    if (const SfxBoolItem* pHiddenCellsItem = 
rInAttrs->GetItemIfSet(SCHATTR_INCLUDE_HIDDEN_CELLS))
     {
-        bool bVal = static_cast<const SfxBoolItem*>(pPoolItem)->GetValue();
+        bool bVal = pHiddenCellsItem->GetValue();
         m_xCB_IncludeHiddenCells->set_active(bVal);
     }
     else
diff --git a/chart2/source/controller/dialogs/tp_Scale.cxx 
b/chart2/source/controller/dialogs/tp_Scale.cxx
index 6c7effde6707..5c60dce0872d 100644
--- a/chart2/source/controller/dialogs/tp_Scale.cxx
+++ b/chart2/source/controller/dialogs/tp_Scale.cxx
@@ -271,19 +271,18 @@ void ScaleTabPage::Reset(const SfxItemSet* rInAttrs)
     if(!pNumFormatter)
         return;
 
-    const SfxPoolItem *pPoolItem = nullptr;
-    if (rInAttrs->GetItemState(SCHATTR_AXIS_ALLOW_DATEAXIS, true, &pPoolItem) 
== SfxItemState::SET)
-        m_bAllowDateAxis = static_cast<const 
SfxBoolItem*>(pPoolItem)->GetValue();
+    if (const SfxBoolItem* pDateAxisItem = 
rInAttrs->GetItemIfSet(SCHATTR_AXIS_ALLOW_DATEAXIS))
+        m_bAllowDateAxis = pDateAxisItem->GetValue();
     m_nAxisType=chart2::AxisType::REALNUMBER;
-    if (rInAttrs->GetItemState(SCHATTR_AXISTYPE, true, &pPoolItem) == 
SfxItemState::SET)
-        m_nAxisType = static_cast<int>(static_cast<const 
SfxInt32Item*>(pPoolItem)->GetValue());
+    if (const SfxInt32Item* pAxisTypeItem = 
rInAttrs->GetItemIfSet(SCHATTR_AXISTYPE))
+        m_nAxisType = static_cast<int>(pAxisTypeItem->GetValue());
     if( m_nAxisType==chart2::AxisType::DATE && !m_bAllowDateAxis )
         m_nAxisType=chart2::AxisType::CATEGORY;
     if( m_bAllowDateAxis )
     {
         bool bAutoDateAxis = false;
-        if (rInAttrs->GetItemState(SCHATTR_AXIS_AUTO_DATEAXIS, true, 
&pPoolItem) == SfxItemState::SET)
-            bAutoDateAxis = static_cast<const 
SfxBoolItem*>(pPoolItem)->GetValue();
+        if (const SfxBoolItem* pDateAxisItem = 
rInAttrs->GetItemIfSet(SCHATTR_AXIS_AUTO_DATEAXIS))
+            bAutoDateAxis = pDateAxisItem->GetValue();
 
         sal_uInt16 nPos = 0;
         if( m_nAxisType==chart2::AxisType::DATE )
@@ -302,74 +301,74 @@ void ScaleTabPage::Reset(const SfxItemSet* rInAttrs)
     m_xCbxAutoOrigin->set_active(true);
     m_xCbx_AutoTimeResolution->set_active(true);
 
-    if (rInAttrs->GetItemState(SCHATTR_AXIS_AUTO_MIN,true,&pPoolItem) == 
SfxItemState::SET)
-        m_xCbxAutoMin->set_active(static_cast<const 
SfxBoolItem*>(pPoolItem)->GetValue());
+    if (const SfxBoolItem* pAutoMinItem = 
rInAttrs->GetItemIfSet(SCHATTR_AXIS_AUTO_MIN))
+        m_xCbxAutoMin->set_active(pAutoMinItem->GetValue());
 
-    if (rInAttrs->GetItemState(SCHATTR_AXIS_MIN,true, &pPoolItem) == 
SfxItemState::SET)
+    if (const SvxDoubleItem* pAxisMinItem = 
rInAttrs->GetItemIfSet(SCHATTR_AXIS_MIN))
     {
-        fMin = static_cast<const SvxDoubleItem*>(pPoolItem)->GetValue();
+        fMin = pAxisMinItem->GetValue();
         lcl_setValue( *m_xFmtFldMin, fMin );
         m_xFmtFldMin->save_value();
     }
 
-    if (rInAttrs->GetItemState(SCHATTR_AXIS_AUTO_MAX,true, &pPoolItem) == 
SfxItemState::SET)
-        m_xCbxAutoMax->set_active(static_cast<const 
SfxBoolItem*>(pPoolItem)->GetValue());
+    if (const SfxBoolItem* pAutoMaxItem = 
rInAttrs->GetItemIfSet(SCHATTR_AXIS_AUTO_MAX))
+        m_xCbxAutoMax->set_active(pAutoMaxItem->GetValue());
 
-    if (rInAttrs->GetItemState(SCHATTR_AXIS_MAX,true, &pPoolItem) == 
SfxItemState::SET)
+    if (const SvxDoubleItem* pAxisMaxItem = 
rInAttrs->GetItemIfSet(SCHATTR_AXIS_MAX))
     {
-        fMax = static_cast<const SvxDoubleItem*>(pPoolItem)->GetValue();
+        fMax = pAxisMaxItem->GetValue();
         lcl_setValue( *m_xFmtFldMax, fMax );
         m_xFmtFldMax->save_value();
     }
 
-    if (rInAttrs->GetItemState(SCHATTR_AXIS_AUTO_STEP_MAIN,true, &pPoolItem) 
== SfxItemState::SET)
-        m_xCbxAutoStepMain->set_active(static_cast<const 
SfxBoolItem*>(pPoolItem)->GetValue());
+    if (const SfxBoolItem* pAutoStepMainItem = 
rInAttrs->GetItemIfSet(SCHATTR_AXIS_AUTO_STEP_MAIN))
+        m_xCbxAutoStepMain->set_active(pAutoStepMainItem->GetValue());
 
-    if (rInAttrs->GetItemState(SCHATTR_AXIS_STEP_MAIN,true, &pPoolItem) == 
SfxItemState::SET)
+    if (const SvxDoubleItem* pStepMainItem = 
rInAttrs->GetItemIfSet(SCHATTR_AXIS_STEP_MAIN))
     {
-        fStepMain = static_cast<const SvxDoubleItem*>(pPoolItem)->GetValue();
+        fStepMain = pStepMainItem->GetValue();
         lcl_setValue( *m_xFmtFldStepMain, fStepMain );
         m_xFmtFldStepMain->save_value();
         m_xMt_MainDateStep->set_value( static_cast<sal_Int32>(fStepMain) );
         m_xMt_MainDateStep->save_value();
     }
-    if (rInAttrs->GetItemState(SCHATTR_AXIS_AUTO_STEP_HELP,true, &pPoolItem) 
== SfxItemState::SET)
-        m_xCbxAutoStepHelp->set_active(static_cast<const 
SfxBoolItem*>(pPoolItem)->GetValue());
-    if (rInAttrs->GetItemState(SCHATTR_AXIS_LOGARITHM,true, &pPoolItem) == 
SfxItemState::SET)
-        m_xCbxLogarithm->set_active(static_cast<const 
SfxBoolItem*>(pPoolItem)->GetValue());
-    if (rInAttrs->GetItemState(SCHATTR_AXIS_REVERSE,true, &pPoolItem) == 
SfxItemState::SET)
-        m_xCbxReverse->set_active(static_cast<const 
SfxBoolItem*>(pPoolItem)->GetValue());
-    if (rInAttrs->GetItemState(SCHATTR_AXIS_STEP_HELP,true, &pPoolItem) == 
SfxItemState::SET)
+    if (const SfxBoolItem* pAutoStepHelpItem = 
rInAttrs->GetItemIfSet(SCHATTR_AXIS_AUTO_STEP_HELP))
+        m_xCbxAutoStepHelp->set_active(pAutoStepHelpItem->GetValue());
+    if (const SfxBoolItem* pLogItem = 
rInAttrs->GetItemIfSet(SCHATTR_AXIS_LOGARITHM))
+        m_xCbxLogarithm->set_active(pLogItem->GetValue());
+    if (const SfxBoolItem* pReverseItem = 
rInAttrs->GetItemIfSet(SCHATTR_AXIS_REVERSE))
+        m_xCbxReverse->set_active(pReverseItem->GetValue());
+    if (const SfxInt32Item* pStepHelpItem = 
rInAttrs->GetItemIfSet(SCHATTR_AXIS_STEP_HELP))
     {
-        nStepHelp = static_cast<const SfxInt32Item*>(pPoolItem)->GetValue();
+        nStepHelp = pStepHelpItem->GetValue();
         m_xMtStepHelp->set_value( nStepHelp );
         m_xMtStepHelp->save_value();
     }
-    if (rInAttrs->GetItemState(SCHATTR_AXIS_AUTO_ORIGIN,true, &pPoolItem) == 
SfxItemState::SET)
-        m_xCbxAutoOrigin->set_active(static_cast<const 
SfxBoolItem*>(pPoolItem)->GetValue());
-    if (rInAttrs->GetItemState(SCHATTR_AXIS_ORIGIN,true, &pPoolItem) == 
SfxItemState::SET)
+    if (const SfxBoolItem* pOriginItem = 
rInAttrs->GetItemIfSet(SCHATTR_AXIS_AUTO_ORIGIN))
+        m_xCbxAutoOrigin->set_active(pOriginItem->GetValue());
+    if (const SvxDoubleItem* pOriginItem = 
rInAttrs->GetItemIfSet(SCHATTR_AXIS_ORIGIN))
     {
-        fOrigin = static_cast<const SvxDoubleItem*>(pPoolItem)->GetValue();
+        fOrigin = pOriginItem->GetValue();
         lcl_setValue( *m_xFmtFldOrigin, fOrigin );
         m_xFmtFldOrigin->save_value();
     }
 
-    if (rInAttrs->GetItemState(SCHATTR_AXIS_AUTO_TIME_RESOLUTION,true, 
&pPoolItem) == SfxItemState::SET)
-        m_xCbx_AutoTimeResolution->set_active(static_cast<const 
SfxBoolItem*>(pPoolItem)->GetValue());
-    if (rInAttrs->GetItemState(SCHATTR_AXIS_TIME_RESOLUTION,true, &pPoolItem) 
== SfxItemState::SET)
+    if (const SfxBoolItem* pAutoTimeResItem = 
rInAttrs->GetItemIfSet(SCHATTR_AXIS_AUTO_TIME_RESOLUTION))
+        m_xCbx_AutoTimeResolution->set_active(pAutoTimeResItem->GetValue());
+    if (const SfxInt32Item* pTimeResItem = 
rInAttrs->GetItemIfSet(SCHATTR_AXIS_TIME_RESOLUTION))
     {
-        m_nTimeResolution = static_cast<const 
SfxInt32Item*>(pPoolItem)->GetValue();
+        m_nTimeResolution = pTimeResItem->GetValue();
         m_xLB_TimeResolution->set_active( m_nTimeResolution );
     }
 
-    if (rInAttrs->GetItemState(SCHATTR_AXIS_MAIN_TIME_UNIT,true, &pPoolItem) 
== SfxItemState::SET)
+    if (const SfxInt32Item* pMainTimeUnitItem = 
rInAttrs->GetItemIfSet(SCHATTR_AXIS_MAIN_TIME_UNIT))
     {
-        m_nMainTimeUnit = static_cast<const 
SfxInt32Item*>(pPoolItem)->GetValue();
+        m_nMainTimeUnit = pMainTimeUnitItem->GetValue();
         m_xLB_MainTimeUnit->set_active( m_nMainTimeUnit );
     }
-    if (rInAttrs->GetItemState(SCHATTR_AXIS_HELP_TIME_UNIT,true, &pPoolItem) 
== SfxItemState::SET)
+    if (const SfxInt32Item* pHelpTimeUnitItem = 
rInAttrs->GetItemIfSet(SCHATTR_AXIS_HELP_TIME_UNIT))
     {
-        m_nHelpTimeUnit = static_cast<const 
SfxInt32Item*>(pPoolItem)->GetValue();
+        m_nHelpTimeUnit = pHelpTimeUnitItem->GetValue();
         m_xLB_HelpTimeUnit->set_active( m_nHelpTimeUnit );
     }
 
@@ -524,12 +523,12 @@ void ScaleTabPage::SetNumFormatter( SvNumberFormatter* 
pFormatter )
 
 void ScaleTabPage::SetNumFormat()
 {
-    const SfxPoolItem *pPoolItem = nullptr;
+    const SfxUInt32Item *pNumFormatItem = GetItemSet().GetItemIfSet( 
SID_ATTR_NUMBERFORMAT_VALUE );
 
-    if( GetItemSet().GetItemState( SID_ATTR_NUMBERFORMAT_VALUE, true, 
&pPoolItem ) != SfxItemState::SET )
+    if( !pNumFormatItem )
         return;
 
-    sal_uLong nFmt = static_cast<const SfxUInt32Item*>(pPoolItem)->GetValue();
+    sal_uLong nFmt = pNumFormatItem->GetValue();
 
     Formatter& rFmtFldMax = m_xFmtFldMax->GetFormatter();
     rFmtFldMax.SetFormatKey(nFmt);
diff --git a/chart2/source/controller/dialogs/tp_SeriesToAxis.cxx 
b/chart2/source/controller/dialogs/tp_SeriesToAxis.cxx
index 15976e89fea8..3ffbc3642e9c 100644
--- a/chart2/source/controller/dialogs/tp_SeriesToAxis.cxx
+++ b/chart2/source/controller/dialogs/tp_SeriesToAxis.cxx
@@ -113,13 +113,11 @@ bool SchOptionTabPage::FillItemSet(SfxItemSet* rOutAttrs)
 
 void SchOptionTabPage::Reset(const SfxItemSet* rInAttrs)
 {
-    const SfxPoolItem *pPoolItem = nullptr;
-
     m_xRbtAxis1->set_active(true);
     m_xRbtAxis2->set_active(false);
-    if (rInAttrs->GetItemState(SCHATTR_AXIS,true, &pPoolItem) == 
SfxItemState::SET)
+    if (const SfxInt32Item* pAxisItem = rInAttrs->GetItemIfSet(SCHATTR_AXIS))
     {
-        tools::Long nVal=static_cast<const 
SfxInt32Item*>(pPoolItem)->GetValue();
+        tools::Long nVal = pAxisItem->GetValue();
         if(nVal==CHART_AXIS_SECONDARY_Y)
         {
             m_xRbtAxis2->set_active(true);
@@ -128,34 +126,34 @@ void SchOptionTabPage::Reset(const SfxItemSet* rInAttrs)
     }
 
     tools::Long nTmp;
-    if (rInAttrs->GetItemState(SCHATTR_BAR_GAPWIDTH, true, &pPoolItem) == 
SfxItemState::SET)
+    if (const SfxInt32Item* pGapWidthItem = 
rInAttrs->GetItemIfSet(SCHATTR_BAR_GAPWIDTH))
     {
-        nTmp = static_cast<tools::Long>(static_cast<const 
SfxInt32Item*>(pPoolItem)->GetValue());
+        nTmp = static_cast<tools::Long>(pGapWidthItem->GetValue());
         m_xMTGap->set_value(nTmp, FieldUnit::PERCENT);
     }
 
-    if (rInAttrs->GetItemState(SCHATTR_BAR_OVERLAP, true, &pPoolItem) == 
SfxItemState::SET)
+    if (const SfxInt32Item* pOverlapItem = 
rInAttrs->GetItemIfSet(SCHATTR_BAR_OVERLAP))
     {
-        nTmp = static_cast<tools::Long>(static_cast<const 
SfxInt32Item*>(pPoolItem)->GetValue());
+        nTmp = static_cast<tools::Long>(pOverlapItem->GetValue());
         m_xMTOverlap->set_value(nTmp, FieldUnit::PERCENT);
     }
 
-    if (rInAttrs->GetItemState(SCHATTR_BAR_CONNECT, true, &pPoolItem) == 
SfxItemState::SET)
+    if (const SfxBoolItem* pConnectItem = 
rInAttrs->GetItemIfSet(SCHATTR_BAR_CONNECT))
     {
-        bool bCheck = static_cast< const SfxBoolItem * >( pPoolItem 
)->GetValue();
+        bool bCheck = pConnectItem->GetValue();
         m_xCBConnect->set_active(bCheck);
     }
 
-    if (rInAttrs->GetItemState(SCHATTR_AXIS_FOR_ALL_SERIES, true, &pPoolItem) 
== SfxItemState::SET)
+    if (const SfxInt32Item* pAllSeriesItem = 
rInAttrs->GetItemIfSet(SCHATTR_AXIS_FOR_ALL_SERIES))
     {
-        m_nAllSeriesAxisIndex = static_cast< const SfxInt32Item * >( pPoolItem 
)->GetValue();
+        m_nAllSeriesAxisIndex = pAllSeriesItem->GetValue();
         m_xCBAxisSideBySide->set_sensitive(false);
     }
-    if (rInAttrs->GetItemState(SCHATTR_GROUP_BARS_PER_AXIS, true, &pPoolItem) 
== SfxItemState::SET)
+    if (const SfxBoolItem* pPerAxisItem = 
rInAttrs->GetItemIfSet(SCHATTR_GROUP_BARS_PER_AXIS))
     {
         // model property is "group bars per axis", UI feature is the other way
         // round: "show bars side by side"
-        bool bCheck = ! static_cast< const SfxBoolItem * >( pPoolItem 
)->GetValue();
+        bool bCheck = ! pPerAxisItem->GetValue();
         m_xCBAxisSideBySide->set_active( bCheck );
     }
     else
@@ -166,10 +164,12 @@ void SchOptionTabPage::Reset(const SfxItemSet* rInAttrs)
     //missing value treatment
     {
         std::vector< sal_Int32 > aMissingValueTreatments;
-        if( rInAttrs->GetItemState(SCHATTR_AVAILABLE_MISSING_VALUE_TREATMENTS, 
true, &pPoolItem) == SfxItemState::SET )
-            aMissingValueTreatments = static_cast<const 
SfxIntegerListItem*>(pPoolItem)->GetList();
+        if (const SfxIntegerListItem* pValueTreatmentsItem = 
rInAttrs->GetItemIfSet(SCHATTR_AVAILABLE_MISSING_VALUE_TREATMENTS))
+            aMissingValueTreatments = pValueTreatmentsItem->GetList();
 
-        if ( aMissingValueTreatments.size()>1 && 
rInAttrs->GetItemState(SCHATTR_MISSING_VALUE_TREATMENT,true, &pPoolItem) == 
SfxItemState::SET)
+        const SfxInt32Item* pMissingValueTreatmentItem;
+        if ( aMissingValueTreatments.size()>1 &&
+            (pMissingValueTreatmentItem = 
rInAttrs->GetItemIfSet(SCHATTR_MISSING_VALUE_TREATMENT)) )
         {
             m_xRB_DontPaint->set_sensitive(false);
             m_xRB_AssumeZero->set_sensitive(false);
@@ -185,7 +185,7 @@ void SchOptionTabPage::Reset(const SfxItemSet* rInAttrs)
                     m_xRB_ContinueLine->set_sensitive(true);
             }
 
-            tools::Long nVal=static_cast<const 
SfxInt32Item*>(pPoolItem)->GetValue();
+            tools::Long nVal=pMissingValueTreatmentItem->GetValue();
             if(nVal==css::chart::MissingValueTreatment::LEAVE_GAP)
                 m_xRB_DontPaint->set_active(true);
             else if(nVal==css::chart::MissingValueTreatment::USE_ZERO)
@@ -200,9 +200,9 @@ void SchOptionTabPage::Reset(const SfxItemSet* rInAttrs)
     }
 
     // Include hidden cells
-    if (rInAttrs->GetItemState(SCHATTR_INCLUDE_HIDDEN_CELLS, true, &pPoolItem) 
== SfxItemState::SET)
+    if (const SfxBoolItem* pHiddenCellsItem = 
rInAttrs->GetItemIfSet(SCHATTR_INCLUDE_HIDDEN_CELLS))
     {
-        bool bVal = static_cast<const SfxBoolItem*>(pPoolItem)->GetValue();
+        bool bVal = pHiddenCellsItem->GetValue();
         m_xCBIncludeHiddenCells->set_active(bVal);
     }
     else
@@ -215,9 +215,9 @@ void SchOptionTabPage::Reset(const SfxItemSet* rInAttrs)
             m_xGrpPlotOptions->hide();
     }
 
-    if (rInAttrs->GetItemState(SCHATTR_HIDE_LEGEND_ENTRY, true, &pPoolItem) == 
SfxItemState::SET)
+    if (const SfxBoolItem* pEntryItem = 
rInAttrs->GetItemIfSet(SCHATTR_HIDE_LEGEND_ENTRY))
     {
-        bool bVal = static_cast<const SfxBoolItem*>(pPoolItem)->GetValue();
+        bool bVal = pEntryItem->GetValue();
         m_xCBHideLegendEntry->set_active(bVal);
     }
 
diff --git a/chart2/source/controller/dialogs/tp_TitleRotation.cxx 
b/chart2/source/controller/dialogs/tp_TitleRotation.cxx
index ed99a9a39501..2cc802f703a2 100644
--- a/chart2/source/controller/dialogs/tp_TitleRotation.cxx
+++ b/chart2/source/controller/dialogs/tp_TitleRotation.cxx
@@ -114,8 +114,8 @@ void SchAlignmentTabPage::Reset(const SfxItemSet* rInAttrs)
     m_xCbStacked->set_active(bStacked);
     StackedToggleHdl(*m_xCbStacked);
 
-    if( rInAttrs->GetItemState(EE_PARA_WRITINGDIR, true, &pItem) == 
SfxItemState::SET)
-        m_xLbTextDirection->set_active_id(static_cast<const 
SvxFrameDirectionItem*>(pItem)->GetValue());
+    if( const SvxFrameDirectionItem* pDirectionItem = 
rInAttrs->GetItemIfSet(EE_PARA_WRITINGDIR) )
+        m_xLbTextDirection->set_active_id(pDirectionItem->GetValue());
 }
 
 } //namespace chart
diff --git a/chart2/source/controller/itemsetwrapper/LegendItemConverter.cxx 
b/chart2/source/controller/itemsetwrapper/LegendItemConverter.cxx
index 081e8ebbd390..7a8dab18855e 100644
--- a/chart2/source/controller/itemsetwrapper/LegendItemConverter.cxx
+++ b/chart2/source/controller/itemsetwrapper/LegendItemConverter.cxx
@@ -96,10 +96,9 @@ bool LegendItemConverter::ApplySpecialItem( sal_uInt16 
nWhichId, const SfxItemSe
     {
         case SCHATTR_LEGEND_SHOW:
         {
-            const SfxPoolItem* pPoolItem = nullptr;
-            if( rInItemSet.GetItemState( SCHATTR_LEGEND_SHOW, true, &pPoolItem 
) == SfxItemState::SET )
+            if( const SfxBoolItem* pShowItem = rInItemSet.GetItemIfSet( 
SCHATTR_LEGEND_SHOW ) )
             {
-                bool bShow = static_cast< const SfxBoolItem * >( pPoolItem 
)->GetValue();
+                bool bShow = pShowItem->GetValue();
                 bool bWasShown = true;
                 if( ! (GetPropertySet()->getPropertyValue( "Show" ) >>= 
bWasShown) ||
                     ( bWasShown != bShow ))
@@ -113,10 +112,9 @@ bool LegendItemConverter::ApplySpecialItem( sal_uInt16 
nWhichId, const SfxItemSe
         break;
         case SCHATTR_LEGEND_POS:
         {
-            const SfxPoolItem* pPoolItem = nullptr;
-            if( rInItemSet.GetItemState( SCHATTR_LEGEND_POS, true, &pPoolItem 
) == SfxItemState::SET )
+            if( const SfxInt32Item* pPosItem = rInItemSet.GetItemIfSet( 
SCHATTR_LEGEND_POS ) )
             {
-                chart2::LegendPosition eNewPos = 
static_cast<chart2::LegendPosition>(static_cast<const 
SfxInt32Item*>(pPoolItem)->GetValue());
+                chart2::LegendPosition eNewPos = 
static_cast<chart2::LegendPosition>(pPosItem->GetValue());
 
                 css::chart::ChartLegendExpansion eExpansion = 
css::chart::ChartLegendExpansion_HIGH;
                 switch( eNewPos )
@@ -154,10 +152,9 @@ bool LegendItemConverter::ApplySpecialItem( sal_uInt16 
nWhichId, const SfxItemSe
         break;
         case SCHATTR_LEGEND_NO_OVERLAY:
         {
-            const SfxPoolItem* pPoolItem = nullptr;
-            if(rInItemSet.GetItemState(SCHATTR_LEGEND_NO_OVERLAY, true, 
&pPoolItem) == SfxItemState::SET)
+            if(const SfxBoolItem* pNoOverlayItem = 
rInItemSet.GetItemIfSet(SCHATTR_LEGEND_NO_OVERLAY))
             {
-                bool bOverlay = !static_cast<const SfxBoolItem 
*>(pPoolItem)->GetValue();
+                bool bOverlay = !pNoOverlayItem->GetValue();
                 bool bOldOverlay = false;
                 if(!(GetPropertySet()->getPropertyValue("Overlay") >>= 
bOldOverlay) ||
                     (bOldOverlay != bOverlay))
diff --git 
a/chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx 
b/chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx
index 12cb196592d5..04b8769a1fde 100644
--- a/chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx
+++ b/chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx
@@ -108,10 +108,9 @@ uno::Reference< beans::XPropertySet > 
lcl_getEquationProperties(
     // ensure that a trendline is on
     if( pItemSet )
     {
-        const SfxPoolItem *pPoolItem = nullptr;
-        if( pItemSet->GetItemState( SCHATTR_REGRESSION_TYPE, true, &pPoolItem 
) == SfxItemState::SET )
+        if( const SvxChartRegressItem* pRegressionItem = 
pItemSet->GetItemIfSet( SCHATTR_REGRESSION_TYPE ) )
         {
-            SvxChartRegress eRegress = static_cast< const SvxChartRegressItem 
* >( pPoolItem )->GetValue();
+            SvxChartRegress eRegress = pRegressionItem->GetValue();
             bEquationExists = ( eRegress != SvxChartRegress::NONE );
         }
     }
@@ -138,10 +137,9 @@ uno::Reference< beans::XPropertySet > 
lcl_getCurveProperties(
     // ensure that a trendline is on
     if( pItemSet )
     {
-        const SfxPoolItem *pPoolItem = nullptr;
-        if( pItemSet->GetItemState( SCHATTR_REGRESSION_TYPE, true, &pPoolItem 
) == SfxItemState::SET )
+        if( const SvxChartRegressItem* pRegressionItem = 
pItemSet->GetItemIfSet( SCHATTR_REGRESSION_TYPE ) )
         {
-            SvxChartRegress eRegress = static_cast< const SvxChartRegressItem 
* >( pPoolItem )->GetValue();
+            SvxChartRegress eRegress = pRegressionItem->GetValue();
             bExists = ( eRegress != SvxChartRegress::NONE );
         }
     }
diff --git a/chart2/source/controller/main/ChartController_Position.cxx 
b/chart2/source/controller/main/ChartController_Position.cxx
index fe746c29e8ff..9a7c1cbfdbf2 100644
--- a/chart2/source/controller/main/ChartController_Position.cxx
+++ b/chart2/source/controller/main/ChartController_Position.cxx
@@ -54,19 +54,18 @@ static void lcl_getPositionAndSizeFromItemSet( const 
SfxItemSet& rItemSet, awt::
 
     RectPoint eRP = RectPoint::LT;
 
-    const SfxPoolItem* pPoolItem=nullptr;
     //read position
-    if 
(rItemSet.GetItemState(SID_ATTR_TRANSFORM_POS_X,true,&pPoolItem)==SfxItemState::SET)
-        nPosX= static_cast<const SfxInt32Item*>(pPoolItem)->GetValue();
-    if 
(rItemSet.GetItemState(SID_ATTR_TRANSFORM_POS_Y,true,&pPoolItem)==SfxItemState::SET)
-        nPosY=static_cast<const SfxInt32Item*>(pPoolItem)->GetValue();
+    if (const SfxInt32Item* pPosXItem = 
rItemSet.GetItemIfSet(SID_ATTR_TRANSFORM_POS_X))
+        nPosX = pPosXItem->GetValue();
+    if (const SfxInt32Item* pPosYItem = 
rItemSet.GetItemIfSet(SID_ATTR_TRANSFORM_POS_Y))
+        nPosY = pPosYItem->GetValue();
     //read size
-    if 
(rItemSet.GetItemState(SID_ATTR_TRANSFORM_WIDTH,true,&pPoolItem)==SfxItemState::SET)
-        nSizX=static_cast<const SfxUInt32Item*>(pPoolItem)->GetValue();
-    if 
(rItemSet.GetItemState(SID_ATTR_TRANSFORM_HEIGHT,true,&pPoolItem)==SfxItemState::SET)
-        nSizY=static_cast<const SfxUInt32Item*>(pPoolItem)->GetValue();
-    if 
(rItemSet.GetItemState(SID_ATTR_TRANSFORM_SIZE_POINT,true,&pPoolItem)==SfxItemState::SET)
-        eRP=static_cast<RectPoint>(static_cast<const 
SfxUInt16Item*>(pPoolItem)->GetValue());
+    if (const SfxUInt32Item* pWidthItem = 
rItemSet.GetItemIfSet(SID_ATTR_TRANSFORM_WIDTH))
+        nSizX = pWidthItem->GetValue();
+    if (const SfxUInt32Item* pHeightItem = 
rItemSet.GetItemIfSet(SID_ATTR_TRANSFORM_HEIGHT))
+        nSizY = pHeightItem->GetValue();
+    if (const SfxUInt16Item* pSizeItem = 
rItemSet.GetItemIfSet(SID_ATTR_TRANSFORM_SIZE_POINT))
+        eRP=static_cast<RectPoint>(pSizeItem->GetValue());
 
     switch( eRP )
     {
diff --git a/chart2/source/controller/main/ChartController_TextEdit.cxx 
b/chart2/source/controller/main/ChartController_TextEdit.cxx
index 100d210c2e9e..8d56429e3855 100644
--- a/chart2/source/controller/main/ChartController_TextEdit.cxx
+++ b/chart2/source/controller/main/ChartController_TextEdit.cxx
@@ -183,11 +183,10 @@ void 
ChartController::executeDispatch_InsertSpecialCharacter()
         return;
 
     const SfxItemSet* pSet = pDlg->GetOutputItemSet();
-    const SfxPoolItem* pItem=nullptr;
     OUString aString;
-    if (pSet && pSet->GetItemState(SID_CHARMAP, true, &pItem) == 
SfxItemState::SET)
-        if (auto pStringItem = dynamic_cast<const SfxStringItem*>(pItem))
-            aString = pStringItem->GetValue();
+    if (pSet)
+        if (const SfxStringItem* pCharMapItem = 
pSet->GetItemIfSet(SID_CHARMAP))
+            aString = pCharMapItem->GetValue();
 
     OutlinerView* pOutlinerView = 
m_pDrawViewWrapper->GetTextEditOutlinerView();
     SdrOutliner*  pOutliner = m_pDrawViewWrapper->getOutliner();

Reply via email to