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
;
38 // class ContentResultSetWrapper
41 ContentResultSetWrapper::ContentResultSetWrapper(
42 Reference
< XResultSet
> const & xOrigin
)
43 : m_xResultSetOrigin( xOrigin
)
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
);
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())
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() )
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();
132 void ContentResultSetWrapper::impl_initPropertySetInfo()
135 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
136 if( m_xPropertySetInfo
.is() )
139 impl_init_xPropertySetOrigin();
140 if( !m_xPropertySetOrigin
.is() )
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
);
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
)
184 // Notify listeners interested especially in the changed property.
185 OInterfaceContainerHelper
* pContainer
=
186 m_pPropertyChangeListeners
->getContainer( rEvt
.PropertyName
);
189 OInterfaceIteratorHelper
aIter( *pContainer
);
190 while( aIter
.hasMoreElements() )
192 Reference
< XPropertyChangeListener
> xListener(
193 aIter
.next(), UNO_QUERY
);
195 xListener
->propertyChange( rEvt
);
199 // Notify listeners interested in all properties.
200 pContainer
= m_pPropertyChangeListeners
->getContainer( OUString() );
203 OInterfaceIteratorHelper
aIter( *pContainer
);
204 while( aIter
.hasMoreElements() )
206 Reference
< XPropertyChangeListener
> xListener(
207 aIter
.next(), UNO_QUERY
);
209 xListener
->propertyChange( rEvt
);
214 void ContentResultSetWrapper::impl_notifyVetoableChangeListeners( const PropertyChangeEvent
& rEvt
)
217 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
218 if( !m_pVetoableChangeListeners
)
222 // Notify listeners interested especially in the changed property.
223 OInterfaceContainerHelper
* pContainer
=
224 m_pVetoableChangeListeners
->getContainer( rEvt
.PropertyName
);
227 OInterfaceIteratorHelper
aIter( *pContainer
);
228 while( aIter
.hasMoreElements() )
230 Reference
< XVetoableChangeListener
> xListener(
231 aIter
.next(), UNO_QUERY
);
233 xListener
->vetoableChange( rEvt
);
237 // Notify listeners interested in all properties.
238 pContainer
= m_pVetoableChangeListeners
->getContainer( OUString() );
241 OInterfaceIteratorHelper
aIter( *pContainer
);
242 while( aIter
.hasMoreElements() )
244 Reference
< XVetoableChangeListener
> xListener(
245 aIter
.next(), UNO_QUERY
);
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
);
265 ReacquireableGuard aGuard( m_aMutex );
266 if( m_nForwardOnly == 2 )
269 if( !getPropertySetInfo().is() )
273 return m_nForwardOnly;
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" );
285 return m_nForwardOnly;
289 Any aAny = m_xPropertySetOrigin->getPropertyValue( aName );
293 if( ( aAny >>= nResultSetType ) &&
294 ( nResultSetType == ResultSetType::FORWARD_ONLY ) )
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.
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
)
334 if( m_xPropertySetOrigin
.is() )
340 m_xPropertySetOrigin
->removePropertyChangeListener(
341 OUString(), static_cast< XPropertyChangeListener
* >( m_xMyListenerImpl
.get() ) );
345 OSL_FAIL( "could not remove PropertyChangeListener" );
349 m_xPropertySetOrigin
->removeVetoableChangeListener(
350 OUString(), static_cast< XVetoableChangeListener
* >( m_xMyListenerImpl
.get() ) );
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() ) );
367 if( m_pDisposeEventListeners
&& m_pDisposeEventListeners
->getLength() )
370 aEvt
.Source
= static_cast< XComponent
* >( this );
374 m_pDisposeEventListeners
->disposeAndClear( aEvt
);
382 if( m_pPropertyChangeListeners
)
385 aEvt
.Source
= static_cast< XPropertySet
* >( this );
389 m_pPropertyChangeListeners
->disposeAndClear( aEvt
);
397 if( m_pVetoableChangeListeners
)
400 aEvt
.Source
= static_cast< XPropertySet
* >( this );
404 m_pVetoableChangeListeners
->disposeAndClear( aEvt
);
412 m_bInDispose
= false;
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
);
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.
444 void SAL_CALL
ContentResultSetWrapper::close()
446 impl_EnsureNotDisposed();
451 //XResultSetMetaDataSupplier methods.
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() )
468 Reference
< XResultSetMetaData
> xMetaData
469 = xMetaDataSupplier
->getMetaData();
472 m_xMetaDataFromOrigin
= xMetaData
;
475 return m_xMetaDataFromOrigin
;
479 // XPropertySet methods.
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
;
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
);
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
);
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
);
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
);
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
);
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
);
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
)
624 OInterfaceContainerHelper
* pContainer
=
625 m_pPropertyChangeListeners
->getContainer( rPropertyName
);
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" );
655 m_xPropertySetOrigin
->removePropertyChangeListener(
656 OUString(), static_cast< XPropertyChangeListener
* >( m_xMyListenerImpl
.get() ) );
660 OSL_FAIL( "could not remove PropertyChangeListener" );
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
)
677 OInterfaceContainerHelper
* pContainer
=
678 m_pVetoableChangeListeners
->getContainer( rPropertyName
);
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" );
708 m_xPropertySetOrigin
->removeVetoableChangeListener(
709 OUString(), static_cast< XVetoableChangeListener
* >( m_xMyListenerImpl
.get() ) );
713 OSL_FAIL( "could not remove VetoableChangeListener" );
723 void ContentResultSetWrapper::impl_disposing( const EventObject
& )
725 impl_EnsureNotDisposed();
727 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
729 if( !m_xResultSetOrigin
.is() )
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();
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
);
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 )
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();
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();
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.
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();
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();
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
);
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
);
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();
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();
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();
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();
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();
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();
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();
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();
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();
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();
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();
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();
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();
1041 Reference
< XInterface
> SAL_CALL
ContentResultSetWrapper::getStatement()
1043 impl_EnsureNotDisposed();
1044 //@todo ?return anything
1045 return Reference
< XInterface
>();
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();
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();
1077 OUString SAL_CALL
ContentResultSetWrapper::getString( sal_Int32 columnIndex
)
1080 return m_xRowOrigin
->getString( columnIndex
);
1084 sal_Bool SAL_CALL
ContentResultSetWrapper::getBoolean( sal_Int32 columnIndex
)
1087 return m_xRowOrigin
->getBoolean( columnIndex
);
1091 sal_Int8 SAL_CALL
ContentResultSetWrapper::getByte( sal_Int32 columnIndex
)
1094 return m_xRowOrigin
->getByte( columnIndex
);
1098 sal_Int16 SAL_CALL
ContentResultSetWrapper::getShort( sal_Int32 columnIndex
)
1101 return m_xRowOrigin
->getShort( columnIndex
);
1105 sal_Int32 SAL_CALL
ContentResultSetWrapper::getInt( sal_Int32 columnIndex
)
1108 return m_xRowOrigin
->getInt( columnIndex
);
1112 sal_Int64 SAL_CALL
ContentResultSetWrapper::getLong( sal_Int32 columnIndex
)
1115 return m_xRowOrigin
->getLong( columnIndex
);
1119 float SAL_CALL
ContentResultSetWrapper::getFloat( sal_Int32 columnIndex
)
1122 return m_xRowOrigin
->getFloat( columnIndex
);
1126 double SAL_CALL
ContentResultSetWrapper::getDouble( sal_Int32 columnIndex
)
1129 return m_xRowOrigin
->getDouble( columnIndex
);
1133 Sequence
< sal_Int8
> SAL_CALL
ContentResultSetWrapper::getBytes( sal_Int32 columnIndex
)
1136 return m_xRowOrigin
->getBytes( columnIndex
);
1140 Date SAL_CALL
ContentResultSetWrapper::getDate( sal_Int32 columnIndex
)
1143 return m_xRowOrigin
->getDate( columnIndex
);
1147 Time SAL_CALL
ContentResultSetWrapper::getTime( sal_Int32 columnIndex
)
1150 return m_xRowOrigin
->getTime( columnIndex
);
1154 DateTime SAL_CALL
ContentResultSetWrapper::getTimestamp( sal_Int32 columnIndex
)
1157 return m_xRowOrigin
->getTimestamp( columnIndex
);
1161 Reference
< css::io::XInputStream
> SAL_CALL
ContentResultSetWrapper::getBinaryStream( sal_Int32 columnIndex
)
1164 return m_xRowOrigin
->getBinaryStream( columnIndex
);
1168 Reference
< css::io::XInputStream
> SAL_CALL
ContentResultSetWrapper::getCharacterStream( sal_Int32 columnIndex
)
1171 return m_xRowOrigin
->getCharacterStream( columnIndex
);
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
);
1191 Reference
< XRef
> SAL_CALL
ContentResultSetWrapper::getRef( sal_Int32 columnIndex
)
1194 return m_xRowOrigin
->getRef( columnIndex
);
1198 Reference
< XBlob
> SAL_CALL
ContentResultSetWrapper::getBlob( sal_Int32 columnIndex
)
1201 return m_xRowOrigin
->getBlob( columnIndex
);
1205 Reference
< XClob
> SAL_CALL
ContentResultSetWrapper::getClob( sal_Int32 columnIndex
)
1208 return m_xRowOrigin
->getClob( columnIndex
);
1212 Reference
< XArray
> SAL_CALL
ContentResultSetWrapper::getArray( sal_Int32 columnIndex
)
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()
1237 OWeakObject::acquire();
1240 void SAL_CALL
ContentResultSetWrapperListener::release()
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.
1262 void SAL_CALL
ContentResultSetWrapperListener::disposing( const EventObject
& rEventObject
)
1265 m_pOwner
->impl_disposing( rEventObject
);
1269 //XPropertyChangeListener methods.
1273 void SAL_CALL
ContentResultSetWrapperListener::propertyChange( const PropertyChangeEvent
& rEvt
)
1276 m_pOwner
->impl_propertyChange( rEvt
);
1280 //XVetoableChangeListener methods.
1283 void SAL_CALL
ContentResultSetWrapperListener::vetoableChange( const PropertyChangeEvent
& rEvt
)
1286 m_pOwner
->impl_vetoableChange( rEvt
);
1289 void ContentResultSetWrapperListener::impl_OwnerDies()
1294 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */