Version 4.0.2.1, tag libreoffice-4.0.2.1
[LibreOffice.git] / ucb / source / ucp / ftp / ftpresultsetbase.hxx
blob805cbf474b53ac221579d2f72aebfb913a176958
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 #ifndef _FTP_FTPRESULTSETBASE_HXX_
20 #define _FTP_FTPRESULTSETBASE_HXX_
22 #include <vector>
23 #include <cppuhelper/weak.hxx>
24 #include <cppuhelper/interfacecontainer.hxx>
25 #include <com/sun/star/lang/XComponent.hpp>
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/sdbc/XResultSet.hpp>
30 #include <com/sun/star/sdbc/XRow.hpp>
31 #include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
32 #include <com/sun/star/ucb/NumberedSortingInfo.hpp>
33 #include <com/sun/star/ucb/XContentProvider.hpp>
34 #include <com/sun/star/ucb/XContentIdentifier.hpp>
35 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
36 #include <com/sun/star/beans/Property.hpp>
39 namespace ftp {
41 class ResultSetBase
42 : public cppu::OWeakObject,
43 public com::sun::star::lang::XComponent,
44 public com::sun::star::sdbc::XRow,
45 public com::sun::star::sdbc::XResultSet,
46 public com::sun::star::sdbc::XCloseable,
47 public com::sun::star::sdbc::XResultSetMetaDataSupplier,
48 public com::sun::star::beans::XPropertySet,
49 public com::sun::star::ucb::XContentAccess
51 public:
53 ResultSetBase(const com::sun::star::uno::Reference<
54 com::sun::star::uno::XComponentContext >& rxContext,
55 const com::sun::star::uno::Reference<
56 com::sun::star::ucb::XContentProvider >& xProvider,
57 sal_Int32 nOpenMode,
58 const com::sun::star::uno::Sequence<
59 com::sun::star::beans::Property >& seq,
60 const com::sun::star::uno::Sequence<
61 com::sun::star::ucb::NumberedSortingInfo >& seqSort);
63 virtual ~ResultSetBase();
65 // XInterface
66 virtual com::sun::star::uno::Any SAL_CALL
67 queryInterface(
68 const com::sun::star::uno::Type& aType )
69 throw( com::sun::star::uno::RuntimeException);
71 virtual void SAL_CALL
72 acquire(
73 void )
74 throw();
76 virtual void SAL_CALL
77 release(
78 void )
79 throw();
81 // XComponent
82 virtual void SAL_CALL
83 dispose(
84 void )
85 throw( com::sun::star::uno::RuntimeException );
87 virtual void SAL_CALL
88 addEventListener(
89 const com::sun::star::uno::Reference<
90 com::sun::star::lang::XEventListener >& xListener )
91 throw( com::sun::star::uno::RuntimeException );
93 virtual void SAL_CALL
94 removeEventListener( const com::sun::star::uno::Reference<
95 com::sun::star::lang::XEventListener >& aListener )
96 throw( com::sun::star::uno::RuntimeException );
99 // XRow
100 virtual sal_Bool SAL_CALL
101 wasNull(
102 void )
103 throw( com::sun::star::sdbc::SQLException,
104 com::sun::star::uno::RuntimeException )
106 if( 0<= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
107 m_nWasNull = m_aItems[m_nRow]->wasNull();
108 else
109 m_nWasNull = true;
110 return m_nWasNull;
113 virtual rtl::OUString SAL_CALL
114 getString(
115 sal_Int32 columnIndex )
116 throw( com::sun::star::sdbc::SQLException,
117 com::sun::star::uno::RuntimeException)
119 rtl::OUString ret;
120 if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
121 ret = m_aItems[m_nRow]->getString( columnIndex );
123 return ret;
126 virtual sal_Bool SAL_CALL
127 getBoolean(
128 sal_Int32 columnIndex )
129 throw( com::sun::star::sdbc::SQLException,
130 com::sun::star::uno::RuntimeException)
132 if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
133 return m_aItems[m_nRow]->getBoolean( columnIndex );
134 else
135 return false;
138 virtual sal_Int8 SAL_CALL
139 getByte(
140 sal_Int32 columnIndex )
141 throw( com::sun::star::sdbc::SQLException,
142 com::sun::star::uno::RuntimeException)
144 if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
145 return m_aItems[m_nRow]->getByte( columnIndex );
146 else
147 return sal_Int8( 0 );
150 virtual sal_Int16 SAL_CALL
151 getShort(
152 sal_Int32 columnIndex )
153 throw(
154 com::sun::star::sdbc::SQLException,
155 com::sun::star::uno::RuntimeException)
157 if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
158 return m_aItems[m_nRow]->getShort( columnIndex );
159 else
160 return sal_Int16( 0 );
163 virtual sal_Int32 SAL_CALL
164 getInt(
165 sal_Int32 columnIndex )
166 throw( com::sun::star::sdbc::SQLException,
167 com::sun::star::uno::RuntimeException )
169 if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
170 return m_aItems[m_nRow]->getInt( columnIndex );
171 else
172 return sal_Int32( 0 );
175 virtual sal_Int64 SAL_CALL
176 getLong(
177 sal_Int32 columnIndex )
178 throw( com::sun::star::sdbc::SQLException,
179 com::sun::star::uno::RuntimeException)
181 if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
182 return m_aItems[m_nRow]->getLong( columnIndex );
183 else
184 return sal_Int64( 0 );
187 virtual float SAL_CALL
188 getFloat(
189 sal_Int32 columnIndex )
190 throw( com::sun::star::sdbc::SQLException,
191 com::sun::star::uno::RuntimeException )
193 if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
194 return m_aItems[m_nRow]->getFloat( columnIndex );
195 else
196 return float( 0 );
199 virtual double SAL_CALL
200 getDouble(
201 sal_Int32 columnIndex )
202 throw( com::sun::star::sdbc::SQLException,
203 com::sun::star::uno::RuntimeException )
205 if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
206 return m_aItems[m_nRow]->getDouble( columnIndex );
207 else
208 return double( 0 );
211 virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL
212 getBytes(
213 sal_Int32 columnIndex )
214 throw( com::sun::star::sdbc::SQLException,
215 com::sun::star::uno::RuntimeException )
217 if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
218 return m_aItems[m_nRow]->getBytes( columnIndex );
219 else
220 return com::sun::star::uno::Sequence< sal_Int8 >();
223 virtual com::sun::star::util::Date SAL_CALL
224 getDate(
225 sal_Int32 columnIndex )
226 throw( com::sun::star::sdbc::SQLException,
227 com::sun::star::uno::RuntimeException)
229 if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
230 return m_aItems[m_nRow]->getDate( columnIndex );
231 else
232 return com::sun::star::util::Date();
235 virtual com::sun::star::util::Time SAL_CALL
236 getTime(
237 sal_Int32 columnIndex )
238 throw( com::sun::star::sdbc::SQLException,
239 com::sun::star::uno::RuntimeException)
241 if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
242 return m_aItems[m_nRow]->getTime( columnIndex );
243 else
244 return com::sun::star::util::Time();
247 virtual com::sun::star::util::DateTime SAL_CALL
248 getTimestamp(
249 sal_Int32 columnIndex )
250 throw( com::sun::star::sdbc::SQLException,
251 com::sun::star::uno::RuntimeException)
253 if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
254 return m_aItems[m_nRow]->getTimestamp( columnIndex );
255 else
256 return com::sun::star::util::DateTime();
260 virtual com::sun::star::uno::Reference<
261 com::sun::star::io::XInputStream > SAL_CALL
262 getBinaryStream(
263 sal_Int32 columnIndex )
264 throw( com::sun::star::sdbc::SQLException,
265 com::sun::star::uno::RuntimeException)
267 if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
268 return m_aItems[m_nRow]->getBinaryStream( columnIndex );
269 else
270 return com::sun::star::uno::Reference<
271 com::sun::star::io::XInputStream >();
274 virtual com::sun::star::uno::Reference<
275 com::sun::star::io::XInputStream > SAL_CALL
276 getCharacterStream(
277 sal_Int32 columnIndex )
278 throw( com::sun::star::sdbc::SQLException,
279 com::sun::star::uno::RuntimeException)
281 if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
282 return m_aItems[m_nRow]->getCharacterStream( columnIndex );
283 else
284 return com::sun::star::uno::Reference<
285 com::sun::star::io::XInputStream >();
288 virtual com::sun::star::uno::Any SAL_CALL
289 getObject(
290 sal_Int32 columnIndex,
291 const com::sun::star::uno::Reference<
292 com::sun::star::container::XNameAccess >& typeMap )
293 throw( com::sun::star::sdbc::SQLException,
294 com::sun::star::uno::RuntimeException)
296 if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
297 return m_aItems[m_nRow]->getObject( columnIndex,typeMap );
298 else
299 return com::sun::star::uno::Any();
302 virtual com::sun::star::uno::Reference<
303 com::sun::star::sdbc::XRef > SAL_CALL
304 getRef(
305 sal_Int32 columnIndex )
306 throw( com::sun::star::sdbc::SQLException,
307 com::sun::star::uno::RuntimeException)
309 if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
310 return m_aItems[m_nRow]->getRef( columnIndex );
311 else
312 return com::sun::star::uno::Reference< com::sun::star::sdbc::XRef >();
315 virtual com::sun::star::uno::Reference<
316 com::sun::star::sdbc::XBlob > SAL_CALL
317 getBlob(
318 sal_Int32 columnIndex )
319 throw( com::sun::star::sdbc::SQLException,
320 com::sun::star::uno::RuntimeException)
322 if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
323 return m_aItems[m_nRow]->getBlob( columnIndex );
324 else
325 return com::sun::star::uno::Reference< com::sun::star::sdbc::XBlob >();
328 virtual com::sun::star::uno::Reference<
329 com::sun::star::sdbc::XClob > SAL_CALL
330 getClob(
331 sal_Int32 columnIndex )
332 throw( com::sun::star::sdbc::SQLException,
333 com::sun::star::uno::RuntimeException)
335 if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
336 return m_aItems[m_nRow]->getClob( columnIndex );
337 else
338 return com::sun::star::uno::Reference<
339 com::sun::star::sdbc::XClob >();
342 virtual com::sun::star::uno::Reference<
343 com::sun::star::sdbc::XArray > SAL_CALL
344 getArray(
345 sal_Int32 columnIndex )
346 throw( com::sun::star::sdbc::SQLException,
347 com::sun::star::uno::RuntimeException)
349 if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
350 return m_aItems[m_nRow]->getArray( columnIndex );
351 else
352 return com::sun::star::uno::Reference<
353 com::sun::star::sdbc::XArray >();
357 // XResultSet
359 virtual sal_Bool SAL_CALL
360 next(
361 void )
362 throw( com::sun::star::sdbc::SQLException,
363 com::sun::star::uno::RuntimeException);
365 virtual sal_Bool SAL_CALL
366 isBeforeFirst(
367 void )
368 throw( com::sun::star::sdbc::SQLException,
369 com::sun::star::uno::RuntimeException);
371 virtual sal_Bool SAL_CALL
372 isAfterLast(
373 void )
374 throw( com::sun::star::sdbc::SQLException,
375 com::sun::star::uno::RuntimeException);
377 virtual sal_Bool SAL_CALL
378 isFirst(
379 void )
380 throw( com::sun::star::sdbc::SQLException,
381 com::sun::star::uno::RuntimeException);
383 virtual sal_Bool SAL_CALL
384 isLast(
385 void )
386 throw( com::sun::star::sdbc::SQLException,
387 com::sun::star::uno::RuntimeException);
389 virtual void SAL_CALL
390 beforeFirst(
391 void )
392 throw( com::sun::star::sdbc::SQLException,
393 com::sun::star::uno::RuntimeException);
395 virtual void SAL_CALL
396 afterLast(
397 void )
398 throw( com::sun::star::sdbc::SQLException,
399 com::sun::star::uno::RuntimeException);
401 virtual sal_Bool SAL_CALL
402 first(
403 void )
404 throw( com::sun::star::sdbc::SQLException,
405 com::sun::star::uno::RuntimeException);
407 virtual sal_Bool SAL_CALL
408 last(
409 void )
410 throw( com::sun::star::sdbc::SQLException,
411 com::sun::star::uno::RuntimeException);
413 virtual sal_Int32 SAL_CALL
414 getRow(
415 void )
416 throw( com::sun::star::sdbc::SQLException,
417 com::sun::star::uno::RuntimeException);
419 virtual sal_Bool SAL_CALL
420 absolute(
421 sal_Int32 row )
422 throw( com::sun::star::sdbc::SQLException,
423 com::sun::star::uno::RuntimeException);
425 virtual sal_Bool SAL_CALL
426 relative(
427 sal_Int32 rows )
428 throw( com::sun::star::sdbc::SQLException,
429 com::sun::star::uno::RuntimeException);
431 virtual sal_Bool SAL_CALL
432 previous(
433 void )
434 throw( com::sun::star::sdbc::SQLException,
435 com::sun::star::uno::RuntimeException);
437 virtual void SAL_CALL
438 refreshRow(
439 void )
440 throw( com::sun::star::sdbc::SQLException,
441 com::sun::star::uno::RuntimeException);
443 virtual sal_Bool SAL_CALL
444 rowUpdated(
445 void )
446 throw( com::sun::star::sdbc::SQLException,
447 com::sun::star::uno::RuntimeException);
449 virtual sal_Bool SAL_CALL
450 rowInserted(
451 void )
452 throw( com::sun::star::sdbc::SQLException,
453 com::sun::star::uno::RuntimeException);
455 virtual sal_Bool SAL_CALL
456 rowDeleted(
457 void )
458 throw( com::sun::star::sdbc::SQLException,
459 com::sun::star::uno::RuntimeException);
462 virtual com::sun::star::uno::Reference<
463 com::sun::star::uno::XInterface > SAL_CALL
464 getStatement(
465 void )
466 throw( com::sun::star::sdbc::SQLException,
467 com::sun::star::uno::RuntimeException);
469 // XCloseable
471 virtual void SAL_CALL
472 close(
473 void )
474 throw( com::sun::star::sdbc::SQLException,
475 com::sun::star::uno::RuntimeException);
477 // XContentAccess
479 virtual rtl::OUString SAL_CALL
480 queryContentIdentifierString(
481 void )
482 throw( com::sun::star::uno::RuntimeException );
484 virtual com::sun::star::uno::Reference<
485 com::sun::star::ucb::XContentIdentifier > SAL_CALL
486 queryContentIdentifier(
487 void )
488 throw( com::sun::star::uno::RuntimeException );
490 virtual com::sun::star::uno::Reference<
491 com::sun::star::ucb::XContent > SAL_CALL
492 queryContent(
493 void )
494 throw( com::sun::star::uno::RuntimeException );
496 // XResultSetMetaDataSupplier
497 virtual com::sun::star::uno::Reference<
498 com::sun::star::sdbc::XResultSetMetaData > SAL_CALL
499 getMetaData(
500 void )
501 throw( com::sun::star::sdbc::SQLException,
502 com::sun::star::uno::RuntimeException);
505 // XPropertySet
506 virtual com::sun::star::uno::Reference<
507 com::sun::star::beans::XPropertySetInfo > SAL_CALL
508 getPropertySetInfo()
509 throw( com::sun::star::uno::RuntimeException);
511 virtual void SAL_CALL setPropertyValue(
512 const rtl::OUString& aPropertyName,
513 const com::sun::star::uno::Any& aValue )
514 throw( com::sun::star::beans::UnknownPropertyException,
515 com::sun::star::beans::PropertyVetoException,
516 com::sun::star::lang::IllegalArgumentException,
517 com::sun::star::lang::WrappedTargetException,
518 com::sun::star::uno::RuntimeException);
520 virtual com::sun::star::uno::Any SAL_CALL
521 getPropertyValue(
522 const rtl::OUString& PropertyName )
523 throw( com::sun::star::beans::UnknownPropertyException,
524 com::sun::star::lang::WrappedTargetException,
525 com::sun::star::uno::RuntimeException);
527 virtual void SAL_CALL
528 addPropertyChangeListener(
529 const rtl::OUString& aPropertyName,
530 const com::sun::star::uno::Reference<
531 com::sun::star::beans::XPropertyChangeListener >& xListener )
532 throw( com::sun::star::beans::UnknownPropertyException,
533 com::sun::star::lang::WrappedTargetException,
534 com::sun::star::uno::RuntimeException);
536 virtual void SAL_CALL
537 removePropertyChangeListener(
538 const rtl::OUString& aPropertyName,
539 const com::sun::star::uno::Reference<
540 com::sun::star::beans::XPropertyChangeListener >& aListener )
541 throw( com::sun::star::beans::UnknownPropertyException,
542 com::sun::star::lang::WrappedTargetException,
543 com::sun::star::uno::RuntimeException);
545 virtual void SAL_CALL
546 addVetoableChangeListener(
547 const rtl::OUString& PropertyName,
548 const com::sun::star::uno::Reference<
549 com::sun::star::beans::XVetoableChangeListener >& aListener )
550 throw( com::sun::star::beans::UnknownPropertyException,
551 com::sun::star::lang::WrappedTargetException,
552 com::sun::star::uno::RuntimeException);
554 virtual void SAL_CALL removeVetoableChangeListener(
555 const rtl::OUString& PropertyName,
556 const com::sun::star::uno::Reference<
557 com::sun::star::beans::XVetoableChangeListener >& aListener )
558 throw( com::sun::star::beans::UnknownPropertyException,
559 com::sun::star::lang::WrappedTargetException,
560 com::sun::star::uno::RuntimeException);
562 protected:
564 com::sun::star::uno::Reference<
565 com::sun::star::uno::XComponentContext > m_xContext;
566 com::sun::star::uno::Reference<
567 com::sun::star::ucb::XContentProvider > m_xProvider;
568 sal_Int32 m_nRow;
569 sal_Bool m_nWasNull;
570 sal_Int32 m_nOpenMode;
571 sal_Bool m_bRowCountFinal;
573 typedef std::vector< com::sun::star::uno::Reference<
574 com::sun::star::ucb::XContentIdentifier > > IdentSet;
575 typedef std::vector< com::sun::star::uno::Reference<
576 com::sun::star::sdbc::XRow > > ItemSet;
577 typedef std::vector< rtl::OUString >
578 PathSet;
580 IdentSet m_aIdents;
581 ItemSet m_aItems;
582 PathSet m_aPath;
584 com::sun::star::uno::Sequence<
585 com::sun::star::beans::Property > m_sProperty;
586 com::sun::star::uno::Sequence<
587 com::sun::star::ucb::NumberedSortingInfo > m_sSortingInfo;
589 osl::Mutex m_aMutex;
590 cppu::OInterfaceContainerHelper* m_pDisposeEventListeners;
592 cppu::OInterfaceContainerHelper* m_pRowCountListeners;
593 cppu::OInterfaceContainerHelper* m_pIsFinalListeners;
597 } // end namespace fileaccess
600 #endif
602 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */