summaryrefslogtreecommitdiff
path: root/chart2/source/tools/PolynomialRegressionCurveCalculator.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'chart2/source/tools/PolynomialRegressionCurveCalculator.cxx')
-rw-r--r--chart2/source/tools/PolynomialRegressionCurveCalculator.cxx33
1 files changed, 23 insertions, 10 deletions
diff --git a/chart2/source/tools/PolynomialRegressionCurveCalculator.cxx b/chart2/source/tools/PolynomialRegressionCurveCalculator.cxx
index 1d26611c865a..6dba3a26fa27 100644
--- a/chart2/source/tools/PolynomialRegressionCurveCalculator.cxx
+++ b/chart2/source/tools/PolynomialRegressionCurveCalculator.cxx
@@ -25,6 +25,9 @@
#include <rtl/math.hxx>
#include <rtl/ustrbuf.hxx>
+#include <SpecialUnicodes.hxx>
+
+
using namespace com::sun::star;
namespace chart
@@ -235,7 +238,7 @@ OUString PolynomialRegressionCurveCalculator::ImplGetRepresentation(
const uno::Reference< util::XNumberFormatter >& xNumFormatter,
sal_Int32 nNumberFormatKey ) const
{
- OUStringBuffer aBuf( "f(x) = ");
+ OUStringBuffer aBuf( "f(x) = " );
sal_Int32 aLastIndex = mCoefficients.size() - 1;
bool bFindValue = false;
@@ -248,12 +251,14 @@ OUString PolynomialRegressionCurveCalculator::ImplGetRepresentation(
}
else if (aValue < 0.0)
{
- aBuf.append( " - " );
+ if ( bFindValue ) // if it is not the first aValue
+ aBuf.append( " " );
+ aBuf.append( aMinusSign + " ");
aValue = - aValue;
}
else
{
- if ( bFindValue )
+ if ( bFindValue ) // if it is not the first aValue
aBuf.append( " + " );
}
bFindValue = true;
@@ -263,17 +268,25 @@ OUString PolynomialRegressionCurveCalculator::ImplGetRepresentation(
if(i > 0)
{
- if (i == 1)
- {
- aBuf.append( "x" );
- }
- else
+ aBuf.append( "x" );
+ if (i > 1)
{
- aBuf.append( "x^" );
- aBuf.append(i);
+ if (i < 10) // simple case if only one digit
+ aBuf.append( aSuperscriptFigures[ i ] );
+ else
+ {
+ OUString aValueOfi = OUString::number( i );
+ for ( sal_Int32 n = 0; n < aValueOfi.getLength() ; n++ )
+ {
+ sal_Int32 nIndex = aValueOfi[n] - sal_Unicode ( '0' );
+ aBuf.append( aSuperscriptFigures[ nIndex ] );
+ }
+ }
}
}
}
+ if ( aBuf.toString() == "f(x) = " )
+ aBuf.append( "0" );
return aBuf.makeStringAndClear();
}