Coverage Report

Created: 2026-05-16 09:25

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/connectivity/source/commontools/FDatabaseMetaDataResultSet.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 <FDatabaseMetaDataResultSet.hxx>
22
#include <FDatabaseMetaDataResultSetMetaData.hxx>
23
#include <com/sun/star/sdbc/ColumnSearch.hpp>
24
#include <com/sun/star/beans/PropertyAttribute.hpp>
25
#include <cppuhelper/typeprovider.hxx>
26
#include <comphelper/sequence.hxx>
27
#include <cppuhelper/supportsservice.hxx>
28
#include <connectivity/dbexception.hxx>
29
#include <o3tl/safeint.hxx>
30
#include <TConnection.hxx>
31
32
using namespace connectivity;
33
using namespace dbtools;
34
using namespace cppu;
35
36
using namespace ::com::sun::star::beans;
37
using namespace ::com::sun::star::uno;
38
using namespace ::com::sun::star::sdbc;
39
using namespace ::com::sun::star::container;
40
using namespace ::com::sun::star::lang;
41
42
ODatabaseMetaDataResultSet::ODatabaseMetaDataResultSet()
43
    :
44
0
    m_nColPos(0)
45
0
    ,m_bBOF(true)
46
0
    ,m_bEOF(true)
47
0
{
48
0
    construct();
49
0
}
Unexecuted instantiation: connectivity::ODatabaseMetaDataResultSet::ODatabaseMetaDataResultSet()
Unexecuted instantiation: connectivity::ODatabaseMetaDataResultSet::ODatabaseMetaDataResultSet()
50
51
52
ODatabaseMetaDataResultSet::ODatabaseMetaDataResultSet( MetaDataResultSetType _eType )
53
    :
54
91.7k
    m_nColPos(0)
55
91.7k
    ,m_bBOF(true)
56
91.7k
    ,m_bEOF(true)
57
91.7k
{
58
91.7k
    construct();
59
60
91.7k
    setType(_eType);
61
91.7k
}
Unexecuted instantiation: connectivity::ODatabaseMetaDataResultSet::ODatabaseMetaDataResultSet(connectivity::ODatabaseMetaDataResultSet::MetaDataResultSetType)
connectivity::ODatabaseMetaDataResultSet::ODatabaseMetaDataResultSet(connectivity::ODatabaseMetaDataResultSet::MetaDataResultSetType)
Line
Count
Source
54
91.7k
    m_nColPos(0)
55
91.7k
    ,m_bBOF(true)
56
91.7k
    ,m_bEOF(true)
57
91.7k
{
58
91.7k
    construct();
59
60
91.7k
    setType(_eType);
61
91.7k
}
62
63
64
ODatabaseMetaDataResultSet::~ODatabaseMetaDataResultSet()
65
91.7k
{
66
91.7k
}
67
68
void ODatabaseMetaDataResultSet::construct()
69
91.7k
{
70
91.7k
    registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FETCHSIZE),           PROPERTY_ID_FETCHSIZE,          0,&m_nFetchSize,        ::cppu::UnoType<sal_Int32>::get());
71
91.7k
    registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_RESULTSETTYPE),        PROPERTY_ID_RESULTSETTYPE,          PropertyAttribute::READONLY,&m_nResultSetType,       ::cppu::UnoType<sal_Int32>::get());
72
91.7k
    registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FETCHDIRECTION),      PROPERTY_ID_FETCHDIRECTION,     0,  &m_nFetchDirection, ::cppu::UnoType<sal_Int32>::get());
73
91.7k
    registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_RESULTSETCONCURRENCY), PROPERTY_ID_RESULTSETCONCURRENCY,   PropertyAttribute::READONLY,&m_nResultSetConcurrency,                ::cppu::UnoType<sal_Int32>::get());
74
91.7k
}
75
76
void ODatabaseMetaDataResultSet::setType(MetaDataResultSetType _eType)
77
91.7k
{
78
91.7k
    switch( _eType )
79
91.7k
    {
80
0
        case eCatalogs:             setCatalogsMap(); break;
81
0
        case eSchemas:              setSchemasMap(); break;
82
0
        case eColumnPrivileges:     setColumnPrivilegesMap(); break;
83
10.1k
        case eColumns:              setColumnsMap(); break;
84
61.4k
        case eTables:               setTablesMap(); break;
85
0
        case eTableTypes:           setTableTypes(); break;
86
0
        case eProcedureColumns:     setProcedureColumnsMap(); break;
87
0
        case eProcedures:           setProceduresMap(); break;
88
0
        case eExportedKeys:         setExportedKeysMap(); break;
89
10.0k
        case eImportedKeys:         setImportedKeysMap(); break;
90
10.0k
        case ePrimaryKeys:          setPrimaryKeysMap(); break;
91
0
        case eIndexInfo:            setIndexInfoMap(); break;
92
0
        case eTablePrivileges:      setTablePrivilegesMap(); break;
93
0
        case eCrossReference:       setCrossReferenceMap(); break;
94
0
        case eTypeInfo:             setTypeInfoMap(); break;
95
0
        case eBestRowIdentifier:    setBestRowIdentifierMap(); break;
96
0
        case eVersionColumns:       setVersionColumnsMap(); break;
97
0
        case eUDTs:                 setUDTsMap(); break;
98
0
        default:
99
0
            OSL_FAIL("Wrong type!");
100
91.7k
    }
101
91.7k
}
102
103
void ODatabaseMetaDataResultSet::disposing(std::unique_lock<std::mutex>& rGuard)
104
51.0k
{
105
51.0k
    OPropertySetHelper::disposing(rGuard);
106
107
51.0k
    m_xMetaData.clear();
108
51.0k
    m_aRowsIter = m_aRows.end();
109
51.0k
    m_aRows.clear();
110
51.0k
    m_aRowsIter = m_aRows.end();
111
51.0k
}
112
113
void SAL_CALL ODatabaseMetaDataResultSet::acquire() noexcept
114
520k
{
115
520k
    ODatabaseMetaDataResultSet_BASE::acquire();
116
520k
}
117
118
void SAL_CALL ODatabaseMetaDataResultSet::release() noexcept
119
520k
{
120
520k
    ODatabaseMetaDataResultSet_BASE::release();
121
520k
}
122
123
Any SAL_CALL ODatabaseMetaDataResultSet::queryInterface( const Type & rType )
124
142k
{
125
142k
    Any aRet = OPropertySetHelper::queryInterface(rType);
126
142k
    return aRet.hasValue() ? aRet : ODatabaseMetaDataResultSet_BASE::queryInterface(rType);
127
142k
}
128
129
Sequence< Type > SAL_CALL ODatabaseMetaDataResultSet::getTypes(  )
130
0
{
131
0
    ::cppu::OTypeCollection aTypes( cppu::UnoType<css::beans::XMultiPropertySet>::get(),
132
0
                                    cppu::UnoType<css::beans::XFastPropertySet>::get(),
133
0
                                    cppu::UnoType<css::beans::XPropertySet>::get());
134
135
0
    return ::comphelper::concatSequences(aTypes.getTypes(),ODatabaseMetaDataResultSet_BASE::getTypes());
136
0
}
137
138
void ODatabaseMetaDataResultSet::setRows(ORows&& _rRows)
139
71.5k
{
140
71.5k
    m_aRows = std::move(_rRows);
141
71.5k
    m_bBOF = true;
142
71.5k
    m_bEOF = m_aRows.empty();
143
71.5k
}
144
145
sal_Int32 SAL_CALL ODatabaseMetaDataResultSet::findColumn( const OUString& columnName )
146
0
{
147
0
    std::unique_lock aGuard( m_aMutex );
148
0
    throwIfDisposed(aGuard);
149
150
0
    Reference< XResultSetMetaData > xMeta = getMetaData(aGuard);
151
0
    sal_Int32 nLen = xMeta->getColumnCount();
152
0
    sal_Int32 i = 1;
153
0
    for(;i<=nLen;++i)
154
0
    {
155
0
        if(xMeta->isCaseSensitive(i) ? columnName == xMeta->getColumnName(i) :
156
0
            columnName.equalsIgnoreAsciiCase(xMeta->getColumnName(i))
157
0
            )
158
0
            return i;
159
0
    }
160
161
0
    ::dbtools::throwInvalidColumnException( columnName, *this );
162
0
}
163
164
void ODatabaseMetaDataResultSet::checkIndex(std::unique_lock<std::mutex>& /*rGuard*/, sal_Int32 columnIndex )
165
3.01M
{
166
3.01M
    if(columnIndex < 1 || o3tl::make_unsigned(columnIndex) >= (*m_aRowsIter).size())
167
0
        ::dbtools::throwInvalidIndexException(*this);
168
3.01M
}
169
170
Reference< css::io::XInputStream > SAL_CALL ODatabaseMetaDataResultSet::getBinaryStream( sal_Int32 /*columnIndex*/ )
171
0
{
172
0
    return nullptr;
173
0
}
174
175
Reference< css::io::XInputStream > SAL_CALL ODatabaseMetaDataResultSet::getCharacterStream( sal_Int32 /*columnIndex*/ )
176
0
{
177
0
    return nullptr;
178
0
}
179
180
181
sal_Bool SAL_CALL ODatabaseMetaDataResultSet::getBoolean( sal_Int32 columnIndex )
182
0
{
183
0
    return getValue(columnIndex).getBool();
184
0
}
185
186
187
sal_Int8 SAL_CALL ODatabaseMetaDataResultSet::getByte( sal_Int32 columnIndex )
188
0
{
189
0
    return getValue(columnIndex).getInt8();
190
0
}
191
192
193
Sequence< sal_Int8 > SAL_CALL ODatabaseMetaDataResultSet::getBytes( sal_Int32 columnIndex )
194
0
{
195
0
    return getValue(columnIndex).getSequence();
196
0
}
197
198
199
css::util::Date SAL_CALL ODatabaseMetaDataResultSet::getDate( sal_Int32 columnIndex )
200
0
{
201
0
    return getValue(columnIndex).getDate();
202
0
}
203
204
205
double SAL_CALL ODatabaseMetaDataResultSet::getDouble( sal_Int32 columnIndex )
206
0
{
207
0
    return getValue(columnIndex).getDouble();
208
0
}
209
210
211
float SAL_CALL ODatabaseMetaDataResultSet::getFloat( sal_Int32 columnIndex )
212
0
{
213
0
    return getValue(columnIndex).getFloat();
214
0
}
215
216
217
sal_Int32 SAL_CALL ODatabaseMetaDataResultSet::getInt( sal_Int32 columnIndex )
218
1.62M
{
219
1.62M
    return getValue(columnIndex).getInt32();
220
1.62M
}
221
222
223
sal_Int32 SAL_CALL ODatabaseMetaDataResultSet::getRow(  )
224
0
{
225
0
    return 0;
226
0
}
227
228
229
sal_Int64 SAL_CALL ODatabaseMetaDataResultSet::getLong( sal_Int32 columnIndex )
230
0
{
231
0
    return getValue(columnIndex).getLong();
232
0
}
233
234
235
Reference< XResultSetMetaData > SAL_CALL ODatabaseMetaDataResultSet::getMetaData(  )
236
0
{
237
0
    std::unique_lock aGuard( m_aMutex );
238
0
    return getMetaData(aGuard);
239
0
}
240
241
Reference< XResultSetMetaData > ODatabaseMetaDataResultSet::getMetaData( std::unique_lock<std::mutex>& rGuard  )
242
0
{
243
0
    throwIfDisposed(rGuard);
244
245
0
    if(!m_xMetaData.is())
246
0
        m_xMetaData = new ODatabaseMetaDataResultSetMetaData();
247
248
0
    return m_xMetaData;
249
0
}
250
251
Reference< XArray > SAL_CALL ODatabaseMetaDataResultSet::getArray( sal_Int32 /*columnIndex*/ )
252
0
{
253
0
    return nullptr;
254
0
}
255
256
257
Reference< XClob > SAL_CALL ODatabaseMetaDataResultSet::getClob( sal_Int32 /*columnIndex*/ )
258
0
{
259
0
    return nullptr;
260
0
}
261
262
Reference< XBlob > SAL_CALL ODatabaseMetaDataResultSet::getBlob( sal_Int32 /*columnIndex*/ )
263
0
{
264
0
    return nullptr;
265
0
}
266
267
268
Reference< XRef > SAL_CALL ODatabaseMetaDataResultSet::getRef( sal_Int32 /*columnIndex*/ )
269
0
{
270
0
    return nullptr;
271
0
}
272
273
274
Any SAL_CALL ODatabaseMetaDataResultSet::getObject( sal_Int32 columnIndex, const Reference< css::container::XNameAccess >& /*typeMap*/ )
275
0
{
276
0
    return getValue(columnIndex).makeAny();
277
0
}
278
279
280
sal_Int16 SAL_CALL ODatabaseMetaDataResultSet::getShort( sal_Int32 columnIndex )
281
0
{
282
0
    return getValue(columnIndex).getInt16();
283
0
}
284
285
286
OUString SAL_CALL ODatabaseMetaDataResultSet::getString( sal_Int32 columnIndex )
287
1.39M
{
288
1.39M
    return getValue(columnIndex).getString();
289
1.39M
}
290
291
292
css::util::Time SAL_CALL ODatabaseMetaDataResultSet::getTime( sal_Int32 columnIndex )
293
0
{
294
0
    return getValue(columnIndex).getTime();
295
0
}
296
297
298
css::util::DateTime SAL_CALL ODatabaseMetaDataResultSet::getTimestamp( sal_Int32 columnIndex )
299
0
{
300
0
    return getValue(columnIndex).getDateTime();
301
0
}
302
303
304
sal_Bool SAL_CALL ODatabaseMetaDataResultSet::isAfterLast()
305
0
{
306
0
    return m_bEOF;
307
0
}
308
309
bool ODatabaseMetaDataResultSet::isAfterLast( std::unique_lock<std::mutex>& /*rGuard*/)
310
3.01M
{
311
3.01M
    return m_bEOF;
312
3.01M
}
313
314
sal_Bool SAL_CALL ODatabaseMetaDataResultSet::isFirst(  )
315
0
{
316
0
    ::dbtools::throwFunctionSequenceException(*this);
317
0
}
318
319
sal_Bool SAL_CALL ODatabaseMetaDataResultSet::isLast(  )
320
0
{
321
0
    ::dbtools::throwFunctionSequenceException(*this);
322
0
}
323
324
void SAL_CALL ODatabaseMetaDataResultSet::beforeFirst(  )
325
0
{
326
0
    ::dbtools::throwFunctionSequenceException(*this);
327
0
}
328
329
void SAL_CALL ODatabaseMetaDataResultSet::afterLast(  )
330
0
{
331
0
    ::dbtools::throwFunctionSequenceException(*this);
332
0
}
333
334
335
void SAL_CALL ODatabaseMetaDataResultSet::close(  )
336
0
{
337
0
    {
338
0
        std::unique_lock aGuard( m_aMutex );
339
0
        throwIfDisposed(aGuard);
340
0
    }
341
0
    dispose();
342
0
}
343
344
sal_Bool SAL_CALL ODatabaseMetaDataResultSet::first(  )
345
0
{
346
0
    ::dbtools::throwFunctionSequenceException(*this);
347
0
}
348
349
sal_Bool SAL_CALL ODatabaseMetaDataResultSet::last(  )
350
0
{
351
0
    ::dbtools::throwFunctionSequenceException(*this);
352
0
}
353
354
sal_Bool SAL_CALL ODatabaseMetaDataResultSet::absolute( sal_Int32 /*row*/ )
355
0
{
356
0
    ::dbtools::throwFunctionSequenceException(*this);
357
0
}
358
359
sal_Bool SAL_CALL ODatabaseMetaDataResultSet::relative( sal_Int32 /*row*/ )
360
0
{
361
0
    ::dbtools::throwFunctionSequenceException(*this);
362
0
}
363
364
sal_Bool SAL_CALL ODatabaseMetaDataResultSet::previous(  )
365
0
{
366
0
    ::dbtools::throwFunctionSequenceException(*this);
367
0
}
368
369
Reference< XInterface > SAL_CALL ODatabaseMetaDataResultSet::getStatement(  )
370
0
{
371
0
    return nullptr;
372
0
}
373
374
sal_Bool SAL_CALL ODatabaseMetaDataResultSet::rowDeleted(  )
375
0
{
376
0
    ::dbtools::throwFunctionSequenceException(*this);
377
0
}
378
379
sal_Bool SAL_CALL ODatabaseMetaDataResultSet::rowInserted(  )
380
0
{
381
0
    ::dbtools::throwFunctionSequenceException(*this);
382
0
}
383
384
sal_Bool SAL_CALL ODatabaseMetaDataResultSet::rowUpdated(  )
385
0
{
386
0
    ::dbtools::throwFunctionSequenceException(*this);
387
0
}
388
389
sal_Bool SAL_CALL ODatabaseMetaDataResultSet::isBeforeFirst()
390
0
{
391
0
    return m_bBOF;
392
0
}
393
394
bool ODatabaseMetaDataResultSet::isBeforeFirst(std::unique_lock<std::mutex>& /*rGuard*/)
395
3.01M
{
396
3.01M
    return m_bBOF;
397
3.01M
}
398
399
sal_Bool SAL_CALL ODatabaseMetaDataResultSet::next(  )
400
466k
{
401
466k
    std::unique_lock aGuard( m_aMutex );
402
466k
    return next(aGuard);
403
466k
}
404
405
bool ODatabaseMetaDataResultSet::next( std::unique_lock<std::mutex>& rGuard )
406
466k
{
407
466k
    throwIfDisposed(rGuard);
408
409
466k
    if ( m_bBOF )
410
91.7k
    {
411
91.7k
       m_aRowsIter = m_aRows.begin();
412
91.7k
       m_bBOF = false;
413
91.7k
    }
414
375k
    else
415
375k
    {
416
375k
        if ( m_bEOF )
417
0
            throwFunctionSequenceException( *this );
418
375k
        else
419
375k
            if ( m_aRowsIter != m_aRows.end() )
420
375k
                ++m_aRowsIter;
421
375k
    }
422
423
466k
    bool bSuccess = m_aRowsIter != m_aRows.end();
424
466k
    if ( !bSuccess )
425
81.4k
    {
426
81.4k
        m_bEOF = true;
427
81.4k
        m_bBOF = m_aRows.empty();
428
81.4k
    }
429
466k
    return bSuccess;
430
466k
}
431
432
433
sal_Bool SAL_CALL ODatabaseMetaDataResultSet::wasNull(  )
434
0
{
435
0
    std::unique_lock aGuard( m_aMutex );
436
0
    throwIfDisposed(aGuard);
437
438
0
    if(m_aRowsIter == m_aRows.end() || !(*m_aRowsIter)[m_nColPos].is())
439
0
        return true;
440
441
0
    return (*m_aRowsIter)[m_nColPos]->getValue().isNull();
442
0
}
443
444
void SAL_CALL ODatabaseMetaDataResultSet::refreshRow(  )
445
0
{
446
0
}
447
448
449
void SAL_CALL ODatabaseMetaDataResultSet::cancel(  )
450
0
{
451
0
}
452
453
void SAL_CALL ODatabaseMetaDataResultSet::clearWarnings(  )
454
0
{
455
0
}
456
457
Any SAL_CALL ODatabaseMetaDataResultSet::getWarnings(  )
458
0
{
459
0
    return Any();
460
0
}
461
462
::cppu::IPropertyArrayHelper* ODatabaseMetaDataResultSet::createArrayHelper( ) const
463
0
{
464
0
    Sequence< Property > aProps;
465
0
    describeProperties(aProps);
466
0
    return new ::cppu::OPropertyArrayHelper(aProps);
467
0
}
468
469
::cppu::IPropertyArrayHelper & ODatabaseMetaDataResultSet::getInfoHelper()
470
0
{
471
0
    return *getArrayHelper();
472
0
}
473
474
void ODatabaseMetaDataResultSet::setProceduresMap()
475
0
{
476
0
    m_xMetaData = new ODatabaseMetaDataResultSetMetaData();
477
0
    m_xMetaData->setProceduresMap();
478
0
}
479
480
void ODatabaseMetaDataResultSet::setCatalogsMap()
481
0
{
482
0
    m_xMetaData = new ODatabaseMetaDataResultSetMetaData();
483
0
    m_xMetaData->setCatalogsMap();
484
0
}
485
486
void ODatabaseMetaDataResultSet::setSchemasMap()
487
0
{
488
0
    m_xMetaData = new ODatabaseMetaDataResultSetMetaData();
489
0
    m_xMetaData->setSchemasMap();
490
0
}
491
492
void ODatabaseMetaDataResultSet::setColumnPrivilegesMap()
493
0
{
494
0
    m_xMetaData = new ODatabaseMetaDataResultSetMetaData();
495
0
    m_xMetaData->setColumnPrivilegesMap();
496
0
}
497
498
void ODatabaseMetaDataResultSet::setColumnsMap()
499
10.1k
{
500
10.1k
    m_xMetaData = new ODatabaseMetaDataResultSetMetaData();
501
10.1k
    m_xMetaData->setColumnsMap();
502
10.1k
}
503
504
void ODatabaseMetaDataResultSet::setTablesMap()
505
61.4k
{
506
61.4k
    m_xMetaData = new ODatabaseMetaDataResultSetMetaData();
507
61.4k
    m_xMetaData->setTablesMap();
508
61.4k
}
509
510
void ODatabaseMetaDataResultSet::setProcedureColumnsMap()
511
0
{
512
0
    m_xMetaData = new ODatabaseMetaDataResultSetMetaData();
513
0
    m_xMetaData->setProcedureColumnsMap();
514
0
}
515
516
void ODatabaseMetaDataResultSet::setPrimaryKeysMap()
517
10.0k
{
518
10.0k
    m_xMetaData = new ODatabaseMetaDataResultSetMetaData();
519
10.0k
    m_xMetaData->setPrimaryKeysMap();
520
10.0k
}
521
522
void ODatabaseMetaDataResultSet::setIndexInfoMap()
523
0
{
524
0
    m_xMetaData = new ODatabaseMetaDataResultSetMetaData();
525
0
    m_xMetaData->setIndexInfoMap();
526
0
}
527
528
void ODatabaseMetaDataResultSet::setTablePrivilegesMap()
529
0
{
530
0
    m_xMetaData = new ODatabaseMetaDataResultSetMetaData();
531
0
    m_xMetaData->setTablePrivilegesMap();
532
0
}
533
534
void ODatabaseMetaDataResultSet::setCrossReferenceMap()
535
0
{
536
0
    m_xMetaData = new ODatabaseMetaDataResultSetMetaData();
537
0
    m_xMetaData->setCrossReferenceMap();
538
0
}
539
540
void ODatabaseMetaDataResultSet::setVersionColumnsMap()
541
0
{
542
0
    m_xMetaData = new ODatabaseMetaDataResultSetMetaData();
543
0
    m_xMetaData->setVersionColumnsMap();
544
0
}
545
546
void ODatabaseMetaDataResultSet::setBestRowIdentifierMap()
547
0
{
548
0
    m_xMetaData = new ODatabaseMetaDataResultSetMetaData();
549
0
    m_xMetaData->setBestRowIdentifierMap();
550
0
}
551
552
void ODatabaseMetaDataResultSet::setTypeInfoMap()
553
0
{
554
0
    m_xMetaData = new ODatabaseMetaDataResultSetMetaData();
555
0
    m_xMetaData->setTypeInfoMap();
556
0
}
557
558
void ODatabaseMetaDataResultSet::setUDTsMap()
559
0
{
560
0
    m_xMetaData = new ODatabaseMetaDataResultSetMetaData();
561
0
    m_xMetaData->setUDTsMap();
562
0
}
563
564
void ODatabaseMetaDataResultSet::setTableTypes()
565
0
{
566
0
    m_xMetaData = new ODatabaseMetaDataResultSetMetaData();
567
0
    m_xMetaData->setTableTypes();
568
0
}
569
570
void ODatabaseMetaDataResultSet::setExportedKeysMap()
571
0
{
572
0
    m_xMetaData = new ODatabaseMetaDataResultSetMetaData();
573
0
    m_xMetaData->setExportedKeysMap();
574
0
}
575
576
void ODatabaseMetaDataResultSet::setImportedKeysMap()
577
10.0k
{
578
10.0k
    m_xMetaData = new ODatabaseMetaDataResultSetMetaData();
579
10.0k
    m_xMetaData->setImportedKeysMap();
580
10.0k
}
581
582
Reference< css::beans::XPropertySetInfo > SAL_CALL ODatabaseMetaDataResultSet::getPropertySetInfo(  )
583
0
{
584
0
    return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
585
0
}
586
587
ORowSetValueDecorator& ORowSetValueDecorator::operator=(const ORowSetValue& _aValue)
588
6.29M
{
589
6.29M
    m_aValue = _aValue;
590
6.29M
    return *this;
591
6.29M
}
592
593
const ORowSetValue& ODatabaseMetaDataResultSet::getValue(sal_Int32 columnIndex)
594
3.01M
{
595
3.01M
    std::unique_lock aGuard( m_aMutex );
596
3.01M
    throwIfDisposed(aGuard);
597
598
3.01M
    if ( isBeforeFirst(aGuard) || isAfterLast(aGuard) )
599
0
        ::dbtools::throwFunctionSequenceException( *this );
600
601
3.01M
    checkIndex(aGuard, columnIndex);
602
3.01M
    m_nColPos = columnIndex;
603
604
3.01M
    if(m_aRowsIter != m_aRows.end() && (*m_aRowsIter)[columnIndex].is())
605
2.67M
        return *(*m_aRowsIter)[columnIndex];
606
344k
    return m_aEmptyValue;
607
3.01M
}
608
609
/// return an empty ORowSetValueDecorator
610
ORowSetValueDecoratorRef const & ODatabaseMetaDataResultSet::getEmptyValue()
611
61.4k
{
612
61.4k
    static ORowSetValueDecoratorRef aEmptyValueRef = new ORowSetValueDecorator();
613
61.4k
    return aEmptyValueRef;
614
61.4k
}
615
616
/// return an ORowSetValueDecorator with 0 as value
617
ORowSetValueDecoratorRef const & ODatabaseMetaDataResultSet::get0Value()
618
0
{
619
0
    static ORowSetValueDecoratorRef a0ValueRef = new ORowSetValueDecorator(sal_Int32(0));
620
0
    return a0ValueRef;
621
0
}
622
623
/// return an ORowSetValueDecorator with 1 as value
624
ORowSetValueDecoratorRef const & ODatabaseMetaDataResultSet::get1Value()
625
0
{
626
0
    static ORowSetValueDecoratorRef a1ValueRef = new ORowSetValueDecorator(sal_Int32(1));
627
0
    return a1ValueRef;
628
0
}
629
630
/// return an ORowSetValueDecorator with ColumnSearch::BASIC as value
631
ORowSetValueDecoratorRef const & ODatabaseMetaDataResultSet::getBasicValue()
632
0
{
633
0
    static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(ColumnSearch::BASIC);
634
0
    return aValueRef;
635
0
}
636
637
ORowSetValueDecoratorRef const & ODatabaseMetaDataResultSet::getSelectValue()
638
0
{
639
0
    static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(u"SELECT"_ustr);
640
0
    return aValueRef;
641
0
}
642
643
ORowSetValueDecoratorRef const & ODatabaseMetaDataResultSet::getInsertValue()
644
0
{
645
0
    static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(u"INSERT"_ustr);
646
0
    return aValueRef;
647
0
}
648
649
ORowSetValueDecoratorRef const & ODatabaseMetaDataResultSet::getDeleteValue()
650
0
{
651
0
    static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(u"DELETE"_ustr);
652
0
    return aValueRef;
653
0
}
654
655
ORowSetValueDecoratorRef const & ODatabaseMetaDataResultSet::getUpdateValue()
656
0
{
657
0
    static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(u"UPDATE"_ustr);
658
0
    return aValueRef;
659
0
}
660
661
ORowSetValueDecoratorRef const & ODatabaseMetaDataResultSet::getCreateValue()
662
0
{
663
0
    static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(u"CREATE"_ustr);
664
0
    return aValueRef;
665
0
}
666
667
ORowSetValueDecoratorRef const & ODatabaseMetaDataResultSet::getReadValue()
668
0
{
669
0
    static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(u"READ"_ustr);
670
0
    return aValueRef;
671
0
}
672
673
ORowSetValueDecoratorRef const & ODatabaseMetaDataResultSet::getAlterValue()
674
0
{
675
0
    static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(u"ALTER"_ustr);
676
0
    return aValueRef;
677
0
}
678
679
ORowSetValueDecoratorRef const & ODatabaseMetaDataResultSet::getDropValue()
680
0
{
681
0
    static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(u"DROP"_ustr);
682
0
    return aValueRef;
683
0
}
684
685
ORowSetValueDecoratorRef const & ODatabaseMetaDataResultSet::getQuoteValue()
686
0
{
687
0
    static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(u"'"_ustr);
688
0
    return aValueRef;
689
0
}
690
691
void SAL_CALL ODatabaseMetaDataResultSet::initialize( const Sequence< Any >& _aArguments )
692
0
{
693
0
    if ( _aArguments.getLength() != 2 )
694
0
        return;
695
696
0
    sal_Int32 nResultSetType = 0;
697
0
    if ( !(_aArguments[0] >>= nResultSetType))
698
0
        return;
699
700
0
    setType(static_cast<MetaDataResultSetType>(nResultSetType));
701
0
    Sequence< Sequence<Any> > aRows;
702
0
    if ( !(_aArguments[1] >>= aRows) )
703
0
        return;
704
705
0
    ORows aRowsToSet;
706
0
    for (auto& row : aRows)
707
0
    {
708
0
        ORow aRowToSet;
709
0
        for (auto& field : row)
710
0
        {
711
0
            ORowSetValueDecoratorRef aValue;
712
0
            switch (field.getValueTypeClass())
713
0
            {
714
0
                case TypeClass_BOOLEAN:
715
0
                    {
716
0
                        bool bValue = false;
717
0
                        field >>= bValue;
718
0
                        aValue = new ORowSetValueDecorator(ORowSetValue(bValue));
719
0
                    }
720
0
                    break;
721
0
                case TypeClass_BYTE:
722
0
                    {
723
0
                        sal_Int8 nValue(0);
724
0
                        field >>= nValue;
725
0
                        aValue = new ORowSetValueDecorator(ORowSetValue(nValue));
726
0
                    }
727
0
                    break;
728
0
                case TypeClass_SHORT:
729
0
                case TypeClass_UNSIGNED_SHORT:
730
0
                    {
731
0
                        sal_Int16 nValue(0);
732
0
                        field >>= nValue;
733
0
                        aValue = new ORowSetValueDecorator(ORowSetValue(nValue));
734
0
                    }
735
0
                    break;
736
0
                case TypeClass_LONG:
737
0
                case TypeClass_UNSIGNED_LONG:
738
0
                    {
739
0
                        sal_Int32 nValue(0);
740
0
                        field >>= nValue;
741
0
                        aValue = new ORowSetValueDecorator(ORowSetValue(nValue));
742
0
                    }
743
0
                    break;
744
0
                case TypeClass_HYPER:
745
0
                case TypeClass_UNSIGNED_HYPER:
746
0
                    {
747
0
                        sal_Int64 nValue(0);
748
0
                        field >>= nValue;
749
0
                        aValue = new ORowSetValueDecorator(ORowSetValue(nValue));
750
0
                    }
751
0
                    break;
752
0
                case TypeClass_FLOAT:
753
0
                    {
754
0
                        float nValue(0.0);
755
0
                        field >>= nValue;
756
0
                        aValue = new ORowSetValueDecorator(ORowSetValue(nValue));
757
0
                    }
758
0
                    break;
759
0
                case TypeClass_DOUBLE:
760
0
                    {
761
0
                        double nValue(0.0);
762
0
                        field >>= nValue;
763
0
                        aValue = new ORowSetValueDecorator(ORowSetValue(nValue));
764
0
                    }
765
0
                    break;
766
0
                case TypeClass_STRING:
767
0
                    {
768
0
                        OUString sValue;
769
0
                        field >>= sValue;
770
0
                        aValue = new ORowSetValueDecorator(ORowSetValue(sValue));
771
0
                    }
772
0
                    break;
773
0
                default:
774
0
                    break;
775
0
            }
776
0
            aRowToSet.push_back(aValue);
777
0
        }
778
0
        aRowsToSet.push_back(std::move(aRowToSet));
779
0
    } // for (; pRowsIter != pRowsEnd;++pRowsIter
780
0
    setRows(std::move(aRowsToSet));
781
0
}
782
// XServiceInfo
783
784
785
    OUString SAL_CALL ODatabaseMetaDataResultSet::getImplementationName(  )
786
0
    {
787
0
        return u"org.openoffice.comp.helper.DatabaseMetaDataResultSet"_ustr;
788
0
    }
789
790
    sal_Bool SAL_CALL ODatabaseMetaDataResultSet::supportsService( const OUString& _rServiceName )
791
0
    {
792
0
        return cppu::supportsService(this, _rServiceName);
793
0
    }
794
795
    Sequence< OUString > SAL_CALL ODatabaseMetaDataResultSet::getSupportedServiceNames(  )
796
0
    {
797
0
        return Sequence<OUString>{ u"com.sun.star.sdbc.ResultSet"_ustr };
798
0
    }
799
800
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
801
connectivity_dbtools_ODatabaseMetaDataResultSet_get_implementation(
802
    css::uno::XComponentContext* , css::uno::Sequence<css::uno::Any> const&)
803
0
{
804
0
    return cppu::acquire(new ODatabaseMetaDataResultSet());
805
0
}
806
807
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */