1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_connectivity.hxx" 30*cdf0e10cSrcweir #include <comphelper/sequence.hxx> 31*cdf0e10cSrcweir #include "ado/ADatabaseMetaDataResultSet.hxx" 32*cdf0e10cSrcweir #include "ado/ADatabaseMetaDataResultSetMetaData.hxx" 33*cdf0e10cSrcweir #include <com/sun/star/sdbc/DataType.hpp> 34*cdf0e10cSrcweir #include <com/sun/star/sdbc/ColumnValue.hpp> 35*cdf0e10cSrcweir #include <com/sun/star/sdbc/KeyRule.hpp> 36*cdf0e10cSrcweir #include <com/sun/star/sdbc/ProcedureResult.hpp> 37*cdf0e10cSrcweir #include <com/sun/star/sdbc/IndexType.hpp> 38*cdf0e10cSrcweir #include <comphelper/property.hxx> 39*cdf0e10cSrcweir #include <com/sun/star/lang/DisposedException.hpp> 40*cdf0e10cSrcweir #include <com/sun/star/sdbc/ResultSetConcurrency.hpp> 41*cdf0e10cSrcweir #include <com/sun/star/sdbc/ResultSetType.hpp> 42*cdf0e10cSrcweir #include <com/sun/star/sdbc/FetchDirection.hpp> 43*cdf0e10cSrcweir #include <cppuhelper/typeprovider.hxx> 44*cdf0e10cSrcweir #include <comphelper/seqstream.hxx> 45*cdf0e10cSrcweir #include "connectivity/dbexception.hxx" 46*cdf0e10cSrcweir 47*cdf0e10cSrcweir 48*cdf0e10cSrcweir #include <oledb.h> 49*cdf0e10cSrcweir 50*cdf0e10cSrcweir using namespace dbtools; 51*cdf0e10cSrcweir using namespace connectivity::ado; 52*cdf0e10cSrcweir using namespace cppu; 53*cdf0e10cSrcweir using namespace ::comphelper; 54*cdf0e10cSrcweir //------------------------------------------------------------------------------ 55*cdf0e10cSrcweir using namespace ::com::sun::star::lang; 56*cdf0e10cSrcweir using namespace com::sun::star::uno; 57*cdf0e10cSrcweir using namespace com::sun::star::lang; 58*cdf0e10cSrcweir using namespace com::sun::star::beans; 59*cdf0e10cSrcweir using namespace com::sun::star::sdbc; 60*cdf0e10cSrcweir 61*cdf0e10cSrcweir // ------------------------------------------------------------------------- 62*cdf0e10cSrcweir ODatabaseMetaDataResultSet::ODatabaseMetaDataResultSet(ADORecordset* _pRecordSet) 63*cdf0e10cSrcweir :ODatabaseMetaDataResultSet_BASE(m_aMutex) 64*cdf0e10cSrcweir ,OPropertySetHelper(ODatabaseMetaDataResultSet_BASE::rBHelper) 65*cdf0e10cSrcweir ,m_aStatement(NULL) 66*cdf0e10cSrcweir ,m_xMetaData(NULL) 67*cdf0e10cSrcweir ,m_pRecordSet(_pRecordSet) 68*cdf0e10cSrcweir ,m_bEOF(sal_False) 69*cdf0e10cSrcweir { 70*cdf0e10cSrcweir osl_incrementInterlockedCount( &m_refCount ); 71*cdf0e10cSrcweir m_aColMapping.push_back(-1); 72*cdf0e10cSrcweir if(_pRecordSet) 73*cdf0e10cSrcweir { 74*cdf0e10cSrcweir m_pRecordSet->AddRef(); 75*cdf0e10cSrcweir VARIANT_BOOL bIsAtBOF; 76*cdf0e10cSrcweir m_pRecordSet->get_BOF(&bIsAtBOF); 77*cdf0e10cSrcweir m_bOnFirstAfterOpen = bIsAtBOF != VARIANT_TRUE; 78*cdf0e10cSrcweir } 79*cdf0e10cSrcweir else 80*cdf0e10cSrcweir m_bOnFirstAfterOpen = sal_False; 81*cdf0e10cSrcweir osl_decrementInterlockedCount( &m_refCount ); 82*cdf0e10cSrcweir // allocBuffer(); 83*cdf0e10cSrcweir } 84*cdf0e10cSrcweir 85*cdf0e10cSrcweir // ------------------------------------------------------------------------- 86*cdf0e10cSrcweir ODatabaseMetaDataResultSet::~ODatabaseMetaDataResultSet() 87*cdf0e10cSrcweir { 88*cdf0e10cSrcweir if(m_pRecordSet) 89*cdf0e10cSrcweir m_pRecordSet->Release(); 90*cdf0e10cSrcweir } 91*cdf0e10cSrcweir // ------------------------------------------------------------------------- 92*cdf0e10cSrcweir void ODatabaseMetaDataResultSet::disposing(void) 93*cdf0e10cSrcweir { 94*cdf0e10cSrcweir OPropertySetHelper::disposing(); 95*cdf0e10cSrcweir 96*cdf0e10cSrcweir ::osl::MutexGuard aGuard(m_aMutex); 97*cdf0e10cSrcweir if(m_pRecordSet) 98*cdf0e10cSrcweir m_pRecordSet->Close(); 99*cdf0e10cSrcweir m_aStatement = NULL; 100*cdf0e10cSrcweir m_xMetaData.clear(); 101*cdf0e10cSrcweir } 102*cdf0e10cSrcweir // ------------------------------------------------------------------------- 103*cdf0e10cSrcweir Any SAL_CALL ODatabaseMetaDataResultSet::queryInterface( const Type & rType ) throw(RuntimeException) 104*cdf0e10cSrcweir { 105*cdf0e10cSrcweir Any aRet = OPropertySetHelper::queryInterface(rType); 106*cdf0e10cSrcweir return aRet.hasValue() ? aRet : ODatabaseMetaDataResultSet_BASE::queryInterface(rType); 107*cdf0e10cSrcweir } 108*cdf0e10cSrcweir // ------------------------------------------------------------------------- 109*cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL ODatabaseMetaDataResultSet::getTypes( ) throw(::com::sun::star::uno::RuntimeException) 110*cdf0e10cSrcweir { 111*cdf0e10cSrcweir ::cppu::OTypeCollection aTypes( ::getCppuType( (const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XMultiPropertySet > *)0 ), 112*cdf0e10cSrcweir ::getCppuType( (const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XFastPropertySet > *)0 ), 113*cdf0e10cSrcweir ::getCppuType( (const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > *)0 )); 114*cdf0e10cSrcweir 115*cdf0e10cSrcweir return ::comphelper::concatSequences(aTypes.getTypes(),ODatabaseMetaDataResultSet_BASE::getTypes()); 116*cdf0e10cSrcweir } 117*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 118*cdf0e10cSrcweir void ODatabaseMetaDataResultSet::checkRecordSet() throw(SQLException) 119*cdf0e10cSrcweir { 120*cdf0e10cSrcweir if(!m_pRecordSet) 121*cdf0e10cSrcweir throwFunctionSequenceException(*this); 122*cdf0e10cSrcweir } 123*cdf0e10cSrcweir // ------------------------------------------------------------------------- 124*cdf0e10cSrcweir 125*cdf0e10cSrcweir sal_Int32 SAL_CALL ODatabaseMetaDataResultSet::findColumn( const ::rtl::OUString& columnName ) throw(SQLException, RuntimeException) 126*cdf0e10cSrcweir { 127*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 128*cdf0e10cSrcweir checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed ); 129*cdf0e10cSrcweir 130*cdf0e10cSrcweir 131*cdf0e10cSrcweir Reference< XResultSetMetaData > xMeta = getMetaData(); 132*cdf0e10cSrcweir sal_Int32 nLen = xMeta->getColumnCount(); 133*cdf0e10cSrcweir sal_Int32 i = 1; 134*cdf0e10cSrcweir for(;i<=nLen;++i) 135*cdf0e10cSrcweir if(xMeta->isCaseSensitive(i) ? columnName == xMeta->getColumnName(i) : 136*cdf0e10cSrcweir columnName.equalsIgnoreAsciiCase(xMeta->getColumnName(i))) 137*cdf0e10cSrcweir break; 138*cdf0e10cSrcweir return i; 139*cdf0e10cSrcweir } 140*cdf0e10cSrcweir #define BLOCK_SIZE 256 141*cdf0e10cSrcweir // ------------------------------------------------------------------------- 142*cdf0e10cSrcweir Reference< ::com::sun::star::io::XInputStream > SAL_CALL ODatabaseMetaDataResultSet::getBinaryStream( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) 143*cdf0e10cSrcweir { 144*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 145*cdf0e10cSrcweir checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed); 146*cdf0e10cSrcweir 147*cdf0e10cSrcweir checkRecordSet(); 148*cdf0e10cSrcweir 149*cdf0e10cSrcweir 150*cdf0e10cSrcweir columnIndex = mapColumn(columnIndex); 151*cdf0e10cSrcweir WpADOField aField = ADOS::getField(m_pRecordSet,columnIndex); 152*cdf0e10cSrcweir if((aField.GetAttributes() & adFldLong) == adFldLong) 153*cdf0e10cSrcweir { 154*cdf0e10cSrcweir //Copy the data only upto the Actual Size of Field. 155*cdf0e10cSrcweir sal_Int32 nSize = aField.GetActualSize(); 156*cdf0e10cSrcweir Sequence<sal_Int8> aData(nSize); 157*cdf0e10cSrcweir long index = 0; 158*cdf0e10cSrcweir while(index < nSize) 159*cdf0e10cSrcweir { 160*cdf0e10cSrcweir m_aValue = aField.GetChunk(BLOCK_SIZE); 161*cdf0e10cSrcweir if(m_aValue.isNull()) 162*cdf0e10cSrcweir break; 163*cdf0e10cSrcweir UCHAR chData; 164*cdf0e10cSrcweir for(long index2 = 0;index2 < BLOCK_SIZE;++index2) 165*cdf0e10cSrcweir { 166*cdf0e10cSrcweir HRESULT hr = ::SafeArrayGetElement(m_aValue.parray,&index2,&chData); 167*cdf0e10cSrcweir if(SUCCEEDED(hr)) 168*cdf0e10cSrcweir { 169*cdf0e10cSrcweir //Take BYTE by BYTE and advance Memory Location 170*cdf0e10cSrcweir aData.getArray()[index++] = chData; 171*cdf0e10cSrcweir } 172*cdf0e10cSrcweir else 173*cdf0e10cSrcweir break; 174*cdf0e10cSrcweir } 175*cdf0e10cSrcweir } 176*cdf0e10cSrcweir return index ? Reference< ::com::sun::star::io::XInputStream >(new SequenceInputStream(aData)) : Reference< ::com::sun::star::io::XInputStream >(); 177*cdf0e10cSrcweir } 178*cdf0e10cSrcweir // else we ask for a bytesequence 179*cdf0e10cSrcweir aField.get_Value(m_aValue); 180*cdf0e10cSrcweir if(m_aValue.isNull()) 181*cdf0e10cSrcweir return NULL; 182*cdf0e10cSrcweir return new SequenceInputStream(m_aValue); 183*cdf0e10cSrcweir } 184*cdf0e10cSrcweir // ------------------------------------------------------------------------- 185*cdf0e10cSrcweir Reference< ::com::sun::star::io::XInputStream > SAL_CALL ODatabaseMetaDataResultSet::getCharacterStream( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException) 186*cdf0e10cSrcweir { 187*cdf0e10cSrcweir ::dbtools::throwFeatureNotImplementedException( "XRow::getCharacterStream", *this ); 188*cdf0e10cSrcweir return NULL; 189*cdf0e10cSrcweir } 190*cdf0e10cSrcweir 191*cdf0e10cSrcweir // ------------------------------------------------------------------------- 192*cdf0e10cSrcweir sal_Bool SAL_CALL ODatabaseMetaDataResultSet::getBoolean( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) 193*cdf0e10cSrcweir { 194*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 195*cdf0e10cSrcweir 196*cdf0e10cSrcweir if ( !m_aValueRange.empty() && columnIndex == 11 && (m_aValueRangeIter = m_aValueRange.find(columnIndex)) != m_aValueRange.end() ) 197*cdf0e10cSrcweir { 198*cdf0e10cSrcweir getValue(2); 199*cdf0e10cSrcweir if ( static_cast<sal_Int16>(m_aValue) != adCurrency ) 200*cdf0e10cSrcweir return sal_False; 201*cdf0e10cSrcweir } 202*cdf0e10cSrcweir return getValue(columnIndex); 203*cdf0e10cSrcweir } 204*cdf0e10cSrcweir // ------------------------------------------------------------------------- 205*cdf0e10cSrcweir 206*cdf0e10cSrcweir sal_Int8 SAL_CALL ODatabaseMetaDataResultSet::getByte( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) 207*cdf0e10cSrcweir { 208*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 209*cdf0e10cSrcweir 210*cdf0e10cSrcweir getValue(columnIndex); 211*cdf0e10cSrcweir 212*cdf0e10cSrcweir columnIndex = mapColumn(columnIndex); 213*cdf0e10cSrcweir 214*cdf0e10cSrcweir if(m_aValue.isNull()) 215*cdf0e10cSrcweir return 0; 216*cdf0e10cSrcweir if ( !m_aValueRange.empty() && (m_aValueRangeIter = m_aValueRange.find(columnIndex)) != m_aValueRange.end()) 217*cdf0e10cSrcweir return (sal_Int8)(*m_aValueRangeIter).second[(sal_Int32)m_aValue]; 218*cdf0e10cSrcweir else if(m_aStrValueRange.size() && (m_aStrValueRangeIter = m_aStrValueRange.find(columnIndex)) != m_aStrValueRange.end()) 219*cdf0e10cSrcweir return (sal_Int8)(*m_aStrValueRangeIter).second[m_aValue]; 220*cdf0e10cSrcweir 221*cdf0e10cSrcweir return m_aValue; 222*cdf0e10cSrcweir } 223*cdf0e10cSrcweir // ------------------------------------------------------------------------- 224*cdf0e10cSrcweir 225*cdf0e10cSrcweir Sequence< sal_Int8 > SAL_CALL ODatabaseMetaDataResultSet::getBytes( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) 226*cdf0e10cSrcweir { 227*cdf0e10cSrcweir return getValue(columnIndex); 228*cdf0e10cSrcweir } 229*cdf0e10cSrcweir // ------------------------------------------------------------------------- 230*cdf0e10cSrcweir 231*cdf0e10cSrcweir ::com::sun::star::util::Date SAL_CALL ODatabaseMetaDataResultSet::getDate( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) 232*cdf0e10cSrcweir { 233*cdf0e10cSrcweir return getValue(columnIndex); 234*cdf0e10cSrcweir } 235*cdf0e10cSrcweir // ------------------------------------------------------------------------- 236*cdf0e10cSrcweir 237*cdf0e10cSrcweir double SAL_CALL ODatabaseMetaDataResultSet::getDouble( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) 238*cdf0e10cSrcweir { 239*cdf0e10cSrcweir return getValue(columnIndex); 240*cdf0e10cSrcweir } 241*cdf0e10cSrcweir // ------------------------------------------------------------------------- 242*cdf0e10cSrcweir 243*cdf0e10cSrcweir float SAL_CALL ODatabaseMetaDataResultSet::getFloat( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) 244*cdf0e10cSrcweir { 245*cdf0e10cSrcweir return getValue(columnIndex); 246*cdf0e10cSrcweir } 247*cdf0e10cSrcweir // ------------------------------------------------------------------------- 248*cdf0e10cSrcweir 249*cdf0e10cSrcweir sal_Int32 SAL_CALL ODatabaseMetaDataResultSet::getInt( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) 250*cdf0e10cSrcweir { 251*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 252*cdf0e10cSrcweir 253*cdf0e10cSrcweir 254*cdf0e10cSrcweir getValue(columnIndex); 255*cdf0e10cSrcweir 256*cdf0e10cSrcweir columnIndex = mapColumn(columnIndex); 257*cdf0e10cSrcweir if(m_aValue.isNull()) 258*cdf0e10cSrcweir return 0; 259*cdf0e10cSrcweir 260*cdf0e10cSrcweir if(m_aValueRange.size() && (m_aValueRangeIter = m_aValueRange.find(columnIndex)) != m_aValueRange.end()) 261*cdf0e10cSrcweir return (*m_aValueRangeIter).second[(sal_Int32)m_aValue]; 262*cdf0e10cSrcweir else if(m_aStrValueRange.size() && (m_aStrValueRangeIter = m_aStrValueRange.find(columnIndex)) != m_aStrValueRange.end()) 263*cdf0e10cSrcweir return (*m_aStrValueRangeIter).second[m_aValue]; 264*cdf0e10cSrcweir 265*cdf0e10cSrcweir return m_aValue; 266*cdf0e10cSrcweir } 267*cdf0e10cSrcweir // ------------------------------------------------------------------------- 268*cdf0e10cSrcweir 269*cdf0e10cSrcweir sal_Int32 SAL_CALL ODatabaseMetaDataResultSet::getRow( ) throw(SQLException, RuntimeException) 270*cdf0e10cSrcweir { 271*cdf0e10cSrcweir ::dbtools::throwFeatureNotImplementedException( "XResultSet::getRow", *this ); 272*cdf0e10cSrcweir return 0; 273*cdf0e10cSrcweir } 274*cdf0e10cSrcweir // ------------------------------------------------------------------------- 275*cdf0e10cSrcweir 276*cdf0e10cSrcweir sal_Int64 SAL_CALL ODatabaseMetaDataResultSet::getLong( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException) 277*cdf0e10cSrcweir { 278*cdf0e10cSrcweir ::dbtools::throwFeatureNotImplementedException( "XRow::getLong", *this ); 279*cdf0e10cSrcweir return sal_Int64(0); 280*cdf0e10cSrcweir } 281*cdf0e10cSrcweir // ------------------------------------------------------------------------- 282*cdf0e10cSrcweir 283*cdf0e10cSrcweir Reference< XResultSetMetaData > SAL_CALL ODatabaseMetaDataResultSet::getMetaData( ) throw(SQLException, RuntimeException) 284*cdf0e10cSrcweir { 285*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 286*cdf0e10cSrcweir checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed); 287*cdf0e10cSrcweir 288*cdf0e10cSrcweir checkRecordSet(); 289*cdf0e10cSrcweir 290*cdf0e10cSrcweir 291*cdf0e10cSrcweir if(!m_xMetaData.is()) 292*cdf0e10cSrcweir m_xMetaData = new ODatabaseMetaDataResultSetMetaData(m_pRecordSet,this); 293*cdf0e10cSrcweir 294*cdf0e10cSrcweir return m_xMetaData; 295*cdf0e10cSrcweir } 296*cdf0e10cSrcweir // ------------------------------------------------------------------------- 297*cdf0e10cSrcweir Reference< XArray > SAL_CALL ODatabaseMetaDataResultSet::getArray( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException) 298*cdf0e10cSrcweir { 299*cdf0e10cSrcweir ::dbtools::throwFeatureNotImplementedException( "XRow::getRow", *this ); 300*cdf0e10cSrcweir return NULL; 301*cdf0e10cSrcweir } 302*cdf0e10cSrcweir 303*cdf0e10cSrcweir // ------------------------------------------------------------------------- 304*cdf0e10cSrcweir 305*cdf0e10cSrcweir Reference< XClob > SAL_CALL ODatabaseMetaDataResultSet::getClob( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException) 306*cdf0e10cSrcweir { 307*cdf0e10cSrcweir ::dbtools::throwFeatureNotImplementedException( "XRow::getRow", *this ); 308*cdf0e10cSrcweir return NULL; 309*cdf0e10cSrcweir } 310*cdf0e10cSrcweir // ------------------------------------------------------------------------- 311*cdf0e10cSrcweir Reference< XBlob > SAL_CALL ODatabaseMetaDataResultSet::getBlob( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException) 312*cdf0e10cSrcweir { 313*cdf0e10cSrcweir ::dbtools::throwFeatureNotImplementedException( "XRow::getRow", *this ); 314*cdf0e10cSrcweir return NULL; 315*cdf0e10cSrcweir } 316*cdf0e10cSrcweir // ------------------------------------------------------------------------- 317*cdf0e10cSrcweir 318*cdf0e10cSrcweir Reference< XRef > SAL_CALL ODatabaseMetaDataResultSet::getRef( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException) 319*cdf0e10cSrcweir { 320*cdf0e10cSrcweir ::dbtools::throwFeatureNotImplementedException( "XRow::getRow", *this ); 321*cdf0e10cSrcweir return NULL; 322*cdf0e10cSrcweir } 323*cdf0e10cSrcweir // ------------------------------------------------------------------------- 324*cdf0e10cSrcweir 325*cdf0e10cSrcweir Any SAL_CALL ODatabaseMetaDataResultSet::getObject( sal_Int32 columnIndex, const Reference< ::com::sun::star::container::XNameAccess >& /*typeMap*/ ) throw(SQLException, RuntimeException) 326*cdf0e10cSrcweir { 327*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 328*cdf0e10cSrcweir checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed); 329*cdf0e10cSrcweir 330*cdf0e10cSrcweir checkRecordSet(); 331*cdf0e10cSrcweir 332*cdf0e10cSrcweir 333*cdf0e10cSrcweir columnIndex = mapColumn(columnIndex); 334*cdf0e10cSrcweir return Any(); 335*cdf0e10cSrcweir } 336*cdf0e10cSrcweir // ------------------------------------------------------------------------- 337*cdf0e10cSrcweir 338*cdf0e10cSrcweir sal_Int16 SAL_CALL ODatabaseMetaDataResultSet::getShort( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) 339*cdf0e10cSrcweir { 340*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 341*cdf0e10cSrcweir 342*cdf0e10cSrcweir getValue(columnIndex); 343*cdf0e10cSrcweir 344*cdf0e10cSrcweir columnIndex = mapColumn(columnIndex); 345*cdf0e10cSrcweir if(m_aValue.isNull()) 346*cdf0e10cSrcweir return 0; 347*cdf0e10cSrcweir 348*cdf0e10cSrcweir if(m_aValueRange.size() && (m_aValueRangeIter = m_aValueRange.find(columnIndex)) != m_aValueRange.end()) 349*cdf0e10cSrcweir return (sal_Int16)(*m_aValueRangeIter).second[(sal_Int32)m_aValue]; 350*cdf0e10cSrcweir else if(m_aStrValueRange.size() && (m_aStrValueRangeIter = m_aStrValueRange.find(columnIndex)) != m_aStrValueRange.end()) 351*cdf0e10cSrcweir return (sal_Int16)(*m_aStrValueRangeIter).second[m_aValue]; 352*cdf0e10cSrcweir 353*cdf0e10cSrcweir return m_aValue; 354*cdf0e10cSrcweir } 355*cdf0e10cSrcweir // ------------------------------------------------------------------------- 356*cdf0e10cSrcweir 357*cdf0e10cSrcweir ::rtl::OUString SAL_CALL ODatabaseMetaDataResultSet::getString( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) 358*cdf0e10cSrcweir { 359*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 360*cdf0e10cSrcweir 361*cdf0e10cSrcweir getValue(columnIndex); 362*cdf0e10cSrcweir 363*cdf0e10cSrcweir 364*cdf0e10cSrcweir columnIndex = mapColumn(columnIndex); 365*cdf0e10cSrcweir if(m_aValue.isNull()) 366*cdf0e10cSrcweir return ::rtl::OUString(); 367*cdf0e10cSrcweir if(m_aIntValueRange.size() && (m_aIntValueRangeIter = m_aIntValueRange.find(columnIndex)) != m_aIntValueRange.end()) 368*cdf0e10cSrcweir return (*m_aIntValueRangeIter).second[m_aValue]; 369*cdf0e10cSrcweir 370*cdf0e10cSrcweir return m_aValue; 371*cdf0e10cSrcweir } 372*cdf0e10cSrcweir 373*cdf0e10cSrcweir // ------------------------------------------------------------------------- 374*cdf0e10cSrcweir 375*cdf0e10cSrcweir 376*cdf0e10cSrcweir ::com::sun::star::util::Time SAL_CALL ODatabaseMetaDataResultSet::getTime( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) 377*cdf0e10cSrcweir { 378*cdf0e10cSrcweir return getValue(columnIndex); 379*cdf0e10cSrcweir } 380*cdf0e10cSrcweir // ------------------------------------------------------------------------- 381*cdf0e10cSrcweir 382*cdf0e10cSrcweir 383*cdf0e10cSrcweir ::com::sun::star::util::DateTime SAL_CALL ODatabaseMetaDataResultSet::getTimestamp( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) 384*cdf0e10cSrcweir { 385*cdf0e10cSrcweir return getValue(columnIndex); 386*cdf0e10cSrcweir } 387*cdf0e10cSrcweir // ------------------------------------------------------------------------- 388*cdf0e10cSrcweir 389*cdf0e10cSrcweir sal_Bool SAL_CALL ODatabaseMetaDataResultSet::isAfterLast( ) throw(SQLException, RuntimeException) 390*cdf0e10cSrcweir { 391*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 392*cdf0e10cSrcweir checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed); 393*cdf0e10cSrcweir 394*cdf0e10cSrcweir checkRecordSet(); 395*cdf0e10cSrcweir 396*cdf0e10cSrcweir 397*cdf0e10cSrcweir VARIANT_BOOL bIsAtEOF; 398*cdf0e10cSrcweir m_pRecordSet->get_EOF(&bIsAtEOF); 399*cdf0e10cSrcweir return bIsAtEOF == VARIANT_TRUE; 400*cdf0e10cSrcweir } 401*cdf0e10cSrcweir // ------------------------------------------------------------------------- 402*cdf0e10cSrcweir sal_Bool SAL_CALL ODatabaseMetaDataResultSet::isFirst( ) throw(SQLException, RuntimeException) 403*cdf0e10cSrcweir { 404*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 405*cdf0e10cSrcweir checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed); 406*cdf0e10cSrcweir 407*cdf0e10cSrcweir checkRecordSet(); 408*cdf0e10cSrcweir 409*cdf0e10cSrcweir 410*cdf0e10cSrcweir return m_nRowPos == 1; 411*cdf0e10cSrcweir } 412*cdf0e10cSrcweir // ------------------------------------------------------------------------- 413*cdf0e10cSrcweir sal_Bool SAL_CALL ODatabaseMetaDataResultSet::isLast( ) throw(SQLException, RuntimeException) 414*cdf0e10cSrcweir { 415*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 416*cdf0e10cSrcweir checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed); 417*cdf0e10cSrcweir 418*cdf0e10cSrcweir checkRecordSet(); 419*cdf0e10cSrcweir 420*cdf0e10cSrcweir 421*cdf0e10cSrcweir return sal_True; 422*cdf0e10cSrcweir } 423*cdf0e10cSrcweir // ------------------------------------------------------------------------- 424*cdf0e10cSrcweir void SAL_CALL ODatabaseMetaDataResultSet::beforeFirst( ) throw(SQLException, RuntimeException) 425*cdf0e10cSrcweir { 426*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 427*cdf0e10cSrcweir checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed); 428*cdf0e10cSrcweir 429*cdf0e10cSrcweir checkRecordSet(); 430*cdf0e10cSrcweir 431*cdf0e10cSrcweir 432*cdf0e10cSrcweir if(first()) 433*cdf0e10cSrcweir previous(); 434*cdf0e10cSrcweir } 435*cdf0e10cSrcweir // ------------------------------------------------------------------------- 436*cdf0e10cSrcweir void SAL_CALL ODatabaseMetaDataResultSet::afterLast( ) throw(SQLException, RuntimeException) 437*cdf0e10cSrcweir { 438*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 439*cdf0e10cSrcweir checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed); 440*cdf0e10cSrcweir 441*cdf0e10cSrcweir checkRecordSet(); 442*cdf0e10cSrcweir 443*cdf0e10cSrcweir 444*cdf0e10cSrcweir if(last()) 445*cdf0e10cSrcweir next(); 446*cdf0e10cSrcweir m_bEOF = sal_True; 447*cdf0e10cSrcweir } 448*cdf0e10cSrcweir // ------------------------------------------------------------------------- 449*cdf0e10cSrcweir 450*cdf0e10cSrcweir void SAL_CALL ODatabaseMetaDataResultSet::close( ) throw(SQLException, RuntimeException) 451*cdf0e10cSrcweir { 452*cdf0e10cSrcweir { 453*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 454*cdf0e10cSrcweir checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed); 455*cdf0e10cSrcweir 456*cdf0e10cSrcweir } 457*cdf0e10cSrcweir dispose(); 458*cdf0e10cSrcweir } 459*cdf0e10cSrcweir // ------------------------------------------------------------------------- 460*cdf0e10cSrcweir 461*cdf0e10cSrcweir sal_Bool SAL_CALL ODatabaseMetaDataResultSet::first( ) throw(SQLException, RuntimeException) 462*cdf0e10cSrcweir { 463*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 464*cdf0e10cSrcweir checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed); 465*cdf0e10cSrcweir 466*cdf0e10cSrcweir 467*cdf0e10cSrcweir if(!m_pRecordSet) 468*cdf0e10cSrcweir return sal_False; 469*cdf0e10cSrcweir 470*cdf0e10cSrcweir sal_Bool bRet = SUCCEEDED(m_pRecordSet->MoveFirst()); 471*cdf0e10cSrcweir if ( bRet ) 472*cdf0e10cSrcweir m_nRowPos = 1; 473*cdf0e10cSrcweir return bRet; 474*cdf0e10cSrcweir } 475*cdf0e10cSrcweir // ------------------------------------------------------------------------- 476*cdf0e10cSrcweir 477*cdf0e10cSrcweir sal_Bool SAL_CALL ODatabaseMetaDataResultSet::last( ) throw(SQLException, RuntimeException) 478*cdf0e10cSrcweir { 479*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 480*cdf0e10cSrcweir checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed ); 481*cdf0e10cSrcweir 482*cdf0e10cSrcweir 483*cdf0e10cSrcweir return m_pRecordSet && SUCCEEDED(m_pRecordSet->MoveLast()) ? sal_True : sal_False; 484*cdf0e10cSrcweir } 485*cdf0e10cSrcweir // ------------------------------------------------------------------------- 486*cdf0e10cSrcweir sal_Bool SAL_CALL ODatabaseMetaDataResultSet::absolute( sal_Int32 row ) throw(SQLException, RuntimeException) 487*cdf0e10cSrcweir { 488*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 489*cdf0e10cSrcweir checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed); 490*cdf0e10cSrcweir 491*cdf0e10cSrcweir 492*cdf0e10cSrcweir if(first()) 493*cdf0e10cSrcweir { 494*cdf0e10cSrcweir OLEVariant aEmpty; 495*cdf0e10cSrcweir aEmpty.setNoArg(); 496*cdf0e10cSrcweir sal_Bool bRet = SUCCEEDED(m_pRecordSet->Move(row,aEmpty)); 497*cdf0e10cSrcweir if(bRet) 498*cdf0e10cSrcweir m_nRowPos = row; 499*cdf0e10cSrcweir return bRet; 500*cdf0e10cSrcweir } 501*cdf0e10cSrcweir return sal_False; 502*cdf0e10cSrcweir } 503*cdf0e10cSrcweir // ------------------------------------------------------------------------- 504*cdf0e10cSrcweir sal_Bool SAL_CALL ODatabaseMetaDataResultSet::relative( sal_Int32 row ) throw(SQLException, RuntimeException) 505*cdf0e10cSrcweir { 506*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 507*cdf0e10cSrcweir checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed); 508*cdf0e10cSrcweir 509*cdf0e10cSrcweir 510*cdf0e10cSrcweir if(!m_pRecordSet) 511*cdf0e10cSrcweir return sal_False; 512*cdf0e10cSrcweir 513*cdf0e10cSrcweir OLEVariant aEmpty; 514*cdf0e10cSrcweir aEmpty.setNoArg(); 515*cdf0e10cSrcweir sal_Bool bRet = SUCCEEDED(m_pRecordSet->Move(row,aEmpty)); 516*cdf0e10cSrcweir if(bRet) 517*cdf0e10cSrcweir m_nRowPos += row; 518*cdf0e10cSrcweir return bRet; 519*cdf0e10cSrcweir } 520*cdf0e10cSrcweir // ------------------------------------------------------------------------- 521*cdf0e10cSrcweir sal_Bool SAL_CALL ODatabaseMetaDataResultSet::previous( ) throw(SQLException, RuntimeException) 522*cdf0e10cSrcweir { 523*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 524*cdf0e10cSrcweir checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed); 525*cdf0e10cSrcweir 526*cdf0e10cSrcweir 527*cdf0e10cSrcweir if(!m_pRecordSet) 528*cdf0e10cSrcweir return sal_False; 529*cdf0e10cSrcweir 530*cdf0e10cSrcweir sal_Bool bRet = SUCCEEDED(m_pRecordSet->MovePrevious()); 531*cdf0e10cSrcweir if(bRet) 532*cdf0e10cSrcweir --m_nRowPos; 533*cdf0e10cSrcweir return bRet; 534*cdf0e10cSrcweir } 535*cdf0e10cSrcweir // ------------------------------------------------------------------------- 536*cdf0e10cSrcweir Reference< XInterface > SAL_CALL ODatabaseMetaDataResultSet::getStatement( ) throw(SQLException, RuntimeException) 537*cdf0e10cSrcweir { 538*cdf0e10cSrcweir return m_aStatement.get(); 539*cdf0e10cSrcweir } 540*cdf0e10cSrcweir // ------------------------------------------------------------------------- 541*cdf0e10cSrcweir 542*cdf0e10cSrcweir sal_Bool SAL_CALL ODatabaseMetaDataResultSet::rowDeleted( ) throw(SQLException, RuntimeException) 543*cdf0e10cSrcweir { 544*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 545*cdf0e10cSrcweir checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed); 546*cdf0e10cSrcweir 547*cdf0e10cSrcweir checkRecordSet(); 548*cdf0e10cSrcweir 549*cdf0e10cSrcweir 550*cdf0e10cSrcweir RecordStatusEnum eRec; 551*cdf0e10cSrcweir m_pRecordSet->get_Status((sal_Int32*)&eRec); 552*cdf0e10cSrcweir return (eRec & adRecDeleted) == adRecDeleted; 553*cdf0e10cSrcweir } 554*cdf0e10cSrcweir // ------------------------------------------------------------------------- 555*cdf0e10cSrcweir sal_Bool SAL_CALL ODatabaseMetaDataResultSet::rowInserted( ) throw(SQLException, RuntimeException) 556*cdf0e10cSrcweir { ::osl::MutexGuard aGuard( m_aMutex ); 557*cdf0e10cSrcweir checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed); 558*cdf0e10cSrcweir 559*cdf0e10cSrcweir checkRecordSet(); 560*cdf0e10cSrcweir 561*cdf0e10cSrcweir 562*cdf0e10cSrcweir RecordStatusEnum eRec; 563*cdf0e10cSrcweir m_pRecordSet->get_Status((sal_Int32*)&eRec); 564*cdf0e10cSrcweir return (eRec & adRecNew) == adRecNew; 565*cdf0e10cSrcweir } 566*cdf0e10cSrcweir // ------------------------------------------------------------------------- 567*cdf0e10cSrcweir sal_Bool SAL_CALL ODatabaseMetaDataResultSet::rowUpdated( ) throw(SQLException, RuntimeException) 568*cdf0e10cSrcweir { 569*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 570*cdf0e10cSrcweir checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed); 571*cdf0e10cSrcweir 572*cdf0e10cSrcweir checkRecordSet(); 573*cdf0e10cSrcweir 574*cdf0e10cSrcweir 575*cdf0e10cSrcweir RecordStatusEnum eRec; 576*cdf0e10cSrcweir m_pRecordSet->get_Status((sal_Int32*)&eRec); 577*cdf0e10cSrcweir return (eRec & adRecModified) == adRecModified; 578*cdf0e10cSrcweir } 579*cdf0e10cSrcweir // ------------------------------------------------------------------------- 580*cdf0e10cSrcweir 581*cdf0e10cSrcweir sal_Bool SAL_CALL ODatabaseMetaDataResultSet::isBeforeFirst( ) throw(SQLException, RuntimeException) 582*cdf0e10cSrcweir { 583*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 584*cdf0e10cSrcweir checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed); 585*cdf0e10cSrcweir 586*cdf0e10cSrcweir 587*cdf0e10cSrcweir if(!m_pRecordSet) 588*cdf0e10cSrcweir return sal_True; 589*cdf0e10cSrcweir 590*cdf0e10cSrcweir VARIANT_BOOL bIsAtBOF; 591*cdf0e10cSrcweir m_pRecordSet->get_BOF(&bIsAtBOF); 592*cdf0e10cSrcweir return bIsAtBOF == VARIANT_TRUE; 593*cdf0e10cSrcweir } 594*cdf0e10cSrcweir // ------------------------------------------------------------------------- 595*cdf0e10cSrcweir 596*cdf0e10cSrcweir sal_Bool SAL_CALL ODatabaseMetaDataResultSet::next( ) throw(SQLException, RuntimeException) 597*cdf0e10cSrcweir { 598*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 599*cdf0e10cSrcweir checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed); 600*cdf0e10cSrcweir 601*cdf0e10cSrcweir 602*cdf0e10cSrcweir if(!m_pRecordSet) 603*cdf0e10cSrcweir return sal_False; 604*cdf0e10cSrcweir 605*cdf0e10cSrcweir if(m_bOnFirstAfterOpen) 606*cdf0e10cSrcweir { 607*cdf0e10cSrcweir m_bOnFirstAfterOpen = sal_False; 608*cdf0e10cSrcweir return sal_True; 609*cdf0e10cSrcweir } 610*cdf0e10cSrcweir else 611*cdf0e10cSrcweir return SUCCEEDED(m_pRecordSet->MoveNext()); 612*cdf0e10cSrcweir } 613*cdf0e10cSrcweir // ------------------------------------------------------------------------- 614*cdf0e10cSrcweir 615*cdf0e10cSrcweir sal_Bool SAL_CALL ODatabaseMetaDataResultSet::wasNull( ) throw(SQLException, RuntimeException) 616*cdf0e10cSrcweir { 617*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 618*cdf0e10cSrcweir checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed); 619*cdf0e10cSrcweir 620*cdf0e10cSrcweir checkRecordSet(); 621*cdf0e10cSrcweir 622*cdf0e10cSrcweir 623*cdf0e10cSrcweir return m_aValue.isNull(); 624*cdf0e10cSrcweir } 625*cdf0e10cSrcweir // ------------------------------------------------------------------------- 626*cdf0e10cSrcweir void SAL_CALL ODatabaseMetaDataResultSet::refreshRow( ) throw(SQLException, RuntimeException) 627*cdf0e10cSrcweir { 628*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 629*cdf0e10cSrcweir checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed); 630*cdf0e10cSrcweir 631*cdf0e10cSrcweir checkRecordSet(); 632*cdf0e10cSrcweir 633*cdf0e10cSrcweir 634*cdf0e10cSrcweir m_pRecordSet->Resync(adAffectCurrent,adResyncAllValues); 635*cdf0e10cSrcweir } 636*cdf0e10cSrcweir // ------------------------------------------------------------------------- 637*cdf0e10cSrcweir 638*cdf0e10cSrcweir void SAL_CALL ODatabaseMetaDataResultSet::cancel( ) throw(RuntimeException) 639*cdf0e10cSrcweir { 640*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 641*cdf0e10cSrcweir checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed); 642*cdf0e10cSrcweir 643*cdf0e10cSrcweir checkRecordSet(); 644*cdf0e10cSrcweir 645*cdf0e10cSrcweir 646*cdf0e10cSrcweir m_pRecordSet->Cancel(); 647*cdf0e10cSrcweir } 648*cdf0e10cSrcweir // ------------------------------------------------------------------------- 649*cdf0e10cSrcweir void SAL_CALL ODatabaseMetaDataResultSet::clearWarnings( ) throw(SQLException, RuntimeException) 650*cdf0e10cSrcweir { 651*cdf0e10cSrcweir } 652*cdf0e10cSrcweir // ------------------------------------------------------------------------- 653*cdf0e10cSrcweir Any SAL_CALL ODatabaseMetaDataResultSet::getWarnings( ) throw(SQLException, RuntimeException) 654*cdf0e10cSrcweir { 655*cdf0e10cSrcweir return Any(); 656*cdf0e10cSrcweir } 657*cdf0e10cSrcweir //------------------------------------------------------------------------------ 658*cdf0e10cSrcweir sal_Int32 ODatabaseMetaDataResultSet::getResultSetConcurrency() const 659*cdf0e10cSrcweir throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) 660*cdf0e10cSrcweir { 661*cdf0e10cSrcweir return ResultSetConcurrency::READ_ONLY; 662*cdf0e10cSrcweir } 663*cdf0e10cSrcweir //------------------------------------------------------------------------------ 664*cdf0e10cSrcweir sal_Int32 ODatabaseMetaDataResultSet::getResultSetType() const 665*cdf0e10cSrcweir throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) 666*cdf0e10cSrcweir { 667*cdf0e10cSrcweir return ResultSetType::FORWARD_ONLY; 668*cdf0e10cSrcweir } 669*cdf0e10cSrcweir //------------------------------------------------------------------------------ 670*cdf0e10cSrcweir sal_Int32 ODatabaseMetaDataResultSet::getFetchDirection() const 671*cdf0e10cSrcweir throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) 672*cdf0e10cSrcweir { 673*cdf0e10cSrcweir return FetchDirection::FORWARD; 674*cdf0e10cSrcweir } 675*cdf0e10cSrcweir //------------------------------------------------------------------------------ 676*cdf0e10cSrcweir sal_Int32 ODatabaseMetaDataResultSet::getFetchSize() const 677*cdf0e10cSrcweir throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) 678*cdf0e10cSrcweir { 679*cdf0e10cSrcweir sal_Int32 nValue=-1; 680*cdf0e10cSrcweir if(m_pRecordSet) 681*cdf0e10cSrcweir m_pRecordSet->get_CacheSize(&nValue); 682*cdf0e10cSrcweir return nValue; 683*cdf0e10cSrcweir } 684*cdf0e10cSrcweir //------------------------------------------------------------------------------ 685*cdf0e10cSrcweir ::rtl::OUString ODatabaseMetaDataResultSet::getCursorName() const 686*cdf0e10cSrcweir throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) 687*cdf0e10cSrcweir { 688*cdf0e10cSrcweir return ::rtl::OUString(); 689*cdf0e10cSrcweir } 690*cdf0e10cSrcweir 691*cdf0e10cSrcweir //------------------------------------------------------------------------------ 692*cdf0e10cSrcweir void ODatabaseMetaDataResultSet::setFetchDirection(sal_Int32 /*_par0*/) 693*cdf0e10cSrcweir throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) 694*cdf0e10cSrcweir { 695*cdf0e10cSrcweir ::dbtools::throwFeatureNotImplementedException( "ResultSet::FetchDirection", *this ); 696*cdf0e10cSrcweir } 697*cdf0e10cSrcweir //------------------------------------------------------------------------------ 698*cdf0e10cSrcweir void ODatabaseMetaDataResultSet::setFetchSize(sal_Int32 _par0) 699*cdf0e10cSrcweir throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) 700*cdf0e10cSrcweir { 701*cdf0e10cSrcweir if(m_pRecordSet) 702*cdf0e10cSrcweir m_pRecordSet->put_CacheSize(_par0); 703*cdf0e10cSrcweir } 704*cdf0e10cSrcweir // ------------------------------------------------------------------------- 705*cdf0e10cSrcweir ::cppu::IPropertyArrayHelper* ODatabaseMetaDataResultSet::createArrayHelper( ) const 706*cdf0e10cSrcweir { 707*cdf0e10cSrcweir 708*cdf0e10cSrcweir Sequence< com::sun::star::beans::Property > aProps(5); 709*cdf0e10cSrcweir com::sun::star::beans::Property* pProperties = aProps.getArray(); 710*cdf0e10cSrcweir sal_Int32 nPos = 0; 711*cdf0e10cSrcweir DECL_PROP0(CURSORNAME, ::rtl::OUString); 712*cdf0e10cSrcweir DECL_PROP0(FETCHDIRECTION, sal_Int32); 713*cdf0e10cSrcweir DECL_PROP0(FETCHSIZE, sal_Int32); 714*cdf0e10cSrcweir DECL_PROP0(RESULTSETCONCURRENCY,sal_Int32); 715*cdf0e10cSrcweir DECL_PROP0(RESULTSETTYPE, sal_Int32); 716*cdf0e10cSrcweir 717*cdf0e10cSrcweir return new ::cppu::OPropertyArrayHelper(aProps); 718*cdf0e10cSrcweir } 719*cdf0e10cSrcweir // ------------------------------------------------------------------------- 720*cdf0e10cSrcweir ::cppu::IPropertyArrayHelper & ODatabaseMetaDataResultSet::getInfoHelper() 721*cdf0e10cSrcweir { 722*cdf0e10cSrcweir return *const_cast<ODatabaseMetaDataResultSet*>(this)->getArrayHelper(); 723*cdf0e10cSrcweir } 724*cdf0e10cSrcweir // ------------------------------------------------------------------------- 725*cdf0e10cSrcweir sal_Bool ODatabaseMetaDataResultSet::convertFastPropertyValue( 726*cdf0e10cSrcweir Any & rConvertedValue, 727*cdf0e10cSrcweir Any & rOldValue, 728*cdf0e10cSrcweir sal_Int32 nHandle, 729*cdf0e10cSrcweir const Any& rValue ) 730*cdf0e10cSrcweir throw (::com::sun::star::lang::IllegalArgumentException) 731*cdf0e10cSrcweir { 732*cdf0e10cSrcweir switch(nHandle) 733*cdf0e10cSrcweir { 734*cdf0e10cSrcweir case PROPERTY_ID_CURSORNAME: 735*cdf0e10cSrcweir case PROPERTY_ID_RESULTSETCONCURRENCY: 736*cdf0e10cSrcweir case PROPERTY_ID_RESULTSETTYPE: 737*cdf0e10cSrcweir throw ::com::sun::star::lang::IllegalArgumentException(); 738*cdf0e10cSrcweir break; 739*cdf0e10cSrcweir case PROPERTY_ID_FETCHDIRECTION: 740*cdf0e10cSrcweir return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getFetchDirection()); 741*cdf0e10cSrcweir case PROPERTY_ID_FETCHSIZE: 742*cdf0e10cSrcweir return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getFetchSize()); 743*cdf0e10cSrcweir default: 744*cdf0e10cSrcweir ; 745*cdf0e10cSrcweir } 746*cdf0e10cSrcweir return sal_False; 747*cdf0e10cSrcweir } 748*cdf0e10cSrcweir // ------------------------------------------------------------------------- 749*cdf0e10cSrcweir void ODatabaseMetaDataResultSet::setFastPropertyValue_NoBroadcast( 750*cdf0e10cSrcweir sal_Int32 nHandle, 751*cdf0e10cSrcweir const Any& /*rValue*/ 752*cdf0e10cSrcweir ) 753*cdf0e10cSrcweir throw (Exception) 754*cdf0e10cSrcweir { 755*cdf0e10cSrcweir switch(nHandle) 756*cdf0e10cSrcweir { 757*cdf0e10cSrcweir case PROPERTY_ID_CURSORNAME: 758*cdf0e10cSrcweir case PROPERTY_ID_RESULTSETCONCURRENCY: 759*cdf0e10cSrcweir case PROPERTY_ID_RESULTSETTYPE: 760*cdf0e10cSrcweir case PROPERTY_ID_FETCHDIRECTION: 761*cdf0e10cSrcweir case PROPERTY_ID_FETCHSIZE: 762*cdf0e10cSrcweir throw Exception(); 763*cdf0e10cSrcweir break; 764*cdf0e10cSrcweir default: 765*cdf0e10cSrcweir OSL_ENSURE(0,"setFastPropertyValue_NoBroadcast: Illegal handle value!"); 766*cdf0e10cSrcweir } 767*cdf0e10cSrcweir } 768*cdf0e10cSrcweir // ------------------------------------------------------------------------- 769*cdf0e10cSrcweir void ODatabaseMetaDataResultSet::getFastPropertyValue( 770*cdf0e10cSrcweir Any& rValue, 771*cdf0e10cSrcweir sal_Int32 nHandle 772*cdf0e10cSrcweir ) const 773*cdf0e10cSrcweir { 774*cdf0e10cSrcweir switch(nHandle) 775*cdf0e10cSrcweir { 776*cdf0e10cSrcweir case PROPERTY_ID_CURSORNAME: 777*cdf0e10cSrcweir rValue <<= getCursorName(); 778*cdf0e10cSrcweir break; 779*cdf0e10cSrcweir case PROPERTY_ID_RESULTSETCONCURRENCY: 780*cdf0e10cSrcweir rValue <<= getResultSetConcurrency(); 781*cdf0e10cSrcweir break; 782*cdf0e10cSrcweir case PROPERTY_ID_RESULTSETTYPE: 783*cdf0e10cSrcweir rValue <<= getResultSetType(); 784*cdf0e10cSrcweir break; 785*cdf0e10cSrcweir case PROPERTY_ID_FETCHDIRECTION: 786*cdf0e10cSrcweir rValue <<= getFetchDirection(); 787*cdf0e10cSrcweir break; 788*cdf0e10cSrcweir case PROPERTY_ID_FETCHSIZE: 789*cdf0e10cSrcweir rValue <<= getFetchSize(); 790*cdf0e10cSrcweir break; 791*cdf0e10cSrcweir } 792*cdf0e10cSrcweir } 793*cdf0e10cSrcweir // ------------------------------------------------------------------------- 794*cdf0e10cSrcweir void ODatabaseMetaDataResultSet::setProceduresMap() 795*cdf0e10cSrcweir { 796*cdf0e10cSrcweir 797*cdf0e10cSrcweir for(sal_Int32 i=1;i<4;i++) 798*cdf0e10cSrcweir m_aColMapping.push_back(i); 799*cdf0e10cSrcweir m_aColMapping.push_back(5); 800*cdf0e10cSrcweir m_aColMapping.push_back(7); 801*cdf0e10cSrcweir m_aColMapping.push_back(8); 802*cdf0e10cSrcweir m_aColMapping.push_back(6); 803*cdf0e10cSrcweir m_aColMapping.push_back(4); 804*cdf0e10cSrcweir 805*cdf0e10cSrcweir TInt2IntMap aMap; 806*cdf0e10cSrcweir aMap[DB_PT_UNKNOWN] = ProcedureResult::UNKNOWN; 807*cdf0e10cSrcweir aMap[DB_PT_PROCEDURE] = ProcedureResult::NONE; 808*cdf0e10cSrcweir aMap[DB_PT_FUNCTION] = ProcedureResult::RETURN; 809*cdf0e10cSrcweir m_aValueRange[4] = aMap; 810*cdf0e10cSrcweir 811*cdf0e10cSrcweir ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData(m_pRecordSet,this); 812*cdf0e10cSrcweir pMetaData->setProceduresMap(); 813*cdf0e10cSrcweir m_xMetaData = pMetaData; 814*cdf0e10cSrcweir } 815*cdf0e10cSrcweir // ------------------------------------------------------------------------- 816*cdf0e10cSrcweir void ODatabaseMetaDataResultSet::setCatalogsMap() 817*cdf0e10cSrcweir { 818*cdf0e10cSrcweir m_aColMapping.push_back(1); 819*cdf0e10cSrcweir 820*cdf0e10cSrcweir m_xMetaData = new ODatabaseMetaDataResultSetMetaData(m_pRecordSet,this); 821*cdf0e10cSrcweir } 822*cdf0e10cSrcweir // ------------------------------------------------------------------------- 823*cdf0e10cSrcweir void ODatabaseMetaDataResultSet::setSchemasMap() 824*cdf0e10cSrcweir { 825*cdf0e10cSrcweir m_aColMapping.push_back(2); 826*cdf0e10cSrcweir 827*cdf0e10cSrcweir m_xMetaData = new ODatabaseMetaDataResultSetMetaData(m_pRecordSet,this); 828*cdf0e10cSrcweir } 829*cdf0e10cSrcweir // ------------------------------------------------------------------------- 830*cdf0e10cSrcweir void ODatabaseMetaDataResultSet::setColumnPrivilegesMap() 831*cdf0e10cSrcweir { 832*cdf0e10cSrcweir 833*cdf0e10cSrcweir m_aColMapping.push_back(3); 834*cdf0e10cSrcweir m_aColMapping.push_back(4); 835*cdf0e10cSrcweir m_aColMapping.push_back(5); 836*cdf0e10cSrcweir m_aColMapping.push_back(6); 837*cdf0e10cSrcweir m_aColMapping.push_back(2); 838*cdf0e10cSrcweir m_aColMapping.push_back(9); 839*cdf0e10cSrcweir m_aColMapping.push_back(10); 840*cdf0e10cSrcweir 841*cdf0e10cSrcweir ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData(m_pRecordSet,this); 842*cdf0e10cSrcweir pMetaData->setColumnPrivilegesMap(); 843*cdf0e10cSrcweir m_xMetaData = pMetaData; 844*cdf0e10cSrcweir } 845*cdf0e10cSrcweir // ------------------------------------------------------------------------- 846*cdf0e10cSrcweir void ODatabaseMetaDataResultSet::setColumnsMap() 847*cdf0e10cSrcweir { 848*cdf0e10cSrcweir 849*cdf0e10cSrcweir for(sal_Int32 i=1;i<5;++i) 850*cdf0e10cSrcweir m_aColMapping.push_back(i); 851*cdf0e10cSrcweir 852*cdf0e10cSrcweir m_aColMapping.push_back(12); 853*cdf0e10cSrcweir m_aColMapping.push_back(12); // is used as TYPE_NAME 854*cdf0e10cSrcweir 855*cdf0e10cSrcweir m_aColMapping.push_back(14); 856*cdf0e10cSrcweir m_aColMapping.push_back(6); 857*cdf0e10cSrcweir m_aColMapping.push_back(17); 858*cdf0e10cSrcweir m_aColMapping.push_back(18); 859*cdf0e10cSrcweir 860*cdf0e10cSrcweir m_aColMapping.push_back(11); 861*cdf0e10cSrcweir m_aColMapping.push_back(29); 862*cdf0e10cSrcweir m_aColMapping.push_back(9); 863*cdf0e10cSrcweir m_aColMapping.push_back(18); 864*cdf0e10cSrcweir m_aColMapping.push_back(18); 865*cdf0e10cSrcweir 866*cdf0e10cSrcweir m_aColMapping.push_back(15); 867*cdf0e10cSrcweir m_aColMapping.push_back(7); 868*cdf0e10cSrcweir m_aColMapping.push_back(11); 869*cdf0e10cSrcweir 870*cdf0e10cSrcweir TInt2IntMap aMap; 871*cdf0e10cSrcweir aMap[adEmpty] = ADOS::MapADOType2Jdbc(adEmpty); 872*cdf0e10cSrcweir aMap[adTinyInt] = ADOS::MapADOType2Jdbc(adTinyInt); 873*cdf0e10cSrcweir aMap[adSmallInt] = ADOS::MapADOType2Jdbc(adSmallInt); 874*cdf0e10cSrcweir aMap[adInteger] = ADOS::MapADOType2Jdbc(adInteger); 875*cdf0e10cSrcweir aMap[adBigInt] = ADOS::MapADOType2Jdbc(adBigInt); 876*cdf0e10cSrcweir aMap[adUnsignedTinyInt] = ADOS::MapADOType2Jdbc(adUnsignedTinyInt); 877*cdf0e10cSrcweir aMap[adUnsignedSmallInt]= ADOS::MapADOType2Jdbc(adUnsignedSmallInt); 878*cdf0e10cSrcweir aMap[adUnsignedInt] = ADOS::MapADOType2Jdbc(adUnsignedInt); 879*cdf0e10cSrcweir aMap[adUnsignedBigInt] = ADOS::MapADOType2Jdbc(adUnsignedBigInt); 880*cdf0e10cSrcweir aMap[adSingle] = ADOS::MapADOType2Jdbc(adSingle); 881*cdf0e10cSrcweir aMap[adDouble] = ADOS::MapADOType2Jdbc(adDouble); 882*cdf0e10cSrcweir aMap[adCurrency] = ADOS::MapADOType2Jdbc(adCurrency); 883*cdf0e10cSrcweir aMap[adDecimal] = ADOS::MapADOType2Jdbc(adDecimal); 884*cdf0e10cSrcweir aMap[adNumeric] = ADOS::MapADOType2Jdbc(adNumeric); 885*cdf0e10cSrcweir aMap[adBoolean] = ADOS::MapADOType2Jdbc(adBoolean); 886*cdf0e10cSrcweir aMap[adError] = ADOS::MapADOType2Jdbc(adError); 887*cdf0e10cSrcweir aMap[adUserDefined] = ADOS::MapADOType2Jdbc(adUserDefined); 888*cdf0e10cSrcweir aMap[adVariant] = ADOS::MapADOType2Jdbc(adVariant); 889*cdf0e10cSrcweir aMap[adIDispatch] = ADOS::MapADOType2Jdbc(adIDispatch); 890*cdf0e10cSrcweir aMap[adIUnknown] = ADOS::MapADOType2Jdbc(adIUnknown); 891*cdf0e10cSrcweir aMap[adGUID] = ADOS::MapADOType2Jdbc(adGUID); 892*cdf0e10cSrcweir aMap[adDate] = ADOS::MapADOType2Jdbc(adDate); 893*cdf0e10cSrcweir aMap[adDBDate] = ADOS::MapADOType2Jdbc(adDBDate); 894*cdf0e10cSrcweir aMap[adDBTime] = ADOS::MapADOType2Jdbc(adDBTime); 895*cdf0e10cSrcweir aMap[adDBTimeStamp] = ADOS::MapADOType2Jdbc(adDBTimeStamp); 896*cdf0e10cSrcweir aMap[adBSTR] = ADOS::MapADOType2Jdbc(adBSTR); 897*cdf0e10cSrcweir aMap[adChar] = ADOS::MapADOType2Jdbc(adChar); 898*cdf0e10cSrcweir aMap[adVarChar] = ADOS::MapADOType2Jdbc(adVarChar); 899*cdf0e10cSrcweir aMap[adLongVarChar] = ADOS::MapADOType2Jdbc(adLongVarChar); 900*cdf0e10cSrcweir aMap[adWChar] = ADOS::MapADOType2Jdbc(adWChar); 901*cdf0e10cSrcweir aMap[adVarWChar] = ADOS::MapADOType2Jdbc(adVarWChar); 902*cdf0e10cSrcweir aMap[adLongVarWChar] = ADOS::MapADOType2Jdbc(adLongVarWChar); 903*cdf0e10cSrcweir aMap[adBinary] = ADOS::MapADOType2Jdbc(adBinary); 904*cdf0e10cSrcweir aMap[adVarBinary] = ADOS::MapADOType2Jdbc(adVarBinary); 905*cdf0e10cSrcweir aMap[adLongVarBinary] = ADOS::MapADOType2Jdbc(adLongVarBinary); 906*cdf0e10cSrcweir aMap[adChapter] = ADOS::MapADOType2Jdbc(adChapter); 907*cdf0e10cSrcweir aMap[adFileTime] = ADOS::MapADOType2Jdbc(adFileTime); 908*cdf0e10cSrcweir aMap[adPropVariant] = ADOS::MapADOType2Jdbc(adPropVariant); 909*cdf0e10cSrcweir aMap[adVarNumeric] = ADOS::MapADOType2Jdbc(adVarNumeric); 910*cdf0e10cSrcweir // aMap[adArray] = ADOS::MapADOType2Jdbc(adArray); 911*cdf0e10cSrcweir 912*cdf0e10cSrcweir m_aValueRange[12] = aMap; 913*cdf0e10cSrcweir 914*cdf0e10cSrcweir ::std::map< sal_Int32,::rtl::OUString> aMap2; 915*cdf0e10cSrcweir aMap2[0] = ::rtl::OUString::createFromAscii("YES"); 916*cdf0e10cSrcweir aMap2[1] = ::rtl::OUString::createFromAscii("NO"); 917*cdf0e10cSrcweir m_aIntValueRange[18] = aMap2; 918*cdf0e10cSrcweir 919*cdf0e10cSrcweir ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData(m_pRecordSet,this); 920*cdf0e10cSrcweir pMetaData->setColumnsMap(); 921*cdf0e10cSrcweir m_xMetaData = pMetaData; 922*cdf0e10cSrcweir } 923*cdf0e10cSrcweir // ------------------------------------------------------------------------- 924*cdf0e10cSrcweir void ODatabaseMetaDataResultSet::setTablesMap() 925*cdf0e10cSrcweir { 926*cdf0e10cSrcweir 927*cdf0e10cSrcweir for(sal_Int32 i=1;i<5;i++) 928*cdf0e10cSrcweir m_aColMapping.push_back(i); 929*cdf0e10cSrcweir m_aColMapping.push_back(6); 930*cdf0e10cSrcweir 931*cdf0e10cSrcweir ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData(m_pRecordSet,this); 932*cdf0e10cSrcweir pMetaData->setTablesMap(); 933*cdf0e10cSrcweir m_xMetaData = pMetaData; 934*cdf0e10cSrcweir } 935*cdf0e10cSrcweir // ------------------------------------------------------------------------- 936*cdf0e10cSrcweir void ODatabaseMetaDataResultSet::setProcedureColumnsMap() 937*cdf0e10cSrcweir { 938*cdf0e10cSrcweir 939*cdf0e10cSrcweir for(sal_Int32 i=1;i<5;i++) 940*cdf0e10cSrcweir m_aColMapping.push_back(i); 941*cdf0e10cSrcweir m_aColMapping.push_back(6); 942*cdf0e10cSrcweir m_aColMapping.push_back(10); 943*cdf0e10cSrcweir m_aColMapping.push_back(16); 944*cdf0e10cSrcweir m_aColMapping.push_back(13); 945*cdf0e10cSrcweir m_aColMapping.push_back(11); 946*cdf0e10cSrcweir m_aColMapping.push_back(12); 947*cdf0e10cSrcweir 948*cdf0e10cSrcweir m_aColMapping.push_back(9); 949*cdf0e10cSrcweir m_aColMapping.push_back(14); 950*cdf0e10cSrcweir 951*cdf0e10cSrcweir TInt2IntMap aMap; 952*cdf0e10cSrcweir aMap[DBTYPE_EMPTY] = DataType::SQLNULL; 953*cdf0e10cSrcweir aMap[DBTYPE_NULL] = DataType::SQLNULL; 954*cdf0e10cSrcweir aMap[DBTYPE_I2] = DataType::SMALLINT; 955*cdf0e10cSrcweir aMap[DBTYPE_I4] = DataType::INTEGER; 956*cdf0e10cSrcweir aMap[DBTYPE_R4] = DataType::FLOAT; 957*cdf0e10cSrcweir aMap[DBTYPE_R8] = DataType::DOUBLE; 958*cdf0e10cSrcweir aMap[DBTYPE_CY] = DataType::BIGINT; 959*cdf0e10cSrcweir aMap[DBTYPE_DATE] = DataType::DATE; 960*cdf0e10cSrcweir aMap[DBTYPE_BSTR] = DataType::VARCHAR; 961*cdf0e10cSrcweir aMap[DBTYPE_IDISPATCH] = DataType::OBJECT; 962*cdf0e10cSrcweir aMap[DBTYPE_ERROR] = DataType::OTHER; 963*cdf0e10cSrcweir aMap[DBTYPE_BOOL] = DataType::BIT; 964*cdf0e10cSrcweir aMap[DBTYPE_VARIANT] = DataType::STRUCT; 965*cdf0e10cSrcweir aMap[DBTYPE_IUNKNOWN] = DataType::OTHER; 966*cdf0e10cSrcweir aMap[DBTYPE_DECIMAL] = DataType::DECIMAL; 967*cdf0e10cSrcweir aMap[DBTYPE_UI1] = DataType::TINYINT; 968*cdf0e10cSrcweir aMap[DBTYPE_ARRAY] = DataType::ARRAY; 969*cdf0e10cSrcweir aMap[DBTYPE_BYREF] = DataType::REF; 970*cdf0e10cSrcweir aMap[DBTYPE_I1] = DataType::CHAR; 971*cdf0e10cSrcweir aMap[DBTYPE_UI2] = DataType::SMALLINT; 972*cdf0e10cSrcweir aMap[DBTYPE_UI4] = DataType::INTEGER; 973*cdf0e10cSrcweir 974*cdf0e10cSrcweir // aMap[The] = ; 975*cdf0e10cSrcweir // aMap[in] = ; 976*cdf0e10cSrcweir aMap[DBTYPE_I8] = DataType::BIGINT; 977*cdf0e10cSrcweir aMap[DBTYPE_UI8] = DataType::BIGINT; 978*cdf0e10cSrcweir aMap[DBTYPE_GUID] = DataType::OTHER; 979*cdf0e10cSrcweir aMap[DBTYPE_VECTOR] = DataType::OTHER; 980*cdf0e10cSrcweir aMap[DBTYPE_FILETIME] = DataType::OTHER; 981*cdf0e10cSrcweir aMap[DBTYPE_RESERVED] = DataType::OTHER; 982*cdf0e10cSrcweir 983*cdf0e10cSrcweir // aMap[The] = ; 984*cdf0e10cSrcweir aMap[DBTYPE_BYTES] = DataType::VARBINARY; 985*cdf0e10cSrcweir aMap[DBTYPE_STR] = DataType::LONGVARCHAR; 986*cdf0e10cSrcweir aMap[DBTYPE_WSTR] = DataType::LONGVARCHAR; 987*cdf0e10cSrcweir aMap[DBTYPE_NUMERIC] = DataType::NUMERIC; 988*cdf0e10cSrcweir aMap[DBTYPE_UDT] = DataType::OTHER; 989*cdf0e10cSrcweir aMap[DBTYPE_DBDATE] = DataType::DATE; 990*cdf0e10cSrcweir aMap[DBTYPE_DBTIME] = DataType::TIME; 991*cdf0e10cSrcweir aMap[DBTYPE_DBTIMESTAMP] = DataType::TIMESTAMP; 992*cdf0e10cSrcweir aMap[DBTYPE_HCHAPTER] = DataType::OTHER; 993*cdf0e10cSrcweir aMap[DBTYPE_PROPVARIANT] = DataType::OTHER; 994*cdf0e10cSrcweir aMap[DBTYPE_VARNUMERIC] = DataType::NUMERIC; 995*cdf0e10cSrcweir 996*cdf0e10cSrcweir m_aValueRange[10] = aMap; 997*cdf0e10cSrcweir 998*cdf0e10cSrcweir ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData(m_pRecordSet,this); 999*cdf0e10cSrcweir pMetaData->setProcedureColumnsMap(); 1000*cdf0e10cSrcweir m_xMetaData = pMetaData; 1001*cdf0e10cSrcweir } 1002*cdf0e10cSrcweir // ------------------------------------------------------------------------- 1003*cdf0e10cSrcweir void ODatabaseMetaDataResultSet::setPrimaryKeysMap() 1004*cdf0e10cSrcweir { 1005*cdf0e10cSrcweir 1006*cdf0e10cSrcweir sal_Int32 i=1; 1007*cdf0e10cSrcweir for(;i<5;i++) 1008*cdf0e10cSrcweir m_aColMapping.push_back(i); 1009*cdf0e10cSrcweir m_aColMapping.push_back(7); 1010*cdf0e10cSrcweir m_aColMapping.push_back(8); 1011*cdf0e10cSrcweir 1012*cdf0e10cSrcweir ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData(m_pRecordSet,this); 1013*cdf0e10cSrcweir pMetaData->setProcedureColumnsMap(); 1014*cdf0e10cSrcweir m_xMetaData = pMetaData; 1015*cdf0e10cSrcweir } 1016*cdf0e10cSrcweir // ------------------------------------------------------------------------- 1017*cdf0e10cSrcweir void ODatabaseMetaDataResultSet::setIndexInfoMap() 1018*cdf0e10cSrcweir { 1019*cdf0e10cSrcweir 1020*cdf0e10cSrcweir sal_Int32 i=1; 1021*cdf0e10cSrcweir for(;i<4;i++) 1022*cdf0e10cSrcweir m_aColMapping.push_back(i); 1023*cdf0e10cSrcweir m_aColMapping.push_back(8); 1024*cdf0e10cSrcweir m_aColMapping.push_back(4); 1025*cdf0e10cSrcweir m_aColMapping.push_back(6); 1026*cdf0e10cSrcweir m_aColMapping.push_back(10); 1027*cdf0e10cSrcweir m_aColMapping.push_back(17); 1028*cdf0e10cSrcweir m_aColMapping.push_back(18); 1029*cdf0e10cSrcweir m_aColMapping.push_back(21); 1030*cdf0e10cSrcweir m_aColMapping.push_back(22); 1031*cdf0e10cSrcweir m_aColMapping.push_back(23); 1032*cdf0e10cSrcweir m_aColMapping.push_back(24); 1033*cdf0e10cSrcweir 1034*cdf0e10cSrcweir TInt2IntMap aMap; 1035*cdf0e10cSrcweir aMap[DBPROPVAL_IT_HASH] = IndexType::HASHED; 1036*cdf0e10cSrcweir aMap[DBPROPVAL_IT_CONTENT] = IndexType::OTHER; 1037*cdf0e10cSrcweir aMap[DBPROPVAL_IT_OTHER] = IndexType::OTHER; 1038*cdf0e10cSrcweir aMap[DBPROPVAL_IT_BTREE] = IndexType::OTHER; 1039*cdf0e10cSrcweir 1040*cdf0e10cSrcweir m_aValueRange[10] = aMap; 1041*cdf0e10cSrcweir 1042*cdf0e10cSrcweir TInt2IntMap aMap2; 1043*cdf0e10cSrcweir aMap[0] = 1; 1044*cdf0e10cSrcweir aMap[1] = 0; 1045*cdf0e10cSrcweir m_aValueRange[8] = aMap2; 1046*cdf0e10cSrcweir 1047*cdf0e10cSrcweir ::std::map< sal_Int32,::rtl::OUString> aMap3; 1048*cdf0e10cSrcweir aMap3[0] = ::rtl::OUString(); 1049*cdf0e10cSrcweir aMap3[DB_COLLATION_ASC] = ::rtl::OUString::createFromAscii("A"); 1050*cdf0e10cSrcweir aMap3[DB_COLLATION_DESC] = ::rtl::OUString::createFromAscii("D"); 1051*cdf0e10cSrcweir 1052*cdf0e10cSrcweir m_aIntValueRange[21] = aMap3; 1053*cdf0e10cSrcweir 1054*cdf0e10cSrcweir ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData(m_pRecordSet,this); 1055*cdf0e10cSrcweir pMetaData->setIndexInfoMap(); 1056*cdf0e10cSrcweir m_xMetaData = pMetaData; 1057*cdf0e10cSrcweir } 1058*cdf0e10cSrcweir // ------------------------------------------------------------------------- 1059*cdf0e10cSrcweir void ODatabaseMetaDataResultSet::setTablePrivilegesMap() 1060*cdf0e10cSrcweir { 1061*cdf0e10cSrcweir 1062*cdf0e10cSrcweir sal_Int32 i=3; 1063*cdf0e10cSrcweir for(;i<6;i++) 1064*cdf0e10cSrcweir m_aColMapping.push_back(i); 1065*cdf0e10cSrcweir m_aColMapping.push_back(1); 1066*cdf0e10cSrcweir m_aColMapping.push_back(2); 1067*cdf0e10cSrcweir m_aColMapping.push_back(6); 1068*cdf0e10cSrcweir m_aColMapping.push_back(7); 1069*cdf0e10cSrcweir 1070*cdf0e10cSrcweir ::std::map< sal_Int32,::rtl::OUString> aMap; 1071*cdf0e10cSrcweir aMap[0] = ::rtl::OUString::createFromAscii("YES"); 1072*cdf0e10cSrcweir aMap[1] = ::rtl::OUString::createFromAscii("NO"); 1073*cdf0e10cSrcweir m_aIntValueRange[7] = aMap; 1074*cdf0e10cSrcweir 1075*cdf0e10cSrcweir 1076*cdf0e10cSrcweir ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData(m_pRecordSet,this); 1077*cdf0e10cSrcweir pMetaData->setTablePrivilegesMap(); 1078*cdf0e10cSrcweir m_xMetaData = pMetaData; 1079*cdf0e10cSrcweir } 1080*cdf0e10cSrcweir // ------------------------------------------------------------------------- 1081*cdf0e10cSrcweir void ODatabaseMetaDataResultSet::setCrossReferenceMap() 1082*cdf0e10cSrcweir { 1083*cdf0e10cSrcweir 1084*cdf0e10cSrcweir sal_Int32 i=1; 1085*cdf0e10cSrcweir for(;i<5;i++) 1086*cdf0e10cSrcweir m_aColMapping.push_back(i); 1087*cdf0e10cSrcweir for(i=7;i<11;i++) 1088*cdf0e10cSrcweir m_aColMapping.push_back(i); 1089*cdf0e10cSrcweir 1090*cdf0e10cSrcweir m_aColMapping.push_back(13); 1091*cdf0e10cSrcweir m_aColMapping.push_back(14); 1092*cdf0e10cSrcweir m_aColMapping.push_back(15); 1093*cdf0e10cSrcweir m_aColMapping.push_back(17); 1094*cdf0e10cSrcweir m_aColMapping.push_back(16); 1095*cdf0e10cSrcweir m_aColMapping.push_back(18); 1096*cdf0e10cSrcweir 1097*cdf0e10cSrcweir ::std::map< ::rtl::OUString,sal_Int32> aMap; 1098*cdf0e10cSrcweir aMap[ ::rtl::OUString::createFromAscii("CASCADE")] = KeyRule::CASCADE; 1099*cdf0e10cSrcweir aMap[ ::rtl::OUString::createFromAscii("RESTRICT")] = KeyRule::RESTRICT; 1100*cdf0e10cSrcweir aMap[ ::rtl::OUString::createFromAscii("SET NULL")] = KeyRule::SET_NULL; 1101*cdf0e10cSrcweir aMap[ ::rtl::OUString::createFromAscii("SET DEFAULT")] = KeyRule::SET_DEFAULT; 1102*cdf0e10cSrcweir aMap[ ::rtl::OUString::createFromAscii("NO ACTION")] = KeyRule::NO_ACTION; 1103*cdf0e10cSrcweir 1104*cdf0e10cSrcweir m_aStrValueRange[14] = aMap; 1105*cdf0e10cSrcweir m_aStrValueRange[15] = aMap; 1106*cdf0e10cSrcweir 1107*cdf0e10cSrcweir ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData(m_pRecordSet,this); 1108*cdf0e10cSrcweir pMetaData->setCrossReferenceMap(); 1109*cdf0e10cSrcweir m_xMetaData = pMetaData; 1110*cdf0e10cSrcweir } 1111*cdf0e10cSrcweir // ------------------------------------------------------------------------- 1112*cdf0e10cSrcweir void ODatabaseMetaDataResultSet::setTypeInfoMap(sal_Bool _bJetEngine) 1113*cdf0e10cSrcweir { 1114*cdf0e10cSrcweir sal_Int32 i=1; 1115*cdf0e10cSrcweir for(;i<19;i++) 1116*cdf0e10cSrcweir m_aColMapping.push_back(i); 1117*cdf0e10cSrcweir 1118*cdf0e10cSrcweir ::std::map< ::rtl::OUString,sal_Int32> aMap1; 1119*cdf0e10cSrcweir aMap1[ ::rtl::OUString()] = 10; 1120*cdf0e10cSrcweir 1121*cdf0e10cSrcweir m_aStrValueRange[18] = aMap1; 1122*cdf0e10cSrcweir 1123*cdf0e10cSrcweir TInt2IntMap aMap; 1124*cdf0e10cSrcweir aMap[adEmpty] = ADOS::MapADOType2Jdbc(adEmpty); 1125*cdf0e10cSrcweir aMap[adTinyInt] = ADOS::MapADOType2Jdbc(adTinyInt); 1126*cdf0e10cSrcweir aMap[adSmallInt] = ADOS::MapADOType2Jdbc(adSmallInt); 1127*cdf0e10cSrcweir aMap[adInteger] = ADOS::MapADOType2Jdbc(adInteger); 1128*cdf0e10cSrcweir aMap[adBigInt] = ADOS::MapADOType2Jdbc(adBigInt); 1129*cdf0e10cSrcweir aMap[adUnsignedTinyInt] = ADOS::MapADOType2Jdbc(adUnsignedTinyInt); 1130*cdf0e10cSrcweir aMap[adUnsignedSmallInt]= ADOS::MapADOType2Jdbc(adUnsignedSmallInt); 1131*cdf0e10cSrcweir aMap[adUnsignedInt] = ADOS::MapADOType2Jdbc(adUnsignedInt); 1132*cdf0e10cSrcweir aMap[adUnsignedBigInt] = ADOS::MapADOType2Jdbc(adUnsignedBigInt); 1133*cdf0e10cSrcweir aMap[adSingle] = ADOS::MapADOType2Jdbc(adSingle); 1134*cdf0e10cSrcweir aMap[adDouble] = ADOS::MapADOType2Jdbc(adDouble); 1135*cdf0e10cSrcweir aMap[adCurrency] = ADOS::MapADOType2Jdbc(adCurrency); 1136*cdf0e10cSrcweir aMap[adDecimal] = ADOS::MapADOType2Jdbc(adDecimal); 1137*cdf0e10cSrcweir aMap[adNumeric] = ADOS::MapADOType2Jdbc(adNumeric); 1138*cdf0e10cSrcweir aMap[adBoolean] = ADOS::MapADOType2Jdbc(adBoolean); 1139*cdf0e10cSrcweir aMap[adError] = ADOS::MapADOType2Jdbc(adError); 1140*cdf0e10cSrcweir aMap[adUserDefined] = ADOS::MapADOType2Jdbc(adUserDefined); 1141*cdf0e10cSrcweir aMap[adVariant] = ADOS::MapADOType2Jdbc(adVariant); 1142*cdf0e10cSrcweir aMap[adIDispatch] = ADOS::MapADOType2Jdbc(adIDispatch); 1143*cdf0e10cSrcweir aMap[adIUnknown] = ADOS::MapADOType2Jdbc(adIUnknown); 1144*cdf0e10cSrcweir aMap[adGUID] = ADOS::MapADOType2Jdbc(adGUID); 1145*cdf0e10cSrcweir aMap[adDate] = _bJetEngine ? ADOS::MapADOType2Jdbc(adDBTimeStamp) : ADOS::MapADOType2Jdbc(adDate); 1146*cdf0e10cSrcweir aMap[adDBDate] = ADOS::MapADOType2Jdbc(adDBDate); 1147*cdf0e10cSrcweir aMap[adDBTime] = ADOS::MapADOType2Jdbc(adDBTime); 1148*cdf0e10cSrcweir aMap[adDBTimeStamp] = ADOS::MapADOType2Jdbc(adDBTimeStamp); 1149*cdf0e10cSrcweir aMap[adBSTR] = ADOS::MapADOType2Jdbc(adBSTR); 1150*cdf0e10cSrcweir aMap[adChar] = ADOS::MapADOType2Jdbc(adChar); 1151*cdf0e10cSrcweir aMap[adVarChar] = ADOS::MapADOType2Jdbc(adVarChar); 1152*cdf0e10cSrcweir aMap[adLongVarChar] = ADOS::MapADOType2Jdbc(adLongVarChar); 1153*cdf0e10cSrcweir aMap[adWChar] = ADOS::MapADOType2Jdbc(adWChar); 1154*cdf0e10cSrcweir aMap[adVarWChar] = ADOS::MapADOType2Jdbc(adVarWChar); 1155*cdf0e10cSrcweir aMap[adLongVarWChar] = ADOS::MapADOType2Jdbc(adLongVarWChar); 1156*cdf0e10cSrcweir aMap[adBinary] = ADOS::MapADOType2Jdbc(adBinary); 1157*cdf0e10cSrcweir aMap[adVarBinary] = ADOS::MapADOType2Jdbc(adVarBinary); 1158*cdf0e10cSrcweir aMap[adLongVarBinary] = ADOS::MapADOType2Jdbc(adLongVarBinary); 1159*cdf0e10cSrcweir aMap[adChapter] = ADOS::MapADOType2Jdbc(adChapter); 1160*cdf0e10cSrcweir aMap[adFileTime] = ADOS::MapADOType2Jdbc(adFileTime); 1161*cdf0e10cSrcweir aMap[adPropVariant] = ADOS::MapADOType2Jdbc(adPropVariant); 1162*cdf0e10cSrcweir aMap[adVarNumeric] = ADOS::MapADOType2Jdbc(adVarNumeric); 1163*cdf0e10cSrcweir // aMap[adArray] = ADOS::MapADOType2Jdbc(adArray); 1164*cdf0e10cSrcweir 1165*cdf0e10cSrcweir m_aValueRange[2] = aMap; 1166*cdf0e10cSrcweir 1167*cdf0e10cSrcweir TInt2IntMap aColumnValueMapping; 1168*cdf0e10cSrcweir aColumnValueMapping[VARIANT_FALSE] = ColumnValue::NO_NULLS; 1169*cdf0e10cSrcweir aColumnValueMapping[VARIANT_TRUE] = ColumnValue::NULLABLE; 1170*cdf0e10cSrcweir m_aValueRange[7] = aColumnValueMapping; 1171*cdf0e10cSrcweir 1172*cdf0e10cSrcweir // now adjust the column mapping 1173*cdf0e10cSrcweir // OJ 24.01.2002 96860 1174*cdf0e10cSrcweir TInt2IntMap aSerachMapping; 1175*cdf0e10cSrcweir aSerachMapping[DB_UNSEARCHABLE] = ColumnSearch::NONE; 1176*cdf0e10cSrcweir aSerachMapping[DB_LIKE_ONLY] = ColumnSearch::CHAR; 1177*cdf0e10cSrcweir aSerachMapping[DB_ALL_EXCEPT_LIKE] = ColumnSearch::BASIC; 1178*cdf0e10cSrcweir aSerachMapping[DB_SEARCHABLE] = ColumnSearch::FULL; 1179*cdf0e10cSrcweir 1180*cdf0e10cSrcweir m_aValueRange[9] = aSerachMapping; 1181*cdf0e10cSrcweir 1182*cdf0e10cSrcweir TInt2IntMap aCurrencyMapping; 1183*cdf0e10cSrcweir m_aValueRange[11] = aCurrencyMapping; 1184*cdf0e10cSrcweir 1185*cdf0e10cSrcweir ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData(m_pRecordSet,this); 1186*cdf0e10cSrcweir pMetaData->setTypeInfoMap(); 1187*cdf0e10cSrcweir m_xMetaData = pMetaData; 1188*cdf0e10cSrcweir } 1189*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1190*cdf0e10cSrcweir void SAL_CALL ODatabaseMetaDataResultSet::acquire() throw() 1191*cdf0e10cSrcweir { 1192*cdf0e10cSrcweir ODatabaseMetaDataResultSet_BASE::acquire(); 1193*cdf0e10cSrcweir } 1194*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1195*cdf0e10cSrcweir void SAL_CALL ODatabaseMetaDataResultSet::release() throw() 1196*cdf0e10cSrcweir { 1197*cdf0e10cSrcweir ODatabaseMetaDataResultSet_BASE::release(); 1198*cdf0e10cSrcweir } 1199*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1200*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL ODatabaseMetaDataResultSet::getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException) 1201*cdf0e10cSrcweir { 1202*cdf0e10cSrcweir return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper()); 1203*cdf0e10cSrcweir } 1204*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1205*cdf0e10cSrcweir OLEVariant ODatabaseMetaDataResultSet::getValue(sal_Int32 columnIndex ) throw(SQLException, RuntimeException) 1206*cdf0e10cSrcweir { 1207*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 1208*cdf0e10cSrcweir checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed); 1209*cdf0e10cSrcweir 1210*cdf0e10cSrcweir checkRecordSet(); 1211*cdf0e10cSrcweir 1212*cdf0e10cSrcweir WpADOField aField = ADOS::getField(m_pRecordSet,columnIndex); 1213*cdf0e10cSrcweir aField.get_Value(m_aValue); 1214*cdf0e10cSrcweir return m_aValue; 1215*cdf0e10cSrcweir } 1216*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1217*cdf0e10cSrcweir 1218*cdf0e10cSrcweir 1219