update dev300-m58
[ooovba.git] / ucb / source / cacher / contentresultsetwrapper.hxx
blob02966e2b54321bb99805352ff734bef053d370bd
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: contentresultsetwrapper.hxx,v $
10 * $Revision: 1.7 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _CONTENT_RESULTSET_WRAPPER_HXX
32 #define _CONTENT_RESULTSET_WRAPPER_HXX
34 #include <rtl/ustring.hxx>
35 #include <ucbhelper/macros.hxx>
36 #include <osl/mutex.hxx>
37 #include <cppuhelper/weak.hxx>
38 #include <com/sun/star/lang/XComponent.hpp>
39 #include <com/sun/star/sdbc/XCloseable.hpp>
40 #include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
41 #include <com/sun/star/sdbc/XResultSet.hpp>
42 #include <com/sun/star/sdbc/XRow.hpp>
43 #include <com/sun/star/ucb/XContentAccess.hpp>
44 #include <com/sun/star/beans/XPropertySet.hpp>
45 #include <com/sun/star/lang/DisposedException.hpp>
46 #include <cppuhelper/interfacecontainer.hxx>
48 //=========================================================================
50 class ContentResultSetWrapperListener;
51 class ContentResultSetWrapper
52 : public cppu::OWeakObject
53 , public com::sun::star::lang::XComponent
54 , public com::sun::star::sdbc::XCloseable
55 , public com::sun::star::sdbc::XResultSetMetaDataSupplier
56 , public com::sun::star::beans::XPropertySet
57 , public com::sun::star::ucb::XContentAccess
58 , public com::sun::star::sdbc::XResultSet
59 , public com::sun::star::sdbc::XRow
61 protected:
63 //--------------------------------------------------------------------------
64 //class PropertyChangeListenerContainer_Impl.
66 struct equalStr_Impl
68 bool operator()( const rtl::OUString& s1, const rtl::OUString& s2 ) const
70 return !!( s1 == s2 );
74 struct hashStr_Impl
76 size_t operator()( const rtl::OUString& rName ) const
78 return rName.hashCode();
82 typedef cppu::OMultiTypeInterfaceContainerHelperVar
83 < rtl::OUString , hashStr_Impl , equalStr_Impl >
84 PropertyChangeListenerContainer_Impl;
85 //--------------------------------------------------------------------------
86 // class ReacquireableGuard
88 class ReacquireableGuard
90 protected:
91 osl::Mutex* pT;
92 public:
94 ReacquireableGuard(osl::Mutex * t) : pT(t)
96 pT->acquire();
99 ReacquireableGuard(osl::Mutex& t) : pT(&t)
101 pT->acquire();
104 /** Releases mutex. */
105 ~ReacquireableGuard()
107 if (pT)
108 pT->release();
111 /** Releases mutex. */
112 void clear()
114 if(pT)
116 pT->release();
117 pT = NULL;
121 /** Reacquire mutex. */
122 void reacquire()
124 if(pT)
126 pT->acquire();
131 //-----------------------------------------------------------------
132 //members
134 //my Mutex
135 osl::Mutex m_aMutex;
137 //different Interfaces from Origin:
138 com::sun::star::uno::Reference< com::sun::star::sdbc::XResultSet >
139 m_xResultSetOrigin;
140 com::sun::star::uno::Reference< com::sun::star::sdbc::XRow >
141 m_xRowOrigin; //XRow-interface from m_xOrigin
142 //!! call impl_init_xRowOrigin() bevor you access this member
143 com::sun::star::uno::Reference< com::sun::star::ucb::XContentAccess >
144 m_xContentAccessOrigin; //XContentAccess-interface from m_xOrigin
145 //!! call impl_init_xContentAccessOrigin() bevor you access this member
146 com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet >
147 m_xPropertySetOrigin; //XPropertySet-interface from m_xOrigin
148 //!! call impl_init_xPropertySetOrigin() bevor you access this member
150 com::sun::star::uno::Reference< com::sun::star::beans::XPropertySetInfo >
151 m_xPropertySetInfo;
152 //call impl_initPropertySetInfo() bevor you access this member
154 sal_Int32 m_nForwardOnly;
156 private:
157 com::sun::star::uno::Reference< com::sun::star::beans::XPropertyChangeListener >
158 m_xMyListenerImpl;
159 ContentResultSetWrapperListener*
160 m_pMyListenerImpl;
162 com::sun::star::uno::Reference< com::sun::star::sdbc::XResultSetMetaData >
163 m_xMetaDataFromOrigin; //XResultSetMetaData from m_xOrigin
165 //management of listeners
166 sal_Bool m_bDisposed; ///Dispose call ready.
167 sal_Bool m_bInDispose;///In dispose call
168 osl::Mutex m_aContainerMutex;
169 cppu::OInterfaceContainerHelper*
170 m_pDisposeEventListeners;
171 PropertyChangeListenerContainer_Impl*
172 m_pPropertyChangeListeners;
173 PropertyChangeListenerContainer_Impl*
174 m_pVetoableChangeListeners;
176 //-----------------------------------------------------------------
177 //methods:
178 private:
179 PropertyChangeListenerContainer_Impl* SAL_CALL
180 impl_getPropertyChangeListenerContainer();
182 PropertyChangeListenerContainer_Impl* SAL_CALL
183 impl_getVetoableChangeListenerContainer();
185 protected:
186 //-----------------------------------------------------------------
188 ContentResultSetWrapper( com::sun::star::uno::Reference<
189 com::sun::star::sdbc::XResultSet > xOrigin );
191 virtual ~ContentResultSetWrapper();
193 void SAL_CALL impl_init();
194 void SAL_CALL impl_deinit();
196 //--
198 void SAL_CALL impl_init_xRowOrigin();
199 void SAL_CALL impl_init_xContentAccessOrigin();
200 void SAL_CALL impl_init_xPropertySetOrigin();
202 //--
204 virtual void SAL_CALL impl_initPropertySetInfo(); //helping XPropertySet
206 void SAL_CALL
207 impl_EnsureNotDisposed()
208 throw( com::sun::star::lang::DisposedException,
209 com::sun::star::uno::RuntimeException );
211 void SAL_CALL
212 impl_notifyPropertyChangeListeners(
213 const com::sun::star::beans::PropertyChangeEvent& rEvt );
215 void SAL_CALL
216 impl_notifyVetoableChangeListeners(
217 const com::sun::star::beans::PropertyChangeEvent& rEvt )
218 throw( com::sun::star::beans::PropertyVetoException,
219 com::sun::star::uno::RuntimeException );
221 sal_Bool SAL_CALL impl_isForwardOnly();
223 public:
225 //-----------------------------------------------------------------
226 // XInterface
227 //-----------------------------------------------------------------
228 virtual com::sun::star::uno::Any SAL_CALL
229 queryInterface( const com::sun::star::uno::Type & rType )
230 throw( com::sun::star::uno::RuntimeException );
232 //-----------------------------------------------------------------
233 // XComponent
234 //-----------------------------------------------------------------
235 virtual void SAL_CALL
236 dispose() throw( com::sun::star::uno::RuntimeException );
238 virtual void SAL_CALL
239 addEventListener( const com::sun::star::uno::Reference<
240 com::sun::star::lang::XEventListener >& Listener )
241 throw( com::sun::star::uno::RuntimeException );
243 virtual void SAL_CALL
244 removeEventListener( const com::sun::star::uno::Reference<
245 com::sun::star::lang::XEventListener >& Listener )
246 throw( com::sun::star::uno::RuntimeException );
248 //-----------------------------------------------------------------
249 //XCloseable
250 //-----------------------------------------------------------------
251 virtual void SAL_CALL
252 close()
253 throw( com::sun::star::sdbc::SQLException,
254 com::sun::star::uno::RuntimeException );
256 //-----------------------------------------------------------------
257 //XResultSetMetaDataSupplier
258 //-----------------------------------------------------------------
259 virtual com::sun::star::uno::Reference<
260 com::sun::star::sdbc::XResultSetMetaData > SAL_CALL
261 getMetaData()
262 throw( com::sun::star::sdbc::SQLException,
263 com::sun::star::uno::RuntimeException );
265 //-----------------------------------------------------------------
266 // XPropertySet
267 //-----------------------------------------------------------------
268 virtual com::sun::star::uno::Reference<
269 com::sun::star::beans::XPropertySetInfo > SAL_CALL
270 getPropertySetInfo()
271 throw( com::sun::star::uno::RuntimeException );
273 virtual void SAL_CALL
274 setPropertyValue( const rtl::OUString& aPropertyName,
275 const com::sun::star::uno::Any& aValue )
276 throw( com::sun::star::beans::UnknownPropertyException,
277 com::sun::star::beans::PropertyVetoException,
278 com::sun::star::lang::IllegalArgumentException,
279 com::sun::star::lang::WrappedTargetException,
280 com::sun::star::uno::RuntimeException );
282 virtual com::sun::star::uno::Any SAL_CALL
283 getPropertyValue( const rtl::OUString& PropertyName )
284 throw( com::sun::star::beans::UnknownPropertyException,
285 com::sun::star::lang::WrappedTargetException,
286 com::sun::star::uno::RuntimeException );
288 virtual void SAL_CALL
289 addPropertyChangeListener( const rtl::OUString& aPropertyName,
290 const com::sun::star::uno::Reference<
291 com::sun::star::beans::XPropertyChangeListener >& xListener )
292 throw( com::sun::star::beans::UnknownPropertyException,
293 com::sun::star::lang::WrappedTargetException,
294 com::sun::star::uno::RuntimeException );
296 virtual void SAL_CALL
297 removePropertyChangeListener( const rtl::OUString& aPropertyName,
298 const com::sun::star::uno::Reference<
299 com::sun::star::beans::XPropertyChangeListener >& aListener )
300 throw( com::sun::star::beans::UnknownPropertyException,
301 com::sun::star::lang::WrappedTargetException,
302 com::sun::star::uno::RuntimeException );
304 virtual void SAL_CALL
305 addVetoableChangeListener( const rtl::OUString& PropertyName,
306 const com::sun::star::uno::Reference<
307 com::sun::star::beans::XVetoableChangeListener >& aListener )
308 throw( com::sun::star::beans::UnknownPropertyException,
309 com::sun::star::lang::WrappedTargetException,
310 com::sun::star::uno::RuntimeException );
312 virtual void SAL_CALL
313 removeVetoableChangeListener( const rtl::OUString& PropertyName,
314 const com::sun::star::uno::Reference<
315 com::sun::star::beans::XVetoableChangeListener >& aListener )
316 throw( com::sun::star::beans::UnknownPropertyException,
317 com::sun::star::lang::WrappedTargetException,
318 com::sun::star::uno::RuntimeException );
320 //-----------------------------------------------------------------
321 // own methods
322 //-----------------------------------------------------------------
323 virtual void SAL_CALL
324 impl_disposing( const com::sun::star::lang::EventObject& Source )
325 throw( com::sun::star::uno::RuntimeException );
327 virtual void SAL_CALL
328 impl_propertyChange( const com::sun::star::beans::PropertyChangeEvent& evt )
329 throw( com::sun::star::uno::RuntimeException );
331 virtual void SAL_CALL
332 impl_vetoableChange( const com::sun::star::beans::PropertyChangeEvent& aEvent )
333 throw( com::sun::star::beans::PropertyVetoException,
334 com::sun::star::uno::RuntimeException );
336 //-----------------------------------------------------------------
337 // XContentAccess
338 //-----------------------------------------------------------------
339 virtual rtl::OUString SAL_CALL
340 queryContentIdentifierString()
341 throw( com::sun::star::uno::RuntimeException );
343 virtual com::sun::star::uno::Reference<
344 com::sun::star::ucb::XContentIdentifier > SAL_CALL
345 queryContentIdentifier()
346 throw( com::sun::star::uno::RuntimeException );
348 virtual com::sun::star::uno::Reference<
349 com::sun::star::ucb::XContent > SAL_CALL
350 queryContent()
351 throw( com::sun::star::uno::RuntimeException );
353 //-----------------------------------------------------------------
354 // XResultSet
355 //-----------------------------------------------------------------
356 virtual sal_Bool SAL_CALL
357 next()
358 throw( com::sun::star::sdbc::SQLException,
359 com::sun::star::uno::RuntimeException );
360 virtual sal_Bool SAL_CALL
361 isBeforeFirst()
362 throw( com::sun::star::sdbc::SQLException,
363 com::sun::star::uno::RuntimeException );
364 virtual sal_Bool SAL_CALL
365 isAfterLast()
366 throw( com::sun::star::sdbc::SQLException,
367 com::sun::star::uno::RuntimeException );
368 virtual sal_Bool SAL_CALL
369 isFirst()
370 throw( com::sun::star::sdbc::SQLException,
371 com::sun::star::uno::RuntimeException );
372 virtual sal_Bool SAL_CALL
373 isLast()
374 throw( com::sun::star::sdbc::SQLException,
375 com::sun::star::uno::RuntimeException );
376 virtual void SAL_CALL
377 beforeFirst()
378 throw( com::sun::star::sdbc::SQLException,
379 com::sun::star::uno::RuntimeException );
380 virtual void SAL_CALL
381 afterLast()
382 throw( com::sun::star::sdbc::SQLException,
383 com::sun::star::uno::RuntimeException );
384 virtual sal_Bool SAL_CALL
385 first()
386 throw( com::sun::star::sdbc::SQLException,
387 com::sun::star::uno::RuntimeException );
388 virtual sal_Bool SAL_CALL
389 last()
390 throw( com::sun::star::sdbc::SQLException,
391 com::sun::star::uno::RuntimeException );
392 virtual sal_Int32 SAL_CALL
393 getRow()
394 throw( com::sun::star::sdbc::SQLException,
395 com::sun::star::uno::RuntimeException );
396 virtual sal_Bool SAL_CALL
397 absolute( sal_Int32 row )
398 throw( com::sun::star::sdbc::SQLException,
399 com::sun::star::uno::RuntimeException );
400 virtual sal_Bool SAL_CALL
401 relative( sal_Int32 rows )
402 throw( com::sun::star::sdbc::SQLException,
403 com::sun::star::uno::RuntimeException );
404 virtual sal_Bool SAL_CALL
405 previous()
406 throw( com::sun::star::sdbc::SQLException,
407 com::sun::star::uno::RuntimeException );
408 virtual void SAL_CALL
409 refreshRow()
410 throw( com::sun::star::sdbc::SQLException,
411 com::sun::star::uno::RuntimeException );
412 virtual sal_Bool SAL_CALL
413 rowUpdated()
414 throw( com::sun::star::sdbc::SQLException,
415 com::sun::star::uno::RuntimeException );
416 virtual sal_Bool SAL_CALL
417 rowInserted()
418 throw( com::sun::star::sdbc::SQLException,
419 com::sun::star::uno::RuntimeException );
420 virtual sal_Bool SAL_CALL
421 rowDeleted()
422 throw( com::sun::star::sdbc::SQLException,
423 com::sun::star::uno::RuntimeException );
424 virtual com::sun::star::uno::Reference<
425 com::sun::star::uno::XInterface > SAL_CALL
426 getStatement()
427 throw( com::sun::star::sdbc::SQLException,
428 com::sun::star::uno::RuntimeException );
430 //-----------------------------------------------------------------
431 // XRow
432 //-----------------------------------------------------------------
433 virtual sal_Bool SAL_CALL
434 wasNull()
435 throw( com::sun::star::sdbc::SQLException,
436 com::sun::star::uno::RuntimeException );
438 virtual rtl::OUString SAL_CALL
439 getString( sal_Int32 columnIndex )
440 throw( com::sun::star::sdbc::SQLException,
441 com::sun::star::uno::RuntimeException );
443 virtual sal_Bool SAL_CALL
444 getBoolean( sal_Int32 columnIndex )
445 throw( com::sun::star::sdbc::SQLException,
446 com::sun::star::uno::RuntimeException );
448 virtual sal_Int8 SAL_CALL
449 getByte( sal_Int32 columnIndex )
450 throw( com::sun::star::sdbc::SQLException,
451 com::sun::star::uno::RuntimeException );
453 virtual sal_Int16 SAL_CALL
454 getShort( sal_Int32 columnIndex )
455 throw( com::sun::star::sdbc::SQLException,
456 com::sun::star::uno::RuntimeException );
458 virtual sal_Int32 SAL_CALL
459 getInt( sal_Int32 columnIndex )
460 throw( com::sun::star::sdbc::SQLException,
461 com::sun::star::uno::RuntimeException );
463 virtual sal_Int64 SAL_CALL
464 getLong( sal_Int32 columnIndex )
465 throw( com::sun::star::sdbc::SQLException,
466 com::sun::star::uno::RuntimeException );
468 virtual float SAL_CALL
469 getFloat( sal_Int32 columnIndex )
470 throw( com::sun::star::sdbc::SQLException,
471 com::sun::star::uno::RuntimeException );
473 virtual double SAL_CALL
474 getDouble( sal_Int32 columnIndex )
475 throw( com::sun::star::sdbc::SQLException,
476 com::sun::star::uno::RuntimeException );
478 virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL
479 getBytes( sal_Int32 columnIndex )
480 throw( com::sun::star::sdbc::SQLException,
481 com::sun::star::uno::RuntimeException );
483 virtual com::sun::star::util::Date SAL_CALL
484 getDate( sal_Int32 columnIndex )
485 throw( com::sun::star::sdbc::SQLException,
486 com::sun::star::uno::RuntimeException );
488 virtual com::sun::star::util::Time SAL_CALL
489 getTime( sal_Int32 columnIndex )
490 throw( com::sun::star::sdbc::SQLException,
491 com::sun::star::uno::RuntimeException );
493 virtual com::sun::star::util::DateTime SAL_CALL
494 getTimestamp( sal_Int32 columnIndex )
495 throw( com::sun::star::sdbc::SQLException,
496 com::sun::star::uno::RuntimeException );
498 virtual com::sun::star::uno::Reference<
499 com::sun::star::io::XInputStream > SAL_CALL
500 getBinaryStream( sal_Int32 columnIndex )
501 throw( com::sun::star::sdbc::SQLException,
502 com::sun::star::uno::RuntimeException );
504 virtual com::sun::star::uno::Reference<
505 com::sun::star::io::XInputStream > SAL_CALL
506 getCharacterStream( sal_Int32 columnIndex )
507 throw( com::sun::star::sdbc::SQLException,
508 com::sun::star::uno::RuntimeException );
510 virtual com::sun::star::uno::Any SAL_CALL
511 getObject( sal_Int32 columnIndex,
512 const com::sun::star::uno::Reference<
513 com::sun::star::container::XNameAccess >& typeMap )
514 throw( com::sun::star::sdbc::SQLException,
515 com::sun::star::uno::RuntimeException );
517 virtual com::sun::star::uno::Reference<
518 com::sun::star::sdbc::XRef > SAL_CALL
519 getRef( sal_Int32 columnIndex )
520 throw( com::sun::star::sdbc::SQLException,
521 com::sun::star::uno::RuntimeException );
523 virtual com::sun::star::uno::Reference<
524 com::sun::star::sdbc::XBlob > SAL_CALL
525 getBlob( sal_Int32 columnIndex )
526 throw( com::sun::star::sdbc::SQLException,
527 com::sun::star::uno::RuntimeException );
529 virtual com::sun::star::uno::Reference<
530 com::sun::star::sdbc::XClob > SAL_CALL
531 getClob( sal_Int32 columnIndex )
532 throw( com::sun::star::sdbc::SQLException,
533 com::sun::star::uno::RuntimeException );
535 virtual com::sun::star::uno::Reference<
536 com::sun::star::sdbc::XArray > SAL_CALL
537 getArray( sal_Int32 columnIndex )
538 throw( com::sun::star::sdbc::SQLException,
539 com::sun::star::uno::RuntimeException );
542 //=========================================================================
544 class ContentResultSetWrapperListener
545 : public cppu::OWeakObject
546 , public com::sun::star::beans::XPropertyChangeListener
547 , public com::sun::star::beans::XVetoableChangeListener
549 protected:
550 ContentResultSetWrapper* m_pOwner;
552 public:
553 ContentResultSetWrapperListener( ContentResultSetWrapper* pOwner );
555 virtual ~ContentResultSetWrapperListener();
557 //-----------------------------------------------------------------
558 // XInterface
559 //-----------------------------------------------------------------
560 XINTERFACE_DECL()
562 //-----------------------------------------------------------------
563 //XEventListener
564 //-----------------------------------------------------------------
565 virtual void SAL_CALL
566 disposing( const com::sun::star::lang::EventObject& Source )
567 throw( com::sun::star::uno::RuntimeException );
569 //-----------------------------------------------------------------
570 //XPropertyChangeListener
571 //-----------------------------------------------------------------
572 virtual void SAL_CALL
573 propertyChange( const com::sun::star::beans::PropertyChangeEvent& evt )
574 throw( com::sun::star::uno::RuntimeException );
576 //-----------------------------------------------------------------
577 //XVetoableChangeListener
578 //-----------------------------------------------------------------
579 virtual void SAL_CALL
580 vetoableChange( const com::sun::star::beans::PropertyChangeEvent& aEvent )
581 throw( com::sun::star::beans::PropertyVetoException,
582 com::sun::star::uno::RuntimeException );
584 //-----------------------------------------------------------------
585 // own methods:
586 void SAL_CALL impl_OwnerDies();
589 #endif