Coverage Report

Created: 2026-09-28 10:59

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/ucbhelper/source/provider/resultset.cxx
Line
Count
Source
1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
/*
3
 * This file is part of the LibreOffice project.
4
 *
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/.
8
 *
9
 * This file incorporates work covered by the following license notice:
10
 *
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 .
18
 */
19
20
#include <memory>
21
#include <mutex>
22
#include <comphelper/interfacecontainer4.hxx>
23
#include <comphelper/multiinterfacecontainer4.hxx>
24
#include <cppuhelper/queryinterface.hxx>
25
#include <com/sun/star/beans/PropertyAttribute.hpp>
26
#include <com/sun/star/sdbc/SQLException.hpp>
27
#include <rtl/ref.hxx>
28
#include <ucbhelper/resultset.hxx>
29
#include <ucbhelper/resultsetmetadata.hxx>
30
#include <ucbhelper/macros.hxx>
31
#include <utility>
32
#include <osl/diagnose.h>
33
34
using namespace com::sun::star;
35
36
37
namespace ucbhelper_impl
38
{
39
40
namespace {
41
42
struct PropertyInfo
43
{
44
    OUString    aName;
45
    sal_Int32   nHandle;
46
    sal_Int16   nAttributes;
47
    const uno::Type& (*pGetCppuType)();
48
};
49
50
}
51
52
static const uno::Type& sal_Int32_getCppuType()
53
0
{
54
0
    return cppu::UnoType<sal_Int32>::get();
55
0
}
56
57
static const uno::Type& sal_Bool_getCppuType()
58
0
{
59
0
    return cppu::UnoType<bool>::get();
60
0
}
61
62
constexpr PropertyInfo aPropertyTable[] =
63
{
64
    { u"IsRowCountFinal"_ustr,
65
      1000,
66
      beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY,
67
      &sal_Bool_getCppuType
68
    },
69
    { u"RowCount"_ustr,
70
      1001,
71
      beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY,
72
      &sal_Int32_getCppuType
73
    },
74
    { u""_ustr,
75
      0,
76
      0,
77
      nullptr
78
    }
79
};
80
81
0
#define RESULTSET_PROPERTY_COUNT 2
82
83
84
85
namespace {
86
87
class PropertySetInfo :
88
        public cppu::OWeakObject,
89
        public lang::XTypeProvider,
90
        public beans::XPropertySetInfo
91
{
92
    uno::Sequence< beans::Property >  m_aProps;
93
94
private:
95
    bool queryProperty(
96
        std::u16string_view aName, beans::Property& rProp ) const;
97
98
public:
99
    PropertySetInfo(
100
        const PropertyInfo* pProps,
101
        sal_Int32 nProps );
102
103
    // XInterface
104
    virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override;
105
    virtual void SAL_CALL acquire()
106
        noexcept override;
107
    virtual void SAL_CALL release()
108
        noexcept override;
109
110
    // XTypeProvider
111
    virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override;
112
    virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override;
113
114
    // XPropertySetInfo
115
    virtual uno::Sequence< beans::Property > SAL_CALL getProperties() override;
116
    virtual beans::Property SAL_CALL getPropertyByName(
117
            const OUString& aName ) override;
118
    virtual sal_Bool SAL_CALL hasPropertyByName( const OUString& Name ) override;
119
};
120
121
}
122
123
typedef comphelper::OMultiTypeInterfaceContainerHelperVar4<OUString, css::beans::XPropertyChangeListener>
124
    PropertyChangeListeners;
125
126
} // namespace ucbhelper_impl
127
128
using namespace ucbhelper_impl;
129
130
namespace ucbhelper
131
{
132
133
134
// struct ResultSet_Impl.
135
136
137
struct ResultSet_Impl
138
{
139
    uno::Reference< uno::XComponentContext >        m_xContext;
140
    uno::Reference< css::ucb::XCommandEnvironment > m_xEnv;
141
    rtl::Reference< PropertySetInfo >               m_xPropSetInfo;
142
    rtl::Reference< ResultSetMetaData >             m_xMetaData;
143
    uno::Sequence< beans::Property >                m_aProperties;
144
    rtl::Reference< ResultSetDataSupplier >         m_xDataSupplier;
145
    std::mutex                          m_aMutex;
146
    comphelper::OInterfaceContainerHelper4<lang::XEventListener> m_aDisposeEventListeners;
147
    std::unique_ptr<PropertyChangeListeners>        m_pPropertyChangeListeners;
148
    sal_Int32                           m_nPos;
149
    bool                            m_bWasNull;
150
    bool                            m_bAfterLast;
151
152
    inline ResultSet_Impl(
153
        uno::Reference< uno::XComponentContext > xContext,
154
        const uno::Sequence< beans::Property >& rProperties,
155
        rtl::Reference< ResultSetDataSupplier > xDataSupplier,
156
        uno::Reference< css::ucb::XCommandEnvironment > xEnv );
157
};
158
159
inline ResultSet_Impl::ResultSet_Impl(
160
    uno::Reference< uno::XComponentContext > xContext,
161
    const uno::Sequence< beans::Property >& rProperties,
162
    rtl::Reference< ResultSetDataSupplier > xDataSupplier,
163
    uno::Reference< css::ucb::XCommandEnvironment > xEnv )
164
0
: m_xContext(std::move( xContext )),
165
0
  m_xEnv(std::move( xEnv )),
166
0
  m_aProperties( rProperties ),
167
0
  m_xDataSupplier(std::move( xDataSupplier )),
168
0
  m_nPos( 0 ), // Position is one-based. Zero means: before first element.
169
0
  m_bWasNull( false ),
170
0
  m_bAfterLast( false )
171
0
{
172
0
}
173
174
175
// ResultSet Implementation.
176
177
178
ResultSet::ResultSet(
179
    const uno::Reference< uno::XComponentContext >& rxContext,
180
    const uno::Sequence< beans::Property >& rProperties,
181
    const rtl::Reference< ResultSetDataSupplier >& rDataSupplier )
182
0
: m_pImpl( new ResultSet_Impl(
183
0
               rxContext,
184
0
               rProperties,
185
0
               rDataSupplier,
186
0
               uno::Reference< css::ucb::XCommandEnvironment >() ) )
187
0
{
188
0
    rDataSupplier->m_pResultSet = this;
189
0
}
190
191
192
ResultSet::ResultSet(
193
    const uno::Reference< uno::XComponentContext >& rxContext,
194
    const uno::Sequence< beans::Property >& rProperties,
195
    const rtl::Reference< ResultSetDataSupplier >& rDataSupplier,
196
    const uno::Reference< css::ucb::XCommandEnvironment >& rxEnv )
197
0
: m_pImpl( new ResultSet_Impl( rxContext, rProperties, rDataSupplier, rxEnv ) )
198
0
{
199
0
    rDataSupplier->m_pResultSet = this;
200
0
}
201
202
203
// virtual
204
ResultSet::~ResultSet()
205
0
{
206
0
}
207
208
209
// XServiceInfo methods.
210
211
OUString SAL_CALL ResultSet::getImplementationName()
212
0
{
213
0
    return u"ResultSet"_ustr;
214
0
}
215
216
sal_Bool SAL_CALL ResultSet::supportsService( const OUString& ServiceName )
217
0
{
218
0
    return cppu::supportsService( this, ServiceName );
219
0
}
220
221
css::uno::Sequence< OUString > SAL_CALL ResultSet::getSupportedServiceNames()
222
0
{
223
0
    return { RESULTSET_SERVICE_NAME };
224
0
}
225
226
227
// XComponent methods.
228
229
230
// virtual
231
void SAL_CALL ResultSet::dispose()
232
0
{
233
0
    std::unique_lock aGuard( m_pImpl->m_aMutex );
234
235
0
    if ( m_pImpl->m_aDisposeEventListeners.getLength(aGuard) )
236
0
    {
237
0
        lang::EventObject aEvt;
238
0
        aEvt.Source = static_cast< lang::XComponent * >( this );
239
0
        m_pImpl->m_aDisposeEventListeners.disposeAndClear( aGuard, aEvt );
240
0
    }
241
242
0
    if ( m_pImpl->m_pPropertyChangeListeners )
243
0
    {
244
0
        lang::EventObject aEvt;
245
0
        aEvt.Source = static_cast< beans::XPropertySet * >( this );
246
0
        m_pImpl->m_pPropertyChangeListeners->disposeAndClear( aGuard, aEvt );
247
0
    }
248
249
0
    m_pImpl->m_xDataSupplier->close();
250
0
}
251
252
253
// virtual
254
void SAL_CALL ResultSet::addEventListener(
255
        const uno::Reference< lang::XEventListener >& Listener )
256
0
{
257
0
    std::unique_lock aGuard( m_pImpl->m_aMutex );
258
259
0
    m_pImpl->m_aDisposeEventListeners.addInterface( aGuard, Listener );
260
0
}
261
262
263
// virtual
264
void SAL_CALL ResultSet::removeEventListener(
265
        const uno::Reference< lang::XEventListener >& Listener )
266
0
{
267
0
    std::unique_lock aGuard( m_pImpl->m_aMutex );
268
269
0
    m_pImpl->m_aDisposeEventListeners.removeInterface( aGuard, Listener );
270
0
}
271
272
273
// XResultSetMetaDataSupplier methods.
274
275
276
// virtual
277
uno::Reference< sdbc::XResultSetMetaData > SAL_CALL ResultSet::getMetaData()
278
0
{
279
0
    std::unique_lock aGuard( m_pImpl->m_aMutex );
280
281
0
    if ( !m_pImpl->m_xMetaData.is() )
282
0
        m_pImpl->m_xMetaData = new ResultSetMetaData( m_pImpl->m_xContext,
283
0
                                                      m_pImpl->m_aProperties );
284
285
0
    return m_pImpl->m_xMetaData;
286
0
}
287
288
289
// XResultSet methods.
290
291
292
// virtual
293
sal_Bool SAL_CALL ResultSet::next()
294
0
{
295
    // Note: Cursor is initially positioned before the first row.
296
    //       First call to 'next()' moves it to first row.
297
298
0
    std::unique_lock aGuard( m_pImpl->m_aMutex );
299
300
0
    if ( m_pImpl->m_bAfterLast )
301
0
    {
302
0
        m_pImpl->m_xDataSupplier->validate();
303
0
        return false;
304
0
    }
305
306
    // getResult works zero-based!
307
0
    if ( !m_pImpl->m_xDataSupplier->getResult( aGuard, m_pImpl->m_nPos ) )
308
0
    {
309
0
        m_pImpl->m_bAfterLast = true;
310
0
        m_pImpl->m_xDataSupplier->validate();
311
0
        return false;
312
0
    }
313
314
0
    m_pImpl->m_nPos++;
315
0
    m_pImpl->m_xDataSupplier->validate();
316
0
    return true;
317
0
}
318
319
320
// virtual
321
sal_Bool SAL_CALL ResultSet::isBeforeFirst()
322
0
{
323
0
    std::unique_lock aGuard( m_pImpl->m_aMutex );
324
0
    if ( m_pImpl->m_bAfterLast )
325
0
    {
326
0
        m_pImpl->m_xDataSupplier->validate();
327
0
        return false;
328
0
    }
329
330
    // getResult works zero-based!
331
0
    if ( !m_pImpl->m_xDataSupplier->getResult( aGuard, 0 ) )
332
0
    {
333
0
        m_pImpl->m_xDataSupplier->validate();
334
0
        return false;
335
0
    }
336
337
0
    m_pImpl->m_xDataSupplier->validate();
338
0
    return ( m_pImpl->m_nPos == 0 );
339
0
}
340
341
342
// virtual
343
sal_Bool SAL_CALL ResultSet::isAfterLast()
344
0
{
345
0
    std::unique_lock aGuard( m_pImpl->m_aMutex );
346
0
    m_pImpl->m_xDataSupplier->validate();
347
0
    return m_pImpl->m_bAfterLast;
348
0
}
349
350
351
// virtual
352
sal_Bool SAL_CALL ResultSet::isFirst()
353
0
{
354
0
    std::unique_lock aGuard( m_pImpl->m_aMutex );
355
0
    if ( m_pImpl->m_bAfterLast )
356
0
    {
357
0
        m_pImpl->m_xDataSupplier->validate();
358
0
        return false;
359
0
    }
360
361
0
    m_pImpl->m_xDataSupplier->validate();
362
0
    return ( m_pImpl->m_nPos == 1 );
363
0
}
364
365
366
// virtual
367
sal_Bool SAL_CALL ResultSet::isLast()
368
0
{
369
0
    std::unique_lock aGuard( m_pImpl->m_aMutex );
370
0
    if ( m_pImpl->m_bAfterLast )
371
0
    {
372
0
        m_pImpl->m_xDataSupplier->validate();
373
0
        return false;
374
0
    }
375
376
0
    sal_Int32 nCount = m_pImpl->m_xDataSupplier->totalCount(aGuard);
377
0
    if ( !nCount )
378
0
    {
379
0
        m_pImpl->m_xDataSupplier->validate();
380
0
        return false;
381
0
    }
382
383
0
    m_pImpl->m_xDataSupplier->validate();
384
0
    return ( m_pImpl->m_nPos == nCount );
385
0
}
386
387
388
// virtual
389
void SAL_CALL ResultSet::beforeFirst()
390
0
{
391
0
    std::unique_lock aGuard( m_pImpl->m_aMutex );
392
0
    m_pImpl->m_bAfterLast = false;
393
0
    m_pImpl->m_nPos = 0;
394
0
    m_pImpl->m_xDataSupplier->validate();
395
0
}
396
397
398
// virtual
399
void SAL_CALL ResultSet::afterLast()
400
0
{
401
0
    std::unique_lock aGuard( m_pImpl->m_aMutex );
402
0
    m_pImpl->m_bAfterLast = true;
403
0
    m_pImpl->m_xDataSupplier->validate();
404
0
}
405
406
407
// virtual
408
sal_Bool SAL_CALL ResultSet::first()
409
0
{
410
0
    std::unique_lock aGuard( m_pImpl->m_aMutex );
411
412
    // getResult works zero-based!
413
0
    if ( m_pImpl->m_xDataSupplier->getResult( aGuard, 0 ) )
414
0
    {
415
0
        m_pImpl->m_bAfterLast = false;
416
0
        m_pImpl->m_nPos = 1;
417
0
        m_pImpl->m_xDataSupplier->validate();
418
0
        return true;
419
0
    }
420
421
0
    m_pImpl->m_xDataSupplier->validate();
422
0
    return false;
423
0
}
424
425
426
// virtual
427
sal_Bool SAL_CALL ResultSet::last()
428
0
{
429
0
    std::unique_lock aGuard( m_pImpl->m_aMutex );
430
431
0
    sal_Int32 nCount = m_pImpl->m_xDataSupplier->totalCount(aGuard);
432
0
    if ( nCount )
433
0
    {
434
0
        m_pImpl->m_bAfterLast = false;
435
0
        m_pImpl->m_nPos = nCount;
436
0
        m_pImpl->m_xDataSupplier->validate();
437
0
        return true;
438
0
    }
439
440
0
    m_pImpl->m_xDataSupplier->validate();
441
0
    return false;
442
0
}
443
444
445
// virtual
446
sal_Int32 SAL_CALL ResultSet::getRow()
447
0
{
448
0
    std::unique_lock aGuard( m_pImpl->m_aMutex );
449
0
    if ( m_pImpl->m_bAfterLast )
450
0
    {
451
0
        m_pImpl->m_xDataSupplier->validate();
452
0
        return 0;
453
0
    }
454
455
0
    m_pImpl->m_xDataSupplier->validate();
456
0
    return m_pImpl->m_nPos;
457
0
}
458
459
460
// virtual
461
sal_Bool SAL_CALL ResultSet::absolute( sal_Int32 row )
462
0
{
463
/*
464
    If the row number is positive, the cursor moves to the given row number
465
    with respect to the beginning of the result set. The first row is row 1,
466
    the second is row 2, and so on.
467
468
    If the given row number is negative, the cursor moves to an absolute row
469
    position with respect to the end of the result set. For example, calling
470
    absolute( -1 ) positions the cursor on the last row, absolute( -2 )
471
    indicates the next-to-last row, and so on.
472
473
    An attempt to position the cursor beyond the first/last row in the result
474
    set leaves the cursor before/after the first/last row, respectively.
475
476
    Calling absolute( 1 ) is the same as calling first().
477
478
    Calling absolute( -1 ) is the same as calling last().
479
*/
480
0
    std::unique_lock aGuard( m_pImpl->m_aMutex );
481
482
0
    if ( row < 0 )
483
0
    {
484
0
        sal_Int32 nCount = m_pImpl->m_xDataSupplier->totalCount(aGuard);
485
486
0
        if ( ( row * -1 ) > nCount )
487
0
        {
488
0
            m_pImpl->m_bAfterLast = false;
489
0
            m_pImpl->m_nPos = 0;
490
0
            m_pImpl->m_xDataSupplier->validate();
491
0
            return false;
492
0
        }
493
0
        else // |row| <= nCount
494
0
        {
495
0
            m_pImpl->m_bAfterLast = false;
496
0
            m_pImpl->m_nPos = ( nCount + row + 1 );
497
0
            m_pImpl->m_xDataSupplier->validate();
498
0
            return true;
499
0
        }
500
0
    }
501
0
    else if ( row == 0 )
502
0
    {
503
        // @throws SQLException
504
        //      ... if row is 0 ...
505
0
        throw sdbc::SQLException();
506
0
    }
507
0
    else // row > 0
508
0
    {
509
0
        sal_Int32 nCount = m_pImpl->m_xDataSupplier->totalCount(aGuard);
510
511
0
        if ( row <= nCount )
512
0
        {
513
0
            m_pImpl->m_bAfterLast = false;
514
0
            m_pImpl->m_nPos = row;
515
0
            m_pImpl->m_xDataSupplier->validate();
516
0
            return true;
517
0
        }
518
0
        else // row > nCount
519
0
        {
520
0
            m_pImpl->m_bAfterLast = true;
521
0
            m_pImpl->m_xDataSupplier->validate();
522
0
            return false;
523
0
        }
524
0
    }
525
526
    // unreachable...
527
0
}
528
529
530
// virtual
531
sal_Bool SAL_CALL ResultSet::relative( sal_Int32 rows )
532
0
{
533
/*
534
    Attempting to move beyond the first/last row in the result set
535
    positions the cursor before/after the first/last row.
536
537
    Calling relative( 0 ) is valid, but does not change the cursor position.
538
539
    Calling relative( 1 ) is different from calling next() because it makes
540
    sense to call next() when there is no current row, for example, when
541
    the cursor is positioned before the first row or after the last row of
542
    the result set.
543
*/
544
0
    std::unique_lock aGuard( m_pImpl->m_aMutex );
545
546
0
    if ( m_pImpl->m_bAfterLast || ( m_pImpl->m_nPos == 0 ) )
547
0
    {
548
        // "No current row".
549
0
        throw sdbc::SQLException();
550
0
    }
551
552
0
    if ( rows < 0 )
553
0
    {
554
0
        if ( ( m_pImpl->m_nPos + rows ) > 0 )
555
0
        {
556
0
            m_pImpl->m_bAfterLast = false;
557
0
            m_pImpl->m_nPos = ( m_pImpl->m_nPos + rows );
558
0
            m_pImpl->m_xDataSupplier->validate();
559
0
            return true;
560
0
        }
561
0
        else
562
0
        {
563
0
            m_pImpl->m_bAfterLast = false;
564
0
            m_pImpl->m_nPos = 0;
565
0
            m_pImpl->m_xDataSupplier->validate();
566
0
            return false;
567
0
        }
568
0
    }
569
0
    else if ( rows == 0 )
570
0
    {
571
        // nop.
572
0
        m_pImpl->m_xDataSupplier->validate();
573
0
        return true;
574
0
    }
575
0
    else // rows > 0
576
0
    {
577
0
        sal_Int32 nCount = m_pImpl->m_xDataSupplier->totalCount(aGuard);
578
0
        if ( ( m_pImpl->m_nPos + rows ) <= nCount )
579
0
        {
580
0
            m_pImpl->m_bAfterLast = false;
581
0
            m_pImpl->m_nPos = ( m_pImpl->m_nPos + rows );
582
0
            m_pImpl->m_xDataSupplier->validate();
583
0
            return true;
584
0
        }
585
0
        else
586
0
        {
587
0
            m_pImpl->m_bAfterLast = true;
588
0
            m_pImpl->m_xDataSupplier->validate();
589
0
            return false;
590
0
        }
591
0
    }
592
593
    // unreachable...
594
0
}
595
596
597
// virtual
598
sal_Bool SAL_CALL ResultSet::previous()
599
0
{
600
/*
601
    previous() is not the same as relative( -1 ) because it makes sense
602
    to call previous() when there is no current row.
603
*/
604
0
    std::unique_lock aGuard( m_pImpl->m_aMutex );
605
606
0
    if ( m_pImpl->m_bAfterLast )
607
0
    {
608
0
        m_pImpl->m_bAfterLast = false;
609
0
        sal_Int32 nCount = m_pImpl->m_xDataSupplier->totalCount(aGuard);
610
0
        m_pImpl->m_nPos = nCount;
611
0
    }
612
0
    else if ( m_pImpl->m_nPos )
613
0
        m_pImpl->m_nPos--;
614
615
0
    if ( m_pImpl->m_nPos )
616
0
    {
617
0
        m_pImpl->m_xDataSupplier->validate();
618
0
        return true;
619
0
    }
620
621
0
    m_pImpl->m_xDataSupplier->validate();
622
0
    return false;
623
0
}
624
625
626
// virtual
627
void SAL_CALL ResultSet::refreshRow()
628
0
{
629
0
    std::unique_lock aGuard( m_pImpl->m_aMutex );
630
0
    if ( m_pImpl->m_bAfterLast || ( m_pImpl->m_nPos == 0 ) )
631
0
        return;
632
633
0
    m_pImpl->m_xDataSupplier->releasePropertyValues( m_pImpl->m_nPos );
634
0
    m_pImpl->m_xDataSupplier->validate();
635
0
}
636
637
638
// virtual
639
sal_Bool SAL_CALL ResultSet::rowUpdated()
640
0
{
641
0
    m_pImpl->m_xDataSupplier->validate();
642
0
    return false;
643
0
}
644
645
646
// virtual
647
sal_Bool SAL_CALL ResultSet::rowInserted()
648
0
{
649
0
    m_pImpl->m_xDataSupplier->validate();
650
0
    return false;
651
0
}
652
653
654
// virtual
655
sal_Bool SAL_CALL ResultSet::rowDeleted()
656
0
{
657
0
    m_pImpl->m_xDataSupplier->validate();
658
0
    return false;
659
0
}
660
661
662
// virtual
663
uno::Reference< uno::XInterface > SAL_CALL ResultSet::getStatement()
664
0
{
665
/*
666
    returns the Statement that produced this ResultSet object. If the
667
    result set was generated some other way, ... this method returns null.
668
*/
669
0
    m_pImpl->m_xDataSupplier->validate();
670
0
    return uno::Reference< uno::XInterface >();
671
0
}
672
673
674
// XRow methods.
675
676
677
// virtual
678
sal_Bool SAL_CALL ResultSet::wasNull()
679
0
{
680
    // This method can not be implemented correctly!!! Imagine different
681
    // threads doing a getXYZ - wasNull calling sequence on the same
682
    // implementation object...
683
684
0
    std::unique_lock aGuard( m_pImpl->m_aMutex );
685
686
0
    if ( m_pImpl->m_nPos && !m_pImpl->m_bAfterLast )
687
0
    {
688
0
        uno::Reference< sdbc::XRow > xValues
689
0
            = m_pImpl->m_xDataSupplier->queryPropertyValues(aGuard,
690
0
                                                        m_pImpl->m_nPos - 1 );
691
0
        if ( xValues.is() )
692
0
        {
693
0
            m_pImpl->m_xDataSupplier->validate();
694
0
            return xValues->wasNull();
695
0
        }
696
0
    }
697
698
0
    m_pImpl->m_xDataSupplier->validate();
699
0
    return m_pImpl->m_bWasNull;
700
0
}
701
702
703
// virtual
704
OUString SAL_CALL ResultSet::getString( sal_Int32 columnIndex )
705
0
{
706
0
    std::unique_lock aGuard( m_pImpl->m_aMutex );
707
708
0
    if ( m_pImpl->m_nPos && !m_pImpl->m_bAfterLast )
709
0
    {
710
0
        uno::Reference< sdbc::XRow > xValues
711
0
            = m_pImpl->m_xDataSupplier->queryPropertyValues(aGuard,
712
0
                                                        m_pImpl->m_nPos - 1 );
713
0
        if ( xValues.is() )
714
0
        {
715
0
            m_pImpl->m_bWasNull = false;
716
0
            m_pImpl->m_xDataSupplier->validate();
717
0
            return xValues->getString( columnIndex );
718
0
        }
719
0
    }
720
721
0
    m_pImpl->m_bWasNull = true;
722
0
    m_pImpl->m_xDataSupplier->validate();
723
0
    return OUString();
724
0
}
725
726
727
// virtual
728
sal_Bool SAL_CALL ResultSet::getBoolean( sal_Int32 columnIndex )
729
0
{
730
0
    std::unique_lock aGuard( m_pImpl->m_aMutex );
731
732
0
    if ( m_pImpl->m_nPos && !m_pImpl->m_bAfterLast )
733
0
    {
734
0
        uno::Reference< sdbc::XRow > xValues
735
0
            = m_pImpl->m_xDataSupplier->queryPropertyValues(aGuard,
736
0
                                                        m_pImpl->m_nPos - 1 );
737
0
        if ( xValues.is() )
738
0
        {
739
0
            m_pImpl->m_bWasNull = false;
740
0
            m_pImpl->m_xDataSupplier->validate();
741
0
            return xValues->getBoolean( columnIndex );
742
0
        }
743
0
    }
744
745
0
    m_pImpl->m_bWasNull = true;
746
0
    m_pImpl->m_xDataSupplier->validate();
747
0
    return false;
748
0
}
749
750
751
// virtual
752
sal_Int8 SAL_CALL ResultSet::getByte( sal_Int32 columnIndex )
753
0
{
754
0
    std::unique_lock aGuard( m_pImpl->m_aMutex );
755
756
0
    if ( m_pImpl->m_nPos && !m_pImpl->m_bAfterLast )
757
0
    {
758
0
        uno::Reference< sdbc::XRow > xValues
759
0
            = m_pImpl->m_xDataSupplier->queryPropertyValues(aGuard,
760
0
                                                        m_pImpl->m_nPos - 1 );
761
0
        if ( xValues.is() )
762
0
        {
763
0
            m_pImpl->m_bWasNull = false;
764
0
            m_pImpl->m_xDataSupplier->validate();
765
0
            return xValues->getByte( columnIndex );
766
0
        }
767
0
    }
768
769
0
    m_pImpl->m_bWasNull = true;
770
0
    m_pImpl->m_xDataSupplier->validate();
771
0
    return 0;
772
0
}
773
774
775
// virtual
776
sal_Int16 SAL_CALL ResultSet::getShort( sal_Int32 columnIndex )
777
0
{
778
0
    std::unique_lock aGuard( m_pImpl->m_aMutex );
779
780
0
    if ( m_pImpl->m_nPos && !m_pImpl->m_bAfterLast )
781
0
    {
782
0
        uno::Reference< sdbc::XRow > xValues
783
0
            = m_pImpl->m_xDataSupplier->queryPropertyValues(aGuard,
784
0
                                                        m_pImpl->m_nPos - 1 );
785
0
        if ( xValues.is() )
786
0
        {
787
0
            m_pImpl->m_bWasNull = false;
788
0
            m_pImpl->m_xDataSupplier->validate();
789
0
            return xValues->getShort( columnIndex );
790
0
        }
791
0
    }
792
793
0
    m_pImpl->m_bWasNull = true;
794
0
    m_pImpl->m_xDataSupplier->validate();
795
0
    return 0;
796
0
}
797
798
799
// virtual
800
sal_Int32 SAL_CALL ResultSet::getInt( sal_Int32 columnIndex )
801
0
{
802
0
    std::unique_lock aGuard( m_pImpl->m_aMutex );
803
804
0
    if ( m_pImpl->m_nPos && !m_pImpl->m_bAfterLast )
805
0
    {
806
0
        uno::Reference< sdbc::XRow > xValues
807
0
            = m_pImpl->m_xDataSupplier->queryPropertyValues(aGuard,
808
0
                                                        m_pImpl->m_nPos - 1 );
809
0
        if ( xValues.is() )
810
0
        {
811
0
            m_pImpl->m_bWasNull = false;
812
0
            m_pImpl->m_xDataSupplier->validate();
813
0
            return xValues->getInt( columnIndex );
814
0
        }
815
0
    }
816
817
0
    m_pImpl->m_bWasNull = true;
818
0
    m_pImpl->m_xDataSupplier->validate();
819
0
    return 0;
820
0
}
821
822
823
// virtual
824
sal_Int64 SAL_CALL ResultSet::getLong( sal_Int32 columnIndex )
825
0
{
826
0
    std::unique_lock aGuard( m_pImpl->m_aMutex );
827
828
0
    if ( m_pImpl->m_nPos && !m_pImpl->m_bAfterLast )
829
0
    {
830
0
        uno::Reference< sdbc::XRow > xValues
831
0
            = m_pImpl->m_xDataSupplier->queryPropertyValues(aGuard,
832
0
                                                        m_pImpl->m_nPos - 1 );
833
0
        if ( xValues.is() )
834
0
        {
835
0
            m_pImpl->m_bWasNull = false;
836
0
            m_pImpl->m_xDataSupplier->validate();
837
0
            return xValues->getLong( columnIndex );
838
0
        }
839
0
    }
840
841
0
    m_pImpl->m_bWasNull = true;
842
0
    m_pImpl->m_xDataSupplier->validate();
843
0
    return 0;
844
0
}
845
846
847
// virtual
848
float SAL_CALL ResultSet::getFloat( sal_Int32 columnIndex )
849
0
{
850
0
    std::unique_lock aGuard( m_pImpl->m_aMutex );
851
852
0
    if ( m_pImpl->m_nPos && !m_pImpl->m_bAfterLast )
853
0
    {
854
0
        uno::Reference< sdbc::XRow > xValues
855
0
            = m_pImpl->m_xDataSupplier->queryPropertyValues(aGuard,
856
0
                                                        m_pImpl->m_nPos - 1 );
857
0
        if ( xValues.is() )
858
0
        {
859
0
            m_pImpl->m_bWasNull = false;
860
0
            m_pImpl->m_xDataSupplier->validate();
861
0
            return xValues->getFloat( columnIndex );
862
0
        }
863
0
    }
864
865
0
    m_pImpl->m_bWasNull = true;
866
0
    m_pImpl->m_xDataSupplier->validate();
867
0
    return 0;
868
0
}
869
870
871
// virtual
872
double SAL_CALL ResultSet::getDouble( sal_Int32 columnIndex )
873
0
{
874
0
    std::unique_lock aGuard( m_pImpl->m_aMutex );
875
876
0
    if ( m_pImpl->m_nPos && !m_pImpl->m_bAfterLast )
877
0
    {
878
0
        uno::Reference< sdbc::XRow > xValues
879
0
            = m_pImpl->m_xDataSupplier->queryPropertyValues(aGuard,
880
0
                                                        m_pImpl->m_nPos - 1 );
881
0
        if ( xValues.is() )
882
0
        {
883
0
            m_pImpl->m_bWasNull = false;
884
0
            m_pImpl->m_xDataSupplier->validate();
885
0
            return xValues->getDouble( columnIndex );
886
0
        }
887
0
    }
888
889
0
    m_pImpl->m_bWasNull = true;
890
0
    m_pImpl->m_xDataSupplier->validate();
891
0
    return 0;
892
0
}
893
894
895
// virtual
896
uno::Sequence< sal_Int8 > SAL_CALL
897
ResultSet::getBytes( sal_Int32 columnIndex )
898
0
{
899
0
    std::unique_lock aGuard( m_pImpl->m_aMutex );
900
901
0
    if ( m_pImpl->m_nPos && !m_pImpl->m_bAfterLast )
902
0
    {
903
0
        uno::Reference< sdbc::XRow > xValues
904
0
            = m_pImpl->m_xDataSupplier->queryPropertyValues(aGuard,
905
0
                                                        m_pImpl->m_nPos - 1 );
906
0
        if ( xValues.is() )
907
0
        {
908
0
            m_pImpl->m_bWasNull = false;
909
0
            m_pImpl->m_xDataSupplier->validate();
910
0
            return xValues->getBytes( columnIndex );
911
0
        }
912
0
    }
913
914
0
    m_pImpl->m_bWasNull = true;
915
0
    m_pImpl->m_xDataSupplier->validate();
916
0
    return uno::Sequence< sal_Int8 >();
917
0
}
918
919
920
// virtual
921
util::Date SAL_CALL ResultSet::getDate( sal_Int32 columnIndex )
922
0
{
923
0
    std::unique_lock aGuard( m_pImpl->m_aMutex );
924
925
0
    if ( m_pImpl->m_nPos && !m_pImpl->m_bAfterLast )
926
0
    {
927
0
        uno::Reference< sdbc::XRow > xValues
928
0
            = m_pImpl->m_xDataSupplier->queryPropertyValues(aGuard,
929
0
                                                        m_pImpl->m_nPos - 1 );
930
0
        if ( xValues.is() )
931
0
        {
932
0
            m_pImpl->m_bWasNull = false;
933
0
            m_pImpl->m_xDataSupplier->validate();
934
0
            return xValues->getDate( columnIndex );
935
0
        }
936
0
    }
937
938
0
    m_pImpl->m_bWasNull = true;
939
0
    m_pImpl->m_xDataSupplier->validate();
940
0
    return util::Date();
941
0
}
942
943
944
// virtual
945
util::Time SAL_CALL ResultSet::getTime( sal_Int32 columnIndex )
946
0
{
947
0
    std::unique_lock aGuard( m_pImpl->m_aMutex );
948
949
0
    if ( m_pImpl->m_nPos && !m_pImpl->m_bAfterLast )
950
0
    {
951
0
        uno::Reference< sdbc::XRow > xValues
952
0
            = m_pImpl->m_xDataSupplier->queryPropertyValues(aGuard,
953
0
                                                        m_pImpl->m_nPos - 1 );
954
0
        if ( xValues.is() )
955
0
        {
956
0
            m_pImpl->m_bWasNull = false;
957
0
            m_pImpl->m_xDataSupplier->validate();
958
0
            return xValues->getTime( columnIndex );
959
0
        }
960
0
    }
961
962
0
    m_pImpl->m_bWasNull = true;
963
0
    m_pImpl->m_xDataSupplier->validate();
964
0
    return util::Time();
965
0
}
966
967
968
// virtual
969
util::DateTime SAL_CALL
970
ResultSet::getTimestamp( sal_Int32 columnIndex )
971
0
{
972
0
    std::unique_lock aGuard( m_pImpl->m_aMutex );
973
974
0
    if ( m_pImpl->m_nPos && !m_pImpl->m_bAfterLast )
975
0
    {
976
0
        uno::Reference< sdbc::XRow > xValues
977
0
            = m_pImpl->m_xDataSupplier->queryPropertyValues(aGuard,
978
0
                                                        m_pImpl->m_nPos - 1 );
979
0
        if ( xValues.is() )
980
0
        {
981
0
            m_pImpl->m_bWasNull = false;
982
0
            m_pImpl->m_xDataSupplier->validate();
983
0
            return xValues->getTimestamp( columnIndex );
984
0
        }
985
0
    }
986
987
0
    m_pImpl->m_bWasNull = true;
988
0
    m_pImpl->m_xDataSupplier->validate();
989
0
    return util::DateTime();
990
0
}
991
992
993
// virtual
994
uno::Reference< io::XInputStream > SAL_CALL
995
ResultSet::getBinaryStream( sal_Int32 columnIndex )
996
0
{
997
0
    std::unique_lock aGuard( m_pImpl->m_aMutex );
998
999
0
    if ( m_pImpl->m_nPos && !m_pImpl->m_bAfterLast )
1000
0
    {
1001
0
        uno::Reference< sdbc::XRow > xValues
1002
0
            = m_pImpl->m_xDataSupplier->queryPropertyValues(aGuard,
1003
0
                                                        m_pImpl->m_nPos - 1 );
1004
0
        if ( xValues.is() )
1005
0
        {
1006
0
            m_pImpl->m_bWasNull = false;
1007
0
            m_pImpl->m_xDataSupplier->validate();
1008
0
            return xValues->getBinaryStream( columnIndex );
1009
0
        }
1010
0
    }
1011
1012
0
    m_pImpl->m_bWasNull = true;
1013
0
    m_pImpl->m_xDataSupplier->validate();
1014
0
    return uno::Reference< io::XInputStream >();
1015
0
}
1016
1017
1018
// virtual
1019
uno::Reference< io::XInputStream > SAL_CALL
1020
ResultSet::getCharacterStream( sal_Int32 columnIndex )
1021
0
{
1022
0
    std::unique_lock aGuard( m_pImpl->m_aMutex );
1023
1024
0
    if ( m_pImpl->m_nPos && !m_pImpl->m_bAfterLast )
1025
0
    {
1026
0
        uno::Reference< sdbc::XRow > xValues
1027
0
            = m_pImpl->m_xDataSupplier->queryPropertyValues(aGuard,
1028
0
                                                        m_pImpl->m_nPos - 1 );
1029
0
        if ( xValues.is() )
1030
0
        {
1031
0
            m_pImpl->m_bWasNull = false;
1032
0
            m_pImpl->m_xDataSupplier->validate();
1033
0
            return xValues->getCharacterStream( columnIndex );
1034
0
        }
1035
0
    }
1036
1037
0
    m_pImpl->m_bWasNull = true;
1038
0
    m_pImpl->m_xDataSupplier->validate();
1039
0
    return uno::Reference< io::XInputStream >();
1040
0
}
1041
1042
1043
// virtual
1044
uno::Any SAL_CALL ResultSet::getObject(
1045
        sal_Int32 columnIndex,
1046
        const uno::Reference< container::XNameAccess >& typeMap )
1047
0
{
1048
0
    std::unique_lock aGuard( m_pImpl->m_aMutex );
1049
1050
0
    if ( m_pImpl->m_nPos && !m_pImpl->m_bAfterLast )
1051
0
    {
1052
0
        uno::Reference< sdbc::XRow > xValues
1053
0
            = m_pImpl->m_xDataSupplier->queryPropertyValues(aGuard,
1054
0
                                                        m_pImpl->m_nPos - 1 );
1055
0
        if ( xValues.is() )
1056
0
        {
1057
0
            m_pImpl->m_bWasNull = false;
1058
0
            m_pImpl->m_xDataSupplier->validate();
1059
0
            return xValues->getObject( columnIndex, typeMap );
1060
0
        }
1061
0
    }
1062
1063
0
    m_pImpl->m_bWasNull = true;
1064
0
    m_pImpl->m_xDataSupplier->validate();
1065
0
    return uno::Any();
1066
0
}
1067
1068
1069
// virtual
1070
uno::Reference< sdbc::XRef > SAL_CALL
1071
ResultSet::getRef( sal_Int32 columnIndex )
1072
0
{
1073
0
    std::unique_lock aGuard( m_pImpl->m_aMutex );
1074
1075
0
    if ( m_pImpl->m_nPos && !m_pImpl->m_bAfterLast )
1076
0
    {
1077
0
        uno::Reference< sdbc::XRow > xValues
1078
0
            = m_pImpl->m_xDataSupplier->queryPropertyValues(aGuard,
1079
0
                                                        m_pImpl->m_nPos - 1 );
1080
0
        if ( xValues.is() )
1081
0
        {
1082
0
            m_pImpl->m_bWasNull = false;
1083
0
            m_pImpl->m_xDataSupplier->validate();
1084
0
            return xValues->getRef( columnIndex );
1085
0
        }
1086
0
    }
1087
1088
0
    m_pImpl->m_bWasNull = true;
1089
0
    m_pImpl->m_xDataSupplier->validate();
1090
0
    return uno::Reference< sdbc::XRef >();
1091
0
}
1092
1093
1094
// virtual
1095
uno::Reference< sdbc::XBlob > SAL_CALL
1096
ResultSet::getBlob( sal_Int32 columnIndex )
1097
0
{
1098
0
    std::unique_lock aGuard( m_pImpl->m_aMutex );
1099
1100
0
    if ( m_pImpl->m_nPos && !m_pImpl->m_bAfterLast )
1101
0
    {
1102
0
        uno::Reference< sdbc::XRow > xValues
1103
0
            = m_pImpl->m_xDataSupplier->queryPropertyValues(aGuard,
1104
0
                                                        m_pImpl->m_nPos - 1 );
1105
0
        if ( xValues.is() )
1106
0
        {
1107
0
            m_pImpl->m_bWasNull = false;
1108
0
            m_pImpl->m_xDataSupplier->validate();
1109
0
            return xValues->getBlob( columnIndex );
1110
0
        }
1111
0
    }
1112
1113
0
    m_pImpl->m_bWasNull = true;
1114
0
    m_pImpl->m_xDataSupplier->validate();
1115
0
    return uno::Reference< sdbc::XBlob >();
1116
0
}
1117
1118
1119
// virtual
1120
uno::Reference< sdbc::XClob > SAL_CALL
1121
ResultSet::getClob( sal_Int32 columnIndex )
1122
0
{
1123
0
    std::unique_lock aGuard( m_pImpl->m_aMutex );
1124
1125
0
    if ( m_pImpl->m_nPos && !m_pImpl->m_bAfterLast )
1126
0
    {
1127
0
        uno::Reference< sdbc::XRow > xValues
1128
0
            = m_pImpl->m_xDataSupplier->queryPropertyValues(aGuard,
1129
0
                                                        m_pImpl->m_nPos - 1 );
1130
0
        if ( xValues.is() )
1131
0
        {
1132
0
            m_pImpl->m_bWasNull = false;
1133
0
            m_pImpl->m_xDataSupplier->validate();
1134
0
            return xValues->getClob( columnIndex );
1135
0
        }
1136
0
    }
1137
1138
0
    m_pImpl->m_bWasNull = true;
1139
0
    m_pImpl->m_xDataSupplier->validate();
1140
0
    return uno::Reference< sdbc::XClob >();
1141
0
}
1142
1143
1144
// virtual
1145
uno::Reference< sdbc::XArray > SAL_CALL
1146
ResultSet::getArray( sal_Int32 columnIndex )
1147
0
{
1148
0
    std::unique_lock aGuard( m_pImpl->m_aMutex );
1149
1150
0
    if ( m_pImpl->m_nPos && !m_pImpl->m_bAfterLast )
1151
0
    {
1152
0
        uno::Reference< sdbc::XRow > xValues
1153
0
            = m_pImpl->m_xDataSupplier->queryPropertyValues(aGuard,
1154
0
                                                        m_pImpl->m_nPos - 1 );
1155
0
        if ( xValues.is() )
1156
0
        {
1157
0
            m_pImpl->m_bWasNull = false;
1158
0
            m_pImpl->m_xDataSupplier->validate();
1159
0
            return xValues->getArray( columnIndex );
1160
0
        }
1161
0
    }
1162
1163
0
    m_pImpl->m_bWasNull = true;
1164
0
    m_pImpl->m_xDataSupplier->validate();
1165
0
    return uno::Reference< sdbc::XArray >();
1166
0
}
1167
1168
1169
// XCloseable methods.
1170
1171
1172
// virtual
1173
void SAL_CALL ResultSet::close()
1174
0
{
1175
0
    m_pImpl->m_xDataSupplier->close();
1176
0
    m_pImpl->m_xDataSupplier->validate();
1177
0
}
1178
1179
1180
// XContentAccess methods.
1181
1182
1183
// virtual
1184
OUString SAL_CALL ResultSet::queryContentIdentifierString()
1185
0
{
1186
0
    std::unique_lock aGuard( m_pImpl->m_aMutex );
1187
1188
0
    if ( m_pImpl->m_nPos && !m_pImpl->m_bAfterLast )
1189
0
        return m_pImpl->m_xDataSupplier->queryContentIdentifierString(aGuard,
1190
0
                                                        m_pImpl->m_nPos - 1 );
1191
1192
0
    return OUString();
1193
0
}
1194
1195
1196
// virtual
1197
uno::Reference< css::ucb::XContentIdentifier > SAL_CALL
1198
ResultSet::queryContentIdentifier()
1199
0
{
1200
0
    std::unique_lock aGuard( m_pImpl->m_aMutex );
1201
1202
0
    if ( m_pImpl->m_nPos && !m_pImpl->m_bAfterLast )
1203
0
        return m_pImpl->m_xDataSupplier->queryContentIdentifier(aGuard,
1204
0
                                                        m_pImpl->m_nPos - 1 );
1205
1206
0
    return uno::Reference< css::ucb::XContentIdentifier >();
1207
0
}
1208
1209
1210
// virtual
1211
uno::Reference< css::ucb::XContent > SAL_CALL
1212
ResultSet::queryContent()
1213
0
{
1214
0
    std::unique_lock aGuard( m_pImpl->m_aMutex );
1215
1216
0
    if ( m_pImpl->m_nPos && !m_pImpl->m_bAfterLast )
1217
0
        return m_pImpl->m_xDataSupplier->queryContent( aGuard, m_pImpl->m_nPos - 1 );
1218
1219
0
    return uno::Reference< css::ucb::XContent >();
1220
0
}
1221
1222
1223
// XPropertySet methods.
1224
1225
1226
// virtual
1227
uno::Reference< beans::XPropertySetInfo > SAL_CALL
1228
ResultSet::getPropertySetInfo()
1229
0
{
1230
0
    std::unique_lock aGuard( m_pImpl->m_aMutex );
1231
1232
0
    if ( !m_pImpl->m_xPropSetInfo.is() )
1233
0
        m_pImpl->m_xPropSetInfo
1234
0
            = new PropertySetInfo( aPropertyTable,
1235
0
                                   RESULTSET_PROPERTY_COUNT );
1236
0
    return m_pImpl->m_xPropSetInfo;
1237
0
}
1238
1239
1240
// virtual
1241
void SAL_CALL ResultSet::setPropertyValue( const OUString& aPropertyName,
1242
                                           const uno::Any& )
1243
0
{
1244
0
    if ( aPropertyName == "RowCount" )
1245
0
    {
1246
        // property is read-only.
1247
0
        throw lang::IllegalArgumentException();
1248
0
    }
1249
0
    else if ( aPropertyName == "IsRowCountFinal" )
1250
0
    {
1251
        // property is read-only.
1252
0
        throw lang::IllegalArgumentException();
1253
0
    }
1254
0
    else
1255
0
    {
1256
0
        throw beans::UnknownPropertyException(aPropertyName);
1257
0
    }
1258
0
}
1259
1260
1261
// virtual
1262
uno::Any SAL_CALL ResultSet::getPropertyValue(
1263
        const OUString& PropertyName )
1264
0
{
1265
0
    uno::Any aValue;
1266
1267
0
    if ( PropertyName == "RowCount" )
1268
0
    {
1269
0
        aValue <<= m_pImpl->m_xDataSupplier->currentCount();
1270
0
    }
1271
0
    else if ( PropertyName == "IsRowCountFinal" )
1272
0
    {
1273
0
        aValue <<= m_pImpl->m_xDataSupplier->isCountFinal();
1274
0
    }
1275
0
    else
1276
0
    {
1277
0
        throw beans::UnknownPropertyException(PropertyName);
1278
0
    }
1279
1280
0
    return aValue;
1281
0
}
1282
1283
1284
// virtual
1285
void SAL_CALL ResultSet::addPropertyChangeListener(
1286
        const OUString& aPropertyName,
1287
        const uno::Reference< beans::XPropertyChangeListener >& xListener )
1288
0
{
1289
    // Note: An empty property name means a listener for "all" properties.
1290
1291
0
    std::unique_lock aGuard( m_pImpl->m_aMutex );
1292
1293
0
    if ( !aPropertyName.isEmpty() &&
1294
0
         aPropertyName != "RowCount" &&
1295
0
         aPropertyName != "IsRowCountFinal" )
1296
0
        throw beans::UnknownPropertyException(aPropertyName);
1297
1298
0
    if ( !m_pImpl->m_pPropertyChangeListeners )
1299
0
        m_pImpl->m_pPropertyChangeListeners.reset(
1300
0
             new PropertyChangeListeners());
1301
1302
0
    m_pImpl->m_pPropertyChangeListeners->addInterface(aGuard,
1303
0
                                                aPropertyName, xListener );
1304
0
}
1305
1306
1307
// virtual
1308
void SAL_CALL ResultSet::removePropertyChangeListener(
1309
        const OUString& aPropertyName,
1310
        const uno::Reference< beans::XPropertyChangeListener >& xListener )
1311
0
{
1312
0
    std::unique_lock aGuard( m_pImpl->m_aMutex );
1313
1314
0
    if ( !aPropertyName.isEmpty() &&
1315
0
         aPropertyName != "RowCount" &&
1316
0
         aPropertyName != "IsRowCountFinal" )
1317
0
        throw beans::UnknownPropertyException(aPropertyName);
1318
1319
0
    if ( m_pImpl->m_pPropertyChangeListeners )
1320
0
        m_pImpl->m_pPropertyChangeListeners->removeInterface(aGuard,
1321
0
                                                    aPropertyName, xListener );
1322
1323
0
}
1324
1325
1326
// virtual
1327
void SAL_CALL ResultSet::addVetoableChangeListener(
1328
        const OUString&,
1329
        const uno::Reference< beans::XVetoableChangeListener >& )
1330
0
{
1331
    //  No constrained props, at the moment.
1332
0
}
1333
1334
1335
// virtual
1336
void SAL_CALL ResultSet::removeVetoableChangeListener(
1337
        const OUString&,
1338
        const uno::Reference< beans::XVetoableChangeListener >& )
1339
0
{
1340
    //  No constrained props, at the moment.
1341
0
}
1342
1343
1344
// Non-interface methods.
1345
1346
void ResultSet::propertyChanged( std::unique_lock<std::mutex>& rGuard, const beans::PropertyChangeEvent& rEvt ) const
1347
0
{
1348
0
    if ( !m_pImpl->m_pPropertyChangeListeners )
1349
0
        return;
1350
1351
    // Notify listeners interested especially in the changed property.
1352
0
    comphelper::OInterfaceContainerHelper4<beans::XPropertyChangeListener>* pPropsContainer
1353
0
        = m_pImpl->m_pPropertyChangeListeners->getContainer(rGuard,
1354
0
                                                        rEvt.PropertyName );
1355
0
    if ( pPropsContainer )
1356
0
    {
1357
0
        pPropsContainer->notifyEach(rGuard, &beans::XPropertyChangeListener::propertyChange, rEvt);
1358
0
    }
1359
1360
    // Notify listeners interested in all properties.
1361
0
    pPropsContainer
1362
0
        = m_pImpl->m_pPropertyChangeListeners->getContainer( rGuard, OUString() );
1363
0
    if ( pPropsContainer )
1364
0
    {
1365
0
        pPropsContainer->notifyEach( rGuard, &beans::XPropertyChangeListener::propertyChange, rEvt);
1366
0
    }
1367
0
}
1368
1369
1370
void ResultSet::rowCountChanged( std::unique_lock<std::mutex>& rGuard, sal_uInt32 nOld, sal_uInt32 nNew )
1371
0
{
1372
0
    OSL_ENSURE( nOld < nNew, "ResultSet::rowCountChanged - nOld >= nNew!" );
1373
1374
0
    if ( !m_pImpl->m_pPropertyChangeListeners )
1375
0
        return;
1376
1377
0
    propertyChanged( rGuard,
1378
0
        beans::PropertyChangeEvent(
1379
0
            getXWeak(),
1380
0
            u"RowCount"_ustr,
1381
0
            false,
1382
0
            1001,
1383
0
            uno::Any( nOld ),     // old value
1384
0
            uno::Any( nNew ) ) ); // new value
1385
0
}
1386
1387
1388
void ResultSet::rowCountFinal(std::unique_lock<std::mutex>& rGuard)
1389
0
{
1390
0
    if ( !m_pImpl->m_pPropertyChangeListeners )
1391
0
        return;
1392
1393
0
    propertyChanged( rGuard,
1394
0
        beans::PropertyChangeEvent(
1395
0
            getXWeak(),
1396
0
            u"IsRowCountFinal"_ustr,
1397
0
            false,
1398
0
            1000,
1399
0
            uno:: Any( false ),   // old value
1400
0
            uno::Any( true ) ) ); // new value
1401
0
}
1402
1403
1404
const uno::Sequence< beans::Property >& ResultSet::getProperties() const
1405
0
{
1406
0
    return m_pImpl->m_aProperties;
1407
0
}
1408
1409
1410
const uno::Reference< css::ucb::XCommandEnvironment >&
1411
ResultSet::getEnvironment() const
1412
0
{
1413
0
    return m_pImpl->m_xEnv;
1414
0
}
1415
1416
} // namespace ucbhelper
1417
1418
namespace ucbhelper_impl {
1419
1420
1421
// PropertySetInfo Implementation.
1422
1423
1424
PropertySetInfo::PropertySetInfo(
1425
    const PropertyInfo* pProps,
1426
    sal_Int32 nProps )
1427
0
    : m_aProps( nProps )
1428
0
{
1429
1430
0
    if ( !nProps )
1431
0
        return;
1432
1433
0
    const PropertyInfo* pEntry = pProps;
1434
0
    beans::Property* pProperties = m_aProps.getArray();
1435
1436
0
    for ( sal_Int32 n = 0; n < nProps; ++n )
1437
0
    {
1438
0
        beans::Property& rProp = pProperties[ n ];
1439
1440
0
        rProp.Name       = pEntry->aName;
1441
0
        rProp.Handle     = pEntry->nHandle;
1442
0
        rProp.Type       = pEntry->pGetCppuType();
1443
0
        rProp.Attributes = pEntry->nAttributes;
1444
1445
0
        pEntry++;
1446
0
    }
1447
0
}
1448
1449
1450
1451
// XInterface methods.
1452
void SAL_CALL PropertySetInfo::acquire()
1453
    noexcept
1454
0
{
1455
0
    OWeakObject::acquire();
1456
0
}
1457
1458
void SAL_CALL PropertySetInfo::release()
1459
    noexcept
1460
0
{
1461
0
    OWeakObject::release();
1462
0
}
1463
1464
css::uno::Any SAL_CALL PropertySetInfo::queryInterface(
1465
                                const css::uno::Type & rType )
1466
0
{
1467
0
    css::uno::Any aRet = cppu::queryInterface( rType,
1468
0
                                               static_cast< lang::XTypeProvider* >(this),
1469
0
                                               static_cast< beans::XPropertySetInfo* >(this)
1470
0
                                               );
1471
0
    return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType );
1472
0
}
1473
1474
// XTypeProvider methods.
1475
1476
1477
XTYPEPROVIDER_IMPL_2( PropertySetInfo,
1478
                         lang::XTypeProvider,
1479
                         beans::XPropertySetInfo );
1480
1481
1482
// XPropertySetInfo methods.
1483
1484
1485
// virtual
1486
uno::Sequence< beans::Property > SAL_CALL PropertySetInfo::getProperties()
1487
0
{
1488
0
    return m_aProps;
1489
0
}
1490
1491
1492
// virtual
1493
beans::Property SAL_CALL PropertySetInfo::getPropertyByName(
1494
        const OUString& aName )
1495
0
{
1496
0
    beans::Property aProp;
1497
0
    if ( queryProperty( aName, aProp ) )
1498
0
        return aProp;
1499
1500
0
    throw beans::UnknownPropertyException(aName);
1501
0
}
1502
1503
1504
// virtual
1505
sal_Bool SAL_CALL PropertySetInfo::hasPropertyByName(
1506
        const OUString& Name )
1507
0
{
1508
0
    beans::Property aProp;
1509
0
    return queryProperty( Name, aProp );
1510
0
}
1511
1512
1513
bool PropertySetInfo::queryProperty(
1514
    std::u16string_view aName, beans::Property& rProp ) const
1515
0
{
1516
0
    sal_Int32 nCount = m_aProps.getLength();
1517
0
    const beans::Property* pProps = m_aProps.getConstArray();
1518
0
    for ( sal_Int32 n = 0; n < nCount; ++n )
1519
0
    {
1520
0
        const beans::Property& rCurr = pProps[ n ];
1521
0
        if ( rCurr.Name == aName )
1522
0
        {
1523
0
            rProp = rCurr;
1524
0
            return true;
1525
0
        }
1526
0
    }
1527
1528
0
    return false;
1529
0
}
1530
1531
} // namespace ucbhelper_impl
1532
1533
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */