Coverage Report

Created: 2025-11-16 09:57

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/connectivity/source/drivers/dbase/DResultSet.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 <com/sun/star/sdbcx/CompareBookmark.hpp>
21
#include <dbase/DResultSet.hxx>
22
#include <com/sun/star/beans/PropertyAttribute.hpp>
23
#include <comphelper/sequence.hxx>
24
#include <cppuhelper/supportsservice.hxx>
25
#include <dbase/DIndex.hxx>
26
#include <dbase/DIndexIter.hxx>
27
#include <comphelper/types.hxx>
28
#include <connectivity/dbexception.hxx>
29
#include <strings.hrc>
30
31
using namespace ::comphelper;
32
33
using namespace connectivity::dbase;
34
using namespace connectivity::file;
35
using namespace ::cppu;
36
using namespace com::sun::star::uno;
37
using namespace com::sun::star::lang;
38
using namespace com::sun::star::beans;
39
using namespace com::sun::star::sdbc;
40
using namespace com::sun::star::sdbcx;
41
42
ODbaseResultSet::ODbaseResultSet( OStatement_Base* pStmt,connectivity::OSQLParseTreeIterator&   _aSQLIterator)
43
19.0k
                : file::OResultSet(pStmt,_aSQLIterator)
44
19.0k
                ,m_bBookmarkable(true)
45
19.0k
{
46
19.0k
    registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISBOOKMARKABLE),         PROPERTY_ID_ISBOOKMARKABLE,       PropertyAttribute::READONLY,&m_bBookmarkable,                cppu::UnoType<bool>::get());
47
19.0k
}
48
49
OUString SAL_CALL ODbaseResultSet::getImplementationName(  )
50
0
{
51
0
    return u"com.sun.star.sdbcx.dbase.ResultSet"_ustr;
52
0
}
53
54
Sequence< OUString > SAL_CALL ODbaseResultSet::getSupportedServiceNames(  )
55
0
{
56
0
    return { u"com.sun.star.sdbc.ResultSet"_ustr, u"com.sun.star.sdbcx.ResultSet"_ustr };
57
0
}
58
59
sal_Bool SAL_CALL ODbaseResultSet::supportsService( const OUString& _rServiceName )
60
0
{
61
0
    return cppu::supportsService(this, _rServiceName);
62
0
}
63
64
Any SAL_CALL ODbaseResultSet::queryInterface( const Type & rType )
65
114k
{
66
114k
    Any aRet = ODbaseResultSet_BASE::queryInterface(rType);
67
114k
    return aRet.hasValue() ? aRet : OResultSet::queryInterface(rType);
68
114k
}
69
70
 Sequence<  Type > SAL_CALL ODbaseResultSet::getTypes(  )
71
0
{
72
0
    return ::comphelper::concatSequences(OResultSet::getTypes(),ODbaseResultSet_BASE::getTypes());
73
0
}
74
75
76
// XRowLocate
77
Any SAL_CALL ODbaseResultSet::getBookmark(  )
78
1.58M
{
79
1.58M
    ::osl::MutexGuard aGuard( m_aMutex );
80
1.58M
    checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
81
1.58M
    OSL_ENSURE((m_bShowDeleted || !m_aRow->isDeleted()),"getBookmark called for deleted row");
82
83
1.58M
    return Any((*m_aRow)[0]->getValue().getInt32());
84
1.58M
}
85
86
sal_Bool SAL_CALL ODbaseResultSet::moveToBookmark( const  Any& bookmark )
87
0
{
88
0
    ::osl::MutexGuard aGuard( m_aMutex );
89
0
    checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
90
91
92
0
    m_bRowDeleted = m_bRowInserted = m_bRowUpdated = false;
93
94
0
    return m_pTable.is() && Move(IResultSetHelper::BOOKMARK,comphelper::getINT32(bookmark),true);
95
0
}
96
97
sal_Bool SAL_CALL ODbaseResultSet::moveRelativeToBookmark( const  Any& bookmark, sal_Int32 rows )
98
0
{
99
0
    ::osl::MutexGuard aGuard( m_aMutex );
100
0
    checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
101
0
    if(!m_pTable.is())
102
0
        return false;
103
104
105
0
    Move(IResultSetHelper::BOOKMARK,comphelper::getINT32(bookmark),false);
106
107
0
    return relative(rows);
108
0
}
109
110
111
sal_Int32 SAL_CALL ODbaseResultSet::compareBookmarks( const Any& lhs, const Any& rhs )
112
1.58M
{
113
1.58M
    sal_Int32 nFirst(0),nSecond(0),nResult(0);
114
1.58M
    if ( !( lhs  >>= nFirst ) || !( rhs >>= nSecond ) )
115
0
    {
116
0
        ::connectivity::SharedResources aResources;
117
0
        const OUString sMessage = aResources.getResourceString(STR_INVALID_BOOKMARK);
118
0
        ::dbtools::throwGenericSQLException(sMessage ,*this);
119
0
    } // if ( !( lhs  >>= nFirst ) || !( rhs >>= nSecond ) )
120
121
1.58M
    if(nFirst < nSecond)
122
0
        nResult = CompareBookmark::LESS;
123
1.58M
    else if(nFirst > nSecond)
124
0
        nResult = CompareBookmark::GREATER;
125
1.58M
    else
126
1.58M
        nResult = CompareBookmark::EQUAL;
127
128
1.58M
    return  nResult;
129
1.58M
}
130
131
sal_Bool SAL_CALL ODbaseResultSet::hasOrderedBookmarks(  )
132
0
{
133
0
    return true;
134
0
}
135
136
sal_Int32 SAL_CALL ODbaseResultSet::hashBookmark( const  Any& bookmark )
137
0
{
138
0
    ::osl::MutexGuard aGuard( m_aMutex );
139
0
    checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
140
141
142
0
    return comphelper::getINT32(bookmark);
143
0
}
144
145
// XDeleteRows
146
Sequence< sal_Int32 > SAL_CALL ODbaseResultSet::deleteRows( const  Sequence<  Any >& /*rows*/ )
147
0
{
148
0
    ::osl::MutexGuard aGuard( m_aMutex );
149
0
    checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
150
151
0
    ::dbtools::throwFeatureNotImplementedSQLException( u"XDeleteRows::deleteRows"_ustr, *this );
152
0
}
153
154
bool ODbaseResultSet::fillIndexValues(const Reference< XColumnsSupplier> &_xIndex)
155
0
{
156
0
    auto pIndex = dynamic_cast<dbase::ODbaseIndex*>(_xIndex.get());
157
0
    if(pIndex)
158
0
    {
159
0
        std::unique_ptr<dbase::OIndexIterator> pIter = pIndex->createIterator();
160
161
0
        if (pIter)
162
0
        {
163
0
            sal_uInt32 nRec = pIter->First();
164
0
            while (nRec != NODE_NOTFOUND)
165
0
            {
166
0
                m_pFileSet->push_back(nRec);
167
0
                nRec = pIter->Next();
168
0
            }
169
0
            m_pFileSet->setFrozen();
170
0
            return true;
171
0
        }
172
0
    }
173
0
    return false;
174
0
}
175
176
::cppu::IPropertyArrayHelper & ODbaseResultSet::getInfoHelper()
177
28.5k
{
178
28.5k
    return *ODbaseResultSet_BASE3::getArrayHelper();
179
28.5k
}
180
181
::cppu::IPropertyArrayHelper* ODbaseResultSet::createArrayHelper() const
182
9.50k
{
183
9.50k
    Sequence< Property > aProps;
184
9.50k
    describeProperties(aProps);
185
9.50k
    return new ::cppu::OPropertyArrayHelper(aProps);
186
9.50k
}
187
188
void SAL_CALL ODbaseResultSet::acquire() noexcept
189
418k
{
190
418k
    ODbaseResultSet_BASE2::acquire();
191
418k
}
192
193
void SAL_CALL ODbaseResultSet::release() noexcept
194
418k
{
195
418k
    ODbaseResultSet_BASE2::release();
196
418k
}
197
198
css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL ODbaseResultSet::getPropertySetInfo(  )
199
9.50k
{
200
9.50k
    return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
201
9.50k
}
202
203
sal_Int32 ODbaseResultSet::getCurrentFilePos() const
204
0
{
205
0
    return m_pTable->getFilePos();
206
0
}
207
208
209
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */