LCOV - code coverage report
Current view: top level - stoc/source/corereflection - crarray.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 80 0.0 %
Date: 2014-04-14 Functions: 0 12 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             : #include <typelib/typedescription.h>
      21             : #include <uno/data.h>
      22             : 
      23             : #include "base.hxx"
      24             : 
      25             : 
      26             : namespace stoc_corefl
      27             : {
      28             : 
      29             : // XInterface
      30             : 
      31           0 : Any ArrayIdlClassImpl::queryInterface( const Type & rType )
      32             :     throw(::com::sun::star::uno::RuntimeException, std::exception)
      33             : {
      34           0 :     Any aRet( ::cppu::queryInterface( rType, static_cast< XIdlArray * >( this ) ) );
      35           0 :     return (aRet.hasValue() ? aRet : IdlClassImpl::queryInterface( rType ));
      36             : }
      37             : 
      38           0 : void ArrayIdlClassImpl::acquire() throw()
      39             : {
      40           0 :     IdlClassImpl::acquire();
      41           0 : }
      42             : 
      43           0 : void ArrayIdlClassImpl::release() throw()
      44             : {
      45           0 :     IdlClassImpl::release();
      46           0 : }
      47             : 
      48             : // XTypeProvider
      49             : 
      50           0 : Sequence< Type > ArrayIdlClassImpl::getTypes()
      51             :     throw (::com::sun::star::uno::RuntimeException, std::exception)
      52             : {
      53             :     static OTypeCollection * s_pTypes = 0;
      54           0 :     if (! s_pTypes)
      55             :     {
      56           0 :         MutexGuard aGuard( getMutexAccess() );
      57           0 :         if (! s_pTypes)
      58             :         {
      59             :             static OTypeCollection s_aTypes(
      60           0 :                 ::getCppuType( (const Reference< XIdlArray > *)0 ),
      61           0 :                 IdlClassImpl::getTypes() );
      62           0 :             s_pTypes = &s_aTypes;
      63           0 :         }
      64             :     }
      65           0 :     return s_pTypes->getTypes();
      66             : }
      67             : 
      68           0 : Sequence< sal_Int8 > ArrayIdlClassImpl::getImplementationId()
      69             :     throw (::com::sun::star::uno::RuntimeException, std::exception)
      70             : {
      71           0 :     return css::uno::Sequence<sal_Int8>();
      72             : }
      73             : 
      74             : // XIdlArray
      75             : 
      76           0 : void ArrayIdlClassImpl::realloc( Any & rArray, sal_Int32 nLen )
      77             :     throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException, std::exception)
      78             : {
      79           0 :     TypeClass eTC = rArray.getValueTypeClass();
      80           0 :     if (eTC != TypeClass_SEQUENCE)
      81             :     {
      82             :         throw IllegalArgumentException(
      83             :             OUString("no sequence given!"),
      84           0 :             (XWeak *)(OWeakObject *)this, 0 );
      85             :     }
      86           0 :     if (nLen < 0)
      87             :     {
      88             :         throw IllegalArgumentException(
      89             :             OUString("illegal length given!"),
      90           0 :             (XWeak *)(OWeakObject *)this, 1 );
      91             :     }
      92             : 
      93           0 :     uno_Sequence ** ppSeq = (uno_Sequence **)rArray.getValue();
      94           0 :     uno_sequence_realloc( ppSeq, (typelib_TypeDescription *)getTypeDescr(),
      95             :                           nLen,
      96             :                           reinterpret_cast< uno_AcquireFunc >(cpp_acquire),
      97           0 :                           reinterpret_cast< uno_ReleaseFunc >(cpp_release) );
      98           0 :     rArray.pData = ppSeq;
      99           0 : }
     100             : 
     101           0 : sal_Int32 ArrayIdlClassImpl::getLen( const Any & rArray )
     102             :     throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException, std::exception)
     103             : {
     104           0 :     TypeClass eTC = rArray.getValueTypeClass();
     105           0 :     if (eTC != TypeClass_SEQUENCE)
     106             :     {
     107             :         throw IllegalArgumentException(
     108             :             OUString("no sequence given!"),
     109           0 :             (XWeak *)(OWeakObject *)this, 0 );
     110             :     }
     111             : 
     112           0 :     return (*(uno_Sequence **)rArray.getValue())->nElements;
     113             : }
     114             : 
     115           0 : Any ArrayIdlClassImpl::get( const Any & rArray, sal_Int32 nIndex )
     116             :     throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::ArrayIndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException, std::exception)
     117             : {
     118           0 :     TypeClass eTC = rArray.getValueTypeClass();
     119           0 :     if (eTC != TypeClass_SEQUENCE)
     120             :     {
     121             :         throw IllegalArgumentException(
     122             :             OUString("no sequence given!"),
     123           0 :             (XWeak *)(OWeakObject *)this, 0 );
     124             :     }
     125             : 
     126           0 :     uno_Sequence * pSeq = *(uno_Sequence **)rArray.getValue();
     127           0 :     if (pSeq->nElements <= nIndex)
     128             :     {
     129             :         throw ArrayIndexOutOfBoundsException(
     130             :             OUString("illegal index given!"),
     131           0 :             (XWeak *)(OWeakObject *)this );
     132             :     }
     133             : 
     134           0 :     Any aRet;
     135           0 :     typelib_TypeDescription * pElemTypeDescr = 0;
     136           0 :     TYPELIB_DANGER_GET( &pElemTypeDescr, getTypeDescr()->pType );
     137           0 :     uno_any_destruct( &aRet, reinterpret_cast< uno_ReleaseFunc >(cpp_release) );
     138           0 :     uno_any_construct( &aRet, &pSeq->elements[nIndex * pElemTypeDescr->nSize],
     139             :                        pElemTypeDescr,
     140           0 :                        reinterpret_cast< uno_AcquireFunc >(cpp_acquire) );
     141           0 :     TYPELIB_DANGER_RELEASE( pElemTypeDescr );
     142           0 :     return aRet;
     143             : }
     144             : 
     145             : 
     146           0 : void ArrayIdlClassImpl::set( Any & rArray, sal_Int32 nIndex, const Any & rNewValue )
     147             :     throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::ArrayIndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException, std::exception)
     148             : {
     149           0 :     TypeClass eTC = rArray.getValueTypeClass();
     150           0 :     if (eTC != TypeClass_SEQUENCE)
     151             :     {
     152             :         throw IllegalArgumentException(
     153             :             OUString("no sequence given!"),
     154           0 :             (XWeak *)(OWeakObject *)this, 0 );
     155             :     }
     156             : 
     157           0 :     uno_Sequence * pSeq = *(uno_Sequence **)rArray.getValue();
     158           0 :     if (pSeq->nElements <= nIndex)
     159             :     {
     160             :         throw ArrayIndexOutOfBoundsException(
     161             :             OUString("illegal index given!"),
     162           0 :             (XWeak *)(OWeakObject *)this );
     163             :     }
     164             : 
     165           0 :     uno_Sequence ** ppSeq = (uno_Sequence **)rArray.getValue();
     166             :     uno_sequence_reference2One(
     167           0 :         ppSeq, (typelib_TypeDescription *)getTypeDescr(),
     168             :         reinterpret_cast< uno_AcquireFunc >(cpp_acquire),
     169           0 :         reinterpret_cast< uno_ReleaseFunc >(cpp_release) );
     170           0 :     rArray.pData = ppSeq;
     171           0 :     pSeq = *ppSeq;
     172             : 
     173           0 :     typelib_TypeDescription * pElemTypeDescr = 0;
     174           0 :     TYPELIB_DANGER_GET( &pElemTypeDescr, getTypeDescr()->pType );
     175             : 
     176           0 :     if (! coerce_assign( &pSeq->elements[nIndex * pElemTypeDescr->nSize],
     177           0 :                          pElemTypeDescr, rNewValue, getReflection() ))
     178             :     {
     179           0 :         TYPELIB_DANGER_RELEASE( pElemTypeDescr );
     180             :         throw IllegalArgumentException(
     181             :             OUString("sequence element is not assignable by given value!"),
     182           0 :             (XWeak *)(OWeakObject *)this, 2 );
     183             :     }
     184           0 :     TYPELIB_DANGER_RELEASE( pElemTypeDescr );
     185           0 : }
     186             : 
     187             : // ArrayIdlClassImpl
     188             : 
     189           0 : sal_Bool ArrayIdlClassImpl::isAssignableFrom( const Reference< XIdlClass > & xType )
     190             :     throw(::com::sun::star::uno::RuntimeException, std::exception)
     191             : {
     192           0 :     return (xType.is() &&
     193           0 :             (equals( xType ) ||
     194           0 :              (xType->getTypeClass() == getTypeClass() && // must be sequence|array
     195           0 :               getComponentType()->isAssignableFrom( xType->getComponentType() ))));
     196             : }
     197             : 
     198           0 : Reference< XIdlClass > ArrayIdlClassImpl::getComponentType()
     199             :     throw(::com::sun::star::uno::RuntimeException, std::exception)
     200             : {
     201           0 :     return getReflection()->forType( getTypeDescr()->pType );
     202             : }
     203             : 
     204           0 : Reference< XIdlArray > ArrayIdlClassImpl::getArray()
     205             :     throw(::com::sun::star::uno::RuntimeException, std::exception)
     206             : {
     207           0 :     return this;
     208             : }
     209             : 
     210             : }
     211             : 
     212             : 
     213             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10