fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / ucb / source / cacher / contentresultsetwrapper.cxx
blob17eeb0932fce80881a901f84e390de067b84b174
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include <contentresultsetwrapper.hxx>
22 #include <com/sun/star/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;
36 using namespace cppu;
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 )
52 , m_nForwardOnly( 2 )
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 );
73 if(m_xRowOrigin.is())
74 return;
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())
92 return;
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() )
111 return;
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();
151 //virtual
152 void SAL_CALL ContentResultSetWrapper
153 ::impl_initPropertySetInfo()
156 osl::Guard< osl::Mutex > aGuard( m_aMutex );
157 if( m_xPropertySetInfo.is() )
158 return;
160 impl_init_xPropertySetOrigin();
161 if( !m_xPropertySetOrigin.is() )
162 return;
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 );
179 if( m_bDisposed )
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 )
212 return;
215 // Notify listeners interested especially in the changed property.
216 OInterfaceContainerHelper* pContainer =
217 m_pPropertyChangeListeners->getContainer( rEvt.PropertyName );
218 if( pContainer )
220 OInterfaceIteratorHelper aIter( *pContainer );
221 while( aIter.hasMoreElements() )
223 Reference< XPropertyChangeListener > xListener(
224 aIter.next(), UNO_QUERY );
225 if( xListener.is() )
226 xListener->propertyChange( rEvt );
230 // Notify listeners interested in all properties.
231 pContainer = m_pPropertyChangeListeners->getContainer( OUString() );
232 if( pContainer )
234 OInterfaceIteratorHelper aIter( *pContainer );
235 while( aIter.hasMoreElements() )
237 Reference< XPropertyChangeListener > xListener(
238 aIter.next(), UNO_QUERY );
239 if( xListener.is() )
240 xListener->propertyChange( rEvt );
245 void SAL_CALL ContentResultSetWrapper
246 ::impl_notifyVetoableChangeListeners( const PropertyChangeEvent& rEvt )
247 throw( PropertyVetoException,
248 RuntimeException )
251 osl::Guard< osl::Mutex > aGuard( m_aMutex );
252 if( !m_pVetoableChangeListeners )
253 return;
256 // Notify listeners interested especially in the changed property.
257 OInterfaceContainerHelper* pContainer =
258 m_pVetoableChangeListeners->getContainer( rEvt.PropertyName );
259 if( pContainer )
261 OInterfaceIteratorHelper aIter( *pContainer );
262 while( aIter.hasMoreElements() )
264 Reference< XVetoableChangeListener > xListener(
265 aIter.next(), UNO_QUERY );
266 if( xListener.is() )
267 xListener->vetoableChange( rEvt );
271 // Notify listeners interested in all properties.
272 pContainer = m_pVetoableChangeListeners->getContainer( OUString() );
273 if( pContainer )
275 OInterfaceIteratorHelper aIter( *pContainer );
276 while( aIter.hasMoreElements() )
278 Reference< XVetoableChangeListener > xListener(
279 aIter.next(), UNO_QUERY );
280 if( xListener.is() )
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 );
295 m_nForwardOnly = 0;
296 return false;
300 ReacquireableGuard aGuard( m_aMutex );
301 if( m_nForwardOnly == 2 )
303 aGuard.clear();
304 if( !getPropertySetInfo().is() )
306 aGuard.reacquire();
307 m_nForwardOnly = 0;
308 return m_nForwardOnly;
310 aGuard.reacquire();
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" );
319 m_nForwardOnly = 0;
320 return m_nForwardOnly;
323 aGuard.clear();
324 Any aAny = m_xPropertySetOrigin->getPropertyValue( aName );
326 aGuard.reacquire();
327 long nResultSetType;
328 if( ( aAny >>= nResultSetType ) &&
329 ( nResultSetType == ResultSetType::FORWARD_ONLY ) )
330 m_nForwardOnly = 1;
331 else
332 m_nForwardOnly = 0;
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.
359 // virtual
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 )
367 return;
368 m_bInDispose = true;
370 if( m_xPropertySetOrigin.is() )
372 aGuard.clear();
375 m_xPropertySetOrigin->removePropertyChangeListener(
376 OUString(), static_cast< XPropertyChangeListener * >( m_pMyListenerImpl ) );
378 catch( Exception& )
380 OSL_FAIL( "could not remove PropertyChangeListener" );
384 m_xPropertySetOrigin->removeVetoableChangeListener(
385 OUString(), static_cast< XVetoableChangeListener * >( m_pMyListenerImpl ) );
387 catch( Exception& )
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 ) );
397 aGuard.reacquire();
398 if( m_pDisposeEventListeners && m_pDisposeEventListeners->getLength() )
400 EventObject aEvt;
401 aEvt.Source = static_cast< XComponent * >( this );
403 aGuard.clear();
404 m_pDisposeEventListeners->disposeAndClear( aEvt );
407 aGuard.reacquire();
408 if( m_pPropertyChangeListeners )
410 EventObject aEvt;
411 aEvt.Source = static_cast< XPropertySet * >( this );
413 aGuard.clear();
414 m_pPropertyChangeListeners->disposeAndClear( aEvt );
417 aGuard.reacquire();
418 if( m_pVetoableChangeListeners )
420 EventObject aEvt;
421 aEvt.Source = static_cast< XPropertySet * >( this );
423 aGuard.clear();
424 m_pVetoableChangeListeners->disposeAndClear( aEvt );
427 aGuard.reacquire();
428 m_bDisposed = true;
429 m_bInDispose = false;
433 // virtual
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 );
449 // virtual
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.
464 //virtual
465 void SAL_CALL ContentResultSetWrapper
466 ::close()
467 throw( SQLException,
468 RuntimeException, std::exception )
470 impl_EnsureNotDisposed();
471 dispose();
475 //XResultSetMetaDataSupplier methods.
477 //virtual
478 Reference< XResultSetMetaData > SAL_CALL ContentResultSetWrapper
479 ::getMetaData()
480 throw( SQLException,
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() )
494 aGuard.clear();
496 Reference< XResultSetMetaData > xMetaData
497 = xMetaDataSupplier->getMetaData();
499 aGuard.reacquire();
500 m_xMetaDataFromOrigin = xMetaData;
503 return m_xMetaDataFromOrigin;
508 // XPropertySet methods.
510 // virtual
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;
524 // virtual
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 );
544 // virtual
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 );
562 // virtual
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 );
589 if( bNeedRegister )
591 impl_init_xPropertySetOrigin();
593 osl::Guard< osl::Mutex > aGuard( m_aMutex );
594 if( !m_xPropertySetOrigin.is() )
596 OSL_FAIL( "broadcaster was disposed already" );
597 return;
602 m_xPropertySetOrigin->addPropertyChangeListener(
603 OUString(), static_cast< XPropertyChangeListener * >( m_pMyListenerImpl ) );
605 catch( Exception& )
607 m_pPropertyChangeListeners->removeInterface( aPropertyName, xListener );
608 throw;
614 // virtual
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 );
640 if( bNeedRegister )
642 impl_init_xPropertySetOrigin();
644 osl::Guard< osl::Mutex > aGuard( m_aMutex );
645 if( !m_xPropertySetOrigin.is() )
647 OSL_FAIL( "broadcaster was disposed already" );
648 return;
653 m_xPropertySetOrigin->addVetoableChangeListener(
654 OUString(), static_cast< XVetoableChangeListener * >( m_pMyListenerImpl ) );
656 catch( Exception& )
658 m_pVetoableChangeListeners->removeInterface( rPropertyName, xListener );
659 throw;
665 // virtual
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 )
680 return;
682 OInterfaceContainerHelper* pContainer =
683 m_pPropertyChangeListeners->getContainer( rPropertyName );
685 if( !pContainer )
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" );
708 return;
713 m_xPropertySetOrigin->removePropertyChangeListener(
714 OUString(), static_cast< XPropertyChangeListener * >( m_pMyListenerImpl ) );
716 catch( Exception& )
718 OSL_FAIL( "could not remove PropertyChangeListener" );
724 // virtual
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 )
739 return;
741 OInterfaceContainerHelper* pContainer =
742 m_pVetoableChangeListeners->getContainer( rPropertyName );
744 if( !pContainer )
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" );
767 return;
772 m_xPropertySetOrigin->removeVetoableChangeListener(
773 OUString(), static_cast< XVetoableChangeListener * >( m_pMyListenerImpl ) );
775 catch( Exception& )
777 OSL_FAIL( "could not remove VetoableChangeListener" );
783 // own methods.
786 //virtual
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() )
796 return;
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();
811 //virtual
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 );
824 //virtual
825 void SAL_CALL ContentResultSetWrapper
826 ::impl_vetoableChange( const PropertyChangeEvent& rEvt )
827 throw( PropertyVetoException,
828 RuntimeException )
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 )
843 // virtual
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();
859 // virtual
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();
875 // virtual
876 Reference< XContent > SAL_CALL ContentResultSetWrapper
877 ::queryContent()
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.
893 //virtual
895 sal_Bool SAL_CALL ContentResultSetWrapper
896 ::next()
897 throw( SQLException,
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();
910 //virtual
911 sal_Bool SAL_CALL ContentResultSetWrapper
912 ::previous()
913 throw( SQLException,
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();
926 //virtual
927 sal_Bool SAL_CALL ContentResultSetWrapper
928 ::absolute( sal_Int32 row )
929 throw( SQLException,
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 );
942 //virtual
943 sal_Bool SAL_CALL ContentResultSetWrapper
944 ::relative( sal_Int32 rows )
945 throw( SQLException,
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 );
959 //virtual
960 sal_Bool SAL_CALL ContentResultSetWrapper
961 ::first()
962 throw( SQLException,
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();
975 //virtual
976 sal_Bool SAL_CALL ContentResultSetWrapper
977 ::last()
978 throw( SQLException,
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();
991 //virtual
992 void SAL_CALL ContentResultSetWrapper
993 ::beforeFirst()
994 throw( SQLException,
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();
1007 //virtual
1008 void SAL_CALL ContentResultSetWrapper
1009 ::afterLast()
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();
1023 //virtual
1024 sal_Bool SAL_CALL ContentResultSetWrapper
1025 ::isAfterLast()
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();
1039 //virtual
1040 sal_Bool SAL_CALL ContentResultSetWrapper
1041 ::isBeforeFirst()
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();
1055 //virtual
1056 sal_Bool SAL_CALL ContentResultSetWrapper
1057 ::isFirst()
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();
1071 //virtual
1072 sal_Bool SAL_CALL ContentResultSetWrapper
1073 ::isLast()
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();
1088 //virtual
1089 sal_Int32 SAL_CALL ContentResultSetWrapper
1090 ::getRow()
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();
1104 //virtual
1105 void SAL_CALL ContentResultSetWrapper
1106 ::refreshRow()
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();
1120 //virtual
1121 sal_Bool SAL_CALL ContentResultSetWrapper
1122 ::rowUpdated()
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();
1135 //virtual
1136 sal_Bool SAL_CALL ContentResultSetWrapper
1137 ::rowInserted()
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();
1151 //virtual
1152 sal_Bool SAL_CALL ContentResultSetWrapper
1153 ::rowDeleted()
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();
1167 //virtual
1168 Reference< XInterface > SAL_CALL ContentResultSetWrapper
1169 ::getStatement()
1170 throw( SQLException,
1171 RuntimeException, std::exception )
1173 impl_EnsureNotDisposed();
1174 //@todo ?return anything
1175 return Reference< XInterface >();
1179 // XRow methods.
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 );
1192 //virtual
1193 sal_Bool SAL_CALL ContentResultSetWrapper
1194 ::wasNull()
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();
1208 //virtual
1209 OUString SAL_CALL ContentResultSetWrapper
1210 ::getString( sal_Int32 columnIndex )
1211 throw( SQLException,
1212 RuntimeException, std::exception )
1214 XROW_GETXXX( getString );
1217 //virtual
1218 sal_Bool SAL_CALL ContentResultSetWrapper
1219 ::getBoolean( sal_Int32 columnIndex )
1220 throw( SQLException,
1221 RuntimeException, std::exception )
1223 XROW_GETXXX( getBoolean );
1226 //virtual
1227 sal_Int8 SAL_CALL ContentResultSetWrapper
1228 ::getByte( sal_Int32 columnIndex )
1229 throw( SQLException,
1230 RuntimeException, std::exception )
1232 XROW_GETXXX( getByte );
1235 //virtual
1236 sal_Int16 SAL_CALL ContentResultSetWrapper
1237 ::getShort( sal_Int32 columnIndex )
1238 throw( SQLException,
1239 RuntimeException, std::exception )
1241 XROW_GETXXX( getShort );
1244 //virtual
1245 sal_Int32 SAL_CALL ContentResultSetWrapper
1246 ::getInt( sal_Int32 columnIndex )
1247 throw( SQLException,
1248 RuntimeException, std::exception )
1250 XROW_GETXXX( getInt );
1253 //virtual
1254 sal_Int64 SAL_CALL ContentResultSetWrapper
1255 ::getLong( sal_Int32 columnIndex )
1256 throw( SQLException,
1257 RuntimeException, std::exception )
1259 XROW_GETXXX( getLong );
1262 //virtual
1263 float SAL_CALL ContentResultSetWrapper
1264 ::getFloat( sal_Int32 columnIndex )
1265 throw( SQLException,
1266 RuntimeException, std::exception )
1268 XROW_GETXXX( getFloat );
1271 //virtual
1272 double SAL_CALL ContentResultSetWrapper
1273 ::getDouble( sal_Int32 columnIndex )
1274 throw( SQLException,
1275 RuntimeException, std::exception )
1277 XROW_GETXXX( getDouble );
1280 //virtual
1281 Sequence< sal_Int8 > SAL_CALL ContentResultSetWrapper
1282 ::getBytes( sal_Int32 columnIndex )
1283 throw( SQLException,
1284 RuntimeException, std::exception )
1286 XROW_GETXXX( getBytes );
1289 //virtual
1290 Date SAL_CALL ContentResultSetWrapper
1291 ::getDate( sal_Int32 columnIndex )
1292 throw( SQLException,
1293 RuntimeException, std::exception )
1295 XROW_GETXXX( getDate );
1298 //virtual
1299 Time SAL_CALL ContentResultSetWrapper
1300 ::getTime( sal_Int32 columnIndex )
1301 throw( SQLException,
1302 RuntimeException, std::exception )
1304 XROW_GETXXX( getTime );
1307 //virtual
1308 DateTime SAL_CALL ContentResultSetWrapper
1309 ::getTimestamp( sal_Int32 columnIndex )
1310 throw( SQLException,
1311 RuntimeException, std::exception )
1313 XROW_GETXXX( getTimestamp );
1316 //virtual
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 );
1326 //virtual
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 );
1336 //virtual
1337 Any SAL_CALL ContentResultSetWrapper
1338 ::getObject( sal_Int32 columnIndex,
1339 const Reference<
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 );
1357 //virtual
1358 Reference< XRef > SAL_CALL ContentResultSetWrapper
1359 ::getRef( sal_Int32 columnIndex )
1360 throw( SQLException,
1361 RuntimeException, std::exception )
1363 XROW_GETXXX( getRef );
1366 //virtual
1367 Reference< XBlob > SAL_CALL ContentResultSetWrapper
1368 ::getBlob( sal_Int32 columnIndex )
1369 throw( SQLException,
1370 RuntimeException, std::exception )
1372 XROW_GETXXX( getBlob );
1375 //virtual
1376 Reference< XClob > SAL_CALL ContentResultSetWrapper
1377 ::getClob( sal_Int32 columnIndex )
1378 throw( SQLException,
1379 RuntimeException, std::exception )
1381 XROW_GETXXX( getClob );
1384 //virtual
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()
1412 throw()
1414 OWeakObject::acquire();
1417 void SAL_CALL ContentResultSetWrapperListener::release()
1418 throw()
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.
1439 //virtual
1440 void SAL_CALL ContentResultSetWrapperListener
1441 ::disposing( const EventObject& rEventObject )
1442 throw( RuntimeException, std::exception )
1444 if( m_pOwner )
1445 m_pOwner->impl_disposing( rEventObject );
1449 //XPropertyChangeListener methods.
1452 //virtual
1453 void SAL_CALL ContentResultSetWrapperListener
1454 ::propertyChange( const PropertyChangeEvent& rEvt )
1455 throw( RuntimeException, std::exception )
1457 if( m_pOwner )
1458 m_pOwner->impl_propertyChange( rEvt );
1462 //XVetoableChangeListener methods.
1464 //virtual
1465 void SAL_CALL ContentResultSetWrapperListener
1466 ::vetoableChange( const PropertyChangeEvent& rEvt )
1467 throw( PropertyVetoException,
1468 RuntimeException, std::exception )
1470 if( m_pOwner )
1471 m_pOwner->impl_vetoableChange( rEvt );
1474 void SAL_CALL ContentResultSetWrapperListener
1475 ::impl_OwnerDies()
1477 m_pOwner = NULL;
1480 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */