merge the formfield patch from ooo-build
[ooovba.git] / connectivity / source / drivers / postgresql / pq_xindex.cxx
blob6edcb7e3cb5b4fa0da0377b6d6be00099068c185
1 /*************************************************************************
3 * $RCSfile: pq_xindex.cxx,v $
5 * $Revision: 1.1.2.1 $
7 * last change: $Author: jbu $ $Date: 2004/06/10 15:27:01 $
9 * The Contents of this file are made available subject to the terms of
10 * either of the following licenses
12 * - GNU Lesser General Public License Version 2.1
13 * - Sun Industry Standards Source License Version 1.1
15 * Sun Microsystems Inc., October, 2000
17 * GNU Lesser General Public License Version 2.1
18 * =============================================
19 * Copyright 2000 by Sun Microsystems, Inc.
20 * 901 San Antonio Road, Palo Alto, CA 94303, USA
22 * This library is free software; you can redistribute it and/or
23 * modify it under the terms of the GNU Lesser General Public
24 * License version 2.1, as published by the Free Software Foundation.
26 * This library is distributed in the hope that it will be useful,
27 * but WITHOUT ANY WARRANTY; without even the implied warranty of
28 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
29 * Lesser General Public License for more details.
31 * You should have received a copy of the GNU Lesser General Public
32 * License along with this library; if not, write to the Free Software
33 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
34 * MA 02111-1307 USA
37 * Sun Industry Standards Source License Version 1.1
38 * =================================================
39 * The contents of this file are subject to the Sun Industry Standards
40 * Source License Version 1.1 (the "License"); You may not use this file
41 * except in compliance with the License. You may obtain a copy of the
42 * License at http://www.openoffice.org/license.html.
44 * Software provided under this License is provided on an "AS IS" basis,
45 * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
46 * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
47 * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
48 * See the License for the specific provisions governing your rights and
49 * obligations concerning the Software.
51 * The Initial Developer of the Original Code is: Joerg Budischewski
53 * Copyright: 2000 by Sun Microsystems, Inc.
55 * All Rights Reserved.
57 * Contributor(s): Joerg Budischewski
60 ************************************************************************/
62 #include <rtl/ustrbuf.hxx>
64 #include <cppuhelper/typeprovider.hxx>
65 #include <cppuhelper/queryinterface.hxx>
67 #include <com/sun/star/beans/PropertyAttribute.hpp>
69 #include <com/sun/star/sdbc/XRow.hpp>
70 #include <com/sun/star/sdbc/XParameters.hpp>
72 #include "pq_xindex.hxx"
73 #include "pq_xindexcolumns.hxx"
74 #include "pq_tools.hxx"
75 #include "pq_statics.hxx"
77 using osl::MutexGuard;
78 using osl::Mutex;
80 using rtl::OUString;
81 using rtl::OUStringBuffer;
83 using com::sun::star::container::XNameAccess;
84 using com::sun::star::container::XIndexAccess;
85 using com::sun::star::container::ElementExistException;
86 using com::sun::star::container::NoSuchElementException;
88 using com::sun::star::uno::Reference;
89 using com::sun::star::uno::Exception;
90 using com::sun::star::uno::UNO_QUERY;
91 using com::sun::star::uno::XInterface;
92 using com::sun::star::uno::Sequence;
93 using com::sun::star::uno::Any;
94 using com::sun::star::uno::makeAny;
95 using com::sun::star::uno::Type;
96 using com::sun::star::uno::RuntimeException;
98 using com::sun::star::lang::IllegalArgumentException;
99 using com::sun::star::lang::IndexOutOfBoundsException;
101 using com::sun::star::beans::XPropertySetInfo;
102 using com::sun::star::beans::XFastPropertySet;
103 using com::sun::star::beans::XMultiPropertySet;
104 using com::sun::star::beans::XPropertySet;
105 using com::sun::star::beans::Property;
107 using com::sun::star::sdbc::XResultSet;
108 using com::sun::star::sdbc::XPreparedStatement;
109 using com::sun::star::sdbc::XStatement;
110 using com::sun::star::sdbc::XParameters;
111 using com::sun::star::sdbc::XRow;
112 using com::sun::star::sdbc::SQLException;
114 namespace pq_sdbc_driver
116 #define ASCII_STR(x) OUString( RTL_CONSTASCII_USTRINGPARAM( x ) )
118 Index::Index( const ::rtl::Reference< RefCountedMutex > & refMutex,
119 const Reference< com::sun::star::sdbc::XConnection > & connection,
120 ConnectionSettings *pSettings,
121 const rtl::OUString & schemaName,
122 const rtl::OUString & tableName )
123 : ReflectionBase(
124 getStatics().refl.index.implName,
125 getStatics().refl.index.serviceNames,
126 refMutex,
127 connection,
128 pSettings,
129 * getStatics().refl.index.pProps ),
130 m_schemaName( schemaName ),
131 m_tableName( tableName )
134 Reference< XPropertySet > Index::createDataDescriptor( ) throw (RuntimeException)
136 IndexDescriptor * pIndex = new IndexDescriptor(
137 m_refMutex, m_conn, m_pSettings );
138 pIndex->copyValuesFrom( this );
140 return Reference< XPropertySet > ( pIndex );
143 Reference< XNameAccess > Index::getColumns( ) throw (::com::sun::star::uno::RuntimeException)
145 if( ! m_indexColumns.is() )
147 Sequence< OUString > columnNames;
148 getPropertyValue( getStatics().PRIVATE_COLUMN_INDEXES ) >>= columnNames;
149 OUString indexName = extractStringProperty( this, getStatics().NAME );
150 m_indexColumns = IndexColumns::create(
151 m_refMutex, m_conn, m_pSettings, m_schemaName,
152 m_tableName, indexName, columnNames );
154 return m_indexColumns;
157 Sequence<Type > Index::getTypes() throw( RuntimeException )
159 static cppu::OTypeCollection *pCollection;
160 if( ! pCollection )
162 MutexGuard guard( osl::Mutex::getGlobalMutex() );
163 if( !pCollection )
165 static cppu::OTypeCollection collection(
166 getCppuType( (Reference< com::sun::star::sdbcx::XColumnsSupplier> *) 0 ),
167 ReflectionBase::getTypes());
168 pCollection = &collection;
171 return pCollection->getTypes();
174 Sequence< sal_Int8> Index::getImplementationId() throw( RuntimeException )
176 return getStatics().refl.index.implementationId;
179 Any Index::queryInterface( const Type & reqType ) throw (RuntimeException)
181 Any ret;
183 ret = ReflectionBase::queryInterface( reqType );
184 if( ! ret.hasValue() )
185 ret = ::cppu::queryInterface(
186 reqType,
187 static_cast< com::sun::star::sdbcx::XColumnsSupplier * > ( this ) );
188 return ret;
192 //___________________________________________________________________________________
193 IndexDescriptor::IndexDescriptor(
194 const ::rtl::Reference< RefCountedMutex > & refMutex,
195 const Reference< com::sun::star::sdbc::XConnection > & connection,
196 ConnectionSettings *pSettings )
197 : ReflectionBase(
198 getStatics().refl.indexDescriptor.implName,
199 getStatics().refl.indexDescriptor.serviceNames,
200 refMutex,
201 connection,
202 pSettings,
203 * getStatics().refl.indexDescriptor.pProps )
206 Reference< XPropertySet > IndexDescriptor::createDataDescriptor( ) throw (RuntimeException)
208 IndexDescriptor * pIndex = new IndexDescriptor(
209 m_refMutex, m_conn, m_pSettings );
210 pIndex->copyValuesFrom( this );
211 return Reference< XPropertySet > ( pIndex );
214 Reference< XNameAccess > IndexDescriptor::getColumns( ) throw (::com::sun::star::uno::RuntimeException)
216 if( ! m_indexColumns.is() )
218 m_indexColumns = IndexColumnDescriptors::create(
219 m_refMutex, m_conn, m_pSettings );
220 // Sequence< OUString > columnNames;
221 // getPropertyValue( getStatics().PRIVATE_COLUMN_INDEXES ) >>= columnNames;
222 // OUString indexName = extractStringProperty( this, getStatics().NAME );
223 // m_indexColumns = IndexColumns::create(
224 // m_refMutex, m_conn, m_pSettings, m_schemaName,
225 // m_tableName, indexName, columnNames );
227 return m_indexColumns;
230 Sequence<Type > IndexDescriptor::getTypes() throw( RuntimeException )
232 static cppu::OTypeCollection *pCollection;
233 if( ! pCollection )
235 MutexGuard guard( osl::Mutex::getGlobalMutex() );
236 if( !pCollection )
238 static cppu::OTypeCollection collection(
239 getCppuType( (Reference< com::sun::star::sdbcx::XColumnsSupplier> *) 0 ),
240 ReflectionBase::getTypes());
241 pCollection = &collection;
244 return pCollection->getTypes();
247 Sequence< sal_Int8> IndexDescriptor::getImplementationId() throw( RuntimeException )
249 return getStatics().refl.indexDescriptor.implementationId;
252 Any IndexDescriptor::queryInterface( const Type & reqType ) throw (RuntimeException)
254 Any ret;
256 ret = ReflectionBase::queryInterface( reqType );
257 if( ! ret.hasValue() )
258 ret = ::cppu::queryInterface(
259 reqType,
260 static_cast< com::sun::star::sdbcx::XColumnsSupplier * > ( this ) );
261 return ret;