diff options
author | Noel Power <noel.power@novell.com> | 2011-01-10 17:35:18 +0000 |
---|---|---|
committer | Noel Power <noel.power@novell.com> | 2011-01-10 17:36:33 +0000 |
commit | 6ca4a890ae8aad116731dddfa4b948934ac85ea9 (patch) | |
tree | 79f1f638d277faf335ead37b1fb1f133d71e913b /basic | |
parent | 19d163890903f02419662909a0a3148cc274845f (diff) |
fix handling of excessive trailing decimal places for currency as string
Diffstat (limited to 'basic')
-rw-r--r-- | basic/source/sbx/sbxcurr.cxx | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/basic/source/sbx/sbxcurr.cxx b/basic/source/sbx/sbxcurr.cxx index 333d51280346..1c039ef66d59 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; } |