Coverage Report

Created: 2026-02-14 09:37

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/connectivity/source/commontools/TIndexColumns.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 <TIndexColumns.hxx>
21
#include <sdbcx/VIndexColumn.hxx>
22
#include <com/sun/star/sdbc/XRow.hpp>
23
#include <com/sun/star/sdbc/XResultSet.hpp>
24
#include <TIndex.hxx>
25
#include <connectivity/TTableHelper.hxx>
26
#include <TConnection.hxx>
27
28
using namespace connectivity;
29
using namespace connectivity::sdbcx;
30
using namespace ::com::sun::star::uno;
31
using namespace ::com::sun::star::beans;
32
using namespace ::com::sun::star::sdbc;
33
34
OIndexColumns::OIndexColumns(   OIndexHelper* _pIndex,
35
                        ::osl::Mutex& _rMutex,
36
                        const std::vector< OUString> &_rVector)
37
0
            : connectivity::sdbcx::OCollection(*_pIndex,true,_rMutex,_rVector)
38
0
            ,m_pIndex(_pIndex)
39
0
{
40
0
}
41
42
css::uno::Reference< css::beans::XPropertySet > OIndexColumns::createObject(const OUString& _rName)
43
0
{
44
0
    ::dbtools::OPropertyMap& rPropMap = OMetaConnection::getPropMap();
45
0
    OUString aCatalog, aSchema, aTable;
46
0
    css::uno::Any Catalog(m_pIndex->getTable()->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_CATALOGNAME)));
47
0
    Catalog >>= aCatalog;
48
0
    m_pIndex->getTable()->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_SCHEMANAME)) >>= aSchema;
49
0
    m_pIndex->getTable()->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_NAME))       >>= aTable;
50
51
0
    Reference< XResultSet > xResult = m_pIndex->getTable()->getConnection()->getMetaData()->getIndexInfo(
52
0
        Catalog, aSchema, aTable, false, false);
53
54
0
    bool bAsc = true;
55
0
    if ( xResult.is() )
56
0
    {
57
0
        Reference< XRow > xRow(xResult,UNO_QUERY);
58
0
        while( xResult->next() )
59
0
        {
60
0
            if(xRow->getString(9) == _rName)
61
0
                bAsc = xRow->getString(10) != "D";
62
0
        }
63
0
    }
64
65
0
    xResult = m_pIndex->getTable()->getConnection()->getMetaData()->getColumns(
66
0
        Catalog, aSchema, aTable, _rName);
67
68
0
    if ( !xResult.is() )
69
0
        return nullptr;
70
71
0
    rtl::Reference< OIndexColumn > xRet;
72
0
    Reference< XRow > xRow(xResult,UNO_QUERY);
73
0
    while( xResult->next() )
74
0
    {
75
0
        if ( xRow->getString(4) == _rName )
76
0
        {
77
0
            sal_Int32 nDataType = xRow->getInt(5);
78
0
            OUString aTypeName(xRow->getString(6));
79
0
            sal_Int32 nSize = xRow->getInt(7);
80
0
            sal_Int32 nDec  = xRow->getInt(9);
81
0
            sal_Int32 nNull = xRow->getInt(11);
82
0
            OUString aColumnDef(xRow->getString(13));
83
84
0
            xRet = new OIndexColumn(bAsc,
85
0
                                    _rName,
86
0
                                    aTypeName,
87
0
                                    aColumnDef,
88
0
                                    nNull,
89
0
                                    nSize,
90
0
                                    nDec,
91
0
                                    nDataType,
92
0
                                    true,
93
0
                                    aCatalog, aSchema, aTable);
94
0
            break;
95
0
        }
96
0
    }
97
98
0
    return xRet;
99
0
}
100
101
Reference< XPropertySet > OIndexColumns::createDescriptor()
102
0
{
103
0
    return new OIndexColumn(true);
104
0
}
105
106
void OIndexColumns::impl_refresh()
107
0
{
108
0
    m_pIndex->refreshColumns();
109
0
}
110
111
112
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */