1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_ado.hxx" 26 #include "ado/AStatement.hxx" 27 #include "ado/AConnection.hxx" 28 #include "ado/AResultSet.hxx" 29 #include <comphelper/property.hxx> 30 #include <comphelper/uno3.hxx> 31 #include <osl/thread.h> 32 #include <cppuhelper/typeprovider.hxx> 33 #include <comphelper/sequence.hxx> 34 #include <com/sun/star/sdbc/ResultSetConcurrency.hpp> 35 #include <com/sun/star/sdbc/ResultSetType.hpp> 36 #include <com/sun/star/sdbc/FetchDirection.hpp> 37 #include "connectivity/dbexception.hxx" 38 #include <comphelper/types.hxx> 39 40 #undef max 41 42 #include <algorithm> 43 44 using namespace ::comphelper; 45 46 #define CHECK_RETURN(x) \ 47 if(!x) \ 48 ADOS::ThrowException(*m_pConnection->getConnection(),*this); 49 50 51 52 using namespace connectivity::ado; 53 54 //------------------------------------------------------------------------------ 55 using namespace com::sun::star::uno; 56 using namespace com::sun::star::lang; 57 using namespace com::sun::star::beans; 58 using namespace com::sun::star::sdbc; 59 using namespace ::std; 60 //------------------------------------------------------------------------------ 61 OStatement_Base::OStatement_Base(OConnection* _pConnection ) : OStatement_BASE(m_aMutex) 62 ,OPropertySetHelper(OStatement_BASE::rBHelper) 63 ,OSubComponent<OStatement_Base, OStatement_BASE>((::cppu::OWeakObject*)_pConnection, this) 64 ,m_pConnection(_pConnection) 65 ,m_nFetchSize(1) 66 ,m_nMaxRows(0) 67 ,m_eLockType(adLockReadOnly) 68 ,m_eCursorType(adOpenForwardOnly) 69 { 70 osl_incrementInterlockedCount( &m_refCount ); 71 72 m_Command.Create(); 73 if(m_Command.IsValid()) 74 m_Command.putref_ActiveConnection(m_pConnection->getConnection()); 75 else 76 ADOS::ThrowException(*m_pConnection->getConnection(),*this); 77 78 m_RecordsAffected.setNoArg(); 79 m_Parameters.setNoArg(); 80 81 m_pConnection->acquire(); 82 83 osl_decrementInterlockedCount( &m_refCount ); 84 } 85 //------------------------------------------------------------------------------ 86 void OStatement_Base::disposeResultSet() 87 { 88 // free the cursor if alive 89 Reference< XComponent > xComp(m_xResultSet.get(), UNO_QUERY); 90 if (xComp.is()) 91 xComp->dispose(); 92 m_xResultSet = Reference< XResultSet>(); 93 } 94 95 //------------------------------------------------------------------------------ 96 void OStatement_Base::disposing() 97 { 98 ::osl::MutexGuard aGuard(m_aMutex); 99 100 101 disposeResultSet(); 102 103 if ( m_Command.IsValid() ) 104 m_Command.putref_ActiveConnection( NULL ); 105 m_Command.clear(); 106 107 if ( m_RecordSet.IsValid() ) 108 m_RecordSet.PutRefDataSource( NULL ); 109 m_RecordSet.clear(); 110 111 if (m_pConnection) 112 m_pConnection->release(); 113 114 dispose_ChildImpl(); 115 OStatement_BASE::disposing(); 116 } 117 //----------------------------------------------------------------------------- 118 void SAL_CALL OStatement_Base::release() throw() 119 { 120 relase_ChildImpl(); 121 } 122 //----------------------------------------------------------------------------- 123 Any SAL_CALL OStatement_Base::queryInterface( const Type & rType ) 124 { 125 Any aRet = OStatement_BASE::queryInterface(rType); 126 return aRet.hasValue() ? aRet : OPropertySetHelper::queryInterface(rType); 127 } 128 // ------------------------------------------------------------------------- 129 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL OStatement_Base::getTypes( ) 130 { 131 ::cppu::OTypeCollection aTypes( ::getCppuType( (const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XMultiPropertySet > *)0 ), 132 ::getCppuType( (const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XFastPropertySet > *)0 ), 133 ::getCppuType( (const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > *)0 )); 134 135 return ::comphelper::concatSequences(aTypes.getTypes(),OStatement_BASE::getTypes()); 136 } 137 138 // ------------------------------------------------------------------------- 139 140 void SAL_CALL OStatement_Base::cancel( ) 141 { 142 ::osl::MutexGuard aGuard( m_aMutex ); 143 checkDisposed(OStatement_BASE::rBHelper.bDisposed); 144 145 146 CHECK_RETURN(m_Command.Cancel()) 147 } 148 // ------------------------------------------------------------------------- 149 150 void SAL_CALL OStatement_Base::close( ) 151 { 152 { 153 ::osl::MutexGuard aGuard( m_aMutex ); 154 checkDisposed(OStatement_BASE::rBHelper.bDisposed); 155 156 } 157 dispose(); 158 } 159 // ------------------------------------------------------------------------- 160 161 void SAL_CALL OStatement::clearBatch( ) 162 { 163 164 } 165 // ------------------------------------------------------------------------- 166 167 void OStatement_Base::reset() 168 { 169 ::osl::MutexGuard aGuard( m_aMutex ); 170 checkDisposed(OStatement_BASE::rBHelper.bDisposed); 171 172 173 clearWarnings (); 174 175 if (m_xResultSet.get().is()) 176 clearMyResultSet(); 177 } 178 //-------------------------------------------------------------------- 179 // clearMyResultSet 180 // If a ResultSet was created for this Statement, close it 181 //-------------------------------------------------------------------- 182 183 void OStatement_Base::clearMyResultSet () 184 { 185 ::osl::MutexGuard aGuard( m_aMutex ); 186 checkDisposed(OStatement_BASE::rBHelper.bDisposed); 187 188 try 189 { 190 Reference<XCloseable> xCloseable; 191 if ( ::comphelper::query_interface( m_xResultSet.get(), xCloseable ) ) 192 xCloseable->close(); 193 } 194 catch( const DisposedException& ) { } 195 196 m_xResultSet = Reference< XResultSet >(); 197 } 198 //-------------------------------------------------------------------- 199 sal_Int32 OStatement_Base::getRowCount () 200 { 201 ::osl::MutexGuard aGuard( m_aMutex ); 202 checkDisposed(OStatement_BASE::rBHelper.bDisposed); 203 204 205 return m_RecordsAffected; 206 } 207 //-------------------------------------------------------------------- 208 // getPrecision 209 // Given a SQL type, return the maximum precision for the column. 210 // Returns -1 if not known 211 //-------------------------------------------------------------------- 212 213 sal_Int32 OStatement_Base::getPrecision ( sal_Int32 sqlType) 214 { 215 ::osl::MutexGuard aGuard( m_aMutex ); 216 checkDisposed(OStatement_BASE::rBHelper.bDisposed); 217 218 219 sal_Int32 prec = -1; 220 OTypeInfo aInfo; 221 aInfo.nType = (sal_Int16)sqlType; 222 if (!m_aTypeInfo.empty()) 223 { 224 ::std::vector<OTypeInfo>::const_iterator aIter = ::std::find(m_aTypeInfo.begin(),m_aTypeInfo.end(),aInfo); 225 for(;aIter != m_aTypeInfo.end();++aIter) 226 { 227 prec = ::std::max(prec,(*aIter).nPrecision); 228 } 229 } 230 231 return prec; 232 } 233 //-------------------------------------------------------------------- 234 // setWarning 235 // Sets the warning 236 //-------------------------------------------------------------------- 237 238 void OStatement_Base::setWarning (const SQLWarning &ex) 239 { 240 ::osl::MutexGuard aGuard( m_aMutex ); 241 checkDisposed(OStatement_BASE::rBHelper.bDisposed); 242 243 244 m_aLastWarning = ex; 245 } 246 // ------------------------------------------------------------------------- 247 void OStatement_Base::assignRecordSet( ADORecordset* _pRS ) 248 { 249 WpADORecordset aOldRS( m_RecordSet ); 250 m_RecordSet = WpADORecordset( _pRS ); 251 252 if ( aOldRS.IsValid() ) 253 aOldRS.PutRefDataSource( NULL ); 254 255 if ( m_RecordSet.IsValid() ) 256 m_RecordSet.PutRefDataSource( (IDispatch*)m_Command ); 257 } 258 // ------------------------------------------------------------------------- 259 sal_Bool SAL_CALL OStatement_Base::execute( const ::rtl::OUString& sql ) 260 { 261 ::osl::MutexGuard aGuard( m_aMutex ); 262 checkDisposed(OStatement_BASE::rBHelper.bDisposed); 263 264 265 // Reset the statement handle and warning 266 267 reset(); 268 269 try 270 { 271 ADORecordset* pSet = NULL; 272 CHECK_RETURN(m_Command.put_CommandText(sql)) 273 CHECK_RETURN(m_Command.Execute(m_RecordsAffected,m_Parameters,adCmdText,&pSet)) 274 275 assignRecordSet( pSet ); 276 } 277 catch (SQLWarning& ex) 278 { 279 280 // Save pointer to warning and save with ResultSet 281 // object once it is created. 282 283 m_aLastWarning = ex; 284 } 285 286 return m_RecordSet.IsValid(); 287 } 288 // ------------------------------------------------------------------------- 289 Reference< XResultSet > SAL_CALL OStatement_Base::executeQuery( const ::rtl::OUString& sql ) 290 { 291 ::osl::MutexGuard aGuard( m_aMutex ); 292 checkDisposed(OStatement_BASE::rBHelper.bDisposed); 293 294 295 reset(); 296 297 m_xResultSet = WeakReference<XResultSet>(NULL); 298 299 WpADORecordset aSet; 300 aSet.Create(); 301 CHECK_RETURN(m_Command.put_CommandText(sql)) 302 OLEVariant aCmd; 303 aCmd.setIDispatch(m_Command); 304 OLEVariant aCon; 305 aCon.setNoArg(); 306 CHECK_RETURN(aSet.put_CacheSize(m_nFetchSize)) 307 sal_IntPtr maxRows = m_nMaxRows; 308 CHECK_RETURN(aSet.put_MaxRecords(maxRows)) 309 CHECK_RETURN(aSet.Open(aCmd,aCon,m_eCursorType,m_eLockType,adOpenUnspecified)) 310 311 312 CHECK_RETURN(aSet.get_CacheSize(m_nFetchSize)) 313 CHECK_RETURN(aSet.get_MaxRecords(maxRows)) 314 m_nMaxRows = maxRows; 315 CHECK_RETURN(aSet.get_CursorType(m_eCursorType)) 316 CHECK_RETURN(aSet.get_LockType(m_eLockType)) 317 318 OResultSet* pSet = new OResultSet(aSet,this); 319 Reference< XResultSet > xRs = pSet; 320 pSet->construct(); 321 322 m_xResultSet = WeakReference<XResultSet>(xRs); 323 324 return xRs; 325 } 326 // ------------------------------------------------------------------------- 327 328 Reference< XConnection > SAL_CALL OStatement_Base::getConnection( ) 329 { 330 ::osl::MutexGuard aGuard( m_aMutex ); 331 checkDisposed(OStatement_BASE::rBHelper.bDisposed); 332 333 334 return (Reference< XConnection >)m_pConnection; 335 } 336 // ------------------------------------------------------------------------- 337 338 Any SAL_CALL OStatement::queryInterface( const Type & rType ) 339 { 340 Any aRet = ::cppu::queryInterface(rType,static_cast< XBatchExecution*> (this)); 341 return aRet.hasValue() ? aRet : OStatement_Base::queryInterface(rType); 342 } 343 // ------------------------------------------------------------------------- 344 345 void SAL_CALL OStatement::addBatch( const ::rtl::OUString& sql ) 346 { 347 ::osl::MutexGuard aGuard( m_aMutex ); 348 checkDisposed(OStatement_BASE::rBHelper.bDisposed); 349 350 351 m_aBatchList.push_back(sql); 352 } 353 // ------------------------------------------------------------------------- 354 Sequence< sal_Int32 > SAL_CALL OStatement::executeBatch( ) 355 { 356 ::osl::MutexGuard aGuard( m_aMutex ); 357 checkDisposed(OStatement_BASE::rBHelper.bDisposed); 358 359 360 reset(); 361 362 ::rtl::OUString aBatchSql; 363 sal_Int32 nLen = 0; 364 for(::std::list< ::rtl::OUString>::const_iterator i=m_aBatchList.begin();i != m_aBatchList.end();++i,++nLen) 365 aBatchSql = aBatchSql + *i + ::rtl::OUString::createFromAscii(";"); 366 367 368 if ( m_RecordSet.IsValid() ) 369 m_RecordSet.PutRefDataSource( NULL ); 370 m_RecordSet.clear(); 371 m_RecordSet.Create(); 372 373 CHECK_RETURN(m_Command.put_CommandText(aBatchSql)) 374 if ( m_RecordSet.IsValid() ) 375 m_RecordSet.PutRefDataSource((IDispatch*)m_Command); 376 377 CHECK_RETURN(m_RecordSet.UpdateBatch(adAffectAll)) 378 379 ADORecordset* pSet=NULL; 380 Sequence< sal_Int32 > aRet(nLen); 381 sal_Int32* pArray = aRet.getArray(); 382 for(sal_Int32 j=0;j<nLen;++j) 383 { 384 pSet = NULL; 385 OLEVariant aRecordsAffected; 386 if(m_RecordSet.NextRecordset(aRecordsAffected,&pSet) && pSet) 387 { 388 assignRecordSet( pSet ); 389 390 sal_IntPtr nValue; 391 if(m_RecordSet.get_RecordCount(nValue)) 392 pArray[j] = nValue; 393 } 394 } 395 return aRet; 396 } 397 // ------------------------------------------------------------------------- 398 399 400 sal_Int32 SAL_CALL OStatement_Base::executeUpdate( const ::rtl::OUString& sql ) 401 { 402 ::osl::MutexGuard aGuard( m_aMutex ); 403 checkDisposed(OStatement_BASE::rBHelper.bDisposed); 404 405 406 reset(); 407 408 try { 409 ADORecordset* pSet = NULL; 410 CHECK_RETURN(m_Command.put_CommandText(sql)) 411 CHECK_RETURN(m_Command.Execute(m_RecordsAffected,m_Parameters,adCmdText|adExecuteNoRecords,&pSet)) 412 } 413 catch (SQLWarning& ex) { 414 415 // Save pointer to warning and save with ResultSet 416 // object once it is created. 417 418 m_aLastWarning = ex; 419 } 420 if(!m_RecordsAffected.isEmpty() && !m_RecordsAffected.isNull() && m_RecordsAffected.getType() != VT_ERROR) 421 return m_RecordsAffected; 422 423 return 0; 424 } 425 // ------------------------------------------------------------------------- 426 427 Reference< XResultSet > SAL_CALL OStatement_Base::getResultSet( ) 428 { 429 ::osl::MutexGuard aGuard( m_aMutex ); 430 checkDisposed(OStatement_BASE::rBHelper.bDisposed); 431 432 433 return m_xResultSet; 434 } 435 // ------------------------------------------------------------------------- 436 437 sal_Int32 SAL_CALL OStatement_Base::getUpdateCount( ) 438 { 439 ::osl::MutexGuard aGuard( m_aMutex ); 440 checkDisposed(OStatement_BASE::rBHelper.bDisposed); 441 442 443 sal_IntPtr nRet; 444 if(m_RecordSet.IsValid() && m_RecordSet.get_RecordCount(nRet)) 445 return nRet; 446 return -1; 447 } 448 // ------------------------------------------------------------------------- 449 450 sal_Bool SAL_CALL OStatement_Base::getMoreResults( ) 451 { 452 ::osl::MutexGuard aGuard( m_aMutex ); 453 checkDisposed(OStatement_BASE::rBHelper.bDisposed); 454 455 456 SQLWarning warning; 457 458 // clear previous warnings 459 460 clearWarnings (); 461 462 // Call SQLMoreResults 463 464 try 465 { 466 ADORecordset* pSet=NULL; 467 OLEVariant aRecordsAffected; 468 if(m_RecordSet.IsValid() && m_RecordSet.NextRecordset(aRecordsAffected,&pSet) && pSet) 469 assignRecordSet( pSet ); 470 } 471 catch (SQLWarning &ex) 472 { 473 474 // Save pointer to warning and save with ResultSet 475 // object once it is created. 476 477 warning = ex; 478 } 479 return m_RecordSet.IsValid(); 480 } 481 // ------------------------------------------------------------------------- 482 483 // ------------------------------------------------------------------------- 484 Any SAL_CALL OStatement_Base::getWarnings( ) 485 { 486 ::osl::MutexGuard aGuard( m_aMutex ); 487 checkDisposed(OStatement_BASE::rBHelper.bDisposed); 488 489 490 return makeAny(m_aLastWarning); 491 } 492 // ------------------------------------------------------------------------- 493 494 // ------------------------------------------------------------------------- 495 void SAL_CALL OStatement_Base::clearWarnings( ) 496 { 497 ::osl::MutexGuard aGuard( m_aMutex ); 498 checkDisposed(OStatement_BASE::rBHelper.bDisposed); 499 500 501 m_aLastWarning = SQLWarning(); 502 } 503 // ------------------------------------------------------------------------- 504 //------------------------------------------------------------------------------ 505 sal_Int32 OStatement_Base::getQueryTimeOut() const 506 { 507 return m_Command.get_CommandTimeout(); 508 } 509 //------------------------------------------------------------------------------ 510 sal_Int32 OStatement_Base::getMaxRows() const 511 { 512 sal_IntPtr nRet=-1; 513 if(!(m_RecordSet.IsValid() && m_RecordSet.get_MaxRecords(nRet))) 514 ::dbtools::throwFunctionSequenceException(NULL); 515 return nRet; 516 } 517 //------------------------------------------------------------------------------ 518 sal_Int32 OStatement_Base::getResultSetConcurrency() const 519 { 520 return m_eLockType; 521 sal_Int32 nValue=0; 522 switch(m_eLockType) 523 { 524 case adLockReadOnly: 525 nValue = ResultSetConcurrency::READ_ONLY; 526 break; 527 default: 528 nValue = ResultSetConcurrency::UPDATABLE; 529 break; 530 } 531 532 return nValue; 533 } 534 //------------------------------------------------------------------------------ 535 sal_Int32 OStatement_Base::getResultSetType() const 536 { 537 sal_Int32 nValue=0; 538 switch(m_eCursorType) 539 { 540 case adOpenUnspecified: 541 case adOpenForwardOnly: 542 nValue = ResultSetType::FORWARD_ONLY; 543 break; 544 case adOpenStatic: 545 case adOpenKeyset: 546 nValue = ResultSetType::SCROLL_INSENSITIVE; 547 break; 548 case adOpenDynamic: 549 nValue = ResultSetType::SCROLL_SENSITIVE; 550 break; 551 } 552 return nValue; 553 } 554 //------------------------------------------------------------------------------ 555 sal_Int32 OStatement_Base::getFetchDirection() const 556 { 557 return FetchDirection::FORWARD; 558 } 559 //------------------------------------------------------------------------------ 560 sal_Int32 OStatement_Base::getFetchSize() const 561 { 562 return m_nFetchSize; 563 } 564 //------------------------------------------------------------------------------ 565 sal_Int32 OStatement_Base::getMaxFieldSize() const 566 { 567 return 0; 568 } 569 //------------------------------------------------------------------------------ 570 ::rtl::OUString OStatement_Base::getCursorName() const 571 { 572 return m_Command.GetName(); 573 } 574 //------------------------------------------------------------------------------ 575 void OStatement_Base::setQueryTimeOut(sal_Int32 seconds) 576 { 577 ::osl::MutexGuard aGuard( m_aMutex ); 578 checkDisposed(OStatement_BASE::rBHelper.bDisposed); 579 580 581 m_Command.put_CommandTimeout(seconds); 582 } 583 //------------------------------------------------------------------------------ 584 void OStatement_Base::setMaxRows(sal_Int32 _par0) 585 { 586 ::osl::MutexGuard aGuard( m_aMutex ); 587 checkDisposed(OStatement_BASE::rBHelper.bDisposed); 588 589 m_nMaxRows = _par0; 590 } 591 //------------------------------------------------------------------------------ 592 void OStatement_Base::setResultSetConcurrency(sal_Int32 _par0) 593 { 594 ::osl::MutexGuard aGuard( m_aMutex ); 595 checkDisposed(OStatement_BASE::rBHelper.bDisposed); 596 597 switch(_par0) 598 { 599 case ResultSetConcurrency::READ_ONLY: 600 m_eLockType = adLockReadOnly; 601 break; 602 default: 603 m_eLockType = adLockOptimistic; 604 break; 605 } 606 } 607 //------------------------------------------------------------------------------ 608 void OStatement_Base::setResultSetType(sal_Int32 _par0) 609 { 610 ::osl::MutexGuard aGuard( m_aMutex ); 611 checkDisposed(OStatement_BASE::rBHelper.bDisposed); 612 613 614 switch(_par0) 615 { 616 case ResultSetType::FORWARD_ONLY: 617 m_eCursorType = adOpenForwardOnly; 618 break; 619 case ResultSetType::SCROLL_INSENSITIVE: 620 m_eCursorType = adOpenKeyset; 621 break; 622 case ResultSetType::SCROLL_SENSITIVE: 623 m_eCursorType = adOpenDynamic; 624 break; 625 } 626 } 627 //------------------------------------------------------------------------------ 628 void OStatement_Base::setFetchDirection(sal_Int32 /*_par0*/) 629 { 630 ::osl::MutexGuard aGuard( m_aMutex ); 631 checkDisposed(OStatement_BASE::rBHelper.bDisposed); 632 ::dbtools::throwFeatureNotImplementedException( "Statement::FetchDirection", *this ); 633 } 634 //------------------------------------------------------------------------------ 635 void OStatement_Base::setFetchSize(sal_Int32 _par0) 636 { 637 ::osl::MutexGuard aGuard( m_aMutex ); 638 checkDisposed(OStatement_BASE::rBHelper.bDisposed); 639 640 641 m_nFetchSize = _par0; 642 // m_RecordSet.put_CacheSize(_par0); 643 } 644 //------------------------------------------------------------------------------ 645 void OStatement_Base::setMaxFieldSize(sal_Int32 /*_par0*/) 646 { 647 ::osl::MutexGuard aGuard( m_aMutex ); 648 checkDisposed(OStatement_BASE::rBHelper.bDisposed); 649 ::dbtools::throwFeatureNotImplementedException( "Statement::MaxFieldSize", *this ); 650 } 651 //------------------------------------------------------------------------------ 652 void OStatement_Base::setCursorName(const ::rtl::OUString &_par0) 653 { 654 ::osl::MutexGuard aGuard( m_aMutex ); 655 checkDisposed(OStatement_BASE::rBHelper.bDisposed); 656 657 m_Command.put_Name(_par0); 658 } 659 660 // ------------------------------------------------------------------------- 661 ::cppu::IPropertyArrayHelper* OStatement_Base::createArrayHelper( ) const 662 { 663 Sequence< com::sun::star::beans::Property > aProps(10); 664 com::sun::star::beans::Property* pProperties = aProps.getArray(); 665 sal_Int32 nPos = 0; 666 DECL_PROP0(CURSORNAME, ::rtl::OUString); 667 DECL_BOOL_PROP0(ESCAPEPROCESSING); 668 DECL_PROP0(FETCHDIRECTION,sal_Int32); 669 DECL_PROP0(FETCHSIZE, sal_Int32); 670 DECL_PROP0(MAXFIELDSIZE,sal_Int32); 671 DECL_PROP0(MAXROWS, sal_Int32); 672 DECL_PROP0(QUERYTIMEOUT,sal_Int32); 673 DECL_PROP0(RESULTSETCONCURRENCY,sal_Int32); 674 DECL_PROP0(RESULTSETTYPE,sal_Int32); 675 DECL_BOOL_PROP0(USEBOOKMARKS); 676 677 678 return new ::cppu::OPropertyArrayHelper(aProps); 679 } 680 681 // ------------------------------------------------------------------------- 682 ::cppu::IPropertyArrayHelper & OStatement_Base::getInfoHelper() 683 { 684 return *const_cast<OStatement_Base*>(this)->getArrayHelper(); 685 } 686 // ------------------------------------------------------------------------- 687 sal_Bool OStatement_Base::convertFastPropertyValue( 688 Any & rConvertedValue, 689 Any & rOldValue, 690 sal_Int32 nHandle, 691 const Any& rValue ) 692 { 693 sal_Bool bModified = sal_False; 694 695 sal_Bool bValidAdoRS = m_RecordSet.IsValid(); 696 // some of the properties below, when set, are remembered in a member, and applied in the next execute 697 // For these properties, the record set does not need to be valid to allow setting them. 698 // For all others (where the values are forwarded to the ADO RS directly), the recordset must be valid. 699 700 try 701 { 702 switch(nHandle) 703 { 704 case PROPERTY_ID_MAXROWS: 705 bModified = ::comphelper::tryPropertyValue( rConvertedValue, rOldValue, rValue, bValidAdoRS ? getMaxRows() : m_nMaxRows ); 706 break; 707 708 case PROPERTY_ID_RESULTSETTYPE: 709 bModified = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getResultSetType()); 710 break; 711 case PROPERTY_ID_FETCHSIZE: 712 bModified = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getFetchSize()); 713 break; 714 case PROPERTY_ID_RESULTSETCONCURRENCY: 715 bModified = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getResultSetConcurrency()); 716 break; 717 case PROPERTY_ID_QUERYTIMEOUT: 718 bModified = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getQueryTimeOut()); 719 break; 720 case PROPERTY_ID_MAXFIELDSIZE: 721 bModified = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getMaxFieldSize()); 722 break; 723 case PROPERTY_ID_CURSORNAME: 724 bModified = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getCursorName()); 725 break; 726 case PROPERTY_ID_FETCHDIRECTION: 727 bModified = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getFetchDirection()); 728 break; 729 } 730 } 731 catch( const Exception& e ) 732 { 733 bModified = sal_True; // will ensure that the property is set 734 OSL_ENSURE( sal_False, "OStatement_Base::convertFastPropertyValue: caught something strange!" ); 735 (void)e; 736 } 737 return bModified; 738 } 739 // ------------------------------------------------------------------------- 740 void OStatement_Base::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& rValue) 741 { 742 switch(nHandle) 743 { 744 case PROPERTY_ID_QUERYTIMEOUT: 745 setQueryTimeOut(comphelper::getINT32(rValue)); 746 break; 747 case PROPERTY_ID_MAXFIELDSIZE: 748 setMaxFieldSize(comphelper::getINT32(rValue)); 749 break; 750 case PROPERTY_ID_MAXROWS: 751 setMaxRows(comphelper::getINT32(rValue)); 752 break; 753 case PROPERTY_ID_CURSORNAME: 754 setCursorName(comphelper::getString(rValue)); 755 break; 756 case PROPERTY_ID_RESULTSETCONCURRENCY: 757 setResultSetConcurrency(comphelper::getINT32(rValue)); 758 break; 759 case PROPERTY_ID_RESULTSETTYPE: 760 setResultSetType(comphelper::getINT32(rValue)); 761 break; 762 case PROPERTY_ID_FETCHDIRECTION: 763 setFetchDirection(comphelper::getINT32(rValue)); 764 break; 765 case PROPERTY_ID_FETCHSIZE: 766 setFetchSize(comphelper::getINT32(rValue)); 767 break; 768 case PROPERTY_ID_ESCAPEPROCESSING: 769 // return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, m_bAsLink); 770 case PROPERTY_ID_USEBOOKMARKS: 771 // return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, m_bAsLink); 772 default: 773 ; 774 } 775 } 776 // ------------------------------------------------------------------------- 777 void OStatement_Base::getFastPropertyValue(Any& rValue,sal_Int32 nHandle) const 778 { 779 switch(nHandle) 780 { 781 case PROPERTY_ID_QUERYTIMEOUT: 782 rValue <<= getQueryTimeOut(); 783 break; 784 case PROPERTY_ID_MAXFIELDSIZE: 785 rValue <<= getMaxFieldSize(); 786 break; 787 case PROPERTY_ID_MAXROWS: 788 rValue <<= getMaxRows(); 789 break; 790 case PROPERTY_ID_CURSORNAME: 791 rValue <<= getCursorName(); 792 break; 793 case PROPERTY_ID_RESULTSETCONCURRENCY: 794 rValue <<= getResultSetConcurrency(); 795 break; 796 case PROPERTY_ID_RESULTSETTYPE: 797 rValue <<= getResultSetType(); 798 break; 799 case PROPERTY_ID_FETCHDIRECTION: 800 rValue <<= getFetchDirection(); 801 break; 802 case PROPERTY_ID_FETCHSIZE: 803 rValue <<= getFetchSize(); 804 break; 805 case PROPERTY_ID_ESCAPEPROCESSING: 806 rValue <<= sal_True; 807 break; 808 case PROPERTY_ID_USEBOOKMARKS: 809 default: 810 ; 811 } 812 } 813 // ------------------------------------------------------------------------- 814 OStatement::~OStatement() 815 { 816 } 817 IMPLEMENT_SERVICE_INFO(OStatement,"com.sun.star.sdbcx.AStatement","com.sun.star.sdbc.Statement"); 818 // ----------------------------------------------------------------------------- 819 void SAL_CALL OStatement_Base::acquire() throw() 820 { 821 OStatement_BASE::acquire(); 822 } 823 // ----------------------------------------------------------------------------- 824 void SAL_CALL OStatement::acquire() throw() 825 { 826 OStatement_Base::acquire(); 827 } 828 // ----------------------------------------------------------------------------- 829 void SAL_CALL OStatement::release() throw() 830 { 831 OStatement_Base::release(); 832 } 833 // ----------------------------------------------------------------------------- 834 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL OStatement_Base::getPropertySetInfo( ) 835 { 836 return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper()); 837 } 838 // ----------------------------------------------------------------------------- 839