Coverage Report

Created: 2026-02-14 09:37

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/connectivity/source/commontools/FValue.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
21
#include <string.h>
22
#include <connectivity/FValue.hxx>
23
#include <connectivity/dbconversion.hxx>
24
#include <comphelper/extract.hxx>
25
#include <com/sun/star/io/XInputStream.hpp>
26
#include <com/sun/star/sdbc/XClob.hpp>
27
#include <com/sun/star/sdbc/XBlob.hpp>
28
#include <com/sun/star/sdb/XColumn.hpp>
29
#include <com/sun/star/sdbc/XRow.hpp>
30
#include <rtl/ustrbuf.hxx>
31
#include <sal/log.hxx>
32
#include <osl/diagnose.h>
33
34
using namespace ::dbtools;
35
using namespace ::com::sun::star::sdbc;
36
using namespace ::com::sun::star::sdb;
37
using namespace ::com::sun::star::uno;
38
using namespace ::com::sun::star::util;
39
using namespace ::com::sun::star::io;
40
41
namespace connectivity
42
{
43
44
namespace {
45
    bool isStorageCompatible(sal_Int32 _eType1, sal_Int32 _eType2)
46
22.6M
    {
47
22.6M
        bool bIsCompatible = true;
48
49
22.6M
        if (_eType1 != _eType2)
50
13.4M
        {
51
13.4M
            SAL_INFO( "connectivity.commontools", "ORowSetValue::isStorageCompatible _eType1 != _eType2" );
52
13.4M
            switch (_eType1)
53
13.4M
            {
54
0
                case DataType::CHAR:
55
0
                case DataType::VARCHAR:
56
170k
                case DataType::DECIMAL:
57
170k
                case DataType::NUMERIC:
58
284k
                case DataType::LONGVARCHAR:
59
284k
                    bIsCompatible = (DataType::CHAR         == _eType2)
60
284k
                                ||  (DataType::VARCHAR      == _eType2)
61
0
                                ||  (DataType::DECIMAL      == _eType2)
62
0
                                ||  (DataType::NUMERIC      == _eType2)
63
0
                                ||  (DataType::LONGVARCHAR  == _eType2);
64
284k
                    break;
65
66
0
                case DataType::DOUBLE:
67
0
                case DataType::REAL:
68
0
                    bIsCompatible = (DataType::DOUBLE   == _eType2)
69
0
                                ||  (DataType::REAL     == _eType2);
70
0
                    break;
71
72
0
                case DataType::BINARY:
73
0
                case DataType::VARBINARY:
74
43.1k
                case DataType::LONGVARBINARY:
75
43.1k
                    bIsCompatible = (DataType::BINARY           == _eType2)
76
43.1k
                                ||  (DataType::VARBINARY        == _eType2)
77
43.1k
                                ||  (DataType::LONGVARBINARY    == _eType2);
78
43.1k
                    break;
79
80
0
                case DataType::INTEGER:
81
0
                    bIsCompatible = (DataType::SMALLINT == _eType2)
82
0
                                ||  (DataType::TINYINT  == _eType2)
83
0
                                ||  (DataType::BIT      == _eType2)
84
0
                                ||  (DataType::BOOLEAN  == _eType2);
85
0
                    break;
86
0
                case DataType::SMALLINT:
87
0
                    bIsCompatible = (DataType::TINYINT  == _eType2)
88
0
                                ||  (DataType::BIT      == _eType2)
89
0
                                ||  (DataType::BOOLEAN  == _eType2);
90
0
                    break;
91
0
                case DataType::TINYINT:
92
0
                    bIsCompatible = (DataType::BIT      == _eType2)
93
0
                                ||  (DataType::BOOLEAN  == _eType2);
94
0
                    break;
95
96
0
                case DataType::BLOB:
97
0
                case DataType::CLOB:
98
6.62M
                case DataType::OBJECT:
99
6.62M
                    bIsCompatible = (DataType::BLOB     == _eType2)
100
6.62M
                                ||  (DataType::CLOB     == _eType2)
101
6.62M
                                ||  (DataType::OBJECT   == _eType2);
102
6.62M
                    break;
103
104
6.54M
                default:
105
6.54M
                    bIsCompatible = false;
106
13.4M
            }
107
13.4M
        }
108
22.6M
        return bIsCompatible;
109
22.6M
    }
110
111
    bool isStorageComparable(sal_Int32 _eType1, sal_Int32 _eType2)
112
0
    {
113
0
        bool bIsComparable = true;
114
115
0
        if (_eType1 != _eType2)
116
0
        {
117
0
            SAL_INFO( "connectivity.commontools", "ORowSetValue::isStorageCompatible _eType1 != _eType2" );
118
0
            switch (_eType1)
119
0
            {
120
0
                case DataType::CHAR:
121
0
                case DataType::VARCHAR:
122
0
                case DataType::LONGVARCHAR:
123
0
                    bIsComparable = (DataType::CHAR         == _eType2)
124
0
                                ||  (DataType::VARCHAR      == _eType2)
125
0
                                ||  (DataType::LONGVARCHAR  == _eType2);
126
0
                    break;
127
128
0
                case DataType::DECIMAL:
129
0
                case DataType::NUMERIC:
130
0
                    bIsComparable = (DataType::DECIMAL      == _eType2)
131
0
                                ||  (DataType::NUMERIC      == _eType2);
132
0
                    break;
133
134
0
            case DataType::DOUBLE:
135
0
                case DataType::REAL:
136
0
                    bIsComparable = (DataType::DOUBLE   == _eType2)
137
0
                                ||  (DataType::REAL     == _eType2);
138
0
                    break;
139
140
0
                case DataType::BINARY:
141
0
                case DataType::VARBINARY:
142
0
                case DataType::LONGVARBINARY:
143
0
                    bIsComparable = (DataType::BINARY           == _eType2)
144
0
                                ||  (DataType::VARBINARY        == _eType2)
145
0
                                ||  (DataType::LONGVARBINARY    == _eType2);
146
0
                    break;
147
148
0
                case DataType::INTEGER:
149
0
                    bIsComparable = (DataType::SMALLINT == _eType2)
150
0
                                ||  (DataType::TINYINT  == _eType2)
151
0
                                ||  (DataType::BIT      == _eType2)
152
0
                                ||  (DataType::BOOLEAN  == _eType2);
153
0
                    break;
154
0
                case DataType::SMALLINT:
155
0
                    bIsComparable = (DataType::TINYINT  == _eType2)
156
0
                                ||  (DataType::BIT      == _eType2)
157
0
                                ||  (DataType::BOOLEAN  == _eType2);
158
0
                    break;
159
0
                case DataType::TINYINT:
160
0
                    bIsComparable = (DataType::BIT      == _eType2)
161
0
                                ||  (DataType::BOOLEAN  == _eType2);
162
0
                    break;
163
164
0
                case DataType::BLOB:
165
0
                case DataType::CLOB:
166
0
                case DataType::OBJECT:
167
0
                    bIsComparable = (DataType::BLOB     == _eType2)
168
0
                                ||  (DataType::CLOB     == _eType2)
169
0
                                ||  (DataType::OBJECT   == _eType2);
170
0
                    break;
171
172
0
                default:
173
0
                    bIsComparable = false;
174
0
            }
175
0
        }
176
0
        return bIsComparable;
177
0
    }
178
}
179
180
void ORowSetValue::setTypeKind(sal_Int32 _eType)
181
16.9M
{
182
16.9M
    if ( !m_bNull && !isStorageCompatible(_eType, m_eTypeKind) )
183
6.54M
    {
184
6.54M
        switch(_eType)
185
6.54M
        {
186
0
            case DataType::VARCHAR:
187
0
            case DataType::CHAR:
188
0
            case DataType::DECIMAL:
189
0
            case DataType::NUMERIC:
190
0
            case DataType::LONGVARCHAR:
191
0
                (*this) = getString();
192
0
                break;
193
0
            case DataType::BIGINT:
194
0
            {
195
0
                sal_Int64 nVal(getLong());
196
0
                sal_uInt64 nuVal(getULong());
197
0
                if (nVal == 0 && nuVal != 0)
198
0
                    (*this) = nuVal;
199
0
                else
200
0
                    (*this) = nVal;
201
0
                break;
202
0
            }
203
204
0
            case DataType::FLOAT:
205
0
                (*this) = getFloat();
206
0
                break;
207
0
            case DataType::DOUBLE:
208
0
            case DataType::REAL:
209
0
                (*this) = getDouble();
210
0
                break;
211
0
            case DataType::TINYINT:
212
0
                (*this) = getInt8();
213
0
                break;
214
0
            case DataType::SMALLINT:
215
0
                (*this) = getInt16();
216
0
                break;
217
0
            case DataType::INTEGER:
218
0
            {
219
0
                sal_Int32 nVal(getInt32());
220
0
                sal_uInt32 nuVal(getUInt32());
221
0
                if (nVal == 0 && nuVal != 0)
222
0
                    (*this) = nuVal;
223
0
                else
224
0
                    (*this) = nVal;
225
0
                break;
226
0
            }
227
100k
            case DataType::BIT:
228
100k
            case DataType::BOOLEAN:
229
100k
                (*this) = getBool();
230
100k
                break;
231
0
            case DataType::DATE:
232
0
                (*this) = getDate();
233
0
                break;
234
0
            case DataType::TIME:
235
0
                (*this) = getTime();
236
0
                break;
237
0
            case DataType::TIMESTAMP:
238
0
                (*this) = getDateTime();
239
0
                break;
240
0
            case DataType::BINARY:
241
0
            case DataType::VARBINARY:
242
0
            case DataType::LONGVARBINARY:
243
0
                (*this) = getSequence();
244
0
                break;
245
0
            case DataType::BLOB:
246
0
            case DataType::CLOB:
247
0
            case DataType::OBJECT:
248
6.44M
            case DataType::OTHER:
249
6.44M
                (*this) = makeAny();
250
6.44M
                break;
251
0
            default:
252
0
                (*this) = makeAny();
253
0
                SAL_WARN( "connectivity.commontools","ORowSetValue::setTypeKind(): UNSUPPORTED TYPE!");
254
6.54M
        }
255
6.54M
    }
256
257
16.9M
    m_eTypeKind = _eType;
258
16.9M
}
259
260
261
void ORowSetValue::free() noexcept
262
80.5M
{
263
80.5M
    if(m_bNull)
264
55.7M
        return;
265
266
24.7M
    switch(m_eTypeKind)
267
24.7M
    {
268
0
        case DataType::CHAR:
269
5.74M
        case DataType::VARCHAR:
270
6.10M
        case DataType::DECIMAL:
271
6.10M
        case DataType::NUMERIC:
272
6.44M
        case DataType::LONGVARCHAR:
273
6.44M
            OSL_ENSURE(m_aValue.m_pString,"String pointer is null!");
274
6.44M
            rtl_uString_release(m_aValue.m_pString);
275
6.44M
            m_aValue.m_pString = nullptr;
276
6.44M
            break;
277
306k
        case DataType::DATE:
278
306k
            delete static_cast<css::util::Date*>(m_aValue.m_pValue);
279
306k
            m_aValue.m_pValue = nullptr;
280
306k
            break;
281
0
        case DataType::TIME:
282
0
            delete static_cast<css::util::Time*>(m_aValue.m_pValue);
283
0
            m_aValue.m_pValue = nullptr;
284
0
            break;
285
350k
        case DataType::TIMESTAMP:
286
350k
            delete static_cast<css::util::DateTime*>(m_aValue.m_pValue);
287
350k
            m_aValue.m_pValue = nullptr;
288
350k
            break;
289
0
        case DataType::BINARY:
290
0
        case DataType::VARBINARY:
291
290k
        case DataType::LONGVARBINARY:
292
290k
            delete static_cast<Sequence<sal_Int8>*>(m_aValue.m_pValue);
293
290k
            m_aValue.m_pValue = nullptr;
294
290k
            break;
295
0
        case DataType::BLOB:
296
0
        case DataType::CLOB:
297
3.42M
        case DataType::OBJECT:
298
3.42M
            delete static_cast<Any*>(m_aValue.m_pValue);
299
3.42M
            m_aValue.m_pValue = nullptr;
300
3.42M
            break;
301
179k
        case DataType::BIT:
302
179k
        case DataType::TINYINT:
303
179k
        case DataType::SMALLINT:
304
6.12M
        case DataType::INTEGER:
305
6.12M
        case DataType::BIGINT:
306
6.38M
        case DataType::BOOLEAN:
307
6.38M
        case DataType::FLOAT:
308
7.46M
        case DataType::DOUBLE:
309
7.46M
        case DataType::REAL:
310
7.46M
            break;
311
6.45M
        default:
312
6.45M
            if ( m_aValue.m_pValue )
313
6.45M
            {
314
6.45M
                delete static_cast<Any*>(m_aValue.m_pValue);
315
6.45M
                m_aValue.m_pValue = nullptr;
316
6.45M
            }
317
6.45M
            break;
318
319
24.7M
    }
320
24.7M
    m_bNull = true;
321
24.7M
}
322
323
ORowSetValue& ORowSetValue::operator=(const ORowSetValue& _rRH)
324
27.5M
{
325
27.5M
    if(&_rRH == this)
326
0
        return *this;
327
328
27.5M
    if ( m_eTypeKind != _rRH.m_eTypeKind || (_rRH.m_bNull && !m_bNull) || m_bSigned != _rRH.m_bSigned)
329
20.3M
        free();
330
331
27.5M
    m_bBound    = _rRH.m_bBound;
332
27.5M
    m_eTypeKind = _rRH.m_eTypeKind;
333
27.5M
    m_bSigned   = _rRH.m_bSigned;
334
335
27.5M
    if(m_bNull && !_rRH.m_bNull)
336
6.02M
    {
337
6.02M
        switch(_rRH.m_eTypeKind)
338
6.02M
        {
339
0
            case DataType::CHAR:
340
1.64M
            case DataType::VARCHAR:
341
1.82M
            case DataType::DECIMAL:
342
1.82M
            case DataType::NUMERIC:
343
2.05M
            case DataType::LONGVARCHAR:
344
2.05M
                rtl_uString_acquire(_rRH.m_aValue.m_pString);
345
2.05M
                m_aValue.m_pString = _rRH.m_aValue.m_pString;
346
2.05M
                break;
347
125k
            case DataType::DATE:
348
125k
                m_aValue.m_pValue   = new Date(*static_cast<Date*>(_rRH.m_aValue.m_pValue));
349
125k
                break;
350
0
            case DataType::TIME:
351
0
                m_aValue.m_pValue   = new Time(*static_cast<Time*>(_rRH.m_aValue.m_pValue));
352
0
                break;
353
152k
            case DataType::TIMESTAMP:
354
152k
                m_aValue.m_pValue   = new DateTime(*static_cast<DateTime*>(_rRH.m_aValue.m_pValue));
355
152k
                break;
356
0
            case DataType::BINARY:
357
0
            case DataType::VARBINARY:
358
20.2k
            case DataType::LONGVARBINARY:
359
20.2k
                m_aValue.m_pValue   = new Sequence<sal_Int8>(*static_cast<Sequence<sal_Int8>*>(_rRH.m_aValue.m_pValue));
360
20.2k
                break;
361
132k
            case DataType::BIT:
362
166k
            case DataType::BOOLEAN:
363
166k
                m_aValue.m_bBool    = _rRH.m_aValue.m_bBool;
364
166k
                break;
365
0
            case DataType::TINYINT:
366
0
                if ( _rRH.m_bSigned )
367
0
                    m_aValue.m_nInt8    = _rRH.m_aValue.m_nInt8;
368
0
                else
369
0
                    m_aValue.m_uInt8    = _rRH.m_aValue.m_uInt8;
370
0
                break;
371
0
            case DataType::SMALLINT:
372
0
                if ( _rRH.m_bSigned )
373
0
                    m_aValue.m_nInt16   = _rRH.m_aValue.m_nInt16;
374
0
                else
375
0
                    m_aValue.m_uInt16   = _rRH.m_aValue.m_uInt16;
376
0
                break;
377
96.1k
            case DataType::INTEGER:
378
96.1k
                if ( _rRH.m_bSigned )
379
96.1k
                    m_aValue.m_nInt32   = _rRH.m_aValue.m_nInt32;
380
0
                else
381
0
                    m_aValue.m_uInt32   = _rRH.m_aValue.m_uInt32;
382
96.1k
                break;
383
0
            case DataType::BIGINT:
384
0
                if ( _rRH.m_bSigned )
385
0
                    m_aValue.m_nInt64   = _rRH.m_aValue.m_nInt64;
386
0
                else
387
0
                    m_aValue.m_uInt64   = _rRH.m_aValue.m_uInt64;
388
0
                break;
389
0
            case DataType::FLOAT:
390
0
                m_aValue.m_nFloat  = _rRH.m_aValue.m_nFloat;
391
0
                break;
392
161k
            case DataType::DOUBLE:
393
161k
            case DataType::REAL:
394
161k
                m_aValue.m_nDouble  = _rRH.m_aValue.m_nDouble;
395
161k
                break;
396
3.25M
            default:
397
3.25M
                m_aValue.m_pValue   = new Any(*static_cast<Any*>(_rRH.m_aValue.m_pValue));
398
6.02M
        }
399
6.02M
    }
400
21.5M
    else if(!_rRH.m_bNull)
401
5.35M
    {
402
5.35M
        switch(_rRH.m_eTypeKind)
403
5.35M
        {
404
0
            case DataType::CHAR:
405
809k
            case DataType::VARCHAR:
406
809k
            case DataType::DECIMAL:
407
809k
            case DataType::NUMERIC:
408
809k
            case DataType::LONGVARCHAR:
409
809k
                (*this) = OUString(_rRH.m_aValue.m_pString);
410
809k
                break;
411
21.2k
            case DataType::DATE:
412
21.2k
                (*this) = *static_cast<Date*>(_rRH.m_aValue.m_pValue);
413
21.2k
                break;
414
0
            case DataType::TIME:
415
0
                (*this) = *static_cast<Time*>(_rRH.m_aValue.m_pValue);
416
0
                break;
417
65.1k
            case DataType::TIMESTAMP:
418
65.1k
                (*this) = *static_cast<DateTime*>(_rRH.m_aValue.m_pValue);
419
65.1k
                break;
420
0
            case DataType::BINARY:
421
0
            case DataType::VARBINARY:
422
0
            case DataType::LONGVARBINARY:
423
0
                (*this) = *static_cast<Sequence<sal_Int8>*>(_rRH.m_aValue.m_pValue);
424
0
                break;
425
0
            case DataType::BIT:
426
0
            case DataType::BOOLEAN:
427
0
                m_aValue.m_bBool    = _rRH.m_aValue.m_bBool;
428
0
                break;
429
0
            case DataType::TINYINT:
430
0
                if ( _rRH.m_bSigned )
431
0
                    m_aValue.m_nInt8    = _rRH.m_aValue.m_nInt8;
432
0
                else
433
0
                    m_aValue.m_uInt8    = _rRH.m_aValue.m_uInt8;
434
0
                break;
435
0
            case DataType::SMALLINT:
436
0
                if ( _rRH.m_bSigned )
437
0
                    m_aValue.m_nInt16   = _rRH.m_aValue.m_nInt16;
438
0
                else
439
0
                    m_aValue.m_uInt16   = _rRH.m_aValue.m_uInt16;
440
0
                break;
441
4.07M
            case DataType::INTEGER:
442
4.07M
                if ( _rRH.m_bSigned )
443
4.07M
                    m_aValue.m_nInt32   = _rRH.m_aValue.m_nInt32;
444
0
                else
445
0
                    m_aValue.m_uInt32   = _rRH.m_aValue.m_uInt32;
446
4.07M
                break;
447
0
            case DataType::BIGINT:
448
0
                if ( _rRH.m_bSigned )
449
0
                    m_aValue.m_nInt64   = _rRH.m_aValue.m_nInt64;
450
0
                else
451
0
                    m_aValue.m_uInt64   = _rRH.m_aValue.m_uInt64;
452
0
                break;
453
0
            case DataType::FLOAT:
454
0
                m_aValue.m_nFloat  = _rRH.m_aValue.m_nFloat;
455
0
                break;
456
385k
            case DataType::DOUBLE:
457
385k
            case DataType::REAL:
458
385k
                m_aValue.m_nDouble  = _rRH.m_aValue.m_nDouble;
459
385k
                break;
460
0
            default:
461
0
                *static_cast<Any*>(m_aValue.m_pValue) = *static_cast<Any*>(_rRH.m_aValue.m_pValue);
462
5.35M
        }
463
5.35M
    }
464
465
27.5M
    m_bNull     = _rRH.m_bNull;
466
    // OJ: BUGID: 96277
467
27.5M
    m_eTypeKind = _rRH.m_eTypeKind;
468
469
27.5M
    return *this;
470
27.5M
}
471
472
ORowSetValue& ORowSetValue::operator=(ORowSetValue&& _rRH) noexcept
473
2.96M
{
474
2.96M
    if ( m_eTypeKind != _rRH.m_eTypeKind || !m_bNull)
475
1.71M
        free();
476
2.96M
    if(!_rRH.m_bNull)
477
2.96M
    {
478
2.96M
        m_aValue    = _rRH.m_aValue;
479
2.96M
        memset(&_rRH.m_aValue, 0, sizeof(_rRH.m_aValue));
480
2.96M
    }
481
2.96M
    m_bBound    = _rRH.m_bBound;
482
2.96M
    m_eTypeKind = _rRH.m_eTypeKind;
483
2.96M
    m_bSigned   = _rRH.m_bSigned;
484
2.96M
    m_bNull     = _rRH.m_bNull;
485
2.96M
    _rRH.m_bNull = true;
486
2.96M
    return *this;
487
2.96M
}
488
489
490
ORowSetValue& ORowSetValue::operator=(const Date& _rRH)
491
251k
{
492
251k
    if(m_eTypeKind != DataType::DATE)
493
35.7k
        free();
494
495
251k
    if(m_bNull)
496
181k
    {
497
181k
        m_aValue.m_pValue = new Date(_rRH);
498
181k
        m_eTypeKind = DataType::DATE;
499
181k
        m_bNull = false;
500
181k
    }
501
70.6k
    else
502
70.6k
        *static_cast<Date*>(m_aValue.m_pValue) = _rRH;
503
504
251k
    return *this;
505
251k
}
506
507
ORowSetValue& ORowSetValue::operator=(const css::util::Time& _rRH)
508
0
{
509
0
    if(m_eTypeKind != DataType::TIME)
510
0
        free();
511
512
0
    if(m_bNull)
513
0
    {
514
0
        m_aValue.m_pValue = new Time(_rRH);
515
0
        m_eTypeKind = DataType::TIME;
516
0
        m_bNull = false;
517
0
    }
518
0
    else
519
0
        *static_cast<Time*>(m_aValue.m_pValue) = _rRH;
520
521
0
    return *this;
522
0
}
523
524
ORowSetValue& ORowSetValue::operator=(const DateTime& _rRH)
525
312k
{
526
312k
    if(m_eTypeKind != DataType::TIMESTAMP)
527
52.5k
        free();
528
312k
    if(m_bNull)
529
198k
    {
530
198k
        m_aValue.m_pValue = new DateTime(_rRH);
531
198k
        m_eTypeKind = DataType::TIMESTAMP;
532
198k
        m_bNull = false;
533
198k
    }
534
114k
    else
535
114k
        *static_cast<DateTime*>(m_aValue.m_pValue) = _rRH;
536
537
312k
    return *this;
538
312k
}
539
540
541
ORowSetValue& ORowSetValue::operator=(const OUString& _rRH)
542
4.39M
{
543
4.39M
    if(m_eTypeKind != DataType::VARCHAR || m_aValue.m_pString != _rRH.pData)
544
4.39M
    {
545
4.39M
        free();
546
4.39M
        m_bNull = false;
547
548
4.39M
        m_aValue.m_pString = _rRH.pData;
549
4.39M
        rtl_uString_acquire(m_aValue.m_pString);
550
4.39M
        m_eTypeKind = DataType::VARCHAR;
551
4.39M
    }
552
553
4.39M
    return *this;
554
4.39M
}
555
556
557
ORowSetValue& ORowSetValue::operator=(double _rRH)
558
987k
{
559
987k
    if(m_eTypeKind != DataType::DOUBLE)
560
108k
        free();
561
562
987k
    m_aValue.m_nDouble = _rRH;
563
987k
    m_eTypeKind = DataType::DOUBLE;
564
987k
    m_bNull = false;
565
566
987k
    return *this;
567
987k
}
568
569
ORowSetValue& ORowSetValue::operator=(float _rRH)
570
0
{
571
0
    if(m_eTypeKind != DataType::FLOAT)
572
0
        free();
573
574
0
    m_aValue.m_nFloat = _rRH;
575
0
    m_eTypeKind = DataType::FLOAT;
576
0
    m_bNull = false;
577
578
0
    return *this;
579
0
}
580
581
582
ORowSetValue& ORowSetValue::operator=(sal_Int8 _rRH)
583
0
{
584
0
    if(m_eTypeKind != DataType::TINYINT )
585
0
        free();
586
587
0
    m_aValue.m_nInt8 = _rRH;
588
0
    m_eTypeKind = DataType::TINYINT;
589
0
    m_bNull = false;
590
0
    m_bSigned = true;
591
0
    return *this;
592
0
}
593
594
ORowSetValue& ORowSetValue::operator=(sal_Int16 _rRH)
595
0
{
596
0
    if(m_eTypeKind != DataType::SMALLINT )
597
0
        free();
598
599
0
    m_aValue.m_nInt16 = _rRH;
600
0
    m_eTypeKind = DataType::SMALLINT;
601
0
    m_bNull = false;
602
0
    m_bSigned = true;
603
604
0
    return *this;
605
0
}
606
607
608
ORowSetValue& ORowSetValue::operator=(sal_uInt16 _rRH)
609
0
{
610
0
    if(m_eTypeKind != DataType::SMALLINT )
611
0
        free();
612
613
0
    m_aValue.m_uInt16 = _rRH;
614
0
    m_eTypeKind = DataType::SMALLINT;
615
0
    m_bNull = false;
616
0
    m_bSigned = false;
617
618
0
    return *this;
619
0
}
620
621
622
ORowSetValue& ORowSetValue::operator=(sal_Int32 _rRH)
623
5.88M
{
624
5.88M
    if(m_eTypeKind != DataType::INTEGER )
625
14.2k
        free();
626
627
5.88M
    m_aValue.m_nInt32 = _rRH;
628
629
5.88M
    m_eTypeKind = DataType::INTEGER;
630
5.88M
    m_bNull = false;
631
5.88M
    m_bSigned = true;
632
633
5.88M
    return *this;
634
5.88M
}
635
636
637
ORowSetValue& ORowSetValue::operator=(sal_uInt32 _rRH)
638
0
{
639
0
    if(m_eTypeKind != DataType::INTEGER )
640
0
        free();
641
642
0
    m_aValue.m_uInt32 = _rRH;
643
644
0
    m_eTypeKind = DataType::INTEGER;
645
0
    m_bNull = false;
646
0
    m_bSigned = false;
647
648
0
    return *this;
649
0
}
650
651
652
ORowSetValue& ORowSetValue::operator=(const bool _rRH)
653
427k
{
654
427k
    if(m_eTypeKind != DataType::BIT && DataType::BOOLEAN != m_eTypeKind )
655
31.6k
        free();
656
657
427k
    m_aValue.m_bBool = _rRH;
658
427k
    m_eTypeKind = DataType::BOOLEAN;
659
427k
    m_bNull = false;
660
661
427k
    return *this;
662
427k
}
663
664
ORowSetValue& ORowSetValue::operator=(sal_Int64 _rRH)
665
0
{
666
0
    if ( DataType::BIGINT != m_eTypeKind)
667
0
        free();
668
669
0
    m_aValue.m_nInt64 = _rRH;
670
0
    m_eTypeKind = DataType::BIGINT;
671
0
    m_bNull = false;
672
0
    m_bSigned = true;
673
674
0
    return *this;
675
0
}
676
677
ORowSetValue& ORowSetValue::operator=(sal_uInt64 _rRH)
678
0
{
679
0
    if ( DataType::BIGINT != m_eTypeKind)
680
0
        free();
681
682
0
    m_aValue.m_uInt64 = _rRH;
683
0
    m_eTypeKind = DataType::BIGINT;
684
0
    m_bNull = false;
685
0
    m_bSigned = false;
686
687
0
    return *this;
688
0
}
689
690
ORowSetValue& ORowSetValue::operator=(const Sequence<sal_Int8>& _rRH)
691
275k
{
692
275k
    if (!isStorageCompatible(DataType::LONGVARBINARY,m_eTypeKind))
693
43.1k
        free();
694
695
275k
    if (m_bNull)
696
270k
    {
697
270k
        m_aValue.m_pValue = new Sequence<sal_Int8>(_rRH);
698
270k
    }
699
4.47k
    else
700
4.47k
        *static_cast< Sequence< sal_Int8 >* >(m_aValue.m_pValue) = _rRH;
701
702
275k
    m_eTypeKind = DataType::LONGVARBINARY;
703
275k
    m_bNull = false;
704
705
275k
    return *this;
706
275k
}
707
708
ORowSetValue& ORowSetValue::operator=(const Any& _rAny)
709
14.5M
{
710
14.5M
    if (!isStorageCompatible(DataType::OBJECT,m_eTypeKind))
711
6.62M
        free();
712
713
14.5M
    if ( m_bNull )
714
6.62M
    {
715
6.62M
        m_aValue.m_pValue = new Any(_rAny);
716
6.62M
    }
717
7.87M
    else
718
7.87M
        *static_cast<Any*>(m_aValue.m_pValue) = _rAny;
719
720
14.5M
    m_eTypeKind = DataType::OBJECT;
721
14.5M
    m_bNull = false;
722
723
14.5M
    return *this;
724
14.5M
}
725
726
727
bool ORowSetValue::operator==(const ORowSetValue& _rRH) const
728
0
{
729
0
    if ( m_bNull != _rRH.isNull() )
730
0
        return false;
731
732
0
    if(m_bNull && _rRH.isNull())
733
0
        return true;
734
735
0
    if ( !isStorageComparable(m_eTypeKind, _rRH.m_eTypeKind ))
736
0
    {
737
0
        switch(m_eTypeKind)
738
0
        {
739
0
            case DataType::FLOAT:
740
0
            case DataType::DOUBLE:
741
0
            case DataType::REAL:
742
0
                return getDouble() == _rRH.getDouble();
743
0
            default:
744
0
                switch(_rRH.m_eTypeKind)
745
0
                {
746
0
                    case DataType::FLOAT:
747
0
                    case DataType::DOUBLE:
748
0
                    case DataType::REAL:
749
0
                            return getDouble() == _rRH.getDouble();
750
0
                    default:
751
0
                            break;
752
0
                }
753
0
                break;
754
0
        }
755
0
        return false;
756
0
    }
757
758
0
    bool bRet = false;
759
0
    OSL_ENSURE(!m_bNull,"Should not be null!");
760
0
    switch(m_eTypeKind)
761
0
    {
762
0
        case DataType::VARCHAR:
763
0
        case DataType::CHAR:
764
0
        case DataType::LONGVARCHAR:
765
0
        {
766
0
            OUString aVal1(m_aValue.m_pString);
767
0
            OUString aVal2(_rRH.m_aValue.m_pString);
768
0
            return aVal1 == aVal2;
769
0
        }
770
0
        default:
771
0
            if ( m_bSigned != _rRH.m_bSigned )
772
0
                return false;
773
0
            break;
774
0
    }
775
776
0
    switch(m_eTypeKind)
777
0
    {
778
0
        case DataType::DECIMAL:
779
0
        case DataType::NUMERIC:
780
0
            {
781
0
                OUString aVal1(m_aValue.m_pString);
782
0
                OUString aVal2(_rRH.m_aValue.m_pString);
783
0
                bRet = aVal1 == aVal2;
784
0
            }
785
0
            break;
786
0
        case DataType::FLOAT:
787
0
            bRet = m_aValue.m_nFloat == _rRH.m_aValue.m_nFloat;
788
0
            break;
789
0
        case DataType::DOUBLE:
790
0
        case DataType::REAL:
791
0
            bRet = m_aValue.m_nDouble == _rRH.m_aValue.m_nDouble;
792
0
            break;
793
0
        case DataType::TINYINT:
794
0
            bRet = m_bSigned ? ( m_aValue.m_nInt8 == _rRH.m_aValue.m_nInt8 ) : (m_aValue.m_uInt8 == _rRH.m_aValue.m_uInt8);
795
0
            break;
796
0
        case DataType::SMALLINT:
797
0
            bRet = m_bSigned ? ( m_aValue.m_nInt16 == _rRH.m_aValue.m_nInt16 ) : (m_aValue.m_uInt16 == _rRH.m_aValue.m_uInt16);
798
0
            break;
799
0
        case DataType::INTEGER:
800
0
            bRet = m_bSigned ? ( m_aValue.m_nInt32 == _rRH.m_aValue.m_nInt32 ) : (m_aValue.m_uInt32 == _rRH.m_aValue.m_uInt32);
801
0
            break;
802
0
        case DataType::BIGINT:
803
0
            bRet = m_bSigned ? ( m_aValue.m_nInt64 == _rRH.m_aValue.m_nInt64 ) : (m_aValue.m_uInt64 == _rRH.m_aValue.m_uInt64);
804
0
            break;
805
0
        case DataType::BIT:
806
0
        case DataType::BOOLEAN:
807
0
            bRet = m_aValue.m_bBool == _rRH.m_aValue.m_bBool;
808
0
            break;
809
0
        case DataType::DATE:
810
0
            bRet = *static_cast<Date*>(m_aValue.m_pValue) == *static_cast<Date*>(_rRH.m_aValue.m_pValue);
811
0
            break;
812
0
        case DataType::TIME:
813
0
            bRet = *static_cast<Time*>(m_aValue.m_pValue) == *static_cast<Time*>(_rRH.m_aValue.m_pValue);
814
0
            break;
815
0
        case DataType::TIMESTAMP:
816
0
            bRet = *static_cast<DateTime*>(m_aValue.m_pValue) == *static_cast<DateTime*>(_rRH.m_aValue.m_pValue);
817
0
            break;
818
0
        case DataType::BINARY:
819
0
        case DataType::VARBINARY:
820
0
        case DataType::LONGVARBINARY:
821
0
        case DataType::BLOB:
822
0
        case DataType::CLOB:
823
0
        case DataType::OBJECT:
824
0
        case DataType::OTHER:
825
0
            bRet = false;
826
0
            break;
827
0
        default:
828
0
            bRet = false;
829
0
            SAL_WARN( "connectivity.commontools","ORowSetValue::operator==(): UNSUPPORTED TYPE!");
830
0
            break;
831
0
    }
832
0
    return bRet;
833
0
}
834
835
Any ORowSetValue::makeAny() const
836
12.8M
{
837
12.8M
    Any rValue;
838
12.8M
    if(isBound() && !isNull())
839
6.45M
    {
840
6.45M
        switch(getTypeKind())
841
6.45M
        {
842
0
            case DataType::SQLNULL:
843
0
                assert(rValue == Any());
844
0
                break;
845
0
            case DataType::CHAR:
846
217
            case DataType::VARCHAR:
847
512
            case DataType::DECIMAL:
848
512
            case DataType::NUMERIC:
849
512
            case DataType::LONGVARCHAR:
850
512
                OSL_ENSURE(m_aValue.m_pString,"Value is null!");
851
512
                rValue <<= OUString(m_aValue.m_pString);
852
512
                break;
853
0
            case DataType::FLOAT:
854
0
                rValue <<= m_aValue.m_nFloat;
855
0
                break;
856
1.09k
            case DataType::DOUBLE:
857
1.09k
            case DataType::REAL:
858
1.09k
                rValue <<= m_aValue.m_nDouble;
859
1.09k
                break;
860
3.49k
            case DataType::DATE:
861
3.49k
                assert(m_aValue.m_pValue && "Value is null!");
862
3.49k
                rValue <<= *static_cast<Date*>(m_aValue.m_pValue);
863
3.49k
                break;
864
0
            case DataType::TIME:
865
0
                assert(m_aValue.m_pValue && "Value is null!");
866
0
                rValue <<= *static_cast<Time*>(m_aValue.m_pValue);
867
0
                break;
868
2.43k
            case DataType::TIMESTAMP:
869
2.43k
                assert(m_aValue.m_pValue && "Value is null!");
870
2.43k
                rValue <<= *static_cast<DateTime*>(m_aValue.m_pValue);
871
2.43k
                break;
872
0
            case DataType::BINARY:
873
0
            case DataType::VARBINARY:
874
0
            case DataType::LONGVARBINARY:
875
0
                assert(m_aValue.m_pValue && "Value is null!");
876
0
                rValue <<= *static_cast<Sequence<sal_Int8>*>(m_aValue.m_pValue);
877
0
                break;
878
0
            case DataType::BLOB:
879
0
            case DataType::CLOB:
880
6.44M
            case DataType::OBJECT:
881
6.44M
            case DataType::OTHER:
882
6.44M
                rValue = getAny();
883
6.44M
                break;
884
304
            case DataType::BIT:
885
304
            case DataType::BOOLEAN:
886
304
                rValue <<= m_aValue.m_bBool;
887
304
                break;
888
0
            case DataType::TINYINT:
889
0
                if ( m_bSigned )
890
                    // TypeClass_BYTE
891
0
                    rValue <<= m_aValue.m_nInt8;
892
0
                else
893
                    // There is no TypeClass_UNSIGNED_BYTE,
894
                    // so silently promote it to a 16-bit integer,
895
                    // that is TypeClass_UNSIGNED_SHORT
896
0
                    rValue <<= static_cast<sal_uInt16>(m_aValue.m_uInt8);
897
0
                break;
898
0
            case DataType::SMALLINT:
899
0
                if ( m_bSigned )
900
                    // TypeClass_SHORT
901
0
                    rValue <<= m_aValue.m_nInt16;
902
0
                else
903
                    // TypeClass_UNSIGNED_SHORT
904
0
                    rValue <<= m_aValue.m_uInt16;
905
0
                break;
906
3.87k
            case DataType::INTEGER:
907
3.87k
                if ( m_bSigned )
908
                    // TypeClass_LONG
909
3.87k
                    rValue <<= m_aValue.m_nInt32;
910
0
                else
911
                    // TypeClass_UNSIGNED_LONG
912
0
                    rValue <<= m_aValue.m_uInt32;
913
3.87k
                break;
914
0
            case DataType::BIGINT:
915
0
                if ( m_bSigned )
916
                    // TypeClass_HYPER
917
0
                    rValue <<= m_aValue.m_nInt64;
918
0
                else
919
                    // TypeClass_UNSIGNED_HYPER
920
0
                    rValue <<= m_aValue.m_uInt64;
921
0
                break;
922
0
            default:
923
0
                SAL_WARN( "connectivity.commontools","ORowSetValue::makeAny(): UNSUPPORTED TYPE!");
924
0
                rValue = getAny();
925
0
                break;
926
6.45M
        }
927
6.45M
    }
928
12.8M
    return rValue;
929
12.8M
}
930
931
OUString ORowSetValue::getString( ) const
932
3.87M
{
933
3.87M
    OUString aRet;
934
3.87M
    if(!m_bNull)
935
2.80M
    {
936
2.80M
        switch(getTypeKind())
937
2.80M
        {
938
0
            case DataType::CHAR:
939
2.42M
            case DataType::VARCHAR:
940
2.48M
            case DataType::DECIMAL:
941
2.48M
            case DataType::NUMERIC:
942
2.59M
            case DataType::LONGVARCHAR:
943
2.59M
                aRet = m_aValue.m_pString;
944
2.59M
                break;
945
0
            case DataType::FLOAT:
946
0
                aRet = OUString::number(getFloat());
947
0
                break;
948
111k
            case DataType::DOUBLE:
949
111k
            case DataType::REAL:
950
111k
                aRet = OUString::number(getDouble());
951
111k
                break;
952
2.22k
            case DataType::DATE:
953
2.22k
                aRet = DBTypeConversion::toDateString(getDate());
954
2.22k
                break;
955
0
            case DataType::TIME:
956
0
                aRet = DBTypeConversion::toTimeString(getTime());
957
0
                break;
958
19.6k
            case DataType::TIMESTAMP:
959
19.6k
                aRet = DBTypeConversion::toDateTimeString(getDateTime());
960
19.6k
                break;
961
0
            case DataType::BINARY:
962
0
            case DataType::VARBINARY:
963
0
            case DataType::LONGVARBINARY:
964
0
                {
965
0
                    OUStringBuffer sVal("0x");
966
0
                    for (sal_Int32 byte : getSequence())
967
0
                        sVal.append(byte, 16);
968
0
                    aRet = sVal.makeStringAndClear();
969
0
                }
970
0
                break;
971
218
            case DataType::BIT:
972
218
                aRet = OUString::number(int(getBool()));
973
218
                break;
974
0
            case DataType::BOOLEAN:
975
0
                aRet = OUString::boolean(getBool());
976
0
                break;
977
0
            case DataType::TINYINT:
978
0
            case DataType::SMALLINT:
979
79.5k
            case DataType::INTEGER:
980
79.5k
                if ( m_bSigned )
981
79.5k
                    aRet = OUString::number(getInt32());
982
0
                else
983
0
                    aRet = OUString::number(getUInt32());
984
79.5k
                break;
985
0
            case DataType::BIGINT:
986
0
                if ( m_bSigned )
987
0
                    aRet = OUString::number(getLong());
988
0
                else
989
0
                    aRet = OUString::number(getULong());
990
0
                break;
991
0
            case DataType::CLOB:
992
0
                {
993
0
                    Any aValue( getAny() );
994
0
                    Reference< XClob > xClob;
995
0
                    if ( (aValue >>= xClob) && xClob.is() )
996
0
                    {
997
0
                        aRet = xClob->getSubString(1,static_cast<sal_Int32>(xClob->length()) );
998
0
                    }
999
0
                }
1000
0
                break;
1001
0
            default:
1002
0
                {
1003
0
                    Any aValue = makeAny();
1004
0
                    aValue >>= aRet;
1005
0
                    break;
1006
0
                }
1007
2.80M
        }
1008
2.80M
    }
1009
3.87M
    return aRet;
1010
3.87M
}
1011
1012
bool ORowSetValue::getBool()    const
1013
686k
{
1014
686k
    bool bRet = false;
1015
686k
    if(!m_bNull)
1016
233k
    {
1017
233k
        switch(getTypeKind())
1018
233k
        {
1019
0
            case DataType::CHAR:
1020
11.8k
            case DataType::VARCHAR:
1021
11.8k
            case DataType::LONGVARCHAR:
1022
11.8k
                {
1023
11.8k
                    const OUString sValue(m_aValue.m_pString);
1024
11.8k
                    if ( sValue.equalsIgnoreAsciiCase("true") || (sValue == "1") )
1025
440
                    {
1026
440
                        bRet = true;
1027
440
                        break;
1028
440
                    }
1029
11.3k
                    else if ( sValue.equalsIgnoreAsciiCase("false") || (sValue == "0") )
1030
942
                    {
1031
942
                        bRet = false;
1032
942
                        break;
1033
942
                    }
1034
11.8k
                }
1035
10.4k
                [[fallthrough]];
1036
10.6k
            case DataType::DECIMAL:
1037
10.6k
            case DataType::NUMERIC:
1038
1039
10.6k
                bRet = OUString::unacquired(&m_aValue.m_pString).toInt32() != 0;
1040
10.6k
                break;
1041
0
            case DataType::FLOAT:
1042
0
                bRet = m_aValue.m_nFloat != 0.0;
1043
0
                break;
1044
850
            case DataType::DOUBLE:
1045
850
            case DataType::REAL:
1046
850
                bRet = m_aValue.m_nDouble != 0.0;
1047
850
                break;
1048
234
            case DataType::DATE:
1049
234
            case DataType::TIME:
1050
757
            case DataType::TIMESTAMP:
1051
757
            case DataType::BINARY:
1052
757
            case DataType::VARBINARY:
1053
757
            case DataType::LONGVARBINARY:
1054
757
                OSL_FAIL("getBool() for this type is not allowed!");
1055
757
                break;
1056
96.2k
            case DataType::BIT:
1057
196k
            case DataType::BOOLEAN:
1058
196k
                bRet = m_aValue.m_bBool;
1059
196k
                break;
1060
0
            case DataType::TINYINT:
1061
0
                bRet = m_bSigned ? (m_aValue.m_nInt8  != 0) : (m_aValue.m_uInt8 != 0);
1062
0
                break;
1063
0
            case DataType::SMALLINT:
1064
0
                bRet = m_bSigned ? (m_aValue.m_nInt16  != 0) : (m_aValue.m_uInt16 != 0);
1065
0
                break;
1066
23.1k
            case DataType::INTEGER:
1067
23.1k
                bRet = m_bSigned ? (m_aValue.m_nInt32 != 0) : (m_aValue.m_uInt32 != 0);
1068
23.1k
                break;
1069
0
            case DataType::BIGINT:
1070
0
                bRet = m_bSigned ? (m_aValue.m_nInt64 != 0) : (m_aValue.m_uInt64 != 0);
1071
0
                break;
1072
0
            default:
1073
0
                {
1074
0
                    Any aValue = makeAny();
1075
0
                    aValue >>= bRet;
1076
0
                    break;
1077
96.2k
                }
1078
233k
        }
1079
233k
    }
1080
686k
    return bRet;
1081
686k
}
1082
1083
1084
sal_Int8 ORowSetValue::getInt8()    const
1085
0
{
1086
0
    sal_Int8 nRet = 0;
1087
0
    if(!m_bNull)
1088
0
    {
1089
0
        switch(getTypeKind())
1090
0
        {
1091
0
            case DataType::CHAR:
1092
0
            case DataType::VARCHAR:
1093
0
            case DataType::DECIMAL:
1094
0
            case DataType::NUMERIC:
1095
0
            case DataType::LONGVARCHAR:
1096
0
                nRet = sal_Int8(OUString::unacquired(&m_aValue.m_pString).toInt32());
1097
0
                break;
1098
0
            case DataType::FLOAT:
1099
0
                nRet = sal_Int8(m_aValue.m_nFloat);
1100
0
                break;
1101
0
            case DataType::DOUBLE:
1102
0
            case DataType::REAL:
1103
0
                nRet = sal_Int8(m_aValue.m_nDouble);
1104
0
                break;
1105
0
            case DataType::DATE:
1106
0
            case DataType::TIME:
1107
0
            case DataType::TIMESTAMP:
1108
0
            case DataType::BINARY:
1109
0
            case DataType::VARBINARY:
1110
0
            case DataType::LONGVARBINARY:
1111
0
            case DataType::BLOB:
1112
0
            case DataType::CLOB:
1113
0
                OSL_FAIL("getInt8() for this type is not allowed!");
1114
0
                break;
1115
0
            case DataType::BIT:
1116
0
            case DataType::BOOLEAN:
1117
0
                nRet = sal_Int8(m_aValue.m_bBool);
1118
0
                break;
1119
0
            case DataType::TINYINT:
1120
0
                if ( m_bSigned )
1121
0
                    nRet = m_aValue.m_nInt8;
1122
0
                else
1123
0
                    nRet = static_cast<sal_Int8>(m_aValue.m_uInt8);
1124
0
                break;
1125
0
            case DataType::SMALLINT:
1126
0
                if ( m_bSigned )
1127
0
                    nRet = static_cast<sal_Int8>(m_aValue.m_nInt16);
1128
0
                else
1129
0
                    nRet = static_cast<sal_Int8>(m_aValue.m_uInt16);
1130
0
                break;
1131
0
            case DataType::INTEGER:
1132
0
                if ( m_bSigned )
1133
0
                    nRet = static_cast<sal_Int8>(m_aValue.m_nInt32);
1134
0
                else
1135
0
                    nRet = static_cast<sal_Int8>(m_aValue.m_uInt32);
1136
0
                break;
1137
0
            case DataType::BIGINT:
1138
0
                if ( m_bSigned )
1139
0
                    nRet = static_cast<sal_Int8>(m_aValue.m_nInt64);
1140
0
                else
1141
0
                    nRet = static_cast<sal_Int8>(m_aValue.m_uInt64);
1142
0
                break;
1143
0
            default:
1144
0
                {
1145
0
                    Any aValue = makeAny();
1146
0
                    aValue >>= nRet;
1147
0
                    break;
1148
0
                }
1149
0
        }
1150
0
    }
1151
0
    return nRet;
1152
0
}
1153
1154
1155
sal_uInt8 ORowSetValue::getUInt8()    const
1156
0
{
1157
0
    sal_uInt8 nRet = 0;
1158
0
    if(!m_bNull)
1159
0
    {
1160
0
        switch(getTypeKind())
1161
0
        {
1162
0
            case DataType::CHAR:
1163
0
            case DataType::VARCHAR:
1164
0
            case DataType::DECIMAL:
1165
0
            case DataType::NUMERIC:
1166
0
            case DataType::LONGVARCHAR:
1167
0
                nRet = sal_uInt8(OUString::unacquired(&m_aValue.m_pString).toInt32());
1168
0
                break;
1169
0
            case DataType::FLOAT:
1170
0
                nRet = sal_uInt8(m_aValue.m_nFloat);
1171
0
                break;
1172
0
            case DataType::DOUBLE:
1173
0
            case DataType::REAL:
1174
0
                nRet = sal_uInt8(m_aValue.m_nDouble);
1175
0
                break;
1176
0
            case DataType::DATE:
1177
0
            case DataType::TIME:
1178
0
            case DataType::TIMESTAMP:
1179
0
            case DataType::BINARY:
1180
0
            case DataType::VARBINARY:
1181
0
            case DataType::LONGVARBINARY:
1182
0
            case DataType::BLOB:
1183
0
            case DataType::CLOB:
1184
0
                OSL_FAIL("getuInt8() for this type is not allowed!");
1185
0
                break;
1186
0
            case DataType::BIT:
1187
0
            case DataType::BOOLEAN:
1188
0
                nRet = int(m_aValue.m_bBool);
1189
0
                break;
1190
0
            case DataType::TINYINT:
1191
0
                if ( m_bSigned )
1192
0
                    nRet = m_aValue.m_nInt8;
1193
0
                else
1194
0
                    nRet = m_aValue.m_uInt8;
1195
0
                break;
1196
0
            case DataType::SMALLINT:
1197
0
                if ( m_bSigned )
1198
0
                    nRet = static_cast<sal_uInt8>(m_aValue.m_nInt16);
1199
0
                else
1200
0
                    nRet = static_cast<sal_uInt8>(m_aValue.m_uInt16);
1201
0
                break;
1202
0
            case DataType::INTEGER:
1203
0
                if ( m_bSigned )
1204
0
                    nRet = static_cast<sal_uInt8>(m_aValue.m_nInt32);
1205
0
                else
1206
0
                    nRet = static_cast<sal_uInt8>(m_aValue.m_uInt32);
1207
0
                break;
1208
0
            case DataType::BIGINT:
1209
0
                if ( m_bSigned )
1210
0
                    nRet = static_cast<sal_uInt8>(m_aValue.m_nInt64);
1211
0
                else
1212
0
                    nRet = static_cast<sal_uInt8>(m_aValue.m_uInt64);
1213
0
                break;
1214
0
            default:
1215
0
                {
1216
0
                    Any aValue = makeAny();
1217
                    // Cf. "There is no TypeClass_UNSIGNED_BYTE" in makeAny:
1218
0
                    sal_uInt16 n;
1219
0
                    if (aValue >>= n) {
1220
0
                        nRet = static_cast<sal_uInt8>(n);
1221
0
                    }
1222
0
                    break;
1223
0
                }
1224
0
        }
1225
0
    }
1226
0
    return nRet;
1227
0
}
1228
1229
1230
sal_Int16 ORowSetValue::getInt16()  const
1231
0
{
1232
0
    sal_Int16 nRet = 0;
1233
0
    if(!m_bNull)
1234
0
    {
1235
0
        switch(getTypeKind())
1236
0
        {
1237
0
            case DataType::CHAR:
1238
0
            case DataType::VARCHAR:
1239
0
            case DataType::DECIMAL:
1240
0
            case DataType::NUMERIC:
1241
0
            case DataType::LONGVARCHAR:
1242
0
                nRet = sal_Int16(OUString::unacquired(&m_aValue.m_pString).toInt32());
1243
0
                break;
1244
0
            case DataType::FLOAT:
1245
0
                nRet = sal_Int16(m_aValue.m_nFloat);
1246
0
                break;
1247
0
            case DataType::DOUBLE:
1248
0
            case DataType::REAL:
1249
0
                nRet = sal_Int16(m_aValue.m_nDouble);
1250
0
                break;
1251
0
            case DataType::DATE:
1252
0
            case DataType::TIME:
1253
0
            case DataType::TIMESTAMP:
1254
0
            case DataType::BINARY:
1255
0
            case DataType::VARBINARY:
1256
0
            case DataType::LONGVARBINARY:
1257
0
            case DataType::BLOB:
1258
0
            case DataType::CLOB:
1259
0
                OSL_FAIL("getInt16() for this type is not allowed!");
1260
0
                break;
1261
0
            case DataType::BIT:
1262
0
            case DataType::BOOLEAN:
1263
0
                nRet = sal_Int16(m_aValue.m_bBool);
1264
0
                break;
1265
0
            case DataType::TINYINT:
1266
0
                if ( m_bSigned )
1267
0
                    nRet = m_aValue.m_nInt8;
1268
0
                else
1269
0
                    nRet = m_aValue.m_uInt8;
1270
0
                break;
1271
0
            case DataType::SMALLINT:
1272
0
                if ( m_bSigned )
1273
0
                    nRet = m_aValue.m_nInt16;
1274
0
                else
1275
0
                    nRet = static_cast<sal_Int16>(m_aValue.m_uInt16);
1276
0
                break;
1277
0
            case DataType::INTEGER:
1278
0
                if ( m_bSigned )
1279
0
                    nRet = static_cast<sal_Int16>(m_aValue.m_nInt32);
1280
0
                else
1281
0
                    nRet = static_cast<sal_Int16>(m_aValue.m_uInt32);
1282
0
                break;
1283
0
            case DataType::BIGINT:
1284
0
                if ( m_bSigned )
1285
0
                    nRet = static_cast<sal_Int16>(m_aValue.m_nInt64);
1286
0
                else
1287
0
                    nRet = static_cast<sal_Int16>(m_aValue.m_uInt64);
1288
0
                break;
1289
0
            default:
1290
0
                {
1291
0
                    Any aValue = makeAny();
1292
0
                    aValue >>= nRet;
1293
0
                    break;
1294
0
                }
1295
0
        }
1296
0
    }
1297
0
    return nRet;
1298
0
}
1299
1300
1301
sal_uInt16 ORowSetValue::getUInt16()  const
1302
0
{
1303
0
    sal_uInt16 nRet = 0;
1304
0
    if(!m_bNull)
1305
0
    {
1306
0
        switch(getTypeKind())
1307
0
        {
1308
0
            case DataType::CHAR:
1309
0
            case DataType::VARCHAR:
1310
0
            case DataType::DECIMAL:
1311
0
            case DataType::NUMERIC:
1312
0
            case DataType::LONGVARCHAR:
1313
0
                nRet = sal_uInt16(OUString::unacquired(&m_aValue.m_pString).toInt32());
1314
0
                break;
1315
0
            case DataType::FLOAT:
1316
0
                nRet = sal_uInt16(m_aValue.m_nFloat);
1317
0
                break;
1318
0
            case DataType::DOUBLE:
1319
0
            case DataType::REAL:
1320
0
                nRet = sal_uInt16(m_aValue.m_nDouble);
1321
0
                break;
1322
0
            case DataType::DATE:
1323
0
            case DataType::TIME:
1324
0
            case DataType::TIMESTAMP:
1325
0
            case DataType::BINARY:
1326
0
            case DataType::VARBINARY:
1327
0
            case DataType::LONGVARBINARY:
1328
0
            case DataType::BLOB:
1329
0
            case DataType::CLOB:
1330
0
                OSL_FAIL("getuInt16() for this type is not allowed!");
1331
0
                break;
1332
0
            case DataType::BIT:
1333
0
            case DataType::BOOLEAN:
1334
0
                nRet = sal_uInt16(m_aValue.m_bBool);
1335
0
                break;
1336
0
            case DataType::TINYINT:
1337
0
                if ( m_bSigned )
1338
0
                    nRet = m_aValue.m_nInt8;
1339
0
                else
1340
0
                    nRet = m_aValue.m_uInt8;
1341
0
                break;
1342
0
            case DataType::SMALLINT:
1343
0
                if ( m_bSigned )
1344
0
                    nRet = m_aValue.m_nInt16;
1345
0
                else
1346
0
                    nRet = m_aValue.m_uInt16;
1347
0
                break;
1348
0
            case DataType::INTEGER:
1349
0
                if ( m_bSigned )
1350
0
                    nRet = static_cast<sal_uInt16>(m_aValue.m_nInt32);
1351
0
                else
1352
0
                    nRet = static_cast<sal_uInt16>(m_aValue.m_uInt32);
1353
0
                break;
1354
0
            case DataType::BIGINT:
1355
0
                if ( m_bSigned )
1356
0
                    nRet = static_cast<sal_uInt16>(m_aValue.m_nInt64);
1357
0
                else
1358
0
                    nRet = static_cast<sal_uInt16>(m_aValue.m_uInt64);
1359
0
                break;
1360
0
            default:
1361
0
                {
1362
0
                    Any aValue = makeAny();
1363
0
                    aValue >>= nRet;
1364
0
                    break;
1365
0
                }
1366
0
        }
1367
0
    }
1368
0
    return nRet;
1369
0
}
1370
1371
1372
sal_Int32 ORowSetValue::getInt32()  const
1373
5.44M
{
1374
5.44M
    sal_Int32 nRet = 0;
1375
5.44M
    if(!m_bNull)
1376
5.40M
    {
1377
5.40M
        switch(getTypeKind())
1378
5.40M
        {
1379
0
            case DataType::CHAR:
1380
198
            case DataType::VARCHAR:
1381
394
            case DataType::DECIMAL:
1382
394
            case DataType::NUMERIC:
1383
394
            case DataType::LONGVARCHAR:
1384
394
                nRet = OUString::unacquired(&m_aValue.m_pString).toInt32();
1385
394
                break;
1386
0
            case DataType::FLOAT:
1387
0
                nRet = sal_Int32(m_aValue.m_nFloat);
1388
0
                break;
1389
253
            case DataType::DOUBLE:
1390
253
            case DataType::REAL:
1391
253
                nRet = sal_Int32(m_aValue.m_nDouble);
1392
253
                break;
1393
3.58k
            case DataType::DATE:
1394
3.58k
                nRet = dbtools::DBTypeConversion::toDays(*static_cast<css::util::Date*>(m_aValue.m_pValue));
1395
3.58k
                break;
1396
0
            case DataType::TIME:
1397
255
            case DataType::TIMESTAMP:
1398
255
            case DataType::BINARY:
1399
255
            case DataType::VARBINARY:
1400
255
            case DataType::LONGVARBINARY:
1401
255
            case DataType::BLOB:
1402
255
            case DataType::CLOB:
1403
255
                OSL_FAIL("getInt32() for this type is not allowed!");
1404
255
                break;
1405
282
            case DataType::BIT:
1406
282
            case DataType::BOOLEAN:
1407
282
                nRet = sal_Int32(m_aValue.m_bBool);
1408
282
                break;
1409
0
            case DataType::TINYINT:
1410
0
                if ( m_bSigned )
1411
0
                    nRet = m_aValue.m_nInt8;
1412
0
                else
1413
0
                    nRet = m_aValue.m_uInt8;
1414
0
                break;
1415
0
            case DataType::SMALLINT:
1416
0
                if ( m_bSigned )
1417
0
                    nRet = m_aValue.m_nInt16;
1418
0
                else
1419
0
                    nRet = m_aValue.m_uInt16;
1420
0
                break;
1421
5.39M
            case DataType::INTEGER:
1422
5.39M
                if ( m_bSigned )
1423
5.39M
                    nRet = m_aValue.m_nInt32;
1424
0
                else
1425
0
                    nRet = static_cast<sal_Int32>(m_aValue.m_uInt32);
1426
5.39M
                break;
1427
0
            case DataType::BIGINT:
1428
0
                if ( m_bSigned )
1429
0
                    nRet = static_cast<sal_Int32>(m_aValue.m_nInt64);
1430
0
                else
1431
0
                    nRet = static_cast<sal_Int32>(m_aValue.m_uInt64);
1432
0
                break;
1433
0
            default:
1434
0
                {
1435
0
                    Any aValue = makeAny();
1436
0
                    aValue >>= nRet;
1437
0
                    break;
1438
282
                }
1439
5.40M
        }
1440
5.40M
    }
1441
5.44M
    return nRet;
1442
5.44M
}
1443
1444
1445
sal_uInt32 ORowSetValue::getUInt32()  const
1446
0
{
1447
0
    sal_uInt32 nRet = 0;
1448
0
    if(!m_bNull)
1449
0
    {
1450
0
        switch(getTypeKind())
1451
0
        {
1452
0
            case DataType::CHAR:
1453
0
            case DataType::VARCHAR:
1454
0
            case DataType::DECIMAL:
1455
0
            case DataType::NUMERIC:
1456
0
            case DataType::LONGVARCHAR:
1457
0
                nRet = OUString::unacquired(&m_aValue.m_pString).toUInt32();
1458
0
                break;
1459
0
            case DataType::FLOAT:
1460
0
                nRet = sal_uInt32(m_aValue.m_nFloat);
1461
0
                break;
1462
0
            case DataType::DOUBLE:
1463
0
            case DataType::REAL:
1464
0
                nRet = sal_uInt32(m_aValue.m_nDouble);
1465
0
                break;
1466
0
            case DataType::DATE:
1467
0
                nRet = dbtools::DBTypeConversion::toDays(*static_cast<css::util::Date*>(m_aValue.m_pValue));
1468
0
                break;
1469
0
            case DataType::TIME:
1470
0
            case DataType::TIMESTAMP:
1471
0
            case DataType::BINARY:
1472
0
            case DataType::VARBINARY:
1473
0
            case DataType::LONGVARBINARY:
1474
0
            case DataType::BLOB:
1475
0
            case DataType::CLOB:
1476
0
                OSL_FAIL("getuInt32() for this type is not allowed!");
1477
0
                break;
1478
0
            case DataType::BIT:
1479
0
            case DataType::BOOLEAN:
1480
0
                nRet = sal_uInt32(m_aValue.m_bBool);
1481
0
                break;
1482
0
            case DataType::TINYINT:
1483
0
                if ( m_bSigned )
1484
0
                    nRet = m_aValue.m_nInt8;
1485
0
                else
1486
0
                    nRet = m_aValue.m_uInt8;
1487
0
                break;
1488
0
            case DataType::SMALLINT:
1489
0
                if ( m_bSigned )
1490
0
                    nRet = m_aValue.m_nInt16;
1491
0
                else
1492
0
                    nRet = m_aValue.m_uInt16;
1493
0
                break;
1494
0
            case DataType::INTEGER:
1495
0
                if ( m_bSigned )
1496
0
                    nRet = m_aValue.m_nInt32;
1497
0
                else
1498
0
                    nRet = m_aValue.m_uInt32;
1499
0
                break;
1500
0
            case DataType::BIGINT:
1501
0
                if ( m_bSigned )
1502
0
                    nRet = static_cast<sal_uInt32>(m_aValue.m_nInt64);
1503
0
                else
1504
0
                    nRet = static_cast<sal_uInt32>(m_aValue.m_uInt64);
1505
0
                break;
1506
0
            default:
1507
0
                {
1508
0
                    Any aValue = makeAny();
1509
0
                    aValue >>= nRet;
1510
0
                    break;
1511
0
                }
1512
0
        }
1513
0
    }
1514
0
    return nRet;
1515
0
}
1516
1517
1518
sal_Int64 ORowSetValue::getLong()   const
1519
28.1k
{
1520
28.1k
    sal_Int64 nRet = 0;
1521
28.1k
    if(!m_bNull)
1522
28.1k
    {
1523
28.1k
        switch(getTypeKind())
1524
28.1k
        {
1525
0
            case DataType::CHAR:
1526
0
            case DataType::VARCHAR:
1527
0
            case DataType::DECIMAL:
1528
0
            case DataType::NUMERIC:
1529
0
            case DataType::LONGVARCHAR:
1530
0
                nRet = OUString::unacquired(&m_aValue.m_pString).toInt64();
1531
0
                break;
1532
0
            case DataType::FLOAT:
1533
0
                nRet = sal_Int64(m_aValue.m_nFloat);
1534
0
                break;
1535
0
            case DataType::DOUBLE:
1536
0
            case DataType::REAL:
1537
0
                nRet = sal_Int64(m_aValue.m_nDouble);
1538
0
                break;
1539
0
            case DataType::DATE:
1540
0
                nRet = dbtools::DBTypeConversion::toDays(*static_cast<css::util::Date*>(m_aValue.m_pValue));
1541
0
                break;
1542
0
            case DataType::TIME:
1543
0
            case DataType::TIMESTAMP:
1544
0
            case DataType::BINARY:
1545
0
            case DataType::VARBINARY:
1546
0
            case DataType::LONGVARBINARY:
1547
0
            case DataType::BLOB:
1548
0
            case DataType::CLOB:
1549
0
                OSL_FAIL("getLong() for this type is not allowed!");
1550
0
                break;
1551
284
            case DataType::BIT:
1552
284
            case DataType::BOOLEAN:
1553
284
                nRet = sal_Int64(m_aValue.m_bBool);
1554
284
                break;
1555
0
            case DataType::TINYINT:
1556
0
                if ( m_bSigned )
1557
0
                    nRet = m_aValue.m_nInt8;
1558
0
                else
1559
0
                    nRet = m_aValue.m_uInt8;
1560
0
                break;
1561
0
            case DataType::SMALLINT:
1562
0
                if ( m_bSigned )
1563
0
                    nRet = m_aValue.m_nInt16;
1564
0
                else
1565
0
                    nRet = m_aValue.m_uInt16;
1566
0
                break;
1567
27.9k
            case DataType::INTEGER:
1568
27.9k
                if ( m_bSigned )
1569
27.9k
                    nRet = m_aValue.m_nInt32;
1570
0
                else
1571
0
                    nRet = m_aValue.m_uInt32;
1572
27.9k
                break;
1573
0
            case DataType::BIGINT:
1574
0
                if ( m_bSigned )
1575
0
                    nRet = m_aValue.m_nInt64;
1576
0
                else
1577
0
                    nRet = static_cast<sal_Int64>(m_aValue.m_uInt64);
1578
0
                break;
1579
0
            default:
1580
0
                {
1581
0
                    Any aValue = makeAny();
1582
0
                    aValue >>= nRet;
1583
0
                    break;
1584
284
                }
1585
28.1k
        }
1586
28.1k
    }
1587
28.1k
    return nRet;
1588
28.1k
}
1589
1590
1591
sal_uInt64 ORowSetValue::getULong()   const
1592
0
{
1593
0
    sal_uInt64 nRet = 0;
1594
0
    if(!m_bNull)
1595
0
    {
1596
0
        switch(getTypeKind())
1597
0
        {
1598
0
            case DataType::CHAR:
1599
0
            case DataType::VARCHAR:
1600
0
            case DataType::DECIMAL:
1601
0
            case DataType::NUMERIC:
1602
0
            case DataType::LONGVARCHAR:
1603
0
                nRet = OUString::unacquired(&m_aValue.m_pString).toUInt64();
1604
0
                break;
1605
0
            case DataType::FLOAT:
1606
0
                nRet = sal_uInt64(m_aValue.m_nFloat);
1607
0
                break;
1608
0
            case DataType::DOUBLE:
1609
0
            case DataType::REAL:
1610
0
                nRet = sal_uInt64(m_aValue.m_nDouble);
1611
0
                break;
1612
0
            case DataType::DATE:
1613
0
                nRet = dbtools::DBTypeConversion::toDays(*static_cast<css::util::Date*>(m_aValue.m_pValue));
1614
0
                break;
1615
0
            case DataType::TIME:
1616
0
            case DataType::TIMESTAMP:
1617
0
            case DataType::BINARY:
1618
0
            case DataType::VARBINARY:
1619
0
            case DataType::LONGVARBINARY:
1620
0
            case DataType::BLOB:
1621
0
            case DataType::CLOB:
1622
0
                OSL_FAIL("getULong() for this type is not allowed!");
1623
0
                break;
1624
0
            case DataType::BIT:
1625
0
            case DataType::BOOLEAN:
1626
0
                nRet = sal_uInt64(m_aValue.m_bBool);
1627
0
                break;
1628
0
            case DataType::TINYINT:
1629
0
                if ( m_bSigned )
1630
0
                    nRet = m_aValue.m_nInt8;
1631
0
                else
1632
0
                    nRet = m_aValue.m_uInt8;
1633
0
                break;
1634
0
            case DataType::SMALLINT:
1635
0
                if ( m_bSigned )
1636
0
                    nRet = m_aValue.m_nInt16;
1637
0
                else
1638
0
                    nRet = m_aValue.m_uInt16;
1639
0
                break;
1640
0
            case DataType::INTEGER:
1641
0
                if ( m_bSigned )
1642
0
                    nRet = m_aValue.m_nInt32;
1643
0
                else
1644
0
                    nRet = m_aValue.m_uInt32;
1645
0
                break;
1646
0
            case DataType::BIGINT:
1647
0
                if ( m_bSigned )
1648
0
                    nRet = m_aValue.m_nInt64;
1649
0
                else
1650
0
                    nRet = m_aValue.m_uInt64;
1651
0
                break;
1652
0
            default:
1653
0
                {
1654
0
                    Any aValue = makeAny();
1655
0
                    aValue >>= nRet;
1656
0
                    break;
1657
0
                }
1658
0
        }
1659
0
    }
1660
0
    return nRet;
1661
0
}
1662
1663
1664
float ORowSetValue::getFloat()  const
1665
0
{
1666
0
    float nRet = 0;
1667
0
    if(!m_bNull)
1668
0
    {
1669
0
        switch(getTypeKind())
1670
0
        {
1671
0
            case DataType::CHAR:
1672
0
            case DataType::VARCHAR:
1673
0
            case DataType::DECIMAL:
1674
0
            case DataType::NUMERIC:
1675
0
            case DataType::LONGVARCHAR:
1676
0
                nRet = OUString::unacquired(&m_aValue.m_pString).toFloat();
1677
0
                break;
1678
0
            case DataType::FLOAT:
1679
0
                nRet = m_aValue.m_nFloat;
1680
0
                break;
1681
0
            case DataType::DOUBLE:
1682
0
            case DataType::REAL:
1683
0
                nRet = static_cast<float>(m_aValue.m_nDouble);
1684
0
                break;
1685
0
            case DataType::DATE:
1686
0
                nRet = static_cast<float>(dbtools::DBTypeConversion::toDouble(*static_cast<css::util::Date*>(m_aValue.m_pValue)));
1687
0
                break;
1688
0
            case DataType::TIME:
1689
0
                nRet = static_cast<float>(dbtools::DBTypeConversion::toDouble(*static_cast<css::util::Time*>(m_aValue.m_pValue)));
1690
0
                break;
1691
0
            case DataType::TIMESTAMP:
1692
0
                nRet = static_cast<float>(dbtools::DBTypeConversion::toDouble(*static_cast<css::util::DateTime*>(m_aValue.m_pValue)));
1693
0
                break;
1694
0
            case DataType::BINARY:
1695
0
            case DataType::VARBINARY:
1696
0
            case DataType::LONGVARBINARY:
1697
0
            case DataType::BLOB:
1698
0
            case DataType::CLOB:
1699
0
                OSL_FAIL("getDouble() for this type is not allowed!");
1700
0
                break;
1701
0
            case DataType::BIT:
1702
0
            case DataType::BOOLEAN:
1703
0
                nRet = float(m_aValue.m_bBool);
1704
0
                break;
1705
0
            case DataType::TINYINT:
1706
0
                if ( m_bSigned )
1707
0
                    nRet = m_aValue.m_nInt8;
1708
0
                else
1709
0
                    nRet = m_aValue.m_uInt8;
1710
0
                break;
1711
0
            case DataType::SMALLINT:
1712
0
                if ( m_bSigned )
1713
0
                    nRet = m_aValue.m_nInt16;
1714
0
                else
1715
0
                    nRet = static_cast<float>(m_aValue.m_uInt16);
1716
0
                break;
1717
0
            case DataType::INTEGER:
1718
0
                if ( m_bSigned )
1719
0
                    nRet = static_cast<float>(m_aValue.m_nInt32);
1720
0
                else
1721
0
                    nRet = static_cast<float>(m_aValue.m_uInt32);
1722
0
                break;
1723
0
            case DataType::BIGINT:
1724
0
                if ( m_bSigned )
1725
0
                    nRet = static_cast<float>(m_aValue.m_nInt64);
1726
0
                else
1727
0
                    nRet = static_cast<float>(m_aValue.m_uInt64);
1728
0
                break;
1729
0
            default:
1730
0
                {
1731
0
                    Any aValue = makeAny();
1732
0
                    aValue >>= nRet;
1733
0
                    break;
1734
0
                }
1735
0
        }
1736
0
    }
1737
0
    return nRet;
1738
0
}
1739
1740
double ORowSetValue::getDouble()    const
1741
1.57M
{
1742
1.57M
    double nRet = 0;
1743
1.57M
    if(!m_bNull)
1744
440k
    {
1745
440k
        switch(getTypeKind())
1746
440k
        {
1747
0
            case DataType::CHAR:
1748
9.30k
            case DataType::VARCHAR:
1749
110k
            case DataType::DECIMAL:
1750
110k
            case DataType::NUMERIC:
1751
110k
            case DataType::LONGVARCHAR:
1752
110k
                nRet = OUString::unacquired(&m_aValue.m_pString).toDouble();
1753
110k
                break;
1754
0
            case DataType::FLOAT:
1755
0
                nRet = m_aValue.m_nFloat;
1756
0
                break;
1757
276k
            case DataType::DOUBLE:
1758
276k
            case DataType::REAL:
1759
276k
                nRet = m_aValue.m_nDouble;
1760
276k
                break;
1761
3.91k
            case DataType::DATE:
1762
3.91k
                nRet = dbtools::DBTypeConversion::toDouble(*static_cast<css::util::Date*>(m_aValue.m_pValue));
1763
3.91k
                break;
1764
0
            case DataType::TIME:
1765
0
                nRet = dbtools::DBTypeConversion::toDouble(*static_cast<css::util::Time*>(m_aValue.m_pValue));
1766
0
                break;
1767
5.44k
            case DataType::TIMESTAMP:
1768
5.44k
                nRet = dbtools::DBTypeConversion::toDouble(*static_cast<css::util::DateTime*>(m_aValue.m_pValue));
1769
5.44k
                break;
1770
0
            case DataType::BINARY:
1771
0
            case DataType::VARBINARY:
1772
0
            case DataType::LONGVARBINARY:
1773
0
            case DataType::BLOB:
1774
0
            case DataType::CLOB:
1775
0
                OSL_FAIL("getDouble() for this type is not allowed!");
1776
0
                break;
1777
197
            case DataType::BIT:
1778
197
            case DataType::BOOLEAN:
1779
197
                nRet = double(m_aValue.m_bBool);
1780
197
                break;
1781
0
            case DataType::TINYINT:
1782
0
                if ( m_bSigned )
1783
0
                    nRet = m_aValue.m_nInt8;
1784
0
                else
1785
0
                    nRet = m_aValue.m_uInt8;
1786
0
                break;
1787
0
            case DataType::SMALLINT:
1788
0
                if ( m_bSigned )
1789
0
                    nRet = m_aValue.m_nInt16;
1790
0
                else
1791
0
                    nRet = m_aValue.m_uInt16;
1792
0
                break;
1793
44.3k
            case DataType::INTEGER:
1794
44.3k
                if ( m_bSigned )
1795
44.3k
                    nRet = m_aValue.m_nInt32;
1796
0
                else
1797
0
                    nRet = m_aValue.m_uInt32;
1798
44.3k
                break;
1799
0
            case DataType::BIGINT:
1800
0
                if ( m_bSigned )
1801
0
                    nRet = m_aValue.m_nInt64;
1802
0
                else
1803
0
                    nRet = m_aValue.m_uInt64;
1804
0
                break;
1805
0
            default:
1806
0
                {
1807
0
                    Any aValue = makeAny();
1808
0
                    aValue >>= nRet;
1809
0
                    break;
1810
197
                }
1811
440k
        }
1812
440k
    }
1813
1.57M
    return nRet;
1814
1.57M
}
1815
1816
Sequence<sal_Int8>  ORowSetValue::getSequence() const
1817
275k
{
1818
275k
    Sequence<sal_Int8> aSeq;
1819
275k
    if (!m_bNull)
1820
10.1k
    {
1821
10.1k
        switch(m_eTypeKind)
1822
10.1k
        {
1823
0
            case DataType::OBJECT:
1824
0
            case DataType::CLOB:
1825
0
            case DataType::BLOB:
1826
0
            {
1827
0
                Reference<XInputStream> xStream;
1828
0
                const Any aValue = makeAny();
1829
0
                if(aValue.hasValue())
1830
0
                {
1831
0
                    Reference<XBlob> xBlob(aValue,UNO_QUERY);
1832
0
                    if ( xBlob.is() )
1833
0
                        xStream = xBlob->getBinaryStream();
1834
0
                    else
1835
0
                    {
1836
0
                        Reference<XClob> xClob(aValue,UNO_QUERY);
1837
0
                        if ( xClob.is() )
1838
0
                            xStream = xClob->getCharacterStream();
1839
0
                    }
1840
0
                    if(xStream.is())
1841
0
                    {
1842
0
                        const sal_uInt32    nBytesToRead = 65535;
1843
0
                        sal_uInt32          nRead;
1844
1845
0
                        do
1846
0
                        {
1847
0
                            css::uno::Sequence< sal_Int8 > aReadSeq;
1848
1849
0
                            nRead = xStream->readSomeBytes( aReadSeq, nBytesToRead );
1850
1851
0
                            if( nRead )
1852
0
                            {
1853
0
                                const sal_uInt32 nOldLength = aSeq.getLength();
1854
0
                                aSeq.realloc( nOldLength + nRead );
1855
0
                                memcpy( aSeq.getArray() + nOldLength, aReadSeq.getConstArray(), aReadSeq.getLength() );
1856
0
                            }
1857
0
                        }
1858
0
                        while( nBytesToRead == nRead );
1859
0
                        xStream->closeInput();
1860
0
                    }
1861
0
                }
1862
0
            }
1863
0
            break;
1864
3.87k
            case DataType::VARCHAR:
1865
3.87k
            case DataType::LONGVARCHAR:
1866
3.87k
                {
1867
3.87k
                    aSeq = Sequence<sal_Int8>(reinterpret_cast<const sal_Int8*>(m_aValue.m_pString->buffer),
1868
3.87k
                                              sizeof(sal_Unicode) * m_aValue.m_pString->length);
1869
3.87k
                }
1870
3.87k
                break;
1871
0
            case DataType::BINARY:
1872
0
            case DataType::VARBINARY:
1873
0
            case DataType::LONGVARBINARY:
1874
0
                aSeq = *static_cast< Sequence<sal_Int8>*>(m_aValue.m_pValue);
1875
0
                break;
1876
6.22k
            default:
1877
6.22k
                {
1878
6.22k
                    Any aValue = makeAny();
1879
6.22k
                    aValue >>= aSeq;
1880
6.22k
                    break;
1881
0
                }
1882
10.1k
        }
1883
10.1k
    }
1884
275k
    return aSeq;
1885
1886
275k
}
1887
1888
css::util::Date ORowSetValue::getDate() const
1889
416k
{
1890
416k
    css::util::Date aValue;
1891
416k
    if(!m_bNull)
1892
125k
    {
1893
125k
        switch(m_eTypeKind)
1894
125k
        {
1895
0
            case DataType::CHAR:
1896
13.1k
            case DataType::VARCHAR:
1897
13.1k
            case DataType::LONGVARCHAR:
1898
13.1k
                aValue = DBTypeConversion::toDate(getString());
1899
13.1k
                break;
1900
8.97k
            case DataType::DECIMAL:
1901
8.97k
            case DataType::NUMERIC:
1902
8.97k
            case DataType::FLOAT:
1903
11.8k
            case DataType::DOUBLE:
1904
11.8k
            case DataType::REAL:
1905
11.8k
                aValue = DBTypeConversion::toDate(getDouble());
1906
11.8k
                break;
1907
1908
71.4k
            case DataType::DATE:
1909
71.4k
                aValue = *static_cast< css::util::Date*>(m_aValue.m_pValue);
1910
71.4k
                break;
1911
493
            case DataType::TIMESTAMP:
1912
493
                {
1913
493
                    css::util::DateTime* pDateTime = static_cast< css::util::DateTime*>(m_aValue.m_pValue);
1914
493
                    aValue.Day      = pDateTime->Day;
1915
493
                    aValue.Month    = pDateTime->Month;
1916
493
                    aValue.Year     = pDateTime->Year;
1917
493
                }
1918
493
                break;
1919
284
            case DataType::BIT:
1920
284
            case DataType::BOOLEAN:
1921
284
            case DataType::TINYINT:
1922
284
            case DataType::SMALLINT:
1923
28.1k
            case DataType::INTEGER:
1924
28.1k
            case DataType::BIGINT:
1925
28.1k
                aValue = DBTypeConversion::toDate( double( getLong() ) );
1926
28.1k
                break;
1927
1928
0
            case DataType::BLOB:
1929
0
            case DataType::CLOB:
1930
0
            case DataType::OBJECT:
1931
0
            default:
1932
0
                OSL_ENSURE( false, "ORowSetValue::getDate: cannot retrieve the data!" );
1933
0
                [[fallthrough]];
1934
1935
0
            case DataType::BINARY:
1936
0
            case DataType::VARBINARY:
1937
0
            case DataType::LONGVARBINARY:
1938
0
            case DataType::TIME:
1939
0
                aValue = DBTypeConversion::toDate( double(0) );
1940
0
                break;
1941
125k
        }
1942
125k
    }
1943
416k
    return aValue;
1944
416k
}
1945
1946
css::util::Time ORowSetValue::getTime()        const
1947
0
{
1948
0
    css::util::Time aValue;
1949
0
    if(!m_bNull)
1950
0
    {
1951
0
        switch(m_eTypeKind)
1952
0
        {
1953
0
            case DataType::CHAR:
1954
0
            case DataType::VARCHAR:
1955
0
            case DataType::LONGVARCHAR:
1956
0
                aValue = DBTypeConversion::toTime(getString());
1957
0
                break;
1958
0
            case DataType::DECIMAL:
1959
0
            case DataType::NUMERIC:
1960
0
            case DataType::FLOAT:
1961
0
            case DataType::DOUBLE:
1962
0
            case DataType::REAL:
1963
0
                aValue = DBTypeConversion::toTime(getDouble());
1964
0
                break;
1965
0
            case DataType::TIMESTAMP:
1966
0
                {
1967
0
                    css::util::DateTime* pDateTime = static_cast< css::util::DateTime*>(m_aValue.m_pValue);
1968
0
                    aValue.NanoSeconds      = pDateTime->NanoSeconds;
1969
0
                    aValue.Seconds          = pDateTime->Seconds;
1970
0
                    aValue.Minutes          = pDateTime->Minutes;
1971
0
                    aValue.Hours            = pDateTime->Hours;
1972
0
                }
1973
0
                break;
1974
0
            case DataType::TIME:
1975
0
                aValue = *static_cast< css::util::Time*>(m_aValue.m_pValue);
1976
0
                break;
1977
0
            default:
1978
0
                {
1979
0
                    Any aAnyValue = makeAny();
1980
0
                    aAnyValue >>= aValue;
1981
0
                    break;
1982
0
                }
1983
0
        }
1984
0
    }
1985
0
    return aValue;
1986
0
}
1987
1988
css::util::DateTime ORowSetValue::getDateTime()    const
1989
379k
{
1990
379k
    css::util::DateTime aValue;
1991
379k
    if(!m_bNull)
1992
169k
    {
1993
169k
        switch(m_eTypeKind)
1994
169k
        {
1995
0
            case DataType::CHAR:
1996
19.8k
            case DataType::VARCHAR:
1997
19.8k
            case DataType::LONGVARCHAR:
1998
19.8k
                aValue = DBTypeConversion::toDateTime(getString());
1999
19.8k
                break;
2000
513
            case DataType::DECIMAL:
2001
513
            case DataType::NUMERIC:
2002
513
            case DataType::FLOAT:
2003
21.3k
            case DataType::DOUBLE:
2004
21.3k
            case DataType::REAL:
2005
21.3k
                aValue = DBTypeConversion::toDateTime(getDouble());
2006
21.3k
                break;
2007
67
            case DataType::DATE:
2008
67
                {
2009
67
                    css::util::Date* pDate = static_cast< css::util::Date*>(m_aValue.m_pValue);
2010
67
                    aValue.Day      = pDate->Day;
2011
67
                    aValue.Month    = pDate->Month;
2012
67
                    aValue.Year     = pDate->Year;
2013
67
                }
2014
67
                break;
2015
0
            case DataType::TIME:
2016
0
                {
2017
0
                    css::util::Time* pTime = static_cast< css::util::Time*>(m_aValue.m_pValue);
2018
0
                    aValue.NanoSeconds      = pTime->NanoSeconds;
2019
0
                    aValue.Seconds          = pTime->Seconds;
2020
0
                    aValue.Minutes          = pTime->Minutes;
2021
0
                    aValue.Hours            = pTime->Hours;
2022
0
                }
2023
0
                break;
2024
127k
            case DataType::TIMESTAMP:
2025
127k
                aValue = *static_cast< css::util::DateTime*>(m_aValue.m_pValue);
2026
127k
                break;
2027
1.14k
            default:
2028
1.14k
                {
2029
1.14k
                    Any aAnyValue = makeAny();
2030
1.14k
                    aAnyValue >>= aValue;
2031
1.14k
                    break;
2032
21.3k
                }
2033
169k
        }
2034
169k
    }
2035
379k
    return aValue;
2036
379k
}
2037
2038
void ORowSetValue::setSigned(bool _bMod)
2039
9.46M
{
2040
9.46M
    if ( m_bSigned == _bMod )
2041
9.46M
        return;
2042
2043
0
    m_bSigned = _bMod;
2044
0
    if ( m_bNull )
2045
0
        return;
2046
2047
0
    sal_Int32 nType = m_eTypeKind;
2048
0
    switch(m_eTypeKind)
2049
0
    {
2050
0
        case DataType::TINYINT:
2051
0
            if ( m_bSigned )
2052
0
                (*this) = getInt8();
2053
0
            else
2054
0
            {
2055
0
                m_bSigned = !m_bSigned;
2056
0
                (*this) = getInt16();
2057
0
                m_bSigned = !m_bSigned;
2058
0
            }
2059
0
            break;
2060
0
        case DataType::SMALLINT:
2061
0
            if ( m_bSigned )
2062
0
                (*this) = getInt16();
2063
0
            else
2064
0
            {
2065
0
                m_bSigned = !m_bSigned;
2066
0
                (*this) = getInt32();
2067
0
                m_bSigned = !m_bSigned;
2068
0
            }
2069
0
            break;
2070
0
        case DataType::INTEGER:
2071
0
            if ( m_bSigned )
2072
0
                (*this) = getInt32();
2073
0
            else
2074
0
            {
2075
0
                m_bSigned = !m_bSigned;
2076
0
                (*this) = getLong();
2077
0
                m_bSigned = !m_bSigned;
2078
0
            }
2079
0
            break;
2080
0
        case DataType::BIGINT:
2081
0
        {
2082
0
            if ( m_bSigned )
2083
0
            {
2084
0
                auto nTmp = static_cast<sal_Int64>(m_aValue.m_uInt64);
2085
0
                m_aValue.m_nInt64 = nTmp;
2086
0
            }
2087
0
            else
2088
0
            {
2089
0
                auto nTmp = static_cast<sal_uInt64>(m_aValue.m_nInt64);
2090
0
                m_aValue.m_uInt64 = nTmp;
2091
0
            }
2092
0
            break;
2093
0
        }
2094
0
    }
2095
0
    m_eTypeKind = nType;
2096
0
}
2097
2098
2099
namespace detail
2100
{
2101
    class SAL_NO_VTABLE IValueSource
2102
    {
2103
    public:
2104
        virtual OUString             getString() const = 0;
2105
        virtual bool                        getBoolean() const = 0;
2106
        virtual sal_Int8                    getByte() const = 0;
2107
        virtual sal_Int16                   getShort() const = 0;
2108
        virtual sal_Int32                   getInt() const = 0;
2109
        virtual sal_Int64                   getLong() const = 0;
2110
        virtual float                       getFloat() const = 0;
2111
        virtual double                      getDouble() const = 0;
2112
        virtual Date                        getDate() const = 0;
2113
        virtual css::util::Time             getTime() const = 0;
2114
        virtual DateTime                    getTimestamp() const = 0;
2115
        virtual Sequence< sal_Int8 >        getBytes() const = 0;
2116
        virtual Reference< XBlob >          getBlob() const = 0;
2117
        virtual Reference< XClob >          getClob() const = 0;
2118
        virtual Any                         getObject() const = 0;
2119
        virtual bool                        wasNull() const = 0;
2120
2121
9.46M
        virtual ~IValueSource() { }
2122
    };
2123
2124
    namespace {
2125
2126
    class RowValue : public IValueSource
2127
    {
2128
    public:
2129
        RowValue( const Reference< XRow >& _xRow, const sal_Int32 _nPos )
2130
9.46M
            :m_xRow( _xRow )
2131
9.46M
            ,m_nPos( _nPos )
2132
9.46M
        {
2133
9.46M
        }
2134
2135
        // IValueSource
2136
1.42M
        virtual OUString             getString() const override           { return m_xRow->getString( m_nPos ); };
2137
293k
        virtual bool                        getBoolean() const override          { return m_xRow->getBoolean( m_nPos ); };
2138
0
        virtual sal_Int8                    getByte() const override             { return m_xRow->getByte( m_nPos ); };
2139
0
        virtual sal_Int16                   getShort() const override            { return m_xRow->getShort( m_nPos ); }
2140
85.7k
        virtual sal_Int32                   getInt() const override              { return m_xRow->getInt( m_nPos ); }
2141
0
        virtual sal_Int64                   getLong() const override             { return m_xRow->getLong( m_nPos ); }
2142
0
        virtual float                       getFloat() const override            { return m_xRow->getFloat( m_nPos ); };
2143
562k
        virtual double                      getDouble() const override           { return m_xRow->getDouble( m_nPos ); };
2144
207k
        virtual Date                        getDate() const override             { return m_xRow->getDate( m_nPos ); };
2145
0
        virtual css::util::Time             getTime() const override             { return m_xRow->getTime( m_nPos ); };
2146
179k
        virtual DateTime                    getTimestamp() const override        { return m_xRow->getTimestamp( m_nPos ); };
2147
275k
        virtual Sequence< sal_Int8 >        getBytes() const override            { return m_xRow->getBytes( m_nPos ); };
2148
0
        virtual Reference< XBlob >          getBlob() const override             { return m_xRow->getBlob( m_nPos ); };
2149
0
        virtual Reference< XClob >          getClob() const override             { return m_xRow->getClob( m_nPos ); };
2150
6.44M
        virtual Any                         getObject() const override           { return m_xRow->getObject( m_nPos ,nullptr); };
2151
9.46M
        virtual bool                        wasNull() const override             { return m_xRow->wasNull( ); };
2152
2153
    private:
2154
        const Reference< XRow > m_xRow;
2155
        const sal_Int32         m_nPos;
2156
    };
2157
2158
    class ColumnValue : public IValueSource
2159
    {
2160
    public:
2161
        explicit ColumnValue( const Reference< XColumn >& _rxColumn )
2162
0
            :m_xColumn( _rxColumn )
2163
0
        {
2164
0
        }
2165
2166
        // IValueSource
2167
0
        virtual OUString             getString() const override           { return m_xColumn->getString(); };
2168
0
        virtual bool                        getBoolean() const override          { return m_xColumn->getBoolean(); };
2169
0
        virtual sal_Int8                    getByte() const override             { return m_xColumn->getByte(); };
2170
0
        virtual sal_Int16                   getShort() const override            { return m_xColumn->getShort(); }
2171
0
        virtual sal_Int32                   getInt() const override              { return m_xColumn->getInt(); }
2172
0
        virtual sal_Int64                   getLong() const override             { return m_xColumn->getLong(); }
2173
0
        virtual float                       getFloat() const override            { return m_xColumn->getFloat(); };
2174
0
        virtual double                      getDouble() const override           { return m_xColumn->getDouble(); };
2175
0
        virtual Date                        getDate() const override             { return m_xColumn->getDate(); };
2176
0
        virtual css::util::Time             getTime() const override             { return m_xColumn->getTime(); };
2177
0
        virtual DateTime                    getTimestamp() const override        { return m_xColumn->getTimestamp(); };
2178
0
        virtual Sequence< sal_Int8 >        getBytes() const override            { return m_xColumn->getBytes(); };
2179
0
        virtual Reference< XBlob >          getBlob() const override             { return m_xColumn->getBlob(); };
2180
0
        virtual Reference< XClob >          getClob() const override             { return m_xColumn->getClob(); };
2181
0
        virtual Any                         getObject() const override           { return m_xColumn->getObject( nullptr ); };
2182
0
        virtual bool                        wasNull() const override             { return m_xColumn->wasNull( ); };
2183
2184
    private:
2185
        const Reference< XColumn >  m_xColumn;
2186
    };
2187
2188
    }
2189
}
2190
2191
2192
void ORowSetValue::fill( const sal_Int32 _nType, const Reference< XColumn >& _rxColumn )
2193
0
{
2194
0
    detail::ColumnValue aColumnValue( _rxColumn );
2195
0
    impl_fill( _nType, true, aColumnValue );
2196
0
}
2197
2198
2199
void ORowSetValue::fill( sal_Int32 _nPos, sal_Int32 _nType, bool  _bNullable, const Reference< XRow>& _xRow )
2200
9.46M
{
2201
9.46M
    detail::RowValue aRowValue( _xRow, _nPos );
2202
9.46M
    impl_fill( _nType, _bNullable, aRowValue );
2203
9.46M
}
2204
2205
2206
void ORowSetValue::fill(sal_Int32 _nPos,
2207
                     sal_Int32 _nType,
2208
                     const css::uno::Reference< css::sdbc::XRow>& _xRow)
2209
9.46M
{
2210
9.46M
    fill(_nPos,_nType,true,_xRow);
2211
9.46M
}
2212
2213
2214
void ORowSetValue::impl_fill( const sal_Int32 _nType, bool _bNullable, const detail::IValueSource& _rValueSource )
2215
9.46M
{
2216
9.46M
    switch(_nType)
2217
9.46M
    {
2218
0
    case DataType::CHAR:
2219
920k
    case DataType::VARCHAR:
2220
1.14M
    case DataType::DECIMAL:
2221
1.14M
    case DataType::NUMERIC:
2222
1.42M
    case DataType::LONGVARCHAR:
2223
1.42M
        (*this) = _rValueSource.getString();
2224
1.42M
        break;
2225
0
    case DataType::BIGINT:
2226
0
        if ( isSigned() )
2227
0
            (*this) = _rValueSource.getLong();
2228
0
        else
2229
            // TODO: this is rather horrible performance-wise
2230
            //       but fixing it needs extending the css::sdbc::XRow API
2231
            //       to have a getULong(), and needs updating all drivers :-|
2232
            //       When doing that, add getUByte, getUShort, getUInt for symmetry/completeness
2233
0
            (*this) = _rValueSource.getString().toUInt64();
2234
0
        break;
2235
0
    case DataType::FLOAT:
2236
0
        (*this) = _rValueSource.getFloat();
2237
0
        break;
2238
562k
    case DataType::DOUBLE:
2239
562k
    case DataType::REAL:
2240
562k
        (*this) = _rValueSource.getDouble();
2241
562k
        break;
2242
207k
    case DataType::DATE:
2243
207k
        (*this) = _rValueSource.getDate();
2244
207k
        break;
2245
0
    case DataType::TIME:
2246
0
        (*this) = _rValueSource.getTime();
2247
0
        break;
2248
179k
    case DataType::TIMESTAMP:
2249
179k
        (*this) = _rValueSource.getTimestamp();
2250
179k
        break;
2251
0
    case DataType::BINARY:
2252
0
    case DataType::VARBINARY:
2253
275k
    case DataType::LONGVARBINARY:
2254
275k
        (*this) = _rValueSource.getBytes();
2255
275k
        break;
2256
293k
    case DataType::BIT:
2257
293k
    case DataType::BOOLEAN:
2258
293k
        (*this) = _rValueSource.getBoolean();
2259
293k
        break;
2260
0
    case DataType::TINYINT:
2261
0
        if ( isSigned() )
2262
0
            (*this) = _rValueSource.getByte();
2263
0
        else
2264
0
            (*this) = _rValueSource.getShort();
2265
0
        break;
2266
0
    case DataType::SMALLINT:
2267
0
        if ( isSigned() )
2268
0
            (*this) = _rValueSource.getShort();
2269
0
        else
2270
0
            (*this) = _rValueSource.getInt();
2271
0
        break;
2272
85.7k
    case DataType::INTEGER:
2273
85.7k
        if ( isSigned() )
2274
85.7k
            (*this) = _rValueSource.getInt();
2275
0
        else
2276
0
            (*this) = _rValueSource.getLong();
2277
85.7k
        break;
2278
0
    case DataType::CLOB:
2279
0
        (*this) = css::uno::Any(_rValueSource.getClob());
2280
0
        setTypeKind(DataType::CLOB);
2281
0
        break;
2282
0
    case DataType::BLOB:
2283
0
        (*this) = css::uno::Any(_rValueSource.getBlob());
2284
0
        setTypeKind(DataType::BLOB);
2285
0
        break;
2286
6.44M
    case DataType::OTHER:
2287
6.44M
        (*this) = _rValueSource.getObject();
2288
6.44M
        setTypeKind(DataType::OTHER);
2289
6.44M
        break;
2290
0
    default:
2291
0
        SAL_WARN( "connectivity.commontools", "ORowSetValue::fill: unsupported type!" );
2292
0
        (*this) = _rValueSource.getObject();
2293
0
        break;
2294
9.46M
    }
2295
9.46M
    if ( _bNullable && _rValueSource.wasNull() )
2296
8.14M
        setNull();
2297
9.46M
    setTypeKind(_nType);
2298
9.46M
}
2299
2300
void ORowSetValue::fill(const Any& _rValue)
2301
0
{
2302
0
    switch (_rValue.getValueTypeClass())
2303
0
    {
2304
0
        case TypeClass_VOID:
2305
0
            setNull();            break;
2306
0
        case TypeClass_BOOLEAN:
2307
0
        {
2308
0
            bool bValue( false );
2309
0
            _rValue >>= bValue;
2310
0
            (*this) = bValue;
2311
0
            break;
2312
0
        }
2313
0
        case TypeClass_CHAR:
2314
0
        {
2315
0
            sal_Unicode aDummy(0);
2316
0
            _rValue >>= aDummy;
2317
0
            (*this) = OUString(aDummy);
2318
0
            break;
2319
0
        }
2320
0
        case TypeClass_STRING:
2321
0
        {
2322
0
            OUString sDummy;
2323
0
            _rValue >>= sDummy;
2324
0
            (*this) = sDummy;
2325
0
            break;
2326
0
        }
2327
0
        case TypeClass_FLOAT:
2328
0
        {
2329
0
            float aDummy(0.0);
2330
0
            _rValue >>= aDummy;
2331
0
            (*this) = aDummy;
2332
0
            break;
2333
0
        }
2334
0
        case TypeClass_DOUBLE:
2335
0
        {
2336
0
            double aDummy(0.0);
2337
0
            _rValue >>= aDummy;
2338
0
            (*this) = aDummy;
2339
0
            break;
2340
0
        }
2341
0
        case TypeClass_BYTE:
2342
0
        {
2343
0
            sal_Int8 aDummy(0);
2344
0
            _rValue >>= aDummy;
2345
0
            (*this) = aDummy;
2346
0
            break;
2347
0
        }
2348
0
        case TypeClass_SHORT:
2349
0
        {
2350
0
            sal_Int16 aDummy(0);
2351
0
            _rValue >>= aDummy;
2352
0
            (*this) = aDummy;
2353
0
            break;
2354
0
        }
2355
0
        case TypeClass_UNSIGNED_SHORT:
2356
0
        {
2357
0
            sal_uInt16 nValue(0);
2358
0
            _rValue >>= nValue;
2359
0
            (*this) = nValue;
2360
0
            break;
2361
0
        }
2362
0
        case TypeClass_LONG:
2363
0
        {
2364
0
            sal_Int32 aDummy(0);
2365
0
            _rValue >>= aDummy;
2366
0
            (*this) = aDummy;
2367
0
            break;
2368
0
        }
2369
0
        case TypeClass_UNSIGNED_LONG:
2370
0
        {
2371
0
            sal_uInt32 nValue(0);
2372
0
            _rValue >>= nValue;
2373
0
            (*this) = static_cast<sal_Int64>(nValue);
2374
0
            setSigned(false);
2375
0
            break;
2376
0
        }
2377
0
        case TypeClass_HYPER:
2378
0
        {
2379
0
            sal_Int64 nValue(0);
2380
0
            _rValue >>= nValue;
2381
0
            (*this) = nValue;
2382
0
            break;
2383
0
        }
2384
0
        case TypeClass_UNSIGNED_HYPER:
2385
0
        {
2386
0
            sal_uInt64 nValue(0);
2387
0
            _rValue >>= nValue;
2388
0
            (*this) = nValue;
2389
0
            setSigned(false);
2390
0
            break;
2391
0
        }
2392
0
        case TypeClass_ENUM:
2393
0
        {
2394
0
            sal_Int32 enumValue( 0 );
2395
0
            ::cppu::enum2int( enumValue, _rValue );
2396
0
            (*this) = enumValue;
2397
0
        }
2398
0
        break;
2399
2400
0
        case TypeClass_SEQUENCE:
2401
0
        {
2402
0
            Sequence<sal_Int8> aDummy;
2403
0
            if ( _rValue >>= aDummy )
2404
0
                (*this) = aDummy;
2405
0
            else
2406
0
                SAL_WARN( "connectivity.commontools", "ORowSetValue::fill: unsupported sequence type!" );
2407
0
            break;
2408
0
        }
2409
2410
0
        case TypeClass_STRUCT:
2411
0
        {
2412
0
            css::util::Date aDate;
2413
0
            css::util::Time aTime;
2414
0
            css::util::DateTime aDateTime;
2415
0
            if ( _rValue >>= aDate )
2416
0
            {
2417
0
                (*this) = aDate;
2418
0
            }
2419
0
            else if ( _rValue >>= aTime )
2420
0
            {
2421
0
                (*this) = aTime;
2422
0
            }
2423
0
            else if ( _rValue >>= aDateTime )
2424
0
            {
2425
0
                (*this) = aDateTime;
2426
0
            }
2427
0
            else
2428
0
                SAL_WARN( "connectivity.commontools", "ORowSetValue::fill: unsupported structure!" );
2429
2430
0
            break;
2431
0
        }
2432
0
        case TypeClass_INTERFACE:
2433
0
            {
2434
0
                Reference< XClob > xClob;
2435
0
                if ( _rValue >>= xClob )
2436
0
                {
2437
0
                    (*this) = _rValue;
2438
0
                    setTypeKind(DataType::CLOB);
2439
0
                }
2440
0
                else
2441
0
                {
2442
0
                    Reference< XBlob > xBlob;
2443
0
                    if ( _rValue >>= xBlob )
2444
0
                    {
2445
0
                        (*this) = _rValue;
2446
0
                        setTypeKind(DataType::BLOB);
2447
0
                    }
2448
0
                    else
2449
0
                    {
2450
0
                        (*this) = _rValue;
2451
0
                    }
2452
0
                }
2453
0
            }
2454
0
            break;
2455
2456
0
        default:
2457
0
            SAL_WARN( "connectivity.commontools","Unknown type");
2458
0
            break;
2459
0
    }
2460
0
}
2461
2462
}   // namespace connectivity
2463
2464
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */