summaryrefslogtreecommitdiff
path: root/chart2/source/controller/itemsetwrapper
diff options
context:
space:
mode:
authorTomaž Vajngerl <quikee@gmail.com>2013-11-20 22:40:51 +0100
committerTomaž Vajngerl <quikee@gmail.com>2013-11-24 19:43:16 +0100
commit3af08dd27d45302d162974e671f50af8a11a9cea (patch)
tree7100a4619fe31617c96147b0929810895c5a20c2 /chart2/source/controller/itemsetwrapper
parent233d247f40dd5069451204f3c3ef2c298e2cad74 (diff)
DRY-cleanup RegressionCurveItemConverter
Change-Id: I8fb799b2efc81587252161ccadfa1dbd6b096bda
Diffstat (limited to 'chart2/source/controller/itemsetwrapper')
-rw-r--r--chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx261
1 files changed, 117 insertions, 144 deletions
diff --git a/chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx b/chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx
index 2bf790005f9f..bce1e7fe6e22 100644
--- a/chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx
+++ b/chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx
@@ -128,55 +128,52 @@ bool RegressionCurveItemConverter::ApplySpecialItem(
uno::Reference< chart2::XRegressionCurve > xCurve( GetPropertySet(), uno::UNO_QUERY );
bool bChanged = false;
+ OSL_ASSERT( xCurve.is());
+ if( !xCurve.is())
+ return false;
+
switch( nWhichId )
{
case SCHATTR_REGRESSION_TYPE:
{
- OSL_ASSERT( xCurve.is());
- if( xCurve.is())
+ SvxChartRegress eRegress = static_cast< SvxChartRegress >(
+ static_cast< sal_Int32 >( RegressionCurveHelper::getRegressionType( xCurve )));
+ SvxChartRegress eNewRegress = static_cast< const SvxChartRegressItem & >(
+ rItemSet.Get( nWhichId )).GetValue();
+ if( eRegress != eNewRegress )
{
- SvxChartRegress eRegress = static_cast< SvxChartRegress >(
- static_cast< sal_Int32 >( RegressionCurveHelper::getRegressionType( xCurve )));
- SvxChartRegress eNewRegress = static_cast< const SvxChartRegressItem & >(
- rItemSet.Get( nWhichId )).GetValue();
- if( eRegress != eNewRegress )
- {
- // note that changing the regression type changes the object
- // for which this converter was created. Not optimal, but
- // currently the only way to handle the type in the
- // regression curve properties dialog
- xCurve = RegressionCurveHelper::changeRegressionCurveType(
- lcl_convertRegressionType( eNewRegress ),
- m_xCurveContainer,
- xCurve,
- uno::Reference< uno::XComponentContext >());
- uno::Reference< beans::XPropertySet > xProperties( xCurve, uno::UNO_QUERY );
- resetPropertySet( xProperties );
- bChanged = true;
- }
+ // note that changing the regression type changes the object
+ // for which this converter was created. Not optimal, but
+ // currently the only way to handle the type in the
+ // regression curve properties dialog
+ xCurve = RegressionCurveHelper::changeRegressionCurveType(
+ lcl_convertRegressionType( eNewRegress ),
+ m_xCurveContainer,
+ xCurve,
+ uno::Reference< uno::XComponentContext >());
+ uno::Reference< beans::XPropertySet > xProperties( xCurve, uno::UNO_QUERY );
+ resetPropertySet( xProperties );
+ bChanged = true;
}
}
break;
case SCHATTR_REGRESSION_DEGREE:
{
- if( xCurve.is())
- {
- sal_Int32 aDegree = static_cast< sal_Int32 >(
- static_cast< const SfxInt32Item & >(
- rItemSet.Get( nWhichId )).GetValue());
+ sal_Int32 aDegree = static_cast< sal_Int32 >(
+ static_cast< const SfxInt32Item & >(
+ rItemSet.Get( nWhichId )).GetValue());
- uno::Reference< beans::XPropertySet > xProperties( xCurve, uno::UNO_QUERY );
- OSL_ASSERT( xProperties.is());
- if( xProperties.is() )
+ uno::Reference< beans::XPropertySet > xProperties( xCurve, uno::UNO_QUERY );
+ OSL_ASSERT( xProperties.is());
+ if( xProperties.is() )
+ {
+ sal_Int32 aOldDegree = 2;
+ xProperties->getPropertyValue( "PolynomialDegree" ) >>= aOldDegree;
+ if (aOldDegree != aDegree)
{
- sal_Int32 aOldDegree = 2;
- xProperties->getPropertyValue( "PolynomialDegree" ) >>= aOldDegree;
- if (aOldDegree != aDegree)
- {
- xProperties->setPropertyValue( "PolynomialDegree" , uno::makeAny( aDegree ));
- bChanged = true;
- }
+ xProperties->setPropertyValue( "PolynomialDegree" , uno::makeAny( aDegree ));
+ bChanged = true;
}
}
}
@@ -184,23 +181,20 @@ bool RegressionCurveItemConverter::ApplySpecialItem(
case SCHATTR_REGRESSION_PERIOD:
{
- if( xCurve.is())
- {
- sal_Int32 aPeriod = static_cast< sal_Int32 >(
- static_cast< const SfxInt32Item & >(
- rItemSet.Get( nWhichId )).GetValue());
+ sal_Int32 aPeriod = static_cast< sal_Int32 >(
+ static_cast< const SfxInt32Item & >(
+ rItemSet.Get( nWhichId )).GetValue());
- uno::Reference< beans::XPropertySet > xProperties( xCurve, uno::UNO_QUERY );
- OSL_ASSERT( xProperties.is());
- if( xProperties.is() )
+ uno::Reference< beans::XPropertySet > xProperties( xCurve, uno::UNO_QUERY );
+ OSL_ASSERT( xProperties.is());
+ if( xProperties.is() )
+ {
+ sal_Int32 aOldPeriod = 2;
+ xProperties->getPropertyValue( "MovingAveragePeriod" ) >>= aOldPeriod;
+ if (aOldPeriod != aPeriod)
{
- sal_Int32 aOldPeriod = 2;
- xProperties->getPropertyValue( "MovingAveragePeriod" ) >>= aOldPeriod;
- if (aOldPeriod != aPeriod)
- {
- xProperties->setPropertyValue( "MovingAveragePeriod" , uno::makeAny( aPeriod ));
- bChanged = true;
- }
+ xProperties->setPropertyValue( "MovingAveragePeriod" , uno::makeAny( aPeriod ));
+ bChanged = true;
}
}
}
@@ -208,23 +202,20 @@ bool RegressionCurveItemConverter::ApplySpecialItem(
case SCHATTR_REGRESSION_EXTRAPOLATE_FORWARD:
{
- if( xCurve.is())
- {
- double aValue = static_cast< double >(
- static_cast< const SvxDoubleItem & >(
- rItemSet.Get( nWhichId )).GetValue());
+ double aValue = static_cast< double >(
+ static_cast< const SvxDoubleItem & >(
+ rItemSet.Get( nWhichId )).GetValue());
- uno::Reference< beans::XPropertySet > xProperties( xCurve, uno::UNO_QUERY );
- OSL_ASSERT( xProperties.is());
- if( xProperties.is() )
+ uno::Reference< beans::XPropertySet > xProperties( xCurve, uno::UNO_QUERY );
+ OSL_ASSERT( xProperties.is());
+ if( xProperties.is() )
+ {
+ double aOldValue = 0.0;
+ xProperties->getPropertyValue( "ExtrapolateForward" ) >>= aOldValue;
+ if (aOldValue != aValue)
{
- double aOldValue = 0.0;
- xProperties->getPropertyValue( "ExtrapolateForward" ) >>= aOldValue;
- if (aOldValue != aValue)
- {
- xProperties->setPropertyValue( "ExtrapolateForward" , uno::makeAny( aValue ));
- bChanged = true;
- }
+ xProperties->setPropertyValue( "ExtrapolateForward" , uno::makeAny( aValue ));
+ bChanged = true;
}
}
}
@@ -232,23 +223,20 @@ bool RegressionCurveItemConverter::ApplySpecialItem(
case SCHATTR_REGRESSION_EXTRAPOLATE_BACKWARD:
{
- if( xCurve.is())
- {
- double aValue = static_cast< double >(
- static_cast< const SvxDoubleItem & >(
- rItemSet.Get( nWhichId )).GetValue());
+ double aValue = static_cast< double >(
+ static_cast< const SvxDoubleItem & >(
+ rItemSet.Get( nWhichId )).GetValue());
- uno::Reference< beans::XPropertySet > xProperties( xCurve, uno::UNO_QUERY );
- OSL_ASSERT( xProperties.is());
- if( xProperties.is() )
+ uno::Reference< beans::XPropertySet > xProperties( xCurve, uno::UNO_QUERY );
+ OSL_ASSERT( xProperties.is());
+ if( xProperties.is() )
+ {
+ double aOldValue = 0.0;
+ xProperties->getPropertyValue( "ExtrapolateBackward" ) >>= aOldValue;
+ if (aOldValue != aValue)
{
- double aOldValue = 0.0;
- xProperties->getPropertyValue( "ExtrapolateBackward" ) >>= aOldValue;
- if (aOldValue != aValue)
- {
- xProperties->setPropertyValue( "ExtrapolateBackward" , uno::makeAny( aValue ));
- bChanged = true;
- }
+ xProperties->setPropertyValue( "ExtrapolateBackward" , uno::makeAny( aValue ));
+ bChanged = true;
}
}
}
@@ -256,23 +244,20 @@ bool RegressionCurveItemConverter::ApplySpecialItem(
case SCHATTR_REGRESSION_SET_INTERCEPT:
{
- if( xCurve.is())
- {
- sal_Bool bNewValue = static_cast< sal_Bool >(
- static_cast< const SfxBoolItem & >(
- rItemSet.Get( nWhichId )).GetValue());
+ sal_Bool bNewValue = static_cast< sal_Bool >(
+ static_cast< const SfxBoolItem & >(
+ rItemSet.Get( nWhichId )).GetValue());
- uno::Reference< beans::XPropertySet > xProperties( xCurve, uno::UNO_QUERY );
- OSL_ASSERT( xProperties.is());
- if( xProperties.is() )
+ uno::Reference< beans::XPropertySet > xProperties( xCurve, uno::UNO_QUERY );
+ OSL_ASSERT( xProperties.is());
+ if( xProperties.is() )
+ {
+ sal_Bool bOldValue = false;
+ xProperties->getPropertyValue( "ForceIntercept" ) >>= bOldValue;
+ if (bOldValue != bNewValue)
{
- sal_Bool bOldValue = false;
- xProperties->getPropertyValue( "ForceIntercept" ) >>= bOldValue;
- if (bOldValue != bNewValue)
- {
- xProperties->setPropertyValue( "ForceIntercept" , uno::makeAny( bNewValue ));
- bChanged = true;
- }
+ xProperties->setPropertyValue( "ForceIntercept" , uno::makeAny( bNewValue ));
+ bChanged = true;
}
}
}
@@ -280,23 +265,20 @@ bool RegressionCurveItemConverter::ApplySpecialItem(
case SCHATTR_REGRESSION_INTERCEPT_VALUE:
{
- if( xCurve.is())
- {
- double aValue = static_cast< double >(
- static_cast< const SvxDoubleItem & >(
- rItemSet.Get( nWhichId )).GetValue());
+ double aValue = static_cast< double >(
+ static_cast< const SvxDoubleItem & >(
+ rItemSet.Get( nWhichId )).GetValue());
- uno::Reference< beans::XPropertySet > xProperties( xCurve, uno::UNO_QUERY );
- OSL_ASSERT( xProperties.is());
- if( xProperties.is() )
+ uno::Reference< beans::XPropertySet > xProperties( xCurve, uno::UNO_QUERY );
+ OSL_ASSERT( xProperties.is());
+ if( xProperties.is() )
+ {
+ double aOldValue = 0.0;
+ xProperties->getPropertyValue( "InterceptValue" ) >>= aOldValue;
+ if (aOldValue != aValue)
{
- double aOldValue = 0.0;
- xProperties->getPropertyValue( "InterceptValue" ) >>= aOldValue;
- if (aOldValue != aValue)
- {
- xProperties->setPropertyValue( "InterceptValue" , uno::makeAny( aValue ));
- bChanged = true;
- }
+ xProperties->setPropertyValue( "InterceptValue" , uno::makeAny( aValue ));
+ bChanged = true;
}
}
}
@@ -304,51 +286,42 @@ bool RegressionCurveItemConverter::ApplySpecialItem(
case SCHATTR_REGRESSION_SHOW_EQUATION:
{
- OSL_ASSERT( xCurve.is());
- if( xCurve.is())
+ bool bNewShow = static_cast< sal_Bool >(
+ static_cast< const SfxBoolItem & >(
+ rItemSet.Get( nWhichId )).GetValue());
+
+ uno::Reference< beans::XPropertySet > xEqProp( xCurve->getEquationProperties());
+ OSL_ASSERT( xEqProp.is());
+ bool bOldShow = false;
+ if( xEqProp.is() &&
+ (xEqProp->getPropertyValue( "ShowEquation" ) >>= bOldShow) &&
+ bOldShow != bNewShow )
{
- bool bNewShow = static_cast< sal_Bool >(
- static_cast< const SfxBoolItem & >(
- rItemSet.Get( nWhichId )).GetValue());
-
- uno::Reference< beans::XPropertySet > xEqProp( xCurve->getEquationProperties());
- OSL_ASSERT( xEqProp.is());
- bool bOldShow = false;
- if( xEqProp.is() &&
- (xEqProp->getPropertyValue( "ShowEquation" ) >>= bOldShow) &&
- bOldShow != bNewShow )
- {
- xEqProp->setPropertyValue( "ShowEquation" , uno::makeAny( bNewShow ));
- bChanged = true;
- }
+ xEqProp->setPropertyValue( "ShowEquation" , uno::makeAny( bNewShow ));
+ bChanged = true;
}
}
break;
case SCHATTR_REGRESSION_SHOW_COEFF:
{
- OSL_ASSERT( xCurve.is());
- if( xCurve.is())
+ bool bNewShow = static_cast< sal_Bool >(
+ static_cast< const SfxBoolItem & >(
+ rItemSet.Get( nWhichId )).GetValue());
+
+ uno::Reference< beans::XPropertySet > xEqProp( xCurve->getEquationProperties());
+ OSL_ASSERT( xEqProp.is());
+ bool bOldShow = false;
+ if( xEqProp.is() &&
+ (xEqProp->getPropertyValue( "ShowCorrelationCoefficient" ) >>= bOldShow) &&
+ bOldShow != bNewShow )
{
- bool bNewShow = static_cast< sal_Bool >(
- static_cast< const SfxBoolItem & >(
- rItemSet.Get( nWhichId )).GetValue());
-
- uno::Reference< beans::XPropertySet > xEqProp( xCurve->getEquationProperties());
- OSL_ASSERT( xEqProp.is());
- bool bOldShow = false;
- if( xEqProp.is() &&
- (xEqProp->getPropertyValue( "ShowCorrelationCoefficient" ) >>= bOldShow) &&
- bOldShow != bNewShow )
- {
- xEqProp->setPropertyValue( "ShowCorrelationCoefficient" , uno::makeAny( bNewShow ));
- bChanged = true;
- }
+ xEqProp->setPropertyValue( "ShowCorrelationCoefficient" , uno::makeAny( bNewShow ));
+ bChanged = true;
}
}
break;
}
-
return bChanged;
}