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/sdbc/FetchDirection.hpp>
23 #include <com/sun/star/ucb/FetchError.hpp>
24 #include <com/sun/star/beans/PropertyAttribute.hpp>
25 #include <com/sun/star/sdbc/ResultSetType.hpp>
26 #include <com/sun/star/lang/DisposedException.hpp>
27 #include <rtl/ustring.hxx>
28 #include <osl/diagnose.h>
30 using namespace com::sun::star::beans
;
31 using namespace com::sun::star::lang
;
32 using namespace com::sun::star::sdbc
;
33 using namespace com::sun::star::ucb
;
34 using namespace com::sun::star::uno
;
35 using namespace com::sun::star::util
;
39 //--------------------------------------------------------------------------
40 //--------------------------------------------------------------------------
41 // class ContentResultSetWrapper
42 //--------------------------------------------------------------------------
43 //--------------------------------------------------------------------------
45 ContentResultSetWrapper::ContentResultSetWrapper(
46 Reference
< XResultSet
> xOrigin
)
47 : m_xResultSetOrigin( xOrigin
)
48 , m_xRowOrigin( NULL
)
49 , m_xContentAccessOrigin( NULL
)
50 , m_xPropertySetOrigin( NULL
)
51 , m_xPropertySetInfo( NULL
)
53 , m_xMetaDataFromOrigin( NULL
)
54 , m_bDisposed( sal_False
)
55 , m_bInDispose( sal_False
)
56 , m_pDisposeEventListeners( NULL
)
57 , m_pPropertyChangeListeners( NULL
)
58 , m_pVetoableChangeListeners( NULL
)
60 m_pMyListenerImpl
= new ContentResultSetWrapperListener( this );
61 m_xMyListenerImpl
= Reference
< XPropertyChangeListener
>( m_pMyListenerImpl
);
63 OSL_ENSURE( m_xResultSetOrigin
.is(), "XResultSet is required" );
65 //!! call impl_init() at the end of constructor of derived class
69 void SAL_CALL
ContentResultSetWrapper::impl_init_xRowOrigin()
72 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
77 Reference
< XRow
> xOrgig
=
78 Reference
< XRow
>( m_xResultSetOrigin
, UNO_QUERY
);
81 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
82 m_xRowOrigin
= xOrgig
;
83 OSL_ENSURE( m_xRowOrigin
.is(), "interface XRow is required" );
87 void SAL_CALL
ContentResultSetWrapper::impl_init_xContentAccessOrigin()
90 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
91 if(m_xContentAccessOrigin
.is())
95 Reference
< XContentAccess
> xOrgig
=
96 Reference
< XContentAccess
>( m_xResultSetOrigin
, UNO_QUERY
);
99 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
100 m_xContentAccessOrigin
= xOrgig
;
101 OSL_ENSURE( m_xContentAccessOrigin
.is(), "interface XContentAccess is required" );
106 void SAL_CALL
ContentResultSetWrapper::impl_init_xPropertySetOrigin()
109 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
110 if( m_xPropertySetOrigin
.is() )
114 Reference
< XPropertySet
> xOrig
=
115 Reference
< XPropertySet
>( m_xResultSetOrigin
, UNO_QUERY
);
118 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
119 m_xPropertySetOrigin
= xOrig
;
120 OSL_ENSURE( m_xPropertySetOrigin
.is(), "interface XPropertySet is required" );
124 void SAL_CALL
ContentResultSetWrapper::impl_init()
126 //call this at the end of constructor of derived class
129 //listen to disposing from Origin:
130 Reference
< XComponent
> xComponentOrigin( m_xResultSetOrigin
, UNO_QUERY
);
131 OSL_ENSURE( xComponentOrigin
.is(), "interface XComponent is required" );
132 xComponentOrigin
->addEventListener( static_cast< XPropertyChangeListener
* >( m_pMyListenerImpl
) );
135 ContentResultSetWrapper::~ContentResultSetWrapper()
137 //call impl_deinit() at start of destructor of derived class
139 delete m_pDisposeEventListeners
;
140 delete m_pPropertyChangeListeners
;
141 delete m_pVetoableChangeListeners
;
144 void SAL_CALL
ContentResultSetWrapper::impl_deinit()
146 //call this at start of destructor of derived class
148 m_pMyListenerImpl
->impl_OwnerDies();
152 void SAL_CALL ContentResultSetWrapper
153 ::impl_initPropertySetInfo()
156 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
157 if( m_xPropertySetInfo
.is() )
160 impl_init_xPropertySetOrigin();
161 if( !m_xPropertySetOrigin
.is() )
165 Reference
< XPropertySetInfo
> xOrig
=
166 m_xPropertySetOrigin
->getPropertySetInfo();
169 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
170 m_xPropertySetInfo
= xOrig
;
174 void SAL_CALL ContentResultSetWrapper
175 ::impl_EnsureNotDisposed()
176 throw( DisposedException
, RuntimeException
)
178 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
180 throw DisposedException();
183 ContentResultSetWrapper::PropertyChangeListenerContainer_Impl
* SAL_CALL
184 ContentResultSetWrapper
185 ::impl_getPropertyChangeListenerContainer()
187 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
188 if ( !m_pPropertyChangeListeners
)
189 m_pPropertyChangeListeners
=
190 new PropertyChangeListenerContainer_Impl( m_aContainerMutex
);
191 return m_pPropertyChangeListeners
;
194 ContentResultSetWrapper::PropertyChangeListenerContainer_Impl
* SAL_CALL
195 ContentResultSetWrapper
196 ::impl_getVetoableChangeListenerContainer()
198 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
199 if ( !m_pVetoableChangeListeners
)
200 m_pVetoableChangeListeners
=
201 new PropertyChangeListenerContainer_Impl( m_aContainerMutex
);
202 return m_pVetoableChangeListeners
;
205 void SAL_CALL ContentResultSetWrapper
206 ::impl_notifyPropertyChangeListeners(
207 const PropertyChangeEvent
& rEvt
)
210 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
211 if( !m_pPropertyChangeListeners
)
215 // Notify listeners interested especially in the changed property.
216 OInterfaceContainerHelper
* pContainer
=
217 m_pPropertyChangeListeners
->getContainer( rEvt
.PropertyName
);
220 OInterfaceIteratorHelper
aIter( *pContainer
);
221 while( aIter
.hasMoreElements() )
223 Reference
< XPropertyChangeListener
> xListener(
224 aIter
.next(), UNO_QUERY
);
226 xListener
->propertyChange( rEvt
);
230 // Notify listeners interested in all properties.
231 pContainer
= m_pPropertyChangeListeners
->getContainer( OUString() );
234 OInterfaceIteratorHelper
aIter( *pContainer
);
235 while( aIter
.hasMoreElements() )
237 Reference
< XPropertyChangeListener
> xListener(
238 aIter
.next(), UNO_QUERY
);
240 xListener
->propertyChange( rEvt
);
245 void SAL_CALL ContentResultSetWrapper
246 ::impl_notifyVetoableChangeListeners( const PropertyChangeEvent
& rEvt
)
247 throw( PropertyVetoException
,
251 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
252 if( !m_pVetoableChangeListeners
)
256 // Notify listeners interested especially in the changed property.
257 OInterfaceContainerHelper
* pContainer
=
258 m_pVetoableChangeListeners
->getContainer( rEvt
.PropertyName
);
261 OInterfaceIteratorHelper
aIter( *pContainer
);
262 while( aIter
.hasMoreElements() )
264 Reference
< XVetoableChangeListener
> xListener(
265 aIter
.next(), UNO_QUERY
);
267 xListener
->vetoableChange( rEvt
);
271 // Notify listeners interested in all properties.
272 pContainer
= m_pVetoableChangeListeners
->getContainer( OUString() );
275 OInterfaceIteratorHelper
aIter( *pContainer
);
276 while( aIter
.hasMoreElements() )
278 Reference
< XVetoableChangeListener
> xListener(
279 aIter
.next(), UNO_QUERY
);
281 xListener
->vetoableChange( rEvt
);
286 sal_Bool SAL_CALL ContentResultSetWrapper
287 ::impl_isForwardOnly()
289 //m_nForwardOnly == 2 -> don't know
290 //m_nForwardOnly == 1 -> YES
291 //m_nForwardOnly == 0 -> NO
293 //@todo replace this with lines in comment
294 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
300 ReacquireableGuard aGuard( m_aMutex );
301 if( m_nForwardOnly == 2 )
304 if( !getPropertySetInfo().is() )
308 return m_nForwardOnly;
312 OUString aName("ResultSetType");
313 //find out, if we are ForwardOnly and cache the value:
315 impl_init_xPropertySetOrigin();
316 if( !m_xPropertySetOrigin.is() )
318 OSL_FAIL( "broadcaster was disposed already" );
320 return m_nForwardOnly;
324 Any aAny = m_xPropertySetOrigin->getPropertyValue( aName );
328 if( ( aAny >>= nResultSetType ) &&
329 ( nResultSetType == ResultSetType::FORWARD_ONLY ) )
334 return m_nForwardOnly;
338 //--------------------------------------------------------------------------
339 // XInterface methods.
340 //--------------------------------------------------------------------------
341 //list all interfaces inclusive baseclasses of interfaces
342 QUERYINTERFACE_IMPL_START( ContentResultSetWrapper
)
344 (static_cast< XComponent
* >(this)),
345 (static_cast< XCloseable
* >(this)),
346 (static_cast< XResultSetMetaDataSupplier
* >(this)),
347 (static_cast< XPropertySet
* >(this)),
349 (static_cast< XContentAccess
* >(this)),
350 (static_cast< XResultSet
* >(this)),
351 (static_cast< XRow
* >(this))
353 QUERYINTERFACE_IMPL_END
355 //--------------------------------------------------------------------------
356 // XComponent methods.
357 //--------------------------------------------------------------------------
359 void SAL_CALL ContentResultSetWrapper
360 ::dispose() throw( RuntimeException
)
362 impl_EnsureNotDisposed();
364 ReacquireableGuard
aGuard( m_aMutex
);
365 if( m_bInDispose
|| m_bDisposed
)
367 m_bInDispose
= sal_True
;
369 if( m_xPropertySetOrigin
.is() )
374 m_xPropertySetOrigin
->removePropertyChangeListener(
375 OUString(), static_cast< XPropertyChangeListener
* >( m_pMyListenerImpl
) );
379 OSL_FAIL( "could not remove PropertyChangeListener" );
383 m_xPropertySetOrigin
->removeVetoableChangeListener(
384 OUString(), static_cast< XVetoableChangeListener
* >( m_pMyListenerImpl
) );
388 OSL_FAIL( "could not remove VetoableChangeListener" );
391 Reference
< XComponent
> xComponentOrigin( m_xResultSetOrigin
, UNO_QUERY
);
392 OSL_ENSURE( xComponentOrigin
.is(), "interface XComponent is required" );
393 xComponentOrigin
->removeEventListener( static_cast< XPropertyChangeListener
* >( m_pMyListenerImpl
) );
397 if( m_pDisposeEventListeners
&& m_pDisposeEventListeners
->getLength() )
400 aEvt
.Source
= static_cast< XComponent
* >( this );
403 m_pDisposeEventListeners
->disposeAndClear( aEvt
);
407 if( m_pPropertyChangeListeners
)
410 aEvt
.Source
= static_cast< XPropertySet
* >( this );
413 m_pPropertyChangeListeners
->disposeAndClear( aEvt
);
417 if( m_pVetoableChangeListeners
)
420 aEvt
.Source
= static_cast< XPropertySet
* >( this );
423 m_pVetoableChangeListeners
->disposeAndClear( aEvt
);
427 m_bDisposed
= sal_True
;
428 m_bInDispose
= sal_False
;
431 //--------------------------------------------------------------------------
433 void SAL_CALL ContentResultSetWrapper
434 ::addEventListener( const Reference
< XEventListener
>& Listener
)
435 throw( RuntimeException
)
437 impl_EnsureNotDisposed();
438 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
440 if ( !m_pDisposeEventListeners
)
441 m_pDisposeEventListeners
=
442 new OInterfaceContainerHelper( m_aContainerMutex
);
444 m_pDisposeEventListeners
->addInterface( Listener
);
447 //--------------------------------------------------------------------------
449 void SAL_CALL ContentResultSetWrapper
450 ::removeEventListener( const Reference
< XEventListener
>& Listener
)
451 throw( RuntimeException
)
453 impl_EnsureNotDisposed();
454 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
456 if ( m_pDisposeEventListeners
)
457 m_pDisposeEventListeners
->removeInterface( Listener
);
460 //--------------------------------------------------------------------------
461 //XCloseable methods.
462 //--------------------------------------------------------------------------
464 void SAL_CALL ContentResultSetWrapper
469 impl_EnsureNotDisposed();
473 //--------------------------------------------------------------------------
474 //XResultSetMetaDataSupplier methods.
475 //--------------------------------------------------------------------------
477 Reference
< XResultSetMetaData
> SAL_CALL ContentResultSetWrapper
482 impl_EnsureNotDisposed();
484 ReacquireableGuard
aGuard( m_aMutex
);
485 if( !m_xMetaDataFromOrigin
.is() && m_xResultSetOrigin
.is() )
487 Reference
< XResultSetMetaDataSupplier
> xMetaDataSupplier
488 = Reference
< XResultSetMetaDataSupplier
>(
489 m_xResultSetOrigin
, UNO_QUERY
);
491 if( xMetaDataSupplier
.is() )
495 Reference
< XResultSetMetaData
> xMetaData
496 = xMetaDataSupplier
->getMetaData();
499 m_xMetaDataFromOrigin
= xMetaData
;
502 return m_xMetaDataFromOrigin
;
506 //--------------------------------------------------------------------------
507 // XPropertySet methods.
508 //--------------------------------------------------------------------------
510 Reference
< XPropertySetInfo
> SAL_CALL ContentResultSetWrapper
511 ::getPropertySetInfo() throw( RuntimeException
)
513 impl_EnsureNotDisposed();
515 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
516 if( m_xPropertySetInfo
.is() )
517 return m_xPropertySetInfo
;
519 impl_initPropertySetInfo();
520 return m_xPropertySetInfo
;
522 //--------------------------------------------------------------------------
524 void SAL_CALL ContentResultSetWrapper
525 ::setPropertyValue( const OUString
& rPropertyName
, const Any
& rValue
)
526 throw( UnknownPropertyException
,
527 PropertyVetoException
,
528 IllegalArgumentException
,
529 WrappedTargetException
,
532 impl_EnsureNotDisposed();
533 impl_init_xPropertySetOrigin();
534 if( !m_xPropertySetOrigin
.is() )
536 OSL_FAIL( "broadcaster was disposed already" );
537 throw UnknownPropertyException();
539 m_xPropertySetOrigin
->setPropertyValue( rPropertyName
, rValue
);
542 //--------------------------------------------------------------------------
544 Any SAL_CALL ContentResultSetWrapper
545 ::getPropertyValue( const OUString
& rPropertyName
)
546 throw( UnknownPropertyException
,
547 WrappedTargetException
,
550 impl_EnsureNotDisposed();
551 impl_init_xPropertySetOrigin();
552 if( !m_xPropertySetOrigin
.is() )
554 OSL_FAIL( "broadcaster was disposed already" );
555 throw UnknownPropertyException();
557 return m_xPropertySetOrigin
->getPropertyValue( rPropertyName
);
560 //--------------------------------------------------------------------------
562 void SAL_CALL ContentResultSetWrapper
563 ::addPropertyChangeListener(
564 const OUString
& aPropertyName
,
565 const Reference
< XPropertyChangeListener
>& xListener
)
566 throw( UnknownPropertyException
,
567 WrappedTargetException
,
570 impl_EnsureNotDisposed();
572 if( !getPropertySetInfo().is() )
574 OSL_FAIL( "broadcaster was disposed already" );
575 throw UnknownPropertyException();
578 if( !aPropertyName
.isEmpty() )
580 m_xPropertySetInfo
->getPropertyByName( aPropertyName
);
581 //throws UnknownPropertyException, if so
584 impl_getPropertyChangeListenerContainer();
585 sal_Bool bNeedRegister
= !m_pPropertyChangeListeners
->
586 getContainedTypes().getLength();
587 m_pPropertyChangeListeners
->addInterface( aPropertyName
, 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
->addPropertyChangeListener(
602 OUString(), static_cast< XPropertyChangeListener
* >( m_pMyListenerImpl
) );
606 m_pPropertyChangeListeners
->removeInterface( aPropertyName
, xListener
);
612 //--------------------------------------------------------------------------
614 void SAL_CALL ContentResultSetWrapper
615 ::addVetoableChangeListener(
616 const OUString
& rPropertyName
,
617 const Reference
< XVetoableChangeListener
>& xListener
)
618 throw( UnknownPropertyException
,
619 WrappedTargetException
,
622 impl_EnsureNotDisposed();
624 if( !getPropertySetInfo().is() )
626 OSL_FAIL( "broadcaster was disposed already" );
627 throw UnknownPropertyException();
629 if( !rPropertyName
.isEmpty() )
631 m_xPropertySetInfo
->getPropertyByName( rPropertyName
);
632 //throws UnknownPropertyException, if so
635 impl_getVetoableChangeListenerContainer();
636 sal_Bool bNeedRegister
= !m_pVetoableChangeListeners
->
637 getContainedTypes().getLength();
638 m_pVetoableChangeListeners
->addInterface( rPropertyName
, xListener
);
641 impl_init_xPropertySetOrigin();
643 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
644 if( !m_xPropertySetOrigin
.is() )
646 OSL_FAIL( "broadcaster was disposed already" );
652 m_xPropertySetOrigin
->addVetoableChangeListener(
653 OUString(), static_cast< XVetoableChangeListener
* >( m_pMyListenerImpl
) );
657 m_pVetoableChangeListeners
->removeInterface( rPropertyName
, xListener
);
663 //--------------------------------------------------------------------------
665 void SAL_CALL ContentResultSetWrapper
666 ::removePropertyChangeListener(
667 const OUString
& rPropertyName
,
668 const Reference
< XPropertyChangeListener
>& xListener
)
669 throw( UnknownPropertyException
,
670 WrappedTargetException
,
673 impl_EnsureNotDisposed();
676 //noop, if no listener registered
677 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
678 if( !m_pPropertyChangeListeners
)
681 OInterfaceContainerHelper
* pContainer
=
682 m_pPropertyChangeListeners
->getContainer( rPropertyName
);
686 if( !rPropertyName
.isEmpty() )
688 if( !getPropertySetInfo().is() )
689 throw UnknownPropertyException();
691 m_xPropertySetInfo
->getPropertyByName( rPropertyName
);
692 //throws UnknownPropertyException, if so
694 return; //the listener was not registered
697 m_pPropertyChangeListeners
->removeInterface( rPropertyName
, xListener
);
699 if( !m_pPropertyChangeListeners
->getContainedTypes().getLength() )
701 impl_init_xPropertySetOrigin();
703 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
704 if( !m_xPropertySetOrigin
.is() )
706 OSL_FAIL( "broadcaster was disposed already" );
712 m_xPropertySetOrigin
->removePropertyChangeListener(
713 OUString(), static_cast< XPropertyChangeListener
* >( m_pMyListenerImpl
) );
717 OSL_FAIL( "could not remove PropertyChangeListener" );
722 //--------------------------------------------------------------------------
724 void SAL_CALL ContentResultSetWrapper
725 ::removeVetoableChangeListener(
726 const OUString
& rPropertyName
,
727 const Reference
< XVetoableChangeListener
>& xListener
)
728 throw( UnknownPropertyException
,
729 WrappedTargetException
,
732 impl_EnsureNotDisposed();
735 //noop, if no listener registered
736 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
737 if( !m_pVetoableChangeListeners
)
740 OInterfaceContainerHelper
* pContainer
=
741 m_pVetoableChangeListeners
->getContainer( rPropertyName
);
745 if( !rPropertyName
.isEmpty() )
747 if( !getPropertySetInfo().is() )
748 throw UnknownPropertyException();
750 m_xPropertySetInfo
->getPropertyByName( rPropertyName
);
751 //throws UnknownPropertyException, if so
753 return; //the listener was not registered
756 m_pVetoableChangeListeners
->removeInterface( rPropertyName
, xListener
);
758 if( !m_pVetoableChangeListeners
->getContainedTypes().getLength() )
760 impl_init_xPropertySetOrigin();
762 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
763 if( !m_xPropertySetOrigin
.is() )
765 OSL_FAIL( "broadcaster was disposed already" );
771 m_xPropertySetOrigin
->removeVetoableChangeListener(
772 OUString(), static_cast< XVetoableChangeListener
* >( m_pMyListenerImpl
) );
776 OSL_FAIL( "could not remove VetoableChangeListener" );
781 //--------------------------------------------------------------------------
783 //--------------------------------------------------------------------------
786 void SAL_CALL ContentResultSetWrapper
787 ::impl_disposing( const EventObject
& )
788 throw( RuntimeException
)
790 impl_EnsureNotDisposed();
792 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
794 if( !m_xResultSetOrigin
.is() )
797 //release all references to the broadcaster:
798 m_xResultSetOrigin
.clear();
799 if(m_xRowOrigin
.is())
800 m_xRowOrigin
.clear();
801 if(m_xContentAccessOrigin
.is())
802 m_xContentAccessOrigin
.clear();
803 if(m_xPropertySetOrigin
.is())
804 m_xPropertySetOrigin
.clear();
805 m_xMetaDataFromOrigin
.clear();
806 if(m_xPropertySetInfo
.is())
807 m_xPropertySetInfo
.clear();
811 void SAL_CALL ContentResultSetWrapper
812 ::impl_propertyChange( const PropertyChangeEvent
& rEvt
)
813 throw( RuntimeException
)
815 impl_EnsureNotDisposed();
817 PropertyChangeEvent
aEvt( rEvt
);
818 aEvt
.Source
= static_cast< XPropertySet
* >( this );
819 aEvt
.Further
= sal_False
;
820 impl_notifyPropertyChangeListeners( aEvt
);
824 void SAL_CALL ContentResultSetWrapper
825 ::impl_vetoableChange( const PropertyChangeEvent
& rEvt
)
826 throw( PropertyVetoException
,
829 impl_EnsureNotDisposed();
831 PropertyChangeEvent
aEvt( rEvt
);
832 aEvt
.Source
= static_cast< XPropertySet
* >( this );
833 aEvt
.Further
= sal_False
;
835 impl_notifyVetoableChangeListeners( aEvt
);
838 //--------------------------------------------------------------------------
839 // XContentAccess methods. ( -- position dependent )
840 //--------------------------------------------------------------------------
843 OUString SAL_CALL ContentResultSetWrapper
844 ::queryContentIdentifierString()
845 throw( RuntimeException
)
847 impl_EnsureNotDisposed();
848 impl_init_xContentAccessOrigin();
849 if( !m_xContentAccessOrigin
.is() )
851 OSL_FAIL( "broadcaster was disposed already" );
852 throw RuntimeException();
854 return m_xContentAccessOrigin
->queryContentIdentifierString();
857 //--------------------------------------------------------------------------
859 Reference
< XContentIdentifier
> SAL_CALL ContentResultSetWrapper
860 ::queryContentIdentifier()
861 throw( RuntimeException
)
863 impl_EnsureNotDisposed();
864 impl_init_xContentAccessOrigin();
865 if( !m_xContentAccessOrigin
.is() )
867 OSL_FAIL( "broadcaster was disposed already" );
868 throw RuntimeException();
870 return m_xContentAccessOrigin
->queryContentIdentifier();
873 //--------------------------------------------------------------------------
875 Reference
< XContent
> SAL_CALL ContentResultSetWrapper
877 throw( RuntimeException
)
879 impl_EnsureNotDisposed();
880 impl_init_xContentAccessOrigin();
881 if( !m_xContentAccessOrigin
.is() )
883 OSL_FAIL( "broadcaster was disposed already" );
884 throw RuntimeException();
886 return m_xContentAccessOrigin
->queryContent();
889 //-----------------------------------------------------------------
890 // XResultSet methods.
891 //-----------------------------------------------------------------
894 sal_Bool SAL_CALL ContentResultSetWrapper
899 impl_EnsureNotDisposed();
901 if( !m_xResultSetOrigin
.is() )
903 OSL_FAIL( "broadcaster was disposed already" );
904 throw RuntimeException();
906 return m_xResultSetOrigin
->next();
910 sal_Bool SAL_CALL ContentResultSetWrapper
915 impl_EnsureNotDisposed();
917 if( !m_xResultSetOrigin
.is() )
919 OSL_FAIL( "broadcaster was disposed already" );
920 throw RuntimeException();
922 return m_xResultSetOrigin
->previous();
926 sal_Bool SAL_CALL ContentResultSetWrapper
927 ::absolute( sal_Int32 row
)
931 impl_EnsureNotDisposed();
933 if( !m_xResultSetOrigin
.is() )
935 OSL_FAIL( "broadcaster was disposed already" );
936 throw RuntimeException();
938 return m_xResultSetOrigin
->absolute( row
);
942 sal_Bool SAL_CALL ContentResultSetWrapper
943 ::relative( sal_Int32 rows
)
947 impl_EnsureNotDisposed();
949 if( !m_xResultSetOrigin
.is() )
951 OSL_FAIL( "broadcaster was disposed already" );
952 throw RuntimeException();
954 return m_xResultSetOrigin
->relative( rows
);
959 sal_Bool SAL_CALL ContentResultSetWrapper
964 impl_EnsureNotDisposed();
966 if( !m_xResultSetOrigin
.is() )
968 OSL_FAIL( "broadcaster was disposed already" );
969 throw RuntimeException();
971 return m_xResultSetOrigin
->first();
975 sal_Bool SAL_CALL ContentResultSetWrapper
980 impl_EnsureNotDisposed();
982 if( !m_xResultSetOrigin
.is() )
984 OSL_FAIL( "broadcaster was disposed already" );
985 throw RuntimeException();
987 return m_xResultSetOrigin
->last();
991 void SAL_CALL ContentResultSetWrapper
996 impl_EnsureNotDisposed();
998 if( !m_xResultSetOrigin
.is() )
1000 OSL_FAIL( "broadcaster was disposed already" );
1001 throw RuntimeException();
1003 m_xResultSetOrigin
->beforeFirst();
1007 void SAL_CALL ContentResultSetWrapper
1009 throw( SQLException
,
1012 impl_EnsureNotDisposed();
1014 if( !m_xResultSetOrigin
.is() )
1016 OSL_FAIL( "broadcaster was disposed already" );
1017 throw RuntimeException();
1019 m_xResultSetOrigin
->afterLast();
1023 sal_Bool SAL_CALL ContentResultSetWrapper
1025 throw( SQLException
,
1028 impl_EnsureNotDisposed();
1030 if( !m_xResultSetOrigin
.is() )
1032 OSL_FAIL( "broadcaster was disposed already" );
1033 throw RuntimeException();
1035 return m_xResultSetOrigin
->isAfterLast();
1039 sal_Bool SAL_CALL ContentResultSetWrapper
1041 throw( SQLException
,
1044 impl_EnsureNotDisposed();
1046 if( !m_xResultSetOrigin
.is() )
1048 OSL_FAIL( "broadcaster was disposed already" );
1049 throw RuntimeException();
1051 return m_xResultSetOrigin
->isBeforeFirst();
1055 sal_Bool SAL_CALL ContentResultSetWrapper
1057 throw( SQLException
,
1060 impl_EnsureNotDisposed();
1062 if( !m_xResultSetOrigin
.is() )
1064 OSL_FAIL( "broadcaster was disposed already" );
1065 throw RuntimeException();
1067 return m_xResultSetOrigin
->isFirst();
1071 sal_Bool SAL_CALL ContentResultSetWrapper
1073 throw( SQLException
,
1076 impl_EnsureNotDisposed();
1078 if( !m_xResultSetOrigin
.is() )
1080 OSL_FAIL( "broadcaster was disposed already" );
1081 throw RuntimeException();
1083 return m_xResultSetOrigin
->isLast();
1088 sal_Int32 SAL_CALL ContentResultSetWrapper
1090 throw( SQLException
,
1093 impl_EnsureNotDisposed();
1095 if( !m_xResultSetOrigin
.is() )
1097 OSL_FAIL( "broadcaster was disposed already" );
1098 throw RuntimeException();
1100 return m_xResultSetOrigin
->getRow();
1104 void SAL_CALL ContentResultSetWrapper
1106 throw( SQLException
,
1109 impl_EnsureNotDisposed();
1111 if( !m_xResultSetOrigin
.is() )
1113 OSL_FAIL( "broadcaster was disposed already" );
1114 throw RuntimeException();
1116 m_xResultSetOrigin
->refreshRow();
1120 sal_Bool SAL_CALL ContentResultSetWrapper
1122 throw( SQLException
,
1125 impl_EnsureNotDisposed();
1127 if( !m_xResultSetOrigin
.is() )
1129 OSL_FAIL( "broadcaster was disposed already" );
1130 throw RuntimeException();
1132 return m_xResultSetOrigin
->rowUpdated();
1135 sal_Bool SAL_CALL ContentResultSetWrapper
1137 throw( SQLException
,
1140 impl_EnsureNotDisposed();
1142 if( !m_xResultSetOrigin
.is() )
1144 OSL_FAIL( "broadcaster was disposed already" );
1145 throw RuntimeException();
1147 return m_xResultSetOrigin
->rowInserted();
1151 sal_Bool SAL_CALL ContentResultSetWrapper
1153 throw( SQLException
,
1156 impl_EnsureNotDisposed();
1158 if( !m_xResultSetOrigin
.is() )
1160 OSL_FAIL( "broadcaster was disposed already" );
1161 throw RuntimeException();
1163 return m_xResultSetOrigin
->rowDeleted();
1167 Reference
< XInterface
> SAL_CALL ContentResultSetWrapper
1169 throw( SQLException
,
1172 impl_EnsureNotDisposed();
1173 //@todo ?return anything
1174 return Reference
< XInterface
>();
1177 //-----------------------------------------------------------------
1179 //-----------------------------------------------------------------
1181 #define XROW_GETXXX( getXXX ) \
1182 impl_EnsureNotDisposed(); \
1183 impl_init_xRowOrigin(); \
1184 if( !m_xRowOrigin.is() ) \
1186 OSL_FAIL( "broadcaster was disposed already" );\
1187 throw RuntimeException(); \
1189 return m_xRowOrigin->getXXX( columnIndex );
1192 sal_Bool SAL_CALL ContentResultSetWrapper
1194 throw( SQLException
,
1197 impl_EnsureNotDisposed();
1198 impl_init_xRowOrigin();
1199 if( !m_xRowOrigin
.is() )
1201 OSL_FAIL( "broadcaster was disposed already" );
1202 throw RuntimeException();
1204 return m_xRowOrigin
->wasNull();
1208 OUString SAL_CALL ContentResultSetWrapper
1209 ::getString( sal_Int32 columnIndex
)
1210 throw( SQLException
,
1213 XROW_GETXXX( getString
);
1217 sal_Bool SAL_CALL ContentResultSetWrapper
1218 ::getBoolean( sal_Int32 columnIndex
)
1219 throw( SQLException
,
1222 XROW_GETXXX( getBoolean
);
1226 sal_Int8 SAL_CALL ContentResultSetWrapper
1227 ::getByte( sal_Int32 columnIndex
)
1228 throw( SQLException
,
1231 XROW_GETXXX( getByte
);
1235 sal_Int16 SAL_CALL ContentResultSetWrapper
1236 ::getShort( sal_Int32 columnIndex
)
1237 throw( SQLException
,
1240 XROW_GETXXX( getShort
);
1244 sal_Int32 SAL_CALL ContentResultSetWrapper
1245 ::getInt( sal_Int32 columnIndex
)
1246 throw( SQLException
,
1249 XROW_GETXXX( getInt
);
1253 sal_Int64 SAL_CALL ContentResultSetWrapper
1254 ::getLong( sal_Int32 columnIndex
)
1255 throw( SQLException
,
1258 XROW_GETXXX( getLong
);
1262 float SAL_CALL ContentResultSetWrapper
1263 ::getFloat( sal_Int32 columnIndex
)
1264 throw( SQLException
,
1267 XROW_GETXXX( getFloat
);
1271 double SAL_CALL ContentResultSetWrapper
1272 ::getDouble( sal_Int32 columnIndex
)
1273 throw( SQLException
,
1276 XROW_GETXXX( getDouble
);
1280 Sequence
< sal_Int8
> SAL_CALL ContentResultSetWrapper
1281 ::getBytes( sal_Int32 columnIndex
)
1282 throw( SQLException
,
1285 XROW_GETXXX( getBytes
);
1289 Date SAL_CALL ContentResultSetWrapper
1290 ::getDate( sal_Int32 columnIndex
)
1291 throw( SQLException
,
1294 XROW_GETXXX( getDate
);
1298 Time SAL_CALL ContentResultSetWrapper
1299 ::getTime( sal_Int32 columnIndex
)
1300 throw( SQLException
,
1303 XROW_GETXXX( getTime
);
1307 DateTime SAL_CALL ContentResultSetWrapper
1308 ::getTimestamp( sal_Int32 columnIndex
)
1309 throw( SQLException
,
1312 XROW_GETXXX( getTimestamp
);
1316 Reference
< com::sun::star::io::XInputStream
>
1317 SAL_CALL ContentResultSetWrapper
1318 ::getBinaryStream( sal_Int32 columnIndex
)
1319 throw( SQLException
,
1322 XROW_GETXXX( getBinaryStream
);
1326 Reference
< com::sun::star::io::XInputStream
>
1327 SAL_CALL ContentResultSetWrapper
1328 ::getCharacterStream( sal_Int32 columnIndex
)
1329 throw( SQLException
,
1332 XROW_GETXXX( getCharacterStream
);
1336 Any SAL_CALL ContentResultSetWrapper
1337 ::getObject( sal_Int32 columnIndex
,
1339 com::sun::star::container::XNameAccess
>& typeMap
)
1340 throw( SQLException
,
1343 //if you change this macro please pay attention to
1344 //define XROW_GETXXX, where this is similar implemented
1346 impl_EnsureNotDisposed();
1347 impl_init_xRowOrigin();
1348 if( !m_xRowOrigin
.is() )
1350 OSL_FAIL( "broadcaster was disposed already" );
1351 throw RuntimeException();
1353 return m_xRowOrigin
->getObject( columnIndex
, typeMap
);
1357 Reference
< XRef
> SAL_CALL ContentResultSetWrapper
1358 ::getRef( sal_Int32 columnIndex
)
1359 throw( SQLException
,
1362 XROW_GETXXX( getRef
);
1366 Reference
< XBlob
> SAL_CALL ContentResultSetWrapper
1367 ::getBlob( sal_Int32 columnIndex
)
1368 throw( SQLException
,
1371 XROW_GETXXX( getBlob
);
1375 Reference
< XClob
> SAL_CALL ContentResultSetWrapper
1376 ::getClob( sal_Int32 columnIndex
)
1377 throw( SQLException
,
1380 XROW_GETXXX( getClob
);
1384 Reference
< XArray
> SAL_CALL ContentResultSetWrapper
1385 ::getArray( sal_Int32 columnIndex
)
1386 throw( SQLException
,
1389 XROW_GETXXX( getArray
);
1392 //--------------------------------------------------------------------------
1393 //--------------------------------------------------------------------------
1394 // class ContentResultSetWrapperListener
1395 //--------------------------------------------------------------------------
1396 //--------------------------------------------------------------------------
1398 ContentResultSetWrapperListener::ContentResultSetWrapperListener(
1399 ContentResultSetWrapper
* pOwner
)
1400 : m_pOwner( pOwner
)
1404 ContentResultSetWrapperListener::~ContentResultSetWrapperListener()
1408 //--------------------------------------------------------------------------
1409 // XInterface methods.
1410 //--------------------------------------------------------------------------
1411 //list all interfaces inclusive baseclasses of interfaces
1412 XINTERFACE_COMMON_IMPL( ContentResultSetWrapperListener
)
1413 QUERYINTERFACE_IMPL_START( ContentResultSetWrapperListener
)
1415 static_cast< XEventListener
* >(
1416 static_cast< XPropertyChangeListener
* >(this))
1417 , (static_cast< XPropertyChangeListener
* >(this))
1418 , (static_cast< XVetoableChangeListener
* >(this))
1420 QUERYINTERFACE_IMPL_END
1423 //--------------------------------------------------------------------------
1424 //XEventListener methods.
1425 //--------------------------------------------------------------------------
1428 void SAL_CALL ContentResultSetWrapperListener
1429 ::disposing( const EventObject
& rEventObject
)
1430 throw( RuntimeException
)
1433 m_pOwner
->impl_disposing( rEventObject
);
1436 //--------------------------------------------------------------------------
1437 //XPropertyChangeListener methods.
1438 //--------------------------------------------------------------------------
1441 void SAL_CALL ContentResultSetWrapperListener
1442 ::propertyChange( const PropertyChangeEvent
& rEvt
)
1443 throw( RuntimeException
)
1446 m_pOwner
->impl_propertyChange( rEvt
);
1449 //--------------------------------------------------------------------------
1450 //XVetoableChangeListener methods.
1451 //--------------------------------------------------------------------------
1453 void SAL_CALL ContentResultSetWrapperListener
1454 ::vetoableChange( const PropertyChangeEvent
& rEvt
)
1455 throw( PropertyVetoException
,
1459 m_pOwner
->impl_vetoableChange( rEvt
);
1462 void SAL_CALL ContentResultSetWrapperListener
1468 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */