LCOV - code coverage report
Current view: top level - stoc/source/invocation - invocation.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 457 0.0 %
Date: 2014-04-14 Functions: 0 53 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 <osl/mutex.hxx>
      21             : #include <cppuhelper/queryinterface.hxx>
      22             : #include <cppuhelper/weak.hxx>
      23             : #include <cppuhelper/factory.hxx>
      24             : #include <cppuhelper/implementationentry.hxx>
      25             : #include <cppuhelper/supportsservice.hxx>
      26             : #include <cppuhelper/typeprovider.hxx>
      27             : #include <cppuhelper/implbase2.hxx>
      28             : 
      29             : #include <com/sun/star/script/FailReason.hpp>
      30             : #include <com/sun/star/script/XTypeConverter.hpp>
      31             : #include <com/sun/star/script/XInvocation.hpp>
      32             : #include <com/sun/star/script/XInvocation2.hpp>
      33             : #include <com/sun/star/reflection/XIdlReflection.hpp>
      34             : #include <com/sun/star/reflection/theCoreReflection.hpp>
      35             : #include <com/sun/star/container/XNameContainer.hpp>
      36             : #include <com/sun/star/container/XIndexContainer.hpp>
      37             : #include <com/sun/star/container/XEnumerationAccess.hpp>
      38             : #include <com/sun/star/beans/XExactName.hpp>
      39             : #include <com/sun/star/beans/XMaterialHolder.hpp>
      40             : #include <com/sun/star/beans/theIntrospection.hpp>
      41             : #include <com/sun/star/beans/XPropertySet.hpp>
      42             : #include <com/sun/star/beans/PropertyAttribute.hpp>
      43             : #include <com/sun/star/beans/MethodConcept.hpp>
      44             : #include <com/sun/star/beans/PropertyConcept.hpp>
      45             : #include <com/sun/star/lang/XSingleServiceFactory.hpp>
      46             : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      47             : #include <com/sun/star/lang/XServiceInfo.hpp>
      48             : #include <com/sun/star/lang/XTypeProvider.hpp>
      49             : #include <com/sun/star/registry/XRegistryKey.hpp>
      50             : 
      51             : #include <boost/scoped_array.hpp>
      52             : #include <rtl/ustrbuf.hxx>
      53             : #include <rtl/strbuf.hxx>
      54             : 
      55             : #define SERVICENAME "com.sun.star.script.Invocation"
      56             : #define IMPLNAME     "com.sun.star.comp.stoc.Invocation"
      57             : 
      58             : using namespace com::sun::star::uno;
      59             : using namespace com::sun::star::lang;
      60             : using namespace com::sun::star::script;
      61             : using namespace com::sun::star::reflection;
      62             : using namespace com::sun::star::beans;
      63             : using namespace com::sun::star::registry;
      64             : using namespace com::sun::star::container;
      65             : using namespace cppu;
      66             : using namespace osl;
      67             : 
      68             : namespace stoc_inv
      69             : {
      70           0 : static Sequence< OUString > inv_getSupportedServiceNames()
      71             : {
      72           0 :     Sequence< OUString > seqNames(1);
      73           0 :     seqNames.getArray()[0] = SERVICENAME;
      74           0 :     return seqNames;
      75             : }
      76             : 
      77           0 : static OUString inv_getImplementationName()
      78             : {
      79           0 :     return OUString(IMPLNAME);
      80             : }
      81             : 
      82             : // TODO: Zentral implementieren
      83           0 : inline Reference<XIdlClass> TypeToIdlClass( const Type& rType, const Reference< XIdlReflection > & xRefl )
      84             : {
      85           0 :     return xRefl->forName( rType.getTypeName() );
      86             : }
      87             : 
      88             : 
      89             : 
      90             : class Invocation_Impl
      91             :     : public OWeakObject
      92             :     , public XInvocation2
      93             :     , public XNameContainer
      94             :     , public XIndexContainer
      95             :     , public XEnumerationAccess
      96             :     , public XExactName
      97             :     , public XMaterialHolder
      98             :     , public XTypeProvider
      99             : {
     100             : public:
     101             :     Invocation_Impl( const Any & rAdapted, const Reference<XTypeConverter> &,
     102             :                                            const Reference<XIntrospection> &,
     103             :                                            const Reference<XIdlReflection> & );
     104             :     virtual ~Invocation_Impl();
     105             : 
     106             :     // XInterface
     107             :     virtual Any         SAL_CALL queryInterface( const Type & aType) throw( RuntimeException, std::exception ) SAL_OVERRIDE;
     108           0 :     virtual void        SAL_CALL acquire() throw() SAL_OVERRIDE { OWeakObject::acquire(); }
     109           0 :     virtual void        SAL_CALL release() throw() SAL_OVERRIDE { OWeakObject::release(); }
     110             : 
     111             : 
     112             :     // XTypeProvider
     113             :     virtual Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes(  )
     114             :        throw(RuntimeException, std::exception) SAL_OVERRIDE;
     115             :     virtual Sequence< sal_Int8 > SAL_CALL getImplementationId(  )
     116             :        throw( RuntimeException, std::exception) SAL_OVERRIDE;
     117             : 
     118             :     // Methoden von XMaterialHolder
     119             :     virtual Any         SAL_CALL getMaterial(void) throw(RuntimeException, std::exception) SAL_OVERRIDE;
     120             : 
     121             :     // XInvocation
     122             :     virtual Reference<XIntrospectionAccess> SAL_CALL getIntrospection(void) throw( RuntimeException, std::exception ) SAL_OVERRIDE;
     123             :     virtual Any SAL_CALL invoke(const OUString& FunctionName, const Sequence< Any >& Params, Sequence< sal_Int16 >& OutParamIndex, Sequence< Any >& OutParam)
     124             :         throw( IllegalArgumentException, CannotConvertException, InvocationTargetException, RuntimeException, std::exception ) SAL_OVERRIDE;
     125             :     virtual void SAL_CALL setValue(const OUString& PropertyName, const Any& Value)
     126             :         throw( UnknownPropertyException, CannotConvertException, InvocationTargetException, RuntimeException, std::exception ) SAL_OVERRIDE;
     127             :     virtual Any SAL_CALL getValue(const OUString& PropertyName)
     128             :         throw( UnknownPropertyException, RuntimeException, std::exception ) SAL_OVERRIDE;
     129             :     virtual sal_Bool SAL_CALL hasMethod(const OUString& Name) throw( RuntimeException, std::exception ) SAL_OVERRIDE;
     130             :     virtual sal_Bool SAL_CALL hasProperty(const OUString& Name) throw( RuntimeException, std::exception ) SAL_OVERRIDE;
     131             : 
     132             :     // XInvocation2
     133             :     virtual Sequence< OUString > SAL_CALL getMemberNames(  )
     134             :         throw( RuntimeException, std::exception ) SAL_OVERRIDE;
     135             :     virtual Sequence< InvocationInfo > SAL_CALL getInfo(  )
     136             :         throw( RuntimeException, std::exception ) SAL_OVERRIDE;
     137             :     virtual InvocationInfo SAL_CALL getInfoForName( const OUString& aName, sal_Bool bExact )
     138             :         throw( IllegalArgumentException, RuntimeException, std::exception ) SAL_OVERRIDE;
     139             : 
     140             :     // All Access and Container methods are not thread save
     141             :     // XElementAccess
     142           0 :     virtual Type SAL_CALL getElementType(void) throw( RuntimeException, std::exception ) SAL_OVERRIDE
     143           0 :         { return _xElementAccess->getElementType(); }
     144             : 
     145           0 :     virtual sal_Bool SAL_CALL hasElements(void) throw( RuntimeException, std::exception ) SAL_OVERRIDE
     146           0 :         { return _xElementAccess->hasElements(); }
     147             : 
     148             :     // XNameContainer
     149           0 :     virtual void SAL_CALL insertByName( const OUString& Name, const Any& Element )
     150             :         throw( IllegalArgumentException, ElementExistException, WrappedTargetException, RuntimeException, std::exception ) SAL_OVERRIDE
     151           0 :         { _xNameContainer->insertByName( Name, Element ); }
     152             : 
     153           0 :     virtual void SAL_CALL replaceByName( const OUString& Name, const Any& Element )
     154             :         throw( IllegalArgumentException, NoSuchElementException, WrappedTargetException, RuntimeException, std::exception ) SAL_OVERRIDE
     155           0 :         { _xNameContainer->replaceByName( Name, Element ); }
     156             : 
     157           0 :     virtual void SAL_CALL removeByName( const OUString& Name )
     158             :         throw( NoSuchElementException, WrappedTargetException, RuntimeException, std::exception ) SAL_OVERRIDE
     159           0 :         { _xNameContainer->removeByName( Name ); }
     160             : 
     161             :     // XNameAccess
     162           0 :     virtual Any SAL_CALL getByName( const OUString& Name )
     163             :         throw( NoSuchElementException, WrappedTargetException, RuntimeException, std::exception ) SAL_OVERRIDE
     164           0 :         { return _xNameAccess->getByName( Name ); }
     165             : 
     166           0 :     virtual Sequence<OUString> SAL_CALL getElementNames(void) throw( RuntimeException, std::exception ) SAL_OVERRIDE
     167           0 :         { return _xNameAccess->getElementNames(); }
     168             : 
     169           0 :     virtual sal_Bool SAL_CALL hasByName( const OUString& Name ) throw( RuntimeException, std::exception ) SAL_OVERRIDE
     170           0 :         { return _xNameAccess->hasByName( Name ); }
     171             : 
     172             :     // XIndexContainer
     173           0 :     virtual void SAL_CALL insertByIndex( sal_Int32 Index, const Any& Element )
     174             :         throw( IllegalArgumentException, IndexOutOfBoundsException, WrappedTargetException, RuntimeException, std::exception ) SAL_OVERRIDE
     175           0 :         { _xIndexContainer->insertByIndex( Index, Element ); }
     176             : 
     177           0 :     virtual void SAL_CALL replaceByIndex( sal_Int32 Index, const Any& Element )
     178             :         throw( IllegalArgumentException, IndexOutOfBoundsException, WrappedTargetException, RuntimeException, std::exception ) SAL_OVERRIDE
     179           0 :         { _xIndexContainer->replaceByIndex( Index, Element ); }
     180             : 
     181           0 :     virtual void SAL_CALL removeByIndex( sal_Int32 Index )
     182             :         throw( IndexOutOfBoundsException, WrappedTargetException, RuntimeException, std::exception ) SAL_OVERRIDE
     183           0 :         { _xIndexContainer->removeByIndex( Index ); }
     184             : 
     185             :     // XIndexAccess
     186           0 :     virtual sal_Int32 SAL_CALL getCount(void) throw( RuntimeException, std::exception ) SAL_OVERRIDE
     187           0 :         { return _xIndexAccess->getCount(); }
     188             : 
     189           0 :     virtual Any SAL_CALL getByIndex( sal_Int32 Index )
     190             :         throw( IndexOutOfBoundsException, WrappedTargetException, RuntimeException, std::exception ) SAL_OVERRIDE
     191           0 :         { return _xIndexAccess->getByIndex( Index ); }
     192             : 
     193             :     // XEnumerationAccess
     194           0 :     virtual Reference<XEnumeration> SAL_CALL createEnumeration(void) throw( RuntimeException, std::exception ) SAL_OVERRIDE
     195           0 :         { return _xEnumerationAccess->createEnumeration(); }
     196             : 
     197             :     // XExactName
     198             :     virtual OUString SAL_CALL getExactName( const OUString& rApproximateName ) throw( RuntimeException, std::exception ) SAL_OVERRIDE;
     199             : 
     200             : 
     201             : 
     202             : private:
     203             :     void setMaterial( const Any& rMaterial );
     204             : 
     205             :     void getInfoSequenceImpl( Sequence< OUString >* pStringSeq, Sequence< InvocationInfo >* pInfoSeq );
     206             :     void fillInfoForNameAccess( InvocationInfo& rInfo, const OUString& aName );
     207             :     void fillInfoForProperty( InvocationInfo& rInfo, const Property& rProp );
     208             :     void fillInfoForMethod( InvocationInfo& rInfo, const Reference< XIdlMethod > xMethod );
     209             : 
     210             :     Reference<XTypeConverter>           xTypeConverter;
     211             :     Reference<XIntrospection>           xIntrospection;
     212             :     Reference<XIdlReflection>           xCoreReflection;
     213             : 
     214             :     Any                             _aMaterial;
     215             :     // _xDirect and (_xIntrospectionAccess, xPropertySet) are exclusive
     216             :     Reference<XInvocation>              _xDirect;
     217             :     Reference<XInvocation2>             _xDirect2;
     218             :     Reference<XPropertySet>             _xPropertySet;
     219             :     Reference<XIntrospectionAccess>     _xIntrospectionAccess;
     220             : 
     221             :     // supplied Interfaces
     222             :     Reference<XNameContainer>           _xNameContainer;
     223             :     Reference<XNameAccess>              _xNameAccess;
     224             :     Reference<XIndexContainer>          _xIndexContainer;
     225             :     Reference<XIndexAccess>             _xIndexAccess;
     226             :     Reference<XEnumerationAccess>       _xEnumerationAccess;
     227             :     Reference<XElementAccess>           _xElementAccess;
     228             : 
     229             : 
     230             :     Reference<XExactName>               _xENDirect, _xENIntrospection, _xENNameAccess;
     231             : };
     232             : 
     233             : 
     234             : 
     235             : 
     236             : 
     237             : 
     238             : 
     239           0 : Invocation_Impl::Invocation_Impl
     240             : (
     241             :     const Any & rAdapted,
     242             :     const Reference<XTypeConverter> & rTC,
     243             :     const Reference<XIntrospection> & rI,
     244             :     const Reference<XIdlReflection> & rCR
     245             : )
     246             :     : xTypeConverter( rTC )
     247             :     , xIntrospection( rI )
     248           0 :     , xCoreReflection( rCR )
     249             : {
     250           0 :     setMaterial( rAdapted );
     251           0 : }
     252             : 
     253           0 : Invocation_Impl::~Invocation_Impl() {}
     254             : 
     255             : 
     256             : //### INTERFACE IMPLEMENTATIONS ####################################################################
     257             : 
     258             : 
     259             : 
     260           0 : Any SAL_CALL Invocation_Impl::queryInterface( const Type & aType )
     261             :     throw( RuntimeException, std::exception )
     262             : {
     263             :     // PropertySet-Implementation
     264             :     Any a = ::cppu::queryInterface( aType,
     265             :                                    (static_cast< XInvocation* >(this)),
     266             :                                    (static_cast< XMaterialHolder* >(this)),
     267           0 :                                    (static_cast< XTypeProvider * >(this))    );
     268           0 :     if( a.hasValue() )
     269             :     {
     270           0 :         return a;
     271             :     }
     272             : 
     273           0 :     if( aType  == getCppuType( (Reference<XExactName>*) NULL ) )
     274             :     {
     275             :         // Ivocation does not support XExactName, if direct object supports
     276             :         // XInvocation, but not XExactName.
     277           0 :         if ((_xDirect.is() && _xENDirect.is()) ||
     278           0 :             (!_xDirect.is() && (_xENIntrospection.is() || _xENNameAccess.is())))
     279             :         {
     280           0 :             return makeAny( Reference< XExactName >( (static_cast< XExactName* >(this)) ) );
     281             :         }
     282             :     }
     283           0 :     else if ( aType == getCppuType( (Reference<XNameContainer>*) NULL ) )
     284             :     {
     285           0 :         if( _xNameContainer.is() )
     286           0 :             return makeAny( Reference< XNameContainer >( (static_cast< XNameContainer* >(this)) ) );
     287             :     }
     288           0 :     else if ( aType == getCppuType( (Reference<XNameAccess>*) NULL ) )
     289             :     {
     290           0 :         if( _xNameAccess.is() )
     291           0 :             return makeAny( Reference< XNameAccess >( (static_cast< XNameAccess* >(this)) ) );
     292             :     }
     293           0 :     else if ( aType == getCppuType( (Reference<XIndexContainer>*) NULL ) )
     294             :     {
     295           0 :         if (_xIndexContainer.is())
     296           0 :             return makeAny( Reference< XIndexContainer >( (static_cast< XIndexContainer* >(this)) ) );
     297             :     }
     298           0 :     else if ( aType == getCppuType( (Reference<XIndexAccess>*) NULL ) )
     299             :     {
     300           0 :         if (_xIndexAccess.is())
     301           0 :             return makeAny( Reference< XIndexAccess >( (static_cast< XIndexAccess* >(this)) ) );
     302             :     }
     303           0 :     else if ( aType == getCppuType( (Reference<XEnumerationAccess>*) NULL ) )
     304             :     {
     305           0 :         if (_xEnumerationAccess.is())
     306           0 :             return makeAny( Reference< XEnumerationAccess >( (static_cast< XEnumerationAccess* >(this)) ) );
     307             :     }
     308           0 :     else if ( aType == getCppuType( (Reference<XElementAccess>*) NULL ) )
     309             :     {
     310           0 :         if (_xElementAccess.is())
     311             :         {
     312             :             return makeAny( Reference< XElementAccess >(
     313           0 :                 (static_cast< XElementAccess* >((static_cast< XNameContainer* >(this))) ) ) );
     314             :         }
     315             :     }
     316           0 :     else if ( aType == getCppuType( (Reference<XInvocation2>*) NULL ) )
     317             :     {
     318             :         // Invocation does not support XInvocation2, if direct object supports
     319             :         // XInvocation, but not XInvocation2.
     320           0 :         if ( ( _xDirect.is() && _xDirect2.is()) ||
     321           0 :              (!_xDirect.is() && _xIntrospectionAccess.is() ) )
     322             :         {
     323           0 :             return makeAny( Reference< XInvocation2 >( (static_cast< XInvocation2* >(this)) ) );
     324             :         }
     325             :     }
     326             : 
     327           0 :     return OWeakObject::queryInterface( aType );
     328             : }
     329             : 
     330             : 
     331             : 
     332           0 : Any Invocation_Impl::getMaterial(void) throw(RuntimeException, std::exception)
     333             : {
     334             :     // AB, 12.2.1999  Sicherstellen, dass das Material wenn moeglich
     335             :     // aus der direkten Invocation bzw. von der Introspection geholt
     336             :     // wird, da sonst Structs nicht korrekt behandelt werden
     337           0 :     Reference<XMaterialHolder> xMaterialHolder;
     338           0 :     if( _xDirect.is() )
     339             :     {
     340           0 :         xMaterialHolder = Reference<XMaterialHolder>::query( _xDirect );
     341             :         //_xDirect->queryInterface( XMaterialHolder::getSmartUik(), xMaterialHolder );
     342             :     }
     343           0 :     else if( _xIntrospectionAccess.is() )
     344             :     {
     345           0 :         xMaterialHolder = Reference<XMaterialHolder>::query( _xIntrospectionAccess );
     346             :         //_xIntrospectionAccess->queryInterface( XMaterialHolder::getSmartUik(), xMaterialHolder );
     347             :     }
     348           0 :     if( xMaterialHolder.is() )
     349             :     {
     350           0 :         return xMaterialHolder->getMaterial();
     351             :     }
     352           0 :     return _aMaterial;
     353             : }
     354             : 
     355             : 
     356           0 : void Invocation_Impl::setMaterial( const Any& rMaterial )
     357             : {
     358             :     // set the material first and only once
     359           0 :     Reference<XInterface> xObj;
     360             : 
     361           0 :     if (rMaterial.getValueType().getTypeClass() == TypeClass_INTERFACE)
     362           0 :         xObj = *(Reference<XInterface>*)rMaterial.getValue();
     363           0 :     _aMaterial = rMaterial;
     364             : 
     365             :     // Ersteinmal alles ausserhalb des guards machen
     366           0 :     _xDirect = Reference<XInvocation>::query( xObj );
     367             : 
     368           0 :     if( _xDirect.is() )
     369             :     {
     370             :         // Objekt direkt befragen
     371           0 :         _xElementAccess     = Reference<XElementAccess>::query( _xDirect );
     372           0 :         _xEnumerationAccess = Reference<XEnumerationAccess>::query( _xDirect );
     373           0 :         _xIndexAccess       = Reference<XIndexAccess>::query( _xDirect );
     374           0 :         _xIndexContainer    = Reference<XIndexContainer>::query( _xDirect );
     375           0 :         _xNameAccess        = Reference<XNameAccess>::query( _xDirect );
     376           0 :         _xNameContainer     = Reference<XNameContainer>::query( _xDirect );
     377           0 :         _xENDirect          = Reference<XExactName>::query( _xDirect );
     378           0 :         _xDirect2           = Reference<XInvocation2>::query( _xDirect );
     379             : 
     380             :         // only once!!!
     381             :         //_xIntrospectionAccess = XIntrospectionAccessRef();
     382             :         //_xPropertySet         = XPropertySetRef();
     383             :     }
     384             :     else
     385             :     {
     386             :         // Invocation ueber die Introspection machen
     387           0 :         if (xIntrospection.is())
     388             :         {
     389           0 :             _xIntrospectionAccess = xIntrospection->inspect( _aMaterial );
     390           0 :             if( _xIntrospectionAccess.is() )
     391             :             {
     392             : 
     393           0 :                 _xElementAccess = Reference<XElementAccess>::query(
     394           0 :                       _xIntrospectionAccess->queryAdapter(
     395           0 :                                  getCppuType( (Reference<XElementAccess>*) NULL ) ) );
     396             : 
     397           0 :                 _xEnumerationAccess = Reference<XEnumerationAccess>::query(
     398           0 :                            _xIntrospectionAccess->queryAdapter(
     399           0 :                                 getCppuType( (Reference<XEnumerationAccess>*) NULL )) );
     400             : 
     401           0 :                 _xIndexAccess = Reference<XIndexAccess>::query(
     402           0 :                        _xIntrospectionAccess->queryAdapter(
     403           0 :                                 getCppuType( (Reference<XIndexAccess>*) NULL ) ) );
     404             : 
     405           0 :                 _xIndexContainer = Reference<XIndexContainer>::query(
     406           0 :                      _xIntrospectionAccess->queryAdapter(
     407           0 :                                 getCppuType( (Reference<XIndexContainer>*) NULL ) ) );
     408             : 
     409           0 :                 _xNameAccess = Reference<XNameAccess>::query(
     410           0 :                      _xIntrospectionAccess->queryAdapter(
     411           0 :                                 getCppuType( (Reference<XNameAccess>*) NULL ) ) );
     412             : 
     413           0 :                 _xNameContainer = Reference<XNameContainer>::query(
     414           0 :                            _xIntrospectionAccess->queryAdapter(
     415           0 :                                getCppuType( (Reference<XNameContainer>*) NULL ) ) );
     416             : 
     417           0 :                 _xPropertySet = Reference<XPropertySet>::query(
     418           0 :                            _xIntrospectionAccess->queryAdapter(
     419           0 :                                getCppuType( (Reference<XPropertySet>*) NULL )) );
     420             : 
     421           0 :                 _xENIntrospection = Reference<XExactName>::query( _xIntrospectionAccess );
     422           0 :                 if (_xNameAccess.is())
     423           0 :                     _xENNameAccess = Reference<XExactName>::query( _xNameAccess );
     424             :             }
     425             :         }
     426             :         /* only once !!!
     427             :         _xDirect = XInvocationRef();
     428             :         if( !_xIntrospectionAccess.is() )
     429             :         {
     430             :             // reset
     431             :             _xElementAccess     = XElementAccessRef();
     432             :             _xEnumerationAccess = XEnumerationAccessRef();
     433             :             _xIndexAccess       = XIndexAccessRef();
     434             :             _xIndexContainer    = XIndexContainerRef();
     435             :             _xNameAccess        = XNameAccessRef();
     436             :             _xNameContainer     = XNameContainerRef();
     437             :             _xPropertySet       = XPropertySetRef();
     438             :         }
     439             :         */
     440           0 :     }
     441           0 : }
     442             : 
     443             : 
     444           0 : OUString Invocation_Impl::getExactName( const OUString& rApproximateName )
     445             :     throw( RuntimeException, std::exception )
     446             : {
     447           0 :     if (_xENDirect.is())
     448           0 :         return _xENDirect->getExactName( rApproximateName );
     449             : 
     450           0 :     OUString aRet;
     451           0 :     if (_xENIntrospection.is())
     452           0 :         aRet = _xENIntrospection->getExactName( rApproximateName );
     453           0 :     if (aRet.isEmpty() && _xENNameAccess.is())
     454           0 :         aRet = _xENNameAccess->getExactName( rApproximateName );
     455           0 :     return aRet;
     456             : }
     457             : 
     458             : 
     459           0 : Reference<XIntrospectionAccess> Invocation_Impl::getIntrospection(void)
     460             :     throw( RuntimeException, std::exception )
     461             : {
     462           0 :     if( _xDirect.is() )
     463           0 :         return _xDirect->getIntrospection();
     464             :     else
     465           0 :         return _xIntrospectionAccess;
     466             : }
     467             : 
     468             : 
     469           0 : sal_Bool Invocation_Impl::hasMethod( const OUString& Name )
     470             :     throw( RuntimeException, std::exception )
     471             : {
     472           0 :     if (_xDirect.is())
     473           0 :         return _xDirect->hasMethod( Name );
     474           0 :     if( _xIntrospectionAccess.is() )
     475           0 :         return _xIntrospectionAccess->hasMethod( Name, MethodConcept::ALL ^ MethodConcept::DANGEROUS );
     476           0 :     return sal_False;
     477             : }
     478             : 
     479             : 
     480           0 : sal_Bool Invocation_Impl::hasProperty( const OUString& Name )
     481             :     throw( RuntimeException, std::exception )
     482             : {
     483           0 :     if (_xDirect.is())
     484           0 :         return _xDirect->hasProperty( Name );
     485             :     // PropertySet
     486           0 :     if( _xIntrospectionAccess.is()
     487           0 :         && _xIntrospectionAccess->hasProperty( Name, PropertyConcept::ALL ^ PropertyConcept::DANGEROUS ) )
     488           0 :         return sal_True;
     489             :     // NameAccess
     490           0 :     if( _xNameAccess.is() )
     491           0 :         return _xNameAccess->hasByName( Name );
     492           0 :     return sal_False;
     493             : }
     494             : 
     495             : 
     496           0 : Any Invocation_Impl::getValue( const OUString& PropertyName )
     497             :     throw( UnknownPropertyException, RuntimeException, std::exception )
     498             : {
     499           0 :     if (_xDirect.is())
     500           0 :         return _xDirect->getValue( PropertyName );
     501             :     try
     502             :     {
     503             :         // PropertySet
     504           0 :         if( _xIntrospectionAccess.is() && _xPropertySet.is()
     505           0 :             && _xIntrospectionAccess->hasProperty
     506           0 :             ( PropertyName, PropertyConcept::ALL ^ PropertyConcept::DANGEROUS ) )
     507             :         {
     508           0 :             return _xPropertySet->getPropertyValue( PropertyName );
     509             :         }
     510             :         // NameAccess
     511           0 :         if( _xNameAccess.is() && _xNameAccess->hasByName( PropertyName ) )
     512           0 :             return _xNameAccess->getByName( PropertyName );
     513             :     }
     514           0 :     catch (UnknownPropertyException &)
     515             :     {
     516           0 :         throw;
     517             :     }
     518           0 :     catch (RuntimeException &)
     519             :     {
     520           0 :         throw;
     521             :     }
     522           0 :     catch (Exception &)
     523             :     {
     524             :     }
     525             : 
     526             :     throw UnknownPropertyException(
     527           0 :         OUString("cannot get value ") + PropertyName,
     528           0 :         Reference< XInterface >() );
     529             : }
     530             : 
     531             : 
     532           0 : void Invocation_Impl::setValue( const OUString& PropertyName, const Any& Value )
     533             :     throw( UnknownPropertyException, CannotConvertException, InvocationTargetException, RuntimeException, std::exception )
     534             : {
     535           0 :     if (_xDirect.is())
     536           0 :         _xDirect->setValue( PropertyName, Value );
     537             :     else
     538             :     {
     539             :         try
     540             :         {
     541             :             // Properties
     542           0 :             if( _xIntrospectionAccess.is() && _xPropertySet.is()
     543           0 :                 && _xIntrospectionAccess->hasProperty(
     544           0 :                     PropertyName, PropertyConcept::ALL ^ PropertyConcept::DANGEROUS ) )
     545             :             {
     546           0 :                 Property aProp = _xIntrospectionAccess->getProperty(
     547           0 :                     PropertyName, PropertyConcept::ALL ^ PropertyConcept::DANGEROUS );
     548           0 :                 Reference < XIdlClass > r = TypeToIdlClass( aProp.Type, xCoreReflection );
     549           0 :                 if( r->isAssignableFrom( TypeToIdlClass( Value.getValueType(), xCoreReflection ) ) )
     550           0 :                     _xPropertySet->setPropertyValue( PropertyName, Value );
     551           0 :                 else if( xTypeConverter.is() )
     552           0 :                     _xPropertySet->setPropertyValue(
     553           0 :                         PropertyName, xTypeConverter->convertTo( Value, aProp.Type ) );
     554             :                 else
     555             :                     throw RuntimeException(
     556             :                         OUString("no type converter service!"),
     557           0 :                         Reference< XInterface >() );
     558             :             }
     559             :             // NameContainer
     560           0 :             else if( _xNameContainer.is() )
     561             :             {
     562           0 :                 Any aConv;
     563             :                 Reference < XIdlClass > r =
     564           0 :                     TypeToIdlClass( _xNameContainer->getElementType(), xCoreReflection );
     565           0 :                 if( r->isAssignableFrom(TypeToIdlClass( Value.getValueType(), xCoreReflection ) ) )
     566           0 :                     aConv = Value;
     567           0 :                 else if( xTypeConverter.is() )
     568           0 :                     aConv = xTypeConverter->convertTo( Value, _xNameContainer->getElementType() );
     569             :                 else
     570             :                     throw RuntimeException(
     571             :                         OUString("no type converter service!"),
     572           0 :                         Reference< XInterface >() );
     573             : 
     574             :                 // bei Vorhandensein ersetzen, ansonsten einfuegen
     575           0 :                 if (_xNameContainer->hasByName( PropertyName ))
     576           0 :                     _xNameContainer->replaceByName( PropertyName, aConv );
     577             :                 else
     578           0 :                     _xNameContainer->insertByName( PropertyName, aConv );
     579             :             }
     580             :             else
     581             :                 throw UnknownPropertyException(
     582             :                     OUString("no introspection nor name container!"),
     583           0 :                     Reference< XInterface >() );
     584             :         }
     585           0 :         catch (UnknownPropertyException &)
     586             :         {
     587           0 :             throw;
     588             :         }
     589           0 :         catch (CannotConvertException &)
     590             :         {
     591           0 :             throw;
     592             :         }
     593           0 :         catch (InvocationTargetException &)
     594             :         {
     595           0 :             throw;
     596             :         }
     597           0 :         catch (RuntimeException &)
     598             :         {
     599           0 :             throw;
     600             :         }
     601           0 :         catch (const Exception & exc)
     602             :         {
     603             :             throw InvocationTargetException(
     604           0 :                 OUString( "exception occurred in setValue(): " ) +
     605           0 :                 exc.Message, Reference< XInterface >(), makeAny( exc /* though sliced */ ) );
     606             :         }
     607             :     }
     608           0 : }
     609             : 
     610             : 
     611           0 : Any Invocation_Impl::invoke( const OUString& FunctionName, const Sequence<Any>& InParams,
     612             :                                 Sequence<sal_Int16>& OutIndices, Sequence<Any>& OutParams )
     613             :     throw( IllegalArgumentException, CannotConvertException, InvocationTargetException, RuntimeException, std::exception )
     614             : {
     615           0 :     if (_xDirect.is())
     616           0 :         return _xDirect->invoke( FunctionName, InParams, OutIndices, OutParams );
     617             : 
     618           0 :     if (_xIntrospectionAccess.is())
     619             :     {
     620             :         // throw NoSuchMethodException if not exist
     621           0 :         Reference<XIdlMethod> xMethod = _xIntrospectionAccess->getMethod(
     622           0 :             FunctionName, MethodConcept::ALL ^ MethodConcept::DANGEROUS );
     623             : 
     624             :         // ParameterInfos
     625           0 :         Sequence<ParamInfo> aFParams        = xMethod->getParameterInfos();
     626           0 :         const ParamInfo* pFParams           = aFParams.getConstArray();
     627           0 :         sal_Int32 nFParamsLen               = aFParams.getLength();
     628           0 :         if (nFParamsLen != InParams.getLength())
     629             :         {
     630             :             throw IllegalArgumentException(
     631           0 :                 OUString("incorrect number of parameters passed invoking function ") + FunctionName,
     632           0 :                 (OWeakObject *) this, (sal_Int16) 1 );
     633             :         }
     634             : 
     635             :         // IN Parameter
     636           0 :         const Any* pInParams                = InParams.getConstArray();
     637             : 
     638             :         // Introspection Invoke Parameter
     639           0 :         Sequence<Any> aInvokeParams( nFParamsLen );
     640           0 :         Any* pInvokeParams                  = aInvokeParams.getArray();
     641             : 
     642             :         // OUT Indices
     643           0 :         OutIndices.realloc( nFParamsLen );
     644           0 :         sal_Int16* pOutIndices              = OutIndices.getArray();
     645           0 :         sal_uInt32 nOutIndex                = 0;
     646             : 
     647           0 :         for ( sal_Int32 nPos = 0; nPos < nFParamsLen; ++nPos )
     648             :         {
     649             :             try
     650             :             {
     651           0 :                 const ParamInfo& rFParam = pFParams[nPos];
     652           0 :                 const Reference<XIdlClass>& rDestType = rFParam.aType;
     653             : 
     654             :                 // is IN/INOUT parameter?
     655           0 :                 if (rFParam.aMode != ParamMode_OUT)
     656             :                 {
     657           0 :                     if (rDestType->isAssignableFrom( TypeToIdlClass( pInParams[nPos].getValueType(), xCoreReflection ) ))
     658             :                     {
     659           0 :                         pInvokeParams[nPos] = pInParams[nPos];
     660             :                     }
     661           0 :                     else if (xTypeConverter.is())
     662             :                     {
     663           0 :                         Type aDestType( rDestType->getTypeClass(), rDestType->getName() );
     664           0 :                         pInvokeParams[nPos] = xTypeConverter->convertTo( pInParams[nPos], aDestType );
     665             :                     }
     666             :                     else
     667             :                     {
     668           0 :                         CannotConvertException aExc;
     669           0 :                         aExc.Context = *this;
     670           0 :                         aExc.Message = "invocation type mismatch!";
     671           0 :                         throw aExc;
     672             :                     }
     673             :                 }
     674             : 
     675             :                 // is OUT/INOUT parameter?
     676           0 :                 if (rFParam.aMode != ParamMode_IN)
     677             :                 {
     678           0 :                     pOutIndices[nOutIndex] = (sal_Int16)nPos;
     679           0 :                     if (rFParam.aMode == ParamMode_OUT)
     680           0 :                         rDestType->createObject( pInvokeParams[nPos] );     // default init
     681           0 :                     ++nOutIndex;
     682             :                 }
     683             :             }
     684           0 :             catch( CannotConvertException& rExc )
     685             :             {
     686           0 :                 rExc.ArgumentIndex = nPos;  // optionalen Parameter Index hinzufuegen
     687           0 :                 throw;
     688             :             }
     689             :         }
     690             : 
     691             :         // execute Method
     692           0 :         Any aRet = xMethod->invoke( _aMaterial, aInvokeParams );
     693             : 
     694             :         // OUT Params
     695           0 :         OutIndices.realloc( nOutIndex );
     696           0 :         pOutIndices        = OutIndices.getArray();
     697           0 :         OutParams.realloc( nOutIndex );
     698           0 :         Any* pOutParams = OutParams.getArray();
     699             : 
     700           0 :         while (nOutIndex--)
     701             :         {
     702           0 :             pOutParams[nOutIndex] = pInvokeParams[ pOutIndices[nOutIndex] ];
     703             :         }
     704             : 
     705           0 :         return aRet;
     706             :     }
     707             : 
     708           0 :     RuntimeException aExc;
     709           0 :     aExc.Context = *this;
     710           0 :     aExc.Message = "invocation lacking of introspection access!";
     711           0 :     throw aExc;
     712             : }
     713             : 
     714             : 
     715             : 
     716             : // Struct to optimize sorting
     717           0 : struct MemberItem
     718             : {
     719             :     OUString aName;
     720             : 
     721             :     // Defines where the member comes from
     722             :     enum Mode { NAMEACCESS, PROPERTYSET, METHOD } eMode;
     723             : 
     724             :     // Index to respective sequence
     725             :     // (Index to NameAccess sequence for eMode==NAMEACCESS etc.)
     726             :     sal_Int32 nIndex;
     727             : };
     728             : 
     729             : // Implementation of getting name or info
     730             : // String sequence will be filled when pStringSeq != NULL
     731             : // Info sequence will be filled when pInfoSeq != NULL
     732           0 : void Invocation_Impl::getInfoSequenceImpl
     733             : (
     734             :     Sequence< OUString >* pStringSeq,
     735             :     Sequence< InvocationInfo >* pInfoSeq
     736             : )
     737             : {
     738             :     //Sequence< OUString > aStrSeq;
     739             :     //if( !pStringSeq )
     740             :         //pStringSeq = &aStrSeq;
     741             : 
     742             : 
     743             :     // Get all needed sequences
     744           0 :     Sequence<OUString> aNameAccessNames;
     745           0 :     Sequence<Property> aPropertySeq;
     746           0 :     Sequence< Reference< XIdlMethod > > aMethodSeq;
     747             : 
     748           0 :     if( _xNameAccess.is() )
     749             :     {
     750           0 :         aNameAccessNames = _xNameAccess->getElementNames();
     751             :     }
     752             : 
     753           0 :     if( _xIntrospectionAccess.is() )
     754             :     {
     755           0 :         aPropertySeq = _xIntrospectionAccess->getProperties
     756           0 :             ( PropertyConcept::ALL - PropertyConcept::DANGEROUS );
     757             : 
     758           0 :         aMethodSeq = _xIntrospectionAccess->getMethods
     759           0 :             ( MethodConcept::ALL - MethodConcept::DANGEROUS );
     760             :     }
     761             : 
     762           0 :     sal_Int32 nNameAccessCount = aNameAccessNames.getLength();
     763           0 :     sal_Int32 nPropertyCount = aPropertySeq.getLength();
     764           0 :     sal_Int32 nMethodCount = aMethodSeq.getLength();
     765           0 :     sal_Int32 nTotalCount = nNameAccessCount + nPropertyCount + nMethodCount;
     766             : 
     767             :     // Create and fill array of MemberItems
     768           0 :     boost::scoped_array< MemberItem > pItems( new MemberItem[ nTotalCount ] );
     769           0 :     const OUString* pStrings = aNameAccessNames.getConstArray();
     770           0 :     const Property* pProps = aPropertySeq.getConstArray();
     771           0 :     const Reference< XIdlMethod >* pMethods = aMethodSeq.getConstArray();
     772             : 
     773             :     // Fill array of MemberItems
     774           0 :     sal_Int32 i, iTotal = 0;
     775             : 
     776             :     // Name Access
     777           0 :     for( i = 0 ; i < nNameAccessCount ; i++, iTotal++ )
     778             :     {
     779           0 :         MemberItem& rItem = pItems[ iTotal ];
     780           0 :         rItem.aName = pStrings[ i ];
     781           0 :         rItem.eMode = MemberItem::NAMEACCESS;
     782           0 :         rItem.nIndex = i;
     783             :     }
     784             : 
     785             :     // Property set
     786           0 :     for( i = 0 ; i < nPropertyCount ; i++, iTotal++ )
     787             :     {
     788           0 :         MemberItem& rItem = pItems[ iTotal ];
     789           0 :         rItem.aName = pProps[ i ].Name;
     790           0 :         rItem.eMode = MemberItem::PROPERTYSET;
     791           0 :         rItem.nIndex = i;
     792             :     }
     793             : 
     794             :     // Methods
     795           0 :     for( i = 0 ; i < nMethodCount ; i++, iTotal++ )
     796             :     {
     797           0 :         MemberItem& rItem = pItems[ iTotal ];
     798           0 :         Reference< XIdlMethod > xMethod = pMethods[ i ];
     799           0 :         rItem.aName = xMethod->getName();
     800           0 :         rItem.eMode = MemberItem::METHOD;
     801           0 :         rItem.nIndex = i;
     802           0 :     }
     803             : 
     804             :     // Setting up result sequences
     805           0 :     OUString* pRetStrings = NULL;
     806           0 :     if( pStringSeq )
     807             :     {
     808           0 :         pStringSeq->realloc( nTotalCount );
     809           0 :         pRetStrings = pStringSeq->getArray();
     810             :     }
     811             : 
     812           0 :     InvocationInfo* pRetInfos = NULL;
     813           0 :     if( pInfoSeq )
     814             :     {
     815           0 :         pInfoSeq->realloc( nTotalCount );
     816           0 :         pRetInfos = pInfoSeq->getArray();
     817             :     }
     818             : 
     819             :     // Fill result sequences in the correct order of members
     820           0 :     for( iTotal = 0 ; iTotal < nTotalCount ; iTotal++ )
     821             :     {
     822           0 :         MemberItem& rItem = pItems[ iTotal ];
     823           0 :         if( pRetStrings )
     824             :         {
     825           0 :             pRetStrings[ iTotal ] = rItem.aName;
     826             :         }
     827             : 
     828           0 :         if( pRetInfos )
     829             :         {
     830           0 :             if( rItem.eMode == MemberItem::NAMEACCESS )
     831             :             {
     832           0 :                 fillInfoForNameAccess( pRetInfos[ iTotal ], rItem.aName );
     833             :             }
     834           0 :             else if( rItem.eMode == MemberItem::PROPERTYSET )
     835             :             {
     836           0 :                 fillInfoForProperty( pRetInfos[ iTotal ], pProps[ rItem.nIndex ] );
     837             :             }
     838           0 :             else if( rItem.eMode == MemberItem::METHOD )
     839             :             {
     840           0 :                 fillInfoForMethod( pRetInfos[ iTotal ], pMethods[ rItem.nIndex ] );
     841             :             }
     842             :         }
     843           0 :     }
     844           0 : }
     845             : 
     846             : // XInvocation2
     847           0 : Sequence< OUString > SAL_CALL Invocation_Impl::getMemberNames(  )
     848             :     throw( RuntimeException, std::exception )
     849             : {
     850           0 :     if( _xDirect2.is() )
     851             :     {
     852           0 :         return _xDirect2->getMemberNames();
     853             :     }
     854           0 :     Sequence< OUString > aRetSeq;
     855           0 :     getInfoSequenceImpl( &aRetSeq, NULL );
     856           0 :     return aRetSeq;
     857             : }
     858             : 
     859           0 : Sequence< InvocationInfo > SAL_CALL Invocation_Impl::getInfo(  )
     860             :     throw( RuntimeException, std::exception )
     861             : {
     862           0 :     if( _xDirect2.is() )
     863             :     {
     864           0 :         return _xDirect2->getInfo();
     865             :     }
     866           0 :     Sequence< InvocationInfo > aRetSeq;
     867           0 :     getInfoSequenceImpl( NULL, &aRetSeq );
     868           0 :     return aRetSeq;
     869             : }
     870             : 
     871           0 : InvocationInfo SAL_CALL Invocation_Impl::getInfoForName( const OUString& aName, sal_Bool bExact )
     872             :     throw( IllegalArgumentException, RuntimeException, std::exception )
     873             : {
     874           0 :     if( _xDirect2.is() )
     875             :     {
     876           0 :         return _xDirect2->getInfoForName( aName, bExact );
     877             :     }
     878             : 
     879           0 :     bool bFound = false;
     880           0 :     OUString aExactName = aName;
     881           0 :     InvocationInfo aRetInfo;
     882             : 
     883           0 :     if( bExact )
     884           0 :         aExactName = getExactName( aName );
     885           0 :     if( !aExactName.isEmpty() )
     886             :     {
     887           0 :         if( _xIntrospectionAccess->hasMethod( aExactName, MethodConcept::ALL ^ MethodConcept::DANGEROUS ) )
     888             :         {
     889           0 :             Reference<XIdlMethod> xMethod = _xIntrospectionAccess->getMethod
     890           0 :                 ( aExactName, MethodConcept::ALL ^ MethodConcept::DANGEROUS );
     891           0 :             fillInfoForMethod( aRetInfo, xMethod );
     892           0 :             bFound = true;
     893             :         }
     894             :         else
     895             :         {
     896           0 :             if( _xIntrospectionAccess.is() && _xIntrospectionAccess->hasProperty
     897           0 :                  ( aExactName, PropertyConcept::ALL ^ PropertyConcept::DANGEROUS ) )
     898             :             {
     899           0 :                  Property aProp = _xIntrospectionAccess->getProperty
     900           0 :                     ( aExactName, PropertyConcept::ALL ^ PropertyConcept::DANGEROUS );
     901           0 :                 fillInfoForProperty( aRetInfo, aProp );
     902           0 :                 bFound = true;
     903             :             }
     904             :             // NameAccess
     905           0 :             else if( _xNameAccess.is() && _xNameAccess->hasByName( aExactName ) )
     906             :             {
     907           0 :                 fillInfoForNameAccess( aRetInfo, aExactName );
     908           0 :                 bFound = true;
     909             :             }
     910             :         }
     911             :     }
     912           0 :     if( !bFound )
     913             :     {
     914             :         throw IllegalArgumentException(
     915             :             OUString( "Unknown name, getExactName() failed!" ),
     916           0 :             (XWeak *)(OWeakObject *)this, 0 );
     917             :     }
     918           0 :     return aRetInfo;
     919             : }
     920             : 
     921             : // Helper functions to fill InvocationInfo for XNameAccess
     922           0 : void Invocation_Impl::fillInfoForNameAccess
     923             : (
     924             :     InvocationInfo& rInfo,
     925             :     const OUString& aName
     926             : )
     927             : {
     928           0 :     rInfo.aName = aName;
     929           0 :     rInfo.eMemberType = MemberType_PROPERTY;
     930           0 :     rInfo.PropertyAttribute = 0;
     931           0 :     if( !_xNameContainer.is() )
     932             :     {
     933           0 :         rInfo.PropertyAttribute = PropertyAttribute::READONLY;
     934             :     }
     935           0 :     rInfo.aType = _xNameAccess->getElementType();
     936           0 : }
     937             : 
     938           0 : void Invocation_Impl::fillInfoForProperty
     939             : (
     940             :     InvocationInfo& rInfo,
     941             :     const Property& rProp
     942             : )
     943             : {
     944           0 :     rInfo.aName = rProp.Name;
     945           0 :     rInfo.eMemberType = MemberType_PROPERTY;
     946           0 :     rInfo.PropertyAttribute = rProp.Attributes;
     947           0 :     rInfo.aType = rProp.Type;
     948           0 : }
     949             : 
     950           0 : void Invocation_Impl::fillInfoForMethod
     951             : (
     952             :     InvocationInfo& rInfo,
     953             :     const Reference< XIdlMethod > xMethod
     954             : )
     955             : {
     956           0 :     rInfo.aName = xMethod->getName();
     957           0 :     rInfo.eMemberType = MemberType_METHOD;
     958           0 :     Reference< XIdlClass > xReturnClass = xMethod->getReturnType();
     959           0 :     Type aReturnType( xReturnClass->getTypeClass(), xReturnClass->getName() );
     960           0 :     rInfo.aType = aReturnType;
     961           0 :     Sequence<ParamInfo> aParamInfos = xMethod->getParameterInfos();
     962           0 :     sal_Int32 nParamCount = aParamInfos.getLength();
     963           0 :     if( nParamCount > 0 )
     964             :     {
     965           0 :         const ParamInfo* pInfos = aParamInfos.getConstArray();
     966             : 
     967           0 :         rInfo.aParamTypes.realloc( nParamCount );
     968           0 :         Type* pParamTypes = rInfo.aParamTypes.getArray();
     969           0 :         rInfo.aParamModes.realloc( nParamCount );
     970           0 :         ParamMode* pParamModes = rInfo.aParamModes.getArray();
     971             : 
     972           0 :         for( sal_Int32 i = 0 ; i < nParamCount ; i++ )
     973             :         {
     974           0 :             Reference< XIdlClass > xParamClass = pInfos[i].aType;
     975           0 :             Type aParamType( xParamClass->getTypeClass(), xParamClass->getName() );
     976           0 :             pParamTypes[ i ] = aParamType;
     977           0 :             pParamModes[ i ] = pInfos[i].aMode;
     978           0 :         }
     979           0 :     }
     980           0 : }
     981             : 
     982             : 
     983             : // XTypeProvider
     984           0 : Sequence< Type > SAL_CALL Invocation_Impl::getTypes(void) throw( RuntimeException, std::exception )
     985             : {
     986             :     static Sequence< Type > const * s_pTypes = 0;
     987           0 :     if (! s_pTypes)
     988             :     {
     989           0 :         Sequence< Type > types( 4 +8 );
     990           0 :         Type * pTypes = types.getArray();
     991           0 :         sal_Int32 n = 0;
     992             : 
     993           0 :         pTypes[ n++ ] = ::getCppuType( (Reference< XTypeProvider > const *)0 );
     994           0 :         pTypes[ n++ ] = ::getCppuType( (Reference< XWeak > const *)0 );
     995           0 :         pTypes[ n++ ] = ::getCppuType( (Reference< XInvocation > const *)0 );
     996           0 :         pTypes[ n++ ] = ::getCppuType( (Reference< XMaterialHolder > const *)0 );
     997             : 
     998             :         // Ivocation does not support XExactName, if direct object supports
     999             :         // XInvocation, but not XExactName.
    1000           0 :         if ((_xDirect.is() && _xENDirect.is()) ||
    1001           0 :             (!_xDirect.is() && (_xENIntrospection.is() || _xENNameAccess.is())))
    1002             :         {
    1003           0 :             pTypes[ n++ ] = ::getCppuType( (Reference< XExactName > const *)0 );
    1004             :         }
    1005           0 :         if( _xNameContainer.is() )
    1006             :         {
    1007           0 :             pTypes[ n++ ] = ::getCppuType( (Reference< XNameContainer > const *)0 );
    1008             :         }
    1009           0 :         if( _xNameAccess.is() )
    1010             :         {
    1011           0 :             pTypes[ n++ ] = ::getCppuType( (Reference< XNameAccess > const *)0 );
    1012             :         }
    1013           0 :         if (_xIndexContainer.is())
    1014             :         {
    1015           0 :             pTypes[ n++ ] = ::getCppuType( (Reference< XIndexContainer > const *)0 );
    1016             :         }
    1017           0 :         if (_xIndexAccess.is())
    1018             :         {
    1019           0 :             pTypes[ n++ ] = ::getCppuType( (Reference< XIndexAccess > const *)0 );
    1020             :         }
    1021           0 :         if (_xEnumerationAccess.is())
    1022             :         {
    1023           0 :             pTypes[ n++ ] = ::getCppuType( (Reference< XEnumerationAccess > const *)0 );
    1024             :         }
    1025           0 :         if (_xElementAccess.is())
    1026             :         {
    1027           0 :             pTypes[ n++ ] = ::getCppuType( (Reference< XElementAccess > const *)0 );
    1028             :         }
    1029             :         // Invocation does not support XInvocation2, if direct object supports
    1030             :         // XInvocation, but not XInvocation2.
    1031           0 :         if ( ( _xDirect.is() && _xDirect2.is()) ||
    1032           0 :              (!_xDirect.is() && _xIntrospectionAccess.is() ) )
    1033             :         {
    1034           0 :             pTypes[ n++ ] = ::getCppuType( (Reference< XInvocation2 > const *)0 );
    1035             :         }
    1036             : 
    1037           0 :         types.realloc( n );
    1038             : 
    1039             :         // store types
    1040           0 :         MutexGuard guard( Mutex::getGlobalMutex() );
    1041           0 :         if (! s_pTypes)
    1042             :         {
    1043           0 :             static Sequence< Type > s_types( types );
    1044           0 :             s_pTypes = &s_types;
    1045           0 :         }
    1046             :     }
    1047           0 :     return *s_pTypes;
    1048             : }
    1049             : 
    1050           0 : Sequence< sal_Int8 > SAL_CALL Invocation_Impl::getImplementationId(  ) throw( RuntimeException, std::exception)
    1051             : {
    1052           0 :     return css::uno::Sequence<sal_Int8>();
    1053             : }
    1054             : 
    1055             : 
    1056             : 
    1057             : 
    1058             : class InvocationService
    1059             :     : public WeakImplHelper2< XSingleServiceFactory, XServiceInfo >
    1060             : {
    1061             : public:
    1062             :     InvocationService( const Reference<XComponentContext> & xCtx );
    1063             :     virtual ~InvocationService();
    1064             : 
    1065             :     // XServiceInfo
    1066             :     OUString                    SAL_CALL getImplementationName() throw( RuntimeException, std::exception ) SAL_OVERRIDE;
    1067             :     sal_Bool                        SAL_CALL supportsService(const OUString& ServiceName) throw( RuntimeException, std::exception ) SAL_OVERRIDE;
    1068             :     Sequence< OUString >        SAL_CALL getSupportedServiceNames(void) throw( RuntimeException, std::exception ) SAL_OVERRIDE;
    1069             : 
    1070             :     // XSingleServiceFactory
    1071             :     Reference<XInterface>       SAL_CALL createInstance(void) throw( Exception, RuntimeException, std::exception ) SAL_OVERRIDE;
    1072             :     Reference<XInterface>       SAL_CALL createInstanceWithArguments(
    1073             :         const Sequence<Any>& rArguments ) throw( Exception, RuntimeException, std::exception ) SAL_OVERRIDE;
    1074             : private:
    1075             :     Reference<XComponentContext> mxCtx;
    1076             :     Reference<XMultiComponentFactory> mxSMgr;
    1077             :     Reference<XTypeConverter> xTypeConverter;
    1078             :     Reference<XIntrospection> xIntrospection;
    1079             :     Reference<XIdlReflection> xCoreReflection;
    1080             : };
    1081             : 
    1082           0 : InvocationService::InvocationService( const Reference<XComponentContext> & xCtx )
    1083             :     : mxCtx( xCtx )
    1084           0 :     , mxSMgr( xCtx->getServiceManager() )
    1085           0 :     , xCoreReflection( css::reflection::theCoreReflection::get(mxCtx) )
    1086             : {
    1087           0 :     xTypeConverter = Reference<XTypeConverter>(
    1088           0 :         mxSMgr->createInstanceWithContext(
    1089             :             OUString("com.sun.star.script.Converter"),
    1090           0 :             xCtx ),
    1091           0 :         UNO_QUERY );
    1092           0 :     xIntrospection = theIntrospection::get(xCtx);
    1093           0 : }
    1094             : 
    1095           0 : InvocationService::~InvocationService() {}
    1096             : 
    1097             : // XServiceInfo
    1098           0 : OUString InvocationService::getImplementationName() throw( RuntimeException, std::exception )
    1099             : {
    1100           0 :     return inv_getImplementationName();
    1101             : }
    1102             : 
    1103             : // XServiceInfo
    1104           0 : sal_Bool InvocationService::supportsService(const OUString& ServiceName) throw( RuntimeException, std::exception )
    1105             : {
    1106           0 :     return cppu::supportsService(this, ServiceName);
    1107             : }
    1108             : 
    1109             : // XServiceInfo
    1110           0 : Sequence< OUString > InvocationService::getSupportedServiceNames(void) throw( RuntimeException, std::exception )
    1111             : {
    1112           0 :     return inv_getSupportedServiceNames();
    1113             : }
    1114             : 
    1115             : 
    1116           0 : Reference<XInterface> InvocationService::createInstance(void) throw( Exception, RuntimeException, std::exception )
    1117             : {
    1118             :     //TODO:throw( Exception("no default construction of invocation adapter possible!", *this) );
    1119           0 :     return Reference<XInterface>(); // dummy
    1120             : }
    1121             : 
    1122             : 
    1123           0 : Reference<XInterface> InvocationService::createInstanceWithArguments(
    1124             :     const Sequence<Any>& rArguments ) throw( Exception, RuntimeException, std::exception )
    1125             : {
    1126           0 :     if (rArguments.getLength() == 1)
    1127             :     {
    1128             :         return Reference< XInterface >
    1129             :             ( *new Invocation_Impl( *rArguments.getConstArray(),
    1130           0 :               xTypeConverter, xIntrospection, xCoreReflection ) );
    1131             :     }
    1132             :     else
    1133             :     {
    1134             :         //TODO:throw( Exception("no default construction of invocation adapter possible!", *this) );
    1135           0 :         return Reference<XInterface>();
    1136             :     }
    1137             : }
    1138             : 
    1139             : 
    1140             : 
    1141           0 : Reference<XInterface> SAL_CALL InvocationService_CreateInstance( const Reference<XComponentContext> & xCtx )
    1142             :     throw( RuntimeException )
    1143             : {
    1144           0 :     Reference<XInterface> xService = Reference< XInterface > ( *new InvocationService( xCtx ) );
    1145           0 :     return xService;
    1146             : }
    1147             : 
    1148             : }
    1149             : 
    1150             : using namespace stoc_inv;
    1151             : static const struct ImplementationEntry g_entries[] =
    1152             : {
    1153             :     {
    1154             :         InvocationService_CreateInstance, inv_getImplementationName,
    1155             :         inv_getSupportedServiceNames, createSingleComponentFactory,
    1156             :         0, 0
    1157             :     },
    1158             :     { 0, 0, 0, 0, 0, 0 }
    1159             : };
    1160             : 
    1161           0 : extern "C" SAL_DLLPUBLIC_EXPORT void * SAL_CALL invocation_component_getFactory(
    1162             :     const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey )
    1163             : {
    1164           0 :     return component_getFactoryHelper( pImplName, pServiceManager, pRegistryKey , g_entries );
    1165             : }
    1166             : 
    1167             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10