Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*************************************************************************
3 : *
4 : * Effective License of whole file:
5 : *
6 : * This library is free software; you can redistribute it and/or
7 : * modify it under the terms of the GNU Lesser General Public
8 : * License version 2.1, as published by the Free Software Foundation.
9 : *
10 : * This library is distributed in the hope that it will be useful,
11 : * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 : * Lesser General Public License for more details.
14 : *
15 : * You should have received a copy of the GNU Lesser General Public
16 : * License along with this library; if not, write to the Free Software
17 : * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
18 : * MA 02111-1307 USA
19 : *
20 : * Parts "Copyright by Sun Microsystems, Inc" prior to August 2011:
21 : *
22 : * The Contents of this file are made available subject to the terms of
23 : * the GNU Lesser General Public License Version 2.1
24 : *
25 : * Copyright: 2000 by Sun Microsystems, Inc.
26 : *
27 : * Contributor(s): Joerg Budischewski
28 : *
29 : * All parts contributed on or after August 2011:
30 : *
31 : * This Source Code Form is subject to the terms of the Mozilla Public
32 : * License, v. 2.0. If a copy of the MPL was not distributed with this
33 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
34 : *
35 : ************************************************************************/
36 :
37 : #include <rtl/ustrbuf.hxx>
38 :
39 : #include <cppuhelper/typeprovider.hxx>
40 : #include <cppuhelper/queryinterface.hxx>
41 :
42 : #include <com/sun/star/beans/PropertyAttribute.hpp>
43 :
44 : #include <com/sun/star/sdbc/XRow.hpp>
45 : #include <com/sun/star/sdbc/XParameters.hpp>
46 :
47 : #include "pq_xindex.hxx"
48 : #include "pq_xindexcolumns.hxx"
49 : #include "pq_tools.hxx"
50 : #include "pq_statics.hxx"
51 :
52 : using osl::MutexGuard;
53 : using osl::Mutex;
54 :
55 :
56 : using com::sun::star::container::XNameAccess;
57 : using com::sun::star::container::XIndexAccess;
58 : using com::sun::star::container::ElementExistException;
59 : using com::sun::star::container::NoSuchElementException;
60 :
61 : using com::sun::star::uno::Reference;
62 : using com::sun::star::uno::Exception;
63 : using com::sun::star::uno::UNO_QUERY;
64 : using com::sun::star::uno::XInterface;
65 : using com::sun::star::uno::Sequence;
66 : using com::sun::star::uno::Any;
67 : using com::sun::star::uno::makeAny;
68 : using com::sun::star::uno::Type;
69 : using com::sun::star::uno::RuntimeException;
70 :
71 : using com::sun::star::lang::IllegalArgumentException;
72 : using com::sun::star::lang::IndexOutOfBoundsException;
73 :
74 : using com::sun::star::beans::XPropertySetInfo;
75 : using com::sun::star::beans::XFastPropertySet;
76 : using com::sun::star::beans::XMultiPropertySet;
77 : using com::sun::star::beans::XPropertySet;
78 : using com::sun::star::beans::Property;
79 :
80 : using com::sun::star::sdbc::XResultSet;
81 : using com::sun::star::sdbc::XPreparedStatement;
82 : using com::sun::star::sdbc::XStatement;
83 : using com::sun::star::sdbc::XParameters;
84 : using com::sun::star::sdbc::XRow;
85 : using com::sun::star::sdbc::SQLException;
86 :
87 : namespace pq_sdbc_driver
88 : {
89 0 : Index::Index( const ::rtl::Reference< RefCountedMutex > & refMutex,
90 : const Reference< com::sun::star::sdbc::XConnection > & connection,
91 : ConnectionSettings *pSettings,
92 : const OUString & schemaName,
93 : const OUString & tableName )
94 : : ReflectionBase(
95 0 : getStatics().refl.index.implName,
96 0 : getStatics().refl.index.serviceNames,
97 : refMutex,
98 : connection,
99 : pSettings,
100 0 : * getStatics().refl.index.pProps ),
101 : m_schemaName( schemaName ),
102 0 : m_tableName( tableName )
103 0 : {}
104 :
105 0 : Reference< XPropertySet > Index::createDataDescriptor( ) throw (RuntimeException, std::exception)
106 : {
107 : IndexDescriptor * pIndex = new IndexDescriptor(
108 0 : m_refMutex, m_conn, m_pSettings );
109 0 : pIndex->copyValuesFrom( this );
110 :
111 0 : return Reference< XPropertySet > ( pIndex );
112 : }
113 :
114 0 : Reference< XNameAccess > Index::getColumns( ) throw (::com::sun::star::uno::RuntimeException, std::exception)
115 : {
116 0 : if( ! m_indexColumns.is() )
117 : {
118 0 : Sequence< OUString > columnNames;
119 0 : getPropertyValue( getStatics().PRIVATE_COLUMN_INDEXES ) >>= columnNames;
120 0 : OUString indexName = extractStringProperty( this, getStatics().NAME );
121 0 : m_indexColumns = IndexColumns::create(
122 : m_refMutex, m_conn, m_pSettings, m_schemaName,
123 0 : m_tableName, indexName, columnNames );
124 : }
125 0 : return m_indexColumns;
126 : }
127 :
128 0 : Sequence<Type > Index::getTypes() throw( RuntimeException, std::exception )
129 : {
130 : static cppu::OTypeCollection *pCollection;
131 0 : if( ! pCollection )
132 : {
133 0 : MutexGuard guard( osl::Mutex::getGlobalMutex() );
134 0 : if( !pCollection )
135 : {
136 : static cppu::OTypeCollection collection(
137 0 : getCppuType( (Reference< com::sun::star::sdbcx::XColumnsSupplier> *) 0 ),
138 0 : ReflectionBase::getTypes());
139 0 : pCollection = &collection;
140 0 : }
141 : }
142 0 : return pCollection->getTypes();
143 : }
144 :
145 0 : Sequence< sal_Int8> Index::getImplementationId() throw( RuntimeException, std::exception )
146 : {
147 0 : return css::uno::Sequence<sal_Int8>();
148 : }
149 :
150 0 : Any Index::queryInterface( const Type & reqType ) throw (RuntimeException, std::exception)
151 : {
152 0 : Any ret;
153 :
154 0 : ret = ReflectionBase::queryInterface( reqType );
155 0 : if( ! ret.hasValue() )
156 0 : ret = ::cppu::queryInterface(
157 : reqType,
158 0 : static_cast< com::sun::star::sdbcx::XColumnsSupplier * > ( this ) );
159 0 : return ret;
160 : }
161 :
162 :
163 :
164 0 : IndexDescriptor::IndexDescriptor(
165 : const ::rtl::Reference< RefCountedMutex > & refMutex,
166 : const Reference< com::sun::star::sdbc::XConnection > & connection,
167 : ConnectionSettings *pSettings )
168 : : ReflectionBase(
169 0 : getStatics().refl.indexDescriptor.implName,
170 0 : getStatics().refl.indexDescriptor.serviceNames,
171 : refMutex,
172 : connection,
173 : pSettings,
174 0 : * getStatics().refl.indexDescriptor.pProps )
175 0 : {}
176 :
177 0 : Reference< XPropertySet > IndexDescriptor::createDataDescriptor( ) throw (RuntimeException, std::exception)
178 : {
179 : IndexDescriptor * pIndex = new IndexDescriptor(
180 0 : m_refMutex, m_conn, m_pSettings );
181 0 : pIndex->copyValuesFrom( this );
182 0 : return Reference< XPropertySet > ( pIndex );
183 : }
184 :
185 0 : Reference< XNameAccess > IndexDescriptor::getColumns( ) throw (::com::sun::star::uno::RuntimeException, std::exception)
186 : {
187 0 : if( ! m_indexColumns.is() )
188 : {
189 0 : m_indexColumns = IndexColumnDescriptors::create(
190 0 : m_refMutex, m_conn, m_pSettings );
191 : // Sequence< OUString > columnNames;
192 : // getPropertyValue( getStatics().PRIVATE_COLUMN_INDEXES ) >>= columnNames;
193 : // OUString indexName = extractStringProperty( this, getStatics().NAME );
194 : // m_indexColumns = IndexColumns::create(
195 : // m_refMutex, m_conn, m_pSettings, m_schemaName,
196 : // m_tableName, indexName, columnNames );
197 : }
198 0 : return m_indexColumns;
199 : }
200 :
201 0 : Sequence<Type > IndexDescriptor::getTypes() throw( RuntimeException, std::exception )
202 : {
203 : static cppu::OTypeCollection *pCollection;
204 0 : if( ! pCollection )
205 : {
206 0 : MutexGuard guard( osl::Mutex::getGlobalMutex() );
207 0 : if( !pCollection )
208 : {
209 : static cppu::OTypeCollection collection(
210 0 : getCppuType( (Reference< com::sun::star::sdbcx::XColumnsSupplier> *) 0 ),
211 0 : ReflectionBase::getTypes());
212 0 : pCollection = &collection;
213 0 : }
214 : }
215 0 : return pCollection->getTypes();
216 : }
217 :
218 0 : Sequence< sal_Int8> IndexDescriptor::getImplementationId() throw( RuntimeException, std::exception )
219 : {
220 0 : return css::uno::Sequence<sal_Int8>();
221 : }
222 :
223 0 : Any IndexDescriptor::queryInterface( const Type & reqType ) throw (RuntimeException, std::exception)
224 : {
225 0 : Any ret;
226 :
227 0 : ret = ReflectionBase::queryInterface( reqType );
228 0 : if( ! ret.hasValue() )
229 0 : ret = ::cppu::queryInterface(
230 : reqType,
231 0 : static_cast< com::sun::star::sdbcx::XColumnsSupplier * > ( this ) );
232 0 : return ret;
233 : }
234 :
235 :
236 :
237 :
238 : }
239 :
240 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|