1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 _CONTENT_RESULTSET_WRAPPER_HXX
21 #define _CONTENT_RESULTSET_WRAPPER_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>
37 //=========================================================================
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
52 //--------------------------------------------------------------------------
53 //class PropertyChangeListenerContainer_Impl.
57 bool operator()( const OUString
& s1
, const OUString
& s2
) const
59 return !!( s1
== s2
);
65 size_t operator()( const OUString
& rName
) const
67 return rName
.hashCode();
71 typedef cppu::OMultiTypeInterfaceContainerHelperVar
72 < OUString
, hashStr_Impl
, equalStr_Impl
>
73 PropertyChangeListenerContainer_Impl
;
74 //--------------------------------------------------------------------------
75 // class ReacquireableGuard
77 class ReacquireableGuard
83 ReacquireableGuard(osl::Mutex
* t
) : pT(t
)
88 ReacquireableGuard(osl::Mutex
& t
) : pT(&t
)
93 /** Releases mutex. */
100 /** Releases mutex. */
110 /** Reacquire mutex. */
120 //-----------------------------------------------------------------
126 //different Interfaces from Origin:
127 com::sun::star::uno::Reference
< com::sun::star::sdbc::XResultSet
>
129 com::sun::star::uno::Reference
< com::sun::star::sdbc::XRow
>
130 m_xRowOrigin
; //XRow-interface from m_xOrigin
131 //!! call impl_init_xRowOrigin() bevor you access this member
132 com::sun::star::uno::Reference
< com::sun::star::ucb::XContentAccess
>
133 m_xContentAccessOrigin
; //XContentAccess-interface from m_xOrigin
134 //!! call impl_init_xContentAccessOrigin() bevor you access this member
135 com::sun::star::uno::Reference
< com::sun::star::beans::XPropertySet
>
136 m_xPropertySetOrigin
; //XPropertySet-interface from m_xOrigin
137 //!! call impl_init_xPropertySetOrigin() bevor you access this member
139 com::sun::star::uno::Reference
< com::sun::star::beans::XPropertySetInfo
>
141 //call impl_initPropertySetInfo() bevor you access this member
143 sal_Int32 m_nForwardOnly
;
146 com::sun::star::uno::Reference
< com::sun::star::beans::XPropertyChangeListener
>
148 ContentResultSetWrapperListener
*
151 com::sun::star::uno::Reference
< com::sun::star::sdbc::XResultSetMetaData
>
152 m_xMetaDataFromOrigin
; //XResultSetMetaData from m_xOrigin
154 //management of listeners
155 sal_Bool m_bDisposed
; ///Dispose call ready.
156 sal_Bool m_bInDispose
;///In dispose call
157 osl::Mutex m_aContainerMutex
;
158 cppu::OInterfaceContainerHelper
*
159 m_pDisposeEventListeners
;
160 PropertyChangeListenerContainer_Impl
*
161 m_pPropertyChangeListeners
;
162 PropertyChangeListenerContainer_Impl
*
163 m_pVetoableChangeListeners
;
165 //-----------------------------------------------------------------
168 PropertyChangeListenerContainer_Impl
* SAL_CALL
169 impl_getPropertyChangeListenerContainer();
171 PropertyChangeListenerContainer_Impl
* SAL_CALL
172 impl_getVetoableChangeListenerContainer();
175 //-----------------------------------------------------------------
177 ContentResultSetWrapper( com::sun::star::uno::Reference
<
178 com::sun::star::sdbc::XResultSet
> xOrigin
);
180 virtual ~ContentResultSetWrapper();
182 void SAL_CALL
impl_init();
183 void SAL_CALL
impl_deinit();
187 void SAL_CALL
impl_init_xRowOrigin();
188 void SAL_CALL
impl_init_xContentAccessOrigin();
189 void SAL_CALL
impl_init_xPropertySetOrigin();
193 virtual void SAL_CALL
impl_initPropertySetInfo(); //helping XPropertySet
196 impl_EnsureNotDisposed()
197 throw( com::sun::star::lang::DisposedException
,
198 com::sun::star::uno::RuntimeException
);
201 impl_notifyPropertyChangeListeners(
202 const com::sun::star::beans::PropertyChangeEvent
& rEvt
);
205 impl_notifyVetoableChangeListeners(
206 const com::sun::star::beans::PropertyChangeEvent
& rEvt
)
207 throw( com::sun::star::beans::PropertyVetoException
,
208 com::sun::star::uno::RuntimeException
);
210 sal_Bool SAL_CALL
impl_isForwardOnly();
214 //-----------------------------------------------------------------
216 //-----------------------------------------------------------------
217 virtual com::sun::star::uno::Any SAL_CALL
218 queryInterface( const com::sun::star::uno::Type
& rType
)
219 throw( com::sun::star::uno::RuntimeException
);
221 //-----------------------------------------------------------------
223 //-----------------------------------------------------------------
224 virtual void SAL_CALL
225 dispose() throw( com::sun::star::uno::RuntimeException
);
227 virtual void SAL_CALL
228 addEventListener( const com::sun::star::uno::Reference
<
229 com::sun::star::lang::XEventListener
>& Listener
)
230 throw( com::sun::star::uno::RuntimeException
);
232 virtual void SAL_CALL
233 removeEventListener( const com::sun::star::uno::Reference
<
234 com::sun::star::lang::XEventListener
>& Listener
)
235 throw( com::sun::star::uno::RuntimeException
);
237 //-----------------------------------------------------------------
239 //-----------------------------------------------------------------
240 virtual void SAL_CALL
242 throw( com::sun::star::sdbc::SQLException
,
243 com::sun::star::uno::RuntimeException
);
245 //-----------------------------------------------------------------
246 //XResultSetMetaDataSupplier
247 //-----------------------------------------------------------------
248 virtual com::sun::star::uno::Reference
<
249 com::sun::star::sdbc::XResultSetMetaData
> SAL_CALL
251 throw( com::sun::star::sdbc::SQLException
,
252 com::sun::star::uno::RuntimeException
);
254 //-----------------------------------------------------------------
256 //-----------------------------------------------------------------
257 virtual com::sun::star::uno::Reference
<
258 com::sun::star::beans::XPropertySetInfo
> SAL_CALL
260 throw( com::sun::star::uno::RuntimeException
);
262 virtual void SAL_CALL
263 setPropertyValue( const OUString
& aPropertyName
,
264 const com::sun::star::uno::Any
& aValue
)
265 throw( com::sun::star::beans::UnknownPropertyException
,
266 com::sun::star::beans::PropertyVetoException
,
267 com::sun::star::lang::IllegalArgumentException
,
268 com::sun::star::lang::WrappedTargetException
,
269 com::sun::star::uno::RuntimeException
);
271 virtual com::sun::star::uno::Any SAL_CALL
272 getPropertyValue( const OUString
& PropertyName
)
273 throw( com::sun::star::beans::UnknownPropertyException
,
274 com::sun::star::lang::WrappedTargetException
,
275 com::sun::star::uno::RuntimeException
);
277 virtual void SAL_CALL
278 addPropertyChangeListener( const OUString
& aPropertyName
,
279 const com::sun::star::uno::Reference
<
280 com::sun::star::beans::XPropertyChangeListener
>& xListener
)
281 throw( com::sun::star::beans::UnknownPropertyException
,
282 com::sun::star::lang::WrappedTargetException
,
283 com::sun::star::uno::RuntimeException
);
285 virtual void SAL_CALL
286 removePropertyChangeListener( const OUString
& aPropertyName
,
287 const com::sun::star::uno::Reference
<
288 com::sun::star::beans::XPropertyChangeListener
>& aListener
)
289 throw( com::sun::star::beans::UnknownPropertyException
,
290 com::sun::star::lang::WrappedTargetException
,
291 com::sun::star::uno::RuntimeException
);
293 virtual void SAL_CALL
294 addVetoableChangeListener( const OUString
& PropertyName
,
295 const com::sun::star::uno::Reference
<
296 com::sun::star::beans::XVetoableChangeListener
>& aListener
)
297 throw( com::sun::star::beans::UnknownPropertyException
,
298 com::sun::star::lang::WrappedTargetException
,
299 com::sun::star::uno::RuntimeException
);
301 virtual void SAL_CALL
302 removeVetoableChangeListener( const OUString
& PropertyName
,
303 const com::sun::star::uno::Reference
<
304 com::sun::star::beans::XVetoableChangeListener
>& aListener
)
305 throw( com::sun::star::beans::UnknownPropertyException
,
306 com::sun::star::lang::WrappedTargetException
,
307 com::sun::star::uno::RuntimeException
);
309 //-----------------------------------------------------------------
311 //-----------------------------------------------------------------
312 virtual void SAL_CALL
313 impl_disposing( const com::sun::star::lang::EventObject
& Source
)
314 throw( com::sun::star::uno::RuntimeException
);
316 virtual void SAL_CALL
317 impl_propertyChange( const com::sun::star::beans::PropertyChangeEvent
& evt
)
318 throw( com::sun::star::uno::RuntimeException
);
320 virtual void SAL_CALL
321 impl_vetoableChange( const com::sun::star::beans::PropertyChangeEvent
& aEvent
)
322 throw( com::sun::star::beans::PropertyVetoException
,
323 com::sun::star::uno::RuntimeException
);
325 //-----------------------------------------------------------------
327 //-----------------------------------------------------------------
328 virtual OUString SAL_CALL
329 queryContentIdentifierString()
330 throw( com::sun::star::uno::RuntimeException
);
332 virtual com::sun::star::uno::Reference
<
333 com::sun::star::ucb::XContentIdentifier
> SAL_CALL
334 queryContentIdentifier()
335 throw( com::sun::star::uno::RuntimeException
);
337 virtual com::sun::star::uno::Reference
<
338 com::sun::star::ucb::XContent
> SAL_CALL
340 throw( com::sun::star::uno::RuntimeException
);
342 //-----------------------------------------------------------------
344 //-----------------------------------------------------------------
345 virtual sal_Bool SAL_CALL
347 throw( com::sun::star::sdbc::SQLException
,
348 com::sun::star::uno::RuntimeException
);
349 virtual sal_Bool SAL_CALL
351 throw( com::sun::star::sdbc::SQLException
,
352 com::sun::star::uno::RuntimeException
);
353 virtual sal_Bool SAL_CALL
355 throw( com::sun::star::sdbc::SQLException
,
356 com::sun::star::uno::RuntimeException
);
357 virtual sal_Bool SAL_CALL
359 throw( com::sun::star::sdbc::SQLException
,
360 com::sun::star::uno::RuntimeException
);
361 virtual sal_Bool SAL_CALL
363 throw( com::sun::star::sdbc::SQLException
,
364 com::sun::star::uno::RuntimeException
);
365 virtual void SAL_CALL
367 throw( com::sun::star::sdbc::SQLException
,
368 com::sun::star::uno::RuntimeException
);
369 virtual void SAL_CALL
371 throw( com::sun::star::sdbc::SQLException
,
372 com::sun::star::uno::RuntimeException
);
373 virtual sal_Bool SAL_CALL
375 throw( com::sun::star::sdbc::SQLException
,
376 com::sun::star::uno::RuntimeException
);
377 virtual sal_Bool SAL_CALL
379 throw( com::sun::star::sdbc::SQLException
,
380 com::sun::star::uno::RuntimeException
);
381 virtual sal_Int32 SAL_CALL
383 throw( com::sun::star::sdbc::SQLException
,
384 com::sun::star::uno::RuntimeException
);
385 virtual sal_Bool SAL_CALL
386 absolute( sal_Int32 row
)
387 throw( com::sun::star::sdbc::SQLException
,
388 com::sun::star::uno::RuntimeException
);
389 virtual sal_Bool SAL_CALL
390 relative( sal_Int32 rows
)
391 throw( com::sun::star::sdbc::SQLException
,
392 com::sun::star::uno::RuntimeException
);
393 virtual sal_Bool SAL_CALL
395 throw( com::sun::star::sdbc::SQLException
,
396 com::sun::star::uno::RuntimeException
);
397 virtual void SAL_CALL
399 throw( com::sun::star::sdbc::SQLException
,
400 com::sun::star::uno::RuntimeException
);
401 virtual sal_Bool SAL_CALL
403 throw( com::sun::star::sdbc::SQLException
,
404 com::sun::star::uno::RuntimeException
);
405 virtual sal_Bool SAL_CALL
407 throw( com::sun::star::sdbc::SQLException
,
408 com::sun::star::uno::RuntimeException
);
409 virtual sal_Bool SAL_CALL
411 throw( com::sun::star::sdbc::SQLException
,
412 com::sun::star::uno::RuntimeException
);
413 virtual com::sun::star::uno::Reference
<
414 com::sun::star::uno::XInterface
> SAL_CALL
416 throw( com::sun::star::sdbc::SQLException
,
417 com::sun::star::uno::RuntimeException
);
419 //-----------------------------------------------------------------
421 //-----------------------------------------------------------------
422 virtual sal_Bool SAL_CALL
424 throw( com::sun::star::sdbc::SQLException
,
425 com::sun::star::uno::RuntimeException
);
427 virtual OUString SAL_CALL
428 getString( sal_Int32 columnIndex
)
429 throw( com::sun::star::sdbc::SQLException
,
430 com::sun::star::uno::RuntimeException
);
432 virtual sal_Bool SAL_CALL
433 getBoolean( sal_Int32 columnIndex
)
434 throw( com::sun::star::sdbc::SQLException
,
435 com::sun::star::uno::RuntimeException
);
437 virtual sal_Int8 SAL_CALL
438 getByte( sal_Int32 columnIndex
)
439 throw( com::sun::star::sdbc::SQLException
,
440 com::sun::star::uno::RuntimeException
);
442 virtual sal_Int16 SAL_CALL
443 getShort( sal_Int32 columnIndex
)
444 throw( com::sun::star::sdbc::SQLException
,
445 com::sun::star::uno::RuntimeException
);
447 virtual sal_Int32 SAL_CALL
448 getInt( sal_Int32 columnIndex
)
449 throw( com::sun::star::sdbc::SQLException
,
450 com::sun::star::uno::RuntimeException
);
452 virtual sal_Int64 SAL_CALL
453 getLong( sal_Int32 columnIndex
)
454 throw( com::sun::star::sdbc::SQLException
,
455 com::sun::star::uno::RuntimeException
);
457 virtual float SAL_CALL
458 getFloat( sal_Int32 columnIndex
)
459 throw( com::sun::star::sdbc::SQLException
,
460 com::sun::star::uno::RuntimeException
);
462 virtual double SAL_CALL
463 getDouble( sal_Int32 columnIndex
)
464 throw( com::sun::star::sdbc::SQLException
,
465 com::sun::star::uno::RuntimeException
);
467 virtual com::sun::star::uno::Sequence
< sal_Int8
> SAL_CALL
468 getBytes( sal_Int32 columnIndex
)
469 throw( com::sun::star::sdbc::SQLException
,
470 com::sun::star::uno::RuntimeException
);
472 virtual com::sun::star::util::Date SAL_CALL
473 getDate( sal_Int32 columnIndex
)
474 throw( com::sun::star::sdbc::SQLException
,
475 com::sun::star::uno::RuntimeException
);
477 virtual com::sun::star::util::Time SAL_CALL
478 getTime( sal_Int32 columnIndex
)
479 throw( com::sun::star::sdbc::SQLException
,
480 com::sun::star::uno::RuntimeException
);
482 virtual com::sun::star::util::DateTime SAL_CALL
483 getTimestamp( sal_Int32 columnIndex
)
484 throw( com::sun::star::sdbc::SQLException
,
485 com::sun::star::uno::RuntimeException
);
487 virtual com::sun::star::uno::Reference
<
488 com::sun::star::io::XInputStream
> SAL_CALL
489 getBinaryStream( sal_Int32 columnIndex
)
490 throw( com::sun::star::sdbc::SQLException
,
491 com::sun::star::uno::RuntimeException
);
493 virtual com::sun::star::uno::Reference
<
494 com::sun::star::io::XInputStream
> SAL_CALL
495 getCharacterStream( sal_Int32 columnIndex
)
496 throw( com::sun::star::sdbc::SQLException
,
497 com::sun::star::uno::RuntimeException
);
499 virtual com::sun::star::uno::Any SAL_CALL
500 getObject( sal_Int32 columnIndex
,
501 const com::sun::star::uno::Reference
<
502 com::sun::star::container::XNameAccess
>& typeMap
)
503 throw( com::sun::star::sdbc::SQLException
,
504 com::sun::star::uno::RuntimeException
);
506 virtual com::sun::star::uno::Reference
<
507 com::sun::star::sdbc::XRef
> SAL_CALL
508 getRef( sal_Int32 columnIndex
)
509 throw( com::sun::star::sdbc::SQLException
,
510 com::sun::star::uno::RuntimeException
);
512 virtual com::sun::star::uno::Reference
<
513 com::sun::star::sdbc::XBlob
> SAL_CALL
514 getBlob( sal_Int32 columnIndex
)
515 throw( com::sun::star::sdbc::SQLException
,
516 com::sun::star::uno::RuntimeException
);
518 virtual com::sun::star::uno::Reference
<
519 com::sun::star::sdbc::XClob
> SAL_CALL
520 getClob( sal_Int32 columnIndex
)
521 throw( com::sun::star::sdbc::SQLException
,
522 com::sun::star::uno::RuntimeException
);
524 virtual com::sun::star::uno::Reference
<
525 com::sun::star::sdbc::XArray
> SAL_CALL
526 getArray( sal_Int32 columnIndex
)
527 throw( com::sun::star::sdbc::SQLException
,
528 com::sun::star::uno::RuntimeException
);
531 //=========================================================================
533 class ContentResultSetWrapperListener
534 : public cppu::OWeakObject
535 , public com::sun::star::beans::XPropertyChangeListener
536 , public com::sun::star::beans::XVetoableChangeListener
539 ContentResultSetWrapper
* m_pOwner
;
542 ContentResultSetWrapperListener( ContentResultSetWrapper
* pOwner
);
544 virtual ~ContentResultSetWrapperListener();
546 //-----------------------------------------------------------------
548 //-----------------------------------------------------------------
551 //-----------------------------------------------------------------
553 //-----------------------------------------------------------------
554 virtual void SAL_CALL
555 disposing( const com::sun::star::lang::EventObject
& Source
)
556 throw( com::sun::star::uno::RuntimeException
);
558 //-----------------------------------------------------------------
559 //XPropertyChangeListener
560 //-----------------------------------------------------------------
561 virtual void SAL_CALL
562 propertyChange( const com::sun::star::beans::PropertyChangeEvent
& evt
)
563 throw( com::sun::star::uno::RuntimeException
);
565 //-----------------------------------------------------------------
566 //XVetoableChangeListener
567 //-----------------------------------------------------------------
568 virtual void SAL_CALL
569 vetoableChange( const com::sun::star::beans::PropertyChangeEvent
& aEvent
)
570 throw( com::sun::star::beans::PropertyVetoException
,
571 com::sun::star::uno::RuntimeException
);
573 //-----------------------------------------------------------------
575 void SAL_CALL
impl_OwnerDies();
580 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */