LCOV - code coverage report
Current view: top level - dbaccess/source/core/api - CRowSetDataColumn.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 91 102 89.2 %
Date: 2014-11-03 Functions: 15 17 88.2 %
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/exc_hlp.hxx>
      26             : #include <cppuhelper/typeprovider.hxx>
      27             : #include <com/sun/star/beans/PropertyAttribute.hpp>
      28             : #include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
      29             : #include <tools/debug.hxx>
      30             : 
      31             : using namespace dbaccess;
      32             : using namespace comphelper;
      33             : using namespace connectivity;
      34             : using namespace ::com::sun::star::uno;
      35             : using namespace ::com::sun::star::beans;
      36             : using namespace ::com::sun::star::sdbc;
      37             : using namespace ::com::sun::star::container;
      38             : using namespace ::com::sun::star::lang;
      39             : using namespace ::com::sun::star::util;
      40             : using namespace cppu;
      41             : using namespace osl;
      42             : 
      43             : 
      44         582 : ORowSetDataColumn::ORowSetDataColumn( const Reference < XResultSetMetaData >& _xMetaData,
      45             :                                       const Reference < XRow >& _xRow,
      46             :                                       const Reference < XRowUpdate >& _xRowUpdate,
      47             :                                       sal_Int32 _nPos,
      48             :                                       const Reference< XDatabaseMetaData >& _rxDBMeta,
      49             :                                       const OUString& _rDescription,
      50             :                                       const OUString& i_sLabel,
      51             :                                       const boost::function< const ORowSetValue& (sal_Int32)> &_getValue)
      52             :     :ODataColumn(_xMetaData,_xRow,_xRowUpdate,_nPos,_rxDBMeta)
      53             :     ,m_pGetValue(_getValue)
      54             :     ,m_sLabel(i_sLabel)
      55         582 :     ,m_aDescription(_rDescription)
      56             : {
      57         582 :     OColumnSettings::registerProperties( *this );
      58         582 :     registerProperty( PROPERTY_DESCRIPTION, PROPERTY_ID_DESCRIPTION, PropertyAttribute::READONLY, &m_aDescription, ::getCppuType( &m_aDescription ) );
      59         582 : }
      60             : 
      61        1080 : ORowSetDataColumn::~ORowSetDataColumn()
      62             : {
      63        1080 : }
      64             : 
      65             : // comphelper::OPropertyArrayUsageHelper
      66          40 : ::cppu::IPropertyArrayHelper* ORowSetDataColumn::createArrayHelper( ) const
      67             : {
      68          40 :     BEGIN_PROPERTY_SEQUENCE(21)
      69             : 
      70          40 :     DECL_PROP1( CATALOGNAME,                OUString,    READONLY );
      71          40 :     DECL_PROP1( DISPLAYSIZE,                sal_Int32,          READONLY );
      72          40 :     DECL_PROP1_BOOL( ISAUTOINCREMENT,                           READONLY );
      73          40 :     DECL_PROP1_BOOL( ISCASESENSITIVE,                           READONLY );
      74          40 :     DECL_PROP1_BOOL( ISCURRENCY,                                READONLY );
      75          40 :     DECL_PROP1_BOOL( ISDEFINITELYWRITABLE,                      READONLY );
      76          40 :     DECL_PROP1( ISNULLABLE,                 sal_Int32,          READONLY );
      77          40 :     DECL_PROP1_BOOL( ISREADONLY,                                BOUND );
      78          40 :     DECL_PROP1_BOOL( ISROWVERSION,                              READONLY );
      79          40 :     DECL_PROP1_BOOL( ISSEARCHABLE,                              READONLY );
      80          40 :     DECL_PROP1_BOOL( ISSIGNED,                                  READONLY );
      81          40 :     DECL_PROP1_BOOL( ISWRITABLE,                                READONLY );
      82          40 :     DECL_PROP1( LABEL,                      OUString,    READONLY );
      83          40 :     DECL_PROP1( PRECISION,                  sal_Int32,          READONLY );
      84          40 :     DECL_PROP1( SCALE,                      sal_Int32,          READONLY );
      85          40 :     DECL_PROP1( SCHEMANAME,                 OUString,    READONLY );
      86          40 :     DECL_PROP1( SERVICENAME,                OUString,    READONLY );
      87          40 :     DECL_PROP1( TABLENAME,                  OUString,    READONLY );
      88          40 :     DECL_PROP1( TYPE,                       sal_Int32,          READONLY );
      89          40 :     DECL_PROP1( TYPENAME,                   OUString,    READONLY );
      90          40 :     DECL_PROP1( VALUE,                      Any,                BOUND );
      91             : 
      92             :     END_PROPERTY_SEQUENCE()
      93             : 
      94          80 :     Sequence< Property > aRegisteredProperties;
      95          40 :     describeProperties( aRegisteredProperties );
      96             : 
      97          80 :     return new ::cppu::OPropertyArrayHelper( ::comphelper::concatSequences( aDescriptor, aRegisteredProperties ), sal_False );
      98             : }
      99             : 
     100             : // cppu::OPropertySetHelper
     101       18242 : ::cppu::IPropertyArrayHelper& ORowSetDataColumn::getInfoHelper()
     102             : {
     103       18242 :     return *static_cast< ::comphelper::OPropertyArrayUsageHelper< ORowSetDataColumn >* >(this)->getArrayHelper();
     104             : }
     105             : 
     106        4675 : void SAL_CALL ORowSetDataColumn::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) const
     107             : {
     108        4675 :     if ( PROPERTY_ID_VALUE == nHandle )
     109             :     {
     110             :         try
     111             :         {
     112          10 :             rValue = m_pGetValue(m_nPos).makeAny();
     113             :         }
     114           4 :         catch(const SQLException &e)
     115             :         {
     116           8 :             throw WrappedTargetRuntimeException("Could not retrieve column value: " + e.Message,
     117             :                                                 *const_cast<ORowSetDataColumn*>(this),
     118          12 :                                                 Any(e));
     119             :         }
     120             :     }
     121        4665 :     else if ( PROPERTY_ID_LABEL == nHandle && !m_sLabel.isEmpty() )
     122           0 :         rValue <<= m_sLabel;
     123             :     else
     124        4665 :         ODataColumn::getFastPropertyValue( rValue, nHandle );
     125        4671 : }
     126             : 
     127        2000 : void SAL_CALL ORowSetDataColumn::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& rValue )throw (Exception, std::exception)
     128             : {
     129        2000 :     switch( nHandle )
     130             :     {
     131             :         case PROPERTY_ID_VALUE:
     132           0 :             updateObject(rValue);
     133           0 :             break;
     134             :         case PROPERTY_ID_ISREADONLY:
     135             :             {
     136         498 :                 bool bVal = false;
     137         498 :                 rValue >>= bVal;
     138         498 :                 m_isReadOnly.reset(bVal);
     139             :             }
     140         498 :             break;
     141             :         default:
     142        1502 :             ODataColumn::setFastPropertyValue_NoBroadcast( nHandle,rValue );
     143        1502 :             break;
     144             :     }
     145        2000 : }
     146             : 
     147        4606 : sal_Bool SAL_CALL ORowSetDataColumn::convertFastPropertyValue( Any & rConvertedValue,
     148             :                                                             Any & rOldValue,
     149             :                                                             sal_Int32 nHandle,
     150             :                                                             const Any& rValue ) throw (IllegalArgumentException)
     151             : {
     152        4606 :     bool bModified = false;
     153        4606 :     switch( nHandle )
     154             :     {
     155             :         case PROPERTY_ID_VALUE:
     156             :             {
     157           0 :                 rConvertedValue = rValue;
     158           0 :                 getFastPropertyValue(rOldValue, PROPERTY_ID_VALUE);
     159           0 :                 bModified = rConvertedValue != rOldValue;
     160             :             }
     161           0 :             break;
     162             :         case PROPERTY_ID_ISREADONLY:
     163             :             {
     164         124 :                 rConvertedValue = rValue;
     165         124 :                 getFastPropertyValue(rOldValue, PROPERTY_ID_ISREADONLY);
     166         124 :                 bModified = rConvertedValue != rOldValue;
     167             :             }
     168         124 :             break;
     169             :         default:
     170        4482 :             bModified = ODataColumn::convertFastPropertyValue(rConvertedValue, rOldValue, nHandle, rValue);
     171        4482 :             break;
     172             :     }
     173             : 
     174        4606 :     return bModified;
     175             : }
     176             : 
     177           0 : Sequence< sal_Int8 > ORowSetDataColumn::getImplementationId() throw (RuntimeException, std::exception)
     178             : {
     179           0 :     return css::uno::Sequence<sal_Int8>();
     180             : }
     181             : 
     182        3474 : void ORowSetDataColumn::fireValueChange(const ORowSetValue& _rOldValue)
     183             : {
     184        3474 :     const ORowSetValue &value(m_pGetValue(m_nPos));
     185        3048 :     if ( value != _rOldValue)
     186             :     {
     187         914 :         sal_Int32 nHandle(PROPERTY_ID_VALUE);
     188         914 :         m_aOldValue = _rOldValue.makeAny();
     189         914 :         Any aNew = value.makeAny();
     190             : 
     191         914 :         fire(&nHandle, &aNew, &m_aOldValue, 1, sal_False );
     192             :     }
     193        3048 : }
     194             : 
     195          38 : ORowSetDataColumns::ORowSetDataColumns(
     196             :                 bool _bCase,
     197             :                 const ::rtl::Reference< ::connectivity::OSQLColumns>& _rColumns,
     198             :                 ::cppu::OWeakObject& _rParent,
     199             :                 ::osl::Mutex& _rMutex,
     200             :                 const ::std::vector< OUString> &_rVector
     201             :                 ) : connectivity::sdbcx::OCollection(_rParent,_bCase,_rMutex,_rVector)
     202          38 :                 ,m_aColumns(_rColumns)
     203             : {
     204          38 : }
     205             : 
     206          76 : ORowSetDataColumns::~ORowSetDataColumns()
     207             : {
     208          76 : }
     209             : 
     210         148 : sdbcx::ObjectType ORowSetDataColumns::createObject(const OUString& _rName)
     211             : {
     212         148 :     connectivity::sdbcx::ObjectType xNamed;
     213             : 
     214         148 :     ::comphelper::UStringMixEqual aCase(isCaseSensitive());
     215         148 :     ::connectivity::OSQLColumns::Vector::const_iterator first =  ::connectivity::find(m_aColumns->get().begin(),m_aColumns->get().end(),_rName,aCase);
     216         148 :     if(first != m_aColumns->get().end())
     217         148 :         xNamed.set(*first,UNO_QUERY);
     218             : 
     219         148 :     return xNamed;
     220             : }
     221             : 
     222         128 : void SAL_CALL ORowSetDataColumns::disposing(void)
     223             : {
     224         128 :     ORowSetDataColumns_BASE::disposing();
     225         128 :     m_aColumns = NULL;
     226         128 : }
     227             : 
     228           6 : void ORowSetDataColumns::assign(const ::rtl::Reference< ::connectivity::OSQLColumns>& _rColumns,const ::std::vector< OUString> &_rVector)
     229             : {
     230           6 :     m_aColumns = _rColumns;
     231           6 :     reFill(_rVector);
     232           6 : }
     233             : 
     234           0 : void ORowSetDataColumns::impl_refresh() throw(::com::sun::star::uno::RuntimeException)
     235             : {
     236           0 : }
     237             : 
     238             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10