update dev300-m58
[ooovba.git] / ucb / source / ucp / file / filrset.cxx
blob134db87e19a29498858504c7a5a9bcb4cc14daa2
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: filrset.cxx,v $
10 * $Revision: 1.21 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_ucb.hxx"
33 #include <com/sun/star/ucb/WelcomeDynamicResultSetStruct.hpp>
34 #include "filid.hxx"
35 #include "shell.hxx"
36 #include "filprp.hxx"
37 #include "filrset.hxx"
38 #include <com/sun/star/ucb/OpenMode.hpp>
39 #include "prov.hxx"
40 #include <com/sun/star/uno/Reference.h>
42 #ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBBUTE_HPP_
43 #include <com/sun/star/beans/PropertyAttribute.hpp>
44 #endif
45 #include <com/sun/star/ucb/ListActionType.hpp>
46 #include <com/sun/star/ucb/XSourceInitialization.hpp>
47 #include <com/sun/star/ucb/XCachedDynamicResultSetStubFactory.hpp>
48 #include <ucbhelper/resultsetmetadata.hxx>
50 using namespace fileaccess;
51 using namespace com::sun::star;
53 XResultSet_impl::XResultSet_impl(
54 shell* pMyShell,
55 const rtl::OUString& aUnqPath,
56 sal_Int32 OpenMode,
57 const uno::Sequence< beans::Property >& seq,
58 const uno::Sequence< ucb::NumberedSortingInfo >& seqSort )
59 : m_pMyShell( pMyShell ),
60 m_xProvider( pMyShell->m_pProvider ),
61 m_nRow( -1 ),
62 m_nOpenMode( OpenMode ),
63 m_bRowCountFinal( false ),
64 m_aBaseDirectory( aUnqPath ),
65 m_aFolder( aUnqPath ),
66 m_sProperty( seq ),
67 m_sSortingInfo( seqSort ),
68 m_pDisposeEventListeners( 0 ),
69 m_pRowCountListeners( 0 ),
70 m_pIsFinalListeners( 0 ),
71 m_bStatic( false ),
72 m_nErrorCode( TASKHANDLER_NO_ERROR ),
73 m_nMinorErrorCode( TASKHANDLER_NO_ERROR )
75 osl::FileBase::RC err = m_aFolder.open();
76 if( err != osl::FileBase::E_None )
78 m_nIsOpen = false;
79 m_aFolder.close();
81 m_nErrorCode = TASKHANDLING_OPEN_FOR_DIRECTORYLISTING;
82 m_nMinorErrorCode = err;
84 else
85 m_nIsOpen = true;
87 m_pMyShell->registerNotifier( m_aBaseDirectory,this );
91 XResultSet_impl::~XResultSet_impl()
93 m_pMyShell->deregisterNotifier( m_aBaseDirectory,this );
95 if( m_nIsOpen )
96 m_aFolder.close();
98 delete m_pDisposeEventListeners;
99 delete m_pRowCountListeners;
100 delete m_pIsFinalListeners;
105 sal_Int32 SAL_CALL XResultSet_impl::CtorSuccess()
107 return m_nErrorCode;
112 sal_Int32 SAL_CALL XResultSet_impl::getMinorError()
114 return m_nMinorErrorCode;
118 void SAL_CALL
119 XResultSet_impl::acquire(
120 void )
121 throw()
123 OWeakObject::acquire();
127 void SAL_CALL
128 XResultSet_impl::release(
129 void )
130 throw()
132 OWeakObject::release();
137 uno::Any SAL_CALL
138 XResultSet_impl::queryInterface(
139 const uno::Type& rType )
140 throw( uno::RuntimeException )
142 uno::Any aRet = cppu::queryInterface(
143 rType,
144 SAL_STATIC_CAST( lang::XComponent*, this),
145 SAL_STATIC_CAST( lang::XTypeProvider*, this),
146 SAL_STATIC_CAST( lang::XEventListener*, this),
147 SAL_STATIC_CAST( sdbc::XRow*, this),
148 SAL_STATIC_CAST( sdbc::XResultSet*, this),
149 SAL_STATIC_CAST( sdbc::XCloseable*, this),
150 SAL_STATIC_CAST( sdbc::XResultSetMetaDataSupplier*, this),
151 SAL_STATIC_CAST( beans::XPropertySet*, this ),
152 SAL_STATIC_CAST( ucb::XContentAccess*, this),
153 SAL_STATIC_CAST( ucb::XDynamicResultSet*,this) );
154 return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType );
158 void SAL_CALL
159 XResultSet_impl::disposing( const lang::EventObject& )
160 throw( uno::RuntimeException )
162 // To do, but what
166 XTYPEPROVIDER_IMPL_10( XResultSet_impl,
167 lang::XTypeProvider,
168 lang::XTypeProvider,
169 lang::XEventListener,
170 sdbc::XRow,
171 sdbc::XResultSet,
172 XDynamicResultSet,
173 sdbc::XCloseable,
174 sdbc::XResultSetMetaDataSupplier,
175 beans::XPropertySet,
176 ucb::XContentAccess )
179 void SAL_CALL
180 XResultSet_impl::addEventListener(
181 const uno::Reference< lang::XEventListener >& Listener )
182 throw( uno::RuntimeException )
184 osl::MutexGuard aGuard( m_aMutex );
186 if ( ! m_pDisposeEventListeners )
187 m_pDisposeEventListeners =
188 new cppu::OInterfaceContainerHelper( m_aEventListenerMutex );
190 m_pDisposeEventListeners->addInterface( Listener );
194 void SAL_CALL
195 XResultSet_impl::removeEventListener(
196 const uno::Reference< lang::XEventListener >& Listener )
197 throw( uno::RuntimeException )
199 osl::MutexGuard aGuard( m_aMutex );
201 if ( m_pDisposeEventListeners )
202 m_pDisposeEventListeners->removeInterface( Listener );
207 void SAL_CALL
208 XResultSet_impl::dispose()
209 throw( uno::RuntimeException )
211 osl::MutexGuard aGuard( m_aMutex );
213 lang::EventObject aEvt;
214 aEvt.Source = static_cast< lang::XComponent * >( this );
216 if ( m_pDisposeEventListeners && m_pDisposeEventListeners->getLength() )
218 m_pDisposeEventListeners->disposeAndClear( aEvt );
220 if( m_pRowCountListeners && m_pRowCountListeners->getLength() )
222 m_pRowCountListeners->disposeAndClear( aEvt );
224 if( m_pIsFinalListeners && m_pIsFinalListeners->getLength() )
226 m_pIsFinalListeners->disposeAndClear( aEvt );
232 void XResultSet_impl::rowCountChanged()
234 sal_Int32 aOldValue,aNewValue;
235 uno::Sequence< uno::Reference< uno::XInterface > > seq;
237 osl::MutexGuard aGuard( m_aMutex );
238 if( m_pRowCountListeners )
239 seq = m_pRowCountListeners->getElements();
240 aNewValue = m_aItems.size();
241 aOldValue = aNewValue-1;
243 beans::PropertyChangeEvent aEv;
244 aEv.PropertyName = rtl::OUString::createFromAscii( "RowCount" );
245 aEv.Further = false;
246 aEv.PropertyHandle = -1;
247 aEv.OldValue <<= aOldValue;
248 aEv.NewValue <<= aNewValue;
249 for( sal_Int32 i = 0; i < seq.getLength(); ++i )
251 uno::Reference< beans::XPropertyChangeListener > listener(
252 seq[i], uno::UNO_QUERY );
253 if( listener.is() )
254 listener->propertyChange( aEv );
259 void XResultSet_impl::isFinalChanged()
261 uno::Sequence< uno::Reference< XInterface > > seq;
263 osl::MutexGuard aGuard( m_aMutex );
264 if( m_pIsFinalListeners )
265 seq = m_pIsFinalListeners->getElements();
266 m_bRowCountFinal = true;
268 beans::PropertyChangeEvent aEv;
269 aEv.PropertyName = rtl::OUString::createFromAscii( "IsRowCountFinal" );
270 aEv.Further = false;
271 aEv.PropertyHandle = -1;
272 sal_Bool fval = false;
273 sal_Bool tval = true;
274 aEv.OldValue <<= fval;
275 aEv.NewValue <<= tval;
276 for( sal_Int32 i = 0; i < seq.getLength(); ++i )
278 uno::Reference< beans::XPropertyChangeListener > listener(
279 seq[i], uno::UNO_QUERY );
280 if( listener.is() )
281 listener->propertyChange( aEv );
286 sal_Bool SAL_CALL
287 XResultSet_impl::OneMore(
288 void )
289 throw( sdbc::SQLException,
290 uno::RuntimeException )
292 if( ! m_nIsOpen )
293 return false;
295 osl::FileBase::RC err;
296 sal_Bool IsRegular;
297 rtl::OUString aUnqPath;
298 osl::DirectoryItem m_aDirIte;
299 uno::Reference< sdbc::XRow > aRow;
301 while( true )
303 err = m_aFolder.getNextItem( m_aDirIte );
305 if( err == osl::FileBase::E_NOENT || err == osl::FileBase::E_INVAL )
307 m_aFolder.close();
308 isFinalChanged();
309 return ( m_nIsOpen = false );
311 else if( err == osl::FileBase::E_None )
313 aRow = m_pMyShell->getv(
314 this, m_sProperty, m_aDirIte, aUnqPath, IsRegular );
316 if( m_nOpenMode == ucb::OpenMode::DOCUMENTS && IsRegular )
318 osl::MutexGuard aGuard( m_aMutex );
319 m_aItems.push_back( aRow );
320 m_aIdents.push_back(
321 uno::Reference< ucb::XContentIdentifier >() );
322 m_aUnqPath.push_back( aUnqPath );
323 rowCountChanged();
324 return true;
327 else if( m_nOpenMode == ucb::OpenMode::DOCUMENTS && ! IsRegular )
329 continue;
331 else if( m_nOpenMode == ucb::OpenMode::FOLDERS && ! IsRegular )
333 osl::MutexGuard aGuard( m_aMutex );
334 m_aItems.push_back( aRow );
335 m_aIdents.push_back(
336 uno::Reference< ucb::XContentIdentifier >() );
337 m_aUnqPath.push_back( aUnqPath );
338 rowCountChanged();
339 return true;
341 else if( m_nOpenMode == ucb::OpenMode::FOLDERS && IsRegular )
343 continue;
345 else
347 osl::MutexGuard aGuard( m_aMutex );
348 m_aItems.push_back( aRow );
349 m_aIdents.push_back(
350 uno::Reference< ucb::XContentIdentifier >() );
351 m_aUnqPath.push_back( aUnqPath );
352 rowCountChanged();
353 return true;
356 else // error fetching anything
358 throw sdbc::SQLException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >(), ::rtl::OUString(), 0, uno::Any() );
367 sal_Bool SAL_CALL
368 XResultSet_impl::next(
369 void )
370 throw( sdbc::SQLException,
371 uno::RuntimeException )
373 sal_Bool test;
374 if( ++m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) ) test = true;
375 else
376 test = OneMore();
377 return test;
381 sal_Bool SAL_CALL
382 XResultSet_impl::isBeforeFirst(
383 void )
384 throw( sdbc::SQLException,
385 uno::RuntimeException )
387 return m_nRow == -1;
391 sal_Bool SAL_CALL
392 XResultSet_impl::isAfterLast(
393 void )
394 throw( sdbc::SQLException,
395 uno::RuntimeException )
397 return m_nRow >= sal::static_int_cast<sal_Int32>(m_aItems.size()); // Cannot happen, if m_aFolder.isOpen()
401 sal_Bool SAL_CALL
402 XResultSet_impl::isFirst(
403 void )
404 throw( sdbc::SQLException,
405 uno::RuntimeException )
407 return m_nRow == 0;
411 sal_Bool SAL_CALL
412 XResultSet_impl::isLast(
413 void )
414 throw( sdbc::SQLException,
415 uno::RuntimeException)
417 if( m_nRow == sal::static_int_cast<sal_Int32>(m_aItems.size()) - 1 )
418 return ! OneMore();
419 else
420 return false;
424 void SAL_CALL
425 XResultSet_impl::beforeFirst(
426 void )
427 throw( sdbc::SQLException,
428 uno::RuntimeException)
430 m_nRow = -1;
434 void SAL_CALL
435 XResultSet_impl::afterLast(
436 void )
437 throw( sdbc::SQLException,
438 uno::RuntimeException )
440 m_nRow = sal::static_int_cast<sal_Int32>(m_aItems.size());
441 while( OneMore() )
442 ++m_nRow;
446 sal_Bool SAL_CALL
447 XResultSet_impl::first(
448 void )
449 throw( sdbc::SQLException,
450 uno::RuntimeException)
452 m_nRow = -1;
453 return next();
457 sal_Bool SAL_CALL
458 XResultSet_impl::last(
459 void )
460 throw( sdbc::SQLException,
461 uno::RuntimeException )
463 m_nRow = sal::static_int_cast<sal_Int32>(m_aItems.size()) - 1;
464 while( OneMore() )
465 ++m_nRow;
466 return true;
470 sal_Int32 SAL_CALL
471 XResultSet_impl::getRow(
472 void )
473 throw( sdbc::SQLException,
474 uno::RuntimeException)
476 // Test, whether behind last row
477 if( -1 == m_nRow || m_nRow >= sal::static_int_cast<sal_Int32>(m_aItems.size()) )
478 return 0;
479 else
480 return m_nRow+1;
485 sal_Bool SAL_CALL XResultSet_impl::absolute( sal_Int32 row )
486 throw( sdbc::SQLException, uno::RuntimeException)
488 if( row >= 0 )
490 m_nRow = row - 1;
491 if( row >= sal::static_int_cast<sal_Int32>(m_aItems.size()) )
492 while( row-- && OneMore() )
495 else
497 last();
498 m_nRow += ( row + 1 );
499 if( m_nRow < -1 )
500 m_nRow = -1;
503 return 0<= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size());
509 sal_Bool SAL_CALL
510 XResultSet_impl::relative(
511 sal_Int32 row )
512 throw( sdbc::SQLException,
513 uno::RuntimeException)
515 if( isAfterLast() || isBeforeFirst() )
516 throw sdbc::SQLException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >(), ::rtl::OUString(), 0, uno::Any() );
517 if( row > 0 )
518 while( row-- ) next();
519 else if( row < 0 )
520 while( row++ && m_nRow > - 1 ) previous();
522 return 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size());
527 sal_Bool SAL_CALL
528 XResultSet_impl::previous(
529 void )
530 throw( sdbc::SQLException,
531 uno::RuntimeException)
533 if( m_nRow > sal::static_int_cast<sal_Int32>(m_aItems.size()) )
534 m_nRow = sal::static_int_cast<sal_Int32>(m_aItems.size()); // Correct Handling of afterLast
535 if( 0 <= m_nRow ) -- m_nRow;
537 return 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size());
541 void SAL_CALL
542 XResultSet_impl::refreshRow(
543 void )
544 throw( sdbc::SQLException,
545 uno::RuntimeException)
547 // get the row from the filesystem
548 return;
552 sal_Bool SAL_CALL
553 XResultSet_impl::rowUpdated(
554 void )
555 throw( sdbc::SQLException,
556 uno::RuntimeException )
558 return false;
561 sal_Bool SAL_CALL
562 XResultSet_impl::rowInserted(
563 void )
564 throw( sdbc::SQLException,
565 uno::RuntimeException )
567 return false;
570 sal_Bool SAL_CALL
571 XResultSet_impl::rowDeleted(
572 void )
573 throw( sdbc::SQLException,
574 uno::RuntimeException )
576 return false;
580 uno::Reference< uno::XInterface > SAL_CALL
581 XResultSet_impl::getStatement(
582 void )
583 throw( sdbc::SQLException,
584 uno::RuntimeException )
586 return uno::Reference< uno::XInterface >();
590 // XCloseable
592 void SAL_CALL
593 XResultSet_impl::close(
594 void )
595 throw( sdbc::SQLException,
596 uno::RuntimeException)
598 if( m_nIsOpen )
600 m_aFolder.close();
601 isFinalChanged();
602 osl::MutexGuard aGuard( m_aMutex );
603 m_nIsOpen = false;
609 rtl::OUString SAL_CALL
610 XResultSet_impl::queryContentIdentifierString(
611 void )
612 throw( uno::RuntimeException )
614 uno::Reference< ucb::XContentIdentifier > xContentId
615 = queryContentIdentifier();
617 if( xContentId.is() )
618 return xContentId->getContentIdentifier();
619 else
620 return rtl::OUString();
624 uno::Reference< ucb::XContentIdentifier > SAL_CALL
625 XResultSet_impl::queryContentIdentifier(
626 void )
627 throw( uno::RuntimeException )
629 if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
631 if( ! m_aIdents[m_nRow].is() )
633 FileContentIdentifier* p
634 = new FileContentIdentifier( m_pMyShell,
635 m_aUnqPath[ m_nRow ] );
636 m_aIdents[m_nRow] = uno::Reference< ucb::XContentIdentifier >(p);
638 return m_aIdents[m_nRow];
640 return uno::Reference< ucb::XContentIdentifier >();
644 uno::Reference< ucb::XContent > SAL_CALL
645 XResultSet_impl::queryContent(
646 void )
647 throw( uno::RuntimeException )
649 if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
650 return m_pMyShell->m_pProvider->queryContent( queryContentIdentifier() );
651 else
652 return uno::Reference< ucb::XContent >();
656 // XDynamicResultSet
659 // virtual
660 uno::Reference< sdbc::XResultSet > SAL_CALL
661 XResultSet_impl::getStaticResultSet()
662 throw( ucb::ListenerAlreadySetException,
663 uno::RuntimeException )
665 osl::MutexGuard aGuard( m_aMutex );
667 if ( m_xListener.is() )
668 throw ucb::ListenerAlreadySetException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
670 return uno::Reference< sdbc::XResultSet >( this );
673 //=========================================================================
674 // virtual
675 void SAL_CALL
676 XResultSet_impl::setListener(
677 const uno::Reference< ucb::XDynamicResultSetListener >& Listener )
678 throw( ucb::ListenerAlreadySetException,
679 uno::RuntimeException )
681 osl::ClearableMutexGuard aGuard( m_aMutex );
683 if ( m_xListener.is() )
684 throw ucb::ListenerAlreadySetException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
686 m_xListener = Listener;
688 //////////////////////////////////////////////////////////////////////
689 // Create "welcome event" and send it to listener.
690 //////////////////////////////////////////////////////////////////////
692 // Note: We only have the implementation for a static result set at the
693 // moment (src590). The dynamic result sets passed to the listener
694 // are a fake. This implementation will never call "notify" at the
695 // listener to propagate any changes!!!
697 uno::Any aInfo;
698 aInfo <<= ucb::WelcomeDynamicResultSetStruct( this, /* "old" */
699 this /* "new" */ );
701 uno::Sequence< ucb::ListAction > aActions( 1 );
702 aActions.getArray()[ 0 ] = ucb::ListAction( 0, // Position; not used
703 0, // Count; not used
704 ucb::ListActionType::WELCOME,
705 aInfo );
706 aGuard.clear();
708 Listener->notify(
709 ucb::ListEvent(
710 static_cast< cppu::OWeakObject * >( this ), aActions ) );
713 //=========================================================================
714 // virtual
715 void SAL_CALL
716 XResultSet_impl::connectToCache(
717 const uno::Reference< ucb::XDynamicResultSet > & xCache )
718 throw( ucb::ListenerAlreadySetException,
719 ucb::AlreadyInitializedException,
720 ucb::ServiceNotFoundException,
721 uno::RuntimeException )
723 uno::Reference< lang::XMultiServiceFactory > mxSMgr
724 = m_pMyShell->m_xMultiServiceFactory;
726 if( m_xListener.is() )
727 throw ucb::ListenerAlreadySetException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
728 if( m_bStatic )
729 throw ucb::ListenerAlreadySetException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
731 uno::Reference< ucb::XSourceInitialization > xTarget(
732 xCache, uno::UNO_QUERY );
733 if( xTarget.is() && mxSMgr.is() )
735 uno::Reference< ucb::XCachedDynamicResultSetStubFactory > xStubFactory;
738 xStubFactory
739 = uno::Reference< ucb::XCachedDynamicResultSetStubFactory >(
740 mxSMgr->createInstance(
741 rtl::OUString::createFromAscii(
742 "com.sun.star.ucb.CachedDynamicResultSetStubFactory" ) ),
743 uno::UNO_QUERY );
745 catch ( uno::Exception const & )
749 if( xStubFactory.is() )
751 xStubFactory->connectToCache(
752 this, xCache,m_sSortingInfo, NULL );
753 return;
756 throw ucb::ServiceNotFoundException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
759 //=========================================================================
760 // virtual
761 sal_Int16 SAL_CALL
762 XResultSet_impl::getCapabilities()
763 throw( uno::RuntimeException )
765 // Never set ucb::ContentResultSetCapability::SORTED
766 // - Underlying content cannot provide sorted data...
767 return 0;
770 // XResultSetMetaDataSupplier
771 uno::Reference< sdbc::XResultSetMetaData > SAL_CALL
772 XResultSet_impl::getMetaData(
773 void )
774 throw( sdbc::SQLException,
775 uno::RuntimeException )
777 for ( sal_Int32 n = 0; n < m_sProperty.getLength(); ++n )
779 if ( m_sProperty.getConstArray()[ n ].Name.compareToAscii( "Title" )
780 == 0 )
782 // @@@ #82177# - Determine correct value!
783 sal_Bool bCaseSensitiveChildren = sal_False;
785 std::vector< ::ucbhelper::ResultSetColumnData >
786 aColumnData( m_sProperty.getLength() );
787 aColumnData[ n ].isCaseSensitive = bCaseSensitiveChildren;
789 ::ucbhelper::ResultSetMetaData* p =
790 new ::ucbhelper::ResultSetMetaData(
791 m_pMyShell->m_xMultiServiceFactory,
792 m_sProperty,
793 aColumnData );
794 return uno::Reference< sdbc::XResultSetMetaData >( p );
798 ::ucbhelper::ResultSetMetaData* p =
799 new ::ucbhelper::ResultSetMetaData(
800 m_pMyShell->m_xMultiServiceFactory, m_sProperty );
801 return uno::Reference< sdbc::XResultSetMetaData >( p );
806 // XPropertySet
807 uno::Reference< beans::XPropertySetInfo > SAL_CALL
808 XResultSet_impl::getPropertySetInfo()
809 throw( uno::RuntimeException)
812 uno::Sequence< beans::Property > seq(2);
813 seq[0].Name = rtl::OUString::createFromAscii( "RowCount" );
814 seq[0].Handle = -1;
815 seq[0].Type = getCppuType( static_cast< sal_Int32* >(0) );
816 seq[0].Attributes = beans::PropertyAttribute::READONLY;
818 seq[0].Name = rtl::OUString::createFromAscii( "IsRowCountFinal" );
819 seq[0].Handle = -1;
820 seq[0].Type = getCppuType( static_cast< sal_Bool* >(0) );
821 seq[0].Attributes = beans::PropertyAttribute::READONLY;
823 XPropertySetInfo_impl* p = new XPropertySetInfo_impl( m_pMyShell,
824 seq );
825 return uno::Reference< beans::XPropertySetInfo > ( p );
830 void SAL_CALL XResultSet_impl::setPropertyValue(
831 const rtl::OUString& aPropertyName, const uno::Any& )
832 throw( beans::UnknownPropertyException,
833 beans::PropertyVetoException,
834 lang::IllegalArgumentException,
835 lang::WrappedTargetException,
836 uno::RuntimeException)
838 if( aPropertyName == rtl::OUString::createFromAscii( "IsRowCountFinal" ) ||
839 aPropertyName == rtl::OUString::createFromAscii( "RowCount" ) )
840 return;
841 throw beans::UnknownPropertyException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
845 uno::Any SAL_CALL XResultSet_impl::getPropertyValue(
846 const rtl::OUString& PropertyName )
847 throw( beans::UnknownPropertyException,
848 lang::WrappedTargetException,
849 uno::RuntimeException)
851 if( PropertyName == rtl::OUString::createFromAscii( "IsRowCountFinal" ) )
853 uno::Any aAny;
854 aAny <<= m_bRowCountFinal;
855 return aAny;
857 else if ( PropertyName == rtl::OUString::createFromAscii( "RowCount" ) )
859 uno::Any aAny;
860 sal_Int32 count = sal::static_int_cast<sal_Int32>(m_aItems.size());
861 aAny <<= count;
862 return aAny;
864 else
865 throw beans::UnknownPropertyException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
869 void SAL_CALL XResultSet_impl::addPropertyChangeListener(
870 const rtl::OUString& aPropertyName,
871 const uno::Reference< beans::XPropertyChangeListener >& xListener )
872 throw( beans::UnknownPropertyException,
873 lang::WrappedTargetException,
874 uno::RuntimeException)
876 if( aPropertyName == rtl::OUString::createFromAscii( "IsRowCountFinal" ) )
878 osl::MutexGuard aGuard( m_aMutex );
879 if ( ! m_pIsFinalListeners )
880 m_pIsFinalListeners =
881 new cppu::OInterfaceContainerHelper( m_aEventListenerMutex );
883 m_pIsFinalListeners->addInterface( xListener );
885 else if ( aPropertyName == rtl::OUString::createFromAscii( "RowCount" ) )
887 osl::MutexGuard aGuard( m_aMutex );
888 if ( ! m_pRowCountListeners )
889 m_pRowCountListeners =
890 new cppu::OInterfaceContainerHelper( m_aEventListenerMutex );
891 m_pRowCountListeners->addInterface( xListener );
893 else
894 throw beans::UnknownPropertyException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
898 void SAL_CALL XResultSet_impl::removePropertyChangeListener(
899 const rtl::OUString& aPropertyName,
900 const uno::Reference< beans::XPropertyChangeListener >& aListener )
901 throw( beans::UnknownPropertyException,
902 lang::WrappedTargetException,
903 uno::RuntimeException)
905 if( aPropertyName == rtl::OUString::createFromAscii( "IsRowCountFinal" ) &&
906 m_pIsFinalListeners )
908 osl::MutexGuard aGuard( m_aMutex );
909 m_pIsFinalListeners->removeInterface( aListener );
911 else if ( aPropertyName == rtl::OUString::createFromAscii( "RowCount" ) &&
912 m_pRowCountListeners )
914 osl::MutexGuard aGuard( m_aMutex );
916 m_pRowCountListeners->removeInterface( aListener );
918 else
919 throw beans::UnknownPropertyException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
922 void SAL_CALL XResultSet_impl::addVetoableChangeListener(
923 const rtl::OUString&,
924 const uno::Reference< beans::XVetoableChangeListener >& )
925 throw( beans::UnknownPropertyException,
926 lang::WrappedTargetException,
927 uno::RuntimeException)
932 void SAL_CALL XResultSet_impl::removeVetoableChangeListener(
933 const rtl::OUString&,
934 const uno::Reference< beans::XVetoableChangeListener >& )
935 throw( beans::UnknownPropertyException,
936 lang::WrappedTargetException,
937 uno::RuntimeException)