[Libreoffice-commits] core.git: basic/source include/basic

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Tue Nov 6 09:19:24 UTC 2018


 basic/source/sbx/sbxform.cxx |   93 -------------------------------------------
 include/basic/sbxform.hxx    |   15 ------
 2 files changed, 108 deletions(-)

New commits:
commit 00055d49f35bbabd46d00fefd395b46872ed45aa
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Tue Nov 6 09:46:14 2018 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Tue Nov 6 10:18:16 2018 +0100

    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 <noel.grandin at collabora.co.uk>

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<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 );
diff --git a/include/basic/sbxform.hxx b/include/basic/sbxform.hxx
index 74253192a69b..6ef7734eb8c1 100644
--- a/include/basic/sbxform.hxx
+++ b/include/basic/sbxform.hxx
@@ -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 );


More information about the Libreoffice-commits mailing list