tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / connectivity / source / commontools / TIndexColumns.cxx
blobd190bb2af312c8cc2833e9fd81dd8af829128260
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 <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>
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;
34 OIndexColumns::OIndexColumns( OIndexHelper* _pIndex,
35 ::osl::Mutex& _rMutex,
36 const std::vector< OUString> &_rVector)
37 : connectivity::sdbcx::OCollection(*_pIndex,true,_rMutex,_rVector)
38 ,m_pIndex(_pIndex)
42 sdbcx::ObjectType OIndexColumns::createObject(const OUString& _rName)
44 ::dbtools::OPropertyMap& rPropMap = OMetaConnection::getPropMap();
45 OUString aCatalog, aSchema, aTable;
46 css::uno::Any Catalog(m_pIndex->getTable()->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_CATALOGNAME)));
47 Catalog >>= aCatalog;
48 m_pIndex->getTable()->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_SCHEMANAME)) >>= aSchema;
49 m_pIndex->getTable()->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_NAME)) >>= aTable;
51 Reference< XResultSet > xResult = m_pIndex->getTable()->getConnection()->getMetaData()->getIndexInfo(
52 Catalog, aSchema, aTable, false, false);
54 bool bAsc = true;
55 if ( xResult.is() )
57 Reference< XRow > xRow(xResult,UNO_QUERY);
58 while( xResult->next() )
60 if(xRow->getString(9) == _rName)
61 bAsc = xRow->getString(10) != "D";
65 xResult = m_pIndex->getTable()->getConnection()->getMetaData()->getColumns(
66 Catalog, aSchema, aTable, _rName);
68 sdbcx::ObjectType xRet;
69 if ( xResult.is() )
71 Reference< XRow > xRow(xResult,UNO_QUERY);
72 while( xResult->next() )
74 if ( xRow->getString(4) == _rName )
76 sal_Int32 nDataType = xRow->getInt(5);
77 OUString aTypeName(xRow->getString(6));
78 sal_Int32 nSize = xRow->getInt(7);
79 sal_Int32 nDec = xRow->getInt(9);
80 sal_Int32 nNull = xRow->getInt(11);
81 OUString aColumnDef(xRow->getString(13));
83 xRet = new OIndexColumn(bAsc,
84 _rName,
85 aTypeName,
86 aColumnDef,
87 nNull,
88 nSize,
89 nDec,
90 nDataType,
91 true,
92 aCatalog, aSchema, aTable);
93 break;
98 return xRet;
101 Reference< XPropertySet > OIndexColumns::createDescriptor()
103 return new OIndexColumn(true);
106 void OIndexColumns::impl_refresh()
108 m_pIndex->refreshColumns();
112 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */