summaryrefslogtreecommitdiff
path: root/ucb/source/ucp/file/filrset.cxx
blob: 386218254f21e9ad0284f86c54a3bdc90389fd34 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * This file incorporates work covered by the following license notice:
 *
 *   Licensed to the Apache Software Foundation (ASF) under one or more
 *   contributor license agreements. See the NOTICE file distributed
 *   with this work for additional information regarding copyright
 *   ownership. The ASF licenses this file to you under the Apache
 *   License, Version 2.0 (the "License"); you may not use this file
 *   except in compliance with the License. You may obtain a copy of
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
 */

#include <com/sun/star/ucb/WelcomeDynamicResultSetStruct.hpp>
#include "filid.hxx"
#include "shell.hxx"
#include "filprp.hxx"
#include "filrset.hxx"
#include <com/sun/star/ucb/OpenMode.hpp>
#include "prov.hxx"
#include <com/sun/star/uno/Reference.h>

#include <com/sun/star/beans/PropertyAttribute.hpp>
#include <com/sun/star/ucb/ListActionType.hpp>
#include <com/sun/star/ucb/XSourceInitialization.hpp>
#include <com/sun/star/ucb/CachedDynamicResultSetStubFactory.hpp>
#include <ucbhelper/resultsetmetadata.hxx>

using namespace fileaccess;
using namespace com::sun::star;

#if OSL_DEBUG_LEVEL > 0
#define THROW_WHERE SAL_WHERE
#else
#define THROW_WHERE ""
#endif

XResultSet_impl::XResultSet_impl( shell* pMyShell,
                                  const OUString& aUnqPath,
                                  sal_Int32 OpenMode,
                                  const uno::Sequence< beans::Property >& seq,
                                  const uno::Sequence< ucb::NumberedSortingInfo >& seqSort )
    : m_pMyShell( pMyShell )
    , m_xProvider( pMyShell->m_pProvider )
    , m_nRow( -1 )
    , m_nWasNull ( false )
    , m_nOpenMode( OpenMode )
    , m_bRowCountFinal( false )
    , m_aBaseDirectory( aUnqPath )
    , m_aFolder( aUnqPath )
    , m_sProperty( seq )
    , m_sSortingInfo( seqSort )
    , m_pDisposeEventListeners( 0 )
    , m_pRowCountListeners( 0 )
    , m_pIsFinalListeners( 0 )
    , m_bStatic( false )
    , m_nErrorCode( TASKHANDLER_NO_ERROR )
    , m_nMinorErrorCode( TASKHANDLER_NO_ERROR )
{
    osl::FileBase::RC err = m_aFolder.open();
    if(  err != osl::FileBase::E_None )
    {
        m_nIsOpen = false;
        m_aFolder.close();

        m_nErrorCode = TASKHANDLING_OPEN_FOR_DIRECTORYLISTING;
        m_nMinorErrorCode = err;
    }
    else
        m_nIsOpen = true;

    m_pMyShell->registerNotifier( m_aBaseDirectory,this );
}


XResultSet_impl::~XResultSet_impl()
{
    m_pMyShell->deregisterNotifier( m_aBaseDirectory,this );

    if( m_nIsOpen )
        m_aFolder.close();

    delete m_pDisposeEventListeners;
    delete m_pRowCountListeners;
    delete m_pIsFinalListeners;
}








void SAL_CALL
XResultSet_impl::disposing( const lang::EventObject& )
    throw( uno::RuntimeException, std::exception )
{
    // To do, but what
}


void SAL_CALL
XResultSet_impl::addEventListener(
    const uno::Reference< lang::XEventListener >& Listener )
    throw( uno::RuntimeException, std::exception )
{
    osl::MutexGuard aGuard( m_aMutex );

    if ( ! m_pDisposeEventListeners )
        m_pDisposeEventListeners =
            new cppu::OInterfaceContainerHelper( m_aEventListenerMutex );

    m_pDisposeEventListeners->addInterface( Listener );
}


void SAL_CALL
XResultSet_impl::removeEventListener(
    const uno::Reference< lang::XEventListener >& Listener )
    throw( uno::RuntimeException, std::exception )
{
    osl::MutexGuard aGuard( m_aMutex );

    if ( m_pDisposeEventListeners )
        m_pDisposeEventListeners->removeInterface( Listener );
}



void SAL_CALL
XResultSet_impl::dispose()
    throw( uno::RuntimeException, std::exception )
{
    osl::MutexGuard aGuard( m_aMutex );

    lang::EventObject aEvt;
    aEvt.Source = static_cast< lang::XComponent * >( this );

    if ( m_pDisposeEventListeners && m_pDisposeEventListeners->getLength() )
    {
        m_pDisposeEventListeners->disposeAndClear( aEvt );
    }
    if( m_pRowCountListeners && m_pRowCountListeners->getLength() )
    {
        m_pRowCountListeners->disposeAndClear( aEvt );
    }
    if( m_pIsFinalListeners && m_pIsFinalListeners->getLength() )
    {
        m_pIsFinalListeners->disposeAndClear( aEvt );
    }
}



void XResultSet_impl::rowCountChanged()
{
    sal_Int32 aOldValue,aNewValue;
    uno::Sequence< uno::Reference< uno::XInterface > > seq;
    {
        osl::MutexGuard aGuard( m_aMutex );
        if( m_pRowCountListeners )
            seq = m_pRowCountListeners->getElements();
        aNewValue = m_aItems.size();
        aOldValue = aNewValue-1;
    }
    beans::PropertyChangeEvent aEv;
    aEv.PropertyName = "RowCount";
    aEv.Further = false;
    aEv.PropertyHandle = -1;
    aEv.OldValue <<= aOldValue;
    aEv.NewValue <<= aNewValue;
    for( sal_Int32 i = 0; i < seq.getLength(); ++i )
    {
        uno::Reference< beans::XPropertyChangeListener > listener(
            seq[i], uno::UNO_QUERY );
        if( listener.is() )
            listener->propertyChange( aEv );
    }
}


void XResultSet_impl::isFinalChanged()
{
    uno::Sequence< uno::Reference< XInterface > > seq;
    {
        osl::MutexGuard aGuard( m_aMutex );
        if( m_pIsFinalListeners )
            seq = m_pIsFinalListeners->getElements();
        m_bRowCountFinal = true;
    }
    beans::PropertyChangeEvent aEv;
    aEv.PropertyName = "IsRowCountFinal";
    aEv.Further = false;
    aEv.PropertyHandle = -1;
    bool fval = false;
    bool tval = true;
    aEv.OldValue <<= fval;
    aEv.NewValue <<= tval;
    for( sal_Int32 i = 0; i < seq.getLength(); ++i )
    {
        uno::Reference< beans::XPropertyChangeListener > listener(
            seq[i], uno::UNO_QUERY );
        if( listener.is() )
            listener->propertyChange( aEv );
    }
}


bool SAL_CALL
XResultSet_impl::OneMore(
    void )
    throw( sdbc::SQLException,
           uno::RuntimeException )
{
    if( ! m_nIsOpen )
        return false;

    osl::FileBase::RC err;
    bool IsRegular;
    OUString aUnqPath;
    osl::DirectoryItem  m_aDirIte;
    uno::Reference< sdbc::XRow > aRow;

    while( true )
    {
        err = m_aFolder.getNextItem( m_aDirIte );

        if( err == osl::FileBase::E_NOENT || err == osl::FileBase::E_INVAL )
        {
            m_aFolder.close();
            isFinalChanged();
            return ( m_nIsOpen = false );
        }
        else if( err == osl::FileBase::E_None )
        {
            aRow = m_pMyShell->getv(
                this, m_sProperty, m_aDirIte, aUnqPath, IsRegular );

            if( m_nOpenMode == ucb::OpenMode::DOCUMENTS && IsRegular )
            {
                osl::MutexGuard aGuard( m_aMutex );
                m_aItems.push_back( aRow );
                m_aIdents.push_back(
                    uno::Reference< ucb::XContentIdentifier >() );
                m_aUnqPath.push_back( aUnqPath );
                rowCountChanged();
                return true;

            }
            else if( m_nOpenMode == ucb::OpenMode::DOCUMENTS && ! IsRegular )
            {
                continue;
            }
            else if( m_nOpenMode == ucb::OpenMode::FOLDERS && ! IsRegular )
            {
                osl::MutexGuard aGuard( m_aMutex );
                m_aItems.push_back( aRow );
                m_aIdents.push_back(
                    uno::Reference< ucb::XContentIdentifier >() );
                m_aUnqPath.push_back( aUnqPath );
                rowCountChanged();
                return true;
            }
            else if( m_nOpenMode == ucb::OpenMode::FOLDERS && IsRegular )
            {
                continue;
            }
            else
            {
                osl::MutexGuard aGuard( m_aMutex );
                m_aItems.push_back( aRow );
                m_aIdents.push_back(
                    uno::Reference< ucb::XContentIdentifier >() );
                m_aUnqPath.push_back( aUnqPath );
                rowCountChanged();
                return true;
            }
        }
        else  // error fetching anything
        {
            throw sdbc::SQLException( THROW_WHERE, uno::Reference< uno::XInterface >(), OUString(), 0, uno::Any() );
        }
    }
}





