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

Generated by: LCOV version 1.10