From 00055d49f35bbabd46d00fefd395b46872ed45aa Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Tue, 6 Nov 2018 09:46:14 +0200 Subject: remove with_sprintf_ define it has been this way since commit f333ee4564f7786f5f4ca501d71e660b5c366b93 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: Noel Grandin --- basic/source/sbx/sbxform.cxx | 93 -------------------------------------------- 1 file changed, 93 deletions(-) (limited to 'basic') diff --git a/basic/source/sbx/sbxform.cxx b/basic/source/sbx/sbxform.cxx index 69d917ae3a1f..aa1bbb0a276f 100644 --- a/basic/source/sbx/sbxform.cxx +++ b/basic/source/sbx/sbxform.cxx @@ -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=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 ); -- cgit