bump product version to 5.0.4.1
[LibreOffice.git] / xmlhelp / source / cxxhelp / provider / resultsetbase.hxx
blobd8d466ac2da930df38a28a38e1fb28bab4e60835
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 INCLUDED_XMLHELP_SOURCE_CXXHELP_PROVIDER_RESULTSETBASE_HXX
20 #define INCLUDED_XMLHELP_SOURCE_CXXHELP_PROVIDER_RESULTSETBASE_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/uno/XComponentContext.hpp>
36 #include <com/sun/star/beans/Property.hpp>
39 namespace chelp {
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< com::sun::star::uno::XComponentContext >& rxContext,
54 const com::sun::star::uno::Reference< com::sun::star::ucb::XContentProvider >& xProvider,
55 sal_Int32 nOpenMode,
56 const com::sun::star::uno::Sequence< com::sun::star::beans::Property >& seq,
57 const com::sun::star::uno::Sequence< com::sun::star::ucb::NumberedSortingInfo >& seqSort );
59 virtual ~ResultSetBase();
61 // XInterface
62 virtual com::sun::star::uno::Any SAL_CALL
63 queryInterface(
64 const com::sun::star::uno::Type& aType )
65 throw( com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
67 virtual void SAL_CALL
68 acquire(
69 void )
70 throw() SAL_OVERRIDE;
72 virtual void SAL_CALL
73 release(
74 void )
75 throw() SAL_OVERRIDE;
77 // XComponent
78 virtual void SAL_CALL
79 dispose(
80 void )
81 throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
83 virtual void SAL_CALL
84 addEventListener(
85 const com::sun::star::uno::Reference< com::sun::star::lang::XEventListener >& xListener )
86 throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
88 virtual void SAL_CALL
89 removeEventListener( const com::sun::star::uno::Reference< com::sun::star::lang::XEventListener >& aListener )
90 throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
93 // XRow
94 virtual sal_Bool SAL_CALL
95 wasNull(
96 void )
97 throw( com::sun::star::sdbc::SQLException,
98 com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE
100 if( 0<= m_nRow && sal::static_int_cast<sal_uInt32>( m_nRow ) < m_aItems.size() )
101 m_nWasNull = m_aItems[m_nRow]->wasNull();
102 else
103 m_nWasNull = true;
104 return m_nWasNull;
107 virtual OUString SAL_CALL
108 getString(
109 sal_Int32 columnIndex )
110 throw( com::sun::star::sdbc::SQLException,
111 com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE
113 if( 0 <= m_nRow && sal::static_int_cast<sal_uInt32>( m_nRow ) < m_aItems.size() )
114 return m_aItems[m_nRow]->getString( columnIndex );
115 else
116 return OUString();
119 virtual sal_Bool SAL_CALL
120 getBoolean(
121 sal_Int32 columnIndex )
122 throw( com::sun::star::sdbc::SQLException,
123 com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE
125 if( 0 <= m_nRow && sal::static_int_cast<sal_uInt32>( m_nRow ) < m_aItems.size() )
126 return m_aItems[m_nRow]->getBoolean( columnIndex );
127 else
128 return false;
131 virtual sal_Int8 SAL_CALL
132 getByte(
133 sal_Int32 columnIndex )
134 throw( com::sun::star::sdbc::SQLException,
135 com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE
137 if( 0 <= m_nRow && sal::static_int_cast<sal_uInt32>( m_nRow ) < m_aItems.size() )
138 return m_aItems[m_nRow]->getByte( columnIndex );
139 else
140 return sal_Int8( 0 );
143 virtual sal_Int16 SAL_CALL
144 getShort(
145 sal_Int32 columnIndex )
146 throw(
147 com::sun::star::sdbc::SQLException,
148 com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE
150 if( 0 <= m_nRow && sal::static_int_cast<sal_uInt32>( m_nRow ) < m_aItems.size() )
151 return m_aItems[m_nRow]->getShort( columnIndex );
152 else
153 return sal_Int16( 0 );
156 virtual sal_Int32 SAL_CALL
157 getInt(
158 sal_Int32 columnIndex )
159 throw( com::sun::star::sdbc::SQLException,
160 com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE
162 if( 0 <= m_nRow && sal::static_int_cast<sal_uInt32>( m_nRow ) < m_aItems.size() )
163 return m_aItems[m_nRow]->getInt( columnIndex );
164 else
165 return sal_Int32( 0 );
168 virtual sal_Int64 SAL_CALL
169 getLong(
170 sal_Int32 columnIndex )
171 throw( com::sun::star::sdbc::SQLException,
172 com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE
174 if( 0 <= m_nRow && sal::static_int_cast<sal_uInt32>( m_nRow ) < m_aItems.size() )
175 return m_aItems[m_nRow]->getLong( columnIndex );
176 else
177 return sal_Int64( 0 );
180 virtual float SAL_CALL
181 getFloat(
182 sal_Int32 columnIndex )
183 throw( com::sun::star::sdbc::SQLException,
184 com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE
186 if( 0 <= m_nRow && sal::static_int_cast<sal_uInt32>( m_nRow ) < m_aItems.size() )
187 return m_aItems[m_nRow]->getFloat( columnIndex );
188 else
189 return float( 0 );
192 virtual double SAL_CALL
193 getDouble(
194 sal_Int32 columnIndex )
195 throw( com::sun::star::sdbc::SQLException,
196 com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE
198 if( 0 <= m_nRow && sal::static_int_cast<sal_uInt32>( m_nRow ) < m_aItems.size() )
199 return m_aItems[m_nRow]->getDouble( columnIndex );
200 else
201 return double( 0 );
204 virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL
205 getBytes(
206 sal_Int32 columnIndex )
207 throw( com::sun::star::sdbc::SQLException,
208 com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE
210 if( 0 <= m_nRow && sal::static_int_cast<sal_uInt32>( m_nRow ) < m_aItems.size() )
211 return m_aItems[m_nRow]->getBytes( columnIndex );
212 else
213 return com::sun::star::uno::Sequence< sal_Int8 >();
216 virtual com::sun::star::util::Date SAL_CALL
217 getDate(
218 sal_Int32 columnIndex )
219 throw( com::sun::star::sdbc::SQLException,
220 com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE
222 if( 0 <= m_nRow && sal::static_int_cast<sal_uInt32>( m_nRow ) < m_aItems.size() )
223 return m_aItems[m_nRow]->getDate( columnIndex );
224 else
225 return com::sun::star::util::Date();
228 virtual com::sun::star::util::Time SAL_CALL
229 getTime(
230 sal_Int32 columnIndex )
231 throw( com::sun::star::sdbc::SQLException,
232 com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE
234 if( 0 <= m_nRow && sal::static_int_cast<sal_uInt32>( m_nRow ) < m_aItems.size() )
235 return m_aItems[m_nRow]->getTime( columnIndex );
236 else
237 return com::sun::star::util::Time();
240 virtual com::sun::star::util::DateTime SAL_CALL
241 getTimestamp(
242 sal_Int32 columnIndex )
243 throw( com::sun::star::sdbc::SQLException,
244 com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE
246 if( 0 <= m_nRow && sal::static_int_cast<sal_uInt32>( m_nRow ) < m_aItems.size() )
247 return m_aItems[m_nRow]->getTimestamp( columnIndex );
248 else
249 return com::sun::star::util::DateTime();
252 virtual com::sun::star::uno::Reference< com::sun::star::io::XInputStream > SAL_CALL
253 getBinaryStream(
254 sal_Int32 columnIndex )
255 throw( com::sun::star::sdbc::SQLException,
256 com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE
258 if( 0 <= m_nRow && sal::static_int_cast<sal_uInt32>( m_nRow ) < m_aItems.size() )
259 return m_aItems[m_nRow]->getBinaryStream( columnIndex );
260 else
261 return com::sun::star::uno::Reference< com::sun::star::io::XInputStream >();
264 virtual com::sun::star::uno::Reference< com::sun::star::io::XInputStream > SAL_CALL
265 getCharacterStream(
266 sal_Int32 columnIndex )
267 throw( com::sun::star::sdbc::SQLException,
268 com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE
270 if( 0 <= m_nRow && sal::static_int_cast<sal_uInt32>( m_nRow ) < m_aItems.size() )
271 return m_aItems[m_nRow]->getCharacterStream( columnIndex );
272 else
273 return com::sun::star::uno::Reference< com::sun::star::io::XInputStream >();
276 virtual com::sun::star::uno::Any SAL_CALL
277 getObject(
278 sal_Int32 columnIndex,
279 const com::sun::star::uno::Reference< com::sun::star::container::XNameAccess >& typeMap )
280 throw( com::sun::star::sdbc::SQLException,
281 com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE
283 if( 0 <= m_nRow && sal::static_int_cast<sal_uInt32>( m_nRow ) < m_aItems.size() )
284 return m_aItems[m_nRow]->getObject( columnIndex,typeMap );
285 else
286 return com::sun::star::uno::Any();
289 virtual com::sun::star::uno::Reference< com::sun::star::sdbc::XRef > SAL_CALL
290 getRef(
291 sal_Int32 columnIndex )
292 throw( com::sun::star::sdbc::SQLException,
293 com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE
295 if( 0 <= m_nRow && sal::static_int_cast<sal_uInt32>( m_nRow ) < m_aItems.size() )
296 return m_aItems[m_nRow]->getRef( columnIndex );
297 else
298 return com::sun::star::uno::Reference< com::sun::star::sdbc::XRef >();
301 virtual com::sun::star::uno::Reference< com::sun::star::sdbc::XBlob > SAL_CALL
302 getBlob(
303 sal_Int32 columnIndex )
304 throw( com::sun::star::sdbc::SQLException,
305 com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE
307 if( 0 <= m_nRow && sal::static_int_cast<sal_uInt32>( m_nRow ) < m_aItems.size() )
308 return m_aItems[m_nRow]->getBlob( columnIndex );
309 else
310 return com::sun::star::uno::Reference< com::sun::star::sdbc::XBlob >();
313 virtual com::sun::star::uno::Reference< com::sun::star::sdbc::XClob > SAL_CALL
314 getClob(
315 sal_Int32 columnIndex )
316 throw( com::sun::star::sdbc::SQLException,
317 com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE
319 if( 0 <= m_nRow && sal::static_int_cast<sal_uInt32>( m_nRow ) < m_aItems.size() )
320 return m_aItems[m_nRow]->getClob( columnIndex );
321 else
322 return com::sun::star::uno::Reference< com::sun::star::sdbc::XClob >();
325 virtual com::sun::star::uno::Reference< com::sun::star::sdbc::XArray > SAL_CALL
326 getArray(
327 sal_Int32 columnIndex )
328 throw( com::sun::star::sdbc::SQLException,
329 com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE
331 if( 0 <= m_nRow && sal::static_int_cast<sal_uInt32>( m_nRow ) < m_aItems.size() )
332 return m_aItems[m_nRow]->getArray( columnIndex );
333 else
334 return com::sun::star::uno::Reference< com::sun::star::sdbc::XArray >();
338 // XResultSet
340 virtual sal_Bool SAL_CALL
341 next(
342 void )
343 throw( com::sun::star::sdbc::SQLException,
344 com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
346 virtual sal_Bool SAL_CALL
347 isBeforeFirst(
348 void )
349 throw( com::sun::star::sdbc::SQLException,
350 com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
352 virtual sal_Bool SAL_CALL
353 isAfterLast(
354 void )
355 throw( com::sun::star::sdbc::SQLException,
356 com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
358 virtual sal_Bool SAL_CALL
359 isFirst(
360 void )
361 throw( com::sun::star::sdbc::SQLException,
362 com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
364 virtual sal_Bool SAL_CALL
365 isLast(
366 void )
367 throw( com::sun::star::sdbc::SQLException,
368 com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
370 virtual void SAL_CALL
371 beforeFirst(
372 void )
373 throw( com::sun::star::sdbc::SQLException,
374 com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
376 virtual void SAL_CALL
377 afterLast(
378 void )
379 throw( com::sun::star::sdbc::SQLException,
380 com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
382 virtual sal_Bool SAL_CALL
383 first(
384 void )
385 throw( com::sun::star::sdbc::SQLException,
386 com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
388 virtual sal_Bool SAL_CALL
389 last(
390 void )
391 throw( com::sun::star::sdbc::SQLException,
392 com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
394 virtual sal_Int32 SAL_CALL
395 getRow(
396 void )
397 throw( com::sun::star::sdbc::SQLException,
398 com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
400 virtual sal_Bool SAL_CALL
401 absolute(
402 sal_Int32 row )
403 throw( com::sun::star::sdbc::SQLException,
404 com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
406 virtual sal_Bool SAL_CALL
407 relative(
408 sal_Int32 rows )
409 throw( com::sun::star::sdbc::SQLException,
410 com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
412 virtual sal_Bool SAL_CALL
413 previous(
414 void )
415 throw( com::sun::star::sdbc::SQLException,
416 com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
418 virtual void SAL_CALL
419 refreshRow(
420 void )
421 throw( com::sun::star::sdbc::SQLException,
422 com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
424 virtual sal_Bool SAL_CALL
425 rowUpdated(
426 void )
427 throw( com::sun::star::sdbc::SQLException,
428 com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
430 virtual sal_Bool SAL_CALL
431 rowInserted(
432 void )
433 throw( com::sun::star::sdbc::SQLException,
434 com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
436 virtual sal_Bool SAL_CALL
437 rowDeleted(
438 void )
439 throw( com::sun::star::sdbc::SQLException,
440 com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
443 virtual com::sun::star::uno::Reference< com::sun::star::uno::XInterface > SAL_CALL
444 getStatement(
445 void )
446 throw( com::sun::star::sdbc::SQLException,
447 com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
449 // XCloseable
451 virtual void SAL_CALL
452 close(
453 void )
454 throw( com::sun::star::sdbc::SQLException,
455 com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
457 // XContentAccess
459 virtual OUString SAL_CALL
460 queryContentIdentifierString(
461 void )
462 throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
464 virtual com::sun::star::uno::Reference< com::sun::star::ucb::XContentIdentifier > SAL_CALL
465 queryContentIdentifier(
466 void )
467 throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
469 virtual com::sun::star::uno::Reference< com::sun::star::ucb::XContent > SAL_CALL
470 queryContent(
471 void )
472 throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
474 // XResultSetMetaDataSupplier
475 virtual com::sun::star::uno::Reference< com::sun::star::sdbc::XResultSetMetaData > SAL_CALL
476 getMetaData(
477 void )
478 throw( com::sun::star::sdbc::SQLException,
479 com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
482 // XPropertySet
483 virtual com::sun::star::uno::Reference< com::sun::star::beans::XPropertySetInfo > SAL_CALL
484 getPropertySetInfo()
485 throw( com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
487 virtual void SAL_CALL setPropertyValue(
488 const OUString& aPropertyName,
489 const com::sun::star::uno::Any& aValue )
490 throw( com::sun::star::beans::UnknownPropertyException,
491 com::sun::star::beans::PropertyVetoException,
492 com::sun::star::lang::IllegalArgumentException,
493 com::sun::star::lang::WrappedTargetException,
494 com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
496 virtual com::sun::star::uno::Any SAL_CALL
497 getPropertyValue(
498 const OUString& PropertyName )
499 throw( com::sun::star::beans::UnknownPropertyException,
500 com::sun::star::lang::WrappedTargetException,
501 com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
503 virtual void SAL_CALL
504 addPropertyChangeListener(
505 const OUString& aPropertyName,
506 const com::sun::star::uno::Reference< com::sun::star::beans::XPropertyChangeListener >& xListener )
507 throw( com::sun::star::beans::UnknownPropertyException,
508 com::sun::star::lang::WrappedTargetException,
509 com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
511 virtual void SAL_CALL
512 removePropertyChangeListener(
513 const OUString& aPropertyName,
514 const com::sun::star::uno::Reference< com::sun::star::beans::XPropertyChangeListener >& aListener )
515 throw( com::sun::star::beans::UnknownPropertyException,
516 com::sun::star::lang::WrappedTargetException,
517 com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
519 virtual void SAL_CALL
520 addVetoableChangeListener(
521 const OUString& PropertyName,
522 const com::sun::star::uno::Reference< com::sun::star::beans::XVetoableChangeListener >& aListener )
523 throw( com::sun::star::beans::UnknownPropertyException,
524 com::sun::star::lang::WrappedTargetException,
525 com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
527 virtual void SAL_CALL removeVetoableChangeListener(
528 const OUString& PropertyName,
529 const com::sun::star::uno::Reference< com::sun::star::beans::XVetoableChangeListener >& aListener )
530 throw( com::sun::star::beans::UnknownPropertyException,
531 com::sun::star::lang::WrappedTargetException,
532 com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
534 protected:
536 com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > m_xContext;
537 com::sun::star::uno::Reference< com::sun::star::ucb::XContentProvider > m_xProvider;
538 sal_Int32 m_nRow;
539 bool m_nWasNull;
540 sal_Int32 m_nOpenMode;
541 bool m_bRowCountFinal;
543 typedef std::vector< com::sun::star::uno::Reference< com::sun::star::ucb::XContentIdentifier > > IdentSet;
544 typedef std::vector< com::sun::star::uno::Reference< com::sun::star::sdbc::XRow > > ItemSet;
545 typedef std::vector< OUString > PathSet;
547 IdentSet m_aIdents;
548 ItemSet m_aItems;
549 PathSet m_aPath;
551 com::sun::star::uno::Sequence< com::sun::star::beans::Property > m_sProperty;
552 com::sun::star::uno::Sequence< com::sun::star::ucb::NumberedSortingInfo > m_sSortingInfo;
554 osl::Mutex m_aMutex;
555 cppu::OInterfaceContainerHelper* m_pDisposeEventListeners;
557 cppu::OInterfaceContainerHelper* m_pRowCountListeners;
558 cppu::OInterfaceContainerHelper* m_pIsFinalListeners;
562 } // end namespace fileaccess
565 #endif
567 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */