LCOV - code coverage report
Current view: top level - dbaccess/source/core/api - CRowSetDataColumn.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 106 0.0 %
Date: 2014-04-14 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             : 
      42           0 : 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           0 :     ,m_aDescription(_rDescription)
      54             : {
      55           0 :     OColumnSettings::registerProperties( *this );
      56           0 :     registerProperty( PROPERTY_DESCRIPTION, PROPERTY_ID_DESCRIPTION, PropertyAttribute::READONLY, &m_aDescription, ::getCppuType( &m_aDescription ) );
      57           0 : }
      58             : 
      59           0 : ORowSetDataColumn::~ORowSetDataColumn()
      60             : {
      61           0 : }
      62             : 
      63             : // comphelper::OPropertyArrayUsageHelper
      64           0 : ::cppu::IPropertyArrayHelper* ORowSetDataColumn::createArrayHelper( ) const
      65             : {
      66           0 :     BEGIN_PROPERTY_SEQUENCE(21)
      67             : 
      68           0 :     DECL_PROP1( CATALOGNAME,                OUString,    READONLY );
      69           0 :     DECL_PROP1( DISPLAYSIZE,                sal_Int32,          READONLY );
      70           0 :     DECL_PROP1_BOOL( ISAUTOINCREMENT,                           READONLY );
      71           0 :     DECL_PROP1_BOOL( ISCASESENSITIVE,                           READONLY );
      72           0 :     DECL_PROP1_BOOL( ISCURRENCY,                                READONLY );
      73           0 :     DECL_PROP1_BOOL( ISDEFINITELYWRITABLE,                      READONLY );
      74           0 :     DECL_PROP1( ISNULLABLE,                 sal_Int32,          READONLY );
      75           0 :     DECL_PROP1_BOOL( ISREADONLY,                                BOUND );
      76           0 :     DECL_PROP1_BOOL( ISROWVERSION,                              READONLY );
      77           0 :     DECL_PROP1_BOOL( ISSEARCHABLE,                              READONLY );
      78           0 :     DECL_PROP1_BOOL( ISSIGNED,                                  READONLY );
      79           0 :     DECL_PROP1_BOOL( ISWRITABLE,                                READONLY );
      80           0 :     DECL_PROP1( LABEL,                      OUString,    READONLY );
      81           0 :     DECL_PROP1( PRECISION,                  sal_Int32,          READONLY );
      82           0 :     DECL_PROP1( SCALE,                      sal_Int32,          READONLY );
      83           0 :     DECL_PROP1( SCHEMANAME,                 OUString,    READONLY );
      84           0 :     DECL_PROP1( SERVICENAME,                OUString,    READONLY );
      85           0 :     DECL_PROP1( TABLENAME,                  OUString,    READONLY );
      86           0 :     DECL_PROP1( TYPE,                       sal_Int32,          READONLY );
      87           0 :     DECL_PROP1( TYPENAME,                   OUString,    READONLY );
      88           0 :     DECL_PROP1( VALUE,                      Any,                BOUND );
      89             : 
      90             :     END_PROPERTY_SEQUENCE()
      91             : 
      92           0 :     Sequence< Property > aRegisteredProperties;
      93           0 :     describeProperties( aRegisteredProperties );
      94             : 
      95           0 :     return new ::cppu::OPropertyArrayHelper( ::comphelper::concatSequences( aDescriptor, aRegisteredProperties ), sal_False );
      96             : }
      97             : 
      98             : // cppu::OPropertySetHelper
      99           0 : ::cppu::IPropertyArrayHelper& ORowSetDataColumn::getInfoHelper()
     100             : {
     101           0 :     return *static_cast< ::comphelper::OPropertyArrayUsageHelper< ORowSetDataColumn >* >(this)->getArrayHelper();
     102             : }
     103             : 
     104           0 : void SAL_CALL ORowSetDataColumn::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) const
     105             : {
     106           0 :     if ( PROPERTY_ID_VALUE == nHandle )
     107             :     {
     108           0 :         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           0 :     else if ( PROPERTY_ID_LABEL == nHandle && !m_sLabel.isEmpty() )
     120           0 :         rValue <<= m_sLabel;
     121             :     else
     122           0 :         ODataColumn::getFastPropertyValue( rValue, nHandle );
     123           0 : }
     124             : 
     125           0 : void SAL_CALL ORowSetDataColumn::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& rValue )throw (Exception, std::exception)
     126             : {
     127           0 :     switch( nHandle )
     128             :     {
     129             :         case PROPERTY_ID_VALUE:
     130           0 :             updateObject(rValue);
     131           0 :             break;
     132             :         case PROPERTY_ID_ISREADONLY:
     133             :             {
     134           0 :                 sal_Bool bVal = sal_False;
     135           0 :                 rValue >>= bVal;
     136           0 :                 m_isReadOnly.reset(bVal);
     137             :             }
     138           0 :             break;
     139             :         default:
     140           0 :             ODataColumn::setFastPropertyValue_NoBroadcast( nHandle,rValue );
     141           0 :             break;
     142             :     }
     143           0 : }
     144             : 
     145           0 : sal_Bool SAL_CALL ORowSetDataColumn::convertFastPropertyValue( Any & rConvertedValue,
     146             :                                                             Any & rOldValue,
     147             :                                                             sal_Int32 nHandle,
     148             :                                                             const Any& rValue ) throw (IllegalArgumentException)
     149             : {
     150           0 :     sal_Bool bModified = sal_False;
     151           0 :     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           0 :                 rConvertedValue = rValue;
     163           0 :                 getFastPropertyValue(rOldValue, PROPERTY_ID_ISREADONLY);
     164           0 :                 bModified = rConvertedValue != rOldValue;
     165             :             }
     166           0 :             break;
     167             :         default:
     168           0 :             bModified = ODataColumn::convertFastPropertyValue(rConvertedValue, rOldValue, nHandle, rValue);
     169           0 :             break;
     170             :     }
     171             : 
     172           0 :     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           0 : void ORowSetDataColumn::fireValueChange(const ORowSetValue& _rOldValue)
     181             : {
     182           0 :     if ( !m_aColumnValue.isNull() && m_aColumnValue->is() && (((*m_aColumnValue)->get())[m_nPos] != _rOldValue) )
     183             :     {
     184           0 :         sal_Int32 nHandle = PROPERTY_ID_VALUE;
     185           0 :         m_aOldValue = _rOldValue.makeAny();
     186           0 :         Any aNew = ((*m_aColumnValue)->get())[m_nPos].makeAny();
     187             : 
     188           0 :         fire(&nHandle, &aNew, &m_aOldValue, 1, sal_False );
     189             :     }
     190           0 :     else if ( !m_aColumnValue.isNull() && !_rOldValue.isNull() )
     191             :     {
     192           0 :         sal_Int32 nHandle = PROPERTY_ID_VALUE;
     193           0 :         m_aOldValue = _rOldValue.makeAny();
     194           0 :         Any aNew;
     195             : 
     196           0 :         fire(&nHandle, &aNew, &m_aOldValue, 1, sal_False );
     197             :     }
     198           0 : }
     199             : 
     200           0 : 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           0 :                 ,m_aColumns(_rColumns)
     208             : {
     209           0 : }
     210             : 
     211           0 : ORowSetDataColumns::~ORowSetDataColumns()
     212             : {
     213           0 : }
     214             : 
     215           0 : sdbcx::ObjectType ORowSetDataColumns::createObject(const OUString& _rName)
     216             : {
     217           0 :     connectivity::sdbcx::ObjectType xNamed;
     218             : 
     219           0 :     ::comphelper::UStringMixEqual aCase(isCaseSensitive());
     220           0 :     ::connectivity::OSQLColumns::Vector::const_iterator first =  ::connectivity::find(m_aColumns->get().begin(),m_aColumns->get().end(),_rName,aCase);
     221           0 :     if(first != m_aColumns->get().end())
     222           0 :         xNamed.set(*first,UNO_QUERY);
     223             : 
     224           0 :     return xNamed;
     225             : }
     226             : 
     227           0 : void SAL_CALL ORowSetDataColumns::disposing(void)
     228             : {
     229           0 :     ORowSetDataColumns_BASE::disposing();
     230           0 :     m_aColumns = NULL;
     231           0 : }
     232             : 
     233           0 : void ORowSetDataColumns::assign(const ::rtl::Reference< ::connectivity::OSQLColumns>& _rColumns,const ::std::vector< OUString> &_rVector)
     234             : {
     235           0 :     m_aColumns = _rColumns;
     236           0 :     reFill(_rVector);
     237           0 : }
     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