bump product version to 7.2.5.1
[LibreOffice.git] / ucb / source / ucp / ftp / ftpresultsetbase.hxx
blobf20a4eb4219c498395b2bbc80449d4bceb2eca97
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 .
19 #pragma once
21 #include <vector>
22 #include <cppuhelper/weak.hxx>
23 #include <comphelper/interfacecontainer2.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>
37 namespace ftp {
39 class ResultSetBase
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
49 public:
51 ResultSetBase(const css::uno::Reference< css::uno::XComponentContext >& rxContext,
52 const css::uno::Reference< css::ucb::XContentProvider >& xProvider,
53 const css::uno::Sequence< css::beans::Property >& seq);
55 virtual ~ResultSetBase() override;
57 // XInterface
58 virtual css::uno::Any SAL_CALL
59 queryInterface( const css::uno::Type& aType ) override;
61 virtual void SAL_CALL
62 acquire()
63 noexcept override;
65 virtual void SAL_CALL
66 release()
67 noexcept override;
69 // XComponent
70 virtual void SAL_CALL
71 dispose() override;
73 virtual void SAL_CALL
74 addEventListener(
75 const css::uno::Reference< css::lang::XEventListener >& xListener ) override;
77 virtual void SAL_CALL
78 removeEventListener( const css::uno::Reference< css::lang::XEventListener >& aListener ) override;
81 // XRow
82 virtual sal_Bool SAL_CALL
83 wasNull() override
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;
92 virtual OUString SAL_CALL
93 getString( sal_Int32 columnIndex ) override
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 );
99 return ret;
102 virtual sal_Bool SAL_CALL
103 getBoolean( sal_Int32 columnIndex ) override
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;
111 virtual sal_Int8 SAL_CALL
112 getByte( sal_Int32 columnIndex ) override
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 );
120 virtual sal_Int16 SAL_CALL
121 getShort( sal_Int32 columnIndex ) override
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 );
129 virtual sal_Int32 SAL_CALL
130 getInt( sal_Int32 columnIndex ) override
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;
138 virtual sal_Int64 SAL_CALL
139 getLong( sal_Int32 columnIndex ) override
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 );
147 virtual float SAL_CALL
148 getFloat( sal_Int32 columnIndex ) override
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 );
156 virtual double SAL_CALL
157 getDouble( sal_Int32 columnIndex ) override
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 );
165 virtual css::uno::Sequence< sal_Int8 > SAL_CALL
166 getBytes( sal_Int32 columnIndex ) override
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 >();
174 virtual css::util::Date SAL_CALL
175 getDate( sal_Int32 columnIndex ) override
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();
183 virtual css::util::Time SAL_CALL
184 getTime( sal_Int32 columnIndex ) override
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();
192 virtual css::util::DateTime SAL_CALL
193 getTimestamp( sal_Int32 columnIndex ) override
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();
202 virtual css::uno::Reference< css::io::XInputStream > SAL_CALL
203 getBinaryStream( sal_Int32 columnIndex ) override
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 >();
211 virtual css::uno::Reference< css::io::XInputStream > SAL_CALL
212 getCharacterStream( sal_Int32 columnIndex ) override
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 >();
220 virtual css::uno::Any SAL_CALL
221 getObject( sal_Int32 columnIndex,
222 const css::uno::Reference< css::container::XNameAccess >& typeMap ) override
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();
230 virtual css::uno::Reference< css::sdbc::XRef > SAL_CALL
231 getRef( sal_Int32 columnIndex ) override
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 >();
239 virtual css::uno::Reference< css::sdbc::XBlob > SAL_CALL
240 getBlob( sal_Int32 columnIndex ) override
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 >();
248 virtual css::uno::Reference< css::sdbc::XClob > SAL_CALL
249 getClob( sal_Int32 columnIndex ) override
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 >();
257 virtual css::uno::Reference< css::sdbc::XArray > SAL_CALL
258 getArray( sal_Int32 columnIndex ) override
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 >();
268 // XResultSet
270 virtual sal_Bool SAL_CALL
271 next() override;
273 virtual sal_Bool SAL_CALL
274 isBeforeFirst() override;
276 virtual sal_Bool SAL_CALL
277 isAfterLast() override;
279 virtual sal_Bool SAL_CALL
280 isFirst() override;
282 virtual sal_Bool SAL_CALL
283 isLast() override;
285 virtual void SAL_CALL
286 beforeFirst() override;
288 virtual void SAL_CALL
289 afterLast() override;
291 virtual sal_Bool SAL_CALL
292 first() override;
294 virtual sal_Bool SAL_CALL
295 last() override;
297 virtual sal_Int32 SAL_CALL
298 getRow() override;
300 virtual sal_Bool SAL_CALL
301 absolute(
302 sal_Int32 row ) override;
304 virtual sal_Bool SAL_CALL
305 relative(
306 sal_Int32 rows ) override;
308 virtual sal_Bool SAL_CALL
309 previous() override;
311 virtual void SAL_CALL
312 refreshRow() override;
314 virtual sal_Bool SAL_CALL
315 rowUpdated() override;
317 virtual sal_Bool SAL_CALL
318 rowInserted() override;
320 virtual sal_Bool SAL_CALL
321 rowDeleted() override;
324 virtual css::uno::Reference< css::uno::XInterface > SAL_CALL
325 getStatement() override;
327 // XCloseable
329 virtual void SAL_CALL
330 close() override;
332 // XContentAccess
334 virtual OUString SAL_CALL
335 queryContentIdentifierString() override;
337 virtual css::uno::Reference< css::ucb::XContentIdentifier > SAL_CALL
338 queryContentIdentifier() override;
340 virtual css::uno::Reference< css::ucb::XContent > SAL_CALL
341 queryContent() override;
343 // XResultSetMetaDataSupplier
344 virtual css::uno::Reference< css::sdbc::XResultSetMetaData > SAL_CALL
345 getMetaData() override;
348 // XPropertySet
349 virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL
350 getPropertySetInfo() override;
352 virtual void SAL_CALL setPropertyValue(
353 const OUString& aPropertyName,
354 const css::uno::Any& aValue ) override;
356 virtual css::uno::Any SAL_CALL
357 getPropertyValue(
358 const OUString& PropertyName ) override;
360 virtual void SAL_CALL
361 addPropertyChangeListener(
362 const OUString& aPropertyName,
363 const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override;
365 virtual void SAL_CALL
366 removePropertyChangeListener(
367 const OUString& aPropertyName,
368 const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override;
370 virtual void SAL_CALL
371 addVetoableChangeListener(
372 const OUString& PropertyName,
373 const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
375 virtual void SAL_CALL removeVetoableChangeListener(
376 const OUString& PropertyName,
377 const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
379 protected:
381 css::uno::Reference< css::uno::XComponentContext >
382 m_xContext;
383 css::uno::Reference< css::ucb::XContentProvider >
384 m_xProvider;
385 sal_Int32 m_nRow;
386 bool m_nWasNull;
388 typedef std::vector< css::uno::Reference<css::ucb::XContentIdentifier > >
389 IdentSet;
390 typedef std::vector< css::uno::Reference< css::sdbc::XRow > >
391 ItemSet;
393 IdentSet m_aIdents;
394 ItemSet m_aItems;
395 std::vector<OUString> m_aPath;
397 css::uno::Sequence< css::beans::Property >
398 m_sProperty;
400 osl::Mutex m_aMutex;
401 std::unique_ptr<comphelper::OInterfaceContainerHelper2> m_pDisposeEventListeners;
402 std::unique_ptr<comphelper::OInterfaceContainerHelper2> m_pRowCountListeners;
403 std::unique_ptr<comphelper::OInterfaceContainerHelper2> m_pIsFinalListeners;
407 } // end namespace fileaccess
410 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */