1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/unreachable.hxx>
31 #include <TConnection.hxx>
33 using namespace connectivity
;
34 using namespace dbtools
;
37 using namespace ::com::sun::star::beans
;
38 using namespace ::com::sun::star::uno
;
39 using namespace ::com::sun::star::sdbcx
;
40 using namespace ::com::sun::star::sdbc
;
41 using namespace ::com::sun::star::container
;
42 using namespace ::com::sun::star::lang
;
44 ODatabaseMetaDataResultSet::ODatabaseMetaDataResultSet()
45 :ODatabaseMetaDataResultSet_BASE(m_aMutex
)
46 ,::comphelper::OPropertyContainer(ODatabaseMetaDataResultSet_BASE::rBHelper
)
47 ,m_aStatement(nullptr)
56 ODatabaseMetaDataResultSet::ODatabaseMetaDataResultSet( MetaDataResultSetType _eType
)
57 :ODatabaseMetaDataResultSet_BASE(m_aMutex
)
58 ,::comphelper::OPropertyContainer(ODatabaseMetaDataResultSet_BASE::rBHelper
)
59 ,m_aStatement(nullptr)
70 ODatabaseMetaDataResultSet::~ODatabaseMetaDataResultSet()
74 void ODatabaseMetaDataResultSet::construct()
76 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FETCHSIZE
), PROPERTY_ID_FETCHSIZE
, 0,&m_nFetchSize
, ::cppu::UnoType
<sal_Int32
>::get());
77 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_RESULTSETTYPE
), PROPERTY_ID_RESULTSETTYPE
, PropertyAttribute::READONLY
,&m_nResultSetType
, ::cppu::UnoType
<sal_Int32
>::get());
78 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FETCHDIRECTION
), PROPERTY_ID_FETCHDIRECTION
, 0, &m_nFetchDirection
, ::cppu::UnoType
<sal_Int32
>::get());
79 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_RESULTSETCONCURRENCY
), PROPERTY_ID_RESULTSETCONCURRENCY
, PropertyAttribute::READONLY
,&m_nResultSetConcurrency
, ::cppu::UnoType
<sal_Int32
>::get());
82 void ODatabaseMetaDataResultSet::setType(MetaDataResultSetType _eType
)
86 case eCatalogs
: setCatalogsMap(); break;
87 case eSchemas
: setSchemasMap(); break;
88 case eColumnPrivileges
: setColumnPrivilegesMap(); break;
89 case eColumns
: setColumnsMap(); break;
90 case eTables
: setTablesMap(); break;
91 case eTableTypes
: setTableTypes(); break;
92 case eProcedureColumns
: setProcedureColumnsMap(); break;
93 case eProcedures
: setProceduresMap(); break;
94 case eExportedKeys
: setExportedKeysMap(); break;
95 case eImportedKeys
: setImportedKeysMap(); break;
96 case ePrimaryKeys
: setPrimaryKeysMap(); break;
97 case eIndexInfo
: setIndexInfoMap(); break;
98 case eTablePrivileges
: setTablePrivilegesMap(); break;
99 case eCrossReference
: setCrossReferenceMap(); break;
100 case eTypeInfo
: setTypeInfoMap(); break;
101 case eBestRowIdentifier
: setBestRowIdentifierMap(); break;
102 case eVersionColumns
: setVersionColumnsMap(); break;
103 case eUDTs
: setUDTsMap(); break;
105 OSL_FAIL("Wrong type!");
109 void ODatabaseMetaDataResultSet::disposing()
111 OPropertySetHelper::disposing();
113 ::osl::MutexGuard
aGuard(m_aMutex
);
114 m_aStatement
= nullptr;
116 m_aRowsIter
= m_aRows
.end();
118 m_aRowsIter
= m_aRows
.end();
121 void SAL_CALL
ODatabaseMetaDataResultSet::acquire() throw()
123 ODatabaseMetaDataResultSet_BASE::acquire();
126 void SAL_CALL
ODatabaseMetaDataResultSet::release() throw()
128 ODatabaseMetaDataResultSet_BASE::release();
131 Any SAL_CALL
ODatabaseMetaDataResultSet::queryInterface( const Type
& rType
)
133 Any aRet
= OPropertySetHelper::queryInterface(rType
);
134 return aRet
.hasValue() ? aRet
: ODatabaseMetaDataResultSet_BASE::queryInterface(rType
);
137 Sequence
< Type
> SAL_CALL
ODatabaseMetaDataResultSet::getTypes( )
139 ::cppu::OTypeCollection
aTypes( cppu::UnoType
<css::beans::XMultiPropertySet
>::get(),
140 cppu::UnoType
<css::beans::XFastPropertySet
>::get(),
141 cppu::UnoType
<css::beans::XPropertySet
>::get());
143 return ::comphelper::concatSequences(aTypes
.getTypes(),ODatabaseMetaDataResultSet_BASE::getTypes());
146 void ODatabaseMetaDataResultSet::setRows(const ORows
& _rRows
)
150 m_bEOF
= m_aRows
.empty();
153 sal_Int32 SAL_CALL
ODatabaseMetaDataResultSet::findColumn( const OUString
& columnName
)
155 ::osl::MutexGuard
aGuard( m_aMutex
);
156 checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper
.bDisposed
);
159 Reference
< XResultSetMetaData
> xMeta
= getMetaData();
160 sal_Int32 nLen
= xMeta
->getColumnCount();
164 if(xMeta
->isCaseSensitive(i
) ? columnName
== xMeta
->getColumnName(i
) :
165 columnName
.equalsIgnoreAsciiCase(xMeta
->getColumnName(i
))
170 ::dbtools::throwInvalidColumnException( columnName
, *this );
174 void ODatabaseMetaDataResultSet::checkIndex(sal_Int32 columnIndex
)
176 if(columnIndex
>= static_cast<sal_Int32
>((*m_aRowsIter
).size()) || columnIndex
< 1)
177 ::dbtools::throwInvalidIndexException(*this);
180 Reference
< css::io::XInputStream
> SAL_CALL
ODatabaseMetaDataResultSet::getBinaryStream( sal_Int32
/*columnIndex*/ )
185 Reference
< css::io::XInputStream
> SAL_CALL
ODatabaseMetaDataResultSet::getCharacterStream( sal_Int32
/*columnIndex*/ )
191 sal_Bool SAL_CALL
ODatabaseMetaDataResultSet::getBoolean( sal_Int32 columnIndex
)
193 return bool(getValue(columnIndex
));
197 sal_Int8 SAL_CALL
ODatabaseMetaDataResultSet::getByte( sal_Int32 columnIndex
)
199 return getValue(columnIndex
);
203 Sequence
< sal_Int8
> SAL_CALL
ODatabaseMetaDataResultSet::getBytes( sal_Int32 columnIndex
)
205 return getValue(columnIndex
);
209 css::util::Date SAL_CALL
ODatabaseMetaDataResultSet::getDate( sal_Int32 columnIndex
)
211 return getValue(columnIndex
);
215 double SAL_CALL
ODatabaseMetaDataResultSet::getDouble( sal_Int32 columnIndex
)
217 return getValue(columnIndex
);
221 float SAL_CALL
ODatabaseMetaDataResultSet::getFloat( sal_Int32 columnIndex
)
223 return getValue(columnIndex
);
227 sal_Int32 SAL_CALL
ODatabaseMetaDataResultSet::getInt( sal_Int32 columnIndex
)
229 return getValue(columnIndex
);
233 sal_Int32 SAL_CALL
ODatabaseMetaDataResultSet::getRow( )
239 sal_Int64 SAL_CALL
ODatabaseMetaDataResultSet::getLong( sal_Int32 columnIndex
)
241 return getValue(columnIndex
);
245 Reference
< XResultSetMetaData
> SAL_CALL
ODatabaseMetaDataResultSet::getMetaData( )
247 ::osl::MutexGuard
aGuard( m_aMutex
);
248 checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper
.bDisposed
);
251 if(!m_xMetaData
.is())
252 m_xMetaData
= new ODatabaseMetaDataResultSetMetaData();
257 Reference
< XArray
> SAL_CALL
ODatabaseMetaDataResultSet::getArray( sal_Int32
/*columnIndex*/ )
263 Reference
< XClob
> SAL_CALL
ODatabaseMetaDataResultSet::getClob( sal_Int32
/*columnIndex*/ )
268 Reference
< XBlob
> SAL_CALL
ODatabaseMetaDataResultSet::getBlob( sal_Int32
/*columnIndex*/ )
274 Reference
< XRef
> SAL_CALL
ODatabaseMetaDataResultSet::getRef( sal_Int32
/*columnIndex*/ )
280 Any SAL_CALL
ODatabaseMetaDataResultSet::getObject( sal_Int32 columnIndex
, const Reference
< css::container::XNameAccess
>& /*typeMap*/ )
282 return getValue(columnIndex
).makeAny();
286 sal_Int16 SAL_CALL
ODatabaseMetaDataResultSet::getShort( sal_Int32 columnIndex
)
288 return getValue(columnIndex
);
292 OUString SAL_CALL
ODatabaseMetaDataResultSet::getString( sal_Int32 columnIndex
)
294 return getValue(columnIndex
);
298 css::util::Time SAL_CALL
ODatabaseMetaDataResultSet::getTime( sal_Int32 columnIndex
)
300 return getValue(columnIndex
);
304 css::util::DateTime SAL_CALL
ODatabaseMetaDataResultSet::getTimestamp( sal_Int32 columnIndex
)
306 return getValue(columnIndex
);
310 sal_Bool SAL_CALL
ODatabaseMetaDataResultSet::isAfterLast( )
316 SAL_WNOUNREACHABLE_CODE_PUSH
318 sal_Bool SAL_CALL
ODatabaseMetaDataResultSet::isFirst( )
320 ::dbtools::throwFunctionSequenceException(*this);
324 sal_Bool SAL_CALL
ODatabaseMetaDataResultSet::isLast( )
326 ::dbtools::throwFunctionSequenceException(*this);
330 SAL_WNOUNREACHABLE_CODE_POP
333 void SAL_CALL
ODatabaseMetaDataResultSet::beforeFirst( )
335 ::dbtools::throwFunctionSequenceException(*this);
338 void SAL_CALL
ODatabaseMetaDataResultSet::afterLast( )
340 ::dbtools::throwFunctionSequenceException(*this);
344 void SAL_CALL
ODatabaseMetaDataResultSet::close( )
347 ::osl::MutexGuard
aGuard( m_aMutex
);
348 checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper
.bDisposed
);
355 SAL_WNOUNREACHABLE_CODE_PUSH
357 sal_Bool SAL_CALL
ODatabaseMetaDataResultSet::first( )
359 ::dbtools::throwFunctionSequenceException(*this);
364 sal_Bool SAL_CALL
ODatabaseMetaDataResultSet::last( )
366 ::dbtools::throwFunctionSequenceException(*this);
370 sal_Bool SAL_CALL
ODatabaseMetaDataResultSet::absolute( sal_Int32
/*row*/ )
372 ::dbtools::throwFunctionSequenceException(*this);
376 sal_Bool SAL_CALL
ODatabaseMetaDataResultSet::relative( sal_Int32
/*row*/ )
378 ::dbtools::throwFunctionSequenceException(*this);
382 sal_Bool SAL_CALL
ODatabaseMetaDataResultSet::previous( )
384 ::dbtools::throwFunctionSequenceException(*this);
388 SAL_WNOUNREACHABLE_CODE_POP
391 Reference
< XInterface
> SAL_CALL
ODatabaseMetaDataResultSet::getStatement( )
393 return m_aStatement
.get();
397 SAL_WNOUNREACHABLE_CODE_PUSH
399 sal_Bool SAL_CALL
ODatabaseMetaDataResultSet::rowDeleted( )
401 ::dbtools::throwFunctionSequenceException(*this);
405 sal_Bool SAL_CALL
ODatabaseMetaDataResultSet::rowInserted( )
407 ::dbtools::throwFunctionSequenceException(*this);
411 sal_Bool SAL_CALL
ODatabaseMetaDataResultSet::rowUpdated( )
413 ::dbtools::throwFunctionSequenceException(*this);
417 SAL_WNOUNREACHABLE_CODE_POP
420 sal_Bool SAL_CALL
ODatabaseMetaDataResultSet::isBeforeFirst( )
426 sal_Bool SAL_CALL
ODatabaseMetaDataResultSet::next( )
428 ::osl::MutexGuard
aGuard( m_aMutex
);
429 checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper
.bDisposed
);
433 m_aRowsIter
= m_aRows
.begin();
439 throwFunctionSequenceException( *this );
441 if ( m_aRowsIter
!= m_aRows
.end() )
445 bool bSuccess
= m_aRowsIter
!= m_aRows
.end();
449 m_bBOF
= m_aRows
.empty();
455 sal_Bool SAL_CALL
ODatabaseMetaDataResultSet::wasNull( )
457 ::osl::MutexGuard
aGuard( m_aMutex
);
458 checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper
.bDisposed
);
461 if(m_aRowsIter
== m_aRows
.end() || !(*m_aRowsIter
)[m_nColPos
].is())
464 return (*m_aRowsIter
)[m_nColPos
]->getValue().isNull();
467 void SAL_CALL
ODatabaseMetaDataResultSet::refreshRow( )
472 void SAL_CALL
ODatabaseMetaDataResultSet::cancel( )
476 void SAL_CALL
ODatabaseMetaDataResultSet::clearWarnings( )
480 Any SAL_CALL
ODatabaseMetaDataResultSet::getWarnings( )
485 ::cppu::IPropertyArrayHelper
* ODatabaseMetaDataResultSet::createArrayHelper( ) const
487 Sequence
< Property
> aProps
;
488 describeProperties(aProps
);
489 return new ::cppu::OPropertyArrayHelper(aProps
);
492 ::cppu::IPropertyArrayHelper
& ODatabaseMetaDataResultSet::getInfoHelper()
494 return *getArrayHelper();
497 void ODatabaseMetaDataResultSet::setProceduresMap()
499 ODatabaseMetaDataResultSetMetaData
* pMetaData
= new ODatabaseMetaDataResultSetMetaData();
500 pMetaData
->setProceduresMap();
501 m_xMetaData
= pMetaData
;
504 void ODatabaseMetaDataResultSet::setCatalogsMap()
506 ODatabaseMetaDataResultSetMetaData
* pMetaData
= new ODatabaseMetaDataResultSetMetaData();
507 pMetaData
->setCatalogsMap();
508 m_xMetaData
= pMetaData
;
511 void ODatabaseMetaDataResultSet::setSchemasMap()
513 ODatabaseMetaDataResultSetMetaData
* pMetaData
= new ODatabaseMetaDataResultSetMetaData();
514 pMetaData
->setSchemasMap();
515 m_xMetaData
= pMetaData
;
518 void ODatabaseMetaDataResultSet::setColumnPrivilegesMap()
520 ODatabaseMetaDataResultSetMetaData
* pMetaData
= new ODatabaseMetaDataResultSetMetaData();
521 pMetaData
->setColumnPrivilegesMap();
522 m_xMetaData
= pMetaData
;
525 void ODatabaseMetaDataResultSet::setColumnsMap()
528 ODatabaseMetaDataResultSetMetaData
* pMetaData
= new ODatabaseMetaDataResultSetMetaData();
529 pMetaData
->setColumnsMap();
530 m_xMetaData
= pMetaData
;
533 void ODatabaseMetaDataResultSet::setTablesMap()
536 ODatabaseMetaDataResultSetMetaData
* pMetaData
= new ODatabaseMetaDataResultSetMetaData();
537 pMetaData
->setTablesMap();
538 m_xMetaData
= pMetaData
;
541 void ODatabaseMetaDataResultSet::setProcedureColumnsMap()
543 ODatabaseMetaDataResultSetMetaData
* pMetaData
= new ODatabaseMetaDataResultSetMetaData();
544 pMetaData
->setProcedureColumnsMap();
545 m_xMetaData
= pMetaData
;
548 void ODatabaseMetaDataResultSet::setPrimaryKeysMap()
550 ODatabaseMetaDataResultSetMetaData
* pMetaData
= new ODatabaseMetaDataResultSetMetaData();
551 pMetaData
->setPrimaryKeysMap();
552 m_xMetaData
= pMetaData
;
555 void ODatabaseMetaDataResultSet::setIndexInfoMap()
557 ODatabaseMetaDataResultSetMetaData
* pMetaData
= new ODatabaseMetaDataResultSetMetaData();
558 pMetaData
->setIndexInfoMap();
559 m_xMetaData
= pMetaData
;
562 void ODatabaseMetaDataResultSet::setTablePrivilegesMap()
564 ODatabaseMetaDataResultSetMetaData
* pMetaData
= new ODatabaseMetaDataResultSetMetaData();
565 pMetaData
->setTablePrivilegesMap();
566 m_xMetaData
= pMetaData
;
569 void ODatabaseMetaDataResultSet::setCrossReferenceMap()
571 ODatabaseMetaDataResultSetMetaData
* pMetaData
= new ODatabaseMetaDataResultSetMetaData();
572 pMetaData
->setCrossReferenceMap();
573 m_xMetaData
= pMetaData
;
576 void ODatabaseMetaDataResultSet::setVersionColumnsMap()
578 ODatabaseMetaDataResultSetMetaData
* pMetaData
= new ODatabaseMetaDataResultSetMetaData();
579 pMetaData
->setVersionColumnsMap();
580 m_xMetaData
= pMetaData
;
583 void ODatabaseMetaDataResultSet::setBestRowIdentifierMap()
585 ODatabaseMetaDataResultSetMetaData
* pMetaData
= new ODatabaseMetaDataResultSetMetaData();
586 pMetaData
->setBestRowIdentifierMap();
587 m_xMetaData
= pMetaData
;
590 void ODatabaseMetaDataResultSet::setTypeInfoMap()
592 ODatabaseMetaDataResultSetMetaData
* pMetaData
= new ODatabaseMetaDataResultSetMetaData();
593 pMetaData
->setTypeInfoMap();
594 m_xMetaData
= pMetaData
;
597 void ODatabaseMetaDataResultSet::setUDTsMap()
599 ODatabaseMetaDataResultSetMetaData
* pMetaData
= new ODatabaseMetaDataResultSetMetaData();
600 pMetaData
->setUDTsMap();
601 m_xMetaData
= pMetaData
;
604 void ODatabaseMetaDataResultSet::setTableTypes()
606 ODatabaseMetaDataResultSetMetaData
* pMetaData
= new ODatabaseMetaDataResultSetMetaData();
607 pMetaData
->setTableTypes();
608 m_xMetaData
= pMetaData
;
611 void ODatabaseMetaDataResultSet::setExportedKeysMap()
613 ODatabaseMetaDataResultSetMetaData
* pMetaData
= new ODatabaseMetaDataResultSetMetaData();
614 pMetaData
->setExportedKeysMap();
615 m_xMetaData
= pMetaData
;
618 void ODatabaseMetaDataResultSet::setImportedKeysMap()
620 ODatabaseMetaDataResultSetMetaData
* pMetaData
= new ODatabaseMetaDataResultSetMetaData();
621 pMetaData
->setImportedKeysMap();
622 m_xMetaData
= pMetaData
;
625 Reference
< css::beans::XPropertySetInfo
> SAL_CALL
ODatabaseMetaDataResultSet::getPropertySetInfo( )
627 return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
630 ORowSetValueDecorator
& ORowSetValueDecorator::operator=(const ORowSetValue
& _aValue
)
636 const ORowSetValue
& ODatabaseMetaDataResultSet::getValue(sal_Int32 columnIndex
)
638 ::osl::MutexGuard
aGuard( m_aMutex
);
639 checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper
.bDisposed
);
641 if ( isBeforeFirst() || isAfterLast() )
642 ::dbtools::throwFunctionSequenceException( *this );
644 checkIndex(columnIndex
);
645 m_nColPos
= columnIndex
;
647 if(m_aRowsIter
!= m_aRows
.end() && (*m_aRowsIter
)[columnIndex
].is())
648 return *(*m_aRowsIter
)[columnIndex
];
649 return m_aEmptyValue
;
652 /// return an empty ORowSetValueDecorator
653 ORowSetValueDecoratorRef
const & ODatabaseMetaDataResultSet::getEmptyValue()
655 static ORowSetValueDecoratorRef aEmptyValueRef
= new ORowSetValueDecorator();
656 return aEmptyValueRef
;
659 /// return an ORowSetValueDecorator with 0 as value
660 ORowSetValueDecoratorRef
const & ODatabaseMetaDataResultSet::get0Value()
662 static ORowSetValueDecoratorRef a0ValueRef
= new ORowSetValueDecorator(sal_Int32(0));
666 /// return an ORowSetValueDecorator with 1 as value
667 ORowSetValueDecoratorRef
const & ODatabaseMetaDataResultSet::get1Value()
669 static ORowSetValueDecoratorRef a1ValueRef
= new ORowSetValueDecorator(sal_Int32(1));
673 /// return an ORowSetValueDecorator with ColumnSearch::BASIC as value
674 ORowSetValueDecoratorRef
const & ODatabaseMetaDataResultSet::getBasicValue()
676 static ORowSetValueDecoratorRef aValueRef
= new ORowSetValueDecorator(ColumnSearch::BASIC
);
680 ORowSetValueDecoratorRef
const & ODatabaseMetaDataResultSet::getSelectValue()
682 static ORowSetValueDecoratorRef aValueRef
= new ORowSetValueDecorator(OUString("SELECT"));
686 ORowSetValueDecoratorRef
const & ODatabaseMetaDataResultSet::getInsertValue()
688 static ORowSetValueDecoratorRef aValueRef
= new ORowSetValueDecorator(OUString("INSERT"));
692 ORowSetValueDecoratorRef
const & ODatabaseMetaDataResultSet::getDeleteValue()
694 static ORowSetValueDecoratorRef aValueRef
= new ORowSetValueDecorator(OUString("DELETE"));
698 ORowSetValueDecoratorRef
const & ODatabaseMetaDataResultSet::getUpdateValue()
700 static ORowSetValueDecoratorRef aValueRef
= new ORowSetValueDecorator(OUString("UPDATE"));
704 ORowSetValueDecoratorRef
const & ODatabaseMetaDataResultSet::getCreateValue()
706 static ORowSetValueDecoratorRef aValueRef
= new ORowSetValueDecorator(OUString("CREATE"));
710 ORowSetValueDecoratorRef
const & ODatabaseMetaDataResultSet::getReadValue()
712 static ORowSetValueDecoratorRef aValueRef
= new ORowSetValueDecorator(OUString("READ"));
716 ORowSetValueDecoratorRef
const & ODatabaseMetaDataResultSet::getAlterValue()
718 static ORowSetValueDecoratorRef aValueRef
= new ORowSetValueDecorator(OUString("ALTER"));
722 ORowSetValueDecoratorRef
const & ODatabaseMetaDataResultSet::getDropValue()
724 static ORowSetValueDecoratorRef aValueRef
= new ORowSetValueDecorator(OUString("DROP"));
728 ORowSetValueDecoratorRef
const & ODatabaseMetaDataResultSet::getQuoteValue()
730 static ORowSetValueDecoratorRef aValueRef
= new ORowSetValueDecorator(OUString("'"));
734 void SAL_CALL
ODatabaseMetaDataResultSet::initialize( const Sequence
< Any
>& _aArguments
)
736 if ( _aArguments
.getLength() != 2 )
739 sal_Int32 nResultSetType
= 0;
740 if ( !(_aArguments
[0] >>= nResultSetType
))
743 setType(static_cast<MetaDataResultSetType
>(nResultSetType
));
744 Sequence
< Sequence
<Any
> > aRows
;
745 if ( !(_aArguments
[1] >>= aRows
) )
749 const Sequence
<Any
>* pRowsIter
= aRows
.getConstArray();
750 const Sequence
<Any
>* pRowsEnd
= pRowsIter
+ aRows
.getLength();
751 for (; pRowsIter
!= pRowsEnd
;++pRowsIter
)
754 const Any
* pRowIter
= pRowsIter
->getConstArray();
755 const Any
* pRowEnd
= pRowIter
+ pRowsIter
->getLength();
756 for (; pRowIter
!= pRowEnd
;++pRowIter
)
758 ORowSetValueDecoratorRef aValue
;
759 switch( pRowIter
->getValueTypeClass() )
761 case TypeClass_BOOLEAN
:
764 *pRowIter
>>= bValue
;
765 aValue
= new ORowSetValueDecorator(ORowSetValue(bValue
));
771 *pRowIter
>>= nValue
;
772 aValue
= new ORowSetValueDecorator(ORowSetValue(nValue
));
775 case TypeClass_SHORT
:
776 case TypeClass_UNSIGNED_SHORT
:
779 *pRowIter
>>= nValue
;
780 aValue
= new ORowSetValueDecorator(ORowSetValue(nValue
));
784 case TypeClass_UNSIGNED_LONG
:
787 *pRowIter
>>= nValue
;
788 aValue
= new ORowSetValueDecorator(ORowSetValue(nValue
));
791 case TypeClass_HYPER
:
792 case TypeClass_UNSIGNED_HYPER
:
795 *pRowIter
>>= nValue
;
796 aValue
= new ORowSetValueDecorator(ORowSetValue(nValue
));
799 case TypeClass_FLOAT
:
802 *pRowIter
>>= nValue
;
803 aValue
= new ORowSetValueDecorator(ORowSetValue(nValue
));
806 case TypeClass_DOUBLE
:
809 *pRowIter
>>= nValue
;
810 aValue
= new ORowSetValueDecorator(ORowSetValue(nValue
));
813 case TypeClass_STRING
:
816 *pRowIter
>>= sValue
;
817 aValue
= new ORowSetValueDecorator(ORowSetValue(sValue
));
823 aRowToSet
.push_back(aValue
);
825 aRowsToSet
.push_back(aRowToSet
);
826 } // for (; pRowsIter != pRowsEnd;++pRowsIter
832 OUString SAL_CALL
ODatabaseMetaDataResultSet::getImplementationName( )
834 return "org.openoffice.comp.helper.DatabaseMetaDataResultSet";
837 sal_Bool SAL_CALL
ODatabaseMetaDataResultSet::supportsService( const OUString
& _rServiceName
)
839 return cppu::supportsService(this, _rServiceName
);
842 Sequence
< OUString
> SAL_CALL
ODatabaseMetaDataResultSet::getSupportedServiceNames( )
844 return Sequence
<OUString
>{ "com.sun.star.sdbc.ResultSet" };
847 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
848 connectivity_dbtools_ODatabaseMetaDataResultSet_get_implementation(
849 css::uno::XComponentContext
* , css::uno::Sequence
<css::uno::Any
> const&)
851 return cppu::acquire(new ODatabaseMetaDataResultSet());
854 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */