Coverage Report

Created: 2026-02-14 09:37

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/connectivity/source/sdbcx/VIndex.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 <sdbcx/VIndex.hxx>
21
#include <com/sun/star/beans/PropertyAttribute.hpp>
22
#include <comphelper/sequence.hxx>
23
#include <connectivity/sdbcx/VCollection.hxx>
24
#include <cppuhelper/supportsservice.hxx>
25
#include <TConnection.hxx>
26
#include <utility>
27
#include <comphelper/diagnose_ex.hxx>
28
29
using namespace ::connectivity;
30
using namespace ::dbtools;
31
using namespace ::connectivity::sdbcx;
32
using namespace ::cppu;
33
using namespace ::com::sun::star::beans;
34
using namespace ::com::sun::star::uno;
35
using namespace ::com::sun::star::sdbcx;
36
using namespace ::com::sun::star::container;
37
using namespace ::com::sun::star::lang;
38
39
40
OUString SAL_CALL OIndex::getImplementationName(  )
41
0
{
42
0
    if(isNew())
43
0
        return u"com.sun.star.sdbcx.VIndexDescriptor"_ustr;
44
0
    return u"com.sun.star.sdbcx.VIndex"_ustr;
45
0
}
46
47
css::uno::Sequence< OUString > SAL_CALL OIndex::getSupportedServiceNames(  )
48
0
{
49
0
    return { isNew()?u"com.sun.star.sdbcx.IndexDescriptor"_ustr:u"com.sun.star.sdbcx.Index"_ustr };
50
0
}
51
52
sal_Bool SAL_CALL OIndex::supportsService( const OUString& _rServiceName )
53
0
{
54
0
    return cppu::supportsService(this, _rServiceName);
55
0
}
56
57
0
OIndex::OIndex(bool _bCase) : ODescriptor_BASE(m_aMutex)
58
0
                ,   ODescriptor(ODescriptor_BASE::rBHelper,_bCase,true)
59
0
                ,m_IsUnique(false)
60
0
                ,m_IsPrimaryKeyIndex(false)
61
0
                ,m_IsClustered(false)
62
0
{
63
0
}
64
65
OIndex::OIndex( const OUString& Name,
66
                OUString Catalog,
67
                bool _isUnique,
68
                bool _isPrimaryKeyIndex,
69
                bool _isClustered,
70
0
                bool _bCase) :  ODescriptor_BASE(m_aMutex)
71
0
                        ,ODescriptor(ODescriptor_BASE::rBHelper, _bCase)
72
0
                        ,m_Catalog(std::move(Catalog))
73
0
                        ,m_IsUnique(_isUnique)
74
0
                        ,m_IsPrimaryKeyIndex(_isPrimaryKeyIndex)
75
0
                        ,m_IsClustered(_isClustered)
76
0
{
77
0
    m_Name = Name;
78
0
}
79
80
OIndex::~OIndex( )
81
0
{
82
0
}
83
84
::cppu::IPropertyArrayHelper* OIndex::createArrayHelper( sal_Int32 /*_nId*/ ) const
85
0
{
86
0
    return doCreateArrayHelper();
87
0
}
88
89
::cppu::IPropertyArrayHelper& SAL_CALL OIndex::getInfoHelper()
90
0
{
91
0
    return *OIndex_PROP::getArrayHelper(isNew() ? 1 : 0);
92
0
}
93
94
Any SAL_CALL OIndex::queryInterface( const Type & rType )
95
0
{
96
0
    Any aRet = ODescriptor::queryInterface( rType);
97
0
    if(!aRet.hasValue())
98
0
    {
99
0
        if(!isNew())
100
0
            aRet = OIndex_BASE::queryInterface(rType);
101
0
        if(!aRet.hasValue())
102
0
            aRet = ODescriptor_BASE::queryInterface( rType);
103
0
    }
104
0
    return aRet;
105
0
}
106
107
Sequence< Type > SAL_CALL OIndex::getTypes(  )
108
0
{
109
0
    if(isNew())
110
0
        return ::comphelper::concatSequences(ODescriptor::getTypes(),ODescriptor_BASE::getTypes());
111
0
    return ::comphelper::concatSequences(ODescriptor::getTypes(),ODescriptor_BASE::getTypes(),OIndex_BASE::getTypes());
112
0
}
113
114
void OIndex::construct()
115
0
{
116
0
    ODescriptor::construct();
117
118
0
    sal_Int32 nAttrib = isNew() ? 0 : PropertyAttribute::READONLY;
119
120
0
    registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_CATALOG),         PROPERTY_ID_CATALOG,            nAttrib,&m_Catalog,         ::cppu::UnoType<OUString>::get());
121
0
    registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISUNIQUE),            PROPERTY_ID_ISUNIQUE,           nAttrib,&m_IsUnique,            cppu::UnoType<bool>::get());
122
0
    registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISPRIMARYKEYINDEX),PROPERTY_ID_ISPRIMARYKEYINDEX, nAttrib,&m_IsPrimaryKeyIndex,   cppu::UnoType<bool>::get());
123
0
    registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISCLUSTERED),     PROPERTY_ID_ISCLUSTERED,        nAttrib,&m_IsClustered,     cppu::UnoType<bool>::get());
124
0
}
125
126
void OIndex::disposing()
127
0
{
128
0
    OPropertySetHelper::disposing();
129
130
0
    ::osl::MutexGuard aGuard(m_aMutex);
131
132
0
    if(m_pColumns)
133
0
        m_pColumns->disposing();
134
0
}
135
136
Reference< css::container::XNameAccess > SAL_CALL OIndex::getColumns(  )
137
0
{
138
0
    ::osl::MutexGuard aGuard(m_aMutex);
139
0
    checkDisposed(ODescriptor_BASE::rBHelper.bDisposed);
140
141
0
    try
142
0
    {
143
0
        if  ( !m_pColumns )
144
0
            refreshColumns();
145
0
    }
146
0
    catch( const RuntimeException& )
147
0
    {
148
        // allowed to leave this method
149
0
        throw;
150
0
    }
151
0
    catch( const Exception& )
152
0
    {
153
0
        TOOLS_WARN_EXCEPTION( "connectivity.commontools", "OIndex::getColumns" );
154
0
    }
155
156
0
    return m_pColumns.get();
157
0
}
158
159
Reference< XPropertySet > SAL_CALL OIndex::createDataDescriptor(  )
160
0
{
161
0
    ::osl::MutexGuard aGuard(m_aMutex);
162
0
    checkDisposed(ODescriptor_BASE::rBHelper.bDisposed);
163
164
165
0
    return this;
166
0
}
167
168
css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL OIndex::getPropertySetInfo(  )
169
0
{
170
0
    return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
171
0
}
172
173
OUString SAL_CALL OIndex::getName(  )
174
0
{
175
0
    return m_Name;
176
0
}
177
178
void SAL_CALL OIndex::setName( const OUString& /*aName*/ )
179
0
{
180
0
}
181
182
// XInterface
183
void SAL_CALL OIndex::acquire() noexcept
184
0
{
185
0
    ODescriptor_BASE::acquire();
186
0
}
187
188
void SAL_CALL OIndex::release() noexcept
189
0
{
190
0
    ODescriptor_BASE::release();
191
0
}
192
193
void OIndex::refreshColumns()
194
0
{
195
0
}
196
197
198
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */