Use COMReference to handle COM pointers in CreateShortcut
[LibreOffice.git] / connectivity / source / commontools / FDatabaseMetaDataResultSet.cxx
blob0e490e3b66ad82e91181948155ca1801e905442b
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #include <ParameterSubstitution.hxx>
22 #include <FDatabaseMetaDataResultSet.hxx>
23 #include <FDatabaseMetaDataResultSetMetaData.hxx>
24 #include <com/sun/star/sdbc/ColumnSearch.hpp>
25 #include <com/sun/star/beans/PropertyAttribute.hpp>
26 #include <cppuhelper/typeprovider.hxx>
27 #include <comphelper/sequence.hxx>
28 #include <cppuhelper/supportsservice.hxx>
29 #include <connectivity/dbexception.hxx>
30 #include <o3tl/safeint.hxx>
31 #include <o3tl/unreachable.hxx>
32 #include <TConnection.hxx>
34 using namespace connectivity;
35 using namespace dbtools;
36 using namespace cppu;
38 using namespace ::com::sun::star::beans;
39 using namespace ::com::sun::star::uno;
40 using namespace ::com::sun::star::sdbc;
41 using namespace ::com::sun::star::container;
42 using namespace ::com::sun::star::lang;
44 ODatabaseMetaDataResultSet::ODatabaseMetaDataResultSet()
46 m_nColPos(0)
47 ,m_bBOF(true)
48 ,m_bEOF(true)
50 construct();
54 ODatabaseMetaDataResultSet::ODatabaseMetaDataResultSet( MetaDataResultSetType _eType )
56 m_nColPos(0)
57 ,m_bBOF(true)
58 ,m_bEOF(true)
60 construct();
62 setType(_eType);
66 ODatabaseMetaDataResultSet::~ODatabaseMetaDataResultSet()
70 void ODatabaseMetaDataResultSet::construct()
72 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FETCHSIZE), PROPERTY_ID_FETCHSIZE, 0,&m_nFetchSize, ::cppu::UnoType<sal_Int32>::get());
73 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_RESULTSETTYPE), PROPERTY_ID_RESULTSETTYPE, PropertyAttribute::READONLY,&m_nResultSetType, ::cppu::UnoType<sal_Int32>::get());
74 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FETCHDIRECTION), PROPERTY_ID_FETCHDIRECTION, 0, &m_nFetchDirection, ::cppu::UnoType<sal_Int32>::get());
75 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_RESULTSETCONCURRENCY), PROPERTY_ID_RESULTSETCONCURRENCY, PropertyAttribute::READONLY,&m_nResultSetConcurrency, ::cppu::UnoType<sal_Int32>::get());
78 void ODatabaseMetaDataResultSet::setType(MetaDataResultSetType _eType)
80 switch( _eType )
82 case eCatalogs: setCatalogsMap(); break;
83 case eSchemas: setSchemasMap(); break;
84 case eColumnPrivileges: setColumnPrivilegesMap(); break;
85 case eColumns: setColumnsMap(); break;
86 case eTables: setTablesMap(); break;
87 case eTableTypes: setTableTypes(); break;
88 case eProcedureColumns: setProcedureColumnsMap(); break;
89 case eProcedures: setProceduresMap(); break;
90 case eExportedKeys: setExportedKeysMap(); break;
91 case eImportedKeys: setImportedKeysMap(); break;
92 case ePrimaryKeys: setPrimaryKeysMap(); break;
93 case eIndexInfo: setIndexInfoMap(); break;
94 case eTablePrivileges: setTablePrivilegesMap(); break;
95 case eCrossReference: setCrossReferenceMap(); break;
96 case eTypeInfo: setTypeInfoMap(); break;
97 case eBestRowIdentifier: setBestRowIdentifierMap(); break;
98 case eVersionColumns: setVersionColumnsMap(); break;
99 case eUDTs: setUDTsMap(); break;
100 default:
101 OSL_FAIL("Wrong type!");
105 void ODatabaseMetaDataResultSet::disposing(std::unique_lock<std::mutex>& rGuard)
107 OPropertySetHelper::disposing(rGuard);
109 m_aStatement.clear();
110 m_xMetaData.clear();
111 m_aRowsIter = m_aRows.end();
112 m_aRows.clear();
113 m_aRowsIter = m_aRows.end();
116 void SAL_CALL ODatabaseMetaDataResultSet::acquire() noexcept
118 ODatabaseMetaDataResultSet_BASE::acquire();
121 void SAL_CALL ODatabaseMetaDataResultSet::release() noexcept
123 ODatabaseMetaDataResultSet_BASE::release();
126 Any SAL_CALL ODatabaseMetaDataResultSet::queryInterface( const Type & rType )
128 Any aRet = OPropertySetHelper::queryInterface(rType);
129 return aRet.hasValue() ? aRet : ODatabaseMetaDataResultSet_BASE::queryInterface(rType);
132 Sequence< Type > SAL_CALL ODatabaseMetaDataResultSet::getTypes( )
134 ::cppu::OTypeCollection aTypes( cppu::UnoType<css::beans::XMultiPropertySet>::get(),
135 cppu::UnoType<css::beans::XFastPropertySet>::get(),
136 cppu::UnoType<css::beans::XPropertySet>::get());
138 return ::comphelper::concatSequences(aTypes.getTypes(),ODatabaseMetaDataResultSet_BASE::getTypes());
141 void ODatabaseMetaDataResultSet::setRows(ORows&& _rRows)
143 m_aRows = std::move(_rRows);
144 m_bBOF = true;
145 m_bEOF = m_aRows.empty();
148 sal_Int32 SAL_CALL ODatabaseMetaDataResultSet::findColumn( const OUString& columnName )
150 std::unique_lock aGuard( m_aMutex );
151 throwIfDisposed(aGuard);
153 Reference< XResultSetMetaData > xMeta = getMetaData(aGuard);
154 sal_Int32 nLen = xMeta->getColumnCount();
155 sal_Int32 i = 1;
156 for(;i<=nLen;++i)
158 if(xMeta->isCaseSensitive(i) ? columnName == xMeta->getColumnName(i) :
159 columnName.equalsIgnoreAsciiCase(xMeta->getColumnName(i))
161 return i;
164 ::dbtools::throwInvalidColumnException( columnName, *this );
167 void ODatabaseMetaDataResultSet::checkIndex(std::unique_lock<std::mutex>& /*rGuard*/, sal_Int32 columnIndex )
169 if(columnIndex < 1 || o3tl::make_unsigned(columnIndex) >= (*m_aRowsIter).size())
170 ::dbtools::throwInvalidIndexException(*this);
173 Reference< css::io::XInputStream > SAL_CALL ODatabaseMetaDataResultSet::getBinaryStream( sal_Int32 /*columnIndex*/ )
175 return nullptr;
178 Reference< css::io::XInputStream > SAL_CALL ODatabaseMetaDataResultSet::getCharacterStream( sal_Int32 /*columnIndex*/ )
180 return nullptr;
184 sal_Bool SAL_CALL ODatabaseMetaDataResultSet::getBoolean( sal_Int32 columnIndex )
186 return getValue(columnIndex).getBool();
190 sal_Int8 SAL_CALL ODatabaseMetaDataResultSet::getByte( sal_Int32 columnIndex )
192 return getValue(columnIndex).getInt8();
196 Sequence< sal_Int8 > SAL_CALL ODatabaseMetaDataResultSet::getBytes( sal_Int32 columnIndex )
198 return getValue(columnIndex).getSequence();
202 css::util::Date SAL_CALL ODatabaseMetaDataResultSet::getDate( sal_Int32 columnIndex )
204 return getValue(columnIndex).getDate();
208 double SAL_CALL ODatabaseMetaDataResultSet::getDouble( sal_Int32 columnIndex )
210 return getValue(columnIndex).getDouble();
214 float SAL_CALL ODatabaseMetaDataResultSet::getFloat( sal_Int32 columnIndex )
216 return getValue(columnIndex).getFloat();
220 sal_Int32 SAL_CALL ODatabaseMetaDataResultSet::getInt( sal_Int32 columnIndex )
222 return getValue(columnIndex).getInt32();
226 sal_Int32 SAL_CALL ODatabaseMetaDataResultSet::getRow( )
228 return 0;
232 sal_Int64 SAL_CALL ODatabaseMetaDataResultSet::getLong( sal_Int32 columnIndex )
234 return getValue(columnIndex).getLong();
238 Reference< XResultSetMetaData > SAL_CALL ODatabaseMetaDataResultSet::getMetaData( )
240 std::unique_lock aGuard( m_aMutex );
241 return getMetaData(aGuard);
244 Reference< XResultSetMetaData > ODatabaseMetaDataResultSet::getMetaData( std::unique_lock<std::mutex>& rGuard )
246 throwIfDisposed(rGuard);
248 if(!m_xMetaData.is())
249 m_xMetaData = new ODatabaseMetaDataResultSetMetaData();
251 return m_xMetaData;
254 Reference< XArray > SAL_CALL ODatabaseMetaDataResultSet::getArray( sal_Int32 /*columnIndex*/ )
256 return nullptr;
260 Reference< XClob > SAL_CALL ODatabaseMetaDataResultSet::getClob( sal_Int32 /*columnIndex*/ )
262 return nullptr;
265 Reference< XBlob > SAL_CALL ODatabaseMetaDataResultSet::getBlob( sal_Int32 /*columnIndex*/ )
267 return nullptr;
271 Reference< XRef > SAL_CALL ODatabaseMetaDataResultSet::getRef( sal_Int32 /*columnIndex*/ )
273 return nullptr;
277 Any SAL_CALL ODatabaseMetaDataResultSet::getObject( sal_Int32 columnIndex, const Reference< css::container::XNameAccess >& /*typeMap*/ )
279 return getValue(columnIndex).makeAny();
283 sal_Int16 SAL_CALL ODatabaseMetaDataResultSet::getShort( sal_Int32 columnIndex )
285 return getValue(columnIndex).getInt16();
289 OUString SAL_CALL ODatabaseMetaDataResultSet::getString( sal_Int32 columnIndex )
291 return getValue(columnIndex).getString();
295 css::util::Time SAL_CALL ODatabaseMetaDataResultSet::getTime( sal_Int32 columnIndex )
297 return getValue(columnIndex).getTime();
301 css::util::DateTime SAL_CALL ODatabaseMetaDataResultSet::getTimestamp( sal_Int32 columnIndex )
303 return getValue(columnIndex).getDateTime();
307 sal_Bool SAL_CALL ODatabaseMetaDataResultSet::isAfterLast()
309 return m_bEOF;
312 bool ODatabaseMetaDataResultSet::isAfterLast( std::unique_lock<std::mutex>& /*rGuard*/)
314 return m_bEOF;
317 sal_Bool SAL_CALL ODatabaseMetaDataResultSet::isFirst( )
319 ::dbtools::throwFunctionSequenceException(*this);
322 sal_Bool SAL_CALL ODatabaseMetaDataResultSet::isLast( )
324 ::dbtools::throwFunctionSequenceException(*this);
327 void SAL_CALL ODatabaseMetaDataResultSet::beforeFirst( )
329 ::dbtools::throwFunctionSequenceException(*this);
332 void SAL_CALL ODatabaseMetaDataResultSet::afterLast( )
334 ::dbtools::throwFunctionSequenceException(*this);
338 void SAL_CALL ODatabaseMetaDataResultSet::close( )
341 std::unique_lock aGuard( m_aMutex );
342 throwIfDisposed(aGuard);
344 dispose();
347 sal_Bool SAL_CALL ODatabaseMetaDataResultSet::first( )
349 ::dbtools::throwFunctionSequenceException(*this);
352 sal_Bool SAL_CALL ODatabaseMetaDataResultSet::last( )
354 ::dbtools::throwFunctionSequenceException(*this);
357 sal_Bool SAL_CALL ODatabaseMetaDataResultSet::absolute( sal_Int32 /*row*/ )
359 ::dbtools::throwFunctionSequenceException(*this);
362 sal_Bool SAL_CALL ODatabaseMetaDataResultSet::relative( sal_Int32 /*row*/ )
364 ::dbtools::throwFunctionSequenceException(*this);
367 sal_Bool SAL_CALL ODatabaseMetaDataResultSet::previous( )
369 ::dbtools::throwFunctionSequenceException(*this);
372 Reference< XInterface > SAL_CALL ODatabaseMetaDataResultSet::getStatement( )
374 return m_aStatement.get();
377 sal_Bool SAL_CALL ODatabaseMetaDataResultSet::rowDeleted( )
379 ::dbtools::throwFunctionSequenceException(*this);
382 sal_Bool SAL_CALL ODatabaseMetaDataResultSet::rowInserted( )
384 ::dbtools::throwFunctionSequenceException(*this);
387 sal_Bool SAL_CALL ODatabaseMetaDataResultSet::rowUpdated( )
389 ::dbtools::throwFunctionSequenceException(*this);
392 sal_Bool SAL_CALL ODatabaseMetaDataResultSet::isBeforeFirst()
394 return m_bBOF;
397 bool ODatabaseMetaDataResultSet::isBeforeFirst(std::unique_lock<std::mutex>& /*rGuard*/)
399 return m_bBOF;
402 sal_Bool SAL_CALL ODatabaseMetaDataResultSet::next( )
404 std::unique_lock aGuard( m_aMutex );
405 return next(aGuard);
408 bool ODatabaseMetaDataResultSet::next( std::unique_lock<std::mutex>& rGuard )
410 throwIfDisposed(rGuard);
412 if ( m_bBOF )
414 m_aRowsIter = m_aRows.begin();
415 m_bBOF = false;
417 else
419 if ( m_bEOF )
420 throwFunctionSequenceException( *this );
421 else
422 if ( m_aRowsIter != m_aRows.end() )
423 ++m_aRowsIter;
426 bool bSuccess = m_aRowsIter != m_aRows.end();
427 if ( !bSuccess )
429 m_bEOF = true;
430 m_bBOF = m_aRows.empty();
432 return bSuccess;
436 sal_Bool SAL_CALL ODatabaseMetaDataResultSet::wasNull( )
438 std::unique_lock aGuard( m_aMutex );
439 throwIfDisposed(aGuard);
441 if(m_aRowsIter == m_aRows.end() || !(*m_aRowsIter)[m_nColPos].is())
442 return true;
444 return (*m_aRowsIter)[m_nColPos]->getValue().isNull();
447 void SAL_CALL ODatabaseMetaDataResultSet::refreshRow( )
452 void SAL_CALL ODatabaseMetaDataResultSet::cancel( )
456 void SAL_CALL ODatabaseMetaDataResultSet::clearWarnings( )
460 Any SAL_CALL ODatabaseMetaDataResultSet::getWarnings( )
462 return Any();
465 ::cppu::IPropertyArrayHelper* ODatabaseMetaDataResultSet::createArrayHelper( ) const
467 Sequence< Property > aProps;
468 describeProperties(aProps);
469 return new ::cppu::OPropertyArrayHelper(aProps);
472 ::cppu::IPropertyArrayHelper & ODatabaseMetaDataResultSet::getInfoHelper()
474 return *getArrayHelper();
477 void ODatabaseMetaDataResultSet::setProceduresMap()
479 m_xMetaData = new ODatabaseMetaDataResultSetMetaData();
480 m_xMetaData->setProceduresMap();
483 void ODatabaseMetaDataResultSet::setCatalogsMap()
485 m_xMetaData = new ODatabaseMetaDataResultSetMetaData();
486 m_xMetaData->setCatalogsMap();
489 void ODatabaseMetaDataResultSet::setSchemasMap()
491 m_xMetaData = new ODatabaseMetaDataResultSetMetaData();
492 m_xMetaData->setSchemasMap();
495 void ODatabaseMetaDataResultSet::setColumnPrivilegesMap()
497 m_xMetaData = new ODatabaseMetaDataResultSetMetaData();
498 m_xMetaData->setColumnPrivilegesMap();
501 void ODatabaseMetaDataResultSet::setColumnsMap()
503 m_xMetaData = new ODatabaseMetaDataResultSetMetaData();
504 m_xMetaData->setColumnsMap();
507 void ODatabaseMetaDataResultSet::setTablesMap()
509 m_xMetaData = new ODatabaseMetaDataResultSetMetaData();
510 m_xMetaData->setTablesMap();
513 void ODatabaseMetaDataResultSet::setProcedureColumnsMap()
515 m_xMetaData = new ODatabaseMetaDataResultSetMetaData();
516 m_xMetaData->setProcedureColumnsMap();
519 void ODatabaseMetaDataResultSet::setPrimaryKeysMap()
521 m_xMetaData = new ODatabaseMetaDataResultSetMetaData();
522 m_xMetaData->setPrimaryKeysMap();
525 void ODatabaseMetaDataResultSet::setIndexInfoMap()
527 m_xMetaData = new ODatabaseMetaDataResultSetMetaData();
528 m_xMetaData->setIndexInfoMap();
531 void ODatabaseMetaDataResultSet::setTablePrivilegesMap()
533 m_xMetaData = new ODatabaseMetaDataResultSetMetaData();
534 m_xMetaData->setTablePrivilegesMap();
537 void ODatabaseMetaDataResultSet::setCrossReferenceMap()
539 m_xMetaData = new ODatabaseMetaDataResultSetMetaData();
540 m_xMetaData->setCrossReferenceMap();
543 void ODatabaseMetaDataResultSet::setVersionColumnsMap()
545 m_xMetaData = new ODatabaseMetaDataResultSetMetaData();
546 m_xMetaData->setVersionColumnsMap();
549 void ODatabaseMetaDataResultSet::setBestRowIdentifierMap()
551 m_xMetaData = new ODatabaseMetaDataResultSetMetaData();
552 m_xMetaData->setBestRowIdentifierMap();
555 void ODatabaseMetaDataResultSet::setTypeInfoMap()
557 m_xMetaData = new ODatabaseMetaDataResultSetMetaData();
558 m_xMetaData->setTypeInfoMap();
561 void ODatabaseMetaDataResultSet::setUDTsMap()
563 m_xMetaData = new ODatabaseMetaDataResultSetMetaData();
564 m_xMetaData->setUDTsMap();
567 void ODatabaseMetaDataResultSet::setTableTypes()
569 m_xMetaData = new ODatabaseMetaDataResultSetMetaData();
570 m_xMetaData->setTableTypes();
573 void ODatabaseMetaDataResultSet::setExportedKeysMap()
575 m_xMetaData = new ODatabaseMetaDataResultSetMetaData();
576 m_xMetaData->setExportedKeysMap();
579 void ODatabaseMetaDataResultSet::setImportedKeysMap()
581 m_xMetaData = new ODatabaseMetaDataResultSetMetaData();
582 m_xMetaData->setImportedKeysMap();
585 Reference< css::beans::XPropertySetInfo > SAL_CALL ODatabaseMetaDataResultSet::getPropertySetInfo( )
587 return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
590 ORowSetValueDecorator& ORowSetValueDecorator::operator=(const ORowSetValue& _aValue)
592 m_aValue = _aValue;
593 return *this;
596 const ORowSetValue& ODatabaseMetaDataResultSet::getValue(sal_Int32 columnIndex)
598 std::unique_lock aGuard( m_aMutex );
599 throwIfDisposed(aGuard);
601 if ( isBeforeFirst(aGuard) || isAfterLast(aGuard) )
602 ::dbtools::throwFunctionSequenceException( *this );
604 checkIndex(aGuard, columnIndex);
605 m_nColPos = columnIndex;
607 if(m_aRowsIter != m_aRows.end() && (*m_aRowsIter)[columnIndex].is())
608 return *(*m_aRowsIter)[columnIndex];
609 return m_aEmptyValue;
612 /// return an empty ORowSetValueDecorator
613 ORowSetValueDecoratorRef const & ODatabaseMetaDataResultSet::getEmptyValue()
615 static ORowSetValueDecoratorRef aEmptyValueRef = new ORowSetValueDecorator();
616 return aEmptyValueRef;
619 /// return an ORowSetValueDecorator with 0 as value
620 ORowSetValueDecoratorRef const & ODatabaseMetaDataResultSet::get0Value()
622 static ORowSetValueDecoratorRef a0ValueRef = new ORowSetValueDecorator(sal_Int32(0));
623 return a0ValueRef;
626 /// return an ORowSetValueDecorator with 1 as value
627 ORowSetValueDecoratorRef const & ODatabaseMetaDataResultSet::get1Value()
629 static ORowSetValueDecoratorRef a1ValueRef = new ORowSetValueDecorator(sal_Int32(1));
630 return a1ValueRef;
633 /// return an ORowSetValueDecorator with ColumnSearch::BASIC as value
634 ORowSetValueDecoratorRef const & ODatabaseMetaDataResultSet::getBasicValue()
636 static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(ColumnSearch::BASIC);
637 return aValueRef;
640 ORowSetValueDecoratorRef const & ODatabaseMetaDataResultSet::getSelectValue()
642 static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(u"SELECT"_ustr);
643 return aValueRef;
646 ORowSetValueDecoratorRef const & ODatabaseMetaDataResultSet::getInsertValue()
648 static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(u"INSERT"_ustr);
649 return aValueRef;
652 ORowSetValueDecoratorRef const & ODatabaseMetaDataResultSet::getDeleteValue()
654 static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(u"DELETE"_ustr);
655 return aValueRef;
658 ORowSetValueDecoratorRef const & ODatabaseMetaDataResultSet::getUpdateValue()
660 static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(u"UPDATE"_ustr);
661 return aValueRef;
664 ORowSetValueDecoratorRef const & ODatabaseMetaDataResultSet::getCreateValue()
666 static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(u"CREATE"_ustr);
667 return aValueRef;
670 ORowSetValueDecoratorRef const & ODatabaseMetaDataResultSet::getReadValue()
672 static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(u"READ"_ustr);
673 return aValueRef;
676 ORowSetValueDecoratorRef const & ODatabaseMetaDataResultSet::getAlterValue()
678 static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(u"ALTER"_ustr);
679 return aValueRef;
682 ORowSetValueDecoratorRef const & ODatabaseMetaDataResultSet::getDropValue()
684 static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(u"DROP"_ustr);
685 return aValueRef;
688 ORowSetValueDecoratorRef const & ODatabaseMetaDataResultSet::getQuoteValue()
690 static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(u"'"_ustr);
691 return aValueRef;
694 void SAL_CALL ODatabaseMetaDataResultSet::initialize( const Sequence< Any >& _aArguments )
696 if ( _aArguments.getLength() != 2 )
697 return;
699 sal_Int32 nResultSetType = 0;
700 if ( !(_aArguments[0] >>= nResultSetType))
701 return;
703 setType(static_cast<MetaDataResultSetType>(nResultSetType));
704 Sequence< Sequence<Any> > aRows;
705 if ( !(_aArguments[1] >>= aRows) )
706 return;
708 ORows aRowsToSet;
709 for (auto& row : aRows)
711 ORow aRowToSet;
712 for (auto& field : row)
714 ORowSetValueDecoratorRef aValue;
715 switch (field.getValueTypeClass())
717 case TypeClass_BOOLEAN:
719 bool bValue = false;
720 field >>= bValue;
721 aValue = new ORowSetValueDecorator(ORowSetValue(bValue));
723 break;
724 case TypeClass_BYTE:
726 sal_Int8 nValue(0);
727 field >>= nValue;
728 aValue = new ORowSetValueDecorator(ORowSetValue(nValue));
730 break;
731 case TypeClass_SHORT:
732 case TypeClass_UNSIGNED_SHORT:
734 sal_Int16 nValue(0);
735 field >>= nValue;
736 aValue = new ORowSetValueDecorator(ORowSetValue(nValue));
738 break;
739 case TypeClass_LONG:
740 case TypeClass_UNSIGNED_LONG:
742 sal_Int32 nValue(0);
743 field >>= nValue;
744 aValue = new ORowSetValueDecorator(ORowSetValue(nValue));
746 break;
747 case TypeClass_HYPER:
748 case TypeClass_UNSIGNED_HYPER:
750 sal_Int64 nValue(0);
751 field >>= nValue;
752 aValue = new ORowSetValueDecorator(ORowSetValue(nValue));
754 break;
755 case TypeClass_FLOAT:
757 float nValue(0.0);
758 field >>= nValue;
759 aValue = new ORowSetValueDecorator(ORowSetValue(nValue));
761 break;
762 case TypeClass_DOUBLE:
764 double nValue(0.0);
765 field >>= nValue;
766 aValue = new ORowSetValueDecorator(ORowSetValue(nValue));
768 break;
769 case TypeClass_STRING:
771 OUString sValue;
772 field >>= sValue;
773 aValue = new ORowSetValueDecorator(ORowSetValue(sValue));
775 break;
776 default:
777 break;
779 aRowToSet.push_back(aValue);
781 aRowsToSet.push_back(aRowToSet);
782 } // for (; pRowsIter != pRowsEnd;++pRowsIter
783 setRows(std::move(aRowsToSet));
785 // XServiceInfo
788 OUString SAL_CALL ODatabaseMetaDataResultSet::getImplementationName( )
790 return u"org.openoffice.comp.helper.DatabaseMetaDataResultSet"_ustr;
793 sal_Bool SAL_CALL ODatabaseMetaDataResultSet::supportsService( const OUString& _rServiceName )
795 return cppu::supportsService(this, _rServiceName);
798 Sequence< OUString > SAL_CALL ODatabaseMetaDataResultSet::getSupportedServiceNames( )
800 return Sequence<OUString>{ u"com.sun.star.sdbc.ResultSet"_ustr };
803 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
804 connectivity_dbtools_ODatabaseMetaDataResultSet_get_implementation(
805 css::uno::XComponentContext* , css::uno::Sequence<css::uno::Any> const&)
807 return cppu::acquire(new ODatabaseMetaDataResultSet());
810 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */