summaryrefslogtreecommitdiff
path: root/chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx
diff options
context:
space:
mode:
authorTomaž Vajngerl <quikee@gmail.com>2013-05-27 08:02:37 +0200
committerTomaž Vajngerl <quikee@gmail.com>2013-07-03 21:46:39 +0200
commite6a0cc2d6cb37bf4e04861173c7e55b307513778 (patch)
tree3569da62ea24a3fd4dce7216751692b1a5e79306 /chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx
parentc63b74d22d360893bb9e1200f59099ffb7943705 (diff)
fdo#35712 polynomial and moving average regression lines
- added polynomial and moving average to the dialog - implemented moving average and polynomal RegressionCurveCalculator - added icon for polynomial regression curve - prepare icon for moving average regression curve - degree parameter for polynomial regression curve - period parameter for moving average regression curve - limit the curve to max and min x value - added extrapolation Change-Id: I4ebb8dc23a3aff285b999e115fdda20ab11910a5
Diffstat (limited to 'chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx')
-rw-r--r--chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx181
1 files changed, 181 insertions, 0 deletions
diff --git a/chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx b/chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx
index fcf49d925ec2..3ea1c0dd4363 100644
--- a/chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx
+++ b/chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx
@@ -28,6 +28,7 @@
// for SfxBoolItem
#include <svl/eitem.hxx>
+#include <svl/intitem.hxx>
#include <svx/chrtitem.hxx>
#include <functional>
@@ -55,6 +56,12 @@ namespace
case CHREGRESS_POWER:
eType = ::chart::RegressionCurveHelper::REGRESSION_TYPE_POWER;
break;
+ case CHREGRESS_POLYNOMIAL:
+ eType = ::chart::RegressionCurveHelper::REGRESSION_TYPE_POLYNOMIAL;
+ break;
+ case CHREGRESS_MOVING_AVERAGE:
+ eType = ::chart::RegressionCurveHelper::REGRESSION_TYPE_MOVING_AVERAGE;
+ break;
case CHREGRESS_NONE:
break;
}
@@ -156,6 +163,112 @@ bool RegressionCurveItemConverter::ApplySpecialItem(
}
break;
+ case SCHATTR_REGRESSION_DEGREE:
+ {
+ if( xCurve.is())
+ {
+ 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());
+ sal_Int32 aOldDegree = 1;
+ if( xProperties.is() )
+ {
+ xProperties->getPropertyValue( "PolynomialDegree" ) >>= aOldDegree;
+ if (aOldDegree != aDegree)
+ {
+ xProperties->setPropertyValue( "PolynomialDegree" , uno::makeAny( aDegree ));
+ bChanged = true;
+ }
+ }
+ }
+ }
+ break;
+
+ case SCHATTR_REGRESSION_PERIOD:
+ {
+ if( xCurve.is())
+ {
+ 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());
+ sal_Int32 aOldPeriod = 2;
+ if( xProperties.is() )
+ {
+ xProperties->getPropertyValue( "MovingAveragePeriod" ) >>= aOldPeriod;
+ if (aOldPeriod != aPeriod)
+ {
+ xProperties->setPropertyValue( "MovingAveragePeriod" , uno::makeAny( aPeriod ));
+ bChanged = true;
+ }
+ }
+ }
+ }
+ break;
+
+ case SCHATTR_REGRESSION_EXTRAPOLATE_FORWARD:
+ {
+ if( xCurve.is())
+ {
+ 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());
+ double aOldValue = 0.0;
+ if( xProperties.is() )
+ {
+ xProperties->getPropertyValue( "ExtrapolateForward" ) >>= aOldValue;
+ if (aOldValue != aValue)
+ {
+ xProperties->setPropertyValue( "ExtrapolateForward" , uno::makeAny( aValue ));
+ bChanged = true;
+ }
+ }
+ }
+ }
+ break;
+
+ case SCHATTR_REGRESSION_EXTRAPOLATE_BACKWARD:
+ {
+ if( xCurve.is())
+ {
+ 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());
+ double aOldValue = 0.0;
+ if( xProperties.is() )
+ {
+ xProperties->getPropertyValue( "ExtrapolateBackward" ) >>= aOldValue;
+ if (aOldValue != aValue)
+ {
+ xProperties->setPropertyValue( "ExtrapolateBackward" , uno::makeAny( aValue ));
+ bChanged = true;
+ }
+ }
+ }
+ }
+ break;
+
+ case SCHATTR_REGRESSION_SET_INTERCEPT:
+ {
+ }
+ break;
+
+ case SCHATTR_REGRESSION_INTERCEPT_VALUE:
+ {
+ }
+ break;
+
case SCHATTR_REGRESSION_SHOW_EQUATION:
{
OSL_ASSERT( xCurve.is());
@@ -226,6 +339,74 @@ void RegressionCurveItemConverter::FillSpecialItem(
}
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 ));
+ }
+ }
+ }
+ 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 ));
+ }
+ }
+ }
+ 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 ));
+ }
+ }
+ }
+ 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 ));
+ }
+ }
+ }
+ break;
+
case SCHATTR_REGRESSION_SHOW_EQUATION:
{
OSL_ASSERT( xCurve.is());