LCOV - code coverage report
Current view: top level - stoc/source/corereflection - crenum.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 3 75 4.0 %
Date: 2012-08-25 Functions: 2 20 10.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 3 110 2.7 %

           Branch data     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 "base.hxx"
      22                 :            : 
      23                 :            : namespace stoc_corefl
      24                 :            : {
      25                 :            : 
      26                 :            : //==================================================================================================
      27                 :            : class IdlEnumFieldImpl
      28                 :            :     : public IdlMemberImpl
      29                 :            :     , public XIdlField
      30                 :            :     , public XIdlField2
      31                 :            : {
      32                 :            :     sal_Int32               _nValue;
      33                 :            : 
      34                 :            : public:
      35                 :          0 :     IdlEnumFieldImpl( IdlReflectionServiceImpl * pReflection, const OUString & rName,
      36                 :            :                       typelib_TypeDescription * pTypeDescr, sal_Int32 nValue )
      37                 :            :         : IdlMemberImpl( pReflection, rName, pTypeDescr, pTypeDescr )
      38                 :          0 :         , _nValue( nValue )
      39                 :          0 :         {}
      40                 :            :     virtual ~IdlEnumFieldImpl();
      41                 :            : 
      42                 :            :     // XInterface
      43                 :            :     virtual Any SAL_CALL queryInterface( const Type & rType ) throw(::com::sun::star::uno::RuntimeException);
      44                 :            :     virtual void SAL_CALL acquire() throw();
      45                 :            :     virtual void SAL_CALL release() throw();
      46                 :            : 
      47                 :            :     // XTypeProvider
      48                 :            :     virtual Sequence< Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException);
      49                 :            :     virtual Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException);
      50                 :            : 
      51                 :            :     // XIdlMember
      52                 :            :     virtual Reference< XIdlClass > SAL_CALL getDeclaringClass() throw(::com::sun::star::uno::RuntimeException);
      53                 :            :     virtual OUString SAL_CALL getName() throw(::com::sun::star::uno::RuntimeException);
      54                 :            :     // XIdlField
      55                 :            :     virtual Reference< XIdlClass > SAL_CALL getType() throw(::com::sun::star::uno::RuntimeException);
      56                 :            :     virtual FieldAccessMode SAL_CALL getAccessMode() throw(::com::sun::star::uno::RuntimeException);
      57                 :            :     virtual Any SAL_CALL get( const Any & rObj ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
      58                 :            :     virtual void SAL_CALL set( const Any & rObj, const Any & rValue ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IllegalAccessException, ::com::sun::star::uno::RuntimeException);
      59                 :            :     // XIdlField2: getType, getAccessMode and get are equal to XIdlField
      60                 :            :     virtual void SAL_CALL set( Any & rObj, const Any & rValue ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IllegalAccessException, ::com::sun::star::uno::RuntimeException);
      61                 :            : };
      62                 :            : //__________________________________________________________________________________________________
      63                 :          0 : IdlEnumFieldImpl::~IdlEnumFieldImpl()
      64                 :            : {
      65         [ #  # ]:          0 : }
      66                 :            : 
      67                 :            : // XInterface
      68                 :            : //__________________________________________________________________________________________________
      69                 :          0 : Any IdlEnumFieldImpl::queryInterface( const Type & rType )
      70                 :            :     throw(::com::sun::star::uno::RuntimeException)
      71                 :            : {
      72                 :            :     Any aRet( ::cppu::queryInterface( rType,
      73                 :            :                                       static_cast< XIdlField * >( this ),
      74         [ #  # ]:          0 :                                       static_cast< XIdlField2 * >( this ) ) );
      75 [ #  # ][ #  # ]:          0 :     return (aRet.hasValue() ? aRet : IdlMemberImpl::queryInterface( rType ));
      76                 :            : }
      77                 :            : //__________________________________________________________________________________________________
      78                 :          0 : void IdlEnumFieldImpl::acquire() throw()
      79                 :            : {
      80                 :          0 :     IdlMemberImpl::acquire();
      81                 :          0 : }
      82                 :            : //__________________________________________________________________________________________________
      83                 :          0 : void IdlEnumFieldImpl::release() throw()
      84                 :            : {
      85                 :          0 :     IdlMemberImpl::release();
      86                 :          0 : }
      87                 :            : 
      88                 :            : // XTypeProvider
      89                 :            : //__________________________________________________________________________________________________
      90                 :          0 : Sequence< Type > IdlEnumFieldImpl::getTypes()
      91                 :            :     throw (::com::sun::star::uno::RuntimeException)
      92                 :            : {
      93                 :            :     static OTypeCollection * s_pTypes = 0;
      94         [ #  # ]:          0 :     if (! s_pTypes)
      95                 :            :     {
      96 [ #  # ][ #  # ]:          0 :         MutexGuard aGuard( getMutexAccess() );
      97         [ #  # ]:          0 :         if (! s_pTypes)
      98                 :            :         {
      99                 :            :             static OTypeCollection s_aTypes(
     100         [ #  # ]:          0 :                 ::getCppuType( (const Reference< XIdlField2 > *)0 ),
     101         [ #  # ]:          0 :                 ::getCppuType( (const Reference< XIdlField > *)0 ),
     102 [ #  # ][ #  # ]:          0 :                 IdlMemberImpl::getTypes() );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     103                 :          0 :             s_pTypes = &s_aTypes;
     104         [ #  # ]:          0 :         }
     105                 :            :     }
     106                 :          0 :     return s_pTypes->getTypes();
     107                 :            : }
     108                 :            : //__________________________________________________________________________________________________
     109                 :          0 : Sequence< sal_Int8 > IdlEnumFieldImpl::getImplementationId()
     110                 :            :     throw (::com::sun::star::uno::RuntimeException)
     111                 :            : {
     112                 :            :     static OImplementationId * s_pId = 0;
     113         [ #  # ]:          0 :     if (! s_pId)
     114                 :            :     {
     115 [ #  # ][ #  # ]:          0 :         MutexGuard aGuard( getMutexAccess() );
     116         [ #  # ]:          0 :         if (! s_pId)
     117                 :            :         {
     118 [ #  # ][ #  # ]:          0 :             static OImplementationId s_aId;
     119                 :          0 :             s_pId = &s_aId;
     120         [ #  # ]:          0 :         }
     121                 :            :     }
     122                 :          0 :     return s_pId->getImplementationId();
     123                 :            : }
     124                 :            : 
     125                 :            : // XIdlMember
     126                 :            : //__________________________________________________________________________________________________
     127                 :          0 : Reference< XIdlClass > IdlEnumFieldImpl::getDeclaringClass()
     128                 :            :     throw(::com::sun::star::uno::RuntimeException)
     129                 :            : {
     130                 :          0 :     return IdlMemberImpl::getDeclaringClass();
     131                 :            : }
     132                 :            : //__________________________________________________________________________________________________
     133                 :          0 : OUString IdlEnumFieldImpl::getName()
     134                 :            :     throw(::com::sun::star::uno::RuntimeException)
     135                 :            : {
     136                 :          0 :     return IdlMemberImpl::getName();
     137                 :            : }
     138                 :            : 
     139                 :            : // XIdlField
     140                 :            : //__________________________________________________________________________________________________
     141                 :          0 : Reference< XIdlClass > IdlEnumFieldImpl::getType()
     142                 :            :     throw(::com::sun::star::uno::RuntimeException)
     143                 :            : {
     144                 :          0 :     return getDeclaringClass();
     145                 :            : }
     146                 :            : //__________________________________________________________________________________________________
     147                 :          0 : FieldAccessMode IdlEnumFieldImpl::getAccessMode()
     148                 :            :     throw(::com::sun::star::uno::RuntimeException)
     149                 :            : {
     150                 :          0 :     return FieldAccessMode_READONLY;
     151                 :            : }
     152                 :            : //__________________________________________________________________________________________________
     153                 :          0 : Any IdlEnumFieldImpl::get( const Any & )
     154                 :            :     throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
     155                 :            : {
     156                 :          0 :     return Any( &_nValue, getTypeDescr() );
     157                 :            : }
     158                 :            : //__________________________________________________________________________________________________
     159                 :          0 : void IdlEnumFieldImpl::set( const Any &, const Any & )
     160                 :            :     throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IllegalAccessException, ::com::sun::star::uno::RuntimeException)
     161                 :            : {
     162                 :            :     throw IllegalAccessException(
     163                 :            :         OUString( RTL_CONSTASCII_USTRINGPARAM("enum field is constant!") ),
     164 [ #  # ][ #  # ]:          0 :         (XWeak *)(OWeakObject *)this );
                 [ #  # ]
     165                 :            : }
     166                 :            : //__________________________________________________________________________________________________
     167                 :          0 : void IdlEnumFieldImpl::set( Any &, const Any & )
     168                 :            :     throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IllegalAccessException, ::com::sun::star::uno::RuntimeException)
     169                 :            : {
     170                 :            :     throw IllegalAccessException(
     171                 :            :         OUString( RTL_CONSTASCII_USTRINGPARAM("enum field is constant!") ),
     172 [ #  # ][ #  # ]:          0 :         (XWeak *)(OWeakObject *)this );
                 [ #  # ]
     173                 :            : }
     174                 :            : 
     175                 :            : //##################################################################################################
     176                 :            : //##################################################################################################
     177                 :            : //##################################################################################################
     178                 :            : 
     179                 :            : 
     180                 :            : //__________________________________________________________________________________________________
     181         [ +  - ]:          4 : EnumIdlClassImpl::~EnumIdlClassImpl()
     182                 :            : {
     183 [ -  + ][ #  # ]:          4 :     delete _pFields;
     184         [ -  + ]:          8 : }
     185                 :            : 
     186                 :            : // IdlClassImpl modifications
     187                 :            : //__________________________________________________________________________________________________
     188                 :          0 : Reference< XIdlField > EnumIdlClassImpl::getField( const OUString & rName )
     189                 :            :     throw(::com::sun::star::uno::RuntimeException)
     190                 :            : {
     191         [ #  # ]:          0 :     if (! _pFields)
     192 [ #  # ][ #  # ]:          0 :         getFields(); // init members
     193                 :            : 
     194         [ #  # ]:          0 :     const OUString2Field::const_iterator iFind( _aName2Field.find( rName ) );
     195 [ #  # ][ #  # ]:          0 :     if (iFind != _aName2Field.end())
     196 [ #  # ][ #  # ]:          0 :         return (*iFind).second;
     197                 :            :     else
     198                 :          0 :         return Reference< XIdlField >();
     199                 :            : }
     200                 :            : //__________________________________________________________________________________________________
     201                 :          0 : Sequence< Reference< XIdlField > > EnumIdlClassImpl::getFields()
     202                 :            :     throw(::com::sun::star::uno::RuntimeException)
     203                 :            : {
     204         [ #  # ]:          0 :     if (! _pFields)
     205                 :            :     {
     206 [ #  # ][ #  # ]:          0 :         MutexGuard aGuard( getMutexAccess() );
     207         [ #  # ]:          0 :         if (! _pFields)
     208                 :            :         {
     209                 :          0 :             sal_Int32 nFields = getTypeDescr()->nEnumValues;
     210                 :            :             Sequence< Reference< XIdlField > > * pFields =
     211         [ #  # ]:          0 :                 new Sequence< Reference< XIdlField > >( nFields );
     212         [ #  # ]:          0 :             Reference< XIdlField > * pSeq = pFields->getArray();
     213                 :            : 
     214         [ #  # ]:          0 :             while (nFields--)
     215                 :            :             {
     216                 :          0 :                 OUString aName( getTypeDescr()->ppEnumNames[nFields] );
     217         [ #  # ]:          0 :                 _aName2Field[aName] = pSeq[nFields] = new IdlEnumFieldImpl(
     218 [ #  # ][ #  # ]:          0 :                     getReflection(), aName, IdlClassImpl::getTypeDescr(), getTypeDescr()->pEnumValues[nFields] );
         [ #  # ][ #  # ]
     219                 :          0 :             }
     220                 :            : 
     221                 :          0 :             _pFields = pFields;
     222         [ #  # ]:          0 :         }
     223                 :            :     }
     224                 :          0 :     return *_pFields;
     225                 :            : }
     226                 :            : //__________________________________________________________________________________________________
     227                 :          0 : void EnumIdlClassImpl::createObject( Any & rObj )
     228                 :            :     throw(::com::sun::star::uno::RuntimeException)
     229                 :            : {
     230                 :            :     sal_Int32 eVal =
     231                 :          0 :         ((typelib_EnumTypeDescription *)IdlClassImpl::getTypeDescr())->nDefaultEnumValue;
     232                 :          0 :     rObj.setValue( &eVal, IdlClassImpl::getTypeDescr() );
     233                 :          0 : }
     234                 :            : 
     235                 :            : }
     236                 :            : 
     237                 :            : 
     238                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10