Version 6.4.0.3, tag libreoffice-6.4.0.3
[LibreOffice.git] / ucb / source / cacher / contentresultsetwrapper.cxx
blob3bb8bb4ed92437de49a39dc371a4c33ba3fb6279
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;
38 // class ContentResultSetWrapper
41 ContentResultSetWrapper::ContentResultSetWrapper(
42 Reference< XResultSet > const & xOrigin )
43 : m_xResultSetOrigin( xOrigin )
44 , m_nForwardOnly( 2 )
45 , m_bDisposed( false )
46 , m_bInDispose( false )
48 m_xMyListenerImpl = new ContentResultSetWrapperListener( this );
50 OSL_ENSURE( m_xResultSetOrigin.is(), "XResultSet is required" );
52 //!! call impl_init() at the end of constructor of derived class
56 void ContentResultSetWrapper::impl_init_xRowOrigin()
59 osl::Guard< osl::Mutex > aGuard( m_aMutex );
60 if(m_xRowOrigin.is())
61 return;
64 Reference< XRow > xOrgig( m_xResultSetOrigin, UNO_QUERY );
67 osl::Guard< osl::Mutex > aGuard( m_aMutex );
68 m_xRowOrigin = xOrgig;
69 OSL_ENSURE( m_xRowOrigin.is(), "interface XRow is required" );
73 void ContentResultSetWrapper::impl_init_xContentAccessOrigin()
76 osl::Guard< osl::Mutex > aGuard( m_aMutex );
77 if(m_xContentAccessOrigin.is())
78 return;
81 Reference< XContentAccess > xOrgig( m_xResultSetOrigin, UNO_QUERY );
84 osl::Guard< osl::Mutex > aGuard( m_aMutex );
85 m_xContentAccessOrigin = xOrgig;
86 OSL_ENSURE( m_xContentAccessOrigin.is(), "interface XContentAccess is required" );
91 void ContentResultSetWrapper::impl_init_xPropertySetOrigin()
94 osl::Guard< osl::Mutex > aGuard( m_aMutex );
95 if( m_xPropertySetOrigin.is() )
96 return;
99 Reference< XPropertySet > xOrig( m_xResultSetOrigin, UNO_QUERY );
102 osl::Guard< osl::Mutex > aGuard( m_aMutex );
103 m_xPropertySetOrigin = xOrig;
104 OSL_ENSURE( m_xPropertySetOrigin.is(), "interface XPropertySet is required" );
108 void ContentResultSetWrapper::impl_init()
110 //call this at the end of constructor of derived class
113 //listen to disposing from Origin:
114 Reference< XComponent > xComponentOrigin( m_xResultSetOrigin, UNO_QUERY );
115 OSL_ENSURE( xComponentOrigin.is(), "interface XComponent is required" );
116 xComponentOrigin->addEventListener( static_cast< XPropertyChangeListener * >( m_xMyListenerImpl.get() ) );
119 ContentResultSetWrapper::~ContentResultSetWrapper()
121 //call impl_deinit() at start of destructor of derived class
124 void ContentResultSetWrapper::impl_deinit()
126 //call this at start of destructor of derived class
128 m_xMyListenerImpl->impl_OwnerDies();
131 //virtual
132 void ContentResultSetWrapper::impl_initPropertySetInfo()
135 osl::Guard< osl::Mutex > aGuard( m_aMutex );
136 if( m_xPropertySetInfo.is() )
137 return;
139 impl_init_xPropertySetOrigin();
140 if( !m_xPropertySetOrigin.is() )
141 return;
144 Reference< XPropertySetInfo > xOrig =
145 m_xPropertySetOrigin->getPropertySetInfo();
148 osl::Guard< osl::Mutex > aGuard( m_aMutex );
149 m_xPropertySetInfo = xOrig;
153 void ContentResultSetWrapper::impl_EnsureNotDisposed()
155 osl::Guard< osl::Mutex > aGuard( m_aMutex );
156 if( m_bDisposed )
157 throw DisposedException();
160 void ContentResultSetWrapper::impl_getPropertyChangeListenerContainer()
162 osl::Guard< osl::Mutex > aGuard( m_aMutex );
163 if ( !m_pPropertyChangeListeners )
164 m_pPropertyChangeListeners.reset(
165 new PropertyChangeListenerContainer_Impl( m_aContainerMutex ) );
168 void ContentResultSetWrapper::impl_getVetoableChangeListenerContainer()
170 osl::Guard< osl::Mutex > aGuard( m_aMutex );
171 if ( !m_pVetoableChangeListeners )
172 m_pVetoableChangeListeners.reset(
173 new PropertyChangeListenerContainer_Impl( m_aContainerMutex ) );
176 void ContentResultSetWrapper::impl_notifyPropertyChangeListeners( const PropertyChangeEvent& rEvt )
179 osl::Guard< osl::Mutex > aGuard( m_aMutex );
180 if( !m_pPropertyChangeListeners )
181 return;
184 // Notify listeners interested especially in the changed property.
185 OInterfaceContainerHelper* pContainer =
186 m_pPropertyChangeListeners->getContainer( rEvt.PropertyName );
187 if( pContainer )
189 OInterfaceIteratorHelper aIter( *pContainer );
190 while( aIter.hasMoreElements() )
192 Reference< XPropertyChangeListener > xListener(
193 aIter.next(), UNO_QUERY );
194 if( xListener.is() )
195 xListener->propertyChange( rEvt );
199 // Notify listeners interested in all properties.
200 pContainer = m_pPropertyChangeListeners->getContainer( OUString() );
201 if( pContainer )
203 OInterfaceIteratorHelper aIter( *pContainer );
204 while( aIter.hasMoreElements() )
206 Reference< XPropertyChangeListener > xListener(
207 aIter.next(), UNO_QUERY );
208 if( xListener.is() )
209 xListener->propertyChange( rEvt );
214 void ContentResultSetWrapper::impl_notifyVetoableChangeListeners( const PropertyChangeEvent& rEvt )
217 osl::Guard< osl::Mutex > aGuard( m_aMutex );
218 if( !m_pVetoableChangeListeners )
219 return;
222 // Notify listeners interested especially in the changed property.
223 OInterfaceContainerHelper* pContainer =
224 m_pVetoableChangeListeners->getContainer( rEvt.PropertyName );
225 if( pContainer )
227 OInterfaceIteratorHelper aIter( *pContainer );
228 while( aIter.hasMoreElements() )
230 Reference< XVetoableChangeListener > xListener(
231 aIter.next(), UNO_QUERY );
232 if( xListener.is() )
233 xListener->vetoableChange( rEvt );
237 // Notify listeners interested in all properties.
238 pContainer = m_pVetoableChangeListeners->getContainer( OUString() );
239 if( pContainer )
241 OInterfaceIteratorHelper aIter( *pContainer );
242 while( aIter.hasMoreElements() )
244 Reference< XVetoableChangeListener > xListener(
245 aIter.next(), UNO_QUERY );
246 if( xListener.is() )
247 xListener->vetoableChange( rEvt );
252 bool ContentResultSetWrapper::impl_isForwardOnly()
254 //m_nForwardOnly == 2 -> don't know
255 //m_nForwardOnly == 1 -> YES
256 //m_nForwardOnly == 0 -> NO
258 //@todo replace this with lines in comment
259 osl::Guard< osl::Mutex > aGuard( m_aMutex );
260 m_nForwardOnly = 0;
261 return false;
265 ReacquireableGuard aGuard( m_aMutex );
266 if( m_nForwardOnly == 2 )
268 aGuard.clear();
269 if( !getPropertySetInfo().is() )
271 aGuard.reacquire();
272 m_nForwardOnly = 0;
273 return m_nForwardOnly;
275 aGuard.reacquire();
277 OUString aName("ResultSetType");
278 //find out, if we are ForwardOnly and cache the value:
280 impl_init_xPropertySetOrigin();
281 if( !m_xPropertySetOrigin.is() )
283 OSL_FAIL( "broadcaster was disposed already" );
284 m_nForwardOnly = 0;
285 return m_nForwardOnly;
288 aGuard.clear();
289 Any aAny = m_xPropertySetOrigin->getPropertyValue( aName );
291 aGuard.reacquire();
292 long nResultSetType;
293 if( ( aAny >>= nResultSetType ) &&
294 ( nResultSetType == ResultSetType::FORWARD_ONLY ) )
295 m_nForwardOnly = 1;
296 else
297 m_nForwardOnly = 0;
299 return m_nForwardOnly;
304 // XInterface methods.
306 css::uno::Any SAL_CALL ContentResultSetWrapper::queryInterface( const css::uno::Type & rType )
308 //list all interfaces inclusive baseclasses of interfaces
309 css::uno::Any aRet = cppu::queryInterface( rType,
310 static_cast< XComponent* >(this),
311 static_cast< XCloseable* >(this),
312 static_cast< XResultSetMetaDataSupplier* >(this),
313 static_cast< XPropertySet* >(this),
314 static_cast< XContentAccess* >(this),
315 static_cast< XResultSet* >(this),
316 static_cast< XRow* >(this)
318 return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType );
321 // XComponent methods.
323 // virtual
324 void SAL_CALL ContentResultSetWrapper::dispose()
326 impl_EnsureNotDisposed();
328 bool isCleared = false;
329 osl::ResettableMutexGuard aGuard(m_aMutex);
330 if( m_bInDispose || m_bDisposed )
331 return;
332 m_bInDispose = true;
334 if( m_xPropertySetOrigin.is() )
336 aGuard.clear();
337 isCleared = true;
340 m_xPropertySetOrigin->removePropertyChangeListener(
341 OUString(), static_cast< XPropertyChangeListener * >( m_xMyListenerImpl.get() ) );
343 catch( Exception& )
345 OSL_FAIL( "could not remove PropertyChangeListener" );
349 m_xPropertySetOrigin->removeVetoableChangeListener(
350 OUString(), static_cast< XVetoableChangeListener * >( m_xMyListenerImpl.get() ) );
352 catch( Exception& )
354 OSL_FAIL( "could not remove VetoableChangeListener" );
357 Reference< XComponent > xComponentOrigin( m_xResultSetOrigin, UNO_QUERY );
358 OSL_ENSURE( xComponentOrigin.is(), "interface XComponent is required" );
359 xComponentOrigin->removeEventListener( static_cast< XPropertyChangeListener * >( m_xMyListenerImpl.get() ) );
362 if (isCleared)
364 aGuard.reset();
365 isCleared = false;
367 if( m_pDisposeEventListeners && m_pDisposeEventListeners->getLength() )
369 EventObject aEvt;
370 aEvt.Source = static_cast< XComponent * >( this );
372 aGuard.clear();
373 isCleared = true;
374 m_pDisposeEventListeners->disposeAndClear( aEvt );
377 if (isCleared)
379 aGuard.reset();
380 isCleared = false;
382 if( m_pPropertyChangeListeners )
384 EventObject aEvt;
385 aEvt.Source = static_cast< XPropertySet * >( this );
387 aGuard.clear();
388 isCleared = true;
389 m_pPropertyChangeListeners->disposeAndClear( aEvt );
392 if (isCleared)
394 aGuard.reset();
395 isCleared = false;
397 if( m_pVetoableChangeListeners )
399 EventObject aEvt;
400 aEvt.Source = static_cast< XPropertySet * >( this );
402 aGuard.clear();
403 isCleared = true;
404 m_pVetoableChangeListeners->disposeAndClear( aEvt );
407 if (isCleared)
409 aGuard.reset();
411 m_bDisposed = true;
412 m_bInDispose = false;
416 // virtual
417 void SAL_CALL ContentResultSetWrapper::addEventListener( const Reference< XEventListener >& Listener )
419 impl_EnsureNotDisposed();
420 osl::Guard< osl::Mutex > aGuard( m_aMutex );
422 if ( !m_pDisposeEventListeners )
423 m_pDisposeEventListeners.reset(
424 new OInterfaceContainerHelper2( m_aContainerMutex ) );
426 m_pDisposeEventListeners->addInterface( Listener );
430 // virtual
431 void SAL_CALL ContentResultSetWrapper::removeEventListener( const Reference< XEventListener >& Listener )
433 impl_EnsureNotDisposed();
434 osl::Guard< osl::Mutex > aGuard( m_aMutex );
436 if ( m_pDisposeEventListeners )
437 m_pDisposeEventListeners->removeInterface( Listener );
441 //XCloseable methods.
443 //virtual
444 void SAL_CALL ContentResultSetWrapper::close()
446 impl_EnsureNotDisposed();
447 dispose();
451 //XResultSetMetaDataSupplier methods.
453 //virtual
454 Reference< XResultSetMetaData > SAL_CALL ContentResultSetWrapper::getMetaData()
456 impl_EnsureNotDisposed();
458 osl::ResettableMutexGuard aGuard(m_aMutex);
459 if( !m_xMetaDataFromOrigin.is() && m_xResultSetOrigin.is() )
461 Reference< XResultSetMetaDataSupplier > xMetaDataSupplier(
462 m_xResultSetOrigin, UNO_QUERY );
464 if( xMetaDataSupplier.is() )
466 aGuard.clear();
468 Reference< XResultSetMetaData > xMetaData
469 = xMetaDataSupplier->getMetaData();
471 aGuard.reset();
472 m_xMetaDataFromOrigin = xMetaData;
475 return m_xMetaDataFromOrigin;
479 // XPropertySet methods.
481 // virtual
482 Reference< XPropertySetInfo > SAL_CALL ContentResultSetWrapper::getPropertySetInfo()
484 impl_EnsureNotDisposed();
486 osl::Guard< osl::Mutex > aGuard( m_aMutex );
487 if( m_xPropertySetInfo.is() )
488 return m_xPropertySetInfo;
490 impl_initPropertySetInfo();
491 return m_xPropertySetInfo;
494 // virtual
495 void SAL_CALL ContentResultSetWrapper::setPropertyValue( const OUString& rPropertyName, const Any& rValue )
497 impl_EnsureNotDisposed();
498 impl_init_xPropertySetOrigin();
499 if( !m_xPropertySetOrigin.is() )
501 OSL_FAIL( "broadcaster was disposed already" );
502 throw UnknownPropertyException();
504 m_xPropertySetOrigin->setPropertyValue( rPropertyName, rValue );
508 // virtual
509 Any SAL_CALL ContentResultSetWrapper::getPropertyValue( const OUString& rPropertyName )
511 impl_EnsureNotDisposed();
512 impl_init_xPropertySetOrigin();
513 if( !m_xPropertySetOrigin.is() )
515 OSL_FAIL( "broadcaster was disposed already" );
516 throw UnknownPropertyException();
518 return m_xPropertySetOrigin->getPropertyValue( rPropertyName );
522 // virtual
523 void SAL_CALL ContentResultSetWrapper::addPropertyChangeListener( const OUString& aPropertyName, const Reference< XPropertyChangeListener >& xListener )
525 impl_EnsureNotDisposed();
527 if( !getPropertySetInfo().is() )
529 OSL_FAIL( "broadcaster was disposed already" );
530 throw UnknownPropertyException();
533 if( !aPropertyName.isEmpty() )
535 m_xPropertySetInfo->getPropertyByName( aPropertyName );
536 //throws UnknownPropertyException, if so
539 impl_getPropertyChangeListenerContainer();
540 bool bNeedRegister = !m_pPropertyChangeListeners->
541 getContainedTypes().hasElements();
542 m_pPropertyChangeListeners->addInterface( aPropertyName, xListener );
543 if( bNeedRegister )
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;
568 // virtual
569 void SAL_CALL ContentResultSetWrapper::addVetoableChangeListener( const OUString& rPropertyName, const Reference< XVetoableChangeListener >& xListener )
571 impl_EnsureNotDisposed();
573 if( !getPropertySetInfo().is() )
575 OSL_FAIL( "broadcaster was disposed already" );
576 throw UnknownPropertyException();
578 if( !rPropertyName.isEmpty() )
580 m_xPropertySetInfo->getPropertyByName( rPropertyName );
581 //throws UnknownPropertyException, if so
584 impl_getVetoableChangeListenerContainer();
585 bool bNeedRegister = !m_pVetoableChangeListeners->
586 getContainedTypes().hasElements();
587 m_pVetoableChangeListeners->addInterface( rPropertyName, xListener );
588 if( bNeedRegister )
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;
613 // virtual
614 void SAL_CALL ContentResultSetWrapper::removePropertyChangeListener( const OUString& rPropertyName, const Reference< XPropertyChangeListener >& xListener )
616 impl_EnsureNotDisposed();
619 //noop, if no listener registered
620 osl::Guard< osl::Mutex > aGuard( m_aMutex );
621 if( !m_pPropertyChangeListeners )
622 return;
624 OInterfaceContainerHelper* pContainer =
625 m_pPropertyChangeListeners->getContainer( rPropertyName );
627 if( !pContainer )
629 if( !rPropertyName.isEmpty() )
631 if( !getPropertySetInfo().is() )
632 throw UnknownPropertyException();
634 m_xPropertySetInfo->getPropertyByName( rPropertyName );
635 //throws UnknownPropertyException, if so
637 return; //the listener was not registered
640 m_pPropertyChangeListeners->removeInterface( rPropertyName, xListener );
642 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" );
650 return;
655 m_xPropertySetOrigin->removePropertyChangeListener(
656 OUString(), static_cast< XPropertyChangeListener * >( m_xMyListenerImpl.get() ) );
658 catch( Exception& )
660 OSL_FAIL( "could not remove PropertyChangeListener" );
666 // virtual
667 void SAL_CALL ContentResultSetWrapper::removeVetoableChangeListener( const OUString& rPropertyName, const Reference< XVetoableChangeListener >& xListener )
669 impl_EnsureNotDisposed();
672 //noop, if no listener registered
673 osl::Guard< osl::Mutex > aGuard( m_aMutex );
674 if( !m_pVetoableChangeListeners )
675 return;
677 OInterfaceContainerHelper* pContainer =
678 m_pVetoableChangeListeners->getContainer( rPropertyName );
680 if( !pContainer )
682 if( !rPropertyName.isEmpty() )
684 if( !getPropertySetInfo().is() )
685 throw UnknownPropertyException(rPropertyName);
687 m_xPropertySetInfo->getPropertyByName( rPropertyName );
688 //throws UnknownPropertyException, if so
690 return; //the listener was not registered
693 m_pVetoableChangeListeners->removeInterface( rPropertyName, xListener );
695 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" );
703 return;
708 m_xPropertySetOrigin->removeVetoableChangeListener(
709 OUString(), static_cast< XVetoableChangeListener * >( m_xMyListenerImpl.get() ) );
711 catch( Exception& )
713 OSL_FAIL( "could not remove VetoableChangeListener" );
719 // own methods.
722 //virtual
723 void ContentResultSetWrapper::impl_disposing( const EventObject& )
725 impl_EnsureNotDisposed();
727 osl::Guard< osl::Mutex > aGuard( m_aMutex );
729 if( !m_xResultSetOrigin.is() )
730 return;
732 //release all references to the broadcaster:
733 m_xResultSetOrigin.clear();
734 if(m_xRowOrigin.is())
735 m_xRowOrigin.clear();
736 if(m_xContentAccessOrigin.is())
737 m_xContentAccessOrigin.clear();
738 if(m_xPropertySetOrigin.is())
739 m_xPropertySetOrigin.clear();
740 m_xMetaDataFromOrigin.clear();
741 if(m_xPropertySetInfo.is())
742 m_xPropertySetInfo.clear();
745 //virtual
746 void ContentResultSetWrapper::impl_propertyChange( const PropertyChangeEvent& rEvt )
748 impl_EnsureNotDisposed();
750 PropertyChangeEvent aEvt( rEvt );
751 aEvt.Source = static_cast< XPropertySet * >( this );
752 aEvt.Further = false;
753 impl_notifyPropertyChangeListeners( aEvt );
756 //virtual
757 void ContentResultSetWrapper::impl_vetoableChange( const PropertyChangeEvent& rEvt )
759 impl_EnsureNotDisposed();
761 PropertyChangeEvent aEvt( rEvt );
762 aEvt.Source = static_cast< XPropertySet * >( this );
763 aEvt.Further = false;
765 impl_notifyVetoableChangeListeners( aEvt );
769 // XContentAccess methods. ( -- position dependent )
772 // virtual
773 OUString SAL_CALL ContentResultSetWrapper::queryContentIdentifierString()
775 impl_EnsureNotDisposed();
776 impl_init_xContentAccessOrigin();
777 if( !m_xContentAccessOrigin.is() )
779 OSL_FAIL( "broadcaster was disposed already" );
780 throw RuntimeException();
782 return m_xContentAccessOrigin->queryContentIdentifierString();
786 // virtual
787 Reference< XContentIdentifier > SAL_CALL ContentResultSetWrapper::queryContentIdentifier()
789 impl_EnsureNotDisposed();
790 impl_init_xContentAccessOrigin();
791 if( !m_xContentAccessOrigin.is() )
793 OSL_FAIL( "broadcaster was disposed already" );
794 throw RuntimeException();
796 return m_xContentAccessOrigin->queryContentIdentifier();
800 // virtual
801 Reference< XContent > SAL_CALL ContentResultSetWrapper::queryContent()
803 impl_EnsureNotDisposed();
804 impl_init_xContentAccessOrigin();
805 if( !m_xContentAccessOrigin.is() )
807 OSL_FAIL( "broadcaster was disposed already" );
808 throw RuntimeException();
810 return m_xContentAccessOrigin->queryContent();
814 // XResultSet methods.
816 //virtual
818 sal_Bool SAL_CALL ContentResultSetWrapper::next()
820 impl_EnsureNotDisposed();
822 if( !m_xResultSetOrigin.is() )
824 OSL_FAIL( "broadcaster was disposed already" );
825 throw RuntimeException();
827 return m_xResultSetOrigin->next();
830 //virtual
831 sal_Bool SAL_CALL ContentResultSetWrapper::previous()
833 impl_EnsureNotDisposed();
835 if( !m_xResultSetOrigin.is() )
837 OSL_FAIL( "broadcaster was disposed already" );
838 throw RuntimeException();
840 return m_xResultSetOrigin->previous();
843 //virtual
844 sal_Bool SAL_CALL ContentResultSetWrapper::absolute( sal_Int32 row )
846 impl_EnsureNotDisposed();
848 if( !m_xResultSetOrigin.is() )
850 OSL_FAIL( "broadcaster was disposed already" );
851 throw RuntimeException();
853 return m_xResultSetOrigin->absolute( row );
856 //virtual
857 sal_Bool SAL_CALL ContentResultSetWrapper::relative( sal_Int32 rows )
859 impl_EnsureNotDisposed();
861 if( !m_xResultSetOrigin.is() )
863 OSL_FAIL( "broadcaster was disposed already" );
864 throw RuntimeException();
866 return m_xResultSetOrigin->relative( rows );
870 //virtual
871 sal_Bool SAL_CALL ContentResultSetWrapper::first()
873 impl_EnsureNotDisposed();
875 if( !m_xResultSetOrigin.is() )
877 OSL_FAIL( "broadcaster was disposed already" );
878 throw RuntimeException();
880 return m_xResultSetOrigin->first();
883 //virtual
884 sal_Bool SAL_CALL ContentResultSetWrapper::last()
886 impl_EnsureNotDisposed();
888 if( !m_xResultSetOrigin.is() )
890 OSL_FAIL( "broadcaster was disposed already" );
891 throw RuntimeException();
893 return m_xResultSetOrigin->last();
896 //virtual
897 void SAL_CALL ContentResultSetWrapper::beforeFirst()
899 impl_EnsureNotDisposed();
901 if( !m_xResultSetOrigin.is() )
903 OSL_FAIL( "broadcaster was disposed already" );
904 throw RuntimeException();
906 m_xResultSetOrigin->beforeFirst();
909 //virtual
910 void SAL_CALL ContentResultSetWrapper::afterLast()
912 impl_EnsureNotDisposed();
914 if( !m_xResultSetOrigin.is() )
916 OSL_FAIL( "broadcaster was disposed already" );
917 throw RuntimeException();
919 m_xResultSetOrigin->afterLast();
922 //virtual
923 sal_Bool SAL_CALL ContentResultSetWrapper::isAfterLast()
925 impl_EnsureNotDisposed();
927 if( !m_xResultSetOrigin.is() )
929 OSL_FAIL( "broadcaster was disposed already" );
930 throw RuntimeException();
932 return m_xResultSetOrigin->isAfterLast();
935 //virtual
936 sal_Bool SAL_CALL ContentResultSetWrapper::isBeforeFirst()
938 impl_EnsureNotDisposed();
940 if( !m_xResultSetOrigin.is() )
942 OSL_FAIL( "broadcaster was disposed already" );
943 throw RuntimeException();
945 return m_xResultSetOrigin->isBeforeFirst();
948 //virtual
949 sal_Bool SAL_CALL ContentResultSetWrapper::isFirst()
951 impl_EnsureNotDisposed();
953 if( !m_xResultSetOrigin.is() )
955 OSL_FAIL( "broadcaster was disposed already" );
956 throw RuntimeException();
958 return m_xResultSetOrigin->isFirst();
961 //virtual
962 sal_Bool SAL_CALL ContentResultSetWrapper::isLast()
964 impl_EnsureNotDisposed();
966 if( !m_xResultSetOrigin.is() )
968 OSL_FAIL( "broadcaster was disposed already" );
969 throw RuntimeException();
971 return m_xResultSetOrigin->isLast();
975 //virtual
976 sal_Int32 SAL_CALL ContentResultSetWrapper::getRow()
978 impl_EnsureNotDisposed();
980 if( !m_xResultSetOrigin.is() )
982 OSL_FAIL( "broadcaster was disposed already" );
983 throw RuntimeException();
985 return m_xResultSetOrigin->getRow();
988 //virtual
989 void SAL_CALL ContentResultSetWrapper::refreshRow()
991 impl_EnsureNotDisposed();
993 if( !m_xResultSetOrigin.is() )
995 OSL_FAIL( "broadcaster was disposed already" );
996 throw RuntimeException();
998 m_xResultSetOrigin->refreshRow();
1001 //virtual
1002 sal_Bool SAL_CALL ContentResultSetWrapper::rowUpdated()
1004 impl_EnsureNotDisposed();
1006 if( !m_xResultSetOrigin.is() )
1008 OSL_FAIL( "broadcaster was disposed already" );
1009 throw RuntimeException();
1011 return m_xResultSetOrigin->rowUpdated();
1014 //virtual
1015 sal_Bool SAL_CALL ContentResultSetWrapper::rowInserted()
1017 impl_EnsureNotDisposed();
1019 if( !m_xResultSetOrigin.is() )
1021 OSL_FAIL( "broadcaster was disposed already" );
1022 throw RuntimeException();
1024 return m_xResultSetOrigin->rowInserted();
1027 //virtual
1028 sal_Bool SAL_CALL ContentResultSetWrapper::rowDeleted()
1030 impl_EnsureNotDisposed();
1032 if( !m_xResultSetOrigin.is() )
1034 OSL_FAIL( "broadcaster was disposed already" );
1035 throw RuntimeException();
1037 return m_xResultSetOrigin->rowDeleted();
1040 //virtual
1041 Reference< XInterface > SAL_CALL ContentResultSetWrapper::getStatement()
1043 impl_EnsureNotDisposed();
1044 //@todo ?return anything
1045 return Reference< XInterface >();
1049 // XRow methods.
1052 void ContentResultSetWrapper::verifyGet()
1054 impl_EnsureNotDisposed();
1055 impl_init_xRowOrigin();
1056 if( !m_xRowOrigin.is() )
1058 OSL_FAIL( "broadcaster was disposed already" );
1059 throw RuntimeException();
1063 //virtual
1064 sal_Bool SAL_CALL ContentResultSetWrapper::wasNull()
1066 impl_EnsureNotDisposed();
1067 impl_init_xRowOrigin();
1068 if( !m_xRowOrigin.is() )
1070 OSL_FAIL( "broadcaster was disposed already" );
1071 throw RuntimeException();
1073 return m_xRowOrigin->wasNull();
1076 //virtual
1077 OUString SAL_CALL ContentResultSetWrapper::getString( sal_Int32 columnIndex )
1079 verifyGet();
1080 return m_xRowOrigin->getString( columnIndex );
1083 //virtual
1084 sal_Bool SAL_CALL ContentResultSetWrapper::getBoolean( sal_Int32 columnIndex )
1086 verifyGet();
1087 return m_xRowOrigin->getBoolean( columnIndex );
1090 //virtual
1091 sal_Int8 SAL_CALL ContentResultSetWrapper::getByte( sal_Int32 columnIndex )
1093 verifyGet();
1094 return m_xRowOrigin->getByte( columnIndex );
1097 //virtual
1098 sal_Int16 SAL_CALL ContentResultSetWrapper::getShort( sal_Int32 columnIndex )
1100 verifyGet();
1101 return m_xRowOrigin->getShort( columnIndex );
1104 //virtual
1105 sal_Int32 SAL_CALL ContentResultSetWrapper::getInt( sal_Int32 columnIndex )
1107 verifyGet();
1108 return m_xRowOrigin->getInt( columnIndex );
1111 //virtual
1112 sal_Int64 SAL_CALL ContentResultSetWrapper::getLong( sal_Int32 columnIndex )
1114 verifyGet();
1115 return m_xRowOrigin->getLong( columnIndex );
1118 //virtual
1119 float SAL_CALL ContentResultSetWrapper::getFloat( sal_Int32 columnIndex )
1121 verifyGet();
1122 return m_xRowOrigin->getFloat( columnIndex );
1125 //virtual
1126 double SAL_CALL ContentResultSetWrapper::getDouble( sal_Int32 columnIndex )
1128 verifyGet();
1129 return m_xRowOrigin->getDouble( columnIndex );
1132 //virtual
1133 Sequence< sal_Int8 > SAL_CALL ContentResultSetWrapper::getBytes( sal_Int32 columnIndex )
1135 verifyGet();
1136 return m_xRowOrigin->getBytes( columnIndex );
1139 //virtual
1140 Date SAL_CALL ContentResultSetWrapper::getDate( sal_Int32 columnIndex )
1142 verifyGet();
1143 return m_xRowOrigin->getDate( columnIndex );
1146 //virtual
1147 Time SAL_CALL ContentResultSetWrapper::getTime( sal_Int32 columnIndex )
1149 verifyGet();
1150 return m_xRowOrigin->getTime( columnIndex );
1153 //virtual
1154 DateTime SAL_CALL ContentResultSetWrapper::getTimestamp( sal_Int32 columnIndex )
1156 verifyGet();
1157 return m_xRowOrigin->getTimestamp( columnIndex );
1160 //virtual
1161 Reference< css::io::XInputStream > SAL_CALL ContentResultSetWrapper::getBinaryStream( sal_Int32 columnIndex )
1163 verifyGet();
1164 return m_xRowOrigin->getBinaryStream( columnIndex );
1167 //virtual
1168 Reference< css::io::XInputStream > SAL_CALL ContentResultSetWrapper::getCharacterStream( sal_Int32 columnIndex )
1170 verifyGet();
1171 return m_xRowOrigin->getCharacterStream( columnIndex );
1174 //virtual
1175 Any SAL_CALL ContentResultSetWrapper::getObject( sal_Int32 columnIndex, const Reference< css::container::XNameAccess >& typeMap )
1177 //if you change this macro please pay attention to
1178 //define XROW_GETXXX, where this is similar implemented
1180 impl_EnsureNotDisposed();
1181 impl_init_xRowOrigin();
1182 if( !m_xRowOrigin.is() )
1184 OSL_FAIL( "broadcaster was disposed already" );
1185 throw RuntimeException();
1187 return m_xRowOrigin->getObject( columnIndex, typeMap );
1190 //virtual
1191 Reference< XRef > SAL_CALL ContentResultSetWrapper::getRef( sal_Int32 columnIndex )
1193 verifyGet();
1194 return m_xRowOrigin->getRef( columnIndex );
1197 //virtual
1198 Reference< XBlob > SAL_CALL ContentResultSetWrapper::getBlob( sal_Int32 columnIndex )
1200 verifyGet();
1201 return m_xRowOrigin->getBlob( columnIndex );
1204 //virtual
1205 Reference< XClob > SAL_CALL ContentResultSetWrapper::getClob( sal_Int32 columnIndex )
1207 verifyGet();
1208 return m_xRowOrigin->getClob( columnIndex );
1211 //virtual
1212 Reference< XArray > SAL_CALL ContentResultSetWrapper::getArray( sal_Int32 columnIndex )
1214 verifyGet();
1215 return m_xRowOrigin->getArray( columnIndex );
1219 // class ContentResultSetWrapperListener
1222 ContentResultSetWrapperListener::ContentResultSetWrapperListener(
1223 ContentResultSetWrapper* pOwner )
1224 : m_pOwner( pOwner )
1228 ContentResultSetWrapperListener::~ContentResultSetWrapperListener()
1233 // XInterface methods.
1234 void SAL_CALL ContentResultSetWrapperListener::acquire()
1235 throw()
1237 OWeakObject::acquire();
1240 void SAL_CALL ContentResultSetWrapperListener::release()
1241 throw()
1243 OWeakObject::release();
1246 css::uno::Any SAL_CALL ContentResultSetWrapperListener::queryInterface( const css::uno::Type & rType )
1248 //list all interfaces inclusive baseclasses of interfaces
1249 css::uno::Any aRet = cppu::queryInterface( rType,
1250 static_cast< XEventListener * >(
1251 static_cast< XPropertyChangeListener * >(this)),
1252 static_cast< XPropertyChangeListener* >(this),
1253 static_cast< XVetoableChangeListener* >(this)
1255 return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType );
1258 //XEventListener methods.
1261 //virtual
1262 void SAL_CALL ContentResultSetWrapperListener::disposing( const EventObject& rEventObject )
1264 if( m_pOwner )
1265 m_pOwner->impl_disposing( rEventObject );
1269 //XPropertyChangeListener methods.
1272 //virtual
1273 void SAL_CALL ContentResultSetWrapperListener::propertyChange( const PropertyChangeEvent& rEvt )
1275 if( m_pOwner )
1276 m_pOwner->impl_propertyChange( rEvt );
1280 //XVetoableChangeListener methods.
1282 //virtual
1283 void SAL_CALL ContentResultSetWrapperListener::vetoableChange( const PropertyChangeEvent& rEvt )
1285 if( m_pOwner )
1286 m_pOwner->impl_vetoableChange( rEvt );
1289 void ContentResultSetWrapperListener::impl_OwnerDies()
1291 m_pOwner = nullptr;
1294 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */