xref: /trunk/main/ucb/source/ucp/file/filrset.hxx (revision 91144cd0085a7583d2099b982122deb2184ab956)
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 _FILRSET_HXX_
24 #define _FILRSET_HXX_
25 
26 #ifndef __SGI_STL_VECTOR
27 #include <vector>
28 #endif
29 #include <ucbhelper/macros.hxx>
30 #include <osl/file.hxx>
31 
32 #include "osl/mutex.hxx"
33 #include <cppuhelper/weak.hxx>
34 #include <cppuhelper/interfacecontainer.hxx>
35 #include <com/sun/star/lang/XTypeProvider.hpp>
36 #include <com/sun/star/ucb/XContentAccess.hpp>
37 #include <com/sun/star/sdbc/XCloseable.hpp>
38 #include <com/sun/star/beans/XPropertySet.hpp>
39 #ifndef _COM_SUN_STAR_UCB_XDYNAMICRESULTSET_HPP__
40 #include <com/sun/star/ucb/XDynamicResultSet.hpp>
41 #endif
42 #include <com/sun/star/ucb/XDynamicResultSetListener.hpp>
43 #include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
44 #include <com/sun/star/ucb/NumberedSortingInfo.hpp>
45 #include <com/sun/star/ucb/XContentProvider.hpp>
46 #include <com/sun/star/ucb/XContentIdentifier.hpp>
47 #include <com/sun/star/beans/Property.hpp>
48 #include "filrow.hxx"
49 #include "filnot.hxx"
50 
51 
52 
53 namespace fileaccess {
54 
55     class Notifier;
56 
57     class XResultSet_impl
58         : public cppu::OWeakObject,
59           public com::sun::star::lang::XTypeProvider,
60           public com::sun::star::lang::XEventListener,
61           public com::sun::star::sdbc::XRow,
62           public com::sun::star::sdbc::XResultSet,
63           public com::sun::star::ucb::XDynamicResultSet,
64           public com::sun::star::sdbc::XCloseable,
65           public com::sun::star::sdbc::XResultSetMetaDataSupplier,
66           public com::sun::star::beans::XPropertySet,
67           public com::sun::star::ucb::XContentAccess,
68           public Notifier
69     {
70     public:
71 
72         XResultSet_impl( shell* pMyShell,
73                          const rtl::OUString& aUnqPath,
74                          sal_Int32 OpenMode,
75                          const com::sun::star::uno::Sequence< com::sun::star::beans::Property >& seq,
76                          const com::sun::star::uno::Sequence< com::sun::star::ucb::NumberedSortingInfo >& seqSort );
77 
78         virtual ~XResultSet_impl();
79 
cDEL(void)80         virtual ContentEventNotifier*        cDEL( void )
81         {
82             return 0;
83         }
84 
cEXC(const rtl::OUString)85         virtual ContentEventNotifier*        cEXC( const rtl::OUString )
86         {
87             return 0;
88         }
89 
cCEL(void)90         virtual ContentEventNotifier*          cCEL( void )
91         {
92             return 0;
93         }
94 
cPSL(void)95         virtual PropertySetInfoChangeNotifier* cPSL( void )
96         {
97             return 0;
98         }
99 
cPCL(void)100         virtual PropertyChangeNotifier*        cPCL( void )
101         {
102             return 0;
103         }
104 
getKey(void)105         virtual rtl::OUString                  getKey( void )
106         {
107             return m_aBaseDirectory;
108         }
109 
110         sal_Int32 SAL_CALL CtorSuccess();
111         sal_Int32 SAL_CALL getMinorError();
112 
113         // XInterface
114         virtual com::sun::star::uno::Any SAL_CALL
115         queryInterface(
116             const com::sun::star::uno::Type& aType );
117 
118         virtual void SAL_CALL
119         acquire(
120             void )
121             throw();
122 
123         virtual void SAL_CALL
124         release(
125             void )
126             throw();
127 
128 
129         // XTypeProvider
130 
131         XTYPEPROVIDER_DECL()
132 
133 
134         // XEventListener
135         virtual void SAL_CALL
136         disposing(
137             const com::sun::star::lang::EventObject& Source );
138 
139         // XComponent
140         virtual void SAL_CALL
141         dispose(
142             void );
143 
144         virtual void SAL_CALL
145         addEventListener(
146             const com::sun::star::uno::Reference< com::sun::star::lang::XEventListener >& xListener );
147 
148         virtual void SAL_CALL
149         removeEventListener( const com::sun::star::uno::Reference< com::sun::star::lang::XEventListener >& aListener );
150 
151 
152         // XRow
153         virtual sal_Bool SAL_CALL
wasNull(void)154         wasNull(
155             void )
156         {
157             if( 0<= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
158                 m_nWasNull = m_aItems[m_nRow]->wasNull();
159             else
160                 m_nWasNull = true;
161             return m_nWasNull;
162         }
163 
164         virtual rtl::OUString SAL_CALL
getString(sal_Int32 columnIndex)165         getString(
166             sal_Int32 columnIndex )
167         {
168             if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
169                 return m_aItems[m_nRow]->getString( columnIndex );
170             else
171                 return rtl::OUString();
172         }
173 
174         virtual sal_Bool SAL_CALL
getBoolean(sal_Int32 columnIndex)175         getBoolean(
176             sal_Int32 columnIndex )
177         {
178             if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
179                 return m_aItems[m_nRow]->getBoolean( columnIndex );
180             else
181                 return false;
182         }
183 
184         virtual sal_Int8 SAL_CALL
getByte(sal_Int32 columnIndex)185         getByte(
186             sal_Int32 columnIndex )
187         {
188             if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
189                 return m_aItems[m_nRow]->getByte( columnIndex );
190             else
191                 return sal_Int8( 0 );
192         }
193 
194         virtual sal_Int16 SAL_CALL
getShort(sal_Int32 columnIndex)195         getShort(
196             sal_Int32 columnIndex )
197         {
198             if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
199                 return m_aItems[m_nRow]->getShort( columnIndex );
200             else
201                 return sal_Int16( 0 );
202         }
203 
204         virtual sal_Int32 SAL_CALL
getInt(sal_Int32 columnIndex)205         getInt(
206             sal_Int32 columnIndex )
207         {
208             if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
209                 return m_aItems[m_nRow]->getInt( columnIndex );
210             else
211                 return sal_Int32( 0 );
212         }
213 
214         virtual sal_Int64 SAL_CALL
getLong(sal_Int32 columnIndex)215         getLong(
216             sal_Int32 columnIndex )
217         {
218             if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
219                 return m_aItems[m_nRow]->getLong( columnIndex );
220             else
221                 return sal_Int64( 0 );
222         }
223 
224         virtual float SAL_CALL
getFloat(sal_Int32 columnIndex)225         getFloat(
226             sal_Int32 columnIndex )
227         {
228             if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
229                 return m_aItems[m_nRow]->getFloat( columnIndex );
230             else
231                 return float( 0 );
232         }
233 
234         virtual double SAL_CALL
getDouble(sal_Int32 columnIndex)235         getDouble(
236             sal_Int32 columnIndex )
237         {
238             if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
239                 return m_aItems[m_nRow]->getDouble( columnIndex );
240             else
241                 return double( 0 );
242         }
243 
244         virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL
getBytes(sal_Int32 columnIndex)245         getBytes(
246             sal_Int32 columnIndex )
247         {
248             if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
249                 return m_aItems[m_nRow]->getBytes( columnIndex );
250             else
251                 return com::sun::star::uno::Sequence< sal_Int8 >();
252         }
253 
254         virtual com::sun::star::util::Date SAL_CALL
getDate(sal_Int32 columnIndex)255         getDate(
256             sal_Int32 columnIndex )
257         {
258             if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
259                 return m_aItems[m_nRow]->getDate( columnIndex );
260             else
261                 return com::sun::star::util::Date();
262         }
263 
264         virtual com::sun::star::util::Time SAL_CALL
getTime(sal_Int32 columnIndex)265         getTime(
266             sal_Int32 columnIndex )
267         {
268             if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
269                 return m_aItems[m_nRow]->getTime( columnIndex );
270             else
271                 return com::sun::star::util::Time();
272         }
273 
274         virtual com::sun::star::util::DateTime SAL_CALL
getTimestamp(sal_Int32 columnIndex)275         getTimestamp(
276             sal_Int32 columnIndex )
277         {
278             if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
279                 return m_aItems[m_nRow]->getTimestamp( columnIndex );
280             else
281                 return com::sun::star::util::DateTime();
282         }
283 
284         virtual com::sun::star::uno::Reference< com::sun::star::io::XInputStream > SAL_CALL
getBinaryStream(sal_Int32 columnIndex)285         getBinaryStream(
286             sal_Int32 columnIndex )
287         {
288             if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
289                 return m_aItems[m_nRow]->getBinaryStream( columnIndex );
290             else
291                 return com::sun::star::uno::Reference< com::sun::star::io::XInputStream >();
292         }
293 
294         virtual com::sun::star::uno::Reference< com::sun::star::io::XInputStream > SAL_CALL
getCharacterStream(sal_Int32 columnIndex)295         getCharacterStream(
296             sal_Int32 columnIndex )
297         {
298             if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
299                 return m_aItems[m_nRow]->getCharacterStream( columnIndex );
300             else
301                 return com::sun::star::uno::Reference< com::sun::star::io::XInputStream >();
302         }
303 
304         virtual com::sun::star::uno::Any SAL_CALL
getObject(sal_Int32 columnIndex,const com::sun::star::uno::Reference<com::sun::star::container::XNameAccess> & typeMap)305         getObject(
306             sal_Int32 columnIndex,
307             const com::sun::star::uno::Reference< com::sun::star::container::XNameAccess >& typeMap )
308         {
309             if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
310                 return m_aItems[m_nRow]->getObject( columnIndex,typeMap );
311             else
312                 return com::sun::star::uno::Any();
313         }
314 
315         virtual com::sun::star::uno::Reference< com::sun::star::sdbc::XRef > SAL_CALL
getRef(sal_Int32 columnIndex)316         getRef(
317             sal_Int32 columnIndex )
318         {
319             if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
320                 return m_aItems[m_nRow]->getRef( columnIndex );
321             else
322                 return com::sun::star::uno::Reference< com::sun::star::sdbc::XRef >();
323         }
324 
325         virtual com::sun::star::uno::Reference< com::sun::star::sdbc::XBlob > SAL_CALL
getBlob(sal_Int32 columnIndex)326         getBlob(
327             sal_Int32 columnIndex )
328         {
329             if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
330                 return m_aItems[m_nRow]->getBlob( columnIndex );
331             else
332                 return com::sun::star::uno::Reference< com::sun::star::sdbc::XBlob >();
333         }
334 
335         virtual com::sun::star::uno::Reference< com::sun::star::sdbc::XClob > SAL_CALL
getClob(sal_Int32 columnIndex)336         getClob(
337             sal_Int32 columnIndex )
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< com::sun::star::sdbc::XClob >();
343         }
344 
345         virtual com::sun::star::uno::Reference< com::sun::star::sdbc::XArray > SAL_CALL
getArray(sal_Int32 columnIndex)346         getArray(
347             sal_Int32 columnIndex )
348         {
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< com::sun::star::sdbc::XArray >();
353         }
354 
355 
356         // XResultSet
357 
358         virtual sal_Bool SAL_CALL
359         next(
360             void );
361 
362         virtual sal_Bool SAL_CALL
363         isBeforeFirst(
364             void );
365 
366         virtual sal_Bool SAL_CALL
367         isAfterLast(
368             void );
369 
370         virtual sal_Bool SAL_CALL
371         isFirst(
372             void  );
373 
374         virtual sal_Bool SAL_CALL
375         isLast(
376             void  );
377 
378         virtual void SAL_CALL
379         beforeFirst(
380             void  );
381 
382         virtual void SAL_CALL
383         afterLast(
384             void  );
385 
386         virtual sal_Bool SAL_CALL
387         first(
388             void  );
389 
390         virtual sal_Bool SAL_CALL
391         last(
392             void  );
393 
394         virtual sal_Int32 SAL_CALL
395         getRow(
396             void  );
397 
398         virtual sal_Bool SAL_CALL
399         absolute(
400             sal_Int32 row );
401 
402         virtual sal_Bool SAL_CALL
403         relative(
404             sal_Int32 rows );
405 
406         virtual sal_Bool SAL_CALL
407         previous(
408             void  );
409 
410         virtual void SAL_CALL
411         refreshRow(
412             void  );
413 
414         virtual sal_Bool SAL_CALL
415         rowUpdated(
416             void );
417 
418         virtual sal_Bool SAL_CALL
419         rowInserted(
420             void  );
421 
422         virtual sal_Bool SAL_CALL
423         rowDeleted(
424             void  );
425 
426 
427         virtual  com::sun::star::uno::Reference<  com::sun::star::uno::XInterface > SAL_CALL
428         getStatement(
429             void  );
430 
431 
432         // XDynamicResultSet
433 
434         virtual com::sun::star::uno::Reference< com::sun::star::sdbc::XResultSet > SAL_CALL
435         getStaticResultSet(
436             void );
437 
438         virtual void SAL_CALL
439         setListener(
440             const com::sun::star::uno::Reference<
441             com::sun::star::ucb::XDynamicResultSetListener >& Listener );
442 
443         virtual void SAL_CALL
444         connectToCache( const com::sun::star::uno::Reference< com::sun::star::ucb::XDynamicResultSet > & xCache );
445 
446         virtual sal_Int16 SAL_CALL
447         getCapabilities();
448 
449 
450         // XCloseable
451 
452         virtual void SAL_CALL
453         close(
454             void );
455 
456         // XContentAccess
457 
458         virtual rtl::OUString SAL_CALL
459         queryContentIdentifierString(
460             void );
461 
462         virtual com::sun::star::uno::Reference< com::sun::star::ucb::XContentIdentifier > SAL_CALL
463         queryContentIdentifier(
464             void );
465 
466         virtual com::sun::star::uno::Reference< com::sun::star::ucb::XContent > SAL_CALL
467         queryContent(
468             void );
469 
470         // XResultSetMetaDataSupplier
471         virtual com::sun::star::uno::Reference< com::sun::star::sdbc::XResultSetMetaData > SAL_CALL
472         getMetaData(
473             void );
474 
475 
476         // XPropertySet
477         virtual com::sun::star::uno::Reference< com::sun::star::beans::XPropertySetInfo > SAL_CALL
478         getPropertySetInfo();
479 
480         virtual void SAL_CALL setPropertyValue(
481             const rtl::OUString& aPropertyName,
482             const com::sun::star::uno::Any& aValue );
483 
484         virtual com::sun::star::uno::Any SAL_CALL
485         getPropertyValue(
486             const rtl::OUString& PropertyName );
487 
488         virtual void SAL_CALL
489         addPropertyChangeListener(
490             const rtl::OUString& aPropertyName,
491             const com::sun::star::uno::Reference< com::sun::star::beans::XPropertyChangeListener >& xListener );
492 
493         virtual void SAL_CALL
494         removePropertyChangeListener(
495             const rtl::OUString& aPropertyName,
496             const com::sun::star::uno::Reference< com::sun::star::beans::XPropertyChangeListener >& aListener );
497 
498         virtual void SAL_CALL
499         addVetoableChangeListener(
500             const rtl::OUString& PropertyName,
501             const com::sun::star::uno::Reference< com::sun::star::beans::XVetoableChangeListener >& aListener );
502 
503         virtual void SAL_CALL removeVetoableChangeListener(
504             const rtl::OUString& PropertyName,
505             const com::sun::star::uno::Reference< com::sun::star::beans::XVetoableChangeListener >& aListener );
506 
507     private:
508 
509         // Members
510         //  const uno::Reference< lang::XMultiServiceFactory > m_xMSF;
511         //  const uno::Reference< ucb::XContentProvider > m_xProvider;
512 
513         shell*                              m_pMyShell;
514         com::sun::star::uno::Reference< com::sun::star::ucb::XContentProvider >  m_xProvider;
515         sal_Bool                            m_nIsOpen;
516         sal_Int32                           m_nRow;
517         sal_Bool                            m_nWasNull;
518         sal_Int32                           m_nOpenMode;
519         sal_Bool                            m_bRowCountFinal;
520 
521         typedef std::vector< com::sun::star::uno::Reference< com::sun::star::ucb::XContentIdentifier > > IdentSet;
522         typedef std::vector< com::sun::star::uno::Reference< com::sun::star::sdbc::XRow > >         ItemSet;
523         typedef std::vector< rtl::OUString >                        UnqPathSet;
524 
525         IdentSet                            m_aIdents;
526         ItemSet                             m_aItems;
527         UnqPathSet                          m_aUnqPath;
528         const rtl::OUString                 m_aBaseDirectory;
529 
530         osl::Directory                        m_aFolder;
531         com::sun::star::uno::Sequence< com::sun::star::beans::Property >      m_sProperty;
532         com::sun::star::uno::Sequence< com::sun::star::ucb::NumberedSortingInfo >  m_sSortingInfo;
533 
534         osl::Mutex                          m_aMutex;
535         osl::Mutex                          m_aEventListenerMutex;
536         cppu::OInterfaceContainerHelper*    m_pDisposeEventListeners;
537 
538         cppu::OInterfaceContainerHelper*    m_pRowCountListeners;
539         cppu::OInterfaceContainerHelper*    m_pIsFinalListeners;
540 
541         com::sun::star::uno::Reference< com::sun::star::ucb::XDynamicResultSetListener >       m_xListener;
542         sal_Bool                            m_bStatic;
543 
544         sal_Int32                                          m_nErrorCode;
545         sal_Int32                                          m_nMinorErrorCode;
546 
547         // Methods
548         sal_Bool SAL_CALL OneMore( void );
549 
550         void rowCountChanged();
551         void isFinalChanged();
552     };
553 
554 
555 } // end namespace fileaccess
556 
557 
558 #endif
559