chart2/qa/extras/chart2export.cxx | 16 +++++++++++++--- chart2/source/inc/RegressionCurveModel.hxx | 1 + chart2/source/tools/RegressionCurveModel.cxx | 11 ++++++++++- 3 files changed, 24 insertions(+), 4 deletions(-)
New commits: commit 4defe6e3c4ab16ee0993c74d9af30fe1abecb8c5 Author: Laurent Balland <laurent.ball...@mailo.fr> AuthorDate: Sun Jul 2 18:00:31 2023 +0200 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Mon Aug 7 10:46:35 2023 +0200 tdf#155526 Remove Insert R2 in all cases When opening a file containing a Moving average trend line, addRegressionCurve is not used, then MayHaveCorrelationCoefficient property is not correctly set. This change modify this property in all cases. Update property in firePropertyChangeEvent() as it is not possible in constructor: JunitTest_chart2_unoapi fails in MeanValue as SolarMutex is not owned Add QA test Change-Id: I13bdb81239a7362431edcf28bfc38ac4820a7776 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153859 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> (cherry picked from commit 6fc12ad600a1ee10253c269a5988907a2894be76) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155174 Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> diff --git a/chart2/qa/extras/chart2export.cxx b/chart2/qa/extras/chart2export.cxx index f287577fb63a..67101a09fad0 100644 --- a/chart2/qa/extras/chart2export.cxx +++ b/chart2/qa/extras/chart2export.cxx @@ -163,7 +163,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()); @@ -197,6 +197,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) @@ -226,7 +230,7 @@ void checkLinearTrendline( xCurve, aExpectedExtrapolateForward, aExpectedExtrapolateBackward, /*aExpectedForceIntercept*/false, aExpectedInterceptValue, - /*aExpectedShowEquation*/true, /*aExpectedR2*/false); + /*aExpectedShowEquation*/true, /*aExpectedR2*/false, /*aExpectedMayHaveR2*/true); } void checkPolynomialTrendline( @@ -248,7 +252,7 @@ void checkPolynomialTrendline( xCurve, aExpectedExtrapolateForward, aExpectedExtrapolateBackward, /*aExpectedForceIntercept*/true, aExpectedInterceptValue, - /*aExpectedShowEquation*/true, /*aExpectedR2*/true); + /*aExpectedShowEquation*/true, /*aExpectedR2*/true, /*aExpectedMayHaveR2*/true); } void checkMovingAverageTrendline( @@ -262,6 +266,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 d64d053e2611..9d4ea544df07 100644 --- a/chart2/source/tools/RegressionCurveModel.cxx +++ b/chart2/source/tools/RegressionCurveModel.cxx @@ -182,12 +182,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() { @@ -238,6 +246,7 @@ void SAL_CALL RegressionCurveModel::disposing( const lang::EventObject& /* Sourc // ____ OPropertySet ____ void RegressionCurveModel::firePropertyChangeEvent() { + setPropertyMayHaveR2(); fireModifyEvent(); }