LibreOffice Module ucbhelper (master)  1
resultset.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 #ifndef INCLUDED_UCBHELPER_RESULTSET_HXX
21 #define INCLUDED_UCBHELPER_RESULTSET_HXX
22 
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>
31 
32 #include <rtl/ref.hxx>
34 #include <cppuhelper/implbase.hxx>
36 #include <memory>
37 
38 namespace com::sun::star::uno { class XComponentContext; }
39 namespace com::sun::star::ucb { class XCommandEnvironment; }
40 
41 namespace ucbhelper {
42 
43 
44 #define RESULTSET_SERVICE_NAME "com.sun.star.ucb.ContentResultSet"
45 
46 
47 class ResultSetDataSupplier;
48 struct ResultSet_Impl;
49 
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>
69 {
70  std::unique_ptr<ResultSet_Impl> m_pImpl;
71 
72 public:
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 );
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;
101 
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;
106 
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;
114 
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;
122 
123  // XResultSetMetaDataSupplier
124  virtual css::uno::Reference< css::sdbc::XResultSetMetaData > SAL_CALL
125  getMetaData() override;
126 
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;
164 
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;
210 
211  // XCloseable
212  virtual void SAL_CALL
213  close() override;
214 
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;
235 
236 
237  // Non-interface methods.
238 
239 
246  void propertyChanged(
247  const css::beans::PropertyChangeEvent& rEvt ) const;
248 
256  void rowCountChanged( sal_uInt32 nOld, sal_uInt32 nNew );
257 
262  void rowCountFinal();
263 
270  const css::uno::Sequence< css::beans::Property >&
271  getProperties() const;
272 
279  const css::uno::Reference< css::ucb::XCommandEnvironment >&
280  getEnvironment() const;
281 };
282 
283 
290 {
291  friend class ResultSet;
292 
293  // No ref, otherwise we get a cyclic reference between supplier and set!
294  // Will be set from ResultSet ctor.
296 
297 public:
298  ResultSetDataSupplier() : m_pResultSet( nullptr ) {}
299 
306 
315  virtual OUString queryContentIdentifierString( sal_uInt32 nIndex ) = 0;
316 
324  virtual css::uno::Reference< css::ucb::XContentIdentifier >
325  queryContentIdentifier( sal_uInt32 nIndex ) = 0;
326 
334  virtual css::uno::Reference< css::ucb::XContent >
335  queryContent( sal_uInt32 nIndex ) = 0;
336 
344  virtual bool getResult( sal_uInt32 nIndex ) = 0;
345 
355  virtual sal_uInt32 totalCount() = 0;
356 
368  virtual sal_uInt32 currentCount() = 0;
369 
381  virtual bool isCountFinal() = 0;
382 
392  virtual css::uno::Reference< css::sdbc::XRow >
393  queryPropertyValues( sal_uInt32 nIndex ) = 0;
394 
402  virtual void releasePropertyValues( sal_uInt32 nIndex ) = 0;
403 
410  virtual void close() = 0;
411 
428  virtual void validate() = 0;
429 };
430 
431 }
432 
433 #endif /* ! INCLUDED_UCBHELPER_RESULTSET_HXX */
434 
435 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Environment getEnvironment(OUString const &name, OUString const &implementation)
float getFloat(const Any &_rAny)
B2DTuple absolute(const B2DTuple &rTup)
signed char sal_Int8
std::unique_ptr< ResultSet_Impl > m_pImpl
Definition: resultset.hxx:70
css::uno::Sequence< OUString > getSupportedServiceNames()
OUString getImplementationName()
virtual bool getResult(sal_uInt32 nIndex)=0
This method returns whether there is a content at the specified index.
virtual css::uno::Reference< css::sdbc::XRow > queryPropertyValues(sal_uInt32 nIndex)=0
This method returns an object for accessing the property values at the specified index.
bool getPropertyValue(ValueType &rValue, css::uno::Reference< css::beans::XPropertySet > const &xPropSet, OUString const &propName)
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
virtual sal_uInt32 totalCount()=0
This method returns the total count of objects in the logical data array of the supplier.
virtual bool isCountFinal()=0
This method returns whether the value returned by currentCount() is "final".
virtual sal_uInt32 currentCount()=0
This method returns the count of objects obtained so far.
virtual OUString queryContentIdentifierString(sal_uInt32 nIndex)=0
This method returns the identifier string of the content at the specified index.
const char last[]
virtual css::uno::Reference< css::ucb::XContent > queryContent(sal_uInt32 nIndex)=0
This method returns the content at the specified index.
unsigned char sal_Bool
virtual void validate()=0
This method will be called by the resultset implementation in order check, whether an error has occur...
bool setPropertyValue(uno::Sequence< beans::PropertyValue > &aProp, const OUString &aName, const uno::Any &aValue)
rtl::Reference< ResultSet > getResultSet() const
This method returns the resultset this supplier belongs to.
Definition: resultset.hxx:305
bool close
This is the base class for an object that supplies data to a result set.
Definition: resultset.hxx:289
This is an implementation of the service com.sun.star.ucb.ContentResultSet.
Definition: resultset.hxx:59
virtual css::uno::Reference< css::ucb::XContentIdentifier > queryContentIdentifier(sal_uInt32 nIndex)=0
This method returns the identifier of the content at the specified index.
double getDouble(const Any &_rAny)
virtual void close()=0
This method will be called by the resultset implementation in order to instruct the data supplier to ...
#define UCBHELPER_DLLPUBLIC
virtual void releasePropertyValues(sal_uInt32 nIndex)=0
This method is called to instruct the supplier to release the (possibly present) property values at t...
void dispose()
OUString getString(const Any &_rAny)
const char first[]