xref: /AOO41X/main/connectivity/source/drivers/dbase/DIndexColumns.cxx (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_connectivity.hxx"
30 #include "dbase/DIndexColumns.hxx"
31 #include "dbase/DTable.hxx"
32 #include "connectivity/sdbcx/VIndexColumn.hxx"
33 #include <comphelper/types.hxx>
34 #include <comphelper/property.hxx>
35 #include <connectivity/dbexception.hxx>
36 
37 using namespace ::comphelper;
38 
39 using namespace connectivity::dbase;
40 using namespace connectivity;
41 using namespace ::com::sun::star::uno;
42 using namespace ::com::sun::star::beans;
43 using namespace ::com::sun::star::sdbcx;
44 using namespace ::com::sun::star::sdbc;
45 using namespace ::com::sun::star::container;
46 
47 
48 sdbcx::ObjectType ODbaseIndexColumns::createObject(const ::rtl::OUString& _rName)
49 {
50 	const ODbaseTable* pTable = m_pIndex->getTable();
51 
52 	::vos::ORef<OSQLColumns> aCols = pTable->getTableColumns();
53 	OSQLColumns::Vector::const_iterator aIter = find(aCols->get().begin(),aCols->get().end(),_rName,::comphelper::UStringMixEqual(isCaseSensitive()));
54 
55 	Reference< XPropertySet > xCol;
56 	if(aIter != aCols->get().end())
57 		xCol = *aIter;
58 
59 	if(!xCol.is())
60 		return sdbcx::ObjectType();
61 
62 	sdbcx::ObjectType xRet = new sdbcx::OIndexColumn(sal_True,_rName
63 													,getString(xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPENAME)))
64 													,::rtl::OUString()
65 													,getINT32(xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISNULLABLE)))
66 													,getINT32(xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION)))
67 													,getINT32(xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE)))
68 													,getINT32(xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE)))
69 													,sal_False
70 													,sal_False
71 													,sal_False
72 													,pTable->getConnection()->getMetaData()->supportsMixedCaseQuotedIdentifiers());
73 
74 	return xRet;
75 }
76 
77 // -------------------------------------------------------------------------
78 void ODbaseIndexColumns::impl_refresh() throw(RuntimeException)
79 {
80 	m_pIndex->refreshColumns();
81 }
82 // -------------------------------------------------------------------------
83 Reference< XPropertySet > ODbaseIndexColumns::createDescriptor()
84 {
85 	return new sdbcx::OIndexColumn(m_pIndex->getTable()->getConnection()->getMetaData()->supportsMixedCaseQuotedIdentifiers());
86 }
87 // -------------------------------------------------------------------------
88 sdbcx::ObjectType ODbaseIndexColumns::appendObject( const ::rtl::OUString& /*_rForName*/, const Reference< XPropertySet >& descriptor )
89 {
90     return cloneDescriptor( descriptor );
91 }
92 // -----------------------------------------------------------------------------
93 
94 
95