nss: upgrade to release 3.73
[LibreOffice.git] / include / ucbhelper / resultset.hxx
blob243d992230d0466962f8e0b1345c1a22f31db8e6
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_UCBHELPER_RESULTSET_HXX
21 #define INCLUDED_UCBHELPER_RESULTSET_HXX
23 #include <com/sun/star/lang/XServiceInfo.hpp>
24 #include <com/sun/star/lang/XComponent.hpp>
25 #include <com/sun/star/ucb/XContentAccess.hpp>
26 #include <com/sun/star/sdbc/XResultSet.hpp>
27 #include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
28 #include <com/sun/star/sdbc/XRow.hpp>
29 #include <com/sun/star/sdbc/XCloseable.hpp>
30 #include <com/sun/star/beans/XPropertySet.hpp>
32 #include <rtl/ref.hxx>
33 #include <salhelper/simplereferenceobject.hxx>
34 #include <cppuhelper/implbase.hxx>
35 #include <ucbhelper/ucbhelperdllapi.h>
36 #include <memory>
38 namespace com::sun::star::uno { class XComponentContext; }
39 namespace com::sun::star::ucb { class XCommandEnvironment; }
41 namespace ucbhelper {
44 #define RESULTSET_SERVICE_NAME "com.sun.star.ucb.ContentResultSet"
47 class ResultSetDataSupplier;
48 struct ResultSet_Impl;
50 /**
51 * This is an implementation of the service com.sun.star.ucb.ContentResultSet.
52 * It can be used to implement the method XDynamicResultSet::getStaticResultSet,
53 * which needs to be implemented for instance to implement the command "open"
54 * at folder objects. This class uses a user supplied ResultSetDataSupplier
55 * object to request data on demand.
57 * @see ResultSetDataSupplier
59 class UCBHELPER_DLLPUBLIC ResultSet final :
60 public cppu::WeakImplHelper<
61 css::lang::XServiceInfo,
62 css::lang::XComponent,
63 css::ucb::XContentAccess,
64 css::sdbc::XResultSet,
65 css::sdbc::XResultSetMetaDataSupplier,
66 css::sdbc::XRow,
67 css::sdbc::XCloseable,
68 css::beans::XPropertySet>
70 std::unique_ptr<ResultSet_Impl> m_pImpl;
72 public:
73 /**
74 * Construction.
76 * @param rxSMgr is a Service Manager.
77 * @param rProperties is a sequence of properties for that the resultset
78 * shall be able to obtain the values.
79 * @param rDataSupplier is a supplier for the resultset data.
81 ResultSet(
82 const css::uno::Reference< css::uno::XComponentContext >& rxContext,
83 const css::uno::Sequence< css::beans::Property >& rProperties,
84 const rtl::Reference< ResultSetDataSupplier >& rDataSupplier );
85 /**
86 * Construction.
88 * @param rxSMgr is a Service Manager.
89 * @param rProperties is a sequence of properties for that the resultset
90 * shall be able to obtain the values.
91 * @param rDataSupplier is a supplier for the resultset data.
92 * @param rxEnv is the environment for interactions, progress propagation,
93 * ...
95 ResultSet(
96 const css::uno::Reference< css::uno::XComponentContext >& rxContext,
97 const css::uno::Sequence< css::beans::Property >& rProperties,
98 const rtl::Reference< ResultSetDataSupplier >& rDataSupplier,
99 const css::uno::Reference< css::ucb::XCommandEnvironment >& rxEnv );
100 virtual ~ResultSet() override;
102 // XServiceInfo
103 virtual OUString SAL_CALL getImplementationName() override;
104 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
105 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
107 // XComponent
108 virtual void SAL_CALL
109 dispose() override;
110 virtual void SAL_CALL
111 addEventListener( const css::uno::Reference< css::lang::XEventListener >& Listener ) override;
112 virtual void SAL_CALL
113 removeEventListener( const css::uno::Reference< css::lang::XEventListener >& Listener ) override;
115 // XContentAccess
116 virtual OUString SAL_CALL
117 queryContentIdentifierString() override;
118 virtual css::uno::Reference< css::ucb::XContentIdentifier > SAL_CALL
119 queryContentIdentifier() override;
120 virtual css::uno::Reference< css::ucb::XContent > SAL_CALL
121 queryContent() override;
123 // XResultSetMetaDataSupplier
124 virtual css::uno::Reference< css::sdbc::XResultSetMetaData > SAL_CALL
125 getMetaData() override;
127 // XResultSet
128 virtual sal_Bool SAL_CALL
129 next() override;
130 virtual sal_Bool SAL_CALL
131 isBeforeFirst() override;
132 virtual sal_Bool SAL_CALL
133 isAfterLast() override;
134 virtual sal_Bool SAL_CALL
135 isFirst() override;
136 virtual sal_Bool SAL_CALL
137 isLast() override;
138 virtual void SAL_CALL
139 beforeFirst() override;
140 virtual void SAL_CALL
141 afterLast() override;
142 virtual sal_Bool SAL_CALL
143 first() override;
144 virtual sal_Bool SAL_CALL
145 last() override;
146 virtual sal_Int32 SAL_CALL
147 getRow() override;
148 virtual sal_Bool SAL_CALL
149 absolute( sal_Int32 row ) override;
150 virtual sal_Bool SAL_CALL
151 relative( sal_Int32 rows ) override;
152 virtual sal_Bool SAL_CALL
153 previous() override;
154 virtual void SAL_CALL
155 refreshRow() override;
156 virtual sal_Bool SAL_CALL
157 rowUpdated() override;
158 virtual sal_Bool SAL_CALL
159 rowInserted() override;
160 virtual sal_Bool SAL_CALL
161 rowDeleted() override;
162 virtual css::uno::Reference< css::uno::XInterface > SAL_CALL
163 getStatement() override;
165 // XRow
166 virtual sal_Bool SAL_CALL
167 wasNull() override;
168 virtual OUString SAL_CALL
169 getString( sal_Int32 columnIndex ) override;
170 virtual sal_Bool SAL_CALL
171 getBoolean( sal_Int32 columnIndex ) override;
172 virtual sal_Int8 SAL_CALL
173 getByte( sal_Int32 columnIndex ) override;
174 virtual sal_Int16 SAL_CALL
175 getShort( sal_Int32 columnIndex ) override;
176 virtual sal_Int32 SAL_CALL
177 getInt( sal_Int32 columnIndex ) override;
178 virtual sal_Int64 SAL_CALL
179 getLong( sal_Int32 columnIndex ) override;
180 virtual float SAL_CALL
181 getFloat( sal_Int32 columnIndex ) override;
182 virtual double SAL_CALL
183 getDouble( sal_Int32 columnIndex ) override;
184 virtual css::uno::Sequence< sal_Int8 > SAL_CALL
185 getBytes( sal_Int32 columnIndex ) override;
186 virtual css::util::Date SAL_CALL
187 getDate( sal_Int32 columnIndex ) override;
188 virtual css::util::Time SAL_CALL
189 getTime( sal_Int32 columnIndex ) override;
190 virtual css::util::DateTime SAL_CALL
191 getTimestamp( sal_Int32 columnIndex ) override;
192 virtual css::uno::Reference<
193 css::io::XInputStream > SAL_CALL
194 getBinaryStream( sal_Int32 columnIndex ) override;
195 virtual css::uno::Reference<
196 css::io::XInputStream > SAL_CALL
197 getCharacterStream( sal_Int32 columnIndex ) override;
198 virtual css::uno::Any SAL_CALL
199 getObject( sal_Int32 columnIndex,
200 const css::uno::Reference< css::container::XNameAccess >& typeMap ) override;
201 virtual css::uno::Reference< css::sdbc::XRef > SAL_CALL
202 getRef( sal_Int32 columnIndex ) override;
203 virtual css::uno::Reference<
204 css::sdbc::XBlob > SAL_CALL
205 getBlob( sal_Int32 columnIndex ) override;
206 virtual css::uno::Reference< css::sdbc::XClob > SAL_CALL
207 getClob( sal_Int32 columnIndex ) override;
208 virtual css::uno::Reference< css::sdbc::XArray > SAL_CALL
209 getArray( sal_Int32 columnIndex ) override;
211 // XCloseable
212 virtual void SAL_CALL
213 close() override;
215 // XPropertySet
216 virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL
217 getPropertySetInfo() override;
218 virtual void SAL_CALL
219 setPropertyValue( const OUString& aPropertyName,
220 const css::uno::Any& aValue ) override;
221 virtual css::uno::Any SAL_CALL
222 getPropertyValue( const OUString& PropertyName ) override;
223 virtual void SAL_CALL
224 addPropertyChangeListener( const OUString& aPropertyName,
225 const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override;
226 virtual void SAL_CALL
227 removePropertyChangeListener( const OUString& aPropertyName,
228 const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override;
229 virtual void SAL_CALL
230 addVetoableChangeListener( const OUString& PropertyName,
231 const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
232 virtual void SAL_CALL
233 removeVetoableChangeListener( const OUString& PropertyName,
234 const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
237 // Non-interface methods.
241 * This method propagates property value changes to all registered
242 * listeners.
244 * @param rEvt is a property change event.
246 void propertyChanged(
247 const css::beans::PropertyChangeEvent& rEvt ) const;
250 * This method should be called by the data supplier for the result set
251 * to indicate that there were new data obtained from the data source.
253 * @param nOld is the old count of rows; must be non-negative.
254 * @param nnew is the new count of rows; must be non-negative.
256 void rowCountChanged( sal_uInt32 nOld, sal_uInt32 nNew );
259 * This method should be called by the data supplier for the result set
260 * to indicate that there were all rows obtained from the data source.
262 void rowCountFinal();
265 * This method returns a sequence containing all properties ( not the
266 * values! ) of the result set.
268 * @return a sequence of properties.
270 const css::uno::Sequence< css::beans::Property >&
271 getProperties() const;
274 * This method returns the environment to use for interactions, progress
275 * propagation, ... It can by empty.
277 * @return an environment or an empty reference.
279 const css::uno::Reference< css::ucb::XCommandEnvironment >&
280 getEnvironment() const;
285 * This is the base class for an object that supplies data to a result set
287 * @see ResultSet
289 class ResultSetDataSupplier : public salhelper::SimpleReferenceObject
291 friend class ResultSet;
293 // No ref, otherwise we get a cyclic reference between supplier and set!
294 // Will be set from ResultSet ctor.
295 ResultSet* m_pResultSet;
297 public:
298 ResultSetDataSupplier() : m_pResultSet( nullptr ) {}
301 * This method returns the resultset this supplier belongs to.
303 * @return the resultset for that the supplier supplies data.
305 rtl::Reference< ResultSet > getResultSet() const { return m_pResultSet; }
308 * This method returns the identifier string of the content at the
309 * specified index.
311 * @param nIndex is the zero-based index within the logical data array
312 * of the supplier; must be non-negative.
313 * @return the content's identifier string.
315 virtual OUString queryContentIdentifierString( sal_uInt32 nIndex ) = 0;
318 * This method returns the identifier of the content at the specified index.
320 * @param nIndex is the zero-based index within the logical data array
321 * of the supplier; must be non-negative.
322 * @return the content's identifier.
324 virtual css::uno::Reference< css::ucb::XContentIdentifier >
325 queryContentIdentifier( sal_uInt32 nIndex ) = 0;
328 * This method returns the content at the specified index.
330 * @param nIndex is the zero-based index within the logical data array
331 * of the supplier; must be non-negative.
332 * @return the content.
334 virtual css::uno::Reference< css::ucb::XContent >
335 queryContent( sal_uInt32 nIndex ) = 0;
338 * This method returns whether there is a content at the specified index.
340 * @param nIndex is the zero-based index within the logical data array
341 * of the supplier; must be non-negative.
342 * @return true, if there is a content at the given index.
344 virtual bool getResult( sal_uInt32 nIndex ) = 0;
347 * This method returns the total count of objects in the logical data array
348 * of the supplier. The implementation of this method may be very
349 * "expensive", because it can be necessary to obtain all data in order
350 * to determine the count. Therefore the ResultSet implementation calls
351 * it very seldom.
353 * @return the total count of objects; will always be non-negative.
355 virtual sal_uInt32 totalCount() = 0;
358 * This method returns the count of objects obtained so far. There is no
359 * for the implementation to obtain all objects at once. It can obtain
360 * all data on demand.
362 * The implementation should call m_pResultSet->rowCountChanged(...)
363 * every time it has inserted a new entry in its logical result array.
365 * @return the count of objects obtained so far; will always be
366 * non-negative.
368 virtual sal_uInt32 currentCount() = 0;
371 * This method returns whether the value returned by currentCount() is
372 * "final". This is the case, if that there was all data obtained by the
373 * supplier and the current count won't increase any more.
375 * The implementation should call m_pResultSet->rowCountFinal(...) if
376 * it has inserted all entries in its logical result array.
378 * @return true, if the value returned by currentCount() won't change
379 anymore.
381 virtual bool isCountFinal() = 0;
384 * This method returns an object for accessing the property values at
385 * the specified index. The implementation may use the helper class
386 * ucb::PropertyValueSet to provide the return value.
388 * @param nIndex is the zero-based index within the logical data array
389 * of the supplier.
390 * @return the object for accessing the property values.
392 virtual css::uno::Reference< css::sdbc::XRow >
393 queryPropertyValues( sal_uInt32 nIndex ) = 0;
396 * This method is called to instruct the supplier to release the (possibly
397 * present) property values at the given index.
399 * @param nIndex is the zero-based index within the logical data array
400 * of the supplier.
402 virtual void releasePropertyValues( sal_uInt32 nIndex ) = 0;
405 * This method will be called by the resultset implementation in order
406 * to instruct the data supplier to release all resources it has
407 * allocated so far. In case the supplier is collecting data
408 * asynchronously, that process must be stopped.
410 virtual void close() = 0;
413 * This method will be called by the resultset implementation in order
414 * check, whether an error has occurred while collecting data. The
415 * implementation of this method must throw an exception in that case.
417 * Note: An exception thrown to indicate an error must always be thrown
418 * by the thread that created the data supplier. If the supplier collects
419 * data asynchronously ( i.e. in a separate thread ) and an error
420 * occurs, throwing of the appropriate exception must be deferred
421 * until validate() is called by the ResultSet implementation from
422 * inside the main thread.
423 * In case data are obtained synchronously, the ResultSetException can
424 * be thrown directly.
426 * @exception ResultSetException thrown, if an error has occurred
428 virtual void validate() = 0;
433 #endif /* ! INCLUDED_UCBHELPER_RESULTSET_HXX */
435 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */