update dev300-m58
[ooovba.git] / xmlhelp / source / cxxhelp / provider / resultsetbase.hxx
blob53dda08b47b6392c12001387b5db1c3a921d4f76
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: resultsetbase.hxx,v $
10 * $Revision: 1.3 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef _RESULTSETBASE_HXX
31 #define _RESULTSETBASE_HXX
33 #ifndef INCLUDED_STL_VECTOR
34 #include <vector>
35 #define INCLUDED_STL_VECTOR
36 #endif
37 #include <cppuhelper/weak.hxx>
38 #include <cppuhelper/interfacecontainer.hxx>
39 #include <com/sun/star/lang/XComponent.hpp>
40 #include <com/sun/star/ucb/XContentAccess.hpp>
41 #include <com/sun/star/sdbc/XCloseable.hpp>
42 #include <com/sun/star/beans/XPropertySet.hpp>
43 #include <com/sun/star/sdbc/XResultSet.hpp>
44 #include <com/sun/star/sdbc/XRow.hpp>
45 #include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
46 #include <com/sun/star/ucb/NumberedSortingInfo.hpp>
47 #include <com/sun/star/ucb/XContentProvider.hpp>
48 #include <com/sun/star/ucb/XContentIdentifier.hpp>
49 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
50 #include <com/sun/star/beans/Property.hpp>
53 namespace chelp {
55 class ResultSetBase
56 : public cppu::OWeakObject,
57 public com::sun::star::lang::XComponent,
58 public com::sun::star::sdbc::XRow,
59 public com::sun::star::sdbc::XResultSet,
60 public com::sun::star::sdbc::XCloseable,
61 public com::sun::star::sdbc::XResultSetMetaDataSupplier,
62 public com::sun::star::beans::XPropertySet,
63 public com::sun::star::ucb::XContentAccess
65 public:
67 ResultSetBase( const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& xMSF,
68 const com::sun::star::uno::Reference< com::sun::star::ucb::XContentProvider >& xProvider,
69 sal_Int32 nOpenMode,
70 const com::sun::star::uno::Sequence< com::sun::star::beans::Property >& seq,
71 const com::sun::star::uno::Sequence< com::sun::star::ucb::NumberedSortingInfo >& seqSort );
73 virtual ~ResultSetBase();
75 // XInterface
76 virtual com::sun::star::uno::Any SAL_CALL
77 queryInterface(
78 const com::sun::star::uno::Type& aType )
79 throw( com::sun::star::uno::RuntimeException);
81 virtual void SAL_CALL
82 acquire(
83 void )
84 throw();
86 virtual void SAL_CALL
87 release(
88 void )
89 throw();
91 // XComponent
92 virtual void SAL_CALL
93 dispose(
94 void )
95 throw( com::sun::star::uno::RuntimeException );
97 virtual void SAL_CALL
98 addEventListener(
99 const com::sun::star::uno::Reference< com::sun::star::lang::XEventListener >& xListener )
100 throw( com::sun::star::uno::RuntimeException );
102 virtual void SAL_CALL
103 removeEventListener( const com::sun::star::uno::Reference< com::sun::star::lang::XEventListener >& aListener )
104 throw( com::sun::star::uno::RuntimeException );
107 // XRow
108 virtual sal_Bool SAL_CALL
109 wasNull(
110 void )
111 throw( com::sun::star::sdbc::SQLException,
112 com::sun::star::uno::RuntimeException )
114 if( 0<= m_nRow && sal::static_int_cast<sal_uInt32>( m_nRow ) < m_aItems.size() )
115 m_nWasNull = m_aItems[m_nRow]->wasNull();
116 else
117 m_nWasNull = true;
118 return m_nWasNull;
121 virtual rtl::OUString SAL_CALL
122 getString(
123 sal_Int32 columnIndex )
124 throw( com::sun::star::sdbc::SQLException,
125 com::sun::star::uno::RuntimeException)
127 if( 0 <= m_nRow && sal::static_int_cast<sal_uInt32>( m_nRow ) < m_aItems.size() )
128 return m_aItems[m_nRow]->getString( columnIndex );
129 else
130 return rtl::OUString();
133 virtual sal_Bool SAL_CALL
134 getBoolean(
135 sal_Int32 columnIndex )
136 throw( com::sun::star::sdbc::SQLException,
137 com::sun::star::uno::RuntimeException)
139 if( 0 <= m_nRow && sal::static_int_cast<sal_uInt32>( m_nRow ) < m_aItems.size() )
140 return m_aItems[m_nRow]->getBoolean( columnIndex );
141 else
142 return false;
145 virtual sal_Int8 SAL_CALL
146 getByte(
147 sal_Int32 columnIndex )
148 throw( com::sun::star::sdbc::SQLException,
149 com::sun::star::uno::RuntimeException)
151 if( 0 <= m_nRow && sal::static_int_cast<sal_uInt32>( m_nRow ) < m_aItems.size() )
152 return m_aItems[m_nRow]->getByte( columnIndex );
153 else
154 return sal_Int8( 0 );
157 virtual sal_Int16 SAL_CALL
158 getShort(
159 sal_Int32 columnIndex )
160 throw(
161 com::sun::star::sdbc::SQLException,
162 com::sun::star::uno::RuntimeException)
164 if( 0 <= m_nRow && sal::static_int_cast<sal_uInt32>( m_nRow ) < m_aItems.size() )
165 return m_aItems[m_nRow]->getShort( columnIndex );
166 else
167 return sal_Int16( 0 );
170 virtual sal_Int32 SAL_CALL
171 getInt(
172 sal_Int32 columnIndex )
173 throw( com::sun::star::sdbc::SQLException,
174 com::sun::star::uno::RuntimeException )
176 if( 0 <= m_nRow && sal::static_int_cast<sal_uInt32>( m_nRow ) < m_aItems.size() )
177 return m_aItems[m_nRow]->getInt( columnIndex );
178 else
179 return sal_Int32( 0 );
182 virtual sal_Int64 SAL_CALL
183 getLong(
184 sal_Int32 columnIndex )
185 throw( com::sun::star::sdbc::SQLException,
186 com::sun::star::uno::RuntimeException)
188 if( 0 <= m_nRow && sal::static_int_cast<sal_uInt32>( m_nRow ) < m_aItems.size() )
189 return m_aItems[m_nRow]->getLong( columnIndex );
190 else
191 return sal_Int64( 0 );
194 virtual float SAL_CALL
195 getFloat(
196 sal_Int32 columnIndex )
197 throw( com::sun::star::sdbc::SQLException,
198 com::sun::star::uno::RuntimeException )
200 if( 0 <= m_nRow && sal::static_int_cast<sal_uInt32>( m_nRow ) < m_aItems.size() )
201 return m_aItems[m_nRow]->getFloat( columnIndex );
202 else
203 return float( 0 );
206 virtual double SAL_CALL
207 getDouble(
208 sal_Int32 columnIndex )
209 throw( com::sun::star::sdbc::SQLException,
210 com::sun::star::uno::RuntimeException )
212 if( 0 <= m_nRow && sal::static_int_cast<sal_uInt32>( m_nRow ) < m_aItems.size() )
213 return m_aItems[m_nRow]->getDouble( columnIndex );
214 else
215 return double( 0 );
218 virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL
219 getBytes(
220 sal_Int32 columnIndex )
221 throw( com::sun::star::sdbc::SQLException,
222 com::sun::star::uno::RuntimeException )
224 if( 0 <= m_nRow && sal::static_int_cast<sal_uInt32>( m_nRow ) < m_aItems.size() )
225 return m_aItems[m_nRow]->getBytes( columnIndex );
226 else
227 return com::sun::star::uno::Sequence< sal_Int8 >();
230 virtual com::sun::star::util::Date SAL_CALL
231 getDate(
232 sal_Int32 columnIndex )
233 throw( com::sun::star::sdbc::SQLException,
234 com::sun::star::uno::RuntimeException)
236 if( 0 <= m_nRow && sal::static_int_cast<sal_uInt32>( m_nRow ) < m_aItems.size() )
237 return m_aItems[m_nRow]->getDate( columnIndex );
238 else
239 return com::sun::star::util::Date();
242 virtual com::sun::star::util::Time SAL_CALL
243 getTime(
244 sal_Int32 columnIndex )
245 throw( com::sun::star::sdbc::SQLException,
246 com::sun::star::uno::RuntimeException)
248 if( 0 <= m_nRow && sal::static_int_cast<sal_uInt32>( m_nRow ) < m_aItems.size() )
249 return m_aItems[m_nRow]->getTime( columnIndex );
250 else
251 return com::sun::star::util::Time();
254 virtual com::sun::star::util::DateTime SAL_CALL
255 getTimestamp(
256 sal_Int32 columnIndex )
257 throw( com::sun::star::sdbc::SQLException,
258 com::sun::star::uno::RuntimeException)
260 if( 0 <= m_nRow && sal::static_int_cast<sal_uInt32>( m_nRow ) < m_aItems.size() )
261 return m_aItems[m_nRow]->getTimestamp( columnIndex );
262 else
263 return com::sun::star::util::DateTime();
266 virtual com::sun::star::uno::Reference< com::sun::star::io::XInputStream > SAL_CALL
267 getBinaryStream(
268 sal_Int32 columnIndex )
269 throw( com::sun::star::sdbc::SQLException,
270 com::sun::star::uno::RuntimeException)
272 if( 0 <= m_nRow && sal::static_int_cast<sal_uInt32>( m_nRow ) < m_aItems.size() )
273 return m_aItems[m_nRow]->getBinaryStream( columnIndex );
274 else
275 return com::sun::star::uno::Reference< com::sun::star::io::XInputStream >();
278 virtual com::sun::star::uno::Reference< com::sun::star::io::XInputStream > SAL_CALL
279 getCharacterStream(
280 sal_Int32 columnIndex )
281 throw( com::sun::star::sdbc::SQLException,
282 com::sun::star::uno::RuntimeException)
284 if( 0 <= m_nRow && sal::static_int_cast<sal_uInt32>( m_nRow ) < m_aItems.size() )
285 return m_aItems[m_nRow]->getCharacterStream( columnIndex );
286 else
287 return com::sun::star::uno::Reference< com::sun::star::io::XInputStream >();
290 virtual com::sun::star::uno::Any SAL_CALL
291 getObject(
292 sal_Int32 columnIndex,
293 const com::sun::star::uno::Reference< com::sun::star::container::XNameAccess >& typeMap )
294 throw( com::sun::star::sdbc::SQLException,
295 com::sun::star::uno::RuntimeException)
297 if( 0 <= m_nRow && sal::static_int_cast<sal_uInt32>( m_nRow ) < m_aItems.size() )
298 return m_aItems[m_nRow]->getObject( columnIndex,typeMap );
299 else
300 return com::sun::star::uno::Any();
303 virtual com::sun::star::uno::Reference< 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 && sal::static_int_cast<sal_uInt32>( m_nRow ) < 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< com::sun::star::sdbc::XBlob > SAL_CALL
316 getBlob(
317 sal_Int32 columnIndex )
318 throw( com::sun::star::sdbc::SQLException,
319 com::sun::star::uno::RuntimeException)
321 if( 0 <= m_nRow && sal::static_int_cast<sal_uInt32>( m_nRow ) < m_aItems.size() )
322 return m_aItems[m_nRow]->getBlob( columnIndex );
323 else
324 return com::sun::star::uno::Reference< com::sun::star::sdbc::XBlob >();
327 virtual com::sun::star::uno::Reference< com::sun::star::sdbc::XClob > SAL_CALL
328 getClob(
329 sal_Int32 columnIndex )
330 throw( com::sun::star::sdbc::SQLException,
331 com::sun::star::uno::RuntimeException)
333 if( 0 <= m_nRow && sal::static_int_cast<sal_uInt32>( m_nRow ) < m_aItems.size() )
334 return m_aItems[m_nRow]->getClob( columnIndex );
335 else
336 return com::sun::star::uno::Reference< com::sun::star::sdbc::XClob >();
339 virtual com::sun::star::uno::Reference< com::sun::star::sdbc::XArray > SAL_CALL
340 getArray(
341 sal_Int32 columnIndex )
342 throw( com::sun::star::sdbc::SQLException,
343 com::sun::star::uno::RuntimeException)
345 if( 0 <= m_nRow && sal::static_int_cast<sal_uInt32>( m_nRow ) < m_aItems.size() )
346 return m_aItems[m_nRow]->getArray( columnIndex );
347 else
348 return com::sun::star::uno::Reference< com::sun::star::sdbc::XArray >();
352 // XResultSet
354 virtual sal_Bool SAL_CALL
355 next(
356 void )
357 throw( com::sun::star::sdbc::SQLException,
358 com::sun::star::uno::RuntimeException);
360 virtual sal_Bool SAL_CALL
361 isBeforeFirst(
362 void )
363 throw( com::sun::star::sdbc::SQLException,
364 com::sun::star::uno::RuntimeException);
366 virtual sal_Bool SAL_CALL
367 isAfterLast(
368 void )
369 throw( com::sun::star::sdbc::SQLException,
370 com::sun::star::uno::RuntimeException);
372 virtual sal_Bool SAL_CALL
373 isFirst(
374 void )
375 throw( com::sun::star::sdbc::SQLException,
376 com::sun::star::uno::RuntimeException);
378 virtual sal_Bool SAL_CALL
379 isLast(
380 void )
381 throw( com::sun::star::sdbc::SQLException,
382 com::sun::star::uno::RuntimeException);
384 virtual void SAL_CALL
385 beforeFirst(
386 void )
387 throw( com::sun::star::sdbc::SQLException,
388 com::sun::star::uno::RuntimeException);
390 virtual void SAL_CALL
391 afterLast(
392 void )
393 throw( com::sun::star::sdbc::SQLException,
394 com::sun::star::uno::RuntimeException);
396 virtual sal_Bool SAL_CALL
397 first(
398 void )
399 throw( com::sun::star::sdbc::SQLException,
400 com::sun::star::uno::RuntimeException);
402 virtual sal_Bool SAL_CALL
403 last(
404 void )
405 throw( com::sun::star::sdbc::SQLException,
406 com::sun::star::uno::RuntimeException);
408 virtual sal_Int32 SAL_CALL
409 getRow(
410 void )
411 throw( com::sun::star::sdbc::SQLException,
412 com::sun::star::uno::RuntimeException);
414 virtual sal_Bool SAL_CALL
415 absolute(
416 sal_Int32 row )
417 throw( com::sun::star::sdbc::SQLException,
418 com::sun::star::uno::RuntimeException);
420 virtual sal_Bool SAL_CALL
421 relative(
422 sal_Int32 rows )
423 throw( com::sun::star::sdbc::SQLException,
424 com::sun::star::uno::RuntimeException);
426 virtual sal_Bool SAL_CALL
427 previous(
428 void )
429 throw( com::sun::star::sdbc::SQLException,
430 com::sun::star::uno::RuntimeException);
432 virtual void SAL_CALL
433 refreshRow(
434 void )
435 throw( com::sun::star::sdbc::SQLException,
436 com::sun::star::uno::RuntimeException);
438 virtual sal_Bool SAL_CALL
439 rowUpdated(
440 void )
441 throw( com::sun::star::sdbc::SQLException,
442 com::sun::star::uno::RuntimeException);
444 virtual sal_Bool SAL_CALL
445 rowInserted(
446 void )
447 throw( com::sun::star::sdbc::SQLException,
448 com::sun::star::uno::RuntimeException);
450 virtual sal_Bool SAL_CALL
451 rowDeleted(
452 void )
453 throw( com::sun::star::sdbc::SQLException,
454 com::sun::star::uno::RuntimeException);
457 virtual com::sun::star::uno::Reference< com::sun::star::uno::XInterface > SAL_CALL
458 getStatement(
459 void )
460 throw( com::sun::star::sdbc::SQLException,
461 com::sun::star::uno::RuntimeException);
463 // XCloseable
465 virtual void SAL_CALL
466 close(
467 void )
468 throw( com::sun::star::sdbc::SQLException,
469 com::sun::star::uno::RuntimeException);
471 // XContentAccess
473 virtual rtl::OUString SAL_CALL
474 queryContentIdentifierString(
475 void )
476 throw( com::sun::star::uno::RuntimeException );
478 virtual com::sun::star::uno::Reference< com::sun::star::ucb::XContentIdentifier > SAL_CALL
479 queryContentIdentifier(
480 void )
481 throw( com::sun::star::uno::RuntimeException );
483 virtual com::sun::star::uno::Reference< com::sun::star::ucb::XContent > SAL_CALL
484 queryContent(
485 void )
486 throw( com::sun::star::uno::RuntimeException );
488 // XResultSetMetaDataSupplier
489 virtual com::sun::star::uno::Reference< com::sun::star::sdbc::XResultSetMetaData > SAL_CALL
490 getMetaData(
491 void )
492 throw( com::sun::star::sdbc::SQLException,
493 com::sun::star::uno::RuntimeException);
496 // XPropertySet
497 virtual com::sun::star::uno::Reference< com::sun::star::beans::XPropertySetInfo > SAL_CALL
498 getPropertySetInfo()
499 throw( com::sun::star::uno::RuntimeException);
501 virtual void SAL_CALL setPropertyValue(
502 const rtl::OUString& aPropertyName,
503 const com::sun::star::uno::Any& aValue )
504 throw( com::sun::star::beans::UnknownPropertyException,
505 com::sun::star::beans::PropertyVetoException,
506 com::sun::star::lang::IllegalArgumentException,
507 com::sun::star::lang::WrappedTargetException,
508 com::sun::star::uno::RuntimeException);
510 virtual com::sun::star::uno::Any SAL_CALL
511 getPropertyValue(
512 const rtl::OUString& PropertyName )
513 throw( com::sun::star::beans::UnknownPropertyException,
514 com::sun::star::lang::WrappedTargetException,
515 com::sun::star::uno::RuntimeException);
517 virtual void SAL_CALL
518 addPropertyChangeListener(
519 const rtl::OUString& aPropertyName,
520 const com::sun::star::uno::Reference< com::sun::star::beans::XPropertyChangeListener >& xListener )
521 throw( com::sun::star::beans::UnknownPropertyException,
522 com::sun::star::lang::WrappedTargetException,
523 com::sun::star::uno::RuntimeException);
525 virtual void SAL_CALL
526 removePropertyChangeListener(
527 const rtl::OUString& aPropertyName,
528 const com::sun::star::uno::Reference< com::sun::star::beans::XPropertyChangeListener >& aListener )
529 throw( com::sun::star::beans::UnknownPropertyException,
530 com::sun::star::lang::WrappedTargetException,
531 com::sun::star::uno::RuntimeException);
533 virtual void SAL_CALL
534 addVetoableChangeListener(
535 const rtl::OUString& PropertyName,
536 const com::sun::star::uno::Reference< com::sun::star::beans::XVetoableChangeListener >& aListener )
537 throw( com::sun::star::beans::UnknownPropertyException,
538 com::sun::star::lang::WrappedTargetException,
539 com::sun::star::uno::RuntimeException);
541 virtual void SAL_CALL removeVetoableChangeListener(
542 const rtl::OUString& PropertyName,
543 const com::sun::star::uno::Reference< com::sun::star::beans::XVetoableChangeListener >& aListener )
544 throw( com::sun::star::beans::UnknownPropertyException,
545 com::sun::star::lang::WrappedTargetException,
546 com::sun::star::uno::RuntimeException);
548 protected:
550 com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > m_xMSF;
551 com::sun::star::uno::Reference< com::sun::star::ucb::XContentProvider > m_xProvider;
552 sal_Int32 m_nRow;
553 sal_Bool m_nWasNull;
554 sal_Int32 m_nOpenMode;
555 sal_Bool m_bRowCountFinal;
557 typedef std::vector< com::sun::star::uno::Reference< com::sun::star::ucb::XContentIdentifier > > IdentSet;
558 typedef std::vector< com::sun::star::uno::Reference< com::sun::star::sdbc::XRow > > ItemSet;
559 typedef std::vector< rtl::OUString > PathSet;
561 IdentSet m_aIdents;
562 ItemSet m_aItems;
563 PathSet m_aPath;
565 com::sun::star::uno::Sequence< com::sun::star::beans::Property > m_sProperty;
566 com::sun::star::uno::Sequence< com::sun::star::ucb::NumberedSortingInfo > m_sSortingInfo;
568 osl::Mutex m_aMutex;
569 cppu::OInterfaceContainerHelper* m_pDisposeEventListeners;
571 cppu::OInterfaceContainerHelper* m_pRowCountListeners;
572 cppu::OInterfaceContainerHelper* m_pIsFinalListeners;
576 } // end namespace fileaccess
579 #endif