Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <com/sun/star/ucb/WelcomeDynamicResultSetStruct.hpp>
30 : : #include "filid.hxx"
31 : : #include "shell.hxx"
32 : : #include "filprp.hxx"
33 : : #include "filrset.hxx"
34 : : #include <com/sun/star/ucb/OpenMode.hpp>
35 : : #include "prov.hxx"
36 : : #include <com/sun/star/uno/Reference.h>
37 : :
38 : : #include <com/sun/star/beans/PropertyAttribute.hpp>
39 : : #include <com/sun/star/ucb/ListActionType.hpp>
40 : : #include <com/sun/star/ucb/XSourceInitialization.hpp>
41 : : #include <com/sun/star/ucb/XCachedDynamicResultSetStubFactory.hpp>
42 : : #include <ucbhelper/resultsetmetadata.hxx>
43 : :
44 : : using namespace fileaccess;
45 : : using namespace com::sun::star;
46 : :
47 : 24361 : XResultSet_impl::XResultSet_impl(
48 : : shell* pMyShell,
49 : : const rtl::OUString& aUnqPath,
50 : : sal_Int32 OpenMode,
51 : : const uno::Sequence< beans::Property >& seq,
52 : : const uno::Sequence< ucb::NumberedSortingInfo >& seqSort )
53 : : : m_pMyShell( pMyShell ),
54 : : m_xProvider( pMyShell->m_pProvider ),
55 : : m_nRow( -1 ),
56 : : m_nOpenMode( OpenMode ),
57 : : m_bRowCountFinal( false ),
58 : : m_aBaseDirectory( aUnqPath ),
59 : : m_aFolder( aUnqPath ),
60 : : m_sProperty( seq ),
61 : : m_sSortingInfo( seqSort ),
62 : : m_pDisposeEventListeners( 0 ),
63 : : m_pRowCountListeners( 0 ),
64 : : m_pIsFinalListeners( 0 ),
65 : : m_bStatic( false ),
66 : : m_nErrorCode( TASKHANDLER_NO_ERROR ),
67 [ + - ][ + - ]: 24361 : m_nMinorErrorCode( TASKHANDLER_NO_ERROR )
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
68 : : {
69 [ + - ]: 24361 : osl::FileBase::RC err = m_aFolder.open();
70 [ - + ]: 24361 : if( err != osl::FileBase::E_None )
71 : : {
72 : 0 : m_nIsOpen = false;
73 [ # # ]: 0 : m_aFolder.close();
74 : :
75 : 0 : m_nErrorCode = TASKHANDLING_OPEN_FOR_DIRECTORYLISTING;
76 : 0 : m_nMinorErrorCode = err;
77 : : }
78 : : else
79 : 24361 : m_nIsOpen = true;
80 : :
81 [ + - ]: 24361 : m_pMyShell->registerNotifier( m_aBaseDirectory,this );
82 : 24361 : }
83 : :
84 : :
85 [ + - ][ + - ]: 24361 : XResultSet_impl::~XResultSet_impl()
[ + - ][ + - ]
[ + - ]
86 : : {
87 [ + - ]: 24361 : m_pMyShell->deregisterNotifier( m_aBaseDirectory,this );
88 : :
89 [ + + ]: 24361 : if( m_nIsOpen )
90 [ + - ]: 112 : m_aFolder.close();
91 : :
92 [ - + ][ # # ]: 24361 : delete m_pDisposeEventListeners;
93 [ - + ][ # # ]: 24361 : delete m_pRowCountListeners;
94 [ - + ][ # # ]: 24361 : delete m_pIsFinalListeners;
95 [ - + ]: 48722 : }
96 : :
97 : :
98 : :
99 : 24361 : sal_Int32 SAL_CALL XResultSet_impl::CtorSuccess()
100 : : {
101 : 24361 : return m_nErrorCode;
102 : : }
103 : :
104 : :
105 : :
106 : 0 : sal_Int32 SAL_CALL XResultSet_impl::getMinorError()
107 : : {
108 : 0 : return m_nMinorErrorCode;
109 : : }
110 : :
111 : :
112 : : void SAL_CALL
113 : 246900 : XResultSet_impl::acquire(
114 : : void )
115 : : throw()
116 : : {
117 : 246900 : OWeakObject::acquire();
118 : 246900 : }
119 : :
120 : :
121 : : void SAL_CALL
122 : 246900 : XResultSet_impl::release(
123 : : void )
124 : : throw()
125 : : {
126 : 246900 : OWeakObject::release();
127 : 246900 : }
128 : :
129 : :
130 : :
131 : : uno::Any SAL_CALL
132 : 48286 : XResultSet_impl::queryInterface(
133 : : const uno::Type& rType )
134 : : throw( uno::RuntimeException )
135 : : {
136 : : uno::Any aRet = cppu::queryInterface(
137 : : rType,
138 : : (static_cast< lang::XComponent* >(this)),
139 : : (static_cast< lang::XTypeProvider* >(this)),
140 : : (static_cast< lang::XEventListener* >(this)),
141 : : (static_cast< sdbc::XRow* >(this)),
142 : : (static_cast< sdbc::XResultSet* >(this)),
143 : : (static_cast< sdbc::XCloseable* >(this)),
144 : : (static_cast< sdbc::XResultSetMetaDataSupplier* >(this)),
145 : : (static_cast< beans::XPropertySet* >(this)),
146 : : (static_cast< ucb::XContentAccess* >(this)),
147 [ + - ]: 48286 : (static_cast< ucb::XDynamicResultSet* >(this)) );
148 [ + - ][ # # ]: 48286 : return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType );
149 : : }
150 : :
151 : :
152 : : void SAL_CALL
153 : 0 : XResultSet_impl::disposing( const lang::EventObject& )
154 : : throw( uno::RuntimeException )
155 : : {
156 : : // To do, but what
157 : 0 : }
158 : :
159 : :
160 [ # # ][ # # ]: 0 : XTYPEPROVIDER_IMPL_10( XResultSet_impl,
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
161 : : lang::XTypeProvider,
162 : : lang::XTypeProvider,
163 : : lang::XEventListener,
164 : : sdbc::XRow,
165 : : sdbc::XResultSet,
166 : : XDynamicResultSet,
167 : : sdbc::XCloseable,
168 : : sdbc::XResultSetMetaDataSupplier,
169 : : beans::XPropertySet,
170 : : ucb::XContentAccess )
171 : :
172 : :
173 : : void SAL_CALL
174 : 0 : XResultSet_impl::addEventListener(
175 : : const uno::Reference< lang::XEventListener >& Listener )
176 : : throw( uno::RuntimeException )
177 : : {
178 [ # # ]: 0 : osl::MutexGuard aGuard( m_aMutex );
179 : :
180 [ # # ]: 0 : if ( ! m_pDisposeEventListeners )
181 : : m_pDisposeEventListeners =
182 [ # # ]: 0 : new cppu::OInterfaceContainerHelper( m_aEventListenerMutex );
183 : :
184 [ # # ][ # # ]: 0 : m_pDisposeEventListeners->addInterface( Listener );
185 : 0 : }
186 : :
187 : :
188 : : void SAL_CALL
189 : 0 : XResultSet_impl::removeEventListener(
190 : : const uno::Reference< lang::XEventListener >& Listener )
191 : : throw( uno::RuntimeException )
192 : : {
193 [ # # ]: 0 : osl::MutexGuard aGuard( m_aMutex );
194 : :
195 [ # # ]: 0 : if ( m_pDisposeEventListeners )
196 [ # # ][ # # ]: 0 : m_pDisposeEventListeners->removeInterface( Listener );
197 : 0 : }
198 : :
199 : :
200 : :
201 : : void SAL_CALL
202 : 0 : XResultSet_impl::dispose()
203 : : throw( uno::RuntimeException )
204 : : {
205 [ # # ]: 0 : osl::MutexGuard aGuard( m_aMutex );
206 : :
207 [ # # ]: 0 : lang::EventObject aEvt;
208 [ # # ]: 0 : aEvt.Source = static_cast< lang::XComponent * >( this );
209 : :
210 [ # # ][ # # ]: 0 : if ( m_pDisposeEventListeners && m_pDisposeEventListeners->getLength() )
[ # # ][ # # ]
211 : : {
212 [ # # ]: 0 : m_pDisposeEventListeners->disposeAndClear( aEvt );
213 : : }
214 [ # # ][ # # ]: 0 : if( m_pRowCountListeners && m_pRowCountListeners->getLength() )
[ # # ][ # # ]
215 : : {
216 [ # # ]: 0 : m_pRowCountListeners->disposeAndClear( aEvt );
217 : : }
218 [ # # ][ # # ]: 0 : if( m_pIsFinalListeners && m_pIsFinalListeners->getLength() )
[ # # ][ # # ]
219 : : {
220 [ # # ]: 0 : m_pIsFinalListeners->disposeAndClear( aEvt );
221 [ # # ][ # # ]: 0 : }
222 : 0 : }
223 : :
224 : :
225 : :
226 : 9486 : void XResultSet_impl::rowCountChanged()
227 : : {
228 : : sal_Int32 aOldValue,aNewValue;
229 [ + - ]: 9486 : uno::Sequence< uno::Reference< uno::XInterface > > seq;
230 : : {
231 [ + - ]: 9486 : osl::MutexGuard aGuard( m_aMutex );
232 [ - + ]: 9486 : if( m_pRowCountListeners )
233 [ # # ][ # # ]: 0 : seq = m_pRowCountListeners->getElements();
[ # # ]
234 : 9486 : aNewValue = m_aItems.size();
235 [ + - ]: 9486 : aOldValue = aNewValue-1;
236 : : }
237 [ + - ]: 9486 : beans::PropertyChangeEvent aEv;
238 : 9486 : aEv.PropertyName = rtl::OUString("RowCount");
239 : 9486 : aEv.Further = false;
240 : 9486 : aEv.PropertyHandle = -1;
241 [ + - ]: 9486 : aEv.OldValue <<= aOldValue;
242 [ + - ]: 9486 : aEv.NewValue <<= aNewValue;
243 [ - + ]: 9486 : for( sal_Int32 i = 0; i < seq.getLength(); ++i )
244 : : {
245 : : uno::Reference< beans::XPropertyChangeListener > listener(
246 [ # # ][ # # ]: 0 : seq[i], uno::UNO_QUERY );
247 [ # # ]: 0 : if( listener.is() )
248 [ # # ][ # # ]: 0 : listener->propertyChange( aEv );
249 [ + - ][ + - ]: 9486 : }
250 : 9486 : }
251 : :
252 : :
253 : 24249 : void XResultSet_impl::isFinalChanged()
254 : : {
255 [ + - ]: 24249 : uno::Sequence< uno::Reference< XInterface > > seq;
256 : : {
257 [ + - ]: 24249 : osl::MutexGuard aGuard( m_aMutex );
258 [ - + ]: 24249 : if( m_pIsFinalListeners )
259 [ # # ][ # # ]: 0 : seq = m_pIsFinalListeners->getElements();
[ # # ]
260 [ + - ]: 24249 : m_bRowCountFinal = true;
261 : : }
262 [ + - ]: 24249 : beans::PropertyChangeEvent aEv;
263 : 24249 : aEv.PropertyName = rtl::OUString("IsRowCountFinal");
264 : 24249 : aEv.Further = false;
265 : 24249 : aEv.PropertyHandle = -1;
266 : 24249 : sal_Bool fval = false;
267 : 24249 : sal_Bool tval = true;
268 [ + - ]: 24249 : aEv.OldValue <<= fval;
269 [ + - ]: 24249 : aEv.NewValue <<= tval;
270 [ - + ]: 24249 : for( sal_Int32 i = 0; i < seq.getLength(); ++i )
271 : : {
272 : : uno::Reference< beans::XPropertyChangeListener > listener(
273 [ # # ][ # # ]: 0 : seq[i], uno::UNO_QUERY );
274 [ # # ]: 0 : if( listener.is() )
275 [ # # ][ # # ]: 0 : listener->propertyChange( aEv );
276 [ + - ][ + - ]: 24249 : }
277 : 24249 : }
278 : :
279 : :
280 : : sal_Bool SAL_CALL
281 : 34197 : XResultSet_impl::OneMore(
282 : : void )
283 : : throw( sdbc::SQLException,
284 : : uno::RuntimeException )
285 : : {
286 [ + + ]: 34197 : if( ! m_nIsOpen )
287 : 462 : return false;
288 : :
289 : : osl::FileBase::RC err;
290 : : sal_Bool IsRegular;
291 : 33735 : rtl::OUString aUnqPath;
292 : 33735 : osl::DirectoryItem m_aDirIte;
293 : 33735 : uno::Reference< sdbc::XRow > aRow;
294 : :
295 : 900 : while( true )
296 : : {
297 [ + - ]: 34635 : err = m_aFolder.getNextItem( m_aDirIte );
298 : :
299 [ + + ][ - + ]: 34635 : if( err == osl::FileBase::E_NOENT || err == osl::FileBase::E_INVAL )
300 : : {
301 [ + - ]: 24249 : m_aFolder.close();
302 [ + - ]: 24249 : isFinalChanged();
303 : 24249 : return ( m_nIsOpen = false );
304 : : }
305 [ + - ]: 10386 : else if( err == osl::FileBase::E_None )
306 : : {
307 : : aRow = m_pMyShell->getv(
308 [ + - ][ + - ]: 10386 : this, m_sProperty, m_aDirIte, aUnqPath, IsRegular );
309 : :
310 [ + + ][ + + ]: 10386 : if( m_nOpenMode == ucb::OpenMode::DOCUMENTS && IsRegular )
311 : : {
312 [ + - ]: 906 : osl::MutexGuard aGuard( m_aMutex );
313 [ + - ]: 906 : m_aItems.push_back( aRow );
314 : : m_aIdents.push_back(
315 [ + - ]: 906 : uno::Reference< ucb::XContentIdentifier >() );
316 [ + - ]: 906 : m_aUnqPath.push_back( aUnqPath );
317 [ + - ]: 906 : rowCountChanged();
318 [ + - ]: 906 : return true;
319 : :
320 : : }
321 [ + + ][ + - ]: 9480 : else if( m_nOpenMode == ucb::OpenMode::DOCUMENTS && ! IsRegular )
322 : : {
323 : 16 : continue;
324 : : }
325 [ + + ][ + + ]: 9464 : else if( m_nOpenMode == ucb::OpenMode::FOLDERS && ! IsRegular )
326 : : {
327 [ + - ]: 1000 : osl::MutexGuard aGuard( m_aMutex );
328 [ + - ]: 1000 : m_aItems.push_back( aRow );
329 : : m_aIdents.push_back(
330 [ + - ]: 1000 : uno::Reference< ucb::XContentIdentifier >() );
331 [ + - ]: 1000 : m_aUnqPath.push_back( aUnqPath );
332 [ + - ]: 1000 : rowCountChanged();
333 [ + - ]: 1000 : return true;
334 : : }
335 [ + + ][ + - ]: 8464 : else if( m_nOpenMode == ucb::OpenMode::FOLDERS && IsRegular )
336 : : {
337 : 884 : continue;
338 : : }
339 : : else
340 : : {
341 [ + - ]: 7580 : osl::MutexGuard aGuard( m_aMutex );
342 [ + - ]: 7580 : m_aItems.push_back( aRow );
343 : : m_aIdents.push_back(
344 [ + - ]: 7580 : uno::Reference< ucb::XContentIdentifier >() );
345 [ + - ]: 7580 : m_aUnqPath.push_back( aUnqPath );
346 [ + - ]: 7580 : rowCountChanged();
347 [ + - ]: 7580 : return true;
348 : : }
349 : : }
350 : : else // error fetching anything
351 : : {
352 [ # # ]: 0 : throw sdbc::SQLException( ::rtl::OUString( OSL_LOG_PREFIX ), uno::Reference< uno::XInterface >(), ::rtl::OUString(), 0, uno::Any() );
353 : : }
354 [ + - ]: 34197 : }
355 : : }
356 : :
357 : :
358 : :
359 : :
360 : :
361 : : sal_Bool SAL_CALL
362 : 33177 : XResultSet_impl::next(
363 : : void )
364 : : throw( sdbc::SQLException,
365 : : uno::RuntimeException )
366 : : {
367 : : sal_Bool test;
368 [ - + ]: 33177 : if( ++m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) ) test = true;
369 : : else
370 : 33177 : test = OneMore();
371 : 33177 : return test;
372 : : }
373 : :
374 : :
375 : : sal_Bool SAL_CALL
376 : 0 : XResultSet_impl::isBeforeFirst(
377 : : void )
378 : : throw( sdbc::SQLException,
379 : : uno::RuntimeException )
380 : : {
381 : 0 : return m_nRow == -1;
382 : : }
383 : :
384 : :
385 : : sal_Bool SAL_CALL
386 : 0 : XResultSet_impl::isAfterLast(
387 : : void )
388 : : throw( sdbc::SQLException,
389 : : uno::RuntimeException )
390 : : {
391 : 0 : return m_nRow >= sal::static_int_cast<sal_Int32>(m_aItems.size()); // Cannot happen, if m_aFolder.isOpen()
392 : : }
393 : :
394 : :
395 : : sal_Bool SAL_CALL
396 : 0 : XResultSet_impl::isFirst(
397 : : void )
398 : : throw( sdbc::SQLException,
399 : : uno::RuntimeException )
400 : : {
401 : 0 : return m_nRow == 0;
402 : : }
403 : :
404 : :
405 : : sal_Bool SAL_CALL
406 : 0 : XResultSet_impl::isLast(
407 : : void )
408 : : throw( sdbc::SQLException,
409 : : uno::RuntimeException)
410 : : {
411 [ # # ]: 0 : if( m_nRow == sal::static_int_cast<sal_Int32>(m_aItems.size()) - 1 )
412 : 0 : return ! OneMore();
413 : : else
414 : 0 : return false;
415 : : }
416 : :
417 : :
418 : : void SAL_CALL
419 : 250 : XResultSet_impl::beforeFirst(
420 : : void )
421 : : throw( sdbc::SQLException,
422 : : uno::RuntimeException)
423 : : {
424 : 250 : m_nRow = -1;
425 : 250 : }
426 : :
427 : :
428 : : void SAL_CALL
429 : 0 : XResultSet_impl::afterLast(
430 : : void )
431 : : throw( sdbc::SQLException,
432 : : uno::RuntimeException )
433 : : {
434 : 0 : m_nRow = sal::static_int_cast<sal_Int32>(m_aItems.size());
435 [ # # ]: 0 : while( OneMore() )
436 : 0 : ++m_nRow;
437 : 0 : }
438 : :
439 : :
440 : : sal_Bool SAL_CALL
441 : 84 : XResultSet_impl::first(
442 : : void )
443 : : throw( sdbc::SQLException,
444 : : uno::RuntimeException)
445 : : {
446 : 84 : m_nRow = -1;
447 : 84 : return next();
448 : : }
449 : :
450 : :
451 : : sal_Bool SAL_CALL
452 : 0 : XResultSet_impl::last(
453 : : void )
454 : : throw( sdbc::SQLException,
455 : : uno::RuntimeException )
456 : : {
457 : 0 : m_nRow = sal::static_int_cast<sal_Int32>(m_aItems.size()) - 1;
458 [ # # ]: 0 : while( OneMore() )
459 : 0 : ++m_nRow;
460 : 0 : return true;
461 : : }
462 : :
463 : :
464 : : sal_Int32 SAL_CALL
465 : 0 : XResultSet_impl::getRow(
466 : : void )
467 : : throw( sdbc::SQLException,
468 : : uno::RuntimeException)
469 : : {
470 : : // Test, whether behind last row
471 [ # # ][ # # ]: 0 : if( -1 == m_nRow || m_nRow >= sal::static_int_cast<sal_Int32>(m_aItems.size()) )
[ # # ]
472 : 0 : return 0;
473 : : else
474 : 0 : return m_nRow+1;
475 : : }
476 : :
477 : :
478 : :
479 : 2072 : sal_Bool SAL_CALL XResultSet_impl::absolute( sal_Int32 row )
480 : : throw( sdbc::SQLException, uno::RuntimeException)
481 : : {
482 [ + - ]: 2072 : if( row >= 0 )
483 : : {
484 : 2072 : m_nRow = row - 1;
485 [ + + ]: 2072 : if( row >= sal::static_int_cast<sal_Int32>(m_aItems.size()) )
486 [ + + ][ + + ]: 1196 : while( row-- && OneMore() )
[ + + ]
487 : : ;
488 : : }
489 : : else
490 : : {
491 : 0 : last();
492 : 0 : m_nRow += ( row + 1 );
493 [ # # ]: 0 : if( m_nRow < -1 )
494 : 0 : m_nRow = -1;
495 : : }
496 : :
497 [ + - ][ + + ]: 2072 : return 0<= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size());
498 : : }
499 : :
500 : :
501 : :
502 : :
503 : : sal_Bool SAL_CALL
504 : 0 : XResultSet_impl::relative(
505 : : sal_Int32 row )
506 : : throw( sdbc::SQLException,
507 : : uno::RuntimeException)
508 : : {
509 [ # # ][ # # ]: 0 : if( isAfterLast() || isBeforeFirst() )
[ # # ]
510 [ # # ]: 0 : throw sdbc::SQLException( ::rtl::OUString( OSL_LOG_PREFIX ), uno::Reference< uno::XInterface >(), ::rtl::OUString(), 0, uno::Any() );
511 [ # # ]: 0 : if( row > 0 )
512 [ # # ]: 0 : while( row-- ) next();
513 [ # # ]: 0 : else if( row < 0 )
514 [ # # ][ # # ]: 0 : while( row++ && m_nRow > - 1 ) previous();
[ # # ]
515 : :
516 [ # # ][ # # ]: 0 : return 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size());
517 : : }
518 : :
519 : :
520 : :
521 : : sal_Bool SAL_CALL
522 : 0 : XResultSet_impl::previous(
523 : : void )
524 : : throw( sdbc::SQLException,
525 : : uno::RuntimeException)
526 : : {
527 [ # # ]: 0 : if( m_nRow > sal::static_int_cast<sal_Int32>(m_aItems.size()) )
528 : 0 : m_nRow = sal::static_int_cast<sal_Int32>(m_aItems.size()); // Correct Handling of afterLast
529 [ # # ]: 0 : if( 0 <= m_nRow ) -- m_nRow;
530 : :
531 [ # # ][ # # ]: 0 : return 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size());
532 : : }
533 : :
534 : :
535 : : void SAL_CALL
536 : 0 : XResultSet_impl::refreshRow(
537 : : void )
538 : : throw( sdbc::SQLException,
539 : : uno::RuntimeException)
540 : : {
541 : : // get the row from the filesystem
542 : 0 : return;
543 : : }
544 : :
545 : :
546 : : sal_Bool SAL_CALL
547 : 0 : XResultSet_impl::rowUpdated(
548 : : void )
549 : : throw( sdbc::SQLException,
550 : : uno::RuntimeException )
551 : : {
552 : 0 : return false;
553 : : }
554 : :
555 : : sal_Bool SAL_CALL
556 : 0 : XResultSet_impl::rowInserted(
557 : : void )
558 : : throw( sdbc::SQLException,
559 : : uno::RuntimeException )
560 : : {
561 : 0 : return false;
562 : : }
563 : :
564 : : sal_Bool SAL_CALL
565 : 0 : XResultSet_impl::rowDeleted(
566 : : void )
567 : : throw( sdbc::SQLException,
568 : : uno::RuntimeException )
569 : : {
570 : 0 : return false;
571 : : }
572 : :
573 : :
574 : : uno::Reference< uno::XInterface > SAL_CALL
575 : 0 : XResultSet_impl::getStatement(
576 : : void )
577 : : throw( sdbc::SQLException,
578 : : uno::RuntimeException )
579 : : {
580 : 0 : return uno::Reference< uno::XInterface >();
581 : : }
582 : :
583 : :
584 : : // XCloseable
585 : :
586 : : void SAL_CALL
587 : 0 : XResultSet_impl::close(
588 : : void )
589 : : throw( sdbc::SQLException,
590 : : uno::RuntimeException)
591 : : {
592 [ # # ]: 0 : if( m_nIsOpen )
593 : : {
594 [ # # ]: 0 : m_aFolder.close();
595 [ # # ]: 0 : isFinalChanged();
596 [ # # ]: 0 : osl::MutexGuard aGuard( m_aMutex );
597 [ # # ]: 0 : m_nIsOpen = false;
598 : : }
599 : 0 : }
600 : :
601 : :
602 : :
603 : : rtl::OUString SAL_CALL
604 : 738 : XResultSet_impl::queryContentIdentifierString(
605 : : void )
606 : : throw( uno::RuntimeException )
607 : : {
608 : : uno::Reference< ucb::XContentIdentifier > xContentId
609 [ + - ]: 738 : = queryContentIdentifier();
610 : :
611 [ + - ]: 738 : if( xContentId.is() )
612 [ + - ][ + - ]: 738 : return xContentId->getContentIdentifier();
613 : : else
614 : 738 : return rtl::OUString();
615 : : }
616 : :
617 : :
618 : : uno::Reference< ucb::XContentIdentifier > SAL_CALL
619 : 800 : XResultSet_impl::queryContentIdentifier(
620 : : void )
621 : : throw( uno::RuntimeException )
622 : : {
623 [ + - ][ + - ]: 800 : if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
[ + - ]
624 : : {
625 [ + - ]: 800 : if( ! m_aIdents[m_nRow].is() )
626 : : {
627 : : FileContentIdentifier* p
628 : : = new FileContentIdentifier( m_pMyShell,
629 [ + - ]: 800 : m_aUnqPath[ m_nRow ] );
630 [ + - ][ + - ]: 800 : m_aIdents[m_nRow] = uno::Reference< ucb::XContentIdentifier >(p);
631 : : }
632 : 800 : return m_aIdents[m_nRow];
633 : : }
634 : 800 : return uno::Reference< ucb::XContentIdentifier >();
635 : : }
636 : :
637 : :
638 : : uno::Reference< ucb::XContent > SAL_CALL
639 : 62 : XResultSet_impl::queryContent(
640 : : void )
641 : : throw( uno::RuntimeException )
642 : : {
643 [ + - ][ + - ]: 62 : if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
[ + - ]
644 [ + - ]: 62 : return m_pMyShell->m_pProvider->queryContent( queryContentIdentifier() );
645 : : else
646 : 62 : return uno::Reference< ucb::XContent >();
647 : : }
648 : :
649 : :
650 : : // XDynamicResultSet
651 : :
652 : :
653 : : // virtual
654 : : uno::Reference< sdbc::XResultSet > SAL_CALL
655 : 24305 : XResultSet_impl::getStaticResultSet()
656 : : throw( ucb::ListenerAlreadySetException,
657 : : uno::RuntimeException )
658 : : {
659 [ + - ]: 24305 : osl::MutexGuard aGuard( m_aMutex );
660 : :
661 [ - + ]: 24305 : if ( m_xListener.is() )
662 [ # # ]: 0 : throw ucb::ListenerAlreadySetException( ::rtl::OUString( OSL_LOG_PREFIX ), uno::Reference< uno::XInterface >() );
663 : :
664 [ + - ][ + - ]: 24305 : return uno::Reference< sdbc::XResultSet >( this );
665 : : }
666 : :
667 : : //=========================================================================
668 : : // virtual
669 : : void SAL_CALL
670 : 0 : XResultSet_impl::setListener(
671 : : const uno::Reference< ucb::XDynamicResultSetListener >& Listener )
672 : : throw( ucb::ListenerAlreadySetException,
673 : : uno::RuntimeException )
674 : : {
675 [ # # ]: 0 : osl::ClearableMutexGuard aGuard( m_aMutex );
676 : :
677 [ # # ]: 0 : if ( m_xListener.is() )
678 [ # # ]: 0 : throw ucb::ListenerAlreadySetException( ::rtl::OUString( OSL_LOG_PREFIX ), uno::Reference< uno::XInterface >() );
679 : :
680 [ # # ]: 0 : m_xListener = Listener;
681 : :
682 : : //////////////////////////////////////////////////////////////////////
683 : : // Create "welcome event" and send it to listener.
684 : : //////////////////////////////////////////////////////////////////////
685 : :
686 : : // Note: We only have the implementation for a static result set at the
687 : : // moment (src590). The dynamic result sets passed to the listener
688 : : // are a fake. This implementation will never call "notify" at the
689 : : // listener to propagate any changes!!!
690 : :
691 : 0 : uno::Any aInfo;
692 : : aInfo <<= ucb::WelcomeDynamicResultSetStruct( this, /* "old" */
693 [ # # ][ # # ]: 0 : this /* "new" */ );
[ # # ][ # # ]
[ # # ]
694 : :
695 [ # # ]: 0 : uno::Sequence< ucb::ListAction > aActions( 1 );
696 : : aActions.getArray()[ 0 ] = ucb::ListAction( 0, // Position; not used
697 : : 0, // Count; not used
698 : : ucb::ListActionType::WELCOME,
699 [ # # ]: 0 : aInfo );
700 [ # # ]: 0 : aGuard.clear();
701 : :
702 [ # # ]: 0 : Listener->notify(
703 : : ucb::ListEvent(
704 [ # # ][ # # ]: 0 : static_cast< cppu::OWeakObject * >( this ), aActions ) );
[ # # ][ # # ]
[ # # ][ # # ]
705 : 0 : }
706 : :
707 : : //=========================================================================
708 : : // virtual
709 : : void SAL_CALL
710 : 0 : XResultSet_impl::connectToCache(
711 : : const uno::Reference< ucb::XDynamicResultSet > & xCache )
712 : : throw( ucb::ListenerAlreadySetException,
713 : : ucb::AlreadyInitializedException,
714 : : ucb::ServiceNotFoundException,
715 : : uno::RuntimeException )
716 : : {
717 : : uno::Reference< lang::XMultiServiceFactory > mxSMgr
718 : 0 : = m_pMyShell->m_xMultiServiceFactory;
719 : :
720 [ # # ]: 0 : if( m_xListener.is() )
721 [ # # ]: 0 : throw ucb::ListenerAlreadySetException( ::rtl::OUString( OSL_LOG_PREFIX ), uno::Reference< uno::XInterface >() );
722 [ # # ]: 0 : if( m_bStatic )
723 [ # # ]: 0 : throw ucb::ListenerAlreadySetException( ::rtl::OUString( OSL_LOG_PREFIX ), uno::Reference< uno::XInterface >() );
724 : :
725 : : uno::Reference< ucb::XSourceInitialization > xTarget(
726 [ # # ]: 0 : xCache, uno::UNO_QUERY );
727 [ # # ][ # # ]: 0 : if( xTarget.is() && mxSMgr.is() )
[ # # ]
728 : : {
729 : 0 : uno::Reference< ucb::XCachedDynamicResultSetStubFactory > xStubFactory;
730 : : try
731 : : {
732 : : xStubFactory
733 : : = uno::Reference< ucb::XCachedDynamicResultSetStubFactory >(
734 [ # # ]: 0 : mxSMgr->createInstance(
735 : : rtl::OUString(
736 : 0 : "com.sun.star.ucb.CachedDynamicResultSetStubFactory" ) ),
737 [ # # ][ # # ]: 0 : uno::UNO_QUERY );
[ # # ][ # # ]
738 : : }
739 [ # # ]: 0 : catch ( uno::Exception const & )
740 : : {
741 : : }
742 : :
743 [ # # ]: 0 : if( xStubFactory.is() )
744 : : {
745 [ # # ]: 0 : xStubFactory->connectToCache(
746 [ # # ][ # # ]: 0 : this, xCache,m_sSortingInfo, NULL );
[ # # ]
747 : 0 : return;
748 [ # # ]: 0 : }
749 : : }
750 [ # # ]: 0 : throw ucb::ServiceNotFoundException( ::rtl::OUString( OSL_LOG_PREFIX ), uno::Reference< uno::XInterface >() );
751 : : }
752 : :
753 : : //=========================================================================
754 : : // virtual
755 : : sal_Int16 SAL_CALL
756 : 0 : XResultSet_impl::getCapabilities()
757 : : throw( uno::RuntimeException )
758 : : {
759 : : // Never set ucb::ContentResultSetCapability::SORTED
760 : : // - Underlying content cannot provide sorted data...
761 : 0 : return 0;
762 : : }
763 : :
764 : : // XResultSetMetaDataSupplier
765 : : uno::Reference< sdbc::XResultSetMetaData > SAL_CALL
766 : 138 : XResultSet_impl::getMetaData(
767 : : void )
768 : : throw( sdbc::SQLException,
769 : : uno::RuntimeException )
770 : : {
771 [ + - ]: 138 : for ( sal_Int32 n = 0; n < m_sProperty.getLength(); ++n )
772 : : {
773 [ + - ]: 138 : if ( m_sProperty.getConstArray()[ n ].Name.compareToAscii( "Title" )
774 : : == 0 )
775 : : {
776 : : // @@@ #82177# - Determine correct value!
777 : 138 : sal_Bool bCaseSensitiveChildren = sal_False;
778 : :
779 : : std::vector< ::ucbhelper::ResultSetColumnData >
780 [ + - ]: 138 : aColumnData( m_sProperty.getLength() );
781 : 138 : aColumnData[ n ].isCaseSensitive = bCaseSensitiveChildren;
782 : :
783 : : ::ucbhelper::ResultSetMetaData* p =
784 : : new ::ucbhelper::ResultSetMetaData(
785 : : m_pMyShell->m_xMultiServiceFactory,
786 : : m_sProperty,
787 [ + - ]: 138 : aColumnData );
788 [ + - ][ + - ]: 138 : return uno::Reference< sdbc::XResultSetMetaData >( p );
789 : : }
790 : : }
791 : :
792 : : ::ucbhelper::ResultSetMetaData* p =
793 : : new ::ucbhelper::ResultSetMetaData(
794 [ # # ]: 0 : m_pMyShell->m_xMultiServiceFactory, m_sProperty );
795 [ # # ]: 138 : return uno::Reference< sdbc::XResultSetMetaData >( p );
796 : : }
797 : :
798 : :
799 : :
800 : : // XPropertySet
801 : : uno::Reference< beans::XPropertySetInfo > SAL_CALL
802 : 0 : XResultSet_impl::getPropertySetInfo()
803 : : throw( uno::RuntimeException)
804 : : {
805 : :
806 [ # # ]: 0 : uno::Sequence< beans::Property > seq(2);
807 [ # # ]: 0 : seq[0].Name = rtl::OUString("RowCount");
808 [ # # ]: 0 : seq[0].Handle = -1;
809 [ # # ][ # # ]: 0 : seq[0].Type = getCppuType( static_cast< sal_Int32* >(0) );
810 [ # # ]: 0 : seq[0].Attributes = beans::PropertyAttribute::READONLY;
811 : :
812 [ # # ]: 0 : seq[0].Name = rtl::OUString("IsRowCountFinal");
813 [ # # ]: 0 : seq[0].Handle = -1;
814 [ # # ][ # # ]: 0 : seq[0].Type = getCppuType( static_cast< sal_Bool* >(0) );
815 [ # # ]: 0 : seq[0].Attributes = beans::PropertyAttribute::READONLY;
816 : :
817 : : XPropertySetInfo_impl* p = new XPropertySetInfo_impl( m_pMyShell,
818 [ # # ]: 0 : seq );
819 [ # # ][ # # ]: 0 : return uno::Reference< beans::XPropertySetInfo > ( p );
[ # # ]
820 : : }
821 : :
822 : :
823 : :
824 : 0 : void SAL_CALL XResultSet_impl::setPropertyValue(
825 : : const rtl::OUString& aPropertyName, const uno::Any& )
826 : : throw( beans::UnknownPropertyException,
827 : : beans::PropertyVetoException,
828 : : lang::IllegalArgumentException,
829 : : lang::WrappedTargetException,
830 : : uno::RuntimeException)
831 : : {
832 [ # # # # ]: 0 : if( aPropertyName == rtl::OUString("IsRowCountFinal") ||
[ # # ][ # # ]
[ # # ]
833 [ # # ][ # # ]: 0 : aPropertyName == rtl::OUString("RowCount") )
834 : 0 : return;
835 [ # # ]: 0 : throw beans::UnknownPropertyException( ::rtl::OUString( OSL_LOG_PREFIX ), uno::Reference< uno::XInterface >() );
836 : : }
837 : :
838 : :
839 : 0 : uno::Any SAL_CALL XResultSet_impl::getPropertyValue(
840 : : const rtl::OUString& PropertyName )
841 : : throw( beans::UnknownPropertyException,
842 : : lang::WrappedTargetException,
843 : : uno::RuntimeException)
844 : : {
845 [ # # ]: 0 : if( PropertyName == rtl::OUString("IsRowCountFinal") )
846 : : {
847 : 0 : uno::Any aAny;
848 [ # # ]: 0 : aAny <<= m_bRowCountFinal;
849 : 0 : return aAny;
850 : : }
851 [ # # ]: 0 : else if ( PropertyName == rtl::OUString("RowCount") )
852 : : {
853 : 0 : uno::Any aAny;
854 : 0 : sal_Int32 count = sal::static_int_cast<sal_Int32>(m_aItems.size());
855 [ # # ]: 0 : aAny <<= count;
856 : 0 : return aAny;
857 : : }
858 : : else
859 [ # # ]: 0 : throw beans::UnknownPropertyException( ::rtl::OUString( OSL_LOG_PREFIX ), uno::Reference< uno::XInterface >() );
860 : : }
861 : :
862 : :
863 : 0 : void SAL_CALL XResultSet_impl::addPropertyChangeListener(
864 : : const rtl::OUString& aPropertyName,
865 : : const uno::Reference< beans::XPropertyChangeListener >& xListener )
866 : : throw( beans::UnknownPropertyException,
867 : : lang::WrappedTargetException,
868 : : uno::RuntimeException)
869 : : {
870 [ # # ]: 0 : if( aPropertyName == rtl::OUString("IsRowCountFinal") )
871 : : {
872 [ # # ]: 0 : osl::MutexGuard aGuard( m_aMutex );
873 [ # # ]: 0 : if ( ! m_pIsFinalListeners )
874 : : m_pIsFinalListeners =
875 [ # # ]: 0 : new cppu::OInterfaceContainerHelper( m_aEventListenerMutex );
876 : :
877 [ # # ][ # # ]: 0 : m_pIsFinalListeners->addInterface( xListener );
878 : : }
879 [ # # ]: 0 : else if ( aPropertyName == rtl::OUString("RowCount") )
880 : : {
881 [ # # ]: 0 : osl::MutexGuard aGuard( m_aMutex );
882 [ # # ]: 0 : if ( ! m_pRowCountListeners )
883 : : m_pRowCountListeners =
884 [ # # ]: 0 : new cppu::OInterfaceContainerHelper( m_aEventListenerMutex );
885 [ # # ][ # # ]: 0 : m_pRowCountListeners->addInterface( xListener );
886 : : }
887 : : else
888 [ # # ]: 0 : throw beans::UnknownPropertyException( ::rtl::OUString( OSL_LOG_PREFIX ), uno::Reference< uno::XInterface >() );
889 : 0 : }
890 : :
891 : :
892 : 0 : void SAL_CALL XResultSet_impl::removePropertyChangeListener(
893 : : const rtl::OUString& aPropertyName,
894 : : const uno::Reference< beans::XPropertyChangeListener >& aListener )
895 : : throw( beans::UnknownPropertyException,
896 : : lang::WrappedTargetException,
897 : : uno::RuntimeException)
898 : : {
899 [ # # ][ # # ]: 0 : if( aPropertyName == rtl::OUString("IsRowCountFinal") &&
[ # # ][ # # ]
[ # # ]
900 : : m_pIsFinalListeners )
901 : : {
902 [ # # ]: 0 : osl::MutexGuard aGuard( m_aMutex );
903 [ # # ][ # # ]: 0 : m_pIsFinalListeners->removeInterface( aListener );
904 : : }
905 [ # # ][ # # ]: 0 : else if ( aPropertyName == rtl::OUString("RowCount") &&
[ # # ][ # # ]
[ # # ]
906 : : m_pRowCountListeners )
907 : : {
908 [ # # ]: 0 : osl::MutexGuard aGuard( m_aMutex );
909 : :
910 [ # # ][ # # ]: 0 : m_pRowCountListeners->removeInterface( aListener );
911 : : }
912 : : else
913 [ # # ]: 0 : throw beans::UnknownPropertyException( ::rtl::OUString( OSL_LOG_PREFIX ), uno::Reference< uno::XInterface >() );
914 : 0 : }
915 : :
916 : 0 : void SAL_CALL XResultSet_impl::addVetoableChangeListener(
917 : : const rtl::OUString&,
918 : : const uno::Reference< beans::XVetoableChangeListener >& )
919 : : throw( beans::UnknownPropertyException,
920 : : lang::WrappedTargetException,
921 : : uno::RuntimeException)
922 : : {
923 : 0 : }
924 : :
925 : :
926 : 0 : void SAL_CALL XResultSet_impl::removeVetoableChangeListener(
927 : : const rtl::OUString&,
928 : : const uno::Reference< beans::XVetoableChangeListener >& )
929 : : throw( beans::UnknownPropertyException,
930 : : lang::WrappedTargetException,
931 : : uno::RuntimeException)
932 : : {
933 : 0 : }
934 : :
935 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|