From fe2bf7b05936bb3e84ccc5ddc3dad865a22de551 Mon Sep 17 00:00:00 2001 From: Laurent Balland-Poirier Date: Sun, 10 Apr 2016 14:30:31 +0200 Subject: tdf#99518 Use correct decimal separator Change-Id: I39169e7c7344fcfd594a0e0d2ab0a762cc3d5829 Reviewed-on: https://gerrit.libreoffice.org/23961 Reviewed-by: Markus Mohrhard Tested-by: Markus Mohrhard --- .../controller/dialogs/ObjectNameProvider.cxx | 27 +++++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) (limited to 'chart2') diff --git a/chart2/source/controller/dialogs/ObjectNameProvider.cxx b/chart2/source/controller/dialogs/ObjectNameProvider.cxx index ec300482f784..a70894b392be 100644 --- a/chart2/source/controller/dialogs/ObjectNameProvider.cxx +++ b/chart2/source/controller/dialogs/ObjectNameProvider.cxx @@ -33,6 +33,7 @@ #include "RegressionCurveHelper.hxx" #include #include +#include #include #include @@ -566,6 +567,11 @@ OUString ObjectNameProvider::getHelpText( const OUString& rObjectCID, const Refe sal_Int32 aPeriod = 2; bool bForceIntercept = false; double aInterceptValue = 0.0; + const LocaleDataWrapper& rLocaleDataWrapper = Application::GetSettings().GetLocaleDataWrapper(); + const OUString& aNumDecimalSep = rLocaleDataWrapper.getNumDecimalSep(); + assert(aNumDecimalSep.getLength() > 0); + sal_Unicode cDecSeparator = aNumDecimalSep.getStr()[0]; + uno::Reference< beans::XPropertySet > xProperties( xCurve, uno::UNO_QUERY ); if ( xProperties.is()) { @@ -591,19 +597,25 @@ OUString ObjectNameProvider::getHelpText( const OUString& rObjectCID, const Refe aWildcard = "%FORMULA"; nIndex = aRet.indexOf( aWildcard ); if( nIndex != -1 ) - aRet = aRet.replaceAt( nIndex, aWildcard.getLength(), xCalculator->getRepresentation()); + { + OUString aFormula ( xCalculator->getRepresentation() ); + if ( cDecSeparator != '.' ) + { + aFormula = aFormula.replace( '.', cDecSeparator ); + } + aRet = aRet.replaceAt( nIndex, aWildcard.getLength(), aFormula ); + } // replace r^2 aWildcard = "%RSQUARED"; nIndex = aRet.indexOf( aWildcard ); if( nIndex != -1 ) { - sal_Unicode aDecimalSep( '.' ); double fR( xCalculator->getCorrelationCoefficient()); aRet = aRet.replaceAt( nIndex, aWildcard.getLength(), ::rtl::math::doubleToUString( - fR*fR, rtl_math_StringFormat_G, 4, aDecimalSep, true )); + fR*fR, rtl_math_StringFormat_G, 4, cDecSeparator, true )); } } catch( const uno::Exception & ex ) @@ -649,7 +661,10 @@ OUString ObjectNameProvider::getHelpText( const OUString& rObjectCID, const Refe Reference< chart2::XRegressionCurveCalculator > xCalculator( xCurve->getCalculator(), uno::UNO_QUERY_THROW ); RegressionCurveHelper::initializeCurveCalculator( xCalculator, xSeries, xChartModel ); - sal_Unicode aDecimalSep( '.' ); + const LocaleDataWrapper& rLocaleDataWrapper = Application::GetSettings().GetLocaleDataWrapper(); + const OUString& aNumDecimalSep = rLocaleDataWrapper.getNumDecimalSep(); + assert(aNumDecimalSep.getLength() > 0); + sal_Unicode cDecSeparator = aNumDecimalSep.getStr()[0]; OUString aWildcard( "%AVERAGE_VALUE" ); sal_Int32 nIndex = aRet.indexOf( aWildcard ); @@ -660,7 +675,7 @@ OUString ObjectNameProvider::getHelpText( const OUString& rObjectCID, const Refe aRet = aRet.replaceAt( nIndex, aWildcard.getLength(), ::rtl::math::doubleToUString( - fMeanValue, rtl_math_StringFormat_G, 4, aDecimalSep, true )); + fMeanValue, rtl_math_StringFormat_G, 4, cDecSeparator, true )); } // replace standard deviation @@ -672,7 +687,7 @@ OUString ObjectNameProvider::getHelpText( const OUString& rObjectCID, const Refe aRet = aRet.replaceAt( nIndex, aWildcard.getLength(), ::rtl::math::doubleToUString( - fStdDev, rtl_math_StringFormat_G, 4, aDecimalSep, true )); + fStdDev, rtl_math_StringFormat_G, 4, cDecSeparator, true )); } } catch( const uno::Exception & ex ) -- cgit