LibreOffice Module ucb (master) 1
contentresultsetwrapper.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20
22#include <com/sun/star/lang/DisposedException.hpp>
23#include <rtl/ustring.hxx>
24#include <osl/diagnose.h>
26
27using namespace com::sun::star::beans;
28using namespace com::sun::star::lang;
29using namespace com::sun::star::sdbc;
30using namespace com::sun::star::ucb;
31using namespace com::sun::star::uno;
32using namespace com::sun::star::util;
33using namespace comphelper;
34using namespace cppu;
35
36
37
38
40 Reference< XResultSet > const & xOrigin )
41 : m_xResultSetOrigin( xOrigin )
42 , m_nForwardOnly( 2 )
43 , m_bDisposed( false )
44 , m_bInDispose( false )
45{
47
48 OSL_ENSURE( m_xResultSetOrigin.is(), "XResultSet is required" );
49
51};
52
53
54void ContentResultSetWrapper::impl_init_xRowOrigin(std::unique_lock<std::mutex>&)
55{
56 if(m_xRowOrigin.is())
57 return;
58
59 Reference< XRow > xOrgig( m_xResultSetOrigin, UNO_QUERY );
60 m_xRowOrigin = xOrgig;
61 OSL_ENSURE( m_xRowOrigin.is(), "interface XRow is required" );
62}
63
65{
67 return;
68
70
72 OSL_ENSURE( m_xContentAccessOrigin.is(), "interface XContentAccess is required" );
73}
74
75
77{
78 if( m_xPropertySetOrigin.is() )
79 return;
80
82
84 OSL_ENSURE( m_xPropertySetOrigin.is(), "interface XPropertySet is required" );
85}
86
88{
89 //call this at the end of constructor of derived class
90
91
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() ) );
96}
97
99{
100 //call impl_deinit() at start of destructor of derived class
101};
102
104{
105 //call this at start of destructor of derived class
106
107 m_xMyListenerImpl->impl_OwnerDies();
108}
109
110//virtual
111void ContentResultSetWrapper::impl_initPropertySetInfo(std::unique_lock<std::mutex>& rGuard)
112{
113 if( m_xPropertySetInfo.is() )
114 return;
115
117 if( !m_xPropertySetOrigin.is() )
118 return;
119
121 m_xPropertySetOrigin->getPropertySetInfo();
122
123 m_xPropertySetInfo = xOrig;
124}
125
126void ContentResultSetWrapper::impl_EnsureNotDisposed(std::unique_lock<std::mutex>& /*rGuard*/)
127{
128 if( m_bDisposed )
129 throw DisposedException();
130}
131
132void ContentResultSetWrapper::impl_notifyPropertyChangeListeners( std::unique_lock<std::mutex>& rGuard, const PropertyChangeEvent& rEvt )
133{
134 // Notify listeners interested especially in the changed property.
136 m_aPropertyChangeListeners.getContainer( rGuard, rEvt.PropertyName );
137 if( pContainer )
138 {
139 pContainer->notifyEach( rGuard, &XPropertyChangeListener::propertyChange, rEvt );
140 }
141
142 // Notify listeners interested in all properties.
143 pContainer = m_aPropertyChangeListeners.getContainer( rGuard, OUString() );
144 if( pContainer )
145 {
146 pContainer->notifyEach( rGuard, &XPropertyChangeListener::propertyChange, rEvt );
147 }
148}
149
150void ContentResultSetWrapper::impl_notifyVetoableChangeListeners( std::unique_lock<std::mutex>& rGuard, const PropertyChangeEvent& rEvt )
151{
152 // Notify listeners interested especially in the changed property.
154 m_aVetoableChangeListeners.getContainer( rGuard, rEvt.PropertyName );
155 if( pContainer )
156 {
157 pContainer->notifyEach( rGuard, &XVetoableChangeListener::vetoableChange, rEvt );
158 }
159
160 // Notify listeners interested in all properties.
161 pContainer = m_aVetoableChangeListeners.getContainer( rGuard, OUString() );
162 if( pContainer )
163 {
164 pContainer->notifyEach( rGuard, &XVetoableChangeListener::vetoableChange, rEvt );
165 }
166}
167
168bool ContentResultSetWrapper::impl_isForwardOnly(std::unique_lock<std::mutex>& /*rGuard*/)
169{
170 //m_nForwardOnly == 2 -> don't know
171 //m_nForwardOnly == 1 -> YES
172 //m_nForwardOnly == 0 -> NO
173
174 //@todo replace this with lines in comment
175 m_nForwardOnly = 0;
176 return false;
177
178
179 /*
180 ReacquireableGuard aGuard( m_aMutex );
181 if( m_nForwardOnly == 2 )
182 {
183 aGuard.clear();
184 if( !getPropertySetInfo().is() )
185 {
186 aGuard.reacquire();
187 m_nForwardOnly = 0;
188 return m_nForwardOnly;
189 }
190 aGuard.reacquire();
191
192 OUString aName("ResultSetType");
193 //find out, if we are ForwardOnly and cache the value:
194
195 impl_init_xPropertySetOrigin();
196 if( !m_xPropertySetOrigin.is() )
197 {
198 OSL_FAIL( "broadcaster was disposed already" );
199 m_nForwardOnly = 0;
200 return m_nForwardOnly;
201 }
202
203 aGuard.clear();
204 Any aAny = m_xPropertySetOrigin->getPropertyValue( aName );
205
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;
213 }
214 return m_nForwardOnly;
215 */
216}
217
218
219// XInterface methods.
220
221css::uno::Any SAL_CALL ContentResultSetWrapper::queryInterface( const css::uno::Type & rType )
222{
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)
232 );
233 return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType );
234}
235
236// XComponent methods.
237
238// virtual
240{
241 std::unique_lock aGuard(m_aMutex);
243
244 bool isCleared = false;
246 return;
247 m_bInDispose = true;
248
249 if( m_xPropertySetOrigin.is() )
250 {
251 aGuard.unlock();
252 isCleared = true;
253 try
254 {
255 m_xPropertySetOrigin->removePropertyChangeListener(
256 OUString(), static_cast< XPropertyChangeListener * >( m_xMyListenerImpl.get() ) );
257 }
258 catch( Exception& )
259 {
260 OSL_FAIL( "could not remove PropertyChangeListener" );
261 }
262 try
263 {
264 m_xPropertySetOrigin->removeVetoableChangeListener(
265 OUString(), static_cast< XVetoableChangeListener * >( m_xMyListenerImpl.get() ) );
266 }
267 catch( Exception& )
268 {
269 OSL_FAIL( "could not remove VetoableChangeListener" );
270 }
271
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() ) );
275 }
276
277 if (isCleared)
278 aGuard.lock();
280 {
281 EventObject aEvt;
282 aEvt.Source = static_cast< XComponent * >( this );
284 }
285
287 {
288 EventObject aEvt;
289 aEvt.Source = static_cast< XPropertySet * >( this );
291 }
292
294 {
295 EventObject aEvt;
296 aEvt.Source = static_cast< XPropertySet * >( this );
298 }
299
300 m_bDisposed = true;
301 m_bInDispose = false;
302}
303
304
305// virtual
307{
308 std::unique_lock aGuard( m_aMutex );
310
311 m_aDisposeEventListeners.addInterface( aGuard, Listener );
312}
313
314
315// virtual
317{
318 std::unique_lock aGuard( m_aMutex );
320 m_aDisposeEventListeners.removeInterface( aGuard, Listener );
321}
322
323
324//XCloseable methods.
325
326//virtual
328{
329 {
330 std::unique_lock aGuard( m_aMutex );
332 }
333 dispose();
334}
335
336
337//XResultSetMetaDataSupplier methods.
338
339//virtual
341{
342 std::unique_lock aGuard(m_aMutex);
344
345 if( !m_xMetaDataFromOrigin.is() && m_xResultSetOrigin.is() )
346 {
348 m_xResultSetOrigin, UNO_QUERY );
349
350 if( xMetaDataSupplier.is() )
351 {
352 aGuard.unlock();
353
355 = xMetaDataSupplier->getMetaData();
356
357 aGuard.lock();
358 m_xMetaDataFromOrigin = xMetaData;
359 }
360 }
362}
363
364
365// XPropertySet methods.
366
367// virtual
369{
370 std::unique_lock aGuard( m_aMutex );
371 return getPropertySetInfoImpl(aGuard);
372}
373
374// virtual
376{
378 if( m_xPropertySetInfo.is() )
379 return m_xPropertySetInfo;
381 return m_xPropertySetInfo;
382}
383
384// virtual
385void SAL_CALL ContentResultSetWrapper::setPropertyValue( const OUString& rPropertyName, const Any& rValue )
386{
387 std::unique_lock aGuard( m_aMutex );
388 return setPropertyValueImpl(aGuard, rPropertyName, rValue);
389}
390
391// virtual
392void ContentResultSetWrapper::setPropertyValueImpl( std::unique_lock<std::mutex>& rGuard, const OUString& rPropertyName, const Any& rValue )
393{
396 if( !m_xPropertySetOrigin.is() )
397 {
398 OSL_FAIL( "broadcaster was disposed already" );
399 throw UnknownPropertyException();
400 }
401 m_xPropertySetOrigin->setPropertyValue( rPropertyName, rValue );
402}
403
404
405// virtual
406Any SAL_CALL ContentResultSetWrapper::getPropertyValue( const OUString& rPropertyName )
407{
408 std::unique_lock aGuard( m_aMutex );
411 if( !m_xPropertySetOrigin.is() )
412 {
413 OSL_FAIL( "broadcaster was disposed already" );
414 throw UnknownPropertyException();
415 }
416 return m_xPropertySetOrigin->getPropertyValue( rPropertyName );
417}
418
419
420// virtual
421void SAL_CALL ContentResultSetWrapper::addPropertyChangeListener( const OUString& aPropertyName, const Reference< XPropertyChangeListener >& xListener )
422{
423 std::unique_lock aGuard( m_aMutex );
425
426 if( !getPropertySetInfo().is() )
427 {
428 OSL_FAIL( "broadcaster was disposed already" );
429 throw UnknownPropertyException();
430 }
431
432 if( !aPropertyName.isEmpty() )
433 {
434 m_xPropertySetInfo->getPropertyByName( aPropertyName );
435 //throws UnknownPropertyException, if so
436 }
437
438 bool bNeedRegister = !m_aPropertyChangeListeners.hasContainedTypes(aGuard);
439 m_aPropertyChangeListeners.addInterface( aGuard, aPropertyName, xListener );
440 if( !bNeedRegister )
441 return;
442
444 if( !m_xPropertySetOrigin.is() )
445 {
446 OSL_FAIL( "broadcaster was disposed already" );
447 return;
448 }
449 try
450 {
451 m_xPropertySetOrigin->addPropertyChangeListener(
452 OUString(), static_cast< XPropertyChangeListener * >( m_xMyListenerImpl.get() ) );
453 }
454 catch( Exception& )
455 {
456 m_aPropertyChangeListeners.removeInterface( aGuard, aPropertyName, xListener );
457 throw;
458 }
459}
460
461
462// virtual
463void SAL_CALL ContentResultSetWrapper::addVetoableChangeListener( const OUString& rPropertyName, const Reference< XVetoableChangeListener >& xListener )
464{
465 std::unique_lock aGuard( m_aMutex );
467
468 if( !getPropertySetInfo().is() )
469 {
470 OSL_FAIL( "broadcaster was disposed already" );
471 throw UnknownPropertyException();
472 }
473 if( !rPropertyName.isEmpty() )
474 {
475 m_xPropertySetInfo->getPropertyByName( rPropertyName );
476 //throws UnknownPropertyException, if so
477 }
478
479 bool bNeedRegister = !m_aVetoableChangeListeners.hasContainedTypes(aGuard);
480 m_aVetoableChangeListeners.addInterface( aGuard, rPropertyName, xListener );
481 if( !bNeedRegister )
482 return;
483
485 {
486 if( !m_xPropertySetOrigin.is() )
487 {
488 OSL_FAIL( "broadcaster was disposed already" );
489 return;
490 }
491 }
492 try
493 {
494 m_xPropertySetOrigin->addVetoableChangeListener(
495 OUString(), static_cast< XVetoableChangeListener * >( m_xMyListenerImpl.get() ) );
496 }
497 catch( Exception& )
498 {
499 m_aVetoableChangeListeners.removeInterface( aGuard, rPropertyName, xListener );
500 throw;
501 }
502}
503
504
505// virtual
506void SAL_CALL ContentResultSetWrapper::removePropertyChangeListener( const OUString& rPropertyName, const Reference< XPropertyChangeListener >& xListener )
507{
508 std::unique_lock aGuard( m_aMutex );
510
511 //noop, if no listener registered
513 return;
514
516 m_aPropertyChangeListeners.getContainer( aGuard, rPropertyName );
517
518 if( !pContainer )
519 {
520 if( !rPropertyName.isEmpty() )
521 {
522 if( !getPropertySetInfo().is() )
523 throw UnknownPropertyException();
524
525 m_xPropertySetInfo->getPropertyByName( rPropertyName );
526 //throws UnknownPropertyException, if so
527 }
528 return; //the listener was not registered
529 }
530
531 m_aPropertyChangeListeners.removeInterface( aGuard, rPropertyName, xListener );
532
534 return;
535
537 if( !m_xPropertySetOrigin.is() )
538 {
539 OSL_FAIL( "broadcaster was disposed already" );
540 return;
541 }
542 try
543 {
544 m_xPropertySetOrigin->removePropertyChangeListener(
545 OUString(), static_cast< XPropertyChangeListener * >( m_xMyListenerImpl.get() ) );
546 }
547 catch( Exception& )
548 {
549 OSL_FAIL( "could not remove PropertyChangeListener" );
550 }
551}
552
553
554// virtual
555void SAL_CALL ContentResultSetWrapper::removeVetoableChangeListener( const OUString& rPropertyName, const Reference< XVetoableChangeListener >& xListener )
556{
557 std::unique_lock aGuard( m_aMutex );
559
560 //noop, if no listener registered
562 return;
564 m_aVetoableChangeListeners.getContainer( aGuard, rPropertyName );
565
566 if( !pContainer )
567 {
568 if( !rPropertyName.isEmpty() )
569 {
570 if( !getPropertySetInfo().is() )
571 throw UnknownPropertyException(rPropertyName);
572
573 m_xPropertySetInfo->getPropertyByName( rPropertyName );
574 //throws UnknownPropertyException, if so
575 }
576 return; //the listener was not registered
577 }
578
579 m_aVetoableChangeListeners.removeInterface( aGuard, rPropertyName, xListener );
580
582 return;
583
585 if( !m_xPropertySetOrigin.is() )
586 {
587 OSL_FAIL( "broadcaster was disposed already" );
588 return;
589 }
590 try
591 {
592 m_xPropertySetOrigin->removeVetoableChangeListener(
593 OUString(), static_cast< XVetoableChangeListener * >( m_xMyListenerImpl.get() ) );
594 }
595 catch( Exception& )
596 {
597 OSL_FAIL( "could not remove VetoableChangeListener" );
598 }
599}
600
601
602// own methods.
603
604
605//virtual, only called from ContentResultSetWrapperListener
607{
608 std::unique_lock aGuard(m_aMutex);
609
611
612 if( !m_xResultSetOrigin.is() )
613 return;
614
615 //release all references to the broadcaster:
616 m_xResultSetOrigin.clear();
617 if(m_xRowOrigin.is())
618 m_xRowOrigin.clear();
621 if(m_xPropertySetOrigin.is())
622 m_xPropertySetOrigin.clear();
623 m_xMetaDataFromOrigin.clear();
624 if(m_xPropertySetInfo.is())
625 m_xPropertySetInfo.clear();
626}
627
628//virtual, only called from ContentResultSetWrapperListener
629void ContentResultSetWrapper::impl_propertyChange( const PropertyChangeEvent& rEvt )
630{
631 std::unique_lock aGuard(m_aMutex);
632
634
635 PropertyChangeEvent aEvt( rEvt );
636 aEvt.Source = static_cast< XPropertySet * >( this );
637 aEvt.Further = false;
639}
640
641//virtual, only called from ContentResultSetWrapperListener
642void ContentResultSetWrapper::impl_vetoableChange( const PropertyChangeEvent& rEvt )
643{
644 std::unique_lock aGuard(m_aMutex);
646
647 PropertyChangeEvent aEvt( rEvt );
648 aEvt.Source = static_cast< XPropertySet * >( this );
649 aEvt.Further = false;
650
652}
653
654
655// XContentAccess methods. ( -- position dependent )
656
657
658// virtual
660{
661 std::unique_lock aGuard(m_aMutex);
663}
664// virtual
665OUString ContentResultSetWrapper::queryContentIdentifierStringImpl(std::unique_lock<std::mutex>& rGuard)
666{
669 if( !m_xContentAccessOrigin.is() )
670 {
671 OSL_FAIL( "broadcaster was disposed already" );
672 throw RuntimeException();
673 }
674 return m_xContentAccessOrigin->queryContentIdentifierString();
675}
676
677
678// virtual
680{
681 std::unique_lock aGuard(m_aMutex);
684 if( !m_xContentAccessOrigin.is() )
685 {
686 OSL_FAIL( "broadcaster was disposed already" );
687 throw RuntimeException();
688 }
689 return m_xContentAccessOrigin->queryContentIdentifier();
690}
691
692
693// virtual
695{
696 std::unique_lock aGuard(m_aMutex);
699 if( !m_xContentAccessOrigin.is() )
700 {
701 OSL_FAIL( "broadcaster was disposed already" );
702 throw RuntimeException();
703 }
704 return m_xContentAccessOrigin->queryContent();
705}
706
707
708// XResultSet methods.
709
710//virtual
711
713{
714 std::unique_lock aGuard(m_aMutex);
716
717 if( !m_xResultSetOrigin.is() )
718 {
719 OSL_FAIL( "broadcaster was disposed already" );
720 throw RuntimeException();
721 }
722 return m_xResultSetOrigin->next();
723}
724
725//virtual
727{
728 std::unique_lock aGuard(m_aMutex);
730
731 if( !m_xResultSetOrigin.is() )
732 {
733 OSL_FAIL( "broadcaster was disposed already" );
734 throw RuntimeException();
735 }
736 return m_xResultSetOrigin->previous();
737}
738
739//virtual
741{
742 std::unique_lock aGuard(m_aMutex);
744
745 if( !m_xResultSetOrigin.is() )
746 {
747 OSL_FAIL( "broadcaster was disposed already" );
748 throw RuntimeException();
749 }
750 return m_xResultSetOrigin->absolute( row );
751}
752
753//virtual
755{
756 std::unique_lock aGuard(m_aMutex);
758
759 if( !m_xResultSetOrigin.is() )
760 {
761 OSL_FAIL( "broadcaster was disposed already" );
762 throw RuntimeException();
763 }
764 return m_xResultSetOrigin->relative( rows );
765}
766
767
768//virtual
770{
771 std::unique_lock aGuard(m_aMutex);
773
774 if( !m_xResultSetOrigin.is() )
775 {
776 OSL_FAIL( "broadcaster was disposed already" );
777 throw RuntimeException();
778 }
779 return m_xResultSetOrigin->first();
780}
781
782//virtual
784{
785 std::unique_lock aGuard(m_aMutex);
787
788 if( !m_xResultSetOrigin.is() )
789 {
790 OSL_FAIL( "broadcaster was disposed already" );
791 throw RuntimeException();
792 }
793 return m_xResultSetOrigin->last();
794}
795
796//virtual
798{
799 std::unique_lock aGuard(m_aMutex);
801
802 if( !m_xResultSetOrigin.is() )
803 {
804 OSL_FAIL( "broadcaster was disposed already" );
805 throw RuntimeException();
806 }
807 m_xResultSetOrigin->beforeFirst();
808}
809
810//virtual
812{
813 std::unique_lock aGuard(m_aMutex);
815
816 if( !m_xResultSetOrigin.is() )
817 {
818 OSL_FAIL( "broadcaster was disposed already" );
819 throw RuntimeException();
820 }
821 m_xResultSetOrigin->afterLast();
822}
823
824//virtual
826{
827 std::unique_lock aGuard(m_aMutex);
829
830 if( !m_xResultSetOrigin.is() )
831 {
832 OSL_FAIL( "broadcaster was disposed already" );
833 throw RuntimeException();
834 }
835 return m_xResultSetOrigin->isAfterLast();
836}
837
838//virtual
840{
841 std::unique_lock aGuard(m_aMutex);
843
844 if( !m_xResultSetOrigin.is() )
845 {
846 OSL_FAIL( "broadcaster was disposed already" );
847 throw RuntimeException();
848 }
849 return m_xResultSetOrigin->isBeforeFirst();
850}
851
852//virtual
854{
855 std::unique_lock aGuard(m_aMutex);
857
858 if( !m_xResultSetOrigin.is() )
859 {
860 OSL_FAIL( "broadcaster was disposed already" );
861 throw RuntimeException();
862 }
863 return m_xResultSetOrigin->isFirst();
864}
865
866//virtual
868{
869 std::unique_lock aGuard(m_aMutex);
871
872 if( !m_xResultSetOrigin.is() )
873 {
874 OSL_FAIL( "broadcaster was disposed already" );
875 throw RuntimeException();
876 }
877 return m_xResultSetOrigin->isLast();
878}
879
880
881//virtual
883{
884 std::unique_lock aGuard(m_aMutex);
886
887 if( !m_xResultSetOrigin.is() )
888 {
889 OSL_FAIL( "broadcaster was disposed already" );
890 throw RuntimeException();
891 }
892 return m_xResultSetOrigin->getRow();
893}
894
895//virtual
897{
898 std::unique_lock aGuard(m_aMutex);
900
901 if( !m_xResultSetOrigin.is() )
902 {
903 OSL_FAIL( "broadcaster was disposed already" );
904 throw RuntimeException();
905 }
906 m_xResultSetOrigin->refreshRow();
907}
908
909//virtual
911{
912 std::unique_lock aGuard(m_aMutex);
914
915 if( !m_xResultSetOrigin.is() )
916 {
917 OSL_FAIL( "broadcaster was disposed already" );
918 throw RuntimeException();
919 }
920 return m_xResultSetOrigin->rowUpdated();
921}
922
923//virtual
925{
926 std::unique_lock aGuard(m_aMutex);
928
929 if( !m_xResultSetOrigin.is() )
930 {
931 OSL_FAIL( "broadcaster was disposed already" );
932 throw RuntimeException();
933 }
934 return m_xResultSetOrigin->rowInserted();
935}
936
937//virtual
939{
940 std::unique_lock aGuard(m_aMutex);
942
943 if( !m_xResultSetOrigin.is() )
944 {
945 OSL_FAIL( "broadcaster was disposed already" );
946 throw RuntimeException();
947 }
948 return m_xResultSetOrigin->rowDeleted();
949}
950
951//virtual
953{
954 std::unique_lock aGuard(m_aMutex);
956 //@todo ?return anything
958}
959
960
961// XRow methods.
962
963
965{
966 std::unique_lock aGuard(m_aMutex);
968 impl_init_xRowOrigin(aGuard);
969 if( !m_xRowOrigin.is() )
970 {
971 OSL_FAIL( "broadcaster was disposed already" );
972 throw RuntimeException();
973 }
974}
975
976//virtual
978{
979 std::unique_lock aGuard(m_aMutex);
981 impl_init_xRowOrigin(aGuard);
982 if( !m_xRowOrigin.is() )
983 {
984 OSL_FAIL( "broadcaster was disposed already" );
985 throw RuntimeException();
986 }
987 return m_xRowOrigin->wasNull();
988}
989
990//virtual
991OUString SAL_CALL ContentResultSetWrapper::getString( sal_Int32 columnIndex )
992{
993 verifyGet();
994 return m_xRowOrigin->getString( columnIndex );
995}
996
997//virtual
998sal_Bool SAL_CALL ContentResultSetWrapper::getBoolean( sal_Int32 columnIndex )
999{
1000 verifyGet();
1001 return m_xRowOrigin->getBoolean( columnIndex );
1002}
1003
1004//virtual
1005sal_Int8 SAL_CALL ContentResultSetWrapper::getByte( sal_Int32 columnIndex )
1006{
1007 verifyGet();
1008 return m_xRowOrigin->getByte( columnIndex );
1009}
1010
1011//virtual
1012sal_Int16 SAL_CALL ContentResultSetWrapper::getShort( sal_Int32 columnIndex )
1013{
1014 verifyGet();
1015 return m_xRowOrigin->getShort( columnIndex );
1016}
1017
1018//virtual
1019sal_Int32 SAL_CALL ContentResultSetWrapper::getInt( sal_Int32 columnIndex )
1020{
1021 verifyGet();
1022 return m_xRowOrigin->getInt( columnIndex );
1023}
1024
1025//virtual
1026sal_Int64 SAL_CALL ContentResultSetWrapper::getLong( sal_Int32 columnIndex )
1027{
1028 verifyGet();
1029 return m_xRowOrigin->getLong( columnIndex );
1030}
1031
1032//virtual
1033float SAL_CALL ContentResultSetWrapper::getFloat( sal_Int32 columnIndex )
1034{
1035 verifyGet();
1036 return m_xRowOrigin->getFloat( columnIndex );
1037}
1038
1039//virtual
1040double SAL_CALL ContentResultSetWrapper::getDouble( sal_Int32 columnIndex )
1041{
1042 verifyGet();
1043 return m_xRowOrigin->getDouble( columnIndex );
1044}
1045
1046//virtual
1048{
1049 verifyGet();
1050 return m_xRowOrigin->getBytes( columnIndex );
1051}
1052
1053//virtual
1054Date SAL_CALL ContentResultSetWrapper::getDate( sal_Int32 columnIndex )
1055{
1056 verifyGet();
1057 return m_xRowOrigin->getDate( columnIndex );
1058}
1059
1060//virtual
1061Time SAL_CALL ContentResultSetWrapper::getTime( sal_Int32 columnIndex )
1062{
1063 verifyGet();
1064 return m_xRowOrigin->getTime( columnIndex );
1065}
1066
1067//virtual
1068DateTime SAL_CALL ContentResultSetWrapper::getTimestamp( sal_Int32 columnIndex )
1069{
1070 verifyGet();
1071 return m_xRowOrigin->getTimestamp( columnIndex );
1072}
1073
1074//virtual
1076{
1077 verifyGet();
1078 return m_xRowOrigin->getBinaryStream( columnIndex );
1079}
1080
1081//virtual
1083{
1084 verifyGet();
1085 return m_xRowOrigin->getCharacterStream( columnIndex );
1086}
1087
1088//virtual
1090{
1091 //if you change this macro please pay attention to
1092 //define XROW_GETXXX, where this is similar implemented
1093
1094 std::unique_lock aGuard(m_aMutex);
1095 impl_EnsureNotDisposed(aGuard);
1096 impl_init_xRowOrigin(aGuard);
1097 if( !m_xRowOrigin.is() )
1098 {
1099 OSL_FAIL( "broadcaster was disposed already" );
1100 throw RuntimeException();
1101 }
1102 return m_xRowOrigin->getObject( columnIndex, typeMap );
1103}
1104
1105//virtual
1107{
1108 verifyGet();
1109 return m_xRowOrigin->getRef( columnIndex );
1110}
1111
1112//virtual
1114{
1115 verifyGet();
1116 return m_xRowOrigin->getBlob( columnIndex );
1117}
1118
1119//virtual
1121{
1122 verifyGet();
1123 return m_xRowOrigin->getClob( columnIndex );
1124}
1125
1126//virtual
1128{
1129 verifyGet();
1130 return m_xRowOrigin->getArray( columnIndex );
1131}
1132
1133
1134
1135
1137 ContentResultSetWrapper* pOwner )
1138 : m_pOwner( pOwner )
1139{
1140}
1141
1143{
1144}
1145
1146
1147// XInterface methods.
1149 noexcept
1150{
1151 OWeakObject::acquire();
1152}
1153
1155 noexcept
1156{
1157 OWeakObject::release();
1158}
1159
1160css::uno::Any SAL_CALL ContentResultSetWrapperListener::queryInterface( const css::uno::Type & rType )
1161{
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)
1168 );
1169 return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType );
1170}
1171
1172//XEventListener methods.
1173
1174
1175//virtual
1176void SAL_CALL ContentResultSetWrapperListener::disposing( const EventObject& rEventObject )
1177{
1178 if( m_pOwner )
1179 m_pOwner->impl_disposing( rEventObject );
1180}
1181
1182
1183//XPropertyChangeListener methods.
1184
1185
1186//virtual
1187void SAL_CALL ContentResultSetWrapperListener::propertyChange( const PropertyChangeEvent& rEvt )
1188{
1189 if( m_pOwner )
1191}
1192
1193
1194//XVetoableChangeListener methods.
1195
1196//virtual
1197void SAL_CALL ContentResultSetWrapperListener::vetoableChange( const PropertyChangeEvent& rEvt )
1198{
1199 if( m_pOwner )
1201}
1202
1204{
1205 m_pOwner = nullptr;
1206}
1207
1208/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
ContentResultSetWrapperListener(ContentResultSetWrapper *pOwner)
virtual void SAL_CALL propertyChange(const css::beans::PropertyChangeEvent &evt) override
virtual void SAL_CALL disposing(const css::lang::EventObject &Source) override
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
virtual void SAL_CALL vetoableChange(const css::beans::PropertyChangeEvent &aEvent) override
virtual void SAL_CALL acquire() noexcept override
virtual void SAL_CALL release() noexcept override
virtual void impl_disposing(const css::lang::EventObject &Source)
virtual sal_Bool SAL_CALL first() override
virtual sal_Bool SAL_CALL isLast() override
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
ContentResultSetWrapper(css::uno::Reference< css::sdbc::XResultSet > const &xOrigin)
virtual void SAL_CALL dispose() override final
virtual css::uno::Reference< css::sdbc::XArray > SAL_CALL getArray(sal_Int32 columnIndex) override
css::uno::Reference< css::sdbc::XResultSet > m_xResultSetOrigin
void impl_notifyVetoableChangeListeners(std::unique_lock< std::mutex > &rGuard, const css::beans::PropertyChangeEvent &rEvt)
VetoableChangeListenerContainer_Impl m_aVetoableChangeListeners
virtual sal_Bool SAL_CALL absolute(sal_Int32 row) override
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) final override
void impl_EnsureNotDisposed(std::unique_lock< std::mutex > &rGuard)
virtual void SAL_CALL afterLast() override
virtual void SAL_CALL addVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
comphelper::OInterfaceContainerHelper4< css::lang::XEventListener > m_aDisposeEventListeners
In dispose call.
virtual sal_Int16 SAL_CALL getShort(sal_Int32 columnIndex) override
css::uno::Reference< css::sdbc::XResultSetMetaData > m_xMetaDataFromOrigin
virtual sal_Int64 SAL_CALL getLong(sal_Int32 columnIndex) override
virtual void SAL_CALL addPropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
virtual OUString SAL_CALL queryContentIdentifierString() override final
virtual sal_Bool SAL_CALL rowDeleted() override
virtual css::uno::Any SAL_CALL getObject(sal_Int32 columnIndex, const css::uno::Reference< css::container::XNameAccess > &typeMap) override
virtual css::uno::Reference< css::ucb::XContent > SAL_CALL queryContent() override
css::uno::Reference< css::beans::XPropertySetInfo > m_xPropertySetInfo
! call impl_init_xPropertySetOrigin() bevor you access this member
virtual sal_Bool SAL_CALL rowInserted() override
virtual sal_Bool SAL_CALL getBoolean(sal_Int32 columnIndex) override
virtual ~ContentResultSetWrapper() override
virtual sal_Bool SAL_CALL relative(sal_Int32 rows) override
virtual OUString queryContentIdentifierStringImpl(std::unique_lock< std::mutex > &rGuard)
virtual sal_Bool SAL_CALL isAfterLast() override
virtual void SAL_CALL removeVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
virtual void SAL_CALL removePropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &aListener) override
virtual void setPropertyValueImpl(std::unique_lock< std::mutex > &rGuard, const OUString &aPropertyName, const css::uno::Any &aValue)
virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > &Listener) override
virtual css::uno::Reference< css::io::XInputStream > SAL_CALL getCharacterStream(sal_Int32 columnIndex) override
virtual void SAL_CALL refreshRow() override
virtual sal_Bool SAL_CALL next() override
virtual sal_Bool SAL_CALL isBeforeFirst() override
rtl::Reference< ContentResultSetWrapperListener > m_xMyListenerImpl
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
virtual OUString SAL_CALL getString(sal_Int32 columnIndex) override
virtual css::uno::Reference< css::ucb::XContentIdentifier > SAL_CALL queryContentIdentifier() override
virtual sal_Bool SAL_CALL wasNull() override
virtual void impl_propertyChange(const css::beans::PropertyChangeEvent &evt)
css::uno::Reference< css::beans::XPropertySet > m_xPropertySetOrigin
! call impl_init_xContentAccessOrigin() bevor you access this member
virtual void SAL_CALL close() override
virtual css::util::Date SAL_CALL getDate(sal_Int32 columnIndex) override
css::uno::Reference< css::sdbc::XRow > m_xRowOrigin
virtual css::uno::Reference< css::sdbc::XRef > SAL_CALL getRef(sal_Int32 columnIndex) override
PropertyChangeListenerContainer_Impl m_aPropertyChangeListeners
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getBytes(sal_Int32 columnIndex) override
virtual css::util::DateTime SAL_CALL getTimestamp(sal_Int32 columnIndex) override
virtual css::uno::Reference< css::sdbc::XBlob > SAL_CALL getBlob(sal_Int32 columnIndex) override
virtual sal_Int8 SAL_CALL getByte(sal_Int32 columnIndex) override
virtual sal_Bool SAL_CALL last() override
virtual sal_Bool SAL_CALL rowUpdated() override
void impl_init_xPropertySetOrigin(std::unique_lock< std::mutex > &)
css::uno::Reference< css::beans::XPropertySetInfo > getPropertySetInfoImpl(std::unique_lock< std::mutex > &rGuard)
bool impl_isForwardOnly(std::unique_lock< std::mutex > &rGuard)
virtual css::uno::Reference< css::io::XInputStream > SAL_CALL getBinaryStream(sal_Int32 columnIndex) override
void impl_init_xRowOrigin(std::unique_lock< std::mutex > &)
void impl_notifyPropertyChangeListeners(std::unique_lock< std::mutex > &rGuard, const css::beans::PropertyChangeEvent &rEvt)
virtual css::util::Time SAL_CALL getTime(sal_Int32 columnIndex) override
void impl_init_xContentAccessOrigin(std::unique_lock< std::mutex > &)
virtual css::uno::Reference< css::sdbc::XClob > SAL_CALL getClob(sal_Int32 columnIndex) override
virtual sal_Int32 SAL_CALL getInt(sal_Int32 columnIndex) override
virtual void impl_vetoableChange(const css::beans::PropertyChangeEvent &aEvent)
css::uno::Reference< css::ucb::XContentAccess > m_xContentAccessOrigin
! call impl_init_xRowOrigin() bevor you access this member
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override final
virtual double SAL_CALL getDouble(sal_Int32 columnIndex) override
virtual css::uno::Reference< css::sdbc::XResultSetMetaData > SAL_CALL getMetaData() override
virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > &Listener) override
virtual sal_Bool SAL_CALL previous() override
bool m_bInDispose
Dispose call ready.
virtual sal_Int32 SAL_CALL getRow() override
virtual sal_Bool SAL_CALL isFirst() override
virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getStatement() override
virtual void SAL_CALL beforeFirst() override
virtual float SAL_CALL getFloat(sal_Int32 columnIndex) override
virtual void impl_initPropertySetInfo(std::unique_lock< std::mutex > &rGuard)
sal_Int32 addInterface(std::unique_lock< std::mutex > &rGuard, const css::uno::Reference< ListenerT > &rxIFace)
void notifyEach(std::unique_lock< std::mutex > &rGuard, void(SAL_CALL ListenerT::*NotificationMethod)(const EventT &), const EventT &Event) const
void disposeAndClear(::std::unique_lock<::std::mutex > &rGuard, const css::lang::EventObject &rEvt)
sal_Int32 getLength(std::unique_lock< std::mutex > &rGuard) const
sal_Int32 removeInterface(std::unique_lock< std::mutex > &rGuard, const css::uno::Reference< ListenerT > &rxIFace)
sal_Int32 removeInterface(::std::unique_lock<::std::mutex > &rGuard, const key &rKey, const css::uno::Reference< listener > &rListener)
bool hasContainedTypes(std::unique_lock< std::mutex > &rGuard) const
sal_Int32 addInterface(::std::unique_lock<::std::mutex > &rGuard, const key &rKey, const css::uno::Reference< listener > &rListener)
void disposeAndClear(std::unique_lock< std::mutex > &rGuard, const css::lang::EventObject &rEvt)
OInterfaceContainerHelper4< listener > * getContainer(std::unique_lock< std::mutex > &rGuard, const key &rKey) const
bool m_bDisposed
SvLinkSource * pOwner
@ Exception
class SAL_NO_VTABLE XPropertySet
css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType, Interface1 *p1)
ContentProvider * m_pOwner
Definition: pkgprovider.cxx:58
unsigned char sal_Bool
signed char sal_Int8