summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--chart2/qa/extras/chart2export.cxx16
-rw-r--r--chart2/source/inc/RegressionCurveModel.hxx1
-rw-r--r--chart2/source/tools/RegressionCurveModel.cxx11
3 files changed, 24 insertions, 4 deletions
diff --git a/chart2/qa/extras/chart2export.cxx b/chart2/qa/extras/chart2export.cxx
index 6e9a18efeed5..2f5f030ef3d1 100644
--- a/chart2/qa/extras/chart2export.cxx
+++ b/chart2/qa/extras/chart2export.cxx
@@ -52,7 +52,7 @@ void checkCommonTrendline(
Reference<chart2::XRegressionCurve> const & xCurve,
double aExpectedExtrapolateForward, double aExpectedExtrapolateBackward,
bool aExpectedForceIntercept, double aExpectedInterceptValue,
- bool aExpectedShowEquation, bool aExpectedR2)
+ bool aExpectedShowEquation, bool aExpectedR2, bool aExpectedMayHaveR2)
{
Reference<XPropertySet> xProperties( xCurve , uno::UNO_QUERY );
CPPUNIT_ASSERT(xProperties.is());
@@ -86,6 +86,10 @@ void checkCommonTrendline(
bool bShowCorrelationCoefficient = false;
CPPUNIT_ASSERT(xEquationProperties->getPropertyValue("ShowCorrelationCoefficient") >>= bShowCorrelationCoefficient);
CPPUNIT_ASSERT_EQUAL(aExpectedR2, bShowCorrelationCoefficient);
+
+ bool bMayHaveR2 = false;
+ CPPUNIT_ASSERT(xEquationProperties->getPropertyValue("MayHaveCorrelationCoefficient") >>= bMayHaveR2);
+ CPPUNIT_ASSERT_EQUAL(aExpectedMayHaveR2, bMayHaveR2);
}
void checkNameAndType(Reference<XPropertySet> const & xProperties, const OUString& aExpectedName, const OUString& aExpectedServiceName)
@@ -115,7 +119,7 @@ void checkLinearTrendline(
xCurve,
aExpectedExtrapolateForward, aExpectedExtrapolateBackward,
/*aExpectedForceIntercept*/false, aExpectedInterceptValue,
- /*aExpectedShowEquation*/true, /*aExpectedR2*/false);
+ /*aExpectedShowEquation*/true, /*aExpectedR2*/false, /*aExpectedMayHaveR2*/true);
}
void checkPolynomialTrendline(
@@ -137,7 +141,7 @@ void checkPolynomialTrendline(
xCurve,
aExpectedExtrapolateForward, aExpectedExtrapolateBackward,
/*aExpectedForceIntercept*/true, aExpectedInterceptValue,
- /*aExpectedShowEquation*/true, /*aExpectedR2*/true);
+ /*aExpectedShowEquation*/true, /*aExpectedR2*/true, /*aExpectedMayHaveR2*/true);
}
void checkMovingAverageTrendline(
@@ -151,6 +155,12 @@ void checkMovingAverageTrendline(
sal_Int32 aPeriod = 2;
CPPUNIT_ASSERT(xProperties->getPropertyValue("MovingAveragePeriod") >>= aPeriod);
CPPUNIT_ASSERT_EQUAL(aExpectedPeriod, aPeriod);
+
+ checkCommonTrendline(
+ xCurve,
+ /*aExpectedExtrapolateForward*/0.0, /*aExpectedExtrapolateBackward*/0.0,
+ /*aExpectedForceIntercept*/false, /*aExpectedInterceptValue*/0.0,
+ /*aExpectedShowEquation*/false, /*aExpectedR2*/false, /*aExpectedMayHaveR2*/false);
}
void checkTrendlinesInChart(uno::Reference< chart2::XChartDocument > const & xChartDoc)
diff --git a/chart2/source/inc/RegressionCurveModel.hxx b/chart2/source/inc/RegressionCurveModel.hxx
index 89955f1314e4..ddd75a8391a1 100644
--- a/chart2/source/inc/RegressionCurveModel.hxx
+++ b/chart2/source/inc/RegressionCurveModel.hxx
@@ -119,6 +119,7 @@ private:
rtl::Reference<ModifyEventForwarder> m_xModifyEventForwarder;
css::uno::Reference< css::beans::XPropertySet > m_xEquationProperties;
+ void setPropertyMayHaveR2();
};
// implementations for factory instantiation
diff --git a/chart2/source/tools/RegressionCurveModel.cxx b/chart2/source/tools/RegressionCurveModel.cxx
index 5c1082e89a74..06be003ef106 100644
--- a/chart2/source/tools/RegressionCurveModel.cxx
+++ b/chart2/source/tools/RegressionCurveModel.cxx
@@ -183,12 +183,20 @@ void SAL_CALL RegressionCurveModel::setEquationProperties( const uno::Reference<
ModifyListenerHelper::removeListener( m_xEquationProperties, m_xModifyEventForwarder );
m_xEquationProperties.set( xEquationProperties );
- m_xEquationProperties->setPropertyValue( "MayHaveCorrelationCoefficient", uno::Any( m_eRegressionCurveType != CURVE_TYPE_MOVING_AVERAGE ) );
+ setPropertyMayHaveR2();
ModifyListenerHelper::addListener( m_xEquationProperties, m_xModifyEventForwarder );
fireModifyEvent();
}
}
+void RegressionCurveModel::setPropertyMayHaveR2()
+{
+ if( m_xEquationProperties.is()) {
+ bool bMayHaveR2 = m_eRegressionCurveType != CURVE_TYPE_MOVING_AVERAGE;
+ m_xEquationProperties->setPropertyValue( "MayHaveCorrelationCoefficient", uno::Any( bMayHaveR2 ) );
+ }
+}
+
// ____ XServiceName ____
OUString SAL_CALL RegressionCurveModel::getServiceName()
{
@@ -239,6 +247,7 @@ void SAL_CALL RegressionCurveModel::disposing( const lang::EventObject& /* Sourc
// ____ OPropertySet ____
void RegressionCurveModel::firePropertyChangeEvent()
{
+ setPropertyMayHaveR2();
fireModifyEvent();
}