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/sdbc/FetchDirection.hpp>
23 #include <com/sun/star/ucb/FetchError.hpp>
24 #include <com/sun/star/beans/PropertyAttribute.hpp>
25 #include <com/sun/star/sdbc/ResultSetType.hpp>
26 #include <com/sun/star/lang/DisposedException.hpp>
27 #include <rtl/ustring.hxx>
28 #include <osl/diagnose.h>
30 
31 using namespace com::sun::star::beans;
32 using namespace com::sun::star::lang;
33 using namespace com::sun::star::sdbc;
34 using namespace com::sun::star::ucb;
35 using namespace com::sun::star::uno;
36 using namespace com::sun::star::util;
37 using namespace comphelper;
38 using namespace cppu;
39 
40 
41 // class ContentResultSetWrapper
42 
43 
45  Reference< XResultSet > const & xOrigin )
46  : m_xResultSetOrigin( xOrigin )
47  , m_nForwardOnly( 2 )
48  , m_bDisposed( false )
49  , m_bInDispose( false )
50 {
52 
53  OSL_ENSURE( m_xResultSetOrigin.is(), "XResultSet is required" );
54 
56 };
57 
58 
60 {
61  {
62  osl::Guard< osl::Mutex > aGuard( m_aMutex );
63  if(m_xRowOrigin.is())
64  return;
65  }
66 
67  Reference< XRow > xOrgig( m_xResultSetOrigin, UNO_QUERY );
68 
69  {
70  osl::Guard< osl::Mutex > aGuard( m_aMutex );
71  m_xRowOrigin = xOrgig;
72  OSL_ENSURE( m_xRowOrigin.is(), "interface XRow is required" );
73  }
74 }
75 
77 {
78  {
79  osl::Guard< osl::Mutex > aGuard( m_aMutex );
80  if(m_xContentAccessOrigin.is())
81  return;
82  }
83 
85 
86  {
87  osl::Guard< osl::Mutex > aGuard( m_aMutex );
88  m_xContentAccessOrigin = xOrgig;
89  OSL_ENSURE( m_xContentAccessOrigin.is(), "interface XContentAccess is required" );
90  }
91 }
92 
93 
95 {
96  {
97  osl::Guard< osl::Mutex > aGuard( m_aMutex );
98  if( m_xPropertySetOrigin.is() )
99  return;
100  }
101 
102  Reference< XPropertySet > xOrig( m_xResultSetOrigin, UNO_QUERY );
103 
104  {
105  osl::Guard< osl::Mutex > aGuard( m_aMutex );
106  m_xPropertySetOrigin = xOrig;
107  OSL_ENSURE( m_xPropertySetOrigin.is(), "interface XPropertySet is required" );
108  }
109 }
110 
112 {
113  //call this at the end of constructor of derived class
114 
115 
116  //listen to disposing from Origin:
117  Reference< XComponent > xComponentOrigin( m_xResultSetOrigin, UNO_QUERY );
118  OSL_ENSURE( xComponentOrigin.is(), "interface XComponent is required" );
119  xComponentOrigin->addEventListener( static_cast< XPropertyChangeListener * >( m_xMyListenerImpl.get() ) );
120 }
121 
123 {
124  //call impl_deinit() at start of destructor of derived class
125 };
126 
128 {
129  //call this at start of destructor of derived class
130 
131  m_xMyListenerImpl->impl_OwnerDies();
132 }
133 
134 //virtual
136 {
137  {
138  osl::Guard< osl::Mutex > aGuard( m_aMutex );
139  if( m_xPropertySetInfo.is() )
140  return;
141 
143  if( !m_xPropertySetOrigin.is() )
144  return;
145  }
146 
148  m_xPropertySetOrigin->getPropertySetInfo();
149 
150  {
151  osl::Guard< osl::Mutex > aGuard( m_aMutex );
152  m_xPropertySetInfo = xOrig;
153  }
154 }
155 
157 {
158  osl::Guard< osl::Mutex > aGuard( m_aMutex );
159  if( m_bDisposed )
160  throw DisposedException();
161 }
162 
164 {
165  osl::Guard< osl::Mutex > aGuard( m_aMutex );
169 }
170 
172 {
173  osl::Guard< osl::Mutex > aGuard( m_aMutex );
177 }
178 
179 void ContentResultSetWrapper::impl_notifyPropertyChangeListeners( const PropertyChangeEvent& rEvt )
180 {
181  {
182  osl::Guard< osl::Mutex > aGuard( m_aMutex );
184  return;
185  }
186 
187  // Notify listeners interested especially in the changed property.
188  OInterfaceContainerHelper* pContainer =
189  m_pPropertyChangeListeners->getContainer( rEvt.PropertyName );
190  if( pContainer )
191  {
192  OInterfaceIteratorHelper aIter( *pContainer );
193  while( aIter.hasMoreElements() )
194  {
196  aIter.next(), UNO_QUERY );
197  if( xListener.is() )
198  xListener->propertyChange( rEvt );
199  }
200  }
201 
202  // Notify listeners interested in all properties.
203  pContainer = m_pPropertyChangeListeners->getContainer( OUString() );
204  if( pContainer )
205  {
206  OInterfaceIteratorHelper aIter( *pContainer );
207  while( aIter.hasMoreElements() )
208  {
210  aIter.next(), UNO_QUERY );
211  if( xListener.is() )
212  xListener->propertyChange( rEvt );
213  }
214  }
215 }
216 
217 void ContentResultSetWrapper::impl_notifyVetoableChangeListeners( const PropertyChangeEvent& rEvt )
218 {
219  {
220  osl::Guard< osl::Mutex > aGuard( m_aMutex );
222  return;
223  }
224 
225  // Notify listeners interested especially in the changed property.
226  OInterfaceContainerHelper* pContainer =
227  m_pVetoableChangeListeners->getContainer( rEvt.PropertyName );
228  if( pContainer )
229  {
230  OInterfaceIteratorHelper aIter( *pContainer );
231  while( aIter.hasMoreElements() )
232  {
234  aIter.next(), UNO_QUERY );
235  if( xListener.is() )
236  xListener->vetoableChange( rEvt );
237  }
238  }
239 
240  // Notify listeners interested in all properties.
241  pContainer = m_pVetoableChangeListeners->getContainer( OUString() );
242  if( pContainer )
243  {
244  OInterfaceIteratorHelper aIter( *pContainer );
245  while( aIter.hasMoreElements() )
246  {
248  aIter.next(), UNO_QUERY );
249  if( xListener.is() )
250  xListener->vetoableChange( rEvt );
251  }
252  }
253 }
254 
256 {
257  //m_nForwardOnly == 2 -> don't know
258  //m_nForwardOnly == 1 -> YES
259  //m_nForwardOnly == 0 -> NO
260 
261  //@todo replace this with lines in comment
262  osl::Guard< osl::Mutex > aGuard( m_aMutex );
263  m_nForwardOnly = 0;
264  return false;
265 
266 
267  /*
268  ReacquireableGuard aGuard( m_aMutex );
269  if( m_nForwardOnly == 2 )
270  {
271  aGuard.clear();
272  if( !getPropertySetInfo().is() )
273  {
274  aGuard.reacquire();
275  m_nForwardOnly = 0;
276  return m_nForwardOnly;
277  }
278  aGuard.reacquire();
279 
280  OUString aName("ResultSetType");
281  //find out, if we are ForwardOnly and cache the value:
282 
283  impl_init_xPropertySetOrigin();
284  if( !m_xPropertySetOrigin.is() )
285  {
286  OSL_FAIL( "broadcaster was disposed already" );
287  m_nForwardOnly = 0;
288  return m_nForwardOnly;
289  }
290 
291  aGuard.clear();
292  Any aAny = m_xPropertySetOrigin->getPropertyValue( aName );
293 
294  aGuard.reacquire();
295  long nResultSetType;
296  if( ( aAny >>= nResultSetType ) &&
297  ( nResultSetType == ResultSetType::FORWARD_ONLY ) )
298  m_nForwardOnly = 1;
299  else
300  m_nForwardOnly = 0;
301  }
302  return m_nForwardOnly;
303  */
304 }
305 
306 
307 // XInterface methods.
308 
309 css::uno::Any SAL_CALL ContentResultSetWrapper::queryInterface( const css::uno::Type & rType )
310 {
311  //list all interfaces inclusive baseclasses of interfaces
312  css::uno::Any aRet = cppu::queryInterface( rType,
313  static_cast< XComponent* >(this),
314  static_cast< XCloseable* >(this),
315  static_cast< XResultSetMetaDataSupplier* >(this),
316  static_cast< XPropertySet* >(this),
317  static_cast< XContentAccess* >(this),
318  static_cast< XResultSet* >(this),
319  static_cast< XRow* >(this)
320  );
321  return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType );
322 }
323 
324 // XComponent methods.
325 
326 // virtual
328 {
330 
331  bool isCleared = false;
332  osl::ResettableMutexGuard aGuard(m_aMutex);
333  if( m_bInDispose || m_bDisposed )
334  return;
335  m_bInDispose = true;
336 
337  if( m_xPropertySetOrigin.is() )
338  {
339  aGuard.clear();
340  isCleared = true;
341  try
342  {
343  m_xPropertySetOrigin->removePropertyChangeListener(
344  OUString(), static_cast< XPropertyChangeListener * >( m_xMyListenerImpl.get() ) );
345  }
346  catch( Exception& )
347  {
348  OSL_FAIL( "could not remove PropertyChangeListener" );
349  }
350  try
351  {
352  m_xPropertySetOrigin->removeVetoableChangeListener(
353  OUString(), static_cast< XVetoableChangeListener * >( m_xMyListenerImpl.get() ) );
354  }
355  catch( Exception& )
356  {
357  OSL_FAIL( "could not remove VetoableChangeListener" );
358  }
359 
360  Reference< XComponent > xComponentOrigin( m_xResultSetOrigin, UNO_QUERY );
361  OSL_ENSURE( xComponentOrigin.is(), "interface XComponent is required" );
362  xComponentOrigin->removeEventListener( static_cast< XPropertyChangeListener * >( m_xMyListenerImpl.get() ) );
363  }
364 
365  if (isCleared)
366  {
367  aGuard.reset();
368  isCleared = false;
369  }
371  {
372  EventObject aEvt;
373  aEvt.Source = static_cast< XComponent * >( this );
374 
375  aGuard.clear();
376  isCleared = true;
377  m_pDisposeEventListeners->disposeAndClear( aEvt );
378  }
379 
380  if (isCleared)
381  {
382  aGuard.reset();
383  isCleared = false;
384  }
386  {
387  EventObject aEvt;
388  aEvt.Source = static_cast< XPropertySet * >( this );
389 
390  aGuard.clear();
391  isCleared = true;
392  m_pPropertyChangeListeners->disposeAndClear( aEvt );
393  }
394 
395  if (isCleared)
396  {
397  aGuard.reset();
398  isCleared = false;
399  }
401  {
402  EventObject aEvt;
403  aEvt.Source = static_cast< XPropertySet * >( this );
404 
405  aGuard.clear();
406  isCleared = true;
407  m_pVetoableChangeListeners->disposeAndClear( aEvt );
408  }
409 
410  if (isCleared)
411  {
412  aGuard.reset();
413  }
414  m_bDisposed = true;
415  m_bInDispose = false;
416 }
417 
418 
419 // virtual
421 {
423  osl::Guard< osl::Mutex > aGuard( m_aMutex );
424 
428 
429  m_pDisposeEventListeners->addInterface( Listener );
430 }
431 
432 
433 // virtual
435 {
437  osl::Guard< osl::Mutex > aGuard( m_aMutex );
438 
440  m_pDisposeEventListeners->removeInterface( Listener );
441 }
442 
443 
444 //XCloseable methods.
445 
446 //virtual
448 {
450  dispose();
451 }
452 
453 
454 //XResultSetMetaDataSupplier methods.
455 
456 //virtual
458 {
460 
461  osl::ResettableMutexGuard aGuard(m_aMutex);
462  if( !m_xMetaDataFromOrigin.is() && m_xResultSetOrigin.is() )
463  {
464  Reference< XResultSetMetaDataSupplier > xMetaDataSupplier(
465  m_xResultSetOrigin, UNO_QUERY );
466 
467  if( xMetaDataSupplier.is() )
468  {
469  aGuard.clear();
470 
472  = xMetaDataSupplier->getMetaData();
473 
474  aGuard.reset();
475  m_xMetaDataFromOrigin = xMetaData;
476  }
477  }
478  return m_xMetaDataFromOrigin;
479 }
480 
481 
482 // XPropertySet methods.
483 
484 // virtual
486 {
488  {
489  osl::Guard< osl::Mutex > aGuard( m_aMutex );
490  if( m_xPropertySetInfo.is() )
491  return m_xPropertySetInfo;
492  }
494  return m_xPropertySetInfo;
495 }
496 
497 // virtual
498 void SAL_CALL ContentResultSetWrapper::setPropertyValue( const OUString& rPropertyName, const Any& rValue )
499 {
502  if( !m_xPropertySetOrigin.is() )
503  {
504  OSL_FAIL( "broadcaster was disposed already" );
505  throw UnknownPropertyException();
506  }
507  m_xPropertySetOrigin->setPropertyValue( rPropertyName, rValue );
508 }
509 
510 
511 // virtual
512 Any SAL_CALL ContentResultSetWrapper::getPropertyValue( const OUString& rPropertyName )
513 {
516  if( !m_xPropertySetOrigin.is() )
517  {
518  OSL_FAIL( "broadcaster was disposed already" );
519  throw UnknownPropertyException();
520  }
521  return m_xPropertySetOrigin->getPropertyValue( rPropertyName );
522 }
523 
524 
525 // virtual
526 void SAL_CALL ContentResultSetWrapper::addPropertyChangeListener( const OUString& aPropertyName, const Reference< XPropertyChangeListener >& xListener )
527 {
529 
530  if( !getPropertySetInfo().is() )
531  {
532  OSL_FAIL( "broadcaster was disposed already" );
533  throw UnknownPropertyException();
534  }
535 
536  if( !aPropertyName.isEmpty() )
537  {
538  m_xPropertySetInfo->getPropertyByName( aPropertyName );
539  //throws UnknownPropertyException, if so
540  }
541 
543  bool bNeedRegister = !m_pPropertyChangeListeners->
544  getContainedTypes().hasElements();
545  m_pPropertyChangeListeners->addInterface( aPropertyName, xListener );
546  if( bNeedRegister )
547  {
549  {
550  osl::Guard< osl::Mutex > aGuard( m_aMutex );
551  if( !m_xPropertySetOrigin.is() )
552  {
553  OSL_FAIL( "broadcaster was disposed already" );
554  return;
555  }
556  }
557  try
558  {
559  m_xPropertySetOrigin->addPropertyChangeListener(
560  OUString(), static_cast< XPropertyChangeListener * >( m_xMyListenerImpl.get() ) );
561  }
562  catch( Exception& )
563  {
564  m_pPropertyChangeListeners->removeInterface( aPropertyName, xListener );
565  throw;
566  }
567  }
568 }
569 
570 
571 // virtual
572 void SAL_CALL ContentResultSetWrapper::addVetoableChangeListener( const OUString& rPropertyName, const Reference< XVetoableChangeListener >& xListener )
573 {
575 
576  if( !getPropertySetInfo().is() )
577  {
578  OSL_FAIL( "broadcaster was disposed already" );
579  throw UnknownPropertyException();
580  }
581  if( !rPropertyName.isEmpty() )
582  {
583  m_xPropertySetInfo->getPropertyByName( rPropertyName );
584  //throws UnknownPropertyException, if so
585  }
586 
588  bool bNeedRegister = !m_pVetoableChangeListeners->
589  getContainedTypes().hasElements();
590  m_pVetoableChangeListeners->addInterface( rPropertyName, xListener );
591  if( bNeedRegister )
592  {
594  {
595  osl::Guard< osl::Mutex > aGuard( m_aMutex );
596  if( !m_xPropertySetOrigin.is() )
597  {
598  OSL_FAIL( "broadcaster was disposed already" );
599  return;
600  }
601  }
602  try
603  {
604  m_xPropertySetOrigin->addVetoableChangeListener(
605  OUString(), static_cast< XVetoableChangeListener * >( m_xMyListenerImpl.get() ) );
606  }
607  catch( Exception& )
608  {
609  m_pVetoableChangeListeners->removeInterface( rPropertyName, xListener );
610  throw;
611  }
612  }
613 }
614 
615 
616 // virtual
617 void SAL_CALL ContentResultSetWrapper::removePropertyChangeListener( const OUString& rPropertyName, const Reference< XPropertyChangeListener >& xListener )
618 {
620 
621  {
622  //noop, if no listener registered
623  osl::Guard< osl::Mutex > aGuard( m_aMutex );
625  return;
626  }
627  OInterfaceContainerHelper* pContainer =
628  m_pPropertyChangeListeners->getContainer( rPropertyName );
629 
630  if( !pContainer )
631  {
632  if( !rPropertyName.isEmpty() )
633  {
634  if( !getPropertySetInfo().is() )
635  throw UnknownPropertyException();
636 
637  m_xPropertySetInfo->getPropertyByName( rPropertyName );
638  //throws UnknownPropertyException, if so
639  }
640  return; //the listener was not registered
641  }
642 
643  m_pPropertyChangeListeners->removeInterface( rPropertyName, xListener );
644 
645  if( !m_pPropertyChangeListeners->getContainedTypes().hasElements() )
646  {
648  {
649  osl::Guard< osl::Mutex > aGuard( m_aMutex );
650  if( !m_xPropertySetOrigin.is() )
651  {
652  OSL_FAIL( "broadcaster was disposed already" );
653  return;
654  }
655  }
656  try
657  {
658  m_xPropertySetOrigin->removePropertyChangeListener(
659  OUString(), static_cast< XPropertyChangeListener * >( m_xMyListenerImpl.get() ) );
660  }
661  catch( Exception& )
662  {
663  OSL_FAIL( "could not remove PropertyChangeListener" );
664  }
665  }
666 }
667 
668 
669 // virtual
670 void SAL_CALL ContentResultSetWrapper::removeVetoableChangeListener( const OUString& rPropertyName, const Reference< XVetoableChangeListener >& xListener )
671 {
673 
674  {
675  //noop, if no listener registered
676  osl::Guard< osl::Mutex > aGuard( m_aMutex );
678  return;
679  }
680  OInterfaceContainerHelper* pContainer =
681  m_pVetoableChangeListeners->getContainer( rPropertyName );
682 
683  if( !pContainer )
684  {
685  if( !rPropertyName.isEmpty() )
686  {
687  if( !getPropertySetInfo().is() )
688  throw UnknownPropertyException();
689 
690  m_xPropertySetInfo->getPropertyByName( rPropertyName );
691  //throws UnknownPropertyException, if so
692  }
693  return; //the listener was not registered
694  }
695 
696  m_pVetoableChangeListeners->removeInterface( rPropertyName, xListener );
697 
698  if( !m_pVetoableChangeListeners->getContainedTypes().hasElements() )
699  {
701  {
702  osl::Guard< osl::Mutex > aGuard( m_aMutex );
703  if( !m_xPropertySetOrigin.is() )
704  {
705  OSL_FAIL( "broadcaster was disposed already" );
706  return;
707  }
708  }
709  try
710  {
711  m_xPropertySetOrigin->removeVetoableChangeListener(
712  OUString(), static_cast< XVetoableChangeListener * >( m_xMyListenerImpl.get() ) );
713  }
714  catch( Exception& )
715  {
716  OSL_FAIL( "could not remove VetoableChangeListener" );
717  }
718  }
719 }
720 
721 
722 // own methods.
723 
724 
725 //virtual
726 void ContentResultSetWrapper::impl_disposing( const EventObject& )
727 {
729 
730  osl::Guard< osl::Mutex > aGuard( m_aMutex );
731 
732  if( !m_xResultSetOrigin.is() )
733  return;
734 
735  //release all references to the broadcaster:
736  m_xResultSetOrigin.clear();
737  if(m_xRowOrigin.is())
738  m_xRowOrigin.clear();
739  if(m_xContentAccessOrigin.is())
740  m_xContentAccessOrigin.clear();
741  if(m_xPropertySetOrigin.is())
742  m_xPropertySetOrigin.clear();
743  m_xMetaDataFromOrigin.clear();
744  if(m_xPropertySetInfo.is())
745  m_xPropertySetInfo.clear();
746 }
747 
748 //virtual
749 void ContentResultSetWrapper::impl_propertyChange( const PropertyChangeEvent& rEvt )
750 {
752 
753  PropertyChangeEvent aEvt( rEvt );
754  aEvt.Source = static_cast< XPropertySet * >( this );
755  aEvt.Further = false;
757 }
758 
759 //virtual
760 void ContentResultSetWrapper::impl_vetoableChange( const PropertyChangeEvent& rEvt )
761 {
763 
764  PropertyChangeEvent aEvt( rEvt );
765  aEvt.Source = static_cast< XPropertySet * >( this );
766  aEvt.Further = false;
767 
769 }
770 
771 
772 // XContentAccess methods. ( -- position dependent )
773 
774 
775 // virtual
777 {
780  if( !m_xContentAccessOrigin.is() )
781  {
782  OSL_FAIL( "broadcaster was disposed already" );
783  throw RuntimeException();
784  }
785  return m_xContentAccessOrigin->queryContentIdentifierString();
786 }
787 
788 
789 // virtual
791 {
794  if( !m_xContentAccessOrigin.is() )
795  {
796  OSL_FAIL( "broadcaster was disposed already" );
797  throw RuntimeException();
798  }
799  return m_xContentAccessOrigin->queryContentIdentifier();
800 }
801 
802 
803 // virtual
805 {
808  if( !m_xContentAccessOrigin.is() )
809  {
810  OSL_FAIL( "broadcaster was disposed already" );
811  throw RuntimeException();
812  }
813  return m_xContentAccessOrigin->queryContent();
814 }
815 
816 
817 // XResultSet methods.
818 
819 //virtual
820 
822 {
824 
825  if( !m_xResultSetOrigin.is() )
826  {
827  OSL_FAIL( "broadcaster was disposed already" );
828  throw RuntimeException();
829  }
830  return m_xResultSetOrigin->next();
831 }
832 
833 //virtual
835 {
837 
838  if( !m_xResultSetOrigin.is() )
839  {
840  OSL_FAIL( "broadcaster was disposed already" );
841  throw RuntimeException();
842  }
843  return m_xResultSetOrigin->previous();
844 }
845 
846 //virtual
848 {
850 
851  if( !m_xResultSetOrigin.is() )
852  {
853  OSL_FAIL( "broadcaster was disposed already" );
854  throw RuntimeException();
855  }
856  return m_xResultSetOrigin->absolute( row );
857 }
858 
859 //virtual
860 sal_Bool SAL_CALL ContentResultSetWrapper::relative( sal_Int32 rows )
861 {
863 
864  if( !m_xResultSetOrigin.is() )
865  {
866  OSL_FAIL( "broadcaster was disposed already" );
867  throw RuntimeException();
868  }
869  return m_xResultSetOrigin->relative( rows );
870 }
871 
872 
873 //virtual
875 {
877 
878  if( !m_xResultSetOrigin.is() )
879  {
880  OSL_FAIL( "broadcaster was disposed already" );
881  throw RuntimeException();
882  }
883  return m_xResultSetOrigin->first();
884 }
885 
886 //virtual
888 {
890 
891  if( !m_xResultSetOrigin.is() )
892  {
893  OSL_FAIL( "broadcaster was disposed already" );
894  throw RuntimeException();
895  }
896  return m_xResultSetOrigin->last();
897 }
898 
899 //virtual
901 {
903 
904  if( !m_xResultSetOrigin.is() )
905  {
906  OSL_FAIL( "broadcaster was disposed already" );
907  throw RuntimeException();
908  }
909  m_xResultSetOrigin->beforeFirst();
910 }
911 
912 //virtual
914 {
916 
917  if( !m_xResultSetOrigin.is() )
918  {
919  OSL_FAIL( "broadcaster was disposed already" );
920  throw RuntimeException();
921  }
922  m_xResultSetOrigin->afterLast();
923 }
924 
925 //virtual
927 {
929 
930  if( !m_xResultSetOrigin.is() )
931  {
932  OSL_FAIL( "broadcaster was disposed already" );
933  throw RuntimeException();
934  }
935  return m_xResultSetOrigin->isAfterLast();
936 }
937 
938 //virtual
940 {
942 
943  if( !m_xResultSetOrigin.is() )
944  {
945  OSL_FAIL( "broadcaster was disposed already" );
946  throw RuntimeException();
947  }
948  return m_xResultSetOrigin->isBeforeFirst();
949 }
950 
951 //virtual
953 {
955 
956  if( !m_xResultSetOrigin.is() )
957  {
958  OSL_FAIL( "broadcaster was disposed already" );
959  throw RuntimeException();
960  }
961  return m_xResultSetOrigin->isFirst();
962 }
963 
964 //virtual
966 {
968 
969  if( !m_xResultSetOrigin.is() )
970  {
971  OSL_FAIL( "broadcaster was disposed already" );
972  throw RuntimeException();
973  }
974  return m_xResultSetOrigin->isLast();
975 }
976 
977 
978 //virtual
980 {
982 
983  if( !m_xResultSetOrigin.is() )
984  {
985  OSL_FAIL( "broadcaster was disposed already" );
986  throw RuntimeException();
987  }
988  return m_xResultSetOrigin->getRow();
989 }
990 
991 //virtual
993 {
995 
996  if( !m_xResultSetOrigin.is() )
997  {
998  OSL_FAIL( "broadcaster was disposed already" );
999  throw RuntimeException();
1000  }
1001  m_xResultSetOrigin->refreshRow();
1002 }
1003 
1004 //virtual
1006 {
1008 
1009  if( !m_xResultSetOrigin.is() )
1010  {
1011  OSL_FAIL( "broadcaster was disposed already" );
1012  throw RuntimeException();
1013  }
1014  return m_xResultSetOrigin->rowUpdated();
1015 }
1016 
1017 //virtual
1019 {
1021 
1022  if( !m_xResultSetOrigin.is() )
1023  {
1024  OSL_FAIL( "broadcaster was disposed already" );
1025  throw RuntimeException();
1026  }
1027  return m_xResultSetOrigin->rowInserted();
1028 }
1029 
1030 //virtual
1032 {
1034 
1035  if( !m_xResultSetOrigin.is() )
1036  {
1037  OSL_FAIL( "broadcaster was disposed already" );
1038  throw RuntimeException();
1039  }
1040  return m_xResultSetOrigin->rowDeleted();
1041 }
1042 
1043 //virtual
1045 {
1047  //@todo ?return anything
1048  return Reference< XInterface >();
1049 }
1050 
1051 
1052 // XRow methods.
1053 
1054 
1056 {
1059  if( !m_xRowOrigin.is() )
1060  {
1061  OSL_FAIL( "broadcaster was disposed already" );
1062  throw RuntimeException();
1063  }
1064 }
1065 
1066 //virtual
1068 {
1071  if( !m_xRowOrigin.is() )
1072  {
1073  OSL_FAIL( "broadcaster was disposed already" );
1074  throw RuntimeException();
1075  }
1076  return m_xRowOrigin->wasNull();
1077 }
1078 
1079 //virtual
1080 OUString SAL_CALL ContentResultSetWrapper::getString( sal_Int32 columnIndex )
1081 {
1082  verifyGet();
1083  return m_xRowOrigin->getString( columnIndex );
1084 }
1085 
1086 //virtual
1087 sal_Bool SAL_CALL ContentResultSetWrapper::getBoolean( sal_Int32 columnIndex )
1088 {
1089  verifyGet();
1090  return m_xRowOrigin->getBoolean( columnIndex );
1091 }
1092 
1093 //virtual
1094 sal_Int8 SAL_CALL ContentResultSetWrapper::getByte( sal_Int32 columnIndex )
1095 {
1096  verifyGet();
1097  return m_xRowOrigin->getByte( columnIndex );
1098 }
1099 
1100 //virtual
1101 sal_Int16 SAL_CALL ContentResultSetWrapper::getShort( sal_Int32 columnIndex )
1102 {
1103  verifyGet();
1104  return m_xRowOrigin->getShort( columnIndex );
1105 }
1106 
1107 //virtual
1108 sal_Int32 SAL_CALL ContentResultSetWrapper::getInt( sal_Int32 columnIndex )
1109 {
1110  verifyGet();
1111  return m_xRowOrigin->getInt( columnIndex );
1112 }
1113 
1114 //virtual
1115 sal_Int64 SAL_CALL ContentResultSetWrapper::getLong( sal_Int32 columnIndex )
1116 {
1117  verifyGet();
1118  return m_xRowOrigin->getLong( columnIndex );
1119 }
1120 
1121 //virtual
1122 float SAL_CALL ContentResultSetWrapper::getFloat( sal_Int32 columnIndex )
1123 {
1124  verifyGet();
1125  return m_xRowOrigin->getFloat( columnIndex );
1126 }
1127 
1128 //virtual
1129 double SAL_CALL ContentResultSetWrapper::getDouble( sal_Int32 columnIndex )
1130 {
1131  verifyGet();
1132  return m_xRowOrigin->getDouble( columnIndex );
1133 }
1134 
1135 //virtual
1137 {
1138  verifyGet();
1139  return m_xRowOrigin->getBytes( columnIndex );
1140 }
1141 
1142 //virtual
1143 Date SAL_CALL ContentResultSetWrapper::getDate( sal_Int32 columnIndex )
1144 {
1145  verifyGet();
1146  return m_xRowOrigin->getDate( columnIndex );
1147 }
1148 
1149 //virtual
1150 Time SAL_CALL ContentResultSetWrapper::getTime( sal_Int32 columnIndex )
1151 {
1152  verifyGet();
1153  return m_xRowOrigin->getTime( columnIndex );
1154 }
1155 
1156 //virtual
1157 DateTime SAL_CALL ContentResultSetWrapper::getTimestamp( sal_Int32 columnIndex )
1158 {
1159  verifyGet();
1160  return m_xRowOrigin->getTimestamp( columnIndex );
1161 }
1162 
1163 //virtual
1165 {
1166  verifyGet();
1167  return m_xRowOrigin->getBinaryStream( columnIndex );
1168 }
1169 
1170 //virtual
1172 {
1173  verifyGet();
1174  return m_xRowOrigin->getCharacterStream( columnIndex );
1175 }
1176 
1177 //virtual
1179 {
1180  //if you change this macro please pay attention to
1181  //define XROW_GETXXX, where this is similar implemented
1182 
1185  if( !m_xRowOrigin.is() )
1186  {
1187  OSL_FAIL( "broadcaster was disposed already" );
1188  throw RuntimeException();
1189  }
1190  return m_xRowOrigin->getObject( columnIndex, typeMap );
1191 }
1192 
1193 //virtual
1194 Reference< XRef > SAL_CALL ContentResultSetWrapper::getRef( sal_Int32 columnIndex )
1195 {
1196  verifyGet();
1197  return m_xRowOrigin->getRef( columnIndex );
1198 }
1199 
1200 //virtual
1201 Reference< XBlob > SAL_CALL ContentResultSetWrapper::getBlob( sal_Int32 columnIndex )
1202 {
1203  verifyGet();
1204  return m_xRowOrigin->getBlob( columnIndex );
1205 }
1206 
1207 //virtual
1208 Reference< XClob > SAL_CALL ContentResultSetWrapper::getClob( sal_Int32 columnIndex )
1209 {
1210  verifyGet();
1211  return m_xRowOrigin->getClob( columnIndex );
1212 }
1213 
1214 //virtual
1216 {
1217  verifyGet();
1218  return m_xRowOrigin->getArray( columnIndex );
1219 }
1220 
1221 
1222 // class ContentResultSetWrapperListener
1223 
1224 
1226  ContentResultSetWrapper* pOwner )
1227  : m_pOwner( pOwner )
1228 {
1229 }
1230 
1232 {
1233 }
1234 
1235 
1236 // XInterface methods.
1238  throw()
1239 {
1240  OWeakObject::acquire();
1241 }
1242 
1244  throw()
1245 {
1246  OWeakObject::release();
1247 }
1248 
1249 css::uno::Any SAL_CALL ContentResultSetWrapperListener::queryInterface( const css::uno::Type & rType )
1250 {
1251  //list all interfaces inclusive baseclasses of interfaces
1252  css::uno::Any aRet = cppu::queryInterface( rType,
1253  static_cast< XEventListener * >(
1254  static_cast< XPropertyChangeListener * >(this)),
1255  static_cast< XPropertyChangeListener* >(this),
1256  static_cast< XVetoableChangeListener* >(this)
1257  );
1258  return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType );
1259 }
1260 
1261 //XEventListener methods.
1262 
1263 
1264 //virtual
1265 void SAL_CALL ContentResultSetWrapperListener::disposing( const EventObject& rEventObject )
1266 {
1267  if( m_pOwner )
1268  m_pOwner->impl_disposing( rEventObject );
1269 }
1270 
1271 
1272 //XPropertyChangeListener methods.
1273 
1274 
1275 //virtual
1276 void SAL_CALL ContentResultSetWrapperListener::propertyChange( const PropertyChangeEvent& rEvt )
1277 {
1278  if( m_pOwner )
1279  m_pOwner->impl_propertyChange( rEvt );
1280 }
1281 
1282 
1283 //XVetoableChangeListener methods.
1284 
1285 //virtual
1286 void SAL_CALL ContentResultSetWrapperListener::vetoableChange( const PropertyChangeEvent& rEvt )
1287 {
1288  if( m_pOwner )
1289  m_pOwner->impl_vetoableChange( rEvt );
1290 }
1291 
1293 {
1294  m_pOwner = nullptr;
1295 }
1296 
1297 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void SAL_CALL removeVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
virtual css::uno::Reference< css::sdbc::XBlob > SAL_CALL getBlob(sal_Int32 columnIndex) override
virtual void SAL_CALL removeEventListener(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 impl_disposing(const css::lang::EventObject &Source)
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
virtual sal_Bool SAL_CALL getBoolean(sal_Int32 columnIndex) override
void impl_notifyPropertyChangeListeners(const css::beans::PropertyChangeEvent &rEvt)
ContentResultSetWrapper(css::uno::Reference< css::sdbc::XResultSet > const &xOrigin)
virtual css::uno::Reference< css::sdbc::XRef > SAL_CALL getRef(sal_Int32 columnIndex) override
signed char sal_Int8
css::uno::Reference< css::sdbc::XResultSetMetaData > m_xMetaDataFromOrigin
void impl_notifyVetoableChangeListeners(const css::beans::PropertyChangeEvent &rEvt)
virtual sal_Bool SAL_CALL rowDeleted() override
virtual OUString SAL_CALL getString(sal_Int32 columnIndex) override
virtual sal_Bool SAL_CALL rowUpdated() override
virtual void SAL_CALL addPropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
virtual void SAL_CALL vetoableChange(const css::beans::PropertyChangeEvent &aEvent) override
virtual sal_Bool SAL_CALL first() override
virtual css::uno::Reference< css::sdbc::XResultSetMetaData > SAL_CALL getMetaData() override
virtual void SAL_CALL removePropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &aListener) override
css::uno::XInterface *SAL_CALL next()
virtual sal_Bool SAL_CALL isAfterLast() override
virtual css::uno::Reference< css::sdbc::XArray > SAL_CALL getArray(sal_Int32 columnIndex) override
virtual css::util::Time SAL_CALL getTime(sal_Int32 columnIndex) override
ContentResultSetWrapperListener(ContentResultSetWrapper *pOwner)
virtual css::uno::Any SAL_CALL getObject(sal_Int32 columnIndex, const css::uno::Reference< css::container::XNameAccess > &typeMap) override
virtual sal_Int32 SAL_CALL getInt(sal_Int32 columnIndex) override
virtual sal_Int32 SAL_CALL getRow() override
virtual css::uno::Reference< css::io::XInputStream > SAL_CALL getBinaryStream(sal_Int32 columnIndex) override
bool m_bInDispose
Dispose call ready.
virtual sal_Bool SAL_CALL last() override
virtual void SAL_CALL acquire() override
virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > &Listener) override
virtual sal_Int8 SAL_CALL getByte(sal_Int32 columnIndex) override
std::unique_ptr< PropertyChangeListenerContainer_Impl > m_pVetoableChangeListeners
css::uno::Reference< css::ucb::XContentAccess > m_xContentAccessOrigin
! call impl_init_xRowOrigin() bevor you access this member
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
virtual void SAL_CALL propertyChange(const css::beans::PropertyChangeEvent &evt) override
virtual void SAL_CALL release() override
virtual sal_Bool SAL_CALL isFirst() override
virtual sal_Bool SAL_CALL previous() override
virtual sal_Int16 SAL_CALL getShort(sal_Int32 columnIndex) override
virtual sal_Bool SAL_CALL next() override
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
std::unique_ptr< comphelper::OInterfaceContainerHelper2 > m_pDisposeEventListeners
virtual void SAL_CALL disposing(const css::lang::EventObject &Source) override
class SAL_NO_VTABLE XPropertySet
cppu::OMultiTypeInterfaceContainerHelperVar< OUString > PropertyChangeListenerContainer_Impl
virtual void SAL_CALL afterLast() override
virtual void SAL_CALL refreshRow() override
virtual css::uno::Reference< css::ucb::XContent > SAL_CALL queryContent() override
css::uno::Reference< css::sdbc::XRow > m_xRowOrigin
unsigned char sal_Bool
virtual sal_Bool SAL_CALL rowInserted() override
virtual sal_Int64 SAL_CALL getLong(sal_Int32 columnIndex) override
virtual css::uno::Reference< css::ucb::XContentIdentifier > SAL_CALL queryContentIdentifier() override
virtual css::uno::Reference< css::sdbc::XClob > SAL_CALL getClob(sal_Int32 columnIndex) override
virtual double SAL_CALL getDouble(sal_Int32 columnIndex) override
virtual float SAL_CALL getFloat(sal_Int32 columnIndex) override
virtual void SAL_CALL addVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
std::unique_ptr< PropertyChangeListenerContainer_Impl > m_pPropertyChangeListeners
virtual void impl_vetoableChange(const css::beans::PropertyChangeEvent &aEvent)
virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getStatement() override
virtual css::util::DateTime SAL_CALL getTimestamp(sal_Int32 columnIndex) override
virtual void SAL_CALL beforeFirst() override
virtual sal_Bool SAL_CALL relative(sal_Int32 rows) override
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getBytes(sal_Int32 columnIndex) override
virtual void SAL_CALL close() override
css::uno::Reference< css::beans::XPropertySet > m_xPropertySetOrigin
! call impl_init_xContentAccessOrigin() bevor you access this member
virtual void SAL_CALL dispose() override
virtual void impl_propertyChange(const css::beans::PropertyChangeEvent &evt)
rtl::Reference< ContentResultSetWrapperListener > m_xMyListenerImpl
virtual css::util::Date SAL_CALL getDate(sal_Int32 columnIndex) override
css::uno::Reference< css::sdbc::XResultSet > m_xResultSetOrigin
css::uno::Reference< css::beans::XPropertySetInfo > m_xPropertySetInfo
! call impl_init_xPropertySetOrigin() bevor you access this member
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) override
virtual sal_Bool SAL_CALL isBeforeFirst() override
osl::Mutex m_aContainerMutex
In dispose call.
virtual OUString SAL_CALL queryContentIdentifierString() override
virtual sal_Bool SAL_CALL absolute(sal_Int32 row) override
virtual ~ContentResultSetWrapper() override
css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType, Interface1 *p1)
virtual sal_Bool SAL_CALL isLast() override
virtual sal_Bool SAL_CALL wasNull() override
bool SAL_CALL hasMoreElements() const
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override