Coverage Report

Created: 2026-08-14 10:22

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/connectivity/source/commontools/TIndex.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 <TIndex.hxx>
21
#include <TIndexColumns.hxx>
22
#include <com/sun/star/sdbc/XRow.hpp>
23
#include <com/sun/star/sdbc/XResultSet.hpp>
24
#include <connectivity/TTableHelper.hxx>
25
#include <TConnection.hxx>
26
27
using namespace connectivity;
28
using namespace connectivity::sdbcx;
29
using namespace ::com::sun::star::uno;
30
using namespace ::com::sun::star::sdbc;
31
32
0
OIndexHelper::OIndexHelper( OTableHelper* _pTable) : connectivity::sdbcx::OIndex(true)
33
0
                 , m_pTable(_pTable)
34
0
{
35
0
    construct();
36
0
    std::vector< OUString> aVector;
37
0
    m_pColumns.reset(new OIndexColumns(this,m_aMutex,aVector));
38
0
}
39
40
OIndexHelper::OIndexHelper( OTableHelper* _pTable,
41
                const OUString& Name,
42
                const OUString& Catalog,
43
                bool _isUnique,
44
                bool _isPrimaryKeyIndex,
45
                bool _isClustered
46
0
                ) : connectivity::sdbcx::OIndex(Name,
47
0
                                  Catalog,
48
0
                                  _isUnique,
49
0
                                  _isPrimaryKeyIndex,
50
0
                                  _isClustered,true)
51
0
                ,m_pTable(_pTable)
52
0
{
53
0
    construct();
54
0
    refreshColumns();
55
0
}
56
57
58
void OIndexHelper::refreshColumns()
59
0
{
60
0
    if ( !m_pTable )
61
0
        return;
62
63
0
    std::vector< OUString> aVector;
64
0
    if ( !isNew() )
65
0
    {
66
0
        ::dbtools::OPropertyMap& rPropMap = OMetaConnection::getPropMap();
67
0
        OUString aSchema,aTable;
68
0
        m_pTable->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_SCHEMANAME)) >>= aSchema;
69
0
        m_pTable->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_NAME))       >>= aTable;
70
71
0
        Reference< XResultSet > xResult = m_pTable->getMetaData()->getIndexInfo(
72
0
            m_pTable->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_CATALOGNAME)),
73
0
            aSchema,aTable,false,false);
74
75
0
        if ( xResult.is() )
76
0
        {
77
0
            Reference< XRow > xRow(xResult,UNO_QUERY);
78
0
            OUString aColName;
79
0
            while( xResult->next() )
80
0
            {
81
0
                if ( xRow->getString(6) == m_Name )
82
0
                {
83
0
                    aColName = xRow->getString(9);
84
0
                    if ( !xRow->wasNull() )
85
0
                        aVector.push_back(aColName);
86
0
                }
87
0
            }
88
0
        }
89
0
    }
90
0
    if(m_pColumns)
91
0
        m_pColumns->reFill(aVector);
92
0
    else
93
0
        m_pColumns.reset(new OIndexColumns(this,m_aMutex,aVector));
94
0
}
95
96
97
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */