LCOV - code coverage report
Current view: top level - ucbhelper/source/provider - propertyvalueset.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 56 182 30.8 %
Date: 2012-08-25 Functions: 19 43 44.2 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 63 1146 5.5 %

           Branch data     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                 :            : /**************************************************************************
      22                 :            :                                 TODO
      23                 :            :  **************************************************************************
      24                 :            : 
      25                 :            :  *************************************************************************/
      26                 :            : 
      27                 :            : #ifndef __VECTOR__
      28                 :            : #include <vector>
      29                 :            : #endif
      30                 :            : #include <com/sun/star/beans/Property.hpp>
      31                 :            : #include <com/sun/star/beans/XPropertyAccess.hpp>
      32                 :            : #include <com/sun/star/beans/XPropertySet.hpp>
      33                 :            : #include <com/sun/star/beans/XPropertySetInfo.hpp>
      34                 :            : #include <com/sun/star/script/XTypeConverter.hpp>
      35                 :            : 
      36                 :            : #include "osl/diagnose.h"
      37                 :            : #include "osl/mutex.hxx"
      38                 :            : #include <ucbhelper/propertyvalueset.hxx>
      39                 :            : 
      40                 :            : using namespace com::sun::star::beans;
      41                 :            : using namespace com::sun::star::container;
      42                 :            : using namespace com::sun::star::io;
      43                 :            : using namespace com::sun::star::lang;
      44                 :            : using namespace com::sun::star::script;
      45                 :            : using namespace com::sun::star::sdbc;
      46                 :            : using namespace com::sun::star::uno;
      47                 :            : using namespace com::sun::star::util;
      48                 :            : using ::rtl::OUString;
      49                 :            : 
      50                 :            : namespace ucbhelper_impl
      51                 :            : {
      52                 :            : 
      53                 :            : //=========================================================================
      54                 :            : //
      55                 :            : // PropertyValue.
      56                 :            : //
      57                 :            : //=========================================================================
      58                 :            : 
      59                 :            : const sal_uInt32 NO_VALUE_SET               = 0x00000000;
      60                 :            : const sal_uInt32 STRING_VALUE_SET           = 0x00000001;
      61                 :            : const sal_uInt32 BOOLEAN_VALUE_SET          = 0x00000002;
      62                 :            : const sal_uInt32 BYTE_VALUE_SET             = 0x00000004;
      63                 :            : const sal_uInt32 SHORT_VALUE_SET            = 0x00000008;
      64                 :            : const sal_uInt32 INT_VALUE_SET              = 0x00000010;
      65                 :            : const sal_uInt32 LONG_VALUE_SET             = 0x00000020;
      66                 :            : const sal_uInt32 FLOAT_VALUE_SET            = 0x00000040;
      67                 :            : const sal_uInt32 DOUBLE_VALUE_SET           = 0x00000080;
      68                 :            : const sal_uInt32 BYTES_VALUE_SET            = 0x00000100;
      69                 :            : const sal_uInt32 DATE_VALUE_SET             = 0x00000200;
      70                 :            : const sal_uInt32 TIME_VALUE_SET             = 0x00000400;
      71                 :            : const sal_uInt32 TIMESTAMP_VALUE_SET        = 0x00000800;
      72                 :            : const sal_uInt32 BINARYSTREAM_VALUE_SET     = 0x00001000;
      73                 :            : const sal_uInt32 CHARACTERSTREAM_VALUE_SET  = 0x00002000;
      74                 :            : const sal_uInt32 REF_VALUE_SET              = 0x00004000;
      75                 :            : const sal_uInt32 BLOB_VALUE_SET             = 0x00008000;
      76                 :            : const sal_uInt32 CLOB_VALUE_SET             = 0x00010000;
      77                 :            : const sal_uInt32 ARRAY_VALUE_SET            = 0x00020000;
      78                 :            : const sal_uInt32 OBJECT_VALUE_SET           = 0x00040000;
      79                 :            : 
      80 [ +  - ][ +  - ]:       3506 : struct PropertyValue
      81                 :            : {
      82                 :            :     ::rtl::OUString
      83                 :            :                 sPropertyName;
      84                 :            : 
      85                 :            :     sal_uInt32  nPropsSet;
      86                 :            :     sal_uInt32  nOrigValue;
      87                 :            : 
      88                 :            :     OUString    aString;    // getString
      89                 :            :     sal_Bool    bBoolean;   // getBoolean
      90                 :            :     sal_Int8    nByte;      // getByte
      91                 :            :     sal_Int16   nShort;     // getShort
      92                 :            :     sal_Int32   nInt;       // getInt
      93                 :            :     sal_Int64   nLong;      // getLong
      94                 :            :     float       nFloat;     // getFloat
      95                 :            :     double      nDouble;    // getDouble
      96                 :            : 
      97                 :            :     Sequence< sal_Int8 >        aBytes;             // getBytes
      98                 :            :     Date                        aDate;              // getDate
      99                 :            :     Time                        aTime;              // getTime
     100                 :            :     DateTime                    aTimestamp;         // getTimestamp
     101                 :            :     Reference< XInputStream >   xBinaryStream;      // getBinaryStream
     102                 :            :     Reference< XInputStream >   xCharacterStream;   // getCharacterStream
     103                 :            :     Reference< XRef >           xRef;               // getRef
     104                 :            :     Reference< XBlob >          xBlob;              // getBlob
     105                 :            :     Reference< XClob >          xClob;              // getClob
     106                 :            :     Reference< XArray >         xArray;             // getArray
     107                 :            :     Any                         aObject;            // getObject
     108                 :            : 
     109                 :       1006 :     inline PropertyValue()
     110                 :            :         : nPropsSet( NO_VALUE_SET ), nOrigValue( NO_VALUE_SET ),
     111                 :            :           bBoolean(false),
     112                 :            :           nByte(0),
     113                 :            :           nShort(0),
     114                 :            :           nInt(0),
     115                 :            :           nLong(0),
     116                 :            :           nFloat(0.0),
     117         [ +  - ]:       1006 :           nDouble(0.0)
     118                 :       1006 :         {}
     119                 :            : };
     120                 :            : } // namespace ucbhelper_impl
     121                 :            : 
     122                 :            : using namespace ucbhelper_impl;
     123                 :            : 
     124                 :            : namespace ucbhelper
     125                 :            : {
     126                 :            : 
     127                 :            : //=========================================================================
     128                 :            : //
     129                 :            : // class PropertyValues.
     130                 :            : //
     131                 :            : //=========================================================================
     132                 :            : 
     133                 :            : typedef std::vector< ucbhelper_impl::PropertyValue > PropertyValuesVector;
     134                 :            : 
     135                 :       1684 : class PropertyValues : public PropertyValuesVector {};
     136                 :            : 
     137                 :            : } // namespace ucbhelper
     138                 :            : 
     139                 :            : //=========================================================================
     140                 :            : //
     141                 :            : // Welcome to the macro hell...
     142                 :            : //
     143                 :            : //=========================================================================
     144                 :            : 
     145                 :            : #define GETVALUE_IMPL_TYPE( _type_, _type_name_, _member_name_, _cppu_type_ ) \
     146                 :            :                                                                               \
     147                 :            :     osl::MutexGuard aGuard( m_aMutex );                                       \
     148                 :            :                                                                               \
     149                 :            :     _type_ aValue = _type_();   /* default ctor */                            \
     150                 :            :                                                                               \
     151                 :            :     m_bWasNull = sal_True;                                                    \
     152                 :            :                                                                               \
     153                 :            :     if ( ( columnIndex < 1 )                                                  \
     154                 :            :          || ( columnIndex > sal_Int32( m_pValues->size() ) ) )                \
     155                 :            :     {                                                                         \
     156                 :            :         OSL_FAIL( "PropertyValueSet - index out of range!" );    \
     157                 :            :     }                                                                         \
     158                 :            :     else                                                                      \
     159                 :            :     {                                                                         \
     160                 :            :         ucbhelper_impl::PropertyValue& rValue                                 \
     161                 :            :             = (*m_pValues)[ columnIndex - 1 ];                                \
     162                 :            :                                                                               \
     163                 :            :         if ( rValue.nOrigValue != NO_VALUE_SET )                              \
     164                 :            :         {                                                                     \
     165                 :            :             if ( rValue.nPropsSet & _type_name_ )                             \
     166                 :            :             {                                                                 \
     167                 :            :                 /* Values is present natively... */                           \
     168                 :            :                 aValue = rValue._member_name_;                                \
     169                 :            :                 m_bWasNull = sal_False;                                       \
     170                 :            :             }                                                                 \
     171                 :            :             else                                                              \
     172                 :            :             {                                                                 \
     173                 :            :                 if ( !(rValue.nPropsSet & OBJECT_VALUE_SET) )                 \
     174                 :            :                 {                                                             \
     175                 :            :                     /* Value is not (yet) available as Any. Create it. */     \
     176                 :            :                     getObject( columnIndex, Reference< XNameAccess >() );     \
     177                 :            :                 }                                                             \
     178                 :            :                                                                               \
     179                 :            :                 if ( rValue.nPropsSet & OBJECT_VALUE_SET )                    \
     180                 :            :                 {                                                             \
     181                 :            :                     /* Value is available as Any. */                          \
     182                 :            :                                                                               \
     183                 :            :                     if ( rValue.aObject.hasValue() )                          \
     184                 :            :                     {                                                         \
     185                 :            :                         /* Try to convert into native value. */               \
     186                 :            :                         if ( rValue.aObject >>= aValue )                      \
     187                 :            :                         {                                                     \
     188                 :            :                             rValue._member_name_ = aValue;                    \
     189                 :            :                             rValue.nPropsSet |= _type_name_;                  \
     190                 :            :                             m_bWasNull = sal_False;                           \
     191                 :            :                         }                                                     \
     192                 :            :                         else                                                  \
     193                 :            :                         {                                                     \
     194                 :            :                             /* Last chance. Try type converter service... */  \
     195                 :            :                                                                               \
     196                 :            :                             Reference< XTypeConverter > xConverter            \
     197                 :            :                                                     = getTypeConverter();     \
     198                 :            :                             if ( xConverter.is() )                            \
     199                 :            :                             {                                                 \
     200                 :            :                                 try                                           \
     201                 :            :                                 {                                             \
     202                 :            :                                     Any aConvAny = xConverter->convertTo(     \
     203                 :            :                                                              rValue.aObject,      \
     204                 :            :                                                             _cppu_type_ );    \
     205                 :            :                                                                               \
     206                 :            :                                     if ( aConvAny >>= aValue )                \
     207                 :            :                                     {                                         \
     208                 :            :                                         rValue._member_name_ = aValue;        \
     209                 :            :                                         rValue.nPropsSet |= _type_name_;      \
     210                 :            :                                         m_bWasNull = sal_False;               \
     211                 :            :                                     }                                         \
     212                 :            :                                 }                                             \
     213                 :            :                                 catch (const IllegalArgumentException&)       \
     214                 :            :                                 {                                             \
     215                 :            :                                 }                                             \
     216                 :            :                                 catch (const CannotConvertException&)         \
     217                 :            :                                 {                                             \
     218                 :            :                                 }                                             \
     219                 :            :                             }                                                 \
     220                 :            :                         }                                                     \
     221                 :            :                     }                                                         \
     222                 :            :                 }                                                             \
     223                 :            :             }                                                                 \
     224                 :            :         }                                                                     \
     225                 :            :     }                                                                         \
     226                 :            :     return aValue;
     227                 :            : 
     228                 :            : #define GETVALUE_IMPL( _type_, _type_name_, _member_name_ )                   \
     229                 :            :     GETVALUE_IMPL_TYPE( _type_,                                               \
     230                 :            :                         _type_name_,                                          \
     231                 :            :                         _member_name_,                                        \
     232                 :            :                         getCppuType( static_cast< const _type_ * >( 0 ) ) )
     233                 :            : 
     234                 :            : #define SETVALUE_IMPL( _prop_name_, _type_name_, _member_name_, _value_ )     \
     235                 :            :                                                                               \
     236                 :            :     osl::MutexGuard aGuard( m_aMutex );                                       \
     237                 :            :                                                                               \
     238                 :            :     ucbhelper_impl::PropertyValue aNewValue;                                  \
     239                 :            :     aNewValue.sPropertyName = _prop_name_;                                    \
     240                 :            :     aNewValue.nPropsSet     = _type_name_;                                    \
     241                 :            :     aNewValue.nOrigValue    = _type_name_;                                    \
     242                 :            :     aNewValue._member_name_ = _value_;                                        \
     243                 :            :                                                                               \
     244                 :            :     m_pValues->push_back( aNewValue );
     245                 :            : 
     246                 :            : namespace ucbhelper {
     247                 :            : 
     248                 :            : //=========================================================================
     249                 :            : //=========================================================================
     250                 :            : //
     251                 :            : // PropertyValueSet Implementation.
     252                 :            : //
     253                 :            : //=========================================================================
     254                 :            : //=========================================================================
     255                 :            : 
     256                 :            : #define PROPERTYVALUESET_INIT()             \
     257                 :            :   m_xSMgr( rxSMgr ),                        \
     258                 :            :   m_pValues( new PropertyValues ),          \
     259                 :            :   m_bWasNull( sal_False ),                  \
     260                 :            :   m_bTriedToGetTypeConverter( sal_False )
     261                 :            : 
     262                 :            : //=========================================================================
     263                 :        842 : PropertyValueSet::PropertyValueSet(
     264                 :            :                     const Reference< XMultiServiceFactory >& rxSMgr )
     265 [ +  - ][ +  - ]:        842 : : PROPERTYVALUESET_INIT()
                 [ +  - ]
     266                 :            : {
     267                 :        842 : }
     268                 :            : 
     269                 :            : //=========================================================================
     270                 :            : // virtual
     271         [ +  - ]:        842 : PropertyValueSet::~PropertyValueSet()
     272                 :            : {
     273         [ +  - ]:        842 :     delete m_pValues;
     274         [ -  + ]:       1684 : }
     275                 :            : 
     276                 :            : //=========================================================================
     277                 :            : //
     278                 :            : // XInterface methods.
     279                 :            : //
     280                 :            : //=========================================================================
     281                 :            : 
     282 [ #  # ][ #  # ]:       7392 : XINTERFACE_IMPL_3( PropertyValueSet,
                 [ #  # ]
     283                 :            :                    XTypeProvider,
     284                 :            :                    XRow,
     285                 :            :                    XColumnLocate );
     286                 :            : 
     287                 :            : //=========================================================================
     288                 :            : //
     289                 :            : // XTypeProvider methods.
     290                 :            : //
     291                 :            : //=========================================================================
     292                 :            : 
     293 [ #  # ][ #  # ]:          0 : XTYPEPROVIDER_IMPL_3( PropertyValueSet,
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     294                 :            :                       XTypeProvider,
     295                 :            :                          XRow,
     296                 :            :                       XColumnLocate );
     297                 :            : 
     298                 :            : //=========================================================================
     299                 :            : //
     300                 :            : // XRow methods.
     301                 :            : //
     302                 :            : //=========================================================================
     303                 :            : 
     304                 :            : // virtual
     305                 :         16 : sal_Bool SAL_CALL PropertyValueSet::wasNull()
     306                 :            :     throw( SQLException, RuntimeException )
     307                 :            : {
     308                 :            :     // This method can not be implemented correctly!!! Imagine different
     309                 :            :     // threads doing a getXYZ - wasNull calling sequence on the same
     310                 :            :     // implementation object...
     311                 :         16 :     return m_bWasNull;
     312                 :            : }
     313                 :            : 
     314                 :            : //=========================================================================
     315                 :            : // virtual
     316                 :         62 : OUString SAL_CALL PropertyValueSet::getString( sal_Int32 columnIndex )
     317                 :            :     throw( SQLException, RuntimeException )
     318                 :            : {
     319 [ +  - ][ +  - ]:         62 :     GETVALUE_IMPL( OUString, STRING_VALUE_SET, aString );
         [ -  + ][ +  - ]
         [ +  + ][ +  - ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ +  - ]
           [ #  #  #  #  
                #  #  # ]
     320                 :            : }
     321                 :            : 
     322                 :            : //=========================================================================
     323                 :            : // virtual
     324                 :         32 : sal_Bool SAL_CALL PropertyValueSet::getBoolean( sal_Int32 columnIndex )
     325                 :            :     throw( SQLException, RuntimeException )
     326                 :            : {
     327 [ +  - ][ +  - ]:         64 :     GETVALUE_IMPL_TYPE(
         [ -  + ][ +  - ]
         [ +  - ][ +  - ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  #  
             #  #  #  #  
                      # ]
     328         [ +  - ]:         32 :             sal_Bool, BOOLEAN_VALUE_SET, bBoolean, getCppuBooleanType() );
     329                 :            : }
     330                 :            : 
     331                 :            : //=========================================================================
     332                 :            : // virtual
     333                 :          0 : sal_Int8 SAL_CALL PropertyValueSet::getByte( sal_Int32 columnIndex )
     334                 :            :     throw( SQLException, RuntimeException )
     335                 :            : {
     336 [ #  # ][ #  # ]:          0 :     GETVALUE_IMPL( sal_Int8, BYTE_VALUE_SET, nByte );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  #  
                #  #  # ]
     337                 :            : }
     338                 :            : 
     339                 :            : //=========================================================================
     340                 :            : // virtual
     341                 :          0 : sal_Int16 SAL_CALL PropertyValueSet::getShort( sal_Int32 columnIndex )
     342                 :            :     throw( SQLException, RuntimeException )
     343                 :            : {
     344 [ #  # ][ #  # ]:          0 :     GETVALUE_IMPL( sal_Int16, SHORT_VALUE_SET, nShort );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  #  
                #  #  # ]
     345                 :            : }
     346                 :            : 
     347                 :            : //=========================================================================
     348                 :            : // virtual
     349                 :          0 : sal_Int32 SAL_CALL PropertyValueSet::getInt( sal_Int32 columnIndex )
     350                 :            :     throw( SQLException, RuntimeException )
     351                 :            : {
     352 [ #  # ][ #  # ]:          0 :     GETVALUE_IMPL( sal_Int32, INT_VALUE_SET, nInt );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  #  
                #  #  # ]
     353                 :            : }
     354                 :            : 
     355                 :            : //=========================================================================
     356                 :            : // virtual
     357                 :          0 : sal_Int64 SAL_CALL PropertyValueSet::getLong( sal_Int32 columnIndex )
     358                 :            :     throw( SQLException, RuntimeException )
     359                 :            : {
     360 [ #  # ][ #  # ]:          0 :     GETVALUE_IMPL( sal_Int64, LONG_VALUE_SET, nLong );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  #  
                #  #  # ]
     361                 :            : }
     362                 :            : 
     363                 :            : //=========================================================================
     364                 :            : // virtual
     365                 :          0 : float SAL_CALL PropertyValueSet::getFloat( sal_Int32 columnIndex )
     366                 :            :     throw( SQLException, RuntimeException )
     367                 :            : {
     368 [ #  # ][ #  # ]:          0 :     GETVALUE_IMPL( float, FLOAT_VALUE_SET, nFloat );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  #  
                #  #  # ]
     369                 :            : }
     370                 :            : 
     371                 :            : //=========================================================================
     372                 :            : // virtual
     373                 :          0 : double SAL_CALL PropertyValueSet::getDouble( sal_Int32 columnIndex )
     374                 :            :     throw( SQLException, RuntimeException )
     375                 :            : {
     376 [ #  # ][ #  # ]:          0 :     GETVALUE_IMPL( double, DOUBLE_VALUE_SET, nDouble );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  #  
                #  #  # ]
     377                 :            : }
     378                 :            : 
     379                 :            : //=========================================================================
     380                 :            : // virtual
     381                 :            : Sequence< sal_Int8 > SAL_CALL
     382                 :          0 : PropertyValueSet::getBytes( sal_Int32 columnIndex )
     383                 :            :     throw( SQLException, RuntimeException )
     384                 :            : {
     385 [ #  # ][ #  # ]:          0 :     GETVALUE_IMPL( Sequence< sal_Int8 >, BYTES_VALUE_SET, aBytes );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  #  
                #  #  # ]
     386                 :            : }
     387                 :            : 
     388                 :            : //=========================================================================
     389                 :            : // virtual
     390                 :          0 : Date SAL_CALL PropertyValueSet::getDate( sal_Int32 columnIndex )
     391                 :            :     throw( SQLException, RuntimeException )
     392                 :            : {
     393 [ #  # ][ #  # ]:          0 :     GETVALUE_IMPL( Date, DATE_VALUE_SET, aDate );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  #  
                #  #  # ]
     394                 :            : }
     395                 :            : 
     396                 :            : //=========================================================================
     397                 :            : // virtual
     398                 :          0 : Time SAL_CALL PropertyValueSet::getTime( sal_Int32 columnIndex )
     399                 :            :     throw( SQLException, RuntimeException )
     400                 :            : {
     401 [ #  # ][ #  # ]:          0 :     GETVALUE_IMPL( Time, TIME_VALUE_SET, aTime );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  #  
                #  #  # ]
     402                 :            : }
     403                 :            : 
     404                 :            : //=========================================================================
     405                 :            : // virtual
     406                 :          0 : DateTime SAL_CALL PropertyValueSet::getTimestamp( sal_Int32 columnIndex )
     407                 :            :     throw( SQLException, RuntimeException )
     408                 :            : {
     409 [ #  # ][ #  # ]:          0 :     GETVALUE_IMPL( DateTime, TIMESTAMP_VALUE_SET, aTimestamp );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  #  
                #  #  # ]
     410                 :            : }
     411                 :            : 
     412                 :            : //=========================================================================
     413                 :            : // virtual
     414                 :            : Reference< XInputStream > SAL_CALL
     415                 :          0 : PropertyValueSet::getBinaryStream( sal_Int32 columnIndex )
     416                 :            :     throw( SQLException, RuntimeException )
     417                 :            : {
     418 [ #  # ][ #  # ]:          0 :     GETVALUE_IMPL(
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  #  
                #  #  # ]
     419         [ #  # ]:          0 :         Reference< XInputStream >, BINARYSTREAM_VALUE_SET, xBinaryStream );
     420                 :            : }
     421                 :            : 
     422                 :            : //=========================================================================
     423                 :            : // virtual
     424                 :            : Reference< XInputStream > SAL_CALL
     425                 :          0 : PropertyValueSet::getCharacterStream( sal_Int32 columnIndex )
     426                 :            :     throw( SQLException, RuntimeException )
     427                 :            : {
     428 [ #  # ][ #  # ]:          0 :     GETVALUE_IMPL(
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  #  
                #  #  # ]
     429         [ #  # ]:          0 :         Reference< XInputStream >, CHARACTERSTREAM_VALUE_SET, xCharacterStream );
     430                 :            : }
     431                 :            : 
     432                 :            : //=========================================================================
     433                 :            : // virtual
     434                 :       1012 : Any SAL_CALL PropertyValueSet::getObject(
     435                 :            :                                     sal_Int32 columnIndex,
     436                 :            :                                          const Reference< XNameAccess >& )
     437                 :            :     throw( SQLException, RuntimeException )
     438                 :            : {
     439         [ +  - ]:       1012 :     osl::MutexGuard aGuard( m_aMutex );
     440                 :            : 
     441                 :       1012 :     Any aValue;
     442                 :            : 
     443                 :       1012 :     m_bWasNull = sal_True;
     444                 :            : 
     445         [ +  - ]:       2024 :     if ( ( columnIndex < 1 )
           [ +  -  -  + ]
     446                 :       1012 :          || ( columnIndex > sal_Int32( m_pValues->size() ) ) )
     447                 :            :     {
     448                 :            :         OSL_FAIL( "PropertyValueSet - index out of range!" );
     449                 :            :     }
     450                 :            :     else
     451                 :            :     {
     452                 :            :         ucbhelper_impl::PropertyValue& rValue
     453                 :       1012 :             = (*m_pValues)[ columnIndex - 1 ];
     454                 :            : 
     455         [ +  + ]:       1012 :         if ( rValue.nPropsSet & OBJECT_VALUE_SET )
     456                 :            :         {
     457                 :            :             // Values is present natively...
     458                 :        267 :             aValue = rValue.aObject;
     459                 :        267 :             m_bWasNull = sal_False;
     460                 :            :         }
     461                 :            :         else
     462                 :            :         {
     463                 :            :             // Make Any from original value.
     464                 :            : 
     465   [ -  +  +  -  :        745 :             switch ( rValue.nOrigValue )
          -  -  +  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
                      - ]
     466                 :            :             {
     467                 :            :                 case NO_VALUE_SET:
     468                 :          0 :                     break;
     469                 :            : 
     470                 :            :                 case STRING_VALUE_SET:
     471         [ +  - ]:        295 :                     aValue <<= rValue.aString;
     472                 :        295 :                     break;
     473                 :            : 
     474                 :            :                 case BOOLEAN_VALUE_SET:
     475         [ +  - ]:        442 :                     aValue <<= rValue.bBoolean;
     476                 :        442 :                     break;
     477                 :            : 
     478                 :            :                 case BYTE_VALUE_SET:
     479         [ #  # ]:          0 :                     aValue <<= rValue.nByte;
     480                 :          0 :                     break;
     481                 :            : 
     482                 :            :                 case SHORT_VALUE_SET:
     483         [ #  # ]:          0 :                     aValue <<= rValue.nShort;
     484                 :          0 :                     break;
     485                 :            : 
     486                 :            :                 case INT_VALUE_SET:
     487         [ #  # ]:          0 :                     aValue <<= rValue.nInt;
     488                 :          0 :                     break;
     489                 :            : 
     490                 :            :                 case LONG_VALUE_SET:
     491         [ +  - ]:          8 :                     aValue <<= rValue.nLong;
     492                 :          8 :                     break;
     493                 :            : 
     494                 :            :                 case FLOAT_VALUE_SET:
     495         [ #  # ]:          0 :                     aValue <<= rValue.nFloat;
     496                 :          0 :                     break;
     497                 :            : 
     498                 :            :                 case DOUBLE_VALUE_SET:
     499         [ #  # ]:          0 :                     aValue <<= rValue.nDouble;
     500                 :          0 :                     break;
     501                 :            : 
     502                 :            :                 case BYTES_VALUE_SET:
     503         [ #  # ]:          0 :                     aValue <<= rValue.aBytes;
     504                 :          0 :                     break;
     505                 :            : 
     506                 :            :                 case DATE_VALUE_SET:
     507         [ #  # ]:          0 :                     aValue <<= rValue.aDate;
     508                 :          0 :                     break;
     509                 :            : 
     510                 :            :                 case TIME_VALUE_SET:
     511         [ #  # ]:          0 :                     aValue <<= rValue.aTime;
     512                 :          0 :                     break;
     513                 :            : 
     514                 :            :                 case TIMESTAMP_VALUE_SET:
     515         [ #  # ]:          0 :                     aValue <<= rValue.aTimestamp;
     516                 :          0 :                     break;
     517                 :            : 
     518                 :            :                 case BINARYSTREAM_VALUE_SET:
     519         [ #  # ]:          0 :                     aValue <<= rValue.xBinaryStream;
     520                 :          0 :                     break;
     521                 :            : 
     522                 :            :                 case CHARACTERSTREAM_VALUE_SET:
     523         [ #  # ]:          0 :                     aValue <<= rValue.xCharacterStream;
     524                 :          0 :                     break;
     525                 :            : 
     526                 :            :                 case REF_VALUE_SET:
     527         [ #  # ]:          0 :                     aValue <<= rValue.xRef;
     528                 :          0 :                     break;
     529                 :            : 
     530                 :            :                 case BLOB_VALUE_SET:
     531         [ #  # ]:          0 :                     aValue <<= rValue.xBlob;
     532                 :          0 :                     break;
     533                 :            : 
     534                 :            :                 case CLOB_VALUE_SET:
     535         [ #  # ]:          0 :                     aValue <<= rValue.xClob;
     536                 :          0 :                     break;
     537                 :            : 
     538                 :            :                 case ARRAY_VALUE_SET:
     539         [ #  # ]:          0 :                     aValue <<= rValue.xArray;
     540                 :          0 :                     break;
     541                 :            : 
     542                 :            :                 case OBJECT_VALUE_SET:
     543                 :            :                     // Fall-through is intended!
     544                 :            :                 default:
     545                 :            :                     OSL_FAIL( "PropertyValueSet::getObject - "
     546                 :            :                                 "Wrong original type" );
     547                 :          0 :                     break;
     548                 :            :             }
     549                 :            : 
     550         [ +  - ]:        745 :             if ( aValue.hasValue() )
     551                 :            :             {
     552                 :        745 :                 rValue.aObject = aValue;
     553                 :        745 :                 rValue.nPropsSet |= OBJECT_VALUE_SET;
     554                 :        745 :                 m_bWasNull = sal_False;
     555                 :            :             }
     556                 :            :         }
     557                 :            :      }
     558                 :            : 
     559         [ +  - ]:       1012 :     return aValue;
     560                 :            : }
     561                 :            : 
     562                 :            : //=========================================================================
     563                 :            : // virtual
     564                 :          0 : Reference< XRef > SAL_CALL PropertyValueSet::getRef( sal_Int32 columnIndex )
     565                 :            :     throw( SQLException, RuntimeException )
     566                 :            : {
     567 [ #  # ][ #  # ]:          0 :     GETVALUE_IMPL( Reference< XRef >, REF_VALUE_SET, xRef );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  #  
             #  #  #  #  
                      # ]
     568                 :            : }
     569                 :            : 
     570                 :            : //=========================================================================
     571                 :            : // virtual
     572                 :          0 : Reference< XBlob > SAL_CALL PropertyValueSet::getBlob( sal_Int32 columnIndex )
     573                 :            :     throw( SQLException, RuntimeException )
     574                 :            : {
     575 [ #  # ][ #  # ]:          0 :     GETVALUE_IMPL( Reference< XBlob >, BLOB_VALUE_SET, xBlob );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  #  
             #  #  #  #  
                      # ]
     576                 :            : }
     577                 :            : 
     578                 :            : //=========================================================================
     579                 :            : // virtual
     580                 :          0 : Reference< XClob > SAL_CALL PropertyValueSet::getClob( sal_Int32 columnIndex )
     581                 :            :     throw( SQLException, RuntimeException )
     582                 :            : {
     583 [ #  # ][ #  # ]:          0 :     GETVALUE_IMPL( Reference< XClob >, CLOB_VALUE_SET, xClob );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  #  
             #  #  #  #  
                      # ]
     584                 :            : }
     585                 :            : 
     586                 :            : //=========================================================================
     587                 :            : // virtual
     588                 :          0 : Reference< XArray > SAL_CALL PropertyValueSet::getArray( sal_Int32 columnIndex )
     589                 :            :     throw( SQLException, RuntimeException )
     590                 :            : {
     591 [ #  # ][ #  # ]:          0 :     GETVALUE_IMPL( Reference< XArray >, ARRAY_VALUE_SET, xArray );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  #  
             #  #  #  #  
                      # ]
     592                 :            : }
     593                 :            : 
     594                 :            : //=========================================================================
     595                 :            : //
     596                 :            : // XColumnLocate methods.
     597                 :            : //
     598                 :            : //=========================================================================
     599                 :            : 
     600                 :            : // virtual
     601                 :          0 : sal_Int32 SAL_CALL PropertyValueSet::findColumn( const OUString& columnName )
     602                 :            :     throw( SQLException, RuntimeException )
     603                 :            : {
     604         [ #  # ]:          0 :     osl::MutexGuard aGuard( m_aMutex );
     605                 :            : 
     606         [ #  # ]:          0 :     if ( !columnName.isEmpty() )
     607                 :            :     {
     608                 :          0 :         sal_Int32 nCount = m_pValues->size();
     609         [ #  # ]:          0 :         for ( sal_Int32 n = 0; n < nCount; ++n )
     610                 :            :         {
     611         [ #  # ]:          0 :             if ( (*m_pValues)[ n ].sPropertyName.equals( columnName ) )
     612                 :          0 :                 return sal_Int32( n + 1 ); // Index is 1-based.
     613                 :            :         }
     614                 :            :     }
     615         [ #  # ]:          0 :     return 0;
     616                 :            : }
     617                 :            : 
     618                 :            : //=========================================================================
     619                 :            : //
     620                 :            : // Non-interface methods.
     621                 :            : //
     622                 :            : //=========================================================================
     623                 :            : 
     624                 :          0 : const Reference< XTypeConverter >& PropertyValueSet::getTypeConverter()
     625                 :            : {
     626         [ #  # ]:          0 :     osl::MutexGuard aGuard( m_aMutex );
     627                 :            : 
     628 [ #  # ][ #  # ]:          0 :     if ( !m_bTriedToGetTypeConverter && !m_xTypeConverter.is() )
                 [ #  # ]
     629                 :            :     {
     630                 :          0 :         m_bTriedToGetTypeConverter = sal_True;
     631                 :            :         m_xTypeConverter = Reference< XTypeConverter >(
     632         [ #  # ]:          0 :                                 m_xSMgr->createInstance(
     633                 :            :                                     OUString(
     634                 :          0 :                                         "com.sun.star.script.Converter" ) ),
     635 [ #  # ][ #  # ]:          0 :                                 UNO_QUERY );
                 [ #  # ]
     636                 :            : 
     637                 :            :         OSL_ENSURE( m_xTypeConverter.is(),
     638                 :            :                     "PropertyValueSet::getTypeConverter() - "
     639                 :            :                     "Service 'com.sun.star.script.Converter' n/a!" );
     640                 :            :     }
     641         [ #  # ]:          0 :     return m_xTypeConverter;
     642                 :            : }
     643                 :            : 
     644                 :            : //=========================================================================
     645                 :        319 : void PropertyValueSet::appendString( const ::rtl::OUString& rPropName,
     646                 :            :                                      const OUString& rValue )
     647                 :            : {
     648 [ +  - ][ +  - ]:        319 :     SETVALUE_IMPL( rPropName, STRING_VALUE_SET, aString, rValue );
         [ +  - ][ +  - ]
                 [ +  - ]
     649                 :        319 : }
     650                 :            : 
     651                 :            : //=========================================================================
     652                 :        474 : void PropertyValueSet::appendBoolean( const ::rtl::OUString& rPropName,
     653                 :            :                                       sal_Bool bValue )
     654                 :            : {
     655 [ +  - ][ +  - ]:        474 :     SETVALUE_IMPL( rPropName, BOOLEAN_VALUE_SET, bBoolean, bValue );
         [ +  - ][ +  - ]
                 [ +  - ]
     656                 :        474 : }
     657                 :            : 
     658                 :            : //=========================================================================
     659                 :          8 : void PropertyValueSet::appendLong( const ::rtl::OUString& rPropName,
     660                 :            :                                    sal_Int64 nValue )
     661                 :            : {
     662 [ +  - ][ +  - ]:          8 :     SETVALUE_IMPL( rPropName, LONG_VALUE_SET, nLong, nValue );
         [ +  - ][ +  - ]
                 [ +  - ]
     663                 :          8 : }
     664                 :            : 
     665                 :            : //=========================================================================
     666                 :          0 : void PropertyValueSet::appendTimestamp( const ::rtl::OUString& rPropName,
     667                 :            :                                         const DateTime& rValue )
     668                 :            : {
     669 [ #  # ][ #  # ]:          0 :     SETVALUE_IMPL( rPropName, TIMESTAMP_VALUE_SET, aTimestamp, rValue );
         [ #  # ][ #  # ]
                 [ #  # ]
     670                 :          0 : }
     671                 :            : 
     672                 :            : //=========================================================================
     673                 :        185 : void PropertyValueSet::appendObject( const ::rtl::OUString& rPropName,
     674                 :            :                                      const Any& rValue )
     675                 :            : {
     676 [ +  - ][ +  - ]:        185 :     SETVALUE_IMPL( rPropName, OBJECT_VALUE_SET, aObject, rValue );
         [ +  - ][ +  - ]
                 [ +  - ]
     677                 :        185 : }
     678                 :            : 
     679                 :            : //=========================================================================
     680                 :         20 : void PropertyValueSet::appendVoid( const ::rtl::OUString& rPropName )
     681                 :            : {
     682 [ +  - ][ +  - ]:         20 :     SETVALUE_IMPL( rPropName, NO_VALUE_SET, aObject, Any() );
         [ +  - ][ +  - ]
                 [ +  - ]
     683                 :         20 : }
     684                 :            : 
     685                 :            : //=========================================================================
     686                 :          0 : void PropertyValueSet::appendPropertySet(
     687                 :            :                                 const Reference< XPropertySet >& rxSet )
     688                 :            : {
     689         [ #  # ]:          0 :     if ( rxSet.is() )
     690                 :            :     {
     691 [ #  # ][ #  # ]:          0 :         Reference< XPropertySetInfo > xInfo = rxSet->getPropertySetInfo();
     692         [ #  # ]:          0 :         if ( xInfo.is() )
     693                 :            :         {
     694 [ #  # ][ #  # ]:          0 :             Sequence< Property > aProps      = xInfo->getProperties();
     695                 :          0 :             const Property*      pProps      = aProps.getConstArray();
     696                 :          0 :             sal_Int32            nPropsCount = aProps.getLength();
     697                 :            : 
     698         [ #  # ]:          0 :             Reference< XPropertyAccess > xPropertyAccess( rxSet, UNO_QUERY );
     699         [ #  # ]:          0 :             if ( xPropertyAccess.is() )
     700                 :            :             {
     701                 :            :                 // Efficient: Get all prop values with one ( remote) call.
     702                 :            : 
     703                 :            :                 Sequence< ::com::sun::star::beans::PropertyValue > aPropValues
     704 [ #  # ][ #  # ]:          0 :                     = xPropertyAccess->getPropertyValues();
     705                 :            : 
     706                 :            :                 const ::com::sun::star::beans::PropertyValue* pPropValues
     707                 :          0 :                       = aPropValues.getConstArray();
     708                 :            : 
     709                 :          0 :                 sal_Int32 nValuesCount = aPropValues.getLength();
     710         [ #  # ]:          0 :                 for ( sal_Int32 n = 0; n < nValuesCount; ++n )
     711                 :            :                 {
     712                 :            :                     const ::com::sun::star::beans::PropertyValue& rPropValue
     713                 :          0 :                         = pPropValues[ n ];
     714                 :            : 
     715                 :            :                     // Find info for current property value.
     716         [ #  # ]:          0 :                     for ( sal_Int32 m = 0; m < nPropsCount; ++m )
     717                 :            :                     {
     718                 :          0 :                         const Property& rProp = pProps[ m ];
     719         [ #  # ]:          0 :                         if ( rProp.Name == rPropValue.Name )
     720                 :            :                         {
     721                 :            :                             // Found!
     722         [ #  # ]:          0 :                             appendObject( rProp, rPropValue.Value );
     723                 :          0 :                             break;
     724                 :            :                         }
     725                 :            :                     }
     726         [ #  # ]:          0 :                 }
     727                 :            :             }
     728                 :            :             else
     729                 :            :             {
     730                 :            :                 // Get every single prop value with one ( remote) call.
     731                 :            : 
     732         [ #  # ]:          0 :                 for ( sal_Int32 n = 0; n < nPropsCount; ++n )
     733                 :            :                 {
     734                 :          0 :                     const Property& rProp = pProps[ n ];
     735                 :            : 
     736                 :            :                     try
     737                 :            :                     {
     738 [ #  # ][ #  # ]:          0 :                         Any aValue = rxSet->getPropertyValue( rProp.Name );
     739                 :            : 
     740         [ #  # ]:          0 :                         if ( aValue.hasValue() )
     741         [ #  # ]:          0 :                             appendObject( rProp, aValue );
              [ #  #  # ]
     742                 :            :                     }
     743         [ #  # ]:          0 :                     catch (const UnknownPropertyException&)
     744                 :            :                     {
     745                 :            :                     }
     746         [ #  # ]:          0 :                     catch (const WrappedTargetException&)
     747                 :            :                     {
     748                 :            :                     }
     749                 :            :                 }
     750         [ #  # ]:          0 :             }
     751                 :          0 :         }
     752                 :            :     }
     753                 :          0 : }
     754                 :            : 
     755                 :            : //=========================================================================
     756                 :          0 : sal_Bool PropertyValueSet::appendPropertySetValue(
     757                 :            :                                 const Reference< XPropertySet >& rxSet,
     758                 :            :                                 const Property& rProperty )
     759                 :            : {
     760         [ #  # ]:          0 :     if ( rxSet.is() )
     761                 :            :     {
     762                 :            :         try
     763                 :            :         {
     764 [ #  # ][ #  # ]:          0 :             Any aValue = rxSet->getPropertyValue( rProperty.Name );
     765         [ #  # ]:          0 :             if ( aValue.hasValue() )
     766                 :            :             {
     767         [ #  # ]:          0 :                 appendObject( rProperty, aValue );
     768                 :          0 :                 return sal_True;
     769         [ #  # ]:          0 :             }
              [ #  #  # ]
     770                 :            :         }
     771                 :          0 :         catch (const UnknownPropertyException&)
     772                 :            :         {
     773                 :            :         }
     774                 :          0 :         catch (const WrappedTargetException&)
     775                 :            :         {
     776                 :            :         }
     777                 :            :     }
     778                 :            : 
     779                 :            :     // Error.
     780                 :          0 :     return sal_False;
     781                 :            : }
     782                 :            : 
     783                 :            : } // namespace ucbhelper
     784                 :            : 
     785                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10