LCOV - code coverage report
Current view: top level - connectivity/source/drivers/postgresql - pq_statics.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 0 242 0.0 %
Date: 2014-11-03 Functions: 0 8 0.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10