nss: upgrade to release 3.73
[LibreOffice.git] / ucb / source / cacher / contentresultsetwrapper.cxx
blob6699fc9df710eb937240bb884c003ab173dccc14
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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;
35 using namespace cppu;
40 ContentResultSetWrapper::ContentResultSetWrapper(
41 Reference< XResultSet > const & xOrigin )
42 : m_xResultSetOrigin( xOrigin )
43 , m_nForwardOnly( 2 )
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 );
59 if(m_xRowOrigin.is())
60 return;
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())
77 return;
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() )
95 return;
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();
130 //virtual
131 void ContentResultSetWrapper::impl_initPropertySetInfo()
134 osl::Guard< osl::Mutex > aGuard( m_aMutex );
135 if( m_xPropertySetInfo.is() )
136 return;
138 impl_init_xPropertySetOrigin();
139 if( !m_xPropertySetOrigin.is() )
140 return;
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 );
155 if( m_bDisposed )
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 )
180 return;
183 // Notify listeners interested especially in the changed property.
184 OInterfaceContainerHelper* pContainer =
185 m_pPropertyChangeListeners->getContainer( rEvt.PropertyName );
186 if( pContainer )
188 OInterfaceIteratorHelper aIter( *pContainer );
189 while( aIter.hasMoreElements() )
191 Reference< XPropertyChangeListener > xListener(
192 aIter.next(), UNO_QUERY );
193 if( xListener.is() )
194 xListener->propertyChange( rEvt );
198 // Notify listeners interested in all properties.
199 pContainer = m_pPropertyChangeListeners->getContainer( OUString() );
200 if( pContainer )
202 OInterfaceIteratorHelper aIter( *pContainer );
203 while( aIter.hasMoreElements() )
205 Reference< XPropertyChangeListener > xListener(
206 aIter.next(), UNO_QUERY );
207 if( xListener.is() )
208 xListener->propertyChange( rEvt );
213 void ContentResultSetWrapper::impl_notifyVetoableChangeListeners( const PropertyChangeEvent& rEvt )
216 osl::Guard< osl::Mutex > aGuard( m_aMutex );
217 if( !m_pVetoableChangeListeners )
218 return;
221 // Notify listeners interested especially in the changed property.
222 OInterfaceContainerHelper* pContainer =
223 m_pVetoableChangeListeners->getContainer( rEvt.PropertyName );
224 if( pContainer )
226 OInterfaceIteratorHelper aIter( *pContainer );
227 while( aIter.hasMoreElements() )
229 Reference< XVetoableChangeListener > xListener(
230 aIter.next(), UNO_QUERY );
231 if( xListener.is() )
232 xListener->vetoableChange( rEvt );
236 // Notify listeners interested in all properties.
237 pContainer = m_pVetoableChangeListeners->getContainer( OUString() );
238 if( pContainer )
240 OInterfaceIteratorHelper aIter( *pContainer );
241 while( aIter.hasMoreElements() )
243 Reference< XVetoableChangeListener > xListener(
244 aIter.next(), UNO_QUERY );
245 if( xListener.is() )
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 );
259 m_nForwardOnly = 0;
260 return false;
264 ReacquireableGuard aGuard( m_aMutex );
265 if( m_nForwardOnly == 2 )
267 aGuard.clear();
268 if( !getPropertySetInfo().is() )
270 aGuard.reacquire();
271 m_nForwardOnly = 0;
272 return m_nForwardOnly;
274 aGuard.reacquire();
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" );
283 m_nForwardOnly = 0;
284 return m_nForwardOnly;
287 aGuard.clear();
288 Any aAny = m_xPropertySetOrigin->getPropertyValue( aName );
290 aGuard.reacquire();
291 long nResultSetType;
292 if( ( aAny >>= nResultSetType ) &&
293 ( nResultSetType == ResultSetType::FORWARD_ONLY ) )
294 m_nForwardOnly = 1;
295 else
296 m_nForwardOnly = 0;
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.
322 // virtual
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 )
330 return;
331 m_bInDispose = true;
333 if( m_xPropertySetOrigin.is() )
335 aGuard.clear();
336 isCleared = true;
339 m_xPropertySetOrigin->removePropertyChangeListener(
340 OUString(), static_cast< XPropertyChangeListener * >( m_xMyListenerImpl.get() ) );
342 catch( Exception& )
344 OSL_FAIL( "could not remove PropertyChangeListener" );
348 m_xPropertySetOrigin->removeVetoableChangeListener(
349 OUString(), static_cast< XVetoableChangeListener * >( m_xMyListenerImpl.get() ) );
351 catch( Exception& )
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() ) );
361 if (isCleared)
363 aGuard.reset();
364 isCleared = false;
366 if( m_pDisposeEventListeners && m_pDisposeEventListeners->getLength() )
368 EventObject aEvt;
369 aEvt.Source = static_cast< XComponent * >( this );
371 aGuard.clear();
372 isCleared = true;
373 m_pDisposeEventListeners->disposeAndClear( aEvt );
376 if (isCleared)
378 aGuard.reset();
379 isCleared = false;
381 if( m_pPropertyChangeListeners )
383 EventObject aEvt;
384 aEvt.Source = static_cast< XPropertySet * >( this );
386 aGuard.clear();
387 isCleared = true;
388 m_pPropertyChangeListeners->disposeAndClear( aEvt );
391 if (isCleared)
393 aGuard.reset();
394 isCleared = false;
396 if( m_pVetoableChangeListeners )
398 EventObject aEvt;
399 aEvt.Source = static_cast< XPropertySet * >( this );
401 aGuard.clear();
402 isCleared = true;
403 m_pVetoableChangeListeners->disposeAndClear( aEvt );
406 if (isCleared)
408 aGuard.reset();
410 m_bDisposed = true;
411 m_bInDispose = false;
415 // virtual
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 );
429 // virtual
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.
442 //virtual
443 void SAL_CALL ContentResultSetWrapper::close()
445 impl_EnsureNotDisposed();
446 dispose();
450 //XResultSetMetaDataSupplier methods.
452 //virtual
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() )
465 aGuard.clear();
467 Reference< XResultSetMetaData > xMetaData
468 = xMetaDataSupplier->getMetaData();
470 aGuard.reset();
471 m_xMetaDataFromOrigin = xMetaData;
474 return m_xMetaDataFromOrigin;
478 // XPropertySet methods.
480 // virtual
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;
493 // virtual
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 );
507 // virtual
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 );
521 // virtual
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 );
542 if( !bNeedRegister )
543 return;
545 impl_init_xPropertySetOrigin();
547 osl::Guard< osl::Mutex > aGuard( m_aMutex );
548 if( !m_xPropertySetOrigin.is() )
550 OSL_FAIL( "broadcaster was disposed already" );
551 return;
556 m_xPropertySetOrigin->addPropertyChangeListener(
557 OUString(), static_cast< XPropertyChangeListener * >( m_xMyListenerImpl.get() ) );
559 catch( Exception& )
561 m_pPropertyChangeListeners->removeInterface( aPropertyName, xListener );
562 throw;
567 // virtual
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 );
587 if( !bNeedRegister )
588 return;
590 impl_init_xPropertySetOrigin();
592 osl::Guard< osl::Mutex > aGuard( m_aMutex );
593 if( !m_xPropertySetOrigin.is() )
595 OSL_FAIL( "broadcaster was disposed already" );
596 return;
601 m_xPropertySetOrigin->addVetoableChangeListener(
602 OUString(), static_cast< XVetoableChangeListener * >( m_xMyListenerImpl.get() ) );
604 catch( Exception& )
606 m_pVetoableChangeListeners->removeInterface( rPropertyName, xListener );
607 throw;
612 // virtual
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 )
621 return;
623 OInterfaceContainerHelper* pContainer =
624 m_pPropertyChangeListeners->getContainer( rPropertyName );
626 if( !pContainer )
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() )
642 return;
644 impl_init_xPropertySetOrigin();
646 osl::Guard< osl::Mutex > aGuard( m_aMutex );
647 if( !m_xPropertySetOrigin.is() )
649 OSL_FAIL( "broadcaster was disposed already" );
650 return;
655 m_xPropertySetOrigin->removePropertyChangeListener(
656 OUString(), static_cast< XPropertyChangeListener * >( m_xMyListenerImpl.get() ) );
658 catch( Exception& )
660 OSL_FAIL( "could not remove PropertyChangeListener" );
665 // virtual
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 )
674 return;
676 OInterfaceContainerHelper* pContainer =
677 m_pVetoableChangeListeners->getContainer( rPropertyName );
679 if( !pContainer )
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() )
695 return;
697 impl_init_xPropertySetOrigin();
699 osl::Guard< osl::Mutex > aGuard( m_aMutex );
700 if( !m_xPropertySetOrigin.is() )
702 OSL_FAIL( "broadcaster was disposed already" );
703 return;
708 m_xPropertySetOrigin->removeVetoableChangeListener(
709 OUString(), static_cast< XVetoableChangeListener * >( m_xMyListenerImpl.get() ) );
711 catch( Exception& )
713 OSL_FAIL( "could not remove VetoableChangeListener" );
718 // own methods.
721 //virtual
722 void ContentResultSetWrapper::impl_disposing( const EventObject& )
724 impl_EnsureNotDisposed();
726 osl::Guard< osl::Mutex > aGuard( m_aMutex );
728 if( !m_xResultSetOrigin.is() )
729 return;
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();
744 //virtual
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 );
755 //virtual
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 )
771 // virtual
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();
785 // virtual
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();
799 // virtual
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.
815 //virtual
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();
829 //virtual
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();
842 //virtual
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 );
855 //virtual
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 );
869 //virtual
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();
882 //virtual
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();
895 //virtual
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();
908 //virtual
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();
921 //virtual
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();
934 //virtual
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();
947 //virtual
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();
960 //virtual
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();
974 //virtual
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();
987 //virtual
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();
1000 //virtual
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();
1013 //virtual
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();
1026 //virtual
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();
1039 //virtual
1040 Reference< XInterface > SAL_CALL ContentResultSetWrapper::getStatement()
1042 impl_EnsureNotDisposed();
1043 //@todo ?return anything
1044 return Reference< XInterface >();
1048 // XRow methods.
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();
1062 //virtual
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();
1075 //virtual
1076 OUString SAL_CALL ContentResultSetWrapper::getString( sal_Int32 columnIndex )
1078 verifyGet();
1079 return m_xRowOrigin->getString( columnIndex );
1082 //virtual
1083 sal_Bool SAL_CALL ContentResultSetWrapper::getBoolean( sal_Int32 columnIndex )
1085 verifyGet();
1086 return m_xRowOrigin->getBoolean( columnIndex );
1089 //virtual
1090 sal_Int8 SAL_CALL ContentResultSetWrapper::getByte( sal_Int32 columnIndex )
1092 verifyGet();
1093 return m_xRowOrigin->getByte( columnIndex );
1096 //virtual
1097 sal_Int16 SAL_CALL ContentResultSetWrapper::getShort( sal_Int32 columnIndex )
1099 verifyGet();
1100 return m_xRowOrigin->getShort( columnIndex );
1103 //virtual
1104 sal_Int32 SAL_CALL ContentResultSetWrapper::getInt( sal_Int32 columnIndex )
1106 verifyGet();
1107 return m_xRowOrigin->getInt( columnIndex );
1110 //virtual
1111 sal_Int64 SAL_CALL ContentResultSetWrapper::getLong( sal_Int32 columnIndex )
1113 verifyGet();
1114 return m_xRowOrigin->getLong( columnIndex );
1117 //virtual
1118 float SAL_CALL ContentResultSetWrapper::getFloat( sal_Int32 columnIndex )
1120 verifyGet();
1121 return m_xRowOrigin->getFloat( columnIndex );
1124 //virtual
1125 double SAL_CALL ContentResultSetWrapper::getDouble( sal_Int32 columnIndex )
1127 verifyGet();
1128 return m_xRowOrigin->getDouble( columnIndex );
1131 //virtual
1132 Sequence< sal_Int8 > SAL_CALL ContentResultSetWrapper::getBytes( sal_Int32 columnIndex )
1134 verifyGet();
1135 return m_xRowOrigin->getBytes( columnIndex );
1138 //virtual
1139 Date SAL_CALL ContentResultSetWrapper::getDate( sal_Int32 columnIndex )
1141 verifyGet();
1142 return m_xRowOrigin->getDate( columnIndex );
1145 //virtual
1146 Time SAL_CALL ContentResultSetWrapper::getTime( sal_Int32 columnIndex )
1148 verifyGet();
1149 return m_xRowOrigin->getTime( columnIndex );
1152 //virtual
1153 DateTime SAL_CALL ContentResultSetWrapper::getTimestamp( sal_Int32 columnIndex )
1155 verifyGet();
1156 return m_xRowOrigin->getTimestamp( columnIndex );
1159 //virtual
1160 Reference< css::io::XInputStream > SAL_CALL ContentResultSetWrapper::getBinaryStream( sal_Int32 columnIndex )
1162 verifyGet();
1163 return m_xRowOrigin->getBinaryStream( columnIndex );
1166 //virtual
1167 Reference< css::io::XInputStream > SAL_CALL ContentResultSetWrapper::getCharacterStream( sal_Int32 columnIndex )
1169 verifyGet();
1170 return m_xRowOrigin->getCharacterStream( columnIndex );
1173 //virtual
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 );
1189 //virtual
1190 Reference< XRef > SAL_CALL ContentResultSetWrapper::getRef( sal_Int32 columnIndex )
1192 verifyGet();
1193 return m_xRowOrigin->getRef( columnIndex );
1196 //virtual
1197 Reference< XBlob > SAL_CALL ContentResultSetWrapper::getBlob( sal_Int32 columnIndex )
1199 verifyGet();
1200 return m_xRowOrigin->getBlob( columnIndex );
1203 //virtual
1204 Reference< XClob > SAL_CALL ContentResultSetWrapper::getClob( sal_Int32 columnIndex )
1206 verifyGet();
1207 return m_xRowOrigin->getClob( columnIndex );
1210 //virtual
1211 Reference< XArray > SAL_CALL ContentResultSetWrapper::getArray( sal_Int32 columnIndex )
1213 verifyGet();
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()
1233 throw()
1235 OWeakObject::acquire();
1238 void SAL_CALL ContentResultSetWrapperListener::release()
1239 throw()
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.
1259 //virtual
1260 void SAL_CALL ContentResultSetWrapperListener::disposing( const EventObject& rEventObject )
1262 if( m_pOwner )
1263 m_pOwner->impl_disposing( rEventObject );
1267 //XPropertyChangeListener methods.
1270 //virtual
1271 void SAL_CALL ContentResultSetWrapperListener::propertyChange( const PropertyChangeEvent& rEvt )
1273 if( m_pOwner )
1274 m_pOwner->impl_propertyChange( rEvt );
1278 //XVetoableChangeListener methods.
1280 //virtual
1281 void SAL_CALL ContentResultSetWrapperListener::vetoableChange( const PropertyChangeEvent& rEvt )
1283 if( m_pOwner )
1284 m_pOwner->impl_vetoableChange( rEvt );
1287 void ContentResultSetWrapperListener::impl_OwnerDies()
1289 m_pOwner = nullptr;
1292 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */