merge the formfield patch from ooo-build
[ooovba.git] / connectivity / source / drivers / adabas / BIndexColumns.cxx
blob26b94897f28cf2ade69f7b7bb93351b3ddd7af11
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: BIndexColumns.cxx,v $
10 * $Revision: 1.13 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_connectivity.hxx"
34 #ifndef _CONNECTIVITY_ADABAS_INDEXCOLUMNS_HXX_
35 #include "adabas/BIndexColumns.hxx"
36 #endif
37 #include "connectivity/sdbcx/VIndexColumn.hxx"
38 #include <com/sun/star/sdbc/XRow.hpp>
39 #include <com/sun/star/sdbc/XResultSet.hpp>
40 #include <com/sun/star/sdbc/DataType.hpp>
41 #include <com/sun/star/sdbc/ColumnValue.hpp>
42 #include "adabas/BTable.hxx"
43 #include "adabas/BCatalog.hxx"
44 #include <comphelper/types.hxx>
45 #include <comphelper/property.hxx>
47 using namespace connectivity::adabas;
48 using namespace connectivity::sdbcx;
49 using namespace ::com::sun::star::uno;
50 using namespace ::com::sun::star::beans;
51 // using namespace ::com::sun::star::sdbcx;
52 using namespace ::com::sun::star::sdbc;
53 using namespace ::com::sun::star::container;
54 using namespace ::com::sun::star::lang;
55 // -------------------------------------------------------------------------
56 ObjectType OIndexColumns::createObject(const ::rtl::OUString& _rName)
59 Reference< XResultSet > xResult = m_pIndex->getTable()->getConnection()->getMetaData()->getIndexInfo(Any(),
60 m_pIndex->getTable()->getSchema(),m_pIndex->getTable()->getTableName(),sal_False,sal_False);
62 sal_Bool bAsc = sal_True;
63 if(xResult.is())
65 Reference< XRow > xRow(xResult,UNO_QUERY);
66 ::rtl::OUString aD(::rtl::OUString::createFromAscii("D"));
67 while(xResult->next())
69 if(xRow->getString(9) == _rName)
70 bAsc = xRow->getString(10) != aD;
72 ::comphelper::disposeComponent(xResult);
75 xResult = m_pIndex->getTable()->getConnection()->getMetaData()->getColumns(Any(),
76 m_pIndex->getTable()->getSchema(),m_pIndex->getTable()->getTableName(),_rName);
78 ObjectType xRet = NULL;
79 if(xResult.is())
81 Reference< XRow > xRow(xResult,UNO_QUERY);
82 while(xResult->next())
84 if(xRow->getString(4) == _rName)
86 sal_Int32 nType = xRow->getInt(5);
87 ::rtl::OUString sTypeName = xRow->getString(6);
88 sal_Int32 nPrec = xRow->getInt(7);
89 OAdabasCatalog::correctColumnProperties(nPrec,nType,sTypeName);
91 OIndexColumn* pRet = new OIndexColumn(bAsc,
92 _rName,
93 sTypeName,
94 xRow->getString(13),
95 xRow->getInt(11),
96 nPrec,
97 xRow->getInt(9),
98 nType,
99 sal_False,sal_False,sal_False,sal_True);
100 xRet = pRet;
101 break;
104 ::comphelper::disposeComponent(xResult);
107 return xRet;
109 // -------------------------------------------------------------------------
110 Reference< XPropertySet > OIndexColumns::createDescriptor()
112 return new OIndexColumn(sal_True);
114 // -----------------------------------------------------------------------------
115 void OIndexColumns::impl_refresh() throw(::com::sun::star::uno::RuntimeException)
117 m_pIndex->refreshColumns();
119 // -----------------------------------------------------------------------------
120 ObjectType OIndexColumns::appendObject( const ::rtl::OUString& /*_rForName*/, const Reference< XPropertySet >& descriptor )
122 return cloneDescriptor( descriptor );
124 // -----------------------------------------------------------------------------