Bump for 3.6-28
[LibreOffice.git] / ucb / source / ucp / file / filrset.cxx
blob2c98f292457004824f020e8ac4e967ebe340d83c
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #include <com/sun/star/ucb/WelcomeDynamicResultSetStruct.hpp>
30 #include "filid.hxx"
31 #include "shell.hxx"
32 #include "filprp.hxx"
33 #include "filrset.hxx"
34 #include <com/sun/star/ucb/OpenMode.hpp>
35 #include "prov.hxx"
36 #include <com/sun/star/uno/Reference.h>
38 #include <com/sun/star/beans/PropertyAttribute.hpp>
39 #include <com/sun/star/ucb/ListActionType.hpp>
40 #include <com/sun/star/ucb/XSourceInitialization.hpp>
41 #include <com/sun/star/ucb/XCachedDynamicResultSetStubFactory.hpp>
42 #include <ucbhelper/resultsetmetadata.hxx>
44 using namespace fileaccess;
45 using namespace com::sun::star;
47 XResultSet_impl::XResultSet_impl(
48 shell* pMyShell,
49 const rtl::OUString& aUnqPath,
50 sal_Int32 OpenMode,
51 const uno::Sequence< beans::Property >& seq,
52 const uno::Sequence< ucb::NumberedSortingInfo >& seqSort )
53 : m_pMyShell( pMyShell ),
54 m_xProvider( pMyShell->m_pProvider ),
55 m_nRow( -1 ),
56 m_nOpenMode( OpenMode ),
57 m_bRowCountFinal( false ),
58 m_aBaseDirectory( aUnqPath ),
59 m_aFolder( aUnqPath ),
60 m_sProperty( seq ),
61 m_sSortingInfo( seqSort ),
62 m_pDisposeEventListeners( 0 ),
63 m_pRowCountListeners( 0 ),
64 m_pIsFinalListeners( 0 ),
65 m_bStatic( false ),
66 m_nErrorCode( TASKHANDLER_NO_ERROR ),
67 m_nMinorErrorCode( TASKHANDLER_NO_ERROR )
69 osl::FileBase::RC err = m_aFolder.open();
70 if( err != osl::FileBase::E_None )
72 m_nIsOpen = false;
73 m_aFolder.close();
75 m_nErrorCode = TASKHANDLING_OPEN_FOR_DIRECTORYLISTING;
76 m_nMinorErrorCode = err;
78 else
79 m_nIsOpen = true;
81 m_pMyShell->registerNotifier( m_aBaseDirectory,this );
85 XResultSet_impl::~XResultSet_impl()
87 m_pMyShell->deregisterNotifier( m_aBaseDirectory,this );
89 if( m_nIsOpen )
90 m_aFolder.close();
92 delete m_pDisposeEventListeners;
93 delete m_pRowCountListeners;
94 delete m_pIsFinalListeners;
99 sal_Int32 SAL_CALL XResultSet_impl::CtorSuccess()
101 return m_nErrorCode;
106 sal_Int32 SAL_CALL XResultSet_impl::getMinorError()
108 return m_nMinorErrorCode;
112 void SAL_CALL
113 XResultSet_impl::acquire(
114 void )
115 throw()
117 OWeakObject::acquire();
121 void SAL_CALL
122 XResultSet_impl::release(
123 void )
124 throw()
126 OWeakObject::release();
131 uno::Any SAL_CALL
132 XResultSet_impl::queryInterface(
133 const uno::Type& rType )
134 throw( uno::RuntimeException )
136 uno::Any aRet = cppu::queryInterface(
137 rType,
138 (static_cast< lang::XComponent* >(this)),
139 (static_cast< lang::XTypeProvider* >(this)),
140 (static_cast< lang::XEventListener* >(this)),
141 (static_cast< sdbc::XRow* >(this)),
142 (static_cast< sdbc::XResultSet* >(this)),
143 (static_cast< sdbc::XCloseable* >(this)),
144 (static_cast< sdbc::XResultSetMetaDataSupplier* >(this)),
145 (static_cast< beans::XPropertySet* >(this)),
146 (static_cast< ucb::XContentAccess* >(this)),
147 (static_cast< ucb::XDynamicResultSet* >(this)) );
148 return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType );
152 void SAL_CALL
153 XResultSet_impl::disposing( const lang::EventObject& )
154 throw( uno::RuntimeException )
156 // To do, but what
160 XTYPEPROVIDER_IMPL_10( XResultSet_impl,
161 lang::XTypeProvider,
162 lang::XTypeProvider,
163 lang::XEventListener,
164 sdbc::XRow,
165 sdbc::XResultSet,
166 XDynamicResultSet,
167 sdbc::XCloseable,
168 sdbc::XResultSetMetaDataSupplier,
169 beans::XPropertySet,
170 ucb::XContentAccess )
173 void SAL_CALL
174 XResultSet_impl::addEventListener(
175 const uno::Reference< lang::XEventListener >& Listener )
176 throw( uno::RuntimeException )
178 osl::MutexGuard aGuard( m_aMutex );
180 if ( ! m_pDisposeEventListeners )
181 m_pDisposeEventListeners =
182 new cppu::OInterfaceContainerHelper( m_aEventListenerMutex );
184 m_pDisposeEventListeners->addInterface( Listener );
188 void SAL_CALL
189 XResultSet_impl::removeEventListener(
190 const uno::Reference< lang::XEventListener >& Listener )
191 throw( uno::RuntimeException )
193 osl::MutexGuard aGuard( m_aMutex );
195 if ( m_pDisposeEventListeners )
196 m_pDisposeEventListeners->removeInterface( Listener );
201 void SAL_CALL
202 XResultSet_impl::dispose()
203 throw( uno::RuntimeException )
205 osl::MutexGuard aGuard( m_aMutex );
207 lang::EventObject aEvt;
208 aEvt.Source = static_cast< lang::XComponent * >( this );
210 if ( m_pDisposeEventListeners && m_pDisposeEventListeners->getLength() )
212 m_pDisposeEventListeners->disposeAndClear( aEvt );
214 if( m_pRowCountListeners && m_pRowCountListeners->getLength() )
216 m_pRowCountListeners->disposeAndClear( aEvt );
218 if( m_pIsFinalListeners && m_pIsFinalListeners->getLength() )
220 m_pIsFinalListeners->disposeAndClear( aEvt );
226 void XResultSet_impl::rowCountChanged()
228 sal_Int32 aOldValue,aNewValue;
229 uno::Sequence< uno::Reference< uno::XInterface > > seq;
231 osl::MutexGuard aGuard( m_aMutex );
232 if( m_pRowCountListeners )
233 seq = m_pRowCountListeners->getElements();
234 aNewValue = m_aItems.size();
235 aOldValue = aNewValue-1;
237 beans::PropertyChangeEvent aEv;
238 aEv.PropertyName = rtl::OUString("RowCount");
239 aEv.Further = false;
240 aEv.PropertyHandle = -1;
241 aEv.OldValue <<= aOldValue;
242 aEv.NewValue <<= aNewValue;
243 for( sal_Int32 i = 0; i < seq.getLength(); ++i )
245 uno::Reference< beans::XPropertyChangeListener > listener(
246 seq[i], uno::UNO_QUERY );
247 if( listener.is() )
248 listener->propertyChange( aEv );
253 void XResultSet_impl::isFinalChanged()
255 uno::Sequence< uno::Reference< XInterface > > seq;
257 osl::MutexGuard aGuard( m_aMutex );
258 if( m_pIsFinalListeners )
259 seq = m_pIsFinalListeners->getElements();
260 m_bRowCountFinal = true;
262 beans::PropertyChangeEvent aEv;
263 aEv.PropertyName = rtl::OUString("IsRowCountFinal");
264 aEv.Further = false;
265 aEv.PropertyHandle = -1;
266 sal_Bool fval = false;
267 sal_Bool tval = true;
268 aEv.OldValue <<= fval;
269 aEv.NewValue <<= tval;
270 for( sal_Int32 i = 0; i < seq.getLength(); ++i )
272 uno::Reference< beans::XPropertyChangeListener > listener(
273 seq[i], uno::UNO_QUERY );
274 if( listener.is() )
275 listener->propertyChange( aEv );
280 sal_Bool SAL_CALL
281 XResultSet_impl::OneMore(
282 void )
283 throw( sdbc::SQLException,
284 uno::RuntimeException )
286 if( ! m_nIsOpen )
287 return false;
289 osl::FileBase::RC err;
290 sal_Bool IsRegular;
291 rtl::OUString aUnqPath;
292 osl::DirectoryItem m_aDirIte;
293 uno::Reference< sdbc::XRow > aRow;
295 while( true )
297 err = m_aFolder.getNextItem( m_aDirIte );
299 if( err == osl::FileBase::E_NOENT || err == osl::FileBase::E_INVAL )
301 m_aFolder.close();
302 isFinalChanged();
303 return ( m_nIsOpen = false );
305 else if( err == osl::FileBase::E_None )
307 aRow = m_pMyShell->getv(
308 this, m_sProperty, m_aDirIte, aUnqPath, IsRegular );
310 if( m_nOpenMode == ucb::OpenMode::DOCUMENTS && IsRegular )
312 osl::MutexGuard aGuard( m_aMutex );
313 m_aItems.push_back( aRow );
314 m_aIdents.push_back(
315 uno::Reference< ucb::XContentIdentifier >() );
316 m_aUnqPath.push_back( aUnqPath );
317 rowCountChanged();
318 return true;
321 else if( m_nOpenMode == ucb::OpenMode::DOCUMENTS && ! IsRegular )
323 continue;
325 else if( m_nOpenMode == ucb::OpenMode::FOLDERS && ! IsRegular )
327 osl::MutexGuard aGuard( m_aMutex );
328 m_aItems.push_back( aRow );
329 m_aIdents.push_back(
330 uno::Reference< ucb::XContentIdentifier >() );
331 m_aUnqPath.push_back( aUnqPath );
332 rowCountChanged();
333 return true;
335 else if( m_nOpenMode == ucb::OpenMode::FOLDERS && IsRegular )
337 continue;
339 else
341 osl::MutexGuard aGuard( m_aMutex );
342 m_aItems.push_back( aRow );
343 m_aIdents.push_back(
344 uno::Reference< ucb::XContentIdentifier >() );
345 m_aUnqPath.push_back( aUnqPath );
346 rowCountChanged();
347 return true;
350 else // error fetching anything
352 throw sdbc::SQLException( ::rtl::OUString( OSL_LOG_PREFIX ), uno::Reference< uno::XInterface >(), ::rtl::OUString(), 0, uno::Any() );
361 sal_Bool SAL_CALL
362 XResultSet_impl::next(
363 void )
364 throw( sdbc::SQLException,
365 uno::RuntimeException )
367 sal_Bool test;
368 if( ++m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) ) test = true;
369 else
370 test = OneMore();
371 return test;
375 sal_Bool SAL_CALL
376 XResultSet_impl::isBeforeFirst(
377 void )
378 throw( sdbc::SQLException,
379 uno::RuntimeException )
381 return m_nRow == -1;
385 sal_Bool SAL_CALL
386 XResultSet_impl::isAfterLast(
387 void )
388 throw( sdbc::SQLException,
389 uno::RuntimeException )
391 return m_nRow >= sal::static_int_cast<sal_Int32>(m_aItems.size()); // Cannot happen, if m_aFolder.isOpen()
395 sal_Bool SAL_CALL
396 XResultSet_impl::isFirst(
397 void )
398 throw( sdbc::SQLException,
399 uno::RuntimeException )
401 return m_nRow == 0;
405 sal_Bool SAL_CALL
406 XResultSet_impl::isLast(
407 void )
408 throw( sdbc::SQLException,
409 uno::RuntimeException)
411 if( m_nRow == sal::static_int_cast<sal_Int32>(m_aItems.size()) - 1 )
412 return ! OneMore();
413 else
414 return false;
418 void SAL_CALL
419 XResultSet_impl::beforeFirst(
420 void )
421 throw( sdbc::SQLException,
422 uno::RuntimeException)
424 m_nRow = -1;
428 void SAL_CALL
429 XResultSet_impl::afterLast(
430 void )
431 throw( sdbc::SQLException,
432 uno::RuntimeException )
434 m_nRow = sal::static_int_cast<sal_Int32>(m_aItems.size());
435 while( OneMore() )
436 ++m_nRow;
440 sal_Bool SAL_CALL
441 XResultSet_impl::first(
442 void )
443 throw( sdbc::SQLException,
444 uno::RuntimeException)
446 m_nRow = -1;
447 return next();
451 sal_Bool SAL_CALL
452 XResultSet_impl::last(
453 void )
454 throw( sdbc::SQLException,
455 uno::RuntimeException )
457 m_nRow = sal::static_int_cast<sal_Int32>(m_aItems.size()) - 1;
458 while( OneMore() )
459 ++m_nRow;
460 return true;
464 sal_Int32 SAL_CALL
465 XResultSet_impl::getRow(
466 void )
467 throw( sdbc::SQLException,
468 uno::RuntimeException)
470 // Test, whether behind last row
471 if( -1 == m_nRow || m_nRow >= sal::static_int_cast<sal_Int32>(m_aItems.size()) )
472 return 0;
473 else
474 return m_nRow+1;
479 sal_Bool SAL_CALL XResultSet_impl::absolute( sal_Int32 row )
480 throw( sdbc::SQLException, uno::RuntimeException)
482 if( row >= 0 )
484 m_nRow = row - 1;
485 if( row >= sal::static_int_cast<sal_Int32>(m_aItems.size()) )
486 while( row-- && OneMore() )
489 else
491 last();
492 m_nRow += ( row + 1 );
493 if( m_nRow < -1 )
494 m_nRow = -1;
497 return 0<= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size());
503 sal_Bool SAL_CALL
504 XResultSet_impl::relative(
505 sal_Int32 row )
506 throw( sdbc::SQLException,
507 uno::RuntimeException)
509 if( isAfterLast() || isBeforeFirst() )
510 throw sdbc::SQLException( ::rtl::OUString( OSL_LOG_PREFIX ), uno::Reference< uno::XInterface >(), ::rtl::OUString(), 0, uno::Any() );
511 if( row > 0 )
512 while( row-- ) next();
513 else if( row < 0 )
514 while( row++ && m_nRow > - 1 ) previous();
516 return 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size());
521 sal_Bool SAL_CALL
522 XResultSet_impl::previous(
523 void )
524 throw( sdbc::SQLException,
525 uno::RuntimeException)
527 if( m_nRow > sal::static_int_cast<sal_Int32>(m_aItems.size()) )
528 m_nRow = sal::static_int_cast<sal_Int32>(m_aItems.size()); // Correct Handling of afterLast
529 if( 0 <= m_nRow ) -- m_nRow;
531 return 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size());
535 void SAL_CALL
536 XResultSet_impl::refreshRow(
537 void )
538 throw( sdbc::SQLException,
539 uno::RuntimeException)
541 // get the row from the filesystem
542 return;
546 sal_Bool SAL_CALL
547 XResultSet_impl::rowUpdated(
548 void )
549 throw( sdbc::SQLException,
550 uno::RuntimeException )
552 return false;
555 sal_Bool SAL_CALL
556 XResultSet_impl::rowInserted(
557 void )
558 throw( sdbc::SQLException,
559 uno::RuntimeException )
561 return false;
564 sal_Bool SAL_CALL
565 XResultSet_impl::rowDeleted(
566 void )
567 throw( sdbc::SQLException,
568 uno::RuntimeException )
570 return false;
574 uno::Reference< uno::XInterface > SAL_CALL
575 XResultSet_impl::getStatement(
576 void )
577 throw( sdbc::SQLException,
578 uno::RuntimeException )
580 return uno::Reference< uno::XInterface >();
584 // XCloseable
586 void SAL_CALL
587 XResultSet_impl::close(
588 void )
589 throw( sdbc::SQLException,
590 uno::RuntimeException)
592 if( m_nIsOpen )
594 m_aFolder.close();
595 isFinalChanged();
596 osl::MutexGuard aGuard( m_aMutex );
597 m_nIsOpen = false;
603 rtl::OUString SAL_CALL
604 XResultSet_impl::queryContentIdentifierString(
605 void )
606 throw( uno::RuntimeException )
608 uno::Reference< ucb::XContentIdentifier > xContentId
609 = queryContentIdentifier();
611 if( xContentId.is() )
612 return xContentId->getContentIdentifier();
613 else
614 return rtl::OUString();
618 uno::Reference< ucb::XContentIdentifier > SAL_CALL
619 XResultSet_impl::queryContentIdentifier(
620 void )
621 throw( uno::RuntimeException )
623 if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
625 if( ! m_aIdents[m_nRow].is() )
627 FileContentIdentifier* p
628 = new FileContentIdentifier( m_pMyShell,
629 m_aUnqPath[ m_nRow ] );
630 m_aIdents[m_nRow] = uno::Reference< ucb::XContentIdentifier >(p);
632 return m_aIdents[m_nRow];
634 return uno::Reference< ucb::XContentIdentifier >();
638 uno::Reference< ucb::XContent > SAL_CALL
639 XResultSet_impl::queryContent(
640 void )
641 throw( uno::RuntimeException )
643 if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
644 return m_pMyShell->m_pProvider->queryContent( queryContentIdentifier() );
645 else
646 return uno::Reference< ucb::XContent >();
650 // XDynamicResultSet
653 // virtual
654 uno::Reference< sdbc::XResultSet > SAL_CALL
655 XResultSet_impl::getStaticResultSet()
656 throw( ucb::ListenerAlreadySetException,
657 uno::RuntimeException )
659 osl::MutexGuard aGuard( m_aMutex );
661 if ( m_xListener.is() )
662 throw ucb::ListenerAlreadySetException( ::rtl::OUString( OSL_LOG_PREFIX ), uno::Reference< uno::XInterface >() );
664 return uno::Reference< sdbc::XResultSet >( this );
667 //=========================================================================
668 // virtual
669 void SAL_CALL
670 XResultSet_impl::setListener(
671 const uno::Reference< ucb::XDynamicResultSetListener >& Listener )
672 throw( ucb::ListenerAlreadySetException,
673 uno::RuntimeException )
675 osl::ClearableMutexGuard aGuard( m_aMutex );
677 if ( m_xListener.is() )
678 throw ucb::ListenerAlreadySetException( ::rtl::OUString( OSL_LOG_PREFIX ), uno::Reference< uno::XInterface >() );
680 m_xListener = Listener;
682 //////////////////////////////////////////////////////////////////////
683 // Create "welcome event" and send it to listener.
684 //////////////////////////////////////////////////////////////////////
686 // Note: We only have the implementation for a static result set at the
687 // moment (src590). The dynamic result sets passed to the listener
688 // are a fake. This implementation will never call "notify" at the
689 // listener to propagate any changes!!!
691 uno::Any aInfo;
692 aInfo <<= ucb::WelcomeDynamicResultSetStruct( this, /* "old" */
693 this /* "new" */ );
695 uno::Sequence< ucb::ListAction > aActions( 1 );
696 aActions.getArray()[ 0 ] = ucb::ListAction( 0, // Position; not used
697 0, // Count; not used
698 ucb::ListActionType::WELCOME,
699 aInfo );
700 aGuard.clear();
702 Listener->notify(
703 ucb::ListEvent(
704 static_cast< cppu::OWeakObject * >( this ), aActions ) );
707 //=========================================================================
708 // virtual
709 void SAL_CALL
710 XResultSet_impl::connectToCache(
711 const uno::Reference< ucb::XDynamicResultSet > & xCache )
712 throw( ucb::ListenerAlreadySetException,
713 ucb::AlreadyInitializedException,
714 ucb::ServiceNotFoundException,
715 uno::RuntimeException )
717 uno::Reference< lang::XMultiServiceFactory > mxSMgr
718 = m_pMyShell->m_xMultiServiceFactory;
720 if( m_xListener.is() )
721 throw ucb::ListenerAlreadySetException( ::rtl::OUString( OSL_LOG_PREFIX ), uno::Reference< uno::XInterface >() );
722 if( m_bStatic )
723 throw ucb::ListenerAlreadySetException( ::rtl::OUString( OSL_LOG_PREFIX ), uno::Reference< uno::XInterface >() );
725 uno::Reference< ucb::XSourceInitialization > xTarget(
726 xCache, uno::UNO_QUERY );
727 if( xTarget.is() && mxSMgr.is() )
729 uno::Reference< ucb::XCachedDynamicResultSetStubFactory > xStubFactory;
732 xStubFactory
733 = uno::Reference< ucb::XCachedDynamicResultSetStubFactory >(
734 mxSMgr->createInstance(
735 rtl::OUString(
736 "com.sun.star.ucb.CachedDynamicResultSetStubFactory" ) ),
737 uno::UNO_QUERY );
739 catch ( uno::Exception const & )
743 if( xStubFactory.is() )
745 xStubFactory->connectToCache(
746 this, xCache,m_sSortingInfo, NULL );
747 return;
750 throw ucb::ServiceNotFoundException( ::rtl::OUString( OSL_LOG_PREFIX ), uno::Reference< uno::XInterface >() );
753 //=========================================================================
754 // virtual
755 sal_Int16 SAL_CALL
756 XResultSet_impl::getCapabilities()
757 throw( uno::RuntimeException )
759 // Never set ucb::ContentResultSetCapability::SORTED
760 // - Underlying content cannot provide sorted data...
761 return 0;
764 // XResultSetMetaDataSupplier
765 uno::Reference< sdbc::XResultSetMetaData > SAL_CALL
766 XResultSet_impl::getMetaData(
767 void )
768 throw( sdbc::SQLException,
769 uno::RuntimeException )
771 for ( sal_Int32 n = 0; n < m_sProperty.getLength(); ++n )
773 if ( m_sProperty.getConstArray()[ n ].Name.compareToAscii( "Title" )
774 == 0 )
776 // @@@ #82177# - Determine correct value!
777 sal_Bool bCaseSensitiveChildren = sal_False;
779 std::vector< ::ucbhelper::ResultSetColumnData >
780 aColumnData( m_sProperty.getLength() );
781 aColumnData[ n ].isCaseSensitive = bCaseSensitiveChildren;
783 ::ucbhelper::ResultSetMetaData* p =
784 new ::ucbhelper::ResultSetMetaData(
785 m_pMyShell->m_xMultiServiceFactory,
786 m_sProperty,
787 aColumnData );
788 return uno::Reference< sdbc::XResultSetMetaData >( p );
792 ::ucbhelper::ResultSetMetaData* p =
793 new ::ucbhelper::ResultSetMetaData(
794 m_pMyShell->m_xMultiServiceFactory, m_sProperty );
795 return uno::Reference< sdbc::XResultSetMetaData >( p );
800 // XPropertySet
801 uno::Reference< beans::XPropertySetInfo > SAL_CALL
802 XResultSet_impl::getPropertySetInfo()
803 throw( uno::RuntimeException)
806 uno::Sequence< beans::Property > seq(2);
807 seq[0].Name = rtl::OUString("RowCount");
808 seq[0].Handle = -1;
809 seq[0].Type = getCppuType( static_cast< sal_Int32* >(0) );
810 seq[0].Attributes = beans::PropertyAttribute::READONLY;
812 seq[0].Name = rtl::OUString("IsRowCountFinal");
813 seq[0].Handle = -1;
814 seq[0].Type = getCppuType( static_cast< sal_Bool* >(0) );
815 seq[0].Attributes = beans::PropertyAttribute::READONLY;
817 XPropertySetInfo_impl* p = new XPropertySetInfo_impl( m_pMyShell,
818 seq );
819 return uno::Reference< beans::XPropertySetInfo > ( p );
824 void SAL_CALL XResultSet_impl::setPropertyValue(
825 const rtl::OUString& aPropertyName, const uno::Any& )
826 throw( beans::UnknownPropertyException,
827 beans::PropertyVetoException,
828 lang::IllegalArgumentException,
829 lang::WrappedTargetException,
830 uno::RuntimeException)
832 if( aPropertyName == rtl::OUString("IsRowCountFinal") ||
833 aPropertyName == rtl::OUString("RowCount") )
834 return;
835 throw beans::UnknownPropertyException( ::rtl::OUString( OSL_LOG_PREFIX ), uno::Reference< uno::XInterface >() );
839 uno::Any SAL_CALL XResultSet_impl::getPropertyValue(
840 const rtl::OUString& PropertyName )
841 throw( beans::UnknownPropertyException,
842 lang::WrappedTargetException,
843 uno::RuntimeException)
845 if( PropertyName == rtl::OUString("IsRowCountFinal") )
847 uno::Any aAny;
848 aAny <<= m_bRowCountFinal;
849 return aAny;
851 else if ( PropertyName == rtl::OUString("RowCount") )
853 uno::Any aAny;
854 sal_Int32 count = sal::static_int_cast<sal_Int32>(m_aItems.size());
855 aAny <<= count;
856 return aAny;
858 else
859 throw beans::UnknownPropertyException( ::rtl::OUString( OSL_LOG_PREFIX ), uno::Reference< uno::XInterface >() );
863 void SAL_CALL XResultSet_impl::addPropertyChangeListener(
864 const rtl::OUString& aPropertyName,
865 const uno::Reference< beans::XPropertyChangeListener >& xListener )
866 throw( beans::UnknownPropertyException,
867 lang::WrappedTargetException,
868 uno::RuntimeException)
870 if( aPropertyName == rtl::OUString("IsRowCountFinal") )
872 osl::MutexGuard aGuard( m_aMutex );
873 if ( ! m_pIsFinalListeners )
874 m_pIsFinalListeners =
875 new cppu::OInterfaceContainerHelper( m_aEventListenerMutex );
877 m_pIsFinalListeners->addInterface( xListener );
879 else if ( aPropertyName == rtl::OUString("RowCount") )
881 osl::MutexGuard aGuard( m_aMutex );
882 if ( ! m_pRowCountListeners )
883 m_pRowCountListeners =
884 new cppu::OInterfaceContainerHelper( m_aEventListenerMutex );
885 m_pRowCountListeners->addInterface( xListener );
887 else
888 throw beans::UnknownPropertyException( ::rtl::OUString( OSL_LOG_PREFIX ), uno::Reference< uno::XInterface >() );
892 void SAL_CALL XResultSet_impl::removePropertyChangeListener(
893 const rtl::OUString& aPropertyName,
894 const uno::Reference< beans::XPropertyChangeListener >& aListener )
895 throw( beans::UnknownPropertyException,
896 lang::WrappedTargetException,
897 uno::RuntimeException)
899 if( aPropertyName == rtl::OUString("IsRowCountFinal") &&
900 m_pIsFinalListeners )
902 osl::MutexGuard aGuard( m_aMutex );
903 m_pIsFinalListeners->removeInterface( aListener );
905 else if ( aPropertyName == rtl::OUString("RowCount") &&
906 m_pRowCountListeners )
908 osl::MutexGuard aGuard( m_aMutex );
910 m_pRowCountListeners->removeInterface( aListener );
912 else
913 throw beans::UnknownPropertyException( ::rtl::OUString( OSL_LOG_PREFIX ), uno::Reference< uno::XInterface >() );
916 void SAL_CALL XResultSet_impl::addVetoableChangeListener(
917 const rtl::OUString&,
918 const uno::Reference< beans::XVetoableChangeListener >& )
919 throw( beans::UnknownPropertyException,
920 lang::WrappedTargetException,
921 uno::RuntimeException)
926 void SAL_CALL XResultSet_impl::removeVetoableChangeListener(
927 const rtl::OUString&,
928 const uno::Reference< beans::XVetoableChangeListener >& )
929 throw( beans::UnknownPropertyException,
930 lang::WrappedTargetException,
931 uno::RuntimeException)
935 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */