Branch data 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 : : * Version: MPL 1.1 / GPLv3+ / LGPLv2.1+
32 : : *
33 : : * The contents of this file are subject to the Mozilla Public License Version
34 : : * 1.1 (the "License"); you may not use this file except in compliance with
35 : : * the License or as specified alternatively below. You may obtain a copy of
36 : : * the License at http://www.mozilla.org/MPL/
37 : : *
38 : : * Software distributed under the License is distributed on an "AS IS" basis,
39 : : * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
40 : : * for the specific language governing rights and limitations under the
41 : : * License.
42 : : *
43 : : * Major Contributor(s):
44 : : * [ Copyright (C) 2011 Lionel Elie Mamane <lionel@mamane.lu> ]
45 : : *
46 : : * All Rights Reserved.
47 : : *
48 : : * For minor contributions see the git repository.
49 : : *
50 : : * Alternatively, the contents of this file may be used under the terms of
51 : : * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
52 : : * the GNU Lesser General Public License Version 2.1 or later (the "LGPLv2.1+"),
53 : : * in which case the provisions of the GPLv3+ or the LGPLv2.1+ are applicable
54 : : * instead of those above.
55 : : *
56 : : ************************************************************************/
57 : :
58 : : #include "pq_statics.hxx"
59 : : #include "pq_updateableresultset.hxx"
60 : : #include <com/sun/star/sdbc/DataType.hpp>
61 : : #include <com/sun/star/beans/PropertyAttribute.hpp>
62 : :
63 : : #include <string.h>
64 : :
65 : : using rtl::OUString;
66 : : using com::sun::star::uno::Sequence;
67 : : using com::sun::star::uno::Any;
68 : : using com::sun::star::uno::Type;
69 : :
70 : : using com::sun::star::beans::PropertyAttribute::READONLY;
71 : : using com::sun::star::beans::PropertyAttribute::BOUND;
72 : : using com::sun::star::beans::Property;
73 : :
74 : : namespace pq_sdbc_driver
75 : : {
76 : :
77 : : struct DefColumnMetaData
78 : : {
79 : : const sal_Char * columnName;
80 : : const sal_Char * tableName;
81 : : const sal_Char * schemaTableName;
82 : : const sal_Char * typeName;
83 : : sal_Int32 type;
84 : : sal_Int32 precision;
85 : : sal_Int32 scale;
86 : : sal_Bool isCurrency;
87 : : sal_Bool isNullable;
88 : : sal_Bool isAutoIncrement;
89 : : sal_Bool isReadOnly;
90 : : sal_Bool isSigned;
91 : : };
92 : :
93 : : #define ASCII_STR(x) OUString( RTL_CONSTASCII_USTRINGPARAM( x ) )
94 : : struct BaseTypeDef { const char * typeName; sal_Int32 value; };
95 : :
96 : 0 : static Sequence< OUString > createStringSequence( const char * name[] )
97 : : {
98 : : int length;
99 : 0 : for( length = 0; name[length] ; length ++ );
100 : :
101 : 0 : Sequence< OUString > seq( length );
102 : 0 : for( int i = 0; i < length; i ++ )
103 : : {
104 : 0 : seq[i] = OUString( name[i] , strlen( name[i] ), RTL_TEXTENCODING_ASCII_US );
105 : : }
106 : 0 : return seq;
107 : : }
108 : :
109 : 0 : struct PropertyDef
110 : : {
111 : 0 : PropertyDef( const OUString &str, const Type &t )
112 : 0 : : name( str ) , type( t ) {}
113 : : ::rtl::OUString name;
114 : : com::sun::star::uno::Type type;
115 : : };
116 : :
117 : 0 : struct PropertyDefEx : public PropertyDef
118 : : {
119 : 0 : PropertyDefEx( const OUString & str, const Type &t , sal_Int32 a )
120 : 0 : : PropertyDef( str, t ) , attribute( a )
121 : 0 : {}
122 : : sal_Int32 attribute;
123 : : };
124 : :
125 : 0 : static cppu::IPropertyArrayHelper * createPropertyArrayHelper(
126 : : PropertyDef *props, int count , sal_Int16 attr )
127 : : {
128 : 0 : Sequence< Property > seq( count );
129 : 0 : for( int i = 0 ; i < count ; i ++ )
130 : : {
131 : 0 : seq[i] = Property( props[i].name, i, props[i].type, attr );
132 : : }
133 : 0 : return new cppu::OPropertyArrayHelper( seq, sal_True );
134 : : }
135 : :
136 : 0 : static cppu::IPropertyArrayHelper * createPropertyArrayHelper(
137 : : PropertyDefEx *props, int count )
138 : : {
139 : 0 : Sequence< Property > seq( count );
140 : 0 : for( int i = 0 ; i < count ; i ++ )
141 : : {
142 : 0 : seq[i] = Property( props[i].name, i, props[i].type, props[i].attribute );
143 : : }
144 : 0 : return new cppu::OPropertyArrayHelper( seq, sal_True );
145 : : }
146 : :
147 : 0 : Statics & getStatics()
148 : : {
149 : : static Statics * p;
150 : 0 : if( ! p )
151 : : {
152 : 0 : ::osl::MutexGuard guard( ::osl::Mutex::getGlobalMutex() );
153 : 0 : if( ! p )
154 : : {
155 : 0 : static Statics statics ;
156 : 0 : statics.SYSTEM_TABLE = ASCII_STR( "SYSTEM TABLE" );
157 : 0 : statics.TABLE = ASCII_STR( "TABLE" );
158 : 0 : statics.VIEW = ASCII_STR( "VIEW" );
159 : 0 : statics.UNKNOWN = ASCII_STR( "UNKNOWN" );
160 : 0 : statics.YES = ASCII_STR( "YES" );
161 : 0 : statics.NO = ASCII_STR( "NO" );
162 : 0 : statics.NO_NULLS = ASCII_STR( "NO_NULLS" );
163 : 0 : statics.NULABLE = ASCII_STR( "NULABLE" );
164 : 0 : statics.NULLABLE_UNKNOWN = ASCII_STR( "NULLABLE_UNKNOWN" );
165 : 0 : statics.cPERCENT = ASCII_STR( "%" );
166 : :
167 : 0 : statics.TYPE = ASCII_STR( "Type" );
168 : 0 : statics.TYPE_NAME = ASCII_STR( "TypeName" );
169 : 0 : statics.NAME = ASCII_STR( "Name" );
170 : 0 : statics.SCHEMA_NAME = ASCII_STR( "SchemaName" );
171 : 0 : statics.CATALOG_NAME = ASCII_STR( "CatalogName" );
172 : 0 : statics.DESCRIPTION = ASCII_STR( "Description" );
173 : 0 : statics.PRIVILEGES = ASCII_STR( "Privileges" );
174 : :
175 : 0 : statics.DEFAULT_VALUE = ASCII_STR( "DefaultValue" );
176 : 0 : statics.IS_AUTO_INCREMENT = ASCII_STR( "IsAutoIncrement" );
177 : 0 : statics.IS_CURRENCY = ASCII_STR( "IsCurrency" );
178 : 0 : statics.IS_NULLABLE = ASCII_STR( "IsNullable" );
179 : 0 : statics.IS_ROW_VERSISON = ASCII_STR( "IsRowVersion" );
180 : 0 : statics.PRECISION = ASCII_STR( "Precision" );
181 : 0 : statics.SCALE = ASCII_STR( "Scale" );
182 : :
183 : 0 : statics.cPERCENT = ASCII_STR( "%" );
184 : 0 : statics.BEGIN = ASCII_STR( "BEGIN" );
185 : 0 : statics.COMMIT = ASCII_STR( "COMMIT" );
186 : 0 : statics.ROLLBACK = ASCII_STR( "ROLLBACK" );
187 : :
188 : 0 : statics.KEY = ASCII_STR( "Key" );
189 : 0 : statics.REFERENCED_TABLE = ASCII_STR( "ReferencedTable" );
190 : 0 : statics.UPDATE_RULE = ASCII_STR( "UpdateRule" );
191 : 0 : statics.DELETE_RULE = ASCII_STR( "DeleteRule" );
192 : 0 : statics.PRIVATE_COLUMNS = ASCII_STR( "PrivateColumns" );
193 : 0 : statics.PRIVATE_FOREIGN_COLUMNS = ASCII_STR( "PrivateForeignColumns" );
194 : :
195 : 0 : statics.KEY_COLUMN = ASCII_STR( "KeyColumn" );
196 : 0 : statics.RELATED_COLUMN = ASCII_STR( "RelatedColumn" );
197 : 0 : statics.PASSWORD = ASCII_STR( "Password" );
198 : 0 : statics.USER = ASCII_STR( "User" );
199 : :
200 : 0 : statics.CURSOR_NAME = ASCII_STR( "CursorName" );
201 : 0 : statics.ESCAPE_PROCESSING = ASCII_STR( "EscapeProcessing" );
202 : 0 : statics.FETCH_DIRECTION = ASCII_STR( "FetchDirection" );
203 : 0 : statics.FETCH_SIZE = ASCII_STR( "FetchSize" );
204 : 0 : statics.IS_BOOKMARKABLE = ASCII_STR( "IsBookmarkable" );
205 : 0 : statics.RESULT_SET_CONCURRENCY = ASCII_STR( "ResultSetConcurrency" );
206 : 0 : statics.RESULT_SET_TYPE = ASCII_STR( "ResultSetType" );
207 : :
208 : 0 : statics.COMMAND = ASCII_STR( "Command" );
209 : 0 : statics.CHECK_OPTION = ASCII_STR( "CheckOption" );
210 : :
211 : 0 : statics.TRUE = ASCII_STR( "t" );
212 : 0 : statics.FALSE = ASCII_STR( "f" );
213 : 0 : statics.IS_PRIMARY_KEY_INDEX = ASCII_STR( "IsPrimaryKeyIndex" );
214 : 0 : statics.IS_CLUSTERED = ASCII_STR( "IsClustered" );
215 : 0 : statics.IS_UNIQUE = ASCII_STR( "IsUnique" );
216 : 0 : statics.IS_ASCENDING = ASCII_STR( "IsAscending" );
217 : 0 : statics.PRIVATE_COLUMN_INDEXES = ASCII_STR( "PrivateColumnIndexes" );
218 : 0 : statics.HELP_TEXT = ASCII_STR( "HelpText" );
219 : :
220 : 0 : statics.CATALOG = ASCII_STR( "Catalog" );
221 : :
222 : 0 : Type tString = getCppuType( (rtl::OUString *) 0 );
223 : 0 : Type tInt = getCppuType( (sal_Int32 * ) 0 );
224 : 0 : Type tBool = getBooleanCppuType();
225 : 0 : Type tStringSequence = getCppuType( (com::sun::star::uno::Sequence< ::rtl::OUString > *) 0);
226 : :
227 : : // Table props set
228 : 0 : ImplementationStatics &ist = statics.refl.table;
229 : 0 : ist.implName = ASCII_STR( "org.openoffice.comp.pq.sdbcx.Table" );
230 : 0 : ist.serviceNames = Sequence< OUString > ( 1 );
231 : 0 : ist.serviceNames[0] = ASCII_STR( "com.sun.star.sdbcx.Table" );
232 : : PropertyDef tableDef[] =
233 : : {
234 : : PropertyDef( statics.CATALOG_NAME , tString ),
235 : : PropertyDef( statics.DESCRIPTION , tString ),
236 : : PropertyDef( statics.NAME , tString ),
237 : : PropertyDef( statics.PRIVILEGES , tInt ),
238 : : PropertyDef( statics.SCHEMA_NAME , tString ),
239 : : PropertyDef( statics.TYPE , tString )
240 : 0 : };
241 : : ist.pProps = createPropertyArrayHelper(
242 : 0 : tableDef, sizeof(tableDef)/sizeof(PropertyDef), READONLY );
243 : :
244 : : statics.refl.tableDescriptor.implName =
245 : 0 : ASCII_STR( "org.openoffice.comp.pq.sdbcx.TableDescriptor" );
246 : 0 : statics.refl.tableDescriptor.serviceNames = Sequence< OUString > (1);
247 : 0 : statics.refl.tableDescriptor.serviceNames[0] =
248 : 0 : ASCII_STR( "com.sun.star.sdbcx.TableDescriptor" );
249 : : PropertyDef tableDescDef[] =
250 : : {
251 : : PropertyDef( statics.CATALOG_NAME , tString ),
252 : : PropertyDef( statics.DESCRIPTION , tString ),
253 : : PropertyDef( statics.NAME , tString ),
254 : : PropertyDef( statics.PRIVILEGES , tInt ),
255 : : PropertyDef( statics.SCHEMA_NAME , tString )
256 : 0 : };
257 : : statics.refl.tableDescriptor.pProps = createPropertyArrayHelper(
258 : 0 : tableDescDef, sizeof(tableDescDef)/sizeof(PropertyDef), 0 );
259 : :
260 : : // Column props set
261 : 0 : statics.refl.column.implName = ASCII_STR( "org.openoffice.comp.pq.sdbcx.Column" );
262 : 0 : statics.refl.column.serviceNames = Sequence< OUString > ( 1 );
263 : 0 : statics.refl.column.serviceNames[0] = ASCII_STR( "com.sun.star.sdbcx.Column" );
264 : : PropertyDefEx columnDef[] =
265 : : {
266 : : PropertyDefEx( statics.CATALOG_NAME , tString, READONLY ),
267 : : PropertyDefEx( statics.DEFAULT_VALUE, tString, READONLY ),
268 : : PropertyDefEx( statics.DESCRIPTION , tString, READONLY ),
269 : : // PropertyDefEx( statics.HELP_TEXT , tString, BOUND ),
270 : : PropertyDefEx( statics.IS_AUTO_INCREMENT, tBool, READONLY ),
271 : : PropertyDefEx( statics.IS_CURRENCY, tBool, READONLY ),
272 : : PropertyDefEx( statics.IS_NULLABLE, tInt, READONLY ),
273 : : PropertyDefEx( statics.IS_ROW_VERSISON, tBool,READONLY ),
274 : : PropertyDefEx( statics.NAME , tString,READONLY ),
275 : : PropertyDefEx( statics.PRECISION , tInt, READONLY ),
276 : : PropertyDefEx( statics.SCALE , tInt ,READONLY),
277 : : PropertyDefEx( statics.TYPE , tInt ,READONLY),
278 : : PropertyDefEx( statics.TYPE_NAME , tString ,READONLY)
279 : 0 : };
280 : : statics.refl.column.pProps = createPropertyArrayHelper(
281 : 0 : columnDef, sizeof(columnDef)/sizeof(PropertyDefEx) );
282 : :
283 : : statics.refl.columnDescriptor.implName =
284 : 0 : ASCII_STR( "org.openoffice.comp.pq.sdbcx.ColumnDescriptor" );
285 : 0 : statics.refl.columnDescriptor.serviceNames = Sequence< OUString > ( 1 );
286 : 0 : statics.refl.columnDescriptor.serviceNames[0] =
287 : 0 : ASCII_STR( "com.sun.star.sdbcx.ColumnDescriptor" );
288 : : PropertyDef columnDescDef[] =
289 : : {
290 : : PropertyDef( statics.CATALOG_NAME , tString ),
291 : : PropertyDef( statics.DEFAULT_VALUE, tString ),
292 : : PropertyDef( statics.DESCRIPTION , tString ),
293 : : // PropertyDef( statics.HELP_TEXT , tString ),
294 : : PropertyDef( statics.IS_AUTO_INCREMENT, tBool ),
295 : : PropertyDef( statics.IS_CURRENCY, tBool ),
296 : : PropertyDef( statics.IS_NULLABLE, tInt ),
297 : : PropertyDef( statics.IS_ROW_VERSISON, tBool ),
298 : : PropertyDef( statics.NAME , tString ),
299 : : PropertyDef( statics.PRECISION , tInt ),
300 : : PropertyDef( statics.SCALE , tInt ),
301 : : PropertyDef( statics.TYPE , tInt ),
302 : : PropertyDef( statics.TYPE_NAME , tString )
303 : 0 : };
304 : :
305 : : statics.refl.columnDescriptor.pProps = createPropertyArrayHelper(
306 : 0 : columnDescDef, sizeof(columnDescDef)/sizeof(PropertyDef), 0 );
307 : :
308 : : // Key properties
309 : 0 : statics.refl.key.implName = ASCII_STR( "org.openoffice.comp.pq.sdbcx.Key" );
310 : 0 : statics.refl.key.serviceNames = Sequence< OUString > ( 1 );
311 : 0 : statics.refl.key.serviceNames[0] = ASCII_STR( "com.sun.star.sdbcx.Key" );
312 : : PropertyDef keyDef[] =
313 : : {
314 : : PropertyDef( statics.DELETE_RULE, tInt ),
315 : : PropertyDef( statics.NAME, tString ),
316 : : PropertyDef( statics.PRIVATE_COLUMNS, tStringSequence ),
317 : : PropertyDef( statics.PRIVATE_FOREIGN_COLUMNS, tStringSequence ),
318 : : PropertyDef( statics.REFERENCED_TABLE, tString ),
319 : : PropertyDef( statics.TYPE, tInt ),
320 : : PropertyDef( statics.UPDATE_RULE, tInt )
321 : 0 : };
322 : : statics.refl.key.pProps = createPropertyArrayHelper(
323 : 0 : keyDef, sizeof(keyDef)/sizeof(PropertyDef), READONLY );
324 : :
325 : :
326 : : // Key properties
327 : : statics.refl.keyDescriptor.implName =
328 : 0 : ASCII_STR( "org.openoffice.comp.pq.sdbcx.KeyDescriptor" );
329 : 0 : statics.refl.keyDescriptor.serviceNames = Sequence< OUString > ( 1 );
330 : 0 : statics.refl.keyDescriptor.serviceNames[0] =
331 : 0 : ASCII_STR( "com.sun.star.sdbcx.KeyDescriptor" );
332 : : PropertyDef keyDescDef[] =
333 : : {
334 : : PropertyDef( statics.DELETE_RULE, tInt ),
335 : : PropertyDef( statics.NAME, tString ),
336 : : PropertyDef( statics.REFERENCED_TABLE, tString ),
337 : : PropertyDef( statics.TYPE, tInt ),
338 : : PropertyDef( statics.UPDATE_RULE, tInt )
339 : 0 : };
340 : : statics.refl.keyDescriptor.pProps = createPropertyArrayHelper(
341 : 0 : keyDescDef, sizeof(keyDescDef)/sizeof(PropertyDef), 0 );
342 : :
343 : :
344 : :
345 : : // KeyColumn props set
346 : 0 : statics.refl.keycolumn.implName = ASCII_STR( "org.openoffice.comp.pq.sdbcx.KeyColumn" );
347 : 0 : statics.refl.keycolumn.serviceNames = Sequence< OUString > ( 1 );
348 : 0 : statics.refl.keycolumn.serviceNames[0] = ASCII_STR( "com.sun.star.sdbcx.KeyColumn" );
349 : : PropertyDef keycolumnDef[] =
350 : : {
351 : : PropertyDef( statics.CATALOG_NAME , tString ),
352 : : PropertyDef( statics.DEFAULT_VALUE, tString ),
353 : : PropertyDef( statics.DESCRIPTION , tString ),
354 : : PropertyDef( statics.IS_AUTO_INCREMENT, tBool ),
355 : : PropertyDef( statics.IS_CURRENCY, tBool ),
356 : : PropertyDef( statics.IS_NULLABLE, tInt ),
357 : : PropertyDef( statics.IS_ROW_VERSISON, tBool ),
358 : : PropertyDef( statics.NAME , tString ),
359 : : PropertyDef( statics.PRECISION , tInt ),
360 : : PropertyDef( statics.RELATED_COLUMN, tString ),
361 : : PropertyDef( statics.SCALE , tInt ),
362 : : PropertyDef( statics.TYPE , tInt ),
363 : : PropertyDef( statics.TYPE_NAME , tString )
364 : 0 : };
365 : : statics.refl.keycolumn.pProps = createPropertyArrayHelper(
366 : 0 : keycolumnDef, sizeof(keycolumnDef)/sizeof(PropertyDef), READONLY );
367 : :
368 : : // KeyColumn props set
369 : : statics.refl.keycolumnDescriptor.implName =
370 : 0 : ASCII_STR( "org.openoffice.comp.pq.sdbcx.KeyColumnDescriptor" );
371 : 0 : statics.refl.keycolumnDescriptor.serviceNames = Sequence< OUString > ( 1 );
372 : 0 : statics.refl.keycolumnDescriptor.serviceNames[0] =
373 : 0 : ASCII_STR( "com.sun.star.sdbcx.KeyColumnDescriptor" );
374 : : PropertyDef keycolumnDescDef[] =
375 : : {
376 : : PropertyDef( statics.NAME , tString ),
377 : : PropertyDef( statics.RELATED_COLUMN, tString )
378 : 0 : };
379 : : statics.refl.keycolumnDescriptor.pProps = createPropertyArrayHelper(
380 : 0 : keycolumnDescDef, sizeof(keycolumnDescDef)/sizeof(PropertyDef), 0 );
381 : :
382 : : // view props set
383 : 0 : statics.refl.view.implName = ASCII_STR( "org.openoffice.comp.pq.sdbcx.View");
384 : 0 : statics.refl.view.serviceNames = Sequence< OUString > ( 1 );
385 : 0 : statics.refl.view.serviceNames[0] = ASCII_STR( "com.sun.star.sdbcx.View" );
386 : : PropertyDef viewDef[] =
387 : : {
388 : : PropertyDef( statics.CATALOG_NAME , tString ),
389 : : PropertyDef( statics.CHECK_OPTION , tInt ),
390 : : PropertyDef( statics.COMMAND , tString ),
391 : : PropertyDef( statics.NAME , tString ),
392 : : PropertyDef( statics.SCHEMA_NAME , tString )
393 : 0 : };
394 : : statics.refl.view.pProps = createPropertyArrayHelper(
395 : 0 : viewDef, sizeof(viewDef)/sizeof(PropertyDef), READONLY );
396 : :
397 : : // view props set
398 : 0 : statics.refl.viewDescriptor.implName = ASCII_STR( "org.openoffice.comp.pq.sdbcx.ViewDescriptor");
399 : 0 : statics.refl.viewDescriptor.serviceNames = Sequence< OUString > ( 1 );
400 : 0 : statics.refl.viewDescriptor.serviceNames[0] = ASCII_STR( "com.sun.star.sdbcx.ViewDescriptor" );
401 : : statics.refl.viewDescriptor.pProps = createPropertyArrayHelper(
402 : 0 : viewDef, sizeof(viewDef)/sizeof(PropertyDef), 0 ); // reuse view, as it is identical
403 : : // user props set
404 : 0 : statics.refl.user.implName = ASCII_STR( "org.openoffice.comp.pq.sdbcx.User");
405 : 0 : statics.refl.user.serviceNames = Sequence< OUString > ( 1 );
406 : 0 : statics.refl.user.serviceNames[0] = ASCII_STR( "com.sun.star.sdbcx.User" );
407 : : PropertyDef userDefRO[] =
408 : : {
409 : : PropertyDef( statics.NAME , tString )
410 : 0 : };
411 : : statics.refl.user.pProps = createPropertyArrayHelper(
412 : 0 : userDefRO, sizeof(userDefRO)/sizeof(PropertyDef), READONLY );
413 : :
414 : : // user props set
415 : : statics.refl.userDescriptor.implName =
416 : 0 : ASCII_STR( "org.openoffice.comp.pq.sdbcx.UserDescriptor");
417 : 0 : statics.refl.userDescriptor.serviceNames = Sequence< OUString > ( 1 );
418 : 0 : statics.refl.userDescriptor.serviceNames[0] =
419 : 0 : ASCII_STR( "com.sun.star.sdbcx.UserDescriptor" );
420 : : PropertyDef userDefWR[] =
421 : : {
422 : : PropertyDef( statics.NAME , tString ),
423 : : PropertyDef( statics.PASSWORD , tString )
424 : 0 : };
425 : : statics.refl.userDescriptor.pProps = createPropertyArrayHelper(
426 : 0 : userDefWR, sizeof(userDefWR)/sizeof(PropertyDef), 0 );
427 : :
428 : : // index props set
429 : 0 : statics.refl.index.implName = ASCII_STR( "org.openoffice.comp.pq.sdbcx.Index");
430 : 0 : statics.refl.index.serviceNames = Sequence< OUString > ( 1 );
431 : 0 : statics.refl.index.serviceNames[0] = ASCII_STR( "com.sun.star.sdbcx.Index" );
432 : : PropertyDef indexDef[] =
433 : : {
434 : : PropertyDef( statics.CATALOG , tString ),
435 : : PropertyDef( statics.IS_CLUSTERED, tBool ),
436 : : PropertyDef( statics.IS_PRIMARY_KEY_INDEX, tBool ),
437 : : PropertyDef( statics.IS_UNIQUE, tBool ),
438 : : PropertyDef( statics.NAME , tString ),
439 : : PropertyDef( statics.PRIVATE_COLUMN_INDEXES, tStringSequence )
440 : 0 : };
441 : : statics.refl.index.pProps = createPropertyArrayHelper(
442 : 0 : indexDef, sizeof(indexDef)/sizeof(PropertyDef), READONLY );
443 : :
444 : : // index props set
445 : : statics.refl.indexDescriptor.implName =
446 : 0 : ASCII_STR( "org.openoffice.comp.pq.sdbcx.IndexDescriptor");
447 : 0 : statics.refl.indexDescriptor.serviceNames = Sequence< OUString > ( 1 );
448 : 0 : statics.refl.indexDescriptor.serviceNames[0] =
449 : 0 : ASCII_STR( "com.sun.star.sdbcx.IndexDescriptor" );
450 : : statics.refl.indexDescriptor.pProps = createPropertyArrayHelper(
451 : 0 : indexDef, sizeof(indexDef)/sizeof(PropertyDef), 0 );
452 : :
453 : : // indexColumn props set
454 : 0 : statics.refl.indexColumn.implName = ASCII_STR( "org.openoffice.comp.pq.sdbcx.IndexColumn");
455 : 0 : statics.refl.indexColumn.serviceNames = Sequence< OUString > ( 1 );
456 : 0 : statics.refl.indexColumn.serviceNames[0] = ASCII_STR("com.sun.star.sdbcx.IndexColumn");
457 : : PropertyDef indexColumnDef[] =
458 : : {
459 : : PropertyDef( statics.CATALOG_NAME , tString ),
460 : : PropertyDef( statics.DEFAULT_VALUE, tString ),
461 : : PropertyDef( statics.DESCRIPTION , tString ),
462 : : PropertyDef( statics.IS_ASCENDING, tBool ),
463 : : PropertyDef( statics.IS_AUTO_INCREMENT, tBool ),
464 : : PropertyDef( statics.IS_CURRENCY, tBool ),
465 : : PropertyDef( statics.IS_NULLABLE, tInt ),
466 : : PropertyDef( statics.IS_ROW_VERSISON, tBool ),
467 : : PropertyDef( statics.NAME , tString ),
468 : : PropertyDef( statics.PRECISION , tInt ),
469 : : PropertyDef( statics.SCALE , tInt ),
470 : : PropertyDef( statics.TYPE , tInt ),
471 : : PropertyDef( statics.TYPE_NAME , tString )
472 : 0 : };
473 : : statics.refl.indexColumn.pProps = createPropertyArrayHelper(
474 : 0 : indexColumnDef, sizeof(indexColumnDef)/sizeof(PropertyDef), READONLY );
475 : :
476 : : // indexColumn props set
477 : : statics.refl.indexColumnDescriptor.implName =
478 : 0 : ASCII_STR( "org.openoffice.comp.pq.sdbcx.IndexColumnDescriptor");
479 : 0 : statics.refl.indexColumnDescriptor.serviceNames = Sequence< OUString > ( 1 );
480 : 0 : statics.refl.indexColumnDescriptor.serviceNames[0] =
481 : 0 : ASCII_STR("com.sun.star.sdbcx.IndexColumnDescriptor");
482 : : PropertyDef indexColumnDescDef[] =
483 : : {
484 : : PropertyDef( statics.IS_ASCENDING, tBool ),
485 : : PropertyDef( statics.NAME , tString )
486 : 0 : };
487 : : statics.refl.indexColumnDescriptor.pProps = createPropertyArrayHelper(
488 : 0 : indexColumnDescDef, sizeof(indexColumnDescDef)/sizeof(PropertyDef), 0 );
489 : :
490 : : // resultset
491 : 0 : statics.refl.resultSet.implName = ASCII_STR( "org.openoffice.comp.pq.ResultSet");
492 : 0 : statics.refl.resultSet.serviceNames = Sequence< OUString > ( 1 );
493 : 0 : statics.refl.resultSet.serviceNames[0] = ASCII_STR( "com.sun.star.sdbc.ResultSet" );
494 : 0 : statics.refl.resultSet.types = UpdateableResultSet::getStaticTypes( false /* updateable */ );
495 : : PropertyDef resultSet[] =
496 : : {
497 : : PropertyDef( statics.CURSOR_NAME , tString ),
498 : : PropertyDef( statics.ESCAPE_PROCESSING , tBool ),
499 : : PropertyDef( statics.FETCH_DIRECTION , tInt ),
500 : : PropertyDef( statics.FETCH_SIZE , tInt ),
501 : : PropertyDef( statics.IS_BOOKMARKABLE , tBool ),
502 : : PropertyDef( statics.RESULT_SET_CONCURRENCY , tInt ),
503 : : PropertyDef( statics.RESULT_SET_TYPE , tInt )
504 : 0 : };
505 : : statics.refl.resultSet.pProps = createPropertyArrayHelper(
506 : 0 : resultSet, sizeof(resultSet)/sizeof(PropertyDef), 0 );
507 : :
508 : : // updateableResultset
509 : 0 : statics.refl.updateableResultSet.implName = ASCII_STR( "org.openoffice.comp.pq.UpdateableResultSet");
510 : 0 : statics.refl.updateableResultSet.serviceNames = Sequence< OUString > ( 1 );
511 : 0 : statics.refl.updateableResultSet.serviceNames[0] = ASCII_STR( "com.sun.star.sdbc.ResultSet" );
512 : 0 : statics.refl.updateableResultSet.types = UpdateableResultSet::getStaticTypes( true /* updateable */ );
513 : : statics.refl.updateableResultSet.pProps = createPropertyArrayHelper(
514 : 0 : resultSet, sizeof(resultSet)/sizeof(PropertyDef), 0 );
515 : :
516 : : // databasemetadata
517 : 0 : statics.tablesRowNames = Sequence< OUString > ( 5 );
518 : 0 : statics.tablesRowNames[TABLE_INDEX_CATALOG] = ASCII_STR( "TABLE_CAT" );
519 : 0 : statics.tablesRowNames[TABLE_INDEX_SCHEMA] = ASCII_STR( "TABLE_SCHEM" );
520 : 0 : statics.tablesRowNames[TABLE_INDEX_NAME] = ASCII_STR( "TABLE_NAME" );
521 : 0 : statics.tablesRowNames[TABLE_INDEX_TYPE] = ASCII_STR( "TABLE_TYPE" );
522 : 0 : statics.tablesRowNames[TABLE_INDEX_REMARKS] = ASCII_STR( "REMARKS" );
523 : :
524 : 0 : statics.primaryKeyNames = Sequence< OUString > ( 6 );
525 : 0 : statics.primaryKeyNames[0] = ASCII_STR( "TABLE_CAT" );
526 : 0 : statics.primaryKeyNames[1] = ASCII_STR( "TABLE_SCHEM" );
527 : 0 : statics.primaryKeyNames[2] = ASCII_STR( "TABLE_NAME" );
528 : 0 : statics.primaryKeyNames[3] = ASCII_STR( "COLUMN_NAME" );
529 : 0 : statics.primaryKeyNames[4] = ASCII_STR( "KEY_SEQ" );
530 : 0 : statics.primaryKeyNames[5] = ASCII_STR( "PK_NAME" );
531 : :
532 : 0 : statics.SELECT = ASCII_STR( "SELECT" );
533 : 0 : statics.UPDATE = ASCII_STR( "UPDATE" );
534 : 0 : statics.INSERT = ASCII_STR( "INSERT" );
535 : 0 : statics.DELETE = ASCII_STR( "DELETE" );
536 : 0 : statics.RULE = ASCII_STR( "RULE" );
537 : 0 : statics.REFERENCES = ASCII_STR( "REFERENCES" );
538 : 0 : statics.TRIGGER = ASCII_STR( "TRIGGER" );
539 : 0 : statics.EXECUTE = ASCII_STR( "EXECUTE" );
540 : 0 : statics.USAGE = ASCII_STR( "USAGE" );
541 : 0 : statics.CREATE = ASCII_STR( "CREATE" );
542 : 0 : statics.TEMPORARY = ASCII_STR( "TEMPORARY" );
543 : 0 : statics.INDEX = ASCII_STR( "Index" );
544 : 0 : statics.INDEX_COLUMN = ASCII_STR( "IndexColumn" );
545 : :
546 : 0 : statics.schemaNames = Sequence< OUString > ( 1 );
547 : 0 : statics.schemaNames[0] = ASCII_STR( "TABLE_SCHEM" );
548 : :
549 : 0 : statics.tableTypeData = Sequence< Sequence< Any > >( 2 );
550 : :
551 : 0 : statics.tableTypeData[0] = Sequence< Any > ( 1 );
552 : 0 : statics.tableTypeData[0][0] <<= statics.TABLE;
553 : :
554 : : // statics.tableTypeData[2] = Sequence< Any > ( 1 );
555 : : // statics.tableTypeData[2][0] <<= statics.VIEW;
556 : :
557 : 0 : statics.tableTypeData[1] = Sequence< Any > ( 1 );
558 : 0 : statics.tableTypeData[1][0] <<= statics.SYSTEM_TABLE;
559 : :
560 : 0 : statics.tableTypeNames = Sequence< OUString > ( 1 );
561 : 0 : statics.tableTypeNames[0] = ASCII_STR( "TABLE_TYPE" );
562 : :
563 : : static const char *tablePrivilegesNames[] =
564 : : {
565 : : "TABLE_CAT", "TABLE_SCHEM", "TABLE_NAME", "GRANTOR", "GRANTEE", "PRIVILEGE",
566 : : "IS_GRANTABLE" , 0
567 : : };
568 : : statics.tablePrivilegesNames =
569 : 0 : createStringSequence( tablePrivilegesNames );
570 : :
571 : : static const char * columnNames[] =
572 : : {
573 : : "TABLE_CAT", "TABLE_SCHEM", "TABLE_NAME", "COLUMN_NAME",
574 : : "DATA_TYPE", "TYPE_NAME", "COLUMN_SIZE", "BUFFER_LENGTH",
575 : : "DECIMAL_DIGITS", "NUM_PREC_RADIX", "NULLABLE", "REMARKS",
576 : : "COLUMN_DEF", "SQL_DATA_TYPE", "SQL_DATETIME_SUB", "CHAR_OCTET_LENGTH",
577 : : "ORDINAL_POSITION", "IS_NULLABLE", 0
578 : : };
579 : : statics.columnRowNames =
580 : 0 : createStringSequence( columnNames );
581 : :
582 : : static const char * typeinfoColumnNames[] =
583 : : {
584 : : "TYPE_NAME", "DATA_TYPE", "PRECISION", "LITERAL_PREFIX",
585 : : "LITERAL_SUFFIX", "CREATE_PARAMS", "NULLABLE", "CASE_SENSITIVE",
586 : : "SEARCHABLE", "UNSIGNED_ATTRIBUTE", "FIXED_PREC_SCALE",
587 : : "AUTO_INCREMENT", "LOCAL_TYPE_NAME", "MINIMUM_SCALE",
588 : : "MAXIMUM_SCALE", "SQL_DATA_TYPE", "SQL_DATETIME_SUB",
589 : : "NUM_PREC_RADIX", 0
590 : : };
591 : 0 : statics.typeinfoColumnNames = createStringSequence( typeinfoColumnNames );
592 : :
593 : : static const char * indexinfoColumnNames[] =
594 : : {
595 : : "TABLE_CAT", "TABLE_SCHEM", "TABLE_NAME",
596 : : "NON_UNIQUE", "INDEX_QUALIFIER", "INDEX_NAME",
597 : : "TYPE", "ORDINAL_POSITION", "COLUMN_NAME",
598 : : "ASC_OR_DESC", "CARDINALITY", "PAGES", "FILTER_CONDITION",0
599 : : };
600 : 0 : statics.indexinfoColumnNames = createStringSequence( indexinfoColumnNames );
601 : :
602 : : static const char * importedKeysColumnNames[] =
603 : : {
604 : : "PKTABLE_CAT" ,
605 : : "PKTABLE_SCHEM",
606 : : "PKTABLE_NAME" ,
607 : : "PKCOLUMN_NAME",
608 : : "FKTABLE_CAT" ,
609 : : "FKTABLE_SCHEM",
610 : : "FKTABLE_NAME" ,
611 : : "FKCOLUMN_NAME",
612 : : "KEY_SEQ" ,
613 : : "UPDATE_RULE",
614 : : "DELETE_RULE",
615 : : "FK_NAME" ,
616 : : "PK_NAME" ,
617 : : "DEFERRABILITY" ,
618 : : 0
619 : : };
620 : : statics.importedKeysColumnNames =
621 : 0 : createStringSequence( importedKeysColumnNames );
622 : :
623 : : static const char * resultSetArrayColumnNames[] = { "INDEX" , "VALUE", 0 };
624 : : statics.resultSetArrayColumnNames =
625 : 0 : createStringSequence( resultSetArrayColumnNames );
626 : :
627 : : // LEM TODO see if a refresh is needed; obtain automatically from pg_catalog.pg_type?
628 : : BaseTypeDef baseTypeDefs[] =
629 : : {
630 : : { "bool" , com::sun::star::sdbc::DataType::BIT },
631 : : { "bytea", com::sun::star::sdbc::DataType::VARBINARY },
632 : : { "char" , com::sun::star::sdbc::DataType::CHAR },
633 : :
634 : : { "int8" , com::sun::star::sdbc::DataType::BIGINT },
635 : : { "serial8" , com::sun::star::sdbc::DataType::BIGINT },
636 : :
637 : :
638 : : { "int2" , com::sun::star::sdbc::DataType::SMALLINT },
639 : :
640 : : { "int4" , com::sun::star::sdbc::DataType::INTEGER },
641 : : // { "regproc" , com::sun::star::sdbc::DataType::INTEGER },
642 : : // { "oid" , com::sun::star::sdbc::DataType::INTEGER },
643 : : // { "xid" , com::sun::star::sdbc::DataType::INTEGER },
644 : : // { "cid" , com::sun::star::sdbc::DataType::INTEGER },
645 : : // { "serial", com::sun::star::sdbc::DataType::INTEGER },
646 : : // { "serial4", com::sun::star::sdbc::DataType::INTEGER },
647 : :
648 : : { "text", com::sun::star::sdbc::DataType::VARCHAR },
649 : : { "bpchar", com::sun::star::sdbc::DataType::CHAR },
650 : : { "varchar", com::sun::star::sdbc::DataType::VARCHAR },
651 : :
652 : : { "float4", com::sun::star::sdbc::DataType::REAL },
653 : : { "float8", com::sun::star::sdbc::DataType::DOUBLE },
654 : :
655 : : { "numeric", com::sun::star::sdbc::DataType::NUMERIC },
656 : : { "decimal", com::sun::star::sdbc::DataType::DECIMAL },
657 : :
658 : : { "date", com::sun::star::sdbc::DataType::DATE },
659 : : { "time", com::sun::star::sdbc::DataType::TIME },
660 : : { "timestamp", com::sun::star::sdbc::DataType::TIMESTAMP },
661 : :
662 : : // { "_bool" , com::sun::star::sdbc::DataType::ARRAY },
663 : : // { "_bytea", com::sun::star::sdbc::DataType::ARRAY },
664 : : // { "_char" , com::sun::star::sdbc::DataType::ARRAY },
665 : :
666 : : // { "_int8" , com::sun::star::sdbc::DataType::ARRAY },
667 : : // { "_serial8" , com::sun::star::sdbc::DataType::ARRAY },
668 : :
669 : :
670 : : // { "_int2" , com::sun::star::sdbc::DataType::ARRAY },
671 : :
672 : : // { "_int4" , com::sun::star::sdbc::DataType::ARRAY },
673 : : // { "_regproc" , com::sun::star::sdbc::DataType::ARRAY },
674 : : // { "_oid" , com::sun::star::sdbc::DataType::ARRAY },
675 : : // { "_xid" , com::sun::star::sdbc::DataType::ARRAY },
676 : : // { "_cid" , com::sun::star::sdbc::DataType::ARRAY },
677 : :
678 : : // { "_text", com::sun::star::sdbc::DataType::ARRAY },
679 : : // { "_bpchar", com::sun::star::sdbc::DataType::ARRAY },
680 : : // { "_varchar", com::sun::star::sdbc::DataType::ARRAY },
681 : :
682 : : // { "_float4", com::sun::star::sdbc::DataType::ARRAY },
683 : : // { "_float8", com::sun::star::sdbc::DataType::ARRAY },
684 : :
685 : : // { "_numeric", com::sun::star::sdbc::DataType::ARRAY },
686 : : // { "_decimal", com::sun::star::sdbc::DataType::ARRAY },
687 : :
688 : : // { "_date", com::sun::star::sdbc::DataType::ARRAY }, // switch to date later
689 : : // { "_time", com::sun::star::sdbc::DataType::ARRAY }, // switch to time later
690 : :
691 : : { 0, 0 }
692 : 0 : };
693 : : int i;
694 : 0 : for( i = 0 ; baseTypeDefs[i].typeName ; i ++ )
695 : : {
696 : : statics.baseTypeMap[
697 : 0 : OUString::createFromAscii( baseTypeDefs[i].typeName) ] =
698 : 0 : baseTypeDefs[i].value;
699 : : }
700 : :
701 : : // This is the metadata for the columns of the recordset returned
702 : : // by ::com::sun::star::sdbc::XDatabaseMetaData::getTypeInfo(),
703 : : // that is what is returned by getTypeInfo().getMetaData()
704 : : DefColumnMetaData defTypeInfoMetaData[] =
705 : : {
706 : : { "TYPE_NAME", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::VARCHAR, 0,50,0,0,0,0, false }, // 0
707 : : { "DATA_TYPE", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::SMALLINT, 0,50,0,0,0,0, true }, // 1
708 : : { "PRECISION", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::INTEGER, 0,50,0,0,0,0, true }, // 2
709 : : { "LITERAL_PREFIX", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::VARCHAR, 0,50,0,0,0,0, false }, // 3
710 : : { "LITERAL_SUFFIX", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::VARCHAR, 0,50,0,0,0,0, false }, // 4
711 : : { "CREATE_PARAMS", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::VARCHAR, 0,50,0,0,0,0, false }, // 5
712 : : { "NULLABLE", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::INTEGER, 0,50,0,0,0,0, true }, // 6
713 : : { "CASE_SENSITIVE", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::BIT, 0,50,0,0,0,0, false }, // 7
714 : : { "SEARCHABLE", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::SMALLINT, 0,50,0,0,0,0, true }, // 8
715 : : { "UNSIGNED_ATTRIBUTE", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::BIT, 0,50,0,0,0,0, false }, // 9
716 : : { "FIXED_PREC_SCALE", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::BIT, 0,50,0,0,0,0, false }, // 10
717 : : { "AUTO_INCREMENT", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::BIT, 0,50,0,0,0,0, false }, // 11
718 : : { "LOCAL_TYPE_NAME", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::VARCHAR, 0,50,0,0,0,0, false }, // 12
719 : : { "MINIMUM_SCALE", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::SMALLINT, 0,50,0,0,0,0, true}, // 13
720 : : { "MAXIMUM_SCALE", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::SMALLINT, 0,50,0,0,0,0, true }, // 14
721 : : { "SQL_DATA_TYPE", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::INTEGER, 0,50,0,0,0,0, true }, // 15
722 : : { "SQL_DATETIME_SUB", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::INTEGER, 0,50,0,0,0,0 , true}, // 16
723 : : { "NUM_PREC_RADIX", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::INTEGER, 0,50,0,0,0,0, true }, // 17
724 : : {0,0,0,0,0,0,0,0,0,0,0, 0}
725 : 0 : };
726 : :
727 : 0 : for( i = 0 ; defTypeInfoMetaData[i].columnName ; i++ )
728 : : {
729 : : statics.typeInfoMetaData.push_back(
730 : : ColumnMetaData(
731 : : rtl::OUString::createFromAscii( defTypeInfoMetaData[i].columnName ),
732 : : rtl::OUString::createFromAscii( defTypeInfoMetaData[i].tableName ),
733 : : rtl::OUString::createFromAscii( defTypeInfoMetaData[i].schemaTableName ),
734 : : rtl::OUString::createFromAscii( defTypeInfoMetaData[i].typeName ),
735 : : defTypeInfoMetaData[i].type,
736 : : defTypeInfoMetaData[i].precision,
737 : : defTypeInfoMetaData[i].scale,
738 : : defTypeInfoMetaData[i].isCurrency,
739 : : defTypeInfoMetaData[i].isNullable,
740 : : defTypeInfoMetaData[i].isAutoIncrement,
741 : : defTypeInfoMetaData[i].isReadOnly,
742 : 0 : defTypeInfoMetaData[i].isSigned ) );
743 : : }
744 : :
745 : 0 : p = &statics;
746 : 0 : }
747 : : }
748 : 0 : return *p;
749 : : }
750 : :
751 : :
752 : :
753 : : }
|