Version 4.3.0.0.beta1, tag libreoffice-4.3.0.0.beta1
[LibreOffice.git] / ucb / source / cacher / contentresultsetwrapper.hxx
blob73a1fbaaacaf5972cf57f4997f6ecff4d4cfccbc
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_UCB_SOURCE_CACHER_CONTENTRESULTSETWRAPPER_HXX
21 #define INCLUDED_UCB_SOURCE_CACHER_CONTENTRESULTSETWRAPPER_HXX
23 #include <rtl/ustring.hxx>
24 #include <ucbhelper/macros.hxx>
25 #include <osl/mutex.hxx>
26 #include <cppuhelper/weak.hxx>
27 #include <com/sun/star/lang/XComponent.hpp>
28 #include <com/sun/star/sdbc/XCloseable.hpp>
29 #include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
30 #include <com/sun/star/sdbc/XResultSet.hpp>
31 #include <com/sun/star/sdbc/XRow.hpp>
32 #include <com/sun/star/ucb/XContentAccess.hpp>
33 #include <com/sun/star/beans/XPropertySet.hpp>
34 #include <com/sun/star/lang/DisposedException.hpp>
35 #include <cppuhelper/interfacecontainer.hxx>
39 class ContentResultSetWrapperListener;
40 class ContentResultSetWrapper
41 : public cppu::OWeakObject
42 , public com::sun::star::lang::XComponent
43 , public com::sun::star::sdbc::XCloseable
44 , public com::sun::star::sdbc::XResultSetMetaDataSupplier
45 , public com::sun::star::beans::XPropertySet
46 , public com::sun::star::ucb::XContentAccess
47 , public com::sun::star::sdbc::XResultSet
48 , public com::sun::star::sdbc::XRow
50 protected:
51 typedef cppu::OMultiTypeInterfaceContainerHelperVar<OUString>
52 PropertyChangeListenerContainer_Impl;
54 class ReacquireableGuard
56 protected:
57 osl::Mutex* pT;
58 public:
60 ReacquireableGuard(osl::Mutex * t) : pT(t)
62 pT->acquire();
65 ReacquireableGuard(osl::Mutex& t) : pT(&t)
67 pT->acquire();
70 /** Releases mutex. */
71 ~ReacquireableGuard()
73 if (pT)
74 pT->release();
77 /** Releases mutex. */
78 void clear()
80 if(pT)
82 pT->release();
83 pT = NULL;
87 /** Reacquire mutex. */
88 void reacquire()
90 if(pT)
92 pT->acquire();
98 //members
100 //my Mutex
101 osl::Mutex m_aMutex;
103 //different Interfaces from Origin:
104 com::sun::star::uno::Reference< com::sun::star::sdbc::XResultSet >
105 m_xResultSetOrigin;
106 com::sun::star::uno::Reference< com::sun::star::sdbc::XRow >
107 m_xRowOrigin; //XRow-interface from m_xOrigin
108 //!! call impl_init_xRowOrigin() bevor you access this member
109 com::sun::star::uno::Reference< com::sun::star::ucb::XContentAccess >
110 m_xContentAccessOrigin; //XContentAccess-interface from m_xOrigin
111 //!! call impl_init_xContentAccessOrigin() bevor you access this member
112 com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet >
113 m_xPropertySetOrigin; //XPropertySet-interface from m_xOrigin
114 //!! call impl_init_xPropertySetOrigin() bevor you access this member
116 com::sun::star::uno::Reference< com::sun::star::beans::XPropertySetInfo >
117 m_xPropertySetInfo;
118 //call impl_initPropertySetInfo() bevor you access this member
120 sal_Int32 m_nForwardOnly;
122 private:
123 com::sun::star::uno::Reference< com::sun::star::beans::XPropertyChangeListener >
124 m_xMyListenerImpl;
125 ContentResultSetWrapperListener*
126 m_pMyListenerImpl;
128 com::sun::star::uno::Reference< com::sun::star::sdbc::XResultSetMetaData >
129 m_xMetaDataFromOrigin; //XResultSetMetaData from m_xOrigin
131 //management of listeners
132 bool m_bDisposed; ///Dispose call ready.
133 bool m_bInDispose;///In dispose call
134 osl::Mutex m_aContainerMutex;
135 cppu::OInterfaceContainerHelper*
136 m_pDisposeEventListeners;
137 PropertyChangeListenerContainer_Impl*
138 m_pPropertyChangeListeners;
139 PropertyChangeListenerContainer_Impl*
140 m_pVetoableChangeListeners;
143 //methods:
144 private:
145 PropertyChangeListenerContainer_Impl* SAL_CALL
146 impl_getPropertyChangeListenerContainer();
148 PropertyChangeListenerContainer_Impl* SAL_CALL
149 impl_getVetoableChangeListenerContainer();
151 protected:
154 ContentResultSetWrapper( com::sun::star::uno::Reference<
155 com::sun::star::sdbc::XResultSet > xOrigin );
157 virtual ~ContentResultSetWrapper();
159 void SAL_CALL impl_init();
160 void SAL_CALL impl_deinit();
162 //--
164 void SAL_CALL impl_init_xRowOrigin();
165 void SAL_CALL impl_init_xContentAccessOrigin();
166 void SAL_CALL impl_init_xPropertySetOrigin();
168 //--
170 virtual void SAL_CALL impl_initPropertySetInfo(); //helping XPropertySet
172 void SAL_CALL
173 impl_EnsureNotDisposed()
174 throw( com::sun::star::lang::DisposedException,
175 com::sun::star::uno::RuntimeException );
177 void SAL_CALL
178 impl_notifyPropertyChangeListeners(
179 const com::sun::star::beans::PropertyChangeEvent& rEvt );
181 void SAL_CALL
182 impl_notifyVetoableChangeListeners(
183 const com::sun::star::beans::PropertyChangeEvent& rEvt )
184 throw( com::sun::star::beans::PropertyVetoException,
185 com::sun::star::uno::RuntimeException );
187 bool SAL_CALL impl_isForwardOnly();
189 public:
192 // XInterface
194 virtual com::sun::star::uno::Any SAL_CALL
195 queryInterface( const com::sun::star::uno::Type & rType )
196 throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
199 // XComponent
201 virtual void SAL_CALL
202 dispose() throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
204 virtual void SAL_CALL
205 addEventListener( const com::sun::star::uno::Reference<
206 com::sun::star::lang::XEventListener >& Listener )
207 throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
209 virtual void SAL_CALL
210 removeEventListener( const com::sun::star::uno::Reference<
211 com::sun::star::lang::XEventListener >& Listener )
212 throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
215 //XCloseable
217 virtual void SAL_CALL
218 close()
219 throw( com::sun::star::sdbc::SQLException,
220 com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
223 //XResultSetMetaDataSupplier
225 virtual com::sun::star::uno::Reference<
226 com::sun::star::sdbc::XResultSetMetaData > SAL_CALL
227 getMetaData()
228 throw( com::sun::star::sdbc::SQLException,
229 com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
232 // XPropertySet
234 virtual com::sun::star::uno::Reference<
235 com::sun::star::beans::XPropertySetInfo > SAL_CALL
236 getPropertySetInfo()
237 throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
239 virtual void SAL_CALL
240 setPropertyValue( const OUString& aPropertyName,
241 const com::sun::star::uno::Any& aValue )
242 throw( com::sun::star::beans::UnknownPropertyException,
243 com::sun::star::beans::PropertyVetoException,
244 com::sun::star::lang::IllegalArgumentException,
245 com::sun::star::lang::WrappedTargetException,
246 com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
248 virtual com::sun::star::uno::Any SAL_CALL
249 getPropertyValue( const OUString& PropertyName )
250 throw( com::sun::star::beans::UnknownPropertyException,
251 com::sun::star::lang::WrappedTargetException,
252 com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
254 virtual void SAL_CALL
255 addPropertyChangeListener( const OUString& aPropertyName,
256 const com::sun::star::uno::Reference<
257 com::sun::star::beans::XPropertyChangeListener >& xListener )
258 throw( com::sun::star::beans::UnknownPropertyException,
259 com::sun::star::lang::WrappedTargetException,
260 com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
262 virtual void SAL_CALL
263 removePropertyChangeListener( const OUString& aPropertyName,
264 const com::sun::star::uno::Reference<
265 com::sun::star::beans::XPropertyChangeListener >& aListener )
266 throw( com::sun::star::beans::UnknownPropertyException,
267 com::sun::star::lang::WrappedTargetException,
268 com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
270 virtual void SAL_CALL
271 addVetoableChangeListener( const OUString& PropertyName,
272 const com::sun::star::uno::Reference<
273 com::sun::star::beans::XVetoableChangeListener >& aListener )
274 throw( com::sun::star::beans::UnknownPropertyException,
275 com::sun::star::lang::WrappedTargetException,
276 com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
278 virtual void SAL_CALL
279 removeVetoableChangeListener( const OUString& PropertyName,
280 const com::sun::star::uno::Reference<
281 com::sun::star::beans::XVetoableChangeListener >& aListener )
282 throw( com::sun::star::beans::UnknownPropertyException,
283 com::sun::star::lang::WrappedTargetException,
284 com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
287 // own methods
289 virtual void SAL_CALL
290 impl_disposing( const com::sun::star::lang::EventObject& Source )
291 throw( com::sun::star::uno::RuntimeException );
293 virtual void SAL_CALL
294 impl_propertyChange( const com::sun::star::beans::PropertyChangeEvent& evt )
295 throw( com::sun::star::uno::RuntimeException );
297 virtual void SAL_CALL
298 impl_vetoableChange( const com::sun::star::beans::PropertyChangeEvent& aEvent )
299 throw( com::sun::star::beans::PropertyVetoException,
300 com::sun::star::uno::RuntimeException );
303 // XContentAccess
305 virtual OUString SAL_CALL
306 queryContentIdentifierString()
307 throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
309 virtual com::sun::star::uno::Reference<
310 com::sun::star::ucb::XContentIdentifier > SAL_CALL
311 queryContentIdentifier()
312 throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
314 virtual com::sun::star::uno::Reference<
315 com::sun::star::ucb::XContent > SAL_CALL
316 queryContent()
317 throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
320 // XResultSet
322 virtual sal_Bool SAL_CALL
323 next()
324 throw( com::sun::star::sdbc::SQLException,
325 com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
326 virtual sal_Bool SAL_CALL
327 isBeforeFirst()
328 throw( com::sun::star::sdbc::SQLException,
329 com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
330 virtual sal_Bool SAL_CALL
331 isAfterLast()
332 throw( com::sun::star::sdbc::SQLException,
333 com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
334 virtual sal_Bool SAL_CALL
335 isFirst()
336 throw( com::sun::star::sdbc::SQLException,
337 com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
338 virtual sal_Bool SAL_CALL
339 isLast()
340 throw( com::sun::star::sdbc::SQLException,
341 com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
342 virtual void SAL_CALL
343 beforeFirst()
344 throw( com::sun::star::sdbc::SQLException,
345 com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
346 virtual void SAL_CALL
347 afterLast()
348 throw( com::sun::star::sdbc::SQLException,
349 com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
350 virtual sal_Bool SAL_CALL
351 first()
352 throw( com::sun::star::sdbc::SQLException,
353 com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
354 virtual sal_Bool SAL_CALL
355 last()
356 throw( com::sun::star::sdbc::SQLException,
357 com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
358 virtual sal_Int32 SAL_CALL
359 getRow()
360 throw( com::sun::star::sdbc::SQLException,
361 com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
362 virtual sal_Bool SAL_CALL
363 absolute( sal_Int32 row )
364 throw( com::sun::star::sdbc::SQLException,
365 com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
366 virtual sal_Bool SAL_CALL
367 relative( sal_Int32 rows )
368 throw( com::sun::star::sdbc::SQLException,
369 com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
370 virtual sal_Bool SAL_CALL
371 previous()
372 throw( com::sun::star::sdbc::SQLException,
373 com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
374 virtual void SAL_CALL
375 refreshRow()
376 throw( com::sun::star::sdbc::SQLException,
377 com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
378 virtual sal_Bool SAL_CALL
379 rowUpdated()
380 throw( com::sun::star::sdbc::SQLException,
381 com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
382 virtual sal_Bool SAL_CALL
383 rowInserted()
384 throw( com::sun::star::sdbc::SQLException,
385 com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
386 virtual sal_Bool SAL_CALL
387 rowDeleted()
388 throw( com::sun::star::sdbc::SQLException,
389 com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
390 virtual com::sun::star::uno::Reference<
391 com::sun::star::uno::XInterface > SAL_CALL
392 getStatement()
393 throw( com::sun::star::sdbc::SQLException,
394 com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
397 // XRow
399 virtual sal_Bool SAL_CALL
400 wasNull()
401 throw( com::sun::star::sdbc::SQLException,
402 com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
404 virtual OUString SAL_CALL
405 getString( sal_Int32 columnIndex )
406 throw( com::sun::star::sdbc::SQLException,
407 com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
409 virtual sal_Bool SAL_CALL
410 getBoolean( sal_Int32 columnIndex )
411 throw( com::sun::star::sdbc::SQLException,
412 com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
414 virtual sal_Int8 SAL_CALL
415 getByte( sal_Int32 columnIndex )
416 throw( com::sun::star::sdbc::SQLException,
417 com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
419 virtual sal_Int16 SAL_CALL
420 getShort( sal_Int32 columnIndex )
421 throw( com::sun::star::sdbc::SQLException,
422 com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
424 virtual sal_Int32 SAL_CALL
425 getInt( sal_Int32 columnIndex )
426 throw( com::sun::star::sdbc::SQLException,
427 com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
429 virtual sal_Int64 SAL_CALL
430 getLong( sal_Int32 columnIndex )
431 throw( com::sun::star::sdbc::SQLException,
432 com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
434 virtual float SAL_CALL
435 getFloat( sal_Int32 columnIndex )
436 throw( com::sun::star::sdbc::SQLException,
437 com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
439 virtual double SAL_CALL
440 getDouble( sal_Int32 columnIndex )
441 throw( com::sun::star::sdbc::SQLException,
442 com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
444 virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL
445 getBytes( sal_Int32 columnIndex )
446 throw( com::sun::star::sdbc::SQLException,
447 com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
449 virtual com::sun::star::util::Date SAL_CALL
450 getDate( sal_Int32 columnIndex )
451 throw( com::sun::star::sdbc::SQLException,
452 com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
454 virtual com::sun::star::util::Time SAL_CALL
455 getTime( sal_Int32 columnIndex )
456 throw( com::sun::star::sdbc::SQLException,
457 com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
459 virtual com::sun::star::util::DateTime SAL_CALL
460 getTimestamp( sal_Int32 columnIndex )
461 throw( com::sun::star::sdbc::SQLException,
462 com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
464 virtual com::sun::star::uno::Reference<
465 com::sun::star::io::XInputStream > SAL_CALL
466 getBinaryStream( sal_Int32 columnIndex )
467 throw( com::sun::star::sdbc::SQLException,
468 com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
470 virtual com::sun::star::uno::Reference<
471 com::sun::star::io::XInputStream > SAL_CALL
472 getCharacterStream( sal_Int32 columnIndex )
473 throw( com::sun::star::sdbc::SQLException,
474 com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
476 virtual com::sun::star::uno::Any SAL_CALL
477 getObject( sal_Int32 columnIndex,
478 const com::sun::star::uno::Reference<
479 com::sun::star::container::XNameAccess >& typeMap )
480 throw( com::sun::star::sdbc::SQLException,
481 com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
483 virtual com::sun::star::uno::Reference<
484 com::sun::star::sdbc::XRef > SAL_CALL
485 getRef( sal_Int32 columnIndex )
486 throw( com::sun::star::sdbc::SQLException,
487 com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
489 virtual com::sun::star::uno::Reference<
490 com::sun::star::sdbc::XBlob > SAL_CALL
491 getBlob( sal_Int32 columnIndex )
492 throw( com::sun::star::sdbc::SQLException,
493 com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
495 virtual com::sun::star::uno::Reference<
496 com::sun::star::sdbc::XClob > SAL_CALL
497 getClob( sal_Int32 columnIndex )
498 throw( com::sun::star::sdbc::SQLException,
499 com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
501 virtual com::sun::star::uno::Reference<
502 com::sun::star::sdbc::XArray > SAL_CALL
503 getArray( sal_Int32 columnIndex )
504 throw( com::sun::star::sdbc::SQLException,
505 com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
510 class ContentResultSetWrapperListener
511 : public cppu::OWeakObject
512 , public com::sun::star::beans::XPropertyChangeListener
513 , public com::sun::star::beans::XVetoableChangeListener
515 protected:
516 ContentResultSetWrapper* m_pOwner;
518 public:
519 ContentResultSetWrapperListener( ContentResultSetWrapper* pOwner );
521 virtual ~ContentResultSetWrapperListener();
524 // XInterface
525 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType )
526 throw( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
527 virtual void SAL_CALL acquire()
528 throw() SAL_OVERRIDE;
529 virtual void SAL_CALL release()
530 throw() SAL_OVERRIDE;
532 //XEventListener
534 virtual void SAL_CALL
535 disposing( const com::sun::star::lang::EventObject& Source )
536 throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
539 //XPropertyChangeListener
541 virtual void SAL_CALL
542 propertyChange( const com::sun::star::beans::PropertyChangeEvent& evt )
543 throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
546 //XVetoableChangeListener
548 virtual void SAL_CALL
549 vetoableChange( const com::sun::star::beans::PropertyChangeEvent& aEvent )
550 throw( com::sun::star::beans::PropertyVetoException,
551 com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
554 // own methods:
555 void SAL_CALL impl_OwnerDies();
558 #endif
560 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */