LCOV - code coverage report
Current view: top level - dbaccess/source/core/api - CRowSetDataColumn.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 92 106 86.8 %
Date: 2014-04-11 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/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             : 
      42         260 : ORowSetDataColumn::ORowSetDataColumn(   const Reference < XResultSetMetaData >& _xMetaData,
      43             :                                       const Reference < XRow >& _xRow,
      44             :                                       const Reference < XRowUpdate >& _xRowUpdate,
      45             :                                       sal_Int32 _nPos,
      46             :                                       const Reference< XDatabaseMetaData >& _rxDBMeta,
      47             :                                       const OUString& _rDescription,
      48             :                                       const OUString& i_sLabel,
      49             :                                       const ORowSetCacheIterator& _rColumnValue)
      50             :     :ODataColumn(_xMetaData,_xRow,_xRowUpdate,_nPos,_rxDBMeta)
      51             :     ,m_aColumnValue(_rColumnValue)
      52             :     ,m_sLabel(i_sLabel)
      53         260 :     ,m_aDescription(_rDescription)
      54             : {
      55         260 :     OColumnSettings::registerProperties( *this );
      56         260 :     registerProperty( PROPERTY_DESCRIPTION, PROPERTY_ID_DESCRIPTION, PropertyAttribute::READONLY, &m_aDescription, ::getCppuType( &m_aDescription ) );
      57         260 : }
      58             : 
      59         478 : ORowSetDataColumn::~ORowSetDataColumn()
      60             : {
      61         478 : }
      62             : 
      63             : // comphelper::OPropertyArrayUsageHelper
      64          18 : ::cppu::IPropertyArrayHelper* ORowSetDataColumn::createArrayHelper( ) const
      65             : {
      66          18 :     BEGIN_PROPERTY_SEQUENCE(21)
      67             : 
      68          18 :     DECL_PROP1( CATALOGNAME,                OUString,    READONLY );
      69          18 :     DECL_PROP1( DISPLAYSIZE,                sal_Int32,          READONLY );
      70          18 :     DECL_PROP1_BOOL( ISAUTOINCREMENT,                           READONLY );
      71          18 :     DECL_PROP1_BOOL( ISCASESENSITIVE,                           READONLY );
      72          18 :     DECL_PROP1_BOOL( ISCURRENCY,                                READONLY );
      73          18 :     DECL_PROP1_BOOL( ISDEFINITELYWRITABLE,                      READONLY );
      74          18 :     DECL_PROP1( ISNULLABLE,                 sal_Int32,          READONLY );
      75          18 :     DECL_PROP1_BOOL( ISREADONLY,                                BOUND );
      76          18 :     DECL_PROP1_BOOL( ISROWVERSION,                              READONLY );
      77          18 :     DECL_PROP1_BOOL( ISSEARCHABLE,                              READONLY );
      78          18 :     DECL_PROP1_BOOL( ISSIGNED,                                  READONLY );
      79          18 :     DECL_PROP1_BOOL( ISWRITABLE,                                READONLY );
      80          18 :     DECL_PROP1( LABEL,                      OUString,    READONLY );
      81          18 :     DECL_PROP1( PRECISION,                  sal_Int32,          READONLY );
      82          18 :     DECL_PROP1( SCALE,                      sal_Int32,          READONLY );
      83          18 :     DECL_PROP1( SCHEMANAME,                 OUString,    READONLY );
      84          18 :     DECL_PROP1( SERVICENAME,                OUString,    READONLY );
      85          18 :     DECL_PROP1( TABLENAME,                  OUString,    READONLY );
      86          18 :     DECL_PROP1( TYPE,                       sal_Int32,          READONLY );
      87          18 :     DECL_PROP1( TYPENAME,                   OUString,    READONLY );
      88          18 :     DECL_PROP1( VALUE,                      Any,                BOUND );
      89             : 
      90             :     END_PROPERTY_SEQUENCE()
      91             : 
      92          36 :     Sequence< Property > aRegisteredProperties;
      93          18 :     describeProperties( aRegisteredProperties );
      94             : 
      95          36 :     return new ::cppu::OPropertyArrayHelper( ::comphelper::concatSequences( aDescriptor, aRegisteredProperties ), sal_False );
      96             : }
      97             : 
      98             : // cppu::OPropertySetHelper
      99        8547 : ::cppu::IPropertyArrayHelper& ORowSetDataColumn::getInfoHelper()
     100             : {
     101        8547 :     return *static_cast< ::comphelper::OPropertyArrayUsageHelper< ORowSetDataColumn >* >(this)->getArrayHelper();
     102             : }
     103             : 
     104        2266 : void SAL_CALL ORowSetDataColumn::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) const
     105             : {
     106        2266 :     if ( PROPERTY_ID_VALUE == nHandle )
     107             :     {
     108           3 :         if ( !m_aColumnValue.isNull() && m_aColumnValue->is() )
     109             :         {
     110           0 :             ::osl::Mutex* pMutex = m_aColumnValue.getMutex();
     111           0 :             ::osl::MutexGuard aGuard( *pMutex );
     112             : #if OSL_DEBUG_LEVEL > 0
     113             :             ORowSetRow aRow = *m_aColumnValue;
     114             : #endif
     115             :             OSL_ENSURE((sal_Int32)aRow->get().size() > m_nPos,"Pos is greater than size of vector");
     116           0 :             rValue = ((*m_aColumnValue)->get())[m_nPos].makeAny();
     117             :         }
     118             :     }
     119        2263 :     else if ( PROPERTY_ID_LABEL == nHandle && !m_sLabel.isEmpty() )
     120           0 :         rValue <<= m_sLabel;
     121             :     else
     122        2263 :         ODataColumn::getFastPropertyValue( rValue, nHandle );
     123        2266 : }
     124             : 
     125         938 : void SAL_CALL ORowSetDataColumn::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& rValue )throw (Exception, std::exception)
     126             : {
     127         938 :     switch( nHandle )
     128             :     {
     129             :         case PROPERTY_ID_VALUE:
     130           0 :             updateObject(rValue);
     131           0 :             break;
     132             :         case PROPERTY_ID_ISREADONLY:
     133             :             {
     134         218 :                 sal_Bool bVal = sal_False;
     135         218 :                 rValue >>= bVal;
     136         218 :                 m_isReadOnly.reset(bVal);
     137             :             }
     138         218 :             break;
     139             :         default:
     140         720 :             ODataColumn::setFastPropertyValue_NoBroadcast( nHandle,rValue );
     141         720 :             break;
     142             :     }
     143         938 : }
     144             : 
     145        2024 : sal_Bool SAL_CALL ORowSetDataColumn::convertFastPropertyValue( Any & rConvertedValue,
     146             :                                                             Any & rOldValue,
     147             :                                                             sal_Int32 nHandle,
     148             :                                                             const Any& rValue ) throw (IllegalArgumentException)
     149             : {
     150        2024 :     sal_Bool bModified = sal_False;
     151        2024 :     switch( nHandle )
     152             :     {
     153             :         case PROPERTY_ID_VALUE:
     154             :             {
     155           0 :                 rConvertedValue = rValue;
     156           0 :                 getFastPropertyValue(rOldValue, PROPERTY_ID_VALUE);
     157           0 :                 bModified = rConvertedValue != rOldValue;
     158             :             }
     159           0 :             break;
     160             :         case PROPERTY_ID_ISREADONLY:
     161             :             {
     162          62 :                 rConvertedValue = rValue;
     163          62 :                 getFastPropertyValue(rOldValue, PROPERTY_ID_ISREADONLY);
     164          62 :                 bModified = rConvertedValue != rOldValue;
     165             :             }
     166          62 :             break;
     167             :         default:
     168        1962 :             bModified = ODataColumn::convertFastPropertyValue(rConvertedValue, rOldValue, nHandle, rValue);
     169        1962 :             break;
     170             :     }
     171             : 
     172        2024 :     return bModified;
     173             : }
     174             : 
     175           0 : Sequence< sal_Int8 > ORowSetDataColumn::getImplementationId() throw (RuntimeException, std::exception)
     176             : {
     177           0 :     return css::uno::Sequence<sal_Int8>();
     178             : }
     179             : 
     180        1777 : void ORowSetDataColumn::fireValueChange(const ORowSetValue& _rOldValue)
     181             : {
     182        1777 :     if ( !m_aColumnValue.isNull() && m_aColumnValue->is() && (((*m_aColumnValue)->get())[m_nPos] != _rOldValue) )
     183             :     {
     184         456 :         sal_Int32 nHandle = PROPERTY_ID_VALUE;
     185         456 :         m_aOldValue = _rOldValue.makeAny();
     186         456 :         Any aNew = ((*m_aColumnValue)->get())[m_nPos].makeAny();
     187             : 
     188         456 :         fire(&nHandle, &aNew, &m_aOldValue, 1, sal_False );
     189             :     }
     190        1321 :     else if ( !m_aColumnValue.isNull() && !_rOldValue.isNull() )
     191             :     {
     192         177 :         sal_Int32 nHandle = PROPERTY_ID_VALUE;
     193         177 :         m_aOldValue = _rOldValue.makeAny();
     194         177 :         Any aNew;
     195             : 
     196         177 :         fire(&nHandle, &aNew, &m_aOldValue, 1, sal_False );
     197             :     }
     198        1777 : }
     199             : 
     200          17 : ORowSetDataColumns::ORowSetDataColumns(
     201             :                 sal_Bool _bCase,
     202             :                 const ::rtl::Reference< ::connectivity::OSQLColumns>& _rColumns,
     203             :                 ::cppu::OWeakObject& _rParent,
     204             :                 ::osl::Mutex& _rMutex,
     205             :                 const ::std::vector< OUString> &_rVector
     206             :                 ) : connectivity::sdbcx::OCollection(_rParent,_bCase,_rMutex,_rVector)
     207          17 :                 ,m_aColumns(_rColumns)
     208             : {
     209          17 : }
     210             : 
     211          34 : ORowSetDataColumns::~ORowSetDataColumns()
     212             : {
     213          34 : }
     214             : 
     215          74 : sdbcx::ObjectType ORowSetDataColumns::createObject(const OUString& _rName)
     216             : {
     217          74 :     connectivity::sdbcx::ObjectType xNamed;
     218             : 
     219          74 :     ::comphelper::UStringMixEqual aCase(isCaseSensitive());
     220          74 :     ::connectivity::OSQLColumns::Vector::const_iterator first =  ::connectivity::find(m_aColumns->get().begin(),m_aColumns->get().end(),_rName,aCase);
     221          74 :     if(first != m_aColumns->get().end())
     222          74 :         xNamed.set(*first,UNO_QUERY);
     223             : 
     224          74 :     return xNamed;
     225             : }
     226             : 
     227          58 : void SAL_CALL ORowSetDataColumns::disposing(void)
     228             : {
     229          58 :     ORowSetDataColumns_BASE::disposing();
     230          58 :     m_aColumns = NULL;
     231          58 : }
     232             : 
     233           3 : void ORowSetDataColumns::assign(const ::rtl::Reference< ::connectivity::OSQLColumns>& _rColumns,const ::std::vector< OUString> &_rVector)
     234             : {
     235           3 :     m_aColumns = _rColumns;
     236           3 :     reFill(_rVector);
     237           3 : }
     238             : 
     239           0 : void ORowSetDataColumns::impl_refresh() throw(::com::sun::star::uno::RuntimeException)
     240             : {
     241           0 : }
     242             : 
     243             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10