sal_Bool SAL_CALL
XResultSet_impl::next(
    void )
    throw( sdbc::SQLException,
           uno::RuntimeException, std::exception )
{
    bool test;
    if( ++m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) ) test = true;
    else
        test = OneMore();
    return test;
}


sal_Bool SAL_CALL
XResultSet_impl::isBeforeFirst(
    void )
    throw( sdbc::SQLException,
           uno::RuntimeException, std::exception )
{
    return m_nRow == -1;
}


sal_Bool SAL_CALL
XResultSet_impl::isAfterLast(
    void )
    throw( sdbc::SQLException,
           uno::RuntimeException, std::exception )
{
    return m_nRow >= sal::static_int_cast<sal_Int32>(m_aItems.size());   // Cannot happen, if m_aFolder.isOpen()
}


sal_Bool SAL_CALL
XResultSet_impl::isFirst(
    void )
    throw( sdbc::SQLException,
           uno::RuntimeException, std::exception )
{
    return m_nRow == 0;
}


sal_Bool SAL_CALL
XResultSet_impl::isLast(
    void  )
    throw( sdbc::SQLException,
           uno::RuntimeException, std::exception)
{
    if( m_nRow ==  sal::static_int_cast<sal_Int32>(m_aItems.size()) - 1 )
        return ! OneMore();
    else
        return false;
}


void SAL_CALL
XResultSet_impl::beforeFirst(
    void  )
    throw( sdbc::SQLException,
           uno::RuntimeException, std::exception)
{
    m_nRow = -1;
}


void SAL_CALL
XResultSet_impl::afterLast(
    void  )
    throw( sdbc::SQLException,
           uno::RuntimeException, std::exception )
{
    m_nRow = sal::static_int_cast<sal_Int32>(m_aItems.size());
    while( OneMore() )
        ++m_nRow;
}


sal_Bool SAL_CALL
XResultSet_impl::first(
    void  )
    throw( sdbc::SQLException,
           uno::RuntimeException, std::exception)
{
    m_nRow = -1;
    return next();
}


sal_Bool SAL_CALL
XResultSet_impl::last(
    void  )
    throw( sdbc::SQLException,
           uno::RuntimeException, std::exception )
{
    m_nRow = sal::static_int_cast<sal_Int32>(m_aItems.size()) - 1;
    while( OneMore() )
        ++m_nRow;
    return true;
}


sal_Int32 SAL_CALL
XResultSet_impl::getRow(
    void )
    throw( sdbc::SQLException,
           uno::RuntimeException, std::exception)
{
    // Test, whether behind last row
    if( -1 == m_nRow || m_nRow >= sal::static_int_cast<sal_Int32>(m_aItems.size()) )
        return 0;
    else
        return m_nRow+1;
}



sal_Bool SAL_CALL XResultSet_impl::absolute( sal_Int32 row )
    throw( sdbc::SQLException, uno::RuntimeException, std::exception)
{
    if( row >= 0 )
    {
        m_nRow = row - 1;
        if( row >= sal::static_int_cast<sal_Int32>(m_aItems.size()) )
            while( row-- && OneMore() )
                ;
    }
    else
    {
        last();
        m_nRow += ( row + 1 );
        if( m_nRow < -1 )
            m_nRow = -1;
    }

    return 0<= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size());
}




sal_Bool SAL_CALL
XResultSet_impl::relative(
    sal_Int32 row )
    throw( sdbc::SQLException,
           uno::RuntimeException, std::exception)
{
    if( isAfterLast() || isBeforeFirst() )
        throw sdbc::SQLException( THROW_WHERE, uno::Reference< uno::XInterface >(), OUString(), 0, uno::Any() );
    if( row > 0 )
        while( row-- ) next();
    else if( row < 0 )
        while( row++ && m_nRow > - 1 ) previous();

    return 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size());
}



sal_Bool SAL_CALL
XResultSet_impl::previous(
    void )
    throw( sdbc::SQLException,
           uno::RuntimeException, std::exception)
{
    if( m_nRow > sal::static_int_cast<sal_Int32>(m_aItems.size()) )
        m_nRow = sal::static_int_cast<sal_Int32>(m_aItems.size());  // Correct Handling of afterLast
    if( 0 <= m_nRow ) -- m_nRow;

    return 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size());
}


void SAL_CALL
XResultSet_impl::refreshRow(
    void )
    throw( sdbc::SQLException,
           uno::RuntimeException, std::exception)
{
    // get the row from the filesystem
    return;
}


sal_Bool SAL_CALL
XResultSet_impl::rowUpdated(
    void )
    throw( sdbc::SQLException,
           uno::RuntimeException, std::exception )
{
    return false;
}

sal_Bool SAL_CALL
XResultSet_impl::rowInserted(
    void  )
    throw( sdbc::SQLException,
           uno::RuntimeException, std::exception )
{
    return false;
}

sal_Bool SAL_CALL
XResultSet_impl::rowDeleted(
    void  )
    throw( sdbc::SQLException,
           uno::RuntimeException, std::exception )
{
    return false;
}


uno::Reference< uno::XInterface > SAL_CALL
XResultSet_impl::getStatement(
    void  )
    throw( sdbc::SQLException,
           uno::RuntimeException, std::exception )
{
    return uno::Reference< uno::XInterface >();
}


// XCloseable

void SAL_CALL
XResultSet_impl::close(
    void )
    throw( sdbc::SQLException,
           uno::RuntimeException, std::exception)
{
    if( m_nIsOpen )
    {
        m_aFolder.close();
        isFinalChanged();
        osl::MutexGuard aGuard( m_aMutex );
        m_nIsOpen = false;
    }
}



OUString SAL_CALL
XResultSet_impl::queryContentIdentifierString(
    void )
    throw( uno::RuntimeException, std::exception )
{
    uno::Reference< ucb::XContentIdentifier > xContentId
        = queryContentIdentifier();

    if( xContentId.is() )
        return xContentId->getContentIdentifier();
    else
        return OUString();
}


uno::Reference< ucb::XContentIdentifier > SAL_CALL
XResultSet_impl::queryContentIdentifier(
    void )
    throw( uno::RuntimeException, std::exception )
{
    if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
    {
        if( ! m_aIdents[m_nRow].is() )
        {
            FileContentIdentifier* p
                = new FileContentIdentifier( m_pMyShell,
                                             m_aUnqPath[  m_nRow ] );
            m_aIdents[m_nRow] = uno::Reference< ucb::XContentIdentifier >(p);
        }
        return m_aIdents[m_nRow];
    }
    return uno::Reference< ucb::XContentIdentifier >();
}


uno::Reference< ucb::XContent > SAL_CALL
XResultSet_impl::queryContent(
    void )
    throw( uno::RuntimeException, std::exception )
{
    if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
        return m_pMyShell->m_pProvider->queryContent( queryContentIdentifier() );
    else
        return uno::Reference< ucb::XContent >();
}


// XDynamicResultSet


// virtual
uno::Reference< sdbc::XResultSet > SAL_CALL
XResultSet_impl::getStaticResultSet()
    throw( ucb::ListenerAlreadySetException,
           uno::RuntimeException, std::exception )
{
    osl::MutexGuard aGuard( m_aMutex );

    if ( m_xListener.is() )
        throw ucb::ListenerAlreadySetException( THROW_WHERE );

    return uno::Reference< sdbc::XResultSet >( this );
}


// virtual
void SAL_CALL
XResultSet_impl::setListener(
    const uno::Reference< ucb::XDynamicResultSetListener >& Listener )
    throw( ucb::ListenerAlreadySetException,
           uno::RuntimeException, std::exception )
{
    osl::ClearableMutexGuard aGuard( m_aMutex );

    if ( m_xListener.is() )
        throw ucb::ListenerAlreadySetException( THROW_WHERE );

    m_xListener = Listener;


    // Create "welcome event" and send it to listener.


    // Note: We only have the implementation for a static result set at the
    //       moment (src590). The dynamic result sets passed to the listener
    //       are a fake. This implementation will never call "notify" at the
    //       listener to propagate any changes!!!

    uno::Any aInfo;
    aInfo <<= ucb::WelcomeDynamicResultSetStruct( this, /* "old" */
                                                  this /* "new" */ );

    uno::Sequence< ucb::ListAction > aActions( 1 );
    aActions.getArray()[ 0 ] = ucb::ListAction( 0, // Position; not used
                                                0, // Count; not used
                                                ucb::ListActionType::WELCOME,
                                                aInfo );
    aGuard.clear();

    Listener->notify(
        ucb::ListEvent(
            static_cast< cppu::OWeakObject * >( this ), aActions ) );
}


// virtual
void SAL_CALL
XResultSet_impl::connectToCache(
    const uno::Reference< ucb::XDynamicResultSet > & xCache )
    throw( ucb::ListenerAlreadySetException,
           ucb::AlreadyInitializedException,
           ucb::ServiceNotFoundException,
           uno::RuntimeException, std::exception )
{
    if( m_xListener.is() )
        throw ucb::ListenerAlreadySetException( THROW_WHERE );
    if( m_bStatic )
        throw ucb::ListenerAlreadySetException( THROW_WHERE );

    uno::Reference< ucb::XSourceInitialization > xTarget(
        xCache, uno::UNO_QUERY );
    if( xTarget.is() && m_pMyShell->m_xContext.is() )
    {
        uno::Reference< ucb::XCachedDynamicResultSetStubFactory > xStubFactory;
        try
        {
            xStubFactory
                = ucb::CachedDynamicResultSetStubFactory::create(
                    m_pMyShell->m_xContext );
        }
        catch ( uno::Exception const & )
        {
        }

        if( xStubFactory.is() )
        {
            xStubFactory->connectToCache(
                this, xCache,m_sSortingInfo, NULL );
            return;
        }
    }
    throw ucb::ServiceNotFoundException( THROW_WHERE );
}


// virtual
sal_Int16 SAL_CALL
XResultSet_impl::getCapabilities()
  throw( uno::RuntimeException, std::exception )
{
    // Never set ucb::ContentResultSetCapability::SORTED
    //  - Underlying content cannot provide sorted data...
    return 0;
}

// XResultSetMetaDataSupplier
uno::Reference< sdbc::XResultSetMetaData > SAL_CALL
XResultSet_impl::getMetaData(
    void )
    throw( sdbc::SQLException,
           uno::RuntimeException, std::exception )
{
    for ( sal_Int32 n = 0; n < m_sProperty.getLength(); ++n )
    {
        if ( m_sProperty.getConstArray()[ n ].Name.equalsAscii( "Title" ) )
        {
            // @@@ #82177# - Determine correct value!
            bool bCaseSensitiveChildren = false;

            std::vector< ::ucbhelper::ResultSetColumnData >
                                    aColumnData( m_sProperty.getLength() );
            aColumnData[ n ].isCaseSensitive = bCaseSensitiveChildren;

            ::ucbhelper::ResultSetMetaData* p =
                new ::ucbhelper::ResultSetMetaData(
                    m_pMyShell->m_xContext,
                    m_sProperty,
                    aColumnData );
            return uno::Reference< sdbc::XResultSetMetaData >( p );
        }
    }

    ::ucbhelper::ResultSetMetaData* p =
            new ::ucbhelper::ResultSetMetaData( m_pMyShell->m_xContext, m_sProperty );
    return uno::Reference< sdbc::XResultSetMetaData >( p );
}



// XPropertySet
uno::Reference< beans::XPropertySetInfo > SAL_CALL
XResultSet_impl::getPropertySetInfo()
    throw( uno::RuntimeException, std::exception)
{

    uno::Sequence< beans::Property > seq(2);
    seq[0].Name = "RowCount";
    seq[0].Handle = -1;
    seq[0].Type = cppu::UnoType<sal_Int32>::get();
    seq[0].Attributes = beans::PropertyAttribute::READONLY;

    seq[0].Name = "IsRowCountFinal";
    seq[0].Handle = -1;
    seq[0].Type = cppu::UnoType<sal_Bool>::get();
    seq[0].Attributes = beans::PropertyAttribute::READONLY;

    XPropertySetInfo_impl* p = new XPropertySetInfo_impl( m_pMyShell,
                                                          seq );
    return uno::Reference< beans::XPropertySetInfo > ( p );
}



void SAL_CALL XResultSet_impl::setPropertyValue(
    const OUString& aPropertyName, const uno::Any& )
    throw( beans::UnknownPropertyException,
           beans::PropertyVetoException,
           lang::IllegalArgumentException,
           lang::WrappedTargetException,
           uno::RuntimeException, std::exception)
{
    if( aPropertyName == "IsRowCountFinal" ||
        aPropertyName == "RowCount" )
        return;
    throw beans::UnknownPropertyException( THROW_WHERE );
}


uno::Any SAL_CALL XResultSet_impl::getPropertyValue(
    const OUString& PropertyName )
    throw( beans::UnknownPropertyException,
           lang::WrappedTargetException,
           uno::RuntimeException, std::exception)
{
    if( PropertyName == "IsRowCountFinal" )
    {
        uno::Any aAny;
        aAny <<= m_bRowCountFinal;
        return aAny;
    }
    else if ( PropertyName == "RowCount" )
    {
        uno::Any aAny;
        sal_Int32 count = sal::static_int_cast<sal_Int32>(m_aItems.size());
        aAny <<= count;
        return aAny;
    }
    else
        throw beans::UnknownPropertyException( THROW_WHERE );
}


void SAL_CALL XResultSet_impl::addPropertyChangeListener(
    const OUString& aPropertyName,
    const uno::Reference< beans::XPropertyChangeListener >& xListener )
    throw( beans::UnknownPropertyException,
           lang::WrappedTargetException,
           uno::RuntimeException, std::exception)
{
    if( aPropertyName == "IsRowCountFinal" )
    {
        osl::MutexGuard aGuard( m_aMutex );
        if ( ! m_pIsFinalListeners )
            m_pIsFinalListeners =
                new cppu::OInterfaceContainerHelper( m_aEventListenerMutex );

        m_pIsFinalListeners->addInterface( xListener );
    }
    else if ( aPropertyName == "RowCount" )
    {
        osl::MutexGuard aGuard( m_aMutex );
        if ( ! m_pRowCountListeners )
            m_pRowCountListeners =
                new cppu::OInterfaceContainerHelper( m_aEventListenerMutex );
        m_pRowCountListeners->addInterface( xListener );
    }
    else
        throw beans::UnknownPropertyException( THROW_WHERE );
}


void SAL_CALL XResultSet_impl::removePropertyChangeListener(
    const OUString& aPropertyName,
    const uno::Reference< beans::XPropertyChangeListener >& aListener )
    throw( beans::UnknownPropertyException,
           lang::WrappedTargetException,
           uno::RuntimeException, std::exception)
{
    if( aPropertyName == "IsRowCountFinal" &&
        m_pIsFinalListeners )
    {
        osl::MutexGuard aGuard( m_aMutex );
        m_pIsFinalListeners->removeInterface( aListener );
    }
    else if ( aPropertyName == "RowCount" &&
              m_pRowCountListeners )
    {
        osl::MutexGuard aGuard( m_aMutex );

        m_pRowCountListeners->removeInterface( aListener );
    }
    else
        throw beans::UnknownPropertyException( THROW_WHERE );
}

void SAL_CALL XResultSet_impl::addVetoableChangeListener(
    const OUString&,
    const uno::Reference< beans::XVetoableChangeListener >& )
    throw( beans::UnknownPropertyException,
           lang::WrappedTargetException,
           uno::RuntimeException, std::exception)
{
}


void SAL_CALL XResultSet_impl::removeVetoableChangeListener(
    const OUString&,
    const uno::Reference< beans::XVetoableChangeListener >& )
    throw( beans::UnknownPropertyException,
           lang::WrappedTargetException,
           uno::RuntimeException, std::exception)
{
}

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */