diff options
author | Lionel Elie Mamane <lionel@mamane.lu> | 2011-08-02 16:10:00 +0200 |
---|---|---|
committer | Lionel Elie Mamane <lionel@mamane.lu> | 2011-11-17 21:15:13 +0100 |
commit | e28033fdfad9750ebe96885b9514adee629acf88 (patch) | |
tree | 799ec7b900dd9c6addcea9a3230f606c60feab18 /connectivity/source/drivers/postgresql/pq_statics.cxx | |
parent | 7ce4bb76593f2116a5943cd8c5f1bd75c2105e29 (diff) |
Apply sdbc-postgresql.diff
Diffstat (limited to 'connectivity/source/drivers/postgresql/pq_statics.cxx')
-rw-r--r-- | connectivity/source/drivers/postgresql/pq_statics.cxx | 758 |
1 files changed, 758 insertions, 0 deletions
diff --git a/connectivity/source/drivers/postgresql/pq_statics.cxx b/connectivity/source/drivers/postgresql/pq_statics.cxx new file mode 100644 index 000000000000..177571d19fac --- /dev/null +++ b/connectivity/source/drivers/postgresql/pq_statics.cxx @@ -0,0 +1,758 @@ +/************************************************************************* + * + * $RCSfile: pq_statics.cxx,v $ + * + * $Revision: 1.1.2.6 $ + * + * last change: $Author: jbu $ $Date: 2007/02/15 20:04:48 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Joerg Budischewski + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): Joerg Budischewski + * + * + ************************************************************************/ + +#include "pq_statics.hxx" +#include "pq_updateableresultset.hxx" +#include <com/sun/star/sdbc/DataType.hpp> +#include <com/sun/star/beans/PropertyAttribute.hpp> + +using rtl::OUString; +using com::sun::star::uno::Sequence; +using com::sun::star::uno::Any; +using com::sun::star::uno::Type; + +using com::sun::star::beans::PropertyAttribute::READONLY; +using com::sun::star::beans::PropertyAttribute::BOUND; +using com::sun::star::beans::Property; + +namespace pq_sdbc_driver +{ + +struct DefColumnMetaData +{ + sal_Char * columnName; + sal_Char * tableName; + sal_Char * schemaTableName; + sal_Char * typeName; + sal_Int32 type; + sal_Int32 precision; + sal_Int32 scale; + sal_Bool isCurrency; + sal_Bool isNullable; + sal_Bool isAutoIncrement; + sal_Bool isReadOnly; + sal_Bool isSigned; +}; + +#define ASCII_STR(x) OUString( RTL_CONSTASCII_USTRINGPARAM( x ) ) +struct BaseTypeDef { const char * typeName; sal_Int32 value; }; + +static Sequence< OUString > createStringSequence( const char * name[] ) +{ + int length; + for( length = 0; name[length] ; length ++ ); + + Sequence< OUString > seq( length ); + for( int i = 0; i < length; i ++ ) + { + seq[i] = OUString( name[i] , strlen( name[i] ), RTL_TEXTENCODING_ASCII_US ); + } + return seq; +} + +static Sequence< sal_Int8 > generateImplementationId() +{ + Sequence< sal_Int8 > seq( 16 ); + rtl_createUuid( (sal_uInt8*)seq.getArray(), 0 , sal_False ); + return seq; +} + +struct PropertyDef +{ + PropertyDef( const OUString &str, const Type &t ) + : name( str ) , type( t ) {} + ::rtl::OUString name; + com::sun::star::uno::Type type; +}; + +struct PropertyDefEx : public PropertyDef +{ + PropertyDefEx( const OUString & str, const Type &t , sal_Int32 a ) + : PropertyDef( str, t ) , attribute( a ) + {} + sal_Int32 attribute; +}; + +static cppu::IPropertyArrayHelper * createPropertyArrayHelper( + PropertyDef *props, int count , sal_Int16 attr ) +{ + Sequence< Property > seq( count ); + for( int i = 0 ; i < count ; i ++ ) + { + seq[i] = Property( props[i].name, i, props[i].type, attr ); + } + return new cppu::OPropertyArrayHelper( seq, sal_True ); +} + +static cppu::IPropertyArrayHelper * createPropertyArrayHelper( + PropertyDefEx *props, int count ) +{ + Sequence< Property > seq( count ); + for( int i = 0 ; i < count ; i ++ ) + { + seq[i] = Property( props[i].name, i, props[i].type, props[i].attribute ); + } + return new cppu::OPropertyArrayHelper( seq, sal_True ); +} + +Statics & getStatics() +{ + static Statics * p; + if( ! p ) + { + ::osl::MutexGuard guard( ::osl::Mutex::getGlobalMutex() ); + if( ! p ) + { + static Statics statics ; + statics.SYSTEM_TABLE = ASCII_STR( "SYSTEM TABLE" ); + statics.TABLE = ASCII_STR( "TABLE" ); + statics.VIEW = ASCII_STR( "VIEW" ); + statics.UNKNOWN = ASCII_STR( "UNKNOWN" ); + statics.YES = ASCII_STR( "YES" ); + statics.NO = ASCII_STR( "NO" ); + statics.NO_NULLS = ASCII_STR( "NO_NULLS" ); + statics.NULABLE = ASCII_STR( "NULABLE" ); + statics.NULLABLE_UNKNOWN = ASCII_STR( "NULLABLE_UNKNOWN" ); + statics.cPERCENT = ASCII_STR( "%" ); + + statics.TYPE = ASCII_STR( "Type" ); + statics.TYPE_NAME = ASCII_STR( "TypeName" ); + statics.NAME = ASCII_STR( "Name" ); + statics.SCHEMA_NAME = ASCII_STR( "SchemaName" ); + statics.CATALOG_NAME = ASCII_STR( "CatalogName" ); + statics.DESCRIPTION = ASCII_STR( "Description" ); + statics.PRIVILEGES = ASCII_STR( "Privileges" ); + + statics.DEFAULT_VALUE = ASCII_STR( "DefaultValue" ); + statics.IS_AUTO_INCREMENT = ASCII_STR( "IsAutoIncrement" ); + statics.IS_CURRENCY = ASCII_STR( "IsCurrency" ); + statics.IS_NULLABLE = ASCII_STR( "IsNullable" ); + statics.IS_ROW_VERSISON = ASCII_STR( "IsRowVersion" ); + statics.PRECISION = ASCII_STR( "Precision" ); + statics.SCALE = ASCII_STR( "Scale" ); + + statics.cPERCENT = ASCII_STR( "%" ); + statics.BEGIN = ASCII_STR( "BEGIN" ); + statics.COMMIT = ASCII_STR( "COMMIT" ); + statics.ROLLBACK = ASCII_STR( "ROLLBACK" ); + + statics.KEY = ASCII_STR( "Key" ); + statics.REFERENCED_TABLE = ASCII_STR( "ReferencedTable" ); + statics.UPDATE_RULE = ASCII_STR( "UpdateRule" ); + statics.DELETE_RULE = ASCII_STR( "DeleteRule" ); + statics.PRIVATE_COLUMNS = ASCII_STR( "PrivateColumns" ); + statics.PRIVATE_FOREIGN_COLUMNS = ASCII_STR( "PrivateForeignColumns" ); + + statics.KEY_COLUMN = ASCII_STR( "KeyColumn" ); + statics.RELATED_COLUMN = ASCII_STR( "RelatedColumn" ); + statics.PASSWORD = ASCII_STR( "Password" ); + statics.USER = ASCII_STR( "User" ); + + statics.CURSOR_NAME = ASCII_STR( "CursorName" ); + statics.ESCAPE_PROCESSING = ASCII_STR( "EscapeProcessing" ); + statics.FETCH_DIRECTION = ASCII_STR( "FetchDirection" ); + statics.FETCH_SIZE = ASCII_STR( "FetchSize" ); + statics.IS_BOOKMARKABLE = ASCII_STR( "IsBookmarkable" ); + statics.RESULT_SET_CONCURRENCY = ASCII_STR( "ResultSetConcurrency" ); + statics.RESULT_SET_TYPE = ASCII_STR( "ResultSetType" ); + + statics.COMMAND = ASCII_STR( "Command" ); + statics.CHECK_OPTION = ASCII_STR( "CheckOption" ); + + statics.TRUE = ASCII_STR( "t" ); + statics.FALSE = ASCII_STR( "f" ); + statics.IS_PRIMARY_KEY_INDEX = ASCII_STR( "IsPrimaryKeyIndex" ); + statics.IS_CLUSTERED = ASCII_STR( "IsClustered" ); + statics.IS_UNIQUE = ASCII_STR( "IsUnique" ); + statics.IS_ASCENDING = ASCII_STR( "IsAscending" ); + statics.PRIVATE_COLUMN_INDEXES = ASCII_STR( "PrivateColumnIndexes" ); + statics.HELP_TEXT = ASCII_STR( "HelpText" ); + + statics.CATALOG = ASCII_STR( "Catalog" ); + + Type tString = getCppuType( (rtl::OUString *) 0 ); + Type tInt = getCppuType( (sal_Int32 * ) 0 ); + Type tBool = getBooleanCppuType(); + Type tStringSequence = getCppuType( (com::sun::star::uno::Sequence< ::rtl::OUString > *) 0); + + // Table props set + ImplementationStatics &ist = statics.refl.table; + ist.implName = ASCII_STR( "org.openoffice.comp.pq.sdbcx.Table" ); + ist.serviceNames = Sequence< OUString > ( 1 ); + ist.serviceNames[0] = ASCII_STR( "com.sun.star.sdbcx.Table" ); + PropertyDef tableDef[] = + { + PropertyDef( statics.CATALOG_NAME , tString ), + PropertyDef( statics.DESCRIPTION , tString ), + PropertyDef( statics.NAME , tString ), + PropertyDef( statics.PRIVILEGES , tInt ), + PropertyDef( statics.SCHEMA_NAME , tString ), + PropertyDef( statics.TYPE , tString ) + }; + ist.pProps = createPropertyArrayHelper( + tableDef, sizeof(tableDef)/sizeof(PropertyDef), READONLY ); + + statics.refl.tableDescriptor.implName = + ASCII_STR( "org.openoffice.comp.pq.sdbcx.TableDescriptor" ); + statics.refl.tableDescriptor.serviceNames = Sequence< OUString > (1); + statics.refl.tableDescriptor.serviceNames[0] = + ASCII_STR( "com.sun.star.sdbcx.TableDescriptor" ); + PropertyDef tableDescDef[] = + { + PropertyDef( statics.CATALOG_NAME , tString ), + PropertyDef( statics.DESCRIPTION , tString ), + PropertyDef( statics.NAME , tString ), + PropertyDef( statics.PRIVILEGES , tInt ), + PropertyDef( statics.SCHEMA_NAME , tString ) + }; + statics.refl.tableDescriptor.pProps = createPropertyArrayHelper( + tableDescDef, sizeof(tableDescDef)/sizeof(PropertyDef), 0 ); + + // Column props set + statics.refl.column.implName = ASCII_STR( "org.openoffice.comp.pq.sdbcx.Column" ); + statics.refl.column.serviceNames = Sequence< OUString > ( 1 ); + statics.refl.column.serviceNames[0] = ASCII_STR( "com.sun.star.sdbcx.Column" ); + PropertyDefEx columnDef[] = + { + PropertyDefEx( statics.CATALOG_NAME , tString, READONLY ), + PropertyDefEx( statics.DEFAULT_VALUE, tString, READONLY ), + PropertyDefEx( statics.DESCRIPTION , tString, READONLY ), +// PropertyDefEx( statics.HELP_TEXT , tString, BOUND ), + PropertyDefEx( statics.IS_AUTO_INCREMENT, tBool, READONLY ), + PropertyDefEx( statics.IS_CURRENCY, tBool, READONLY ), + PropertyDefEx( statics.IS_NULLABLE, tInt, READONLY ), + PropertyDefEx( statics.IS_ROW_VERSISON, tBool,READONLY ), + PropertyDefEx( statics.NAME , tString,READONLY ), + PropertyDefEx( statics.PRECISION , tInt, READONLY ), + PropertyDefEx( statics.SCALE , tInt ,READONLY), + PropertyDefEx( statics.TYPE , tInt ,READONLY), + PropertyDefEx( statics.TYPE_NAME , tString ,READONLY) + }; + statics.refl.column.pProps = createPropertyArrayHelper( + columnDef, sizeof(columnDef)/sizeof(PropertyDefEx) ); + + statics.refl.columnDescriptor.implName = + ASCII_STR( "org.openoffice.comp.pq.sdbcx.ColumnDescriptor" ); + statics.refl.columnDescriptor.serviceNames = Sequence< OUString > ( 1 ); + statics.refl.columnDescriptor.serviceNames[0] = + ASCII_STR( "com.sun.star.sdbcx.ColumnDescriptor" ); + PropertyDef columnDescDef[] = + { + PropertyDef( statics.CATALOG_NAME , tString ), + PropertyDef( statics.DEFAULT_VALUE, tString ), + PropertyDef( statics.DESCRIPTION , tString ), +// PropertyDef( statics.HELP_TEXT , tString ), + PropertyDef( statics.IS_AUTO_INCREMENT, tBool ), + PropertyDef( statics.IS_CURRENCY, tBool ), + PropertyDef( statics.IS_NULLABLE, tInt ), + PropertyDef( statics.IS_ROW_VERSISON, tBool ), + PropertyDef( statics.NAME , tString ), + PropertyDef( statics.PRECISION , tInt ), + PropertyDef( statics.SCALE , tInt ), + PropertyDef( statics.TYPE , tInt ), + PropertyDef( statics.TYPE_NAME , tString ) + }; + + statics.refl.columnDescriptor.pProps = createPropertyArrayHelper( + columnDescDef, sizeof(columnDescDef)/sizeof(PropertyDef), 0 ); + + // Key properties + statics.refl.key.implName = ASCII_STR( "org.openoffice.comp.pq.sdbcx.Key" ); + statics.refl.key.serviceNames = Sequence< OUString > ( 1 ); + statics.refl.key.serviceNames[0] = ASCII_STR( "com.sun.star.sdbcx.Key" ); + PropertyDef keyDef[] = + { + PropertyDef( statics.DELETE_RULE, tInt ), + PropertyDef( statics.NAME, tString ), + PropertyDef( statics.PRIVATE_COLUMNS, tStringSequence ), + PropertyDef( statics.PRIVATE_FOREIGN_COLUMNS, tStringSequence ), + PropertyDef( statics.REFERENCED_TABLE, tString ), + PropertyDef( statics.TYPE, tInt ), + PropertyDef( statics.UPDATE_RULE, tInt ) + }; + statics.refl.key.pProps = createPropertyArrayHelper( + keyDef, sizeof(keyDef)/sizeof(PropertyDef), READONLY ); + + + // Key properties + statics.refl.keyDescriptor.implName = + ASCII_STR( "org.openoffice.comp.pq.sdbcx.KeyDescriptor" ); + statics.refl.keyDescriptor.serviceNames = Sequence< OUString > ( 1 ); + statics.refl.keyDescriptor.serviceNames[0] = + ASCII_STR( "com.sun.star.sdbcx.KeyDescriptor" ); + PropertyDef keyDescDef[] = + { + PropertyDef( statics.DELETE_RULE, tInt ), + PropertyDef( statics.NAME, tString ), + PropertyDef( statics.REFERENCED_TABLE, tString ), + PropertyDef( statics.TYPE, tInt ), + PropertyDef( statics.UPDATE_RULE, tInt ) + }; + statics.refl.keyDescriptor.pProps = createPropertyArrayHelper( + keyDescDef, sizeof(keyDescDef)/sizeof(PropertyDef), 0 ); + + + + // KeyColumn props set + statics.refl.keycolumn.implName = ASCII_STR( "org.openoffice.comp.pq.sdbcx.KeyColumn" ); + statics.refl.keycolumn.serviceNames = Sequence< OUString > ( 1 ); + statics.refl.keycolumn.serviceNames[0] = ASCII_STR( "com.sun.star.sdbcx.KeyColumn" ); + PropertyDef keycolumnDef[] = + { + PropertyDef( statics.CATALOG_NAME , tString ), + PropertyDef( statics.DEFAULT_VALUE, tString ), + PropertyDef( statics.DESCRIPTION , tString ), + PropertyDef( statics.IS_AUTO_INCREMENT, tBool ), + PropertyDef( statics.IS_CURRENCY, tBool ), + PropertyDef( statics.IS_NULLABLE, tInt ), + PropertyDef( statics.IS_ROW_VERSISON, tBool ), + PropertyDef( statics.NAME , tString ), + PropertyDef( statics.PRECISION , tInt ), + PropertyDef( statics.RELATED_COLUMN, tString ), + PropertyDef( statics.SCALE , tInt ), + PropertyDef( statics.TYPE , tInt ), + PropertyDef( statics.TYPE_NAME , tString ) + }; + statics.refl.keycolumn.pProps = createPropertyArrayHelper( + keycolumnDef, sizeof(keycolumnDef)/sizeof(PropertyDef), READONLY ); + + // KeyColumn props set + statics.refl.keycolumnDescriptor.implName = + ASCII_STR( "org.openoffice.comp.pq.sdbcx.KeyColumnDescriptor" ); + statics.refl.keycolumnDescriptor.serviceNames = Sequence< OUString > ( 1 ); + statics.refl.keycolumnDescriptor.serviceNames[0] = + ASCII_STR( "com.sun.star.sdbcx.KeyColumnDescriptor" ); + PropertyDef keycolumnDescDef[] = + { + PropertyDef( statics.NAME , tString ), + PropertyDef( statics.RELATED_COLUMN, tString ) + }; + statics.refl.keycolumnDescriptor.pProps = createPropertyArrayHelper( + keycolumnDescDef, sizeof(keycolumnDescDef)/sizeof(PropertyDef), 0 ); + + // view props set + statics.refl.view.implName = ASCII_STR( "org.openoffice.comp.pq.sdbcx.View"); + statics.refl.view.serviceNames = Sequence< OUString > ( 1 ); + statics.refl.view.serviceNames[0] = ASCII_STR( "com.sun.star.sdbcx.View" ); + PropertyDef viewDef[] = + { + PropertyDef( statics.CATALOG_NAME , tString ), + PropertyDef( statics.CHECK_OPTION , tInt ), + PropertyDef( statics.COMMAND , tString ), + PropertyDef( statics.NAME , tString ), + PropertyDef( statics.SCHEMA_NAME , tString ) + }; + statics.refl.view.pProps = createPropertyArrayHelper( + viewDef, sizeof(viewDef)/sizeof(PropertyDef), READONLY ); + + // view props set + statics.refl.viewDescriptor.implName = ASCII_STR( "org.openoffice.comp.pq.sdbcx.ViewDescriptor"); + statics.refl.viewDescriptor.serviceNames = Sequence< OUString > ( 1 ); + statics.refl.viewDescriptor.serviceNames[0] = ASCII_STR( "com.sun.star.sdbcx.ViewDescriptor" ); + statics.refl.viewDescriptor.pProps = createPropertyArrayHelper( + viewDef, sizeof(viewDef)/sizeof(PropertyDef), 0 ); // reuse view, as it is identical + // user props set + statics.refl.user.implName = ASCII_STR( "org.openoffice.comp.pq.sdbcx.User"); + statics.refl.user.serviceNames = Sequence< OUString > ( 1 ); + statics.refl.user.serviceNames[0] = ASCII_STR( "com.sun.star.sdbcx.User" ); + PropertyDef userDefRO[] = + { + PropertyDef( statics.NAME , tString ) + }; + statics.refl.user.pProps = createPropertyArrayHelper( + userDefRO, sizeof(userDefRO)/sizeof(PropertyDef), READONLY ); + + // user props set + statics.refl.userDescriptor.implName = + ASCII_STR( "org.openoffice.comp.pq.sdbcx.UserDescriptor"); + statics.refl.userDescriptor.serviceNames = Sequence< OUString > ( 1 ); + statics.refl.userDescriptor.serviceNames[0] = + ASCII_STR( "com.sun.star.sdbcx.UserDescriptor" ); + PropertyDef userDefWR[] = + { + PropertyDef( statics.NAME , tString ), + PropertyDef( statics.PASSWORD , tString ) + }; + statics.refl.userDescriptor.pProps = createPropertyArrayHelper( + userDefWR, sizeof(userDefWR)/sizeof(PropertyDef), 0 ); + + // index props set + statics.refl.index.implName = ASCII_STR( "org.openoffice.comp.pq.sdbcx.Index"); + statics.refl.index.serviceNames = Sequence< OUString > ( 1 ); + statics.refl.index.serviceNames[0] = ASCII_STR( "com.sun.star.sdbcx.Index" ); + PropertyDef indexDef[] = + { + PropertyDef( statics.CATALOG , tString ), + PropertyDef( statics.IS_CLUSTERED, tBool ), + PropertyDef( statics.IS_PRIMARY_KEY_INDEX, tBool ), + PropertyDef( statics.IS_UNIQUE, tBool ), + PropertyDef( statics.NAME , tString ), + PropertyDef( statics.PRIVATE_COLUMN_INDEXES, tStringSequence ) + }; + statics.refl.index.pProps = createPropertyArrayHelper( + indexDef, sizeof(indexDef)/sizeof(PropertyDef), READONLY ); + + // index props set + statics.refl.indexDescriptor.implName = + ASCII_STR( "org.openoffice.comp.pq.sdbcx.IndexDescriptor"); + statics.refl.indexDescriptor.serviceNames = Sequence< OUString > ( 1 ); + statics.refl.indexDescriptor.serviceNames[0] = + ASCII_STR( "com.sun.star.sdbcx.IndexDescriptor" ); + statics.refl.indexDescriptor.pProps = createPropertyArrayHelper( + indexDef, sizeof(indexDef)/sizeof(PropertyDef), 0 ); + + // indexColumn props set + statics.refl.indexColumn.implName = ASCII_STR( "org.openoffice.comp.pq.sdbcx.IndexColumn"); + statics.refl.indexColumn.serviceNames = Sequence< OUString > ( 1 ); + statics.refl.indexColumn.serviceNames[0] = ASCII_STR("com.sun.star.sdbcx.IndexColumn"); + PropertyDef indexColumnDef[] = + { + PropertyDef( statics.CATALOG_NAME , tString ), + PropertyDef( statics.DEFAULT_VALUE, tString ), + PropertyDef( statics.DESCRIPTION , tString ), + PropertyDef( statics.IS_ASCENDING, tBool ), + PropertyDef( statics.IS_AUTO_INCREMENT, tBool ), + PropertyDef( statics.IS_CURRENCY, tBool ), + PropertyDef( statics.IS_NULLABLE, tInt ), + PropertyDef( statics.IS_ROW_VERSISON, tBool ), + PropertyDef( statics.NAME , tString ), + PropertyDef( statics.PRECISION , tInt ), + PropertyDef( statics.SCALE , tInt ), + PropertyDef( statics.TYPE , tInt ), + PropertyDef( statics.TYPE_NAME , tString ) + }; + statics.refl.indexColumn.pProps = createPropertyArrayHelper( + indexColumnDef, sizeof(indexColumnDef)/sizeof(PropertyDef), READONLY ); + + // indexColumn props set + statics.refl.indexColumnDescriptor.implName = + ASCII_STR( "org.openoffice.comp.pq.sdbcx.IndexColumnDescriptor"); + statics.refl.indexColumnDescriptor.serviceNames = Sequence< OUString > ( 1 ); + statics.refl.indexColumnDescriptor.serviceNames[0] = + ASCII_STR("com.sun.star.sdbcx.IndexColumnDescriptor"); + PropertyDef indexColumnDescDef[] = + { + PropertyDef( statics.IS_ASCENDING, tBool ), + PropertyDef( statics.NAME , tString ) + }; + statics.refl.indexColumnDescriptor.pProps = createPropertyArrayHelper( + indexColumnDescDef, sizeof(indexColumnDescDef)/sizeof(PropertyDef), 0 ); + + // resultset + statics.refl.resultSet.implName = ASCII_STR( "org.openoffice.comp.pq.ResultSet"); + statics.refl.resultSet.serviceNames = Sequence< OUString > ( 1 ); + statics.refl.resultSet.serviceNames[0] = ASCII_STR( "com.sun.star.sdbc.ResultSet" ); + statics.refl.resultSet.types = UpdateableResultSet::getStaticTypes( false /* updateable */ ); + PropertyDef resultSet[] = + { + PropertyDef( statics.CURSOR_NAME , tString ), + PropertyDef( statics.ESCAPE_PROCESSING , tBool ), + PropertyDef( statics.FETCH_DIRECTION , tInt ), + PropertyDef( statics.FETCH_SIZE , tInt ), + PropertyDef( statics.IS_BOOKMARKABLE , tBool ), + PropertyDef( statics.RESULT_SET_CONCURRENCY , tInt ), + PropertyDef( statics.RESULT_SET_TYPE , tInt ) + }; + statics.refl.resultSet.pProps = createPropertyArrayHelper( + resultSet, sizeof(resultSet)/sizeof(PropertyDef), 0 ); + + // updateableResultset + statics.refl.updateableResultSet.implName = ASCII_STR( "org.openoffice.comp.pq.UpdateableResultSet"); + statics.refl.updateableResultSet.serviceNames = Sequence< OUString > ( 1 ); + statics.refl.updateableResultSet.serviceNames[0] = ASCII_STR( "com.sun.star.sdbc.ResultSet" ); + statics.refl.updateableResultSet.types = UpdateableResultSet::getStaticTypes( true /* updateable */ ); + statics.refl.updateableResultSet.pProps = createPropertyArrayHelper( + resultSet, sizeof(resultSet)/sizeof(PropertyDef), 0 ); + + // databasemetadata + statics.tablesRowNames = Sequence< OUString > ( 5 ); + statics.tablesRowNames[TABLE_INDEX_CATALOG] = ASCII_STR( "TABLE_CAT" ); + statics.tablesRowNames[TABLE_INDEX_SCHEMA] = ASCII_STR( "TABLE_SCHEM" ); + statics.tablesRowNames[TABLE_INDEX_NAME] = ASCII_STR( "TABLE_NAME" ); + statics.tablesRowNames[TABLE_INDEX_TYPE] = ASCII_STR( "TABLE_TYPE" ); + statics.tablesRowNames[TABLE_INDEX_REMARKS] = ASCII_STR( "REMARKS" ); + + statics.primaryKeyNames = Sequence< OUString > ( 6 ); + statics.primaryKeyNames[0] = ASCII_STR( "TABLE_CAT" ); + statics.primaryKeyNames[1] = ASCII_STR( "TABLE_SCHEM" ); + statics.primaryKeyNames[2] = ASCII_STR( "TABLE_NAME" ); + statics.primaryKeyNames[3] = ASCII_STR( "COLUMN_NAME" ); + statics.primaryKeyNames[4] = ASCII_STR( "KEY_SEQ" ); + statics.primaryKeyNames[5] = ASCII_STR( "PK_NAME" ); + + statics.SELECT = ASCII_STR( "SELECT" ); + statics.UPDATE = ASCII_STR( "UPDATE" ); + statics.INSERT = ASCII_STR( "INSERT" ); + statics.DELETE = ASCII_STR( "DELETE" ); + statics.RULE = ASCII_STR( "RULE" ); + statics.REFERENCES = ASCII_STR( "REFERENCES" ); + statics.TRIGGER = ASCII_STR( "TRIGGER" ); + statics.EXECUTE = ASCII_STR( "EXECUTE" ); + statics.USAGE = ASCII_STR( "USAGE" ); + statics.CREATE = ASCII_STR( "CREATE" ); + statics.TEMPORARY = ASCII_STR( "TEMPORARY" ); + statics.INDEX = ASCII_STR( "Index" ); + statics.INDEX_COLUMN = ASCII_STR( "IndexColumn" ); + + statics.schemaNames = Sequence< OUString > ( 1 ); + statics.schemaNames[0] = ASCII_STR( "TABLE_SCHEM" ); + + statics.tableTypeData = Sequence< Sequence< Any > >( 2 ); + + statics.tableTypeData[0] = Sequence< Any > ( 1 ); + statics.tableTypeData[0][0] <<= statics.TABLE; + +// statics.tableTypeData[2] = Sequence< Any > ( 1 ); +// statics.tableTypeData[2][0] <<= statics.VIEW; + + statics.tableTypeData[1] = Sequence< Any > ( 1 ); + statics.tableTypeData[1][0] <<= statics.SYSTEM_TABLE; + + statics.tableTypeNames = Sequence< OUString > ( 1 ); + statics.tableTypeNames[0] = ASCII_STR( "TABLE_TYPE" ); + + static const char *tablePrivilegesNames[] = + { + "TABLE_CAT", "TABLE_SCHEM", "TABLE_NAME", "GRANTOR", "GRANTEE", "PRIVILEGE", + "IS_GRANTABLE" , 0 + }; + statics.tablePrivilegesNames = + createStringSequence( tablePrivilegesNames ); + + static const char * columnNames[] = + { + "TABLE_CAT", "TABLE_SCHEM", "TABLE_NAME", "COLUMN_NAME", + "DATA_TYPE", "TYPE_NAME", "COLUMN_SIZE", "BUFFER_LENGTH", + "DECIMAL_DIGITS", "NUM_PREC_RADIX", "NULLABLE", "REMARKS", + "COLUMN_DEF", "SQL_DATA_TYPE", "SQL_DATETIME_SUB", "CHAR_OCTET_LENGTH", + "ORDINAL_POSITION", "IS_NULLABLE", 0 + }; + statics.columnRowNames = + createStringSequence( columnNames ); + + static const char * typeinfoColumnNames[] = + { + "TYPE_NAME", "DATA_TYPE", "PRECISION", "LITERAL_PREFIX", + "LITERAL_SUFFIX", "CREATE_PARAMS", "NULLABLE", "CASE_SENSITIVE", + "SEARCHABLE", "UNSIGNED_ATTRIBUTE", "FIXED_PREC_SCALE", + "AUTO_INCREMENT", "LOCAL_TYPE_NAME", "MINIMUM_SCALE", + "MAXIMUM_SCALE", "SQL_DATA_TYPE", "SQL_DATETIME_SUB", + "NUM_PREC_RADIX", 0 + }; + statics.typeinfoColumnNames = createStringSequence( typeinfoColumnNames ); + + static const char * indexinfoColumnNames[] = + { + "TABLE_CAT", "TABLE_SCHEM", "TABLE_NAME", + "NON_UNIQUE", "INDEX_QUALIFIER", "INDEX_NAME", + "TYPE", "ORDINAL_POSITION", "COLUMN_NAME", + "ASC_OR_DESC", "CARDINALITY", "PAGES", "FILTER_CONDITION",0 + }; + statics.indexinfoColumnNames = createStringSequence( indexinfoColumnNames ); + + static const char * importedKeysColumnNames[] = + { + "PKTABLE_CAT" , + "PKTABLE_SCHEM", + "PKTABLE_NAME" , + "PKCOLUMN_NAME", + "FKTABLE_CAT" , + "FKTABLE_SCHEM", + "FKTABLE_NAME" , + "FKCOLUMN_NAME", + "KEY_SEQ" , + "UPDATE_RULE", + "DELETE_RULE", + "FK_NAME" , + "PK_NAME" , + "DEFERRABILITY" , + 0 + }; + statics.importedKeysColumnNames = + createStringSequence( importedKeysColumnNames ); + + static const char * resultSetArrayColumnNames[] = { "INDEX" , "VALUE", 0 }; + statics.resultSetArrayColumnNames = + createStringSequence( resultSetArrayColumnNames ); + + BaseTypeDef baseTypeDefs[] = + { + { "bool" , com::sun::star::sdbc::DataType::BIT }, + { "bytea", com::sun::star::sdbc::DataType::VARBINARY }, + { "char" , com::sun::star::sdbc::DataType::CHAR }, + + { "int8" , com::sun::star::sdbc::DataType::BIGINT }, + { "serial8" , com::sun::star::sdbc::DataType::BIGINT }, + + + { "int2" , com::sun::star::sdbc::DataType::SMALLINT }, + + { "int4" , com::sun::star::sdbc::DataType::INTEGER }, +// { "regproc" , com::sun::star::sdbc::DataType::INTEGER }, +// { "oid" , com::sun::star::sdbc::DataType::INTEGER }, +// { "xid" , com::sun::star::sdbc::DataType::INTEGER }, +// { "cid" , com::sun::star::sdbc::DataType::INTEGER }, +// { "serial", com::sun::star::sdbc::DataType::INTEGER }, +// { "serial4", com::sun::star::sdbc::DataType::INTEGER }, + + { "text", com::sun::star::sdbc::DataType::VARCHAR }, + { "bpchar", com::sun::star::sdbc::DataType::CHAR }, + { "varchar", com::sun::star::sdbc::DataType::VARCHAR }, + + { "float4", com::sun::star::sdbc::DataType::REAL }, + { "float8", com::sun::star::sdbc::DataType::DOUBLE }, + + { "numeric", com::sun::star::sdbc::DataType::NUMERIC }, + { "decimal", com::sun::star::sdbc::DataType::DECIMAL }, + + { "date", com::sun::star::sdbc::DataType::DATE }, // switch to date later + { "time", com::sun::star::sdbc::DataType::TIME }, // switch to time later + { "timestamp", com::sun::star::sdbc::DataType::TIMESTAMP }, // switch to time later + +// { "_bool" , com::sun::star::sdbc::DataType::ARRAY }, +// { "_bytea", com::sun::star::sdbc::DataType::ARRAY }, +// { "_char" , com::sun::star::sdbc::DataType::ARRAY }, + +// { "_int8" , com::sun::star::sdbc::DataType::ARRAY }, +// { "_serial8" , com::sun::star::sdbc::DataType::ARRAY }, + + +// { "_int2" , com::sun::star::sdbc::DataType::ARRAY }, + +// { "_int4" , com::sun::star::sdbc::DataType::ARRAY }, +// { "_regproc" , com::sun::star::sdbc::DataType::ARRAY }, +// { "_oid" , com::sun::star::sdbc::DataType::ARRAY }, +// { "_xid" , com::sun::star::sdbc::DataType::ARRAY }, +// { "_cid" , com::sun::star::sdbc::DataType::ARRAY }, + +// { "_text", com::sun::star::sdbc::DataType::ARRAY }, +// { "_bpchar", com::sun::star::sdbc::DataType::ARRAY }, +// { "_varchar", com::sun::star::sdbc::DataType::ARRAY }, + +// { "_float4", com::sun::star::sdbc::DataType::ARRAY }, +// { "_float8", com::sun::star::sdbc::DataType::ARRAY }, + +// { "_numeric", com::sun::star::sdbc::DataType::ARRAY }, +// { "_decimal", com::sun::star::sdbc::DataType::ARRAY }, + +// { "_date", com::sun::star::sdbc::DataType::ARRAY }, // switch to date later +// { "_time", com::sun::star::sdbc::DataType::ARRAY }, // switch to time later + + { 0, 0 } + }; + int i; + for( i = 0 ; baseTypeDefs[i].typeName ; i ++ ) + { + statics.baseTypeMap[ + OUString::createFromAscii( baseTypeDefs[i].typeName) ] = + baseTypeDefs[i].value; + } + + DefColumnMetaData defTypeInfoMetaData[] = + { + { "TYPE_NAME", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::VARCHAR, 0,50,0,0,0,0 }, // 0 + { "DATA_TYPE", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::INTEGER, 0,50,0,0,0,0 }, // 1 + { "PRECISION", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::INTEGER, 0,50,0,0,0,0 }, // 2 + { "foo1", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::INTEGER, 0,50,0,0,0,0 }, // 3 + { "foo2", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::INTEGER, 0,50,0,0,0,0 }, // 4 + { "CREATE_PARAMS", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::VARCHAR, 0,50,0,0,0,0 }, // 5 + { "NULLABLE", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::INTEGER, 0,50,0,0,0,0 }, // 6 + { "CASE_SENSITIVE", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::BIT, 0,50,0,0,0,0 }, // 7 + { "SEARCHABLE", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::SMALLINT, 0,50,0,0,0,0 }, // 8 + { "UNSIGNED_ATTRIBUTE", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::BIT, 0,50,0,0,0,0 }, // 9 + { "FIXED_PREC_SCALE", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::BIT, 0,50,0,0,0,0 }, // 10 + { "AUTO_INCREMENT", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::BIT, 0,50,0,0,0,0 }, // 11 + { "foo3", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::INTEGER, 0,50,0,0,0,0 }, // 12 + { "MINIMUM_SCALE", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::INTEGER, 0,50,0,0,0,0 }, // 13 + { "MAXIMUM_SCALE", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::INTEGER, 0,50,0,0,0,0 }, // 14 + { "foo4", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::INTEGER, 0,50,0,0,0,0 }, // 15 + { "foo5", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::INTEGER, 0,50,0,0,0,0 }, // 16 + { "NUM_PREC_RADIX", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::INTEGER, 0,50,0,0,0,0 }, // 17 + {0,0,0,0,0,0,0,0,0,0,0} + }; + + for( i = 0 ; defTypeInfoMetaData[i].columnName ; i++ ) + { + statics.typeInfoMetaData.push_back( + ColumnMetaData( + rtl::OUString::createFromAscii( defTypeInfoMetaData[i].columnName ), + rtl::OUString::createFromAscii( defTypeInfoMetaData[i].tableName ), + rtl::OUString::createFromAscii( defTypeInfoMetaData[i].schemaTableName ), + rtl::OUString::createFromAscii( defTypeInfoMetaData[i].typeName ), + defTypeInfoMetaData[i].type, + defTypeInfoMetaData[i].precision, + defTypeInfoMetaData[i].scale, + defTypeInfoMetaData[i].isCurrency, + defTypeInfoMetaData[i].isNullable, + defTypeInfoMetaData[i].isAutoIncrement, + defTypeInfoMetaData[i].isReadOnly, + defTypeInfoMetaData[i].isSigned ) ); + } + + p = &statics; + } + } + return *p; +} + + + +} |