1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include "contentresultsetwrapper.hxx"
22 #include <com/sun/star/lang/DisposedException.hpp>
23 #include <rtl/ustring.hxx>
24 #include <osl/diagnose.h>
25 #include <cppuhelper/queryinterface.hxx>
26 #include <cppuhelper/interfacecontainer.hxx>
28 using namespace com::sun::star::beans
;
29 using namespace com::sun::star::lang
;
30 using namespace com::sun::star::sdbc
;
31 using namespace com::sun::star::ucb
;
32 using namespace com::sun::star::uno
;
33 using namespace com::sun::star::util
;
34 using namespace comphelper
;
40 ContentResultSetWrapper::ContentResultSetWrapper(
41 Reference
< XResultSet
> const & xOrigin
)
42 : m_xResultSetOrigin( xOrigin
)
44 , m_bDisposed( false )
45 , m_bInDispose( false )
47 m_xMyListenerImpl
= new ContentResultSetWrapperListener( this );
49 OSL_ENSURE( m_xResultSetOrigin
.is(), "XResultSet is required" );
51 //!! call impl_init() at the end of constructor of derived class
55 void ContentResultSetWrapper::impl_init_xRowOrigin()
58 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
63 Reference
< XRow
> xOrgig( m_xResultSetOrigin
, UNO_QUERY
);
66 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
67 m_xRowOrigin
= xOrgig
;
68 OSL_ENSURE( m_xRowOrigin
.is(), "interface XRow is required" );
72 void ContentResultSetWrapper::impl_init_xContentAccessOrigin()
75 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
76 if(m_xContentAccessOrigin
.is())
80 Reference
< XContentAccess
> xOrgig( m_xResultSetOrigin
, UNO_QUERY
);
83 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
84 m_xContentAccessOrigin
= xOrgig
;
85 OSL_ENSURE( m_xContentAccessOrigin
.is(), "interface XContentAccess is required" );
90 void ContentResultSetWrapper::impl_init_xPropertySetOrigin()
93 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
94 if( m_xPropertySetOrigin
.is() )
98 Reference
< XPropertySet
> xOrig( m_xResultSetOrigin
, UNO_QUERY
);
101 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
102 m_xPropertySetOrigin
= xOrig
;
103 OSL_ENSURE( m_xPropertySetOrigin
.is(), "interface XPropertySet is required" );
107 void ContentResultSetWrapper::impl_init()
109 //call this at the end of constructor of derived class
112 //listen to disposing from Origin:
113 Reference
< XComponent
> xComponentOrigin( m_xResultSetOrigin
, UNO_QUERY
);
114 OSL_ENSURE( xComponentOrigin
.is(), "interface XComponent is required" );
115 xComponentOrigin
->addEventListener( static_cast< XPropertyChangeListener
* >( m_xMyListenerImpl
.get() ) );
118 ContentResultSetWrapper::~ContentResultSetWrapper()
120 //call impl_deinit() at start of destructor of derived class
123 void ContentResultSetWrapper::impl_deinit()
125 //call this at start of destructor of derived class
127 m_xMyListenerImpl
->impl_OwnerDies();
131 void ContentResultSetWrapper::impl_initPropertySetInfo()
134 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
135 if( m_xPropertySetInfo
.is() )
138 impl_init_xPropertySetOrigin();
139 if( !m_xPropertySetOrigin
.is() )
143 Reference
< XPropertySetInfo
> xOrig
=
144 m_xPropertySetOrigin
->getPropertySetInfo();
147 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
148 m_xPropertySetInfo
= xOrig
;
152 void ContentResultSetWrapper::impl_EnsureNotDisposed()
154 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
156 throw DisposedException();
159 void ContentResultSetWrapper::impl_getPropertyChangeListenerContainer()
161 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
162 if ( !m_pPropertyChangeListeners
)
163 m_pPropertyChangeListeners
.reset(
164 new PropertyChangeListenerContainer_Impl( m_aContainerMutex
) );
167 void ContentResultSetWrapper::impl_getVetoableChangeListenerContainer()
169 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
170 if ( !m_pVetoableChangeListeners
)
171 m_pVetoableChangeListeners
.reset(
172 new PropertyChangeListenerContainer_Impl( m_aContainerMutex
) );
175 void ContentResultSetWrapper::impl_notifyPropertyChangeListeners( const PropertyChangeEvent
& rEvt
)
178 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
179 if( !m_pPropertyChangeListeners
)
183 // Notify listeners interested especially in the changed property.
184 OInterfaceContainerHelper
* pContainer
=
185 m_pPropertyChangeListeners
->getContainer( rEvt
.PropertyName
);
188 OInterfaceIteratorHelper
aIter( *pContainer
);
189 while( aIter
.hasMoreElements() )
191 Reference
< XPropertyChangeListener
> xListener(
192 aIter
.next(), UNO_QUERY
);
194 xListener
->propertyChange( rEvt
);
198 // Notify listeners interested in all properties.
199 pContainer
= m_pPropertyChangeListeners
->getContainer( OUString() );
202 OInterfaceIteratorHelper
aIter( *pContainer
);
203 while( aIter
.hasMoreElements() )
205 Reference
< XPropertyChangeListener
> xListener(
206 aIter
.next(), UNO_QUERY
);
208 xListener
->propertyChange( rEvt
);
213 void ContentResultSetWrapper::impl_notifyVetoableChangeListeners( const PropertyChangeEvent
& rEvt
)
216 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
217 if( !m_pVetoableChangeListeners
)
221 // Notify listeners interested especially in the changed property.
222 OInterfaceContainerHelper
* pContainer
=
223 m_pVetoableChangeListeners
->getContainer( rEvt
.PropertyName
);
226 OInterfaceIteratorHelper
aIter( *pContainer
);
227 while( aIter
.hasMoreElements() )
229 Reference
< XVetoableChangeListener
> xListener(
230 aIter
.next(), UNO_QUERY
);
232 xListener
->vetoableChange( rEvt
);
236 // Notify listeners interested in all properties.
237 pContainer
= m_pVetoableChangeListeners
->getContainer( OUString() );
240 OInterfaceIteratorHelper
aIter( *pContainer
);
241 while( aIter
.hasMoreElements() )
243 Reference
< XVetoableChangeListener
> xListener(
244 aIter
.next(), UNO_QUERY
);
246 xListener
->vetoableChange( rEvt
);
251 bool ContentResultSetWrapper::impl_isForwardOnly()
253 //m_nForwardOnly == 2 -> don't know
254 //m_nForwardOnly == 1 -> YES
255 //m_nForwardOnly == 0 -> NO
257 //@todo replace this with lines in comment
258 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
264 ReacquireableGuard aGuard( m_aMutex );
265 if( m_nForwardOnly == 2 )
268 if( !getPropertySetInfo().is() )
272 return m_nForwardOnly;
276 OUString aName("ResultSetType");
277 //find out, if we are ForwardOnly and cache the value:
279 impl_init_xPropertySetOrigin();
280 if( !m_xPropertySetOrigin.is() )
282 OSL_FAIL( "broadcaster was disposed already" );
284 return m_nForwardOnly;
288 Any aAny = m_xPropertySetOrigin->getPropertyValue( aName );
292 if( ( aAny >>= nResultSetType ) &&
293 ( nResultSetType == ResultSetType::FORWARD_ONLY ) )
298 return m_nForwardOnly;
303 // XInterface methods.
305 css::uno::Any SAL_CALL
ContentResultSetWrapper::queryInterface( const css::uno::Type
& rType
)
307 //list all interfaces inclusive baseclasses of interfaces
308 css::uno::Any aRet
= cppu::queryInterface( rType
,
309 static_cast< XComponent
* >(this),
310 static_cast< XCloseable
* >(this),
311 static_cast< XResultSetMetaDataSupplier
* >(this),
312 static_cast< XPropertySet
* >(this),
313 static_cast< XContentAccess
* >(this),
314 static_cast< XResultSet
* >(this),
315 static_cast< XRow
* >(this)
317 return aRet
.hasValue() ? aRet
: OWeakObject::queryInterface( rType
);
320 // XComponent methods.
323 void SAL_CALL
ContentResultSetWrapper::dispose()
325 impl_EnsureNotDisposed();
327 bool isCleared
= false;
328 osl::ResettableMutexGuard
aGuard(m_aMutex
);
329 if( m_bInDispose
|| m_bDisposed
)
333 if( m_xPropertySetOrigin
.is() )
339 m_xPropertySetOrigin
->removePropertyChangeListener(
340 OUString(), static_cast< XPropertyChangeListener
* >( m_xMyListenerImpl
.get() ) );
344 OSL_FAIL( "could not remove PropertyChangeListener" );
348 m_xPropertySetOrigin
->removeVetoableChangeListener(
349 OUString(), static_cast< XVetoableChangeListener
* >( m_xMyListenerImpl
.get() ) );
353 OSL_FAIL( "could not remove VetoableChangeListener" );
356 Reference
< XComponent
> xComponentOrigin( m_xResultSetOrigin
, UNO_QUERY
);
357 OSL_ENSURE( xComponentOrigin
.is(), "interface XComponent is required" );
358 xComponentOrigin
->removeEventListener( static_cast< XPropertyChangeListener
* >( m_xMyListenerImpl
.get() ) );
366 if( m_pDisposeEventListeners
&& m_pDisposeEventListeners
->getLength() )
369 aEvt
.Source
= static_cast< XComponent
* >( this );
373 m_pDisposeEventListeners
->disposeAndClear( aEvt
);
381 if( m_pPropertyChangeListeners
)
384 aEvt
.Source
= static_cast< XPropertySet
* >( this );
388 m_pPropertyChangeListeners
->disposeAndClear( aEvt
);
396 if( m_pVetoableChangeListeners
)
399 aEvt
.Source
= static_cast< XPropertySet
* >( this );
403 m_pVetoableChangeListeners
->disposeAndClear( aEvt
);
411 m_bInDispose
= false;
416 void SAL_CALL
ContentResultSetWrapper::addEventListener( const Reference
< XEventListener
>& Listener
)
418 impl_EnsureNotDisposed();
419 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
421 if ( !m_pDisposeEventListeners
)
422 m_pDisposeEventListeners
.reset(
423 new OInterfaceContainerHelper2( m_aContainerMutex
) );
425 m_pDisposeEventListeners
->addInterface( Listener
);
430 void SAL_CALL
ContentResultSetWrapper::removeEventListener( const Reference
< XEventListener
>& Listener
)
432 impl_EnsureNotDisposed();
433 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
435 if ( m_pDisposeEventListeners
)
436 m_pDisposeEventListeners
->removeInterface( Listener
);
440 //XCloseable methods.
443 void SAL_CALL
ContentResultSetWrapper::close()
445 impl_EnsureNotDisposed();
450 //XResultSetMetaDataSupplier methods.
453 Reference
< XResultSetMetaData
> SAL_CALL
ContentResultSetWrapper::getMetaData()
455 impl_EnsureNotDisposed();
457 osl::ResettableMutexGuard
aGuard(m_aMutex
);
458 if( !m_xMetaDataFromOrigin
.is() && m_xResultSetOrigin
.is() )
460 Reference
< XResultSetMetaDataSupplier
> xMetaDataSupplier(
461 m_xResultSetOrigin
, UNO_QUERY
);
463 if( xMetaDataSupplier
.is() )
467 Reference
< XResultSetMetaData
> xMetaData
468 = xMetaDataSupplier
->getMetaData();
471 m_xMetaDataFromOrigin
= xMetaData
;
474 return m_xMetaDataFromOrigin
;
478 // XPropertySet methods.
481 Reference
< XPropertySetInfo
> SAL_CALL
ContentResultSetWrapper::getPropertySetInfo()
483 impl_EnsureNotDisposed();
485 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
486 if( m_xPropertySetInfo
.is() )
487 return m_xPropertySetInfo
;
489 impl_initPropertySetInfo();
490 return m_xPropertySetInfo
;
494 void SAL_CALL
ContentResultSetWrapper::setPropertyValue( const OUString
& rPropertyName
, const Any
& rValue
)
496 impl_EnsureNotDisposed();
497 impl_init_xPropertySetOrigin();
498 if( !m_xPropertySetOrigin
.is() )
500 OSL_FAIL( "broadcaster was disposed already" );
501 throw UnknownPropertyException();
503 m_xPropertySetOrigin
->setPropertyValue( rPropertyName
, rValue
);
508 Any SAL_CALL
ContentResultSetWrapper::getPropertyValue( const OUString
& rPropertyName
)
510 impl_EnsureNotDisposed();
511 impl_init_xPropertySetOrigin();
512 if( !m_xPropertySetOrigin
.is() )
514 OSL_FAIL( "broadcaster was disposed already" );
515 throw UnknownPropertyException();
517 return m_xPropertySetOrigin
->getPropertyValue( rPropertyName
);
522 void SAL_CALL
ContentResultSetWrapper::addPropertyChangeListener( const OUString
& aPropertyName
, const Reference
< XPropertyChangeListener
>& xListener
)
524 impl_EnsureNotDisposed();
526 if( !getPropertySetInfo().is() )
528 OSL_FAIL( "broadcaster was disposed already" );
529 throw UnknownPropertyException();
532 if( !aPropertyName
.isEmpty() )
534 m_xPropertySetInfo
->getPropertyByName( aPropertyName
);
535 //throws UnknownPropertyException, if so
538 impl_getPropertyChangeListenerContainer();
539 bool bNeedRegister
= !m_pPropertyChangeListeners
->
540 getContainedTypes().hasElements();
541 m_pPropertyChangeListeners
->addInterface( aPropertyName
, xListener
);
545 impl_init_xPropertySetOrigin();
547 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
548 if( !m_xPropertySetOrigin
.is() )
550 OSL_FAIL( "broadcaster was disposed already" );
556 m_xPropertySetOrigin
->addPropertyChangeListener(
557 OUString(), static_cast< XPropertyChangeListener
* >( m_xMyListenerImpl
.get() ) );
561 m_pPropertyChangeListeners
->removeInterface( aPropertyName
, xListener
);
568 void SAL_CALL
ContentResultSetWrapper::addVetoableChangeListener( const OUString
& rPropertyName
, const Reference
< XVetoableChangeListener
>& xListener
)
570 impl_EnsureNotDisposed();
572 if( !getPropertySetInfo().is() )
574 OSL_FAIL( "broadcaster was disposed already" );
575 throw UnknownPropertyException();
577 if( !rPropertyName
.isEmpty() )
579 m_xPropertySetInfo
->getPropertyByName( rPropertyName
);
580 //throws UnknownPropertyException, if so
583 impl_getVetoableChangeListenerContainer();
584 bool bNeedRegister
= !m_pVetoableChangeListeners
->
585 getContainedTypes().hasElements();
586 m_pVetoableChangeListeners
->addInterface( rPropertyName
, xListener
);
590 impl_init_xPropertySetOrigin();
592 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
593 if( !m_xPropertySetOrigin
.is() )
595 OSL_FAIL( "broadcaster was disposed already" );
601 m_xPropertySetOrigin
->addVetoableChangeListener(
602 OUString(), static_cast< XVetoableChangeListener
* >( m_xMyListenerImpl
.get() ) );
606 m_pVetoableChangeListeners
->removeInterface( rPropertyName
, xListener
);
613 void SAL_CALL
ContentResultSetWrapper::removePropertyChangeListener( const OUString
& rPropertyName
, const Reference
< XPropertyChangeListener
>& xListener
)
615 impl_EnsureNotDisposed();
618 //noop, if no listener registered
619 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
620 if( !m_pPropertyChangeListeners
)
623 OInterfaceContainerHelper
* pContainer
=
624 m_pPropertyChangeListeners
->getContainer( rPropertyName
);
628 if( !rPropertyName
.isEmpty() )
630 if( !getPropertySetInfo().is() )
631 throw UnknownPropertyException();
633 m_xPropertySetInfo
->getPropertyByName( rPropertyName
);
634 //throws UnknownPropertyException, if so
636 return; //the listener was not registered
639 m_pPropertyChangeListeners
->removeInterface( rPropertyName
, xListener
);
641 if( m_pPropertyChangeListeners
->getContainedTypes().hasElements() )
644 impl_init_xPropertySetOrigin();
646 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
647 if( !m_xPropertySetOrigin
.is() )
649 OSL_FAIL( "broadcaster was disposed already" );
655 m_xPropertySetOrigin
->removePropertyChangeListener(
656 OUString(), static_cast< XPropertyChangeListener
* >( m_xMyListenerImpl
.get() ) );
660 OSL_FAIL( "could not remove PropertyChangeListener" );
666 void SAL_CALL
ContentResultSetWrapper::removeVetoableChangeListener( const OUString
& rPropertyName
, const Reference
< XVetoableChangeListener
>& xListener
)
668 impl_EnsureNotDisposed();
671 //noop, if no listener registered
672 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
673 if( !m_pVetoableChangeListeners
)
676 OInterfaceContainerHelper
* pContainer
=
677 m_pVetoableChangeListeners
->getContainer( rPropertyName
);
681 if( !rPropertyName
.isEmpty() )
683 if( !getPropertySetInfo().is() )
684 throw UnknownPropertyException(rPropertyName
);
686 m_xPropertySetInfo
->getPropertyByName( rPropertyName
);
687 //throws UnknownPropertyException, if so
689 return; //the listener was not registered
692 m_pVetoableChangeListeners
->removeInterface( rPropertyName
, xListener
);
694 if( m_pVetoableChangeListeners
->getContainedTypes().hasElements() )
697 impl_init_xPropertySetOrigin();
699 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
700 if( !m_xPropertySetOrigin
.is() )
702 OSL_FAIL( "broadcaster was disposed already" );
708 m_xPropertySetOrigin
->removeVetoableChangeListener(
709 OUString(), static_cast< XVetoableChangeListener
* >( m_xMyListenerImpl
.get() ) );
713 OSL_FAIL( "could not remove VetoableChangeListener" );
722 void ContentResultSetWrapper::impl_disposing( const EventObject
& )
724 impl_EnsureNotDisposed();
726 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
728 if( !m_xResultSetOrigin
.is() )
731 //release all references to the broadcaster:
732 m_xResultSetOrigin
.clear();
733 if(m_xRowOrigin
.is())
734 m_xRowOrigin
.clear();
735 if(m_xContentAccessOrigin
.is())
736 m_xContentAccessOrigin
.clear();
737 if(m_xPropertySetOrigin
.is())
738 m_xPropertySetOrigin
.clear();
739 m_xMetaDataFromOrigin
.clear();
740 if(m_xPropertySetInfo
.is())
741 m_xPropertySetInfo
.clear();
745 void ContentResultSetWrapper::impl_propertyChange( const PropertyChangeEvent
& rEvt
)
747 impl_EnsureNotDisposed();
749 PropertyChangeEvent
aEvt( rEvt
);
750 aEvt
.Source
= static_cast< XPropertySet
* >( this );
751 aEvt
.Further
= false;
752 impl_notifyPropertyChangeListeners( aEvt
);
756 void ContentResultSetWrapper::impl_vetoableChange( const PropertyChangeEvent
& rEvt
)
758 impl_EnsureNotDisposed();
760 PropertyChangeEvent
aEvt( rEvt
);
761 aEvt
.Source
= static_cast< XPropertySet
* >( this );
762 aEvt
.Further
= false;
764 impl_notifyVetoableChangeListeners( aEvt
);
768 // XContentAccess methods. ( -- position dependent )
772 OUString SAL_CALL
ContentResultSetWrapper::queryContentIdentifierString()
774 impl_EnsureNotDisposed();
775 impl_init_xContentAccessOrigin();
776 if( !m_xContentAccessOrigin
.is() )
778 OSL_FAIL( "broadcaster was disposed already" );
779 throw RuntimeException();
781 return m_xContentAccessOrigin
->queryContentIdentifierString();
786 Reference
< XContentIdentifier
> SAL_CALL
ContentResultSetWrapper::queryContentIdentifier()
788 impl_EnsureNotDisposed();
789 impl_init_xContentAccessOrigin();
790 if( !m_xContentAccessOrigin
.is() )
792 OSL_FAIL( "broadcaster was disposed already" );
793 throw RuntimeException();
795 return m_xContentAccessOrigin
->queryContentIdentifier();
800 Reference
< XContent
> SAL_CALL
ContentResultSetWrapper::queryContent()
802 impl_EnsureNotDisposed();
803 impl_init_xContentAccessOrigin();
804 if( !m_xContentAccessOrigin
.is() )
806 OSL_FAIL( "broadcaster was disposed already" );
807 throw RuntimeException();
809 return m_xContentAccessOrigin
->queryContent();
813 // XResultSet methods.
817 sal_Bool SAL_CALL
ContentResultSetWrapper::next()
819 impl_EnsureNotDisposed();
821 if( !m_xResultSetOrigin
.is() )
823 OSL_FAIL( "broadcaster was disposed already" );
824 throw RuntimeException();
826 return m_xResultSetOrigin
->next();
830 sal_Bool SAL_CALL
ContentResultSetWrapper::previous()
832 impl_EnsureNotDisposed();
834 if( !m_xResultSetOrigin
.is() )
836 OSL_FAIL( "broadcaster was disposed already" );
837 throw RuntimeException();
839 return m_xResultSetOrigin
->previous();
843 sal_Bool SAL_CALL
ContentResultSetWrapper::absolute( sal_Int32 row
)
845 impl_EnsureNotDisposed();
847 if( !m_xResultSetOrigin
.is() )
849 OSL_FAIL( "broadcaster was disposed already" );
850 throw RuntimeException();
852 return m_xResultSetOrigin
->absolute( row
);
856 sal_Bool SAL_CALL
ContentResultSetWrapper::relative( sal_Int32 rows
)
858 impl_EnsureNotDisposed();
860 if( !m_xResultSetOrigin
.is() )
862 OSL_FAIL( "broadcaster was disposed already" );
863 throw RuntimeException();
865 return m_xResultSetOrigin
->relative( rows
);
870 sal_Bool SAL_CALL
ContentResultSetWrapper::first()
872 impl_EnsureNotDisposed();
874 if( !m_xResultSetOrigin
.is() )
876 OSL_FAIL( "broadcaster was disposed already" );
877 throw RuntimeException();
879 return m_xResultSetOrigin
->first();
883 sal_Bool SAL_CALL
ContentResultSetWrapper::last()
885 impl_EnsureNotDisposed();
887 if( !m_xResultSetOrigin
.is() )
889 OSL_FAIL( "broadcaster was disposed already" );
890 throw RuntimeException();
892 return m_xResultSetOrigin
->last();
896 void SAL_CALL
ContentResultSetWrapper::beforeFirst()
898 impl_EnsureNotDisposed();
900 if( !m_xResultSetOrigin
.is() )
902 OSL_FAIL( "broadcaster was disposed already" );
903 throw RuntimeException();
905 m_xResultSetOrigin
->beforeFirst();
909 void SAL_CALL
ContentResultSetWrapper::afterLast()
911 impl_EnsureNotDisposed();
913 if( !m_xResultSetOrigin
.is() )
915 OSL_FAIL( "broadcaster was disposed already" );
916 throw RuntimeException();
918 m_xResultSetOrigin
->afterLast();
922 sal_Bool SAL_CALL
ContentResultSetWrapper::isAfterLast()
924 impl_EnsureNotDisposed();
926 if( !m_xResultSetOrigin
.is() )
928 OSL_FAIL( "broadcaster was disposed already" );
929 throw RuntimeException();
931 return m_xResultSetOrigin
->isAfterLast();
935 sal_Bool SAL_CALL
ContentResultSetWrapper::isBeforeFirst()
937 impl_EnsureNotDisposed();
939 if( !m_xResultSetOrigin
.is() )
941 OSL_FAIL( "broadcaster was disposed already" );
942 throw RuntimeException();
944 return m_xResultSetOrigin
->isBeforeFirst();
948 sal_Bool SAL_CALL
ContentResultSetWrapper::isFirst()
950 impl_EnsureNotDisposed();
952 if( !m_xResultSetOrigin
.is() )
954 OSL_FAIL( "broadcaster was disposed already" );
955 throw RuntimeException();
957 return m_xResultSetOrigin
->isFirst();
961 sal_Bool SAL_CALL
ContentResultSetWrapper::isLast()
963 impl_EnsureNotDisposed();
965 if( !m_xResultSetOrigin
.is() )
967 OSL_FAIL( "broadcaster was disposed already" );
968 throw RuntimeException();
970 return m_xResultSetOrigin
->isLast();
975 sal_Int32 SAL_CALL
ContentResultSetWrapper::getRow()
977 impl_EnsureNotDisposed();
979 if( !m_xResultSetOrigin
.is() )
981 OSL_FAIL( "broadcaster was disposed already" );
982 throw RuntimeException();
984 return m_xResultSetOrigin
->getRow();
988 void SAL_CALL
ContentResultSetWrapper::refreshRow()
990 impl_EnsureNotDisposed();
992 if( !m_xResultSetOrigin
.is() )
994 OSL_FAIL( "broadcaster was disposed already" );
995 throw RuntimeException();
997 m_xResultSetOrigin
->refreshRow();
1001 sal_Bool SAL_CALL
ContentResultSetWrapper::rowUpdated()
1003 impl_EnsureNotDisposed();
1005 if( !m_xResultSetOrigin
.is() )
1007 OSL_FAIL( "broadcaster was disposed already" );
1008 throw RuntimeException();
1010 return m_xResultSetOrigin
->rowUpdated();
1014 sal_Bool SAL_CALL
ContentResultSetWrapper::rowInserted()
1016 impl_EnsureNotDisposed();
1018 if( !m_xResultSetOrigin
.is() )
1020 OSL_FAIL( "broadcaster was disposed already" );
1021 throw RuntimeException();
1023 return m_xResultSetOrigin
->rowInserted();
1027 sal_Bool SAL_CALL
ContentResultSetWrapper::rowDeleted()
1029 impl_EnsureNotDisposed();
1031 if( !m_xResultSetOrigin
.is() )
1033 OSL_FAIL( "broadcaster was disposed already" );
1034 throw RuntimeException();
1036 return m_xResultSetOrigin
->rowDeleted();
1040 Reference
< XInterface
> SAL_CALL
ContentResultSetWrapper::getStatement()
1042 impl_EnsureNotDisposed();
1043 //@todo ?return anything
1044 return Reference
< XInterface
>();
1051 void ContentResultSetWrapper::verifyGet()
1053 impl_EnsureNotDisposed();
1054 impl_init_xRowOrigin();
1055 if( !m_xRowOrigin
.is() )
1057 OSL_FAIL( "broadcaster was disposed already" );
1058 throw RuntimeException();
1063 sal_Bool SAL_CALL
ContentResultSetWrapper::wasNull()
1065 impl_EnsureNotDisposed();
1066 impl_init_xRowOrigin();
1067 if( !m_xRowOrigin
.is() )
1069 OSL_FAIL( "broadcaster was disposed already" );
1070 throw RuntimeException();
1072 return m_xRowOrigin
->wasNull();
1076 OUString SAL_CALL
ContentResultSetWrapper::getString( sal_Int32 columnIndex
)
1079 return m_xRowOrigin
->getString( columnIndex
);
1083 sal_Bool SAL_CALL
ContentResultSetWrapper::getBoolean( sal_Int32 columnIndex
)
1086 return m_xRowOrigin
->getBoolean( columnIndex
);
1090 sal_Int8 SAL_CALL
ContentResultSetWrapper::getByte( sal_Int32 columnIndex
)
1093 return m_xRowOrigin
->getByte( columnIndex
);
1097 sal_Int16 SAL_CALL
ContentResultSetWrapper::getShort( sal_Int32 columnIndex
)
1100 return m_xRowOrigin
->getShort( columnIndex
);
1104 sal_Int32 SAL_CALL
ContentResultSetWrapper::getInt( sal_Int32 columnIndex
)
1107 return m_xRowOrigin
->getInt( columnIndex
);
1111 sal_Int64 SAL_CALL
ContentResultSetWrapper::getLong( sal_Int32 columnIndex
)
1114 return m_xRowOrigin
->getLong( columnIndex
);
1118 float SAL_CALL
ContentResultSetWrapper::getFloat( sal_Int32 columnIndex
)
1121 return m_xRowOrigin
->getFloat( columnIndex
);
1125 double SAL_CALL
ContentResultSetWrapper::getDouble( sal_Int32 columnIndex
)
1128 return m_xRowOrigin
->getDouble( columnIndex
);
1132 Sequence
< sal_Int8
> SAL_CALL
ContentResultSetWrapper::getBytes( sal_Int32 columnIndex
)
1135 return m_xRowOrigin
->getBytes( columnIndex
);
1139 Date SAL_CALL
ContentResultSetWrapper::getDate( sal_Int32 columnIndex
)
1142 return m_xRowOrigin
->getDate( columnIndex
);
1146 Time SAL_CALL
ContentResultSetWrapper::getTime( sal_Int32 columnIndex
)
1149 return m_xRowOrigin
->getTime( columnIndex
);
1153 DateTime SAL_CALL
ContentResultSetWrapper::getTimestamp( sal_Int32 columnIndex
)
1156 return m_xRowOrigin
->getTimestamp( columnIndex
);
1160 Reference
< css::io::XInputStream
> SAL_CALL
ContentResultSetWrapper::getBinaryStream( sal_Int32 columnIndex
)
1163 return m_xRowOrigin
->getBinaryStream( columnIndex
);
1167 Reference
< css::io::XInputStream
> SAL_CALL
ContentResultSetWrapper::getCharacterStream( sal_Int32 columnIndex
)
1170 return m_xRowOrigin
->getCharacterStream( columnIndex
);
1174 Any SAL_CALL
ContentResultSetWrapper::getObject( sal_Int32 columnIndex
, const Reference
< css::container::XNameAccess
>& typeMap
)
1176 //if you change this macro please pay attention to
1177 //define XROW_GETXXX, where this is similar implemented
1179 impl_EnsureNotDisposed();
1180 impl_init_xRowOrigin();
1181 if( !m_xRowOrigin
.is() )
1183 OSL_FAIL( "broadcaster was disposed already" );
1184 throw RuntimeException();
1186 return m_xRowOrigin
->getObject( columnIndex
, typeMap
);
1190 Reference
< XRef
> SAL_CALL
ContentResultSetWrapper::getRef( sal_Int32 columnIndex
)
1193 return m_xRowOrigin
->getRef( columnIndex
);
1197 Reference
< XBlob
> SAL_CALL
ContentResultSetWrapper::getBlob( sal_Int32 columnIndex
)
1200 return m_xRowOrigin
->getBlob( columnIndex
);
1204 Reference
< XClob
> SAL_CALL
ContentResultSetWrapper::getClob( sal_Int32 columnIndex
)
1207 return m_xRowOrigin
->getClob( columnIndex
);
1211 Reference
< XArray
> SAL_CALL
ContentResultSetWrapper::getArray( sal_Int32 columnIndex
)
1214 return m_xRowOrigin
->getArray( columnIndex
);
1220 ContentResultSetWrapperListener::ContentResultSetWrapperListener(
1221 ContentResultSetWrapper
* pOwner
)
1222 : m_pOwner( pOwner
)
1226 ContentResultSetWrapperListener::~ContentResultSetWrapperListener()
1231 // XInterface methods.
1232 void SAL_CALL
ContentResultSetWrapperListener::acquire()
1235 OWeakObject::acquire();
1238 void SAL_CALL
ContentResultSetWrapperListener::release()
1241 OWeakObject::release();
1244 css::uno::Any SAL_CALL
ContentResultSetWrapperListener::queryInterface( const css::uno::Type
& rType
)
1246 //list all interfaces inclusive baseclasses of interfaces
1247 css::uno::Any aRet
= cppu::queryInterface( rType
,
1248 static_cast< XEventListener
* >(
1249 static_cast< XPropertyChangeListener
* >(this)),
1250 static_cast< XPropertyChangeListener
* >(this),
1251 static_cast< XVetoableChangeListener
* >(this)
1253 return aRet
.hasValue() ? aRet
: OWeakObject::queryInterface( rType
);
1256 //XEventListener methods.
1260 void SAL_CALL
ContentResultSetWrapperListener::disposing( const EventObject
& rEventObject
)
1263 m_pOwner
->impl_disposing( rEventObject
);
1267 //XPropertyChangeListener methods.
1271 void SAL_CALL
ContentResultSetWrapperListener::propertyChange( const PropertyChangeEvent
& rEvt
)
1274 m_pOwner
->impl_propertyChange( rEvt
);
1278 //XVetoableChangeListener methods.
1281 void SAL_CALL
ContentResultSetWrapperListener::vetoableChange( const PropertyChangeEvent
& rEvt
)
1284 m_pOwner
->impl_vetoableChange( rEvt
);
1287 void ContentResultSetWrapperListener::impl_OwnerDies()
1292 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */