summaryrefslogtreecommitdiff
path: root/scaddins
diff options
context:
space:
mode:
authorRüdiger Timm <rt@openoffice.org>2004-03-02 08:29:14 +0000
committerRüdiger Timm <rt@openoffice.org>2004-03-02 08:29:14 +0000
commitc019a87be0975e81c2727f208f33227265bf2a5b (patch)
tree3b821cf0c816296cea8c54664af6a974c85e498b /scaddins
parent0a5fb4715cb3ddb7b0bd758dad1714b6ec3cb85f (diff)
INTEGRATION: CWS calc18 (1.40.32); FILE MERGED
2004/02/11 12:24:18 dr 1.40.32.2: RESYNC: (1.40-1.41); FILE MERGED 2003/11/10 11:45:30 dr 1.40.32.1: #i22280# BIN,DEC,OCT,HEX use doubles for limits now
Diffstat (limited to 'scaddins')
-rw-r--r--scaddins/source/analysis/analysishelper.cxx22
1 files changed, 14 insertions, 8 deletions
diff --git a/scaddins/source/analysis/analysishelper.cxx b/scaddins/source/analysis/analysishelper.cxx
index d3c83ee46854..ec91d46bbe0e 100644
--- a/scaddins/source/analysis/analysishelper.cxx
+++ b/scaddins/source/analysis/analysishelper.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: analysishelper.cxx,v $
*
- * $Revision: 1.41 $
+ * $Revision: 1.42 $
*
- * last change: $Author: hr $ $Date: 2004-02-04 14:11:40 $
+ * last change: $Author: rt $ $Date: 2004-03-02 09:29:14 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -824,28 +824,34 @@ static inline sal_Char GetMaxChar( sal_uInt16 nBase )
}
-STRING ConvertFromDec( sal_Int64 nNum, sal_Int64 nMin, sal_Int64 nMax, sal_uInt16 nBase,
- sal_Int32 nPlaces, sal_Int32 nMaxPlaces ) THROWDEF_RTE_IAE
+STRING ConvertFromDec( double fNum, double fMin, double fMax, sal_uInt16 nBase,
+ sal_Int32 nPlaces, sal_Int32 nMaxPlaces, sal_Bool bUsePlaces ) THROWDEF_RTE_IAE
{
- sal_Bool bUsePlaces = nPlaces != 0x80000000;
- if( nNum < nMin || nNum > nMax || ( bUsePlaces && ( nPlaces <= 0 || nPlaces > nMaxPlaces ) ) )
+ fNum = ::rtl::math::approxFloor( fNum );
+ fMin = ::rtl::math::approxFloor( fMin );
+ fMax = ::rtl::math::approxFloor( fMax );
+
+ if( fNum < fMin || fNum > fMax || ( bUsePlaces && ( nPlaces <= 0 || nPlaces > nMaxPlaces ) ) )
THROW_IAE;
+ sal_Int64 nNum = static_cast< sal_Int64 >( fNum );
sal_Bool bNeg = nNum < 0;
if( bNeg )
nNum = sal_Int64( pow( double( nBase ), double( nMaxPlaces ) ) ) + nNum;
STRING aRet( STRING::valueOf( nNum, nBase ).toAsciiUpperCase() );
- sal_Int32 nLen = aRet.getLength();
if( bUsePlaces )
{
+ sal_Int32 nLen = aRet.getLength();
if( !bNeg && nLen > nPlaces )
+ {
THROW_IAE;
+ }
else if( ( bNeg && nLen < nMaxPlaces ) || ( !bNeg && nLen < nPlaces ) )
{
- sal_uInt32 nLeft = nPlaces - nLen;
+ sal_Int32 nLeft = nPlaces - nLen;
sal_Char* p = new sal_Char[ nLeft + 1 ];
memset( p, bNeg? GetMaxChar( nBase ) : '0', nLeft );
p[ nLeft ] = 0x00;