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 INCLUDED_UCB_SOURCE_CACHER_CONTENTRESULTSETWRAPPER_HXX
21 #define INCLUDED_UCB_SOURCE_CACHER_CONTENTRESULTSETWRAPPER_HXX
23 #include <rtl/ustring.hxx>
24 #include <rtl/ref.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 <cppuhelper/interfacecontainer.h>
35 #include <comphelper/interfacecontainer2.hxx>
39 class ContentResultSetWrapperListener
;
40 class ContentResultSetWrapper
41 : public cppu::OWeakObject
42 , public css::lang::XComponent
43 , public css::sdbc::XCloseable
44 , public css::sdbc::XResultSetMetaDataSupplier
45 , public css::beans::XPropertySet
46 , public css::ucb::XContentAccess
47 , public css::sdbc::XResultSet
48 , public css::sdbc::XRow
51 typedef cppu::OMultiTypeInterfaceContainerHelperVar
<OUString
>
52 PropertyChangeListenerContainer_Impl
;
59 //different Interfaces from Origin:
60 css::uno::Reference
< css::sdbc::XResultSet
>
62 css::uno::Reference
< css::sdbc::XRow
>
63 m_xRowOrigin
; //XRow-interface from m_xOrigin
64 //!! call impl_init_xRowOrigin() bevor you access this member
65 css::uno::Reference
< css::ucb::XContentAccess
>
66 m_xContentAccessOrigin
; //XContentAccess-interface from m_xOrigin
67 //!! call impl_init_xContentAccessOrigin() bevor you access this member
68 css::uno::Reference
< css::beans::XPropertySet
>
69 m_xPropertySetOrigin
; //XPropertySet-interface from m_xOrigin
70 //!! call impl_init_xPropertySetOrigin() bevor you access this member
72 css::uno::Reference
< css::beans::XPropertySetInfo
>
74 //call impl_initPropertySetInfo() bevor you access this member
76 sal_Int32 m_nForwardOnly
;
79 rtl::Reference
<ContentResultSetWrapperListener
>
82 css::uno::Reference
< css::sdbc::XResultSetMetaData
>
83 m_xMetaDataFromOrigin
; //XResultSetMetaData from m_xOrigin
85 //management of listeners
86 bool m_bDisposed
; ///Dispose call ready.
87 bool m_bInDispose
;///In dispose call
88 osl::Mutex m_aContainerMutex
;
89 std::unique_ptr
<comphelper::OInterfaceContainerHelper2
>
90 m_pDisposeEventListeners
;
91 std::unique_ptr
<PropertyChangeListenerContainer_Impl
>
92 m_pPropertyChangeListeners
;
93 std::unique_ptr
<PropertyChangeListenerContainer_Impl
>
94 m_pVetoableChangeListeners
;
100 impl_getPropertyChangeListenerContainer();
103 impl_getVetoableChangeListenerContainer();
110 ContentResultSetWrapper( css::uno::Reference
< css::sdbc::XResultSet
> const & xOrigin
);
112 virtual ~ContentResultSetWrapper() override
;
119 void impl_init_xRowOrigin();
120 void impl_init_xContentAccessOrigin();
121 void impl_init_xPropertySetOrigin();
125 virtual void impl_initPropertySetInfo(); //helping XPropertySet
127 /// @throws css::lang::DisposedException
128 /// @throws css::uno::RuntimeException
130 impl_EnsureNotDisposed();
133 impl_notifyPropertyChangeListeners(
134 const css::beans::PropertyChangeEvent
& rEvt
);
136 /// @throws css::beans::PropertyVetoException
137 /// @throws css::uno::RuntimeException
139 impl_notifyVetoableChangeListeners(
140 const css::beans::PropertyChangeEvent
& rEvt
);
142 bool impl_isForwardOnly();
149 virtual css::uno::Any SAL_CALL
150 queryInterface( const css::uno::Type
& rType
) override
;
155 virtual void SAL_CALL
158 virtual void SAL_CALL
159 addEventListener( const css::uno::Reference
< css::lang::XEventListener
>& Listener
) override
;
161 virtual void SAL_CALL
162 removeEventListener( const css::uno::Reference
< css::lang::XEventListener
>& Listener
) override
;
167 virtual void SAL_CALL
171 //XResultSetMetaDataSupplier
173 virtual css::uno::Reference
< css::sdbc::XResultSetMetaData
> SAL_CALL
174 getMetaData() override
;
179 virtual css::uno::Reference
< css::beans::XPropertySetInfo
> SAL_CALL
180 getPropertySetInfo() override
;
182 virtual void SAL_CALL
183 setPropertyValue( const OUString
& aPropertyName
,
184 const css::uno::Any
& aValue
) override
;
186 virtual css::uno::Any SAL_CALL
187 getPropertyValue( const OUString
& PropertyName
) override
;
189 virtual void SAL_CALL
190 addPropertyChangeListener( const OUString
& aPropertyName
,
191 const css::uno::Reference
< css::beans::XPropertyChangeListener
>& xListener
) override
;
193 virtual void SAL_CALL
194 removePropertyChangeListener( const OUString
& aPropertyName
,
195 const css::uno::Reference
< css::beans::XPropertyChangeListener
>& aListener
) override
;
197 virtual void SAL_CALL
198 addVetoableChangeListener( const OUString
& PropertyName
,
199 const css::uno::Reference
< css::beans::XVetoableChangeListener
>& aListener
) override
;
201 virtual void SAL_CALL
202 removeVetoableChangeListener( const OUString
& PropertyName
,
203 const css::uno::Reference
< css::beans::XVetoableChangeListener
>& aListener
) override
;
208 /// @throws css::uno::RuntimeException
210 impl_disposing( const css::lang::EventObject
& Source
);
212 /// @throws css::uno::RuntimeException
214 impl_propertyChange( const css::beans::PropertyChangeEvent
& evt
);
216 /// @throws css::beans::PropertyVetoException
217 /// @throws css::uno::RuntimeException
219 impl_vetoableChange( const css::beans::PropertyChangeEvent
& aEvent
);
224 virtual OUString SAL_CALL
225 queryContentIdentifierString() override
;
227 virtual css::uno::Reference
< css::ucb::XContentIdentifier
> SAL_CALL
228 queryContentIdentifier() override
;
230 virtual css::uno::Reference
< css::ucb::XContent
> SAL_CALL
231 queryContent() override
;
236 virtual sal_Bool SAL_CALL
238 virtual sal_Bool SAL_CALL
239 isBeforeFirst() override
;
240 virtual sal_Bool SAL_CALL
241 isAfterLast() override
;
242 virtual sal_Bool SAL_CALL
244 virtual sal_Bool SAL_CALL
246 virtual void SAL_CALL
247 beforeFirst() override
;
248 virtual void SAL_CALL
249 afterLast() override
;
250 virtual sal_Bool SAL_CALL
252 virtual sal_Bool SAL_CALL
254 virtual sal_Int32 SAL_CALL
256 virtual sal_Bool SAL_CALL
257 absolute( sal_Int32 row
) override
;
258 virtual sal_Bool SAL_CALL
259 relative( sal_Int32 rows
) override
;
260 virtual sal_Bool SAL_CALL
262 virtual void SAL_CALL
263 refreshRow() override
;
264 virtual sal_Bool SAL_CALL
265 rowUpdated() override
;
266 virtual sal_Bool SAL_CALL
267 rowInserted() override
;
268 virtual sal_Bool SAL_CALL
269 rowDeleted() override
;
270 virtual css::uno::Reference
<
271 css::uno::XInterface
> SAL_CALL
272 getStatement() override
;
277 virtual sal_Bool SAL_CALL
280 virtual OUString SAL_CALL
281 getString( sal_Int32 columnIndex
) override
;
283 virtual sal_Bool SAL_CALL
284 getBoolean( sal_Int32 columnIndex
) override
;
286 virtual sal_Int8 SAL_CALL
287 getByte( sal_Int32 columnIndex
) override
;
289 virtual sal_Int16 SAL_CALL
290 getShort( sal_Int32 columnIndex
) override
;
292 virtual sal_Int32 SAL_CALL
293 getInt( sal_Int32 columnIndex
) override
;
295 virtual sal_Int64 SAL_CALL
296 getLong( sal_Int32 columnIndex
) override
;
298 virtual float SAL_CALL
299 getFloat( sal_Int32 columnIndex
) override
;
301 virtual double SAL_CALL
302 getDouble( sal_Int32 columnIndex
) override
;
304 virtual css::uno::Sequence
< sal_Int8
> SAL_CALL
305 getBytes( sal_Int32 columnIndex
) override
;
307 virtual css::util::Date SAL_CALL
308 getDate( sal_Int32 columnIndex
) override
;
310 virtual css::util::Time SAL_CALL
311 getTime( sal_Int32 columnIndex
) override
;
313 virtual css::util::DateTime SAL_CALL
314 getTimestamp( sal_Int32 columnIndex
) override
;
316 virtual css::uno::Reference
< css::io::XInputStream
> SAL_CALL
317 getBinaryStream( sal_Int32 columnIndex
) override
;
319 virtual css::uno::Reference
< css::io::XInputStream
> SAL_CALL
320 getCharacterStream( sal_Int32 columnIndex
) override
;
322 virtual css::uno::Any SAL_CALL
323 getObject( sal_Int32 columnIndex
,
324 const css::uno::Reference
< css::container::XNameAccess
>& typeMap
) override
;
326 virtual css::uno::Reference
< css::sdbc::XRef
> SAL_CALL
327 getRef( sal_Int32 columnIndex
) override
;
329 virtual css::uno::Reference
< css::sdbc::XBlob
> SAL_CALL
330 getBlob( sal_Int32 columnIndex
) override
;
332 virtual css::uno::Reference
< css::sdbc::XClob
> SAL_CALL
333 getClob( sal_Int32 columnIndex
) override
;
335 virtual css::uno::Reference
< css::sdbc::XArray
> SAL_CALL
336 getArray( sal_Int32 columnIndex
) override
;
340 class ContentResultSetWrapperListener
341 : public cppu::OWeakObject
342 , public css::beans::XPropertyChangeListener
343 , public css::beans::XVetoableChangeListener
345 ContentResultSetWrapper
* m_pOwner
;
348 ContentResultSetWrapperListener( ContentResultSetWrapper
* pOwner
);
350 virtual ~ContentResultSetWrapperListener() override
;
354 virtual css::uno::Any SAL_CALL
queryInterface( const css::uno::Type
& rType
) override
;
355 virtual void SAL_CALL
acquire()
357 virtual void SAL_CALL
release()
362 virtual void SAL_CALL
363 disposing( const css::lang::EventObject
& Source
) override
;
366 //XPropertyChangeListener
368 virtual void SAL_CALL
369 propertyChange( const css::beans::PropertyChangeEvent
& evt
) override
;
372 //XVetoableChangeListener
374 virtual void SAL_CALL
375 vetoableChange( const css::beans::PropertyChangeEvent
& aEvent
) override
;
379 void impl_OwnerDies();
384 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */