Coverage Report

Created: 2025-11-16 09:57

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/connectivity/source/sdbcx/VColumn.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 <connectivity/sdbcx/VColumn.hxx>
21
#include <com/sun/star/beans/PropertyAttribute.hpp>
22
#include <comphelper/sequence.hxx>
23
#include <cppuhelper/supportsservice.hxx>
24
#include <TConnection.hxx>
25
#include <com/sun/star/sdbc/ColumnValue.hpp>
26
#include <utility>
27
28
using namespace connectivity;
29
using namespace connectivity::sdbcx;
30
using namespace cppu;
31
using namespace ::com::sun::star::beans;
32
using namespace ::com::sun::star::uno;
33
using namespace ::com::sun::star::lang;
34
using namespace ::com::sun::star::sdbc;
35
36
37
OUString SAL_CALL OColumn::getImplementationName(  )
38
0
{
39
0
    if(isNew())
40
0
        return u"com.sun.star.sdbcx.VColumnDescriptor"_ustr;
41
0
    return u"com.sun.star.sdbcx.VColumn"_ustr;
42
0
}
43
44
css::uno::Sequence< OUString > SAL_CALL OColumn::getSupportedServiceNames(  )
45
0
{
46
0
    return { isNew()?u"com.sun.star.sdbcx.ColumnDescriptor"_ustr:u"com.sun.star.sdbcx.Column"_ustr };
47
0
}
48
49
sal_Bool SAL_CALL OColumn::supportsService( const OUString& _rServiceName )
50
0
{
51
0
    return cppu::supportsService(this, _rServiceName);
52
0
}
53
54
OColumn::OColumn(bool _bCase)
55
0
    :OColumnDescriptor_BASE(m_aMutex)
56
0
    ,ODescriptor(OColumnDescriptor_BASE::rBHelper,_bCase,true)
57
0
    ,m_IsNullable(ColumnValue::NULLABLE)
58
0
    ,m_Precision(0)
59
0
    ,m_Scale(0)
60
0
    ,m_Type(0)
61
0
    ,m_IsAutoIncrement(false)
62
0
    ,m_IsRowVersion(false)
63
0
    ,m_IsCurrency(false)
64
0
{
65
0
    construct();
66
0
}
67
68
OColumn::OColumn(   const OUString& Name,
69
                    OUString TypeName,
70
                    OUString DefaultValue,
71
                    OUString Description,
72
                    sal_Int32       IsNullable,
73
                    sal_Int32       Precision,
74
                    sal_Int32       Scale,
75
                    sal_Int32       Type,
76
                    bool            IsAutoIncrement,
77
                    bool            IsRowVersion,
78
                    bool            IsCurrency,
79
                    bool            _bCase,
80
                    OUString CatalogName,
81
                    OUString SchemaName,
82
                    OUString TableName)
83
2.94M
    :OColumnDescriptor_BASE(m_aMutex)
84
2.94M
    ,ODescriptor(OColumnDescriptor_BASE::rBHelper,_bCase)
85
2.94M
    ,m_TypeName(std::move(TypeName))
86
2.94M
    ,m_Description(std::move(Description))
87
2.94M
    ,m_DefaultValue(std::move(DefaultValue))
88
2.94M
    ,m_IsNullable(IsNullable)
89
2.94M
    ,m_Precision(Precision)
90
2.94M
    ,m_Scale(Scale)
91
2.94M
    ,m_Type(Type)
92
2.94M
    ,m_IsAutoIncrement(IsAutoIncrement)
93
2.94M
    ,m_IsRowVersion(IsRowVersion)
94
2.94M
    ,m_IsCurrency(IsCurrency)
95
2.94M
    ,m_CatalogName(std::move(CatalogName))
96
2.94M
    ,m_SchemaName(std::move(SchemaName))
97
2.94M
    ,m_TableName(std::move(TableName))
98
2.94M
{
99
2.94M
    m_Name = Name;
100
101
2.94M
    construct();
102
2.94M
}
103
104
OColumn::~OColumn()
105
2.94M
{
106
2.94M
}
107
108
::cppu::IPropertyArrayHelper* OColumn::createArrayHelper( sal_Int32 /*_nId*/ ) const
109
28.5k
{
110
28.5k
    return doCreateArrayHelper();
111
28.5k
}
112
113
::cppu::IPropertyArrayHelper& SAL_CALL OColumn::getInfoHelper()
114
236M
{
115
236M
    return *OColumn_PROP::getArrayHelper(isNew() ? 1 : 0);
116
236M
}
117
118
void SAL_CALL OColumn::acquire() noexcept
119
42.4M
{
120
42.4M
    OColumnDescriptor_BASE::acquire();
121
42.4M
}
122
123
void SAL_CALL OColumn::release() noexcept
124
42.4M
{
125
42.4M
    OColumnDescriptor_BASE::release();
126
42.4M
}
127
128
Any SAL_CALL OColumn::queryInterface( const Type & rType )
129
13.9M
{
130
13.9M
    Any aRet = ODescriptor::queryInterface( rType);
131
13.9M
    if(!aRet.hasValue())
132
13.6M
    {
133
13.6M
        if(!isNew())
134
13.6M
            aRet = OColumn_BASE::queryInterface(rType);
135
13.6M
        if(!aRet.hasValue())
136
3.40M
            aRet = OColumnDescriptor_BASE::queryInterface( rType);
137
13.6M
    }
138
13.9M
    return aRet;
139
13.9M
}
140
141
Sequence< Type > SAL_CALL OColumn::getTypes(  )
142
0
{
143
0
    if(isNew())
144
0
        return ::comphelper::concatSequences(ODescriptor::getTypes(),OColumnDescriptor_BASE::getTypes());
145
146
0
    return ::comphelper::concatSequences(ODescriptor::getTypes(),OColumn_BASE::getTypes(),OColumnDescriptor_BASE::getTypes());
147
0
}
148
149
void OColumn::construct()
150
2.94M
{
151
2.94M
    ODescriptor::construct();
152
153
2.94M
    sal_Int32 nAttrib = isNew() ? 0 : PropertyAttribute::READONLY;
154
155
2.94M
    registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPENAME),        PROPERTY_ID_TYPENAME,           nAttrib, &m_TypeName,        cppu::UnoType<decltype(m_TypeName)>::get());
156
2.94M
    registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DESCRIPTION),     PROPERTY_ID_DESCRIPTION,        nAttrib, &m_Description,     cppu::UnoType<decltype(m_Description)>::get());
157
2.94M
    registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DEFAULTVALUE),    PROPERTY_ID_DEFAULTVALUE,       nAttrib, &m_DefaultValue,    cppu::UnoType<decltype(m_DefaultValue)>::get());
158
2.94M
    registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION),       PROPERTY_ID_PRECISION,          nAttrib, &m_Precision,       cppu::UnoType<decltype(m_Precision)>::get());
159
2.94M
    registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE),            PROPERTY_ID_TYPE,               nAttrib, &m_Type,            cppu::UnoType<decltype(m_Type)>::get());
160
2.94M
    registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE),           PROPERTY_ID_SCALE,              nAttrib, &m_Scale,           cppu::UnoType<decltype(m_Scale)>::get());
161
2.94M
    registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISNULLABLE),      PROPERTY_ID_ISNULLABLE,         nAttrib, &m_IsNullable,      cppu::UnoType<decltype(m_IsNullable)>::get());
162
2.94M
    registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISAUTOINCREMENT), PROPERTY_ID_ISAUTOINCREMENT,    nAttrib, &m_IsAutoIncrement, cppu::UnoType<bool>::get());
163
2.94M
    registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISROWVERSION),    PROPERTY_ID_ISROWVERSION,       nAttrib, &m_IsRowVersion,    cppu::UnoType<bool>::get());
164
2.94M
    registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISCURRENCY),      PROPERTY_ID_ISCURRENCY,         nAttrib, &m_IsCurrency,      cppu::UnoType<bool>::get());
165
2.94M
    registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_CATALOGNAME),     PROPERTY_ID_CATALOGNAME,        nAttrib, &m_CatalogName,     cppu::UnoType<decltype(m_CatalogName)>::get());
166
2.94M
    registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCHEMANAME),      PROPERTY_ID_SCHEMANAME,         nAttrib, &m_SchemaName,      cppu::UnoType<decltype(m_SchemaName)>::get());
167
2.94M
    registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TABLENAME),       PROPERTY_ID_TABLENAME,          nAttrib, &m_TableName,       cppu::UnoType<decltype(m_TableName)>::get());
168
2.94M
}
169
170
void OColumn::disposing()
171
2.94M
{
172
2.94M
    OPropertySetHelper::disposing();
173
2.94M
}
174
175
Reference< XPropertySet > SAL_CALL OColumn::createDataDescriptor(  )
176
0
{
177
0
    ::osl::MutexGuard aGuard(m_aMutex);
178
0
    checkDisposed(OColumnDescriptor_BASE::rBHelper.bDisposed);
179
180
0
    rtl::Reference<OColumn> pNewColumn = new OColumn(  m_Name,
181
0
                                        m_TypeName,
182
0
                                        m_DefaultValue,
183
0
                                        m_Description,
184
0
                                        m_IsNullable,
185
0
                                        m_Precision,
186
0
                                        m_Scale,
187
0
                                        m_Type,
188
0
                                        m_IsAutoIncrement,
189
0
                                        m_IsRowVersion,
190
0
                                        m_IsCurrency,
191
0
                                        isCaseSensitive(),
192
0
                                        m_CatalogName,
193
0
                                        m_SchemaName,
194
0
                                        m_TableName);
195
0
    pNewColumn->setNew(true);
196
0
    return pNewColumn;
197
0
}
198
199
css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL OColumn::getPropertySetInfo(  )
200
139M
{
201
139M
    return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
202
139M
}
203
204
// XNamed
205
OUString SAL_CALL OColumn::getName(  )
206
1.23M
{
207
1.23M
    return m_Name;
208
1.23M
}
209
210
void SAL_CALL OColumn::setName( const OUString& aName )
211
0
{
212
0
    m_Name = aName;
213
0
}
214
215
216
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */