1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #include "connectivity/TIndex.hxx"
30 #include "connectivity/TIndexColumns.hxx"
31 #include <com/sun/star/sdbc/XRow.hpp>
32 #include <com/sun/star/sdbc/XResultSet.hpp>
33 #include "connectivity/TTableHelper.hxx"
34 #include "TConnection.hxx"
36 using namespace connectivity
;
37 using namespace connectivity::sdbcx
;
38 using namespace ::com::sun::star::uno
;
39 using namespace ::com::sun::star::beans
;
40 using namespace ::com::sun::star::sdbc
;
41 using namespace ::com::sun::star::container
;
42 using namespace ::com::sun::star::lang
;
43 // -------------------------------------------------------------------------
44 OIndexHelper::OIndexHelper( OTableHelper
* _pTable
) : connectivity::sdbcx::OIndex(sal_True
)
48 ::std::vector
< ::rtl::OUString
> aVector
;
49 m_pColumns
= new OIndexColumns(this,m_aMutex
,aVector
);
51 // -------------------------------------------------------------------------
52 OIndexHelper::OIndexHelper( OTableHelper
* _pTable
,
53 const ::rtl::OUString
& _Name
,
54 const ::rtl::OUString
& _Catalog
,
56 sal_Bool _isPrimaryKeyIndex
,
58 ) : connectivity::sdbcx::OIndex(_Name
,
62 _isClustered
,sal_True
)
68 // -------------------------------------------------------------------------
70 void OIndexHelper::refreshColumns()
75 ::std::vector
< ::rtl::OUString
> aVector
;
78 ::dbtools::OPropertyMap
& rPropMap
= OMetaConnection::getPropMap();
79 ::rtl::OUString aSchema
,aTable
;
80 m_pTable
->getPropertyValue(rPropMap
.getNameByIndex(PROPERTY_ID_SCHEMANAME
)) >>= aSchema
;
81 m_pTable
->getPropertyValue(rPropMap
.getNameByIndex(PROPERTY_ID_NAME
)) >>= aTable
;
83 Reference
< XResultSet
> xResult
= m_pTable
->getMetaData()->getIndexInfo(
84 m_pTable
->getPropertyValue(rPropMap
.getNameByIndex(PROPERTY_ID_CATALOGNAME
)),
85 aSchema
,aTable
,sal_False
,sal_False
);
89 Reference
< XRow
> xRow(xResult
,UNO_QUERY
);
90 ::rtl::OUString aColName
;
91 while( xResult
->next() )
93 if ( xRow
->getString(6) == m_Name
)
95 aColName
= xRow
->getString(9);
96 if ( !xRow
->wasNull() )
97 aVector
.push_back(aColName
);
103 m_pColumns
->reFill(aVector
);
105 m_pColumns
= new OIndexColumns(this,m_aMutex
,aVector
);
107 // -----------------------------------------------------------------------------
109 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */