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 .
20 #include <comphelper/sequence.hxx>
21 #include <ado/ADatabaseMetaDataResultSet.hxx>
22 #include <ado/ADatabaseMetaDataResultSetMetaData.hxx>
23 #include <com/sun/star/sdbc/DataType.hpp>
24 #include <com/sun/star/sdbc/ColumnValue.hpp>
25 #include <com/sun/star/sdbc/KeyRule.hpp>
26 #include <com/sun/star/sdbc/ProcedureResult.hpp>
27 #include <com/sun/star/sdbc/IndexType.hpp>
28 #include <comphelper/property.hxx>
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 <cppuhelper/typeprovider.hxx>
34 #include <comphelper/seqstream.hxx>
35 #include <connectivity/dbexception.hxx>
40 using namespace dbtools
;
41 using namespace connectivity::ado
;
43 using namespace ::comphelper
;
45 using namespace com::sun::star::uno
;
46 using namespace com::sun::star::lang
;
47 using namespace com::sun::star::beans
;
48 using namespace com::sun::star::sdbc
;
51 ODatabaseMetaDataResultSet::ODatabaseMetaDataResultSet(ADORecordset
* _pRecordSet
)
52 :ODatabaseMetaDataResultSet_BASE(m_aMutex
)
53 ,OPropertySetHelper(ODatabaseMetaDataResultSet_BASE::rBHelper
)
54 ,m_pRecordSet(_pRecordSet
)
55 ,m_aStatement(nullptr)
59 ,m_bOnFirstAfterOpen(false)
61 osl_atomic_increment( &m_refCount
);
62 m_aColMapping
.push_back(-1);
65 m_pRecordSet
->AddRef();
66 VARIANT_BOOL bIsAtBOF
;
67 m_pRecordSet
->get_BOF(&bIsAtBOF
);
68 m_bOnFirstAfterOpen
= bIsAtBOF
!= VARIANT_TRUE
;
71 m_bOnFirstAfterOpen
= false;
72 osl_atomic_decrement( &m_refCount
);
77 ODatabaseMetaDataResultSet::~ODatabaseMetaDataResultSet()
80 m_pRecordSet
->Release();
83 void ODatabaseMetaDataResultSet::disposing()
85 OPropertySetHelper::disposing();
87 ::osl::MutexGuard
aGuard(m_aMutex
);
89 m_pRecordSet
->Close();
90 m_aStatement
= nullptr;
94 Any SAL_CALL
ODatabaseMetaDataResultSet::queryInterface( const Type
& rType
)
96 Any aRet
= OPropertySetHelper::queryInterface(rType
);
97 return aRet
.hasValue() ? aRet
: ODatabaseMetaDataResultSet_BASE::queryInterface(rType
);
100 css::uno::Sequence
< css::uno::Type
> SAL_CALL
ODatabaseMetaDataResultSet::getTypes( )
102 ::cppu::OTypeCollection
aTypes( cppu::UnoType
<css::beans::XMultiPropertySet
>::get(),
103 cppu::UnoType
<css::beans::XFastPropertySet
>::get(),
104 cppu::UnoType
<css::beans::XPropertySet
>::get());
106 return ::comphelper::concatSequences(aTypes
.getTypes(),ODatabaseMetaDataResultSet_BASE::getTypes());
109 void ODatabaseMetaDataResultSet::checkRecordSet()
112 throwFunctionSequenceException(*this);
116 sal_Int32 SAL_CALL
ODatabaseMetaDataResultSet::findColumn( const OUString
& columnName
)
118 ::osl::MutexGuard
aGuard( m_aMutex
);
119 checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper
.bDisposed
);
122 Reference
< XResultSetMetaData
> xMeta
= getMetaData();
123 sal_Int32 nLen
= xMeta
->getColumnCount();
127 if(xMeta
->isCaseSensitive(i
) ? columnName
== xMeta
->getColumnName(i
) :
128 columnName
.equalsIgnoreAsciiCase(xMeta
->getColumnName(i
)))
132 ::dbtools::throwInvalidColumnException( columnName
, *this );
134 return 0; // Never reached
136 #define BLOCK_SIZE 256
138 Reference
< css::io::XInputStream
> SAL_CALL
ODatabaseMetaDataResultSet::getBinaryStream( sal_Int32 columnIndex
)
140 ::osl::MutexGuard
aGuard( m_aMutex
);
141 checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper
.bDisposed
);
146 columnIndex
= mapColumn(columnIndex
);
147 WpADOField aField
= ADOS::getField(m_pRecordSet
,columnIndex
);
148 if((aField
.GetAttributes() & adFldLong
) == adFldLong
)
150 //Copy the data only up to the Actual Size of Field.
151 sal_Int32 nSize
= aField
.GetActualSize();
152 Sequence
<sal_Int8
> aData(nSize
);
156 m_aValue
= aField
.GetChunk(BLOCK_SIZE
);
157 if(m_aValue
.isNull())
160 for(long index2
= 0;index2
< BLOCK_SIZE
;++index2
)
162 HRESULT hr
= ::SafeArrayGetElement(m_aValue
.parray
,&index2
,&chData
);
165 //Take BYTE by BYTE and advance Memory Location
166 aData
.getArray()[index
++] = chData
;
172 return index
? Reference
< css::io::XInputStream
>(new SequenceInputStream(aData
)) : Reference
< css::io::XInputStream
>();
174 // else we ask for a bytesequence
175 aField
.get_Value(m_aValue
);
176 if(m_aValue
.isNull())
178 return new SequenceInputStream(m_aValue
.getByteSequence());
181 Reference
< css::io::XInputStream
> SAL_CALL
ODatabaseMetaDataResultSet::getCharacterStream( sal_Int32
/*columnIndex*/ )
183 ::dbtools::throwFeatureNotImplementedSQLException( "XRow::getCharacterStream", *this );
188 sal_Bool SAL_CALL
ODatabaseMetaDataResultSet::getBoolean( sal_Int32 columnIndex
)
190 ::osl::MutexGuard
aGuard( m_aMutex
);
192 if ( !m_aValueRange
.empty() && columnIndex
== 11 && (m_aValueRangeIter
= m_aValueRange
.find(columnIndex
)) != m_aValueRange
.end() )
195 if ( m_aValue
.getInt16() != adCurrency
)
198 return getValue(columnIndex
).getBool();
202 sal_Int8 SAL_CALL
ODatabaseMetaDataResultSet::getByte( sal_Int32 columnIndex
)
204 ::osl::MutexGuard
aGuard( m_aMutex
);
206 getValue(columnIndex
);
208 columnIndex
= mapColumn(columnIndex
);
210 if(m_aValue
.isNull())
212 if ( !m_aValueRange
.empty() && (m_aValueRangeIter
= m_aValueRange
.find(columnIndex
)) != m_aValueRange
.end())
213 return static_cast<sal_Int8
>((*m_aValueRangeIter
).second
[m_aValue
.getInt32()]);
214 else if(m_aStrValueRange
.size() && (m_aStrValueRangeIter
= m_aStrValueRange
.find(columnIndex
)) != m_aStrValueRange
.end())
215 return static_cast<sal_Int8
>((*m_aStrValueRangeIter
).second
[m_aValue
.getString()]);
217 return m_aValue
.getInt8();
221 Sequence
< sal_Int8
> SAL_CALL
ODatabaseMetaDataResultSet::getBytes( sal_Int32 columnIndex
)
223 return getValue(columnIndex
).getByteSequence();
227 css::util::Date SAL_CALL
ODatabaseMetaDataResultSet::getDate( sal_Int32 columnIndex
)
229 return getValue(columnIndex
).getDate();
233 double SAL_CALL
ODatabaseMetaDataResultSet::getDouble( sal_Int32 columnIndex
)
235 return getValue(columnIndex
).getDouble();
239 float SAL_CALL
ODatabaseMetaDataResultSet::getFloat( sal_Int32 columnIndex
)
241 return getValue(columnIndex
).getFloat();
245 sal_Int32 SAL_CALL
ODatabaseMetaDataResultSet::getInt( sal_Int32 columnIndex
)
247 ::osl::MutexGuard
aGuard( m_aMutex
);
250 getValue(columnIndex
);
252 columnIndex
= mapColumn(columnIndex
);
253 if(m_aValue
.isNull())
256 if(m_aValueRange
.size() && (m_aValueRangeIter
= m_aValueRange
.find(columnIndex
)) != m_aValueRange
.end())
257 return (*m_aValueRangeIter
).second
[m_aValue
.getInt32()];
258 else if(m_aStrValueRange
.size() && (m_aStrValueRangeIter
= m_aStrValueRange
.find(columnIndex
)) != m_aStrValueRange
.end())
259 return (*m_aStrValueRangeIter
).second
[m_aValue
.getString()];
261 return m_aValue
.getInt32();
265 sal_Int32 SAL_CALL
ODatabaseMetaDataResultSet::getRow( )
267 ::dbtools::throwFeatureNotImplementedSQLException( "XResultSet::getRow", *this );
272 sal_Int64 SAL_CALL
ODatabaseMetaDataResultSet::getLong( sal_Int32
/*columnIndex*/ )
274 ::dbtools::throwFeatureNotImplementedSQLException( "XRow::getLong", *this );
279 Reference
< XResultSetMetaData
> SAL_CALL
ODatabaseMetaDataResultSet::getMetaData( )
281 ::osl::MutexGuard
aGuard( m_aMutex
);
282 checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper
.bDisposed
);
287 if(!m_xMetaData
.is())
288 m_xMetaData
= new ODatabaseMetaDataResultSetMetaData(m_pRecordSet
,this);
293 Reference
< XArray
> SAL_CALL
ODatabaseMetaDataResultSet::getArray( sal_Int32
/*columnIndex*/ )
295 ::dbtools::throwFeatureNotImplementedSQLException( "XRow::getRow", *this );
300 Reference
< XClob
> SAL_CALL
ODatabaseMetaDataResultSet::getClob( sal_Int32
/*columnIndex*/ )
302 ::dbtools::throwFeatureNotImplementedSQLException( "XRow::getRow", *this );
306 Reference
< XBlob
> SAL_CALL
ODatabaseMetaDataResultSet::getBlob( sal_Int32
/*columnIndex*/ )
308 ::dbtools::throwFeatureNotImplementedSQLException( "XRow::getRow", *this );
313 Reference
< XRef
> SAL_CALL
ODatabaseMetaDataResultSet::getRef( sal_Int32
/*columnIndex*/ )
315 ::dbtools::throwFeatureNotImplementedSQLException( "XRow::getRow", *this );
320 Any SAL_CALL
ODatabaseMetaDataResultSet::getObject( sal_Int32 columnIndex
, const Reference
< css::container::XNameAccess
>& /*typeMap*/ )
322 ::osl::MutexGuard
aGuard( m_aMutex
);
323 checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper
.bDisposed
);
328 columnIndex
= mapColumn(columnIndex
);
333 sal_Int16 SAL_CALL
ODatabaseMetaDataResultSet::getShort( sal_Int32 columnIndex
)
335 ::osl::MutexGuard
aGuard( m_aMutex
);
337 getValue(columnIndex
);
339 columnIndex
= mapColumn(columnIndex
);
340 if(m_aValue
.isNull())
343 if(m_aValueRange
.size() && (m_aValueRangeIter
= m_aValueRange
.find(columnIndex
)) != m_aValueRange
.end())
344 return static_cast<sal_Int16
>((*m_aValueRangeIter
).second
[m_aValue
.getInt32()]);
345 else if(m_aStrValueRange
.size() && (m_aStrValueRangeIter
= m_aStrValueRange
.find(columnIndex
)) != m_aStrValueRange
.end())
346 return static_cast<sal_Int16
>((*m_aStrValueRangeIter
).second
[m_aValue
.getString()]);
348 return m_aValue
.getInt16();
352 OUString SAL_CALL
ODatabaseMetaDataResultSet::getString( sal_Int32 columnIndex
)
354 ::osl::MutexGuard
aGuard( m_aMutex
);
356 getValue(columnIndex
);
359 columnIndex
= mapColumn(columnIndex
);
360 if(m_aValue
.isNull())
362 if(m_aIntValueRange
.size() && (m_aIntValueRangeIter
= m_aIntValueRange
.find(columnIndex
)) != m_aIntValueRange
.end())
363 return (*m_aIntValueRangeIter
).second
[m_aValue
.getInt32()];
365 return m_aValue
.getString();
369 css::util::Time SAL_CALL
ODatabaseMetaDataResultSet::getTime( sal_Int32 columnIndex
)
371 return getValue(columnIndex
).getTime();
375 css::util::DateTime SAL_CALL
ODatabaseMetaDataResultSet::getTimestamp( sal_Int32 columnIndex
)
377 return getValue(columnIndex
).getDateTime();
381 sal_Bool SAL_CALL
ODatabaseMetaDataResultSet::isAfterLast( )
383 ::osl::MutexGuard
aGuard( m_aMutex
);
384 checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper
.bDisposed
);
389 VARIANT_BOOL bIsAtEOF
;
390 m_pRecordSet
->get_EOF(&bIsAtEOF
);
391 return bIsAtEOF
== VARIANT_TRUE
;
394 sal_Bool SAL_CALL
ODatabaseMetaDataResultSet::isFirst( )
396 ::osl::MutexGuard
aGuard( m_aMutex
);
397 checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper
.bDisposed
);
402 return m_nRowPos
== 1;
405 sal_Bool SAL_CALL
ODatabaseMetaDataResultSet::isLast( )
407 ::osl::MutexGuard
aGuard( m_aMutex
);
408 checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper
.bDisposed
);
416 void SAL_CALL
ODatabaseMetaDataResultSet::beforeFirst( )
418 ::osl::MutexGuard
aGuard( m_aMutex
);
419 checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper
.bDisposed
);
428 void SAL_CALL
ODatabaseMetaDataResultSet::afterLast( )
430 ::osl::MutexGuard
aGuard( m_aMutex
);
431 checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper
.bDisposed
);
442 void SAL_CALL
ODatabaseMetaDataResultSet::close( )
445 ::osl::MutexGuard
aGuard( m_aMutex
);
446 checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper
.bDisposed
);
453 sal_Bool SAL_CALL
ODatabaseMetaDataResultSet::first( )
455 ::osl::MutexGuard
aGuard( m_aMutex
);
456 checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper
.bDisposed
);
462 bool bRet
= SUCCEEDED(m_pRecordSet
->MoveFirst());
469 sal_Bool SAL_CALL
ODatabaseMetaDataResultSet::last( )
471 ::osl::MutexGuard
aGuard( m_aMutex
);
472 checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper
.bDisposed
);
475 return m_pRecordSet
&& SUCCEEDED(m_pRecordSet
->MoveLast());
478 sal_Bool SAL_CALL
ODatabaseMetaDataResultSet::absolute( sal_Int32 row
)
480 ::osl::MutexGuard
aGuard( m_aMutex
);
481 checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper
.bDisposed
);
488 bool bRet
= SUCCEEDED(m_pRecordSet
->Move(row
,aEmpty
));
496 sal_Bool SAL_CALL
ODatabaseMetaDataResultSet::relative( sal_Int32 row
)
498 ::osl::MutexGuard
aGuard( m_aMutex
);
499 checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper
.bDisposed
);
507 bool bRet
= SUCCEEDED(m_pRecordSet
->Move(row
,aEmpty
));
513 sal_Bool SAL_CALL
ODatabaseMetaDataResultSet::previous( )
515 ::osl::MutexGuard
aGuard( m_aMutex
);
516 checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper
.bDisposed
);
522 bool bRet
= SUCCEEDED(m_pRecordSet
->MovePrevious());
528 Reference
< XInterface
> SAL_CALL
ODatabaseMetaDataResultSet::getStatement( )
530 return m_aStatement
.get();
534 sal_Bool SAL_CALL
ODatabaseMetaDataResultSet::rowDeleted( )
536 ::osl::MutexGuard
aGuard( m_aMutex
);
537 checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper
.bDisposed
);
543 m_pRecordSet
->get_Status(&eRec
);
544 return (RecordStatusEnum(eRec
) & adRecDeleted
) == adRecDeleted
;
547 sal_Bool SAL_CALL
ODatabaseMetaDataResultSet::rowInserted( )
548 { ::osl::MutexGuard
aGuard( m_aMutex
);
549 checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper
.bDisposed
);
555 m_pRecordSet
->get_Status(&eRec
);
556 return (RecordStatusEnum(eRec
) & adRecNew
) == adRecNew
;
559 sal_Bool SAL_CALL
ODatabaseMetaDataResultSet::rowUpdated( )
561 ::osl::MutexGuard
aGuard( m_aMutex
);
562 checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper
.bDisposed
);
568 m_pRecordSet
->get_Status(&eRec
);
569 return (RecordStatusEnum(eRec
) & adRecModified
) == adRecModified
;
573 sal_Bool SAL_CALL
ODatabaseMetaDataResultSet::isBeforeFirst( )
575 ::osl::MutexGuard
aGuard( m_aMutex
);
576 checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper
.bDisposed
);
582 VARIANT_BOOL bIsAtBOF
;
583 m_pRecordSet
->get_BOF(&bIsAtBOF
);
584 return bIsAtBOF
== VARIANT_TRUE
;
588 sal_Bool SAL_CALL
ODatabaseMetaDataResultSet::next( )
590 ::osl::MutexGuard
aGuard( m_aMutex
);
591 checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper
.bDisposed
);
597 if(m_bOnFirstAfterOpen
)
599 m_bOnFirstAfterOpen
= false;
603 return SUCCEEDED(m_pRecordSet
->MoveNext());
607 sal_Bool SAL_CALL
ODatabaseMetaDataResultSet::wasNull( )
609 ::osl::MutexGuard
aGuard( m_aMutex
);
610 checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper
.bDisposed
);
615 return m_aValue
.isNull();
618 void SAL_CALL
ODatabaseMetaDataResultSet::refreshRow( )
620 ::osl::MutexGuard
aGuard( m_aMutex
);
621 checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper
.bDisposed
);
626 m_pRecordSet
->Resync(adAffectCurrent
);
630 void SAL_CALL
ODatabaseMetaDataResultSet::cancel( )
632 ::osl::MutexGuard
aGuard( m_aMutex
);
633 checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper
.bDisposed
);
638 m_pRecordSet
->Cancel();
641 void SAL_CALL
ODatabaseMetaDataResultSet::clearWarnings( )
645 Any SAL_CALL
ODatabaseMetaDataResultSet::getWarnings( )
650 sal_Int32
ODatabaseMetaDataResultSet::getResultSetConcurrency()
652 return ResultSetConcurrency::READ_ONLY
;
655 sal_Int32
ODatabaseMetaDataResultSet::getResultSetType()
657 return ResultSetType::FORWARD_ONLY
;
660 sal_Int32
ODatabaseMetaDataResultSet::getFetchDirection()
662 return FetchDirection::FORWARD
;
665 sal_Int32
ODatabaseMetaDataResultSet::getFetchSize() const
669 m_pRecordSet
->get_CacheSize(&nValue
);
673 OUString
ODatabaseMetaDataResultSet::getCursorName()
679 void ODatabaseMetaDataResultSet::setFetchDirection(sal_Int32
/*_par0*/)
681 ::dbtools::throwFeatureNotImplementedSQLException( "ResultSet::FetchDirection", *this );
684 void ODatabaseMetaDataResultSet::setFetchSize(sal_Int32 _par0
)
687 m_pRecordSet
->put_CacheSize(_par0
);
690 ::cppu::IPropertyArrayHelper
* ODatabaseMetaDataResultSet::createArrayHelper( ) const
693 Sequence
< css::beans::Property
> aProps(5);
694 css::beans::Property
* pProperties
= aProps
.getArray();
696 pProperties
[nPos
++] = css::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_CURSORNAME
),
697 PROPERTY_ID_CURSORNAME
, cppu::UnoType
<OUString
>::get(), 0);
698 pProperties
[nPos
++] = css::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FETCHDIRECTION
),
699 PROPERTY_ID_FETCHDIRECTION
, cppu::UnoType
<sal_Int32
>::get(), 0);
700 pProperties
[nPos
++] = css::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FETCHSIZE
),
701 PROPERTY_ID_FETCHSIZE
, cppu::UnoType
<sal_Int32
>::get(), 0);
702 pProperties
[nPos
++] = css::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_RESULTSETCONCURRENCY
),
703 PROPERTY_ID_RESULTSETCONCURRENCY
, cppu::UnoType
<sal_Int32
>::get(), 0);
704 pProperties
[nPos
++] = css::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_RESULTSETTYPE
),
705 PROPERTY_ID_RESULTSETTYPE
, cppu::UnoType
<sal_Int32
>::get(), 0);
707 return new ::cppu::OPropertyArrayHelper(aProps
);
710 ::cppu::IPropertyArrayHelper
& ODatabaseMetaDataResultSet::getInfoHelper()
712 return *getArrayHelper();
715 sal_Bool
ODatabaseMetaDataResultSet::convertFastPropertyValue(
716 Any
& rConvertedValue
,
723 case PROPERTY_ID_CURSORNAME
:
724 case PROPERTY_ID_RESULTSETCONCURRENCY
:
725 case PROPERTY_ID_RESULTSETTYPE
:
726 throw css::lang::IllegalArgumentException();
727 case PROPERTY_ID_FETCHDIRECTION
:
728 return ::comphelper::tryPropertyValue(rConvertedValue
, rOldValue
, rValue
, getFetchDirection());
729 case PROPERTY_ID_FETCHSIZE
:
730 return ::comphelper::tryPropertyValue(rConvertedValue
, rOldValue
, rValue
, getFetchSize());
737 void ODatabaseMetaDataResultSet::setFastPropertyValue_NoBroadcast(
739 const Any
& /*rValue*/
744 case PROPERTY_ID_CURSORNAME
:
745 case PROPERTY_ID_RESULTSETCONCURRENCY
:
746 case PROPERTY_ID_RESULTSETTYPE
:
747 case PROPERTY_ID_FETCHDIRECTION
:
748 case PROPERTY_ID_FETCHSIZE
:
749 throw Exception("cannot set prop " + OUString::number(nHandle
), nullptr);
751 OSL_FAIL("setFastPropertyValue_NoBroadcast: Illegal handle value!");
755 void ODatabaseMetaDataResultSet::getFastPropertyValue(
762 case PROPERTY_ID_CURSORNAME
:
763 rValue
<<= getCursorName();
765 case PROPERTY_ID_RESULTSETCONCURRENCY
:
766 rValue
<<= getResultSetConcurrency();
768 case PROPERTY_ID_RESULTSETTYPE
:
769 rValue
<<= getResultSetType();
771 case PROPERTY_ID_FETCHDIRECTION
:
772 rValue
<<= getFetchDirection();
774 case PROPERTY_ID_FETCHSIZE
:
775 rValue
<<= getFetchSize();
780 void ODatabaseMetaDataResultSet::setProceduresMap()
783 for(sal_Int32 i
=1;i
<4;i
++)
784 m_aColMapping
.push_back(i
);
785 m_aColMapping
.push_back(5);
786 m_aColMapping
.push_back(7);
787 m_aColMapping
.push_back(8);
788 m_aColMapping
.push_back(6);
789 m_aColMapping
.push_back(4);
791 ::std::map
<sal_Int32
,sal_Int32
> aMap
;
792 aMap
[DB_PT_UNKNOWN
] = ProcedureResult::UNKNOWN
;
793 aMap
[DB_PT_PROCEDURE
] = ProcedureResult::NONE
;
794 aMap
[DB_PT_FUNCTION
] = ProcedureResult::RETURN
;
795 m_aValueRange
[4] = aMap
;
797 ODatabaseMetaDataResultSetMetaData
* pMetaData
= new ODatabaseMetaDataResultSetMetaData(m_pRecordSet
,this);
798 pMetaData
->setProceduresMap();
799 m_xMetaData
= pMetaData
;
802 void ODatabaseMetaDataResultSet::setCatalogsMap()
804 m_aColMapping
.push_back(1);
806 m_xMetaData
= new ODatabaseMetaDataResultSetMetaData(m_pRecordSet
,this);
809 void ODatabaseMetaDataResultSet::setSchemasMap()
811 m_aColMapping
.push_back(2);
813 m_xMetaData
= new ODatabaseMetaDataResultSetMetaData(m_pRecordSet
,this);
816 void ODatabaseMetaDataResultSet::setColumnPrivilegesMap()
819 m_aColMapping
.push_back(3);
820 m_aColMapping
.push_back(4);
821 m_aColMapping
.push_back(5);
822 m_aColMapping
.push_back(6);
823 m_aColMapping
.push_back(2);
824 m_aColMapping
.push_back(9);
825 m_aColMapping
.push_back(10);
827 ODatabaseMetaDataResultSetMetaData
* pMetaData
= new ODatabaseMetaDataResultSetMetaData(m_pRecordSet
,this);
828 pMetaData
->setColumnPrivilegesMap();
829 m_xMetaData
= pMetaData
;
832 void ODatabaseMetaDataResultSet::setColumnsMap()
835 for(sal_Int32 i
=1;i
<5;++i
)
836 m_aColMapping
.push_back(i
);
838 m_aColMapping
.push_back(12);
839 m_aColMapping
.push_back(12); // is used as TYPE_NAME
841 m_aColMapping
.push_back(14);
842 m_aColMapping
.push_back(6);
843 m_aColMapping
.push_back(17);
844 m_aColMapping
.push_back(18);
846 m_aColMapping
.push_back(11);
847 m_aColMapping
.push_back(29);
848 m_aColMapping
.push_back(9);
849 m_aColMapping
.push_back(18);
850 m_aColMapping
.push_back(18);
852 m_aColMapping
.push_back(15);
853 m_aColMapping
.push_back(7);
854 m_aColMapping
.push_back(11);
856 ::std::map
<sal_Int32
,sal_Int32
> aMap
;
857 aMap
[adEmpty
] = ADOS::MapADOType2Jdbc(adEmpty
);
858 aMap
[adTinyInt
] = ADOS::MapADOType2Jdbc(adTinyInt
);
859 aMap
[adSmallInt
] = ADOS::MapADOType2Jdbc(adSmallInt
);
860 aMap
[adInteger
] = ADOS::MapADOType2Jdbc(adInteger
);
861 aMap
[adBigInt
] = ADOS::MapADOType2Jdbc(adBigInt
);
862 aMap
[adUnsignedTinyInt
] = ADOS::MapADOType2Jdbc(adUnsignedTinyInt
);
863 aMap
[adUnsignedSmallInt
]= ADOS::MapADOType2Jdbc(adUnsignedSmallInt
);
864 aMap
[adUnsignedInt
] = ADOS::MapADOType2Jdbc(adUnsignedInt
);
865 aMap
[adUnsignedBigInt
] = ADOS::MapADOType2Jdbc(adUnsignedBigInt
);
866 aMap
[adSingle
] = ADOS::MapADOType2Jdbc(adSingle
);
867 aMap
[adDouble
] = ADOS::MapADOType2Jdbc(adDouble
);
868 aMap
[adCurrency
] = ADOS::MapADOType2Jdbc(adCurrency
);
869 aMap
[adDecimal
] = ADOS::MapADOType2Jdbc(adDecimal
);
870 aMap
[adNumeric
] = ADOS::MapADOType2Jdbc(adNumeric
);
871 aMap
[adBoolean
] = ADOS::MapADOType2Jdbc(adBoolean
);
872 aMap
[adError
] = ADOS::MapADOType2Jdbc(adError
);
873 aMap
[adUserDefined
] = ADOS::MapADOType2Jdbc(adUserDefined
);
874 aMap
[adVariant
] = ADOS::MapADOType2Jdbc(adVariant
);
875 aMap
[adIDispatch
] = ADOS::MapADOType2Jdbc(adIDispatch
);
876 aMap
[adIUnknown
] = ADOS::MapADOType2Jdbc(adIUnknown
);
877 aMap
[adGUID
] = ADOS::MapADOType2Jdbc(adGUID
);
878 aMap
[adDate
] = ADOS::MapADOType2Jdbc(adDate
);
879 aMap
[adDBDate
] = ADOS::MapADOType2Jdbc(adDBDate
);
880 aMap
[adDBTime
] = ADOS::MapADOType2Jdbc(adDBTime
);
881 aMap
[adDBTimeStamp
] = ADOS::MapADOType2Jdbc(adDBTimeStamp
);
882 aMap
[adBSTR
] = ADOS::MapADOType2Jdbc(adBSTR
);
883 aMap
[adChar
] = ADOS::MapADOType2Jdbc(adChar
);
884 aMap
[adVarChar
] = ADOS::MapADOType2Jdbc(adVarChar
);
885 aMap
[adLongVarChar
] = ADOS::MapADOType2Jdbc(adLongVarChar
);
886 aMap
[adWChar
] = ADOS::MapADOType2Jdbc(adWChar
);
887 aMap
[adVarWChar
] = ADOS::MapADOType2Jdbc(adVarWChar
);
888 aMap
[adLongVarWChar
] = ADOS::MapADOType2Jdbc(adLongVarWChar
);
889 aMap
[adBinary
] = ADOS::MapADOType2Jdbc(adBinary
);
890 aMap
[adVarBinary
] = ADOS::MapADOType2Jdbc(adVarBinary
);
891 aMap
[adLongVarBinary
] = ADOS::MapADOType2Jdbc(adLongVarBinary
);
892 aMap
[adChapter
] = ADOS::MapADOType2Jdbc(adChapter
);
893 aMap
[adFileTime
] = ADOS::MapADOType2Jdbc(adFileTime
);
894 aMap
[adPropVariant
] = ADOS::MapADOType2Jdbc(adPropVariant
);
895 aMap
[adVarNumeric
] = ADOS::MapADOType2Jdbc(adVarNumeric
);
897 m_aValueRange
[12] = aMap
;
899 std::map
< sal_Int32
,OUString
> aMap2
;
902 m_aIntValueRange
[18] = aMap2
;
904 ODatabaseMetaDataResultSetMetaData
* pMetaData
= new ODatabaseMetaDataResultSetMetaData(m_pRecordSet
,this);
905 pMetaData
->setColumnsMap();
906 m_xMetaData
= pMetaData
;
909 void ODatabaseMetaDataResultSet::setTablesMap()
912 for(sal_Int32 i
=1;i
<5;i
++)
913 m_aColMapping
.push_back(i
);
914 m_aColMapping
.push_back(6);
916 ODatabaseMetaDataResultSetMetaData
* pMetaData
= new ODatabaseMetaDataResultSetMetaData(m_pRecordSet
,this);
917 pMetaData
->setTablesMap();
918 m_xMetaData
= pMetaData
;
921 void ODatabaseMetaDataResultSet::setProcedureColumnsMap()
924 for(sal_Int32 i
=1;i
<5;i
++)
925 m_aColMapping
.push_back(i
);
926 m_aColMapping
.push_back(6);
927 m_aColMapping
.push_back(10);
928 m_aColMapping
.push_back(16);
929 m_aColMapping
.push_back(13);
930 m_aColMapping
.push_back(11);
931 m_aColMapping
.push_back(12);
933 m_aColMapping
.push_back(9);
934 m_aColMapping
.push_back(14);
936 ::std::map
<sal_Int32
,sal_Int32
> aMap
;
937 aMap
[DBTYPE_EMPTY
] = DataType::SQLNULL
;
938 aMap
[DBTYPE_NULL
] = DataType::SQLNULL
;
939 aMap
[DBTYPE_I2
] = DataType::SMALLINT
;
940 aMap
[DBTYPE_I4
] = DataType::INTEGER
;
941 aMap
[DBTYPE_R4
] = DataType::FLOAT
;
942 aMap
[DBTYPE_R8
] = DataType::DOUBLE
;
943 aMap
[DBTYPE_CY
] = DataType::BIGINT
;
944 aMap
[DBTYPE_DATE
] = DataType::DATE
;
945 aMap
[DBTYPE_BSTR
] = DataType::VARCHAR
;
946 aMap
[DBTYPE_IDISPATCH
] = DataType::OBJECT
;
947 aMap
[DBTYPE_ERROR
] = DataType::OTHER
;
948 aMap
[DBTYPE_BOOL
] = DataType::BIT
;
949 aMap
[DBTYPE_VARIANT
] = DataType::STRUCT
;
950 aMap
[DBTYPE_IUNKNOWN
] = DataType::OTHER
;
951 aMap
[DBTYPE_DECIMAL
] = DataType::DECIMAL
;
952 aMap
[DBTYPE_UI1
] = DataType::TINYINT
;
953 aMap
[DBTYPE_ARRAY
] = DataType::ARRAY
;
954 aMap
[DBTYPE_BYREF
] = DataType::REF
;
955 aMap
[DBTYPE_I1
] = DataType::CHAR
;
956 aMap
[DBTYPE_UI2
] = DataType::SMALLINT
;
957 aMap
[DBTYPE_UI4
] = DataType::INTEGER
;
961 aMap
[DBTYPE_I8
] = DataType::BIGINT
;
962 aMap
[DBTYPE_UI8
] = DataType::BIGINT
;
963 aMap
[DBTYPE_GUID
] = DataType::OTHER
;
964 aMap
[DBTYPE_VECTOR
] = DataType::OTHER
;
965 aMap
[DBTYPE_FILETIME
] = DataType::OTHER
;
966 aMap
[DBTYPE_RESERVED
] = DataType::OTHER
;
969 aMap
[DBTYPE_BYTES
] = DataType::VARBINARY
;
970 aMap
[DBTYPE_STR
] = DataType::LONGVARCHAR
;
971 aMap
[DBTYPE_WSTR
] = DataType::LONGVARCHAR
;
972 aMap
[DBTYPE_NUMERIC
] = DataType::NUMERIC
;
973 aMap
[DBTYPE_UDT
] = DataType::OTHER
;
974 aMap
[DBTYPE_DBDATE
] = DataType::DATE
;
975 aMap
[DBTYPE_DBTIME
] = DataType::TIME
;
976 aMap
[DBTYPE_DBTIMESTAMP
] = DataType::TIMESTAMP
;
977 aMap
[DBTYPE_HCHAPTER
] = DataType::OTHER
;
978 aMap
[DBTYPE_PROPVARIANT
] = DataType::OTHER
;
979 aMap
[DBTYPE_VARNUMERIC
] = DataType::NUMERIC
;
981 m_aValueRange
[10] = aMap
;
983 ODatabaseMetaDataResultSetMetaData
* pMetaData
= new ODatabaseMetaDataResultSetMetaData(m_pRecordSet
,this);
984 pMetaData
->setProcedureColumnsMap();
985 m_xMetaData
= pMetaData
;
988 void ODatabaseMetaDataResultSet::setPrimaryKeysMap()
993 m_aColMapping
.push_back(i
);
994 m_aColMapping
.push_back(7);
995 m_aColMapping
.push_back(8);
997 ODatabaseMetaDataResultSetMetaData
* pMetaData
= new ODatabaseMetaDataResultSetMetaData(m_pRecordSet
,this);
998 pMetaData
->setProcedureColumnsMap();
999 m_xMetaData
= pMetaData
;
1002 void ODatabaseMetaDataResultSet::setIndexInfoMap()
1007 m_aColMapping
.push_back(i
);
1008 m_aColMapping
.push_back(8);
1009 m_aColMapping
.push_back(4);
1010 m_aColMapping
.push_back(6);
1011 m_aColMapping
.push_back(10);
1012 m_aColMapping
.push_back(17);
1013 m_aColMapping
.push_back(18);
1014 m_aColMapping
.push_back(21);
1015 m_aColMapping
.push_back(22);
1016 m_aColMapping
.push_back(23);
1017 m_aColMapping
.push_back(24);
1019 ::std::map
<sal_Int32
,sal_Int32
> aMap
;
1020 aMap
[DBPROPVAL_IT_HASH
] = IndexType::HASHED
;
1021 aMap
[DBPROPVAL_IT_CONTENT
] = IndexType::OTHER
;
1022 aMap
[DBPROPVAL_IT_OTHER
] = IndexType::OTHER
;
1023 aMap
[DBPROPVAL_IT_BTREE
] = IndexType::OTHER
;
1025 m_aValueRange
[10] = aMap
;
1027 ::std::map
<sal_Int32
,sal_Int32
> aMap2
;
1030 m_aValueRange
[8] = aMap2
;
1032 std::map
< sal_Int32
,OUString
> aMap3
;
1034 aMap3
[DB_COLLATION_ASC
] = "A";
1035 aMap3
[DB_COLLATION_DESC
] = "D";
1037 m_aIntValueRange
[21] = aMap3
;
1039 ODatabaseMetaDataResultSetMetaData
* pMetaData
= new ODatabaseMetaDataResultSetMetaData(m_pRecordSet
,this);
1040 pMetaData
->setIndexInfoMap();
1041 m_xMetaData
= pMetaData
;
1044 void ODatabaseMetaDataResultSet::setTablePrivilegesMap()
1049 m_aColMapping
.push_back(i
);
1050 m_aColMapping
.push_back(1);
1051 m_aColMapping
.push_back(2);
1052 m_aColMapping
.push_back(6);
1053 m_aColMapping
.push_back(7);
1055 std::map
< sal_Int32
,OUString
> aMap
;
1058 m_aIntValueRange
[7] = aMap
;
1061 ODatabaseMetaDataResultSetMetaData
* pMetaData
= new ODatabaseMetaDataResultSetMetaData(m_pRecordSet
,this);
1062 pMetaData
->setTablePrivilegesMap();
1063 m_xMetaData
= pMetaData
;
1066 void ODatabaseMetaDataResultSet::setCrossReferenceMap()
1071 m_aColMapping
.push_back(i
);
1073 m_aColMapping
.push_back(i
);
1075 m_aColMapping
.push_back(13);
1076 m_aColMapping
.push_back(14);
1077 m_aColMapping
.push_back(15);
1078 m_aColMapping
.push_back(17);
1079 m_aColMapping
.push_back(16);
1080 m_aColMapping
.push_back(18);
1082 std::map
< OUString
,sal_Int32
> aMap
;
1083 aMap
[ OUString("CASCADE")] = KeyRule::CASCADE
;
1084 aMap
[ OUString("RESTRICT")] = KeyRule::RESTRICT
;
1085 aMap
[ OUString("SET NULL")] = KeyRule::SET_NULL
;
1086 aMap
[ OUString("SET DEFAULT")] = KeyRule::SET_DEFAULT
;
1087 aMap
[ OUString("NO ACTION")] = KeyRule::NO_ACTION
;
1089 m_aStrValueRange
[14] = aMap
;
1090 m_aStrValueRange
[15] = aMap
;
1092 ODatabaseMetaDataResultSetMetaData
* pMetaData
= new ODatabaseMetaDataResultSetMetaData(m_pRecordSet
,this);
1093 pMetaData
->setCrossReferenceMap();
1094 m_xMetaData
= pMetaData
;
1097 void ODatabaseMetaDataResultSet::setTypeInfoMap(bool _bJetEngine
)
1101 m_aColMapping
.push_back(i
);
1103 std::map
< OUString
,sal_Int32
> aMap1
;
1104 aMap1
[ OUString()] = 10;
1106 m_aStrValueRange
[18] = aMap1
;
1108 ::std::map
<sal_Int32
,sal_Int32
> aMap
;
1109 aMap
[adEmpty
] = ADOS::MapADOType2Jdbc(adEmpty
);
1110 aMap
[adTinyInt
] = ADOS::MapADOType2Jdbc(adTinyInt
);
1111 aMap
[adSmallInt
] = ADOS::MapADOType2Jdbc(adSmallInt
);
1112 aMap
[adInteger
] = ADOS::MapADOType2Jdbc(adInteger
);
1113 aMap
[adBigInt
] = ADOS::MapADOType2Jdbc(adBigInt
);
1114 aMap
[adUnsignedTinyInt
] = ADOS::MapADOType2Jdbc(adUnsignedTinyInt
);
1115 aMap
[adUnsignedSmallInt
]= ADOS::MapADOType2Jdbc(adUnsignedSmallInt
);
1116 aMap
[adUnsignedInt
] = ADOS::MapADOType2Jdbc(adUnsignedInt
);
1117 aMap
[adUnsignedBigInt
] = ADOS::MapADOType2Jdbc(adUnsignedBigInt
);
1118 aMap
[adSingle
] = ADOS::MapADOType2Jdbc(adSingle
);
1119 aMap
[adDouble
] = ADOS::MapADOType2Jdbc(adDouble
);
1120 aMap
[adCurrency
] = ADOS::MapADOType2Jdbc(adCurrency
);
1121 aMap
[adDecimal
] = ADOS::MapADOType2Jdbc(adDecimal
);
1122 aMap
[adNumeric
] = ADOS::MapADOType2Jdbc(adNumeric
);
1123 aMap
[adBoolean
] = ADOS::MapADOType2Jdbc(adBoolean
);
1124 aMap
[adError
] = ADOS::MapADOType2Jdbc(adError
);
1125 aMap
[adUserDefined
] = ADOS::MapADOType2Jdbc(adUserDefined
);
1126 aMap
[adVariant
] = ADOS::MapADOType2Jdbc(adVariant
);
1127 aMap
[adIDispatch
] = ADOS::MapADOType2Jdbc(adIDispatch
);
1128 aMap
[adIUnknown
] = ADOS::MapADOType2Jdbc(adIUnknown
);
1129 aMap
[adGUID
] = ADOS::MapADOType2Jdbc(adGUID
);
1130 aMap
[adDate
] = _bJetEngine
? ADOS::MapADOType2Jdbc(adDBTimeStamp
) : ADOS::MapADOType2Jdbc(adDate
);
1131 aMap
[adDBDate
] = ADOS::MapADOType2Jdbc(adDBDate
);
1132 aMap
[adDBTime
] = ADOS::MapADOType2Jdbc(adDBTime
);
1133 aMap
[adDBTimeStamp
] = ADOS::MapADOType2Jdbc(adDBTimeStamp
);
1134 aMap
[adBSTR
] = ADOS::MapADOType2Jdbc(adBSTR
);
1135 aMap
[adChar
] = ADOS::MapADOType2Jdbc(adChar
);
1136 aMap
[adVarChar
] = ADOS::MapADOType2Jdbc(adVarChar
);
1137 aMap
[adLongVarChar
] = ADOS::MapADOType2Jdbc(adLongVarChar
);
1138 aMap
[adWChar
] = ADOS::MapADOType2Jdbc(adWChar
);
1139 aMap
[adVarWChar
] = ADOS::MapADOType2Jdbc(adVarWChar
);
1140 aMap
[adLongVarWChar
] = ADOS::MapADOType2Jdbc(adLongVarWChar
);
1141 aMap
[adBinary
] = ADOS::MapADOType2Jdbc(adBinary
);
1142 aMap
[adVarBinary
] = ADOS::MapADOType2Jdbc(adVarBinary
);
1143 aMap
[adLongVarBinary
] = ADOS::MapADOType2Jdbc(adLongVarBinary
);
1144 aMap
[adChapter
] = ADOS::MapADOType2Jdbc(adChapter
);
1145 aMap
[adFileTime
] = ADOS::MapADOType2Jdbc(adFileTime
);
1146 aMap
[adPropVariant
] = ADOS::MapADOType2Jdbc(adPropVariant
);
1147 aMap
[adVarNumeric
] = ADOS::MapADOType2Jdbc(adVarNumeric
);
1148 // aMap[adArray] = ADOS::MapADOType2Jdbc(adArray);
1150 m_aValueRange
[2] = aMap
;
1152 ::std::map
<sal_Int32
,sal_Int32
> aColumnValueMapping
;
1153 aColumnValueMapping
[VARIANT_FALSE
] = ColumnValue::NO_NULLS
;
1154 aColumnValueMapping
[VARIANT_TRUE
] = ColumnValue::NULLABLE
;
1155 m_aValueRange
[7] = aColumnValueMapping
;
1157 // now adjust the column mapping
1158 // OJ 24.01.2002 96860
1159 ::std::map
<sal_Int32
,sal_Int32
> aSerachMapping
;
1160 aSerachMapping
[DB_UNSEARCHABLE
] = ColumnSearch::NONE
;
1161 aSerachMapping
[DB_LIKE_ONLY
] = ColumnSearch::CHAR
;
1162 aSerachMapping
[DB_ALL_EXCEPT_LIKE
] = ColumnSearch::BASIC
;
1163 aSerachMapping
[DB_SEARCHABLE
] = ColumnSearch::FULL
;
1165 m_aValueRange
[9] = aSerachMapping
;
1167 ::std::map
<sal_Int32
,sal_Int32
> aCurrencyMapping
;
1168 m_aValueRange
[11] = aCurrencyMapping
;
1170 ODatabaseMetaDataResultSetMetaData
* pMetaData
= new ODatabaseMetaDataResultSetMetaData(m_pRecordSet
,this);
1171 pMetaData
->setTypeInfoMap();
1172 m_xMetaData
= pMetaData
;
1175 void SAL_CALL
ODatabaseMetaDataResultSet::acquire() throw()
1177 ODatabaseMetaDataResultSet_BASE::acquire();
1180 void SAL_CALL
ODatabaseMetaDataResultSet::release() throw()
1182 ODatabaseMetaDataResultSet_BASE::release();
1185 css::uno::Reference
< css::beans::XPropertySetInfo
> SAL_CALL
ODatabaseMetaDataResultSet::getPropertySetInfo( )
1187 return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
1190 OLEVariant
ODatabaseMetaDataResultSet::getValue(sal_Int32 columnIndex
)
1192 ::osl::MutexGuard
aGuard( m_aMutex
);
1193 checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper
.bDisposed
);
1197 WpADOField aField
= ADOS::getField(m_pRecordSet
,columnIndex
);
1198 aField
.get_Value(m_aValue
);
1203 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */