1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
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
)
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
)));
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);
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
;
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
,
92 aCatalog
, aSchema
, aTable
);
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: */