Coverage Report

Created: 2025-12-31 10:39

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/basic/source/sbx/sbxdec.cxx
Line
Count
Source
1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
/*
3
 * This file is part of the LibreOffice project.
4
 *
5
 * This Source Code Form is subject to the terms of the Mozilla Public
6
 * License, v. 2.0. If a copy of the MPL was not distributed with this
7
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8
 *
9
 * This file incorporates work covered by the following license notice:
10
 *
11
 *   Licensed to the Apache Software Foundation (ASF) under one or more
12
 *   contributor license agreements. See the NOTICE file distributed
13
 *   with this work for additional information regarding copyright
14
 *   ownership. The ASF licenses this file to you under the Apache
15
 *   License, Version 2.0 (the "License"); you may not use this file
16
 *   except in compliance with the License. You may obtain a copy of
17
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
18
 */
19
20
#include <sal/config.h>
21
#ifdef _WIN32
22
#include <o3tl/char16_t2wchar_t.hxx>
23
#include <systools/win32/oleauto.hxx>
24
#endif
25
26
#include <basic/sberrors.hxx>
27
#include "sbxconv.hxx"
28
29
#include <com/sun/star/bridge/oleautomation/Decimal.hpp>
30
31
// Implementation SbxDecimal
32
SbxDecimal::SbxDecimal()
33
0
    : mnRefCount(0)
34
0
{
35
0
    setInt( 0 );
36
0
}
37
38
SbxDecimal::SbxDecimal( const SbxDecimal& rDec )
39
0
    : mnRefCount(0)
40
0
{
41
#ifdef _WIN32
42
    maDec = rDec.maDec;
43
#else
44
0
    (void)rDec;
45
0
#endif
46
0
}
47
48
SbxDecimal::SbxDecimal
49
    ( const css::bridge::oleautomation::Decimal& rAutomationDec )
50
0
    : mnRefCount(0)
51
0
{
52
#ifdef _WIN32
53
    maDec.scale = rAutomationDec.Scale;
54
    maDec.sign  = rAutomationDec.Sign;
55
    maDec.Lo32 = rAutomationDec.LowValue;
56
    maDec.Mid32 = rAutomationDec.MiddleValue;
57
    maDec.Hi32 = rAutomationDec.HighValue;
58
#else
59
0
    (void)rAutomationDec;
60
0
#endif
61
0
}
62
63
void SbxDecimal::fillAutomationDecimal
64
    ( css::bridge::oleautomation::Decimal& rAutomationDec )
65
0
{
66
#ifdef _WIN32
67
    rAutomationDec.Scale = maDec.scale;
68
    rAutomationDec.Sign = maDec.sign;
69
    rAutomationDec.LowValue = maDec.Lo32;
70
    rAutomationDec.MiddleValue = maDec.Mid32;
71
    rAutomationDec.HighValue = maDec.Hi32;
72
#else
73
0
    (void)rAutomationDec;
74
0
#endif
75
0
}
76
77
void releaseDecimalPtr( SbxDecimal*& rpDecimal )
78
0
{
79
0
    if( rpDecimal )
80
0
    {
81
0
        rpDecimal->mnRefCount--;
82
0
        if( rpDecimal->mnRefCount == 0 )
83
0
            delete rpDecimal;
84
0
        rpDecimal = nullptr;
85
0
    }
86
0
}
87
88
#ifdef _WIN32
89
90
bool SbxDecimal::operator -= ( const SbxDecimal &r )
91
{
92
    HRESULT hResult = VarDecSub( &maDec, const_cast<LPDECIMAL>(&r.maDec), &maDec );
93
    bool bRet = ( hResult == S_OK );
94
    return bRet;
95
}
96
97
bool SbxDecimal::operator += ( const SbxDecimal &r )
98
{
99
    HRESULT hResult = VarDecAdd( &maDec, const_cast<LPDECIMAL>(&r.maDec), &maDec );
100
    bool bRet = ( hResult == S_OK );
101
    return bRet;
102
}
103
104
bool SbxDecimal::operator /= ( const SbxDecimal &r )
105
{
106
    HRESULT hResult = VarDecDiv( &maDec, const_cast<LPDECIMAL>(&r.maDec), &maDec );
107
    bool bRet = ( hResult == S_OK );
108
    return bRet;
109
}
110
111
bool SbxDecimal::operator *= ( const SbxDecimal &r )
112
{
113
    HRESULT hResult = VarDecMul( &maDec, const_cast<LPDECIMAL>(&r.maDec), &maDec );
114
    bool bRet = ( hResult == S_OK );
115
    return bRet;
116
}
117
118
bool SbxDecimal::neg()
119
{
120
    HRESULT hResult = VarDecNeg( &maDec, &maDec );
121
    bool bRet = ( hResult == S_OK );
122
    return bRet;
123
}
124
125
bool SbxDecimal::isZero() const
126
{
127
    SbxDecimal aZeroDec;
128
    aZeroDec.setLong( 0 );
129
    bool bZero = CmpResult::EQ == compare( *this, aZeroDec );
130
    return bZero;
131
}
132
133
SbxDecimal::CmpResult compare( const SbxDecimal &rLeft, const SbxDecimal &rRight )
134
{
135
    HRESULT hResult = VarDecCmp( const_cast<LPDECIMAL>(&rLeft.maDec), const_cast<LPDECIMAL>(&rRight.maDec) );
136
    SbxDecimal::CmpResult eRes = static_cast<SbxDecimal::CmpResult>(hResult);
137
    return eRes;
138
}
139
140
void SbxDecimal::setChar( sal_Unicode val )
141
{
142
    VarDecFromUI2( static_cast<sal_uInt16>(val), &maDec );
143
}
144
145
void SbxDecimal::setByte( sal_uInt8 val )
146
{
147
    VarDecFromUI1( val, &maDec );
148
}
149
150
void SbxDecimal::setShort( sal_Int16 val )
151
{
152
    VarDecFromI2( static_cast<short>(val), &maDec );
153
}
154
155
void SbxDecimal::setLong( sal_Int32 val )
156
{
157
    VarDecFromI4(static_cast<LONG>(val), &maDec);
158
}
159
160
bool SbxDecimal::setHyper( sal_Int64 val )
161
{
162
    return SUCCEEDED(VarDecFromI8(static_cast<LONG64>(val), &maDec));
163
}
164
165
void SbxDecimal::setUShort( sal_uInt16 val )
166
{
167
    VarDecFromUI2( val, &maDec );
168
}
169
170
void SbxDecimal::setULong( sal_uInt32 val )
171
{
172
    VarDecFromUI4( static_cast<ULONG>(val), &maDec );
173
}
174
175
bool SbxDecimal::setUHyper( sal_uInt64 val )
176
{
177
    return SUCCEEDED(VarDecFromUI8( static_cast<ULONG64>(val), &maDec ));
178
}
179
180
bool SbxDecimal::setSingle( float val )
181
{
182
    bool bRet = ( VarDecFromR4( val, &maDec ) == S_OK );
183
    return bRet;
184
}
185
186
bool SbxDecimal::setDouble( double val )
187
{
188
    bool bRet = ( VarDecFromR8( val, &maDec ) == S_OK );
189
    return bRet;
190
}
191
192
void SbxDecimal::setInt( int val )
193
{
194
    setLong( static_cast<sal_Int32>(val) );
195
}
196
197
void SbxDecimal::setUInt( unsigned int val )
198
{
199
    setULong( static_cast<sal_uInt32>(val) );
200
}
201
202
bool SbxDecimal::setString( OUString* pOUString )
203
{
204
    assert(pOUString);
205
206
    static LCID nLANGID = MAKELANGID( LANG_ENGLISH, SUBLANG_ENGLISH_US );
207
208
    // Convert delimiter
209
    sal_Unicode cDecimalSep;
210
    sal_Unicode cThousandSep;
211
    sal_Unicode cDecimalSepAlt;
212
    ImpGetIntntlSep( cDecimalSep, cThousandSep, cDecimalSepAlt );
213
214
    bool bRet = false;
215
    HRESULT hResult;
216
    if( cDecimalSep != '.' || cThousandSep != ',' )
217
    {
218
        int nLen = pOUString->getLength();
219
        std::unique_ptr<sal_Unicode[]> pBuffer(new sal_Unicode[nLen +  1]);
220
        pBuffer[nLen] = 0;
221
222
        const sal_Unicode* pSrc = pOUString->getStr();
223
        for( int i = 0 ; i < nLen ; ++i )
224
        {
225
            sal_Unicode c = pSrc[i];
226
            if (c == cDecimalSep)
227
                c = '.';
228
            else if (c == cThousandSep)
229
                c = ',';
230
231
            pBuffer[i] = c;
232
        }
233
        hResult = VarDecFromStr( o3tl::toW(pBuffer.get()), nLANGID, 0, &maDec );
234
    }
235
    else
236
    {
237
        hResult = VarDecFromStr( o3tl::toW(pOUString->getStr()), nLANGID, 0, &maDec );
238
    }
239
    bRet = ( hResult == S_OK );
240
    return bRet;
241
}
242
243
244
bool SbxDecimal::getChar( sal_Unicode& rVal )
245
{
246
    USHORT n;
247
    bool bRet = ( VarUI2FromDec( &maDec, &n ) == S_OK );
248
    if (bRet) {
249
        rVal = n;
250
    }
251
    return bRet;
252
}
253
254
bool SbxDecimal::getByte( sal_uInt8& rVal )
255
{
256
    bool bRet = ( VarUI1FromDec( &maDec, &rVal ) == S_OK );
257
    return bRet;
258
}
259
260
bool SbxDecimal::getShort( sal_Int16& rVal )
261
{
262
    bool bRet = ( VarI2FromDec( &maDec, &rVal ) == S_OK );
263
    return bRet;
264
}
265
266
bool SbxDecimal::getLong( sal_Int32& rVal )
267
{
268
    bool bRet = ( VarI4FromDec( &maDec, &rVal ) == S_OK );
269
    return bRet;
270
}
271
272
bool SbxDecimal::getHyper( sal_Int64& rVal )
273
{
274
    bool bRet = ( VarI8FromDec( &maDec, &rVal ) == S_OK );
275
    return bRet;
276
}
277
278
bool SbxDecimal::getUShort( sal_uInt16& rVal )
279
{
280
    bool bRet = ( VarUI2FromDec( &maDec, &rVal ) == S_OK );
281
    return bRet;
282
}
283
284
bool SbxDecimal::getULong( sal_uInt32& rVal )
285
{
286
    bool bRet = ( VarUI4FromDec( &maDec, &rVal ) == S_OK );
287
    return bRet;
288
}
289
290
bool SbxDecimal::getUHyper( sal_uInt64& rVal )
291
{
292
    bool bRet = ( VarUI8FromDec( &maDec, &rVal ) == S_OK );
293
    return bRet;
294
}
295
296
bool SbxDecimal::getSingle( float& rVal )
297
{
298
    bool bRet = ( VarR4FromDec( &maDec, &rVal ) == S_OK );
299
    return bRet;
300
}
301
302
bool SbxDecimal::getDouble( double& rVal )
303
{
304
    bool bRet = ( VarR8FromDec( &maDec, &rVal ) == S_OK );
305
    return bRet;
306
}
307
308
#else
309
// !_WIN32
310
311
bool SbxDecimal::operator -= ( const SbxDecimal & )
312
0
{
313
0
    return false;
314
0
}
315
316
bool SbxDecimal::operator += ( const SbxDecimal & )
317
0
{
318
0
    return false;
319
0
}
320
321
bool SbxDecimal::operator /= ( const SbxDecimal & )
322
0
{
323
0
    return false;
324
0
}
325
326
bool SbxDecimal::operator *= ( const SbxDecimal & )
327
0
{
328
0
    return false;
329
0
}
330
331
bool SbxDecimal::neg()
332
0
{
333
0
    return false;
334
0
}
335
336
bool SbxDecimal::isZero() const
337
0
{
338
0
    return false;
339
0
}
340
341
SbxDecimal::CmpResult compare( SAL_UNUSED_PARAMETER const SbxDecimal &, SAL_UNUSED_PARAMETER const SbxDecimal & )
342
0
{
343
0
    return SbxDecimal::CmpResult::LT;
344
0
}
345
346
0
void SbxDecimal::setChar( SAL_UNUSED_PARAMETER sal_Unicode ) {}
347
0
void SbxDecimal::setByte( SAL_UNUSED_PARAMETER sal_uInt8 ) {}
348
0
void SbxDecimal::setShort( SAL_UNUSED_PARAMETER sal_Int16 ) {}
349
0
void SbxDecimal::setLong( SAL_UNUSED_PARAMETER sal_Int32 ) {}
350
0
bool SbxDecimal::setHyper( SAL_UNUSED_PARAMETER sal_Int64 ) { return false; }
351
0
void SbxDecimal::setUShort( SAL_UNUSED_PARAMETER sal_uInt16 ) {}
352
0
void SbxDecimal::setULong( SAL_UNUSED_PARAMETER sal_uInt32 ) {}
353
0
bool SbxDecimal::setUHyper( SAL_UNUSED_PARAMETER sal_uInt64 ) { return false; }
354
0
bool SbxDecimal::setSingle( SAL_UNUSED_PARAMETER float ) { return false; }
355
0
bool SbxDecimal::setDouble( SAL_UNUSED_PARAMETER double ) { return false; }
356
0
void SbxDecimal::setInt( SAL_UNUSED_PARAMETER int ) {}
357
0
void SbxDecimal::setUInt( SAL_UNUSED_PARAMETER unsigned int ) {}
358
0
bool SbxDecimal::setString( SAL_UNUSED_PARAMETER OUString* ) { return false; }
359
360
0
bool SbxDecimal::getChar( SAL_UNUSED_PARAMETER sal_Unicode& ) { return false; }
361
0
bool SbxDecimal::getByte( SAL_UNUSED_PARAMETER sal_uInt8& ) { return false; }
362
0
bool SbxDecimal::getShort( SAL_UNUSED_PARAMETER sal_Int16& ) { return false; }
363
0
bool SbxDecimal::getLong( SAL_UNUSED_PARAMETER sal_Int32& ) { return false; }
364
0
bool SbxDecimal::getHyper( SAL_UNUSED_PARAMETER sal_Int64& ) { return false; }
365
0
bool SbxDecimal::getUShort( SAL_UNUSED_PARAMETER sal_uInt16& ) { return false; }
366
0
bool SbxDecimal::getULong( SAL_UNUSED_PARAMETER sal_uInt32& ) { return false; }
367
0
bool SbxDecimal::getUHyper( SAL_UNUSED_PARAMETER sal_uInt64& ) { return false; }
368
0
bool SbxDecimal::getSingle( SAL_UNUSED_PARAMETER float& ) { return false; }
369
0
bool SbxDecimal::getDouble( SAL_UNUSED_PARAMETER double& ) { return false; }
370
371
#endif
372
373
void SbxDecimal::getString( OUString& rString )
374
0
{
375
#ifdef _WIN32
376
    static LCID nLANGID = MAKELANGID( LANG_ENGLISH, SUBLANG_ENGLISH_US );
377
378
    sal::systools::BStr pBStr;
379
    // VarBstrFromDec allocates new BSTR that needs to be released with SysFreeString
380
    HRESULT hResult = VarBstrFromDec( &maDec, nLANGID, 0, &pBStr );
381
    if( hResult == S_OK )
382
    {
383
        // Convert delimiter
384
        sal_Unicode cDecimalSep;
385
        sal_Unicode cThousandSep;
386
        sal_Unicode cDecimalSepAlt;
387
        ImpGetIntntlSep( cDecimalSep, cThousandSep, cDecimalSepAlt );
388
389
        if( cDecimalSep != '.' || cThousandSep != ',' )
390
        {
391
            sal_Unicode c;
392
            int i = 0;
393
            while( (c = pBStr[i]) != 0 )
394
            {
395
                if( c == '.' )
396
                    pBStr[i] = cDecimalSep;
397
                else if( c == ',' )
398
                    pBStr[i] = cThousandSep;
399
                i++;
400
            }
401
        }
402
        rString = pBStr;
403
    }
404
#else
405
0
    (void)rString;
406
0
#endif
407
0
}
408
409
void SbxDecimal::HandleFailure(bool isSuccess)
410
0
{
411
0
    if (!isSuccess)
412
0
        SbxBase::SetError(ERRCODE_BASIC_MATH_OVERFLOW);
413
0
}
414
415
SbxDecimal* ImpCreateDecimal( SbxValues* p )
416
0
{
417
0
    if( !p )
418
0
        return nullptr;
419
420
0
    SbxDecimal*& rpDecimal = p->pDecimal;
421
0
    if( rpDecimal == nullptr )
422
0
    {
423
0
        rpDecimal = new SbxDecimal();
424
0
        rpDecimal->addRef();
425
0
    }
426
0
    return rpDecimal;
427
0
}
428
429
SbxDecimal* ImpGetDecimal( const SbxValues* p )
430
0
{
431
0
    SbxDataType eType = p->eType;
432
0
    if( eType == SbxDECIMAL && p->pDecimal )
433
0
    {
434
0
        SbxDecimal* pnDecRes = new SbxDecimal( *p->pDecimal );
435
0
        pnDecRes->addRef();
436
0
        return pnDecRes;
437
0
    }
438
0
    SbxDecimal* pnDecRes = new SbxDecimal();
439
0
    pnDecRes->addRef();
440
441
0
    switch( +eType )
442
0
    {
443
0
        case SbxEMPTY:
444
0
            pnDecRes->setShort( 0 ); break;
445
0
        case SbxCHAR:
446
0
            pnDecRes->setChar( p->nChar ); break;
447
0
        case SbxBYTE:
448
0
            pnDecRes->setByte( p->nByte ); break;
449
0
        case SbxINTEGER:
450
0
        case SbxBOOL:
451
0
            pnDecRes->setInt( p->nInteger ); break;
452
0
        case SbxERROR:
453
0
        case SbxUSHORT:
454
0
            pnDecRes->setUShort( p->nUShort ); break;
455
0
        case SbxLONG:
456
0
            pnDecRes->setLong( p->nLong ); break;
457
0
        case SbxULONG:
458
0
            pnDecRes->setULong( p->nULong ); break;
459
0
        case SbxSINGLE:
460
0
            pnDecRes->setWithOverflow(p->nSingle);
461
0
            break;
462
0
        case SbxBYREF | SbxSINGLE:
463
0
            pnDecRes->setWithOverflow(*p->pSingle);
464
0
            break;
465
0
        case SbxCURRENCY:
466
0
            pnDecRes->setWithOverflow(CurTo<double>(p->nInt64));
467
0
            break;
468
0
        case SbxBYREF | SbxCURRENCY:
469
0
            pnDecRes->setWithOverflow(CurTo<double>(*p->pnInt64));
470
0
            break;
471
0
        case SbxSALINT64:
472
0
            pnDecRes->setWithOverflow(p->nInt64);
473
0
            break;
474
0
        case SbxBYREF | SbxSALINT64:
475
0
            pnDecRes->setWithOverflow(*p->pnInt64);
476
0
            break;
477
0
        case SbxSALUINT64:
478
0
            pnDecRes->setWithOverflow(p->uInt64);
479
0
            break;
480
0
        case SbxBYREF | SbxSALUINT64:
481
0
            pnDecRes->setWithOverflow(*p->puInt64);
482
0
            break;
483
0
        case SbxDATE:
484
0
        case SbxDOUBLE:
485
0
            pnDecRes->setWithOverflow(p->nDouble);
486
0
            break;
487
0
        case SbxBYREF | SbxDATE:
488
0
        case SbxBYREF | SbxDOUBLE:
489
0
            pnDecRes->setWithOverflow(*p->pDouble);
490
0
            break;
491
0
        case SbxLPSTR:
492
0
        case SbxSTRING:
493
0
        case SbxBYREF | SbxSTRING:
494
0
            if ( p->pOUString )
495
0
                pnDecRes->setString( p->pOUString );
496
0
            break;
497
0
        case SbxOBJECT:
498
0
            if (SbxValue* pVal = dynamic_cast<SbxValue*>(p->pObj))
499
0
                pnDecRes->setDecimal( pVal->GetDecimal() );
500
0
            else
501
0
            {
502
0
                SbxBase::SetError( ERRCODE_BASIC_NO_OBJECT );
503
0
                pnDecRes->setShort( 0 );
504
0
            }
505
0
            break;
506
507
0
        case SbxBYREF | SbxCHAR:
508
0
            pnDecRes->setChar( *p->pChar ); break;
509
0
        case SbxBYREF | SbxBYTE:
510
0
            pnDecRes->setByte( *p->pByte ); break;
511
0
        case SbxBYREF | SbxINTEGER:
512
0
        case SbxBYREF | SbxBOOL:
513
0
            pnDecRes->setInt( *p->pInteger ); break;
514
0
        case SbxBYREF | SbxLONG:
515
0
            pnDecRes->setLong( *p->pLong ); break;
516
0
        case SbxBYREF | SbxULONG:
517
0
            pnDecRes->setULong( *p->pULong ); break;
518
0
        case SbxBYREF | SbxERROR:
519
0
        case SbxBYREF | SbxUSHORT:
520
0
            pnDecRes->setUShort( *p->pUShort ); break;
521
522
0
        default:
523
0
            SbxBase::SetError( ERRCODE_BASIC_CONVERSION ); pnDecRes->setShort( 0 );
524
0
    }
525
0
    return pnDecRes;
526
0
}
527
528
void ImpPutDecimal( SbxValues* p, SbxDecimal* pDec )
529
0
{
530
0
    if( !pDec )
531
0
        return;
532
533
0
    switch( +p->eType )
534
0
    {
535
0
        case SbxCHAR:
536
0
            assignWithOverflowTo(p->nChar, *pDec);
537
0
            break;
538
0
        case SbxBYREF | SbxCHAR:
539
0
            assignWithOverflowTo(*p->pChar, *pDec);
540
0
            break;
541
0
        case SbxBYTE:
542
0
            assignWithOverflowTo(p->nByte, *pDec);
543
0
            break;
544
0
        case SbxBYREF | SbxBYTE:
545
0
            assignWithOverflowTo(*p->pByte, *pDec);
546
0
            break;
547
0
        case SbxINTEGER:
548
0
        case SbxBOOL:
549
0
            assignWithOverflowTo(p->nInteger, *pDec);
550
0
            break;
551
0
        case SbxBYREF | SbxINTEGER:
552
0
        case SbxBYREF | SbxBOOL:
553
0
            assignWithOverflowTo(*p->pInteger, *pDec);
554
0
            break;
555
0
        case SbxERROR:
556
0
        case SbxUSHORT:
557
0
            assignWithOverflowTo(p->nUShort, *pDec);
558
0
            break;
559
0
        case SbxBYREF | SbxERROR:
560
0
        case SbxBYREF | SbxUSHORT:
561
0
            assignWithOverflowTo(*p->pUShort, *pDec);
562
0
            break;
563
0
        case SbxLONG:
564
0
            assignWithOverflowTo(p->nLong, *pDec);
565
0
            break;
566
0
        case SbxBYREF | SbxLONG:
567
0
            assignWithOverflowTo(*p->pLong, *pDec);
568
0
            break;
569
0
        case SbxULONG:
570
0
            assignWithOverflowTo(p->nULong, *pDec);
571
0
            break;
572
0
        case SbxBYREF | SbxULONG:
573
0
            assignWithOverflowTo(*p->pULong, *pDec);
574
0
            break;
575
0
        case SbxCURRENCY:
576
0
            p->nInt64 = CurFrom(pDec->getWithOverflow<double>());
577
0
            break;
578
0
        case SbxBYREF | SbxCURRENCY:
579
0
            *p->pnInt64 = CurFrom(pDec->getWithOverflow<double>());
580
0
            break;
581
0
        case SbxSALINT64:
582
0
            assignWithOverflowTo(p->nInt64, *pDec);
583
0
            break;
584
0
        case SbxBYREF | SbxSALINT64:
585
0
            assignWithOverflowTo(*p->pnInt64, *pDec);
586
0
            break;
587
0
        case SbxSALUINT64:
588
0
            assignWithOverflowTo(p->uInt64, *pDec);
589
0
            break;
590
0
        case SbxBYREF | SbxSALUINT64:
591
0
            assignWithOverflowTo(*p->puInt64, *pDec);
592
0
            break;
593
594
0
        case SbxDECIMAL:
595
0
        case SbxBYREF | SbxDECIMAL:
596
0
            if( pDec != p->pDecimal )
597
0
            {
598
0
                releaseDecimalPtr( p->pDecimal );
599
0
                p->pDecimal = pDec;
600
0
                if( pDec )
601
0
                    pDec->addRef();
602
0
            }
603
0
            break;
604
0
        case SbxSINGLE:
605
0
            assignWithOverflowTo(p->nSingle, *pDec);
606
0
            break;
607
0
        case SbxBYREF | SbxSINGLE:
608
0
            assignWithOverflowTo(*p->pSingle, *pDec);
609
0
            break;
610
0
        case SbxDATE:
611
0
        case SbxDOUBLE:
612
0
            assignWithOverflowTo(p->nDouble, *pDec);
613
0
            break;
614
0
        case SbxBYREF | SbxDATE:
615
0
        case SbxBYREF | SbxDOUBLE:
616
0
            assignWithOverflowTo(*p->pDouble, *pDec);
617
0
            break;
618
619
0
        case SbxLPSTR:
620
0
        case SbxSTRING:
621
0
        case SbxBYREF | SbxSTRING:
622
0
            if( !p->pOUString )
623
0
                p->pOUString = new OUString;
624
0
            pDec->getString( *p->pOUString );
625
0
            break;
626
0
        case SbxOBJECT:
627
0
            if (SbxValue* pVal = dynamic_cast<SbxValue*>(p->pObj))
628
0
                pVal->PutDecimal( pDec );
629
0
            else
630
0
                SbxBase::SetError( ERRCODE_BASIC_NO_OBJECT );
631
0
            break;
632
633
0
        default:
634
0
            SbxBase::SetError( ERRCODE_BASIC_CONVERSION );
635
0
    }
636
0
}
637
638
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */