bump product version to 7.6.3.2-android
[LibreOffice.git] / ucb / source / cacher / contentresultsetwrapper.cxx
blob72388222f12d9edc5ea1ce2ed6412d0799e228a2
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/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;
34 using namespace cppu;
39 ContentResultSetWrapper::ContentResultSetWrapper(
40 Reference< XResultSet > const & xOrigin )
41 : m_xResultSetOrigin( xOrigin )
42 , m_nForwardOnly( 2 )
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>&)
56 if(m_xRowOrigin.is())
57 return;
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())
67 return;
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() )
79 return;
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();
110 //virtual
111 void ContentResultSetWrapper::impl_initPropertySetInfo(std::unique_lock<std::mutex>& rGuard)
113 if( m_xPropertySetInfo.is() )
114 return;
116 impl_init_xPropertySetOrigin(rGuard);
117 if( !m_xPropertySetOrigin.is() )
118 return;
120 Reference< XPropertySetInfo > xOrig =
121 m_xPropertySetOrigin->getPropertySetInfo();
123 m_xPropertySetInfo = xOrig;
126 void ContentResultSetWrapper::impl_EnsureNotDisposed(std::unique_lock<std::mutex>& /*rGuard*/)
128 if( m_bDisposed )
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 );
137 if( pContainer )
139 pContainer->notifyEach( rGuard, &XPropertyChangeListener::propertyChange, rEvt );
142 // Notify listeners interested in all properties.
143 pContainer = m_aPropertyChangeListeners.getContainer( rGuard, OUString() );
144 if( pContainer )
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 );
155 if( pContainer )
157 pContainer->notifyEach( rGuard, &XVetoableChangeListener::vetoableChange, rEvt );
160 // Notify listeners interested in all properties.
161 pContainer = m_aVetoableChangeListeners.getContainer( rGuard, OUString() );
162 if( pContainer )
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
175 m_nForwardOnly = 0;
176 return false;
180 ReacquireableGuard aGuard( m_aMutex );
181 if( m_nForwardOnly == 2 )
183 aGuard.clear();
184 if( !getPropertySetInfo().is() )
186 aGuard.reacquire();
187 m_nForwardOnly = 0;
188 return m_nForwardOnly;
190 aGuard.reacquire();
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" );
199 m_nForwardOnly = 0;
200 return m_nForwardOnly;
203 aGuard.clear();
204 Any aAny = m_xPropertySetOrigin->getPropertyValue( aName );
206 aGuard.reacquire();
207 long nResultSetType;
208 if( ( aAny >>= nResultSetType ) &&
209 ( nResultSetType == ResultSetType::FORWARD_ONLY ) )
210 m_nForwardOnly = 1;
211 else
212 m_nForwardOnly = 0;
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.
238 // virtual
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 )
246 return;
247 m_bInDispose = true;
249 if( m_xPropertySetOrigin.is() )
251 aGuard.unlock();
252 isCleared = true;
255 m_xPropertySetOrigin->removePropertyChangeListener(
256 OUString(), static_cast< XPropertyChangeListener * >( m_xMyListenerImpl.get() ) );
258 catch( Exception& )
260 OSL_FAIL( "could not remove PropertyChangeListener" );
264 m_xPropertySetOrigin->removeVetoableChangeListener(
265 OUString(), static_cast< XVetoableChangeListener * >( m_xMyListenerImpl.get() ) );
267 catch( Exception& )
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() ) );
277 if (isCleared)
278 aGuard.lock();
279 if( m_aDisposeEventListeners.getLength(aGuard) )
281 EventObject aEvt;
282 aEvt.Source = static_cast< XComponent * >( this );
283 m_aDisposeEventListeners.disposeAndClear( aGuard, aEvt );
286 if( m_aPropertyChangeListeners.hasContainedTypes(aGuard) )
288 EventObject aEvt;
289 aEvt.Source = static_cast< XPropertySet * >( this );
290 m_aPropertyChangeListeners.disposeAndClear( aGuard, aEvt );
293 if( m_aVetoableChangeListeners.hasContainedTypes(aGuard) )
295 EventObject aEvt;
296 aEvt.Source = static_cast< XPropertySet * >( this );
297 m_aVetoableChangeListeners.disposeAndClear( aGuard, aEvt );
300 m_bDisposed = true;
301 m_bInDispose = false;
305 // virtual
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 );
315 // virtual
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.
326 //virtual
327 void SAL_CALL ContentResultSetWrapper::close()
330 std::unique_lock aGuard( m_aMutex );
331 impl_EnsureNotDisposed(aGuard);
333 dispose();
337 //XResultSetMetaDataSupplier methods.
339 //virtual
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() )
352 aGuard.unlock();
354 Reference< XResultSetMetaData > xMetaData
355 = xMetaDataSupplier->getMetaData();
357 aGuard.lock();
358 m_xMetaDataFromOrigin = xMetaData;
361 return m_xMetaDataFromOrigin;
365 // XPropertySet methods.
367 // virtual
368 Reference< XPropertySetInfo > SAL_CALL ContentResultSetWrapper::getPropertySetInfo()
370 std::unique_lock aGuard( m_aMutex );
371 return getPropertySetInfoImpl(aGuard);
374 // virtual
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;
384 // virtual
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);
391 // virtual
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 );
405 // virtual
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 );
420 // virtual
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 );
440 if( !bNeedRegister )
441 return;
443 impl_init_xPropertySetOrigin(aGuard);
444 if( !m_xPropertySetOrigin.is() )
446 OSL_FAIL( "broadcaster was disposed already" );
447 return;
451 m_xPropertySetOrigin->addPropertyChangeListener(
452 OUString(), static_cast< XPropertyChangeListener * >( m_xMyListenerImpl.get() ) );
454 catch( Exception& )
456 m_aPropertyChangeListeners.removeInterface( aGuard, aPropertyName, xListener );
457 throw;
462 // virtual
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 );
481 if( !bNeedRegister )
482 return;
484 impl_init_xPropertySetOrigin(aGuard);
486 if( !m_xPropertySetOrigin.is() )
488 OSL_FAIL( "broadcaster was disposed already" );
489 return;
494 m_xPropertySetOrigin->addVetoableChangeListener(
495 OUString(), static_cast< XVetoableChangeListener * >( m_xMyListenerImpl.get() ) );
497 catch( Exception& )
499 m_aVetoableChangeListeners.removeInterface( aGuard, rPropertyName, xListener );
500 throw;
505 // virtual
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) )
513 return;
515 OInterfaceContainerHelper4<XPropertyChangeListener>* pContainer =
516 m_aPropertyChangeListeners.getContainer( aGuard, rPropertyName );
518 if( !pContainer )
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) )
534 return;
536 impl_init_xPropertySetOrigin(aGuard);
537 if( !m_xPropertySetOrigin.is() )
539 OSL_FAIL( "broadcaster was disposed already" );
540 return;
544 m_xPropertySetOrigin->removePropertyChangeListener(
545 OUString(), static_cast< XPropertyChangeListener * >( m_xMyListenerImpl.get() ) );
547 catch( Exception& )
549 OSL_FAIL( "could not remove PropertyChangeListener" );
554 // virtual
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) )
562 return;
563 OInterfaceContainerHelper4<XVetoableChangeListener>* pContainer =
564 m_aVetoableChangeListeners.getContainer( aGuard, rPropertyName );
566 if( !pContainer )
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) )
582 return;
584 impl_init_xPropertySetOrigin(aGuard);
585 if( !m_xPropertySetOrigin.is() )
587 OSL_FAIL( "broadcaster was disposed already" );
588 return;
592 m_xPropertySetOrigin->removeVetoableChangeListener(
593 OUString(), static_cast< XVetoableChangeListener * >( m_xMyListenerImpl.get() ) );
595 catch( Exception& )
597 OSL_FAIL( "could not remove VetoableChangeListener" );
602 // own methods.
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() )
613 return;
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 )
658 // virtual
659 OUString SAL_CALL ContentResultSetWrapper::queryContentIdentifierString()
661 std::unique_lock aGuard(m_aMutex);
662 return queryContentIdentifierStringImpl(aGuard);
664 // virtual
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();
678 // virtual
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();
693 // virtual
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.
710 //virtual
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();
725 //virtual
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();
739 //virtual
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 );
753 //virtual
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 );
768 //virtual
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();
782 //virtual
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();
796 //virtual
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();
810 //virtual
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();
824 //virtual
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();
838 //virtual
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();
852 //virtual
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();
866 //virtual
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();
881 //virtual
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();
895 //virtual
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();
909 //virtual
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();
923 //virtual
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();
937 //virtual
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();
951 //virtual
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 >();
961 // XRow methods.
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();
976 //virtual
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();
990 //virtual
991 OUString SAL_CALL ContentResultSetWrapper::getString( sal_Int32 columnIndex )
993 verifyGet();
994 return m_xRowOrigin->getString( columnIndex );
997 //virtual
998 sal_Bool SAL_CALL ContentResultSetWrapper::getBoolean( sal_Int32 columnIndex )
1000 verifyGet();
1001 return m_xRowOrigin->getBoolean( columnIndex );
1004 //virtual
1005 sal_Int8 SAL_CALL ContentResultSetWrapper::getByte( sal_Int32 columnIndex )
1007 verifyGet();
1008 return m_xRowOrigin->getByte( columnIndex );
1011 //virtual
1012 sal_Int16 SAL_CALL ContentResultSetWrapper::getShort( sal_Int32 columnIndex )
1014 verifyGet();
1015 return m_xRowOrigin->getShort( columnIndex );
1018 //virtual
1019 sal_Int32 SAL_CALL ContentResultSetWrapper::getInt( sal_Int32 columnIndex )
1021 verifyGet();
1022 return m_xRowOrigin->getInt( columnIndex );
1025 //virtual
1026 sal_Int64 SAL_CALL ContentResultSetWrapper::getLong( sal_Int32 columnIndex )
1028 verifyGet();
1029 return m_xRowOrigin->getLong( columnIndex );
1032 //virtual
1033 float SAL_CALL ContentResultSetWrapper::getFloat( sal_Int32 columnIndex )
1035 verifyGet();
1036 return m_xRowOrigin->getFloat( columnIndex );
1039 //virtual
1040 double SAL_CALL ContentResultSetWrapper::getDouble( sal_Int32 columnIndex )
1042 verifyGet();
1043 return m_xRowOrigin->getDouble( columnIndex );
1046 //virtual
1047 Sequence< sal_Int8 > SAL_CALL ContentResultSetWrapper::getBytes( sal_Int32 columnIndex )
1049 verifyGet();
1050 return m_xRowOrigin->getBytes( columnIndex );
1053 //virtual
1054 Date SAL_CALL ContentResultSetWrapper::getDate( sal_Int32 columnIndex )
1056 verifyGet();
1057 return m_xRowOrigin->getDate( columnIndex );
1060 //virtual
1061 Time SAL_CALL ContentResultSetWrapper::getTime( sal_Int32 columnIndex )
1063 verifyGet();
1064 return m_xRowOrigin->getTime( columnIndex );
1067 //virtual
1068 DateTime SAL_CALL ContentResultSetWrapper::getTimestamp( sal_Int32 columnIndex )
1070 verifyGet();
1071 return m_xRowOrigin->getTimestamp( columnIndex );
1074 //virtual
1075 Reference< css::io::XInputStream > SAL_CALL ContentResultSetWrapper::getBinaryStream( sal_Int32 columnIndex )
1077 verifyGet();
1078 return m_xRowOrigin->getBinaryStream( columnIndex );
1081 //virtual
1082 Reference< css::io::XInputStream > SAL_CALL ContentResultSetWrapper::getCharacterStream( sal_Int32 columnIndex )
1084 verifyGet();
1085 return m_xRowOrigin->getCharacterStream( columnIndex );
1088 //virtual
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 );
1105 //virtual
1106 Reference< XRef > SAL_CALL ContentResultSetWrapper::getRef( sal_Int32 columnIndex )
1108 verifyGet();
1109 return m_xRowOrigin->getRef( columnIndex );
1112 //virtual
1113 Reference< XBlob > SAL_CALL ContentResultSetWrapper::getBlob( sal_Int32 columnIndex )
1115 verifyGet();
1116 return m_xRowOrigin->getBlob( columnIndex );
1119 //virtual
1120 Reference< XClob > SAL_CALL ContentResultSetWrapper::getClob( sal_Int32 columnIndex )
1122 verifyGet();
1123 return m_xRowOrigin->getClob( columnIndex );
1126 //virtual
1127 Reference< XArray > SAL_CALL ContentResultSetWrapper::getArray( sal_Int32 columnIndex )
1129 verifyGet();
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()
1149 noexcept
1151 OWeakObject::acquire();
1154 void SAL_CALL ContentResultSetWrapperListener::release()
1155 noexcept
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.
1175 //virtual
1176 void SAL_CALL ContentResultSetWrapperListener::disposing( const EventObject& rEventObject )
1178 if( m_pOwner )
1179 m_pOwner->impl_disposing( rEventObject );
1183 //XPropertyChangeListener methods.
1186 //virtual
1187 void SAL_CALL ContentResultSetWrapperListener::propertyChange( const PropertyChangeEvent& rEvt )
1189 if( m_pOwner )
1190 m_pOwner->impl_propertyChange( rEvt );
1194 //XVetoableChangeListener methods.
1196 //virtual
1197 void SAL_CALL ContentResultSetWrapperListener::vetoableChange( const PropertyChangeEvent& rEvt )
1199 if( m_pOwner )
1200 m_pOwner->impl_vetoableChange( rEvt );
1203 void ContentResultSetWrapperListener::impl_OwnerDies()
1205 m_pOwner = nullptr;
1208 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */