bump product version to 6.3.0.0.beta1
[LibreOffice.git] / connectivity / source / commontools / TIndexColumns.cxx
blob966db4fc141c597c3406e1dd2a1cb3eb64f3c452
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <connectivity/TIndexColumns.hxx>
21 #include <connectivity/sdbcx/VIndexColumn.hxx>
22 #include <com/sun/star/sdbc/XRow.hpp>
23 #include <com/sun/star/sdbc/XResultSet.hpp>
24 #include <com/sun/star/sdbc/DataType.hpp>
25 #include <com/sun/star/sdbc/ColumnValue.hpp>
26 #include <connectivity/TIndex.hxx>
27 #include <connectivity/TTableHelper.hxx>
28 #include <TConnection.hxx>
30 using namespace connectivity;
31 using namespace connectivity::sdbcx;
32 using namespace ::com::sun::star::uno;
33 using namespace ::com::sun::star::beans;
34 using namespace ::com::sun::star::sdbc;
35 using namespace ::com::sun::star::container;
36 using namespace ::com::sun::star::lang;
38 OIndexColumns::OIndexColumns( OIndexHelper* _pIndex,
39 ::osl::Mutex& _rMutex,
40 const std::vector< OUString> &_rVector)
41 : connectivity::sdbcx::OCollection(*_pIndex,true,_rMutex,_rVector)
42 ,m_pIndex(_pIndex)
46 sdbcx::ObjectType OIndexColumns::createObject(const OUString& _rName)
48 ::dbtools::OPropertyMap& rPropMap = OMetaConnection::getPropMap();
49 OUString aCatalog, aSchema, aTable;
50 css::uno::Any Catalog(m_pIndex->getTable()->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_CATALOGNAME)));
51 Catalog >>= aCatalog;
52 m_pIndex->getTable()->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_SCHEMANAME)) >>= aSchema;
53 m_pIndex->getTable()->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_NAME)) >>= aTable;
55 Reference< XResultSet > xResult = m_pIndex->getTable()->getConnection()->getMetaData()->getIndexInfo(
56 Catalog, aSchema, aTable, false, false);
58 bool bAsc = true;
59 if ( xResult.is() )
61 Reference< XRow > xRow(xResult,UNO_QUERY);
62 while( xResult->next() )
64 if(xRow->getString(9) == _rName)
65 bAsc = xRow->getString(10) != "D";
69 xResult = m_pIndex->getTable()->getConnection()->getMetaData()->getColumns(
70 Catalog, aSchema, aTable, _rName);
72 sdbcx::ObjectType xRet;
73 if ( xResult.is() )
75 Reference< XRow > xRow(xResult,UNO_QUERY);
76 while( xResult->next() )
78 if ( xRow->getString(4) == _rName )
80 sal_Int32 nDataType = xRow->getInt(5);
81 OUString aTypeName(xRow->getString(6));
82 sal_Int32 nSize = xRow->getInt(7);
83 sal_Int32 nDec = xRow->getInt(9);
84 sal_Int32 nNull = xRow->getInt(11);
85 OUString aColumnDef(xRow->getString(13));
87 OIndexColumn* pRet = new OIndexColumn(bAsc,
88 _rName,
89 aTypeName,
90 aColumnDef,
91 nNull,
92 nSize,
93 nDec,
94 nDataType,
95 true,
96 aCatalog, aSchema, aTable);
97 xRet = pRet;
98 break;
103 return xRet;
106 Reference< XPropertySet > OIndexColumns::createDescriptor()
108 return new OIndexColumn(true);
111 void OIndexColumns::impl_refresh()
113 m_pIndex->refreshColumns();
117 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */