20#include <rtl/ustrbuf.hxx>
30 bool isNeg = ( rVal < 0 );
31 sal_Int64 absVal = isNeg ? -rVal : rVal;
35 OUString aAbsStr = OUString::number( absVal );
37 sal_Int32 initialLen = aAbsStr.getLength();
39 bool bLessThanOne =
false;
40 if ( initialLen <= 4 )
43 sal_Int32 nCapacity = 6;
47 nCapacity = initialLen + 1;
53 OUStringBuffer
aBuf( nCapacity );
54 aBuf.setLength( nCapacity );
57 sal_Int32 nDigitCount = 0;
58 sal_Int32 nInsertIndex = nCapacity - 1;
59 sal_Int32 nEndIndex = isNeg ? 1 : 0;
61 for ( sal_Int32 charCpyIndex = aAbsStr.getLength() - 1; nInsertIndex >= nEndIndex; ++nDigitCount )
63 if ( nDigitCount == 4 )
64 aBuf[nInsertIndex--] = cDecimalSep;
65 if ( nDigitCount < initialLen )
66 aBuf[nInsertIndex--] = aAbsStr[ charCpyIndex-- ];
79 aBuf[nInsertIndex--] =
'0';
82 aBuf[nInsertIndex] =
'-';
84 aAbsStr =
aBuf.makeStringAndClear();
92 sal_Int32 nFractDigit = 4;
103 std::u16string_view sTmp =
o3tl::trim( rStr );
104 auto p = sTmp.begin();
105 auto pEnd = sTmp.end();
108 OUStringBuffer sNormalisedNumString(
static_cast<sal_Int32
>(sTmp.size()) + nFractDigit );
110 if (
p != pEnd && (*
p ==
'-' || *
p ==
'+' ) )
111 sNormalisedNumString.append( *
p++ );
113 while (
p != pEnd && *
p >=
'0' && *
p <=
'9' )
115 sNormalisedNumString.append( *
p++ );
118 if(
p != pEnd && *
p == c1000Sep )
122 bool bRoundUp =
false;
124 if(
p != pEnd && *
p == cDeciPnt )
127 while( nFractDigit &&
p != pEnd && *
p >=
'0' && *
p <=
'9' )
129 sNormalisedNumString.append( *
p++ );
134 if(
p != pEnd && *
p >=
'5' && *
p <=
'9' )
136 while(
p != pEnd && *
p >=
'0' && *
p <=
'9' )
147 sNormalisedNumString.append(
'0' );
173 nRes =
p->nInt64;
break;
255 p->pDecimal->getDouble(
d );
299 aTmp.
nLong = *
p->pLong;
goto ref;
301 aTmp.
nULong = *
p->pULong;
goto ref;
303 aTmp.
nSingle = *
p->pSingle;
goto ref;
306 aTmp.
nDouble = *
p->pDouble;
goto ref;
309 aTmp.
nInt64 = *
p->pnInt64;
goto ref;
311 aTmp.
uInt64 = *
p->puInt64;
goto ref;
332 aTmp.
pChar = &
p->nChar;
goto direct;
334 aTmp.
pByte = &
p->nByte;
goto direct;
337 aTmp.
pInteger = &
p->nInteger;
goto direct;
339 aTmp.
pLong = &
p->nLong;
goto direct;
341 aTmp.
pULong = &
p->nULong;
goto direct;
344 aTmp.
pUShort = &
p->nUShort;
goto direct;
361 p->nInt64 = r;
break;
375 p->pOUString =
new OUString;
412 *
p->pByte =
static_cast<sal_uInt8>(val);
break;
426 *
p->pInteger =
static_cast<sal_uInt16
>(val);
break;
440 *
p->pUShort =
static_cast<sal_uInt16
>(val);
break;
453 *
p->pLong =
static_cast<sal_Int32
>(val);
break;
466 *
p->pULong =
static_cast<sal_uInt32
>(val);
break;
469 *
p->pnInt64 = r;
break;
static void SetError(ErrCode)
bool setDouble(double val)
bool PutCurrency(sal_Int64)
sal_Int64 GetCurrency() const
std::basic_string_view< charT, traits > trim(std::basic_string_view< charT, traits > str)
sal_Int64 toInt64(std::u16string_view str, sal_Int16 radix=10)
#define ERRCODE_BASIC_NO_OBJECT
#define ERRCODE_BASIC_MATH_OVERFLOW
#define ERRCODE_BASIC_CONVERSION
double ImpCurrencyToDouble(const sal_Int64 r)
sal_Int64 ImpDoubleToCurrency(double d)
SbxDecimal * ImpCreateDecimal(SbxValues *p)
static sal_Int64 ImpStringToCurrency(std::u16string_view rStr)
void ImpPutCurrency(SbxValues *p, const sal_Int64 r)
sal_Int64 ImpGetCurrency(const SbxValues *p)
static OUString ImpCurrencyToString(sal_Int64 rVal)
constexpr sal_uInt32 SbxMAXULNG
constexpr sal_Int32 SbxMINLNG
constexpr auto SbxMAXCHAR
constexpr sal_uInt16 SbxMAXUINT
constexpr auto SbxMINCHAR
constexpr auto CURRENCY_FACTOR
constexpr auto SbxMAXBYTE