LCOV - code coverage report
Current view: top level - connectivity/source/commontools - FValue.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 480 1172 41.0 %
Date: 2014-04-11 Functions: 48 89 53.9 %
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             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : 
      21             : #include <string.h>
      22             : #include <stdio.h>
      23             : #include "connectivity/FValue.hxx"
      24             : #include "connectivity/CommonTools.hxx"
      25             : #include <connectivity/dbconversion.hxx>
      26             : #include <comphelper/extract.hxx>
      27             : #include <com/sun/star/io/XInputStream.hpp>
      28             : #include <rtl/ustrbuf.hxx>
      29             : #include <boost/type_traits.hpp>
      30             : #include <boost/static_assert.hpp>
      31             : 
      32             : using namespace ::dbtools;
      33             : using namespace ::com::sun::star::sdbc;
      34             : using namespace ::com::sun::star::sdb;
      35             : using namespace ::com::sun::star::uno;
      36             : using namespace ::com::sun::star::util;
      37             : using namespace ::com::sun::star::io;
      38             : 
      39             : namespace connectivity
      40             : {
      41             : 
      42             : namespace {
      43       10974 :     static bool isStorageCompatible(sal_Int32 _eType1, sal_Int32 _eType2)
      44             :     {
      45             :         SAL_INFO( "connectivity.commontools", "dbtools Ocke.Janssen@sun.com ORowSetValue::isStorageCompatible" );
      46       10974 :         bool bIsCompatible = true;
      47             : 
      48       10974 :         if (_eType1 != _eType2)
      49             :         {
      50             :             SAL_INFO( "connectivity.commontools", "ORowSetValue::isStorageCompatible _eType1 != _eType2" );
      51       10315 :             switch (_eType1)
      52             :             {
      53             :                 case DataType::CHAR:
      54             :                 case DataType::VARCHAR:
      55             :                 case DataType::DECIMAL:
      56             :                 case DataType::NUMERIC:
      57             :                 case DataType::LONGVARCHAR:
      58             :                     bIsCompatible = (DataType::CHAR         == _eType2)
      59        9969 :                                 ||  (DataType::VARCHAR      == _eType2)
      60           0 :                                 ||  (DataType::DECIMAL      == _eType2)
      61           0 :                                 ||  (DataType::NUMERIC      == _eType2)
      62        9969 :                                 ||  (DataType::LONGVARCHAR  == _eType2);
      63        9969 :                     break;
      64             : 
      65             :                 case DataType::DOUBLE:
      66             :                 case DataType::REAL:
      67             :                     bIsCompatible = (DataType::DOUBLE   == _eType2)
      68           0 :                                 ||  (DataType::REAL     == _eType2);
      69           0 :                     break;
      70             : 
      71             :                 case DataType::BINARY:
      72             :                 case DataType::VARBINARY:
      73             :                 case DataType::LONGVARBINARY:
      74             :                     bIsCompatible = (DataType::BINARY           == _eType2)
      75           0 :                                 ||  (DataType::VARBINARY        == _eType2)
      76           0 :                                 ||  (DataType::LONGVARBINARY    == _eType2);
      77           0 :                     break;
      78             : 
      79             :                 case DataType::INTEGER:
      80             :                     bIsCompatible = (DataType::SMALLINT == _eType2)
      81           0 :                                 ||  (DataType::TINYINT  == _eType2)
      82           0 :                                 ||  (DataType::BIT      == _eType2)
      83           0 :                                 ||  (DataType::BOOLEAN  == _eType2);
      84           0 :                     break;
      85             :                 case DataType::SMALLINT:
      86             :                     bIsCompatible = (DataType::TINYINT  == _eType2)
      87           0 :                                 ||  (DataType::BIT      == _eType2)
      88           0 :                                 ||  (DataType::BOOLEAN  == _eType2);
      89           0 :                     break;
      90             :                 case DataType::TINYINT:
      91             :                     bIsCompatible = (DataType::BIT      == _eType2)
      92           0 :                                 ||  (DataType::BOOLEAN  == _eType2);
      93           0 :                     break;
      94             : 
      95             :                 case DataType::BLOB:
      96             :                 case DataType::CLOB:
      97             :                 case DataType::OBJECT:
      98             :                     bIsCompatible = (DataType::BLOB     == _eType2)
      99         285 :                                 ||  (DataType::CLOB     == _eType2)
     100         540 :                                 ||  (DataType::OBJECT   == _eType2);
     101         285 :                     break;
     102             : 
     103             :                 default:
     104          61 :                     bIsCompatible = false;
     105             :             }
     106             :         }
     107       10974 :         return bIsCompatible;
     108             :     }
     109             : }
     110             : 
     111             : 
     112             : #ifdef DBG_UTIL
     113             : 
     114             : #include <vector>
     115             : #include <rtl/string.h>
     116             : 
     117             : namespace tracing
     118             : {
     119             :     struct AllocationType
     120             :     {
     121             :         const sal_Char* pName;
     122             :         sal_Int32       nAllocatedUnits;
     123             : 
     124             :         AllocationType( ) : pName( NULL ), nAllocatedUnits( 0 ) { }
     125             :     };
     126             : 
     127             : 
     128             :     class AllocationTracer
     129             :     {
     130             :     public:
     131             :         typedef ::std::vector< AllocationType > AllocationState;
     132             :         static AllocationState                  s_aAllocated;
     133             :         static ::osl::Mutex                     s_aMutex;
     134             : 
     135             :     public:
     136             :         static void registerUnit( const sal_Char* _pName );
     137             :         static void revokeUnit( const sal_Char* _pName );
     138             : 
     139             :     private:
     140             :         static AllocationState::iterator    getLocation( const sal_Char* _pName );
     141             :     };
     142             : 
     143             : 
     144             :     AllocationTracer::AllocationState::iterator AllocationTracer::getLocation( const sal_Char* _pName )
     145             :     {
     146             :         AllocationState::iterator aLookFor = s_aAllocated.begin();
     147             :         for (   ;
     148             :                 aLookFor != s_aAllocated.end();
     149             :                 ++aLookFor
     150             :             )
     151             :         {
     152             :             if ( 0 == rtl_str_compare( aLookFor->pName, _pName ) )
     153             :                 // found
     154             :                 return aLookFor;
     155             :         }
     156             :         // not found
     157             :         s_aAllocated.push_back( AllocationType() );
     158             :         aLookFor = s_aAllocated.end(); --aLookFor;
     159             :         aLookFor->pName = _pName;   // note that this assumes that _pName is a constant string ....
     160             :         return aLookFor;
     161             :     }
     162             : 
     163             : 
     164             :     AllocationTracer::AllocationState           AllocationTracer::s_aAllocated;
     165             :     ::osl::Mutex                                AllocationTracer::s_aMutex;
     166             : 
     167             : 
     168             :     void AllocationTracer::registerUnit( const sal_Char* _pName )
     169             :     {
     170             :         ::osl::MutexGuard aGuard( s_aMutex );
     171             : 
     172             :         AllocationState::iterator aPos = getLocation( _pName );
     173             :         ++aPos->nAllocatedUnits;
     174             :     }
     175             : 
     176             : 
     177             :     void AllocationTracer::revokeUnit( const sal_Char* _pName )
     178             :     {
     179             :         ::osl::MutexGuard aGuard( s_aMutex );
     180             : 
     181             :         AllocationState::iterator aPos = getLocation( _pName );
     182             :         --aPos->nAllocatedUnits;
     183             :     }
     184             : 
     185             : #define TRACE_ALLOC( type ) tracing::AllocationTracer::registerUnit( #type );
     186             : #define TRACE_FREE( type )  tracing::AllocationTracer::revokeUnit( #type );
     187             : }
     188             : #else
     189             : #define TRACE_ALLOC( type )
     190             : #define TRACE_FREE( type )
     191             : #endif
     192             : 
     193             : 
     194       13303 : void ORowSetValue::setTypeKind(sal_Int32 _eType)
     195             : {
     196             :     SAL_INFO( "connectivity.commontools", "dbtools Ocke.Janssen@sun.com ORowSetValue::setTypeKind" );
     197       13303 :     if ( !m_bNull && !isStorageCompatible(_eType, m_eTypeKind) )
     198             :     {
     199          61 :         switch(_eType)
     200             :         {
     201             :             case DataType::VARCHAR:
     202             :             case DataType::CHAR:
     203             :             case DataType::DECIMAL:
     204             :             case DataType::NUMERIC:
     205             :             case DataType::LONGVARCHAR:
     206           0 :                 (*this) = getString();
     207           0 :                 break;
     208             :             case DataType::BIGINT:
     209             :             {
     210           0 :                 sal_Int64 nVal(getLong());
     211           0 :                 sal_uInt64 nuVal(getULong());
     212           0 :                 if (nVal == 0 && nuVal != 0)
     213           0 :                     (*this) = nuVal;
     214             :                 else
     215           0 :                     (*this) = nVal;
     216           0 :                 break;
     217             :             }
     218             : 
     219             :             case DataType::FLOAT:
     220           0 :                 (*this) = getFloat();
     221           0 :                 break;
     222             :             case DataType::DOUBLE:
     223             :             case DataType::REAL:
     224           0 :                 (*this) = getDouble();
     225           0 :                 break;
     226             :             case DataType::TINYINT:
     227           0 :                 (*this) = getInt8();
     228           0 :                 break;
     229             :             case DataType::SMALLINT:
     230           0 :                 (*this) = getInt16();
     231           0 :                 break;
     232             :             case DataType::INTEGER:
     233             :             {
     234           0 :                 sal_Int32 nVal(getInt32());
     235           0 :                 sal_uInt32 nuVal(getUInt32());
     236           0 :                 if (nVal == 0 && nuVal != 0)
     237           0 :                     (*this) = nuVal;
     238             :                 else
     239           0 :                     (*this) = nVal;
     240           0 :                 break;
     241             :             }
     242             :             case DataType::BIT:
     243             :             case DataType::BOOLEAN:
     244           8 :                 (*this) = getBool();
     245           8 :                 break;
     246             :             case DataType::DATE:
     247           0 :                 (*this) = getDate();
     248           0 :                 break;
     249             :             case DataType::TIME:
     250           0 :                 (*this) = getTime();
     251           0 :                 break;
     252             :             case DataType::TIMESTAMP:
     253           0 :                 (*this) = getDateTime();
     254           0 :                 break;
     255             :             case DataType::BINARY:
     256             :             case DataType::VARBINARY:
     257             :             case DataType::LONGVARBINARY:
     258           0 :                 (*this) = getSequence();
     259           0 :                 break;
     260             :             case DataType::BLOB:
     261             :             case DataType::CLOB:
     262             :             case DataType::OBJECT:
     263             :             case DataType::OTHER:
     264          53 :                 (*this) = makeAny();
     265          53 :                 break;
     266             :             default:
     267           0 :                 (*this) = makeAny();
     268             :                 SAL_WARN( "connectivity.commontools","ORowSetValue::setTypeKind(): UNSUPPORTED TYPE!");
     269             :         }
     270             :     }
     271             : 
     272       13303 :     m_eTypeKind = _eType;
     273       13303 : }
     274             : 
     275             : 
     276       67061 : void ORowSetValue::free()
     277             : {
     278             :     SAL_INFO( "connectivity.commontools", "dbtools Ocke.Janssen@sun.com ORowSetValue::free" );
     279       67061 :     if(!m_bNull)
     280             :     {
     281       30417 :         switch(m_eTypeKind)
     282             :         {
     283             :             case DataType::CHAR:
     284             :             case DataType::VARCHAR:
     285             :             case DataType::DECIMAL:
     286             :             case DataType::NUMERIC:
     287             :             case DataType::LONGVARCHAR:
     288             :                 OSL_ENSURE(m_aValue.m_pString,"String pointer is null!");
     289       24020 :                 rtl_uString_release(m_aValue.m_pString);
     290       24020 :                 m_aValue.m_pString = NULL;
     291       24020 :                 break;
     292             :             case DataType::DATE:
     293         191 :                 delete (::com::sun::star::util::Date*)m_aValue.m_pValue;
     294             :                 TRACE_FREE( Date )
     295         191 :                 m_aValue.m_pValue = NULL;
     296         191 :                 break;
     297             :             case DataType::TIME:
     298           0 :                 delete (::com::sun::star::util::Time*)m_aValue.m_pValue;
     299             :                 TRACE_FREE( Time )
     300           0 :                 m_aValue.m_pValue = NULL;
     301           0 :                 break;
     302             :             case DataType::TIMESTAMP:
     303           0 :                 delete (::com::sun::star::util::DateTime*)m_aValue.m_pValue;
     304             :                 TRACE_FREE( DateTime )
     305           0 :                 m_aValue.m_pValue = NULL;
     306           0 :                 break;
     307             :             case DataType::BINARY:
     308             :             case DataType::VARBINARY:
     309             :             case DataType::LONGVARBINARY:
     310           0 :                 delete (Sequence<sal_Int8>*)m_aValue.m_pValue;
     311             :                 TRACE_FREE( Sequence_sal_Int8 )
     312           0 :                 m_aValue.m_pValue = NULL;
     313           0 :                 break;
     314             :             case DataType::BLOB:
     315             :             case DataType::CLOB:
     316             :             case DataType::OBJECT:
     317         435 :                 delete (Any*)m_aValue.m_pValue;
     318             :                 TRACE_FREE( Any )
     319         435 :                 m_aValue.m_pValue = NULL;
     320         435 :                 break;
     321             :             case DataType::BIT:
     322             :             case DataType::TINYINT:
     323             :             case DataType::SMALLINT:
     324             :             case DataType::INTEGER:
     325             :             case DataType::BIGINT:
     326             :             case DataType::BOOLEAN:
     327             :             case DataType::FLOAT:
     328             :             case DataType::DOUBLE:
     329             :             case DataType::REAL:
     330        5067 :                 break;
     331             :             default:
     332         704 :                 if ( m_aValue.m_pValue )
     333             :                 {
     334         704 :                     delete (Any*)m_aValue.m_pValue;
     335             :                     TRACE_FREE( Any )
     336         704 :                     m_aValue.m_pValue = NULL;
     337             :                 }
     338         704 :                 break;
     339             : 
     340             :         }
     341       30417 :         m_bNull = true;
     342             :     }
     343       67061 : }
     344             : 
     345       15633 : ORowSetValue& ORowSetValue::operator=(const ORowSetValue& _rRH)
     346             : {
     347       15633 :     if(&_rRH == this)
     348           6 :         return *this;
     349             : 
     350       15627 :     if ( m_eTypeKind != _rRH.m_eTypeKind || (_rRH.m_bNull && !m_bNull) || m_bSigned != _rRH.m_bSigned)
     351        4676 :         free();
     352             : 
     353       15627 :     m_bBound    = _rRH.m_bBound;
     354       15627 :     m_eTypeKind = _rRH.m_eTypeKind;
     355       15627 :     m_bSigned   = _rRH.m_bSigned;
     356             : 
     357       20321 :     if(m_bNull && !_rRH.m_bNull)
     358             :     {
     359        4694 :         switch(_rRH.m_eTypeKind)
     360             :         {
     361             :             case DataType::CHAR:
     362             :             case DataType::VARCHAR:
     363             :             case DataType::DECIMAL:
     364             :             case DataType::NUMERIC:
     365             :             case DataType::LONGVARCHAR:
     366        2800 :                 rtl_uString_acquire(_rRH.m_aValue.m_pString);
     367        2800 :                 m_aValue.m_pString = _rRH.m_aValue.m_pString;
     368        2800 :                 break;
     369             :             case DataType::DATE:
     370          81 :                 m_aValue.m_pValue   = new Date(*(Date*)_rRH.m_aValue.m_pValue);
     371             :                 TRACE_ALLOC( Date )
     372          81 :                 break;
     373             :             case DataType::TIME:
     374           0 :                 m_aValue.m_pValue   = new Time(*(Time*)_rRH.m_aValue.m_pValue);
     375             :                 TRACE_ALLOC( Time )
     376           0 :                 break;
     377             :             case DataType::TIMESTAMP:
     378           0 :                 m_aValue.m_pValue   = new DateTime(*(DateTime*)_rRH.m_aValue.m_pValue);
     379             :                 TRACE_ALLOC( DateTime )
     380           0 :                 break;
     381             :             case DataType::BINARY:
     382             :             case DataType::VARBINARY:
     383             :             case DataType::LONGVARBINARY:
     384           0 :                 m_aValue.m_pValue   = new Sequence<sal_Int8>(*(Sequence<sal_Int8>*)_rRH.m_aValue.m_pValue);
     385             :                 TRACE_ALLOC( Sequence_sal_Int8 )
     386           0 :                 break;
     387             :             case DataType::BIT:
     388             :             case DataType::BOOLEAN:
     389          40 :                 m_aValue.m_bBool    = _rRH.m_aValue.m_bBool;
     390          40 :                 break;
     391             :             case DataType::TINYINT:
     392          14 :                 if ( _rRH.m_bSigned )
     393           0 :                     m_aValue.m_nInt8    = _rRH.m_aValue.m_nInt8;
     394             :                 else
     395          14 :                     m_aValue.m_uInt8    = _rRH.m_aValue.m_uInt8;
     396          14 :                 break;
     397             :             case DataType::SMALLINT:
     398          98 :                 if ( _rRH.m_bSigned )
     399          98 :                     m_aValue.m_nInt16   = _rRH.m_aValue.m_nInt16;
     400             :                 else
     401           0 :                     m_aValue.m_uInt16   = _rRH.m_aValue.m_uInt16;
     402          98 :                 break;
     403             :             case DataType::INTEGER:
     404         741 :                 if ( _rRH.m_bSigned )
     405         741 :                     m_aValue.m_nInt32   = _rRH.m_aValue.m_nInt32;
     406             :                 else
     407           0 :                     m_aValue.m_uInt32   = _rRH.m_aValue.m_uInt32;
     408         741 :                 break;
     409             :             case DataType::BIGINT:
     410           0 :                 if ( _rRH.m_bSigned )
     411           0 :                     m_aValue.m_nInt64   = _rRH.m_aValue.m_nInt64;
     412             :                 else
     413           0 :                     m_aValue.m_uInt64   = _rRH.m_aValue.m_uInt64;
     414           0 :                 break;
     415             :             case DataType::FLOAT:
     416           0 :                 m_aValue.m_nFloat  = _rRH.m_aValue.m_nFloat;
     417           0 :                 break;
     418             :             case DataType::DOUBLE:
     419             :             case DataType::REAL:
     420           0 :                 m_aValue.m_nDouble  = _rRH.m_aValue.m_nDouble;
     421           0 :                 break;
     422             :             default:
     423         920 :                 m_aValue.m_pValue   = new Any(*(Any*)_rRH.m_aValue.m_pValue);
     424             :                 TRACE_ALLOC( Any )
     425             :         }
     426             :     }
     427       10933 :     else if(!_rRH.m_bNull)
     428             :     {
     429        7873 :         switch(_rRH.m_eTypeKind)
     430             :         {
     431             :             case DataType::CHAR:
     432             :             case DataType::VARCHAR:
     433             :             case DataType::DECIMAL:
     434             :             case DataType::NUMERIC:
     435             :             case DataType::LONGVARCHAR:
     436        4589 :                 (*this) = OUString(_rRH.m_aValue.m_pString);
     437        4589 :                 break;
     438             :             case DataType::DATE:
     439          30 :                 (*this) = *(Date*)_rRH.m_aValue.m_pValue;
     440          30 :                 break;
     441             :             case DataType::TIME:
     442           0 :                 (*this) = *(Time*)_rRH.m_aValue.m_pValue;
     443           0 :                 break;
     444             :             case DataType::TIMESTAMP:
     445           0 :                 (*this) = *(DateTime*)_rRH.m_aValue.m_pValue;
     446           0 :                 break;
     447             :             case DataType::BINARY:
     448             :             case DataType::VARBINARY:
     449             :             case DataType::LONGVARBINARY:
     450           0 :                 (*this) = *(Sequence<sal_Int8>*)_rRH.m_aValue.m_pValue;
     451           0 :                 break;
     452             :             case DataType::BIT:
     453             :             case DataType::BOOLEAN:
     454           0 :                 m_aValue.m_bBool    = _rRH.m_aValue.m_bBool;
     455           0 :                 break;
     456             :             case DataType::TINYINT:
     457           0 :                 if ( _rRH.m_bSigned )
     458           0 :                     m_aValue.m_nInt8    = _rRH.m_aValue.m_nInt8;
     459             :                 else
     460           0 :                     m_aValue.m_uInt8    = _rRH.m_aValue.m_uInt8;
     461           0 :                 break;
     462             :             case DataType::SMALLINT:
     463           0 :                 if ( _rRH.m_bSigned )
     464           0 :                     m_aValue.m_nInt16   = _rRH.m_aValue.m_nInt16;
     465             :                 else
     466           0 :                     m_aValue.m_uInt16   = _rRH.m_aValue.m_uInt16;
     467           0 :                 break;
     468             :             case DataType::INTEGER:
     469        3254 :                 if ( _rRH.m_bSigned )
     470        3254 :                     m_aValue.m_nInt32   = _rRH.m_aValue.m_nInt32;
     471             :                 else
     472           0 :                     m_aValue.m_uInt32   = _rRH.m_aValue.m_uInt32;
     473        3254 :                 break;
     474             :             case DataType::BIGINT:
     475           0 :                 if ( _rRH.m_bSigned )
     476           0 :                     m_aValue.m_nInt64   = _rRH.m_aValue.m_nInt64;
     477             :                 else
     478           0 :                     m_aValue.m_uInt64   = _rRH.m_aValue.m_uInt64;
     479           0 :                 break;
     480             :             case DataType::FLOAT:
     481           0 :                 m_aValue.m_nFloat  = _rRH.m_aValue.m_nFloat;
     482           0 :                 break;
     483             :             case DataType::DOUBLE:
     484             :             case DataType::REAL:
     485           0 :                 m_aValue.m_nDouble  = _rRH.m_aValue.m_nDouble;
     486           0 :                 break;
     487             :             default:
     488           0 :                 (*(Any*)m_aValue.m_pValue)  = (*(Any*)_rRH.m_aValue.m_pValue);
     489             :         }
     490             :     }
     491             : 
     492       15627 :     m_bNull     = _rRH.m_bNull;
     493             :     // OJ: BUGID: 96277
     494       15627 :     m_eTypeKind = _rRH.m_eTypeKind;
     495             : 
     496       15627 :     return *this;
     497             : }
     498             : 
     499             : 
     500         140 : ORowSetValue& ORowSetValue::operator=(const Date& _rRH)
     501             : {
     502         140 :     if(m_eTypeKind != DataType::DATE)
     503          52 :         free();
     504             : 
     505         140 :     if(m_bNull)
     506             :     {
     507         110 :         m_aValue.m_pValue = new Date(_rRH);
     508             :         TRACE_ALLOC( Date )
     509         110 :         m_eTypeKind = DataType::DATE;
     510         110 :         m_bNull = false;
     511             :     }
     512             :     else
     513          30 :         *(Date*)m_aValue.m_pValue = _rRH;
     514             : 
     515         140 :     return *this;
     516             : }
     517             : 
     518           0 : ORowSetValue& ORowSetValue::operator=(const Time& _rRH)
     519             : {
     520           0 :     if(m_eTypeKind != DataType::TIME)
     521           0 :         free();
     522             : 
     523           0 :     if(m_bNull)
     524             :     {
     525           0 :         m_aValue.m_pValue = new Time(_rRH);
     526             :         TRACE_ALLOC( Time )
     527           0 :         m_eTypeKind = DataType::TIME;
     528           0 :         m_bNull = false;
     529             :     }
     530             :     else
     531           0 :         *(Time*)m_aValue.m_pValue = _rRH;
     532             : 
     533           0 :     return *this;
     534             : }
     535             : 
     536           0 : ORowSetValue& ORowSetValue::operator=(const DateTime& _rRH)
     537             : {
     538           0 :     if(m_eTypeKind != DataType::TIMESTAMP)
     539           0 :         free();
     540           0 :     if(m_bNull)
     541             :     {
     542           0 :         m_aValue.m_pValue = new DateTime(_rRH);
     543             :         TRACE_ALLOC( DateTime )
     544           0 :         m_eTypeKind = DataType::TIMESTAMP;
     545           0 :         m_bNull = false;
     546             :     }
     547             :     else
     548           0 :         *(DateTime*)m_aValue.m_pValue = _rRH;
     549             : 
     550           0 :     return *this;
     551             : }
     552             : 
     553             : 
     554       22546 : ORowSetValue& ORowSetValue::operator=(const OUString& _rRH)
     555             : {
     556       22546 :     if(m_eTypeKind != DataType::VARCHAR || m_aValue.m_pString != _rRH.pData)
     557             :     {
     558       21230 :         free();
     559       21230 :         m_bNull = false;
     560             : 
     561       21230 :         m_aValue.m_pString = _rRH.pData;
     562       21230 :         rtl_uString_acquire(m_aValue.m_pString);
     563       21230 :         m_eTypeKind = DataType::VARCHAR;
     564             :     }
     565             : 
     566       22546 :     return *this;
     567             : }
     568             : 
     569             : 
     570          64 : ORowSetValue& ORowSetValue::operator=(const double& _rRH)
     571             : {
     572          64 :     if(m_eTypeKind != DataType::DOUBLE)
     573          63 :         free();
     574             : 
     575          64 :     m_aValue.m_nDouble = _rRH;
     576          64 :     m_eTypeKind = DataType::DOUBLE;
     577          64 :     m_bNull = false;
     578             : 
     579          64 :     return *this;
     580             : }
     581             : 
     582           2 : ORowSetValue& ORowSetValue::operator=(const float& _rRH)
     583             : {
     584           2 :     if(m_eTypeKind != DataType::FLOAT)
     585           1 :         free();
     586             : 
     587           2 :     m_aValue.m_nFloat = _rRH;
     588           2 :     m_eTypeKind = DataType::FLOAT;
     589           2 :     m_bNull = false;
     590             : 
     591           2 :     return *this;
     592             : }
     593             : 
     594             : 
     595           2 : ORowSetValue& ORowSetValue::operator=(const sal_Int8& _rRH)
     596             : {
     597           2 :     if(m_eTypeKind != DataType::TINYINT )
     598           1 :         free();
     599             : 
     600           2 :     m_aValue.m_nInt8 = _rRH;
     601           2 :     m_eTypeKind = DataType::TINYINT;
     602           2 :     m_bNull = false;
     603           2 :     m_bSigned = true;
     604           2 :     return *this;
     605             : }
     606             : 
     607             : 
     608          15 : ORowSetValue& ORowSetValue::operator=(const sal_uInt8& _rRH)
     609             : {
     610          15 :     if(m_eTypeKind != DataType::TINYINT )
     611           0 :         free();
     612             : 
     613          15 :     m_aValue.m_uInt8 = _rRH;
     614          15 :     m_eTypeKind = DataType::TINYINT;
     615          15 :     m_bNull = false;
     616          15 :     m_bSigned = false;
     617          15 :     return *this;
     618             : }
     619             : 
     620             : 
     621         100 : ORowSetValue& ORowSetValue::operator=(const sal_Int16& _rRH)
     622             : {
     623         100 :     if(m_eTypeKind != DataType::SMALLINT )
     624           1 :         free();
     625             : 
     626         100 :     m_aValue.m_nInt16 = _rRH;
     627         100 :     m_eTypeKind = DataType::SMALLINT;
     628         100 :     m_bNull = false;
     629         100 :     m_bSigned = true;
     630             : 
     631         100 :     return *this;
     632             : }
     633             : 
     634             : 
     635           3 : ORowSetValue& ORowSetValue::operator=(const sal_uInt16& _rRH)
     636             : {
     637           3 :     if(m_eTypeKind != DataType::SMALLINT )
     638           2 :         free();
     639             : 
     640           3 :     m_aValue.m_uInt16 = _rRH;
     641           3 :     m_eTypeKind = DataType::SMALLINT;
     642           3 :     m_bNull = false;
     643           3 :     m_bSigned = false;
     644             : 
     645           3 :     return *this;
     646             : }
     647             : 
     648             : 
     649        3914 : ORowSetValue& ORowSetValue::operator=(const sal_Int32& _rRH)
     650             : {
     651        3914 :     if(m_eTypeKind != DataType::INTEGER )
     652          93 :         free();
     653             : 
     654        3914 :     m_aValue.m_nInt32 = _rRH;
     655             : 
     656        3914 :     m_eTypeKind = DataType::INTEGER;
     657        3914 :     m_bNull = false;
     658        3914 :     m_bSigned = true;
     659             : 
     660        3914 :     return *this;
     661             : }
     662             : 
     663             : 
     664           1 : ORowSetValue& ORowSetValue::operator=(const sal_uInt32& _rRH)
     665             : {
     666           1 :     if(m_eTypeKind != DataType::INTEGER )
     667           0 :         free();
     668             : 
     669           1 :     m_aValue.m_uInt32 = _rRH;
     670             : 
     671           1 :     m_eTypeKind = DataType::INTEGER;
     672           1 :     m_bNull = false;
     673           1 :     m_bSigned = false;
     674             : 
     675           1 :     return *this;
     676             : }
     677             : 
     678             : 
     679          84 : ORowSetValue& ORowSetValue::operator=(const bool _rRH)
     680             : {
     681          84 :     if(m_eTypeKind != DataType::BIT && DataType::BOOLEAN != m_eTypeKind )
     682          73 :         free();
     683             : 
     684          84 :     m_aValue.m_bBool = _rRH;
     685          84 :     m_eTypeKind = DataType::BOOLEAN;
     686          84 :     m_bNull = false;
     687             : 
     688          84 :     return *this;
     689             : }
     690             : 
     691           3 : ORowSetValue& ORowSetValue::operator=(const sal_Int64& _rRH)
     692             : {
     693           3 :     if ( DataType::BIGINT != m_eTypeKind)
     694           2 :         free();
     695             : 
     696           3 :     m_aValue.m_nInt64 = _rRH;
     697           3 :     m_eTypeKind = DataType::BIGINT;
     698           3 :     m_bNull = false;
     699           3 :     m_bSigned = true;
     700             : 
     701           3 :     return *this;
     702             : }
     703             : 
     704           2 : ORowSetValue& ORowSetValue::operator=(const sal_uInt64& _rRH)
     705             : {
     706           2 :     if ( DataType::BIGINT != m_eTypeKind)
     707           1 :         free();
     708             : 
     709           2 :     m_aValue.m_uInt64 = _rRH;
     710           2 :     m_eTypeKind = DataType::BIGINT;
     711           2 :     m_bNull = false;
     712           2 :     m_bSigned = false;
     713             : 
     714           2 :     return *this;
     715             : }
     716             : 
     717           0 : ORowSetValue& ORowSetValue::operator=(const Sequence<sal_Int8>& _rRH)
     718             : {
     719           0 :     if (!isStorageCompatible(DataType::LONGVARBINARY,m_eTypeKind))
     720           0 :         free();
     721             : 
     722           0 :     if (m_bNull)
     723             :     {
     724           0 :         m_aValue.m_pValue = new Sequence<sal_Int8>(_rRH);
     725             :         TRACE_ALLOC( Sequence_sal_Int8 )
     726             :     }
     727             :     else
     728           0 :         *static_cast< Sequence< sal_Int8 >* >(m_aValue.m_pValue) = _rRH;
     729             : 
     730           0 :     m_eTypeKind = DataType::LONGVARBINARY;
     731           0 :     m_bNull = false;
     732             : 
     733           0 :     return *this;
     734             : }
     735             : 
     736         258 : ORowSetValue& ORowSetValue::operator=(const Any& _rAny)
     737             : {
     738         258 :     if (!isStorageCompatible(DataType::OBJECT,m_eTypeKind))
     739         225 :         free();
     740             : 
     741         258 :     if ( m_bNull )
     742             :     {
     743         225 :         m_aValue.m_pValue = new Any(_rAny);
     744             :         TRACE_ALLOC( Any )
     745             :     }
     746             :     else
     747          33 :         *static_cast<Any*>(m_aValue.m_pValue) = _rAny;
     748             : 
     749         258 :     m_eTypeKind = DataType::OBJECT;
     750         258 :     m_bNull = false;
     751             : 
     752         258 :     return *this;
     753             : }
     754             : 
     755             : 
     756          10 : bool operator==(const Date& _rLH,const Date& _rRH)
     757             : {
     758          10 :     return _rLH.Day == _rRH.Day && _rLH.Month == _rRH.Month && _rLH.Year == _rRH.Year;
     759             : }
     760             : 
     761             : 
     762           0 : bool operator==(const Time& _rLH,const Time& _rRH)
     763             : {
     764           0 :     return _rLH.Minutes == _rRH.Minutes && _rLH.Hours == _rRH.Hours && _rLH.Seconds == _rRH.Seconds && _rLH.NanoSeconds == _rRH.NanoSeconds;
     765             : }
     766             : 
     767             : 
     768           0 : bool operator==(const DateTime& _rLH,const DateTime& _rRH)
     769             : {
     770           0 :     return _rLH.Day == _rRH.Day && _rLH.Month == _rRH.Month && _rLH.Year == _rRH.Year &&
     771           0 :         _rLH.Minutes == _rRH.Minutes && _rLH.Hours == _rRH.Hours && _rLH.Seconds == _rRH.Seconds && _rLH.NanoSeconds == _rRH.NanoSeconds;
     772             : }
     773             : 
     774             : 
     775        1770 : bool ORowSetValue::operator==(const ORowSetValue& _rRH) const
     776             : {
     777        1770 :     if ( m_bNull != _rRH.isNull() )
     778         230 :         return false;
     779             : 
     780        1540 :     if(m_bNull && _rRH.isNull())
     781        1009 :         return true;
     782             : 
     783         531 :     if ( m_eTypeKind != _rRH.m_eTypeKind )
     784             :     {
     785           6 :         switch(m_eTypeKind)
     786             :         {
     787             :             case DataType::FLOAT:
     788             :             case DataType::DOUBLE:
     789             :             case DataType::REAL:
     790           0 :                 return getDouble() == _rRH.getDouble();
     791             :             default:
     792           6 :                 switch(_rRH.m_eTypeKind)
     793             :                 {
     794             :                     case DataType::FLOAT:
     795             :                     case DataType::DOUBLE:
     796             :                     case DataType::REAL:
     797           0 :                             return getDouble() == _rRH.getDouble();
     798             :                     default:
     799           6 :                             break;
     800             :                 }
     801           6 :                 break;
     802             :             }
     803           6 :         return false;
     804             :     }
     805             : 
     806         525 :     bool bRet = false;
     807             :     OSL_ENSURE(!m_bNull,"SHould not be null!");
     808         525 :     switch(m_eTypeKind)
     809             :     {
     810             :         case DataType::VARCHAR:
     811             :         case DataType::CHAR:
     812             :         case DataType::LONGVARCHAR:
     813             :         {
     814         373 :             OUString aVal1(m_aValue.m_pString);
     815         746 :             OUString aVal2(_rRH.m_aValue.m_pString);
     816         746 :             return aVal1 == aVal2;
     817             :         }
     818             :         default:
     819         152 :             if ( m_bSigned != _rRH.m_bSigned )
     820           0 :                 return false;
     821         152 :             break;
     822             :     }
     823             : 
     824         152 :     switch(m_eTypeKind)
     825             :     {
     826             :         case DataType::DECIMAL:
     827             :         case DataType::NUMERIC:
     828             :             {
     829          20 :                 OUString aVal1(m_aValue.m_pString);
     830          40 :                 OUString aVal2(_rRH.m_aValue.m_pString);
     831          40 :                 bRet = aVal1 == aVal2;
     832             :             }
     833          20 :             break;
     834             :         case DataType::FLOAT:
     835           0 :             bRet = m_aValue.m_nFloat == _rRH.m_aValue.m_nFloat;
     836           0 :             break;
     837             :         case DataType::DOUBLE:
     838             :         case DataType::REAL:
     839           0 :             bRet = m_aValue.m_nDouble == _rRH.m_aValue.m_nDouble;
     840           0 :             break;
     841             :         case DataType::TINYINT:
     842           0 :             bRet = m_bSigned ? ( m_aValue.m_nInt8 == _rRH.m_aValue.m_nInt8 ) : (m_aValue.m_uInt8 == _rRH.m_aValue.m_uInt8);
     843           0 :             break;
     844             :         case DataType::SMALLINT:
     845           0 :             bRet = m_bSigned ? ( m_aValue.m_nInt16 == _rRH.m_aValue.m_nInt16 ) : (m_aValue.m_uInt16 == _rRH.m_aValue.m_uInt16);
     846           0 :             break;
     847             :         case DataType::INTEGER:
     848           0 :             bRet = m_bSigned ? ( m_aValue.m_nInt32 == _rRH.m_aValue.m_nInt32 ) : (m_aValue.m_uInt32 == _rRH.m_aValue.m_uInt32);
     849           0 :             break;
     850             :         case DataType::BIGINT:
     851           0 :             bRet = m_bSigned ? ( m_aValue.m_nInt64 == _rRH.m_aValue.m_nInt64 ) : (m_aValue.m_uInt64 == _rRH.m_aValue.m_uInt64);
     852           0 :             break;
     853             :         case DataType::BIT:
     854             :         case DataType::BOOLEAN:
     855           6 :             bRet = m_aValue.m_bBool == _rRH.m_aValue.m_bBool;
     856           6 :             break;
     857             :         case DataType::DATE:
     858          10 :             bRet = *(Date*)m_aValue.m_pValue == *(Date*)_rRH.m_aValue.m_pValue;
     859          10 :             break;
     860             :         case DataType::TIME:
     861           0 :             bRet = *(Time*)m_aValue.m_pValue == *(Time*)_rRH.m_aValue.m_pValue;
     862           0 :             break;
     863             :         case DataType::TIMESTAMP:
     864           0 :             bRet = *(DateTime*)m_aValue.m_pValue == *(DateTime*)_rRH.m_aValue.m_pValue;
     865           0 :             break;
     866             :         case DataType::BINARY:
     867             :         case DataType::VARBINARY:
     868             :         case DataType::LONGVARBINARY:
     869           0 :             bRet = false;
     870           0 :             break;
     871             :         case DataType::BLOB:
     872             :         case DataType::CLOB:
     873             :         case DataType::OBJECT:
     874             :         case DataType::OTHER:
     875         116 :             bRet = false;
     876         116 :             break;
     877             :         default:
     878           0 :             bRet = false;
     879             :             SAL_WARN( "connectivity.commontools","ORowSetValue::operator==(): UNSUPPORTED TYPE!");
     880           0 :             break;
     881             :     }
     882         152 :     return bRet;
     883             : }
     884             : 
     885        1163 : Any ORowSetValue::makeAny() const
     886             : {
     887             :     SAL_INFO( "connectivity.commontools", "dbtools Ocke.Janssen@sun.com ORowSetValue::makeAny" );
     888        1163 :     Any rValue;
     889        1163 :     if(isBound() && !isNull())
     890             :     {
     891         935 :         switch(getTypeKind())
     892             :         {
     893             :             case DataType::CHAR:
     894             :             case DataType::VARCHAR:
     895             :             case DataType::DECIMAL:
     896             :             case DataType::NUMERIC:
     897             :             case DataType::LONGVARCHAR:
     898             :                 OSL_ENSURE(m_aValue.m_pString,"Value is null!");
     899         855 :                 rValue <<= (OUString)m_aValue.m_pString;
     900         855 :                 break;
     901             :             case DataType::FLOAT:
     902           1 :                 rValue <<= m_aValue.m_nFloat;
     903           1 :                 break;
     904             :             case DataType::DOUBLE:
     905             :             case DataType::REAL:
     906           1 :                 rValue <<= m_aValue.m_nDouble;
     907           1 :                 break;
     908             :             case DataType::DATE:
     909             :                 OSL_ENSURE(m_aValue.m_pValue,"Value is null!");
     910          29 :                 rValue <<= *(Date*)m_aValue.m_pValue;
     911          29 :                 break;
     912             :             case DataType::TIME:
     913             :                 OSL_ENSURE(m_aValue.m_pValue,"Value is null!");
     914           0 :                 rValue <<= *(Time*)m_aValue.m_pValue;
     915           0 :                 break;
     916             :             case DataType::TIMESTAMP:
     917             :                 OSL_ENSURE(m_aValue.m_pValue,"Value is null!");
     918           0 :                 rValue <<= *(DateTime*)m_aValue.m_pValue;
     919           0 :                 break;
     920             :             case DataType::BINARY:
     921             :             case DataType::VARBINARY:
     922             :             case DataType::LONGVARBINARY:
     923             :                 OSL_ENSURE(m_aValue.m_pValue,"Value is null!");
     924           0 :                 rValue <<= *(Sequence<sal_Int8>*)m_aValue.m_pValue;
     925           0 :                 break;
     926             :             case DataType::BLOB:
     927             :             case DataType::CLOB:
     928             :             case DataType::OBJECT:
     929             :             case DataType::OTHER:
     930          40 :                 rValue = getAny();
     931          40 :                 break;
     932             :             case DataType::BIT:
     933             :             case DataType::BOOLEAN:
     934           1 :                 rValue <<= m_aValue.m_bBool;
     935           1 :                 break;
     936             :             case DataType::TINYINT:
     937           2 :                 if ( m_bSigned )
     938             :                     // TypeClass_BYTE
     939           1 :                     rValue <<= m_aValue.m_nInt8;
     940             :                 else
     941             :                     // There is no TypeClass_UNSIGNED_BYTE,
     942             :                     // so silently promote it to a 16-bit integer,
     943             :                     // that is TypeClass_UNSIGNED_SHORT
     944           1 :                     rValue <<= static_cast<sal_uInt16>(m_aValue.m_uInt8);
     945           2 :                 break;
     946             :             case DataType::SMALLINT:
     947           2 :                 if ( m_bSigned )
     948             :                     // TypeClass_SHORT
     949           1 :                     rValue <<= m_aValue.m_nInt16;
     950             :                 else
     951             :                     // TypeClass_UNSIGNED_SHORT
     952           1 :                     rValue <<= m_aValue.m_uInt16;
     953           2 :                 break;
     954             :             case DataType::INTEGER:
     955           2 :                 if ( m_bSigned )
     956             :                     // TypeClass_LONG
     957           1 :                     rValue <<= m_aValue.m_nInt32;
     958             :                 else
     959             :                     // TypeClass_UNSIGNED_LONG
     960           1 :                     rValue <<= m_aValue.m_uInt32;
     961           2 :                 break;
     962             :             case DataType::BIGINT:
     963           2 :                 if ( m_bSigned )
     964             :                     // TypeClass_HYPER
     965           1 :                     rValue <<= m_aValue.m_nInt64;
     966             :                 else
     967             :                     // TypeClass_UNSIGNED_HYPER
     968           1 :                     rValue <<= m_aValue.m_uInt64;
     969           2 :                 break;
     970             :             default:
     971             :                 SAL_WARN( "connectivity.commontools","ORowSetValue::makeAny(): UNSPUPPORTED TYPE!");
     972           0 :                 rValue = getAny();
     973           0 :                 break;
     974             :         }
     975             :     }
     976        1163 :     return rValue;
     977             : }
     978             : 
     979        2715 : OUString ORowSetValue::getString( ) const
     980             : {
     981             :     SAL_INFO( "connectivity.commontools", "dbtools Ocke.Janssen@sun.com ORowSetValue::getString" );
     982        2715 :     OUString aRet;
     983        2715 :     if(!m_bNull)
     984             :     {
     985        2715 :         switch(getTypeKind())
     986             :         {
     987             :             case DataType::CHAR:
     988             :             case DataType::VARCHAR:
     989             :             case DataType::DECIMAL:
     990             :             case DataType::NUMERIC:
     991             :             case DataType::LONGVARCHAR:
     992        2711 :                 aRet = m_aValue.m_pString;
     993        2711 :                 break;
     994             :             case DataType::FLOAT:
     995           0 :                 aRet = OUString::number(static_cast<float>(*this));
     996           0 :                 break;
     997             :             case DataType::DOUBLE:
     998             :             case DataType::REAL:
     999           0 :                 aRet = OUString::number(static_cast<double>(*this));
    1000           0 :                 break;
    1001             :             case DataType::DATE:
    1002           0 :                 aRet = DBTypeConversion::toDateString(*this);
    1003           0 :                 break;
    1004             :             case DataType::TIME:
    1005           0 :                 aRet = DBTypeConversion::toTimeString(*this);
    1006           0 :                 break;
    1007             :             case DataType::TIMESTAMP:
    1008           0 :                 aRet = DBTypeConversion::toDateTimeString(*this);
    1009           0 :                 break;
    1010             :             case DataType::BINARY:
    1011             :             case DataType::VARBINARY:
    1012             :             case DataType::LONGVARBINARY:
    1013             :                 {
    1014           0 :                     OUStringBuffer sVal("0x");
    1015           0 :                     Sequence<sal_Int8> aSeq(getSequence());
    1016           0 :                     const sal_Int8* pBegin  = aSeq.getConstArray();
    1017           0 :                     const sal_Int8* pEnd    = pBegin + aSeq.getLength();
    1018           0 :                     for(;pBegin != pEnd;++pBegin)
    1019           0 :                         sVal.append((sal_Int32)*pBegin,16);
    1020           0 :                     aRet = sVal.makeStringAndClear();
    1021             :                 }
    1022           0 :                 break;
    1023             :             case DataType::BIT:
    1024           2 :                 aRet = OUString::number(int(static_cast<bool>(*this)));
    1025           2 :                 break;
    1026             :             case DataType::BOOLEAN:
    1027           2 :                 aRet = OUString::boolean(static_cast<bool>(*this));
    1028           2 :                 break;
    1029             :             case DataType::TINYINT:
    1030             :             case DataType::SMALLINT:
    1031             :             case DataType::INTEGER:
    1032           0 :                 if ( m_bSigned )
    1033           0 :                     aRet = OUString::number(static_cast<sal_Int32>(*this));
    1034             :                 else
    1035           0 :                     aRet = OUString::number(static_cast<sal_uInt32>(*this));
    1036           0 :                 break;
    1037             :             case DataType::BIGINT:
    1038           0 :                 if ( m_bSigned )
    1039           0 :                     aRet = OUString::number(static_cast<sal_Int64>(*this));
    1040             :                 else
    1041           0 :                     aRet = OUString::number(static_cast<sal_uInt64>(*this));
    1042           0 :                 break;
    1043             :             case DataType::CLOB:
    1044             :                 {
    1045           0 :                     Any aValue( getAny() );
    1046           0 :                     Reference< XClob > xClob;
    1047           0 :                     if ( aValue >>= xClob )
    1048             :                     {
    1049           0 :                         if ( xClob.is() )
    1050             :                         {
    1051           0 :                             aRet = xClob->getSubString(1,(sal_Int32)xClob->length() );
    1052             :                         }
    1053           0 :                     }
    1054             :                 }
    1055           0 :                 break;
    1056             :             default:
    1057             :                 {
    1058           0 :                     Any aValue = getAny();
    1059           0 :                     aValue >>= aRet;
    1060           0 :                     break;
    1061             :                 }
    1062             :         }
    1063             :     }
    1064        2715 :     return aRet;
    1065             : }
    1066             : 
    1067          14 : bool ORowSetValue::getBool()    const
    1068             : {
    1069             :     SAL_INFO( "connectivity.commontools", "dbtools Ocke.Janssen@sun.com ORowSetValue::getBool" );
    1070          14 :     bool bRet = false;
    1071          14 :     if(!m_bNull)
    1072             :     {
    1073          14 :         switch(getTypeKind())
    1074             :         {
    1075             :             case DataType::CHAR:
    1076             :             case DataType::VARCHAR:
    1077             :             case DataType::LONGVARCHAR:
    1078             :                 {
    1079           6 :                     const OUString sValue(m_aValue.m_pString);
    1080           6 :                     const static OUString s_sTrue("true");
    1081           6 :                     const static OUString s_sFalse("false");
    1082           6 :                     if ( sValue.equalsIgnoreAsciiCase(s_sTrue) || (sValue == "1") )
    1083             :                     {
    1084           3 :                         bRet = true;
    1085           3 :                         break;
    1086             :                     }
    1087           3 :                     else if ( sValue.equalsIgnoreAsciiCase(s_sFalse) || (sValue == "0") )
    1088             :                     {
    1089           3 :                         bRet = false;
    1090           3 :                         break;
    1091           0 :                     }
    1092             :                 }
    1093             :                 // run through
    1094             :             case DataType::DECIMAL:
    1095             :             case DataType::NUMERIC:
    1096             : 
    1097           0 :                 bRet = OUString(m_aValue.m_pString).toInt32() != 0;
    1098           0 :                 break;
    1099             :             case DataType::FLOAT:
    1100           0 :                 bRet = m_aValue.m_nFloat != 0.0;
    1101           0 :                 break;
    1102             :             case DataType::DOUBLE:
    1103             :             case DataType::REAL:
    1104           0 :                 bRet = m_aValue.m_nDouble != 0.0;
    1105           0 :                 break;
    1106             :             case DataType::DATE:
    1107             :             case DataType::TIME:
    1108             :             case DataType::TIMESTAMP:
    1109             :             case DataType::BINARY:
    1110             :             case DataType::VARBINARY:
    1111             :             case DataType::LONGVARBINARY:
    1112             :                 OSL_FAIL("getBool() for this type is not allowed!");
    1113           0 :                 break;
    1114             :             case DataType::BIT:
    1115             :             case DataType::BOOLEAN:
    1116           8 :                 bRet = m_aValue.m_bBool;
    1117           8 :                 break;
    1118             :             case DataType::TINYINT:
    1119           0 :                 bRet = m_bSigned ? (m_aValue.m_nInt8  != 0) : (m_aValue.m_uInt8 != 0);
    1120           0 :                 break;
    1121             :             case DataType::SMALLINT:
    1122           0 :                 bRet = m_bSigned ? (m_aValue.m_nInt16  != 0) : (m_aValue.m_uInt16 != 0);
    1123           0 :                 break;
    1124             :             case DataType::INTEGER:
    1125           0 :                 bRet = m_bSigned ? (m_aValue.m_nInt32 != 0) : (m_aValue.m_uInt32 != 0);
    1126           0 :                 break;
    1127             :             case DataType::BIGINT:
    1128           0 :                 bRet = m_bSigned ? (m_aValue.m_nInt64 != 0) : (m_aValue.m_uInt64 != 0);
    1129           0 :                 break;
    1130             :             default:
    1131             :                 {
    1132           0 :                     Any aValue = getAny();
    1133           0 :                     aValue >>= bRet;
    1134           0 :                     break;
    1135             :                 }
    1136             :         }
    1137             :     }
    1138          14 :     return bRet;
    1139             : }
    1140             : 
    1141             : 
    1142           2 : sal_Int8 ORowSetValue::getInt8()    const
    1143             : {
    1144             :     SAL_INFO( "connectivity.commontools", "dbtools Ocke.Janssen@sun.com ORowSetValue::getInt8" );
    1145             : 
    1146             : 
    1147           2 :     sal_Int8 nRet = 0;
    1148           2 :     if(!m_bNull)
    1149             :     {
    1150           2 :         switch(getTypeKind())
    1151             :         {
    1152             :             case DataType::CHAR:
    1153             :             case DataType::VARCHAR:
    1154             :             case DataType::DECIMAL:
    1155             :             case DataType::NUMERIC:
    1156             :             case DataType::LONGVARCHAR:
    1157           0 :                 nRet = sal_Int8(OUString(m_aValue.m_pString).toInt32());
    1158           0 :                 break;
    1159             :             case DataType::FLOAT:
    1160           0 :                 nRet = sal_Int8(m_aValue.m_nFloat);
    1161           0 :                 break;
    1162             :             case DataType::DOUBLE:
    1163             :             case DataType::REAL:
    1164           0 :                 nRet = sal_Int8(m_aValue.m_nDouble);
    1165           0 :                 break;
    1166             :             case DataType::DATE:
    1167             :             case DataType::TIME:
    1168             :             case DataType::TIMESTAMP:
    1169             :             case DataType::BINARY:
    1170             :             case DataType::VARBINARY:
    1171             :             case DataType::LONGVARBINARY:
    1172             :             case DataType::BLOB:
    1173             :             case DataType::CLOB:
    1174             :                 OSL_FAIL("getInt8() for this type is not allowed!");
    1175           0 :                 break;
    1176             :             case DataType::BIT:
    1177             :             case DataType::BOOLEAN:
    1178           0 :                 nRet = sal_Int8(m_aValue.m_bBool);
    1179           0 :                 break;
    1180             :             case DataType::TINYINT:
    1181           2 :                 if ( m_bSigned )
    1182           2 :                     nRet = m_aValue.m_nInt8;
    1183             :                 else
    1184           0 :                     nRet = static_cast<sal_Int8>(m_aValue.m_uInt8);
    1185           2 :                 break;
    1186             :             case DataType::SMALLINT:
    1187           0 :                 if ( m_bSigned )
    1188           0 :                     nRet = static_cast<sal_Int8>(m_aValue.m_nInt16);
    1189             :                 else
    1190           0 :                     nRet = static_cast<sal_Int8>(m_aValue.m_uInt16);
    1191           0 :                 break;
    1192             :             case DataType::INTEGER:
    1193           0 :                 if ( m_bSigned )
    1194           0 :                     nRet = static_cast<sal_Int8>(m_aValue.m_nInt32);
    1195             :                 else
    1196           0 :                     nRet = static_cast<sal_Int8>(m_aValue.m_uInt32);
    1197           0 :                 break;
    1198             :             case DataType::BIGINT:
    1199           0 :                 if ( m_bSigned )
    1200           0 :                     nRet = static_cast<sal_Int8>(m_aValue.m_nInt64);
    1201             :                 else
    1202           0 :                     nRet = static_cast<sal_Int8>(m_aValue.m_uInt64);
    1203           0 :                 break;
    1204             :             default:
    1205             :                 {
    1206           0 :                     Any aValue = getAny();
    1207           0 :                     aValue >>= nRet;
    1208           0 :                     break;
    1209             :                 }
    1210             :         }
    1211             :     }
    1212           2 :     return nRet;
    1213             : }
    1214             : 
    1215             : 
    1216         152 : sal_uInt8 ORowSetValue::getUInt8()    const
    1217             : {
    1218         152 :     sal_uInt8 nRet = 0;
    1219         152 :     if(!m_bNull)
    1220             :     {
    1221         152 :         switch(getTypeKind())
    1222             :         {
    1223             :             case DataType::CHAR:
    1224             :             case DataType::VARCHAR:
    1225             :             case DataType::DECIMAL:
    1226             :             case DataType::NUMERIC:
    1227             :             case DataType::LONGVARCHAR:
    1228           0 :                 nRet = sal_uInt8(OUString(m_aValue.m_pString).toInt32());
    1229           0 :                 break;
    1230             :             case DataType::FLOAT:
    1231           0 :                 nRet = sal_uInt8(m_aValue.m_nFloat);
    1232           0 :                 break;
    1233             :             case DataType::DOUBLE:
    1234             :             case DataType::REAL:
    1235           0 :                 nRet = sal_uInt8(m_aValue.m_nDouble);
    1236           0 :                 break;
    1237             :             case DataType::DATE:
    1238             :             case DataType::TIME:
    1239             :             case DataType::TIMESTAMP:
    1240             :             case DataType::BINARY:
    1241             :             case DataType::VARBINARY:
    1242             :             case DataType::LONGVARBINARY:
    1243             :             case DataType::BLOB:
    1244             :             case DataType::CLOB:
    1245             :                 OSL_FAIL("getuInt8() for this type is not allowed!");
    1246           0 :                 break;
    1247             :             case DataType::BIT:
    1248             :             case DataType::BOOLEAN:
    1249           0 :                 nRet = m_aValue.m_bBool;
    1250           0 :                 break;
    1251             :             case DataType::TINYINT:
    1252         116 :                 if ( m_bSigned )
    1253           0 :                     nRet = m_aValue.m_nInt8;
    1254             :                 else
    1255         116 :                     nRet = m_aValue.m_uInt8;
    1256         116 :                 break;
    1257             :             case DataType::SMALLINT:
    1258           1 :                 if ( m_bSigned )
    1259           0 :                     nRet = static_cast<sal_uInt8>(m_aValue.m_nInt16);
    1260             :                 else
    1261           1 :                     nRet = static_cast<sal_uInt8>(m_aValue.m_uInt16);
    1262           1 :                 break;
    1263             :             case DataType::INTEGER:
    1264          35 :                 if ( m_bSigned )
    1265          35 :                     nRet = static_cast<sal_uInt8>(m_aValue.m_nInt32);
    1266             :                 else
    1267           0 :                     nRet = static_cast<sal_uInt8>(m_aValue.m_uInt32);
    1268          35 :                 break;
    1269             :             case DataType::BIGINT:
    1270           0 :                 if ( m_bSigned )
    1271           0 :                     nRet = static_cast<sal_uInt8>(m_aValue.m_nInt64);
    1272             :                 else
    1273           0 :                     nRet = static_cast<sal_uInt8>(m_aValue.m_uInt64);
    1274           0 :                 break;
    1275             :             default:
    1276             :                 {
    1277           0 :                     Any aValue = getAny();
    1278           0 :                     aValue >>= nRet;
    1279           0 :                     break;
    1280             :                 }
    1281             :         }
    1282             :     }
    1283         152 :     return nRet;
    1284             : }
    1285             : 
    1286             : 
    1287             : 
    1288          90 : sal_Int16 ORowSetValue::getInt16()  const
    1289             : {
    1290             :     SAL_INFO( "connectivity.commontools", "dbtools Ocke.Janssen@sun.com ORowSetValue::getInt16" );
    1291             : 
    1292             : 
    1293          90 :     sal_Int16 nRet = 0;
    1294          90 :     if(!m_bNull)
    1295             :     {
    1296          90 :         switch(getTypeKind())
    1297             :         {
    1298             :             case DataType::CHAR:
    1299             :             case DataType::VARCHAR:
    1300             :             case DataType::DECIMAL:
    1301             :             case DataType::NUMERIC:
    1302             :             case DataType::LONGVARCHAR:
    1303           0 :                 nRet = sal_Int16(OUString(m_aValue.m_pString).toInt32());
    1304           0 :                 break;
    1305             :             case DataType::FLOAT:
    1306           0 :                 nRet = sal_Int16(m_aValue.m_nFloat);
    1307           0 :                 break;
    1308             :             case DataType::DOUBLE:
    1309             :             case DataType::REAL:
    1310           0 :                 nRet = sal_Int16(m_aValue.m_nDouble);
    1311           0 :                 break;
    1312             :             case DataType::DATE:
    1313             :             case DataType::TIME:
    1314             :             case DataType::TIMESTAMP:
    1315             :             case DataType::BINARY:
    1316             :             case DataType::VARBINARY:
    1317             :             case DataType::LONGVARBINARY:
    1318             :             case DataType::BLOB:
    1319             :             case DataType::CLOB:
    1320             :                 OSL_FAIL("getInt16() for this type is not allowed!");
    1321           0 :                 break;
    1322             :             case DataType::BIT:
    1323             :             case DataType::BOOLEAN:
    1324           0 :                 nRet = sal_Int16(m_aValue.m_bBool);
    1325           0 :                 break;
    1326             :             case DataType::TINYINT:
    1327           0 :                 if ( m_bSigned )
    1328           0 :                     nRet = m_aValue.m_nInt8;
    1329             :                 else
    1330           0 :                     nRet = m_aValue.m_uInt8;
    1331           0 :                 break;
    1332             :             case DataType::SMALLINT:
    1333          32 :                 if ( m_bSigned )
    1334          32 :                     nRet = m_aValue.m_nInt16;
    1335             :                 else
    1336           0 :                     nRet = static_cast<sal_Int16>(m_aValue.m_uInt16);
    1337          32 :                 break;
    1338             :             case DataType::INTEGER:
    1339          58 :                 if ( m_bSigned )
    1340          58 :                     nRet = static_cast<sal_Int16>(m_aValue.m_nInt32);
    1341             :                 else
    1342           0 :                     nRet = static_cast<sal_Int16>(m_aValue.m_uInt32);
    1343          58 :                 break;
    1344             :             case DataType::BIGINT:
    1345           0 :                 if ( m_bSigned )
    1346           0 :                     nRet = static_cast<sal_Int16>(m_aValue.m_nInt64);
    1347             :                 else
    1348           0 :                     nRet = static_cast<sal_Int16>(m_aValue.m_uInt64);
    1349           0 :                 break;
    1350             :             default:
    1351             :                 {
    1352           0 :                     Any aValue = getAny();
    1353           0 :                     aValue >>= nRet;
    1354           0 :                     break;
    1355             :                 }
    1356             :         }
    1357             :     }
    1358          90 :     return nRet;
    1359             : }
    1360             : 
    1361             : 
    1362           2 : sal_uInt16 ORowSetValue::getUInt16()  const
    1363             : {
    1364           2 :     sal_uInt16 nRet = 0;
    1365           2 :     if(!m_bNull)
    1366             :     {
    1367           2 :         switch(getTypeKind())
    1368             :         {
    1369             :             case DataType::CHAR:
    1370             :             case DataType::VARCHAR:
    1371             :             case DataType::DECIMAL:
    1372             :             case DataType::NUMERIC:
    1373             :             case DataType::LONGVARCHAR:
    1374           0 :                 nRet = sal_uInt16(OUString(m_aValue.m_pString).toInt32());
    1375           0 :                 break;
    1376             :             case DataType::FLOAT:
    1377           0 :                 nRet = sal_uInt16(m_aValue.m_nFloat);
    1378           0 :                 break;
    1379             :             case DataType::DOUBLE:
    1380             :             case DataType::REAL:
    1381           0 :                 nRet = sal_uInt16(m_aValue.m_nDouble);
    1382           0 :                 break;
    1383             :             case DataType::DATE:
    1384             :             case DataType::TIME:
    1385             :             case DataType::TIMESTAMP:
    1386             :             case DataType::BINARY:
    1387             :             case DataType::VARBINARY:
    1388             :             case DataType::LONGVARBINARY:
    1389             :             case DataType::BLOB:
    1390             :             case DataType::CLOB:
    1391             :                 OSL_FAIL("getuInt16() for this type is not allowed!");
    1392           0 :                 break;
    1393             :             case DataType::BIT:
    1394             :             case DataType::BOOLEAN:
    1395           0 :                 nRet = sal_uInt16(m_aValue.m_bBool);
    1396           0 :                 break;
    1397             :             case DataType::TINYINT:
    1398           0 :                 if ( m_bSigned )
    1399           0 :                     nRet = m_aValue.m_nInt8;
    1400             :                 else
    1401           0 :                     nRet = m_aValue.m_uInt8;
    1402           0 :                 break;
    1403             :             case DataType::SMALLINT:
    1404           2 :                 if ( m_bSigned )
    1405           0 :                     nRet = m_aValue.m_nInt16;
    1406             :                 else
    1407           2 :                     nRet = m_aValue.m_uInt16;
    1408           2 :                 break;
    1409             :             case DataType::INTEGER:
    1410           0 :                 if ( m_bSigned )
    1411           0 :                     nRet = static_cast<sal_uInt16>(m_aValue.m_nInt32);
    1412             :                 else
    1413           0 :                     nRet = static_cast<sal_uInt16>(m_aValue.m_uInt32);
    1414           0 :                 break;
    1415             :             case DataType::BIGINT:
    1416           0 :                 if ( m_bSigned )
    1417           0 :                     nRet = static_cast<sal_uInt16>(m_aValue.m_nInt64);
    1418             :                 else
    1419           0 :                     nRet = static_cast<sal_uInt16>(m_aValue.m_uInt64);
    1420           0 :                 break;
    1421             :             default:
    1422             :                 {
    1423           0 :                     Any aValue = getAny();
    1424           0 :                     aValue >>= nRet;
    1425           0 :                     break;
    1426             :                 }
    1427             :         }
    1428             :     }
    1429           2 :     return nRet;
    1430             : }
    1431             : 
    1432             : 
    1433        1402 : sal_Int32 ORowSetValue::getInt32()  const
    1434             : {
    1435             :     SAL_INFO( "connectivity.commontools", "dbtools Ocke.Janssen@sun.com ORowSetValue::getInt32" );
    1436        1402 :     sal_Int32 nRet = 0;
    1437        1402 :     if(!m_bNull)
    1438             :     {
    1439        1402 :         switch(getTypeKind())
    1440             :         {
    1441             :             case DataType::CHAR:
    1442             :             case DataType::VARCHAR:
    1443             :             case DataType::DECIMAL:
    1444             :             case DataType::NUMERIC:
    1445             :             case DataType::LONGVARCHAR:
    1446           0 :                 nRet = OUString(m_aValue.m_pString).toInt32();
    1447           0 :                 break;
    1448             :             case DataType::FLOAT:
    1449           0 :                 nRet = sal_Int32(m_aValue.m_nFloat);
    1450           0 :                 break;
    1451             :             case DataType::DOUBLE:
    1452             :             case DataType::REAL:
    1453           0 :                 nRet = sal_Int32(m_aValue.m_nDouble);
    1454           0 :                 break;
    1455             :             case DataType::DATE:
    1456           0 :                 nRet = dbtools::DBTypeConversion::toDays(*(::com::sun::star::util::Date*)m_aValue.m_pValue);
    1457           0 :                 break;
    1458             :             case DataType::TIME:
    1459             :             case DataType::TIMESTAMP:
    1460             :             case DataType::BINARY:
    1461             :             case DataType::VARBINARY:
    1462             :             case DataType::LONGVARBINARY:
    1463             :             case DataType::BLOB:
    1464             :             case DataType::CLOB:
    1465             :                 OSL_FAIL("getInt32() for this type is not allowed!");
    1466           0 :                 break;
    1467             :             case DataType::BIT:
    1468             :             case DataType::BOOLEAN:
    1469           0 :                 nRet = sal_Int32(m_aValue.m_bBool);
    1470           0 :                 break;
    1471             :             case DataType::TINYINT:
    1472           0 :                 if ( m_bSigned )
    1473           0 :                     nRet = m_aValue.m_nInt8;
    1474             :                 else
    1475           0 :                     nRet = m_aValue.m_uInt8;
    1476           0 :                 break;
    1477             :             case DataType::SMALLINT:
    1478         184 :                 if ( m_bSigned )
    1479         184 :                     nRet = m_aValue.m_nInt16;
    1480             :                 else
    1481           0 :                     nRet = m_aValue.m_uInt16;
    1482         184 :                 break;
    1483             :             case DataType::INTEGER:
    1484        1218 :                 if ( m_bSigned )
    1485        1218 :                     nRet = m_aValue.m_nInt32;
    1486             :                 else
    1487           0 :                     nRet = static_cast<sal_Int32>(m_aValue.m_uInt32);
    1488        1218 :                 break;
    1489             :             case DataType::BIGINT:
    1490           0 :                 if ( m_bSigned )
    1491           0 :                     nRet = static_cast<sal_Int32>(m_aValue.m_nInt64);
    1492             :                 else
    1493           0 :                     nRet = static_cast<sal_Int32>(m_aValue.m_uInt64);
    1494           0 :                 break;
    1495             :             default:
    1496             :                 {
    1497           0 :                     Any aValue = getAny();
    1498           0 :                     aValue >>= nRet;
    1499           0 :                     break;
    1500             :                 }
    1501             :         }
    1502             :     }
    1503        1402 :     return nRet;
    1504             : }
    1505             : 
    1506             : 
    1507           2 : sal_uInt32 ORowSetValue::getUInt32()  const
    1508             : {
    1509           2 :     sal_uInt32 nRet = 0;
    1510           2 :     if(!m_bNull)
    1511             :     {
    1512           2 :         switch(getTypeKind())
    1513             :         {
    1514             :             case DataType::CHAR:
    1515             :             case DataType::VARCHAR:
    1516             :             case DataType::DECIMAL:
    1517             :             case DataType::NUMERIC:
    1518             :             case DataType::LONGVARCHAR:
    1519           0 :                 nRet = OUString(m_aValue.m_pString).toUInt32();
    1520           0 :                 break;
    1521             :             case DataType::FLOAT:
    1522           0 :                 nRet = sal_uInt32(m_aValue.m_nFloat);
    1523           0 :                 break;
    1524             :             case DataType::DOUBLE:
    1525             :             case DataType::REAL:
    1526           0 :                 nRet = sal_uInt32(m_aValue.m_nDouble);
    1527           0 :                 break;
    1528             :             case DataType::DATE:
    1529           0 :                 nRet = dbtools::DBTypeConversion::toDays(*(::com::sun::star::util::Date*)m_aValue.m_pValue);
    1530           0 :                 break;
    1531             :             case DataType::TIME:
    1532             :             case DataType::TIMESTAMP:
    1533             :             case DataType::BINARY:
    1534             :             case DataType::VARBINARY:
    1535             :             case DataType::LONGVARBINARY:
    1536             :             case DataType::BLOB:
    1537             :             case DataType::CLOB:
    1538             :                 OSL_FAIL("getuInt32() for this type is not allowed!");
    1539           0 :                 break;
    1540             :             case DataType::BIT:
    1541             :             case DataType::BOOLEAN:
    1542           0 :                 nRet = sal_uInt32(m_aValue.m_bBool);
    1543           0 :                 break;
    1544             :             case DataType::TINYINT:
    1545           0 :                 if ( m_bSigned )
    1546           0 :                     nRet = m_aValue.m_nInt8;
    1547             :                 else
    1548           0 :                     nRet = m_aValue.m_uInt8;
    1549           0 :                 break;
    1550             :             case DataType::SMALLINT:
    1551           0 :                 if ( m_bSigned )
    1552           0 :                     nRet = m_aValue.m_nInt16;
    1553             :                 else
    1554           0 :                     nRet = m_aValue.m_uInt16;
    1555           0 :                 break;
    1556             :             case DataType::INTEGER:
    1557           1 :                 if ( m_bSigned )
    1558           0 :                     nRet = m_aValue.m_nInt32;
    1559             :                 else
    1560           1 :                     nRet = m_aValue.m_uInt32;
    1561           1 :                 break;
    1562             :             case DataType::BIGINT:
    1563           1 :                 if ( m_bSigned )
    1564           0 :                     nRet = static_cast<sal_uInt32>(m_aValue.m_nInt64);
    1565             :                 else
    1566           1 :                     nRet = static_cast<sal_uInt32>(m_aValue.m_uInt64);
    1567           1 :                 break;
    1568             :             default:
    1569             :                 {
    1570           0 :                     Any aValue = getAny();
    1571           0 :                     aValue >>= nRet;
    1572           0 :                     break;
    1573             :                 }
    1574             :         }
    1575             :     }
    1576           2 :     return nRet;
    1577             : }
    1578             : 
    1579             : 
    1580           2 : sal_Int64 ORowSetValue::getLong()   const
    1581             : {
    1582             :     SAL_INFO( "connectivity.commontools", "dbtools Ocke.Janssen@sun.com ORowSetValue::getLong" );
    1583           2 :     sal_Int64 nRet = 0;
    1584           2 :     if(!m_bNull)
    1585             :     {
    1586           2 :         switch(getTypeKind())
    1587             :         {
    1588             :             case DataType::CHAR:
    1589             :             case DataType::VARCHAR:
    1590             :             case DataType::DECIMAL:
    1591             :             case DataType::NUMERIC:
    1592             :             case DataType::LONGVARCHAR:
    1593           0 :                 nRet = OUString(m_aValue.m_pString).toInt64();
    1594           0 :                 break;
    1595             :             case DataType::FLOAT:
    1596           0 :                 nRet = sal_Int64(m_aValue.m_nFloat);
    1597           0 :                 break;
    1598             :             case DataType::DOUBLE:
    1599             :             case DataType::REAL:
    1600           0 :                 nRet = sal_Int64(m_aValue.m_nDouble);
    1601           0 :                 break;
    1602             :             case DataType::DATE:
    1603           0 :                 nRet = dbtools::DBTypeConversion::toDays(*(::com::sun::star::util::Date*)m_aValue.m_pValue);
    1604           0 :                 break;
    1605             :             case DataType::TIME:
    1606             :             case DataType::TIMESTAMP:
    1607             :             case DataType::BINARY:
    1608             :             case DataType::VARBINARY:
    1609             :             case DataType::LONGVARBINARY:
    1610             :             case DataType::BLOB:
    1611             :             case DataType::CLOB:
    1612             :                 OSL_FAIL("getLong() for this type is not allowed!");
    1613           0 :                 break;
    1614             :             case DataType::BIT:
    1615             :             case DataType::BOOLEAN:
    1616           0 :                 nRet = sal_Int64(m_aValue.m_bBool);
    1617           0 :                 break;
    1618             :             case DataType::TINYINT:
    1619           0 :                 if ( m_bSigned )
    1620           0 :                     nRet = m_aValue.m_nInt8;
    1621             :                 else
    1622           0 :                     nRet = m_aValue.m_uInt8;
    1623           0 :                 break;
    1624             :             case DataType::SMALLINT:
    1625           0 :                 if ( m_bSigned )
    1626           0 :                     nRet = m_aValue.m_nInt16;
    1627             :                 else
    1628           0 :                     nRet = m_aValue.m_uInt16;
    1629           0 :                 break;
    1630             :             case DataType::INTEGER:
    1631           0 :                 if ( m_bSigned )
    1632           0 :                     nRet = m_aValue.m_nInt32;
    1633             :                 else
    1634           0 :                     nRet = m_aValue.m_uInt32;
    1635           0 :                 break;
    1636             :             case DataType::BIGINT:
    1637           2 :                 if ( m_bSigned )
    1638           2 :                     nRet = m_aValue.m_nInt64;
    1639             :                 else
    1640           0 :                     nRet = static_cast<sal_Int64>(m_aValue.m_uInt64);
    1641           2 :                 break;
    1642             :             default:
    1643             :                 {
    1644           0 :                     Any aValue = getAny();
    1645           0 :                     aValue >>= nRet;
    1646           0 :                     break;
    1647             :                 }
    1648             :         }
    1649             :     }
    1650           2 :     return nRet;
    1651             : }
    1652             : 
    1653             : 
    1654           2 : sal_uInt64 ORowSetValue::getULong()   const
    1655             : {
    1656           2 :     sal_uInt64 nRet = 0;
    1657           2 :     if(!m_bNull)
    1658             :     {
    1659           2 :         switch(getTypeKind())
    1660             :         {
    1661             :             case DataType::CHAR:
    1662             :             case DataType::VARCHAR:
    1663             :             case DataType::DECIMAL:
    1664             :             case DataType::NUMERIC:
    1665             :             case DataType::LONGVARCHAR:
    1666           0 :                 nRet = static_cast<sal_uInt64>(OUString(m_aValue.m_pString).toUInt64());
    1667           0 :                 break;
    1668             :             case DataType::FLOAT:
    1669           0 :                 nRet = sal_uInt64(m_aValue.m_nFloat);
    1670           0 :                 break;
    1671             :             case DataType::DOUBLE:
    1672             :             case DataType::REAL:
    1673           0 :                 nRet = sal_uInt64(m_aValue.m_nDouble);
    1674           0 :                 break;
    1675             :             case DataType::DATE:
    1676           0 :                 nRet = dbtools::DBTypeConversion::toDays(*(::com::sun::star::util::Date*)m_aValue.m_pValue);
    1677           0 :                 break;
    1678             :             case DataType::TIME:
    1679             :             case DataType::TIMESTAMP:
    1680             :             case DataType::BINARY:
    1681             :             case DataType::VARBINARY:
    1682             :             case DataType::LONGVARBINARY:
    1683             :             case DataType::BLOB:
    1684             :             case DataType::CLOB:
    1685             :                 OSL_FAIL("getULong() for this type is not allowed!");
    1686           0 :                 break;
    1687             :             case DataType::BIT:
    1688             :             case DataType::BOOLEAN:
    1689           0 :                 nRet = sal_uInt64(m_aValue.m_bBool);
    1690           0 :                 break;
    1691             :             case DataType::TINYINT:
    1692           0 :                 if ( m_bSigned )
    1693           0 :                     nRet = m_aValue.m_nInt8;
    1694             :                 else
    1695           0 :                     nRet = m_aValue.m_uInt8;
    1696           0 :                 break;
    1697             :             case DataType::SMALLINT:
    1698           0 :                 if ( m_bSigned )
    1699           0 :                     nRet = m_aValue.m_nInt16;
    1700             :                 else
    1701           0 :                     nRet = m_aValue.m_uInt16;
    1702           0 :                 break;
    1703             :             case DataType::INTEGER:
    1704           0 :                 if ( m_bSigned )
    1705           0 :                     nRet = m_aValue.m_nInt32;
    1706             :                 else
    1707           0 :                     nRet = m_aValue.m_uInt32;
    1708           0 :                 break;
    1709             :             case DataType::BIGINT:
    1710           2 :                 if ( m_bSigned )
    1711           0 :                     nRet = m_aValue.m_nInt64;
    1712             :                 else
    1713           2 :                     nRet = m_aValue.m_uInt64;
    1714           2 :                 break;
    1715             :             default:
    1716             :                 {
    1717           0 :                     Any aValue = getAny();
    1718           0 :                     aValue >>= nRet;
    1719           0 :                     break;
    1720             :                 }
    1721             :         }
    1722             :     }
    1723           2 :     return nRet;
    1724             : }
    1725             : 
    1726             : 
    1727           2 : float ORowSetValue::getFloat()  const
    1728             : {
    1729             :     SAL_INFO( "connectivity.commontools", "dbtools Ocke.Janssen@sun.com ORowSetValue::getFloat" );
    1730           2 :     float nRet = 0;
    1731           2 :     if(!m_bNull)
    1732             :     {
    1733           2 :         switch(getTypeKind())
    1734             :         {
    1735             :             case DataType::CHAR:
    1736             :             case DataType::VARCHAR:
    1737             :             case DataType::DECIMAL:
    1738             :             case DataType::NUMERIC:
    1739             :             case DataType::LONGVARCHAR:
    1740           0 :                 nRet = OUString(m_aValue.m_pString).toFloat();
    1741           0 :                 break;
    1742             :             case DataType::FLOAT:
    1743           2 :                 nRet = m_aValue.m_nFloat;
    1744           2 :                 break;
    1745             :             case DataType::DOUBLE:
    1746             :             case DataType::REAL:
    1747           0 :                 nRet = (float)m_aValue.m_nDouble;
    1748           0 :                 break;
    1749             :             case DataType::DATE:
    1750           0 :                 nRet = (float)dbtools::DBTypeConversion::toDouble(*(::com::sun::star::util::Date*)m_aValue.m_pValue);
    1751           0 :                 break;
    1752             :             case DataType::TIME:
    1753           0 :                 nRet = (float)dbtools::DBTypeConversion::toDouble(*(::com::sun::star::util::Time*)m_aValue.m_pValue);
    1754           0 :                 break;
    1755             :             case DataType::TIMESTAMP:
    1756           0 :                 nRet = (float)dbtools::DBTypeConversion::toDouble(*(::com::sun::star::util::DateTime*)m_aValue.m_pValue);
    1757           0 :                 break;
    1758             :             case DataType::BINARY:
    1759             :             case DataType::VARBINARY:
    1760             :             case DataType::LONGVARBINARY:
    1761             :             case DataType::BLOB:
    1762             :             case DataType::CLOB:
    1763             :                 OSL_FAIL("getDouble() for this type is not allowed!");
    1764           0 :                 break;
    1765             :             case DataType::BIT:
    1766             :             case DataType::BOOLEAN:
    1767           0 :                 nRet = float(m_aValue.m_bBool);
    1768           0 :                 break;
    1769             :             case DataType::TINYINT:
    1770           0 :                 if ( m_bSigned )
    1771           0 :                     nRet = m_aValue.m_nInt8;
    1772             :                 else
    1773           0 :                     nRet = m_aValue.m_uInt8;
    1774           0 :                 break;
    1775             :             case DataType::SMALLINT:
    1776           0 :                 if ( m_bSigned )
    1777           0 :                     nRet = m_aValue.m_nInt16;
    1778             :                 else
    1779           0 :                     nRet = (float)m_aValue.m_uInt16;
    1780           0 :                 break;
    1781             :             case DataType::INTEGER:
    1782           0 :                 if ( m_bSigned )
    1783           0 :                     nRet = (float)m_aValue.m_nInt32;
    1784             :                 else
    1785           0 :                     nRet = (float)m_aValue.m_uInt32;
    1786           0 :                 break;
    1787             :             case DataType::BIGINT:
    1788           0 :                 if ( m_bSigned )
    1789           0 :                     nRet = (float)m_aValue.m_nInt64;
    1790             :                 else
    1791           0 :                     nRet = (float)m_aValue.m_uInt64;
    1792           0 :                 break;
    1793             :             default:
    1794             :                 {
    1795           0 :                     Any aValue = getAny();
    1796           0 :                     aValue >>= nRet;
    1797           0 :                     break;
    1798             :                 }
    1799             :         }
    1800             :     }
    1801           2 :     return nRet;
    1802             : }
    1803             : 
    1804          20 : double ORowSetValue::getDouble()    const
    1805             : {
    1806             :     SAL_INFO( "connectivity.commontools", "dbtools Ocke.Janssen@sun.com ORowSetValue::getDouble" );
    1807             : 
    1808             : 
    1809          20 :     double nRet = 0;
    1810          20 :     if(!m_bNull)
    1811             :     {
    1812          20 :         switch(getTypeKind())
    1813             :         {
    1814             :             case DataType::CHAR:
    1815             :             case DataType::VARCHAR:
    1816             :             case DataType::DECIMAL:
    1817             :             case DataType::NUMERIC:
    1818             :             case DataType::LONGVARCHAR:
    1819           0 :                 nRet = OUString(m_aValue.m_pString).toDouble();
    1820           0 :                 break;
    1821             :             case DataType::FLOAT:
    1822           0 :                 nRet = m_aValue.m_nFloat;
    1823           0 :                 break;
    1824             :             case DataType::DOUBLE:
    1825             :             case DataType::REAL:
    1826          20 :                 nRet = m_aValue.m_nDouble;
    1827          20 :                 break;
    1828             :             case DataType::DATE:
    1829           0 :                 nRet = dbtools::DBTypeConversion::toDouble(*(::com::sun::star::util::Date*)m_aValue.m_pValue);
    1830           0 :                 break;
    1831             :             case DataType::TIME:
    1832           0 :                 nRet = dbtools::DBTypeConversion::toDouble(*(::com::sun::star::util::Time*)m_aValue.m_pValue);
    1833           0 :                 break;
    1834             :             case DataType::TIMESTAMP:
    1835           0 :                 nRet = dbtools::DBTypeConversion::toDouble(*(::com::sun::star::util::DateTime*)m_aValue.m_pValue);
    1836           0 :                 break;
    1837             :             case DataType::BINARY:
    1838             :             case DataType::VARBINARY:
    1839             :             case DataType::LONGVARBINARY:
    1840             :             case DataType::BLOB:
    1841             :             case DataType::CLOB:
    1842             :                 OSL_FAIL("getDouble() for this type is not allowed!");
    1843           0 :                 break;
    1844             :             case DataType::BIT:
    1845             :             case DataType::BOOLEAN:
    1846           0 :                 nRet = double(m_aValue.m_bBool);
    1847           0 :                 break;
    1848             :             case DataType::TINYINT:
    1849           0 :                 if ( m_bSigned )
    1850           0 :                     nRet = m_aValue.m_nInt8;
    1851             :                 else
    1852           0 :                     nRet = m_aValue.m_uInt8;
    1853           0 :                 break;
    1854             :             case DataType::SMALLINT:
    1855           0 :                 if ( m_bSigned )
    1856           0 :                     nRet = m_aValue.m_nInt16;
    1857             :                 else
    1858           0 :                     nRet = m_aValue.m_uInt16;
    1859           0 :                 break;
    1860             :             case DataType::INTEGER:
    1861           0 :                 if ( m_bSigned )
    1862           0 :                     nRet = m_aValue.m_nInt32;
    1863             :                 else
    1864           0 :                     nRet = m_aValue.m_uInt32;
    1865           0 :                 break;
    1866             :             case DataType::BIGINT:
    1867           0 :                 if ( m_bSigned )
    1868           0 :                     nRet = m_aValue.m_nInt64;
    1869             :                 else
    1870           0 :                     nRet = m_aValue.m_uInt64;
    1871           0 :                 break;
    1872             :             default:
    1873             :                 {
    1874           0 :                     Any aValue = getAny();
    1875           0 :                     aValue >>= nRet;
    1876           0 :                     break;
    1877             :                 }
    1878             :         }
    1879             :     }
    1880          20 :     return nRet;
    1881             : }
    1882             : 
    1883           0 : Sequence<sal_Int8>  ORowSetValue::getSequence() const
    1884             : {
    1885             :     SAL_INFO( "connectivity.commontools", "dbtools Ocke.Janssen@sun.com ORowSetValue::getSequence" );
    1886           0 :     Sequence<sal_Int8> aSeq;
    1887           0 :     if (!m_bNull)
    1888             :     {
    1889           0 :         switch(m_eTypeKind)
    1890             :         {
    1891             :             case DataType::OBJECT:
    1892             :             case DataType::CLOB:
    1893             :             case DataType::BLOB:
    1894             :             {
    1895           0 :                 Reference<XInputStream> xStream;
    1896           0 :                 const Any aValue = makeAny();
    1897           0 :                 if(aValue.hasValue())
    1898             :                 {
    1899           0 :                     Reference<XBlob> xBlob(aValue,UNO_QUERY);
    1900           0 :                     if ( xBlob.is() )
    1901           0 :                         xStream = xBlob->getBinaryStream();
    1902             :                     else
    1903             :                     {
    1904           0 :                         Reference<XClob> xClob(aValue,UNO_QUERY);
    1905           0 :                         if ( xClob.is() )
    1906           0 :                             xStream = xClob->getCharacterStream();
    1907             :                     }
    1908           0 :                     if(xStream.is())
    1909             :                     {
    1910           0 :                         const sal_uInt32    nBytesToRead = 65535;
    1911             :                         sal_uInt32          nRead;
    1912             : 
    1913           0 :                         do
    1914             :                         {
    1915           0 :                             ::com::sun::star::uno::Sequence< sal_Int8 > aReadSeq;
    1916             : 
    1917           0 :                             nRead = xStream->readSomeBytes( aReadSeq, nBytesToRead );
    1918             : 
    1919           0 :                             if( nRead )
    1920             :                             {
    1921           0 :                                 const sal_uInt32 nOldLength = aSeq.getLength();
    1922           0 :                                 aSeq.realloc( nOldLength + nRead );
    1923           0 :                                 memcpy( aSeq.getArray() + nOldLength, aReadSeq.getConstArray(), aReadSeq.getLength() );
    1924           0 :                             }
    1925             :                         }
    1926             :                         while( nBytesToRead == nRead );
    1927           0 :                         xStream->closeInput();
    1928           0 :                     }
    1929           0 :                 }
    1930             :             }
    1931           0 :             break;
    1932             :             case DataType::VARCHAR:
    1933             :             case DataType::LONGVARCHAR:
    1934             :                 {
    1935           0 :                     OUString sVal(m_aValue.m_pString);
    1936           0 :                     aSeq = Sequence<sal_Int8>(reinterpret_cast<const sal_Int8*>(sVal.getStr()),sizeof(sal_Unicode)*sVal.getLength());
    1937             :                 }
    1938           0 :                 break;
    1939             :             case DataType::BINARY:
    1940             :             case DataType::VARBINARY:
    1941             :             case DataType::LONGVARBINARY:
    1942           0 :                 aSeq = *static_cast< Sequence<sal_Int8>*>(m_aValue.m_pValue);
    1943           0 :                 break;
    1944             :             default:
    1945             :                 {
    1946           0 :                     Any aValue = getAny();
    1947           0 :                     aValue >>= aSeq;
    1948           0 :                     break;
    1949             :                 }
    1950             :         }
    1951             :     }
    1952           0 :     return aSeq;
    1953             : 
    1954             : }
    1955             : 
    1956          18 : ::com::sun::star::util::Date ORowSetValue::getDate() const
    1957             : {
    1958             :     SAL_INFO( "connectivity.commontools", "dbtools Ocke.Janssen@sun.com ORowSetValue::getDate" );
    1959          18 :     ::com::sun::star::util::Date aValue;
    1960          18 :     if(!m_bNull)
    1961             :     {
    1962          18 :         switch(m_eTypeKind)
    1963             :         {
    1964             :             case DataType::CHAR:
    1965             :             case DataType::VARCHAR:
    1966             :             case DataType::LONGVARCHAR:
    1967           0 :                 aValue = DBTypeConversion::toDate(getString());
    1968           0 :                 break;
    1969             :             case DataType::DECIMAL:
    1970             :             case DataType::NUMERIC:
    1971             :             case DataType::FLOAT:
    1972             :             case DataType::DOUBLE:
    1973             :             case DataType::REAL:
    1974           0 :                 aValue = DBTypeConversion::toDate((double)*this);
    1975           0 :                 break;
    1976             : 
    1977             :             case DataType::DATE:
    1978          18 :                 aValue = *static_cast< ::com::sun::star::util::Date*>(m_aValue.m_pValue);
    1979          18 :                 break;
    1980             :             case DataType::TIMESTAMP:
    1981             :                 {
    1982           0 :                     ::com::sun::star::util::DateTime* pDateTime = static_cast< ::com::sun::star::util::DateTime*>(m_aValue.m_pValue);
    1983           0 :                     aValue.Day      = pDateTime->Day;
    1984           0 :                     aValue.Month    = pDateTime->Month;
    1985           0 :                     aValue.Year     = pDateTime->Year;
    1986             :                 }
    1987           0 :                 break;
    1988             :             case DataType::BIT:
    1989             :             case DataType::BOOLEAN:
    1990             :             case DataType::TINYINT:
    1991             :             case DataType::SMALLINT:
    1992             :             case DataType::INTEGER:
    1993             :             case DataType::BIGINT:
    1994           0 :                 aValue = DBTypeConversion::toDate( double( sal_Int64( *this ) ) );
    1995           0 :                 break;
    1996             : 
    1997             :             case DataType::BLOB:
    1998             :             case DataType::CLOB:
    1999             :             case DataType::OBJECT:
    2000             :             default:
    2001             :                 OSL_ENSURE( false, "ORowSetValue::getDate: cannot retrieve the data!" );
    2002             :                 // NO break!
    2003             : 
    2004             :             case DataType::BINARY:
    2005             :             case DataType::VARBINARY:
    2006             :             case DataType::LONGVARBINARY:
    2007             :             case DataType::TIME:
    2008           0 :                 aValue = DBTypeConversion::toDate( (double)0 );
    2009           0 :                 break;
    2010             :         }
    2011             :     }
    2012          18 :     return aValue;
    2013             : }
    2014             : 
    2015           0 : ::com::sun::star::util::Time ORowSetValue::getTime()        const
    2016             : {
    2017             :     SAL_INFO( "connectivity.commontools", "dbtools Ocke.Janssen@sun.com ORowSetValue::getTime" );
    2018           0 :     ::com::sun::star::util::Time aValue;
    2019           0 :     if(!m_bNull)
    2020             :     {
    2021           0 :         switch(m_eTypeKind)
    2022             :         {
    2023             :             case DataType::CHAR:
    2024             :             case DataType::VARCHAR:
    2025             :             case DataType::LONGVARCHAR:
    2026           0 :                 aValue = DBTypeConversion::toTime(getString());
    2027           0 :                 break;
    2028             :             case DataType::DECIMAL:
    2029             :             case DataType::NUMERIC:
    2030           0 :                 aValue = DBTypeConversion::toTime((double)*this);
    2031           0 :                 break;
    2032             :             case DataType::FLOAT:
    2033             :             case DataType::DOUBLE:
    2034             :             case DataType::REAL:
    2035           0 :                 aValue = DBTypeConversion::toTime((double)*this);
    2036           0 :                 break;
    2037             :             case DataType::TIMESTAMP:
    2038             :                 {
    2039           0 :                     ::com::sun::star::util::DateTime* pDateTime = static_cast< ::com::sun::star::util::DateTime*>(m_aValue.m_pValue);
    2040           0 :                     aValue.NanoSeconds      = pDateTime->NanoSeconds;
    2041           0 :                     aValue.Seconds          = pDateTime->Seconds;
    2042           0 :                     aValue.Minutes          = pDateTime->Minutes;
    2043           0 :                     aValue.Hours            = pDateTime->Hours;
    2044             :                 }
    2045           0 :                 break;
    2046             :             case DataType::TIME:
    2047           0 :                 aValue = *static_cast< ::com::sun::star::util::Time*>(m_aValue.m_pValue);
    2048           0 :                 break;
    2049             :             default:
    2050             :                 {
    2051           0 :                     Any aAnyValue = getAny();
    2052           0 :                     aAnyValue >>= aValue;
    2053           0 :                     break;
    2054             :                 }
    2055             :         }
    2056             :     }
    2057           0 :     return aValue;
    2058             : }
    2059             : 
    2060           0 : ::com::sun::star::util::DateTime ORowSetValue::getDateTime()    const
    2061             : {
    2062             :     SAL_INFO( "connectivity.commontools", "dbtools Ocke.Janssen@sun.com ORowSetValue::getDateTime" );
    2063           0 :     ::com::sun::star::util::DateTime aValue;
    2064           0 :     if(!m_bNull)
    2065             :     {
    2066           0 :         switch(m_eTypeKind)
    2067             :         {
    2068             :             case DataType::CHAR:
    2069             :             case DataType::VARCHAR:
    2070             :             case DataType::LONGVARCHAR:
    2071           0 :                 aValue = DBTypeConversion::toDateTime(getString());
    2072           0 :                 break;
    2073             :             case DataType::DECIMAL:
    2074             :             case DataType::NUMERIC:
    2075           0 :                 aValue = DBTypeConversion::toDateTime((double)*this);
    2076           0 :                 break;
    2077             :             case DataType::FLOAT:
    2078             :             case DataType::DOUBLE:
    2079             :             case DataType::REAL:
    2080           0 :                 aValue = DBTypeConversion::toDateTime((double)*this);
    2081           0 :                 break;
    2082             :             case DataType::DATE:
    2083             :                 {
    2084           0 :                     ::com::sun::star::util::Date* pDate = static_cast< ::com::sun::star::util::Date*>(m_aValue.m_pValue);
    2085           0 :                     aValue.Day      = pDate->Day;
    2086           0 :                     aValue.Month    = pDate->Month;
    2087           0 :                     aValue.Year     = pDate->Year;
    2088             :                 }
    2089           0 :                 break;
    2090             :             case DataType::TIME:
    2091             :                 {
    2092           0 :                     ::com::sun::star::util::Time* pTime = static_cast< ::com::sun::star::util::Time*>(m_aValue.m_pValue);
    2093           0 :                     aValue.NanoSeconds      = pTime->NanoSeconds;
    2094           0 :                     aValue.Seconds          = pTime->Seconds;
    2095           0 :                     aValue.Minutes          = pTime->Minutes;
    2096           0 :                     aValue.Hours            = pTime->Hours;
    2097             :                 }
    2098           0 :                 break;
    2099             :             case DataType::TIMESTAMP:
    2100           0 :                 aValue = *static_cast< ::com::sun::star::util::DateTime*>(m_aValue.m_pValue);
    2101           0 :                 break;
    2102             :             default:
    2103             :                 {
    2104           0 :                     Any aAnyValue = getAny();
    2105           0 :                     aAnyValue >>= aValue;
    2106           0 :                     break;
    2107             :                 }
    2108             :         }
    2109             :     }
    2110           0 :     return aValue;
    2111             : }
    2112             : 
    2113        2941 : void ORowSetValue::setSigned(bool _bMod)
    2114             : {
    2115             :     SAL_INFO( "connectivity.commontools", "dbtools Ocke.Janssen@sun.com ORowSetValue::setSigned" );
    2116        2941 :     if ( m_bSigned != _bMod )
    2117             :     {
    2118           1 :         m_bSigned = _bMod;
    2119           1 :         if ( !m_bNull )
    2120             :         {
    2121           1 :             sal_Int32 nType = m_eTypeKind;
    2122           1 :             switch(m_eTypeKind)
    2123             :             {
    2124             :                 case DataType::TINYINT:
    2125           0 :                     if ( m_bSigned )
    2126           0 :                         (*this) = getInt8();
    2127             :                     else
    2128             :                     {
    2129           0 :                         m_bSigned = !m_bSigned;
    2130           0 :                         (*this) = getInt16();
    2131           0 :                         m_bSigned = !m_bSigned;
    2132             :                     }
    2133           0 :                     break;
    2134             :                 case DataType::SMALLINT:
    2135           0 :                     if ( m_bSigned )
    2136           0 :                         (*this) = getInt16();
    2137             :                     else
    2138             :                     {
    2139           0 :                         m_bSigned = !m_bSigned;
    2140           0 :                         (*this) = getInt32();
    2141           0 :                         m_bSigned = !m_bSigned;
    2142             :                     }
    2143           0 :                     break;
    2144             :                 case DataType::INTEGER:
    2145           0 :                     if ( m_bSigned )
    2146           0 :                         (*this) = getInt32();
    2147             :                     else
    2148             :                     {
    2149           0 :                         m_bSigned = !m_bSigned;
    2150           0 :                         (*this) = getLong();
    2151           0 :                         m_bSigned = !m_bSigned;
    2152             :                     }
    2153           0 :                     break;
    2154             :                 case DataType::BIGINT:
    2155           1 :                     if ( m_bSigned )
    2156           0 :                         m_aValue.m_nInt64 = static_cast<sal_Int64>(m_aValue.m_uInt64);
    2157             :                     else
    2158           1 :                         m_aValue.m_uInt64 = static_cast<sal_uInt64>(m_aValue.m_nInt64);
    2159           1 :                     break;
    2160             :             }
    2161           1 :             m_eTypeKind = nType;
    2162             :         }
    2163             :     }
    2164        2941 : }
    2165             : 
    2166             : 
    2167             : namespace detail
    2168             : {
    2169        3064 :     class SAL_NO_VTABLE IValueSource
    2170             :     {
    2171             :     public:
    2172             :         virtual OUString             getString() const = 0;
    2173             :         virtual bool                        getBoolean() const = 0;
    2174             :         virtual sal_Int8                    getByte() const = 0;
    2175             :         virtual sal_Int16                   getShort() const = 0;
    2176             :         virtual sal_Int32                   getInt() const = 0;
    2177             :         virtual sal_Int64                   getLong() const = 0;
    2178             :         virtual float                       getFloat() const = 0;
    2179             :         virtual double                      getDouble() const = 0;
    2180             :         virtual Date                        getDate() const = 0;
    2181             :         virtual Time                        getTime() const = 0;
    2182             :         virtual DateTime                    getTimestamp() const = 0;
    2183             :         virtual Sequence< sal_Int8 >        getBytes() const = 0;
    2184             :         virtual Reference< XBlob >          getBlob() const = 0;
    2185             :         virtual Reference< XClob >          getClob() const = 0;
    2186             :         virtual Any                         getObject() const = 0;
    2187             :         virtual bool                        wasNull() const = 0;
    2188             : 
    2189        3064 :         virtual ~IValueSource() { }
    2190             :     };
    2191             : 
    2192        3064 :     class RowValue : public IValueSource
    2193             :     {
    2194             :     public:
    2195        3064 :         RowValue( const Reference< XRow >& _xRow, const sal_Int32 _nPos )
    2196             :             :m_xRow( _xRow )
    2197        3064 :             ,m_nPos( _nPos )
    2198             :         {
    2199        3064 :         }
    2200             : 
    2201             :         // IValueSource
    2202        2850 :         virtual OUString             getString() const SAL_OVERRIDE           { return m_xRow->getString( m_nPos ); };
    2203          68 :         virtual bool                        getBoolean() const SAL_OVERRIDE          { return m_xRow->getBoolean( m_nPos ); };
    2204           0 :         virtual sal_Int8                    getByte() const SAL_OVERRIDE             { return m_xRow->getByte( m_nPos ); };
    2205           0 :         virtual sal_Int16                   getShort() const SAL_OVERRIDE            { return m_xRow->getShort( m_nPos ); }
    2206          90 :         virtual sal_Int32                   getInt() const SAL_OVERRIDE              { return m_xRow->getInt( m_nPos ); }
    2207           0 :         virtual sal_Int64                   getLong() const SAL_OVERRIDE             { return m_xRow->getLong( m_nPos ); }
    2208           0 :         virtual float                       getFloat() const SAL_OVERRIDE            { return m_xRow->getFloat( m_nPos ); };
    2209           0 :         virtual double                      getDouble() const SAL_OVERRIDE           { return m_xRow->getDouble( m_nPos ); };
    2210          56 :         virtual Date                        getDate() const SAL_OVERRIDE             { return m_xRow->getDate( m_nPos ); };
    2211           0 :         virtual Time                        getTime() const SAL_OVERRIDE             { return m_xRow->getTime( m_nPos ); };
    2212           0 :         virtual DateTime                    getTimestamp() const SAL_OVERRIDE        { return m_xRow->getTimestamp( m_nPos ); };
    2213           0 :         virtual Sequence< sal_Int8 >        getBytes() const SAL_OVERRIDE            { return m_xRow->getBytes( m_nPos ); };
    2214           0 :         virtual Reference< XBlob >          getBlob() const SAL_OVERRIDE             { return m_xRow->getBlob( m_nPos ); };
    2215           0 :         virtual Reference< XClob >          getClob() const SAL_OVERRIDE             { return m_xRow->getClob( m_nPos ); };
    2216           0 :         virtual Any                         getObject() const SAL_OVERRIDE           { return m_xRow->getObject( m_nPos ,NULL); };
    2217        3064 :         virtual bool                        wasNull() const SAL_OVERRIDE             { return m_xRow->wasNull( ); };
    2218             : 
    2219             :     private:
    2220             :         const Reference< XRow > m_xRow;
    2221             :         const sal_Int32         m_nPos;
    2222             :     };
    2223             : 
    2224           0 :     class ColumnValue : public IValueSource
    2225             :     {
    2226             :     public:
    2227           0 :         ColumnValue( const Reference< XColumn >& _rxColumn )
    2228           0 :             :m_xColumn( _rxColumn )
    2229             :         {
    2230           0 :         }
    2231             : 
    2232             :         // IValueSource
    2233           0 :         virtual OUString             getString() const SAL_OVERRIDE           { return m_xColumn->getString(); };
    2234           0 :         virtual bool                        getBoolean() const SAL_OVERRIDE          { return m_xColumn->getBoolean(); };
    2235           0 :         virtual sal_Int8                    getByte() const SAL_OVERRIDE             { return m_xColumn->getByte(); };
    2236           0 :         virtual sal_Int16                   getShort() const SAL_OVERRIDE            { return m_xColumn->getShort(); }
    2237           0 :         virtual sal_Int32                   getInt() const SAL_OVERRIDE              { return m_xColumn->getInt(); }
    2238           0 :         virtual sal_Int64                   getLong() const SAL_OVERRIDE             { return m_xColumn->getLong(); }
    2239           0 :         virtual float                       getFloat() const SAL_OVERRIDE            { return m_xColumn->getFloat(); };
    2240           0 :         virtual double                      getDouble() const SAL_OVERRIDE           { return m_xColumn->getDouble(); };
    2241           0 :         virtual Date                        getDate() const SAL_OVERRIDE             { return m_xColumn->getDate(); };
    2242           0 :         virtual Time                        getTime() const SAL_OVERRIDE             { return m_xColumn->getTime(); };
    2243           0 :         virtual DateTime                    getTimestamp() const SAL_OVERRIDE        { return m_xColumn->getTimestamp(); };
    2244           0 :         virtual Sequence< sal_Int8 >        getBytes() const SAL_OVERRIDE            { return m_xColumn->getBytes(); };
    2245           0 :         virtual Reference< XBlob >          getBlob() const SAL_OVERRIDE             { return m_xColumn->getBlob(); };
    2246           0 :         virtual Reference< XClob >          getClob() const SAL_OVERRIDE             { return m_xColumn->getClob(); };
    2247           0 :         virtual Any                         getObject() const SAL_OVERRIDE           { return m_xColumn->getObject( NULL ); };
    2248           0 :         virtual bool                        wasNull() const SAL_OVERRIDE             { return m_xColumn->wasNull( ); };
    2249             : 
    2250             :     private:
    2251             :         const Reference< XColumn >  m_xColumn;
    2252             :     };
    2253             : }
    2254             : 
    2255             : 
    2256           0 : void ORowSetValue::fill( const sal_Int32 _nType, const Reference< XColumn >& _rxColumn )
    2257             : {
    2258           0 :     detail::ColumnValue aColumnValue( _rxColumn );
    2259           0 :     impl_fill( _nType, true, aColumnValue );
    2260           0 : }
    2261             : 
    2262             : 
    2263        3064 : void ORowSetValue::fill( sal_Int32 _nPos, sal_Int32 _nType, bool  _bNullable, const Reference< XRow>& _xRow )
    2264             : {
    2265        3064 :     detail::RowValue aRowValue( _xRow, _nPos );
    2266        3064 :     impl_fill( _nType, _bNullable, aRowValue );
    2267        3064 : }
    2268             : 
    2269             : 
    2270        3064 : void ORowSetValue::fill(sal_Int32 _nPos,
    2271             :                      sal_Int32 _nType,
    2272             :                      const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow>& _xRow)
    2273             : {
    2274             :     SAL_INFO( "connectivity.commontools", "dbtools Ocke.Janssen@sun.com ORowSetValue::fill (1)" );
    2275        3064 :     fill(_nPos,_nType,true,_xRow);
    2276        3064 : }
    2277             : 
    2278             : 
    2279        3064 : void ORowSetValue::impl_fill( const sal_Int32 _nType, bool _bNullable, const detail::IValueSource& _rValueSource )
    2280             : 
    2281             : {
    2282             :     SAL_INFO( "connectivity.commontools", "dbtools Ocke.Janssen@sun.com ORowSetValue::fill (2)" );
    2283        3064 :     bool bReadData = true;
    2284        3064 :     switch(_nType)
    2285             :     {
    2286             :     case DataType::CHAR:
    2287             :     case DataType::VARCHAR:
    2288             :     case DataType::DECIMAL:
    2289             :     case DataType::NUMERIC:
    2290             :     case DataType::LONGVARCHAR:
    2291        2850 :         (*this) = _rValueSource.getString();
    2292        2850 :         break;
    2293             :     case DataType::BIGINT:
    2294           0 :         if ( isSigned() )
    2295           0 :             (*this) = _rValueSource.getLong();
    2296             :         else
    2297             :             // TODO: this is rather horrible performance-wise
    2298             :             //       but fixing it needs extending the ::com::sun::star::sdbc::XRow API
    2299             :             //       to have a getULong(), and needs updating all drivers :-|
    2300             :             //       When doing that, add getUByte, getUShort, getUInt for symmetry/completeness
    2301           0 :             (*this) = _rValueSource.getString().toUInt64();
    2302           0 :         break;
    2303             :     case DataType::FLOAT:
    2304           0 :         (*this) = _rValueSource.getFloat();
    2305           0 :         break;
    2306             :     case DataType::DOUBLE:
    2307             :     case DataType::REAL:
    2308           0 :         (*this) = _rValueSource.getDouble();
    2309           0 :         break;
    2310             :     case DataType::DATE:
    2311          56 :         (*this) = _rValueSource.getDate();
    2312          56 :         break;
    2313             :     case DataType::TIME:
    2314           0 :         (*this) = _rValueSource.getTime();
    2315           0 :         break;
    2316             :     case DataType::TIMESTAMP:
    2317           0 :         (*this) = _rValueSource.getTimestamp();
    2318           0 :         break;
    2319             :     case DataType::BINARY:
    2320             :     case DataType::VARBINARY:
    2321             :     case DataType::LONGVARBINARY:
    2322           0 :         (*this) = _rValueSource.getBytes();
    2323           0 :         break;
    2324             :     case DataType::BIT:
    2325             :     case DataType::BOOLEAN:
    2326          68 :         (*this) = _rValueSource.getBoolean();
    2327          68 :         break;
    2328             :     case DataType::TINYINT:
    2329           0 :         if ( isSigned() )
    2330           0 :             (*this) = _rValueSource.getByte();
    2331             :         else
    2332           0 :             (*this) = _rValueSource.getShort();
    2333           0 :         break;
    2334             :     case DataType::SMALLINT:
    2335           0 :         if ( isSigned() )
    2336           0 :             (*this) = _rValueSource.getShort();
    2337             :         else
    2338           0 :             (*this) = _rValueSource.getInt();
    2339           0 :         break;
    2340             :     case DataType::INTEGER:
    2341          90 :         if ( isSigned() )
    2342          90 :             (*this) = _rValueSource.getInt();
    2343             :         else
    2344           0 :             (*this) = _rValueSource.getLong();
    2345          90 :         break;
    2346             :     case DataType::CLOB:
    2347           0 :         (*this) = ::com::sun::star::uno::makeAny(_rValueSource.getClob());
    2348           0 :         setTypeKind(DataType::CLOB);
    2349           0 :         break;
    2350             :     case DataType::BLOB:
    2351           0 :         (*this) = ::com::sun::star::uno::makeAny(_rValueSource.getBlob());
    2352           0 :         setTypeKind(DataType::BLOB);
    2353           0 :         break;
    2354             :     case DataType::OTHER:
    2355           0 :         (*this) = _rValueSource.getObject();
    2356           0 :         setTypeKind(DataType::OTHER);
    2357           0 :         break;
    2358             :     default:
    2359             :         SAL_WARN( "connectivity.commontools", "ORowSetValue::fill: unsupported type!" );
    2360           0 :         (*this) = _rValueSource.getObject();
    2361           0 :         break;
    2362             :     }
    2363        3064 :     if ( bReadData && _bNullable && _rValueSource.wasNull() )
    2364        2044 :         setNull();
    2365        3064 :     setTypeKind(_nType);
    2366        3064 : }
    2367             : 
    2368          46 : void ORowSetValue::fill(const Any& _rValue)
    2369             : {
    2370             :     SAL_INFO( "connectivity.commontools", "dbtools Ocke.Janssen@sun.com ORowSetValue::fill (3)" );
    2371          46 :     switch (_rValue.getValueType().getTypeClass())
    2372             :     {
    2373             :         case TypeClass_VOID:
    2374           0 :             setNull();            break;
    2375             :         case TypeClass_BOOLEAN:
    2376             :         {
    2377           1 :             bool bValue( false );
    2378           1 :             _rValue >>= bValue;
    2379           1 :             (*this) = bValue;
    2380           1 :             break;
    2381             :         }
    2382             :         case TypeClass_CHAR:
    2383             :         {
    2384           0 :             sal_Unicode aDummy(0);
    2385           0 :             _rValue >>= aDummy;
    2386           0 :             (*this) = OUString(aDummy);
    2387           0 :             break;
    2388             :         }
    2389             :         case TypeClass_STRING:
    2390             :         {
    2391           5 :             OUString sDummy;
    2392           5 :             _rValue >>= sDummy;
    2393           5 :             (*this) = sDummy;
    2394           5 :             break;
    2395             :         }
    2396             :         case TypeClass_FLOAT:
    2397             :         {
    2398           1 :             float aDummy(0.0);
    2399           1 :             _rValue >>= aDummy;
    2400           1 :             (*this) = aDummy;
    2401           1 :             break;
    2402             :         }
    2403             :         case TypeClass_DOUBLE:
    2404             :         {
    2405           1 :             double aDummy(0.0);
    2406           1 :             _rValue >>= aDummy;
    2407           1 :             (*this) = aDummy;
    2408           1 :             break;
    2409             :         }
    2410             :         case TypeClass_BYTE:
    2411             :         {
    2412           1 :             sal_Int8 aDummy(0);
    2413           1 :             _rValue >>= aDummy;
    2414           1 :             (*this) = aDummy;
    2415           1 :             break;
    2416             :         }
    2417             :         case TypeClass_SHORT:
    2418             :         {
    2419           1 :             sal_Int16 aDummy(0);
    2420           1 :             _rValue >>= aDummy;
    2421           1 :             (*this) = aDummy;
    2422           1 :             break;
    2423             :         }
    2424             :         case TypeClass_UNSIGNED_SHORT:
    2425             :         {
    2426           2 :             sal_uInt16 nValue(0);
    2427           2 :             _rValue >>= nValue;
    2428           2 :             (*this) = nValue;
    2429           2 :             break;
    2430             :         }
    2431             :         case TypeClass_LONG:
    2432             :         {
    2433           1 :             sal_Int32 aDummy(0);
    2434           1 :             _rValue >>= aDummy;
    2435           1 :             (*this) = aDummy;
    2436           1 :             break;
    2437             :         }
    2438             :         case TypeClass_UNSIGNED_LONG:
    2439             :         {
    2440           1 :             sal_uInt32 nValue(0);
    2441           1 :             _rValue >>= nValue;
    2442           1 :             (*this) = static_cast<sal_Int64>(nValue);
    2443           1 :             setSigned(false);
    2444           1 :             break;
    2445             :         }
    2446             :         case TypeClass_HYPER:
    2447             :         {
    2448           1 :             sal_Int64 nValue(0);
    2449           1 :             _rValue >>= nValue;
    2450           1 :             (*this) = nValue;
    2451           1 :             break;
    2452             :         }
    2453             :         case TypeClass_UNSIGNED_HYPER:
    2454             :         {
    2455           1 :             sal_uInt64 nValue(0);
    2456           1 :             _rValue >>= nValue;
    2457           1 :             (*this) = nValue;
    2458           1 :             setSigned(false);
    2459           1 :             break;
    2460             :         }
    2461             :         case TypeClass_ENUM:
    2462             :         {
    2463           0 :             sal_Int32 enumValue( 0 );
    2464           0 :             ::cppu::enum2int( enumValue, _rValue );
    2465           0 :             (*this) = enumValue;
    2466             :         }
    2467           0 :         break;
    2468             : 
    2469             :         case TypeClass_SEQUENCE:
    2470             :         {
    2471           0 :             Sequence<sal_Int8> aDummy;
    2472           0 :             if ( _rValue >>= aDummy )
    2473           0 :                 (*this) = aDummy;
    2474             :             else
    2475             :                 SAL_WARN( "connectivity.commontools", "ORowSetValue::fill: unsupported sequence type!" );
    2476           0 :             break;
    2477             :         }
    2478             : 
    2479             :         case TypeClass_STRUCT:
    2480             :         {
    2481           0 :             ::com::sun::star::util::Date aDate;
    2482           0 :             ::com::sun::star::util::Time aTime;
    2483           0 :             ::com::sun::star::util::DateTime aDateTime;
    2484           0 :             if ( _rValue >>= aDate )
    2485             :             {
    2486           0 :                 (*this) = aDate;
    2487             :             }
    2488           0 :             else if ( _rValue >>= aTime )
    2489             :             {
    2490           0 :                 (*this) = aTime;
    2491             :             }
    2492           0 :             else if ( _rValue >>= aDateTime )
    2493             :             {
    2494           0 :                 (*this) = aDateTime;
    2495             :             }
    2496             :             else
    2497             :                 SAL_WARN( "connectivity.commontools", "ORowSetValue::fill: unsupported structure!" );
    2498             : 
    2499           0 :             break;
    2500             :         }
    2501             :         case TypeClass_INTERFACE:
    2502             :             {
    2503          30 :                 Reference< XClob > xClob;
    2504          30 :                 if ( _rValue >>= xClob )
    2505             :                 {
    2506          30 :                     (*this) = _rValue;
    2507          30 :                     setTypeKind(DataType::CLOB);
    2508             :                 }
    2509             :                 else
    2510             :                 {
    2511           0 :                     Reference< XBlob > xBlob;
    2512           0 :                     if ( _rValue >>= xBlob )
    2513             :                     {
    2514           0 :                         (*this) = _rValue;
    2515           0 :                         setTypeKind(DataType::BLOB);
    2516             :                     }
    2517             :                     else
    2518             :                     {
    2519           0 :                         (*this) = _rValue;
    2520           0 :                     }
    2521          30 :                 }
    2522             :             }
    2523          30 :             break;
    2524             : 
    2525             :         default:
    2526             :             SAL_WARN( "connectivity.commontools","Unknown type");
    2527           0 :             break;
    2528             :     }
    2529          46 : }
    2530             : 
    2531             : }   // namespace connectivity
    2532             : 
    2533             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10