LibreOffice Module connectivity (master) 1
TIndex.cxx
Go to the documentation of this file.
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>
25#include <TConnection.hxx>
26
27using namespace connectivity;
28using namespace connectivity::sdbcx;
29using namespace ::com::sun::star::uno;
30using namespace ::com::sun::star::beans;
31using namespace ::com::sun::star::sdbc;
32using namespace ::com::sun::star::container;
33using namespace ::com::sun::star::lang;
34
35OIndexHelper::OIndexHelper( OTableHelper* _pTable) : connectivity::sdbcx::OIndex(true)
36 , m_pTable(_pTable)
37{
38 construct();
39 std::vector< OUString> aVector;
40 m_pColumns.reset(new OIndexColumns(this,m_aMutex,aVector));
41}
42
44 const OUString& Name,
45 const OUString& Catalog,
46 bool _isUnique,
47 bool _isPrimaryKeyIndex,
48 bool _isClustered
49 ) : connectivity::sdbcx::OIndex(Name,
50 Catalog,
51 _isUnique,
52 _isPrimaryKeyIndex,
53 _isClustered,true)
54 ,m_pTable(_pTable)
55{
56 construct();
58}
59
60
62{
63 if ( !m_pTable )
64 return;
65
66 std::vector< OUString> aVector;
67 if ( !isNew() )
68 {
70 OUString aSchema,aTable;
71 m_pTable->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_SCHEMANAME)) >>= aSchema;
72 m_pTable->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_NAME)) >>= aTable;
73
74 Reference< XResultSet > xResult = m_pTable->getMetaData()->getIndexInfo(
75 m_pTable->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_CATALOGNAME)),
76 aSchema,aTable,false,false);
77
78 if ( xResult.is() )
79 {
80 Reference< XRow > xRow(xResult,UNO_QUERY);
81 OUString aColName;
82 while( xResult->next() )
83 {
84 if ( xRow->getString(6) == m_Name )
85 {
86 aColName = xRow->getString(9);
87 if ( !xRow->wasNull() )
88 aVector.push_back(aColName);
89 }
90 }
91 }
92 }
93 if(m_pColumns)
94 m_pColumns->reFill(aVector);
95 else
96 m_pColumns.reset(new OIndexColumns(this,m_aMutex,aVector));
97}
98
99
100/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OIndexHelper(OTableHelper *_pTable)
Definition: TIndex.cxx:35
OTableHelper * m_pTable
Definition: TIndex.hxx:29
virtual void refreshColumns() override
Definition: TIndex.cxx:61
::dbtools::OPropertyMap & getPropMap()
Definition: TConnection.cxx:68
virtual css::uno::Reference< css::sdbc::XDatabaseMetaData > getMetaData() const override
std::unique_ptr< OCollection > m_pColumns
Definition: VIndex.hxx:54
virtual void construct() override
Definition: VIndex.cxx:116
mutable::osl::Mutex m_aMutex
const OUString & getNameByIndex(sal_Int32 _nIndex) const
Definition: propertyids.cxx:95
#define PROPERTY_ID_NAME
Definition: propertyids.hxx:50
#define PROPERTY_ID_CATALOGNAME
Definition: propertyids.hxx:70
#define PROPERTY_ID_SCHEMANAME
Definition: propertyids.hxx:69
OUString Name