Kaydet (Commit) 00055d49 authored tarafından Noel Grandin's avatar Noel Grandin

remove with_sprintf_ define

it has been this way since

    commit f333ee45
    Date:   Wed Apr 11 11:54:30 2007 +0000
    INTEGRATION: CWS hedaburemove01 (1.1.2); FILE ADDED

Change-Id: I317efd9538436480a9fc3d37e748b0a51052ef80
Reviewed-on: https://gerrit.libreoffice.org/62932
Tested-by: Jenkins
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst b4608f36
......@@ -225,9 +225,6 @@ void SbxBasicFormater::ParseBack( OUStringBuffer& sStrg, const OUString& sFormat
}
}
#ifdef with_sprintf_
void SbxBasicFormater::InitScan( double _dNum )
{
char sBuffer[ MAX_DOUBLE_BUFFER_LENGTH ];
......@@ -296,70 +293,6 @@ short SbxBasicFormater::GetDigitAtPosExpScan( double dNewExponent, short nPos,
return GetDigitAtPosExpScan( nPos,bFoundFirstDigit );
}
#else
/* Problems with the following method:
TODO: an 'intelligent' peek-parser might be needed to detect rounding
mistakes at double-numbers - e. g. for 0.00115 #.#e-000
problem with: format( 0.3345 , "0.000" )
problem with: format( 0.00115 , "0.0000" )
*/
// returns the digit at the given '10 system'-position,
// i. e. positive nPos for positions before the decimal
// point and negative for positions after.
// nPos==0 means first position after the decimalpoint, so 10^0.
// returns 0..9 for valid digits and -1 for not existing,
// i. e. if the passed number is too small
// (e. g. position 5 of dNumber=123).
// Furthermore in dNextNumber the number shorted by leading
// positions (till nPos) is returned, e. g.
// GetDigitAtPos( 3434.565 , 2 , dNewNumber ) --> dNewNumber = 434.565
// In bFoundFirstDigit a flag is set if a digit has been found,
// this is used to prevent 'errors' on parsing 202
// ATTENTION: apparently there are sometimes still problems with rounding mistakes!
short SbxBasicFormater::GetDigitAtPos( double dNumber, short nPos,
double& dNextNumber, bool& bFoundFirstDigit )
{
double dDigit;
short nMaxDigit;
dNumber = fabs( dNumber );
nMaxDigit = (short)get_number_of_digits( dNumber );
// error only at numbers > 0, i. e. for digits before
// the decimal point
if( nMaxDigit<nPos && !bFoundFirstDigit && nPos>=0 )
return NO_DIGIT_;
bFoundFirstDigit = true;
for( short i=nMaxDigit; i>=nPos; i-- )
{
double dI = (double)i;
double dTemp1 = pow( 10.0,dI );
dDigit = floor( pow( 10.0,log10( fabs( dNumber ) )-dI ) );
dNumber -= dTemp1 * dDigit;
}
// for optimized loop run
dNextNumber = dNumber;
return RoundDigit( dDigit );
}
short SbxBasicFormater::RoundDigit( double dNumber )
{
if( dNumber<0.0 || dNumber>10.0 )
return -1;
short nTempHigh = (short)(dNumber+0.5); // maybe floor( )
return nTempHigh;
}
#endif
// Copies the respective part of the format-string, if existing, and returns it.
// So a new string is created, which has to be freed by the caller later.
OUString SbxBasicFormater::GetPosFormatString( const OUString& sFormatStrg, bool & bFound )
......@@ -655,9 +588,7 @@ void SbxBasicFormater::ScanFormatString( double dNumber,
bZeroSpaceOn = false;
#ifdef with_sprintf_
InitScan( dNumber );
#endif
// scanning the format-string:
sal_Unicode cForce = 0;
for( i = 0; i < nLen; i++ )
......@@ -695,11 +626,7 @@ void SbxBasicFormater::ScanFormatString( double dNumber,
for( short j = nMaxDigit; j > nDigitPos; j-- )
{
short nTempDigit;
#ifdef with_sprintf_
AppendDigit( sReturnStrg, nTempDigit = GetDigitAtPosScan( j, bFoundFirstDigit ) );
#else
AppendDigit( sReturnStrg, nTempDigit = GetDigitAtPos( dNumber, j, dNumber, bFoundFirstDigit ) );
#endif
if( nTempDigit != NO_DIGIT_ )
{
bFirstDigit = false;
......@@ -728,11 +655,7 @@ void SbxBasicFormater::ScanFormatString( double dNumber,
else
{
short nTempDigit;
#ifdef with_sprintf_
AppendDigit( sReturnStrg, nTempDigit = GetDigitAtPosScan( nDigitPos, bFoundFirstDigit ) );
#else
AppendDigit( sReturnStrg, nTempDigit = GetDigitAtPos( dNumber, nDigitPos, dNumber, bFoundFirstDigit ) );
#endif
if( nTempDigit != NO_DIGIT_ )
{
......@@ -758,11 +681,7 @@ void SbxBasicFormater::ScanFormatString( double dNumber,
{
for( short j = nMaxExponentDigit; j > nExponentPos; j-- )
{
#ifdef with_sprintf_
AppendDigit( sReturnStrg, GetDigitAtPosExpScan( dExponent, j, bFoundFirstDigit ) );
#else
AppendDigit( sReturnStrg,GetDigitAtPos( dExponent, j, dExponent, bFoundFirstDigit ) );
#endif
}
}
}
......@@ -773,11 +692,7 @@ void SbxBasicFormater::ScanFormatString( double dNumber,
}
else
{
#ifdef with_sprintf_
AppendDigit( sReturnStrg, GetDigitAtPosExpScan( dExponent, nExponentPos, bFoundFirstDigit ) );
#else
AppendDigit( sReturnStrg, GetDigitAtPos( dExponent, nExponentPos, dExponent, bFoundFirstDigit ) );
#endif
}
nExponentPos--;
}
......@@ -815,11 +730,7 @@ void SbxBasicFormater::ScanFormatString( double dNumber,
}
bool bOverflow = false;
#ifdef with_sprintf_
short nNextDigit = GetDigitAtPosScan( nDigitPos, bFoundFirstDigit );
#else
short nNextDigit = GetDigitAtPos( dNumber, nDigitPos, dNumber, bFoundFirstDigit );
#endif
if( nNextDigit>=5 )
{
StrRoundDigit( sReturnStrg, sReturnStrg.getLength() - 1, bOverflow );
......@@ -914,11 +825,7 @@ void SbxBasicFormater::ScanFormatString( double dNumber,
// scan completed - rounding necessary?
if( !bScientific )
{
#ifdef with_sprintf_
short nNextDigit = GetDigitAtPosScan( nDigitPos, bFoundFirstDigit );
#else
short nNextDigit = GetDigitAtPos( dNumber, nDigitPos, dNumber, bFoundFirstDigit );
#endif
if( nNextDigit>=5 )
{
StrRoundDigit( sReturnStrg, sReturnStrg.getLength() - 1 );
......
......@@ -67,14 +67,6 @@
"AMPM", "Long Date", "Long Time"
*/
/*
There are two possibilities to get the number of digits of a number:
a) use sprintf()
b) use log10() and pow() digit
*/
#define with_sprintf_ // use a)
#include <rtl/ustring.hxx>
#include <rtl/ustrbuf.hxx>
#include <basic/basicdllapi.h>
......@@ -115,7 +107,6 @@ class BASIC_DLLPUBLIC SbxBasicFormater {
BASIC_DLLPRIVATE void StrRoundDigit( OUStringBuffer& sStrg, short nPos );
BASIC_DLLPRIVATE static void ParseBack( OUStringBuffer& sStrg, const OUString& sFormatStrg,
short nFormatPos );
#ifdef with_sprintf_
// Methods for string conversion with sprintf():
BASIC_DLLPRIVATE void InitScan( double _dNum );
BASIC_DLLPRIVATE void InitExp( double _dNewExp );
......@@ -123,12 +114,6 @@ class BASIC_DLLPUBLIC SbxBasicFormater {
BASIC_DLLPRIVATE short GetDigitAtPosExpScan( double dNewExponent, short nPos,
bool& bFoundFirstDigit );
BASIC_DLLPRIVATE short GetDigitAtPosExpScan( short nPos, bool& bFoundFirstDigit );
#else
// Methods for direct 'calculation' with log10() and pow():
BASIC_DLLPRIVATE short GetDigitAtPos( double dNumber, short nPos, double& dNextNumber,
bool& bFoundFirstDigit );
BASIC_DLLPRIVATE short RoundDigit( double dNumber );
#endif
BASIC_DLLPRIVATE static OUString GetPosFormatString( const OUString& sFormatStrg, bool & bFound );
BASIC_DLLPRIVATE static OUString GetNegFormatString( const OUString& sFormatStrg, bool & bFound );
BASIC_DLLPRIVATE static OUString Get0FormatString( const OUString& sFormatStrg, bool & bFound );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment