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