LCOV - code coverage report
Current view: top level - libreoffice/dbaccess/source/core/api - CRowSetDataColumn.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 112 0.0 %
Date: 2012-12-27 Functions: 0 17 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : 
      21             : #include "CRowSetDataColumn.hxx"
      22             : #include "dbastrings.hrc"
      23             : #include "apitools.hxx"
      24             : #include <comphelper/types.hxx>
      25             : #include <cppuhelper/typeprovider.hxx>
      26             : #include <com/sun/star/beans/PropertyAttribute.hpp>
      27             : #include <tools/debug.hxx>
      28             : 
      29             : using namespace dbaccess;
      30             : using namespace comphelper;
      31             : using namespace connectivity;
      32             : using namespace ::com::sun::star::uno;
      33             : using namespace ::com::sun::star::beans;
      34             : using namespace ::com::sun::star::sdbc;
      35             : using namespace ::com::sun::star::container;
      36             : using namespace ::com::sun::star::lang;
      37             : using namespace ::com::sun::star::util;
      38             : using namespace cppu;
      39             : using namespace osl;
      40             : 
      41             : DBG_NAME(ORowSetDataColumn)
      42             : 
      43           0 : ORowSetDataColumn::ORowSetDataColumn(   const Reference < XResultSetMetaData >& _xMetaData,
      44             :                                       const Reference < XRow >& _xRow,
      45             :                                       const Reference < XRowUpdate >& _xRowUpdate,
      46             :                                       sal_Int32 _nPos,
      47             :                                       const Reference< XDatabaseMetaData >& _rxDBMeta,
      48             :                                       const ::rtl::OUString& _rDescription,
      49             :                                       const ::rtl::OUString& i_sLabel,
      50             :                                       const ORowSetCacheIterator& _rColumnValue)
      51             :     :ODataColumn(_xMetaData,_xRow,_xRowUpdate,_nPos,_rxDBMeta)
      52             :     ,m_aColumnValue(_rColumnValue)
      53             :     ,m_sLabel(i_sLabel)
      54           0 :     ,m_aDescription(_rDescription)
      55             : {
      56             :     DBG_CTOR(ORowSetDataColumn,NULL);
      57           0 :     OColumnSettings::registerProperties( *this );
      58           0 :     registerProperty( PROPERTY_DESCRIPTION, PROPERTY_ID_DESCRIPTION, PropertyAttribute::READONLY, &m_aDescription, ::getCppuType( &m_aDescription ) );
      59           0 : }
      60             : 
      61           0 : ORowSetDataColumn::~ORowSetDataColumn()
      62             : {
      63             :     DBG_DTOR(ORowSetDataColumn,NULL);
      64           0 : }
      65             : 
      66             : // comphelper::OPropertyArrayUsageHelper
      67           0 : ::cppu::IPropertyArrayHelper* ORowSetDataColumn::createArrayHelper( ) const
      68             : {
      69           0 :     BEGIN_PROPERTY_SEQUENCE(21)
      70             : 
      71           0 :     DECL_PROP1( CATALOGNAME,                ::rtl::OUString,    READONLY );
      72           0 :     DECL_PROP1( DISPLAYSIZE,                sal_Int32,          READONLY );
      73           0 :     DECL_PROP1_BOOL( ISAUTOINCREMENT,                           READONLY );
      74           0 :     DECL_PROP1_BOOL( ISCASESENSITIVE,                           READONLY );
      75           0 :     DECL_PROP1_BOOL( ISCURRENCY,                                READONLY );
      76           0 :     DECL_PROP1_BOOL( ISDEFINITELYWRITABLE,                      READONLY );
      77           0 :     DECL_PROP1( ISNULLABLE,                 sal_Int32,          READONLY );
      78           0 :     DECL_PROP1_BOOL( ISREADONLY,                                BOUND );
      79           0 :     DECL_PROP1_BOOL( ISROWVERSION,                              READONLY );
      80           0 :     DECL_PROP1_BOOL( ISSEARCHABLE,                              READONLY );
      81           0 :     DECL_PROP1_BOOL( ISSIGNED,                                  READONLY );
      82           0 :     DECL_PROP1_BOOL( ISWRITABLE,                                READONLY );
      83           0 :     DECL_PROP1( LABEL,                      ::rtl::OUString,    READONLY );
      84           0 :     DECL_PROP1( PRECISION,                  sal_Int32,          READONLY );
      85           0 :     DECL_PROP1( SCALE,                      sal_Int32,          READONLY );
      86           0 :     DECL_PROP1( SCHEMANAME,                 ::rtl::OUString,    READONLY );
      87           0 :     DECL_PROP1( SERVICENAME,                ::rtl::OUString,    READONLY );
      88           0 :     DECL_PROP1( TABLENAME,                  ::rtl::OUString,    READONLY );
      89           0 :     DECL_PROP1( TYPE,                       sal_Int32,          READONLY );
      90           0 :     DECL_PROP1( TYPENAME,                   ::rtl::OUString,    READONLY );
      91           0 :     DECL_PROP1( VALUE,                      Any,                BOUND );
      92             : 
      93             :     END_PROPERTY_SEQUENCE()
      94             : 
      95           0 :     Sequence< Property > aRegisteredProperties;
      96           0 :     describeProperties( aRegisteredProperties );
      97             : 
      98           0 :     return new ::cppu::OPropertyArrayHelper( ::comphelper::concatSequences( aDescriptor, aRegisteredProperties ), sal_False );
      99             : }
     100             : 
     101             : // cppu::OPropertySetHelper
     102           0 : ::cppu::IPropertyArrayHelper& ORowSetDataColumn::getInfoHelper()
     103             : {
     104           0 :     return *static_cast< ::comphelper::OPropertyArrayUsageHelper< ORowSetDataColumn >* >(this)->getArrayHelper();
     105             : }
     106             : 
     107           0 : void SAL_CALL ORowSetDataColumn::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) const
     108             : {
     109           0 :     if ( PROPERTY_ID_VALUE == nHandle )
     110             :     {
     111           0 :         if ( !m_aColumnValue.isNull() && m_aColumnValue->is() )
     112             :         {
     113           0 :             ::osl::Mutex* pMutex = m_aColumnValue.getMutex();
     114           0 :             ::osl::MutexGuard aGuard( *pMutex );
     115             : #if OSL_DEBUG_LEVEL > 0
     116             :             ORowSetRow aRow = *m_aColumnValue;
     117             : #endif
     118             :             OSL_ENSURE((sal_Int32)aRow->get().size() > m_nPos,"Pos is greater than size of vector");
     119           0 :             rValue = ((*m_aColumnValue)->get())[m_nPos].makeAny();
     120             :         }
     121             :     }
     122           0 :     else if ( PROPERTY_ID_LABEL == nHandle && !m_sLabel.isEmpty() )
     123           0 :         rValue <<= m_sLabel;
     124             :     else
     125           0 :         ODataColumn::getFastPropertyValue( rValue, nHandle );
     126           0 : }
     127             : 
     128           0 : void SAL_CALL ORowSetDataColumn::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& rValue )throw (Exception)
     129             : {
     130           0 :     switch( nHandle )
     131             :     {
     132             :         case PROPERTY_ID_VALUE:
     133           0 :             updateObject(rValue);
     134           0 :             break;
     135             :         case PROPERTY_ID_ISREADONLY:
     136             :             {
     137           0 :                 sal_Bool bVal = sal_False;
     138           0 :                 rValue >>= bVal;
     139           0 :                 m_isReadOnly.reset(bVal);
     140             :             }
     141           0 :             break;
     142             :         default:
     143           0 :             ODataColumn::setFastPropertyValue_NoBroadcast( nHandle,rValue );
     144           0 :             break;
     145             :     }
     146           0 : }
     147             : 
     148           0 : sal_Bool SAL_CALL ORowSetDataColumn::convertFastPropertyValue( Any & rConvertedValue,
     149             :                                                             Any & rOldValue,
     150             :                                                             sal_Int32 nHandle,
     151             :                                                             const Any& rValue ) throw (IllegalArgumentException)
     152             : {
     153           0 :     sal_Bool bModified = sal_False;
     154           0 :     switch( nHandle )
     155             :     {
     156             :         case PROPERTY_ID_VALUE:
     157             :             {
     158           0 :                 rConvertedValue = rValue;
     159           0 :                 getFastPropertyValue(rOldValue, PROPERTY_ID_VALUE);
     160           0 :                 bModified = rConvertedValue != rOldValue;
     161             :             }
     162           0 :             break;
     163             :         case PROPERTY_ID_ISREADONLY:
     164             :             {
     165           0 :                 rConvertedValue = rValue;
     166           0 :                 getFastPropertyValue(rOldValue, PROPERTY_ID_ISREADONLY);
     167           0 :                 bModified = rConvertedValue != rOldValue;
     168             :             }
     169           0 :             break;
     170             :         default:
     171           0 :             bModified = ODataColumn::convertFastPropertyValue(rConvertedValue, rOldValue, nHandle, rValue);
     172           0 :             break;
     173             :     }
     174             : 
     175           0 :     return bModified;
     176             : }
     177             : 
     178           0 : Sequence< sal_Int8 > ORowSetDataColumn::getImplementationId() throw (RuntimeException)
     179             : {
     180             :     static OImplementationId * pId = 0;
     181           0 :     if (! pId)
     182             :     {
     183           0 :         MutexGuard aGuard( Mutex::getGlobalMutex() );
     184           0 :         if (! pId)
     185             :         {
     186           0 :             static OImplementationId aId;
     187           0 :             pId = &aId;
     188           0 :         }
     189             :     }
     190           0 :     return pId->getImplementationId();
     191             : }
     192             : 
     193           0 : void ORowSetDataColumn::fireValueChange(const ORowSetValue& _rOldValue)
     194             : {
     195           0 :     if ( !m_aColumnValue.isNull() && m_aColumnValue->is() && (((*m_aColumnValue)->get())[m_nPos] != _rOldValue) )
     196             :     {
     197           0 :         sal_Int32 nHandle = PROPERTY_ID_VALUE;
     198           0 :         m_aOldValue = _rOldValue.makeAny();
     199           0 :         Any aNew = ((*m_aColumnValue)->get())[m_nPos].makeAny();
     200             : 
     201           0 :         fire(&nHandle, &aNew, &m_aOldValue, 1, sal_False );
     202             :     }
     203           0 :     else if ( !m_aColumnValue.isNull() && !_rOldValue.isNull() )
     204             :     {
     205           0 :         sal_Int32 nHandle = PROPERTY_ID_VALUE;
     206           0 :         m_aOldValue = _rOldValue.makeAny();
     207           0 :         Any aNew;
     208             : 
     209           0 :         fire(&nHandle, &aNew, &m_aOldValue, 1, sal_False );
     210             :     }
     211           0 : }
     212             : 
     213             : DBG_NAME(ORowSetDataColumns )
     214           0 : ORowSetDataColumns::ORowSetDataColumns(
     215             :                 sal_Bool _bCase,
     216             :                 const ::rtl::Reference< ::connectivity::OSQLColumns>& _rColumns,
     217             :                 ::cppu::OWeakObject& _rParent,
     218             :                 ::osl::Mutex& _rMutex,
     219             :                 const ::std::vector< ::rtl::OUString> &_rVector
     220             :                 ) : connectivity::sdbcx::OCollection(_rParent,_bCase,_rMutex,_rVector)
     221           0 :                 ,m_aColumns(_rColumns)
     222             : {
     223             :     DBG_CTOR(ORowSetDataColumns ,NULL);
     224           0 : }
     225             : 
     226           0 : ORowSetDataColumns::~ORowSetDataColumns()
     227             : {
     228             :     DBG_DTOR(ORowSetDataColumns ,NULL);
     229           0 : }
     230             : 
     231           0 : sdbcx::ObjectType ORowSetDataColumns::createObject(const ::rtl::OUString& _rName)
     232             : {
     233           0 :     connectivity::sdbcx::ObjectType xNamed;
     234             : 
     235           0 :     ::comphelper::UStringMixEqual aCase(isCaseSensitive());
     236           0 :     ::connectivity::OSQLColumns::Vector::const_iterator first =  ::connectivity::find(m_aColumns->get().begin(),m_aColumns->get().end(),_rName,aCase);
     237           0 :     if(first != m_aColumns->get().end())
     238           0 :         xNamed.set(*first,UNO_QUERY);
     239             : 
     240           0 :     return xNamed;
     241             : }
     242             : 
     243           0 : void SAL_CALL ORowSetDataColumns::disposing(void)
     244             : {
     245           0 :     ORowSetDataColumns_BASE::disposing();
     246           0 :     m_aColumns = NULL;
     247           0 : }
     248             : 
     249           0 : void ORowSetDataColumns::assign(const ::rtl::Reference< ::connectivity::OSQLColumns>& _rColumns,const ::std::vector< ::rtl::OUString> &_rVector)
     250             : {
     251           0 :     m_aColumns = _rColumns;
     252           0 :     reFill(_rVector);
     253           0 : }
     254             : 
     255           0 : void ORowSetDataColumns::impl_refresh() throw(::com::sun::star::uno::RuntimeException)
     256             : {
     257           0 : }
     258             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10