diff options
Diffstat (limited to 'chart2/source/controller/dialogs/res_Trendline.cxx')
-rw-r--r-- | chart2/source/controller/dialogs/res_Trendline.cxx | 53 |
1 files changed, 24 insertions, 29 deletions
diff --git a/chart2/source/controller/dialogs/res_Trendline.cxx b/chart2/source/controller/dialogs/res_Trendline.cxx index 8fc5e63ee2be..3cbba1e59a28 100644 --- a/chart2/source/controller/dialogs/res_Trendline.cxx +++ b/chart2/source/controller/dialogs/res_Trendline.cxx @@ -24,8 +24,8 @@ #include <com/sun/star/chart2/MovingAverageType.hpp> #include <svl/intitem.hxx> +#include <svl/numformat.hxx> #include <svl/stritem.hxx> -#include <svl/zforlist.hxx> #include <vcl/formatter.hxx> #include <vcl/weld.hxx> @@ -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,8 +154,9 @@ 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 ); + m_bTrendLineUnique = ( aState != SfxItemState::INVALID ); if( aState == SfxItemState::SET ) { const SvxChartRegressItem * pItem = dynamic_cast< const SvxChartRegressItem * >( pPoolItem ); @@ -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,28 +191,28 @@ 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); aState = rInAttrs.GetItemState( SCHATTR_REGRESSION_SET_INTERCEPT, true, &pPoolItem ); - if( aState == SfxItemState::DONTCARE ) + if( aState == SfxItemState::INVALID ) { m_xCB_SetIntercept->set_state(TRISTATE_INDET); } @@ -224,7 +223,7 @@ void TrendlineResources::Reset( const SfxItemSet& rInAttrs ) } aState = rInAttrs.GetItemState( SCHATTR_REGRESSION_SHOW_EQUATION, true, &pPoolItem ); - if( aState == SfxItemState::DONTCARE ) + if( aState == SfxItemState::INVALID ) { m_xCB_ShowEquation->set_state(TRISTATE_INDET); } @@ -235,7 +234,7 @@ void TrendlineResources::Reset( const SfxItemSet& rInAttrs ) } aState = rInAttrs.GetItemState( SCHATTR_REGRESSION_SHOW_COEFF, true, &pPoolItem ); - if( aState == SfxItemState::DONTCARE ) + if( aState == SfxItemState::INVALID ) { m_xCB_ShowCorrelationCoeff->set_state(TRISTATE_INDET); } @@ -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) @@ -373,10 +372,8 @@ void TrendlineResources::UpdateControlStates() m_xFmtFld_InterceptValue->set_sensitive( bInterceptAvailable ); if( bMovingAverage ) { - m_xCB_ShowEquation->set_state(TRISTATE_FALSE); m_xCB_ShowCorrelationCoeff->set_state(TRISTATE_FALSE); } - m_xCB_ShowEquation->set_sensitive( !bMovingAverage ); m_xCB_ShowCorrelationCoeff->set_sensitive( !bMovingAverage ); m_xCB_RegressionMovingType->set_sensitive(bMovingAverage); m_xNF_Period->set_sensitive(bMovingAverage); @@ -429,8 +426,6 @@ void TrendlineResources::SetNbPoints( sal_Int32 nNbPoints ) IMPL_LINK_NOARG(TrendlineResources, ShowEquation, weld::Toggleable&, void) { - m_xEE_XName->set_sensitive(m_xCB_ShowEquation->get_active()); - m_xEE_YName->set_sensitive(m_xCB_ShowEquation->get_active()); UpdateControlStates(); } |