LCOV - code coverage report
Current view: top level - stoc/source/corereflection - crenum.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 69 0.0 %
Date: 2014-04-14 Functions: 0 20 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 "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, std::exception) SAL_OVERRIDE;
      44             :     virtual void SAL_CALL acquire() throw() SAL_OVERRIDE;
      45             :     virtual void SAL_CALL release() throw() SAL_OVERRIDE;
      46             : 
      47             :     // XTypeProvider
      48             :     virtual Sequence< Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      49             :     virtual Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      50             : 
      51             :     // XIdlMember
      52             :     virtual Reference< XIdlClass > SAL_CALL getDeclaringClass() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      53             :     virtual OUString SAL_CALL getName() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      54             :     // XIdlField
      55             :     virtual Reference< XIdlClass > SAL_CALL getType() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      56             :     virtual FieldAccessMode SAL_CALL getAccessMode() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      57             :     virtual Any SAL_CALL get( const Any & rObj ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      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, std::exception) SAL_OVERRIDE;
      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, std::exception) SAL_OVERRIDE;
      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, std::exception)
      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, std::exception)
      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, std::exception)
     111             : {
     112           0 :     return css::uno::Sequence<sal_Int8>();
     113             : }
     114             : 
     115             : // XIdlMember
     116             : 
     117           0 : Reference< XIdlClass > IdlEnumFieldImpl::getDeclaringClass()
     118             :     throw(::com::sun::star::uno::RuntimeException, std::exception)
     119             : {
     120           0 :     return IdlMemberImpl::getDeclaringClass();
     121             : }
     122             : 
     123           0 : OUString IdlEnumFieldImpl::getName()
     124             :     throw(::com::sun::star::uno::RuntimeException, std::exception)
     125             : {
     126           0 :     return IdlMemberImpl::getName();
     127             : }
     128             : 
     129             : // XIdlField
     130             : 
     131           0 : Reference< XIdlClass > IdlEnumFieldImpl::getType()
     132             :     throw(::com::sun::star::uno::RuntimeException, std::exception)
     133             : {
     134           0 :     return getDeclaringClass();
     135             : }
     136             : 
     137           0 : FieldAccessMode IdlEnumFieldImpl::getAccessMode()
     138             :     throw(::com::sun::star::uno::RuntimeException, std::exception)
     139             : {
     140           0 :     return FieldAccessMode_READONLY;
     141             : }
     142             : 
     143           0 : Any IdlEnumFieldImpl::get( const Any & )
     144             :     throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException, std::exception)
     145             : {
     146           0 :     return Any( &_nValue, getTypeDescr() );
     147             : }
     148             : 
     149           0 : void IdlEnumFieldImpl::set( const Any &, const Any & )
     150             :     throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IllegalAccessException, ::com::sun::star::uno::RuntimeException, std::exception)
     151             : {
     152             :     throw IllegalAccessException(
     153             :         OUString("enum field is constant!"),
     154           0 :         (XWeak *)(OWeakObject *)this );
     155             : }
     156             : 
     157           0 : void IdlEnumFieldImpl::set( Any &, const Any & )
     158             :     throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IllegalAccessException, ::com::sun::star::uno::RuntimeException, std::exception)
     159             : {
     160             :     throw IllegalAccessException(
     161             :         OUString("enum field is constant!"),
     162           0 :         (XWeak *)(OWeakObject *)this );
     163             : }
     164             : 
     165             : 
     166             : 
     167             : 
     168             : 
     169             : 
     170             : 
     171           0 : EnumIdlClassImpl::~EnumIdlClassImpl()
     172             : {
     173           0 :     delete _pFields;
     174           0 : }
     175             : 
     176             : // IdlClassImpl modifications
     177             : 
     178           0 : Reference< XIdlField > EnumIdlClassImpl::getField( const OUString & rName )
     179             :     throw(::com::sun::star::uno::RuntimeException, std::exception)
     180             : {
     181           0 :     if (! _pFields)
     182           0 :         getFields(); // init members
     183             : 
     184           0 :     const OUString2Field::const_iterator iFind( _aName2Field.find( rName ) );
     185           0 :     if (iFind != _aName2Field.end())
     186           0 :         return (*iFind).second;
     187             :     else
     188           0 :         return Reference< XIdlField >();
     189             : }
     190             : 
     191           0 : Sequence< Reference< XIdlField > > EnumIdlClassImpl::getFields()
     192             :     throw(::com::sun::star::uno::RuntimeException, std::exception)
     193             : {
     194           0 :     if (! _pFields)
     195             :     {
     196           0 :         MutexGuard aGuard( getMutexAccess() );
     197           0 :         if (! _pFields)
     198             :         {
     199           0 :             sal_Int32 nFields = getTypeDescr()->nEnumValues;
     200             :             Sequence< Reference< XIdlField > > * pFields =
     201           0 :                 new Sequence< Reference< XIdlField > >( nFields );
     202           0 :             Reference< XIdlField > * pSeq = pFields->getArray();
     203             : 
     204           0 :             while (nFields--)
     205             :             {
     206           0 :                 OUString aName( getTypeDescr()->ppEnumNames[nFields] );
     207           0 :                 _aName2Field[aName] = pSeq[nFields] = new IdlEnumFieldImpl(
     208           0 :                     getReflection(), aName, IdlClassImpl::getTypeDescr(), getTypeDescr()->pEnumValues[nFields] );
     209           0 :             }
     210             : 
     211           0 :             _pFields = pFields;
     212           0 :         }
     213             :     }
     214           0 :     return *_pFields;
     215             : }
     216             : 
     217           0 : void EnumIdlClassImpl::createObject( Any & rObj )
     218             :     throw(::com::sun::star::uno::RuntimeException, std::exception)
     219             : {
     220             :     sal_Int32 eVal =
     221           0 :         ((typelib_EnumTypeDescription *)IdlClassImpl::getTypeDescr())->nDefaultEnumValue;
     222           0 :     rObj.setValue( &eVal, IdlClassImpl::getTypeDescr() );
     223           0 : }
     224             : 
     225             : }
     226             : 
     227             : 
     228             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10