LibreOffice Module ucb (master) 1
contentresultsetwrapper.hxx
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#pragma once
21
22#include <rtl/ustring.hxx>
23#include <rtl/ref.hxx>
24#include <cppuhelper/weak.hxx>
25#include <com/sun/star/lang/XComponent.hpp>
26#include <com/sun/star/sdbc/XCloseable.hpp>
27#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
28#include <com/sun/star/sdbc/XResultSet.hpp>
29#include <com/sun/star/sdbc/XRow.hpp>
30#include <com/sun/star/ucb/XContentAccess.hpp>
31#include <com/sun/star/beans/XPropertySet.hpp>
34#include <memory>
35
36
39 : public cppu::OWeakObject
40 , public css::lang::XComponent
41 , public css::sdbc::XCloseable
42 , public css::sdbc::XResultSetMetaDataSupplier
43 , public css::beans::XPropertySet
44 , public css::ucb::XContentAccess
45 , public css::sdbc::XResultSet
46 , public css::sdbc::XRow
47{
48protected:
53
54 //members
55
56 //my Mutex
57 std::mutex m_aMutex;
58
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
65 css::uno::Reference< css::ucb::XContentAccess >
66 m_xContentAccessOrigin; //XContentAccess-interface from m_xOrigin
68 css::uno::Reference< css::beans::XPropertySet >
69 m_xPropertySetOrigin; //XPropertySet-interface from m_xOrigin
71
72 css::uno::Reference< css::beans::XPropertySetInfo >
74 //call impl_initPropertySetInfo() bevor you access this member
75
76 sal_Int32 m_nForwardOnly;
77
78private:
81
82 css::uno::Reference< css::sdbc::XResultSetMetaData >
83 m_xMetaDataFromOrigin; //XResultSetMetaData from m_xOrigin
84
85 //management of listeners
94
95
96 //methods:
97private:
98 void verifyGet();
99
100protected:
101
102
103 ContentResultSetWrapper( css::uno::Reference< css::sdbc::XResultSet > const & xOrigin );
104
105 virtual ~ContentResultSetWrapper() override;
106
107 void impl_init();
108 void impl_deinit();
109
110 //--
111
112 void impl_init_xRowOrigin(std::unique_lock<std::mutex>&);
113 void impl_init_xContentAccessOrigin(std::unique_lock<std::mutex>&);
114 void impl_init_xPropertySetOrigin(std::unique_lock<std::mutex>&);
115
116 //--
117
118 virtual void impl_initPropertySetInfo(std::unique_lock<std::mutex>& rGuard); //helping XPropertySet
119
122 void
123 impl_EnsureNotDisposed(std::unique_lock<std::mutex>& rGuard);
124
125 void
127 std::unique_lock<std::mutex>& rGuard,
128 const css::beans::PropertyChangeEvent& rEvt );
129
132 void
134 std::unique_lock<std::mutex>& rGuard,
135 const css::beans::PropertyChangeEvent& rEvt );
136
137 bool impl_isForwardOnly(std::unique_lock<std::mutex>& rGuard);
138
139public:
140
141
142 // XInterface
143
144 virtual css::uno::Any SAL_CALL
145 queryInterface( const css::uno::Type & rType ) override;
146
147
148 // XComponent
149
150 virtual void SAL_CALL
151 dispose() override final;
152
153 virtual void SAL_CALL
154 addEventListener( const css::uno::Reference< css::lang::XEventListener >& Listener ) override;
155
156 virtual void SAL_CALL
157 removeEventListener( const css::uno::Reference< css::lang::XEventListener >& Listener ) override;
158
159
160 //XCloseable
161
162 virtual void SAL_CALL
163 close() override;
164
165
166 //XResultSetMetaDataSupplier
167
168 virtual css::uno::Reference< css::sdbc::XResultSetMetaData > SAL_CALL
169 getMetaData() override;
170
171
172 // XPropertySet
173
174 virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL
175 getPropertySetInfo() override final;
176 css::uno::Reference< css::beans::XPropertySetInfo >
177 getPropertySetInfoImpl(std::unique_lock<std::mutex>& rGuard);
178
179 virtual void SAL_CALL
180 setPropertyValue( const OUString& aPropertyName,
181 const css::uno::Any& aValue ) final override;
182 virtual void
183 setPropertyValueImpl( std::unique_lock<std::mutex>& rGuard, const OUString& aPropertyName,
184 const css::uno::Any& aValue );
185
186 virtual css::uno::Any SAL_CALL
187 getPropertyValue( const OUString& PropertyName ) override;
188
189 virtual void SAL_CALL
190 addPropertyChangeListener( const OUString& aPropertyName,
191 const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override;
192
193 virtual void SAL_CALL
194 removePropertyChangeListener( const OUString& aPropertyName,
195 const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override;
196
197 virtual void SAL_CALL
198 addVetoableChangeListener( const OUString& PropertyName,
199 const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
200
201 virtual void SAL_CALL
202 removeVetoableChangeListener( const OUString& PropertyName,
203 const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
204
205
206 // own methods
207
209 virtual void
210 impl_disposing( const css::lang::EventObject& Source );
211
213 virtual void
214 impl_propertyChange( const css::beans::PropertyChangeEvent& evt );
215
218 virtual void
219 impl_vetoableChange( const css::beans::PropertyChangeEvent& aEvent );
220
221
222 // XContentAccess
223
224 virtual OUString SAL_CALL
225 queryContentIdentifierString() override final;
226 virtual OUString
227 queryContentIdentifierStringImpl(std::unique_lock<std::mutex>& rGuard);
228
229 virtual css::uno::Reference< css::ucb::XContentIdentifier > SAL_CALL
230 queryContentIdentifier() override;
231
232 virtual css::uno::Reference< css::ucb::XContent > SAL_CALL
233 queryContent() override;
234
235
236 // XResultSet
237
238 virtual sal_Bool SAL_CALL
239 next() override;
240 virtual sal_Bool SAL_CALL
241 isBeforeFirst() override;
242 virtual sal_Bool SAL_CALL
243 isAfterLast() override;
244 virtual sal_Bool SAL_CALL
245 isFirst() override;
246 virtual sal_Bool SAL_CALL
247 isLast() override;
248 virtual void SAL_CALL
249 beforeFirst() override;
250 virtual void SAL_CALL
251 afterLast() override;
252 virtual sal_Bool SAL_CALL
253 first() override;
254 virtual sal_Bool SAL_CALL
255 last() override;
256 virtual sal_Int32 SAL_CALL
257 getRow() override;
258 virtual sal_Bool SAL_CALL
259 absolute( sal_Int32 row ) override;
260 virtual sal_Bool SAL_CALL
261 relative( sal_Int32 rows ) override;
262 virtual sal_Bool SAL_CALL
263 previous() override;
264 virtual void SAL_CALL
265 refreshRow() override;
266 virtual sal_Bool SAL_CALL
267 rowUpdated() override;
268 virtual sal_Bool SAL_CALL
269 rowInserted() override;
270 virtual sal_Bool SAL_CALL
271 rowDeleted() override;
272 virtual css::uno::Reference<
273 css::uno::XInterface > SAL_CALL
274 getStatement() override;
275
276
277 // XRow
278
279 virtual sal_Bool SAL_CALL
280 wasNull() override;
281
282 virtual OUString SAL_CALL
283 getString( sal_Int32 columnIndex ) override;
284
285 virtual sal_Bool SAL_CALL
286 getBoolean( sal_Int32 columnIndex ) override;
287
288 virtual sal_Int8 SAL_CALL
289 getByte( sal_Int32 columnIndex ) override;
290
291 virtual sal_Int16 SAL_CALL
292 getShort( sal_Int32 columnIndex ) override;
293
294 virtual sal_Int32 SAL_CALL
295 getInt( sal_Int32 columnIndex ) override;
296
297 virtual sal_Int64 SAL_CALL
298 getLong( sal_Int32 columnIndex ) override;
299
300 virtual float SAL_CALL
301 getFloat( sal_Int32 columnIndex ) override;
302
303 virtual double SAL_CALL
304 getDouble( sal_Int32 columnIndex ) override;
305
306 virtual css::uno::Sequence< sal_Int8 > SAL_CALL
307 getBytes( sal_Int32 columnIndex ) override;
308
309 virtual css::util::Date SAL_CALL
310 getDate( sal_Int32 columnIndex ) override;
311
312 virtual css::util::Time SAL_CALL
313 getTime( sal_Int32 columnIndex ) override;
314
315 virtual css::util::DateTime SAL_CALL
316 getTimestamp( sal_Int32 columnIndex ) override;
317
318 virtual css::uno::Reference< css::io::XInputStream > SAL_CALL
319 getBinaryStream( sal_Int32 columnIndex ) override;
320
321 virtual css::uno::Reference< css::io::XInputStream > SAL_CALL
322 getCharacterStream( sal_Int32 columnIndex ) override;
323
324 virtual css::uno::Any SAL_CALL
325 getObject( sal_Int32 columnIndex,
326 const css::uno::Reference< css::container::XNameAccess >& typeMap ) override;
327
328 virtual css::uno::Reference< css::sdbc::XRef > SAL_CALL
329 getRef( sal_Int32 columnIndex ) override;
330
331 virtual css::uno::Reference< css::sdbc::XBlob > SAL_CALL
332 getBlob( sal_Int32 columnIndex ) override;
333
334 virtual css::uno::Reference< css::sdbc::XClob > SAL_CALL
335 getClob( sal_Int32 columnIndex ) override;
336
337 virtual css::uno::Reference< css::sdbc::XArray > SAL_CALL
338 getArray( sal_Int32 columnIndex ) override;
339};
340
341
343 : public cppu::OWeakObject
344 , public css::beans::XPropertyChangeListener
345 , public css::beans::XVetoableChangeListener
346{
348
349public:
351
352 virtual ~ContentResultSetWrapperListener() override;
353
354
355 // XInterface
356 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override;
357 virtual void SAL_CALL acquire()
358 noexcept override;
359 virtual void SAL_CALL release()
360 noexcept override;
361
362 //XEventListener
363
364 virtual void SAL_CALL
365 disposing( const css::lang::EventObject& Source ) override;
366
367
368 //XPropertyChangeListener
369
370 virtual void SAL_CALL
371 propertyChange( const css::beans::PropertyChangeEvent& evt ) override;
372
373
374 //XVetoableChangeListener
375
376 virtual void SAL_CALL
377 vetoableChange( const css::beans::PropertyChangeEvent& aEvent ) override;
378
379
380 // own methods:
381 void impl_OwnerDies();
382};
383
384/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void impl_disposing(const css::lang::EventObject &Source)
virtual sal_Bool SAL_CALL first() override
virtual sal_Bool SAL_CALL isLast() override
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
ContentResultSetWrapper(css::uno::Reference< css::sdbc::XResultSet > const &xOrigin)
virtual void SAL_CALL dispose() override final
virtual css::uno::Reference< css::sdbc::XArray > SAL_CALL getArray(sal_Int32 columnIndex) override
css::uno::Reference< css::sdbc::XResultSet > m_xResultSetOrigin
void impl_notifyVetoableChangeListeners(std::unique_lock< std::mutex > &rGuard, const css::beans::PropertyChangeEvent &rEvt)
VetoableChangeListenerContainer_Impl m_aVetoableChangeListeners
virtual sal_Bool SAL_CALL absolute(sal_Int32 row) override
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) final override
void impl_EnsureNotDisposed(std::unique_lock< std::mutex > &rGuard)
virtual void SAL_CALL afterLast() override
virtual void SAL_CALL addVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
comphelper::OInterfaceContainerHelper4< css::lang::XEventListener > m_aDisposeEventListeners
In dispose call.
virtual sal_Int16 SAL_CALL getShort(sal_Int32 columnIndex) override
css::uno::Reference< css::sdbc::XResultSetMetaData > m_xMetaDataFromOrigin
virtual sal_Int64 SAL_CALL getLong(sal_Int32 columnIndex) override
virtual void SAL_CALL addPropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
virtual OUString SAL_CALL queryContentIdentifierString() override final
virtual sal_Bool SAL_CALL rowDeleted() override
virtual css::uno::Any SAL_CALL getObject(sal_Int32 columnIndex, const css::uno::Reference< css::container::XNameAccess > &typeMap) override
virtual css::uno::Reference< css::ucb::XContent > SAL_CALL queryContent() override
css::uno::Reference< css::beans::XPropertySetInfo > m_xPropertySetInfo
! call impl_init_xPropertySetOrigin() bevor you access this member
virtual sal_Bool SAL_CALL rowInserted() override
virtual sal_Bool SAL_CALL getBoolean(sal_Int32 columnIndex) override
virtual ~ContentResultSetWrapper() override
virtual sal_Bool SAL_CALL relative(sal_Int32 rows) override
virtual OUString queryContentIdentifierStringImpl(std::unique_lock< std::mutex > &rGuard)
virtual sal_Bool SAL_CALL isAfterLast() override
virtual void SAL_CALL removeVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
virtual void SAL_CALL removePropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &aListener) override
virtual void setPropertyValueImpl(std::unique_lock< std::mutex > &rGuard, const OUString &aPropertyName, const css::uno::Any &aValue)
virtual void SAL_CALL addEventListener(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 SAL_CALL refreshRow() override
virtual sal_Bool SAL_CALL next() override
virtual sal_Bool SAL_CALL isBeforeFirst() override
rtl::Reference< ContentResultSetWrapperListener > m_xMyListenerImpl
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
virtual OUString SAL_CALL getString(sal_Int32 columnIndex) override
virtual css::uno::Reference< css::ucb::XContentIdentifier > SAL_CALL queryContentIdentifier() override
virtual sal_Bool SAL_CALL wasNull() override
virtual void impl_propertyChange(const css::beans::PropertyChangeEvent &evt)
css::uno::Reference< css::beans::XPropertySet > m_xPropertySetOrigin
! call impl_init_xContentAccessOrigin() bevor you access this member
virtual void SAL_CALL close() override
virtual css::util::Date SAL_CALL getDate(sal_Int32 columnIndex) override
css::uno::Reference< css::sdbc::XRow > m_xRowOrigin
comphelper::OMultiTypeInterfaceContainerHelperVar4< OUString, css::beans::XPropertyChangeListener > PropertyChangeListenerContainer_Impl
virtual css::uno::Reference< css::sdbc::XRef > SAL_CALL getRef(sal_Int32 columnIndex) override
PropertyChangeListenerContainer_Impl m_aPropertyChangeListeners
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getBytes(sal_Int32 columnIndex) override
virtual css::util::DateTime SAL_CALL getTimestamp(sal_Int32 columnIndex) override
virtual css::uno::Reference< css::sdbc::XBlob > SAL_CALL getBlob(sal_Int32 columnIndex) override
virtual sal_Int8 SAL_CALL getByte(sal_Int32 columnIndex) override
virtual sal_Bool SAL_CALL last() override
virtual sal_Bool SAL_CALL rowUpdated() override
void impl_init_xPropertySetOrigin(std::unique_lock< std::mutex > &)
comphelper::OMultiTypeInterfaceContainerHelperVar4< OUString, css::beans::XVetoableChangeListener > VetoableChangeListenerContainer_Impl
css::uno::Reference< css::beans::XPropertySetInfo > getPropertySetInfoImpl(std::unique_lock< std::mutex > &rGuard)
bool impl_isForwardOnly(std::unique_lock< std::mutex > &rGuard)
virtual css::uno::Reference< css::io::XInputStream > SAL_CALL getBinaryStream(sal_Int32 columnIndex) override
void impl_init_xRowOrigin(std::unique_lock< std::mutex > &)
void impl_notifyPropertyChangeListeners(std::unique_lock< std::mutex > &rGuard, const css::beans::PropertyChangeEvent &rEvt)
virtual css::util::Time SAL_CALL getTime(sal_Int32 columnIndex) override
void impl_init_xContentAccessOrigin(std::unique_lock< std::mutex > &)
virtual css::uno::Reference< css::sdbc::XClob > SAL_CALL getClob(sal_Int32 columnIndex) override
virtual sal_Int32 SAL_CALL getInt(sal_Int32 columnIndex) override
virtual void impl_vetoableChange(const css::beans::PropertyChangeEvent &aEvent)
css::uno::Reference< css::ucb::XContentAccess > m_xContentAccessOrigin
! call impl_init_xRowOrigin() bevor you access this member
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override final
virtual double SAL_CALL getDouble(sal_Int32 columnIndex) override
virtual css::uno::Reference< css::sdbc::XResultSetMetaData > SAL_CALL getMetaData() override
virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > &Listener) override
virtual sal_Bool SAL_CALL previous() override
bool m_bInDispose
Dispose call ready.
virtual sal_Int32 SAL_CALL getRow() override
virtual sal_Bool SAL_CALL isFirst() override
virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getStatement() override
virtual void SAL_CALL beforeFirst() override
virtual float SAL_CALL getFloat(sal_Int32 columnIndex) override
virtual void impl_initPropertySetInfo(std::unique_lock< std::mutex > &rGuard)
virtual void SAL_CALL acquire() SAL_NOEXCEPT SAL_OVERRIDE
virtual void SAL_CALL release() SAL_NOEXCEPT SAL_OVERRIDE
unsigned char sal_Bool
signed char sal_Int8