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 <osl/file.hxx>
25 #include <comphelper/interfacecontainer4.hxx>
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/ucb/XDynamicResultSet.hpp>
30 #include <com/sun/star/ucb/XDynamicResultSetListener.hpp>
31 #include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
32 #include <com/sun/star/ucb/NumberedSortingInfo.hpp>
33 #include <com/sun/star/ucb/XContentIdentifier.hpp>
34 #include <com/sun/star/beans/Property.hpp>
36 #include <cppuhelper/implbase.hxx>
38 namespace fileaccess
{
40 class XResultSet_impl
:
41 public cppu::WeakImplHelper
< css::lang::XEventListener
,
43 css::sdbc::XResultSet
,
44 css::ucb::XDynamicResultSet
,
45 css::sdbc::XCloseable
,
46 css::sdbc::XResultSetMetaDataSupplier
,
47 css::beans::XPropertySet
,
48 css::ucb::XContentAccess
>
52 XResultSet_impl( TaskManager
* pMyShell
,
53 const OUString
& aUnqPath
,
55 const css::uno::Sequence
< css::beans::Property
>& seq
,
56 const css::uno::Sequence
< css::ucb::NumberedSortingInfo
>& seqSort
);
58 virtual ~XResultSet_impl() override
;
60 TaskHandlerErr
CtorSuccess() const { return m_nErrorCode
;}
61 sal_Int32
getMinorError() const { return m_nMinorErrorCode
;}
65 disposing( const css::lang::EventObject
& Source
) override
;
73 const css::uno::Reference
< css::lang::XEventListener
>& xListener
) override
;
76 removeEventListener( const css::uno::Reference
< css::lang::XEventListener
>& aListener
) override
;
80 virtual sal_Bool SAL_CALL
83 if( 0<= m_nRow
&& m_nRow
< sal::static_int_cast
<sal_Int32
>(m_aItems
.size()) )
84 m_nWasNull
= m_aItems
[m_nRow
]->wasNull();
90 virtual OUString SAL_CALL
91 getString( sal_Int32 columnIndex
) override
93 if( 0 <= m_nRow
&& m_nRow
< sal::static_int_cast
<sal_Int32
>(m_aItems
.size()) )
94 return m_aItems
[m_nRow
]->getString( columnIndex
);
99 virtual sal_Bool SAL_CALL
100 getBoolean( sal_Int32 columnIndex
) override
102 if( 0 <= m_nRow
&& m_nRow
< sal::static_int_cast
<sal_Int32
>(m_aItems
.size()) )
103 return m_aItems
[m_nRow
]->getBoolean( columnIndex
);
108 virtual sal_Int8 SAL_CALL
109 getByte( sal_Int32 columnIndex
) override
111 if( 0 <= m_nRow
&& m_nRow
< sal::static_int_cast
<sal_Int32
>(m_aItems
.size()) )
112 return m_aItems
[m_nRow
]->getByte( columnIndex
);
114 return sal_Int8( 0 );
117 virtual sal_Int16 SAL_CALL
118 getShort( sal_Int32 columnIndex
) override
120 if( 0 <= m_nRow
&& m_nRow
< sal::static_int_cast
<sal_Int32
>(m_aItems
.size()) )
121 return m_aItems
[m_nRow
]->getShort( columnIndex
);
123 return sal_Int16( 0 );
126 virtual sal_Int32 SAL_CALL
127 getInt( sal_Int32 columnIndex
) override
129 if( 0 <= m_nRow
&& m_nRow
< sal::static_int_cast
<sal_Int32
>(m_aItems
.size()) )
130 return m_aItems
[m_nRow
]->getInt( columnIndex
);
135 virtual sal_Int64 SAL_CALL
136 getLong( sal_Int32 columnIndex
) override
138 if( 0 <= m_nRow
&& m_nRow
< sal::static_int_cast
<sal_Int32
>(m_aItems
.size()) )
139 return m_aItems
[m_nRow
]->getLong( columnIndex
);
141 return sal_Int64( 0 );
144 virtual float SAL_CALL
145 getFloat( sal_Int32 columnIndex
) override
147 if( 0 <= m_nRow
&& m_nRow
< sal::static_int_cast
<sal_Int32
>(m_aItems
.size()) )
148 return m_aItems
[m_nRow
]->getFloat( columnIndex
);
153 virtual double SAL_CALL
154 getDouble( sal_Int32 columnIndex
) override
156 if( 0 <= m_nRow
&& m_nRow
< sal::static_int_cast
<sal_Int32
>(m_aItems
.size()) )
157 return m_aItems
[m_nRow
]->getDouble( columnIndex
);
162 virtual css::uno::Sequence
< sal_Int8
> SAL_CALL
163 getBytes( sal_Int32 columnIndex
) override
165 if( 0 <= m_nRow
&& m_nRow
< sal::static_int_cast
<sal_Int32
>(m_aItems
.size()) )
166 return m_aItems
[m_nRow
]->getBytes( columnIndex
);
168 return css::uno::Sequence
< sal_Int8
>();
171 virtual css::util::Date SAL_CALL
172 getDate( sal_Int32 columnIndex
) override
174 if( 0 <= m_nRow
&& m_nRow
< sal::static_int_cast
<sal_Int32
>(m_aItems
.size()) )
175 return m_aItems
[m_nRow
]->getDate( columnIndex
);
177 return css::util::Date();
180 virtual css::util::Time SAL_CALL
181 getTime( sal_Int32 columnIndex
) override
183 if( 0 <= m_nRow
&& m_nRow
< sal::static_int_cast
<sal_Int32
>(m_aItems
.size()) )
184 return m_aItems
[m_nRow
]->getTime( columnIndex
);
186 return css::util::Time();
189 virtual css::util::DateTime SAL_CALL
190 getTimestamp( sal_Int32 columnIndex
) override
192 if( 0 <= m_nRow
&& m_nRow
< sal::static_int_cast
<sal_Int32
>(m_aItems
.size()) )
193 return m_aItems
[m_nRow
]->getTimestamp( columnIndex
);
195 return css::util::DateTime();
198 virtual css::uno::Reference
< css::io::XInputStream
> SAL_CALL
199 getBinaryStream( sal_Int32 columnIndex
) override
201 if( 0 <= m_nRow
&& m_nRow
< sal::static_int_cast
<sal_Int32
>(m_aItems
.size()) )
202 return m_aItems
[m_nRow
]->getBinaryStream( columnIndex
);
204 return css::uno::Reference
< css::io::XInputStream
>();
207 virtual css::uno::Reference
< css::io::XInputStream
> SAL_CALL
208 getCharacterStream( sal_Int32 columnIndex
) override
210 if( 0 <= m_nRow
&& m_nRow
< sal::static_int_cast
<sal_Int32
>(m_aItems
.size()) )
211 return m_aItems
[m_nRow
]->getCharacterStream( columnIndex
);
213 return css::uno::Reference
< css::io::XInputStream
>();
216 virtual css::uno::Any SAL_CALL
217 getObject( sal_Int32 columnIndex
,
218 const css::uno::Reference
< css::container::XNameAccess
>& typeMap
) override
220 if( 0 <= m_nRow
&& m_nRow
< sal::static_int_cast
<sal_Int32
>(m_aItems
.size()) )
221 return m_aItems
[m_nRow
]->getObject( columnIndex
,typeMap
);
223 return css::uno::Any();
226 virtual css::uno::Reference
< css::sdbc::XRef
> SAL_CALL
227 getRef( sal_Int32 columnIndex
) override
229 if( 0 <= m_nRow
&& m_nRow
< sal::static_int_cast
<sal_Int32
>(m_aItems
.size()) )
230 return m_aItems
[m_nRow
]->getRef( columnIndex
);
232 return css::uno::Reference
< css::sdbc::XRef
>();
235 virtual css::uno::Reference
< css::sdbc::XBlob
> SAL_CALL
236 getBlob( sal_Int32 columnIndex
) override
238 if( 0 <= m_nRow
&& m_nRow
< sal::static_int_cast
<sal_Int32
>(m_aItems
.size()) )
239 return m_aItems
[m_nRow
]->getBlob( columnIndex
);
241 return css::uno::Reference
< css::sdbc::XBlob
>();
244 virtual css::uno::Reference
< css::sdbc::XClob
> SAL_CALL
245 getClob( sal_Int32 columnIndex
) override
247 if( 0 <= m_nRow
&& m_nRow
< sal::static_int_cast
<sal_Int32
>(m_aItems
.size()) )
248 return m_aItems
[m_nRow
]->getClob( columnIndex
);
250 return css::uno::Reference
< css::sdbc::XClob
>();
253 virtual css::uno::Reference
< css::sdbc::XArray
> SAL_CALL
254 getArray( sal_Int32 columnIndex
) override
256 if( 0 <= m_nRow
&& m_nRow
< sal::static_int_cast
<sal_Int32
>(m_aItems
.size()) )
257 return m_aItems
[m_nRow
]->getArray( columnIndex
);
259 return css::uno::Reference
< css::sdbc::XArray
>();
265 virtual sal_Bool SAL_CALL
268 virtual sal_Bool SAL_CALL
269 isBeforeFirst() override
;
271 virtual sal_Bool SAL_CALL
272 isAfterLast() override
;
274 virtual sal_Bool SAL_CALL
277 virtual sal_Bool SAL_CALL
280 virtual void SAL_CALL
281 beforeFirst() override
;
283 virtual void SAL_CALL
284 afterLast() override
;
286 virtual sal_Bool SAL_CALL
289 virtual sal_Bool SAL_CALL
292 virtual sal_Int32 SAL_CALL
295 virtual sal_Bool SAL_CALL
296 absolute( sal_Int32 row
) override
;
298 virtual sal_Bool SAL_CALL
299 relative( sal_Int32 rows
) override
;
301 virtual sal_Bool SAL_CALL
304 virtual void SAL_CALL
305 refreshRow() override
;
307 virtual sal_Bool SAL_CALL
308 rowUpdated() override
;
310 virtual sal_Bool SAL_CALL
311 rowInserted() override
;
313 virtual sal_Bool SAL_CALL
314 rowDeleted() override
;
317 virtual css::uno::Reference
< css::uno::XInterface
> SAL_CALL
318 getStatement() override
;
323 virtual css::uno::Reference
< css::sdbc::XResultSet
> SAL_CALL
324 getStaticResultSet() override
;
326 virtual void SAL_CALL
328 const css::uno::Reference
<
329 css::ucb::XDynamicResultSetListener
>& Listener
) override
;
331 virtual void SAL_CALL
332 connectToCache( const css::uno::Reference
< css::ucb::XDynamicResultSet
> & xCache
) override
;
334 virtual sal_Int16 SAL_CALL
335 getCapabilities() override
;
340 virtual void SAL_CALL
345 virtual OUString SAL_CALL
346 queryContentIdentifierString() override
;
348 virtual css::uno::Reference
< css::ucb::XContentIdentifier
> SAL_CALL
349 queryContentIdentifier() override
;
351 virtual css::uno::Reference
< css::ucb::XContent
> SAL_CALL
352 queryContent() override
;
354 // XResultSetMetaDataSupplier
355 virtual css::uno::Reference
< css::sdbc::XResultSetMetaData
> SAL_CALL
356 getMetaData() override
;
360 virtual css::uno::Reference
< css::beans::XPropertySetInfo
> SAL_CALL
361 getPropertySetInfo() override
;
363 virtual void SAL_CALL
setPropertyValue(
364 const OUString
& aPropertyName
,
365 const css::uno::Any
& aValue
) override
;
367 virtual css::uno::Any SAL_CALL
369 const OUString
& PropertyName
) override
;
371 virtual void SAL_CALL
372 addPropertyChangeListener(
373 const OUString
& aPropertyName
,
374 const css::uno::Reference
< css::beans::XPropertyChangeListener
>& xListener
) override
;
376 virtual void SAL_CALL
377 removePropertyChangeListener(
378 const OUString
& aPropertyName
,
379 const css::uno::Reference
< css::beans::XPropertyChangeListener
>& aListener
) override
;
381 virtual void SAL_CALL
382 addVetoableChangeListener(
383 const OUString
& PropertyName
,
384 const css::uno::Reference
< css::beans::XVetoableChangeListener
>& aListener
) override
;
386 virtual void SAL_CALL
removeVetoableChangeListener(
387 const OUString
& PropertyName
,
388 const css::uno::Reference
< css::beans::XVetoableChangeListener
>& aListener
) override
;
392 TaskManager
* m_pMyShell
;
396 sal_Int32 m_nOpenMode
;
397 bool m_bRowCountFinal
;
399 typedef std::vector
< css::uno::Reference
< css::ucb::XContentIdentifier
> > IdentSet
;
400 typedef std::vector
< css::uno::Reference
< css::sdbc::XRow
> > ItemSet
;
404 std::vector
< OUString
> m_aUnqPath
;
405 const OUString m_aBaseDirectory
;
407 osl::Directory m_aFolder
;
408 css::uno::Sequence
< css::beans::Property
> m_sProperty
;
409 css::uno::Sequence
< css::ucb::NumberedSortingInfo
> m_sSortingInfo
;
412 comphelper::OInterfaceContainerHelper4
<css::lang::XEventListener
> m_aDisposeEventListeners
;
413 comphelper::OInterfaceContainerHelper4
<css::beans::XPropertyChangeListener
> m_aRowCountListeners
;
414 comphelper::OInterfaceContainerHelper4
<css::beans::XPropertyChangeListener
> m_aIsFinalListeners
;
416 css::uno::Reference
< css::ucb::XDynamicResultSetListener
> m_xListener
;
418 TaskHandlerErr m_nErrorCode
;
419 sal_Int32 m_nMinorErrorCode
;
422 /// @throws css::sdbc::SQLException
423 /// @throws css::uno::RuntimeException
424 bool OneMore(std::unique_lock
<std::mutex
>&);
426 void rowCountChanged(std::unique_lock
<std::mutex
>&);
427 void isFinalChanged(std::unique_lock
<std::mutex
>&);
431 } // end namespace fileaccess
434 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */