summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomaž Vajngerl <quikee@gmail.com>2013-11-21 20:25:53 +0100
committerTomaž Vajngerl <quikee@gmail.com>2013-11-24 19:43:16 +0100
commitf58e03e7bb0016c1ca789f7e7b35933c95378121 (patch)
tree00f57db7deecfe9545bac42ff1096dc3def118b9
parent3af08dd27d45302d162974e671f50af8a11a9cea (diff)
Simplify conversion from/to ItemSet/PropertySet for RegressionCurves
Change-Id: I5ddf53f984508a88fd02063eb9f81cd05cf627c9
-rw-r--r--chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx299
-rw-r--r--chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx193
-rw-r--r--chart2/source/view/main/ChartItemPool.cxx2
3 files changed, 139 insertions, 355 deletions
diff --git a/chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx b/chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx
index bce1e7fe6e22..6b284393afc4 100644
--- a/chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx
+++ b/chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx
@@ -68,6 +68,51 @@ namespace
return eType;
}
+template <class T, class D>
+bool lclConvertToPropertySet(const SfxItemSet& rItemSet, sal_uInt16 nWhichId, uno::Reference<beans::XPropertySet> xProperties, OUString aPropertyID)
+{
+ OSL_ASSERT(xProperties.is());
+ if( xProperties.is() )
+ {
+ T aValue = static_cast<T>(static_cast<const D&>(rItemSet.Get( nWhichId )).GetValue());
+ T aOldValue = aValue;
+ bool aSuccess = xProperties->getPropertyValue( aPropertyID ) >>= aOldValue;
+ if (!aSuccess || aOldValue != aValue)
+ {
+ xProperties->setPropertyValue( aPropertyID , uno::makeAny( aValue ));
+ return true;
+ }
+ }
+ return false;
+}
+
+template <class T, class D>
+void lclConvertToItemSet(SfxItemSet& rItemSet, sal_uInt16 nWhichId, uno::Reference<beans::XPropertySet> xProperties, OUString aPropertyID)
+{
+ OSL_ASSERT(xProperties.is());
+ if( xProperties.is() )
+ {
+ T aValue = static_cast<T>(static_cast<const D&>(rItemSet.Get( nWhichId )).GetValue());
+ if(xProperties->getPropertyValue( aPropertyID ) >>= aValue)
+ {
+ rItemSet.Put(D( nWhichId, aValue ));
+ }
+ }
+}
+
+void lclConvertToItemSetDouble(SfxItemSet& rItemSet, sal_uInt16 nWhichId, uno::Reference<beans::XPropertySet> xProperties, OUString aPropertyID)
+{
+ OSL_ASSERT(xProperties.is());
+ if( xProperties.is() )
+ {
+ double aValue = static_cast<double>(static_cast<const SvxDoubleItem&>(rItemSet.Get( nWhichId )).GetValue());
+ if(xProperties->getPropertyValue( aPropertyID ) >>= aValue)
+ {
+ rItemSet.Put(SvxDoubleItem( aValue, nWhichId ));
+ }
+ }
+}
+
} // anonymous namespace
namespace chart
@@ -128,8 +173,8 @@ bool RegressionCurveItemConverter::ApplySpecialItem(
uno::Reference< chart2::XRegressionCurve > xCurve( GetPropertySet(), uno::UNO_QUERY );
bool bChanged = false;
- OSL_ASSERT( xCurve.is());
- if( !xCurve.is())
+ OSL_ASSERT(xCurve.is());
+ if(!xCurve.is())
return false;
switch( nWhichId )
@@ -151,7 +196,7 @@ bool RegressionCurveItemConverter::ApplySpecialItem(
m_xCurveContainer,
xCurve,
uno::Reference< uno::XComponentContext >());
- uno::Reference< beans::XPropertySet > xProperties( xCurve, uno::UNO_QUERY );
+ uno::Reference<beans::XPropertySet> xProperties( xCurve, uno::UNO_QUERY );
resetPropertySet( xProperties );
bChanged = true;
}
@@ -160,324 +205,128 @@ bool RegressionCurveItemConverter::ApplySpecialItem(
case SCHATTR_REGRESSION_DEGREE:
{
- 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() )
- {
- sal_Int32 aOldDegree = 2;
- xProperties->getPropertyValue( "PolynomialDegree" ) >>= aOldDegree;
- if (aOldDegree != aDegree)
- {
- xProperties->setPropertyValue( "PolynomialDegree" , uno::makeAny( aDegree ));
- bChanged = true;
- }
- }
+ bChanged = lclConvertToPropertySet<sal_Int32, SfxInt32Item>(rItemSet, nWhichId, xProperties, OUString("PolynomialDegree"));
}
break;
case SCHATTR_REGRESSION_PERIOD:
{
- 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() )
- {
- sal_Int32 aOldPeriod = 2;
- xProperties->getPropertyValue( "MovingAveragePeriod" ) >>= aOldPeriod;
- if (aOldPeriod != aPeriod)
- {
- xProperties->setPropertyValue( "MovingAveragePeriod" , uno::makeAny( aPeriod ));
- bChanged = true;
- }
- }
+ bChanged = lclConvertToPropertySet<sal_Int32, SfxInt32Item>(rItemSet, nWhichId, xProperties, "MovingAveragePeriod");
}
break;
case SCHATTR_REGRESSION_EXTRAPOLATE_FORWARD:
{
- 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() )
- {
- double aOldValue = 0.0;
- xProperties->getPropertyValue( "ExtrapolateForward" ) >>= aOldValue;
- if (aOldValue != aValue)
- {
- xProperties->setPropertyValue( "ExtrapolateForward" , uno::makeAny( aValue ));
- bChanged = true;
- }
- }
+ bChanged = lclConvertToPropertySet<double, SvxDoubleItem>(rItemSet, nWhichId, xProperties, "ExtrapolateForward");
}
break;
case SCHATTR_REGRESSION_EXTRAPOLATE_BACKWARD:
{
- 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() )
- {
- double aOldValue = 0.0;
- xProperties->getPropertyValue( "ExtrapolateBackward" ) >>= aOldValue;
- if (aOldValue != aValue)
- {
- xProperties->setPropertyValue( "ExtrapolateBackward" , uno::makeAny( aValue ));
- bChanged = true;
- }
- }
+ bChanged = lclConvertToPropertySet<double, SvxDoubleItem>(rItemSet, nWhichId, xProperties, "ExtrapolateBackward");
}
break;
case SCHATTR_REGRESSION_SET_INTERCEPT:
{
- 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() )
- {
- sal_Bool bOldValue = false;
- xProperties->getPropertyValue( "ForceIntercept" ) >>= bOldValue;
- if (bOldValue != bNewValue)
- {
- xProperties->setPropertyValue( "ForceIntercept" , uno::makeAny( bNewValue ));
- bChanged = true;
- }
- }
+ bChanged = lclConvertToPropertySet<sal_Bool, SfxBoolItem>(rItemSet, nWhichId, xProperties, "ForceIntercept");
}
break;
case SCHATTR_REGRESSION_INTERCEPT_VALUE:
{
- 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() )
- {
- double aOldValue = 0.0;
- xProperties->getPropertyValue( "InterceptValue" ) >>= aOldValue;
- if (aOldValue != aValue)
- {
- xProperties->setPropertyValue( "InterceptValue" , uno::makeAny( aValue ));
- bChanged = true;
- }
- }
+ bChanged = lclConvertToPropertySet<double, SvxDoubleItem>(rItemSet, nWhichId, xProperties, "InterceptValue");
}
break;
case SCHATTR_REGRESSION_SHOW_EQUATION:
{
- 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;
- }
+ bChanged = lclConvertToPropertySet<sal_Bool, SfxBoolItem>(rItemSet, nWhichId, xEqProp, "ShowEquation");
}
break;
case SCHATTR_REGRESSION_SHOW_COEFF:
{
- 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;
- }
+ bChanged = lclConvertToPropertySet<sal_Bool, SfxBoolItem>(rItemSet, nWhichId, xEqProp, "ShowCorrelationCoefficient");
}
break;
}
return bChanged;
}
-void RegressionCurveItemConverter::FillSpecialItem(
- sal_uInt16 nWhichId, SfxItemSet & rOutItemSet ) const
+void RegressionCurveItemConverter::FillSpecialItem(sal_uInt16 nWhichId, SfxItemSet& rOutItemSet ) const
throw( uno::Exception )
{
- uno::Reference< chart2::XRegressionCurve > xCurve( GetPropertySet(), uno::UNO_QUERY );
+ uno::Reference<chart2::XRegressionCurve> xCurve(GetPropertySet(), uno::UNO_QUERY);
+ OSL_ASSERT(xCurve.is());
+ if(!xCurve.is())
+ return;
+
+ uno::Reference< beans::XPropertySet > xProperties( xCurve, uno::UNO_QUERY );
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 )));
- rOutItemSet.Put( SvxChartRegressItem( eRegress, SCHATTR_REGRESSION_TYPE ));
- }
+ sal_Int32 aRegressionType = static_cast< sal_Int32 >(RegressionCurveHelper::getRegressionType(xCurve));
+ SvxChartRegress eRegress = static_cast< SvxChartRegress >(aRegressionType);
+ rOutItemSet.Put( SvxChartRegressItem( eRegress, SCHATTR_REGRESSION_TYPE ));
}
break;
case SCHATTR_REGRESSION_DEGREE:
{
- OSL_ASSERT( xCurve.is());
- if( xCurve.is())
- {
- uno::Reference< beans::XPropertySet > xProperties( xCurve, uno::UNO_QUERY );
- OSL_ASSERT( xProperties.is());
- sal_Int32 aDegree = 1;
- if( xProperties.is() &&
- (xProperties->getPropertyValue( "PolynomialDegree" ) >>= aDegree))
- {
- rOutItemSet.Put( SfxInt32Item( nWhichId, aDegree ));
- }
- }
+ lclConvertToItemSet<sal_Int32, SfxInt32Item>(rOutItemSet, nWhichId, xProperties, "PolynomialDegree");
}
break;
case SCHATTR_REGRESSION_PERIOD:
{
- OSL_ASSERT( xCurve.is());
- if( xCurve.is())
- {
- uno::Reference< beans::XPropertySet > xProperties( xCurve, uno::UNO_QUERY );
- OSL_ASSERT( xProperties.is());
- sal_Int32 aPeriod = 2;
- if( xProperties.is() &&
- (xProperties->getPropertyValue( "MovingAveragePeriod" ) >>= aPeriod))
- {
- rOutItemSet.Put( SfxInt32Item( nWhichId, aPeriod ));
- }
- }
+ lclConvertToItemSet<sal_Int32, SfxInt32Item>(rOutItemSet, nWhichId, xProperties, "MovingAveragePeriod");
}
break;
case SCHATTR_REGRESSION_EXTRAPOLATE_FORWARD:
{
- OSL_ASSERT( xCurve.is());
- if( xCurve.is())
- {
- uno::Reference< beans::XPropertySet > xProperties( xCurve, uno::UNO_QUERY );
- OSL_ASSERT( xProperties.is());
- double aValue = 0.0;
- if( xProperties.is() &&
- (xProperties->getPropertyValue( "ExtrapolateForward" ) >>= aValue))
- {
- rOutItemSet.Put( SvxDoubleItem( aValue, nWhichId ));
- }
- }
+ lclConvertToItemSetDouble(rOutItemSet, nWhichId, xProperties, "ExtrapolateForward");
}
break;
case SCHATTR_REGRESSION_EXTRAPOLATE_BACKWARD:
{
- OSL_ASSERT( xCurve.is());
- if( xCurve.is())
- {
- uno::Reference< beans::XPropertySet > xProperties( xCurve, uno::UNO_QUERY );
- OSL_ASSERT( xProperties.is());
- double aValue = 0.0;
- if( xProperties.is() &&
- (xProperties->getPropertyValue( "ExtrapolateBackward" ) >>= aValue))
- {
- rOutItemSet.Put( SvxDoubleItem( aValue, nWhichId ));
- }
- }
+ lclConvertToItemSetDouble(rOutItemSet, nWhichId, xProperties, "ExtrapolateBackward");
}
break;
case SCHATTR_REGRESSION_SET_INTERCEPT:
{
- OSL_ASSERT( xCurve.is());
- if( xCurve.is())
- {
- uno::Reference< beans::XPropertySet > xProperties( xCurve, uno::UNO_QUERY );
- OSL_ASSERT( xProperties.is());
- sal_Bool bForceIntercept = false;
- if( xProperties.is() &&
- (xProperties->getPropertyValue( "ForceIntercept" ) >>= bForceIntercept))
- {
- rOutItemSet.Put( SfxBoolItem( nWhichId, bForceIntercept ));
- }
- }
+ lclConvertToItemSet<sal_Bool, SfxBoolItem>(rOutItemSet, nWhichId, xProperties, "ForceIntercept");
}
break;
case SCHATTR_REGRESSION_INTERCEPT_VALUE:
{
- OSL_ASSERT( xCurve.is());
- if( xCurve.is())
- {
- uno::Reference< beans::XPropertySet > xProperties( xCurve, uno::UNO_QUERY );
- OSL_ASSERT( xProperties.is());
- double aValue = 0.0;
- if( xProperties.is() &&
- (xProperties->getPropertyValue( "InterceptValue" ) >>= aValue))
- {
- rOutItemSet.Put( SvxDoubleItem( aValue, nWhichId ));
- }
- }
+ lclConvertToItemSetDouble(rOutItemSet, nWhichId, xProperties, "InterceptValue");
}
break;
case SCHATTR_REGRESSION_SHOW_EQUATION:
{
- OSL_ASSERT( xCurve.is());
- if( xCurve.is())
- {
- uno::Reference< beans::XPropertySet > xEqProp( xCurve->getEquationProperties());
- OSL_ASSERT( xEqProp.is());
- bool bShow = false;
- if( xEqProp.is() &&
- (xEqProp->getPropertyValue( "ShowEquation" ) >>= bShow))
- {
- rOutItemSet.Put( SfxBoolItem( nWhichId, bShow ));
- }
- }
+ lclConvertToItemSet<sal_Bool, SfxBoolItem>(rOutItemSet, nWhichId, xCurve->getEquationProperties(), "ShowEquation");
}
break;
case SCHATTR_REGRESSION_SHOW_COEFF:
{
- OSL_ASSERT( xCurve.is());
- if( xCurve.is())
- {
- uno::Reference< beans::XPropertySet > xEqProp( xCurve->getEquationProperties());
- OSL_ASSERT( xEqProp.is());
- bool bShow = false;
- if( xEqProp.is() &&
- (xEqProp->getPropertyValue( "ShowCorrelationCoefficient" ) >>= bShow))
- {
- rOutItemSet.Put( SfxBoolItem( nWhichId, bShow ));
- }
- }
+ lclConvertToItemSet<sal_Bool, SfxBoolItem>(rOutItemSet, nWhichId, xCurve->getEquationProperties(), "ShowCorrelationCoefficient");
}
break;
}
diff --git a/chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx b/chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx
index bf4f050e0863..3693ea5f511e 100644
--- a/chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx
+++ b/chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx
@@ -201,6 +201,52 @@ uno::Reference< beans::XPropertySet > lcl_getCurveProperties(
return uno::Reference< beans::XPropertySet >();
}
+template <class T, class D>
+bool lclConvertToPropertySet(const SfxItemSet& rItemSet, sal_uInt16 nWhichId, uno::Reference<beans::XPropertySet> xProperties, OUString aPropertyID)
+{
+ OSL_ASSERT(xProperties.is());
+ if( xProperties.is() )
+ {
+ T aValue = static_cast<T>(static_cast<const D&>(rItemSet.Get( nWhichId )).GetValue());
+ T aOldValue = aValue;
+ bool aSuccess = xProperties->getPropertyValue( aPropertyID ) >>= aOldValue;
+ if (!aSuccess || aOldValue != aValue)
+ {
+ xProperties->setPropertyValue( aPropertyID , uno::makeAny( aValue ));
+ return true;
+ }
+ }
+ return false;
+}
+
+template <class T, class D>
+void lclConvertToItemSet(SfxItemSet& rItemSet, sal_uInt16 nWhichId, uno::Reference<beans::XPropertySet> xProperties, OUString aPropertyID)
+{
+ OSL_ASSERT(xProperties.is());
+ if( xProperties.is() )
+ {
+ T aValue = static_cast<T>(static_cast<const D&>(rItemSet.Get( nWhichId )).GetValue());
+ if(xProperties->getPropertyValue( aPropertyID ) >>= aValue)
+ {
+ rItemSet.Put(D( nWhichId, aValue ));
+ }
+ }
+}
+
+void lclConvertToItemSetDouble(SfxItemSet& rItemSet, sal_uInt16 nWhichId, uno::Reference<beans::XPropertySet> xProperties, OUString aPropertyID)
+{
+ OSL_ASSERT(xProperties.is());
+ if( xProperties.is() )
+ {
+ double aValue = static_cast<double>(static_cast<const SvxDoubleItem&>(rItemSet.Get( nWhichId )).GetValue());
+ if(xProperties->getPropertyValue( aPropertyID ) >>= aValue)
+ {
+ rItemSet.Put(SvxDoubleItem( aValue, nWhichId ));
+ }
+ }
+}
+
+
} // anonymous namespace
namespace chart
@@ -452,144 +498,56 @@ bool StatisticsItemConverter::ApplySpecialItem(
case SCHATTR_REGRESSION_DEGREE:
{
uno::Reference< beans::XPropertySet > xProperties( lcl_getCurveProperties( GetPropertySet(), &rItemSet ));
- if( xProperties.is())
- {
- sal_Int32 aDegree = 1;
- xProperties->getPropertyValue( "PolynomialDegree" ) >>= aDegree;
- sal_Int32 aNewDegree =
- static_cast< const SfxInt32Item & >( rItemSet.Get( nWhichId )).GetValue();
- if( aDegree != aNewDegree )
- {
- xProperties->setPropertyValue( "PolynomialDegree" , uno::makeAny( aNewDegree ));
- bChanged = true;
- }
- }
+ bChanged = lclConvertToPropertySet<sal_Int32, SfxInt32Item>(rItemSet, nWhichId, xProperties, "PolynomialDegree");
}
break;
case SCHATTR_REGRESSION_PERIOD:
{
uno::Reference< beans::XPropertySet > xProperties( lcl_getCurveProperties( GetPropertySet(), &rItemSet ));
- if( xProperties.is())
- {
- sal_Int32 aPeriod = 2;
- xProperties->getPropertyValue( "MovingAveragePeriod" ) >>= aPeriod;
- sal_Int32 aNewPeriod =
- static_cast< const SfxInt32Item & >( rItemSet.Get( nWhichId )).GetValue();
- if( aPeriod != aNewPeriod )
- {
- xProperties->setPropertyValue( "MovingAveragePeriod" , uno::makeAny( aNewPeriod ));
- bChanged = true;
- }
- }
+ bChanged = lclConvertToPropertySet<sal_Int32, SfxInt32Item>(rItemSet, nWhichId, xProperties, "MovingAveragePeriod");
}
break;
case SCHATTR_REGRESSION_EXTRAPOLATE_FORWARD:
{
uno::Reference< beans::XPropertySet > xProperties( lcl_getCurveProperties( GetPropertySet(), &rItemSet ));
- if( xProperties.is())
- {
- double aExtrapolationValue = 0.0;
- xProperties->getPropertyValue( "ExtrapolateForward" ) >>= aExtrapolationValue;
- double aNewValue =
- static_cast< const SvxDoubleItem & >( rItemSet.Get( nWhichId )).GetValue();
- if( aExtrapolationValue != aNewValue )
- {
- xProperties->setPropertyValue( "ExtrapolateForward" , uno::makeAny( aNewValue ));
- bChanged = true;
- }
- }
+ bChanged = lclConvertToPropertySet<double, SvxDoubleItem>(rItemSet, nWhichId, xProperties, "ExtrapolateForward");
}
break;
case SCHATTR_REGRESSION_EXTRAPOLATE_BACKWARD:
{
uno::Reference< beans::XPropertySet > xProperties( lcl_getCurveProperties( GetPropertySet(), &rItemSet ));
- if( xProperties.is())
- {
- double aExtrapolationValue = 0.0;
- xProperties->getPropertyValue( "ExtrapolateBackward" ) >>= aExtrapolationValue;
- double aNewValue =
- static_cast< const SvxDoubleItem & >( rItemSet.Get( nWhichId )).GetValue();
- if( aExtrapolationValue != aNewValue )
- {
- xProperties->setPropertyValue( "ExtrapolateBackward" , uno::makeAny( aNewValue ));
- bChanged = true;
- }
- }
+ bChanged = lclConvertToPropertySet<double, SvxDoubleItem>(rItemSet, nWhichId, xProperties, "ExtrapolateBackward");
}
break;
case SCHATTR_REGRESSION_SET_INTERCEPT:
{
uno::Reference< beans::XPropertySet > xProperties( lcl_getCurveProperties( GetPropertySet(), &rItemSet ));
- if( xProperties.is())
- {
- sal_Bool aSetInterceptValue = false;
- xProperties->getPropertyValue( "ForceIntercept" ) >>= aSetInterceptValue;
- sal_Bool bNewValue =
- static_cast< const SfxBoolItem & >( rItemSet.Get( nWhichId )).GetValue();
- if( aSetInterceptValue != bNewValue )
- {
- xProperties->setPropertyValue( "ForceIntercept" , uno::makeAny( bNewValue ));
- bChanged = true;
- }
- }
+ bChanged = lclConvertToPropertySet<sal_Bool, SfxBoolItem>(rItemSet, nWhichId, xProperties, "InterceptValue");
}
break;
case SCHATTR_REGRESSION_INTERCEPT_VALUE:
{
uno::Reference< beans::XPropertySet > xProperties( lcl_getCurveProperties( GetPropertySet(), &rItemSet ));
- if( xProperties.is())
- {
- double aInterceptValue = 0.0;
- xProperties->getPropertyValue( "InterceptValue" ) >>= aInterceptValue;
- double aNewValue =
- static_cast< const SvxDoubleItem& >( rItemSet.Get( nWhichId )).GetValue();
- if( aInterceptValue != aNewValue )
- {
- xProperties->setPropertyValue( "InterceptValue" , uno::makeAny( aNewValue ));
- bChanged = true;
- }
- }
+ bChanged = lclConvertToPropertySet<double, SvxDoubleItem>(rItemSet, nWhichId, xProperties, "InterceptValue");
}
break;
case SCHATTR_REGRESSION_SHOW_EQUATION:
{
uno::Reference< beans::XPropertySet > xEqProp( lcl_getEquationProperties( GetPropertySet(), &rItemSet ));
- if( xEqProp.is())
- {
- bool bShowEq = false;
- xEqProp->getPropertyValue( "ShowEquation" ) >>= bShowEq;
- bool bNewShowEq =
- static_cast< const SfxBoolItem & >( rItemSet.Get( nWhichId )).GetValue();
- if( bShowEq != bNewShowEq )
- {
- xEqProp->setPropertyValue( "ShowEquation" , uno::makeAny( bNewShowEq ));
- bChanged = true;
- }
- }
+ bChanged = lclConvertToPropertySet<sal_Bool, SfxBoolItem>(rItemSet, nWhichId, xEqProp, "ShowEquation");
}
break;
case SCHATTR_REGRESSION_SHOW_COEFF:
{
uno::Reference< beans::XPropertySet > xEqProp( lcl_getEquationProperties( GetPropertySet(), &rItemSet ));
- if( xEqProp.is())
- {
- bool bShowCoeff = false;
- xEqProp->getPropertyValue( "ShowCorrelationCoefficient" ) >>= bShowCoeff;
- bool bNewShowCoeff =
- static_cast< const SfxBoolItem & >( rItemSet.Get( nWhichId )).GetValue();
- if( bShowCoeff != bNewShowCoeff )
- {
- xEqProp->setPropertyValue( "ShowCorrelationCoefficient" , uno::makeAny( bNewShowCoeff ));
- bChanged = true;
- }
- }
+ bChanged = lclConvertToPropertySet<sal_Bool, SfxBoolItem>(rItemSet, nWhichId, xEqProp, "ShowCorrelationCoefficient");
}
break;
@@ -801,81 +759,58 @@ void StatisticsItemConverter::FillSpecialItem(
case SCHATTR_REGRESSION_DEGREE:
{
- sal_Int32 aDegree = 1;
- uno::Reference< beans::XPropertySet > xProperties( lcl_getCurveProperties( GetPropertySet(), 0 ));
- if( xProperties.is())
- xProperties->getPropertyValue( "PolynomialDegree" ) >>= aDegree;
- rOutItemSet.Put( SfxInt32Item( nWhichId, aDegree ));
+
+ uno::Reference<beans::XPropertySet> xProperties( lcl_getCurveProperties( GetPropertySet(), 0 ));
+ lclConvertToItemSet<sal_Int32, SfxInt32Item>(rOutItemSet, nWhichId, xProperties, "PolynomialDegree");
}
break;
case SCHATTR_REGRESSION_PERIOD:
{
- sal_Int32 aPeriod = 2;
uno::Reference< beans::XPropertySet > xProperties( lcl_getCurveProperties( GetPropertySet(), 0 ));
- if( xProperties.is())
- xProperties->getPropertyValue( "MovingAveragePeriod" ) >>= aPeriod;
- rOutItemSet.Put( SfxInt32Item( nWhichId, aPeriod ));
+ lclConvertToItemSet<sal_Int32, SfxInt32Item>(rOutItemSet, nWhichId, xProperties, "MovingAveragePeriod");
}
break;
case SCHATTR_REGRESSION_EXTRAPOLATE_FORWARD:
{
- double aValue = 0.0;
uno::Reference< beans::XPropertySet > xProperties( lcl_getCurveProperties( GetPropertySet(), 0 ));
- if( xProperties.is())
- xProperties->getPropertyValue( "ExtrapolateForward" ) >>= aValue;
- rOutItemSet.Put( SvxDoubleItem( aValue, nWhichId ));
+ lclConvertToItemSetDouble(rOutItemSet, nWhichId, xProperties, "ExtrapolateForward");
}
break;
case SCHATTR_REGRESSION_EXTRAPOLATE_BACKWARD:
{
- double aValue = 0.0;
uno::Reference< beans::XPropertySet > xProperties( lcl_getCurveProperties( GetPropertySet(), 0 ));
- if( xProperties.is())
- xProperties->getPropertyValue( "ExtrapolateBackward" ) >>= aValue;
- rOutItemSet.Put( SvxDoubleItem( aValue, nWhichId ));
+ lclConvertToItemSetDouble(rOutItemSet, nWhichId, xProperties, "ExtrapolateBackward");
}
break;
case SCHATTR_REGRESSION_SET_INTERCEPT:
{
- sal_Bool bForceIntercept = false;
uno::Reference< beans::XPropertySet > xProperties( lcl_getCurveProperties( GetPropertySet(), 0 ));
- if( xProperties.is())
- xProperties->getPropertyValue( "ForceIntercept" ) >>= bForceIntercept;
- rOutItemSet.Put( SfxBoolItem( nWhichId, bForceIntercept ));
+ lclConvertToItemSet<sal_Bool, SfxBoolItem>(rOutItemSet, nWhichId, xProperties, "ForceIntercept");
}
break;
case SCHATTR_REGRESSION_INTERCEPT_VALUE:
{
- double aValue = 0.0;
uno::Reference< beans::XPropertySet > xProperties( lcl_getCurveProperties( GetPropertySet(), 0 ));
- if( xProperties.is())
- xProperties->getPropertyValue( "InterceptValue" ) >>= aValue;
- rOutItemSet.Put( SvxDoubleItem( aValue, nWhichId ));
+ lclConvertToItemSetDouble(rOutItemSet, nWhichId, xProperties, "InterceptValue");
}
break;
case SCHATTR_REGRESSION_SHOW_EQUATION:
{
- bool bShowEq = false;
uno::Reference< beans::XPropertySet > xEqProp( lcl_getEquationProperties( GetPropertySet(), 0 ));
- if( xEqProp.is())
- xEqProp->getPropertyValue( "ShowEquation" ) >>= bShowEq;
- rOutItemSet.Put( SfxBoolItem( nWhichId, bShowEq ));
+ lclConvertToItemSet<sal_Bool, SfxBoolItem>(rOutItemSet, nWhichId, xEqProp, "ShowEquation");
}
break;
case SCHATTR_REGRESSION_SHOW_COEFF:
{
- bool bShowCoeff = false;
uno::Reference< beans::XPropertySet > xEqProp( lcl_getEquationProperties( GetPropertySet(), 0 ));
- if( xEqProp.is())
- xEqProp->getPropertyValue( "ShowCorrelationCoefficient" ) >>= bShowCoeff;
- rOutItemSet.Put( SfxBoolItem( nWhichId, bShowCoeff ));
+ lclConvertToItemSet<sal_Bool, SfxBoolItem>(rOutItemSet, nWhichId, xEqProp, "ShowCorrelationCoefficient");
}
break;
diff --git a/chart2/source/view/main/ChartItemPool.cxx b/chart2/source/view/main/ChartItemPool.cxx
index ef480dddd3de..b5c21d3bc4fa 100644
--- a/chart2/source/view/main/ChartItemPool.cxx
+++ b/chart2/source/view/main/ChartItemPool.cxx
@@ -156,7 +156,7 @@ ChartItemPool::ChartItemPool():
ppPoolDefaults[SCHATTR_REGRESSION_EXTRAPOLATE_FORWARD - SCHATTR_START] = new SvxDoubleItem(0.0, SCHATTR_REGRESSION_EXTRAPOLATE_FORWARD);
ppPoolDefaults[SCHATTR_REGRESSION_EXTRAPOLATE_BACKWARD - SCHATTR_START] = new SvxDoubleItem(0.0, SCHATTR_REGRESSION_EXTRAPOLATE_BACKWARD);
ppPoolDefaults[SCHATTR_REGRESSION_SET_INTERCEPT - SCHATTR_START] = new SfxBoolItem(SCHATTR_REGRESSION_SET_INTERCEPT, sal_False);
- ppPoolDefaults[SCHATTR_REGRESSION_INTERCEPT_VALUE - SCHATTR_START] = new SvxDoubleItem( 0.0, SCHATTR_REGRESSION_INTERCEPT_VALUE);
+ ppPoolDefaults[SCHATTR_REGRESSION_INTERCEPT_VALUE - SCHATTR_START] = new SvxDoubleItem(0.0, SCHATTR_REGRESSION_INTERCEPT_VALUE);
/**************************************************************************
* ItemInfos