fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / ucb / source / cacher / contentresultsetwrapper.cxx
blob14fa320cc8d946d93a1e8289680a05836188782f
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;
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 )
52 , m_nForwardOnly( 2 )
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 );
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 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 );
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;
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 //--------------------------------------------------------------------------
358 // virtual
359 void SAL_CALL ContentResultSetWrapper
360 ::dispose() throw( RuntimeException )
362 impl_EnsureNotDisposed();
364 ReacquireableGuard aGuard( m_aMutex );
365 if( m_bInDispose || m_bDisposed )
366 return;
367 m_bInDispose = sal_True;
369 if( m_xPropertySetOrigin.is() )
371 aGuard.clear();
374 m_xPropertySetOrigin->removePropertyChangeListener(
375 OUString(), static_cast< XPropertyChangeListener * >( m_pMyListenerImpl ) );
377 catch( Exception& )
379 OSL_FAIL( "could not remove PropertyChangeListener" );
383 m_xPropertySetOrigin->removeVetoableChangeListener(
384 OUString(), static_cast< XVetoableChangeListener * >( m_pMyListenerImpl ) );
386 catch( Exception& )
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 ) );
396 aGuard.reacquire();
397 if( m_pDisposeEventListeners && m_pDisposeEventListeners->getLength() )
399 EventObject aEvt;
400 aEvt.Source = static_cast< XComponent * >( this );
402 aGuard.clear();
403 m_pDisposeEventListeners->disposeAndClear( aEvt );
406 aGuard.reacquire();
407 if( m_pPropertyChangeListeners )
409 EventObject aEvt;
410 aEvt.Source = static_cast< XPropertySet * >( this );
412 aGuard.clear();
413 m_pPropertyChangeListeners->disposeAndClear( aEvt );
416 aGuard.reacquire();
417 if( m_pVetoableChangeListeners )
419 EventObject aEvt;
420 aEvt.Source = static_cast< XPropertySet * >( this );
422 aGuard.clear();
423 m_pVetoableChangeListeners->disposeAndClear( aEvt );
426 aGuard.reacquire();
427 m_bDisposed = sal_True;
428 m_bInDispose = sal_False;
431 //--------------------------------------------------------------------------
432 // virtual
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 //--------------------------------------------------------------------------
448 // virtual
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 //--------------------------------------------------------------------------
463 //virtual
464 void SAL_CALL ContentResultSetWrapper
465 ::close()
466 throw( SQLException,
467 RuntimeException )
469 impl_EnsureNotDisposed();
470 dispose();
473 //--------------------------------------------------------------------------
474 //XResultSetMetaDataSupplier methods.
475 //--------------------------------------------------------------------------
476 //virtual
477 Reference< XResultSetMetaData > SAL_CALL ContentResultSetWrapper
478 ::getMetaData()
479 throw( SQLException,
480 RuntimeException )
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() )
493 aGuard.clear();
495 Reference< XResultSetMetaData > xMetaData
496 = xMetaDataSupplier->getMetaData();
498 aGuard.reacquire();
499 m_xMetaDataFromOrigin = xMetaData;
502 return m_xMetaDataFromOrigin;
506 //--------------------------------------------------------------------------
507 // XPropertySet methods.
508 //--------------------------------------------------------------------------
509 // virtual
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 //--------------------------------------------------------------------------
523 // virtual
524 void SAL_CALL ContentResultSetWrapper
525 ::setPropertyValue( const OUString& rPropertyName, const Any& rValue )
526 throw( UnknownPropertyException,
527 PropertyVetoException,
528 IllegalArgumentException,
529 WrappedTargetException,
530 RuntimeException )
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 //--------------------------------------------------------------------------
543 // virtual
544 Any SAL_CALL ContentResultSetWrapper
545 ::getPropertyValue( const OUString& rPropertyName )
546 throw( UnknownPropertyException,
547 WrappedTargetException,
548 RuntimeException )
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 //--------------------------------------------------------------------------
561 // virtual
562 void SAL_CALL ContentResultSetWrapper
563 ::addPropertyChangeListener(
564 const OUString& aPropertyName,
565 const Reference< XPropertyChangeListener >& xListener )
566 throw( UnknownPropertyException,
567 WrappedTargetException,
568 RuntimeException )
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 );
588 if( bNeedRegister )
590 impl_init_xPropertySetOrigin();
592 osl::Guard< osl::Mutex > aGuard( m_aMutex );
593 if( !m_xPropertySetOrigin.is() )
595 OSL_FAIL( "broadcaster was disposed already" );
596 return;
601 m_xPropertySetOrigin->addPropertyChangeListener(
602 OUString(), static_cast< XPropertyChangeListener * >( m_pMyListenerImpl ) );
604 catch( Exception& )
606 m_pPropertyChangeListeners->removeInterface( aPropertyName, xListener );
607 throw;
612 //--------------------------------------------------------------------------
613 // virtual
614 void SAL_CALL ContentResultSetWrapper
615 ::addVetoableChangeListener(
616 const OUString& rPropertyName,
617 const Reference< XVetoableChangeListener >& xListener )
618 throw( UnknownPropertyException,
619 WrappedTargetException,
620 RuntimeException )
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 );
639 if( bNeedRegister )
641 impl_init_xPropertySetOrigin();
643 osl::Guard< osl::Mutex > aGuard( m_aMutex );
644 if( !m_xPropertySetOrigin.is() )
646 OSL_FAIL( "broadcaster was disposed already" );
647 return;
652 m_xPropertySetOrigin->addVetoableChangeListener(
653 OUString(), static_cast< XVetoableChangeListener * >( m_pMyListenerImpl ) );
655 catch( Exception& )
657 m_pVetoableChangeListeners->removeInterface( rPropertyName, xListener );
658 throw;
663 //--------------------------------------------------------------------------
664 // virtual
665 void SAL_CALL ContentResultSetWrapper
666 ::removePropertyChangeListener(
667 const OUString& rPropertyName,
668 const Reference< XPropertyChangeListener >& xListener )
669 throw( UnknownPropertyException,
670 WrappedTargetException,
671 RuntimeException )
673 impl_EnsureNotDisposed();
676 //noop, if no listener registered
677 osl::Guard< osl::Mutex > aGuard( m_aMutex );
678 if( !m_pPropertyChangeListeners )
679 return;
681 OInterfaceContainerHelper* pContainer =
682 m_pPropertyChangeListeners->getContainer( rPropertyName );
684 if( !pContainer )
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" );
707 return;
712 m_xPropertySetOrigin->removePropertyChangeListener(
713 OUString(), static_cast< XPropertyChangeListener * >( m_pMyListenerImpl ) );
715 catch( Exception& )
717 OSL_FAIL( "could not remove PropertyChangeListener" );
722 //--------------------------------------------------------------------------
723 // virtual
724 void SAL_CALL ContentResultSetWrapper
725 ::removeVetoableChangeListener(
726 const OUString& rPropertyName,
727 const Reference< XVetoableChangeListener >& xListener )
728 throw( UnknownPropertyException,
729 WrappedTargetException,
730 RuntimeException )
732 impl_EnsureNotDisposed();
735 //noop, if no listener registered
736 osl::Guard< osl::Mutex > aGuard( m_aMutex );
737 if( !m_pVetoableChangeListeners )
738 return;
740 OInterfaceContainerHelper* pContainer =
741 m_pVetoableChangeListeners->getContainer( rPropertyName );
743 if( !pContainer )
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" );
766 return;
771 m_xPropertySetOrigin->removeVetoableChangeListener(
772 OUString(), static_cast< XVetoableChangeListener * >( m_pMyListenerImpl ) );
774 catch( Exception& )
776 OSL_FAIL( "could not remove VetoableChangeListener" );
781 //--------------------------------------------------------------------------
782 // own methods.
783 //--------------------------------------------------------------------------
785 //virtual
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() )
795 return;
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();
810 //virtual
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 );
823 //virtual
824 void SAL_CALL ContentResultSetWrapper
825 ::impl_vetoableChange( const PropertyChangeEvent& rEvt )
826 throw( PropertyVetoException,
827 RuntimeException )
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 //--------------------------------------------------------------------------
842 // virtual
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 //--------------------------------------------------------------------------
858 // virtual
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 //--------------------------------------------------------------------------
874 // virtual
875 Reference< XContent > SAL_CALL ContentResultSetWrapper
876 ::queryContent()
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 //-----------------------------------------------------------------
892 //virtual
894 sal_Bool SAL_CALL ContentResultSetWrapper
895 ::next()
896 throw( SQLException,
897 RuntimeException )
899 impl_EnsureNotDisposed();
901 if( !m_xResultSetOrigin.is() )
903 OSL_FAIL( "broadcaster was disposed already" );
904 throw RuntimeException();
906 return m_xResultSetOrigin->next();
909 //virtual
910 sal_Bool SAL_CALL ContentResultSetWrapper
911 ::previous()
912 throw( SQLException,
913 RuntimeException )
915 impl_EnsureNotDisposed();
917 if( !m_xResultSetOrigin.is() )
919 OSL_FAIL( "broadcaster was disposed already" );
920 throw RuntimeException();
922 return m_xResultSetOrigin->previous();
925 //virtual
926 sal_Bool SAL_CALL ContentResultSetWrapper
927 ::absolute( sal_Int32 row )
928 throw( SQLException,
929 RuntimeException )
931 impl_EnsureNotDisposed();
933 if( !m_xResultSetOrigin.is() )
935 OSL_FAIL( "broadcaster was disposed already" );
936 throw RuntimeException();
938 return m_xResultSetOrigin->absolute( row );
941 //virtual
942 sal_Bool SAL_CALL ContentResultSetWrapper
943 ::relative( sal_Int32 rows )
944 throw( SQLException,
945 RuntimeException )
947 impl_EnsureNotDisposed();
949 if( !m_xResultSetOrigin.is() )
951 OSL_FAIL( "broadcaster was disposed already" );
952 throw RuntimeException();
954 return m_xResultSetOrigin->relative( rows );
958 //virtual
959 sal_Bool SAL_CALL ContentResultSetWrapper
960 ::first()
961 throw( SQLException,
962 RuntimeException )
964 impl_EnsureNotDisposed();
966 if( !m_xResultSetOrigin.is() )
968 OSL_FAIL( "broadcaster was disposed already" );
969 throw RuntimeException();
971 return m_xResultSetOrigin->first();
974 //virtual
975 sal_Bool SAL_CALL ContentResultSetWrapper
976 ::last()
977 throw( SQLException,
978 RuntimeException )
980 impl_EnsureNotDisposed();
982 if( !m_xResultSetOrigin.is() )
984 OSL_FAIL( "broadcaster was disposed already" );
985 throw RuntimeException();
987 return m_xResultSetOrigin->last();
990 //virtual
991 void SAL_CALL ContentResultSetWrapper
992 ::beforeFirst()
993 throw( SQLException,
994 RuntimeException )
996 impl_EnsureNotDisposed();
998 if( !m_xResultSetOrigin.is() )
1000 OSL_FAIL( "broadcaster was disposed already" );
1001 throw RuntimeException();
1003 m_xResultSetOrigin->beforeFirst();
1006 //virtual
1007 void SAL_CALL ContentResultSetWrapper
1008 ::afterLast()
1009 throw( SQLException,
1010 RuntimeException )
1012 impl_EnsureNotDisposed();
1014 if( !m_xResultSetOrigin.is() )
1016 OSL_FAIL( "broadcaster was disposed already" );
1017 throw RuntimeException();
1019 m_xResultSetOrigin->afterLast();
1022 //virtual
1023 sal_Bool SAL_CALL ContentResultSetWrapper
1024 ::isAfterLast()
1025 throw( SQLException,
1026 RuntimeException )
1028 impl_EnsureNotDisposed();
1030 if( !m_xResultSetOrigin.is() )
1032 OSL_FAIL( "broadcaster was disposed already" );
1033 throw RuntimeException();
1035 return m_xResultSetOrigin->isAfterLast();
1038 //virtual
1039 sal_Bool SAL_CALL ContentResultSetWrapper
1040 ::isBeforeFirst()
1041 throw( SQLException,
1042 RuntimeException )
1044 impl_EnsureNotDisposed();
1046 if( !m_xResultSetOrigin.is() )
1048 OSL_FAIL( "broadcaster was disposed already" );
1049 throw RuntimeException();
1051 return m_xResultSetOrigin->isBeforeFirst();
1054 //virtual
1055 sal_Bool SAL_CALL ContentResultSetWrapper
1056 ::isFirst()
1057 throw( SQLException,
1058 RuntimeException )
1060 impl_EnsureNotDisposed();
1062 if( !m_xResultSetOrigin.is() )
1064 OSL_FAIL( "broadcaster was disposed already" );
1065 throw RuntimeException();
1067 return m_xResultSetOrigin->isFirst();
1070 //virtual
1071 sal_Bool SAL_CALL ContentResultSetWrapper
1072 ::isLast()
1073 throw( SQLException,
1074 RuntimeException )
1076 impl_EnsureNotDisposed();
1078 if( !m_xResultSetOrigin.is() )
1080 OSL_FAIL( "broadcaster was disposed already" );
1081 throw RuntimeException();
1083 return m_xResultSetOrigin->isLast();
1087 //virtual
1088 sal_Int32 SAL_CALL ContentResultSetWrapper
1089 ::getRow()
1090 throw( SQLException,
1091 RuntimeException )
1093 impl_EnsureNotDisposed();
1095 if( !m_xResultSetOrigin.is() )
1097 OSL_FAIL( "broadcaster was disposed already" );
1098 throw RuntimeException();
1100 return m_xResultSetOrigin->getRow();
1103 //virtual
1104 void SAL_CALL ContentResultSetWrapper
1105 ::refreshRow()
1106 throw( SQLException,
1107 RuntimeException )
1109 impl_EnsureNotDisposed();
1111 if( !m_xResultSetOrigin.is() )
1113 OSL_FAIL( "broadcaster was disposed already" );
1114 throw RuntimeException();
1116 m_xResultSetOrigin->refreshRow();
1119 //virtual
1120 sal_Bool SAL_CALL ContentResultSetWrapper
1121 ::rowUpdated()
1122 throw( SQLException,
1123 RuntimeException )
1125 impl_EnsureNotDisposed();
1127 if( !m_xResultSetOrigin.is() )
1129 OSL_FAIL( "broadcaster was disposed already" );
1130 throw RuntimeException();
1132 return m_xResultSetOrigin->rowUpdated();
1134 //virtual
1135 sal_Bool SAL_CALL ContentResultSetWrapper
1136 ::rowInserted()
1137 throw( SQLException,
1138 RuntimeException )
1140 impl_EnsureNotDisposed();
1142 if( !m_xResultSetOrigin.is() )
1144 OSL_FAIL( "broadcaster was disposed already" );
1145 throw RuntimeException();
1147 return m_xResultSetOrigin->rowInserted();
1150 //virtual
1151 sal_Bool SAL_CALL ContentResultSetWrapper
1152 ::rowDeleted()
1153 throw( SQLException,
1154 RuntimeException )
1156 impl_EnsureNotDisposed();
1158 if( !m_xResultSetOrigin.is() )
1160 OSL_FAIL( "broadcaster was disposed already" );
1161 throw RuntimeException();
1163 return m_xResultSetOrigin->rowDeleted();
1166 //virtual
1167 Reference< XInterface > SAL_CALL ContentResultSetWrapper
1168 ::getStatement()
1169 throw( SQLException,
1170 RuntimeException )
1172 impl_EnsureNotDisposed();
1173 //@todo ?return anything
1174 return Reference< XInterface >();
1177 //-----------------------------------------------------------------
1178 // XRow methods.
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 );
1191 //virtual
1192 sal_Bool SAL_CALL ContentResultSetWrapper
1193 ::wasNull()
1194 throw( SQLException,
1195 RuntimeException )
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();
1207 //virtual
1208 OUString SAL_CALL ContentResultSetWrapper
1209 ::getString( sal_Int32 columnIndex )
1210 throw( SQLException,
1211 RuntimeException )
1213 XROW_GETXXX( getString );
1216 //virtual
1217 sal_Bool SAL_CALL ContentResultSetWrapper
1218 ::getBoolean( sal_Int32 columnIndex )
1219 throw( SQLException,
1220 RuntimeException )
1222 XROW_GETXXX( getBoolean );
1225 //virtual
1226 sal_Int8 SAL_CALL ContentResultSetWrapper
1227 ::getByte( sal_Int32 columnIndex )
1228 throw( SQLException,
1229 RuntimeException )
1231 XROW_GETXXX( getByte );
1234 //virtual
1235 sal_Int16 SAL_CALL ContentResultSetWrapper
1236 ::getShort( sal_Int32 columnIndex )
1237 throw( SQLException,
1238 RuntimeException )
1240 XROW_GETXXX( getShort );
1243 //virtual
1244 sal_Int32 SAL_CALL ContentResultSetWrapper
1245 ::getInt( sal_Int32 columnIndex )
1246 throw( SQLException,
1247 RuntimeException )
1249 XROW_GETXXX( getInt );
1252 //virtual
1253 sal_Int64 SAL_CALL ContentResultSetWrapper
1254 ::getLong( sal_Int32 columnIndex )
1255 throw( SQLException,
1256 RuntimeException )
1258 XROW_GETXXX( getLong );
1261 //virtual
1262 float SAL_CALL ContentResultSetWrapper
1263 ::getFloat( sal_Int32 columnIndex )
1264 throw( SQLException,
1265 RuntimeException )
1267 XROW_GETXXX( getFloat );
1270 //virtual
1271 double SAL_CALL ContentResultSetWrapper
1272 ::getDouble( sal_Int32 columnIndex )
1273 throw( SQLException,
1274 RuntimeException )
1276 XROW_GETXXX( getDouble );
1279 //virtual
1280 Sequence< sal_Int8 > SAL_CALL ContentResultSetWrapper
1281 ::getBytes( sal_Int32 columnIndex )
1282 throw( SQLException,
1283 RuntimeException )
1285 XROW_GETXXX( getBytes );
1288 //virtual
1289 Date SAL_CALL ContentResultSetWrapper
1290 ::getDate( sal_Int32 columnIndex )
1291 throw( SQLException,
1292 RuntimeException )
1294 XROW_GETXXX( getDate );
1297 //virtual
1298 Time SAL_CALL ContentResultSetWrapper
1299 ::getTime( sal_Int32 columnIndex )
1300 throw( SQLException,
1301 RuntimeException )
1303 XROW_GETXXX( getTime );
1306 //virtual
1307 DateTime SAL_CALL ContentResultSetWrapper
1308 ::getTimestamp( sal_Int32 columnIndex )
1309 throw( SQLException,
1310 RuntimeException )
1312 XROW_GETXXX( getTimestamp );
1315 //virtual
1316 Reference< com::sun::star::io::XInputStream >
1317 SAL_CALL ContentResultSetWrapper
1318 ::getBinaryStream( sal_Int32 columnIndex )
1319 throw( SQLException,
1320 RuntimeException )
1322 XROW_GETXXX( getBinaryStream );
1325 //virtual
1326 Reference< com::sun::star::io::XInputStream >
1327 SAL_CALL ContentResultSetWrapper
1328 ::getCharacterStream( sal_Int32 columnIndex )
1329 throw( SQLException,
1330 RuntimeException )
1332 XROW_GETXXX( getCharacterStream );
1335 //virtual
1336 Any SAL_CALL ContentResultSetWrapper
1337 ::getObject( sal_Int32 columnIndex,
1338 const Reference<
1339 com::sun::star::container::XNameAccess >& typeMap )
1340 throw( SQLException,
1341 RuntimeException )
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 );
1356 //virtual
1357 Reference< XRef > SAL_CALL ContentResultSetWrapper
1358 ::getRef( sal_Int32 columnIndex )
1359 throw( SQLException,
1360 RuntimeException )
1362 XROW_GETXXX( getRef );
1365 //virtual
1366 Reference< XBlob > SAL_CALL ContentResultSetWrapper
1367 ::getBlob( sal_Int32 columnIndex )
1368 throw( SQLException,
1369 RuntimeException )
1371 XROW_GETXXX( getBlob );
1374 //virtual
1375 Reference< XClob > SAL_CALL ContentResultSetWrapper
1376 ::getClob( sal_Int32 columnIndex )
1377 throw( SQLException,
1378 RuntimeException )
1380 XROW_GETXXX( getClob );
1383 //virtual
1384 Reference< XArray > SAL_CALL ContentResultSetWrapper
1385 ::getArray( sal_Int32 columnIndex )
1386 throw( SQLException,
1387 RuntimeException )
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 //--------------------------------------------------------------------------
1427 //virtual
1428 void SAL_CALL ContentResultSetWrapperListener
1429 ::disposing( const EventObject& rEventObject )
1430 throw( RuntimeException )
1432 if( m_pOwner )
1433 m_pOwner->impl_disposing( rEventObject );
1436 //--------------------------------------------------------------------------
1437 //XPropertyChangeListener methods.
1438 //--------------------------------------------------------------------------
1440 //virtual
1441 void SAL_CALL ContentResultSetWrapperListener
1442 ::propertyChange( const PropertyChangeEvent& rEvt )
1443 throw( RuntimeException )
1445 if( m_pOwner )
1446 m_pOwner->impl_propertyChange( rEvt );
1449 //--------------------------------------------------------------------------
1450 //XVetoableChangeListener methods.
1451 //--------------------------------------------------------------------------
1452 //virtual
1453 void SAL_CALL ContentResultSetWrapperListener
1454 ::vetoableChange( const PropertyChangeEvent& rEvt )
1455 throw( PropertyVetoException,
1456 RuntimeException )
1458 if( m_pOwner )
1459 m_pOwner->impl_vetoableChange( rEvt );
1462 void SAL_CALL ContentResultSetWrapperListener
1463 ::impl_OwnerDies()
1465 m_pOwner = NULL;
1468 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */