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 Reference
< XRow
> xOrgig( m_xResultSetOrigin
, UNO_QUERY
);
60 m_xRowOrigin
= xOrgig
;
61 OSL_ENSURE( m_xRowOrigin
.is(), "interface XRow is required" );
64 void ContentResultSetWrapper::impl_init_xContentAccessOrigin(std::unique_lock
<std::mutex
>&)
66 if(m_xContentAccessOrigin
.is())
69 Reference
< XContentAccess
> xOrgig( m_xResultSetOrigin
, UNO_QUERY
);
71 m_xContentAccessOrigin
= xOrgig
;
72 OSL_ENSURE( m_xContentAccessOrigin
.is(), "interface XContentAccess is required" );
76 void ContentResultSetWrapper::impl_init_xPropertySetOrigin(std::unique_lock
<std::mutex
>&)
78 if( m_xPropertySetOrigin
.is() )
81 Reference
< XPropertySet
> xOrig( m_xResultSetOrigin
, UNO_QUERY
);
83 m_xPropertySetOrigin
= xOrig
;
84 OSL_ENSURE( m_xPropertySetOrigin
.is(), "interface XPropertySet is required" );
87 void ContentResultSetWrapper::impl_init()
89 //call this at the end of constructor of derived class
92 //listen to disposing from Origin:
93 Reference
< XComponent
> xComponentOrigin( m_xResultSetOrigin
, UNO_QUERY
);
94 OSL_ENSURE( xComponentOrigin
.is(), "interface XComponent is required" );
95 xComponentOrigin
->addEventListener( static_cast< XPropertyChangeListener
* >( m_xMyListenerImpl
.get() ) );
98 ContentResultSetWrapper::~ContentResultSetWrapper()
100 //call impl_deinit() at start of destructor of derived class
103 void ContentResultSetWrapper::impl_deinit()
105 //call this at start of destructor of derived class
107 m_xMyListenerImpl
->impl_OwnerDies();
111 void ContentResultSetWrapper::impl_initPropertySetInfo(std::unique_lock
<std::mutex
>& rGuard
)
113 if( m_xPropertySetInfo
.is() )
116 impl_init_xPropertySetOrigin(rGuard
);
117 if( !m_xPropertySetOrigin
.is() )
120 Reference
< XPropertySetInfo
> xOrig
=
121 m_xPropertySetOrigin
->getPropertySetInfo();
123 m_xPropertySetInfo
= xOrig
;
126 void ContentResultSetWrapper::impl_EnsureNotDisposed(std::unique_lock
<std::mutex
>& /*rGuard*/)
129 throw DisposedException();
132 void ContentResultSetWrapper::impl_notifyPropertyChangeListeners( std::unique_lock
<std::mutex
>& rGuard
, const PropertyChangeEvent
& rEvt
)
134 // Notify listeners interested especially in the changed property.
135 OInterfaceContainerHelper4
<XPropertyChangeListener
>* pContainer
=
136 m_aPropertyChangeListeners
.getContainer( rGuard
, rEvt
.PropertyName
);
139 pContainer
->notifyEach( rGuard
, &XPropertyChangeListener::propertyChange
, rEvt
);
142 // Notify listeners interested in all properties.
143 pContainer
= m_aPropertyChangeListeners
.getContainer( rGuard
, OUString() );
146 pContainer
->notifyEach( rGuard
, &XPropertyChangeListener::propertyChange
, rEvt
);
150 void ContentResultSetWrapper::impl_notifyVetoableChangeListeners( std::unique_lock
<std::mutex
>& rGuard
, const PropertyChangeEvent
& rEvt
)
152 // Notify listeners interested especially in the changed property.
153 OInterfaceContainerHelper4
<XVetoableChangeListener
>* pContainer
=
154 m_aVetoableChangeListeners
.getContainer( rGuard
, rEvt
.PropertyName
);
157 pContainer
->notifyEach( rGuard
, &XVetoableChangeListener::vetoableChange
, rEvt
);
160 // Notify listeners interested in all properties.
161 pContainer
= m_aVetoableChangeListeners
.getContainer( rGuard
, OUString() );
164 pContainer
->notifyEach( rGuard
, &XVetoableChangeListener::vetoableChange
, rEvt
);
168 bool ContentResultSetWrapper::impl_isForwardOnly(std::unique_lock
<std::mutex
>& /*rGuard*/)
170 //m_nForwardOnly == 2 -> don't know
171 //m_nForwardOnly == 1 -> YES
172 //m_nForwardOnly == 0 -> NO
174 //@todo replace this with lines in comment
180 ReacquireableGuard aGuard( m_aMutex );
181 if( m_nForwardOnly == 2 )
184 if( !getPropertySetInfo().is() )
188 return m_nForwardOnly;
192 OUString aName("ResultSetType");
193 //find out, if we are ForwardOnly and cache the value:
195 impl_init_xPropertySetOrigin();
196 if( !m_xPropertySetOrigin.is() )
198 OSL_FAIL( "broadcaster was disposed already" );
200 return m_nForwardOnly;
204 Any aAny = m_xPropertySetOrigin->getPropertyValue( aName );
208 if( ( aAny >>= nResultSetType ) &&
209 ( nResultSetType == ResultSetType::FORWARD_ONLY ) )
214 return m_nForwardOnly;
219 // XInterface methods.
221 css::uno::Any SAL_CALL
ContentResultSetWrapper::queryInterface( const css::uno::Type
& rType
)
223 //list all interfaces inclusive baseclasses of interfaces
224 css::uno::Any aRet
= cppu::queryInterface( rType
,
225 static_cast< XComponent
* >(this),
226 static_cast< XCloseable
* >(this),
227 static_cast< XResultSetMetaDataSupplier
* >(this),
228 static_cast< XPropertySet
* >(this),
229 static_cast< XContentAccess
* >(this),
230 static_cast< XResultSet
* >(this),
231 static_cast< XRow
* >(this)
233 return aRet
.hasValue() ? aRet
: OWeakObject::queryInterface( rType
);
236 // XComponent methods.
239 void SAL_CALL
ContentResultSetWrapper::dispose()
241 std::unique_lock
aGuard(m_aMutex
);
242 impl_EnsureNotDisposed(aGuard
);
244 bool isCleared
= false;
245 if( m_bInDispose
|| m_bDisposed
)
249 if( m_xPropertySetOrigin
.is() )
255 m_xPropertySetOrigin
->removePropertyChangeListener(
256 OUString(), static_cast< XPropertyChangeListener
* >( m_xMyListenerImpl
.get() ) );
260 OSL_FAIL( "could not remove PropertyChangeListener" );
264 m_xPropertySetOrigin
->removeVetoableChangeListener(
265 OUString(), static_cast< XVetoableChangeListener
* >( m_xMyListenerImpl
.get() ) );
269 OSL_FAIL( "could not remove VetoableChangeListener" );
272 Reference
< XComponent
> xComponentOrigin( m_xResultSetOrigin
, UNO_QUERY
);
273 OSL_ENSURE( xComponentOrigin
.is(), "interface XComponent is required" );
274 xComponentOrigin
->removeEventListener( static_cast< XPropertyChangeListener
* >( m_xMyListenerImpl
.get() ) );
279 if( m_aDisposeEventListeners
.getLength(aGuard
) )
282 aEvt
.Source
= static_cast< XComponent
* >( this );
283 m_aDisposeEventListeners
.disposeAndClear( aGuard
, aEvt
);
286 if( m_aPropertyChangeListeners
.hasContainedTypes(aGuard
) )
289 aEvt
.Source
= static_cast< XPropertySet
* >( this );
290 m_aPropertyChangeListeners
.disposeAndClear( aGuard
, aEvt
);
293 if( m_aVetoableChangeListeners
.hasContainedTypes(aGuard
) )
296 aEvt
.Source
= static_cast< XPropertySet
* >( this );
297 m_aVetoableChangeListeners
.disposeAndClear( aGuard
, aEvt
);
301 m_bInDispose
= false;
306 void SAL_CALL
ContentResultSetWrapper::addEventListener( const Reference
< XEventListener
>& Listener
)
308 std::unique_lock
aGuard( m_aMutex
);
309 impl_EnsureNotDisposed(aGuard
);
311 m_aDisposeEventListeners
.addInterface( aGuard
, Listener
);
316 void SAL_CALL
ContentResultSetWrapper::removeEventListener( const Reference
< XEventListener
>& Listener
)
318 std::unique_lock
aGuard( m_aMutex
);
319 impl_EnsureNotDisposed(aGuard
);
320 m_aDisposeEventListeners
.removeInterface( aGuard
, Listener
);
324 //XCloseable methods.
327 void SAL_CALL
ContentResultSetWrapper::close()
330 std::unique_lock
aGuard( m_aMutex
);
331 impl_EnsureNotDisposed(aGuard
);
337 //XResultSetMetaDataSupplier methods.
340 Reference
< XResultSetMetaData
> SAL_CALL
ContentResultSetWrapper::getMetaData()
342 std::unique_lock
aGuard(m_aMutex
);
343 impl_EnsureNotDisposed(aGuard
);
345 if( !m_xMetaDataFromOrigin
.is() && m_xResultSetOrigin
.is() )
347 Reference
< XResultSetMetaDataSupplier
> xMetaDataSupplier(
348 m_xResultSetOrigin
, UNO_QUERY
);
350 if( xMetaDataSupplier
.is() )
354 Reference
< XResultSetMetaData
> xMetaData
355 = xMetaDataSupplier
->getMetaData();
358 m_xMetaDataFromOrigin
= xMetaData
;
361 return m_xMetaDataFromOrigin
;
365 // XPropertySet methods.
368 Reference
< XPropertySetInfo
> SAL_CALL
ContentResultSetWrapper::getPropertySetInfo()
370 std::unique_lock
aGuard( m_aMutex
);
371 return getPropertySetInfoImpl(aGuard
);
375 Reference
< XPropertySetInfo
> ContentResultSetWrapper::getPropertySetInfoImpl(std::unique_lock
<std::mutex
>& rGuard
)
377 impl_EnsureNotDisposed(rGuard
);
378 if( m_xPropertySetInfo
.is() )
379 return m_xPropertySetInfo
;
380 impl_initPropertySetInfo(rGuard
);
381 return m_xPropertySetInfo
;
385 void SAL_CALL
ContentResultSetWrapper::setPropertyValue( const OUString
& rPropertyName
, const Any
& rValue
)
387 std::unique_lock
aGuard( m_aMutex
);
388 return setPropertyValueImpl(aGuard
, rPropertyName
, rValue
);
392 void ContentResultSetWrapper::setPropertyValueImpl( std::unique_lock
<std::mutex
>& rGuard
, const OUString
& rPropertyName
, const Any
& rValue
)
394 impl_EnsureNotDisposed(rGuard
);
395 impl_init_xPropertySetOrigin(rGuard
);
396 if( !m_xPropertySetOrigin
.is() )
398 OSL_FAIL( "broadcaster was disposed already" );
399 throw UnknownPropertyException();
401 m_xPropertySetOrigin
->setPropertyValue( rPropertyName
, rValue
);
406 Any SAL_CALL
ContentResultSetWrapper::getPropertyValue( const OUString
& rPropertyName
)
408 std::unique_lock
aGuard( m_aMutex
);
409 impl_EnsureNotDisposed(aGuard
);
410 impl_init_xPropertySetOrigin(aGuard
);
411 if( !m_xPropertySetOrigin
.is() )
413 OSL_FAIL( "broadcaster was disposed already" );
414 throw UnknownPropertyException();
416 return m_xPropertySetOrigin
->getPropertyValue( rPropertyName
);
421 void SAL_CALL
ContentResultSetWrapper::addPropertyChangeListener( const OUString
& aPropertyName
, const Reference
< XPropertyChangeListener
>& xListener
)
423 std::unique_lock
aGuard( m_aMutex
);
424 impl_EnsureNotDisposed(aGuard
);
426 if( !getPropertySetInfo().is() )
428 OSL_FAIL( "broadcaster was disposed already" );
429 throw UnknownPropertyException();
432 if( !aPropertyName
.isEmpty() )
434 m_xPropertySetInfo
->getPropertyByName( aPropertyName
);
435 //throws UnknownPropertyException, if so
438 bool bNeedRegister
= !m_aPropertyChangeListeners
.hasContainedTypes(aGuard
);
439 m_aPropertyChangeListeners
.addInterface( aGuard
, aPropertyName
, xListener
);
443 impl_init_xPropertySetOrigin(aGuard
);
444 if( !m_xPropertySetOrigin
.is() )
446 OSL_FAIL( "broadcaster was disposed already" );
451 m_xPropertySetOrigin
->addPropertyChangeListener(
452 OUString(), static_cast< XPropertyChangeListener
* >( m_xMyListenerImpl
.get() ) );
456 m_aPropertyChangeListeners
.removeInterface( aGuard
, aPropertyName
, xListener
);
463 void SAL_CALL
ContentResultSetWrapper::addVetoableChangeListener( const OUString
& rPropertyName
, const Reference
< XVetoableChangeListener
>& xListener
)
465 std::unique_lock
aGuard( m_aMutex
);
466 impl_EnsureNotDisposed(aGuard
);
468 if( !getPropertySetInfo().is() )
470 OSL_FAIL( "broadcaster was disposed already" );
471 throw UnknownPropertyException();
473 if( !rPropertyName
.isEmpty() )
475 m_xPropertySetInfo
->getPropertyByName( rPropertyName
);
476 //throws UnknownPropertyException, if so
479 bool bNeedRegister
= !m_aVetoableChangeListeners
.hasContainedTypes(aGuard
);
480 m_aVetoableChangeListeners
.addInterface( aGuard
, rPropertyName
, xListener
);
484 impl_init_xPropertySetOrigin(aGuard
);
486 if( !m_xPropertySetOrigin
.is() )
488 OSL_FAIL( "broadcaster was disposed already" );
494 m_xPropertySetOrigin
->addVetoableChangeListener(
495 OUString(), static_cast< XVetoableChangeListener
* >( m_xMyListenerImpl
.get() ) );
499 m_aVetoableChangeListeners
.removeInterface( aGuard
, rPropertyName
, xListener
);
506 void SAL_CALL
ContentResultSetWrapper::removePropertyChangeListener( const OUString
& rPropertyName
, const Reference
< XPropertyChangeListener
>& xListener
)
508 std::unique_lock
aGuard( m_aMutex
);
509 impl_EnsureNotDisposed(aGuard
);
511 //noop, if no listener registered
512 if( !m_aPropertyChangeListeners
.hasContainedTypes(aGuard
) )
515 OInterfaceContainerHelper4
<XPropertyChangeListener
>* pContainer
=
516 m_aPropertyChangeListeners
.getContainer( aGuard
, rPropertyName
);
520 if( !rPropertyName
.isEmpty() )
522 if( !getPropertySetInfo().is() )
523 throw UnknownPropertyException();
525 m_xPropertySetInfo
->getPropertyByName( rPropertyName
);
526 //throws UnknownPropertyException, if so
528 return; //the listener was not registered
531 m_aPropertyChangeListeners
.removeInterface( aGuard
, rPropertyName
, xListener
);
533 if( m_aPropertyChangeListeners
.hasContainedTypes(aGuard
) )
536 impl_init_xPropertySetOrigin(aGuard
);
537 if( !m_xPropertySetOrigin
.is() )
539 OSL_FAIL( "broadcaster was disposed already" );
544 m_xPropertySetOrigin
->removePropertyChangeListener(
545 OUString(), static_cast< XPropertyChangeListener
* >( m_xMyListenerImpl
.get() ) );
549 OSL_FAIL( "could not remove PropertyChangeListener" );
555 void SAL_CALL
ContentResultSetWrapper::removeVetoableChangeListener( const OUString
& rPropertyName
, const Reference
< XVetoableChangeListener
>& xListener
)
557 std::unique_lock
aGuard( m_aMutex
);
558 impl_EnsureNotDisposed(aGuard
);
560 //noop, if no listener registered
561 if( !m_aVetoableChangeListeners
.hasContainedTypes(aGuard
) )
563 OInterfaceContainerHelper4
<XVetoableChangeListener
>* pContainer
=
564 m_aVetoableChangeListeners
.getContainer( aGuard
, rPropertyName
);
568 if( !rPropertyName
.isEmpty() )
570 if( !getPropertySetInfo().is() )
571 throw UnknownPropertyException(rPropertyName
);
573 m_xPropertySetInfo
->getPropertyByName( rPropertyName
);
574 //throws UnknownPropertyException, if so
576 return; //the listener was not registered
579 m_aVetoableChangeListeners
.removeInterface( aGuard
, rPropertyName
, xListener
);
581 if( m_aVetoableChangeListeners
.hasContainedTypes(aGuard
) )
584 impl_init_xPropertySetOrigin(aGuard
);
585 if( !m_xPropertySetOrigin
.is() )
587 OSL_FAIL( "broadcaster was disposed already" );
592 m_xPropertySetOrigin
->removeVetoableChangeListener(
593 OUString(), static_cast< XVetoableChangeListener
* >( m_xMyListenerImpl
.get() ) );
597 OSL_FAIL( "could not remove VetoableChangeListener" );
605 //virtual, only called from ContentResultSetWrapperListener
606 void ContentResultSetWrapper::impl_disposing( const EventObject
& )
608 std::unique_lock
aGuard(m_aMutex
);
610 impl_EnsureNotDisposed(aGuard
);
612 if( !m_xResultSetOrigin
.is() )
615 //release all references to the broadcaster:
616 m_xResultSetOrigin
.clear();
617 if(m_xRowOrigin
.is())
618 m_xRowOrigin
.clear();
619 if(m_xContentAccessOrigin
.is())
620 m_xContentAccessOrigin
.clear();
621 if(m_xPropertySetOrigin
.is())
622 m_xPropertySetOrigin
.clear();
623 m_xMetaDataFromOrigin
.clear();
624 if(m_xPropertySetInfo
.is())
625 m_xPropertySetInfo
.clear();
628 //virtual, only called from ContentResultSetWrapperListener
629 void ContentResultSetWrapper::impl_propertyChange( const PropertyChangeEvent
& rEvt
)
631 std::unique_lock
aGuard(m_aMutex
);
633 impl_EnsureNotDisposed(aGuard
);
635 PropertyChangeEvent
aEvt( rEvt
);
636 aEvt
.Source
= static_cast< XPropertySet
* >( this );
637 aEvt
.Further
= false;
638 impl_notifyPropertyChangeListeners( aGuard
, aEvt
);
641 //virtual, only called from ContentResultSetWrapperListener
642 void ContentResultSetWrapper::impl_vetoableChange( const PropertyChangeEvent
& rEvt
)
644 std::unique_lock
aGuard(m_aMutex
);
645 impl_EnsureNotDisposed(aGuard
);
647 PropertyChangeEvent
aEvt( rEvt
);
648 aEvt
.Source
= static_cast< XPropertySet
* >( this );
649 aEvt
.Further
= false;
651 impl_notifyVetoableChangeListeners( aGuard
, aEvt
);
655 // XContentAccess methods. ( -- position dependent )
659 OUString SAL_CALL
ContentResultSetWrapper::queryContentIdentifierString()
661 std::unique_lock
aGuard(m_aMutex
);
662 return queryContentIdentifierStringImpl(aGuard
);
665 OUString
ContentResultSetWrapper::queryContentIdentifierStringImpl(std::unique_lock
<std::mutex
>& rGuard
)
667 impl_EnsureNotDisposed(rGuard
);
668 impl_init_xContentAccessOrigin(rGuard
);
669 if( !m_xContentAccessOrigin
.is() )
671 OSL_FAIL( "broadcaster was disposed already" );
672 throw RuntimeException();
674 return m_xContentAccessOrigin
->queryContentIdentifierString();
679 Reference
< XContentIdentifier
> SAL_CALL
ContentResultSetWrapper::queryContentIdentifier()
681 std::unique_lock
aGuard(m_aMutex
);
682 impl_EnsureNotDisposed(aGuard
);
683 impl_init_xContentAccessOrigin(aGuard
);
684 if( !m_xContentAccessOrigin
.is() )
686 OSL_FAIL( "broadcaster was disposed already" );
687 throw RuntimeException();
689 return m_xContentAccessOrigin
->queryContentIdentifier();
694 Reference
< XContent
> SAL_CALL
ContentResultSetWrapper::queryContent()
696 std::unique_lock
aGuard(m_aMutex
);
697 impl_EnsureNotDisposed(aGuard
);
698 impl_init_xContentAccessOrigin(aGuard
);
699 if( !m_xContentAccessOrigin
.is() )
701 OSL_FAIL( "broadcaster was disposed already" );
702 throw RuntimeException();
704 return m_xContentAccessOrigin
->queryContent();
708 // XResultSet methods.
712 sal_Bool SAL_CALL
ContentResultSetWrapper::next()
714 std::unique_lock
aGuard(m_aMutex
);
715 impl_EnsureNotDisposed(aGuard
);
717 if( !m_xResultSetOrigin
.is() )
719 OSL_FAIL( "broadcaster was disposed already" );
720 throw RuntimeException();
722 return m_xResultSetOrigin
->next();
726 sal_Bool SAL_CALL
ContentResultSetWrapper::previous()
728 std::unique_lock
aGuard(m_aMutex
);
729 impl_EnsureNotDisposed(aGuard
);
731 if( !m_xResultSetOrigin
.is() )
733 OSL_FAIL( "broadcaster was disposed already" );
734 throw RuntimeException();
736 return m_xResultSetOrigin
->previous();
740 sal_Bool SAL_CALL
ContentResultSetWrapper::absolute( sal_Int32 row
)
742 std::unique_lock
aGuard(m_aMutex
);
743 impl_EnsureNotDisposed(aGuard
);
745 if( !m_xResultSetOrigin
.is() )
747 OSL_FAIL( "broadcaster was disposed already" );
748 throw RuntimeException();
750 return m_xResultSetOrigin
->absolute( row
);
754 sal_Bool SAL_CALL
ContentResultSetWrapper::relative( sal_Int32 rows
)
756 std::unique_lock
aGuard(m_aMutex
);
757 impl_EnsureNotDisposed(aGuard
);
759 if( !m_xResultSetOrigin
.is() )
761 OSL_FAIL( "broadcaster was disposed already" );
762 throw RuntimeException();
764 return m_xResultSetOrigin
->relative( rows
);
769 sal_Bool SAL_CALL
ContentResultSetWrapper::first()
771 std::unique_lock
aGuard(m_aMutex
);
772 impl_EnsureNotDisposed(aGuard
);
774 if( !m_xResultSetOrigin
.is() )
776 OSL_FAIL( "broadcaster was disposed already" );
777 throw RuntimeException();
779 return m_xResultSetOrigin
->first();
783 sal_Bool SAL_CALL
ContentResultSetWrapper::last()
785 std::unique_lock
aGuard(m_aMutex
);
786 impl_EnsureNotDisposed(aGuard
);
788 if( !m_xResultSetOrigin
.is() )
790 OSL_FAIL( "broadcaster was disposed already" );
791 throw RuntimeException();
793 return m_xResultSetOrigin
->last();
797 void SAL_CALL
ContentResultSetWrapper::beforeFirst()
799 std::unique_lock
aGuard(m_aMutex
);
800 impl_EnsureNotDisposed(aGuard
);
802 if( !m_xResultSetOrigin
.is() )
804 OSL_FAIL( "broadcaster was disposed already" );
805 throw RuntimeException();
807 m_xResultSetOrigin
->beforeFirst();
811 void SAL_CALL
ContentResultSetWrapper::afterLast()
813 std::unique_lock
aGuard(m_aMutex
);
814 impl_EnsureNotDisposed(aGuard
);
816 if( !m_xResultSetOrigin
.is() )
818 OSL_FAIL( "broadcaster was disposed already" );
819 throw RuntimeException();
821 m_xResultSetOrigin
->afterLast();
825 sal_Bool SAL_CALL
ContentResultSetWrapper::isAfterLast()
827 std::unique_lock
aGuard(m_aMutex
);
828 impl_EnsureNotDisposed(aGuard
);
830 if( !m_xResultSetOrigin
.is() )
832 OSL_FAIL( "broadcaster was disposed already" );
833 throw RuntimeException();
835 return m_xResultSetOrigin
->isAfterLast();
839 sal_Bool SAL_CALL
ContentResultSetWrapper::isBeforeFirst()
841 std::unique_lock
aGuard(m_aMutex
);
842 impl_EnsureNotDisposed(aGuard
);
844 if( !m_xResultSetOrigin
.is() )
846 OSL_FAIL( "broadcaster was disposed already" );
847 throw RuntimeException();
849 return m_xResultSetOrigin
->isBeforeFirst();
853 sal_Bool SAL_CALL
ContentResultSetWrapper::isFirst()
855 std::unique_lock
aGuard(m_aMutex
);
856 impl_EnsureNotDisposed(aGuard
);
858 if( !m_xResultSetOrigin
.is() )
860 OSL_FAIL( "broadcaster was disposed already" );
861 throw RuntimeException();
863 return m_xResultSetOrigin
->isFirst();
867 sal_Bool SAL_CALL
ContentResultSetWrapper::isLast()
869 std::unique_lock
aGuard(m_aMutex
);
870 impl_EnsureNotDisposed(aGuard
);
872 if( !m_xResultSetOrigin
.is() )
874 OSL_FAIL( "broadcaster was disposed already" );
875 throw RuntimeException();
877 return m_xResultSetOrigin
->isLast();
882 sal_Int32 SAL_CALL
ContentResultSetWrapper::getRow()
884 std::unique_lock
aGuard(m_aMutex
);
885 impl_EnsureNotDisposed(aGuard
);
887 if( !m_xResultSetOrigin
.is() )
889 OSL_FAIL( "broadcaster was disposed already" );
890 throw RuntimeException();
892 return m_xResultSetOrigin
->getRow();
896 void SAL_CALL
ContentResultSetWrapper::refreshRow()
898 std::unique_lock
aGuard(m_aMutex
);
899 impl_EnsureNotDisposed(aGuard
);
901 if( !m_xResultSetOrigin
.is() )
903 OSL_FAIL( "broadcaster was disposed already" );
904 throw RuntimeException();
906 m_xResultSetOrigin
->refreshRow();
910 sal_Bool SAL_CALL
ContentResultSetWrapper::rowUpdated()
912 std::unique_lock
aGuard(m_aMutex
);
913 impl_EnsureNotDisposed(aGuard
);
915 if( !m_xResultSetOrigin
.is() )
917 OSL_FAIL( "broadcaster was disposed already" );
918 throw RuntimeException();
920 return m_xResultSetOrigin
->rowUpdated();
924 sal_Bool SAL_CALL
ContentResultSetWrapper::rowInserted()
926 std::unique_lock
aGuard(m_aMutex
);
927 impl_EnsureNotDisposed(aGuard
);
929 if( !m_xResultSetOrigin
.is() )
931 OSL_FAIL( "broadcaster was disposed already" );
932 throw RuntimeException();
934 return m_xResultSetOrigin
->rowInserted();
938 sal_Bool SAL_CALL
ContentResultSetWrapper::rowDeleted()
940 std::unique_lock
aGuard(m_aMutex
);
941 impl_EnsureNotDisposed(aGuard
);
943 if( !m_xResultSetOrigin
.is() )
945 OSL_FAIL( "broadcaster was disposed already" );
946 throw RuntimeException();
948 return m_xResultSetOrigin
->rowDeleted();
952 Reference
< XInterface
> SAL_CALL
ContentResultSetWrapper::getStatement()
954 std::unique_lock
aGuard(m_aMutex
);
955 impl_EnsureNotDisposed(aGuard
);
956 //@todo ?return anything
957 return Reference
< XInterface
>();
964 void ContentResultSetWrapper::verifyGet()
966 std::unique_lock
aGuard(m_aMutex
);
967 impl_EnsureNotDisposed(aGuard
);
968 impl_init_xRowOrigin(aGuard
);
969 if( !m_xRowOrigin
.is() )
971 OSL_FAIL( "broadcaster was disposed already" );
972 throw RuntimeException();
977 sal_Bool SAL_CALL
ContentResultSetWrapper::wasNull()
979 std::unique_lock
aGuard(m_aMutex
);
980 impl_EnsureNotDisposed(aGuard
);
981 impl_init_xRowOrigin(aGuard
);
982 if( !m_xRowOrigin
.is() )
984 OSL_FAIL( "broadcaster was disposed already" );
985 throw RuntimeException();
987 return m_xRowOrigin
->wasNull();
991 OUString SAL_CALL
ContentResultSetWrapper::getString( sal_Int32 columnIndex
)
994 return m_xRowOrigin
->getString( columnIndex
);
998 sal_Bool SAL_CALL
ContentResultSetWrapper::getBoolean( sal_Int32 columnIndex
)
1001 return m_xRowOrigin
->getBoolean( columnIndex
);
1005 sal_Int8 SAL_CALL
ContentResultSetWrapper::getByte( sal_Int32 columnIndex
)
1008 return m_xRowOrigin
->getByte( columnIndex
);
1012 sal_Int16 SAL_CALL
ContentResultSetWrapper::getShort( sal_Int32 columnIndex
)
1015 return m_xRowOrigin
->getShort( columnIndex
);
1019 sal_Int32 SAL_CALL
ContentResultSetWrapper::getInt( sal_Int32 columnIndex
)
1022 return m_xRowOrigin
->getInt( columnIndex
);
1026 sal_Int64 SAL_CALL
ContentResultSetWrapper::getLong( sal_Int32 columnIndex
)
1029 return m_xRowOrigin
->getLong( columnIndex
);
1033 float SAL_CALL
ContentResultSetWrapper::getFloat( sal_Int32 columnIndex
)
1036 return m_xRowOrigin
->getFloat( columnIndex
);
1040 double SAL_CALL
ContentResultSetWrapper::getDouble( sal_Int32 columnIndex
)
1043 return m_xRowOrigin
->getDouble( columnIndex
);
1047 Sequence
< sal_Int8
> SAL_CALL
ContentResultSetWrapper::getBytes( sal_Int32 columnIndex
)
1050 return m_xRowOrigin
->getBytes( columnIndex
);
1054 Date SAL_CALL
ContentResultSetWrapper::getDate( sal_Int32 columnIndex
)
1057 return m_xRowOrigin
->getDate( columnIndex
);
1061 Time SAL_CALL
ContentResultSetWrapper::getTime( sal_Int32 columnIndex
)
1064 return m_xRowOrigin
->getTime( columnIndex
);
1068 DateTime SAL_CALL
ContentResultSetWrapper::getTimestamp( sal_Int32 columnIndex
)
1071 return m_xRowOrigin
->getTimestamp( columnIndex
);
1075 Reference
< css::io::XInputStream
> SAL_CALL
ContentResultSetWrapper::getBinaryStream( sal_Int32 columnIndex
)
1078 return m_xRowOrigin
->getBinaryStream( columnIndex
);
1082 Reference
< css::io::XInputStream
> SAL_CALL
ContentResultSetWrapper::getCharacterStream( sal_Int32 columnIndex
)
1085 return m_xRowOrigin
->getCharacterStream( columnIndex
);
1089 Any SAL_CALL
ContentResultSetWrapper::getObject( sal_Int32 columnIndex
, const Reference
< css::container::XNameAccess
>& typeMap
)
1091 //if you change this macro please pay attention to
1092 //define XROW_GETXXX, where this is similar implemented
1094 std::unique_lock
aGuard(m_aMutex
);
1095 impl_EnsureNotDisposed(aGuard
);
1096 impl_init_xRowOrigin(aGuard
);
1097 if( !m_xRowOrigin
.is() )
1099 OSL_FAIL( "broadcaster was disposed already" );
1100 throw RuntimeException();
1102 return m_xRowOrigin
->getObject( columnIndex
, typeMap
);
1106 Reference
< XRef
> SAL_CALL
ContentResultSetWrapper::getRef( sal_Int32 columnIndex
)
1109 return m_xRowOrigin
->getRef( columnIndex
);
1113 Reference
< XBlob
> SAL_CALL
ContentResultSetWrapper::getBlob( sal_Int32 columnIndex
)
1116 return m_xRowOrigin
->getBlob( columnIndex
);
1120 Reference
< XClob
> SAL_CALL
ContentResultSetWrapper::getClob( sal_Int32 columnIndex
)
1123 return m_xRowOrigin
->getClob( columnIndex
);
1127 Reference
< XArray
> SAL_CALL
ContentResultSetWrapper::getArray( sal_Int32 columnIndex
)
1130 return m_xRowOrigin
->getArray( columnIndex
);
1136 ContentResultSetWrapperListener::ContentResultSetWrapperListener(
1137 ContentResultSetWrapper
* pOwner
)
1138 : m_pOwner( pOwner
)
1142 ContentResultSetWrapperListener::~ContentResultSetWrapperListener()
1147 // XInterface methods.
1148 void SAL_CALL
ContentResultSetWrapperListener::acquire()
1151 OWeakObject::acquire();
1154 void SAL_CALL
ContentResultSetWrapperListener::release()
1157 OWeakObject::release();
1160 css::uno::Any SAL_CALL
ContentResultSetWrapperListener::queryInterface( const css::uno::Type
& rType
)
1162 //list all interfaces inclusive baseclasses of interfaces
1163 css::uno::Any aRet
= cppu::queryInterface( rType
,
1164 static_cast< XEventListener
* >(
1165 static_cast< XPropertyChangeListener
* >(this)),
1166 static_cast< XPropertyChangeListener
* >(this),
1167 static_cast< XVetoableChangeListener
* >(this)
1169 return aRet
.hasValue() ? aRet
: OWeakObject::queryInterface( rType
);
1172 //XEventListener methods.
1176 void SAL_CALL
ContentResultSetWrapperListener::disposing( const EventObject
& rEventObject
)
1179 m_pOwner
->impl_disposing( rEventObject
);
1183 //XPropertyChangeListener methods.
1187 void SAL_CALL
ContentResultSetWrapperListener::propertyChange( const PropertyChangeEvent
& rEvt
)
1190 m_pOwner
->impl_propertyChange( rEvt
);
1194 //XVetoableChangeListener methods.
1197 void SAL_CALL
ContentResultSetWrapperListener::vetoableChange( const PropertyChangeEvent
& rEvt
)
1200 m_pOwner
->impl_vetoableChange( rEvt
);
1203 void ContentResultSetWrapperListener::impl_OwnerDies()
1208 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */