LibreOffice Module ucb (master) 1
ftpresultsetbase.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#pragma once
20
21#include <vector>
22#include <cppuhelper/weak.hxx>
24#include <com/sun/star/lang/XComponent.hpp>
25#include <com/sun/star/ucb/XContentAccess.hpp>
26#include <com/sun/star/sdbc/XCloseable.hpp>
27#include <com/sun/star/beans/XPropertySet.hpp>
28#include <com/sun/star/sdbc/XResultSet.hpp>
29#include <com/sun/star/sdbc/XRow.hpp>
30#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
31#include <com/sun/star/ucb/XContentProvider.hpp>
32#include <com/sun/star/ucb/XContentIdentifier.hpp>
33#include <com/sun/star/uno/XComponentContext.hpp>
34#include <com/sun/star/beans/Property.hpp>
35
36
37namespace ftp {
38
40 : public cppu::OWeakObject,
41 public css::lang::XComponent,
42 public css::sdbc::XRow,
43 public css::sdbc::XResultSet,
44 public css::sdbc::XCloseable,
45 public css::sdbc::XResultSetMetaDataSupplier,
46 public css::beans::XPropertySet,
47 public css::ucb::XContentAccess
48 {
49 public:
50
51 ResultSetBase(css::uno::Reference< css::uno::XComponentContext > xContext,
52 css::uno::Reference< css::ucb::XContentProvider > xProvider,
53 const css::uno::Sequence< css::beans::Property >& seq);
54
55 virtual ~ResultSetBase() override;
56
57 // XInterface
58 virtual css::uno::Any SAL_CALL
59 queryInterface( const css::uno::Type& aType ) override;
60
61 virtual void SAL_CALL
62 acquire()
63 noexcept override;
64
65 virtual void SAL_CALL
66 release()
67 noexcept override;
68
69 // XComponent
70 virtual void SAL_CALL
71 dispose() override;
72
73 virtual void SAL_CALL
75 const css::uno::Reference< css::lang::XEventListener >& xListener ) override;
76
77 virtual void SAL_CALL
78 removeEventListener( const css::uno::Reference< css::lang::XEventListener >& aListener ) override;
79
80
81 // XRow
82 virtual sal_Bool SAL_CALL
83 wasNull() override
84 {
85 if( 0<= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
86 m_nWasNull = m_aItems[m_nRow]->wasNull();
87 else
88 m_nWasNull = true;
89 return m_nWasNull;
90 }
91
92 virtual OUString SAL_CALL
93 getString( sal_Int32 columnIndex ) override
94 {
95 OUString ret;
96 if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
97 ret = m_aItems[m_nRow]->getString( columnIndex );
98
99 return ret;
100 }
101
102 virtual sal_Bool SAL_CALL
103 getBoolean( sal_Int32 columnIndex ) override
104 {
105 if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
106 return m_aItems[m_nRow]->getBoolean( columnIndex );
107 else
108 return false;
109 }
110
111 virtual sal_Int8 SAL_CALL
112 getByte( sal_Int32 columnIndex ) override
113 {
114 if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
115 return m_aItems[m_nRow]->getByte( columnIndex );
116 else
117 return sal_Int8( 0 );
118 }
119
120 virtual sal_Int16 SAL_CALL
121 getShort( sal_Int32 columnIndex ) override
122 {
123 if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
124 return m_aItems[m_nRow]->getShort( columnIndex );
125 else
126 return sal_Int16( 0 );
127 }
128
129 virtual sal_Int32 SAL_CALL
130 getInt( sal_Int32 columnIndex ) override
131 {
132 if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
133 return m_aItems[m_nRow]->getInt( columnIndex );
134 else
135 return 0;
136 }
137
138 virtual sal_Int64 SAL_CALL
139 getLong( sal_Int32 columnIndex ) override
140 {
141 if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
142 return m_aItems[m_nRow]->getLong( columnIndex );
143 else
144 return sal_Int64( 0 );
145 }
146
147 virtual float SAL_CALL
148 getFloat( sal_Int32 columnIndex ) override
149 {
150 if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
151 return m_aItems[m_nRow]->getFloat( columnIndex );
152 else
153 return float( 0 );
154 }
155
156 virtual double SAL_CALL
157 getDouble( sal_Int32 columnIndex ) override
158 {
159 if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
160 return m_aItems[m_nRow]->getDouble( columnIndex );
161 else
162 return double( 0 );
163 }
164
165 virtual css::uno::Sequence< sal_Int8 > SAL_CALL
166 getBytes( sal_Int32 columnIndex ) override
167 {
168 if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
169 return m_aItems[m_nRow]->getBytes( columnIndex );
170 else
171 return css::uno::Sequence< sal_Int8 >();
172 }
173
174 virtual css::util::Date SAL_CALL
175 getDate( sal_Int32 columnIndex ) override
176 {
177 if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
178 return m_aItems[m_nRow]->getDate( columnIndex );
179 else
180 return css::util::Date();
181 }
182
183 virtual css::util::Time SAL_CALL
184 getTime( sal_Int32 columnIndex ) override
185 {
186 if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
187 return m_aItems[m_nRow]->getTime( columnIndex );
188 else
189 return css::util::Time();
190 }
191
192 virtual css::util::DateTime SAL_CALL
193 getTimestamp( sal_Int32 columnIndex ) override
194 {
195 if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
196 return m_aItems[m_nRow]->getTimestamp( columnIndex );
197 else
198 return css::util::DateTime();
199 }
200
201
202 virtual css::uno::Reference< css::io::XInputStream > SAL_CALL
203 getBinaryStream( sal_Int32 columnIndex ) override
204 {
205 if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
206 return m_aItems[m_nRow]->getBinaryStream( columnIndex );
207 else
208 return css::uno::Reference< css::io::XInputStream >();
209 }
210
211 virtual css::uno::Reference< css::io::XInputStream > SAL_CALL
212 getCharacterStream( sal_Int32 columnIndex ) override
213 {
214 if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
215 return m_aItems[m_nRow]->getCharacterStream( columnIndex );
216 else
217 return css::uno::Reference< css::io::XInputStream >();
218 }
219
220 virtual css::uno::Any SAL_CALL
221 getObject( sal_Int32 columnIndex,
222 const css::uno::Reference< css::container::XNameAccess >& typeMap ) override
223 {
224 if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
225 return m_aItems[m_nRow]->getObject( columnIndex,typeMap );
226 else
227 return css::uno::Any();
228 }
229
230 virtual css::uno::Reference< css::sdbc::XRef > SAL_CALL
231 getRef( sal_Int32 columnIndex ) override
232 {
233 if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
234 return m_aItems[m_nRow]->getRef( columnIndex );
235 else
236 return css::uno::Reference< css::sdbc::XRef >();
237 }
238
239 virtual css::uno::Reference< css::sdbc::XBlob > SAL_CALL
240 getBlob( sal_Int32 columnIndex ) override
241 {
242 if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
243 return m_aItems[m_nRow]->getBlob( columnIndex );
244 else
245 return css::uno::Reference< css::sdbc::XBlob >();
246 }
247
248 virtual css::uno::Reference< css::sdbc::XClob > SAL_CALL
249 getClob( sal_Int32 columnIndex ) override
250 {
251 if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
252 return m_aItems[m_nRow]->getClob( columnIndex );
253 else
254 return css::uno::Reference< css::sdbc::XClob >();
255 }
256
257 virtual css::uno::Reference< css::sdbc::XArray > SAL_CALL
258 getArray( sal_Int32 columnIndex ) override
259 {
260 if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
261 return m_aItems[m_nRow]->getArray( columnIndex );
262 else
263 return css::uno::Reference<
264 css::sdbc::XArray >();
265 }
266
267
268 // XResultSet
269
270 virtual sal_Bool SAL_CALL
271 next() override;
272
273 virtual sal_Bool SAL_CALL
274 isBeforeFirst() override;
275
276 virtual sal_Bool SAL_CALL
277 isAfterLast() override;
278
279 virtual sal_Bool SAL_CALL
280 isFirst() override;
281
282 virtual sal_Bool SAL_CALL
283 isLast() override;
284
285 virtual void SAL_CALL
286 beforeFirst() override;
287
288 virtual void SAL_CALL
289 afterLast() override;
290
291 virtual sal_Bool SAL_CALL
292 first() override;
293
294 virtual sal_Bool SAL_CALL
295 last() override;
296
297 virtual sal_Int32 SAL_CALL
298 getRow() override;
299
300 virtual sal_Bool SAL_CALL
301 absolute(
302 sal_Int32 row ) override;
303
304 virtual sal_Bool SAL_CALL
305 relative(
306 sal_Int32 rows ) override;
307
308 virtual sal_Bool SAL_CALL
309 previous() override;
310
311 virtual void SAL_CALL
312 refreshRow() override;
313
314 virtual sal_Bool SAL_CALL
315 rowUpdated() override;
316
317 virtual sal_Bool SAL_CALL
318 rowInserted() override;
319
320 virtual sal_Bool SAL_CALL
321 rowDeleted() override;
322
323
324 virtual css::uno::Reference< css::uno::XInterface > SAL_CALL
325 getStatement() override;
326
327 // XCloseable
328
329 virtual void SAL_CALL
330 close() override;
331
332 // XContentAccess
333
334 virtual OUString SAL_CALL
336
337 virtual css::uno::Reference< css::ucb::XContentIdentifier > SAL_CALL
338 queryContentIdentifier() override;
339
340 virtual css::uno::Reference< css::ucb::XContent > SAL_CALL
341 queryContent() override;
342
343 // XResultSetMetaDataSupplier
344 virtual css::uno::Reference< css::sdbc::XResultSetMetaData > SAL_CALL
345 getMetaData() override;
346
347
348 // XPropertySet
349 virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL
350 getPropertySetInfo() override;
351
352 virtual void SAL_CALL setPropertyValue(
353 const OUString& aPropertyName,
354 const css::uno::Any& aValue ) override;
355
356 virtual css::uno::Any SAL_CALL
358 const OUString& PropertyName ) override;
359
360 virtual void SAL_CALL
362 const OUString& aPropertyName,
363 const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override;
364
365 virtual void SAL_CALL
367 const OUString& aPropertyName,
368 const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override;
369
370 virtual void SAL_CALL
372 const OUString& PropertyName,
373 const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
374
375 virtual void SAL_CALL removeVetoableChangeListener(
376 const OUString& PropertyName,
377 const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
378
379 protected:
380
381 css::uno::Reference< css::uno::XComponentContext >
383 css::uno::Reference< css::ucb::XContentProvider >
385 sal_Int32 m_nRow;
387
388 typedef std::vector< css::uno::Reference<css::ucb::XContentIdentifier > >
390 typedef std::vector< css::uno::Reference< css::sdbc::XRow > >
392
395 std::vector<OUString> m_aPath;
396
397 css::uno::Sequence< css::beans::Property >
399
400 osl::Mutex m_aMutex;
401 std::unique_ptr<comphelper::OInterfaceContainerHelper3<css::lang::XEventListener>> m_pDisposeEventListeners;
402 std::unique_ptr<comphelper::OInterfaceContainerHelper3<css::beans::XPropertyChangeListener>> m_pRowCountListeners;
403 std::unique_ptr<comphelper::OInterfaceContainerHelper3<css::beans::XPropertyChangeListener>> m_pIsFinalListeners;
404 };
405
406
407} // end namespace fileaccess
408
409
410/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual sal_Bool SAL_CALL isAfterLast() override
virtual OUString SAL_CALL getString(sal_Int32 columnIndex) override
virtual css::uno::Reference< css::io::XInputStream > SAL_CALL getBinaryStream(sal_Int32 columnIndex) override
virtual void SAL_CALL addVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
virtual sal_Bool SAL_CALL rowUpdated() override
virtual void SAL_CALL acquire() noexcept override
virtual float SAL_CALL getFloat(sal_Int32 columnIndex) override
virtual sal_Bool SAL_CALL previous() override
std::vector< OUString > m_aPath
ResultSetBase(css::uno::Reference< css::uno::XComponentContext > xContext, css::uno::Reference< css::ucb::XContentProvider > xProvider, const css::uno::Sequence< css::beans::Property > &seq)
virtual sal_Int32 SAL_CALL getInt(sal_Int32 columnIndex) override
css::uno::Sequence< css::beans::Property > m_sProperty
virtual css::uno::Reference< css::sdbc::XResultSetMetaData > SAL_CALL getMetaData() override
virtual css::uno::Any SAL_CALL getObject(sal_Int32 columnIndex, const css::uno::Reference< css::container::XNameAccess > &typeMap) override
std::unique_ptr< comphelper::OInterfaceContainerHelper3< css::lang::XEventListener > > m_pDisposeEventListeners
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getBytes(sal_Int32 columnIndex) override
virtual css::uno::Reference< css::io::XInputStream > SAL_CALL getCharacterStream(sal_Int32 columnIndex) override
virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > &xListener) override
css::uno::Reference< css::uno::XComponentContext > m_xContext
virtual sal_Bool SAL_CALL next() override
virtual css::util::Date SAL_CALL getDate(sal_Int32 columnIndex) override
virtual css::uno::Reference< css::sdbc::XArray > SAL_CALL getArray(sal_Int32 columnIndex) override
virtual css::uno::Reference< css::sdbc::XBlob > SAL_CALL getBlob(sal_Int32 columnIndex) override
virtual void SAL_CALL refreshRow() override
virtual sal_Bool SAL_CALL wasNull() override
virtual sal_Bool SAL_CALL rowInserted() override
virtual css::uno::Reference< css::sdbc::XClob > SAL_CALL getClob(sal_Int32 columnIndex) override
virtual double SAL_CALL getDouble(sal_Int32 columnIndex) override
std::unique_ptr< comphelper::OInterfaceContainerHelper3< css::beans::XPropertyChangeListener > > m_pIsFinalListeners
virtual sal_Bool SAL_CALL relative(sal_Int32 rows) override
css::uno::Reference< css::ucb::XContentProvider > m_xProvider
virtual void SAL_CALL beforeFirst() override
virtual void SAL_CALL close() override
virtual sal_Bool SAL_CALL first() override
virtual void SAL_CALL removePropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &aListener) override
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
virtual ~ResultSetBase() override
virtual void SAL_CALL dispose() override
virtual sal_Bool SAL_CALL isLast() override
std::vector< css::uno::Reference< css::sdbc::XRow > > ItemSet
virtual sal_Int8 SAL_CALL getByte(sal_Int32 columnIndex) override
virtual OUString SAL_CALL queryContentIdentifierString() override
virtual sal_Bool SAL_CALL absolute(sal_Int32 row) override
std::vector< css::uno::Reference< css::ucb::XContentIdentifier > > IdentSet
virtual void SAL_CALL removeVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
virtual sal_Bool SAL_CALL last() override
virtual sal_Bool SAL_CALL rowDeleted() override
virtual sal_Bool SAL_CALL isBeforeFirst() override
virtual css::util::Time SAL_CALL getTime(sal_Int32 columnIndex) override
virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getStatement() override
virtual css::uno::Reference< css::sdbc::XRef > SAL_CALL getRef(sal_Int32 columnIndex) override
virtual css::uno::Reference< css::ucb::XContent > SAL_CALL queryContent() override
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) override
virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > &aListener) override
virtual void SAL_CALL afterLast() override
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &aType) override
virtual css::uno::Reference< css::ucb::XContentIdentifier > SAL_CALL queryContentIdentifier() override
virtual sal_Bool SAL_CALL isFirst() override
virtual css::util::DateTime SAL_CALL getTimestamp(sal_Int32 columnIndex) override
virtual void SAL_CALL release() noexcept override
virtual sal_Bool SAL_CALL getBoolean(sal_Int32 columnIndex) override
virtual sal_Int32 SAL_CALL getRow() override
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
std::unique_ptr< comphelper::OInterfaceContainerHelper3< css::beans::XPropertyChangeListener > > m_pRowCountListeners
virtual void SAL_CALL addPropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
virtual sal_Int16 SAL_CALL getShort(sal_Int32 columnIndex) override
virtual sal_Int64 SAL_CALL getLong(sal_Int32 columnIndex) override
Definition of ftpcontentprovider.
unsigned char sal_Bool
signed char sal_Int8