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
;
41 // class ContentResultSetWrapper
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( false )
55 , m_bInDispose( 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 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;
339 // XInterface methods.
341 css::uno::Any SAL_CALL
ContentResultSetWrapper::queryInterface( const css::uno::Type
& rType
)
342 throw( css::uno::RuntimeException
, std::exception
)
344 //list all interfaces inclusive baseclasses of interfaces
345 css::uno::Any aRet
= cppu::queryInterface( rType
,
346 (static_cast< XComponent
* >(this)),
347 (static_cast< XCloseable
* >(this)),
348 (static_cast< XResultSetMetaDataSupplier
* >(this)),
349 (static_cast< XPropertySet
* >(this)),
350 (static_cast< XContentAccess
* >(this)),
351 (static_cast< XResultSet
* >(this)),
352 (static_cast< XRow
* >(this))
354 return aRet
.hasValue() ? aRet
: OWeakObject::queryInterface( rType
);
357 // XComponent methods.
360 void SAL_CALL ContentResultSetWrapper
361 ::dispose() throw( RuntimeException
, std::exception
)
363 impl_EnsureNotDisposed();
365 ReacquireableGuard
aGuard( m_aMutex
);
366 if( m_bInDispose
|| m_bDisposed
)
370 if( m_xPropertySetOrigin
.is() )
375 m_xPropertySetOrigin
->removePropertyChangeListener(
376 OUString(), static_cast< XPropertyChangeListener
* >( m_pMyListenerImpl
) );
380 OSL_FAIL( "could not remove PropertyChangeListener" );
384 m_xPropertySetOrigin
->removeVetoableChangeListener(
385 OUString(), static_cast< XVetoableChangeListener
* >( m_pMyListenerImpl
) );
389 OSL_FAIL( "could not remove VetoableChangeListener" );
392 Reference
< XComponent
> xComponentOrigin( m_xResultSetOrigin
, UNO_QUERY
);
393 OSL_ENSURE( xComponentOrigin
.is(), "interface XComponent is required" );
394 xComponentOrigin
->removeEventListener( static_cast< XPropertyChangeListener
* >( m_pMyListenerImpl
) );
398 if( m_pDisposeEventListeners
&& m_pDisposeEventListeners
->getLength() )
401 aEvt
.Source
= static_cast< XComponent
* >( this );
404 m_pDisposeEventListeners
->disposeAndClear( aEvt
);
408 if( m_pPropertyChangeListeners
)
411 aEvt
.Source
= static_cast< XPropertySet
* >( this );
414 m_pPropertyChangeListeners
->disposeAndClear( aEvt
);
418 if( m_pVetoableChangeListeners
)
421 aEvt
.Source
= static_cast< XPropertySet
* >( this );
424 m_pVetoableChangeListeners
->disposeAndClear( aEvt
);
429 m_bInDispose
= false;
434 void SAL_CALL ContentResultSetWrapper
435 ::addEventListener( const Reference
< XEventListener
>& Listener
)
436 throw( RuntimeException
, std::exception
)
438 impl_EnsureNotDisposed();
439 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
441 if ( !m_pDisposeEventListeners
)
442 m_pDisposeEventListeners
=
443 new OInterfaceContainerHelper( m_aContainerMutex
);
445 m_pDisposeEventListeners
->addInterface( Listener
);
450 void SAL_CALL ContentResultSetWrapper
451 ::removeEventListener( const Reference
< XEventListener
>& Listener
)
452 throw( RuntimeException
, std::exception
)
454 impl_EnsureNotDisposed();
455 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
457 if ( m_pDisposeEventListeners
)
458 m_pDisposeEventListeners
->removeInterface( Listener
);
462 //XCloseable methods.
465 void SAL_CALL ContentResultSetWrapper
468 RuntimeException
, std::exception
)
470 impl_EnsureNotDisposed();
475 //XResultSetMetaDataSupplier methods.
478 Reference
< XResultSetMetaData
> SAL_CALL ContentResultSetWrapper
481 RuntimeException
, std::exception
)
483 impl_EnsureNotDisposed();
485 ReacquireableGuard
aGuard( m_aMutex
);
486 if( !m_xMetaDataFromOrigin
.is() && m_xResultSetOrigin
.is() )
488 Reference
< XResultSetMetaDataSupplier
> xMetaDataSupplier
489 = Reference
< XResultSetMetaDataSupplier
>(
490 m_xResultSetOrigin
, UNO_QUERY
);
492 if( xMetaDataSupplier
.is() )
496 Reference
< XResultSetMetaData
> xMetaData
497 = xMetaDataSupplier
->getMetaData();
500 m_xMetaDataFromOrigin
= xMetaData
;
503 return m_xMetaDataFromOrigin
;
508 // XPropertySet methods.
511 Reference
< XPropertySetInfo
> SAL_CALL ContentResultSetWrapper
512 ::getPropertySetInfo() throw( RuntimeException
, std::exception
)
514 impl_EnsureNotDisposed();
516 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
517 if( m_xPropertySetInfo
.is() )
518 return m_xPropertySetInfo
;
520 impl_initPropertySetInfo();
521 return m_xPropertySetInfo
;
525 void SAL_CALL ContentResultSetWrapper
526 ::setPropertyValue( const OUString
& rPropertyName
, const Any
& rValue
)
527 throw( UnknownPropertyException
,
528 PropertyVetoException
,
529 IllegalArgumentException
,
530 WrappedTargetException
,
531 RuntimeException
, std::exception
)
533 impl_EnsureNotDisposed();
534 impl_init_xPropertySetOrigin();
535 if( !m_xPropertySetOrigin
.is() )
537 OSL_FAIL( "broadcaster was disposed already" );
538 throw UnknownPropertyException();
540 m_xPropertySetOrigin
->setPropertyValue( rPropertyName
, rValue
);
545 Any SAL_CALL ContentResultSetWrapper
546 ::getPropertyValue( const OUString
& rPropertyName
)
547 throw( UnknownPropertyException
,
548 WrappedTargetException
,
549 RuntimeException
, std::exception
)
551 impl_EnsureNotDisposed();
552 impl_init_xPropertySetOrigin();
553 if( !m_xPropertySetOrigin
.is() )
555 OSL_FAIL( "broadcaster was disposed already" );
556 throw UnknownPropertyException();
558 return m_xPropertySetOrigin
->getPropertyValue( rPropertyName
);
563 void SAL_CALL ContentResultSetWrapper
564 ::addPropertyChangeListener(
565 const OUString
& aPropertyName
,
566 const Reference
< XPropertyChangeListener
>& xListener
)
567 throw( UnknownPropertyException
,
568 WrappedTargetException
,
569 RuntimeException
, std::exception
)
571 impl_EnsureNotDisposed();
573 if( !getPropertySetInfo().is() )
575 OSL_FAIL( "broadcaster was disposed already" );
576 throw UnknownPropertyException();
579 if( !aPropertyName
.isEmpty() )
581 m_xPropertySetInfo
->getPropertyByName( aPropertyName
);
582 //throws UnknownPropertyException, if so
585 impl_getPropertyChangeListenerContainer();
586 bool bNeedRegister
= !m_pPropertyChangeListeners
->
587 getContainedTypes().getLength();
588 m_pPropertyChangeListeners
->addInterface( aPropertyName
, xListener
);
591 impl_init_xPropertySetOrigin();
593 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
594 if( !m_xPropertySetOrigin
.is() )
596 OSL_FAIL( "broadcaster was disposed already" );
602 m_xPropertySetOrigin
->addPropertyChangeListener(
603 OUString(), static_cast< XPropertyChangeListener
* >( m_pMyListenerImpl
) );
607 m_pPropertyChangeListeners
->removeInterface( aPropertyName
, xListener
);
615 void SAL_CALL ContentResultSetWrapper
616 ::addVetoableChangeListener(
617 const OUString
& rPropertyName
,
618 const Reference
< XVetoableChangeListener
>& xListener
)
619 throw( UnknownPropertyException
,
620 WrappedTargetException
,
621 RuntimeException
, std::exception
)
623 impl_EnsureNotDisposed();
625 if( !getPropertySetInfo().is() )
627 OSL_FAIL( "broadcaster was disposed already" );
628 throw UnknownPropertyException();
630 if( !rPropertyName
.isEmpty() )
632 m_xPropertySetInfo
->getPropertyByName( rPropertyName
);
633 //throws UnknownPropertyException, if so
636 impl_getVetoableChangeListenerContainer();
637 bool bNeedRegister
= !m_pVetoableChangeListeners
->
638 getContainedTypes().getLength();
639 m_pVetoableChangeListeners
->addInterface( rPropertyName
, xListener
);
642 impl_init_xPropertySetOrigin();
644 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
645 if( !m_xPropertySetOrigin
.is() )
647 OSL_FAIL( "broadcaster was disposed already" );
653 m_xPropertySetOrigin
->addVetoableChangeListener(
654 OUString(), static_cast< XVetoableChangeListener
* >( m_pMyListenerImpl
) );
658 m_pVetoableChangeListeners
->removeInterface( rPropertyName
, xListener
);
666 void SAL_CALL ContentResultSetWrapper
667 ::removePropertyChangeListener(
668 const OUString
& rPropertyName
,
669 const Reference
< XPropertyChangeListener
>& xListener
)
670 throw( UnknownPropertyException
,
671 WrappedTargetException
,
672 RuntimeException
, std::exception
)
674 impl_EnsureNotDisposed();
677 //noop, if no listener registered
678 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
679 if( !m_pPropertyChangeListeners
)
682 OInterfaceContainerHelper
* pContainer
=
683 m_pPropertyChangeListeners
->getContainer( rPropertyName
);
687 if( !rPropertyName
.isEmpty() )
689 if( !getPropertySetInfo().is() )
690 throw UnknownPropertyException();
692 m_xPropertySetInfo
->getPropertyByName( rPropertyName
);
693 //throws UnknownPropertyException, if so
695 return; //the listener was not registered
698 m_pPropertyChangeListeners
->removeInterface( rPropertyName
, xListener
);
700 if( !m_pPropertyChangeListeners
->getContainedTypes().getLength() )
702 impl_init_xPropertySetOrigin();
704 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
705 if( !m_xPropertySetOrigin
.is() )
707 OSL_FAIL( "broadcaster was disposed already" );
713 m_xPropertySetOrigin
->removePropertyChangeListener(
714 OUString(), static_cast< XPropertyChangeListener
* >( m_pMyListenerImpl
) );
718 OSL_FAIL( "could not remove PropertyChangeListener" );
725 void SAL_CALL ContentResultSetWrapper
726 ::removeVetoableChangeListener(
727 const OUString
& rPropertyName
,
728 const Reference
< XVetoableChangeListener
>& xListener
)
729 throw( UnknownPropertyException
,
730 WrappedTargetException
,
731 RuntimeException
, std::exception
)
733 impl_EnsureNotDisposed();
736 //noop, if no listener registered
737 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
738 if( !m_pVetoableChangeListeners
)
741 OInterfaceContainerHelper
* pContainer
=
742 m_pVetoableChangeListeners
->getContainer( rPropertyName
);
746 if( !rPropertyName
.isEmpty() )
748 if( !getPropertySetInfo().is() )
749 throw UnknownPropertyException();
751 m_xPropertySetInfo
->getPropertyByName( rPropertyName
);
752 //throws UnknownPropertyException, if so
754 return; //the listener was not registered
757 m_pVetoableChangeListeners
->removeInterface( rPropertyName
, xListener
);
759 if( !m_pVetoableChangeListeners
->getContainedTypes().getLength() )
761 impl_init_xPropertySetOrigin();
763 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
764 if( !m_xPropertySetOrigin
.is() )
766 OSL_FAIL( "broadcaster was disposed already" );
772 m_xPropertySetOrigin
->removeVetoableChangeListener(
773 OUString(), static_cast< XVetoableChangeListener
* >( m_pMyListenerImpl
) );
777 OSL_FAIL( "could not remove VetoableChangeListener" );
787 void SAL_CALL ContentResultSetWrapper
788 ::impl_disposing( const EventObject
& )
789 throw( RuntimeException
)
791 impl_EnsureNotDisposed();
793 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
795 if( !m_xResultSetOrigin
.is() )
798 //release all references to the broadcaster:
799 m_xResultSetOrigin
.clear();
800 if(m_xRowOrigin
.is())
801 m_xRowOrigin
.clear();
802 if(m_xContentAccessOrigin
.is())
803 m_xContentAccessOrigin
.clear();
804 if(m_xPropertySetOrigin
.is())
805 m_xPropertySetOrigin
.clear();
806 m_xMetaDataFromOrigin
.clear();
807 if(m_xPropertySetInfo
.is())
808 m_xPropertySetInfo
.clear();
812 void SAL_CALL ContentResultSetWrapper
813 ::impl_propertyChange( const PropertyChangeEvent
& rEvt
)
814 throw( RuntimeException
)
816 impl_EnsureNotDisposed();
818 PropertyChangeEvent
aEvt( rEvt
);
819 aEvt
.Source
= static_cast< XPropertySet
* >( this );
820 aEvt
.Further
= sal_False
;
821 impl_notifyPropertyChangeListeners( aEvt
);
825 void SAL_CALL ContentResultSetWrapper
826 ::impl_vetoableChange( const PropertyChangeEvent
& rEvt
)
827 throw( PropertyVetoException
,
830 impl_EnsureNotDisposed();
832 PropertyChangeEvent
aEvt( rEvt
);
833 aEvt
.Source
= static_cast< XPropertySet
* >( this );
834 aEvt
.Further
= sal_False
;
836 impl_notifyVetoableChangeListeners( aEvt
);
840 // XContentAccess methods. ( -- position dependent )
844 OUString SAL_CALL ContentResultSetWrapper
845 ::queryContentIdentifierString()
846 throw( RuntimeException
, std::exception
)
848 impl_EnsureNotDisposed();
849 impl_init_xContentAccessOrigin();
850 if( !m_xContentAccessOrigin
.is() )
852 OSL_FAIL( "broadcaster was disposed already" );
853 throw RuntimeException();
855 return m_xContentAccessOrigin
->queryContentIdentifierString();
860 Reference
< XContentIdentifier
> SAL_CALL ContentResultSetWrapper
861 ::queryContentIdentifier()
862 throw( RuntimeException
, std::exception
)
864 impl_EnsureNotDisposed();
865 impl_init_xContentAccessOrigin();
866 if( !m_xContentAccessOrigin
.is() )
868 OSL_FAIL( "broadcaster was disposed already" );
869 throw RuntimeException();
871 return m_xContentAccessOrigin
->queryContentIdentifier();
876 Reference
< XContent
> SAL_CALL ContentResultSetWrapper
878 throw( RuntimeException
, std::exception
)
880 impl_EnsureNotDisposed();
881 impl_init_xContentAccessOrigin();
882 if( !m_xContentAccessOrigin
.is() )
884 OSL_FAIL( "broadcaster was disposed already" );
885 throw RuntimeException();
887 return m_xContentAccessOrigin
->queryContent();
891 // XResultSet methods.
895 sal_Bool SAL_CALL ContentResultSetWrapper
898 RuntimeException
, std::exception
)
900 impl_EnsureNotDisposed();
902 if( !m_xResultSetOrigin
.is() )
904 OSL_FAIL( "broadcaster was disposed already" );
905 throw RuntimeException();
907 return m_xResultSetOrigin
->next();
911 sal_Bool SAL_CALL ContentResultSetWrapper
914 RuntimeException
, std::exception
)
916 impl_EnsureNotDisposed();
918 if( !m_xResultSetOrigin
.is() )
920 OSL_FAIL( "broadcaster was disposed already" );
921 throw RuntimeException();
923 return m_xResultSetOrigin
->previous();
927 sal_Bool SAL_CALL ContentResultSetWrapper
928 ::absolute( sal_Int32 row
)
930 RuntimeException
, std::exception
)
932 impl_EnsureNotDisposed();
934 if( !m_xResultSetOrigin
.is() )
936 OSL_FAIL( "broadcaster was disposed already" );
937 throw RuntimeException();
939 return m_xResultSetOrigin
->absolute( row
);
943 sal_Bool SAL_CALL ContentResultSetWrapper
944 ::relative( sal_Int32 rows
)
946 RuntimeException
, std::exception
)
948 impl_EnsureNotDisposed();
950 if( !m_xResultSetOrigin
.is() )
952 OSL_FAIL( "broadcaster was disposed already" );
953 throw RuntimeException();
955 return m_xResultSetOrigin
->relative( rows
);
960 sal_Bool SAL_CALL ContentResultSetWrapper
963 RuntimeException
, std::exception
)
965 impl_EnsureNotDisposed();
967 if( !m_xResultSetOrigin
.is() )
969 OSL_FAIL( "broadcaster was disposed already" );
970 throw RuntimeException();
972 return m_xResultSetOrigin
->first();
976 sal_Bool SAL_CALL ContentResultSetWrapper
979 RuntimeException
, std::exception
)
981 impl_EnsureNotDisposed();
983 if( !m_xResultSetOrigin
.is() )
985 OSL_FAIL( "broadcaster was disposed already" );
986 throw RuntimeException();
988 return m_xResultSetOrigin
->last();
992 void SAL_CALL ContentResultSetWrapper
995 RuntimeException
, std::exception
)
997 impl_EnsureNotDisposed();
999 if( !m_xResultSetOrigin
.is() )
1001 OSL_FAIL( "broadcaster was disposed already" );
1002 throw RuntimeException();
1004 m_xResultSetOrigin
->beforeFirst();
1008 void SAL_CALL ContentResultSetWrapper
1010 throw( SQLException
,
1011 RuntimeException
, std::exception
)
1013 impl_EnsureNotDisposed();
1015 if( !m_xResultSetOrigin
.is() )
1017 OSL_FAIL( "broadcaster was disposed already" );
1018 throw RuntimeException();
1020 m_xResultSetOrigin
->afterLast();
1024 sal_Bool SAL_CALL ContentResultSetWrapper
1026 throw( SQLException
,
1027 RuntimeException
, std::exception
)
1029 impl_EnsureNotDisposed();
1031 if( !m_xResultSetOrigin
.is() )
1033 OSL_FAIL( "broadcaster was disposed already" );
1034 throw RuntimeException();
1036 return m_xResultSetOrigin
->isAfterLast();
1040 sal_Bool SAL_CALL ContentResultSetWrapper
1042 throw( SQLException
,
1043 RuntimeException
, std::exception
)
1045 impl_EnsureNotDisposed();
1047 if( !m_xResultSetOrigin
.is() )
1049 OSL_FAIL( "broadcaster was disposed already" );
1050 throw RuntimeException();
1052 return m_xResultSetOrigin
->isBeforeFirst();
1056 sal_Bool SAL_CALL ContentResultSetWrapper
1058 throw( SQLException
,
1059 RuntimeException
, std::exception
)
1061 impl_EnsureNotDisposed();
1063 if( !m_xResultSetOrigin
.is() )
1065 OSL_FAIL( "broadcaster was disposed already" );
1066 throw RuntimeException();
1068 return m_xResultSetOrigin
->isFirst();
1072 sal_Bool SAL_CALL ContentResultSetWrapper
1074 throw( SQLException
,
1075 RuntimeException
, std::exception
)
1077 impl_EnsureNotDisposed();
1079 if( !m_xResultSetOrigin
.is() )
1081 OSL_FAIL( "broadcaster was disposed already" );
1082 throw RuntimeException();
1084 return m_xResultSetOrigin
->isLast();
1089 sal_Int32 SAL_CALL ContentResultSetWrapper
1091 throw( SQLException
,
1092 RuntimeException
, std::exception
)
1094 impl_EnsureNotDisposed();
1096 if( !m_xResultSetOrigin
.is() )
1098 OSL_FAIL( "broadcaster was disposed already" );
1099 throw RuntimeException();
1101 return m_xResultSetOrigin
->getRow();
1105 void SAL_CALL ContentResultSetWrapper
1107 throw( SQLException
,
1108 RuntimeException
, std::exception
)
1110 impl_EnsureNotDisposed();
1112 if( !m_xResultSetOrigin
.is() )
1114 OSL_FAIL( "broadcaster was disposed already" );
1115 throw RuntimeException();
1117 m_xResultSetOrigin
->refreshRow();
1121 sal_Bool SAL_CALL ContentResultSetWrapper
1123 throw( SQLException
,
1124 RuntimeException
, std::exception
)
1126 impl_EnsureNotDisposed();
1128 if( !m_xResultSetOrigin
.is() )
1130 OSL_FAIL( "broadcaster was disposed already" );
1131 throw RuntimeException();
1133 return m_xResultSetOrigin
->rowUpdated();
1136 sal_Bool SAL_CALL ContentResultSetWrapper
1138 throw( SQLException
,
1139 RuntimeException
, std::exception
)
1141 impl_EnsureNotDisposed();
1143 if( !m_xResultSetOrigin
.is() )
1145 OSL_FAIL( "broadcaster was disposed already" );
1146 throw RuntimeException();
1148 return m_xResultSetOrigin
->rowInserted();
1152 sal_Bool SAL_CALL ContentResultSetWrapper
1154 throw( SQLException
,
1155 RuntimeException
, std::exception
)
1157 impl_EnsureNotDisposed();
1159 if( !m_xResultSetOrigin
.is() )
1161 OSL_FAIL( "broadcaster was disposed already" );
1162 throw RuntimeException();
1164 return m_xResultSetOrigin
->rowDeleted();
1168 Reference
< XInterface
> SAL_CALL ContentResultSetWrapper
1170 throw( SQLException
,
1171 RuntimeException
, std::exception
)
1173 impl_EnsureNotDisposed();
1174 //@todo ?return anything
1175 return Reference
< XInterface
>();
1182 #define XROW_GETXXX( getXXX ) \
1183 impl_EnsureNotDisposed(); \
1184 impl_init_xRowOrigin(); \
1185 if( !m_xRowOrigin.is() ) \
1187 OSL_FAIL( "broadcaster was disposed already" );\
1188 throw RuntimeException(); \
1190 return m_xRowOrigin->getXXX( columnIndex );
1193 sal_Bool SAL_CALL ContentResultSetWrapper
1195 throw( SQLException
,
1196 RuntimeException
, std::exception
)
1198 impl_EnsureNotDisposed();
1199 impl_init_xRowOrigin();
1200 if( !m_xRowOrigin
.is() )
1202 OSL_FAIL( "broadcaster was disposed already" );
1203 throw RuntimeException();
1205 return m_xRowOrigin
->wasNull();
1209 OUString SAL_CALL ContentResultSetWrapper
1210 ::getString( sal_Int32 columnIndex
)
1211 throw( SQLException
,
1212 RuntimeException
, std::exception
)
1214 XROW_GETXXX( getString
);
1218 sal_Bool SAL_CALL ContentResultSetWrapper
1219 ::getBoolean( sal_Int32 columnIndex
)
1220 throw( SQLException
,
1221 RuntimeException
, std::exception
)
1223 XROW_GETXXX( getBoolean
);
1227 sal_Int8 SAL_CALL ContentResultSetWrapper
1228 ::getByte( sal_Int32 columnIndex
)
1229 throw( SQLException
,
1230 RuntimeException
, std::exception
)
1232 XROW_GETXXX( getByte
);
1236 sal_Int16 SAL_CALL ContentResultSetWrapper
1237 ::getShort( sal_Int32 columnIndex
)
1238 throw( SQLException
,
1239 RuntimeException
, std::exception
)
1241 XROW_GETXXX( getShort
);
1245 sal_Int32 SAL_CALL ContentResultSetWrapper
1246 ::getInt( sal_Int32 columnIndex
)
1247 throw( SQLException
,
1248 RuntimeException
, std::exception
)
1250 XROW_GETXXX( getInt
);
1254 sal_Int64 SAL_CALL ContentResultSetWrapper
1255 ::getLong( sal_Int32 columnIndex
)
1256 throw( SQLException
,
1257 RuntimeException
, std::exception
)
1259 XROW_GETXXX( getLong
);
1263 float SAL_CALL ContentResultSetWrapper
1264 ::getFloat( sal_Int32 columnIndex
)
1265 throw( SQLException
,
1266 RuntimeException
, std::exception
)
1268 XROW_GETXXX( getFloat
);
1272 double SAL_CALL ContentResultSetWrapper
1273 ::getDouble( sal_Int32 columnIndex
)
1274 throw( SQLException
,
1275 RuntimeException
, std::exception
)
1277 XROW_GETXXX( getDouble
);
1281 Sequence
< sal_Int8
> SAL_CALL ContentResultSetWrapper
1282 ::getBytes( sal_Int32 columnIndex
)
1283 throw( SQLException
,
1284 RuntimeException
, std::exception
)
1286 XROW_GETXXX( getBytes
);
1290 Date SAL_CALL ContentResultSetWrapper
1291 ::getDate( sal_Int32 columnIndex
)
1292 throw( SQLException
,
1293 RuntimeException
, std::exception
)
1295 XROW_GETXXX( getDate
);
1299 Time SAL_CALL ContentResultSetWrapper
1300 ::getTime( sal_Int32 columnIndex
)
1301 throw( SQLException
,
1302 RuntimeException
, std::exception
)
1304 XROW_GETXXX( getTime
);
1308 DateTime SAL_CALL ContentResultSetWrapper
1309 ::getTimestamp( sal_Int32 columnIndex
)
1310 throw( SQLException
,
1311 RuntimeException
, std::exception
)
1313 XROW_GETXXX( getTimestamp
);
1317 Reference
< com::sun::star::io::XInputStream
>
1318 SAL_CALL ContentResultSetWrapper
1319 ::getBinaryStream( sal_Int32 columnIndex
)
1320 throw( SQLException
,
1321 RuntimeException
, std::exception
)
1323 XROW_GETXXX( getBinaryStream
);
1327 Reference
< com::sun::star::io::XInputStream
>
1328 SAL_CALL ContentResultSetWrapper
1329 ::getCharacterStream( sal_Int32 columnIndex
)
1330 throw( SQLException
,
1331 RuntimeException
, std::exception
)
1333 XROW_GETXXX( getCharacterStream
);
1337 Any SAL_CALL ContentResultSetWrapper
1338 ::getObject( sal_Int32 columnIndex
,
1340 com::sun::star::container::XNameAccess
>& typeMap
)
1341 throw( SQLException
,
1342 RuntimeException
, std::exception
)
1344 //if you change this macro please pay attention to
1345 //define XROW_GETXXX, where this is similar implemented
1347 impl_EnsureNotDisposed();
1348 impl_init_xRowOrigin();
1349 if( !m_xRowOrigin
.is() )
1351 OSL_FAIL( "broadcaster was disposed already" );
1352 throw RuntimeException();
1354 return m_xRowOrigin
->getObject( columnIndex
, typeMap
);
1358 Reference
< XRef
> SAL_CALL ContentResultSetWrapper
1359 ::getRef( sal_Int32 columnIndex
)
1360 throw( SQLException
,
1361 RuntimeException
, std::exception
)
1363 XROW_GETXXX( getRef
);
1367 Reference
< XBlob
> SAL_CALL ContentResultSetWrapper
1368 ::getBlob( sal_Int32 columnIndex
)
1369 throw( SQLException
,
1370 RuntimeException
, std::exception
)
1372 XROW_GETXXX( getBlob
);
1376 Reference
< XClob
> SAL_CALL ContentResultSetWrapper
1377 ::getClob( sal_Int32 columnIndex
)
1378 throw( SQLException
,
1379 RuntimeException
, std::exception
)
1381 XROW_GETXXX( getClob
);
1385 Reference
< XArray
> SAL_CALL ContentResultSetWrapper
1386 ::getArray( sal_Int32 columnIndex
)
1387 throw( SQLException
,
1388 RuntimeException
, std::exception
)
1390 XROW_GETXXX( getArray
);
1395 // class ContentResultSetWrapperListener
1399 ContentResultSetWrapperListener::ContentResultSetWrapperListener(
1400 ContentResultSetWrapper
* pOwner
)
1401 : m_pOwner( pOwner
)
1405 ContentResultSetWrapperListener::~ContentResultSetWrapperListener()
1410 // XInterface methods.
1411 void SAL_CALL
ContentResultSetWrapperListener::acquire()
1414 OWeakObject::acquire();
1417 void SAL_CALL
ContentResultSetWrapperListener::release()
1420 OWeakObject::release();
1423 css::uno::Any SAL_CALL
ContentResultSetWrapperListener::queryInterface( const css::uno::Type
& rType
)
1424 throw( com::sun::star::uno::RuntimeException
, std::exception
)
1426 //list all interfaces inclusive baseclasses of interfaces
1427 css::uno::Any aRet
= cppu::queryInterface( rType
,
1428 static_cast< XEventListener
* >(
1429 static_cast< XPropertyChangeListener
* >(this)),
1430 static_cast< XPropertyChangeListener
* >(this),
1431 static_cast< XVetoableChangeListener
* >(this)
1433 return aRet
.hasValue() ? aRet
: OWeakObject::queryInterface( rType
);
1436 //XEventListener methods.
1440 void SAL_CALL ContentResultSetWrapperListener
1441 ::disposing( const EventObject
& rEventObject
)
1442 throw( RuntimeException
, std::exception
)
1445 m_pOwner
->impl_disposing( rEventObject
);
1449 //XPropertyChangeListener methods.
1453 void SAL_CALL ContentResultSetWrapperListener
1454 ::propertyChange( const PropertyChangeEvent
& rEvt
)
1455 throw( RuntimeException
, std::exception
)
1458 m_pOwner
->impl_propertyChange( rEvt
);
1462 //XVetoableChangeListener methods.
1465 void SAL_CALL ContentResultSetWrapperListener
1466 ::vetoableChange( const PropertyChangeEvent
& rEvt
)
1467 throw( PropertyVetoException
,
1468 RuntimeException
, std::exception
)
1471 m_pOwner
->impl_vetoableChange( rEvt
);
1474 void SAL_CALL ContentResultSetWrapperListener
1480 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */