Bump version to 24.04.3.4
[LibreOffice.git] / ucb / source / cacher / contentresultsetwrapper.hxx
blob372779d6e30668a44c2d26adacc77c2f739ee834
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 #pragma once
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>
32 #include <comphelper/interfacecontainer4.hxx>
33 #include <comphelper/multiinterfacecontainer4.hxx>
34 #include <memory>
37 class ContentResultSetWrapperListener;
38 class ContentResultSetWrapper
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
48 protected:
49 typedef comphelper::OMultiTypeInterfaceContainerHelperVar4<OUString, css::beans::XPropertyChangeListener>
50 PropertyChangeListenerContainer_Impl;
51 typedef comphelper::OMultiTypeInterfaceContainerHelperVar4<OUString, css::beans::XVetoableChangeListener>
52 VetoableChangeListenerContainer_Impl;
54 //members
56 //my Mutex
57 std::mutex m_aMutex;
59 //different Interfaces from Origin:
60 css::uno::Reference< css::sdbc::XResultSet >
61 m_xResultSetOrigin;
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 >
73 m_xPropertySetInfo;
74 //call impl_initPropertySetInfo() bevor you access this member
76 sal_Int32 m_nForwardOnly;
78 private:
79 rtl::Reference<ContentResultSetWrapperListener>
80 m_xMyListenerImpl;
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 comphelper::OInterfaceContainerHelper4<css::lang::XEventListener>
89 m_aDisposeEventListeners;
90 PropertyChangeListenerContainer_Impl
91 m_aPropertyChangeListeners;
92 VetoableChangeListenerContainer_Impl
93 m_aVetoableChangeListeners;
96 //methods:
97 private:
98 void verifyGet();
100 protected:
103 ContentResultSetWrapper( css::uno::Reference< css::sdbc::XResultSet > const & xOrigin );
105 virtual ~ContentResultSetWrapper() override;
107 void impl_init();
108 void impl_deinit();
110 //--
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>&);
116 //--
118 virtual void impl_initPropertySetInfo(std::unique_lock<std::mutex>& rGuard); //helping XPropertySet
120 /// @throws css::lang::DisposedException
121 /// @throws css::uno::RuntimeException
122 void
123 impl_EnsureNotDisposed(std::unique_lock<std::mutex>& rGuard);
125 void
126 impl_notifyPropertyChangeListeners(
127 std::unique_lock<std::mutex>& rGuard,
128 const css::beans::PropertyChangeEvent& rEvt );
130 /// @throws css::beans::PropertyVetoException
131 /// @throws css::uno::RuntimeException
132 void
133 impl_notifyVetoableChangeListeners(
134 std::unique_lock<std::mutex>& rGuard,
135 const css::beans::PropertyChangeEvent& rEvt );
137 bool impl_isForwardOnly(std::unique_lock<std::mutex>& rGuard);
139 public:
142 // XInterface
144 virtual css::uno::Any SAL_CALL
145 queryInterface( const css::uno::Type & rType ) override;
148 // XComponent
150 virtual void SAL_CALL
151 dispose() override final;
153 virtual void SAL_CALL
154 addEventListener( const css::uno::Reference< css::lang::XEventListener >& Listener ) override;
156 virtual void SAL_CALL
157 removeEventListener( const css::uno::Reference< css::lang::XEventListener >& Listener ) override;
160 //XCloseable
162 virtual void SAL_CALL
163 close() override;
166 //XResultSetMetaDataSupplier
168 virtual css::uno::Reference< css::sdbc::XResultSetMetaData > SAL_CALL
169 getMetaData() override;
172 // XPropertySet
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);
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 );
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;
206 // own methods
208 /// @throws css::uno::RuntimeException
209 virtual void
210 impl_disposing( const css::lang::EventObject& Source );
212 /// @throws css::uno::RuntimeException
213 virtual void
214 impl_propertyChange( const css::beans::PropertyChangeEvent& evt );
216 /// @throws css::beans::PropertyVetoException
217 /// @throws css::uno::RuntimeException
218 virtual void
219 impl_vetoableChange( const css::beans::PropertyChangeEvent& aEvent );
222 // XContentAccess
224 virtual OUString SAL_CALL
225 queryContentIdentifierString() override final;
226 virtual OUString
227 queryContentIdentifierStringImpl(std::unique_lock<std::mutex>& rGuard);
229 virtual css::uno::Reference< css::ucb::XContentIdentifier > SAL_CALL
230 queryContentIdentifier() override;
232 virtual css::uno::Reference< css::ucb::XContent > SAL_CALL
233 queryContent() override;
236 // XResultSet
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;
277 // XRow
279 virtual sal_Bool SAL_CALL
280 wasNull() override;
282 virtual OUString SAL_CALL
283 getString( sal_Int32 columnIndex ) override;
285 virtual sal_Bool SAL_CALL
286 getBoolean( sal_Int32 columnIndex ) override;
288 virtual sal_Int8 SAL_CALL
289 getByte( sal_Int32 columnIndex ) override;
291 virtual sal_Int16 SAL_CALL
292 getShort( sal_Int32 columnIndex ) override;
294 virtual sal_Int32 SAL_CALL
295 getInt( sal_Int32 columnIndex ) override;
297 virtual sal_Int64 SAL_CALL
298 getLong( sal_Int32 columnIndex ) override;
300 virtual float SAL_CALL
301 getFloat( sal_Int32 columnIndex ) override;
303 virtual double SAL_CALL
304 getDouble( sal_Int32 columnIndex ) override;
306 virtual css::uno::Sequence< sal_Int8 > SAL_CALL
307 getBytes( sal_Int32 columnIndex ) override;
309 virtual css::util::Date SAL_CALL
310 getDate( sal_Int32 columnIndex ) override;
312 virtual css::util::Time SAL_CALL
313 getTime( sal_Int32 columnIndex ) override;
315 virtual css::util::DateTime SAL_CALL
316 getTimestamp( sal_Int32 columnIndex ) override;
318 virtual css::uno::Reference< css::io::XInputStream > SAL_CALL
319 getBinaryStream( sal_Int32 columnIndex ) override;
321 virtual css::uno::Reference< css::io::XInputStream > SAL_CALL
322 getCharacterStream( sal_Int32 columnIndex ) override;
324 virtual css::uno::Any SAL_CALL
325 getObject( sal_Int32 columnIndex,
326 const css::uno::Reference< css::container::XNameAccess >& typeMap ) override;
328 virtual css::uno::Reference< css::sdbc::XRef > SAL_CALL
329 getRef( sal_Int32 columnIndex ) override;
331 virtual css::uno::Reference< css::sdbc::XBlob > SAL_CALL
332 getBlob( sal_Int32 columnIndex ) override;
334 virtual css::uno::Reference< css::sdbc::XClob > SAL_CALL
335 getClob( sal_Int32 columnIndex ) override;
337 virtual css::uno::Reference< css::sdbc::XArray > SAL_CALL
338 getArray( sal_Int32 columnIndex ) override;
342 class ContentResultSetWrapperListener
343 : public cppu::OWeakObject
344 , public css::beans::XPropertyChangeListener
345 , public css::beans::XVetoableChangeListener
347 ContentResultSetWrapper* m_pOwner;
349 public:
350 ContentResultSetWrapperListener( ContentResultSetWrapper* pOwner );
352 virtual ~ContentResultSetWrapperListener() override;
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;
362 //XEventListener
364 virtual void SAL_CALL
365 disposing( const css::lang::EventObject& Source ) override;
368 //XPropertyChangeListener
370 virtual void SAL_CALL
371 propertyChange( const css::beans::PropertyChangeEvent& evt ) override;
374 //XVetoableChangeListener
376 virtual void SAL_CALL
377 vetoableChange( const css::beans::PropertyChangeEvent& aEvent ) override;
380 // own methods:
381 void impl_OwnerDies();
384 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */