Coverage Report

Created: 2026-02-14 09:37

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/ucb/source/ucp/file/filrow.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 "filrow.hxx"
21
#include "filtask.hxx"
22
#include <com/sun/star/script/CannotConvertException.hpp>
23
#include <com/sun/star/script/Converter.hpp>
24
#include <com/sun/star/sdbc/SQLException.hpp>
25
26
using namespace fileaccess;
27
using namespace com::sun::star;
28
using namespace css::uno;
29
30
// Function for TypeConverting
31
32
template< class _type_ >
33
static bool convert( TaskManager const * pShell,
34
                  uno::Reference< script::XTypeConverter >& xConverter,
35
                  const uno::Any& rValue,
36
                  _type_& aReturn  )
37
96.6k
{
38
    // Try first without converting
39
96.6k
    bool no_success = ! ( rValue >>= aReturn );
40
41
96.6k
    if ( no_success )
42
0
    {
43
0
        if( ! xConverter.is() )
44
0
        {
45
0
            xConverter = script::Converter::create(pShell->m_xContext);
46
0
        }
47
48
0
        try
49
0
        {
50
0
            if( rValue.hasValue() )
51
0
            {
52
0
                uno::Any aConvertedValue
53
0
                    = xConverter->convertTo( rValue,cppu::UnoType<_type_>::get() );
54
0
                no_success = ! ( aConvertedValue >>= aReturn );
55
0
            }
56
0
            else
57
0
                no_success = true;
58
0
        }
59
0
        catch (const lang::IllegalArgumentException&)
60
0
        {
61
0
            no_success = true;
62
0
        }
63
0
        catch (const script::CannotConvertException&)
64
0
        {
65
0
            no_success = true;
66
0
        }
67
0
    }
68
96.6k
    return no_success;
69
96.6k
}
filrow.cxx:bool convert<rtl::OUString>(fileaccess::TaskManager const*, com::sun::star::uno::Reference<com::sun::star::script::XTypeConverter>&, com::sun::star::uno::Any const&, rtl::OUString&)
Line
Count
Source
37
96.6k
{
38
    // Try first without converting
39
96.6k
    bool no_success = ! ( rValue >>= aReturn );
40
41
96.6k
    if ( no_success )
42
0
    {
43
0
        if( ! xConverter.is() )
44
0
        {
45
0
            xConverter = script::Converter::create(pShell->m_xContext);
46
0
        }
47
48
0
        try
49
0
        {
50
0
            if( rValue.hasValue() )
51
0
            {
52
0
                uno::Any aConvertedValue
53
0
                    = xConverter->convertTo( rValue,cppu::UnoType<_type_>::get() );
54
0
                no_success = ! ( aConvertedValue >>= aReturn );
55
0
            }
56
0
            else
57
0
                no_success = true;
58
0
        }
59
0
        catch (const lang::IllegalArgumentException&)
60
0
        {
61
0
            no_success = true;
62
0
        }
63
0
        catch (const script::CannotConvertException&)
64
0
        {
65
0
            no_success = true;
66
0
        }
67
0
    }
68
96.6k
    return no_success;
69
96.6k
}
Unexecuted instantiation: filrow.cxx:bool convert<bool>(fileaccess::TaskManager const*, com::sun::star::uno::Reference<com::sun::star::script::XTypeConverter>&, com::sun::star::uno::Any const&, bool&)
Unexecuted instantiation: filrow.cxx:bool convert<signed char>(fileaccess::TaskManager const*, com::sun::star::uno::Reference<com::sun::star::script::XTypeConverter>&, com::sun::star::uno::Any const&, signed char&)
Unexecuted instantiation: filrow.cxx:bool convert<short>(fileaccess::TaskManager const*, com::sun::star::uno::Reference<com::sun::star::script::XTypeConverter>&, com::sun::star::uno::Any const&, short&)
Unexecuted instantiation: filrow.cxx:bool convert<int>(fileaccess::TaskManager const*, com::sun::star::uno::Reference<com::sun::star::script::XTypeConverter>&, com::sun::star::uno::Any const&, int&)
Unexecuted instantiation: filrow.cxx:bool convert<long>(fileaccess::TaskManager const*, com::sun::star::uno::Reference<com::sun::star::script::XTypeConverter>&, com::sun::star::uno::Any const&, long&)
Unexecuted instantiation: filrow.cxx:bool convert<float>(fileaccess::TaskManager const*, com::sun::star::uno::Reference<com::sun::star::script::XTypeConverter>&, com::sun::star::uno::Any const&, float&)
Unexecuted instantiation: filrow.cxx:bool convert<double>(fileaccess::TaskManager const*, com::sun::star::uno::Reference<com::sun::star::script::XTypeConverter>&, com::sun::star::uno::Any const&, double&)
Unexecuted instantiation: filrow.cxx:bool convert<com::sun::star::uno::Sequence<signed char> >(fileaccess::TaskManager const*, com::sun::star::uno::Reference<com::sun::star::script::XTypeConverter>&, com::sun::star::uno::Any const&, com::sun::star::uno::Sequence<signed char>&)
Unexecuted instantiation: filrow.cxx:bool convert<com::sun::star::util::Date>(fileaccess::TaskManager const*, com::sun::star::uno::Reference<com::sun::star::script::XTypeConverter>&, com::sun::star::uno::Any const&, com::sun::star::util::Date&)
Unexecuted instantiation: filrow.cxx:bool convert<com::sun::star::util::Time>(fileaccess::TaskManager const*, com::sun::star::uno::Reference<com::sun::star::script::XTypeConverter>&, com::sun::star::uno::Any const&, com::sun::star::util::Time&)
Unexecuted instantiation: filrow.cxx:bool convert<com::sun::star::util::DateTime>(fileaccess::TaskManager const*, com::sun::star::uno::Reference<com::sun::star::script::XTypeConverter>&, com::sun::star::uno::Any const&, com::sun::star::util::DateTime&)
Unexecuted instantiation: filrow.cxx:bool convert<com::sun::star::uno::Reference<com::sun::star::io::XInputStream> >(fileaccess::TaskManager const*, com::sun::star::uno::Reference<com::sun::star::script::XTypeConverter>&, com::sun::star::uno::Any const&, com::sun::star::uno::Reference<com::sun::star::io::XInputStream>&)
Unexecuted instantiation: filrow.cxx:bool convert<com::sun::star::uno::Reference<com::sun::star::sdbc::XRef> >(fileaccess::TaskManager const*, com::sun::star::uno::Reference<com::sun::star::script::XTypeConverter>&, com::sun::star::uno::Any const&, com::sun::star::uno::Reference<com::sun::star::sdbc::XRef>&)
Unexecuted instantiation: filrow.cxx:bool convert<com::sun::star::uno::Reference<com::sun::star::sdbc::XBlob> >(fileaccess::TaskManager const*, com::sun::star::uno::Reference<com::sun::star::script::XTypeConverter>&, com::sun::star::uno::Any const&, com::sun::star::uno::Reference<com::sun::star::sdbc::XBlob>&)
Unexecuted instantiation: filrow.cxx:bool convert<com::sun::star::uno::Reference<com::sun::star::sdbc::XClob> >(fileaccess::TaskManager const*, com::sun::star::uno::Reference<com::sun::star::script::XTypeConverter>&, com::sun::star::uno::Any const&, com::sun::star::uno::Reference<com::sun::star::sdbc::XClob>&)
Unexecuted instantiation: filrow.cxx:bool convert<com::sun::star::uno::Reference<com::sun::star::sdbc::XArray> >(fileaccess::TaskManager const*, com::sun::star::uno::Reference<com::sun::star::script::XTypeConverter>&, com::sun::star::uno::Any const&, com::sun::star::uno::Reference<com::sun::star::sdbc::XArray>&)
70
71
72
XRow_impl::XRow_impl( TaskManager* pMyShell,const uno::Sequence< uno::Any >& seq )
73
106k
    : m_aValueMap( seq ),
74
106k
      m_nWasNull(false),
75
106k
      m_pMyShell( pMyShell )
76
106k
{
77
106k
}
78
79
XRow_impl::~XRow_impl()
80
106k
{
81
106k
}
82
83
84
sal_Bool SAL_CALL
85
XRow_impl::wasNull()
86
0
{
87
0
  std::scoped_lock aGuard( m_aMutex );
88
0
  return m_nWasNull;
89
0
}
90
91
92
OUString SAL_CALL
93
XRow_impl::getString(
94
             sal_Int32 columnIndex )
95
96.6k
{
96
96.6k
  if( isIndexOutOfBounds( columnIndex ) )
97
0
    throw sdbc::SQLException( u""_ustr, uno::Reference< uno::XInterface >(), OUString(), 0, uno::Any() );
98
96.6k
  return getValue<OUString>(columnIndex);
99
96.6k
}
100
101
sal_Bool SAL_CALL
102
XRow_impl::getBoolean(
103
    sal_Int32 columnIndex )
104
0
{
105
0
    if( isIndexOutOfBounds( columnIndex ) )
106
0
        throw sdbc::SQLException( u""_ustr, uno::Reference< uno::XInterface >(), OUString(), 0, uno::Any() );
107
0
    return getValue<bool>(columnIndex);
108
0
}
109
110
111
sal_Int8 SAL_CALL
112
XRow_impl::getByte(
113
    sal_Int32 columnIndex )
114
0
{
115
0
    if( isIndexOutOfBounds( columnIndex ) )
116
0
        throw sdbc::SQLException( u""_ustr, uno::Reference< uno::XInterface >(), OUString(), 0, uno::Any() );
117
0
    return getValue<sal_Int8>(columnIndex);
118
0
}
119
120
sal_Int16 SAL_CALL
121
XRow_impl::getShort(
122
    sal_Int32 columnIndex )
123
0
{
124
0
    if( isIndexOutOfBounds( columnIndex ) )
125
0
        throw sdbc::SQLException( u""_ustr, uno::Reference< uno::XInterface >(), OUString(), 0, uno::Any() );
126
0
    return getValue<sal_Int16>(columnIndex);
127
0
}
128
129
130
sal_Int32 SAL_CALL
131
XRow_impl::getInt(
132
          sal_Int32 columnIndex )
133
0
{
134
0
    if( isIndexOutOfBounds( columnIndex ) )
135
0
        throw sdbc::SQLException( u""_ustr, uno::Reference< uno::XInterface >(), OUString(), 0, uno::Any() );
136
0
    return getValue<sal_Int32>(columnIndex);
137
0
}
138
139
sal_Int64 SAL_CALL
140
XRow_impl::getLong(
141
           sal_Int32 columnIndex )
142
0
{
143
0
    if( isIndexOutOfBounds( columnIndex ) )
144
0
        throw sdbc::SQLException( u""_ustr, uno::Reference< uno::XInterface >(), OUString(), 0, uno::Any() );
145
0
    return getValue<sal_Int64>(columnIndex);
146
0
}
147
148
float SAL_CALL
149
XRow_impl::getFloat(
150
    sal_Int32 columnIndex )
151
0
{
152
0
    if( isIndexOutOfBounds( columnIndex ) )
153
0
        throw sdbc::SQLException( u""_ustr, uno::Reference< uno::XInterface >(), OUString(), 0, uno::Any() );
154
0
    return getValue<float>(columnIndex);
155
0
}
156
157
double SAL_CALL
158
XRow_impl::getDouble(
159
    sal_Int32 columnIndex )
160
0
{
161
0
    if( isIndexOutOfBounds( columnIndex ) )
162
0
        throw sdbc::SQLException( u""_ustr, uno::Reference< uno::XInterface >(), OUString(), 0, uno::Any() );
163
0
    return getValue<double>(columnIndex);
164
0
}
165
166
uno::Sequence< sal_Int8 > SAL_CALL
167
XRow_impl::getBytes(
168
    sal_Int32 columnIndex )
169
0
{
170
0
    if( isIndexOutOfBounds( columnIndex ) )
171
0
        throw sdbc::SQLException( u""_ustr, uno::Reference< uno::XInterface >(), OUString(), 0, uno::Any() );
172
0
    return getValue<uno::Sequence< sal_Int8 >>(columnIndex);
173
0
}
174
175
util::Date SAL_CALL
176
XRow_impl::getDate(
177
    sal_Int32 columnIndex )
178
0
{
179
0
    if( isIndexOutOfBounds( columnIndex ) )
180
0
        throw sdbc::SQLException( u""_ustr, uno::Reference< uno::XInterface >(), OUString(), 0, uno::Any() );
181
0
    return getValue<util::Date>(columnIndex);
182
0
}
183
184
util::Time SAL_CALL
185
XRow_impl::getTime(
186
    sal_Int32 columnIndex )
187
0
{
188
0
    if( isIndexOutOfBounds( columnIndex ) )
189
0
        throw sdbc::SQLException( u""_ustr, uno::Reference< uno::XInterface >(), OUString(), 0, uno::Any() );
190
0
    return getValue<util::Time>(columnIndex);
191
0
}
192
193
util::DateTime SAL_CALL
194
XRow_impl::getTimestamp(
195
            sal_Int32 columnIndex )
196
0
{
197
0
  if( isIndexOutOfBounds( columnIndex ) )
198
0
    throw sdbc::SQLException( u""_ustr, uno::Reference< uno::XInterface >(), OUString(), 0, uno::Any() );
199
0
  return getValue<util::DateTime>(columnIndex);
200
0
}
201
202
203
uno::Reference< io::XInputStream > SAL_CALL
204
XRow_impl::getBinaryStream(
205
               sal_Int32 columnIndex )
206
0
{
207
0
  if( isIndexOutOfBounds( columnIndex ) )
208
0
    throw sdbc::SQLException( u""_ustr, uno::Reference< uno::XInterface >(), OUString(), 0, uno::Any() );
209
0
  return getValue<uno::Reference< io::XInputStream >>(columnIndex);
210
0
}
211
212
213
uno::Reference< io::XInputStream > SAL_CALL
214
XRow_impl::getCharacterStream(
215
                  sal_Int32 columnIndex )
216
0
{
217
0
  if( isIndexOutOfBounds( columnIndex ) )
218
0
      throw sdbc::SQLException( u""_ustr, uno::Reference< uno::XInterface >(), OUString(), 0, uno::Any() );
219
0
  return getValue<uno::Reference< io::XInputStream >>(columnIndex);
220
0
}
221
222
223
uno::Any SAL_CALL
224
XRow_impl::getObject(
225
    sal_Int32 columnIndex,
226
    const uno::Reference< container::XNameAccess >& )
227
9.73k
{
228
9.73k
    if( isIndexOutOfBounds( columnIndex ) )
229
0
        throw sdbc::SQLException( u""_ustr, uno::Reference< uno::XInterface >(), OUString(), 0, uno::Any() );
230
9.73k
    std::scoped_lock aGuard( m_aMutex );
231
9.73k
    uno::Any Value = m_aValueMap[columnIndex - 1];
232
9.73k
    m_nWasNull = !Value.hasValue();
233
9.73k
    return Value;
234
9.73k
}
235
236
uno::Reference< sdbc::XRef > SAL_CALL
237
XRow_impl::getRef(
238
    sal_Int32 columnIndex )
239
0
{
240
0
    if( isIndexOutOfBounds( columnIndex ) )
241
0
        throw sdbc::SQLException( u""_ustr, uno::Reference< uno::XInterface >(), OUString(), 0, uno::Any() );
242
0
    return getValue<uno::Reference< sdbc::XRef >>(columnIndex);
243
0
}
244
245
uno::Reference< sdbc::XBlob > SAL_CALL
246
XRow_impl::getBlob(
247
           sal_Int32 columnIndex )
248
0
{
249
0
    if( isIndexOutOfBounds( columnIndex ) )
250
0
        throw sdbc::SQLException( u""_ustr, uno::Reference< uno::XInterface >(), OUString(), 0, uno::Any() );
251
0
    return getValue<uno::Reference< sdbc::XBlob >>(columnIndex);
252
0
}
253
254
uno::Reference< sdbc::XClob > SAL_CALL
255
XRow_impl::getClob(
256
           sal_Int32 columnIndex )
257
0
{
258
0
    if( isIndexOutOfBounds( columnIndex ) )
259
0
        throw sdbc::SQLException( u""_ustr, uno::Reference< uno::XInterface >(), OUString(), 0, uno::Any() );
260
0
    return getValue<uno::Reference< sdbc::XClob >>(columnIndex);
261
0
}
262
263
264
uno::Reference< sdbc::XArray > SAL_CALL
265
XRow_impl::getArray(
266
    sal_Int32 columnIndex )
267
0
{
268
0
    if( isIndexOutOfBounds( columnIndex ) )
269
0
        throw sdbc::SQLException( u""_ustr, uno::Reference< uno::XInterface >(), OUString(), 0, uno::Any() );
270
0
    return getValue<uno::Reference< sdbc::XArray >>(columnIndex);
271
0
}
272
273
bool
274
XRow_impl::isIndexOutOfBounds(sal_Int32 nIndex) const
275
106k
{
276
106k
    return nIndex < 1 || m_aValueMap.getLength() < nIndex;
277
106k
}
278
279
template<typename T>
280
T XRow_impl::getValue(sal_Int32 columnIndex)
281
96.6k
{
282
96.6k
    T aValue{};
283
96.6k
    std::scoped_lock aGuard( m_aMutex );
284
96.6k
    m_nWasNull = ::convert<T>( m_pMyShell, m_xTypeConverter, m_aValueMap[ --columnIndex ], aValue );
285
96.6k
    return aValue;
286
96.6k
}
rtl::OUString fileaccess::XRow_impl::getValue<rtl::OUString>(int)
Line
Count
Source
281
96.6k
{
282
96.6k
    T aValue{};
283
96.6k
    std::scoped_lock aGuard( m_aMutex );
284
96.6k
    m_nWasNull = ::convert<T>( m_pMyShell, m_xTypeConverter, m_aValueMap[ --columnIndex ], aValue );
285
96.6k
    return aValue;
286
96.6k
}
Unexecuted instantiation: bool fileaccess::XRow_impl::getValue<bool>(int)
Unexecuted instantiation: signed char fileaccess::XRow_impl::getValue<signed char>(int)
Unexecuted instantiation: short fileaccess::XRow_impl::getValue<short>(int)
Unexecuted instantiation: int fileaccess::XRow_impl::getValue<int>(int)
Unexecuted instantiation: long fileaccess::XRow_impl::getValue<long>(int)
Unexecuted instantiation: float fileaccess::XRow_impl::getValue<float>(int)
Unexecuted instantiation: double fileaccess::XRow_impl::getValue<double>(int)
Unexecuted instantiation: com::sun::star::uno::Sequence<signed char> fileaccess::XRow_impl::getValue<com::sun::star::uno::Sequence<signed char> >(int)
Unexecuted instantiation: com::sun::star::util::Date fileaccess::XRow_impl::getValue<com::sun::star::util::Date>(int)
Unexecuted instantiation: com::sun::star::util::Time fileaccess::XRow_impl::getValue<com::sun::star::util::Time>(int)
Unexecuted instantiation: com::sun::star::util::DateTime fileaccess::XRow_impl::getValue<com::sun::star::util::DateTime>(int)
Unexecuted instantiation: com::sun::star::uno::Reference<com::sun::star::io::XInputStream> fileaccess::XRow_impl::getValue<com::sun::star::uno::Reference<com::sun::star::io::XInputStream> >(int)
Unexecuted instantiation: com::sun::star::uno::Reference<com::sun::star::sdbc::XRef> fileaccess::XRow_impl::getValue<com::sun::star::uno::Reference<com::sun::star::sdbc::XRef> >(int)
Unexecuted instantiation: com::sun::star::uno::Reference<com::sun::star::sdbc::XBlob> fileaccess::XRow_impl::getValue<com::sun::star::uno::Reference<com::sun::star::sdbc::XBlob> >(int)
Unexecuted instantiation: com::sun::star::uno::Reference<com::sun::star::sdbc::XClob> fileaccess::XRow_impl::getValue<com::sun::star::uno::Reference<com::sun::star::sdbc::XClob> >(int)
Unexecuted instantiation: com::sun::star::uno::Reference<com::sun::star::sdbc::XArray> fileaccess::XRow_impl::getValue<com::sun::star::uno::Reference<com::sun::star::sdbc::XArray> >(int)
287
288
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */