1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: contentresultsetwrapper.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_ucb.hxx"
34 #include <contentresultsetwrapper.hxx>
35 #include <com/sun/star/sdbc/FetchDirection.hpp>
36 #include <com/sun/star/ucb/FetchError.hpp>
37 #include <com/sun/star/beans/PropertyAttribute.hpp>
38 #include <com/sun/star/sdbc/ResultSetType.hpp>
39 #include <com/sun/star/lang/DisposedException.hpp>
40 #include <rtl/ustring.hxx>
41 #include <osl/diagnose.h>
43 using namespace com::sun::star::beans
;
44 using namespace com::sun::star::lang
;
45 using namespace com::sun::star::sdbc
;
46 using namespace com::sun::star::ucb
;
47 using namespace com::sun::star::uno
;
48 using namespace com::sun::star::util
;
52 //--------------------------------------------------------------------------
53 //--------------------------------------------------------------------------
54 // class ContentResultSetWrapper
55 //--------------------------------------------------------------------------
56 //--------------------------------------------------------------------------
58 ContentResultSetWrapper::ContentResultSetWrapper(
59 Reference
< XResultSet
> xOrigin
)
60 : m_xResultSetOrigin( xOrigin
)
61 , m_xRowOrigin( NULL
)
62 , m_xContentAccessOrigin( NULL
)
63 , m_xPropertySetOrigin( NULL
)
64 , m_xPropertySetInfo( NULL
)
66 , m_xMetaDataFromOrigin( NULL
)
67 , m_bDisposed( sal_False
)
68 , m_bInDispose( sal_False
)
69 , m_pDisposeEventListeners( NULL
)
70 , m_pPropertyChangeListeners( NULL
)
71 , m_pVetoableChangeListeners( NULL
)
73 m_pMyListenerImpl
= new ContentResultSetWrapperListener( this );
74 m_xMyListenerImpl
= Reference
< XPropertyChangeListener
>( m_pMyListenerImpl
);
76 OSL_ENSURE( m_xResultSetOrigin
.is(), "XResultSet is required" );
78 //!! call impl_init() at the end of constructor of derived class
82 void SAL_CALL
ContentResultSetWrapper::impl_init_xRowOrigin()
85 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
90 Reference
< XRow
> xOrgig
=
91 Reference
< XRow
>( m_xResultSetOrigin
, UNO_QUERY
);
94 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
95 m_xRowOrigin
= xOrgig
;
96 OSL_ENSURE( m_xRowOrigin
.is(), "interface XRow is required" );
100 void SAL_CALL
ContentResultSetWrapper::impl_init_xContentAccessOrigin()
103 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
104 if(m_xContentAccessOrigin
.is())
108 Reference
< XContentAccess
> xOrgig
=
109 Reference
< XContentAccess
>( m_xResultSetOrigin
, UNO_QUERY
);
112 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
113 m_xContentAccessOrigin
= xOrgig
;
114 OSL_ENSURE( m_xContentAccessOrigin
.is(), "interface XContentAccess is required" );
119 void SAL_CALL
ContentResultSetWrapper::impl_init_xPropertySetOrigin()
122 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
123 if( m_xPropertySetOrigin
.is() )
127 Reference
< XPropertySet
> xOrig
=
128 Reference
< XPropertySet
>( m_xResultSetOrigin
, UNO_QUERY
);
131 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
132 m_xPropertySetOrigin
= xOrig
;
133 OSL_ENSURE( m_xPropertySetOrigin
.is(), "interface XPropertySet is required" );
137 void SAL_CALL
ContentResultSetWrapper::impl_init()
139 //call this at the end of constructor of derived class
142 //listen to disposing from Origin:
143 Reference
< XComponent
> xComponentOrigin( m_xResultSetOrigin
, UNO_QUERY
);
144 OSL_ENSURE( xComponentOrigin
.is(), "interface XComponent is required" );
145 xComponentOrigin
->addEventListener( static_cast< XPropertyChangeListener
* >( m_pMyListenerImpl
) );
148 ContentResultSetWrapper::~ContentResultSetWrapper()
150 //call impl_deinit() at start of destructor of derived class
152 delete m_pDisposeEventListeners
;
153 delete m_pPropertyChangeListeners
;
154 delete m_pVetoableChangeListeners
;
157 void SAL_CALL
ContentResultSetWrapper::impl_deinit()
159 //call this at start of destructor of derived class
161 m_pMyListenerImpl
->impl_OwnerDies();
165 void SAL_CALL ContentResultSetWrapper
166 ::impl_initPropertySetInfo()
169 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
170 if( m_xPropertySetInfo
.is() )
173 impl_init_xPropertySetOrigin();
174 if( !m_xPropertySetOrigin
.is() )
178 Reference
< XPropertySetInfo
> xOrig
=
179 m_xPropertySetOrigin
->getPropertySetInfo();
182 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
183 m_xPropertySetInfo
= xOrig
;
187 void SAL_CALL ContentResultSetWrapper
188 ::impl_EnsureNotDisposed()
189 throw( DisposedException
, RuntimeException
)
191 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
193 throw DisposedException();
196 ContentResultSetWrapper::PropertyChangeListenerContainer_Impl
* SAL_CALL
197 ContentResultSetWrapper
198 ::impl_getPropertyChangeListenerContainer()
200 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
201 if ( !m_pPropertyChangeListeners
)
202 m_pPropertyChangeListeners
=
203 new PropertyChangeListenerContainer_Impl( m_aContainerMutex
);
204 return m_pPropertyChangeListeners
;
207 ContentResultSetWrapper::PropertyChangeListenerContainer_Impl
* SAL_CALL
208 ContentResultSetWrapper
209 ::impl_getVetoableChangeListenerContainer()
211 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
212 if ( !m_pVetoableChangeListeners
)
213 m_pVetoableChangeListeners
=
214 new PropertyChangeListenerContainer_Impl( m_aContainerMutex
);
215 return m_pVetoableChangeListeners
;
218 void SAL_CALL ContentResultSetWrapper
219 ::impl_notifyPropertyChangeListeners(
220 const PropertyChangeEvent
& rEvt
)
223 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
224 if( !m_pPropertyChangeListeners
)
228 // Notify listeners interested especially in the changed property.
229 OInterfaceContainerHelper
* pContainer
=
230 m_pPropertyChangeListeners
->getContainer( rEvt
.PropertyName
);
233 OInterfaceIteratorHelper
aIter( *pContainer
);
234 while( aIter
.hasMoreElements() )
236 Reference
< XPropertyChangeListener
> xListener(
237 aIter
.next(), UNO_QUERY
);
239 xListener
->propertyChange( rEvt
);
243 // Notify listeners interested in all properties.
244 pContainer
= m_pPropertyChangeListeners
->getContainer( OUString() );
247 OInterfaceIteratorHelper
aIter( *pContainer
);
248 while( aIter
.hasMoreElements() )
250 Reference
< XPropertyChangeListener
> xListener(
251 aIter
.next(), UNO_QUERY
);
253 xListener
->propertyChange( rEvt
);
258 void SAL_CALL ContentResultSetWrapper
259 ::impl_notifyVetoableChangeListeners( const PropertyChangeEvent
& rEvt
)
260 throw( PropertyVetoException
,
264 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
265 if( !m_pVetoableChangeListeners
)
269 // Notify listeners interested especially in the changed property.
270 OInterfaceContainerHelper
* pContainer
=
271 m_pVetoableChangeListeners
->getContainer( rEvt
.PropertyName
);
274 OInterfaceIteratorHelper
aIter( *pContainer
);
275 while( aIter
.hasMoreElements() )
277 Reference
< XVetoableChangeListener
> xListener(
278 aIter
.next(), UNO_QUERY
);
280 xListener
->vetoableChange( rEvt
);
284 // Notify listeners interested in all properties.
285 pContainer
= m_pVetoableChangeListeners
->getContainer( OUString() );
288 OInterfaceIteratorHelper
aIter( *pContainer
);
289 while( aIter
.hasMoreElements() )
291 Reference
< XVetoableChangeListener
> xListener(
292 aIter
.next(), UNO_QUERY
);
294 xListener
->vetoableChange( rEvt
);
299 sal_Bool SAL_CALL ContentResultSetWrapper
300 ::impl_isForwardOnly()
302 //m_nForwardOnly == 2 -> don't know
303 //m_nForwardOnly == 1 -> YES
304 //m_nForwardOnly == 0 -> NO
306 //@todo replace this with lines in comment
307 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
313 ReacquireableGuard aGuard( m_aMutex );
314 if( m_nForwardOnly == 2 )
317 if( !getPropertySetInfo().is() )
321 return m_nForwardOnly;
325 rtl::OUString aName = OUString::createFromAscii( "ResultSetType" );
326 //find out, if we are ForwardOnly and cache the value:
328 impl_init_xPropertySetOrigin();
329 if( !m_xPropertySetOrigin.is() )
331 OSL_ENSURE( sal_False, "broadcaster was disposed already" );
333 return m_nForwardOnly;
337 Any aAny = m_xPropertySetOrigin->getPropertyValue( aName );
341 if( ( aAny >>= nResultSetType ) &&
342 ( nResultSetType == ResultSetType::FORWARD_ONLY ) )
347 return m_nForwardOnly;
351 //--------------------------------------------------------------------------
352 // XInterface methods.
353 //--------------------------------------------------------------------------
354 //list all interfaces inclusive baseclasses of interfaces
355 QUERYINTERFACE_IMPL_START( ContentResultSetWrapper
)
357 SAL_STATIC_CAST( XComponent
*, this ),
358 SAL_STATIC_CAST( XCloseable
*, this ),
359 SAL_STATIC_CAST( XResultSetMetaDataSupplier
*, this ),
360 SAL_STATIC_CAST( XPropertySet
*, this ),
362 SAL_STATIC_CAST( XContentAccess
*, this ),
363 SAL_STATIC_CAST( XResultSet
*, this ),
364 SAL_STATIC_CAST( XRow
*, this )
366 QUERYINTERFACE_IMPL_END
368 //--------------------------------------------------------------------------
369 // XComponent methods.
370 //--------------------------------------------------------------------------
372 void SAL_CALL ContentResultSetWrapper
373 ::dispose() throw( RuntimeException
)
375 impl_EnsureNotDisposed();
377 ReacquireableGuard
aGuard( m_aMutex
);
378 if( m_bInDispose
|| m_bDisposed
)
380 m_bInDispose
= sal_True
;
382 if( m_xPropertySetOrigin
.is() )
387 m_xPropertySetOrigin
->removePropertyChangeListener(
388 OUString(), static_cast< XPropertyChangeListener
* >( m_pMyListenerImpl
) );
392 OSL_ENSURE( sal_False
, "could not remove PropertyChangeListener" );
396 m_xPropertySetOrigin
->removeVetoableChangeListener(
397 OUString(), static_cast< XVetoableChangeListener
* >( m_pMyListenerImpl
) );
401 OSL_ENSURE( sal_False
, "could not remove VetoableChangeListener" );
404 Reference
< XComponent
> xComponentOrigin( m_xResultSetOrigin
, UNO_QUERY
);
405 OSL_ENSURE( xComponentOrigin
.is(), "interface XComponent is required" );
406 xComponentOrigin
->removeEventListener( static_cast< XPropertyChangeListener
* >( m_pMyListenerImpl
) );
410 if( m_pDisposeEventListeners
&& m_pDisposeEventListeners
->getLength() )
413 aEvt
.Source
= static_cast< XComponent
* >( this );
416 m_pDisposeEventListeners
->disposeAndClear( aEvt
);
420 if( m_pPropertyChangeListeners
)
423 aEvt
.Source
= static_cast< XPropertySet
* >( this );
426 m_pPropertyChangeListeners
->disposeAndClear( aEvt
);
430 if( m_pVetoableChangeListeners
)
433 aEvt
.Source
= static_cast< XPropertySet
* >( this );
436 m_pVetoableChangeListeners
->disposeAndClear( aEvt
);
440 m_bDisposed
= sal_True
;
441 m_bInDispose
= sal_False
;
444 //--------------------------------------------------------------------------
446 void SAL_CALL ContentResultSetWrapper
447 ::addEventListener( const Reference
< XEventListener
>& Listener
)
448 throw( RuntimeException
)
450 impl_EnsureNotDisposed();
451 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
453 if ( !m_pDisposeEventListeners
)
454 m_pDisposeEventListeners
=
455 new OInterfaceContainerHelper( m_aContainerMutex
);
457 m_pDisposeEventListeners
->addInterface( Listener
);
460 //--------------------------------------------------------------------------
462 void SAL_CALL ContentResultSetWrapper
463 ::removeEventListener( const Reference
< XEventListener
>& Listener
)
464 throw( RuntimeException
)
466 impl_EnsureNotDisposed();
467 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
469 if ( m_pDisposeEventListeners
)
470 m_pDisposeEventListeners
->removeInterface( Listener
);
473 //--------------------------------------------------------------------------
474 //XCloseable methods.
475 //--------------------------------------------------------------------------
477 void SAL_CALL ContentResultSetWrapper
482 impl_EnsureNotDisposed();
486 //--------------------------------------------------------------------------
487 //XResultSetMetaDataSupplier methods.
488 //--------------------------------------------------------------------------
490 Reference
< XResultSetMetaData
> SAL_CALL ContentResultSetWrapper
495 impl_EnsureNotDisposed();
497 ReacquireableGuard
aGuard( m_aMutex
);
498 if( !m_xMetaDataFromOrigin
.is() && m_xResultSetOrigin
.is() )
500 Reference
< XResultSetMetaDataSupplier
> xMetaDataSupplier
501 = Reference
< XResultSetMetaDataSupplier
>(
502 m_xResultSetOrigin
, UNO_QUERY
);
504 if( xMetaDataSupplier
.is() )
508 Reference
< XResultSetMetaData
> xMetaData
509 = xMetaDataSupplier
->getMetaData();
512 m_xMetaDataFromOrigin
= xMetaData
;
515 return m_xMetaDataFromOrigin
;
519 //--------------------------------------------------------------------------
520 // XPropertySet methods.
521 //--------------------------------------------------------------------------
523 Reference
< XPropertySetInfo
> SAL_CALL ContentResultSetWrapper
524 ::getPropertySetInfo() throw( RuntimeException
)
526 impl_EnsureNotDisposed();
528 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
529 if( m_xPropertySetInfo
.is() )
530 return m_xPropertySetInfo
;
532 impl_initPropertySetInfo();
533 return m_xPropertySetInfo
;
535 //--------------------------------------------------------------------------
537 void SAL_CALL ContentResultSetWrapper
538 ::setPropertyValue( const OUString
& rPropertyName
, const Any
& rValue
)
539 throw( UnknownPropertyException
,
540 PropertyVetoException
,
541 IllegalArgumentException
,
542 WrappedTargetException
,
545 impl_EnsureNotDisposed();
546 impl_init_xPropertySetOrigin();
547 if( !m_xPropertySetOrigin
.is() )
549 OSL_ENSURE( sal_False
, "broadcaster was disposed already" );
550 throw UnknownPropertyException();
552 m_xPropertySetOrigin
->setPropertyValue( rPropertyName
, rValue
);
555 //--------------------------------------------------------------------------
557 Any SAL_CALL ContentResultSetWrapper
558 ::getPropertyValue( const OUString
& rPropertyName
)
559 throw( UnknownPropertyException
,
560 WrappedTargetException
,
563 impl_EnsureNotDisposed();
564 impl_init_xPropertySetOrigin();
565 if( !m_xPropertySetOrigin
.is() )
567 OSL_ENSURE( sal_False
, "broadcaster was disposed already" );
568 throw UnknownPropertyException();
570 return m_xPropertySetOrigin
->getPropertyValue( rPropertyName
);
573 //--------------------------------------------------------------------------
575 void SAL_CALL ContentResultSetWrapper
576 ::addPropertyChangeListener(
577 const OUString
& aPropertyName
,
578 const Reference
< XPropertyChangeListener
>& xListener
)
579 throw( UnknownPropertyException
,
580 WrappedTargetException
,
583 impl_EnsureNotDisposed();
585 if( !getPropertySetInfo().is() )
587 OSL_ENSURE( sal_False
, "broadcaster was disposed already" );
588 throw UnknownPropertyException();
591 if( aPropertyName
.getLength() )
593 m_xPropertySetInfo
->getPropertyByName( aPropertyName
);
594 //throws UnknownPropertyException, if so
597 impl_getPropertyChangeListenerContainer();
598 sal_Bool bNeedRegister
= !m_pPropertyChangeListeners
->
599 getContainedTypes().getLength();
600 m_pPropertyChangeListeners
->addInterface( aPropertyName
, xListener
);
603 impl_init_xPropertySetOrigin();
605 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
606 if( !m_xPropertySetOrigin
.is() )
608 OSL_ENSURE( sal_False
, "broadcaster was disposed already" );
614 m_xPropertySetOrigin
->addPropertyChangeListener(
615 OUString(), static_cast< XPropertyChangeListener
* >( m_pMyListenerImpl
) );
617 catch( Exception
& rEx
)
619 m_pPropertyChangeListeners
->removeInterface( aPropertyName
, xListener
);
625 //--------------------------------------------------------------------------
627 void SAL_CALL ContentResultSetWrapper
628 ::addVetoableChangeListener(
629 const OUString
& rPropertyName
,
630 const Reference
< XVetoableChangeListener
>& xListener
)
631 throw( UnknownPropertyException
,
632 WrappedTargetException
,
635 impl_EnsureNotDisposed();
637 if( !getPropertySetInfo().is() )
639 OSL_ENSURE( sal_False
, "broadcaster was disposed already" );
640 throw UnknownPropertyException();
642 if( rPropertyName
.getLength() )
644 m_xPropertySetInfo
->getPropertyByName( rPropertyName
);
645 //throws UnknownPropertyException, if so
648 impl_getVetoableChangeListenerContainer();
649 sal_Bool bNeedRegister
= !m_pVetoableChangeListeners
->
650 getContainedTypes().getLength();
651 m_pVetoableChangeListeners
->addInterface( rPropertyName
, xListener
);
654 impl_init_xPropertySetOrigin();
656 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
657 if( !m_xPropertySetOrigin
.is() )
659 OSL_ENSURE( sal_False
, "broadcaster was disposed already" );
665 m_xPropertySetOrigin
->addVetoableChangeListener(
666 OUString(), static_cast< XVetoableChangeListener
* >( m_pMyListenerImpl
) );
668 catch( Exception
& rEx
)
670 m_pVetoableChangeListeners
->removeInterface( rPropertyName
, xListener
);
676 //--------------------------------------------------------------------------
678 void SAL_CALL ContentResultSetWrapper
679 ::removePropertyChangeListener(
680 const OUString
& rPropertyName
,
681 const Reference
< XPropertyChangeListener
>& xListener
)
682 throw( UnknownPropertyException
,
683 WrappedTargetException
,
686 impl_EnsureNotDisposed();
689 //noop, if no listener registered
690 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
691 if( !m_pPropertyChangeListeners
)
694 OInterfaceContainerHelper
* pContainer
=
695 m_pPropertyChangeListeners
->getContainer( rPropertyName
);
699 if( rPropertyName
.getLength() )
701 if( !getPropertySetInfo().is() )
702 throw UnknownPropertyException();
704 m_xPropertySetInfo
->getPropertyByName( rPropertyName
);
705 //throws UnknownPropertyException, if so
707 return; //the listener was not registered
710 m_pPropertyChangeListeners
->removeInterface( rPropertyName
, xListener
);
712 if( !m_pPropertyChangeListeners
->getContainedTypes().getLength() )
714 impl_init_xPropertySetOrigin();
716 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
717 if( !m_xPropertySetOrigin
.is() )
719 OSL_ENSURE( sal_False
, "broadcaster was disposed already" );
725 m_xPropertySetOrigin
->removePropertyChangeListener(
726 OUString(), static_cast< XPropertyChangeListener
* >( m_pMyListenerImpl
) );
730 OSL_ENSURE( sal_False
, "could not remove PropertyChangeListener" );
735 //--------------------------------------------------------------------------
737 void SAL_CALL ContentResultSetWrapper
738 ::removeVetoableChangeListener(
739 const OUString
& rPropertyName
,
740 const Reference
< XVetoableChangeListener
>& xListener
)
741 throw( UnknownPropertyException
,
742 WrappedTargetException
,
745 impl_EnsureNotDisposed();
748 //noop, if no listener registered
749 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
750 if( !m_pVetoableChangeListeners
)
753 OInterfaceContainerHelper
* pContainer
=
754 m_pVetoableChangeListeners
->getContainer( rPropertyName
);
758 if( rPropertyName
.getLength() )
760 if( !getPropertySetInfo().is() )
761 throw UnknownPropertyException();
763 m_xPropertySetInfo
->getPropertyByName( rPropertyName
);
764 //throws UnknownPropertyException, if so
766 return; //the listener was not registered
769 m_pVetoableChangeListeners
->removeInterface( rPropertyName
, xListener
);
771 if( !m_pVetoableChangeListeners
->getContainedTypes().getLength() )
773 impl_init_xPropertySetOrigin();
775 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
776 if( !m_xPropertySetOrigin
.is() )
778 OSL_ENSURE( sal_False
, "broadcaster was disposed already" );
784 m_xPropertySetOrigin
->removeVetoableChangeListener(
785 OUString(), static_cast< XVetoableChangeListener
* >( m_pMyListenerImpl
) );
789 OSL_ENSURE( sal_False
, "could not remove VetoableChangeListener" );
794 //--------------------------------------------------------------------------
796 //--------------------------------------------------------------------------
799 void SAL_CALL ContentResultSetWrapper
800 ::impl_disposing( const EventObject
& )
801 throw( RuntimeException
)
803 impl_EnsureNotDisposed();
805 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
807 if( !m_xResultSetOrigin
.is() )
810 //release all references to the broadcaster:
811 m_xResultSetOrigin
.clear();
812 if(m_xRowOrigin
.is())
813 m_xRowOrigin
.clear();
814 if(m_xContentAccessOrigin
.is())
815 m_xContentAccessOrigin
.clear();
816 if(m_xPropertySetOrigin
.is())
817 m_xPropertySetOrigin
.clear();
818 m_xMetaDataFromOrigin
.clear();
819 if(m_xPropertySetInfo
.is())
820 m_xPropertySetInfo
.clear();
824 void SAL_CALL ContentResultSetWrapper
825 ::impl_propertyChange( const PropertyChangeEvent
& rEvt
)
826 throw( RuntimeException
)
828 impl_EnsureNotDisposed();
830 PropertyChangeEvent
aEvt( rEvt
);
831 aEvt
.Source
= static_cast< XPropertySet
* >( this );
832 aEvt
.Further
= sal_False
;
833 impl_notifyPropertyChangeListeners( aEvt
);
837 void SAL_CALL ContentResultSetWrapper
838 ::impl_vetoableChange( const PropertyChangeEvent
& rEvt
)
839 throw( PropertyVetoException
,
842 impl_EnsureNotDisposed();
844 PropertyChangeEvent
aEvt( rEvt
);
845 aEvt
.Source
= static_cast< XPropertySet
* >( this );
846 aEvt
.Further
= sal_False
;
848 impl_notifyVetoableChangeListeners( aEvt
);
851 //--------------------------------------------------------------------------
852 // XContentAccess methods. ( -- position dependent )
853 //--------------------------------------------------------------------------
856 OUString SAL_CALL ContentResultSetWrapper
857 ::queryContentIdentifierString()
858 throw( RuntimeException
)
860 impl_EnsureNotDisposed();
861 impl_init_xContentAccessOrigin();
862 if( !m_xContentAccessOrigin
.is() )
864 OSL_ENSURE( sal_False
, "broadcaster was disposed already" );
865 throw RuntimeException();
867 return m_xContentAccessOrigin
->queryContentIdentifierString();
870 //--------------------------------------------------------------------------
872 Reference
< XContentIdentifier
> SAL_CALL ContentResultSetWrapper
873 ::queryContentIdentifier()
874 throw( RuntimeException
)
876 impl_EnsureNotDisposed();
877 impl_init_xContentAccessOrigin();
878 if( !m_xContentAccessOrigin
.is() )
880 OSL_ENSURE( sal_False
, "broadcaster was disposed already" );
881 throw RuntimeException();
883 return m_xContentAccessOrigin
->queryContentIdentifier();
886 //--------------------------------------------------------------------------
888 Reference
< XContent
> SAL_CALL ContentResultSetWrapper
890 throw( RuntimeException
)
892 impl_EnsureNotDisposed();
893 impl_init_xContentAccessOrigin();
894 if( !m_xContentAccessOrigin
.is() )
896 OSL_ENSURE( sal_False
, "broadcaster was disposed already" );
897 throw RuntimeException();
899 return m_xContentAccessOrigin
->queryContent();
902 //-----------------------------------------------------------------
903 // XResultSet methods.
904 //-----------------------------------------------------------------
907 sal_Bool SAL_CALL ContentResultSetWrapper
912 impl_EnsureNotDisposed();
914 if( !m_xResultSetOrigin
.is() )
916 OSL_ENSURE( sal_False
, "broadcaster was disposed already" );
917 throw RuntimeException();
919 return m_xResultSetOrigin
->next();
923 sal_Bool SAL_CALL ContentResultSetWrapper
928 impl_EnsureNotDisposed();
930 if( !m_xResultSetOrigin
.is() )
932 OSL_ENSURE( sal_False
, "broadcaster was disposed already" );
933 throw RuntimeException();
935 return m_xResultSetOrigin
->previous();
939 sal_Bool SAL_CALL ContentResultSetWrapper
940 ::absolute( sal_Int32 row
)
944 impl_EnsureNotDisposed();
946 if( !m_xResultSetOrigin
.is() )
948 OSL_ENSURE( sal_False
, "broadcaster was disposed already" );
949 throw RuntimeException();
951 return m_xResultSetOrigin
->absolute( row
);
955 sal_Bool SAL_CALL ContentResultSetWrapper
956 ::relative( sal_Int32 rows
)
960 impl_EnsureNotDisposed();
962 if( !m_xResultSetOrigin
.is() )
964 OSL_ENSURE( sal_False
, "broadcaster was disposed already" );
965 throw RuntimeException();
967 return m_xResultSetOrigin
->relative( rows
);
972 sal_Bool SAL_CALL ContentResultSetWrapper
977 impl_EnsureNotDisposed();
979 if( !m_xResultSetOrigin
.is() )
981 OSL_ENSURE( sal_False
, "broadcaster was disposed already" );
982 throw RuntimeException();
984 return m_xResultSetOrigin
->first();
988 sal_Bool SAL_CALL ContentResultSetWrapper
993 impl_EnsureNotDisposed();
995 if( !m_xResultSetOrigin
.is() )
997 OSL_ENSURE( sal_False
, "broadcaster was disposed already" );
998 throw RuntimeException();
1000 return m_xResultSetOrigin
->last();
1004 void SAL_CALL ContentResultSetWrapper
1006 throw( SQLException
,
1009 impl_EnsureNotDisposed();
1011 if( !m_xResultSetOrigin
.is() )
1013 OSL_ENSURE( sal_False
, "broadcaster was disposed already" );
1014 throw RuntimeException();
1016 m_xResultSetOrigin
->beforeFirst();
1020 void SAL_CALL ContentResultSetWrapper
1022 throw( SQLException
,
1025 impl_EnsureNotDisposed();
1027 if( !m_xResultSetOrigin
.is() )
1029 OSL_ENSURE( sal_False
, "broadcaster was disposed already" );
1030 throw RuntimeException();
1032 m_xResultSetOrigin
->afterLast();
1036 sal_Bool SAL_CALL ContentResultSetWrapper
1038 throw( SQLException
,
1041 impl_EnsureNotDisposed();
1043 if( !m_xResultSetOrigin
.is() )
1045 OSL_ENSURE( sal_False
, "broadcaster was disposed already" );
1046 throw RuntimeException();
1048 return m_xResultSetOrigin
->isAfterLast();
1052 sal_Bool SAL_CALL ContentResultSetWrapper
1054 throw( SQLException
,
1057 impl_EnsureNotDisposed();
1059 if( !m_xResultSetOrigin
.is() )
1061 OSL_ENSURE( sal_False
, "broadcaster was disposed already" );
1062 throw RuntimeException();
1064 return m_xResultSetOrigin
->isBeforeFirst();
1068 sal_Bool SAL_CALL ContentResultSetWrapper
1070 throw( SQLException
,
1073 impl_EnsureNotDisposed();
1075 if( !m_xResultSetOrigin
.is() )
1077 OSL_ENSURE( sal_False
, "broadcaster was disposed already" );
1078 throw RuntimeException();
1080 return m_xResultSetOrigin
->isFirst();
1084 sal_Bool SAL_CALL ContentResultSetWrapper
1086 throw( SQLException
,
1089 impl_EnsureNotDisposed();
1091 if( !m_xResultSetOrigin
.is() )
1093 OSL_ENSURE( sal_False
, "broadcaster was disposed already" );
1094 throw RuntimeException();
1096 return m_xResultSetOrigin
->isLast();
1101 sal_Int32 SAL_CALL ContentResultSetWrapper
1103 throw( SQLException
,
1106 impl_EnsureNotDisposed();
1108 if( !m_xResultSetOrigin
.is() )
1110 OSL_ENSURE( sal_False
, "broadcaster was disposed already" );
1111 throw RuntimeException();
1113 return m_xResultSetOrigin
->getRow();
1117 void SAL_CALL ContentResultSetWrapper
1119 throw( SQLException
,
1122 impl_EnsureNotDisposed();
1124 if( !m_xResultSetOrigin
.is() )
1126 OSL_ENSURE( sal_False
, "broadcaster was disposed already" );
1127 throw RuntimeException();
1129 m_xResultSetOrigin
->refreshRow();
1133 sal_Bool SAL_CALL ContentResultSetWrapper
1135 throw( SQLException
,
1138 impl_EnsureNotDisposed();
1140 if( !m_xResultSetOrigin
.is() )
1142 OSL_ENSURE( sal_False
, "broadcaster was disposed already" );
1143 throw RuntimeException();
1145 return m_xResultSetOrigin
->rowUpdated();
1148 sal_Bool SAL_CALL ContentResultSetWrapper
1150 throw( SQLException
,
1153 impl_EnsureNotDisposed();
1155 if( !m_xResultSetOrigin
.is() )
1157 OSL_ENSURE( sal_False
, "broadcaster was disposed already" );
1158 throw RuntimeException();
1160 return m_xResultSetOrigin
->rowInserted();
1164 sal_Bool SAL_CALL ContentResultSetWrapper
1166 throw( SQLException
,
1169 impl_EnsureNotDisposed();
1171 if( !m_xResultSetOrigin
.is() )
1173 OSL_ENSURE( sal_False
, "broadcaster was disposed already" );
1174 throw RuntimeException();
1176 return m_xResultSetOrigin
->rowDeleted();
1180 Reference
< XInterface
> SAL_CALL ContentResultSetWrapper
1182 throw( SQLException
,
1185 impl_EnsureNotDisposed();
1186 //@todo ?return anything
1187 return Reference
< XInterface
>();
1190 //-----------------------------------------------------------------
1192 //-----------------------------------------------------------------
1194 #define XROW_GETXXX( getXXX ) \
1195 impl_EnsureNotDisposed(); \
1196 impl_init_xRowOrigin(); \
1197 if( !m_xRowOrigin.is() ) \
1199 OSL_ENSURE( sal_False, "broadcaster was disposed already" );\
1200 throw RuntimeException(); \
1202 return m_xRowOrigin->getXXX( columnIndex );
1205 sal_Bool SAL_CALL ContentResultSetWrapper
1207 throw( SQLException
,
1210 impl_EnsureNotDisposed();
1211 impl_init_xRowOrigin();
1212 if( !m_xRowOrigin
.is() )
1214 OSL_ENSURE( sal_False
, "broadcaster was disposed already" );
1215 throw RuntimeException();
1217 return m_xRowOrigin
->wasNull();
1221 rtl::OUString SAL_CALL ContentResultSetWrapper
1222 ::getString( sal_Int32 columnIndex
)
1223 throw( SQLException
,
1226 XROW_GETXXX( getString
);
1230 sal_Bool SAL_CALL ContentResultSetWrapper
1231 ::getBoolean( sal_Int32 columnIndex
)
1232 throw( SQLException
,
1235 XROW_GETXXX( getBoolean
);
1239 sal_Int8 SAL_CALL ContentResultSetWrapper
1240 ::getByte( sal_Int32 columnIndex
)
1241 throw( SQLException
,
1244 XROW_GETXXX( getByte
);
1248 sal_Int16 SAL_CALL ContentResultSetWrapper
1249 ::getShort( sal_Int32 columnIndex
)
1250 throw( SQLException
,
1253 XROW_GETXXX( getShort
);
1257 sal_Int32 SAL_CALL ContentResultSetWrapper
1258 ::getInt( sal_Int32 columnIndex
)
1259 throw( SQLException
,
1262 XROW_GETXXX( getInt
);
1266 sal_Int64 SAL_CALL ContentResultSetWrapper
1267 ::getLong( sal_Int32 columnIndex
)
1268 throw( SQLException
,
1271 XROW_GETXXX( getLong
);
1275 float SAL_CALL ContentResultSetWrapper
1276 ::getFloat( sal_Int32 columnIndex
)
1277 throw( SQLException
,
1280 XROW_GETXXX( getFloat
);
1284 double SAL_CALL ContentResultSetWrapper
1285 ::getDouble( sal_Int32 columnIndex
)
1286 throw( SQLException
,
1289 XROW_GETXXX( getDouble
);
1293 Sequence
< sal_Int8
> SAL_CALL ContentResultSetWrapper
1294 ::getBytes( sal_Int32 columnIndex
)
1295 throw( SQLException
,
1298 XROW_GETXXX( getBytes
);
1302 Date SAL_CALL ContentResultSetWrapper
1303 ::getDate( sal_Int32 columnIndex
)
1304 throw( SQLException
,
1307 XROW_GETXXX( getDate
);
1311 Time SAL_CALL ContentResultSetWrapper
1312 ::getTime( sal_Int32 columnIndex
)
1313 throw( SQLException
,
1316 XROW_GETXXX( getTime
);
1320 DateTime SAL_CALL ContentResultSetWrapper
1321 ::getTimestamp( sal_Int32 columnIndex
)
1322 throw( SQLException
,
1325 XROW_GETXXX( getTimestamp
);
1329 Reference
< com::sun::star::io::XInputStream
>
1330 SAL_CALL ContentResultSetWrapper
1331 ::getBinaryStream( sal_Int32 columnIndex
)
1332 throw( SQLException
,
1335 XROW_GETXXX( getBinaryStream
);
1339 Reference
< com::sun::star::io::XInputStream
>
1340 SAL_CALL ContentResultSetWrapper
1341 ::getCharacterStream( sal_Int32 columnIndex
)
1342 throw( SQLException
,
1345 XROW_GETXXX( getCharacterStream
);
1349 Any SAL_CALL ContentResultSetWrapper
1350 ::getObject( sal_Int32 columnIndex
,
1352 com::sun::star::container::XNameAccess
>& typeMap
)
1353 throw( SQLException
,
1356 //if you change this macro please pay attention to
1357 //define XROW_GETXXX, where this is similar implemented
1359 impl_EnsureNotDisposed();
1360 impl_init_xRowOrigin();
1361 if( !m_xRowOrigin
.is() )
1363 OSL_ENSURE( sal_False
, "broadcaster was disposed already" );
1364 throw RuntimeException();
1366 return m_xRowOrigin
->getObject( columnIndex
, typeMap
);
1370 Reference
< XRef
> SAL_CALL ContentResultSetWrapper
1371 ::getRef( sal_Int32 columnIndex
)
1372 throw( SQLException
,
1375 XROW_GETXXX( getRef
);
1379 Reference
< XBlob
> SAL_CALL ContentResultSetWrapper
1380 ::getBlob( sal_Int32 columnIndex
)
1381 throw( SQLException
,
1384 XROW_GETXXX( getBlob
);
1388 Reference
< XClob
> SAL_CALL ContentResultSetWrapper
1389 ::getClob( sal_Int32 columnIndex
)
1390 throw( SQLException
,
1393 XROW_GETXXX( getClob
);
1397 Reference
< XArray
> SAL_CALL ContentResultSetWrapper
1398 ::getArray( sal_Int32 columnIndex
)
1399 throw( SQLException
,
1402 XROW_GETXXX( getArray
);
1405 //--------------------------------------------------------------------------
1406 //--------------------------------------------------------------------------
1407 // class ContentResultSetWrapperListener
1408 //--------------------------------------------------------------------------
1409 //--------------------------------------------------------------------------
1411 ContentResultSetWrapperListener::ContentResultSetWrapperListener(
1412 ContentResultSetWrapper
* pOwner
)
1413 : m_pOwner( pOwner
)
1417 ContentResultSetWrapperListener::~ContentResultSetWrapperListener()
1421 //--------------------------------------------------------------------------
1422 // XInterface methods.
1423 //--------------------------------------------------------------------------
1424 //list all interfaces inclusive baseclasses of interfaces
1425 XINTERFACE_COMMON_IMPL( ContentResultSetWrapperListener
)
1426 QUERYINTERFACE_IMPL_START( ContentResultSetWrapperListener
)
1428 static_cast< XEventListener
* >(
1429 static_cast< XPropertyChangeListener
* >(this))
1430 , SAL_STATIC_CAST( XPropertyChangeListener
*, this )
1431 , SAL_STATIC_CAST( XVetoableChangeListener
*, this )
1433 QUERYINTERFACE_IMPL_END
1436 //--------------------------------------------------------------------------
1437 //XEventListener methods.
1438 //--------------------------------------------------------------------------
1441 void SAL_CALL ContentResultSetWrapperListener
1442 ::disposing( const EventObject
& rEventObject
)
1443 throw( RuntimeException
)
1446 m_pOwner
->impl_disposing( rEventObject
);
1449 //--------------------------------------------------------------------------
1450 //XPropertyChangeListener methods.
1451 //--------------------------------------------------------------------------
1454 void SAL_CALL ContentResultSetWrapperListener
1455 ::propertyChange( const PropertyChangeEvent
& rEvt
)
1456 throw( RuntimeException
)
1459 m_pOwner
->impl_propertyChange( rEvt
);
1462 //--------------------------------------------------------------------------
1463 //XVetoableChangeListener methods.
1464 //--------------------------------------------------------------------------
1466 void SAL_CALL ContentResultSetWrapperListener
1467 ::vetoableChange( const PropertyChangeEvent
& rEvt
)
1468 throw( PropertyVetoException
,
1472 m_pOwner
->impl_vetoableChange( rEvt
);
1475 void SAL_CALL ContentResultSetWrapperListener