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/DataType.hpp>
25 #include <com/sun/star/sdbc/ColumnSearch.hpp>
26 #include <com/sun/star/sdbc/KeyRule.hpp>
27 #include <com/sun/star/sdbc/ProcedureResult.hpp>
28 #include <com/sun/star/sdbc/IndexType.hpp>
29 #include <com/sun/star/lang/DisposedException.hpp>
30 #include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
31 #include <com/sun/star/sdbc/ResultSetType.hpp>
32 #include <com/sun/star/sdbc/FetchDirection.hpp>
33 #include <com/sun/star/beans/PropertyAttribute.hpp>
34 #include <cppuhelper/typeprovider.hxx>
35 #include <comphelper/sequence.hxx>
36 #include <cppuhelper/factory.hxx>
37 #include <cppuhelper/implementationentry.hxx>
38 #include <cppuhelper/supportsservice.hxx>
39 #include <connectivity/dbexception.hxx>
40 #include <strings.hrc>
41 #include <TConnection.hxx>
43 using namespace connectivity
;
44 using namespace dbtools
;
47 using namespace ::com::sun::star::beans
;
48 using namespace ::com::sun::star::uno
;
49 using namespace ::com::sun::star::sdbcx
;
50 using namespace ::com::sun::star::sdbc
;
51 using namespace ::com::sun::star::container
;
52 using namespace ::com::sun::star::lang
;
54 ODatabaseMetaDataResultSet::ODatabaseMetaDataResultSet()
55 :ODatabaseMetaDataResultSet_BASE(m_aMutex
)
56 ,::comphelper::OPropertyContainer(ODatabaseMetaDataResultSet_BASE::rBHelper
)
57 ,m_aStatement(nullptr)
66 ODatabaseMetaDataResultSet::ODatabaseMetaDataResultSet( MetaDataResultSetType _eType
)
67 :ODatabaseMetaDataResultSet_BASE(m_aMutex
)
68 ,::comphelper::OPropertyContainer(ODatabaseMetaDataResultSet_BASE::rBHelper
)
69 ,m_aStatement(nullptr)
80 ODatabaseMetaDataResultSet::~ODatabaseMetaDataResultSet()
84 void ODatabaseMetaDataResultSet::construct()
86 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FETCHSIZE
), PROPERTY_ID_FETCHSIZE
, 0,&m_nFetchSize
, ::cppu::UnoType
<sal_Int32
>::get());
87 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_RESULTSETTYPE
), PROPERTY_ID_RESULTSETTYPE
, PropertyAttribute::READONLY
,&m_nResultSetType
, ::cppu::UnoType
<sal_Int32
>::get());
88 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FETCHDIRECTION
), PROPERTY_ID_FETCHDIRECTION
, 0, &m_nFetchDirection
, ::cppu::UnoType
<sal_Int32
>::get());
89 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_RESULTSETCONCURRENCY
), PROPERTY_ID_RESULTSETCONCURRENCY
, PropertyAttribute::READONLY
,&m_nResultSetConcurrency
, ::cppu::UnoType
<sal_Int32
>::get());
92 void ODatabaseMetaDataResultSet::setType(MetaDataResultSetType _eType
)
96 case eCatalogs
: setCatalogsMap(); break;
97 case eSchemas
: setSchemasMap(); break;
98 case eColumnPrivileges
: setColumnPrivilegesMap(); break;
99 case eColumns
: setColumnsMap(); break;
100 case eTables
: setTablesMap(); break;
101 case eTableTypes
: setTableTypes(); break;
102 case eProcedureColumns
: setProcedureColumnsMap(); break;
103 case eProcedures
: setProceduresMap(); break;
104 case eExportedKeys
: setExportedKeysMap(); break;
105 case eImportedKeys
: setImportedKeysMap(); break;
106 case ePrimaryKeys
: setPrimaryKeysMap(); break;
107 case eIndexInfo
: setIndexInfoMap(); break;
108 case eTablePrivileges
: setTablePrivilegesMap(); break;
109 case eCrossReference
: setCrossReferenceMap(); break;
110 case eTypeInfo
: setTypeInfoMap(); break;
111 case eBestRowIdentifier
: setBestRowIdentifierMap(); break;
112 case eVersionColumns
: setVersionColumnsMap(); break;
113 case eUDTs
: setUDTsMap(); break;
115 OSL_FAIL("Wrong type!");
119 void ODatabaseMetaDataResultSet::disposing()
121 OPropertySetHelper::disposing();
123 ::osl::MutexGuard
aGuard(m_aMutex
);
124 m_aStatement
= nullptr;
126 m_aRowsIter
= m_aRows
.end();
128 m_aRowsIter
= m_aRows
.end();
131 void SAL_CALL
ODatabaseMetaDataResultSet::acquire() throw()
133 ODatabaseMetaDataResultSet_BASE::acquire();
136 void SAL_CALL
ODatabaseMetaDataResultSet::release() throw()
138 ODatabaseMetaDataResultSet_BASE::release();
141 Any SAL_CALL
ODatabaseMetaDataResultSet::queryInterface( const Type
& rType
)
143 Any aRet
= OPropertySetHelper::queryInterface(rType
);
144 return aRet
.hasValue() ? aRet
: ODatabaseMetaDataResultSet_BASE::queryInterface(rType
);
147 Sequence
< Type
> SAL_CALL
ODatabaseMetaDataResultSet::getTypes( )
149 ::cppu::OTypeCollection
aTypes( cppu::UnoType
<css::beans::XMultiPropertySet
>::get(),
150 cppu::UnoType
<css::beans::XFastPropertySet
>::get(),
151 cppu::UnoType
<css::beans::XPropertySet
>::get());
153 return ::comphelper::concatSequences(aTypes
.getTypes(),ODatabaseMetaDataResultSet_BASE::getTypes());
156 void ODatabaseMetaDataResultSet::setRows(const ORows
& _rRows
)
160 m_bEOF
= m_aRows
.empty();
163 sal_Int32 SAL_CALL
ODatabaseMetaDataResultSet::findColumn( const OUString
& columnName
)
165 ::osl::MutexGuard
aGuard( m_aMutex
);
166 checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper
.bDisposed
);
169 Reference
< XResultSetMetaData
> xMeta
= getMetaData();
170 sal_Int32 nLen
= xMeta
->getColumnCount();
174 if(xMeta
->isCaseSensitive(i
) ? columnName
== xMeta
->getColumnName(i
) :
175 columnName
.equalsIgnoreAsciiCase(xMeta
->getColumnName(i
))
180 ::dbtools::throwInvalidColumnException( columnName
, *this );
181 #if !(defined(_MSC_VER) && defined(ENABLE_LTO))
183 return 0; // Never reached
187 void ODatabaseMetaDataResultSet::checkIndex(sal_Int32 columnIndex
)
189 if(columnIndex
>= static_cast<sal_Int32
>((*m_aRowsIter
).size()) || columnIndex
< 1)
190 ::dbtools::throwInvalidIndexException(*this);
193 Reference
< css::io::XInputStream
> SAL_CALL
ODatabaseMetaDataResultSet::getBinaryStream( sal_Int32
/*columnIndex*/ )
198 Reference
< css::io::XInputStream
> SAL_CALL
ODatabaseMetaDataResultSet::getCharacterStream( sal_Int32
/*columnIndex*/ )
204 sal_Bool SAL_CALL
ODatabaseMetaDataResultSet::getBoolean( sal_Int32 columnIndex
)
206 return bool(getValue(columnIndex
));
210 sal_Int8 SAL_CALL
ODatabaseMetaDataResultSet::getByte( sal_Int32 columnIndex
)
212 return getValue(columnIndex
);
216 Sequence
< sal_Int8
> SAL_CALL
ODatabaseMetaDataResultSet::getBytes( sal_Int32 columnIndex
)
218 return getValue(columnIndex
);
222 css::util::Date SAL_CALL
ODatabaseMetaDataResultSet::getDate( sal_Int32 columnIndex
)
224 return getValue(columnIndex
);
228 double SAL_CALL
ODatabaseMetaDataResultSet::getDouble( sal_Int32 columnIndex
)
230 return getValue(columnIndex
);
234 float SAL_CALL
ODatabaseMetaDataResultSet::getFloat( sal_Int32 columnIndex
)
236 return getValue(columnIndex
);
240 sal_Int32 SAL_CALL
ODatabaseMetaDataResultSet::getInt( sal_Int32 columnIndex
)
242 return getValue(columnIndex
);
246 sal_Int32 SAL_CALL
ODatabaseMetaDataResultSet::getRow( )
252 sal_Int64 SAL_CALL
ODatabaseMetaDataResultSet::getLong( sal_Int32 columnIndex
)
254 return getValue(columnIndex
);
258 Reference
< XResultSetMetaData
> SAL_CALL
ODatabaseMetaDataResultSet::getMetaData( )
260 ::osl::MutexGuard
aGuard( m_aMutex
);
261 checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper
.bDisposed
);
264 if(!m_xMetaData
.is())
265 m_xMetaData
= new ODatabaseMetaDataResultSetMetaData();
270 Reference
< XArray
> SAL_CALL
ODatabaseMetaDataResultSet::getArray( sal_Int32
/*columnIndex*/ )
276 Reference
< XClob
> SAL_CALL
ODatabaseMetaDataResultSet::getClob( sal_Int32
/*columnIndex*/ )
281 Reference
< XBlob
> SAL_CALL
ODatabaseMetaDataResultSet::getBlob( sal_Int32
/*columnIndex*/ )
287 Reference
< XRef
> SAL_CALL
ODatabaseMetaDataResultSet::getRef( sal_Int32
/*columnIndex*/ )
293 Any SAL_CALL
ODatabaseMetaDataResultSet::getObject( sal_Int32 columnIndex
, const Reference
< css::container::XNameAccess
>& /*typeMap*/ )
295 return getValue(columnIndex
).makeAny();
299 sal_Int16 SAL_CALL
ODatabaseMetaDataResultSet::getShort( sal_Int32 columnIndex
)
301 return getValue(columnIndex
);
305 OUString SAL_CALL
ODatabaseMetaDataResultSet::getString( sal_Int32 columnIndex
)
307 return getValue(columnIndex
);
311 css::util::Time SAL_CALL
ODatabaseMetaDataResultSet::getTime( sal_Int32 columnIndex
)
313 return getValue(columnIndex
);
317 css::util::DateTime SAL_CALL
ODatabaseMetaDataResultSet::getTimestamp( sal_Int32 columnIndex
)
319 return getValue(columnIndex
);
323 sal_Bool SAL_CALL
ODatabaseMetaDataResultSet::isAfterLast( )
329 SAL_WNOUNREACHABLE_CODE_PUSH
331 sal_Bool SAL_CALL
ODatabaseMetaDataResultSet::isFirst( )
333 ::dbtools::throwFunctionSequenceException(*this);
337 sal_Bool SAL_CALL
ODatabaseMetaDataResultSet::isLast( )
339 ::dbtools::throwFunctionSequenceException(*this);
343 SAL_WNOUNREACHABLE_CODE_POP
346 void SAL_CALL
ODatabaseMetaDataResultSet::beforeFirst( )
348 ::dbtools::throwFunctionSequenceException(*this);
351 void SAL_CALL
ODatabaseMetaDataResultSet::afterLast( )
353 ::dbtools::throwFunctionSequenceException(*this);
357 void SAL_CALL
ODatabaseMetaDataResultSet::close( )
360 ::osl::MutexGuard
aGuard( m_aMutex
);
361 checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper
.bDisposed
);
368 SAL_WNOUNREACHABLE_CODE_PUSH
370 sal_Bool SAL_CALL
ODatabaseMetaDataResultSet::first( )
372 ::dbtools::throwFunctionSequenceException(*this);
377 sal_Bool SAL_CALL
ODatabaseMetaDataResultSet::last( )
379 ::dbtools::throwFunctionSequenceException(*this);
383 sal_Bool SAL_CALL
ODatabaseMetaDataResultSet::absolute( sal_Int32
/*row*/ )
385 ::dbtools::throwFunctionSequenceException(*this);
389 sal_Bool SAL_CALL
ODatabaseMetaDataResultSet::relative( sal_Int32
/*row*/ )
391 ::dbtools::throwFunctionSequenceException(*this);
395 sal_Bool SAL_CALL
ODatabaseMetaDataResultSet::previous( )
397 ::dbtools::throwFunctionSequenceException(*this);
401 SAL_WNOUNREACHABLE_CODE_POP
404 Reference
< XInterface
> SAL_CALL
ODatabaseMetaDataResultSet::getStatement( )
406 return m_aStatement
.get();
410 SAL_WNOUNREACHABLE_CODE_PUSH
412 sal_Bool SAL_CALL
ODatabaseMetaDataResultSet::rowDeleted( )
414 ::dbtools::throwFunctionSequenceException(*this);
418 sal_Bool SAL_CALL
ODatabaseMetaDataResultSet::rowInserted( )
420 ::dbtools::throwFunctionSequenceException(*this);
424 sal_Bool SAL_CALL
ODatabaseMetaDataResultSet::rowUpdated( )
426 ::dbtools::throwFunctionSequenceException(*this);
430 SAL_WNOUNREACHABLE_CODE_POP
433 sal_Bool SAL_CALL
ODatabaseMetaDataResultSet::isBeforeFirst( )
439 sal_Bool SAL_CALL
ODatabaseMetaDataResultSet::next( )
441 ::osl::MutexGuard
aGuard( m_aMutex
);
442 checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper
.bDisposed
);
446 m_aRowsIter
= m_aRows
.begin();
452 throwFunctionSequenceException( *this );
454 if ( m_aRowsIter
!= m_aRows
.end() )
458 bool bSuccess
= m_aRowsIter
!= m_aRows
.end();
462 m_bBOF
= m_aRows
.empty();
468 sal_Bool SAL_CALL
ODatabaseMetaDataResultSet::wasNull( )
470 ::osl::MutexGuard
aGuard( m_aMutex
);
471 checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper
.bDisposed
);
474 if(m_aRowsIter
== m_aRows
.end() || !(*m_aRowsIter
)[m_nColPos
].is())
477 return (*m_aRowsIter
)[m_nColPos
]->getValue().isNull();
480 void SAL_CALL
ODatabaseMetaDataResultSet::refreshRow( )
485 void SAL_CALL
ODatabaseMetaDataResultSet::cancel( )
489 void SAL_CALL
ODatabaseMetaDataResultSet::clearWarnings( )
493 Any SAL_CALL
ODatabaseMetaDataResultSet::getWarnings( )
498 ::cppu::IPropertyArrayHelper
* ODatabaseMetaDataResultSet::createArrayHelper( ) const
500 Sequence
< Property
> aProps
;
501 describeProperties(aProps
);
502 return new ::cppu::OPropertyArrayHelper(aProps
);
505 ::cppu::IPropertyArrayHelper
& ODatabaseMetaDataResultSet::getInfoHelper()
507 return *getArrayHelper();
510 void ODatabaseMetaDataResultSet::setProceduresMap()
512 ODatabaseMetaDataResultSetMetaData
* pMetaData
= new ODatabaseMetaDataResultSetMetaData();
513 pMetaData
->setProceduresMap();
514 m_xMetaData
= pMetaData
;
517 void ODatabaseMetaDataResultSet::setCatalogsMap()
519 ODatabaseMetaDataResultSetMetaData
* pMetaData
= new ODatabaseMetaDataResultSetMetaData();
520 pMetaData
->setCatalogsMap();
521 m_xMetaData
= pMetaData
;
524 void ODatabaseMetaDataResultSet::setSchemasMap()
526 ODatabaseMetaDataResultSetMetaData
* pMetaData
= new ODatabaseMetaDataResultSetMetaData();
527 pMetaData
->setSchemasMap();
528 m_xMetaData
= pMetaData
;
531 void ODatabaseMetaDataResultSet::setColumnPrivilegesMap()
533 ODatabaseMetaDataResultSetMetaData
* pMetaData
= new ODatabaseMetaDataResultSetMetaData();
534 pMetaData
->setColumnPrivilegesMap();
535 m_xMetaData
= pMetaData
;
538 void ODatabaseMetaDataResultSet::setColumnsMap()
541 ODatabaseMetaDataResultSetMetaData
* pMetaData
= new ODatabaseMetaDataResultSetMetaData();
542 pMetaData
->setColumnsMap();
543 m_xMetaData
= pMetaData
;
546 void ODatabaseMetaDataResultSet::setTablesMap()
549 ODatabaseMetaDataResultSetMetaData
* pMetaData
= new ODatabaseMetaDataResultSetMetaData();
550 pMetaData
->setTablesMap();
551 m_xMetaData
= pMetaData
;
554 void ODatabaseMetaDataResultSet::setProcedureColumnsMap()
556 ODatabaseMetaDataResultSetMetaData
* pMetaData
= new ODatabaseMetaDataResultSetMetaData();
557 pMetaData
->setProcedureColumnsMap();
558 m_xMetaData
= pMetaData
;
561 void ODatabaseMetaDataResultSet::setPrimaryKeysMap()
563 ODatabaseMetaDataResultSetMetaData
* pMetaData
= new ODatabaseMetaDataResultSetMetaData();
564 pMetaData
->setPrimaryKeysMap();
565 m_xMetaData
= pMetaData
;
568 void ODatabaseMetaDataResultSet::setIndexInfoMap()
570 ODatabaseMetaDataResultSetMetaData
* pMetaData
= new ODatabaseMetaDataResultSetMetaData();
571 pMetaData
->setIndexInfoMap();
572 m_xMetaData
= pMetaData
;
575 void ODatabaseMetaDataResultSet::setTablePrivilegesMap()
577 ODatabaseMetaDataResultSetMetaData
* pMetaData
= new ODatabaseMetaDataResultSetMetaData();
578 pMetaData
->setTablePrivilegesMap();
579 m_xMetaData
= pMetaData
;
582 void ODatabaseMetaDataResultSet::setCrossReferenceMap()
584 ODatabaseMetaDataResultSetMetaData
* pMetaData
= new ODatabaseMetaDataResultSetMetaData();
585 pMetaData
->setCrossReferenceMap();
586 m_xMetaData
= pMetaData
;
589 void ODatabaseMetaDataResultSet::setVersionColumnsMap()
591 ODatabaseMetaDataResultSetMetaData
* pMetaData
= new ODatabaseMetaDataResultSetMetaData();
592 pMetaData
->setVersionColumnsMap();
593 m_xMetaData
= pMetaData
;
596 void ODatabaseMetaDataResultSet::setBestRowIdentifierMap()
598 ODatabaseMetaDataResultSetMetaData
* pMetaData
= new ODatabaseMetaDataResultSetMetaData();
599 pMetaData
->setBestRowIdentifierMap();
600 m_xMetaData
= pMetaData
;
603 void ODatabaseMetaDataResultSet::setTypeInfoMap()
605 ODatabaseMetaDataResultSetMetaData
* pMetaData
= new ODatabaseMetaDataResultSetMetaData();
606 pMetaData
->setTypeInfoMap();
607 m_xMetaData
= pMetaData
;
610 void ODatabaseMetaDataResultSet::setUDTsMap()
612 ODatabaseMetaDataResultSetMetaData
* pMetaData
= new ODatabaseMetaDataResultSetMetaData();
613 pMetaData
->setUDTsMap();
614 m_xMetaData
= pMetaData
;
617 void ODatabaseMetaDataResultSet::setTableTypes()
619 ODatabaseMetaDataResultSetMetaData
* pMetaData
= new ODatabaseMetaDataResultSetMetaData();
620 pMetaData
->setTableTypes();
621 m_xMetaData
= pMetaData
;
624 void ODatabaseMetaDataResultSet::setExportedKeysMap()
626 ODatabaseMetaDataResultSetMetaData
* pMetaData
= new ODatabaseMetaDataResultSetMetaData();
627 pMetaData
->setExportedKeysMap();
628 m_xMetaData
= pMetaData
;
631 void ODatabaseMetaDataResultSet::setImportedKeysMap()
633 ODatabaseMetaDataResultSetMetaData
* pMetaData
= new ODatabaseMetaDataResultSetMetaData();
634 pMetaData
->setImportedKeysMap();
635 m_xMetaData
= pMetaData
;
638 Reference
< css::beans::XPropertySetInfo
> SAL_CALL
ODatabaseMetaDataResultSet::getPropertySetInfo( )
640 return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
643 ORowSetValueDecorator
& ORowSetValueDecorator::operator=(const ORowSetValue
& _aValue
)
649 const ORowSetValue
& ODatabaseMetaDataResultSet::getValue(sal_Int32 columnIndex
)
651 ::osl::MutexGuard
aGuard( m_aMutex
);
652 checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper
.bDisposed
);
654 if ( isBeforeFirst() || isAfterLast() )
655 ::dbtools::throwFunctionSequenceException( *this );
657 checkIndex(columnIndex
);
658 m_nColPos
= columnIndex
;
660 if(m_aRowsIter
!= m_aRows
.end() && (*m_aRowsIter
)[columnIndex
].is())
661 return *(*m_aRowsIter
)[columnIndex
];
662 return m_aEmptyValue
;
665 /// return an empty ORowSetValueDecorator
666 ORowSetValueDecoratorRef
const & ODatabaseMetaDataResultSet::getEmptyValue()
668 static ORowSetValueDecoratorRef aEmptyValueRef
= new ORowSetValueDecorator();
669 return aEmptyValueRef
;
672 /// return an ORowSetValueDecorator with 0 as value
673 ORowSetValueDecoratorRef
const & ODatabaseMetaDataResultSet::get0Value()
675 static ORowSetValueDecoratorRef a0ValueRef
= new ORowSetValueDecorator(sal_Int32(0));
679 /// return an ORowSetValueDecorator with 1 as value
680 ORowSetValueDecoratorRef
const & ODatabaseMetaDataResultSet::get1Value()
682 static ORowSetValueDecoratorRef a1ValueRef
= new ORowSetValueDecorator(sal_Int32(1));
686 /// return an ORowSetValueDecorator with ColumnSearch::BASIC as value
687 ORowSetValueDecoratorRef
const & ODatabaseMetaDataResultSet::getBasicValue()
689 static ORowSetValueDecoratorRef aValueRef
= new ORowSetValueDecorator(ColumnSearch::BASIC
);
693 ORowSetValueDecoratorRef
const & ODatabaseMetaDataResultSet::getSelectValue()
695 static ORowSetValueDecoratorRef aValueRef
= new ORowSetValueDecorator(OUString("SELECT"));
699 ORowSetValueDecoratorRef
const & ODatabaseMetaDataResultSet::getInsertValue()
701 static ORowSetValueDecoratorRef aValueRef
= new ORowSetValueDecorator(OUString("INSERT"));
705 ORowSetValueDecoratorRef
const & ODatabaseMetaDataResultSet::getDeleteValue()
707 static ORowSetValueDecoratorRef aValueRef
= new ORowSetValueDecorator(OUString("DELETE"));
711 ORowSetValueDecoratorRef
const & ODatabaseMetaDataResultSet::getUpdateValue()
713 static ORowSetValueDecoratorRef aValueRef
= new ORowSetValueDecorator(OUString("UPDATE"));
717 ORowSetValueDecoratorRef
const & ODatabaseMetaDataResultSet::getCreateValue()
719 static ORowSetValueDecoratorRef aValueRef
= new ORowSetValueDecorator(OUString("CREATE"));
723 ORowSetValueDecoratorRef
const & ODatabaseMetaDataResultSet::getReadValue()
725 static ORowSetValueDecoratorRef aValueRef
= new ORowSetValueDecorator(OUString("READ"));
729 ORowSetValueDecoratorRef
const & ODatabaseMetaDataResultSet::getAlterValue()
731 static ORowSetValueDecoratorRef aValueRef
= new ORowSetValueDecorator(OUString("ALTER"));
735 ORowSetValueDecoratorRef
const & ODatabaseMetaDataResultSet::getDropValue()
737 static ORowSetValueDecoratorRef aValueRef
= new ORowSetValueDecorator(OUString("DROP"));
741 ORowSetValueDecoratorRef
const & ODatabaseMetaDataResultSet::getQuoteValue()
743 static ORowSetValueDecoratorRef aValueRef
= new ORowSetValueDecorator(OUString("'"));
747 void SAL_CALL
ODatabaseMetaDataResultSet::initialize( const Sequence
< Any
>& _aArguments
)
749 if ( _aArguments
.getLength() == 2 )
751 sal_Int32 nResultSetType
= 0;
752 if ( _aArguments
[0] >>= nResultSetType
)
754 setType(static_cast<MetaDataResultSetType
>(nResultSetType
));
755 Sequence
< Sequence
<Any
> > aRows
;
756 if ( _aArguments
[1] >>= aRows
)
759 const Sequence
<Any
>* pRowsIter
= aRows
.getConstArray();
760 const Sequence
<Any
>* pRowsEnd
= pRowsIter
+ aRows
.getLength();
761 for (; pRowsIter
!= pRowsEnd
;++pRowsIter
)
764 const Any
* pRowIter
= pRowsIter
->getConstArray();
765 const Any
* pRowEnd
= pRowIter
+ pRowsIter
->getLength();
766 for (; pRowIter
!= pRowEnd
;++pRowIter
)
768 ORowSetValueDecoratorRef aValue
;
769 switch( pRowIter
->getValueTypeClass() )
771 case TypeClass_BOOLEAN
:
774 *pRowIter
>>= bValue
;
775 aValue
= new ORowSetValueDecorator(ORowSetValue(bValue
));
781 *pRowIter
>>= nValue
;
782 aValue
= new ORowSetValueDecorator(ORowSetValue(nValue
));
785 case TypeClass_SHORT
:
786 case TypeClass_UNSIGNED_SHORT
:
789 *pRowIter
>>= nValue
;
790 aValue
= new ORowSetValueDecorator(ORowSetValue(nValue
));
794 case TypeClass_UNSIGNED_LONG
:
797 *pRowIter
>>= nValue
;
798 aValue
= new ORowSetValueDecorator(ORowSetValue(nValue
));
801 case TypeClass_HYPER
:
802 case TypeClass_UNSIGNED_HYPER
:
805 *pRowIter
>>= nValue
;
806 aValue
= new ORowSetValueDecorator(ORowSetValue(nValue
));
809 case TypeClass_FLOAT
:
812 *pRowIter
>>= nValue
;
813 aValue
= new ORowSetValueDecorator(ORowSetValue(nValue
));
816 case TypeClass_DOUBLE
:
819 *pRowIter
>>= nValue
;
820 aValue
= new ORowSetValueDecorator(ORowSetValue(nValue
));
823 case TypeClass_STRING
:
826 *pRowIter
>>= sValue
;
827 aValue
= new ORowSetValueDecorator(ORowSetValue(sValue
));
833 aRowToSet
.push_back(aValue
);
835 aRowsToSet
.push_back(aRowToSet
);
836 } // for (; pRowsIter != pRowsEnd;++pRowsIter
845 OUString
ODatabaseMetaDataResultSet::getImplementationName_Static( )
847 return OUString("org.openoffice.comp.helper.DatabaseMetaDataResultSet");
850 Sequence
< OUString
> ODatabaseMetaDataResultSet::getSupportedServiceNames_Static( )
852 Sequence
<OUString
> aSNS
{ "com.sun.star.sdbc.ResultSet" };
856 OUString SAL_CALL
ODatabaseMetaDataResultSet::getImplementationName( )
858 return getImplementationName_Static();
861 sal_Bool SAL_CALL
ODatabaseMetaDataResultSet::supportsService( const OUString
& _rServiceName
)
863 return cppu::supportsService(this, _rServiceName
);
866 Sequence
< OUString
> SAL_CALL
ODatabaseMetaDataResultSet::getSupportedServiceNames( )
868 return getSupportedServiceNames_Static();
871 namespace connectivity
873 /// @throws Exception
874 static Reference
< XInterface
> ODatabaseMetaDataResultSet_CreateInstance(const Reference
< XComponentContext
>& )
876 return *(new ODatabaseMetaDataResultSet());
883 cppu::ImplementationEntry
const entries
[] = {
884 { &ODatabaseMetaDataResultSet_CreateInstance
, &ODatabaseMetaDataResultSet::getImplementationName_Static
, &ODatabaseMetaDataResultSet::getSupportedServiceNames_Static
,
885 &cppu::createSingleComponentFactory
, nullptr, 0 },
886 { &ParameterSubstitution::create
, &ParameterSubstitution::getImplementationName_Static
, &ParameterSubstitution::getSupportedServiceNames_Static
,
887 &cppu::createSingleComponentFactory
, nullptr, 0 },
888 { nullptr, nullptr, nullptr, nullptr, nullptr, 0 }
896 SAL_DLLPUBLIC_EXPORT
void* dbtools_component_getFactory(const sal_Char
* implName
, void* serviceManager
, void* registryKey
)
898 return cppu::component_getFactoryHelper(implName
, serviceManager
, registryKey
, entries
);
903 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */