[Libreoffice-commits] .: basic/source

Noel Power noelp at kemper.freedesktop.org
Mon Jan 10 09:36:42 PST 2011


 basic/source/sbx/sbxcurr.cxx |   15 +++++++++++++++
 1 file changed, 15 insertions(+)

New commits:
commit 3b55cdf1d041c4b03043dee25a880d6f807a7e99
Author: Noel Power <noel.power at novell.com>
Date:   Mon Jan 10 17:35:18 2011 +0000

    fix handling of excessive trailing decimal places for currency as string

diff --git a/basic/source/sbx/sbxcurr.cxx b/basic/source/sbx/sbxcurr.cxx
index 333d512..1c039ef 100644
--- a/basic/source/sbx/sbxcurr.cxx
+++ b/basic/source/sbx/sbxcurr.cxx
@@ -189,6 +189,8 @@ static sal_Int64 ImpStringToCurrency( const rtl::OUString &rStr )
             p++;
     }
 
+    bool bRoundUp = false;
+
     if( *p == cDeciPnt )
     {
         p++;
@@ -197,6 +199,16 @@ static sal_Int64 ImpStringToCurrency( const rtl::OUString &rStr )
             sNormalisedNumString.append( *p++ );
             nFractDigit--;
         }
+        // Consume trailing content
+        if ( p != NULL )
+        {
+            // Round up if necessary
+            if( *p >= '5' && *p <= '9' )
+                bRoundUp = true;
+            while( *p >= '0' && *p <= '9' )
+                p++;
+        }
+
     }
     // can we raise error here ? ( previous behaviour was more forgiving )
     // so... not sure that could bread existing code, lets see if anyone
@@ -211,6 +223,9 @@ static sal_Int64 ImpStringToCurrency( const rtl::OUString &rStr )
     }
 
     sal_Int64 result = sNormalisedNumString.makeStringAndClear().toInt64();
+
+    if ( bRoundUp )
+        ++result;
     return result;
 }
 


More information about the Libreoffice-commits mailing list