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/lang/DisposedException.hpp>
23 #include <rtl/ustring.hxx>
24 #include <osl/diagnose.h>
25 #include <cppuhelper/queryinterface.hxx>
27 using namespace com::sun::star::beans
;
28 using namespace com::sun::star::lang
;
29 using namespace com::sun::star::sdbc
;
30 using namespace com::sun::star::ucb
;
31 using namespace com::sun::star::uno
;
32 using namespace com::sun::star::util
;
33 using namespace comphelper
;
39 ContentResultSetWrapper::ContentResultSetWrapper(
40 Reference
< XResultSet
> const & xOrigin
)
41 : m_xResultSetOrigin( xOrigin
)
43 , m_bDisposed( false )
44 , m_bInDispose( false )
46 m_xMyListenerImpl
= new ContentResultSetWrapperListener( this );
48 OSL_ENSURE( m_xResultSetOrigin
.is(), "XResultSet is required" );
50 //!! call impl_init() at the end of constructor of derived class
54 void ContentResultSetWrapper::impl_init_xRowOrigin(std::unique_lock
<std::mutex
>&)
59 m_xRowOrigin
.set(m_xResultSetOrigin
, UNO_QUERY
);
60 OSL_ENSURE( m_xRowOrigin
.is(), "interface XRow is required" );
63 void ContentResultSetWrapper::impl_init_xContentAccessOrigin(std::unique_lock
<std::mutex
>&)
65 if(m_xContentAccessOrigin
.is())
68 Reference
< XContentAccess
> xOrgig( m_xResultSetOrigin
, UNO_QUERY
);
70 m_xContentAccessOrigin
= xOrgig
;
71 OSL_ENSURE( m_xContentAccessOrigin
.is(), "interface XContentAccess is required" );
75 void ContentResultSetWrapper::impl_init_xPropertySetOrigin(std::unique_lock
<std::mutex
>&)
77 if( m_xPropertySetOrigin
.is() )
80 Reference
< XPropertySet
> xOrig( m_xResultSetOrigin
, UNO_QUERY
);
82 m_xPropertySetOrigin
= xOrig
;
83 OSL_ENSURE( m_xPropertySetOrigin
.is(), "interface XPropertySet is required" );
86 void ContentResultSetWrapper::impl_init()
88 //call this at the end of constructor of derived class
91 //listen to disposing from Origin:
92 Reference
< XComponent
> xComponentOrigin( m_xResultSetOrigin
, UNO_QUERY
);
93 OSL_ENSURE( xComponentOrigin
.is(), "interface XComponent is required" );
94 xComponentOrigin
->addEventListener( static_cast< XPropertyChangeListener
* >( m_xMyListenerImpl
.get() ) );
97 ContentResultSetWrapper::~ContentResultSetWrapper()
99 //call impl_deinit() at start of destructor of derived class
102 void ContentResultSetWrapper::impl_deinit()
104 //call this at start of destructor of derived class
106 m_xMyListenerImpl
->impl_OwnerDies();
110 void ContentResultSetWrapper::impl_initPropertySetInfo(std::unique_lock
<std::mutex
>& rGuard
)
112 if( m_xPropertySetInfo
.is() )
115 impl_init_xPropertySetOrigin(rGuard
);
116 if( !m_xPropertySetOrigin
.is() )
119 Reference
< XPropertySetInfo
> xOrig
=
120 m_xPropertySetOrigin
->getPropertySetInfo();
122 m_xPropertySetInfo
= xOrig
;
125 void ContentResultSetWrapper::impl_EnsureNotDisposed(std::unique_lock
<std::mutex
>& /*rGuard*/)
128 throw DisposedException();
131 void ContentResultSetWrapper::impl_notifyPropertyChangeListeners( std::unique_lock
<std::mutex
>& rGuard
, const PropertyChangeEvent
& rEvt
)
133 // Notify listeners interested especially in the changed property.
134 OInterfaceContainerHelper4
<XPropertyChangeListener
>* pContainer
=
135 m_aPropertyChangeListeners
.getContainer( rGuard
, rEvt
.PropertyName
);
138 pContainer
->notifyEach( rGuard
, &XPropertyChangeListener::propertyChange
, rEvt
);
141 // Notify listeners interested in all properties.
142 pContainer
= m_aPropertyChangeListeners
.getContainer( rGuard
, OUString() );
145 pContainer
->notifyEach( rGuard
, &XPropertyChangeListener::propertyChange
, rEvt
);
149 void ContentResultSetWrapper::impl_notifyVetoableChangeListeners( std::unique_lock
<std::mutex
>& rGuard
, const PropertyChangeEvent
& rEvt
)
151 // Notify listeners interested especially in the changed property.
152 OInterfaceContainerHelper4
<XVetoableChangeListener
>* pContainer
=
153 m_aVetoableChangeListeners
.getContainer( rGuard
, rEvt
.PropertyName
);
156 pContainer
->notifyEach( rGuard
, &XVetoableChangeListener::vetoableChange
, rEvt
);
159 // Notify listeners interested in all properties.
160 pContainer
= m_aVetoableChangeListeners
.getContainer( rGuard
, OUString() );
163 pContainer
->notifyEach( rGuard
, &XVetoableChangeListener::vetoableChange
, rEvt
);
167 bool ContentResultSetWrapper::impl_isForwardOnly(std::unique_lock
<std::mutex
>& /*rGuard*/)
169 //m_nForwardOnly == 2 -> don't know
170 //m_nForwardOnly == 1 -> YES
171 //m_nForwardOnly == 0 -> NO
173 //@todo replace this with lines in comment
179 ReacquireableGuard aGuard( m_aMutex );
180 if( m_nForwardOnly == 2 )
183 if( !getPropertySetInfo().is() )
187 return m_nForwardOnly;
191 OUString aName("ResultSetType");
192 //find out, if we are ForwardOnly and cache the value:
194 impl_init_xPropertySetOrigin();
195 if( !m_xPropertySetOrigin.is() )
197 OSL_FAIL( "broadcaster was disposed already" );
199 return m_nForwardOnly;
203 Any aAny = m_xPropertySetOrigin->getPropertyValue( aName );
207 if( ( aAny >>= nResultSetType ) &&
208 ( nResultSetType == ResultSetType::FORWARD_ONLY ) )
213 return m_nForwardOnly;
218 // XInterface methods.
220 css::uno::Any SAL_CALL
ContentResultSetWrapper::queryInterface( const css::uno::Type
& rType
)
222 //list all interfaces inclusive baseclasses of interfaces
223 css::uno::Any aRet
= cppu::queryInterface( rType
,
224 static_cast< XComponent
* >(this),
225 static_cast< XCloseable
* >(this),
226 static_cast< XResultSetMetaDataSupplier
* >(this),
227 static_cast< XPropertySet
* >(this),
228 static_cast< XContentAccess
* >(this),
229 static_cast< XResultSet
* >(this),
230 static_cast< XRow
* >(this)
232 return aRet
.hasValue() ? aRet
: OWeakObject::queryInterface( rType
);
235 // XComponent methods.
238 void SAL_CALL
ContentResultSetWrapper::dispose()
240 std::unique_lock
aGuard(m_aMutex
);
241 impl_EnsureNotDisposed(aGuard
);
243 bool isCleared
= false;
244 if( m_bInDispose
|| m_bDisposed
)
248 if( m_xPropertySetOrigin
.is() )
254 m_xPropertySetOrigin
->removePropertyChangeListener(
255 OUString(), static_cast< XPropertyChangeListener
* >( m_xMyListenerImpl
.get() ) );
259 OSL_FAIL( "could not remove PropertyChangeListener" );
263 m_xPropertySetOrigin
->removeVetoableChangeListener(
264 OUString(), static_cast< XVetoableChangeListener
* >( m_xMyListenerImpl
.get() ) );
268 OSL_FAIL( "could not remove VetoableChangeListener" );
271 Reference
< XComponent
> xComponentOrigin( m_xResultSetOrigin
, UNO_QUERY
);
272 OSL_ENSURE( xComponentOrigin
.is(), "interface XComponent is required" );
273 xComponentOrigin
->removeEventListener( static_cast< XPropertyChangeListener
* >( m_xMyListenerImpl
.get() ) );
278 if( m_aDisposeEventListeners
.getLength(aGuard
) )
281 aEvt
.Source
= static_cast< XComponent
* >( this );
282 m_aDisposeEventListeners
.disposeAndClear( aGuard
, aEvt
);
285 if( m_aPropertyChangeListeners
.hasContainedTypes(aGuard
) )
288 aEvt
.Source
= static_cast< XPropertySet
* >( this );
289 m_aPropertyChangeListeners
.disposeAndClear( aGuard
, aEvt
);
292 if( m_aVetoableChangeListeners
.hasContainedTypes(aGuard
) )
295 aEvt
.Source
= static_cast< XPropertySet
* >( this );
296 m_aVetoableChangeListeners
.disposeAndClear( aGuard
, aEvt
);
300 m_bInDispose
= false;
305 void SAL_CALL
ContentResultSetWrapper::addEventListener( const Reference
< XEventListener
>& Listener
)
307 std::unique_lock
aGuard( m_aMutex
);
308 impl_EnsureNotDisposed(aGuard
);
310 m_aDisposeEventListeners
.addInterface( aGuard
, Listener
);
315 void SAL_CALL
ContentResultSetWrapper::removeEventListener( const Reference
< XEventListener
>& Listener
)
317 std::unique_lock
aGuard( m_aMutex
);
318 impl_EnsureNotDisposed(aGuard
);
319 m_aDisposeEventListeners
.removeInterface( aGuard
, Listener
);
323 //XCloseable methods.
326 void SAL_CALL
ContentResultSetWrapper::close()
329 std::unique_lock
aGuard( m_aMutex
);
330 impl_EnsureNotDisposed(aGuard
);
336 //XResultSetMetaDataSupplier methods.
339 Reference
< XResultSetMetaData
> SAL_CALL
ContentResultSetWrapper::getMetaData()
341 std::unique_lock
aGuard(m_aMutex
);
342 impl_EnsureNotDisposed(aGuard
);
344 if( !m_xMetaDataFromOrigin
.is() && m_xResultSetOrigin
.is() )
346 Reference
< XResultSetMetaDataSupplier
> xMetaDataSupplier(
347 m_xResultSetOrigin
, UNO_QUERY
);
349 if( xMetaDataSupplier
.is() )
353 Reference
< XResultSetMetaData
> xMetaData
354 = xMetaDataSupplier
->getMetaData();
357 m_xMetaDataFromOrigin
= xMetaData
;
360 return m_xMetaDataFromOrigin
;
364 // XPropertySet methods.
367 Reference
< XPropertySetInfo
> SAL_CALL
ContentResultSetWrapper::getPropertySetInfo()
369 std::unique_lock
aGuard( m_aMutex
);
370 return getPropertySetInfoImpl(aGuard
);
374 Reference
< XPropertySetInfo
> ContentResultSetWrapper::getPropertySetInfoImpl(std::unique_lock
<std::mutex
>& rGuard
)
376 impl_EnsureNotDisposed(rGuard
);
377 if( m_xPropertySetInfo
.is() )
378 return m_xPropertySetInfo
;
379 impl_initPropertySetInfo(rGuard
);
380 return m_xPropertySetInfo
;
384 void SAL_CALL
ContentResultSetWrapper::setPropertyValue( const OUString
& rPropertyName
, const Any
& rValue
)
386 std::unique_lock
aGuard( m_aMutex
);
387 return setPropertyValueImpl(aGuard
, rPropertyName
, rValue
);
391 void ContentResultSetWrapper::setPropertyValueImpl( std::unique_lock
<std::mutex
>& rGuard
, const OUString
& rPropertyName
, const Any
& rValue
)
393 impl_EnsureNotDisposed(rGuard
);
394 impl_init_xPropertySetOrigin(rGuard
);
395 if( !m_xPropertySetOrigin
.is() )
397 OSL_FAIL( "broadcaster was disposed already" );
398 throw UnknownPropertyException();
400 m_xPropertySetOrigin
->setPropertyValue( rPropertyName
, rValue
);
405 Any SAL_CALL
ContentResultSetWrapper::getPropertyValue( const OUString
& rPropertyName
)
407 std::unique_lock
aGuard( m_aMutex
);
408 impl_EnsureNotDisposed(aGuard
);
409 impl_init_xPropertySetOrigin(aGuard
);
410 if( !m_xPropertySetOrigin
.is() )
412 OSL_FAIL( "broadcaster was disposed already" );
413 throw UnknownPropertyException();
415 return m_xPropertySetOrigin
->getPropertyValue( rPropertyName
);
420 void SAL_CALL
ContentResultSetWrapper::addPropertyChangeListener( const OUString
& aPropertyName
, const Reference
< XPropertyChangeListener
>& xListener
)
422 std::unique_lock
aGuard( m_aMutex
);
423 impl_EnsureNotDisposed(aGuard
);
425 if( !getPropertySetInfo().is() )
427 OSL_FAIL( "broadcaster was disposed already" );
428 throw UnknownPropertyException();
431 if( !aPropertyName
.isEmpty() )
433 m_xPropertySetInfo
->getPropertyByName( aPropertyName
);
434 //throws UnknownPropertyException, if so
437 bool bNeedRegister
= !m_aPropertyChangeListeners
.hasContainedTypes(aGuard
);
438 m_aPropertyChangeListeners
.addInterface( aGuard
, aPropertyName
, xListener
);
442 impl_init_xPropertySetOrigin(aGuard
);
443 if( !m_xPropertySetOrigin
.is() )
445 OSL_FAIL( "broadcaster was disposed already" );
450 m_xPropertySetOrigin
->addPropertyChangeListener(
451 OUString(), static_cast< XPropertyChangeListener
* >( m_xMyListenerImpl
.get() ) );
455 m_aPropertyChangeListeners
.removeInterface( aGuard
, aPropertyName
, xListener
);
462 void SAL_CALL
ContentResultSetWrapper::addVetoableChangeListener( const OUString
& rPropertyName
, const Reference
< XVetoableChangeListener
>& xListener
)
464 std::unique_lock
aGuard( m_aMutex
);
465 impl_EnsureNotDisposed(aGuard
);
467 if( !getPropertySetInfo().is() )
469 OSL_FAIL( "broadcaster was disposed already" );
470 throw UnknownPropertyException();
472 if( !rPropertyName
.isEmpty() )
474 m_xPropertySetInfo
->getPropertyByName( rPropertyName
);
475 //throws UnknownPropertyException, if so
478 bool bNeedRegister
= !m_aVetoableChangeListeners
.hasContainedTypes(aGuard
);
479 m_aVetoableChangeListeners
.addInterface( aGuard
, rPropertyName
, xListener
);
483 impl_init_xPropertySetOrigin(aGuard
);
485 if( !m_xPropertySetOrigin
.is() )
487 OSL_FAIL( "broadcaster was disposed already" );
493 m_xPropertySetOrigin
->addVetoableChangeListener(
494 OUString(), static_cast< XVetoableChangeListener
* >( m_xMyListenerImpl
.get() ) );
498 m_aVetoableChangeListeners
.removeInterface( aGuard
, rPropertyName
, xListener
);
505 void SAL_CALL
ContentResultSetWrapper::removePropertyChangeListener( const OUString
& rPropertyName
, const Reference
< XPropertyChangeListener
>& xListener
)
507 std::unique_lock
aGuard( m_aMutex
);
508 impl_EnsureNotDisposed(aGuard
);
510 //noop, if no listener registered
511 if( !m_aPropertyChangeListeners
.hasContainedTypes(aGuard
) )
514 OInterfaceContainerHelper4
<XPropertyChangeListener
>* pContainer
=
515 m_aPropertyChangeListeners
.getContainer( aGuard
, rPropertyName
);
519 if( !rPropertyName
.isEmpty() )
521 if( !getPropertySetInfo().is() )
522 throw UnknownPropertyException();
524 m_xPropertySetInfo
->getPropertyByName( rPropertyName
);
525 //throws UnknownPropertyException, if so
527 return; //the listener was not registered
530 m_aPropertyChangeListeners
.removeInterface( aGuard
, rPropertyName
, xListener
);
532 if( m_aPropertyChangeListeners
.hasContainedTypes(aGuard
) )
535 impl_init_xPropertySetOrigin(aGuard
);
536 if( !m_xPropertySetOrigin
.is() )
538 OSL_FAIL( "broadcaster was disposed already" );
543 m_xPropertySetOrigin
->removePropertyChangeListener(
544 OUString(), static_cast< XPropertyChangeListener
* >( m_xMyListenerImpl
.get() ) );
548 OSL_FAIL( "could not remove PropertyChangeListener" );
554 void SAL_CALL
ContentResultSetWrapper::removeVetoableChangeListener( const OUString
& rPropertyName
, const Reference
< XVetoableChangeListener
>& xListener
)
556 std::unique_lock
aGuard( m_aMutex
);
557 impl_EnsureNotDisposed(aGuard
);
559 //noop, if no listener registered
560 if( !m_aVetoableChangeListeners
.hasContainedTypes(aGuard
) )
562 OInterfaceContainerHelper4
<XVetoableChangeListener
>* pContainer
=
563 m_aVetoableChangeListeners
.getContainer( aGuard
, rPropertyName
);
567 if( !rPropertyName
.isEmpty() )
569 if( !getPropertySetInfo().is() )
570 throw UnknownPropertyException(rPropertyName
);
572 m_xPropertySetInfo
->getPropertyByName( rPropertyName
);
573 //throws UnknownPropertyException, if so
575 return; //the listener was not registered
578 m_aVetoableChangeListeners
.removeInterface( aGuard
, rPropertyName
, xListener
);
580 if( m_aVetoableChangeListeners
.hasContainedTypes(aGuard
) )
583 impl_init_xPropertySetOrigin(aGuard
);
584 if( !m_xPropertySetOrigin
.is() )
586 OSL_FAIL( "broadcaster was disposed already" );
591 m_xPropertySetOrigin
->removeVetoableChangeListener(
592 OUString(), static_cast< XVetoableChangeListener
* >( m_xMyListenerImpl
.get() ) );
596 OSL_FAIL( "could not remove VetoableChangeListener" );
604 //virtual, only called from ContentResultSetWrapperListener
605 void ContentResultSetWrapper::impl_disposing( const EventObject
& )
607 std::unique_lock
aGuard(m_aMutex
);
609 impl_EnsureNotDisposed(aGuard
);
611 if( !m_xResultSetOrigin
.is() )
614 //release all references to the broadcaster:
615 m_xResultSetOrigin
.clear();
616 if(m_xRowOrigin
.is())
617 m_xRowOrigin
.clear();
618 if(m_xContentAccessOrigin
.is())
619 m_xContentAccessOrigin
.clear();
620 if(m_xPropertySetOrigin
.is())
621 m_xPropertySetOrigin
.clear();
622 m_xMetaDataFromOrigin
.clear();
623 if(m_xPropertySetInfo
.is())
624 m_xPropertySetInfo
.clear();
627 //virtual, only called from ContentResultSetWrapperListener
628 void ContentResultSetWrapper::impl_propertyChange( const PropertyChangeEvent
& rEvt
)
630 std::unique_lock
aGuard(m_aMutex
);
632 impl_EnsureNotDisposed(aGuard
);
634 PropertyChangeEvent
aEvt( rEvt
);
635 aEvt
.Source
= static_cast< XPropertySet
* >( this );
636 aEvt
.Further
= false;
637 impl_notifyPropertyChangeListeners( aGuard
, aEvt
);
640 //virtual, only called from ContentResultSetWrapperListener
641 void ContentResultSetWrapper::impl_vetoableChange( const PropertyChangeEvent
& rEvt
)
643 std::unique_lock
aGuard(m_aMutex
);
644 impl_EnsureNotDisposed(aGuard
);
646 PropertyChangeEvent
aEvt( rEvt
);
647 aEvt
.Source
= static_cast< XPropertySet
* >( this );
648 aEvt
.Further
= false;
650 impl_notifyVetoableChangeListeners( aGuard
, aEvt
);
654 // XContentAccess methods. ( -- position dependent )
658 OUString SAL_CALL
ContentResultSetWrapper::queryContentIdentifierString()
660 std::unique_lock
aGuard(m_aMutex
);
661 return queryContentIdentifierStringImpl(aGuard
);
664 OUString
ContentResultSetWrapper::queryContentIdentifierStringImpl(std::unique_lock
<std::mutex
>& rGuard
)
666 impl_EnsureNotDisposed(rGuard
);
667 impl_init_xContentAccessOrigin(rGuard
);
668 if( !m_xContentAccessOrigin
.is() )
670 OSL_FAIL( "broadcaster was disposed already" );
671 throw RuntimeException();
673 return m_xContentAccessOrigin
->queryContentIdentifierString();
678 Reference
< XContentIdentifier
> SAL_CALL
ContentResultSetWrapper::queryContentIdentifier()
680 std::unique_lock
aGuard(m_aMutex
);
681 impl_EnsureNotDisposed(aGuard
);
682 impl_init_xContentAccessOrigin(aGuard
);
683 if( !m_xContentAccessOrigin
.is() )
685 OSL_FAIL( "broadcaster was disposed already" );
686 throw RuntimeException();
688 return m_xContentAccessOrigin
->queryContentIdentifier();
693 Reference
< XContent
> SAL_CALL
ContentResultSetWrapper::queryContent()
695 std::unique_lock
aGuard(m_aMutex
);
696 impl_EnsureNotDisposed(aGuard
);
697 impl_init_xContentAccessOrigin(aGuard
);
698 if( !m_xContentAccessOrigin
.is() )
700 OSL_FAIL( "broadcaster was disposed already" );
701 throw RuntimeException();
703 return m_xContentAccessOrigin
->queryContent();
707 // XResultSet methods.
711 sal_Bool SAL_CALL
ContentResultSetWrapper::next()
713 std::unique_lock
aGuard(m_aMutex
);
714 impl_EnsureNotDisposed(aGuard
);
716 if( !m_xResultSetOrigin
.is() )
718 OSL_FAIL( "broadcaster was disposed already" );
719 throw RuntimeException();
721 return m_xResultSetOrigin
->next();
725 sal_Bool SAL_CALL
ContentResultSetWrapper::previous()
727 std::unique_lock
aGuard(m_aMutex
);
728 impl_EnsureNotDisposed(aGuard
);
730 if( !m_xResultSetOrigin
.is() )
732 OSL_FAIL( "broadcaster was disposed already" );
733 throw RuntimeException();
735 return m_xResultSetOrigin
->previous();
739 sal_Bool SAL_CALL
ContentResultSetWrapper::absolute( sal_Int32 row
)
741 std::unique_lock
aGuard(m_aMutex
);
742 impl_EnsureNotDisposed(aGuard
);
744 if( !m_xResultSetOrigin
.is() )
746 OSL_FAIL( "broadcaster was disposed already" );
747 throw RuntimeException();
749 return m_xResultSetOrigin
->absolute( row
);
753 sal_Bool SAL_CALL
ContentResultSetWrapper::relative( sal_Int32 rows
)
755 std::unique_lock
aGuard(m_aMutex
);
756 impl_EnsureNotDisposed(aGuard
);
758 if( !m_xResultSetOrigin
.is() )
760 OSL_FAIL( "broadcaster was disposed already" );
761 throw RuntimeException();
763 return m_xResultSetOrigin
->relative( rows
);
768 sal_Bool SAL_CALL
ContentResultSetWrapper::first()
770 std::unique_lock
aGuard(m_aMutex
);
771 impl_EnsureNotDisposed(aGuard
);
773 if( !m_xResultSetOrigin
.is() )
775 OSL_FAIL( "broadcaster was disposed already" );
776 throw RuntimeException();
778 return m_xResultSetOrigin
->first();
782 sal_Bool SAL_CALL
ContentResultSetWrapper::last()
784 std::unique_lock
aGuard(m_aMutex
);
785 impl_EnsureNotDisposed(aGuard
);
787 if( !m_xResultSetOrigin
.is() )
789 OSL_FAIL( "broadcaster was disposed already" );
790 throw RuntimeException();
792 return m_xResultSetOrigin
->last();
796 void SAL_CALL
ContentResultSetWrapper::beforeFirst()
798 std::unique_lock
aGuard(m_aMutex
);
799 impl_EnsureNotDisposed(aGuard
);
801 if( !m_xResultSetOrigin
.is() )
803 OSL_FAIL( "broadcaster was disposed already" );
804 throw RuntimeException();
806 m_xResultSetOrigin
->beforeFirst();
810 void SAL_CALL
ContentResultSetWrapper::afterLast()
812 std::unique_lock
aGuard(m_aMutex
);
813 impl_EnsureNotDisposed(aGuard
);
815 if( !m_xResultSetOrigin
.is() )
817 OSL_FAIL( "broadcaster was disposed already" );
818 throw RuntimeException();
820 m_xResultSetOrigin
->afterLast();
824 sal_Bool SAL_CALL
ContentResultSetWrapper::isAfterLast()
826 std::unique_lock
aGuard(m_aMutex
);
827 impl_EnsureNotDisposed(aGuard
);
829 if( !m_xResultSetOrigin
.is() )
831 OSL_FAIL( "broadcaster was disposed already" );
832 throw RuntimeException();
834 return m_xResultSetOrigin
->isAfterLast();
838 sal_Bool SAL_CALL
ContentResultSetWrapper::isBeforeFirst()
840 std::unique_lock
aGuard(m_aMutex
);
841 impl_EnsureNotDisposed(aGuard
);
843 if( !m_xResultSetOrigin
.is() )
845 OSL_FAIL( "broadcaster was disposed already" );
846 throw RuntimeException();
848 return m_xResultSetOrigin
->isBeforeFirst();
852 sal_Bool SAL_CALL
ContentResultSetWrapper::isFirst()
854 std::unique_lock
aGuard(m_aMutex
);
855 impl_EnsureNotDisposed(aGuard
);
857 if( !m_xResultSetOrigin
.is() )
859 OSL_FAIL( "broadcaster was disposed already" );
860 throw RuntimeException();
862 return m_xResultSetOrigin
->isFirst();
866 sal_Bool SAL_CALL
ContentResultSetWrapper::isLast()
868 std::unique_lock
aGuard(m_aMutex
);
869 impl_EnsureNotDisposed(aGuard
);
871 if( !m_xResultSetOrigin
.is() )
873 OSL_FAIL( "broadcaster was disposed already" );
874 throw RuntimeException();
876 return m_xResultSetOrigin
->isLast();
881 sal_Int32 SAL_CALL
ContentResultSetWrapper::getRow()
883 std::unique_lock
aGuard(m_aMutex
);
884 impl_EnsureNotDisposed(aGuard
);
886 if( !m_xResultSetOrigin
.is() )
888 OSL_FAIL( "broadcaster was disposed already" );
889 throw RuntimeException();
891 return m_xResultSetOrigin
->getRow();
895 void SAL_CALL
ContentResultSetWrapper::refreshRow()
897 std::unique_lock
aGuard(m_aMutex
);
898 impl_EnsureNotDisposed(aGuard
);
900 if( !m_xResultSetOrigin
.is() )
902 OSL_FAIL( "broadcaster was disposed already" );
903 throw RuntimeException();
905 m_xResultSetOrigin
->refreshRow();
909 sal_Bool SAL_CALL
ContentResultSetWrapper::rowUpdated()
911 std::unique_lock
aGuard(m_aMutex
);
912 impl_EnsureNotDisposed(aGuard
);
914 if( !m_xResultSetOrigin
.is() )
916 OSL_FAIL( "broadcaster was disposed already" );
917 throw RuntimeException();
919 return m_xResultSetOrigin
->rowUpdated();
923 sal_Bool SAL_CALL
ContentResultSetWrapper::rowInserted()
925 std::unique_lock
aGuard(m_aMutex
);
926 impl_EnsureNotDisposed(aGuard
);
928 if( !m_xResultSetOrigin
.is() )
930 OSL_FAIL( "broadcaster was disposed already" );
931 throw RuntimeException();
933 return m_xResultSetOrigin
->rowInserted();
937 sal_Bool SAL_CALL
ContentResultSetWrapper::rowDeleted()
939 std::unique_lock
aGuard(m_aMutex
);
940 impl_EnsureNotDisposed(aGuard
);
942 if( !m_xResultSetOrigin
.is() )
944 OSL_FAIL( "broadcaster was disposed already" );
945 throw RuntimeException();
947 return m_xResultSetOrigin
->rowDeleted();
951 Reference
< XInterface
> SAL_CALL
ContentResultSetWrapper::getStatement()
953 std::unique_lock
aGuard(m_aMutex
);
954 impl_EnsureNotDisposed(aGuard
);
955 //@todo ?return anything
956 return Reference
< XInterface
>();
963 void ContentResultSetWrapper::verifyGet()
965 std::unique_lock
aGuard(m_aMutex
);
966 impl_EnsureNotDisposed(aGuard
);
967 impl_init_xRowOrigin(aGuard
);
968 if( !m_xRowOrigin
.is() )
970 OSL_FAIL( "broadcaster was disposed already" );
971 throw RuntimeException();
976 sal_Bool SAL_CALL
ContentResultSetWrapper::wasNull()
978 std::unique_lock
aGuard(m_aMutex
);
979 impl_EnsureNotDisposed(aGuard
);
980 impl_init_xRowOrigin(aGuard
);
981 if( !m_xRowOrigin
.is() )
983 OSL_FAIL( "broadcaster was disposed already" );
984 throw RuntimeException();
986 return m_xRowOrigin
->wasNull();
990 OUString SAL_CALL
ContentResultSetWrapper::getString( sal_Int32 columnIndex
)
993 return m_xRowOrigin
->getString( columnIndex
);
997 sal_Bool SAL_CALL
ContentResultSetWrapper::getBoolean( sal_Int32 columnIndex
)
1000 return m_xRowOrigin
->getBoolean( columnIndex
);
1004 sal_Int8 SAL_CALL
ContentResultSetWrapper::getByte( sal_Int32 columnIndex
)
1007 return m_xRowOrigin
->getByte( columnIndex
);
1011 sal_Int16 SAL_CALL
ContentResultSetWrapper::getShort( sal_Int32 columnIndex
)
1014 return m_xRowOrigin
->getShort( columnIndex
);
1018 sal_Int32 SAL_CALL
ContentResultSetWrapper::getInt( sal_Int32 columnIndex
)
1021 return m_xRowOrigin
->getInt( columnIndex
);
1025 sal_Int64 SAL_CALL
ContentResultSetWrapper::getLong( sal_Int32 columnIndex
)
1028 return m_xRowOrigin
->getLong( columnIndex
);
1032 float SAL_CALL
ContentResultSetWrapper::getFloat( sal_Int32 columnIndex
)
1035 return m_xRowOrigin
->getFloat( columnIndex
);
1039 double SAL_CALL
ContentResultSetWrapper::getDouble( sal_Int32 columnIndex
)
1042 return m_xRowOrigin
->getDouble( columnIndex
);
1046 Sequence
< sal_Int8
> SAL_CALL
ContentResultSetWrapper::getBytes( sal_Int32 columnIndex
)
1049 return m_xRowOrigin
->getBytes( columnIndex
);
1053 Date SAL_CALL
ContentResultSetWrapper::getDate( sal_Int32 columnIndex
)
1056 return m_xRowOrigin
->getDate( columnIndex
);
1060 Time SAL_CALL
ContentResultSetWrapper::getTime( sal_Int32 columnIndex
)
1063 return m_xRowOrigin
->getTime( columnIndex
);
1067 DateTime SAL_CALL
ContentResultSetWrapper::getTimestamp( sal_Int32 columnIndex
)
1070 return m_xRowOrigin
->getTimestamp( columnIndex
);
1074 Reference
< css::io::XInputStream
> SAL_CALL
ContentResultSetWrapper::getBinaryStream( sal_Int32 columnIndex
)
1077 return m_xRowOrigin
->getBinaryStream( columnIndex
);
1081 Reference
< css::io::XInputStream
> SAL_CALL
ContentResultSetWrapper::getCharacterStream( sal_Int32 columnIndex
)
1084 return m_xRowOrigin
->getCharacterStream( columnIndex
);
1088 Any SAL_CALL
ContentResultSetWrapper::getObject( sal_Int32 columnIndex
, const Reference
< css::container::XNameAccess
>& typeMap
)
1090 //if you change this macro please pay attention to
1091 //define XROW_GETXXX, where this is similar implemented
1093 std::unique_lock
aGuard(m_aMutex
);
1094 impl_EnsureNotDisposed(aGuard
);
1095 impl_init_xRowOrigin(aGuard
);
1096 if( !m_xRowOrigin
.is() )
1098 OSL_FAIL( "broadcaster was disposed already" );
1099 throw RuntimeException();
1101 return m_xRowOrigin
->getObject( columnIndex
, typeMap
);
1105 Reference
< XRef
> SAL_CALL
ContentResultSetWrapper::getRef( sal_Int32 columnIndex
)
1108 return m_xRowOrigin
->getRef( columnIndex
);
1112 Reference
< XBlob
> SAL_CALL
ContentResultSetWrapper::getBlob( sal_Int32 columnIndex
)
1115 return m_xRowOrigin
->getBlob( columnIndex
);
1119 Reference
< XClob
> SAL_CALL
ContentResultSetWrapper::getClob( sal_Int32 columnIndex
)
1122 return m_xRowOrigin
->getClob( columnIndex
);
1126 Reference
< XArray
> SAL_CALL
ContentResultSetWrapper::getArray( sal_Int32 columnIndex
)
1129 return m_xRowOrigin
->getArray( columnIndex
);
1135 ContentResultSetWrapperListener::ContentResultSetWrapperListener(
1136 ContentResultSetWrapper
* pOwner
)
1137 : m_pOwner( pOwner
)
1141 ContentResultSetWrapperListener::~ContentResultSetWrapperListener()
1146 // XInterface methods.
1147 void SAL_CALL
ContentResultSetWrapperListener::acquire()
1150 OWeakObject::acquire();
1153 void SAL_CALL
ContentResultSetWrapperListener::release()
1156 OWeakObject::release();
1159 css::uno::Any SAL_CALL
ContentResultSetWrapperListener::queryInterface( const css::uno::Type
& rType
)
1161 //list all interfaces inclusive baseclasses of interfaces
1162 css::uno::Any aRet
= cppu::queryInterface( rType
,
1163 static_cast< XEventListener
* >(
1164 static_cast< XPropertyChangeListener
* >(this)),
1165 static_cast< XPropertyChangeListener
* >(this),
1166 static_cast< XVetoableChangeListener
* >(this)
1168 return aRet
.hasValue() ? aRet
: OWeakObject::queryInterface( rType
);
1171 //XEventListener methods.
1175 void SAL_CALL
ContentResultSetWrapperListener::disposing( const EventObject
& rEventObject
)
1178 m_pOwner
->impl_disposing( rEventObject
);
1182 //XPropertyChangeListener methods.
1186 void SAL_CALL
ContentResultSetWrapperListener::propertyChange( const PropertyChangeEvent
& rEvt
)
1189 m_pOwner
->impl_propertyChange( rEvt
);
1193 //XVetoableChangeListener methods.
1196 void SAL_CALL
ContentResultSetWrapperListener::vetoableChange( const PropertyChangeEvent
& rEvt
)
1199 m_pOwner
->impl_vetoableChange( rEvt
);
1202 void ContentResultSetWrapperListener::impl_OwnerDies()
1207 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */