User: kz      
Date: 06/02/28 02:33:22

Modified:
 /dba/connectivity/source/drivers/evoab2/
  NDatabaseMetaData.cxx

Log:
 INTEGRATION: CWS evo2fixes (1.3.74); FILE MERGED
 2006/02/15 12:15:29 mmeeks 1.3.74.1: Issue numbers: i#50913#, i#62042#, 
i#55893#, i#62043#
 Submitted by: misc, Tor, Jayant, me
 Reviewed by:   mmeeks
 
 Fix a number of bugs, make it work with evo 2.4 & 2.6.

File Changes:

Directory: /dba/connectivity/source/drivers/evoab2/
===================================================

File [changed]: NDatabaseMetaData.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/connectivity/source/drivers/evoab2/NDatabaseMetaData.cxx?r1=1.3&r2=1.4
Delta lines:  +174 -112
-----------------------
--- NDatabaseMetaData.cxx       8 Sep 2005 05:50:17 -0000       1.3
+++ NDatabaseMetaData.cxx       28 Feb 2006 10:33:20 -0000      1.4
@@ -89,30 +89,46 @@
                static sal_Int32    const s_nNULLABLE = 1;
                static sal_Int32 const s_nCHAR_OCTET_LENGTH = 65535;
 
-static GParamSpec **pFields = NULL;
-static guint        nFields = 0;
+               static ColumnProperty **pFields=NULL;
+               static guint        nFields = 0;
 
-static const char *pBlackList[] = {
+        static const char *pBlackList[] = 
+        {
                "id",
-               "list-show-addresses"
-};
+            "list-show-addresses",
+            "address-label-home",
+            "address-label-work",
+            "address-label-other"
+        };
 
-static void
-initFields()
-{
+    static void 
+    splitColumn (ColumnProperty **pToBeFields)
+    {
+        for (int i = 0; i < OTHER_ZIP; i++) 
+        {
+            pToBeFields[nFields] = g_new0(ColumnProperty,1);
+            pToBeFields[nFields]->bIsSplittedValue = true;
+            pToBeFields[nFields]->pField = 
g_param_spec_ref(g_param_spec_string 
(evo_addr[i].pColumnName,evo_addr[i].pColumnName,"",NULL,G_PARAM_WRITABLE));
+            nFields++;
+        }
+    }
+
+    static void
+    initFields()
+    {
        if( !pFields )
        {
                ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
                if( !pFields )
                {
                        guint        nProps;
+                ColumnProperty **pToBeFields;
                        GParamSpec **pProps;
-                       GParamSpec **pToBeFields;
+                nFields = 0;
                        pProps = g_object_class_list_properties
                                        ( (GObjectClass *) g_type_class_ref( 
E_TYPE_CONTACT ),
                                          &nProps );
-                       pToBeFields = g_new0( GParamSpec *, nProps );
-
+                pToBeFields = g_new0(ColumnProperty  *, (nProps + OTHER_ZIP)/* 
new column(s)*/ );
                        for ( guint i = 0; i < nProps; i++ )
                        {
                                switch (pProps[i]->value_type)
@@ -131,53 +147,77 @@
                                                }
                                        }
                                        if( bAdd )
-                                               pToBeFields[ nFields++ ] = 
g_param_spec_ref( pProps[i] );
+                            {
+                                pToBeFields[nFields]= g_new0(ColumnProperty,1);
+                                pToBeFields[nFields]->bIsSplittedValue=false;
+                                pToBeFields[ nFields++ ]->pField = 
g_param_spec_ref( pProps[i] );
+                            }
                                        break;
                                }
                                default:
                                        break;
                                }
                        }
+                       
+                splitColumn(pToBeFields);
                        pFields = pToBeFields;
                }
        }
-}
+    }
 
-guint
-getFieldCount()
-{
+
+    guint
+    getFieldCount()
+    {
        initFields();
        return nFields;
-}
+    }
 
-const GParamSpec *
-getField(guint n)
-{
+    const ColumnProperty *
+    getField(guint n)
+    {
        initFields();
        if( n < nFields )
                return pFields[n];
        else
                return NULL;
-}
+    }
 
-sal_Int32
-getFieldType( sal_Int32 nCol )
-{
+    sal_Int32
+    getFieldType( sal_Int32 nCol )
+    {
        sal_Int32 nType = DataType::VARCHAR;
        initFields();
        if (nCol >= 0 && nCol < nFields )
        {
-               if( pFields[nCol]->value_type == G_TYPE_STRING )
+            if( ((GParamSpec *)pFields[nCol]->pField)->value_type == 
G_TYPE_STRING )
                        nType = DataType::VARCHAR;
                else 
                        nType = DataType::BIT;
        }
        return nType;
-}
+    }
 
-rtl::OUString
-getFieldTypeName( sal_Int32 nCol )
-{
+    sal_Int32 findEvoabField(const rtl::OUString& aColName)
+    {
+        sal_Int32 nRet = -1;   
+        sal_Bool bFound = sal_False;
+        initFields();
+        for (int i=0;(i < nFields) && !bFound;i++)
+        {
+            rtl::OUString aName = getFieldName(i);
+            if (aName == aColName)
+            {
+                nRet = i;
+                bFound = sal_True;
+            }
+        }
+        return nRet;
+    }
+
+    rtl::OUString
+    getFieldTypeName( sal_Int32 nCol )
+    {
        switch( getFieldType( nCol ) )
        {
        case DataType::BIT:
@@ -188,30 +228,52 @@
                        break;
        }
        return ::rtl::OUString();
-}
+    }
 
-rtl::OUString
-getFieldName( sal_Int32 nCol )
-{
-       const GParamSpec *pSpec = getField( nCol );
+    rtl::OUString
+    getFieldName( sal_Int32 nCol )
+    {
+        const GParamSpec *pSpec = getField( nCol )->pField;
        rtl::OUString aName;
+        initFields();
 
        if( pSpec )
                        aName = rtl::OStringToOUString( g_param_spec_get_name( 
( GParamSpec * )pSpec ),
                                                                                
        RTL_TEXTENCODING_UTF8 );
        aName = aName.replace( '-', '_' );
        return aName;
-}
+    }
+
+    void  
+    free_column_resources()
+    {
+        for (int i=nFields-1;i > 0;i--) 
+        {
+            if (pFields && pFields[i] ) 
+            {
+                if (pFields[i]->pField) 
+                    g_param_spec_unref(pFields[i]->pField);
+                g_free(pFields[i]);
+            }
+        }
+       if(pFields) 
+        {
+            g_free(pFields);
+            pFields=NULL;
+        }
+       
+    }
+
 
        }
 }
 
+
 OEvoabDatabaseMetaData::OEvoabDatabaseMetaData(OEvoabConnection* _pCon)
        : ::connectivity::ODatabaseMetaDataBase(_pCon)
        ,m_pConnection(_pCon)
 {
        
OSL_ENSURE(m_pConnection,"OEvoabDatabaseMetaData::OEvoabDatabaseMetaData: No 
connection set!");
-       //construct();
 }
 void OEvoabDatabaseMetaData::construct()
 {
@@ -272,7 +334,7 @@
                        aRow[5] = new ORowSetValueDecorator( 
static_cast<sal_Int16>( getFieldType( i ) ) );
                        aRow[6] = new ORowSetValueDecorator( getFieldTypeName( 
i ) );
 
-                       OSL_TRACE( "   ColumnName = '%s'", 
g_param_spec_get_name( pFields[i] ) );
+                       OSL_TRACE( "   ColumnName = '%s'", 
g_param_spec_get_name( pFields[i]->pField ) );
                        // COLUMN_NAME
                        aRow[4] = new ORowSetValueDecorator( getFieldName( i ) 
);
                        // ORDINAL_POSITION




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to