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