tdf#155526 Add Period to trend line equation

Insert Period value earlier to have it ready for representation
Allow Moving average equation in dialog UI

Change-Id: I1d20572c39462e60b60ab7eec1f174a3cf934d4a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153094
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
This commit is contained in:
Laurent Balland
2023-06-18 13:31:09 +02:00
committed by Tomaž Vajngerl
parent a2d7cabe0d
commit dc03f59374
3 changed files with 11 additions and 16 deletions
@@ -601,18 +601,9 @@ OUString ObjectNameProvider::getHelpText( std::u16string_view rObjectCID, const
xCalculator->setXYNames ( aXName, aYName );
RegressionCurveHelper::initializeCurveCalculator( xCalculator, xSeries, xChartModel );
// change text for Moving Average
OUString aWildcard( "%PERIOD" );
sal_Int32 nIndex = xCalculator->getRepresentation().indexOf( aWildcard );
if( nIndex != -1 )
{ // replace period
aRet = xCalculator->getRepresentation();
aRet = aRet.replaceAt( nIndex, aWildcard.getLength(), OUString::number(aPeriod) );
}
// replace formula
aWildcard = "%FORMULA";
nIndex = aRet.indexOf( aWildcard );
OUString aWildcard = "%FORMULA";
sal_Int32 nIndex = aRet.indexOf( aWildcard );
if( nIndex != -1 )
{
OUString aFormula ( xCalculator->getRepresentation() );
@@ -372,10 +372,8 @@ void TrendlineResources::UpdateControlStates()
m_xFmtFld_InterceptValue->set_sensitive( bInterceptAvailable );
if( bMovingAverage )
{
m_xCB_ShowEquation->set_state(TRISTATE_FALSE);
m_xCB_ShowCorrelationCoeff->set_state(TRISTATE_FALSE);
}
m_xCB_ShowEquation->set_sensitive( !bMovingAverage );
m_xCB_ShowCorrelationCoeff->set_sensitive( !bMovingAverage );
m_xCB_RegressionMovingType->set_sensitive(bMovingAverage);
m_xNF_Period->set_sensitive(bMovingAverage);
@@ -428,8 +426,6 @@ void TrendlineResources::SetNbPoints( sal_Int32 nNbPoints )
IMPL_LINK_NOARG(TrendlineResources, ShowEquation, weld::Toggleable&, void)
{
m_xEE_XName->set_sensitive(m_xCB_ShowEquation->get_active());
m_xEE_YName->set_sensitive(m_xCB_ShowEquation->get_active());
UpdateControlStates();
}
@@ -157,7 +157,15 @@ OUString MovingAverageRegressionCurveCalculator::ImplGetRepresentation(
const uno::Reference< util::XNumberFormatter >& /*xNumFormatter*/,
sal_Int32 /*nNumberFormatKey*/, sal_Int32* /*pFormulaLength = nullptr */ ) const
{
return SchResId( STR_OBJECT_MOVING_AVERAGE_WITH_PARAMETERS );
OUString aRet = SchResId( STR_OBJECT_MOVING_AVERAGE_WITH_PARAMETERS );
// change text for Moving Average
OUString aWildcard( "%PERIOD" );
sal_Int32 nIndex = aRet.indexOf( aWildcard );
if( nIndex != -1 )
{ // replace period
aRet = aRet.replaceAt( nIndex, aWildcard.getLength(), OUString::number(mPeriod) );
}
return aRet;
}
} // namespace chart