LibreOffice Module ucb (master) 1
filrset.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 <mutex>
22#include <vector>
23#include <osl/file.hxx>
24
26#include <com/sun/star/ucb/XContentAccess.hpp>
27#include <com/sun/star/sdbc/XCloseable.hpp>
28#include <com/sun/star/beans/XPropertySet.hpp>
29#include <com/sun/star/ucb/XDynamicResultSet.hpp>
30#include <com/sun/star/ucb/XDynamicResultSetListener.hpp>
31#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
32#include <com/sun/star/ucb/NumberedSortingInfo.hpp>
33#include <com/sun/star/ucb/XContentIdentifier.hpp>
34#include <com/sun/star/beans/Property.hpp>
35#include "filrow.hxx"
37
38namespace fileaccess {
39
41 public cppu::WeakImplHelper< css::lang::XEventListener,
42 css::sdbc::XRow,
43 css::sdbc::XResultSet,
44 css::ucb::XDynamicResultSet,
45 css::sdbc::XCloseable,
46 css::sdbc::XResultSetMetaDataSupplier,
47 css::beans::XPropertySet,
48 css::ucb::XContentAccess >
49 {
50 public:
51
53 const OUString& aUnqPath,
54 sal_Int32 OpenMode,
55 const css::uno::Sequence< css::beans::Property >& seq,
56 const css::uno::Sequence< css::ucb::NumberedSortingInfo >& seqSort );
57
58 virtual ~XResultSet_impl() override;
59
60 sal_Int32 CtorSuccess() const { return m_nErrorCode;}
61 sal_Int32 getMinorError() const { return m_nMinorErrorCode;}
62
63 // XEventListener
64 virtual void SAL_CALL
65 disposing( const css::lang::EventObject& Source ) override;
66
67 // XComponent
68 virtual void SAL_CALL
69 dispose() override;
70
71 virtual void SAL_CALL
73 const css::uno::Reference< css::lang::XEventListener >& xListener ) override;
74
75 virtual void SAL_CALL
76 removeEventListener( const css::uno::Reference< css::lang::XEventListener >& aListener ) override;
77
78
79 // XRow
80 virtual sal_Bool SAL_CALL
81 wasNull() override
82 {
83 if( 0<= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
84 m_nWasNull = m_aItems[m_nRow]->wasNull();
85 else
86 m_nWasNull = true;
87 return m_nWasNull;
88 }
89
90 virtual OUString SAL_CALL
91 getString( sal_Int32 columnIndex ) override
92 {
93 if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
94 return m_aItems[m_nRow]->getString( columnIndex );
95 else
96 return OUString();
97 }
98
99 virtual sal_Bool SAL_CALL
100 getBoolean( sal_Int32 columnIndex ) override
101 {
102 if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
103 return m_aItems[m_nRow]->getBoolean( columnIndex );
104 else
105 return false;
106 }
107
108 virtual sal_Int8 SAL_CALL
109 getByte( sal_Int32 columnIndex ) override
110 {
111 if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
112 return m_aItems[m_nRow]->getByte( columnIndex );
113 else
114 return sal_Int8( 0 );
115 }
116
117 virtual sal_Int16 SAL_CALL
118 getShort( sal_Int32 columnIndex ) override
119 {
120 if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
121 return m_aItems[m_nRow]->getShort( columnIndex );
122 else
123 return sal_Int16( 0 );
124 }
125
126 virtual sal_Int32 SAL_CALL
127 getInt( sal_Int32 columnIndex ) override
128 {
129 if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
130 return m_aItems[m_nRow]->getInt( columnIndex );
131 else
132 return 0;
133 }
134
135 virtual sal_Int64 SAL_CALL
136 getLong( sal_Int32 columnIndex ) override
137 {
138 if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
139 return m_aItems[m_nRow]->getLong( columnIndex );
140 else
141 return sal_Int64( 0 );
142 }
143
144 virtual float SAL_CALL
145 getFloat( sal_Int32 columnIndex ) override
146 {
147 if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
148 return m_aItems[m_nRow]->getFloat( columnIndex );
149 else
150 return float( 0 );
151 }
152
153 virtual double SAL_CALL
154 getDouble( sal_Int32 columnIndex ) override
155 {
156 if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
157 return m_aItems[m_nRow]->getDouble( columnIndex );
158 else
159 return double( 0 );
160 }
161
162 virtual css::uno::Sequence< sal_Int8 > SAL_CALL
163 getBytes( sal_Int32 columnIndex ) override
164 {
165 if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
166 return m_aItems[m_nRow]->getBytes( columnIndex );
167 else
168 return css::uno::Sequence< sal_Int8 >();
169 }
170
171 virtual css::util::Date SAL_CALL
172 getDate( sal_Int32 columnIndex ) override
173 {
174 if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
175 return m_aItems[m_nRow]->getDate( columnIndex );
176 else
177 return css::util::Date();
178 }
179
180 virtual css::util::Time SAL_CALL
181 getTime( sal_Int32 columnIndex ) override
182 {
183 if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
184 return m_aItems[m_nRow]->getTime( columnIndex );
185 else
186 return css::util::Time();
187 }
188
189 virtual css::util::DateTime SAL_CALL
190 getTimestamp( sal_Int32 columnIndex ) override
191 {
192 if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
193 return m_aItems[m_nRow]->getTimestamp( columnIndex );
194 else
195 return css::util::DateTime();
196 }
197
198 virtual css::uno::Reference< css::io::XInputStream > SAL_CALL
199 getBinaryStream( sal_Int32 columnIndex ) override
200 {
201 if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
202 return m_aItems[m_nRow]->getBinaryStream( columnIndex );
203 else
204 return css::uno::Reference< css::io::XInputStream >();
205 }
206
207 virtual css::uno::Reference< css::io::XInputStream > SAL_CALL
208 getCharacterStream( sal_Int32 columnIndex ) override
209 {
210 if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
211 return m_aItems[m_nRow]->getCharacterStream( columnIndex );
212 else
213 return css::uno::Reference< css::io::XInputStream >();
214 }
215
216 virtual css::uno::Any SAL_CALL
217 getObject( sal_Int32 columnIndex,
218 const css::uno::Reference< css::container::XNameAccess >& typeMap ) override
219 {
220 if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
221 return m_aItems[m_nRow]->getObject( columnIndex,typeMap );
222 else
223 return css::uno::Any();
224 }
225
226 virtual css::uno::Reference< css::sdbc::XRef > SAL_CALL
227 getRef( sal_Int32 columnIndex ) override
228 {
229 if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
230 return m_aItems[m_nRow]->getRef( columnIndex );
231 else
232 return css::uno::Reference< css::sdbc::XRef >();
233 }
234
235 virtual css::uno::Reference< css::sdbc::XBlob > SAL_CALL
236 getBlob( sal_Int32 columnIndex ) override
237 {
238 if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
239 return m_aItems[m_nRow]->getBlob( columnIndex );
240 else
241 return css::uno::Reference< css::sdbc::XBlob >();
242 }
243
244 virtual css::uno::Reference< css::sdbc::XClob > SAL_CALL
245 getClob( sal_Int32 columnIndex ) override
246 {
247 if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
248 return m_aItems[m_nRow]->getClob( columnIndex );
249 else
250 return css::uno::Reference< css::sdbc::XClob >();
251 }
252
253 virtual css::uno::Reference< css::sdbc::XArray > SAL_CALL
254 getArray( sal_Int32 columnIndex ) override
255 {
256 if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
257 return m_aItems[m_nRow]->getArray( columnIndex );
258 else
259 return css::uno::Reference< css::sdbc::XArray >();
260 }
261
262
263 // XResultSet
264
265 virtual sal_Bool SAL_CALL
266 next() override;
267
268 virtual sal_Bool SAL_CALL
269 isBeforeFirst() override;
270
271 virtual sal_Bool SAL_CALL
272 isAfterLast() override;
273
274 virtual sal_Bool SAL_CALL
275 isFirst() override;
276
277 virtual sal_Bool SAL_CALL
278 isLast() override;
279
280 virtual void SAL_CALL
281 beforeFirst() override;
282
283 virtual void SAL_CALL
284 afterLast() override;
285
286 virtual sal_Bool SAL_CALL
287 first() override;
288
289 virtual sal_Bool SAL_CALL
290 last() override;
291
292 virtual sal_Int32 SAL_CALL
293 getRow() override;
294
295 virtual sal_Bool SAL_CALL
296 absolute( sal_Int32 row ) override;
297
298 virtual sal_Bool SAL_CALL
299 relative( sal_Int32 rows ) override;
300
301 virtual sal_Bool SAL_CALL
302 previous() override;
303
304 virtual void SAL_CALL
305 refreshRow() override;
306
307 virtual sal_Bool SAL_CALL
308 rowUpdated() override;
309
310 virtual sal_Bool SAL_CALL
311 rowInserted() override;
312
313 virtual sal_Bool SAL_CALL
314 rowDeleted() override;
315
316
317 virtual css::uno::Reference< css::uno::XInterface > SAL_CALL
318 getStatement() override;
319
320
321 // XDynamicResultSet
322
323 virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL
324 getStaticResultSet() override;
325
326 virtual void SAL_CALL
328 const css::uno::Reference<
329 css::ucb::XDynamicResultSetListener >& Listener ) override;
330
331 virtual void SAL_CALL
332 connectToCache( const css::uno::Reference< css::ucb::XDynamicResultSet > & xCache ) override;
333
334 virtual sal_Int16 SAL_CALL
335 getCapabilities() override;
336
337
338 // XCloseable
339
340 virtual void SAL_CALL
341 close() override;
342
343 // XContentAccess
344
345 virtual OUString SAL_CALL
347
348 virtual css::uno::Reference< css::ucb::XContentIdentifier > SAL_CALL
349 queryContentIdentifier() override;
350
351 virtual css::uno::Reference< css::ucb::XContent > SAL_CALL
352 queryContent() override;
353
354 // XResultSetMetaDataSupplier
355 virtual css::uno::Reference< css::sdbc::XResultSetMetaData > SAL_CALL
356 getMetaData() override;
357
358
359 // XPropertySet
360 virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL
361 getPropertySetInfo() override;
362
363 virtual void SAL_CALL setPropertyValue(
364 const OUString& aPropertyName,
365 const css::uno::Any& aValue ) override;
366
367 virtual css::uno::Any SAL_CALL
369 const OUString& PropertyName ) override;
370
371 virtual void SAL_CALL
373 const OUString& aPropertyName,
374 const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override;
375
376 virtual void SAL_CALL
378 const OUString& aPropertyName,
379 const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override;
380
381 virtual void SAL_CALL
383 const OUString& PropertyName,
384 const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
385
386 virtual void SAL_CALL removeVetoableChangeListener(
387 const OUString& PropertyName,
388 const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
389
390 private:
391
394 sal_Int32 m_nRow;
396 sal_Int32 m_nOpenMode;
398
399 typedef std::vector< css::uno::Reference< css::ucb::XContentIdentifier > > IdentSet;
400 typedef std::vector< css::uno::Reference< css::sdbc::XRow > > ItemSet;
401
404 std::vector< OUString > m_aUnqPath;
405 const OUString m_aBaseDirectory;
406
407 osl::Directory m_aFolder;
408 css::uno::Sequence< css::beans::Property > m_sProperty;
409 css::uno::Sequence< css::ucb::NumberedSortingInfo > m_sSortingInfo;
410
411 std::mutex m_aMutex;
415
416 css::uno::Reference< css::ucb::XDynamicResultSetListener > m_xListener;
417
418 sal_Int32 m_nErrorCode;
420
421 // Methods
424 bool OneMore();
425
426 void rowCountChanged(std::unique_lock<std::mutex>&);
427 void isFinalChanged();
428 };
429
430
431} // end namespace fileaccess
432
433
434/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void SAL_CALL refreshRow() override
Definition: filrset.cxx:377
osl::Directory m_aFolder
Definition: filrset.hxx:407
virtual css::uno::Reference< css::sdbc::XBlob > SAL_CALL getBlob(sal_Int32 columnIndex) override
Definition: filrset.hxx:236
comphelper::OInterfaceContainerHelper4< css::lang::XEventListener > m_aDisposeEventListeners
Definition: filrset.hxx:412
css::uno::Reference< css::ucb::XDynamicResultSetListener > m_xListener
Definition: filrset.hxx:416
virtual sal_Bool SAL_CALL previous() override
Definition: filrset.cxx:366
virtual css::util::Time SAL_CALL getTime(sal_Int32 columnIndex) override
Definition: filrset.hxx:181
virtual ~XResultSet_impl() override
Definition: filrset.cxx:81
comphelper::OInterfaceContainerHelper4< css::beans::XPropertyChangeListener > m_aIsFinalListeners
Definition: filrset.hxx:414
virtual sal_Bool SAL_CALL isLast() override
Definition: filrset.cxx:276
virtual sal_Bool SAL_CALL isAfterLast() override
Definition: filrset.cxx:262
virtual void SAL_CALL close() override
Definition: filrset.cxx:412
virtual void SAL_CALL removePropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &aListener) override
Definition: filrset.cxx:646
std::vector< css::uno::Reference< css::sdbc::XRow > > ItemSet
Definition: filrset.hxx:400
virtual sal_Int16 SAL_CALL getCapabilities() override
Definition: filrset.cxx:552
virtual void SAL_CALL removeVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
Definition: filrset.cxx:673
css::uno::Sequence< css::beans::Property > m_sProperty
Definition: filrset.hxx:408
virtual css::util::Date SAL_CALL getDate(sal_Int32 columnIndex) override
Definition: filrset.hxx:172
virtual sal_Int32 SAL_CALL getInt(sal_Int32 columnIndex) override
Definition: filrset.hxx:127
virtual sal_Bool SAL_CALL getBoolean(sal_Int32 columnIndex) override
Definition: filrset.hxx:100
virtual sal_Bool SAL_CALL rowDeleted() override
Definition: filrset.cxx:396
virtual sal_Int8 SAL_CALL getByte(sal_Int32 columnIndex) override
Definition: filrset.hxx:109
XResultSet_impl(TaskManager *pMyShell, const OUString &aUnqPath, sal_Int32 OpenMode, const css::uno::Sequence< css::beans::Property > &seq, const css::uno::Sequence< css::ucb::NumberedSortingInfo > &seqSort)
Definition: filrset.cxx:50
virtual css::uno::Any SAL_CALL getObject(sal_Int32 columnIndex, const css::uno::Reference< css::container::XNameAccess > &typeMap) override
Definition: filrset.hxx:217
std::vector< OUString > m_aUnqPath
Definition: filrset.hxx:404
virtual sal_Bool SAL_CALL last() override
Definition: filrset.cxx:310
virtual OUString SAL_CALL queryContentIdentifierString() override
Definition: filrset.cxx:425
virtual void SAL_CALL afterLast() override
Definition: filrset.cxx:293
virtual css::uno::Reference< css::ucb::XContent > SAL_CALL queryContent() override
Definition: filrset.cxx:453
virtual void SAL_CALL disposing(const css::lang::EventObject &Source) override
Definition: filrset.cxx:89
virtual css::uno::Reference< css::io::XInputStream > SAL_CALL getBinaryStream(sal_Int32 columnIndex) override
Definition: filrset.hxx:199
virtual css::uno::Reference< css::sdbc::XResultSetMetaData > SAL_CALL getMetaData() override
Definition: filrset.cxx:561
void rowCountChanged(std::unique_lock< std::mutex > &)
Definition: filrset.cxx:129
virtual css::uno::Reference< css::sdbc::XClob > SAL_CALL getClob(sal_Int32 columnIndex) override
Definition: filrset.hxx:245
TaskManager * m_pMyShell
Definition: filrset.hxx:392
virtual sal_Bool SAL_CALL rowInserted() override
Definition: filrset.cxx:390
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getBytes(sal_Int32 columnIndex) override
Definition: filrset.hxx:163
css::uno::Sequence< css::ucb::NumberedSortingInfo > m_sSortingInfo
Definition: filrset.hxx:409
virtual void SAL_CALL addVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
Definition: filrset.cxx:666
virtual sal_Bool SAL_CALL isFirst() override
Definition: filrset.cxx:269
virtual float SAL_CALL getFloat(sal_Int32 columnIndex) override
Definition: filrset.hxx:145
sal_Int32 CtorSuccess() const
Definition: filrset.hxx:60
virtual css::uno::Reference< css::sdbc::XArray > SAL_CALL getArray(sal_Int32 columnIndex) override
Definition: filrset.hxx:254
sal_Int32 getMinorError() const
Definition: filrset.hxx:61
virtual void SAL_CALL beforeFirst() override
Definition: filrset.cxx:286
virtual sal_Bool SAL_CALL rowUpdated() override
Definition: filrset.cxx:384
virtual OUString SAL_CALL getString(sal_Int32 columnIndex) override
Definition: filrset.hxx:91
virtual void SAL_CALL dispose() override
Definition: filrset.cxx:116
virtual sal_Int16 SAL_CALL getShort(sal_Int32 columnIndex) override
Definition: filrset.hxx:118
virtual css::util::DateTime SAL_CALL getTimestamp(sal_Int32 columnIndex) override
Definition: filrset.hxx:190
virtual sal_Int32 SAL_CALL getRow() override
Definition: filrset.cxx:320
virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > &xListener) override
Definition: filrset.cxx:96
virtual sal_Bool SAL_CALL isBeforeFirst() override
Definition: filrset.cxx:255
virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getStaticResultSet() override
Definition: filrset.cxx:467
virtual void SAL_CALL addPropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
Definition: filrset.cxx:625
virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > &aListener) override
Definition: filrset.cxx:106
virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getStatement() override
Definition: filrset.cxx:403
const OUString m_aBaseDirectory
Definition: filrset.hxx:405
virtual void SAL_CALL setListener(const css::uno::Reference< css::ucb::XDynamicResultSetListener > &Listener) override
Definition: filrset.cxx:480
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
Definition: filrset.cxx:608
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: filrset.cxx:585
virtual void SAL_CALL connectToCache(const css::uno::Reference< css::ucb::XDynamicResultSet > &xCache) override
Definition: filrset.cxx:518
comphelper::OInterfaceContainerHelper4< css::beans::XPropertyChangeListener > m_aRowCountListeners
Definition: filrset.hxx:413
virtual sal_Bool SAL_CALL relative(sal_Int32 rows) override
Definition: filrset.cxx:352
virtual sal_Int64 SAL_CALL getLong(sal_Int32 columnIndex) override
Definition: filrset.hxx:136
virtual css::uno::Reference< css::sdbc::XRef > SAL_CALL getRef(sal_Int32 columnIndex) override
Definition: filrset.hxx:227
virtual css::uno::Reference< css::ucb::XContentIdentifier > SAL_CALL queryContentIdentifier() override
Definition: filrset.cxx:438
virtual sal_Bool SAL_CALL absolute(sal_Int32 row) override
Definition: filrset.cxx:330
virtual sal_Bool SAL_CALL next() override
Definition: filrset.cxx:244
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) override
Definition: filrset.cxx:598
virtual sal_Bool SAL_CALL wasNull() override
Definition: filrset.hxx:81
virtual sal_Bool SAL_CALL first() override
Definition: filrset.cxx:302
virtual double SAL_CALL getDouble(sal_Int32 columnIndex) override
Definition: filrset.hxx:154
virtual css::uno::Reference< css::io::XInputStream > SAL_CALL getCharacterStream(sal_Int32 columnIndex) override
Definition: filrset.hxx:208
std::vector< css::uno::Reference< css::ucb::XContentIdentifier > > IdentSet
Definition: filrset.hxx:399
unsigned char sal_Bool
signed char sal_Int8