LCOV - code coverage report
Current view: top level - dbaccess/source/core/api - definitioncolumn.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 136 264 51.5 %
Date: 2014-11-03 Functions: 24 54 44.4 %
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             : #include <bitset>
      21             : 
      22             : #include "apitools.hxx"
      23             : #include "dbastrings.hrc"
      24             : #include "definitioncolumn.hxx"
      25             : #include "sdbcoretools.hxx"
      26             : 
      27             : #include <com/sun/star/beans/PropertyAttribute.hpp>
      28             : #include <com/sun/star/sdbcx/XTablesSupplier.hpp>
      29             : 
      30             : #include <comphelper/property.hxx>
      31             : #include <comphelper/types.hxx>
      32             : #include <connectivity/dbtools.hxx>
      33             : #include <cppuhelper/typeprovider.hxx>
      34             : #include <tools/debug.hxx>
      35             : #include <tools/diagnose_ex.h>
      36             : 
      37             : using namespace ::com::sun::star::sdbc;
      38             : using namespace ::com::sun::star::sdbcx;
      39             : using namespace ::com::sun::star::beans;
      40             : using namespace ::com::sun::star::uno;
      41             : using namespace ::com::sun::star::lang;
      42             : using namespace ::com::sun::star::container;
      43             : using namespace ::cppu;
      44             : using namespace ::comphelper;
      45             : using namespace ::osl;
      46             : using namespace dbaccess;
      47             : 
      48             : namespace
      49             : {
      50             :     const sal_Int32 HAS_DESCRIPTION            = 0x00000001;
      51             :     const sal_Int32 HAS_DEFAULTVALUE           = 0x00000002;
      52             :     const sal_Int32 HAS_ROWVERSION             = 0x00000004;
      53             :     const sal_Int32 HAS_AUTOINCREMENT_CREATION = 0x00000008;
      54             :     const sal_Int32 HAS_CATALOGNAME            = 0x00000010;
      55             :     const sal_Int32 HAS_SCHEMANAME             = 0x00000020;
      56             :     const sal_Int32 HAS_TABLENAME              = 0x00000040;
      57             : }
      58             : 
      59             : // OTableColumnDescriptor
      60       46496 : IMPLEMENT_FORWARD_XINTERFACE2(OTableColumnDescriptor,OColumn,TXChild)
      61             : 
      62        1488 : void OTableColumnDescriptor::impl_registerProperties()
      63             : {
      64        1488 :     sal_Int32 nDefaultAttr = m_bActAsDescriptor ? 0 : PropertyAttribute::READONLY;
      65             : 
      66        1488 :     registerProperty( PROPERTY_TYPENAME, PROPERTY_ID_TYPENAME, nDefaultAttr, &m_aTypeName, ::getCppuType( &m_aTypeName ) );
      67        1488 :     registerProperty( PROPERTY_DESCRIPTION, PROPERTY_ID_DESCRIPTION, nDefaultAttr, &m_aDescription, ::getCppuType( &m_aDescription ) );
      68        1488 :     registerProperty( PROPERTY_DEFAULTVALUE, PROPERTY_ID_DEFAULTVALUE, nDefaultAttr, &m_aDefaultValue, ::getCppuType( &m_aDefaultValue ) );
      69             : 
      70        1488 :     if ( m_bActAsDescriptor )
      71        1488 :         registerProperty( PROPERTY_AUTOINCREMENTCREATION, PROPERTY_ID_AUTOINCREMENTCREATION, nDefaultAttr, &m_aAutoIncrementValue, ::getCppuType( &m_aAutoIncrementValue ) );
      72             : 
      73        1488 :     registerProperty( PROPERTY_TYPE, PROPERTY_ID_TYPE, nDefaultAttr, &m_nType, ::getCppuType( &m_nType ) );
      74        1488 :     registerProperty( PROPERTY_PRECISION, PROPERTY_ID_PRECISION, nDefaultAttr, &m_nPrecision, ::getCppuType( &m_nPrecision ) );
      75        1488 :     registerProperty( PROPERTY_SCALE, PROPERTY_ID_SCALE, nDefaultAttr, &m_nScale, ::getCppuType( &m_nScale ) );
      76        1488 :     registerProperty( PROPERTY_ISNULLABLE, PROPERTY_ID_ISNULLABLE, nDefaultAttr, &m_nIsNullable, ::getCppuType( &m_nIsNullable ) );
      77        1488 :     registerProperty( PROPERTY_ISAUTOINCREMENT, PROPERTY_ID_ISAUTOINCREMENT, nDefaultAttr, &m_bAutoIncrement, ::getCppuType( &m_bAutoIncrement ) );
      78        1488 :     registerProperty( PROPERTY_ISROWVERSION, PROPERTY_ID_ISROWVERSION, nDefaultAttr, &m_bRowVersion, ::getCppuType( &m_bRowVersion ) );
      79        1488 :     registerProperty( PROPERTY_ISCURRENCY, PROPERTY_ID_ISCURRENCY, nDefaultAttr, &m_bCurrency, ::getCppuType( &m_bCurrency ) );
      80             : 
      81        1488 :     OColumnSettings::registerProperties( *this );
      82        1488 : }
      83             : 
      84           0 : IMPLEMENT_GET_IMPLEMENTATION_ID( OTableColumnDescriptor )
      85             : 
      86             : // ::com::sun::star::lang::XServiceInfo
      87           0 : OUString OTableColumnDescriptor::getImplementationName(  ) throw (RuntimeException, std::exception)
      88             : {
      89           0 :     return OUString("com.sun.star.sdb.OTableColumnDescriptor");
      90             : }
      91             : 
      92           0 : Sequence< OUString > OTableColumnDescriptor::getSupportedServiceNames(  ) throw (RuntimeException, std::exception)
      93             : {
      94           0 :     Sequence< OUString > aSNS( 2 );
      95           0 :     aSNS[0] = m_bActAsDescriptor ? OUString(SERVICE_SDBCX_COLUMNDESCRIPTOR) : OUString(SERVICE_SDBCX_COLUMN);
      96           0 :     aSNS[1] = SERVICE_SDB_COLUMNSETTINGS;
      97           0 :     return aSNS;
      98             : }
      99             : 
     100             : // comphelper::OPropertyArrayUsageHelper
     101          20 : ::cppu::IPropertyArrayHelper* OTableColumnDescriptor::createArrayHelper( ) const
     102             : {
     103          20 :     Sequence< Property > aProps;
     104          20 :     describeProperties( aProps );
     105          20 :     return new ::cppu::OPropertyArrayHelper( aProps );
     106             : }
     107             : 
     108             : // cppu::OPropertySetHelper
     109      136256 : ::cppu::IPropertyArrayHelper& OTableColumnDescriptor::getInfoHelper()
     110             : {
     111      136256 :     return *static_cast< ::comphelper::OPropertyArrayUsageHelper< OTableColumnDescriptor >* >(this)->getArrayHelper();
     112             : }
     113             : 
     114        2160 : void OTableColumnDescriptor::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const Any& rValue ) throw (Exception, std::exception)
     115             : {
     116        2160 :     OColumn::setFastPropertyValue_NoBroadcast( nHandle, rValue );
     117        2160 :     ::dbaccess::notifyDataSourceModified( m_xParent, true );
     118        2160 : }
     119             : 
     120           0 : Reference< XInterface > SAL_CALL OTableColumnDescriptor::getParent(  ) throw (RuntimeException, std::exception)
     121             : {
     122           0 :     ::osl::MutexGuard aGuard(m_aMutex);
     123           0 :     return m_xParent;
     124             : }
     125             : 
     126         992 : void SAL_CALL OTableColumnDescriptor::setParent( const Reference< XInterface >& _xParent ) throw (NoSupportException, RuntimeException, std::exception)
     127             : {
     128         992 :     ::osl::MutexGuard aGuard(m_aMutex);
     129         992 :     m_xParent = _xParent;
     130         992 : }
     131             : 
     132             : // OTableColumn
     133             : 
     134           0 : OTableColumn::OTableColumn( const OUString& _rName )
     135           0 :     :OTableColumnDescriptor( false /* do not act as descriptor */ )
     136             : {
     137           0 :     m_sName = _rName;
     138           0 : }
     139             : 
     140           0 : OTableColumn::~OTableColumn()
     141             : {
     142           0 : }
     143             : 
     144           0 : IMPLEMENT_GET_IMPLEMENTATION_ID( OTableColumn )
     145             : 
     146           0 : OUString OTableColumn::getImplementationName(  ) throw (RuntimeException, std::exception)
     147             : {
     148           0 :     return OUString("com.sun.star.sdb.OTableColumn");
     149             : }
     150             : 
     151           0 : ::cppu::IPropertyArrayHelper& SAL_CALL OTableColumn::getInfoHelper()
     152             : {
     153           0 :     return *OTableColumn_PBase::getArrayHelper();
     154             : }
     155             : 
     156           0 : ::cppu::IPropertyArrayHelper* OTableColumn::createArrayHelper( ) const
     157             : {
     158           0 :     return OTableColumnDescriptor::createArrayHelper();
     159             : }
     160             : 
     161             : // OQueryColumn
     162             : 
     163           0 : OQueryColumn::OQueryColumn( const Reference< XPropertySet >& _rxParserColumn, const Reference< XConnection >& _rxConnection, const OUString &i_sLabel )
     164             :     :OTableColumnDescriptor( false /* do not act as descriptor */ )
     165           0 :     ,m_sLabel(i_sLabel)
     166             : {
     167           0 :     const sal_Int32 nPropAttr = PropertyAttribute::READONLY;
     168           0 :     registerProperty( PROPERTY_CATALOGNAME, PROPERTY_ID_CATALOGNAME, nPropAttr, &m_sCatalogName, ::getCppuType( &m_sCatalogName ) );
     169           0 :     registerProperty( PROPERTY_SCHEMANAME, PROPERTY_ID_SCHEMANAME, nPropAttr, &m_sSchemaName, ::getCppuType( &m_sSchemaName ) );
     170           0 :     registerProperty( PROPERTY_TABLENAME, PROPERTY_ID_TABLENAME, nPropAttr, &m_sTableName, ::getCppuType( &m_sTableName ) );
     171           0 :     registerProperty( PROPERTY_REALNAME, PROPERTY_ID_REALNAME, nPropAttr, &m_sRealName, ::getCppuType( &m_sRealName ) );
     172           0 :     registerProperty( PROPERTY_LABEL, PROPERTY_ID_LABEL, nPropAttr, &m_sLabel, ::getCppuType( &m_sLabel ) );
     173             : 
     174             : 
     175           0 :     OSL_VERIFY( _rxParserColumn->getPropertyValue( PROPERTY_TYPENAME ) >>= m_aTypeName );
     176           0 :     OSL_VERIFY( _rxParserColumn->getPropertyValue( PROPERTY_ISNULLABLE ) >>= m_nIsNullable );
     177           0 :     OSL_VERIFY( _rxParserColumn->getPropertyValue( PROPERTY_PRECISION ) >>= m_nPrecision );
     178           0 :     OSL_VERIFY( _rxParserColumn->getPropertyValue( PROPERTY_SCALE ) >>= m_nScale );
     179           0 :     OSL_VERIFY( _rxParserColumn->getPropertyValue( PROPERTY_TYPE ) >>= m_nType );
     180           0 :     OSL_VERIFY( _rxParserColumn->getPropertyValue( PROPERTY_ISAUTOINCREMENT ) >>= m_bAutoIncrement );
     181           0 :     OSL_VERIFY( _rxParserColumn->getPropertyValue( PROPERTY_ISCURRENCY ) >>= m_bCurrency );
     182           0 :     OSL_VERIFY( _rxParserColumn->getPropertyValue( PROPERTY_NAME ) >>= m_sName );
     183             : 
     184           0 :     m_bRowVersion = false;
     185             : 
     186           0 :     Reference< XPropertySetInfo > xPSI( _rxParserColumn->getPropertySetInfo(), UNO_SET_THROW );
     187           0 :     if ( xPSI->hasPropertyByName( PROPERTY_DEFAULTVALUE ) )
     188           0 :         OSL_VERIFY( _rxParserColumn->getPropertyValue( PROPERTY_DEFAULTVALUE ) >>= m_aDefaultValue );
     189             : 
     190             :     // copy some optional properties from the parser column
     191           0 :     struct PropertyDescriptor
     192             :     {
     193             :         OUString sName;
     194             :         sal_Int32       nHandle;
     195             :     };
     196             :     PropertyDescriptor aProps[] =
     197             :     {
     198             :         { OUString(PROPERTY_CATALOGNAME),      PROPERTY_ID_CATALOGNAME },
     199             :         { OUString(PROPERTY_SCHEMANAME),       PROPERTY_ID_SCHEMANAME },
     200             :         { OUString(PROPERTY_TABLENAME),        PROPERTY_ID_TABLENAME },
     201             :         { OUString(PROPERTY_REALNAME),         PROPERTY_ID_REALNAME }
     202           0 :     };
     203           0 :     for ( size_t i=0; i < sizeof( aProps ) / sizeof( aProps[0] ); ++i )
     204             :     {
     205           0 :         if ( xPSI->hasPropertyByName( aProps[i].sName ) )
     206           0 :             setFastPropertyValue_NoBroadcast( aProps[i].nHandle, _rxParserColumn->getPropertyValue( aProps[i].sName ) );
     207             :     }
     208             : 
     209             :     // determine the table column we're based on
     210           0 :     osl_atomic_increment( &m_refCount );
     211             :     {
     212           0 :         m_xOriginalTableColumn = impl_determineOriginalTableColumn( _rxConnection );
     213             :     }
     214           0 :     osl_atomic_decrement( &m_refCount );
     215           0 : }
     216             : 
     217           0 : OQueryColumn::~OQueryColumn()
     218             : {
     219           0 : }
     220             : 
     221           0 : Reference< XPropertySet > OQueryColumn::impl_determineOriginalTableColumn( const Reference< XConnection >& _rxConnection )
     222             : {
     223             :     OSL_PRECOND( _rxConnection.is(), "OQueryColumn::impl_determineOriginalTableColumn: illegal connection!" );
     224           0 :     if ( !_rxConnection.is() )
     225           0 :         return NULL;
     226             : 
     227           0 :     Reference< XPropertySet > xOriginalTableColumn;
     228             :     try
     229             :     {
     230             :         // determine the composed table name, plus the column name, as indicated by the
     231             :         // respective properties
     232           0 :         OUString sCatalog, sSchema, sTable;
     233           0 :         OSL_VERIFY( getPropertyValue( PROPERTY_CATALOGNAME ) >>= sCatalog );
     234           0 :         OSL_VERIFY( getPropertyValue( PROPERTY_SCHEMANAME ) >>= sSchema );
     235           0 :         OSL_VERIFY( getPropertyValue( PROPERTY_TABLENAME ) >>= sTable );
     236           0 :         if ( sCatalog.isEmpty() && sSchema.isEmpty() && sTable.isEmpty() )
     237           0 :             return NULL;
     238             : 
     239             :         OUString sComposedTableName = ::dbtools::composeTableName(
     240           0 :             _rxConnection->getMetaData(), sCatalog, sSchema, sTable, false, ::dbtools::eComplete );
     241             : 
     242             :         // retrieve the table in question
     243           0 :         Reference< XTablesSupplier > xSuppTables( _rxConnection, UNO_QUERY_THROW );
     244           0 :         Reference< XNameAccess > xTables( xSuppTables->getTables(), UNO_QUERY_THROW );
     245           0 :         if ( !xTables->hasByName( sComposedTableName ) )
     246           0 :             return NULL;
     247             : 
     248           0 :         Reference< XColumnsSupplier > xSuppCols( xTables->getByName( sComposedTableName ), UNO_QUERY_THROW );
     249           0 :         Reference< XNameAccess > xColumns( xSuppCols->getColumns(), UNO_QUERY_THROW );
     250             : 
     251           0 :         OUString sColumn;
     252           0 :         OSL_VERIFY( getPropertyValue( PROPERTY_REALNAME ) >>= sColumn );
     253           0 :         if ( !xColumns->hasByName( sColumn ) )
     254           0 :             return NULL;
     255             : 
     256           0 :         xOriginalTableColumn.set( xColumns->getByName( sColumn ), UNO_QUERY );
     257             :     }
     258           0 :     catch( const Exception& )
     259             :     {
     260             :         DBG_UNHANDLED_EXCEPTION();
     261             :     }
     262           0 :     return xOriginalTableColumn;
     263             : }
     264             : 
     265           0 : IMPLEMENT_GET_IMPLEMENTATION_ID( OQueryColumn )
     266             : 
     267           0 : OUString SAL_CALL OQueryColumn::getImplementationName(  ) throw(RuntimeException, std::exception)
     268             : {
     269           0 :     return OUString( "org.openoffice.comp.dbaccess.OQueryColumn"  );
     270             : }
     271             : 
     272           0 : ::cppu::IPropertyArrayHelper& SAL_CALL OQueryColumn::getInfoHelper()
     273             : {
     274           0 :     return *OQueryColumn_PBase::getArrayHelper();
     275             : }
     276             : 
     277           0 : ::cppu::IPropertyArrayHelper* OQueryColumn::createArrayHelper() const
     278             : {
     279           0 :     return OTableColumnDescriptor::createArrayHelper();
     280             : }
     281             : 
     282           0 : void SAL_CALL OQueryColumn::getFastPropertyValue( Any& _rValue, sal_Int32 _nHandle ) const
     283             : {
     284           0 :     OTableColumnDescriptor::getFastPropertyValue( _rValue, _nHandle );
     285             : 
     286             :     // special treatment for column settings:
     287           0 :     if ( !OColumnSettings::isColumnSettingProperty( _nHandle ) )
     288           0 :         return;
     289             : 
     290             :     // If the setting has its default value, then try to obtain the value from the table column which
     291             :     // this query column is based on
     292           0 :     if ( !OColumnSettings::isDefaulted( _nHandle, _rValue ) )
     293           0 :         return;
     294             : 
     295           0 :     if ( !m_xOriginalTableColumn.is() )
     296           0 :         return;
     297             : 
     298             :     try
     299             :     {
     300             :         // determine original property name
     301           0 :         OUString sPropName;
     302           0 :         sal_Int16 nAttributes( 0 );
     303           0 :         const_cast< OQueryColumn* >( this )->getInfoHelper().fillPropertyMembersByHandle( &sPropName, &nAttributes, _nHandle );
     304             :         OSL_ENSURE( !sPropName.isEmpty(), "OColumnWrapper::impl_getPropertyNameFromHandle: property not found!" );
     305             : 
     306           0 :         _rValue = m_xOriginalTableColumn->getPropertyValue( sPropName );
     307             :     }
     308           0 :     catch( const Exception& )
     309             :     {
     310             :         DBG_UNHANDLED_EXCEPTION();
     311             :     }
     312             : }
     313             : 
     314             : // OColumnWrapper
     315             : 
     316        1530 : OColumnWrapper::OColumnWrapper( const Reference< XPropertySet > & rCol, const bool _bNameIsReadOnly )
     317             :     :OColumn( _bNameIsReadOnly )
     318             :     ,m_xAggregate(rCol)
     319        1530 :     ,m_nColTypeID(-1)
     320             : {
     321             :     // which type of aggregate property do we have?
     322             :     // we distinguish the properties by the containment of optional properties
     323        1530 :     m_nColTypeID = 0;
     324        1530 :     if ( m_xAggregate.is() )
     325             :     {
     326        1530 :         Reference <XPropertySetInfo > xInfo(m_xAggregate->getPropertySetInfo());
     327        1530 :         m_nColTypeID |= xInfo->hasPropertyByName(PROPERTY_DESCRIPTION) ? HAS_DESCRIPTION : 0;
     328        1530 :         m_nColTypeID |= xInfo->hasPropertyByName(PROPERTY_DEFAULTVALUE) ? HAS_DEFAULTVALUE : 0;
     329        1530 :         m_nColTypeID |= xInfo->hasPropertyByName(PROPERTY_ISROWVERSION) ? HAS_ROWVERSION : 0;
     330        1530 :         m_nColTypeID |= xInfo->hasPropertyByName(PROPERTY_AUTOINCREMENTCREATION) ? HAS_AUTOINCREMENT_CREATION : 0;
     331        1530 :         m_nColTypeID |= xInfo->hasPropertyByName(PROPERTY_CATALOGNAME) ? HAS_CATALOGNAME : 0;
     332        1530 :         m_nColTypeID |= xInfo->hasPropertyByName(PROPERTY_SCHEMANAME) ? HAS_SCHEMANAME : 0;
     333        1530 :         m_nColTypeID |= xInfo->hasPropertyByName(PROPERTY_TABLENAME) ? HAS_TABLENAME : 0;
     334             : 
     335        1530 :         m_xAggregate->getPropertyValue(PROPERTY_NAME) >>= m_sName;
     336             :     }
     337        1530 : }
     338             : 
     339        1524 : OColumnWrapper::~OColumnWrapper()
     340             : {
     341        1524 : }
     342             : 
     343       46514 : OUString OColumnWrapper::impl_getPropertyNameFromHandle( const sal_Int32 _nHandle ) const
     344             : {
     345       46514 :     OUString sPropName;
     346       46514 :     sal_Int16 nAttributes( 0 );
     347       46514 :     const_cast< OColumnWrapper* >( this )->getInfoHelper().fillPropertyMembersByHandle( &sPropName, &nAttributes, _nHandle );
     348             :     OSL_ENSURE( !sPropName.isEmpty(), "OColumnWrapper::impl_getPropertyNameFromHandle: property not found!" );
     349       46514 :     return sPropName;
     350             : }
     351             : 
     352       37206 : void OColumnWrapper::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) const
     353             : {
     354             :     // derived classes are free to either use the OPropertyContainer(Helper) mechanisms for properties,
     355             :     // or to declare additional properties which are to be forwarded to the wrapped object. So we need
     356             :     // to distinguish those cases.
     357       37206 :     if ( OColumn::isRegisteredProperty( nHandle ) )
     358             :     {
     359        4388 :         OColumn::getFastPropertyValue( rValue, nHandle );
     360             :     }
     361             :     else
     362             :     {
     363       32818 :         rValue = m_xAggregate->getPropertyValue( impl_getPropertyNameFromHandle( nHandle ) );
     364             :     }
     365       37206 : }
     366             : 
     367        4192 : sal_Bool OColumnWrapper::convertFastPropertyValue( Any & rConvertedValue, Any & rOldValue, sal_Int32 nHandle,
     368             :             const Any& rValue ) throw (IllegalArgumentException)
     369             : {
     370        4192 :     bool bModified( false );
     371        4192 :     if ( OColumn::isRegisteredProperty( nHandle ) )
     372             :     {
     373        4192 :         bModified = OColumn::convertFastPropertyValue( rConvertedValue, rOldValue, nHandle, rValue );
     374             :     }
     375             :     else
     376             :     {
     377           0 :         getFastPropertyValue( rOldValue, nHandle );
     378           0 :         if ( rOldValue != rValue )
     379             :         {
     380           0 :             rConvertedValue = rValue;
     381           0 :             bModified = true;
     382             :         }
     383             :     }
     384        4192 :     return bModified;
     385             : }
     386             : 
     387         364 : void OColumnWrapper::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const Any& rValue ) throw (Exception, std::exception)
     388             : {
     389         364 :     if ( OColumn::isRegisteredProperty( nHandle ) )
     390             :     {
     391         364 :         OColumn::setFastPropertyValue_NoBroadcast( nHandle, rValue );
     392             :     }
     393             :     else
     394             :     {
     395           0 :         m_xAggregate->setPropertyValue( impl_getPropertyNameFromHandle( nHandle ), rValue );
     396             :     }
     397         364 : }
     398             : 
     399           0 : sal_Int64 SAL_CALL OColumnWrapper::getSomething( const Sequence< sal_Int8 >& aIdentifier ) throw(RuntimeException)
     400             : {
     401           0 :     Reference< XUnoTunnel > xTunnel( m_xAggregate, UNO_QUERY);
     402           0 :     if ( xTunnel.is() )
     403           0 :         return xTunnel->getSomething( aIdentifier );
     404           0 :     return 0;
     405             : }
     406             : 
     407             : // OTableColumnDescriptorWrapper
     408        1530 : OTableColumnDescriptorWrapper::OTableColumnDescriptorWrapper( const Reference< XPropertySet >& _rCol, const bool _bPureWrap, const bool _bIsDescriptor )
     409        1530 :     :OColumnWrapper( _rCol, !_bIsDescriptor )
     410             :     ,m_bPureWrap( _bPureWrap )
     411        1530 :     ,m_bIsDescriptor( _bIsDescriptor )
     412             : {
     413             :     // let the ColumnSettings register its properties
     414        1530 :     OColumnSettings::registerProperties( *this );
     415        1530 : }
     416             : 
     417             : // com::sun::star::lang::XTypeProvider
     418           0 : IMPLEMENT_GET_IMPLEMENTATION_ID( OTableColumnDescriptorWrapper )
     419             : 
     420             : // ::com::sun::star::lang::XServiceInfo
     421           0 : OUString OTableColumnDescriptorWrapper::getImplementationName(  ) throw (RuntimeException, std::exception)
     422             : {
     423           0 :     return OUString("com.sun.star.sdb.OTableColumnDescriptorWrapper");
     424             : }
     425             : 
     426           0 : Sequence< OUString > OTableColumnDescriptorWrapper::getSupportedServiceNames(  ) throw (RuntimeException, std::exception)
     427             : {
     428           0 :     Sequence< OUString > aSNS( 2 );
     429           0 :     aSNS[0] = SERVICE_SDBCX_COLUMNDESCRIPTOR;
     430           0 :     aSNS[1] = SERVICE_SDB_COLUMNSETTINGS;
     431           0 :     return aSNS;
     432             : }
     433             : 
     434             : // comphelper::OPropertyArrayUsageHelper
     435         552 : ::cppu::IPropertyArrayHelper* OTableColumnDescriptorWrapper::createArrayHelper( sal_Int32 nId ) const
     436             : {
     437         552 :     const sal_Int32 nHaveAlways = 7;
     438             : 
     439             :     // Which optional properties are contained?
     440         552 :     const sal_Int32 nHaveOptionally (::std::bitset<7>(nId).count());
     441             : 
     442         552 :     BEGIN_PROPERTY_SEQUENCE( nHaveAlways + nHaveOptionally )
     443             : 
     444         552 :     DECL_PROP0_BOOL( ISAUTOINCREMENT                );
     445         552 :     DECL_PROP0_BOOL( ISCURRENCY                     );
     446         552 :     DECL_PROP0( ISNULLABLE,         sal_Int32       );
     447         552 :     DECL_PROP0( PRECISION,          sal_Int32       );
     448         552 :     DECL_PROP0( SCALE,              sal_Int32       );
     449         552 :     DECL_PROP0( TYPE,               sal_Int32       );
     450         552 :     DECL_PROP0( TYPENAME,           OUString );
     451             : 
     452         552 :     if ( nId & HAS_AUTOINCREMENT_CREATION )
     453             :     {
     454         514 :         DECL_PROP1( AUTOINCREMENTCREATION, OUString, MAYBEVOID );
     455             :     }
     456         552 :     if ( nId & HAS_DEFAULTVALUE )
     457             :     {
     458         552 :         DECL_PROP0( DEFAULTVALUE, OUString );
     459             :     }
     460         552 :     if ( nId & HAS_DESCRIPTION )
     461             :     {
     462         552 :         DECL_PROP0( DESCRIPTION, OUString );
     463             :     }
     464         552 :     if ( nId & HAS_ROWVERSION )
     465             :     {
     466         552 :         DECL_PROP0_BOOL( ISROWVERSION );
     467             :     }
     468         552 :     if ( nId & HAS_CATALOGNAME )
     469             :     {
     470          38 :         DECL_PROP0( CATALOGNAME, OUString );
     471             :     }
     472         552 :     if ( nId & HAS_SCHEMANAME )
     473             :     {
     474          38 :         DECL_PROP0( SCHEMANAME, OUString );
     475             :     }
     476         552 :     if ( nId & HAS_TABLENAME )
     477             :     {
     478          38 :         DECL_PROP0( TABLENAME, OUString );
     479             :     }
     480             : 
     481             :     END_PROPERTY_SEQUENCE()
     482             : 
     483         552 :     if ( !m_bIsDescriptor )
     484             :     {
     485       13400 :         for (   Property* prop = aDescriptor.getArray();
     486        6700 :                 prop != aDescriptor.getArray() + aDescriptor.getLength();
     487             :                 ++prop
     488             :             )
     489             :         {
     490        6148 :             prop->Attributes |= PropertyAttribute::READONLY;
     491             :         }
     492             :     }
     493             : 
     494             :     // finally also describe the properties which are maintained by our base class, in particular the OPropertyContainerHelper
     495        1104 :     Sequence< Property > aBaseProperties;
     496         552 :     describeProperties( aBaseProperties );
     497             : 
     498        1104 :     Sequence< Property > aAllProperties( ::comphelper::concatSequences( aDescriptor, aBaseProperties ) );
     499        1104 :     return new ::cppu::OPropertyArrayHelper( aAllProperties, sal_False );
     500             : }
     501             : 
     502             : // cppu::OPropertySetHelper
     503           0 : ::cppu::IPropertyArrayHelper& OTableColumnDescriptorWrapper::getInfoHelper()
     504             : {
     505           0 :     return *static_cast< OIdPropertyArrayUsageHelper< OTableColumnDescriptorWrapper >* >(this)->getArrayHelper(m_nColTypeID);
     506             : }
     507             : 
     508       41398 : void OTableColumnDescriptorWrapper::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) const
     509             : {
     510       41398 :     if ( m_bPureWrap )
     511             :     {
     512        4192 :         rValue = m_xAggregate->getPropertyValue( impl_getPropertyNameFromHandle( nHandle ) );
     513             :     }
     514             :     else
     515             :     {
     516       37206 :         OColumnWrapper::getFastPropertyValue( rValue, nHandle );
     517             :     }
     518       41398 : }
     519             : 
     520       13024 : sal_Bool OTableColumnDescriptorWrapper::convertFastPropertyValue( Any & rConvertedValue, Any & rOldValue, sal_Int32 nHandle, const Any& rValue ) throw (IllegalArgumentException)
     521             : {
     522       13024 :     bool bModified(false);
     523       13024 :     if ( m_bPureWrap )
     524             :     {
     525             :         // do not delegate to OColumnWrapper: It would, for the properties which were registered with registerProperty,
     526             :         // ask the OPropertyContainer base class, which is not what we want here.
     527             :         // TODO: the whole "m_bPureWrap"-thingie is strange. We should have a dedicated class doing this wrapping,
     528             :         // not a class which normally serves other purposes, and only sometimes does a "pure wrap". It makes the
     529             :         // code unnecessarily hard to maintain, and error prone.
     530        8832 :         rOldValue = m_xAggregate->getPropertyValue( impl_getPropertyNameFromHandle( nHandle ) );
     531        8832 :         if ( rOldValue != rValue )
     532             :         {
     533         672 :             rConvertedValue = rValue;
     534         672 :             bModified = true;
     535             :         }
     536             :     }
     537             :     else
     538             :     {
     539        4192 :         bModified = OColumnWrapper::convertFastPropertyValue( rConvertedValue, rOldValue, nHandle, rValue );
     540             :     }
     541       13024 :     return bModified;
     542             : }
     543             : 
     544        1036 : void OTableColumnDescriptorWrapper::setFastPropertyValue_NoBroadcast(
     545             :                                                 sal_Int32 nHandle,
     546             :                                                 const Any& rValue
     547             :                                                  )
     548             :                                                  throw (Exception, std::exception)
     549             : {
     550        1036 :     if ( m_bPureWrap )
     551             :     {
     552         672 :         m_xAggregate->setPropertyValue( impl_getPropertyNameFromHandle( nHandle ), rValue );
     553             :     }
     554             :     else
     555             :     {
     556         364 :         OColumnWrapper::setFastPropertyValue_NoBroadcast( nHandle, rValue );
     557             :     }
     558        1036 : }
     559             : 
     560             : // OTableColumnWrapper
     561        1530 : OTableColumnWrapper::OTableColumnWrapper( const Reference< XPropertySet >& rCol, const Reference< XPropertySet >& _xColDefintion,
     562             :             const bool _bPureWrap )
     563        1530 :     :OTableColumnDescriptorWrapper( rCol, _bPureWrap, false )
     564             : {
     565        1530 :     osl_atomic_increment( &m_refCount );
     566        1530 :     if ( _xColDefintion.is() )
     567             :     {
     568             :         try
     569             :         {
     570        1282 :             ::comphelper::copyProperties( _xColDefintion, this );
     571             :         }
     572           0 :         catch( const Exception& )
     573             :         {
     574             :             DBG_UNHANDLED_EXCEPTION();
     575             :         }
     576             :     }
     577        1530 :     osl_atomic_decrement( &m_refCount );
     578        1530 : }
     579             : 
     580        3048 : OTableColumnWrapper::~OTableColumnWrapper()
     581             : {
     582        3048 : }
     583             : 
     584           0 : IMPLEMENT_GET_IMPLEMENTATION_ID( OTableColumnWrapper )
     585             : 
     586           0 : OUString OTableColumnWrapper::getImplementationName(  ) throw (RuntimeException, std::exception)
     587             : {
     588           0 :     return OUString("com.sun.star.sdb.OTableColumnWrapper" );
     589             : }
     590             : 
     591           0 : Sequence< OUString > OTableColumnWrapper::getSupportedServiceNames(  ) throw (RuntimeException, std::exception)
     592             : {
     593           0 :     Sequence< OUString > aSNS( 2 );
     594           0 :     aSNS[0] = SERVICE_SDBCX_COLUMN;
     595           0 :     aSNS[1] = SERVICE_SDB_COLUMNSETTINGS;
     596           0 :     return aSNS;
     597             : }
     598             : 
     599      165534 : ::cppu::IPropertyArrayHelper& OTableColumnWrapper::getInfoHelper()
     600             : {
     601      165534 :     return *static_cast< OIdPropertyArrayUsageHelper< OTableColumnWrapper >* >(this)->getArrayHelper(m_nColTypeID);
     602             : }
     603             : 
     604             : // comphelper::OPropertyArrayUsageHelper
     605         552 : ::cppu::IPropertyArrayHelper* OTableColumnWrapper::createArrayHelper( sal_Int32 nId ) const
     606             : {
     607         552 :     return OTableColumnDescriptorWrapper::createArrayHelper( nId );
     608             : }
     609             : 
     610             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10