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