1*89dcb3daSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*89dcb3daSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*89dcb3daSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*89dcb3daSAndrew Rist * distributed with this work for additional information 6*89dcb3daSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*89dcb3daSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*89dcb3daSAndrew Rist * "License"); you may not use this file except in compliance 9*89dcb3daSAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*89dcb3daSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*89dcb3daSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*89dcb3daSAndrew Rist * software distributed under the License is distributed on an 15*89dcb3daSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*89dcb3daSAndrew Rist * KIND, either express or implied. See the License for the 17*89dcb3daSAndrew Rist * specific language governing permissions and limitations 18*89dcb3daSAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*89dcb3daSAndrew Rist *************************************************************/ 21*89dcb3daSAndrew Rist 22*89dcb3daSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_xmlhelp.hxx" 26cdf0e10cSrcweir #include <ucbhelper/contentidentifier.hxx> 27cdf0e10cSrcweir #include <com/sun/star/ucb/OpenMode.hpp> 28cdf0e10cSrcweir #include <com/sun/star/uno/Reference.h> 29cdf0e10cSrcweir #ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBBUTE_HPP_ 30cdf0e10cSrcweir #include <com/sun/star/beans/PropertyAttribute.hpp> 31cdf0e10cSrcweir #endif 32cdf0e10cSrcweir #include <com/sun/star/ucb/ListActionType.hpp> 33cdf0e10cSrcweir #include <com/sun/star/ucb/XSourceInitialization.hpp> 34cdf0e10cSrcweir #include <ucbhelper/resultsetmetadata.hxx> 35cdf0e10cSrcweir 36cdf0e10cSrcweir #include "resultsetbase.hxx" 37cdf0e10cSrcweir 38cdf0e10cSrcweir using namespace chelp; 39cdf0e10cSrcweir using namespace com::sun::star; 40cdf0e10cSrcweir 41cdf0e10cSrcweir ResultSetBase::ResultSetBase( const uno::Reference< lang::XMultiServiceFactory >& xMSF, 42cdf0e10cSrcweir const uno::Reference< ucb::XContentProvider >& xProvider, 43cdf0e10cSrcweir sal_Int32 nOpenMode, 44cdf0e10cSrcweir const uno::Sequence< beans::Property >& seq, 45cdf0e10cSrcweir const uno::Sequence< ucb::NumberedSortingInfo >& seqSort ) 46cdf0e10cSrcweir : m_xMSF( xMSF ), 47cdf0e10cSrcweir m_xProvider( xProvider ), 48cdf0e10cSrcweir m_nRow( -1 ), 49cdf0e10cSrcweir m_nWasNull( true ), 50cdf0e10cSrcweir m_nOpenMode( nOpenMode ), 51cdf0e10cSrcweir m_bRowCountFinal( true ), 52cdf0e10cSrcweir m_sProperty( seq ), 53cdf0e10cSrcweir m_sSortingInfo( seqSort ), 54cdf0e10cSrcweir m_pDisposeEventListeners( 0 ), 55cdf0e10cSrcweir m_pRowCountListeners( 0 ), 56cdf0e10cSrcweir m_pIsFinalListeners( 0 ) 57cdf0e10cSrcweir { 58cdf0e10cSrcweir } 59cdf0e10cSrcweir 60cdf0e10cSrcweir ResultSetBase::~ResultSetBase() 61cdf0e10cSrcweir { 62cdf0e10cSrcweir delete m_pIsFinalListeners; 63cdf0e10cSrcweir delete m_pRowCountListeners; 64cdf0e10cSrcweir delete m_pDisposeEventListeners; 65cdf0e10cSrcweir } 66cdf0e10cSrcweir 67cdf0e10cSrcweir 68cdf0e10cSrcweir // XInterface 69cdf0e10cSrcweir 70cdf0e10cSrcweir void SAL_CALL 71cdf0e10cSrcweir ResultSetBase::acquire( 72cdf0e10cSrcweir void ) 73cdf0e10cSrcweir throw() 74cdf0e10cSrcweir { 75cdf0e10cSrcweir OWeakObject::acquire(); 76cdf0e10cSrcweir } 77cdf0e10cSrcweir 78cdf0e10cSrcweir 79cdf0e10cSrcweir void SAL_CALL 80cdf0e10cSrcweir ResultSetBase::release( 81cdf0e10cSrcweir void ) 82cdf0e10cSrcweir throw() 83cdf0e10cSrcweir { 84cdf0e10cSrcweir OWeakObject::release(); 85cdf0e10cSrcweir } 86cdf0e10cSrcweir 87cdf0e10cSrcweir 88cdf0e10cSrcweir 89cdf0e10cSrcweir uno::Any SAL_CALL 90cdf0e10cSrcweir ResultSetBase::queryInterface( 91cdf0e10cSrcweir const uno::Type& rType ) 92cdf0e10cSrcweir throw( uno::RuntimeException ) 93cdf0e10cSrcweir { 94cdf0e10cSrcweir uno::Any aRet = cppu::queryInterface( rType, 95cdf0e10cSrcweir SAL_STATIC_CAST( lang::XComponent*, this), 96cdf0e10cSrcweir SAL_STATIC_CAST( sdbc::XRow*, this), 97cdf0e10cSrcweir SAL_STATIC_CAST( sdbc::XResultSet*, this), 98cdf0e10cSrcweir SAL_STATIC_CAST( sdbc::XResultSetMetaDataSupplier*, this), 99cdf0e10cSrcweir SAL_STATIC_CAST( beans::XPropertySet*, this ), 100cdf0e10cSrcweir SAL_STATIC_CAST( ucb::XContentAccess*, this) ); 101cdf0e10cSrcweir return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType ); 102cdf0e10cSrcweir } 103cdf0e10cSrcweir 104cdf0e10cSrcweir 105cdf0e10cSrcweir 106cdf0e10cSrcweir // XComponent 107cdf0e10cSrcweir 108cdf0e10cSrcweir 109cdf0e10cSrcweir void SAL_CALL 110cdf0e10cSrcweir ResultSetBase::addEventListener( 111cdf0e10cSrcweir const uno::Reference< lang::XEventListener >& Listener ) 112cdf0e10cSrcweir throw( uno::RuntimeException ) 113cdf0e10cSrcweir { 114cdf0e10cSrcweir osl::MutexGuard aGuard( m_aMutex ); 115cdf0e10cSrcweir 116cdf0e10cSrcweir if ( ! m_pDisposeEventListeners ) 117cdf0e10cSrcweir m_pDisposeEventListeners = 118cdf0e10cSrcweir new cppu::OInterfaceContainerHelper( m_aMutex ); 119cdf0e10cSrcweir 120cdf0e10cSrcweir m_pDisposeEventListeners->addInterface( Listener ); 121cdf0e10cSrcweir } 122cdf0e10cSrcweir 123cdf0e10cSrcweir 124cdf0e10cSrcweir void SAL_CALL 125cdf0e10cSrcweir ResultSetBase::removeEventListener( 126cdf0e10cSrcweir const uno::Reference< lang::XEventListener >& Listener ) 127cdf0e10cSrcweir throw( uno::RuntimeException ) 128cdf0e10cSrcweir { 129cdf0e10cSrcweir osl::MutexGuard aGuard( m_aMutex ); 130cdf0e10cSrcweir 131cdf0e10cSrcweir if ( m_pDisposeEventListeners ) 132cdf0e10cSrcweir m_pDisposeEventListeners->removeInterface( Listener ); 133cdf0e10cSrcweir } 134cdf0e10cSrcweir 135cdf0e10cSrcweir 136cdf0e10cSrcweir 137cdf0e10cSrcweir void SAL_CALL 138cdf0e10cSrcweir ResultSetBase::dispose() 139cdf0e10cSrcweir throw( uno::RuntimeException ) 140cdf0e10cSrcweir { 141cdf0e10cSrcweir osl::MutexGuard aGuard( m_aMutex ); 142cdf0e10cSrcweir 143cdf0e10cSrcweir lang::EventObject aEvt; 144cdf0e10cSrcweir aEvt.Source = static_cast< lang::XComponent * >( this ); 145cdf0e10cSrcweir 146cdf0e10cSrcweir if ( m_pDisposeEventListeners && m_pDisposeEventListeners->getLength() ) 147cdf0e10cSrcweir { 148cdf0e10cSrcweir m_pDisposeEventListeners->disposeAndClear( aEvt ); 149cdf0e10cSrcweir } 150cdf0e10cSrcweir if( m_pRowCountListeners && m_pRowCountListeners->getLength() ) 151cdf0e10cSrcweir { 152cdf0e10cSrcweir m_pRowCountListeners->disposeAndClear( aEvt ); 153cdf0e10cSrcweir } 154cdf0e10cSrcweir if( m_pIsFinalListeners && m_pIsFinalListeners->getLength() ) 155cdf0e10cSrcweir { 156cdf0e10cSrcweir m_pIsFinalListeners->disposeAndClear( aEvt ); 157cdf0e10cSrcweir } 158cdf0e10cSrcweir } 159cdf0e10cSrcweir 160cdf0e10cSrcweir 161cdf0e10cSrcweir 162cdf0e10cSrcweir // XResultSet 163cdf0e10cSrcweir 164cdf0e10cSrcweir sal_Bool SAL_CALL 165cdf0e10cSrcweir ResultSetBase::next( 166cdf0e10cSrcweir void ) 167cdf0e10cSrcweir throw( sdbc::SQLException, 168cdf0e10cSrcweir uno::RuntimeException ) 169cdf0e10cSrcweir { 170cdf0e10cSrcweir sal_Bool test; 171cdf0e10cSrcweir m_nRow++; 172cdf0e10cSrcweir if( sal::static_int_cast<sal_uInt32>( m_nRow ) < m_aItems.size() ) 173cdf0e10cSrcweir test = true; 174cdf0e10cSrcweir else 175cdf0e10cSrcweir test = false; 176cdf0e10cSrcweir return test; 177cdf0e10cSrcweir } 178cdf0e10cSrcweir 179cdf0e10cSrcweir 180cdf0e10cSrcweir sal_Bool SAL_CALL 181cdf0e10cSrcweir ResultSetBase::isBeforeFirst( 182cdf0e10cSrcweir void ) 183cdf0e10cSrcweir throw( sdbc::SQLException, 184cdf0e10cSrcweir uno::RuntimeException ) 185cdf0e10cSrcweir { 186cdf0e10cSrcweir return m_nRow == -1; 187cdf0e10cSrcweir } 188cdf0e10cSrcweir 189cdf0e10cSrcweir 190cdf0e10cSrcweir sal_Bool SAL_CALL 191cdf0e10cSrcweir ResultSetBase::isAfterLast( 192cdf0e10cSrcweir void ) 193cdf0e10cSrcweir throw( sdbc::SQLException, 194cdf0e10cSrcweir uno::RuntimeException ) 195cdf0e10cSrcweir { 196cdf0e10cSrcweir return sal::static_int_cast<sal_uInt32>( m_nRow ) >= m_aItems.size(); // Cannot happen, if m_aFolder.isOpen() 197cdf0e10cSrcweir } 198cdf0e10cSrcweir 199cdf0e10cSrcweir 200cdf0e10cSrcweir sal_Bool SAL_CALL 201cdf0e10cSrcweir ResultSetBase::isFirst( 202cdf0e10cSrcweir void ) 203cdf0e10cSrcweir throw( sdbc::SQLException, 204cdf0e10cSrcweir uno::RuntimeException ) 205cdf0e10cSrcweir { 206cdf0e10cSrcweir return m_nRow == 0; 207cdf0e10cSrcweir } 208cdf0e10cSrcweir 209cdf0e10cSrcweir 210cdf0e10cSrcweir sal_Bool SAL_CALL 211cdf0e10cSrcweir ResultSetBase::isLast( 212cdf0e10cSrcweir void ) 213cdf0e10cSrcweir throw( sdbc::SQLException, 214cdf0e10cSrcweir uno::RuntimeException) 215cdf0e10cSrcweir { 216cdf0e10cSrcweir if( sal::static_int_cast<sal_uInt32>( m_nRow ) == m_aItems.size() - 1 ) 217cdf0e10cSrcweir return true; 218cdf0e10cSrcweir else 219cdf0e10cSrcweir return false; 220cdf0e10cSrcweir } 221cdf0e10cSrcweir 222cdf0e10cSrcweir 223cdf0e10cSrcweir void SAL_CALL 224cdf0e10cSrcweir ResultSetBase::beforeFirst( 225cdf0e10cSrcweir void ) 226cdf0e10cSrcweir throw( sdbc::SQLException, 227cdf0e10cSrcweir uno::RuntimeException) 228cdf0e10cSrcweir { 229cdf0e10cSrcweir m_nRow = -1; 230cdf0e10cSrcweir } 231cdf0e10cSrcweir 232cdf0e10cSrcweir 233cdf0e10cSrcweir void SAL_CALL 234cdf0e10cSrcweir ResultSetBase::afterLast( 235cdf0e10cSrcweir void ) 236cdf0e10cSrcweir throw( sdbc::SQLException, 237cdf0e10cSrcweir uno::RuntimeException ) 238cdf0e10cSrcweir { 239cdf0e10cSrcweir m_nRow = m_aItems.size(); 240cdf0e10cSrcweir } 241cdf0e10cSrcweir 242cdf0e10cSrcweir 243cdf0e10cSrcweir sal_Bool SAL_CALL 244cdf0e10cSrcweir ResultSetBase::first( 245cdf0e10cSrcweir void ) 246cdf0e10cSrcweir throw( sdbc::SQLException, 247cdf0e10cSrcweir uno::RuntimeException) 248cdf0e10cSrcweir { 249cdf0e10cSrcweir m_nRow = -1; 250cdf0e10cSrcweir return next(); 251cdf0e10cSrcweir } 252cdf0e10cSrcweir 253cdf0e10cSrcweir 254cdf0e10cSrcweir sal_Bool SAL_CALL 255cdf0e10cSrcweir ResultSetBase::last( 256cdf0e10cSrcweir void ) 257cdf0e10cSrcweir throw( sdbc::SQLException, 258cdf0e10cSrcweir uno::RuntimeException ) 259cdf0e10cSrcweir { 260cdf0e10cSrcweir m_nRow = m_aItems.size() - 1; 261cdf0e10cSrcweir return true; 262cdf0e10cSrcweir } 263cdf0e10cSrcweir 264cdf0e10cSrcweir 265cdf0e10cSrcweir sal_Int32 SAL_CALL 266cdf0e10cSrcweir ResultSetBase::getRow( 267cdf0e10cSrcweir void ) 268cdf0e10cSrcweir throw( sdbc::SQLException, 269cdf0e10cSrcweir uno::RuntimeException) 270cdf0e10cSrcweir { 271cdf0e10cSrcweir // Test, whether behind last row 272cdf0e10cSrcweir if( -1 == m_nRow || sal::static_int_cast<sal_uInt32>( m_nRow ) >= m_aItems.size() ) 273cdf0e10cSrcweir return 0; 274cdf0e10cSrcweir else 275cdf0e10cSrcweir return m_nRow+1; 276cdf0e10cSrcweir } 277cdf0e10cSrcweir 278cdf0e10cSrcweir 279cdf0e10cSrcweir sal_Bool SAL_CALL ResultSetBase::absolute( sal_Int32 row ) 280cdf0e10cSrcweir throw( sdbc::SQLException, uno::RuntimeException) 281cdf0e10cSrcweir { 282cdf0e10cSrcweir if( row >= 0 ) 283cdf0e10cSrcweir m_nRow = row - 1; 284cdf0e10cSrcweir else 285cdf0e10cSrcweir { 286cdf0e10cSrcweir last(); 287cdf0e10cSrcweir m_nRow += ( row + 1 ); 288cdf0e10cSrcweir if( m_nRow < -1 ) 289cdf0e10cSrcweir m_nRow = -1; 290cdf0e10cSrcweir } 291cdf0e10cSrcweir 292cdf0e10cSrcweir return 0<= m_nRow && sal::static_int_cast<sal_uInt32>( m_nRow ) < m_aItems.size(); 293cdf0e10cSrcweir } 294cdf0e10cSrcweir 295cdf0e10cSrcweir 296cdf0e10cSrcweir 297cdf0e10cSrcweir 298cdf0e10cSrcweir sal_Bool SAL_CALL 299cdf0e10cSrcweir ResultSetBase::relative( 300cdf0e10cSrcweir sal_Int32 row ) 301cdf0e10cSrcweir throw( sdbc::SQLException, 302cdf0e10cSrcweir uno::RuntimeException) 303cdf0e10cSrcweir { 304cdf0e10cSrcweir if( isAfterLast() || isBeforeFirst() ) 305cdf0e10cSrcweir throw sdbc::SQLException(); 306cdf0e10cSrcweir 307cdf0e10cSrcweir if( row > 0 ) 308cdf0e10cSrcweir while( row-- ) 309cdf0e10cSrcweir next(); 310cdf0e10cSrcweir else if( row < 0 ) 311cdf0e10cSrcweir while( row++ && m_nRow > -1 ) 312cdf0e10cSrcweir previous(); 313cdf0e10cSrcweir 314cdf0e10cSrcweir return 0 <= m_nRow && sal::static_int_cast<sal_uInt32>( m_nRow ) < m_aItems.size(); 315cdf0e10cSrcweir } 316cdf0e10cSrcweir 317cdf0e10cSrcweir 318cdf0e10cSrcweir 319cdf0e10cSrcweir sal_Bool SAL_CALL 320cdf0e10cSrcweir ResultSetBase::previous( 321cdf0e10cSrcweir void ) 322cdf0e10cSrcweir throw( sdbc::SQLException, 323cdf0e10cSrcweir uno::RuntimeException) 324cdf0e10cSrcweir { 325cdf0e10cSrcweir if( sal::static_int_cast<sal_uInt32>( m_nRow ) > m_aItems.size() ) 326cdf0e10cSrcweir m_nRow = m_aItems.size(); // Correct Handling of afterLast 327cdf0e10cSrcweir if( 0 <= m_nRow ) -- m_nRow; 328cdf0e10cSrcweir 329cdf0e10cSrcweir return 0 <= m_nRow && sal::static_int_cast<sal_uInt32>( m_nRow ) < m_aItems.size(); 330cdf0e10cSrcweir } 331cdf0e10cSrcweir 332cdf0e10cSrcweir 333cdf0e10cSrcweir void SAL_CALL 334cdf0e10cSrcweir ResultSetBase::refreshRow( 335cdf0e10cSrcweir void ) 336cdf0e10cSrcweir throw( sdbc::SQLException, 337cdf0e10cSrcweir uno::RuntimeException) 338cdf0e10cSrcweir { 339cdf0e10cSrcweir } 340cdf0e10cSrcweir 341cdf0e10cSrcweir 342cdf0e10cSrcweir sal_Bool SAL_CALL 343cdf0e10cSrcweir ResultSetBase::rowUpdated( 344cdf0e10cSrcweir void ) 345cdf0e10cSrcweir throw( sdbc::SQLException, 346cdf0e10cSrcweir uno::RuntimeException ) 347cdf0e10cSrcweir { 348cdf0e10cSrcweir return false; 349cdf0e10cSrcweir } 350cdf0e10cSrcweir 351cdf0e10cSrcweir sal_Bool SAL_CALL 352cdf0e10cSrcweir ResultSetBase::rowInserted( 353cdf0e10cSrcweir void ) 354cdf0e10cSrcweir throw( sdbc::SQLException, 355cdf0e10cSrcweir uno::RuntimeException ) 356cdf0e10cSrcweir { 357cdf0e10cSrcweir return false; 358cdf0e10cSrcweir } 359cdf0e10cSrcweir 360cdf0e10cSrcweir sal_Bool SAL_CALL 361cdf0e10cSrcweir ResultSetBase::rowDeleted( 362cdf0e10cSrcweir void ) 363cdf0e10cSrcweir throw( sdbc::SQLException, 364cdf0e10cSrcweir uno::RuntimeException ) 365cdf0e10cSrcweir { 366cdf0e10cSrcweir return false; 367cdf0e10cSrcweir } 368cdf0e10cSrcweir 369cdf0e10cSrcweir 370cdf0e10cSrcweir uno::Reference< uno::XInterface > SAL_CALL 371cdf0e10cSrcweir ResultSetBase::getStatement( 372cdf0e10cSrcweir void ) 373cdf0e10cSrcweir throw( sdbc::SQLException, 374cdf0e10cSrcweir uno::RuntimeException ) 375cdf0e10cSrcweir { 376cdf0e10cSrcweir uno::Reference< uno::XInterface > test( 0 ); 377cdf0e10cSrcweir return test; 378cdf0e10cSrcweir } 379cdf0e10cSrcweir 380cdf0e10cSrcweir 381cdf0e10cSrcweir // XCloseable 382cdf0e10cSrcweir 383cdf0e10cSrcweir void SAL_CALL 384cdf0e10cSrcweir ResultSetBase::close( 385cdf0e10cSrcweir void ) 386cdf0e10cSrcweir throw( sdbc::SQLException, 387cdf0e10cSrcweir uno::RuntimeException) 388cdf0e10cSrcweir { 389cdf0e10cSrcweir } 390cdf0e10cSrcweir 391cdf0e10cSrcweir 392cdf0e10cSrcweir rtl::OUString SAL_CALL 393cdf0e10cSrcweir ResultSetBase::queryContentIdentifierString( 394cdf0e10cSrcweir void ) 395cdf0e10cSrcweir throw( uno::RuntimeException ) 396cdf0e10cSrcweir { 397cdf0e10cSrcweir if( 0 <= m_nRow && sal::static_int_cast<sal_uInt32>( m_nRow ) < m_aItems.size() ) 398cdf0e10cSrcweir return m_aPath[m_nRow]; 399cdf0e10cSrcweir else 400cdf0e10cSrcweir return rtl::OUString(); 401cdf0e10cSrcweir } 402cdf0e10cSrcweir 403cdf0e10cSrcweir 404cdf0e10cSrcweir uno::Reference< ucb::XContentIdentifier > SAL_CALL 405cdf0e10cSrcweir ResultSetBase::queryContentIdentifier( 406cdf0e10cSrcweir void ) 407cdf0e10cSrcweir throw( uno::RuntimeException ) 408cdf0e10cSrcweir { 409cdf0e10cSrcweir if( 0 <= m_nRow && sal::static_int_cast<sal_uInt32>( m_nRow ) < m_aItems.size() ) 410cdf0e10cSrcweir { 411cdf0e10cSrcweir rtl::OUString url = queryContentIdentifierString(); 412cdf0e10cSrcweir if( ! m_aIdents[m_nRow].is() && url.getLength() ) 413cdf0e10cSrcweir m_aIdents[m_nRow] = uno::Reference< ucb::XContentIdentifier >( 414cdf0e10cSrcweir new ::ucbhelper::ContentIdentifier( m_xMSF,url ) ); 415cdf0e10cSrcweir return m_aIdents[m_nRow]; 416cdf0e10cSrcweir } 417cdf0e10cSrcweir 418cdf0e10cSrcweir return uno::Reference< ucb::XContentIdentifier >(); 419cdf0e10cSrcweir } 420cdf0e10cSrcweir 421cdf0e10cSrcweir 422cdf0e10cSrcweir uno::Reference< ucb::XContent > SAL_CALL 423cdf0e10cSrcweir ResultSetBase::queryContent( 424cdf0e10cSrcweir void ) 425cdf0e10cSrcweir throw( uno::RuntimeException ) 426cdf0e10cSrcweir { 427cdf0e10cSrcweir if( 0 <= m_nRow && sal::static_int_cast<sal_uInt32>( m_nRow ) < m_aItems.size() ) 428cdf0e10cSrcweir return m_xProvider->queryContent( queryContentIdentifier() ); 429cdf0e10cSrcweir else 430cdf0e10cSrcweir return uno::Reference< ucb::XContent >(); 431cdf0e10cSrcweir } 432cdf0e10cSrcweir 433cdf0e10cSrcweir 434cdf0e10cSrcweir 435cdf0e10cSrcweir class XPropertySetInfoImpl 436cdf0e10cSrcweir : public cppu::OWeakObject, 437cdf0e10cSrcweir public beans::XPropertySetInfo 438cdf0e10cSrcweir { 439cdf0e10cSrcweir public: 440cdf0e10cSrcweir 441cdf0e10cSrcweir XPropertySetInfoImpl( const uno::Sequence< beans::Property >& aSeq ) 442cdf0e10cSrcweir : m_aSeq( aSeq ) 443cdf0e10cSrcweir { 444cdf0e10cSrcweir } 445cdf0e10cSrcweir 446cdf0e10cSrcweir void SAL_CALL acquire( void ) 447cdf0e10cSrcweir throw() 448cdf0e10cSrcweir { 449cdf0e10cSrcweir OWeakObject::acquire(); 450cdf0e10cSrcweir } 451cdf0e10cSrcweir 452cdf0e10cSrcweir 453cdf0e10cSrcweir void SAL_CALL release( void ) 454cdf0e10cSrcweir throw() 455cdf0e10cSrcweir { 456cdf0e10cSrcweir OWeakObject::release(); 457cdf0e10cSrcweir } 458cdf0e10cSrcweir 459cdf0e10cSrcweir uno::Any SAL_CALL queryInterface( const uno::Type& rType ) 460cdf0e10cSrcweir throw( uno::RuntimeException ) 461cdf0e10cSrcweir { 462cdf0e10cSrcweir uno::Any aRet = cppu::queryInterface( rType, 463cdf0e10cSrcweir SAL_STATIC_CAST( beans::XPropertySetInfo*, this ) ); 464cdf0e10cSrcweir return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType ); 465cdf0e10cSrcweir } 466cdf0e10cSrcweir 467cdf0e10cSrcweir uno::Sequence< beans::Property > SAL_CALL getProperties() 468cdf0e10cSrcweir throw( uno::RuntimeException ) 469cdf0e10cSrcweir { 470cdf0e10cSrcweir return m_aSeq; 471cdf0e10cSrcweir } 472cdf0e10cSrcweir 473cdf0e10cSrcweir beans::Property SAL_CALL getPropertyByName( const ::rtl::OUString& aName ) 474cdf0e10cSrcweir throw( beans::UnknownPropertyException, 475cdf0e10cSrcweir uno::RuntimeException) 476cdf0e10cSrcweir { 477cdf0e10cSrcweir for( int i = 0; i < m_aSeq.getLength(); ++i ) 478cdf0e10cSrcweir if( aName == m_aSeq[i].Name ) 479cdf0e10cSrcweir return m_aSeq[i]; 480cdf0e10cSrcweir throw beans::UnknownPropertyException(); 481cdf0e10cSrcweir } 482cdf0e10cSrcweir 483cdf0e10cSrcweir sal_Bool SAL_CALL hasPropertyByName( const ::rtl::OUString& Name ) 484cdf0e10cSrcweir throw( uno::RuntimeException ) 485cdf0e10cSrcweir { 486cdf0e10cSrcweir for( int i = 0; i < m_aSeq.getLength(); ++i ) 487cdf0e10cSrcweir if( Name == m_aSeq[i].Name ) 488cdf0e10cSrcweir return true; 489cdf0e10cSrcweir return false; 490cdf0e10cSrcweir } 491cdf0e10cSrcweir 492cdf0e10cSrcweir private: 493cdf0e10cSrcweir 494cdf0e10cSrcweir uno::Sequence< beans::Property > m_aSeq; 495cdf0e10cSrcweir }; 496cdf0e10cSrcweir 497cdf0e10cSrcweir 498cdf0e10cSrcweir 499cdf0e10cSrcweir // XPropertySet 500cdf0e10cSrcweir uno::Reference< beans::XPropertySetInfo > SAL_CALL 501cdf0e10cSrcweir ResultSetBase::getPropertySetInfo() 502cdf0e10cSrcweir throw( uno::RuntimeException) 503cdf0e10cSrcweir { 504cdf0e10cSrcweir uno::Sequence< beans::Property > seq(2); 505cdf0e10cSrcweir seq[0].Name = rtl::OUString::createFromAscii( "RowCount" ); 506cdf0e10cSrcweir seq[0].Handle = -1; 507cdf0e10cSrcweir seq[0].Type = getCppuType( static_cast< sal_Int32* >(0) ); 508cdf0e10cSrcweir seq[0].Attributes = beans::PropertyAttribute::READONLY; 509cdf0e10cSrcweir 510cdf0e10cSrcweir seq[1].Name = rtl::OUString::createFromAscii( "IsRowCountFinal" ); 511cdf0e10cSrcweir seq[1].Handle = -1; 512cdf0e10cSrcweir seq[1].Type = getCppuType( static_cast< sal_Bool* >(0) ); 513cdf0e10cSrcweir seq[1].Attributes = beans::PropertyAttribute::READONLY; 514cdf0e10cSrcweir 515cdf0e10cSrcweir //t 516cdf0e10cSrcweir return uno::Reference< beans::XPropertySetInfo > ( new XPropertySetInfoImpl( seq ) ); 517cdf0e10cSrcweir } 518cdf0e10cSrcweir 519cdf0e10cSrcweir 520cdf0e10cSrcweir 521cdf0e10cSrcweir void SAL_CALL ResultSetBase::setPropertyValue( 522cdf0e10cSrcweir const rtl::OUString& aPropertyName, const uno::Any& aValue ) 523cdf0e10cSrcweir throw( beans::UnknownPropertyException, 524cdf0e10cSrcweir beans::PropertyVetoException, 525cdf0e10cSrcweir lang::IllegalArgumentException, 526cdf0e10cSrcweir lang::WrappedTargetException, 527cdf0e10cSrcweir uno::RuntimeException) 528cdf0e10cSrcweir { 529cdf0e10cSrcweir (void)aValue; 530cdf0e10cSrcweir 531cdf0e10cSrcweir if( aPropertyName == rtl::OUString::createFromAscii( "IsRowCountFinal" ) || 532cdf0e10cSrcweir aPropertyName == rtl::OUString::createFromAscii( "RowCount" ) ) 533cdf0e10cSrcweir return; 534cdf0e10cSrcweir 535cdf0e10cSrcweir throw beans::UnknownPropertyException(); 536cdf0e10cSrcweir } 537cdf0e10cSrcweir 538cdf0e10cSrcweir 539cdf0e10cSrcweir uno::Any SAL_CALL ResultSetBase::getPropertyValue( 540cdf0e10cSrcweir const rtl::OUString& PropertyName ) 541cdf0e10cSrcweir throw( beans::UnknownPropertyException, 542cdf0e10cSrcweir lang::WrappedTargetException, 543cdf0e10cSrcweir uno::RuntimeException) 544cdf0e10cSrcweir { 545cdf0e10cSrcweir if( PropertyName == rtl::OUString::createFromAscii( "IsRowCountFinal" ) ) 546cdf0e10cSrcweir { 547cdf0e10cSrcweir uno::Any aAny; 548cdf0e10cSrcweir aAny <<= m_bRowCountFinal; 549cdf0e10cSrcweir return aAny; 550cdf0e10cSrcweir } 551cdf0e10cSrcweir else if ( PropertyName == rtl::OUString::createFromAscii( "RowCount" ) ) 552cdf0e10cSrcweir { 553cdf0e10cSrcweir uno::Any aAny; 554cdf0e10cSrcweir sal_Int32 count = m_aItems.size(); 555cdf0e10cSrcweir aAny <<= count; 556cdf0e10cSrcweir return aAny; 557cdf0e10cSrcweir } 558cdf0e10cSrcweir else 559cdf0e10cSrcweir throw beans::UnknownPropertyException(); 560cdf0e10cSrcweir } 561cdf0e10cSrcweir 562cdf0e10cSrcweir 563cdf0e10cSrcweir void SAL_CALL ResultSetBase::addPropertyChangeListener( 564cdf0e10cSrcweir const rtl::OUString& aPropertyName, 565cdf0e10cSrcweir const uno::Reference< beans::XPropertyChangeListener >& xListener ) 566cdf0e10cSrcweir throw( beans::UnknownPropertyException, 567cdf0e10cSrcweir lang::WrappedTargetException, 568cdf0e10cSrcweir uno::RuntimeException) 569cdf0e10cSrcweir { 570cdf0e10cSrcweir if( aPropertyName == rtl::OUString::createFromAscii( "IsRowCountFinal" ) ) 571cdf0e10cSrcweir { 572cdf0e10cSrcweir osl::MutexGuard aGuard( m_aMutex ); 573cdf0e10cSrcweir if ( ! m_pIsFinalListeners ) 574cdf0e10cSrcweir m_pIsFinalListeners = 575cdf0e10cSrcweir new cppu::OInterfaceContainerHelper( m_aMutex ); 576cdf0e10cSrcweir 577cdf0e10cSrcweir m_pIsFinalListeners->addInterface( xListener ); 578cdf0e10cSrcweir } 579cdf0e10cSrcweir else if ( aPropertyName == rtl::OUString::createFromAscii( "RowCount" ) ) 580cdf0e10cSrcweir { 581cdf0e10cSrcweir osl::MutexGuard aGuard( m_aMutex ); 582cdf0e10cSrcweir if ( ! m_pRowCountListeners ) 583cdf0e10cSrcweir m_pRowCountListeners = 584cdf0e10cSrcweir new cppu::OInterfaceContainerHelper( m_aMutex ); 585cdf0e10cSrcweir m_pRowCountListeners->addInterface( xListener ); 586cdf0e10cSrcweir } 587cdf0e10cSrcweir else 588cdf0e10cSrcweir throw beans::UnknownPropertyException(); 589cdf0e10cSrcweir } 590cdf0e10cSrcweir 591cdf0e10cSrcweir 592cdf0e10cSrcweir void SAL_CALL ResultSetBase::removePropertyChangeListener( 593cdf0e10cSrcweir const rtl::OUString& aPropertyName, 594cdf0e10cSrcweir const uno::Reference< beans::XPropertyChangeListener >& aListener ) 595cdf0e10cSrcweir throw( beans::UnknownPropertyException, 596cdf0e10cSrcweir lang::WrappedTargetException, 597cdf0e10cSrcweir uno::RuntimeException) 598cdf0e10cSrcweir { 599cdf0e10cSrcweir if( aPropertyName == rtl::OUString::createFromAscii( "IsRowCountFinal" ) && 600cdf0e10cSrcweir m_pIsFinalListeners ) 601cdf0e10cSrcweir { 602cdf0e10cSrcweir osl::MutexGuard aGuard( m_aMutex ); 603cdf0e10cSrcweir m_pIsFinalListeners->removeInterface( aListener ); 604cdf0e10cSrcweir } 605cdf0e10cSrcweir else if ( aPropertyName == rtl::OUString::createFromAscii( "RowCount" ) && 606cdf0e10cSrcweir m_pRowCountListeners ) 607cdf0e10cSrcweir { 608cdf0e10cSrcweir osl::MutexGuard aGuard( m_aMutex ); 609cdf0e10cSrcweir m_pRowCountListeners->removeInterface( aListener ); 610cdf0e10cSrcweir } 611cdf0e10cSrcweir else 612cdf0e10cSrcweir throw beans::UnknownPropertyException(); 613cdf0e10cSrcweir } 614cdf0e10cSrcweir 615cdf0e10cSrcweir 616cdf0e10cSrcweir void SAL_CALL ResultSetBase::addVetoableChangeListener( 617cdf0e10cSrcweir const rtl::OUString& PropertyName, 618cdf0e10cSrcweir const uno::Reference< beans::XVetoableChangeListener >& aListener ) 619cdf0e10cSrcweir throw( beans::UnknownPropertyException, 620cdf0e10cSrcweir lang::WrappedTargetException, 621cdf0e10cSrcweir uno::RuntimeException) 622cdf0e10cSrcweir { 623cdf0e10cSrcweir (void)PropertyName; 624cdf0e10cSrcweir (void)aListener; 625cdf0e10cSrcweir } 626cdf0e10cSrcweir 627cdf0e10cSrcweir 628cdf0e10cSrcweir void SAL_CALL ResultSetBase::removeVetoableChangeListener( 629cdf0e10cSrcweir const rtl::OUString& PropertyName, 630cdf0e10cSrcweir const uno::Reference< beans::XVetoableChangeListener >& aListener ) 631cdf0e10cSrcweir throw( beans::UnknownPropertyException, 632cdf0e10cSrcweir lang::WrappedTargetException, 633cdf0e10cSrcweir uno::RuntimeException) 634cdf0e10cSrcweir { 635cdf0e10cSrcweir (void)PropertyName; 636cdf0e10cSrcweir (void)aListener; 637cdf0e10cSrcweir } 638cdf0e10cSrcweir 639cdf0e10cSrcweir 640cdf0e10cSrcweir 641cdf0e10cSrcweir // XResultSetMetaDataSupplier 642cdf0e10cSrcweir uno::Reference< sdbc::XResultSetMetaData > SAL_CALL 643cdf0e10cSrcweir ResultSetBase::getMetaData( 644cdf0e10cSrcweir void ) 645cdf0e10cSrcweir throw( sdbc::SQLException, 646cdf0e10cSrcweir uno::RuntimeException ) 647cdf0e10cSrcweir { 648cdf0e10cSrcweir ::ucbhelper::ResultSetMetaData* p = 649cdf0e10cSrcweir new ::ucbhelper::ResultSetMetaData( 650cdf0e10cSrcweir m_xMSF, m_sProperty ); 651cdf0e10cSrcweir return uno::Reference< sdbc::XResultSetMetaData >( p ); 652cdf0e10cSrcweir } 653