xref: /AOO41X/main/ucb/source/ucp/ftp/ftpresultsetbase.hxx (revision 6df1ea1f75e32b7bdb9b43f28f6c06e1fbd0c5ce)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef _FTP_FTPRESULTSETBASE_HXX_
24 #define _FTP_FTPRESULTSETBASE_HXX_
25 
26 #include <vector>
27 #include <cppuhelper/weak.hxx>
28 #include <cppuhelper/interfacecontainer.hxx>
29 #include <com/sun/star/lang/XComponent.hpp>
30 #include <com/sun/star/ucb/XContentAccess.hpp>
31 #include <com/sun/star/sdbc/XCloseable.hpp>
32 #include <com/sun/star/beans/XPropertySet.hpp>
33 #include <com/sun/star/sdbc/XResultSet.hpp>
34 #include <com/sun/star/sdbc/XRow.hpp>
35 #include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
36 #include <com/sun/star/ucb/NumberedSortingInfo.hpp>
37 #include <com/sun/star/ucb/XContentProvider.hpp>
38 #include <com/sun/star/ucb/XContentIdentifier.hpp>
39 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
40 #include <com/sun/star/beans/Property.hpp>
41 
42 
43 namespace ftp {
44 
45     class ResultSetBase
46         : public cppu::OWeakObject,
47           public com::sun::star::lang::XComponent,
48           public com::sun::star::sdbc::XRow,
49           public com::sun::star::sdbc::XResultSet,
50           public com::sun::star::sdbc::XCloseable,
51           public com::sun::star::sdbc::XResultSetMetaDataSupplier,
52           public com::sun::star::beans::XPropertySet,
53           public com::sun::star::ucb::XContentAccess
54     {
55     public:
56 
57         ResultSetBase(const com::sun::star::uno::Reference<
58                       com::sun::star::lang::XMultiServiceFactory >&  xMSF,
59                       const com::sun::star::uno::Reference<
60                       com::sun::star::ucb::XContentProvider >&  xProvider,
61                       sal_Int32 nOpenMode,
62                       const com::sun::star::uno::Sequence<
63                       com::sun::star::beans::Property >& seq,
64                       const com::sun::star::uno::Sequence<
65                       com::sun::star::ucb::NumberedSortingInfo >& seqSort);
66 
67         virtual ~ResultSetBase();
68 
69         // XInterface
70         virtual com::sun::star::uno::Any SAL_CALL
71         queryInterface(
72             const com::sun::star::uno::Type& aType )
73             throw( com::sun::star::uno::RuntimeException);
74 
75         virtual void SAL_CALL
76         acquire(
77             void )
78             throw();
79 
80         virtual void SAL_CALL
81         release(
82             void )
83             throw();
84 
85         // XComponent
86         virtual void SAL_CALL
87         dispose(
88             void )
89             throw( com::sun::star::uno::RuntimeException );
90 
91         virtual void SAL_CALL
92         addEventListener(
93             const com::sun::star::uno::Reference<
94             com::sun::star::lang::XEventListener >& xListener )
95             throw( com::sun::star::uno::RuntimeException );
96 
97         virtual void SAL_CALL
98         removeEventListener( const com::sun::star::uno::Reference<
99                              com::sun::star::lang::XEventListener >& aListener )
100             throw( com::sun::star::uno::RuntimeException );
101 
102 
103         // XRow
104         virtual sal_Bool SAL_CALL
wasNull(void)105         wasNull(
106             void )
107             throw( com::sun::star::sdbc::SQLException,
108                    com::sun::star::uno::RuntimeException )
109         {
110             if( 0<= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
111                 m_nWasNull = m_aItems[m_nRow]->wasNull();
112             else
113                 m_nWasNull = true;
114             return m_nWasNull;
115         }
116 
117         virtual rtl::OUString SAL_CALL
getString(sal_Int32 columnIndex)118         getString(
119             sal_Int32 columnIndex )
120             throw( com::sun::star::sdbc::SQLException,
121                    com::sun::star::uno::RuntimeException)
122         {
123             rtl::OUString ret;
124             if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
125                 ret = m_aItems[m_nRow]->getString( columnIndex );
126 
127             return ret;
128         }
129 
130         virtual sal_Bool SAL_CALL
getBoolean(sal_Int32 columnIndex)131         getBoolean(
132             sal_Int32 columnIndex )
133             throw( com::sun::star::sdbc::SQLException,
134                    com::sun::star::uno::RuntimeException)
135         {
136             if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
137                 return m_aItems[m_nRow]->getBoolean( columnIndex );
138             else
139                 return false;
140         }
141 
142         virtual sal_Int8 SAL_CALL
getByte(sal_Int32 columnIndex)143         getByte(
144             sal_Int32 columnIndex )
145             throw( com::sun::star::sdbc::SQLException,
146                    com::sun::star::uno::RuntimeException)
147         {
148             if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
149                 return m_aItems[m_nRow]->getByte( columnIndex );
150             else
151                 return sal_Int8( 0 );
152         }
153 
154         virtual sal_Int16 SAL_CALL
getShort(sal_Int32 columnIndex)155         getShort(
156             sal_Int32 columnIndex )
157             throw(
158                 com::sun::star::sdbc::SQLException,
159                 com::sun::star::uno::RuntimeException)
160         {
161             if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
162                 return m_aItems[m_nRow]->getShort( columnIndex );
163             else
164                 return sal_Int16( 0 );
165         }
166 
167         virtual sal_Int32 SAL_CALL
getInt(sal_Int32 columnIndex)168         getInt(
169             sal_Int32 columnIndex )
170             throw( com::sun::star::sdbc::SQLException,
171                    com::sun::star::uno::RuntimeException )
172         {
173             if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
174                 return m_aItems[m_nRow]->getInt( columnIndex );
175             else
176                 return sal_Int32( 0 );
177         }
178 
179         virtual sal_Int64 SAL_CALL
getLong(sal_Int32 columnIndex)180         getLong(
181             sal_Int32 columnIndex )
182             throw( com::sun::star::sdbc::SQLException,
183                    com::sun::star::uno::RuntimeException)
184         {
185             if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
186                 return m_aItems[m_nRow]->getLong( columnIndex );
187             else
188                 return sal_Int64( 0 );
189         }
190 
191         virtual float SAL_CALL
getFloat(sal_Int32 columnIndex)192         getFloat(
193             sal_Int32 columnIndex )
194             throw( com::sun::star::sdbc::SQLException,
195                    com::sun::star::uno::RuntimeException )
196         {
197             if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
198                 return m_aItems[m_nRow]->getFloat( columnIndex );
199             else
200                 return float( 0 );
201         }
202 
203         virtual double SAL_CALL
getDouble(sal_Int32 columnIndex)204         getDouble(
205             sal_Int32 columnIndex )
206             throw( com::sun::star::sdbc::SQLException,
207                    com::sun::star::uno::RuntimeException )
208         {
209             if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
210                 return m_aItems[m_nRow]->getDouble( columnIndex );
211             else
212                 return double( 0 );
213         }
214 
215         virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL
getBytes(sal_Int32 columnIndex)216         getBytes(
217             sal_Int32 columnIndex )
218             throw( com::sun::star::sdbc::SQLException,
219                    com::sun::star::uno::RuntimeException )
220         {
221             if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
222                 return m_aItems[m_nRow]->getBytes( columnIndex );
223             else
224                 return com::sun::star::uno::Sequence< sal_Int8 >();
225         }
226 
227         virtual com::sun::star::util::Date SAL_CALL
getDate(sal_Int32 columnIndex)228         getDate(
229             sal_Int32 columnIndex )
230             throw( com::sun::star::sdbc::SQLException,
231                    com::sun::star::uno::RuntimeException)
232         {
233             if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
234                 return m_aItems[m_nRow]->getDate( columnIndex );
235             else
236                 return com::sun::star::util::Date();
237         }
238 
239         virtual com::sun::star::util::Time SAL_CALL
getTime(sal_Int32 columnIndex)240         getTime(
241             sal_Int32 columnIndex )
242             throw( com::sun::star::sdbc::SQLException,
243                    com::sun::star::uno::RuntimeException)
244         {
245             if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
246                 return m_aItems[m_nRow]->getTime( columnIndex );
247             else
248                 return com::sun::star::util::Time();
249         }
250 
251         virtual com::sun::star::util::DateTime SAL_CALL
getTimestamp(sal_Int32 columnIndex)252         getTimestamp(
253             sal_Int32 columnIndex )
254             throw( com::sun::star::sdbc::SQLException,
255                    com::sun::star::uno::RuntimeException)
256         {
257             if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
258                 return m_aItems[m_nRow]->getTimestamp( columnIndex );
259             else
260                 return com::sun::star::util::DateTime();
261         }
262 
263 
264         virtual com::sun::star::uno::Reference<
265         com::sun::star::io::XInputStream > SAL_CALL
getBinaryStream(sal_Int32 columnIndex)266         getBinaryStream(
267             sal_Int32 columnIndex )
268             throw( com::sun::star::sdbc::SQLException,
269                    com::sun::star::uno::RuntimeException)
270         {
271             if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
272                 return m_aItems[m_nRow]->getBinaryStream( columnIndex );
273             else
274                 return com::sun::star::uno::Reference<
275                     com::sun::star::io::XInputStream >();
276         }
277 
278         virtual com::sun::star::uno::Reference<
279         com::sun::star::io::XInputStream > SAL_CALL
getCharacterStream(sal_Int32 columnIndex)280         getCharacterStream(
281             sal_Int32 columnIndex )
282             throw( com::sun::star::sdbc::SQLException,
283                    com::sun::star::uno::RuntimeException)
284         {
285             if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
286                 return m_aItems[m_nRow]->getCharacterStream( columnIndex );
287             else
288                 return com::sun::star::uno::Reference<
289                     com::sun::star::io::XInputStream >();
290         }
291 
292         virtual com::sun::star::uno::Any SAL_CALL
getObject(sal_Int32 columnIndex,const com::sun::star::uno::Reference<com::sun::star::container::XNameAccess> & typeMap)293         getObject(
294             sal_Int32 columnIndex,
295             const com::sun::star::uno::Reference<
296             com::sun::star::container::XNameAccess >& typeMap )
297             throw( com::sun::star::sdbc::SQLException,
298                    com::sun::star::uno::RuntimeException)
299         {
300             if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
301                 return m_aItems[m_nRow]->getObject( columnIndex,typeMap );
302             else
303                 return com::sun::star::uno::Any();
304         }
305 
306         virtual com::sun::star::uno::Reference<
307         com::sun::star::sdbc::XRef > SAL_CALL
getRef(sal_Int32 columnIndex)308         getRef(
309             sal_Int32 columnIndex )
310             throw( com::sun::star::sdbc::SQLException,
311                    com::sun::star::uno::RuntimeException)
312         {
313             if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
314                 return m_aItems[m_nRow]->getRef( columnIndex );
315             else
316                 return com::sun::star::uno::Reference< com::sun::star::sdbc::XRef >();
317         }
318 
319         virtual com::sun::star::uno::Reference<
320         com::sun::star::sdbc::XBlob > SAL_CALL
getBlob(sal_Int32 columnIndex)321         getBlob(
322             sal_Int32 columnIndex )
323             throw( com::sun::star::sdbc::SQLException,
324                    com::sun::star::uno::RuntimeException)
325         {
326             if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
327                 return m_aItems[m_nRow]->getBlob( columnIndex );
328             else
329                 return com::sun::star::uno::Reference< com::sun::star::sdbc::XBlob >();
330         }
331 
332         virtual com::sun::star::uno::Reference<
333         com::sun::star::sdbc::XClob > SAL_CALL
getClob(sal_Int32 columnIndex)334         getClob(
335             sal_Int32 columnIndex )
336             throw( com::sun::star::sdbc::SQLException,
337                    com::sun::star::uno::RuntimeException)
338         {
339             if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
340                 return m_aItems[m_nRow]->getClob( columnIndex );
341             else
342                 return com::sun::star::uno::Reference<
343                     com::sun::star::sdbc::XClob >();
344         }
345 
346         virtual com::sun::star::uno::Reference<
347         com::sun::star::sdbc::XArray > SAL_CALL
getArray(sal_Int32 columnIndex)348         getArray(
349             sal_Int32 columnIndex )
350             throw( com::sun::star::sdbc::SQLException,
351                    com::sun::star::uno::RuntimeException)
352         {
353             if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
354                 return m_aItems[m_nRow]->getArray( columnIndex );
355             else
356                 return com::sun::star::uno::Reference<
357                     com::sun::star::sdbc::XArray >();
358         }
359 
360 
361         // XResultSet
362 
363         virtual sal_Bool SAL_CALL
364         next(
365             void )
366             throw( com::sun::star::sdbc::SQLException,
367                    com::sun::star::uno::RuntimeException);
368 
369         virtual sal_Bool SAL_CALL
370         isBeforeFirst(
371             void )
372             throw( com::sun::star::sdbc::SQLException,
373                    com::sun::star::uno::RuntimeException);
374 
375         virtual sal_Bool SAL_CALL
376         isAfterLast(
377             void )
378             throw( com::sun::star::sdbc::SQLException,
379                    com::sun::star::uno::RuntimeException);
380 
381         virtual sal_Bool SAL_CALL
382         isFirst(
383             void  )
384             throw( com::sun::star::sdbc::SQLException,
385                    com::sun::star::uno::RuntimeException);
386 
387         virtual sal_Bool SAL_CALL
388         isLast(
389             void  )
390             throw( com::sun::star::sdbc::SQLException,
391                    com::sun::star::uno::RuntimeException);
392 
393         virtual void SAL_CALL
394         beforeFirst(
395             void  )
396             throw( com::sun::star::sdbc::SQLException,
397                    com::sun::star::uno::RuntimeException);
398 
399         virtual void SAL_CALL
400         afterLast(
401             void  )
402             throw( com::sun::star::sdbc::SQLException,
403                    com::sun::star::uno::RuntimeException);
404 
405         virtual sal_Bool SAL_CALL
406         first(
407             void  )
408             throw( com::sun::star::sdbc::SQLException,
409                    com::sun::star::uno::RuntimeException);
410 
411         virtual sal_Bool SAL_CALL
412         last(
413             void  )
414             throw( com::sun::star::sdbc::SQLException,
415                    com::sun::star::uno::RuntimeException);
416 
417         virtual sal_Int32 SAL_CALL
418         getRow(
419             void  )
420             throw( com::sun::star::sdbc::SQLException,
421                    com::sun::star::uno::RuntimeException);
422 
423         virtual sal_Bool SAL_CALL
424         absolute(
425             sal_Int32 row )
426             throw( com::sun::star::sdbc::SQLException,
427                    com::sun::star::uno::RuntimeException);
428 
429         virtual sal_Bool SAL_CALL
430         relative(
431             sal_Int32 rows )
432             throw( com::sun::star::sdbc::SQLException,
433                    com::sun::star::uno::RuntimeException);
434 
435         virtual sal_Bool SAL_CALL
436         previous(
437             void  )
438             throw( com::sun::star::sdbc::SQLException,
439                    com::sun::star::uno::RuntimeException);
440 
441         virtual void SAL_CALL
442         refreshRow(
443             void  )
444             throw( com::sun::star::sdbc::SQLException,
445                    com::sun::star::uno::RuntimeException);
446 
447         virtual sal_Bool SAL_CALL
448         rowUpdated(
449             void )
450             throw( com::sun::star::sdbc::SQLException,
451                    com::sun::star::uno::RuntimeException);
452 
453         virtual sal_Bool SAL_CALL
454         rowInserted(
455             void  )
456             throw( com::sun::star::sdbc::SQLException,
457                    com::sun::star::uno::RuntimeException);
458 
459         virtual sal_Bool SAL_CALL
460         rowDeleted(
461             void  )
462             throw( com::sun::star::sdbc::SQLException,
463                    com::sun::star::uno::RuntimeException);
464 
465 
466         virtual  com::sun::star::uno::Reference<
467         com::sun::star::uno::XInterface > SAL_CALL
468         getStatement(
469             void  )
470             throw( com::sun::star::sdbc::SQLException,
471                    com::sun::star::uno::RuntimeException);
472 
473         // XCloseable
474 
475         virtual void SAL_CALL
476         close(
477             void )
478             throw( com::sun::star::sdbc::SQLException,
479                    com::sun::star::uno::RuntimeException);
480 
481         // XContentAccess
482 
483         virtual rtl::OUString SAL_CALL
484         queryContentIdentifierString(
485             void )
486             throw( com::sun::star::uno::RuntimeException );
487 
488         virtual com::sun::star::uno::Reference<
489         com::sun::star::ucb::XContentIdentifier > SAL_CALL
490         queryContentIdentifier(
491             void )
492             throw( com::sun::star::uno::RuntimeException );
493 
494         virtual com::sun::star::uno::Reference<
495         com::sun::star::ucb::XContent > SAL_CALL
496         queryContent(
497             void )
498             throw( com::sun::star::uno::RuntimeException );
499 
500         // XResultSetMetaDataSupplier
501         virtual com::sun::star::uno::Reference<
502         com::sun::star::sdbc::XResultSetMetaData > SAL_CALL
503         getMetaData(
504             void )
505             throw( com::sun::star::sdbc::SQLException,
506                    com::sun::star::uno::RuntimeException);
507 
508 
509         // XPropertySet
510         virtual com::sun::star::uno::Reference<
511         com::sun::star::beans::XPropertySetInfo > SAL_CALL
512         getPropertySetInfo()
513             throw( com::sun::star::uno::RuntimeException);
514 
515         virtual void SAL_CALL setPropertyValue(
516             const rtl::OUString& aPropertyName,
517             const com::sun::star::uno::Any& aValue )
518             throw( com::sun::star::beans::UnknownPropertyException,
519                    com::sun::star::beans::PropertyVetoException,
520                    com::sun::star::lang::IllegalArgumentException,
521                    com::sun::star::lang::WrappedTargetException,
522                    com::sun::star::uno::RuntimeException);
523 
524         virtual com::sun::star::uno::Any SAL_CALL
525         getPropertyValue(
526             const rtl::OUString& PropertyName )
527             throw( com::sun::star::beans::UnknownPropertyException,
528                    com::sun::star::lang::WrappedTargetException,
529                    com::sun::star::uno::RuntimeException);
530 
531         virtual void SAL_CALL
532         addPropertyChangeListener(
533             const rtl::OUString& aPropertyName,
534             const com::sun::star::uno::Reference<
535             com::sun::star::beans::XPropertyChangeListener >& xListener )
536             throw( com::sun::star::beans::UnknownPropertyException,
537                    com::sun::star::lang::WrappedTargetException,
538                    com::sun::star::uno::RuntimeException);
539 
540         virtual void SAL_CALL
541         removePropertyChangeListener(
542             const rtl::OUString& aPropertyName,
543             const com::sun::star::uno::Reference<
544             com::sun::star::beans::XPropertyChangeListener >& aListener )
545             throw( com::sun::star::beans::UnknownPropertyException,
546                    com::sun::star::lang::WrappedTargetException,
547                    com::sun::star::uno::RuntimeException);
548 
549         virtual void SAL_CALL
550         addVetoableChangeListener(
551             const rtl::OUString& PropertyName,
552             const com::sun::star::uno::Reference<
553             com::sun::star::beans::XVetoableChangeListener >& aListener )
554             throw( com::sun::star::beans::UnknownPropertyException,
555                    com::sun::star::lang::WrappedTargetException,
556                    com::sun::star::uno::RuntimeException);
557 
558         virtual void SAL_CALL removeVetoableChangeListener(
559             const rtl::OUString& PropertyName,
560             const com::sun::star::uno::Reference<
561             com::sun::star::beans::XVetoableChangeListener >& aListener )
562             throw( com::sun::star::beans::UnknownPropertyException,
563                    com::sun::star::lang::WrappedTargetException,
564                    com::sun::star::uno::RuntimeException);
565 
566     protected:
567 
568         com::sun::star::uno::Reference<
569         com::sun::star::lang::XMultiServiceFactory >  m_xMSF;
570         com::sun::star::uno::Reference<
571         com::sun::star::ucb::XContentProvider >  m_xProvider;
572         sal_Int32                           m_nRow;
573         sal_Bool                            m_nWasNull;
574         sal_Int32                           m_nOpenMode;
575         sal_Bool                            m_bRowCountFinal;
576 
577         typedef std::vector< com::sun::star::uno::Reference<
578         com::sun::star::ucb::XContentIdentifier > > IdentSet;
579         typedef std::vector< com::sun::star::uno::Reference<
580         com::sun::star::sdbc::XRow > >              ItemSet;
581         typedef std::vector< rtl::OUString >
582         PathSet;
583 
584         IdentSet                            m_aIdents;
585         ItemSet                             m_aItems;
586         PathSet                             m_aPath;
587 
588         com::sun::star::uno::Sequence<
589         com::sun::star::beans::Property >           m_sProperty;
590         com::sun::star::uno::Sequence<
591         com::sun::star::ucb::NumberedSortingInfo >  m_sSortingInfo;
592 
593         osl::Mutex                          m_aMutex;
594         cppu::OInterfaceContainerHelper*    m_pDisposeEventListeners;
595 
596         cppu::OInterfaceContainerHelper*    m_pRowCountListeners;
597         cppu::OInterfaceContainerHelper*    m_pIsFinalListeners;
598     };
599 
600 
601 } // end namespace fileaccess
602 
603 
604 #endif
605