1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
23 #include <ucbhelper/macros.hxx>
24 #include <osl/file.hxx>
26 #include "osl/mutex.hxx"
27 #include <cppuhelper/weak.hxx>
28 #include <cppuhelper/interfacecontainer.hxx>
29 #include <com/sun/star/lang/XTypeProvider.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/ucb/XDynamicResultSet.hpp>
34 #include <com/sun/star/ucb/XDynamicResultSetListener.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/beans/Property.hpp>
45 namespace fileaccess
{
50 : public cppu::OWeakObject
,
51 public com::sun::star::lang::XTypeProvider
,
52 public com::sun::star::lang::XEventListener
,
53 public com::sun::star::sdbc::XRow
,
54 public com::sun::star::sdbc::XResultSet
,
55 public com::sun::star::ucb::XDynamicResultSet
,
56 public com::sun::star::sdbc::XCloseable
,
57 public com::sun::star::sdbc::XResultSetMetaDataSupplier
,
58 public com::sun::star::beans::XPropertySet
,
59 public com::sun::star::ucb::XContentAccess
,
64 XResultSet_impl( shell
* pMyShell
,
65 const rtl::OUString
& aUnqPath
,
67 const com::sun::star::uno::Sequence
< com::sun::star::beans::Property
>& seq
,
68 const com::sun::star::uno::Sequence
< com::sun::star::ucb::NumberedSortingInfo
>& seqSort
);
70 virtual ~XResultSet_impl();
72 virtual ContentEventNotifier
* cDEL( void )
77 virtual ContentEventNotifier
* cEXC( const rtl::OUString
)
82 virtual ContentEventNotifier
* cCEL( void )
87 virtual PropertySetInfoChangeNotifier
* cPSL( void )
92 virtual PropertyChangeNotifier
* cPCL( void )
97 virtual rtl::OUString
getKey( void )
99 return m_aBaseDirectory
;
102 sal_Int32 SAL_CALL
CtorSuccess();
103 sal_Int32 SAL_CALL
getMinorError();
106 virtual com::sun::star::uno::Any SAL_CALL
108 const com::sun::star::uno::Type
& aType
)
109 throw( com::sun::star::uno::RuntimeException
);
111 virtual void SAL_CALL
116 virtual void SAL_CALL
128 virtual void SAL_CALL
130 const com::sun::star::lang::EventObject
& Source
)
131 throw( com::sun::star::uno::RuntimeException
);
134 virtual void SAL_CALL
137 throw( com::sun::star::uno::RuntimeException
);
139 virtual void SAL_CALL
141 const com::sun::star::uno::Reference
< com::sun::star::lang::XEventListener
>& xListener
)
142 throw( com::sun::star::uno::RuntimeException
);
144 virtual void SAL_CALL
145 removeEventListener( const com::sun::star::uno::Reference
< com::sun::star::lang::XEventListener
>& aListener
)
146 throw( com::sun::star::uno::RuntimeException
);
150 virtual sal_Bool SAL_CALL
153 throw( com::sun::star::sdbc::SQLException
,
154 com::sun::star::uno::RuntimeException
)
156 if( 0<= m_nRow
&& m_nRow
< sal::static_int_cast
<sal_Int32
>(m_aItems
.size()) )
157 m_nWasNull
= m_aItems
[m_nRow
]->wasNull();
163 virtual rtl::OUString SAL_CALL
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
]->getString( columnIndex
);
172 return rtl::OUString();
175 virtual sal_Bool SAL_CALL
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
]->getBoolean( columnIndex
);
187 virtual sal_Int8 SAL_CALL
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
]->getByte( columnIndex
);
196 return sal_Int8( 0 );
199 virtual sal_Int16 SAL_CALL
201 sal_Int32 columnIndex
)
203 com::sun::star::sdbc::SQLException
,
204 com::sun::star::uno::RuntimeException
)
206 if( 0 <= m_nRow
&& m_nRow
< sal::static_int_cast
<sal_Int32
>(m_aItems
.size()) )
207 return m_aItems
[m_nRow
]->getShort( columnIndex
);
209 return sal_Int16( 0 );
212 virtual sal_Int32 SAL_CALL
214 sal_Int32 columnIndex
)
215 throw( com::sun::star::sdbc::SQLException
,
216 com::sun::star::uno::RuntimeException
)
218 if( 0 <= m_nRow
&& m_nRow
< sal::static_int_cast
<sal_Int32
>(m_aItems
.size()) )
219 return m_aItems
[m_nRow
]->getInt( columnIndex
);
221 return sal_Int32( 0 );
224 virtual sal_Int64 SAL_CALL
226 sal_Int32 columnIndex
)
227 throw( com::sun::star::sdbc::SQLException
,
228 com::sun::star::uno::RuntimeException
)
230 if( 0 <= m_nRow
&& m_nRow
< sal::static_int_cast
<sal_Int32
>(m_aItems
.size()) )
231 return m_aItems
[m_nRow
]->getLong( columnIndex
);
233 return sal_Int64( 0 );
236 virtual float SAL_CALL
238 sal_Int32 columnIndex
)
239 throw( com::sun::star::sdbc::SQLException
,
240 com::sun::star::uno::RuntimeException
)
242 if( 0 <= m_nRow
&& m_nRow
< sal::static_int_cast
<sal_Int32
>(m_aItems
.size()) )
243 return m_aItems
[m_nRow
]->getFloat( columnIndex
);
248 virtual double SAL_CALL
250 sal_Int32 columnIndex
)
251 throw( com::sun::star::sdbc::SQLException
,
252 com::sun::star::uno::RuntimeException
)
254 if( 0 <= m_nRow
&& m_nRow
< sal::static_int_cast
<sal_Int32
>(m_aItems
.size()) )
255 return m_aItems
[m_nRow
]->getDouble( columnIndex
);
260 virtual com::sun::star::uno::Sequence
< sal_Int8
> SAL_CALL
262 sal_Int32 columnIndex
)
263 throw( com::sun::star::sdbc::SQLException
,
264 com::sun::star::uno::RuntimeException
)
266 if( 0 <= m_nRow
&& m_nRow
< sal::static_int_cast
<sal_Int32
>(m_aItems
.size()) )
267 return m_aItems
[m_nRow
]->getBytes( columnIndex
);
269 return com::sun::star::uno::Sequence
< sal_Int8
>();
272 virtual com::sun::star::util::Date SAL_CALL
274 sal_Int32 columnIndex
)
275 throw( com::sun::star::sdbc::SQLException
,
276 com::sun::star::uno::RuntimeException
)
278 if( 0 <= m_nRow
&& m_nRow
< sal::static_int_cast
<sal_Int32
>(m_aItems
.size()) )
279 return m_aItems
[m_nRow
]->getDate( columnIndex
);
281 return com::sun::star::util::Date();
284 virtual com::sun::star::util::Time SAL_CALL
286 sal_Int32 columnIndex
)
287 throw( com::sun::star::sdbc::SQLException
,
288 com::sun::star::uno::RuntimeException
)
290 if( 0 <= m_nRow
&& m_nRow
< sal::static_int_cast
<sal_Int32
>(m_aItems
.size()) )
291 return m_aItems
[m_nRow
]->getTime( columnIndex
);
293 return com::sun::star::util::Time();
296 virtual com::sun::star::util::DateTime SAL_CALL
298 sal_Int32 columnIndex
)
299 throw( com::sun::star::sdbc::SQLException
,
300 com::sun::star::uno::RuntimeException
)
302 if( 0 <= m_nRow
&& m_nRow
< sal::static_int_cast
<sal_Int32
>(m_aItems
.size()) )
303 return m_aItems
[m_nRow
]->getTimestamp( columnIndex
);
305 return com::sun::star::util::DateTime();
308 virtual com::sun::star::uno::Reference
< com::sun::star::io::XInputStream
> SAL_CALL
310 sal_Int32 columnIndex
)
311 throw( com::sun::star::sdbc::SQLException
,
312 com::sun::star::uno::RuntimeException
)
314 if( 0 <= m_nRow
&& m_nRow
< sal::static_int_cast
<sal_Int32
>(m_aItems
.size()) )
315 return m_aItems
[m_nRow
]->getBinaryStream( columnIndex
);
317 return com::sun::star::uno::Reference
< com::sun::star::io::XInputStream
>();
320 virtual com::sun::star::uno::Reference
< com::sun::star::io::XInputStream
> SAL_CALL
322 sal_Int32 columnIndex
)
323 throw( com::sun::star::sdbc::SQLException
,
324 com::sun::star::uno::RuntimeException
)
326 if( 0 <= m_nRow
&& m_nRow
< sal::static_int_cast
<sal_Int32
>(m_aItems
.size()) )
327 return m_aItems
[m_nRow
]->getCharacterStream( columnIndex
);
329 return com::sun::star::uno::Reference
< com::sun::star::io::XInputStream
>();
332 virtual com::sun::star::uno::Any SAL_CALL
334 sal_Int32 columnIndex
,
335 const com::sun::star::uno::Reference
< com::sun::star::container::XNameAccess
>& typeMap
)
336 throw( com::sun::star::sdbc::SQLException
,
337 com::sun::star::uno::RuntimeException
)
339 if( 0 <= m_nRow
&& m_nRow
< sal::static_int_cast
<sal_Int32
>(m_aItems
.size()) )
340 return m_aItems
[m_nRow
]->getObject( columnIndex
,typeMap
);
342 return com::sun::star::uno::Any();
345 virtual com::sun::star::uno::Reference
< com::sun::star::sdbc::XRef
> SAL_CALL
347 sal_Int32 columnIndex
)
348 throw( com::sun::star::sdbc::SQLException
,
349 com::sun::star::uno::RuntimeException
)
351 if( 0 <= m_nRow
&& m_nRow
< sal::static_int_cast
<sal_Int32
>(m_aItems
.size()) )
352 return m_aItems
[m_nRow
]->getRef( columnIndex
);
354 return com::sun::star::uno::Reference
< com::sun::star::sdbc::XRef
>();
357 virtual com::sun::star::uno::Reference
< com::sun::star::sdbc::XBlob
> SAL_CALL
359 sal_Int32 columnIndex
)
360 throw( com::sun::star::sdbc::SQLException
,
361 com::sun::star::uno::RuntimeException
)
363 if( 0 <= m_nRow
&& m_nRow
< sal::static_int_cast
<sal_Int32
>(m_aItems
.size()) )
364 return m_aItems
[m_nRow
]->getBlob( columnIndex
);
366 return com::sun::star::uno::Reference
< com::sun::star::sdbc::XBlob
>();
369 virtual com::sun::star::uno::Reference
< com::sun::star::sdbc::XClob
> SAL_CALL
371 sal_Int32 columnIndex
)
372 throw( com::sun::star::sdbc::SQLException
,
373 com::sun::star::uno::RuntimeException
)
375 if( 0 <= m_nRow
&& m_nRow
< sal::static_int_cast
<sal_Int32
>(m_aItems
.size()) )
376 return m_aItems
[m_nRow
]->getClob( columnIndex
);
378 return com::sun::star::uno::Reference
< com::sun::star::sdbc::XClob
>();
381 virtual com::sun::star::uno::Reference
< com::sun::star::sdbc::XArray
> SAL_CALL
383 sal_Int32 columnIndex
)
384 throw( com::sun::star::sdbc::SQLException
,
385 com::sun::star::uno::RuntimeException
)
387 if( 0 <= m_nRow
&& m_nRow
< sal::static_int_cast
<sal_Int32
>(m_aItems
.size()) )
388 return m_aItems
[m_nRow
]->getArray( columnIndex
);
390 return com::sun::star::uno::Reference
< com::sun::star::sdbc::XArray
>();
396 virtual sal_Bool SAL_CALL
399 throw( com::sun::star::sdbc::SQLException
,
400 com::sun::star::uno::RuntimeException
);
402 virtual sal_Bool SAL_CALL
405 throw( com::sun::star::sdbc::SQLException
,
406 com::sun::star::uno::RuntimeException
);
408 virtual sal_Bool SAL_CALL
411 throw( com::sun::star::sdbc::SQLException
,
412 com::sun::star::uno::RuntimeException
);
414 virtual sal_Bool SAL_CALL
417 throw( com::sun::star::sdbc::SQLException
,
418 com::sun::star::uno::RuntimeException
);
420 virtual sal_Bool SAL_CALL
423 throw( com::sun::star::sdbc::SQLException
,
424 com::sun::star::uno::RuntimeException
);
426 virtual void SAL_CALL
429 throw( com::sun::star::sdbc::SQLException
,
430 com::sun::star::uno::RuntimeException
);
432 virtual void SAL_CALL
435 throw( com::sun::star::sdbc::SQLException
,
436 com::sun::star::uno::RuntimeException
);
438 virtual sal_Bool SAL_CALL
441 throw( com::sun::star::sdbc::SQLException
,
442 com::sun::star::uno::RuntimeException
);
444 virtual sal_Bool SAL_CALL
447 throw( com::sun::star::sdbc::SQLException
,
448 com::sun::star::uno::RuntimeException
);
450 virtual sal_Int32 SAL_CALL
453 throw( com::sun::star::sdbc::SQLException
,
454 com::sun::star::uno::RuntimeException
);
456 virtual sal_Bool SAL_CALL
459 throw( com::sun::star::sdbc::SQLException
,
460 com::sun::star::uno::RuntimeException
);
462 virtual sal_Bool SAL_CALL
465 throw( com::sun::star::sdbc::SQLException
,
466 com::sun::star::uno::RuntimeException
);
468 virtual sal_Bool SAL_CALL
471 throw( com::sun::star::sdbc::SQLException
,
472 com::sun::star::uno::RuntimeException
);
474 virtual void SAL_CALL
477 throw( com::sun::star::sdbc::SQLException
,
478 com::sun::star::uno::RuntimeException
);
480 virtual sal_Bool SAL_CALL
483 throw( com::sun::star::sdbc::SQLException
,
484 com::sun::star::uno::RuntimeException
);
486 virtual sal_Bool SAL_CALL
489 throw( com::sun::star::sdbc::SQLException
,
490 com::sun::star::uno::RuntimeException
);
492 virtual sal_Bool SAL_CALL
495 throw( com::sun::star::sdbc::SQLException
,
496 com::sun::star::uno::RuntimeException
);
499 virtual com::sun::star::uno::Reference
< com::sun::star::uno::XInterface
> SAL_CALL
502 throw( com::sun::star::sdbc::SQLException
,
503 com::sun::star::uno::RuntimeException
);
508 virtual com::sun::star::uno::Reference
< com::sun::star::sdbc::XResultSet
> SAL_CALL
511 throw( com::sun::star::ucb::ListenerAlreadySetException
,
512 com::sun::star::uno::RuntimeException
);
514 virtual void SAL_CALL
516 const com::sun::star::uno::Reference
<
517 com::sun::star::ucb::XDynamicResultSetListener
>& Listener
)
518 throw( com::sun::star::ucb::ListenerAlreadySetException
,
519 com::sun::star::uno::RuntimeException
);
521 virtual void SAL_CALL
522 connectToCache( const com::sun::star::uno::Reference
< com::sun::star::ucb::XDynamicResultSet
> & xCache
)
523 throw( com::sun::star::ucb::ListenerAlreadySetException
,
524 com::sun::star::ucb::AlreadyInitializedException
,
525 com::sun::star::ucb::ServiceNotFoundException
,
526 com::sun::star::uno::RuntimeException
);
528 virtual sal_Int16 SAL_CALL
530 throw( com::sun::star::uno::RuntimeException
);
535 virtual void SAL_CALL
538 throw( com::sun::star::sdbc::SQLException
,
539 com::sun::star::uno::RuntimeException
);
543 virtual rtl::OUString SAL_CALL
544 queryContentIdentifierString(
546 throw( com::sun::star::uno::RuntimeException
);
548 virtual com::sun::star::uno::Reference
< com::sun::star::ucb::XContentIdentifier
> SAL_CALL
549 queryContentIdentifier(
551 throw( com::sun::star::uno::RuntimeException
);
553 virtual com::sun::star::uno::Reference
< com::sun::star::ucb::XContent
> SAL_CALL
556 throw( com::sun::star::uno::RuntimeException
);
558 // XResultSetMetaDataSupplier
559 virtual com::sun::star::uno::Reference
< com::sun::star::sdbc::XResultSetMetaData
> SAL_CALL
562 throw( com::sun::star::sdbc::SQLException
,
563 com::sun::star::uno::RuntimeException
);
567 virtual com::sun::star::uno::Reference
< com::sun::star::beans::XPropertySetInfo
> SAL_CALL
569 throw( com::sun::star::uno::RuntimeException
);
571 virtual void SAL_CALL
setPropertyValue(
572 const rtl::OUString
& aPropertyName
,
573 const com::sun::star::uno::Any
& aValue
)
574 throw( com::sun::star::beans::UnknownPropertyException
,
575 com::sun::star::beans::PropertyVetoException
,
576 com::sun::star::lang::IllegalArgumentException
,
577 com::sun::star::lang::WrappedTargetException
,
578 com::sun::star::uno::RuntimeException
);
580 virtual com::sun::star::uno::Any SAL_CALL
582 const rtl::OUString
& PropertyName
)
583 throw( com::sun::star::beans::UnknownPropertyException
,
584 com::sun::star::lang::WrappedTargetException
,
585 com::sun::star::uno::RuntimeException
);
587 virtual void SAL_CALL
588 addPropertyChangeListener(
589 const rtl::OUString
& aPropertyName
,
590 const com::sun::star::uno::Reference
< com::sun::star::beans::XPropertyChangeListener
>& xListener
)
591 throw( com::sun::star::beans::UnknownPropertyException
,
592 com::sun::star::lang::WrappedTargetException
,
593 com::sun::star::uno::RuntimeException
);
595 virtual void SAL_CALL
596 removePropertyChangeListener(
597 const rtl::OUString
& aPropertyName
,
598 const com::sun::star::uno::Reference
< com::sun::star::beans::XPropertyChangeListener
>& aListener
)
599 throw( com::sun::star::beans::UnknownPropertyException
,
600 com::sun::star::lang::WrappedTargetException
,
601 com::sun::star::uno::RuntimeException
);
603 virtual void SAL_CALL
604 addVetoableChangeListener(
605 const rtl::OUString
& PropertyName
,
606 const com::sun::star::uno::Reference
< com::sun::star::beans::XVetoableChangeListener
>& aListener
)
607 throw( com::sun::star::beans::UnknownPropertyException
,
608 com::sun::star::lang::WrappedTargetException
,
609 com::sun::star::uno::RuntimeException
);
611 virtual void SAL_CALL
removeVetoableChangeListener(
612 const rtl::OUString
& PropertyName
,
613 const com::sun::star::uno::Reference
< com::sun::star::beans::XVetoableChangeListener
>& aListener
)
614 throw( com::sun::star::beans::UnknownPropertyException
,
615 com::sun::star::lang::WrappedTargetException
,
616 com::sun::star::uno::RuntimeException
);
621 // const uno::Reference< lang::XMultiServiceFactory > m_xMSF;
622 // const uno::Reference< ucb::XContentProvider > m_xProvider;
625 com::sun::star::uno::Reference
< com::sun::star::ucb::XContentProvider
> m_xProvider
;
629 sal_Int32 m_nOpenMode
;
630 sal_Bool m_bRowCountFinal
;
632 typedef std::vector
< com::sun::star::uno::Reference
< com::sun::star::ucb::XContentIdentifier
> > IdentSet
;
633 typedef std::vector
< com::sun::star::uno::Reference
< com::sun::star::sdbc::XRow
> > ItemSet
;
634 typedef std::vector
< rtl::OUString
> UnqPathSet
;
638 UnqPathSet m_aUnqPath
;
639 const rtl::OUString m_aBaseDirectory
;
641 osl::Directory m_aFolder
;
642 com::sun::star::uno::Sequence
< com::sun::star::beans::Property
> m_sProperty
;
643 com::sun::star::uno::Sequence
< com::sun::star::ucb::NumberedSortingInfo
> m_sSortingInfo
;
646 osl::Mutex m_aEventListenerMutex
;
647 cppu::OInterfaceContainerHelper
* m_pDisposeEventListeners
;
649 cppu::OInterfaceContainerHelper
* m_pRowCountListeners
;
650 cppu::OInterfaceContainerHelper
* m_pIsFinalListeners
;
652 com::sun::star::uno::Reference
< com::sun::star::ucb::XDynamicResultSetListener
> m_xListener
;
655 sal_Int32 m_nErrorCode
;
656 sal_Int32 m_nMinorErrorCode
;
659 sal_Bool SAL_CALL
OneMore( void )
660 throw( com::sun::star::sdbc::SQLException
,
661 com::sun::star::uno::RuntimeException
);
663 void rowCountChanged();
664 void isFinalChanged();
668 } // end namespace fileaccess
673 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */