LCOV - code coverage report
Current view: top level - dbaccess/source/core/api - CRowSetDataColumn.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 91 102 89.2 %
Date: 2015-06-13 12:38:46 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         665 : 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         665 :     ,m_aDescription(_rDescription)
      56             : {
      57         665 :     OColumnSettings::registerProperties( *this );
      58         665 :     registerProperty( PROPERTY_DESCRIPTION, PROPERTY_ID_DESCRIPTION, PropertyAttribute::READONLY, &m_aDescription, cppu::UnoType<decltype(m_aDescription)>::get() );
      59         665 : }
      60             : 
      61        1041 : ORowSetDataColumn::~ORowSetDataColumn()
      62             : {
      63        1041 : }
      64             : 
      65             : // comphelper::OPropertyArrayUsageHelper
      66          28 : ::cppu::IPropertyArrayHelper* ORowSetDataColumn::createArrayHelper( ) const
      67             : {
      68          28 :     BEGIN_PROPERTY_SEQUENCE(21)
      69             : 
      70          28 :     DECL_PROP1( CATALOGNAME,                OUString,    READONLY );
      71          28 :     DECL_PROP1( DISPLAYSIZE,                sal_Int32,          READONLY );
      72          28 :     DECL_PROP1_BOOL( ISAUTOINCREMENT,                           READONLY );
      73          28 :     DECL_PROP1_BOOL( ISCASESENSITIVE,                           READONLY );
      74          28 :     DECL_PROP1_BOOL( ISCURRENCY,                                READONLY );
      75          28 :     DECL_PROP1_BOOL( ISDEFINITELYWRITABLE,                      READONLY );
      76          28 :     DECL_PROP1( ISNULLABLE,                 sal_Int32,          READONLY );
      77          28 :     DECL_PROP1_BOOL( ISREADONLY,                                BOUND );
      78          28 :     DECL_PROP1_BOOL( ISROWVERSION,                              READONLY );
      79          28 :     DECL_PROP1_BOOL( ISSEARCHABLE,                              READONLY );
      80          28 :     DECL_PROP1_BOOL( ISSIGNED,                                  READONLY );
      81          28 :     DECL_PROP1_BOOL( ISWRITABLE,                                READONLY );
      82          28 :     DECL_PROP1( LABEL,                      OUString,    READONLY );
      83          28 :     DECL_PROP1( PRECISION,                  sal_Int32,          READONLY );
      84          28 :     DECL_PROP1( SCALE,                      sal_Int32,          READONLY );
      85          28 :     DECL_PROP1( SCHEMANAME,                 OUString,    READONLY );
      86          28 :     DECL_PROP1( SERVICENAME,                OUString,    READONLY );
      87          28 :     DECL_PROP1( TABLENAME,                  OUString,    READONLY );
      88          28 :     DECL_PROP1( TYPE,                       sal_Int32,          READONLY );
      89          28 :     DECL_PROP1( TYPENAME,                   OUString,    READONLY );
      90          28 :     DECL_PROP1( VALUE,                      Any,                BOUND );
      91             : 
      92             :     END_PROPERTY_SEQUENCE()
      93             : 
      94          56 :     Sequence< Property > aRegisteredProperties;
      95          28 :     describeProperties( aRegisteredProperties );
      96             : 
      97          56 :     return new ::cppu::OPropertyArrayHelper( ::comphelper::concatSequences( aDescriptor, aRegisteredProperties ), sal_False );
      98             : }
      99             : 
     100             : // cppu::OPropertySetHelper
     101       23727 : ::cppu::IPropertyArrayHelper& ORowSetDataColumn::getInfoHelper()
     102             : {
     103       23727 :     return *static_cast< ::comphelper::OPropertyArrayUsageHelper< ORowSetDataColumn >* >(this)->getArrayHelper();
     104             : }
     105             : 
     106        7668 : void SAL_CALL ORowSetDataColumn::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) const
     107             : {
     108        7668 :     if ( PROPERTY_ID_VALUE == nHandle )
     109             :     {
     110             :         try
     111             :         {
     112           5 :             rValue = m_pGetValue(m_nPos).makeAny();
     113             :         }
     114           2 :         catch(const SQLException &e)
     115             :         {
     116           4 :             throw WrappedTargetRuntimeException("Could not retrieve column value: " + e.Message,
     117             :                                                 *const_cast<ORowSetDataColumn*>(this),
     118           6 :                                                 Any(e));
     119             :         }
     120             :     }
     121        7663 :     else if ( PROPERTY_ID_LABEL == nHandle && !m_sLabel.isEmpty() )
     122           0 :         rValue <<= m_sLabel;
     123             :     else
     124        7663 :         ODataColumn::getFastPropertyValue( rValue, nHandle );
     125        7666 : }
     126             : 
     127        3230 : void SAL_CALL ORowSetDataColumn::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& rValue )throw (Exception, std::exception)
     128             : {
     129        3230 :     switch( nHandle )
     130             :     {
     131             :         case PROPERTY_ID_VALUE:
     132           0 :             updateObject(rValue);
     133           0 :             break;
     134             :         case PROPERTY_ID_ISREADONLY:
     135             :             {
     136         376 :                 bool bVal = false;
     137         376 :                 rValue >>= bVal;
     138         376 :                 m_isReadOnly.reset(bVal);
     139             :             }
     140         376 :             break;
     141             :         default:
     142        2854 :             ODataColumn::setFastPropertyValue_NoBroadcast( nHandle,rValue );
     143        2854 :             break;
     144             :     }
     145        3230 : }
     146             : 
     147        3462 : sal_Bool SAL_CALL ORowSetDataColumn::convertFastPropertyValue( Any & rConvertedValue,
     148             :                                                             Any & rOldValue,
     149             :                                                             sal_Int32 nHandle,
     150             :                                                             const Any& rValue ) throw (IllegalArgumentException)
     151             : {
     152        3462 :     bool bModified = false;
     153        3462 :     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          78 :                 rConvertedValue = rValue;
     165          78 :                 getFastPropertyValue(rOldValue, PROPERTY_ID_ISREADONLY);
     166          78 :                 bModified = rConvertedValue != rOldValue;
     167             :             }
     168          78 :             break;
     169             :         default:
     170        3384 :             bModified = ODataColumn::convertFastPropertyValue(rConvertedValue, rOldValue, nHandle, rValue);
     171        3384 :             break;
     172             :     }
     173             : 
     174        3462 :     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        6104 : void ORowSetDataColumn::fireValueChange(const ORowSetValue& _rOldValue)
     183             : {
     184        6104 :     const ORowSetValue &value(m_pGetValue(m_nPos));
     185        6104 :     if ( value != _rOldValue)
     186             :     {
     187        4607 :         sal_Int32 nHandle(PROPERTY_ID_VALUE);
     188        4607 :         m_aOldValue = _rOldValue.makeAny();
     189        4607 :         Any aNew = value.makeAny();
     190             : 
     191        4607 :         fire(&nHandle, &aNew, &m_aOldValue, 1, sal_False );
     192             :     }
     193        6104 : }
     194             : 
     195         146 : 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         146 :                 ,m_aColumns(_rColumns)
     203             : {
     204         146 : }
     205             : 
     206         292 : ORowSetDataColumns::~ORowSetDataColumns()
     207             : {
     208         292 : }
     209             : 
     210         158 : sdbcx::ObjectType ORowSetDataColumns::createObject(const OUString& _rName)
     211             : {
     212         158 :     connectivity::sdbcx::ObjectType xNamed;
     213             : 
     214         158 :     ::comphelper::UStringMixEqual aCase(isCaseSensitive());
     215         158 :     ::connectivity::OSQLColumns::Vector::const_iterator first =  ::connectivity::find(m_aColumns->get().begin(),m_aColumns->get().end(),_rName,aCase);
     216         158 :     if(first != m_aColumns->get().end())
     217         158 :         xNamed.set(*first,UNO_QUERY);
     218             : 
     219         158 :     return xNamed;
     220             : }
     221             : 
     222         338 : void SAL_CALL ORowSetDataColumns::disposing()
     223             : {
     224         338 :     ORowSetDataColumns_BASE::disposing();
     225         338 :     m_aColumns = NULL;
     226         338 : }
     227             : 
     228           4 : void ORowSetDataColumns::assign(const ::rtl::Reference< ::connectivity::OSQLColumns>& _rColumns,const ::std::vector< OUString> &_rVector)
     229             : {
     230           4 :     m_aColumns = _rColumns;
     231           4 :     reFill(_rVector);
     232           4 : }
     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.11