LCOV - code coverage report
Current view: top level - basic/source/classes - sbunoobj.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 963 2525 38.1 %
Date: 2012-08-25 Functions: 95 221 43.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 1098 5369 20.5 %

           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                 :            : #include <osl/mutex.hxx>
      21                 :            : #include <vcl/svapp.hxx>
      22                 :            : #include <tools/errcode.hxx>
      23                 :            : #include <svl/hint.hxx>
      24                 :            : 
      25                 :            : #include <cppuhelper/implbase1.hxx>
      26                 :            : #include <cppuhelper/implbase2.hxx>
      27                 :            : #include <cppuhelper/exc_hlp.hxx>
      28                 :            : #include <cppuhelper/typeprovider.hxx>
      29                 :            : #include <cppuhelper/interfacecontainer.hxx>
      30                 :            : #include <comphelper/extract.hxx>
      31                 :            : #include <comphelper/processfactory.hxx>
      32                 :            : 
      33                 :            : #include <rtl/instance.hxx>
      34                 :            : #include <rtl/strbuf.hxx>
      35                 :            : #include <rtl/ustrbuf.hxx>
      36                 :            : 
      37                 :            : #include <com/sun/star/script/ArrayWrapper.hpp>
      38                 :            : #include <com/sun/star/script/NativeObjectWrapper.hpp>
      39                 :            : 
      40                 :            : #include <com/sun/star/uno/XComponentContext.hpp>
      41                 :            : #include <com/sun/star/uno/DeploymentException.hpp>
      42                 :            : #include <com/sun/star/lang/XTypeProvider.hpp>
      43                 :            : #include <com/sun/star/lang/XSingleServiceFactory.hpp>
      44                 :            : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      45                 :            : #include <com/sun/star/lang/XServiceInfo.hpp>
      46                 :            : #include <com/sun/star/beans/PropertyAttribute.hpp>
      47                 :            : #include <com/sun/star/beans/PropertyConcept.hpp>
      48                 :            : #include <com/sun/star/beans/MethodConcept.hpp>
      49                 :            : #include <com/sun/star/beans/XPropertySet.hpp>
      50                 :            : #include <com/sun/star/script/BasicErrorException.hpp>
      51                 :            : #include <com/sun/star/script/XAllListener.hpp>
      52                 :            : #include <com/sun/star/script/XInvocationAdapterFactory.hpp>
      53                 :            : #include <com/sun/star/script/XTypeConverter.hpp>
      54                 :            : #include <com/sun/star/script/XDefaultProperty.hpp>
      55                 :            : #include <com/sun/star/script/XDefaultMethod.hpp>
      56                 :            : #include <com/sun/star/script/XDirectInvocation.hpp>
      57                 :            : #include <com/sun/star/container/XNameAccess.hpp>
      58                 :            : #include <com/sun/star/container/XHierarchicalNameAccess.hpp>
      59                 :            : #include <com/sun/star/reflection/XIdlArray.hpp>
      60                 :            : #include <com/sun/star/reflection/XIdlReflection.hpp>
      61                 :            : #include <com/sun/star/reflection/XServiceConstructorDescription.hpp>
      62                 :            : #include <com/sun/star/bridge/oleautomation/NamedArgument.hpp>
      63                 :            : #include <com/sun/star/bridge/oleautomation/Date.hpp>
      64                 :            : #include <com/sun/star/bridge/oleautomation/Decimal.hpp>
      65                 :            : #include <com/sun/star/bridge/oleautomation/Currency.hpp>
      66                 :            : #include <com/sun/star/bridge/oleautomation/XAutomationObject.hpp>
      67                 :            : #include <com/sun/star/script/XAutomationInvocation.hpp>
      68                 :            : 
      69                 :            : using com::sun::star::uno::Reference;
      70                 :            : using namespace com::sun::star::uno;
      71                 :            : using namespace com::sun::star::lang;
      72                 :            : using namespace com::sun::star::reflection;
      73                 :            : using namespace com::sun::star::beans;
      74                 :            : using namespace com::sun::star::script;
      75                 :            : using namespace com::sun::star::container;
      76                 :            : using namespace com::sun::star::bridge;
      77                 :            : using namespace cppu;
      78                 :            : 
      79                 :            : 
      80                 :            : #include<basic/sbstar.hxx>
      81                 :            : #include<basic/sbuno.hxx>
      82                 :            : #include<basic/sberrors.hxx>
      83                 :            : #include<sbunoobj.hxx>
      84                 :            : #include"sbjsmod.hxx"
      85                 :            : #include<basic/basmgr.hxx>
      86                 :            : #include<sbintern.hxx>
      87                 :            : #include<runtime.hxx>
      88                 :            : 
      89                 :            : #include<math.h>
      90                 :            : #include <boost/unordered_map.hpp>
      91                 :            : #include <com/sun/star/reflection/XTypeDescriptionEnumerationAccess.hpp>
      92                 :            : #include <com/sun/star/reflection/XConstantsTypeDescription.hpp>
      93                 :            : 
      94 [ +  + ][ +  + ]:       5836 : TYPEINIT1(SbUnoMethod,SbxMethod)
      95 [ +  + ][ +  + ]:      10581 : TYPEINIT1(SbUnoProperty,SbxProperty)
      96 [ +  + ][ +  + ]:     104090 : TYPEINIT1(SbUnoObject,SbxObject)
      97 [ +  + ][ +  + ]:        616 : TYPEINIT1(SbUnoStructRefObject,SbxObject)
      98 [ -  + ][ +  - ]:         30 : TYPEINIT1(SbUnoClass,SbxObject)
      99 [ #  # ][ #  # ]:          0 : TYPEINIT1(SbUnoService,SbxObject)
     100 [ #  # ][ #  # ]:          0 : TYPEINIT1(SbUnoServiceCtor,SbxMethod)
     101 [ #  # ][ #  # ]:          0 : TYPEINIT1(SbUnoSingleton,SbxObject)
     102                 :            : 
     103                 :            : typedef WeakImplHelper1< XAllListener > BasicAllListenerHelper;
     104                 :            : 
     105                 :            : // Identifiers for creating the strings for dbg_Properties
     106                 :            : static char const ID_DBG_SUPPORTEDINTERFACES[] = "Dbg_SupportedInterfaces";
     107                 :            : static char const ID_DBG_PROPERTIES[] = "Dbg_Properties";
     108                 :            : static char const ID_DBG_METHODS[] = "Dbg_Methods";
     109                 :            : 
     110                 :            : static char const aSeqLevelStr[] = "[]";
     111                 :            : static char const defaultNameSpace[] = "ooo.vba";
     112                 :            : 
     113                 :            : // Gets the default property for an uno object. Note: There is some
     114                 :            : // redirection built in. The property name specifies the name
     115                 :            : // of the default property.
     116                 :            : 
     117                 :        282 : bool SbUnoObject::getDefaultPropName( SbUnoObject* pUnoObj, ::rtl::OUString& sDfltProp )
     118                 :            : {
     119                 :        282 :     bool result = false;
     120         [ +  - ]:        282 :     Reference< XDefaultProperty> xDefaultProp( pUnoObj->maTmpUnoObj, UNO_QUERY );
     121         [ +  + ]:        282 :     if ( xDefaultProp.is() )
     122                 :            :     {
     123 [ +  - ][ +  - ]:        128 :         sDfltProp = xDefaultProp->getDefaultPropertyName();
     124         [ +  - ]:        128 :         if ( !sDfltProp.isEmpty() )
     125                 :        128 :             result = true;
     126                 :            :     }
     127                 :        282 :     return result;
     128                 :            : }
     129                 :            : 
     130                 :         18 : SbxVariable* getDefaultProp( SbxVariable* pRef )
     131                 :            : {
     132                 :         18 :     SbxVariable* pDefaultProp = NULL;
     133         [ +  - ]:         18 :     if ( pRef->GetType() == SbxOBJECT )
     134                 :            :     {
     135 [ +  - ][ +  + ]:         18 :           SbxObject* pObj = PTR_CAST(SbxObject,(SbxVariable*) pRef);
     136         [ +  + ]:         18 :         if ( !pObj )
     137                 :            :         {
     138                 :         12 :             SbxBase* pObjVarObj = pRef->GetObject();
     139 [ +  - ][ +  - ]:         12 :             pObj = PTR_CAST(SbxObject,pObjVarObj);
     140                 :            :         }
     141 [ +  - ][ +  + ]:         18 :         if ( pObj && pObj->ISA(SbUnoObject) )
                 [ +  + ]
     142                 :            :         {
     143 [ +  - ][ +  - ]:         12 :             SbUnoObject* pUnoObj = PTR_CAST(SbUnoObject,(SbxObject*)pObj);
     144                 :         12 :             pDefaultProp = pUnoObj->GetDfltProperty();
     145                 :            :         }
     146                 :            :     }
     147                 :         18 :     return pDefaultProp;
     148                 :            : }
     149                 :            : 
     150                 :          0 : void SetSbUnoObjectDfltPropName( SbxObject* pObj )
     151                 :            : {
     152 [ #  # ][ #  # ]:          0 :     SbUnoObject* pUnoObj = PTR_CAST(SbUnoObject,(SbxObject*) pObj);
     153         [ #  # ]:          0 :     if ( pUnoObj )
     154                 :            :     {
     155                 :          0 :         ::rtl::OUString sDfltPropName;
     156                 :            : 
     157 [ #  # ][ #  # ]:          0 :         if ( SbUnoObject::getDefaultPropName( pUnoObj, sDfltPropName ) )
     158                 :            :         {
     159                 :            :             OSL_TRACE("SetSbUnoObjectDfltPropName setting dflt prop for %s", rtl::OUStringToOString( pObj->GetName(), RTL_TEXTENCODING_UTF8 ).getStr() );
     160 [ #  # ][ #  # ]:          0 :             pUnoObj->SetDfltProperty( sDfltPropName );
                 [ #  # ]
     161                 :          0 :         }
     162                 :            :     }
     163                 :          0 : }
     164                 :            : 
     165                 :        132 : Reference< XComponentContext > getComponentContext_Impl( void )
     166                 :            : {
     167 [ +  + ][ +  - ]:        132 :     static Reference< XComponentContext > xContext;
     168                 :            : 
     169                 :            :     // Do we have already CoreReflection; if not obtain it
     170         [ +  + ]:        132 :     if( !xContext.is() )
     171                 :            :     {
     172         [ +  - ]:        117 :         Reference< XMultiServiceFactory > xFactory = comphelper::getProcessServiceFactory();
     173         [ +  - ]:        117 :         Reference< XPropertySet > xProps( xFactory, UNO_QUERY );
     174                 :            :         OSL_ASSERT( xProps.is() );
     175         [ +  - ]:        117 :         if (xProps.is())
     176                 :            :         {
     177         [ +  - ]:        117 :             xProps->getPropertyValue(
     178 [ +  - ][ +  - ]:        117 :                 ::rtl::OUString( "DefaultContext" ) ) >>= xContext;
     179                 :            :             OSL_ASSERT( xContext.is() );
     180                 :        117 :         }
     181                 :            :     }
     182                 :        132 :     return xContext;
     183                 :            : }
     184                 :            : 
     185                 :            : // save CoreReflection statically
     186                 :       2336 : Reference< XIdlReflection > getCoreReflection_Impl( void )
     187                 :            : {
     188 [ +  + ][ +  - ]:       2336 :     static Reference< XIdlReflection > xCoreReflection;
     189                 :            : 
     190                 :            :     // Do we have already CoreReflection; if not obtain it
     191         [ +  + ]:       2336 :     if( !xCoreReflection.is() )
     192                 :            :     {
     193         [ +  - ]:        117 :         Reference< XComponentContext > xContext = getComponentContext_Impl();
     194         [ +  - ]:        117 :         if( xContext.is() )
     195                 :            :         {
     196         [ +  - ]:        117 :             xContext->getValueByName(
     197                 :        117 :                 ::rtl::OUString( "/singletons/com.sun.star.reflection.theCoreReflection" ) )
     198 [ +  - ][ +  - ]:        117 :                     >>= xCoreReflection;
     199                 :            :             OSL_ENSURE( xCoreReflection.is(), "### CoreReflection singleton not accessable!?" );
     200                 :            :         }
     201         [ -  + ]:        117 :         if( !xCoreReflection.is() )
     202                 :            :         {
     203                 :            :             throw DeploymentException(
     204                 :            :                 ::rtl::OUString( "/singletons/com.sun.star.reflection.theCoreReflection singleton not accessable" ),
     205         [ #  # ]:          0 :                 Reference< XInterface >() );
     206                 :        117 :         }
     207                 :            :     }
     208                 :       2336 :     return xCoreReflection;
     209                 :            : }
     210                 :            : 
     211                 :            : // save CoreReflection statically
     212                 :        128 : Reference< XHierarchicalNameAccess > getCoreReflection_HierarchicalNameAccess_Impl( void )
     213                 :            : {
     214 [ +  + ][ +  - ]:        128 :     static Reference< XHierarchicalNameAccess > xCoreReflection_HierarchicalNameAccess;
     215                 :            : 
     216         [ +  + ]:        128 :     if( !xCoreReflection_HierarchicalNameAccess.is() )
     217                 :            :     {
     218         [ +  - ]:          5 :         Reference< XIdlReflection > xCoreReflection = getCoreReflection_Impl();
     219         [ +  - ]:          5 :         if( xCoreReflection.is() )
     220                 :            :         {
     221                 :            :             xCoreReflection_HierarchicalNameAccess =
     222 [ +  - ][ +  - ]:          5 :                 Reference< XHierarchicalNameAccess >( xCoreReflection, UNO_QUERY );
     223                 :          5 :         }
     224                 :            :     }
     225                 :        128 :     return xCoreReflection_HierarchicalNameAccess;
     226                 :            : }
     227                 :            : 
     228                 :            : // Hold TypeProvider statically
     229                 :        106 : Reference< XHierarchicalNameAccess > getTypeProvider_Impl( void )
     230                 :            : {
     231 [ +  + ][ +  - ]:        106 :     static Reference< XHierarchicalNameAccess > xAccess;
     232                 :            : 
     233                 :            :     // Do we have already CoreReflection; if not obtain it
     234         [ +  + ]:        106 :     if( !xAccess.is() )
     235                 :            :     {
     236         [ +  - ]:         10 :         Reference< XComponentContext > xContext = getComponentContext_Impl();
     237         [ +  - ]:         10 :         if( xContext.is() )
     238                 :            :         {
     239         [ +  - ]:         10 :             xContext->getValueByName(
     240                 :         10 :                 ::rtl::OUString( "/singletons/com.sun.star.reflection.theTypeDescriptionManager" ) )
     241 [ +  - ][ +  - ]:         10 :                     >>= xAccess;
     242                 :            :             OSL_ENSURE( xAccess.is(), "### TypeDescriptionManager singleton not accessable!?" );
     243                 :            :         }
     244         [ -  + ]:         10 :         if( !xAccess.is() )
     245                 :            :         {
     246                 :            :             throw DeploymentException(
     247                 :            :                 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM
     248                 :            :                     ("/singletons/com.sun.star.reflection.theTypeDescriptionManager singleton not accessable") ),
     249 [ #  # ][ #  # ]:          0 :                 Reference< XInterface >() );
     250                 :         10 :         }
     251                 :            :     }
     252                 :        106 :     return xAccess;
     253                 :            : }
     254                 :            : 
     255                 :            : // Hold TypeConverter statically
     256                 :          0 : Reference< XTypeConverter > getTypeConverter_Impl( void )
     257                 :            : {
     258 [ #  # ][ #  # ]:          0 :     static Reference< XTypeConverter > xTypeConverter;
     259                 :            : 
     260                 :            :     // Do we have already CoreReflection; if not obtain it
     261         [ #  # ]:          0 :     if( !xTypeConverter.is() )
     262                 :            :     {
     263         [ #  # ]:          0 :         Reference< XComponentContext > xContext = getComponentContext_Impl();
     264         [ #  # ]:          0 :         if( xContext.is() )
     265                 :            :         {
     266 [ #  # ][ #  # ]:          0 :             Reference<XMultiComponentFactory> xSMgr = xContext->getServiceManager();
     267                 :            :             xTypeConverter = Reference<XTypeConverter>(
     268         [ #  # ]:          0 :                 xSMgr->createInstanceWithContext(
     269                 :            :                     ::rtl::OUString( "com.sun.star.script.Converter"),
     270 [ #  # ][ #  # ]:          0 :                         xContext ), UNO_QUERY );
                 [ #  # ]
     271                 :            :         }
     272         [ #  # ]:          0 :         if( !xTypeConverter.is() )
     273                 :            :         {
     274                 :            :             throw DeploymentException(
     275                 :            :                 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM
     276                 :            :                     ("com.sun.star.script.Converter service not accessable") ),
     277 [ #  # ][ #  # ]:          0 :                 Reference< XInterface >() );
     278                 :          0 :         }
     279                 :            :     }
     280                 :          0 :     return xTypeConverter;
     281                 :            : }
     282                 :            : 
     283                 :            : 
     284                 :            : // #111851 factory function to create an OLE object
     285                 :         24 : SbUnoObject* createOLEObject_Impl( const ::rtl::OUString& aType )
     286                 :            : {
     287 [ +  + ][ +  - ]:         24 :     static Reference< XMultiServiceFactory > xOLEFactory;
     288                 :            :     static bool bNeedsInit = true;
     289                 :            : 
     290         [ +  + ]:         24 :     if( bNeedsInit )
     291                 :            :     {
     292                 :          5 :         bNeedsInit = false;
     293                 :            : 
     294         [ +  - ]:          5 :         Reference< XComponentContext > xContext = getComponentContext_Impl();
     295         [ +  - ]:          5 :         if( xContext.is() )
     296                 :            :         {
     297 [ +  - ][ +  - ]:          5 :             Reference<XMultiComponentFactory> xSMgr = xContext->getServiceManager();
     298                 :            :             xOLEFactory = Reference<XMultiServiceFactory>(
     299         [ +  - ]:          5 :                 xSMgr->createInstanceWithContext(
     300                 :            :                     ::rtl::OUString( "com.sun.star.bridge.OleObjectFactory"),
     301 [ +  - ][ +  - ]:          5 :                         xContext ), UNO_QUERY );
                 [ +  - ]
     302                 :          5 :         }
     303                 :            :     }
     304                 :            : 
     305                 :         24 :     SbUnoObject* pUnoObj = NULL;
     306         [ -  + ]:         24 :     if( xOLEFactory.is() )
     307                 :            :     {
     308                 :            :         // some type names available in VBA can not be directly used in COM
     309                 :          0 :         ::rtl::OUString aOLEType = aType;
     310         [ #  # ]:          0 :         if ( aOLEType == "SAXXMLReader30" )
     311                 :          0 :             aOLEType = ::rtl::OUString( "Msxml2.SAXXMLReader.3.0"  );
     312                 :            : 
     313 [ #  # ][ #  # ]:          0 :         Reference< XInterface > xOLEObject = xOLEFactory->createInstance( aOLEType );
     314         [ #  # ]:          0 :         if( xOLEObject.is() )
     315                 :            :         {
     316                 :          0 :             Any aAny;
     317         [ #  # ]:          0 :             aAny <<= xOLEObject;
     318 [ #  # ][ #  # ]:          0 :             pUnoObj = new SbUnoObject( aType, aAny );
     319                 :          0 :         }
     320                 :            :     }
     321                 :         24 :     return pUnoObj;
     322                 :            : }
     323                 :            : 
     324                 :            : 
     325                 :            : namespace
     326                 :            : {
     327                 :          8 :     void lcl_indent( ::rtl::OUStringBuffer& _inout_rBuffer, sal_Int32 _nLevel )
     328                 :            :     {
     329         [ -  + ]:          8 :         while ( _nLevel-- > 0 )
     330                 :          0 :             _inout_rBuffer.appendAscii( "  " );
     331                 :          8 :     }
     332                 :            : }
     333                 :            : 
     334                 :          4 : void implAppendExceptionMsg( ::rtl::OUStringBuffer& _inout_rBuffer, const Exception& _e, const ::rtl::OUString& _rExceptionType, sal_Int32 _nLevel )
     335                 :            : {
     336                 :          4 :     _inout_rBuffer.appendAscii( "\n" );
     337                 :          4 :     lcl_indent( _inout_rBuffer, _nLevel );
     338                 :          4 :     _inout_rBuffer.appendAscii( "Type: " );
     339                 :            : 
     340         [ -  + ]:          4 :     if ( _rExceptionType.isEmpty() )
     341                 :          0 :         _inout_rBuffer.appendAscii( "Unknown" );
     342                 :            :     else
     343                 :          4 :         _inout_rBuffer.append( _rExceptionType );
     344                 :            : 
     345                 :          4 :     _inout_rBuffer.appendAscii( "\n" );
     346                 :          4 :     lcl_indent( _inout_rBuffer, _nLevel );
     347                 :          4 :     _inout_rBuffer.appendAscii( "Message: " );
     348                 :          4 :     _inout_rBuffer.append( _e.Message );
     349                 :            : 
     350                 :          4 : }
     351                 :            : 
     352                 :            : // construct an error message for the exception
     353                 :          0 : ::rtl::OUString implGetExceptionMsg( const Exception& e, const ::rtl::OUString& aExceptionType_ )
     354                 :            : {
     355                 :          0 :     ::rtl::OUStringBuffer aMessageBuf;
     356         [ #  # ]:          0 :     implAppendExceptionMsg( aMessageBuf, e, aExceptionType_, 0 );
     357         [ #  # ]:          0 :     return aMessageBuf.makeStringAndClear();
     358                 :            : }
     359                 :            : 
     360                 :          0 : ::rtl::OUString implGetExceptionMsg( const Any& _rCaughtException )
     361                 :            : {
     362                 :            :     OSL_PRECOND( _rCaughtException.getValueTypeClass() == TypeClass_EXCEPTION, "implGetExceptionMsg: illegal argument!" );
     363         [ #  # ]:          0 :     if ( _rCaughtException.getValueTypeClass() != TypeClass_EXCEPTION )
     364         [ #  # ]:          0 :         return String();
     365                 :            : 
     366         [ #  # ]:          0 :     return implGetExceptionMsg( *static_cast< const Exception* >( _rCaughtException.getValue() ), _rCaughtException.getValueTypeName() );
     367                 :            : }
     368                 :            : 
     369                 :          0 : Any convertAny( const Any& rVal, const Type& aDestType )
     370                 :            : {
     371                 :          0 :     Any aConvertedVal;
     372         [ #  # ]:          0 :     Reference< XTypeConverter > xConverter = getTypeConverter_Impl();
     373                 :            :     try
     374                 :            :     {
     375 [ #  # ][ #  # ]:          0 :         aConvertedVal = xConverter->convertTo( rVal, aDestType );
     376                 :            :     }
     377         [ #  # ]:          0 :     catch( const IllegalArgumentException& )
     378                 :            :     {
     379                 :            :         StarBASIC::Error( ERRCODE_BASIC_EXCEPTION,
     380   [ #  #  #  #  :          0 :             implGetExceptionMsg( ::cppu::getCaughtException() ) );
          #  #  #  #  #  
                      # ]
     381                 :            :         return aConvertedVal;
     382                 :            :     }
     383   [ #  #  #  #  :          0 :     catch( const CannotConvertException& e2 )
                      # ]
     384                 :            :     {
     385                 :            :         ::rtl::OUString aCannotConvertExceptionName
     386                 :          0 :             ( "com.sun.star.lang.IllegalArgumentException"  );
     387                 :            :         StarBASIC::Error( ERRCODE_BASIC_EXCEPTION,
     388   [ #  #  #  #  :          0 :             implGetExceptionMsg( e2, aCannotConvertExceptionName ) );
             #  #  #  # ]
     389                 :          0 :         return aConvertedVal;
     390                 :            :     }
     391                 :          0 :     return aConvertedVal;
     392                 :            : }
     393                 :            : 
     394                 :            : 
     395                 :            : // #105565 Special Object to wrap a strongly typed Uno Any
     396 [ #  # ][ #  # ]:       7918 : TYPEINIT1(SbUnoAnyObject,SbxObject)
     397                 :            : 
     398                 :            : 
     399                 :            : // TODO: source out later
     400                 :       2181 : Reference<XIdlClass> TypeToIdlClass( const Type& rType )
     401                 :            : {
     402                 :            :     // register void as default class
     403                 :       2181 :     Reference<XIdlClass> xRetClass;
     404                 :       2181 :     typelib_TypeDescription * pTD = 0;
     405                 :       2181 :     rType.getDescription( &pTD );
     406                 :            : 
     407         [ +  - ]:       2181 :     if( pTD )
     408                 :            :     {
     409                 :       2181 :         ::rtl::OUString sOWName( pTD->pTypeName );
     410         [ +  - ]:       2181 :         Reference< XIdlReflection > xRefl = getCoreReflection_Impl();
     411 [ +  - ][ +  - ]:       2181 :         xRetClass = xRefl->forName( sOWName );
                 [ +  - ]
     412                 :            :     }
     413                 :       2181 :     return xRetClass;
     414                 :            : }
     415                 :            : 
     416                 :            : // Exception type unknown
     417                 :            : template< class EXCEPTION >
     418                 :          0 : ::rtl::OUString implGetExceptionMsg( const EXCEPTION& e )
     419                 :            : {
     420 [ #  # ][ #  # ]:          0 :     return implGetExceptionMsg( e, ::getCppuType( &e ).getTypeName() );
     421                 :            : }
     422                 :            : 
     423                 :          0 : void implHandleBasicErrorException( BasicErrorException& e )
     424                 :            : {
     425                 :          0 :     SbError nError = StarBASIC::GetSfxFromVBError( (sal_uInt16)e.ErrorCode );
     426         [ #  # ]:          0 :     StarBASIC::Error( nError, e.ErrorMessageArgument );
     427                 :          0 : }
     428                 :            : 
     429                 :          4 : void implHandleWrappedTargetException( const Any& _rWrappedTargetException )
     430                 :            : {
     431                 :          4 :     Any aExamine( _rWrappedTargetException );
     432                 :            : 
     433                 :            :     // completely strip the first InvocationTargetException, its error message isn't of any
     434                 :            :     // interest to the user, it just says something like "invoking the UNO method went wrong.".
     435         [ +  - ]:          4 :     InvocationTargetException aInvocationError;
     436 [ +  - ][ +  - ]:          4 :     if ( aExamine >>= aInvocationError )
     437                 :          4 :         aExamine = aInvocationError.TargetException;
     438                 :            : 
     439         [ +  - ]:          4 :     BasicErrorException aBasicError;
     440                 :            : 
     441                 :          4 :     SbError nError( ERRCODE_BASIC_EXCEPTION );
     442                 :          4 :     ::rtl::OUStringBuffer aMessageBuf;
     443                 :            : 
     444                 :            :     // Add for VBA, to get the correct error code and message.
     445 [ +  - ][ +  - ]:          4 :     if ( SbiRuntime::isVBAEnabled() )
     446                 :            :     {
     447 [ +  - ][ -  + ]:          4 :         if ( aExamine >>= aBasicError )
     448                 :            :         {
     449         [ #  # ]:          0 :             if ( aBasicError.ErrorCode != 0 )
     450                 :            :             {
     451         [ #  # ]:          0 :                 nError = StarBASIC::GetSfxFromVBError( (sal_uInt16) aBasicError.ErrorCode );
     452         [ #  # ]:          0 :                 if ( nError == 0 )
     453                 :            :                 {
     454                 :          0 :                     nError = (SbError) aBasicError.ErrorCode;
     455                 :            :                 }
     456         [ #  # ]:          0 :                 aMessageBuf.append( aBasicError.ErrorMessageArgument );
     457                 :          0 :                 aExamine.clear();
     458                 :            :             }
     459                 :            :         }
     460                 :            : 
     461         [ +  - ]:          4 :         IndexOutOfBoundsException aIdxOutBndsExp;
     462 [ +  - ][ -  + ]:          4 :         if ( aExamine >>= aIdxOutBndsExp )
     463                 :            :         {
     464                 :          0 :             nError = SbERR_OUT_OF_RANGE;
     465                 :          0 :             aExamine.clear();
     466         [ +  - ]:          4 :         }
     467                 :            :     }
     468                 :            :     // End add
     469                 :            : 
     470                 :            :     // strip any other WrappedTargetException instances, but this time preserve the error messages.
     471         [ +  - ]:          4 :     WrappedTargetException aWrapped;
     472                 :          4 :     sal_Int32 nLevel = 0;
     473 [ +  - ][ -  + ]:          4 :     while ( aExamine >>= aWrapped )
     474                 :            :     {
     475                 :            :         // special handling for BasicErrorException errors
     476 [ #  # ][ #  # ]:          0 :         if ( aWrapped.TargetException >>= aBasicError )
     477                 :            :         {
     478         [ #  # ]:          0 :             nError = StarBASIC::GetSfxFromVBError( (sal_uInt16)aBasicError.ErrorCode );
     479         [ #  # ]:          0 :             aMessageBuf.append( aBasicError.ErrorMessageArgument );
     480                 :          0 :             aExamine.clear();
     481                 :          0 :             break;
     482                 :            :         }
     483                 :            : 
     484                 :            :         // append this round's message
     485         [ #  # ]:          0 :         implAppendExceptionMsg( aMessageBuf, aWrapped, aExamine.getValueTypeName(), nLevel );
     486         [ #  # ]:          0 :         if ( aWrapped.TargetException.getValueTypeClass() == TypeClass_EXCEPTION )
     487                 :            :             // there is a next chain element
     488         [ #  # ]:          0 :             aMessageBuf.appendAscii( "\nTargetException:" );
     489                 :            : 
     490                 :            :         // next round
     491                 :          0 :         aExamine = aWrapped.TargetException;
     492                 :          0 :         ++nLevel;
     493                 :            :     }
     494                 :            : 
     495         [ +  - ]:          4 :     if ( aExamine.getValueTypeClass() == TypeClass_EXCEPTION )
     496                 :            :     {
     497                 :            :         // the last element in the chain is still an exception, but no WrappedTargetException
     498         [ +  - ]:          4 :         implAppendExceptionMsg( aMessageBuf, *static_cast< const Exception* >( aExamine.getValue() ), aExamine.getValueTypeName(), nLevel );
     499                 :            :     }
     500                 :            : 
     501 [ +  - ][ +  - ]:          4 :     StarBASIC::Error( nError, aMessageBuf.makeStringAndClear() );
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
                 [ +  - ]
     502                 :          4 : }
     503                 :            : 
     504                 :          4 : static void implHandleAnyException( const Any& _rCaughtException )
     505                 :            : {
     506         [ +  - ]:          4 :     BasicErrorException aBasicError;
     507         [ +  - ]:          4 :     WrappedTargetException aWrappedError;
     508                 :            : 
     509 [ +  - ][ -  + ]:          4 :     if ( _rCaughtException >>= aBasicError )
     510                 :            :     {
     511         [ #  # ]:          0 :         implHandleBasicErrorException( aBasicError );
     512                 :            :     }
     513 [ +  - ][ +  - ]:          4 :     else if ( _rCaughtException >>= aWrappedError )
     514                 :            :     {
     515         [ +  - ]:          4 :         implHandleWrappedTargetException( _rCaughtException );
     516                 :            :     }
     517                 :            :     else
     518                 :            :     {
     519 [ #  # ][ #  # ]:          0 :         StarBASIC::Error( ERRCODE_BASIC_EXCEPTION, implGetExceptionMsg( _rCaughtException ) );
         [ #  # ][ #  # ]
     520 [ +  - ][ +  - ]:          4 :     }
     521                 :          4 : }
     522                 :            : 
     523                 :            : // NativeObjectWrapper handling
     524                 :          0 : struct ObjectItem
     525                 :            : {
     526                 :            :     SbxObjectRef    m_xNativeObj;
     527                 :            : 
     528                 :            :     ObjectItem( void )
     529                 :            :     {}
     530                 :          0 :     ObjectItem( SbxObject* pNativeObj )
     531                 :          0 :         : m_xNativeObj( pNativeObj )
     532                 :          0 :     {}
     533                 :            : };
     534                 :            : 
     535                 :            : typedef std::vector< ObjectItem > NativeObjectWrapperVector;
     536                 :            : class GaNativeObjectWrapperVector : public rtl::Static<NativeObjectWrapperVector, GaNativeObjectWrapperVector> {};
     537                 :            : 
     538                 :         31 : void clearNativeObjectWrapperVector( void )
     539                 :            : {
     540                 :         31 :     GaNativeObjectWrapperVector::get().clear();
     541                 :         31 : }
     542                 :            : 
     543                 :          0 : sal_uInt32 lcl_registerNativeObjectWrapper( SbxObject* pNativeObj )
     544                 :            : {
     545                 :          0 :     NativeObjectWrapperVector &rNativeObjectWrapperVector = GaNativeObjectWrapperVector::get();
     546                 :          0 :     sal_uInt32 nIndex = rNativeObjectWrapperVector.size();
     547         [ #  # ]:          0 :     rNativeObjectWrapperVector.push_back( ObjectItem( pNativeObj ) );
     548                 :          0 :     return nIndex;
     549                 :            : }
     550                 :            : 
     551                 :          0 : SbxObject* lcl_getNativeObject( sal_uInt32 nIndex )
     552                 :            : {
     553                 :          0 :     SbxObjectRef xRetObj;
     554         [ #  # ]:          0 :     NativeObjectWrapperVector &rNativeObjectWrapperVector = GaNativeObjectWrapperVector::get();
     555         [ #  # ]:          0 :     if( nIndex < rNativeObjectWrapperVector.size() )
     556                 :            :     {
     557                 :          0 :         ObjectItem& rItem = rNativeObjectWrapperVector[ nIndex ];
     558         [ #  # ]:          0 :         xRetObj = rItem.m_xNativeObj;
     559                 :            :     }
     560         [ #  # ]:          0 :     return xRetObj;
     561                 :            : }
     562                 :            : 
     563                 :            : // convert from Uno to Sbx
     564                 :        550 : SbxDataType unoToSbxType( TypeClass eType )
     565                 :            : {
     566                 :        550 :     SbxDataType eRetType = SbxVOID;
     567                 :            : 
     568   [ +  -  +  +  :        550 :     switch( eType )
          +  -  +  -  +  
          -  +  +  -  -  
                -  -  + ]
     569                 :            :     {
     570                 :            :         case TypeClass_INTERFACE:
     571                 :            :         case TypeClass_TYPE:
     572                 :            :         case TypeClass_STRUCT:
     573                 :         90 :         case TypeClass_EXCEPTION:       eRetType = SbxOBJECT;   break;
     574                 :            : 
     575                 :          0 :         case TypeClass_ENUM:            eRetType = SbxLONG;     break;
     576                 :            :         case TypeClass_SEQUENCE:
     577                 :          2 :             eRetType = (SbxDataType) ( SbxOBJECT | SbxARRAY );
     578                 :          2 :             break;
     579                 :            : 
     580                 :            : 
     581                 :         82 :         case TypeClass_ANY:             eRetType = SbxVARIANT;  break;
     582                 :         24 :         case TypeClass_BOOLEAN:         eRetType = SbxBOOL;     break;
     583                 :          0 :         case TypeClass_CHAR:            eRetType = SbxCHAR;     break;
     584                 :        226 :         case TypeClass_STRING:          eRetType = SbxSTRING;   break;
     585                 :          0 :         case TypeClass_FLOAT:           eRetType = SbxSINGLE;   break;
     586                 :          2 :         case TypeClass_DOUBLE:          eRetType = SbxDOUBLE;   break;
     587                 :          0 :         case TypeClass_BYTE:            eRetType = SbxINTEGER;  break;
     588                 :         24 :         case TypeClass_SHORT:           eRetType = SbxINTEGER;  break;
     589                 :         12 :         case TypeClass_LONG:            eRetType = SbxLONG;     break;
     590                 :          0 :         case TypeClass_HYPER:           eRetType = SbxSALINT64; break;
     591                 :          0 :         case TypeClass_UNSIGNED_SHORT:  eRetType = SbxUSHORT;   break;
     592                 :          0 :         case TypeClass_UNSIGNED_LONG:   eRetType = SbxULONG;    break;
     593                 :          0 :         case TypeClass_UNSIGNED_HYPER:  eRetType = SbxSALUINT64;break;
     594                 :         88 :         default: break;
     595                 :            :     }
     596                 :        550 :     return eRetType;
     597                 :            : }
     598                 :            : 
     599                 :        288 : SbxDataType unoToSbxType( const Reference< XIdlClass >& xIdlClass )
     600                 :            : {
     601                 :        288 :     SbxDataType eRetType = SbxVOID;
     602         [ +  - ]:        288 :     if( xIdlClass.is() )
     603                 :            :     {
     604                 :        288 :         TypeClass eType = xIdlClass->getTypeClass();
     605                 :        288 :         eRetType = unoToSbxType( eType );
     606                 :            :     }
     607                 :        288 :     return eRetType;
     608                 :            : }
     609                 :            : 
     610                 :          0 : static void implSequenceToMultiDimArray( SbxDimArray*& pArray, Sequence< sal_Int32 >& indices, Sequence< sal_Int32 >& sizes, const Any& aValue, sal_Int32& dimension, sal_Bool bIsZeroIndex, Type* pType = NULL )
     611                 :            : {
     612                 :          0 :     Type aType = aValue.getValueType();
     613                 :          0 :     TypeClass eTypeClass = aType.getTypeClass();
     614                 :            : 
     615                 :          0 :     sal_Int32 dimCopy = dimension;
     616                 :            : 
     617         [ #  # ]:          0 :     if ( eTypeClass == TypeClass_SEQUENCE )
     618                 :            :     {
     619         [ #  # ]:          0 :         Reference< XIdlClass > xIdlTargetClass = TypeToIdlClass( aType );
     620 [ #  # ][ #  # ]:          0 :         Reference< XIdlArray > xIdlArray = xIdlTargetClass->getArray();
     621                 :          0 :         typelib_TypeDescription * pTD = 0;
     622                 :          0 :         aType.getDescription( &pTD );
     623                 :          0 :         Type aElementType( ((typelib_IndirectTypeDescription *)pTD)->pType );
     624                 :          0 :         ::typelib_typedescription_release( pTD );
     625                 :            : 
     626 [ #  # ][ #  # ]:          0 :         sal_Int32 nLen = xIdlArray->getLen( aValue );
     627         [ #  # ]:          0 :         for ( sal_Int32 index = 0; index < nLen; ++index )
     628                 :            :         {
     629 [ #  # ][ #  # ]:          0 :             Any aElementAny = xIdlArray->get( aValue, (sal_uInt32)index );
     630                 :            :             // This detects the dimension were currently processing
     631         [ #  # ]:          0 :             if ( dimCopy == dimension )
     632                 :            :             {
     633                 :          0 :                 ++dimCopy;
     634         [ #  # ]:          0 :                 if ( sizes.getLength() < dimCopy )
     635                 :            :                 {
     636         [ #  # ]:          0 :                     sizes.realloc( sizes.getLength() + 1 );
     637         [ #  # ]:          0 :                     sizes[ sizes.getLength() - 1 ] = nLen;
     638         [ #  # ]:          0 :                     indices.realloc( indices.getLength() + 1 );
     639                 :            :                 }
     640                 :            :             }
     641                 :            : 
     642         [ #  # ]:          0 :             if ( bIsZeroIndex )
     643         [ #  # ]:          0 :                 indices[ dimCopy - 1 ] = index;
     644                 :            :             else
     645         [ #  # ]:          0 :                 indices[ dimCopy - 1] = index + 1;
     646                 :            : 
     647         [ #  # ]:          0 :             implSequenceToMultiDimArray( pArray, indices, sizes, aElementAny, dimCopy, bIsZeroIndex, &aElementType );
     648                 :          0 :         }
     649                 :            : 
     650                 :            :     }
     651                 :            :     else
     652                 :            :     {
     653         [ #  # ]:          0 :         if ( indices.getLength() < 1 )
     654                 :            :         {
     655                 :            :             // Should never ever get here ( indices.getLength()
     656                 :            :             // should equal number of dimensions in the array )
     657                 :            :             // And that should at least be 1 !
     658                 :            :             // #QUESTION is there a better error?
     659         [ #  # ]:          0 :             StarBASIC::Error( SbERR_INVALID_OBJECT );
     660                 :          0 :             return;
     661                 :            :         }
     662                 :            : 
     663         [ #  # ]:          0 :         SbxDataType eSbxElementType = unoToSbxType( pType ? pType->getTypeClass() : aValue.getValueTypeClass() );
     664         [ #  # ]:          0 :         if ( !pArray )
     665                 :            :         {
     666 [ #  # ][ #  # ]:          0 :             pArray = new SbxDimArray( eSbxElementType );
     667                 :          0 :             sal_Int32 nIndexLen = indices.getLength();
     668                 :            : 
     669                 :            :             // Dimension the array
     670         [ #  # ]:          0 :             for ( sal_Int32 index = 0; index < nIndexLen; ++index )
     671                 :            :             {
     672         [ #  # ]:          0 :                 if ( bIsZeroIndex )
     673 [ #  # ][ #  # ]:          0 :                     pArray->unoAddDim32( 0, sizes[ index ] - 1);
     674                 :            :                 else
     675 [ #  # ][ #  # ]:          0 :                     pArray->unoAddDim32( 1, sizes[ index ] );
     676                 :            : 
     677                 :            :             }
     678                 :            :         }
     679                 :            : 
     680         [ #  # ]:          0 :         if ( pArray )
     681                 :            :         {
     682 [ #  # ][ #  # ]:          0 :             SbxVariableRef xVar = new SbxVariable( eSbxElementType );
     683         [ #  # ]:          0 :             unoToSbxValue( (SbxVariable*)xVar, aValue );
     684                 :            : 
     685         [ #  # ]:          0 :             sal_Int32* pIndices = indices.getArray();
     686 [ #  # ][ #  # ]:          0 :             pArray->Put32(  (SbxVariable*)xVar, pIndices );
     687                 :            : 
     688                 :            :         }
     689         [ #  # ]:          0 :     }
     690                 :            : }
     691                 :            : 
     692                 :        630 : void unoToSbxValue( SbxVariable* pVar, const Any& aValue )
     693                 :            : {
     694                 :        630 :     Type aType = aValue.getValueType();
     695                 :        630 :     TypeClass eTypeClass = aType.getTypeClass();
     696   [ -  +  -  +  :        630 :     switch( eTypeClass )
          +  -  +  -  +  
          -  +  +  -  -  
                -  -  + ]
     697                 :            :     {
     698                 :            :         case TypeClass_TYPE:
     699                 :            :         {
     700                 :            :             // Map Type to IdlClass
     701                 :          0 :             Type aType_;
     702                 :          0 :             aValue >>= aType_;
     703         [ #  # ]:          0 :             Reference<XIdlClass> xClass = TypeToIdlClass( aType_ );
     704                 :          0 :             Any aClassAny;
     705         [ #  # ]:          0 :             aClassAny <<= xClass;
     706                 :            : 
     707                 :            :             // instantiate SbUnoObject
     708                 :          0 :             ::rtl::OUString aName;
     709 [ #  # ][ #  # ]:          0 :             SbUnoObject* pSbUnoObject = new SbUnoObject( aName, aClassAny );
     710                 :          0 :             SbxObjectRef xWrapper = (SbxObject*)pSbUnoObject;
     711                 :            : 
     712                 :            :             // If the object is invalid deliver zero
     713 [ #  # ][ #  # ]:          0 :             if( pSbUnoObject->getUnoAny().getValueType().getTypeClass() == TypeClass_VOID )
     714                 :            :             {
     715         [ #  # ]:          0 :                 pVar->PutObject( NULL );
     716                 :            :             }
     717                 :            :             else
     718                 :            :             {
     719         [ #  # ]:          0 :                 pVar->PutObject( xWrapper );
     720         [ #  # ]:          0 :             }
     721                 :            :         }
     722                 :          0 :         break;
     723                 :            :         // Interfaces and  Structs must be wrapped in a SbUnoObject
     724                 :            :         case TypeClass_INTERFACE:
     725                 :            :         case TypeClass_STRUCT:
     726                 :            :         case TypeClass_EXCEPTION:
     727                 :            :         {
     728         [ +  + ]:        282 :             if( eTypeClass == TypeClass_STRUCT )
     729                 :            :             {
     730                 :         64 :                 ArrayWrapper aWrap;
     731                 :         64 :                 NativeObjectWrapper aNativeObjectWrapper;
     732 [ -  + ][ +  - ]:         64 :                 if ( (aValue >>= aWrap) )
     733                 :            :                 {
     734                 :          0 :                     SbxDimArray* pArray = NULL;
     735         [ #  # ]:          0 :                     Sequence< sal_Int32 > indices;
     736         [ #  # ]:          0 :                     Sequence< sal_Int32 > sizes;
     737                 :          0 :                     sal_Int32 dimension = 0;
     738         [ #  # ]:          0 :                     implSequenceToMultiDimArray( pArray, indices, sizes, aWrap.Array, dimension, aWrap.IsZeroIndex );
     739         [ #  # ]:          0 :                     if ( pArray )
     740                 :            :                     {
     741                 :          0 :                         SbxDimArrayRef xArray = pArray;
     742                 :          0 :                         sal_uInt16 nFlags = pVar->GetFlags();
     743                 :          0 :                         pVar->ResetFlag( SBX_FIXED );
     744         [ #  # ]:          0 :                         pVar->PutObject( (SbxDimArray*)xArray );
     745         [ #  # ]:          0 :                         pVar->SetFlags( nFlags );
     746                 :            :                     }
     747                 :            :                     else
     748         [ #  # ]:          0 :                         pVar->PutEmpty();
     749 [ #  # ][ #  # ]:          0 :                     break;
     750                 :            :                 }
     751 [ +  - ][ -  + ]:         64 :                 else if ( (aValue >>= aNativeObjectWrapper) )
     752                 :            :                 {
     753                 :          0 :                     sal_uInt32 nIndex = 0;
     754         [ #  # ]:          0 :                     if( (aNativeObjectWrapper.ObjectId >>= nIndex) )
     755                 :            :                     {
     756         [ #  # ]:          0 :                         SbxObject* pObj = lcl_getNativeObject( nIndex );
     757         [ #  # ]:          0 :                         pVar->PutObject( pObj );
     758                 :            :                     }
     759                 :            :                     else
     760         [ #  # ]:          0 :                         pVar->PutEmpty();
     761                 :            :                     break;
     762                 :            :                 }
     763                 :            :                 else
     764                 :            :                 {
     765         [ +  - ]:         64 :                     SbiInstance* pInst = GetSbData()->pInst;
     766 [ +  + ][ -  + ]:         64 :                     if( pInst && pInst->IsCompatibility() )
                 [ -  + ]
     767                 :            :                     {
     768                 :          0 :                         oleautomation::Date aDate;
     769 [ #  # ][ #  # ]:          0 :                         if( (aValue >>= aDate) )
     770                 :            :                         {
     771         [ #  # ]:          0 :                             pVar->PutDate( aDate.Value );
     772                 :            :                             break;
     773                 :            :                         }
     774                 :            :                         else
     775                 :            :                         {
     776                 :          0 :                             oleautomation::Decimal aDecimal;
     777 [ #  # ][ #  # ]:          0 :                             if( (aValue >>= aDecimal) )
     778                 :            :                             {
     779         [ #  # ]:          0 :                                 pVar->PutDecimal( aDecimal );
     780                 :            :                                 break;
     781                 :            :                             }
     782                 :            :                             else
     783                 :            :                             {
     784                 :          0 :                                 oleautomation::Currency aCurrency;
     785 [ #  # ][ #  # ]:          0 :                                 if( (aValue >>= aCurrency) )
     786                 :            :                                 {
     787         [ #  # ]:         64 :                                     pVar->PutCurrency( aCurrency.Value );
     788                 :            :                                     break;
     789                 :            :                                 }
     790                 :            :                             }
     791                 :            :                         }
     792                 :            :                     }
     793 [ -  + ][ +  - ]:         64 :                 }
     794                 :            :             }
     795                 :            :             // instantiate a SbUnoObject
     796                 :        282 :             ::rtl::OUString aName;
     797 [ +  - ][ +  - ]:        282 :             SbUnoObject* pSbUnoObject = new SbUnoObject( aName, aValue );
     798                 :            :             //If this is called externally e.g. from the scripting
     799                 :            :             //framework then there is no 'active' runtime the default property will not be set up
     800                 :            :             //only a vba object will have XDefaultProp set anyway so... this
     801                 :            :             //test seems a bit of overkill
     802                 :            :             //if ( SbiRuntime::isVBAEnabled() )
     803                 :            :             {
     804                 :        282 :                 ::rtl::OUString sDfltPropName;
     805                 :            : 
     806 [ +  + ][ +  - ]:        282 :                 if ( SbUnoObject::getDefaultPropName( pSbUnoObject, sDfltPropName ) )
     807 [ +  - ][ +  - ]:        282 :                         pSbUnoObject->SetDfltProperty( sDfltPropName );
                 [ +  - ]
     808                 :            :             }
     809                 :        282 :             SbxObjectRef xWrapper = (SbxObject*)pSbUnoObject;
     810                 :            : 
     811                 :            :             // If the object is invalid deliver zero
     812 [ -  + ][ +  - ]:        282 :             if( pSbUnoObject->getUnoAny().getValueType().getTypeClass() == TypeClass_VOID )
     813                 :            :             {
     814         [ #  # ]:          0 :                 pVar->PutObject( NULL );
     815                 :            :             }
     816                 :            :             else
     817                 :            :             {
     818         [ +  - ]:        282 :                 pVar->PutObject( xWrapper );
     819         [ +  - ]:        282 :             }
     820                 :            :         }
     821                 :        282 :         break;
     822                 :            : 
     823                 :            : 
     824                 :            :         case TypeClass_ENUM:
     825                 :            :         {
     826                 :          0 :             sal_Int32 nEnum = 0;
     827                 :          0 :             enum2int( nEnum, aValue );
     828         [ #  # ]:          0 :             pVar->PutLong( nEnum );
     829                 :            :         }
     830                 :          0 :             break;
     831                 :            : 
     832                 :            :         case TypeClass_SEQUENCE:
     833                 :            :         {
     834         [ +  - ]:          2 :             Reference< XIdlClass > xIdlTargetClass = TypeToIdlClass( aType );
     835 [ +  - ][ +  - ]:          2 :             Reference< XIdlArray > xIdlArray = xIdlTargetClass->getArray();
     836 [ +  - ][ +  - ]:          2 :             sal_Int32 i, nLen = xIdlArray->getLen( aValue );
     837                 :            : 
     838                 :          2 :             typelib_TypeDescription * pTD = 0;
     839                 :          2 :             aType.getDescription( &pTD );
     840                 :            :             OSL_ASSERT( pTD && pTD->eTypeClass == typelib_TypeClass_SEQUENCE );
     841                 :          2 :             Type aElementType( ((typelib_IndirectTypeDescription *)pTD)->pType );
     842                 :          2 :             ::typelib_typedescription_release( pTD );
     843                 :            : 
     844                 :            :             // build an Array in Basic
     845                 :          2 :             SbxDimArrayRef xArray;
     846                 :          2 :             SbxDataType eSbxElementType = unoToSbxType( aElementType.getTypeClass() );
     847 [ +  - ][ +  - ]:          2 :             xArray = new SbxDimArray( eSbxElementType );
                 [ +  - ]
     848         [ +  - ]:          2 :             if( nLen > 0 )
     849                 :            :             {
     850         [ +  - ]:          2 :                 xArray->unoAddDim32( 0, nLen - 1 );
     851                 :            : 
     852                 :            :                 // register the elements as variables
     853         [ +  + ]:          6 :                 for( i = 0 ; i < nLen ; i++ )
     854                 :            :                 {
     855                 :            :                     // convert elements
     856 [ +  - ][ +  - ]:          4 :                     Any aElementAny = xIdlArray->get( aValue, (sal_uInt32)i );
     857 [ +  - ][ +  - ]:          4 :                     SbxVariableRef xVar = new SbxVariable( eSbxElementType );
     858         [ +  - ]:          4 :                     unoToSbxValue( (SbxVariable*)xVar, aElementAny );
     859                 :            : 
     860                 :            :                     // put into the Array
     861         [ +  - ]:          4 :                     xArray->Put32( (SbxVariable*)xVar, &i );
     862         [ +  - ]:          4 :                 }
     863                 :            :             }
     864                 :            :             else
     865                 :            :             {
     866         [ #  # ]:          0 :                 xArray->unoAddDim( 0, -1 );
     867                 :            :             }
     868                 :            : 
     869                 :            :             // return the Array
     870                 :          2 :             sal_uInt16 nFlags = pVar->GetFlags();
     871                 :          2 :             pVar->ResetFlag( SBX_FIXED );
     872         [ +  - ]:          2 :             pVar->PutObject( (SbxDimArray*)xArray );
     873         [ +  - ]:          2 :             pVar->SetFlags( nFlags );
     874                 :            : 
     875                 :            :         }
     876                 :          2 :         break;
     877                 :            : 
     878                 :            : 
     879         [ +  - ]:         36 :         case TypeClass_BOOLEAN:         pVar->PutBool( *(sal_Bool*)aValue.getValue() ); break;
     880                 :            :         case TypeClass_CHAR:
     881                 :            :         {
     882         [ #  # ]:          0 :             pVar->PutChar( *(sal_Unicode*)aValue.getValue() );
     883                 :          0 :             break;
     884                 :            :         }
     885         [ +  - ]:        176 :         case TypeClass_STRING:          { ::rtl::OUString val; aValue >>= val; pVar->PutString( val ); }  break;
     886         [ #  # ]:          0 :         case TypeClass_FLOAT:           { float val = 0; aValue >>= val; pVar->PutSingle( val ); } break;
     887         [ +  - ]:          2 :         case TypeClass_DOUBLE:          { double val = 0; aValue >>= val; pVar->PutDouble( val ); } break;
     888         [ #  # ]:          0 :         case TypeClass_BYTE:            { sal_Int8 val = 0; aValue >>= val; pVar->PutInteger( val ); } break;
     889         [ +  - ]:         18 :         case TypeClass_SHORT:           { sal_Int16 val = 0; aValue >>= val; pVar->PutInteger( val ); } break;
     890         [ +  - ]:         18 :         case TypeClass_LONG:            { sal_Int32 val = 0; aValue >>= val; pVar->PutLong( val ); } break;
     891         [ #  # ]:          0 :         case TypeClass_HYPER:           { sal_Int64 val = 0; aValue >>= val; pVar->PutInt64( val ); } break;
     892         [ #  # ]:          0 :         case TypeClass_UNSIGNED_SHORT:  { sal_uInt16 val = 0; aValue >>= val; pVar->PutUShort( val ); } break;
     893         [ #  # ]:          0 :         case TypeClass_UNSIGNED_LONG:   { sal_uInt32 val = 0; aValue >>= val; pVar->PutULong( val ); } break;
     894         [ #  # ]:          0 :         case TypeClass_UNSIGNED_HYPER:  { sal_uInt64 val = 0; aValue >>= val; pVar->PutUInt64( val ); } break;
     895         [ +  - ]:         96 :         default:                        pVar->PutEmpty();                       break;
     896                 :        630 :     }
     897                 :        630 : }
     898                 :            : 
     899                 :            : // Deliver the reflection for Sbx types
     900                 :        364 : Type getUnoTypeForSbxBaseType( SbxDataType eType )
     901                 :            : {
     902                 :        364 :     Type aRetType = getCppuVoidType();
     903   [ -  +  +  -  :        364 :     switch( eType )
          -  -  -  -  +  
          +  -  -  -  -  
             -  -  -  + ]
     904                 :            :     {
     905         [ #  # ]:          0 :         case SbxNULL:       aRetType = ::getCppuType( (const Reference< XInterface > *)0 ); break;
     906         [ +  - ]:         28 :         case SbxINTEGER:    aRetType = ::getCppuType( (sal_Int16*)0 ); break;
     907         [ +  - ]:         28 :         case SbxLONG:       aRetType = ::getCppuType( (sal_Int32*)0 ); break;
     908         [ #  # ]:          0 :         case SbxSINGLE:     aRetType = ::getCppuType( (float*)0 ); break;
     909         [ #  # ]:          0 :         case SbxDOUBLE:     aRetType = ::getCppuType( (double*)0 ); break;
     910         [ #  # ]:          0 :         case SbxCURRENCY:   aRetType = ::getCppuType( (oleautomation::Currency*)0 ); break;
     911         [ #  # ]:          0 :         case SbxDECIMAL:    aRetType = ::getCppuType( (oleautomation::Decimal*)0 ); break;
     912                 :            :         case SbxDATE:       {
     913         [ #  # ]:          0 :                             SbiInstance* pInst = GetSbData()->pInst;
     914 [ #  # ][ #  # ]:          0 :                             if( pInst && pInst->IsCompatibility() )
                 [ #  # ]
     915         [ #  # ]:          0 :                                 aRetType = ::getCppuType( (double*)0 );
     916                 :            :                             else
     917         [ #  # ]:          0 :                                 aRetType = ::getCppuType( (oleautomation::Date*)0 );
     918                 :            :                             }
     919                 :          0 :                             break;
     920         [ +  - ]:        186 :         case SbxSTRING:     aRetType = ::getCppuType( (::rtl::OUString*)0 ); break;
     921         [ +  - ]:         12 :         case SbxBOOL:       aRetType = ::getCppuType( (sal_Bool*)0 ); break;
     922         [ #  # ]:          0 :         case SbxVARIANT:    aRetType = ::getCppuType( (Any*)0 ); break;
     923         [ #  # ]:          0 :         case SbxCHAR:       aRetType = ::getCppuType( (sal_Unicode*)0 ); break;
     924         [ #  # ]:          0 :         case SbxBYTE:       aRetType = ::getCppuType( (sal_Int8*)0 ); break;
     925         [ #  # ]:          0 :         case SbxUSHORT:     aRetType = ::getCppuType( (sal_uInt16*)0 ); break;
     926         [ #  # ]:          0 :         case SbxULONG:      aRetType = ::getCppuType( (sal_uInt32*)0 ); break;
     927                 :            :         // map machine-dependent ones on hyper for secureness
     928         [ #  # ]:          0 :         case SbxINT:        aRetType = ::getCppuType( (sal_Int32*)0 ); break;
     929         [ #  # ]:          0 :         case SbxUINT:       aRetType = ::getCppuType( (sal_uInt32*)0 ); break;
     930                 :        110 :         default: break;
     931                 :            :     }
     932                 :        364 :     return aRetType;
     933                 :            : }
     934                 :            : 
     935                 :            : // Converting of Sbx to Uno without a know target class for TypeClass_ANY
     936                 :       4058 : Type getUnoTypeForSbxValue( SbxValue* pVal )
     937                 :            : {
     938                 :       4058 :     Type aRetType = getCppuVoidType();
     939         [ -  + ]:       4058 :     if( !pVal )
     940                 :          0 :         return aRetType;
     941                 :            : 
     942                 :            :     // convert SbxType to Uno
     943         [ +  - ]:       4058 :     SbxDataType eBaseType = pVal->SbxValue::GetType();
     944         [ +  + ]:       4058 :     if( eBaseType == SbxOBJECT )
     945                 :            :     {
     946         [ +  - ]:       3694 :         SbxBaseRef xObj = (SbxBase*)pVal->GetObject();
     947         [ -  + ]:       3694 :         if( !xObj )
     948                 :            :         {
     949         [ #  # ]:          0 :             aRetType = getCppuType( static_cast<Reference<XInterface> *>(0) );
     950                 :            :             return aRetType;
     951                 :            :         }
     952                 :            : 
     953 [ +  - ][ +  - ]:       3694 :         if( xObj->ISA(SbxDimArray) )
                 [ -  + ]
     954                 :            :         {
     955                 :          0 :             SbxBase* pObj = (SbxBase*)xObj;
     956                 :          0 :             SbxDimArray* pArray = (SbxDimArray*)pObj;
     957                 :            : 
     958         [ #  # ]:          0 :             short nDims = pArray->GetDims();
     959 [ #  # ][ #  # ]:          0 :             Type aElementType = getUnoTypeForSbxBaseType( (SbxDataType)(pArray->GetType() & 0xfff) );
     960                 :          0 :             TypeClass eElementTypeClass = aElementType.getTypeClass();
     961                 :            : 
     962                 :            :             // Normal case: One dimensional array
     963                 :            :             sal_Int32 nLower, nUpper;
     964 [ #  # ][ #  # ]:          0 :             if( nDims == 1 && pArray->GetDim32( 1, nLower, nUpper ) )
         [ #  # ][ #  # ]
     965                 :            :             {
     966 [ #  # ][ #  # ]:          0 :                 if( eElementTypeClass == TypeClass_VOID || eElementTypeClass == TypeClass_ANY )
     967                 :            :                 {
     968                 :            :                     // If all elements of the arrays are from the same type, take
     969                 :            :                     // this one - otherwise the whole will be considered as Any-Sequence
     970                 :          0 :                     sal_Bool bNeedsInit = sal_True;
     971                 :            : 
     972                 :          0 :                     sal_Int32 nSize = nUpper - nLower + 1;
     973                 :          0 :                     sal_Int32 nIdx = nLower;
     974         [ #  # ]:          0 :                     for( sal_Int32 i = 0 ; i < nSize ; i++,nIdx++ )
     975                 :            :                     {
     976         [ #  # ]:          0 :                         SbxVariableRef xVar = pArray->Get32( &nIdx );
     977         [ #  # ]:          0 :                         Type aType = getUnoTypeForSbxValue( (SbxVariable*)xVar );
     978         [ #  # ]:          0 :                         if( bNeedsInit )
     979                 :            :                         {
     980         [ #  # ]:          0 :                             if( aType.getTypeClass() == TypeClass_VOID )
     981                 :            :                             {
     982                 :            :                                 // if only first element is void: different types  -> []any
     983                 :            :                                 // if all elements are void: []void is not allowed -> []any
     984         [ #  # ]:          0 :                                 aElementType = getCppuType( (Any*)0 );
     985                 :            :                                 break;
     986                 :            :                             }
     987                 :          0 :                             aElementType = aType;
     988                 :          0 :                             bNeedsInit = sal_False;
     989                 :            :                         }
     990         [ #  # ]:          0 :                         else if( aElementType != aType )
     991                 :            :                         {
     992                 :            :                             // different types -> AnySequence
     993         [ #  # ]:          0 :                             aElementType = getCppuType( (Any*)0 );
     994                 :            :                             break;
     995                 :            :                         }
     996 [ #  # ][ #  # ]:          0 :                     }
                 [ #  # ]
     997                 :            :                 }
     998                 :            : 
     999                 :          0 :                 ::rtl::OUStringBuffer aSeqTypeName;
    1000         [ #  # ]:          0 :                 aSeqTypeName.appendAscii(RTL_CONSTASCII_STRINGPARAM(aSeqLevelStr))
    1001         [ #  # ]:          0 :                             .append(aElementType.getTypeName());
    1002         [ #  # ]:          0 :                 aRetType = Type( TypeClass_SEQUENCE, aSeqTypeName.makeStringAndClear() );
    1003                 :            :             }
    1004                 :            :             // #i33795 Map also multi dimensional arrays to corresponding sequences
    1005         [ #  # ]:          0 :             else if( nDims > 1 )
    1006                 :            :             {
    1007 [ #  # ][ #  # ]:          0 :                 if( eElementTypeClass == TypeClass_VOID || eElementTypeClass == TypeClass_ANY )
    1008                 :            :                 {
    1009                 :            :                     // For this check the array's dim structure does not matter
    1010         [ #  # ]:          0 :                     sal_uInt32 nFlatArraySize = pArray->Count32();
    1011                 :            : 
    1012                 :          0 :                     sal_Bool bNeedsInit = sal_True;
    1013         [ #  # ]:          0 :                     for( sal_uInt32 i = 0 ; i < nFlatArraySize ; i++ )
    1014                 :            :                     {
    1015         [ #  # ]:          0 :                         SbxVariableRef xVar = pArray->SbxArray::Get32( i );
    1016         [ #  # ]:          0 :                         Type aType = getUnoTypeForSbxValue( (SbxVariable*)xVar );
    1017         [ #  # ]:          0 :                         if( bNeedsInit )
    1018                 :            :                         {
    1019         [ #  # ]:          0 :                             if( aType.getTypeClass() == TypeClass_VOID )
    1020                 :            :                             {
    1021                 :            :                                 // if only first element is void: different types  -> []any
    1022                 :            :                                 // if all elements are void: []void is not allowed -> []any
    1023         [ #  # ]:          0 :                                 aElementType = getCppuType( (Any*)0 );
    1024                 :            :                                 break;
    1025                 :            :                             }
    1026                 :          0 :                             aElementType = aType;
    1027                 :          0 :                             bNeedsInit = sal_False;
    1028                 :            :                         }
    1029         [ #  # ]:          0 :                         else if( aElementType != aType )
    1030                 :            :                         {
    1031                 :            :                             // different types -> AnySequence
    1032         [ #  # ]:          0 :                             aElementType = getCppuType( (Any*)0 );
    1033                 :            :                             break;
    1034                 :            :                         }
    1035 [ #  # ][ #  # ]:          0 :                     }
                 [ #  # ]
    1036                 :            :                 }
    1037                 :            : 
    1038                 :          0 :                 ::rtl::OUStringBuffer aSeqTypeName;
    1039         [ #  # ]:          0 :                 for( short iDim = 0 ; iDim < nDims ; iDim++ )
    1040         [ #  # ]:          0 :                     aSeqTypeName.appendAscii(RTL_CONSTASCII_STRINGPARAM(aSeqLevelStr));
    1041         [ #  # ]:          0 :                 aSeqTypeName.append(aElementType.getTypeName());
    1042         [ #  # ]:          0 :                 aRetType = Type( TypeClass_SEQUENCE, aSeqTypeName.makeStringAndClear() );
    1043                 :          0 :             }
    1044                 :            :         }
    1045                 :            :         // No array, but ...
    1046 [ +  - ][ +  - ]:       3694 :         else if( xObj->ISA(SbUnoObject) )
    1047                 :            :         {
    1048         [ +  - ]:       3694 :             aRetType = ((SbUnoObject*)(SbxBase*)xObj)->getUnoAny().getValueType();
    1049                 :            :         }
    1050                 :            :         // SbUnoAnyObject?
    1051 [ #  # ][ #  # ]:          0 :         else if( xObj->ISA(SbUnoAnyObject) )
    1052                 :            :         {
    1053                 :       3694 :             aRetType = ((SbUnoAnyObject*)(SbxBase*)xObj)->getValue().getValueType();
    1054 [ +  - ][ +  - ]:       3694 :         }
    1055                 :            :         // Otherwise it is a No-Uno-Basic-Object -> default==deliver void
    1056                 :            :     }
    1057                 :            :     // No object, convert basic type
    1058                 :            :     else
    1059                 :            :     {
    1060         [ +  - ]:        364 :         aRetType = getUnoTypeForSbxBaseType( eBaseType );
    1061                 :            :     }
    1062                 :       4058 :     return aRetType;
    1063                 :            : }
    1064                 :            : 
    1065                 :            : // Declaration converting of Sbx to Uno with known target class
    1066                 :            : Any sbxToUnoValue( SbxVariable* pVar, const Type& rType, Property* pUnoProperty = NULL );
    1067                 :            : 
    1068                 :            : // converting of Sbx to Uno without known target class for TypeClass_ANY
    1069                 :       4058 : Any sbxToUnoValueImpl( SbxVariable* pVar, bool bBlockConversionToSmallestType = false )
    1070                 :            : {
    1071         [ +  - ]:       4058 :     SbxDataType eBaseType = pVar->SbxValue::GetType();
    1072         [ +  + ]:       4058 :     if( eBaseType == SbxOBJECT )
    1073                 :            :     {
    1074         [ +  - ]:       3694 :         SbxBaseRef xObj = (SbxBase*)pVar->GetObject();
    1075         [ +  - ]:       3694 :         if( xObj.Is() )
    1076                 :            :         {
    1077 [ +  - ][ -  + ]:       3694 :             if( xObj->ISA(SbUnoAnyObject) )
    1078                 :          0 :                 return ((SbUnoAnyObject*)(SbxBase*)xObj)->getValue();
    1079 [ +  - ][ +  - ]:       3694 :             if( xObj->ISA(SbClassModuleObject) )
                 [ -  + ]
    1080                 :            :             {
    1081                 :          0 :                 Any aRetAny;
    1082                 :          0 :                 SbClassModuleObject* pClassModuleObj = (SbClassModuleObject*)(SbxBase*)xObj;
    1083                 :          0 :                 SbModule* pClassModule = pClassModuleObj->getClassModule();
    1084 [ #  # ][ #  # ]:          0 :                 if( pClassModule->createCOMWrapperForIface( aRetAny, pClassModuleObj ) )
    1085         [ #  # ]:          0 :                     return aRetAny;
    1086                 :            :             }
    1087 [ +  - ][ -  + ]:       3694 :             if( !xObj->ISA(SbUnoObject) )
    1088                 :            :             {
    1089                 :            :                 // Create NativeObjectWrapper to identify object in case of callbacks
    1090 [ #  # ][ #  # ]:          0 :                 SbxObject* pObj = PTR_CAST(SbxObject,pVar->GetObject());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    1091         [ #  # ]:          0 :                 if( pObj != NULL )
    1092                 :            :                 {
    1093                 :          0 :                     NativeObjectWrapper aNativeObjectWrapper;
    1094         [ #  # ]:          0 :                     sal_uInt32 nIndex = lcl_registerNativeObjectWrapper( pObj );
    1095         [ #  # ]:          0 :                     aNativeObjectWrapper.ObjectId <<= nIndex;
    1096                 :          0 :                     Any aRetAny;
    1097         [ #  # ]:          0 :                     aRetAny <<= aNativeObjectWrapper;
    1098                 :       3694 :                     return aRetAny;
    1099                 :            :                 }
    1100                 :            :             }
    1101 [ +  - ][ +  - ]:       3694 :         }
    1102                 :            :     }
    1103                 :            : 
    1104         [ +  - ]:       4058 :     Type aType = getUnoTypeForSbxValue( pVar );
    1105                 :       4058 :     TypeClass eType = aType.getTypeClass();
    1106                 :            : 
    1107         [ +  - ]:       4058 :     if( !bBlockConversionToSmallestType )
    1108                 :            :     {
    1109                 :            :         // #79615 Choose "smallest" represention for int values
    1110                 :            :         // because up cast is allowed, downcast not
    1111   [ -  +  +  -  :       4058 :         switch( eType )
                   -  + ]
    1112                 :            :         {
    1113                 :            :             case TypeClass_FLOAT:
    1114                 :            :             case TypeClass_DOUBLE:
    1115                 :            :             {
    1116         [ #  # ]:          0 :                 double d = pVar->GetDouble();
    1117         [ #  # ]:          0 :                 if( d == floor( d ) )
    1118                 :            :                 {
    1119 [ #  # ][ #  # ]:          0 :                     if( d >= -128 && d <= 127 )
    1120         [ #  # ]:          0 :                         aType = ::getCppuType( (sal_Int8*)0 );
    1121 [ #  # ][ #  # ]:          0 :                     else if( d >= SbxMININT && d <= SbxMAXINT )
    1122         [ #  # ]:          0 :                         aType = ::getCppuType( (sal_Int16*)0 );
    1123 [ #  # ][ #  # ]:          0 :                     else if( d >= -SbxMAXLNG && d <= SbxMAXLNG )
    1124         [ #  # ]:          0 :                         aType = ::getCppuType( (sal_Int32*)0 );
    1125                 :            :                 }
    1126                 :          0 :                 break;
    1127                 :            :             }
    1128                 :            :             case TypeClass_SHORT:
    1129                 :            :             {
    1130         [ +  - ]:         28 :                 sal_Int16 n = pVar->GetInteger();
    1131 [ +  - ][ +  - ]:         28 :                 if( n >= -128 && n <= 127 )
    1132         [ +  - ]:         28 :                     aType = ::getCppuType( (sal_Int8*)0 );
    1133                 :         28 :                 break;
    1134                 :            :             }
    1135                 :            :             case TypeClass_LONG:
    1136                 :            :             {
    1137         [ +  - ]:         28 :                 sal_Int32 n = pVar->GetLong();
    1138 [ -  + ][ #  # ]:         28 :                 if( n >= -128 && n <= 127 )
    1139         [ #  # ]:          0 :                     aType = ::getCppuType( (sal_Int8*)0 );
    1140 [ +  - ][ +  - ]:         28 :                 else if( n >= SbxMININT && n <= SbxMAXINT )
    1141         [ +  - ]:         28 :                     aType = ::getCppuType( (sal_Int16*)0 );
    1142                 :         28 :                 break;
    1143                 :            :             }
    1144                 :            :             case TypeClass_UNSIGNED_SHORT:
    1145                 :            :             {
    1146         [ #  # ]:          0 :                 sal_uInt16 n = pVar->GetUShort();
    1147         [ #  # ]:          0 :                 if( n <= 255 )
    1148         [ #  # ]:          0 :                     aType = ::getCppuType( (sal_uInt8*)0 );
    1149                 :          0 :                 break;
    1150                 :            :             }
    1151                 :            :             case TypeClass_UNSIGNED_LONG:
    1152                 :            :             {
    1153         [ #  # ]:          0 :                 sal_uInt32 n = pVar->GetLong();
    1154         [ #  # ]:          0 :                 if( n <= 255 )
    1155         [ #  # ]:          0 :                     aType = ::getCppuType( (sal_uInt8*)0 );
    1156         [ #  # ]:          0 :                 else if( n <= SbxMAXUINT )
    1157         [ #  # ]:          0 :                     aType = ::getCppuType( (sal_uInt16*)0 );
    1158                 :          0 :                 break;
    1159                 :            :             }
    1160                 :            :             // TODO: need to add hyper types ?
    1161                 :       4058 :             default: break;
    1162                 :            :         }
    1163                 :            :     }
    1164                 :            : 
    1165         [ +  - ]:       4058 :     return sbxToUnoValue( pVar, aType );
    1166                 :            : }
    1167                 :            : 
    1168                 :            : 
    1169                 :            : 
    1170                 :            : // Helper function for StepREDIMP
    1171                 :          0 : static Any implRekMultiDimArrayToSequence( SbxDimArray* pArray,
    1172                 :            :     const Type& aElemType, short nMaxDimIndex, short nActualDim,
    1173                 :            :     sal_Int32* pActualIndices, sal_Int32* pLowerBounds, sal_Int32* pUpperBounds )
    1174                 :            : {
    1175                 :          0 :     sal_Int32 nSeqLevel = nMaxDimIndex - nActualDim + 1;
    1176                 :          0 :     ::rtl::OUStringBuffer aSeqTypeName;
    1177                 :            :     sal_Int32 i;
    1178         [ #  # ]:          0 :     for( i = 0 ; i < nSeqLevel ; i++ )
    1179         [ #  # ]:          0 :         aSeqTypeName.appendAscii(RTL_CONSTASCII_STRINGPARAM(aSeqLevelStr));
    1180         [ #  # ]:          0 :     aSeqTypeName.append(aElemType.getTypeName());
    1181         [ #  # ]:          0 :     Type aSeqType( TypeClass_SEQUENCE, aSeqTypeName.makeStringAndClear() );
    1182                 :            : 
    1183                 :            :     // Create Sequence instance
    1184                 :          0 :     Any aRetVal;
    1185         [ #  # ]:          0 :     Reference< XIdlClass > xIdlTargetClass = TypeToIdlClass( aSeqType );
    1186 [ #  # ][ #  # ]:          0 :     xIdlTargetClass->createObject( aRetVal );
    1187                 :            : 
    1188                 :            :     // Alloc sequence according to array bounds
    1189                 :          0 :     sal_Int32 nUpper = pUpperBounds[nActualDim];
    1190                 :          0 :     sal_Int32 nLower = pLowerBounds[nActualDim];
    1191                 :          0 :     sal_Int32 nSeqSize = nUpper - nLower + 1;
    1192 [ #  # ][ #  # ]:          0 :     Reference< XIdlArray > xArray = xIdlTargetClass->getArray();
    1193 [ #  # ][ #  # ]:          0 :     xArray->realloc( aRetVal, nSeqSize );
    1194                 :            : 
    1195                 :          0 :     sal_Int32& ri = pActualIndices[nActualDim];
    1196                 :            : 
    1197         [ #  # ]:          0 :     for( ri = nLower,i = 0 ; ri <= nUpper ; ri++,i++ )
    1198                 :            :     {
    1199                 :          0 :         Any aElementVal;
    1200                 :            : 
    1201         [ #  # ]:          0 :         if( nActualDim < nMaxDimIndex )
    1202                 :            :         {
    1203                 :            :             aElementVal = implRekMultiDimArrayToSequence( pArray, aElemType,
    1204         [ #  # ]:          0 :                 nMaxDimIndex, nActualDim + 1, pActualIndices, pLowerBounds, pUpperBounds );
    1205                 :            :         }
    1206                 :            :         else
    1207                 :            :         {
    1208         [ #  # ]:          0 :             SbxVariable* pSource = pArray->Get32( pActualIndices );
    1209         [ #  # ]:          0 :             aElementVal = sbxToUnoValue( pSource, aElemType );
    1210                 :            :         }
    1211                 :            : 
    1212                 :            :         try
    1213                 :            :         {
    1214                 :            :             // transfer to the sequence
    1215 [ #  # ][ #  # ]:          0 :             xArray->set( aRetVal, i, aElementVal );
    1216                 :            :         }
    1217         [ #  # ]:          0 :         catch( const IllegalArgumentException& )
    1218                 :            :         {
    1219                 :            :             StarBASIC::Error( ERRCODE_BASIC_EXCEPTION,
    1220   [ #  #  #  #  :          0 :                 implGetExceptionMsg( ::cppu::getCaughtException() ) );
          #  #  #  #  #  
                      # ]
    1221                 :            :         }
    1222   [ #  #  #  #  :          0 :         catch (const IndexOutOfBoundsException&)
                      # ]
    1223                 :            :         {
    1224         [ #  # ]:          0 :             StarBASIC::Error( SbERR_OUT_OF_RANGE );
    1225                 :            :         }
    1226                 :          0 :     }
    1227                 :          0 :     return aRetVal;
    1228                 :            : }
    1229                 :            : 
    1230                 :            : // Map old interface
    1231                 :       3710 : Any sbxToUnoValue( SbxVariable* pVar )
    1232                 :            : {
    1233                 :       3710 :     return sbxToUnoValueImpl( pVar );
    1234                 :            : }
    1235                 :            : 
    1236                 :            : // function to find a global identifier in
    1237                 :            : // the UnoScope and to wrap it for Sbx
    1238                 :          0 : static bool implGetTypeByName( const String& rName, Type& rRetType )
    1239                 :            : {
    1240                 :          0 :     bool bSuccess = false;
    1241                 :            : 
    1242         [ #  # ]:          0 :     Reference< XHierarchicalNameAccess > xTypeAccess = getTypeProvider_Impl();
    1243 [ #  # ][ #  # ]:          0 :     if( xTypeAccess->hasByHierarchicalName( rName ) )
         [ #  # ][ #  # ]
    1244                 :            :     {
    1245 [ #  # ][ #  # ]:          0 :         Any aRet = xTypeAccess->getByHierarchicalName( rName );
                 [ #  # ]
    1246                 :          0 :         Reference< XTypeDescription > xTypeDesc;
    1247         [ #  # ]:          0 :         aRet >>= xTypeDesc;
    1248                 :            : 
    1249         [ #  # ]:          0 :         if( xTypeDesc.is() )
    1250                 :            :         {
    1251 [ #  # ][ #  # ]:          0 :             rRetType = Type( xTypeDesc->getTypeClass(), xTypeDesc->getName() );
         [ #  # ][ #  # ]
    1252                 :          0 :             bSuccess = true;
    1253                 :          0 :         }
    1254                 :            :     }
    1255                 :          0 :     return bSuccess;
    1256                 :            : }
    1257                 :            : 
    1258                 :            : 
    1259                 :            : // converting of Sbx to Uno with known target class
    1260                 :       4920 : Any sbxToUnoValue( SbxVariable* pVar, const Type& rType, Property* pUnoProperty )
    1261                 :            : {
    1262                 :       4920 :     Any aRetVal;
    1263                 :            : 
    1264                 :            :     // #94560 No conversion of empty/void for MAYBE_VOID properties
    1265 [ +  + ][ +  + ]:       4920 :     if( pUnoProperty && pUnoProperty->Attributes & PropertyAttribute::MAYBEVOID )
    1266                 :            :     {
    1267 [ +  - ][ -  + ]:          2 :         if( pVar->IsEmpty() )
    1268                 :          0 :             return aRetVal;
    1269                 :            :     }
    1270                 :            : 
    1271         [ +  - ]:       4920 :     SbxDataType eBaseType = pVar->SbxValue::GetType();
    1272         [ +  + ]:       4920 :     if( eBaseType == SbxOBJECT )
    1273                 :            :     {
    1274         [ +  - ]:       3870 :         SbxBaseRef xObj = (SbxBase*)pVar->GetObject();
    1275 [ +  - ][ -  + ]:       3870 :         if( xObj.Is() && xObj->ISA(SbUnoAnyObject) )
         [ -  + ][ +  + ]
    1276                 :            :         {
    1277                 :       3870 :             return ((SbUnoAnyObject*)(SbxBase*)xObj)->getValue();
    1278 [ +  - ][ +  - ]:       3870 :         }
    1279                 :            :     }
    1280                 :            : 
    1281                 :       4920 :     TypeClass eType = rType.getTypeClass();
    1282   [ +  -  -  +  :       4920 :     switch( eType )
          +  +  -  +  -  
          +  +  +  +  -  
             -  -  -  + ]
    1283                 :            :     {
    1284                 :            :         case TypeClass_INTERFACE:
    1285                 :            :         case TypeClass_STRUCT:
    1286                 :            :         case TypeClass_EXCEPTION:
    1287                 :            :         {
    1288         [ +  - ]:       2109 :             Reference< XIdlClass > xIdlTargetClass = TypeToIdlClass( rType );
    1289                 :            : 
    1290                 :            :             // zero referenz?
    1291 [ +  - ][ -  + ]:       2109 :             if( pVar->IsNull() && eType == TypeClass_INTERFACE )
         [ #  # ][ -  + ]
    1292                 :            :             {
    1293                 :          0 :                 Reference< XInterface > xRef;
    1294 [ #  # ][ #  # ]:          0 :                 ::rtl::OUString aClassName = xIdlTargetClass->getName();
    1295 [ #  # ][ #  # ]:          0 :                 Type aClassType( xIdlTargetClass->getTypeClass(), aClassName.getStr() );
    1296                 :          0 :                 aRetVal.setValue( &xRef, aClassType );
    1297                 :            :             }
    1298                 :            :             else
    1299                 :            :             {
    1300                 :            :                 // #112368 Special conversion for Decimal, Currency and Date
    1301         [ +  + ]:       2109 :                 if( eType == TypeClass_STRUCT )
    1302                 :            :                 {
    1303         [ +  - ]:         78 :                     SbiInstance* pInst = GetSbData()->pInst;
    1304 [ +  - ][ -  + ]:         78 :                     if( pInst && pInst->IsCompatibility() )
                 [ -  + ]
    1305                 :            :                     {
    1306 [ #  # ][ #  # ]:          0 :                         if( rType == ::getCppuType( (oleautomation::Decimal*)0 ) )
    1307                 :            :                         {
    1308                 :          0 :                             oleautomation::Decimal aDecimal;
    1309         [ #  # ]:          0 :                             pVar->fillAutomationDecimal( aDecimal );
    1310         [ #  # ]:          0 :                             aRetVal <<= aDecimal;
    1311                 :            :                             break;
    1312                 :            :                         }
    1313 [ #  # ][ #  # ]:          0 :                         else if( rType == ::getCppuType( (oleautomation::Currency*)0 ) )
    1314                 :            :                         {
    1315                 :            :                             // assumes per previous code that ole Currency is Int64
    1316 [ #  # ][ #  # ]:          0 :                             aRetVal <<= (sal_Int64)( pVar->GetInt64() );
    1317                 :            :                             break;
    1318                 :            :                         }
    1319 [ #  # ][ #  # ]:          0 :                         else if( rType == ::getCppuType( (oleautomation::Date*)0 ) )
    1320                 :            :                         {
    1321                 :          0 :                             oleautomation::Date aDate;
    1322         [ #  # ]:          0 :                             aDate.Value = pVar->GetDate();
    1323         [ #  # ]:          0 :                             aRetVal <<= aDate;
    1324                 :            :                             break;
    1325                 :            :                         }
    1326                 :            :                     }
    1327                 :            :                 }
    1328                 :            : 
    1329         [ +  - ]:       2109 :                 SbxBaseRef pObj = (SbxBase*)pVar->GetObject();
    1330 [ +  - ][ +  - ]:       2109 :                 if( pObj && pObj->ISA(SbUnoObject) )
         [ +  + ][ +  + ]
    1331                 :            :                 {
    1332         [ +  - ]:       2105 :                     aRetVal = ((SbUnoObject*)(SbxBase*)pObj)->getUnoAny();
    1333                 :            :                 }
    1334 [ -  + ][ #  # ]:          4 :                 else if( pObj && pObj->ISA(SbUnoStructRefObject) )
         [ #  # ][ -  + ]
    1335                 :            :                 {
    1336         [ #  # ]:          0 :                     aRetVal = ((SbUnoStructRefObject*)(SbxBase*)pObj)->getUnoAny();
    1337                 :            :                 }
    1338                 :            :                 else
    1339                 :            :                 {
    1340                 :            :                     // zero object -> zero XInterface
    1341                 :          4 :                     Reference<XInterface> xInt;
    1342         [ +  - ]:          4 :                     aRetVal <<= xInt;
    1343         [ +  - ]:       2109 :                 }
    1344         [ +  - ]:       2109 :             }
    1345                 :            :         }
    1346                 :       2109 :         break;
    1347                 :            : 
    1348                 :            :         case TypeClass_TYPE:
    1349                 :            :         {
    1350         [ #  # ]:          0 :             if( eBaseType == SbxOBJECT )
    1351                 :            :             {
    1352                 :            :                 // XIdlClass?
    1353                 :          0 :                 Reference< XIdlClass > xIdlClass;
    1354                 :            : 
    1355         [ #  # ]:          0 :                 SbxBaseRef pObj = (SbxBase*)pVar->GetObject();
    1356 [ #  # ][ #  # ]:          0 :                 if( pObj && pObj->ISA(SbUnoObject) )
         [ #  # ][ #  # ]
    1357                 :            :                 {
    1358         [ #  # ]:          0 :                     Any aUnoAny = ((SbUnoObject*)(SbxBase*)pObj)->getUnoAny();
    1359         [ #  # ]:          0 :                     aUnoAny >>= xIdlClass;
    1360                 :            :                 }
    1361                 :            : 
    1362         [ #  # ]:          0 :                 if( xIdlClass.is() )
    1363                 :            :                 {
    1364 [ #  # ][ #  # ]:          0 :                     ::rtl::OUString aClassName = xIdlClass->getName();
    1365 [ #  # ][ #  # ]:          0 :                     Type aType( xIdlClass->getTypeClass(), aClassName.getStr() );
    1366         [ #  # ]:          0 :                     aRetVal <<= aType;
    1367         [ #  # ]:          0 :                 }
    1368                 :            :             }
    1369         [ #  # ]:          0 :             else if( eBaseType == SbxSTRING )
    1370                 :            :             {
    1371                 :            :                 // String representing type?
    1372 [ #  # ][ #  # ]:          0 :                 String aTypeName = pVar->GetString();
    1373                 :          0 :                 Type aType;
    1374         [ #  # ]:          0 :                 bool bSuccess = implGetTypeByName( aTypeName, aType );
    1375         [ #  # ]:          0 :                 if( bSuccess )
    1376 [ #  # ][ #  # ]:          0 :                     aRetVal <<= aType;
    1377                 :            :             }
    1378                 :            :         }
    1379                 :          0 :         break;
    1380                 :            : 
    1381                 :            : 
    1382                 :            :         case TypeClass_ENUM:
    1383                 :            :         {
    1384         [ #  # ]:          0 :             aRetVal = int2enum( pVar->GetLong(), rType );
    1385                 :            :         }
    1386                 :          0 :         break;
    1387                 :            : 
    1388                 :            :         case TypeClass_SEQUENCE:
    1389                 :            :         {
    1390         [ +  - ]:         70 :             SbxBaseRef xObj = (SbxBase*)pVar->GetObject();
    1391 [ +  - ][ +  - ]:         70 :             if( xObj && xObj->ISA(SbxDimArray) )
         [ +  - ][ +  - ]
                 [ +  - ]
    1392                 :            :             {
    1393                 :         70 :                 SbxBase* pObj = (SbxBase*)xObj;
    1394                 :         70 :                 SbxDimArray* pArray = (SbxDimArray*)pObj;
    1395                 :            : 
    1396         [ +  - ]:         70 :                 short nDims = pArray->GetDims();
    1397                 :            : 
    1398                 :            :                 // Normal case: One dimensional array
    1399                 :            :                 sal_Int32 nLower, nUpper;
    1400 [ +  - ][ +  - ]:         70 :                 if( nDims == 1 && pArray->GetDim32( 1, nLower, nUpper ) )
         [ +  - ][ +  - ]
    1401                 :            :                 {
    1402                 :         70 :                     sal_Int32 nSeqSize = nUpper - nLower + 1;
    1403                 :            : 
    1404                 :            :                     // create the instanz of the required sequence
    1405         [ +  - ]:         70 :                     Reference< XIdlClass > xIdlTargetClass = TypeToIdlClass( rType );
    1406 [ +  - ][ +  - ]:         70 :                     xIdlTargetClass->createObject( aRetVal );
    1407 [ +  - ][ +  - ]:         70 :                     Reference< XIdlArray > xArray = xIdlTargetClass->getArray();
    1408 [ +  - ][ +  - ]:         70 :                     xArray->realloc( aRetVal, nSeqSize );
    1409                 :            : 
    1410                 :            :                     // Element-Type
    1411 [ +  - ][ +  - ]:         70 :                     ::rtl::OUString aClassName = xIdlTargetClass->getName();
    1412                 :         70 :                     typelib_TypeDescription * pSeqTD = 0;
    1413                 :         70 :                     typelib_typedescription_getByName( &pSeqTD, aClassName.pData );
    1414                 :            :                     OSL_ASSERT( pSeqTD );
    1415                 :         70 :                     Type aElemType( ((typelib_IndirectTypeDescription *)pSeqTD)->pType );
    1416                 :            : 
    1417                 :            :                     // convert all array member and register them
    1418                 :         70 :                     sal_Int32 nIdx = nLower;
    1419         [ +  + ]:        130 :                     for( sal_Int32 i = 0 ; i < nSeqSize ; i++,nIdx++ )
    1420                 :            :                     {
    1421         [ +  - ]:         60 :                         SbxVariableRef xVar = pArray->Get32( &nIdx );
    1422                 :            : 
    1423                 :            :                         // Convert the value of Sbx to Uno
    1424         [ +  - ]:         60 :                         Any aAnyValue = sbxToUnoValue( (SbxVariable*)xVar, aElemType );
    1425                 :            : 
    1426                 :            :                         try
    1427                 :            :                         {
    1428                 :            :                             // take over to the sequence
    1429 [ +  - ][ +  - ]:         60 :                             xArray->set( aRetVal, i, aAnyValue );
    1430                 :            :                         }
    1431         [ #  # ]:          0 :                         catch( const IllegalArgumentException& )
    1432                 :            :                         {
    1433                 :            :                             StarBASIC::Error( ERRCODE_BASIC_EXCEPTION,
    1434   [ #  #  #  #  :          0 :                                 implGetExceptionMsg( ::cppu::getCaughtException() ) );
          #  #  #  #  #  
                      # ]
    1435                 :            :                         }
    1436   [ #  #  #  #  :          0 :                         catch (const IndexOutOfBoundsException&)
                      # ]
    1437                 :            :                         {
    1438         [ #  # ]:          0 :                             StarBASIC::Error( SbERR_OUT_OF_RANGE );
    1439                 :            :                         }
    1440         [ +  - ]:        130 :                     }
    1441                 :            :                 }
    1442                 :            :                 // #i33795 Map also multi dimensional arrays to corresponding sequences
    1443         [ #  # ]:          0 :                 else if( nDims > 1 )
    1444                 :            :                 {
    1445                 :            :                     // Element-Type
    1446                 :          0 :                     typelib_TypeDescription * pSeqTD = 0;
    1447                 :          0 :                     Type aCurType( rType );
    1448                 :          0 :                     sal_Int32 nSeqLevel = 0;
    1449                 :          0 :                     Type aElemType;
    1450                 :          0 :                     do
    1451                 :            :                     {
    1452                 :          0 :                         ::rtl::OUString aTypeName = aCurType.getTypeName();
    1453                 :          0 :                         typelib_typedescription_getByName( &pSeqTD, aTypeName.pData );
    1454                 :            :                         OSL_ASSERT( pSeqTD );
    1455         [ #  # ]:          0 :                         if( pSeqTD->eTypeClass == typelib_TypeClass_SEQUENCE )
    1456                 :            :                         {
    1457                 :          0 :                             aCurType = Type( ((typelib_IndirectTypeDescription *)pSeqTD)->pType );
    1458                 :          0 :                             nSeqLevel++;
    1459                 :            :                         }
    1460                 :            :                         else
    1461                 :            :                         {
    1462                 :          0 :                             aElemType = aCurType;
    1463                 :            :                             break;
    1464         [ #  # ]:          0 :                         }
    1465                 :            :                     }
    1466                 :            :                     while( true );
    1467                 :            : 
    1468         [ #  # ]:          0 :                     if( nSeqLevel == nDims )
    1469                 :            :                     {
    1470         [ #  # ]:          0 :                         sal_Int32* pLowerBounds = new sal_Int32[nDims];
    1471         [ #  # ]:          0 :                         sal_Int32* pUpperBounds = new sal_Int32[nDims];
    1472         [ #  # ]:          0 :                         sal_Int32* pActualIndices = new sal_Int32[nDims];
    1473         [ #  # ]:          0 :                         for( short i = 1 ; i <= nDims ; i++ )
    1474                 :            :                         {
    1475                 :            :                             sal_Int32 lBound, uBound;
    1476         [ #  # ]:          0 :                             pArray->GetDim32( i, lBound, uBound );
    1477                 :            : 
    1478                 :          0 :                             short j = i - 1;
    1479                 :          0 :                             pActualIndices[j] = pLowerBounds[j] = lBound;
    1480                 :          0 :                             pUpperBounds[j] = uBound;
    1481                 :            :                         }
    1482                 :            : 
    1483                 :            :                         aRetVal = implRekMultiDimArrayToSequence( pArray, aElemType,
    1484         [ #  # ]:          0 :                             nDims - 1, 0, pActualIndices, pLowerBounds, pUpperBounds );
    1485                 :            : 
    1486         [ #  # ]:          0 :                         delete[] pUpperBounds;
    1487         [ #  # ]:          0 :                         delete[] pLowerBounds;
    1488         [ #  # ]:          0 :                         delete[] pActualIndices;
    1489                 :         70 :                     }
    1490                 :            :                 }
    1491         [ +  - ]:         70 :             }
    1492                 :            :         }
    1493                 :         70 :         break;
    1494                 :            : 
    1495                 :            : 
    1496                 :            :         // Use for Any the class indipendent converting routine
    1497                 :            :         case TypeClass_ANY:
    1498                 :            :         {
    1499         [ +  - ]:        324 :             aRetVal = sbxToUnoValueImpl( pVar );
    1500                 :            :         }
    1501                 :        324 :         break;
    1502                 :            : 
    1503                 :            :         case TypeClass_BOOLEAN:
    1504                 :            :         {
    1505         [ +  - ]:         54 :             sal_Bool b = pVar->GetBool();
    1506         [ +  - ]:         54 :             aRetVal.setValue( &b, getBooleanCppuType() );
    1507                 :            :             break;
    1508                 :            :         }
    1509                 :            :         case TypeClass_CHAR:
    1510                 :            :         {
    1511         [ #  # ]:          0 :             sal_Unicode c = pVar->GetChar();
    1512         [ #  # ]:          0 :             aRetVal.setValue( &c , getCharCppuType() );
    1513                 :            :             break;
    1514                 :            :         }
    1515 [ +  - ][ +  - ]:        434 :         case TypeClass_STRING:          aRetVal <<= pVar->GetOUString(); break;
    1516 [ #  # ][ #  # ]:          0 :         case TypeClass_FLOAT:           aRetVal <<= pVar->GetSingle(); break;
    1517 [ +  - ][ +  - ]:          2 :         case TypeClass_DOUBLE:          aRetVal <<= pVar->GetDouble(); break;
    1518                 :            : 
    1519                 :            :         case TypeClass_BYTE:
    1520                 :            :         {
    1521         [ +  - ]:         28 :             sal_Int16 nVal = pVar->GetInteger();
    1522                 :         28 :             sal_Bool bOverflow = sal_False;
    1523         [ -  + ]:         28 :             if( nVal < -128 )
    1524                 :            :             {
    1525                 :          0 :                 bOverflow = sal_True;
    1526                 :          0 :                 nVal = -128;
    1527                 :            :             }
    1528         [ -  + ]:         28 :             else if( nVal > 127 )
    1529                 :            :             {
    1530                 :          0 :                 bOverflow = sal_True;
    1531                 :          0 :                 nVal = 127;
    1532                 :            :             }
    1533         [ -  + ]:         28 :             if( bOverflow )
    1534         [ #  # ]:          0 :                    StarBASIC::Error( ERRCODE_BASIC_MATH_OVERFLOW );
    1535                 :            : 
    1536                 :         28 :             sal_Int8 nByteVal = (sal_Int8)nVal;
    1537         [ +  - ]:         28 :             aRetVal <<= nByteVal;
    1538                 :            :             break;
    1539                 :            :         }
    1540 [ +  - ][ +  - ]:         46 :         case TypeClass_SHORT:           aRetVal <<= (sal_Int16)( pVar->GetInteger() );  break;
    1541 [ +  - ][ +  - ]:         52 :         case TypeClass_LONG:            aRetVal <<= (sal_Int32)( pVar->GetLong() );     break;
    1542 [ #  # ][ #  # ]:          0 :         case TypeClass_HYPER:           aRetVal <<= (sal_Int64)( pVar->GetInt64() );    break;
    1543 [ #  # ][ #  # ]:          0 :         case TypeClass_UNSIGNED_SHORT:  aRetVal <<= (sal_uInt16)( pVar->GetUShort() );  break;
    1544 [ #  # ][ #  # ]:          0 :         case TypeClass_UNSIGNED_LONG:   aRetVal <<= (sal_uInt32)( pVar->GetULong() );   break;
    1545 [ #  # ][ #  # ]:          0 :         case TypeClass_UNSIGNED_HYPER:  aRetVal <<= (sal_uInt64)( pVar->GetUInt64() );  break;
    1546                 :       1801 :         default: break;
    1547                 :            :     }
    1548                 :            : 
    1549                 :       4920 :     return aRetVal;
    1550                 :            : }
    1551                 :            : 
    1552                 :          0 : void processAutomationParams( SbxArray* pParams, Sequence< Any >& args, bool bOLEAutomation, sal_uInt32 nParamCount )
    1553                 :            : {
    1554                 :          0 :     AutomationNamedArgsSbxArray* pArgNamesArray = NULL;
    1555         [ #  # ]:          0 :     if( bOLEAutomation )
    1556 [ #  # ][ #  # ]:          0 :         pArgNamesArray = PTR_CAST(AutomationNamedArgsSbxArray,pParams);
    1557                 :            : 
    1558                 :          0 :     args.realloc( nParamCount );
    1559                 :          0 :     Any* pAnyArgs = args.getArray();
    1560                 :          0 :     bool bBlockConversionToSmallestType = GetSbData()->pInst->IsCompatibility();
    1561                 :          0 :     sal_uInt32 i = 0;
    1562         [ #  # ]:          0 :     if( pArgNamesArray )
    1563                 :            :     {
    1564                 :          0 :         Sequence< ::rtl::OUString >& rNameSeq = pArgNamesArray->getNames();
    1565         [ #  # ]:          0 :         ::rtl::OUString* pNames = rNameSeq.getArray();
    1566                 :          0 :         Any aValAny;
    1567         [ #  # ]:          0 :         for( i = 0 ; i < nParamCount ; i++ )
    1568                 :            :         {
    1569                 :          0 :             sal_uInt16 iSbx = (sal_uInt16)(i+1);
    1570                 :            : 
    1571                 :            :             aValAny = sbxToUnoValueImpl( pParams->Get( iSbx ),
    1572 [ #  # ][ #  # ]:          0 :             bBlockConversionToSmallestType );
    1573                 :            : 
    1574                 :          0 :             ::rtl::OUString aParamName = pNames[iSbx];
    1575         [ #  # ]:          0 :             if( !aParamName.isEmpty() )
    1576                 :            :             {
    1577                 :          0 :                 oleautomation::NamedArgument aNamedArgument;
    1578                 :          0 :                 aNamedArgument.Name = aParamName;
    1579                 :          0 :                 aNamedArgument.Value = aValAny;
    1580         [ #  # ]:          0 :                 pAnyArgs[i] <<= aNamedArgument;
    1581                 :            :             }
    1582                 :            :             else
    1583                 :            :             {
    1584                 :          0 :                 pAnyArgs[i] = aValAny;
    1585                 :            :             }
    1586                 :          0 :         }
    1587                 :            :     }
    1588                 :            :     else
    1589                 :            :     {
    1590         [ #  # ]:          0 :         for( i = 0 ; i < nParamCount ; i++ )
    1591                 :            :         {
    1592                 :            :             pAnyArgs[i] = sbxToUnoValueImpl( pParams->Get( (sal_uInt16)(i+1) ),
    1593                 :          0 :             bBlockConversionToSmallestType );
    1594                 :            :         }
    1595                 :            :     }
    1596                 :            : 
    1597                 :          0 : }
    1598                 :            : enum INVOKETYPE
    1599                 :            : {
    1600                 :            :    GetProp = 0,
    1601                 :            :    SetProp,
    1602                 :            :    Func
    1603                 :            : };
    1604                 :          0 : Any invokeAutomationMethod( const rtl::OUString& Name, Sequence< Any >& args, SbxArray* pParams, sal_uInt32 nParamCount, Reference< XInvocation >& rxInvocation, INVOKETYPE invokeType = Func )
    1605                 :            : {
    1606         [ #  # ]:          0 :     Sequence< sal_Int16 > OutParamIndex;
    1607         [ #  # ]:          0 :     Sequence< Any > OutParam;
    1608                 :            : 
    1609                 :          0 :     Any aRetAny;
    1610   [ #  #  #  # ]:          0 :     switch( invokeType )
    1611                 :            :     {
    1612                 :            :         case Func:
    1613 [ #  # ][ #  # ]:          0 :             aRetAny = rxInvocation->invoke( Name, args, OutParamIndex, OutParam );
    1614                 :          0 :             break;
    1615                 :            :         case GetProp:
    1616                 :            :             {
    1617         [ #  # ]:          0 :                 Reference< XAutomationInvocation > xAutoInv( rxInvocation, UNO_QUERY );
    1618 [ #  # ][ #  # ]:          0 :                 aRetAny = xAutoInv->invokeGetProperty( Name, args, OutParamIndex, OutParam );
    1619                 :          0 :                 break;
    1620                 :            :             }
    1621                 :            :         case SetProp:
    1622                 :            :             {
    1623         [ #  # ]:          0 :                 Reference< XAutomationInvocation > xAutoInv( rxInvocation, UNO_QUERY_THROW );
    1624 [ #  # ][ #  # ]:          0 :                 aRetAny = xAutoInv->invokePutProperty( Name, args, OutParamIndex, OutParam );
    1625                 :          0 :                 break;
    1626                 :            :             }
    1627                 :            :         default:
    1628                 :          0 :             break; // should introduce an error here
    1629                 :            : 
    1630                 :            :     }
    1631                 :          0 :     const sal_Int16* pIndices = OutParamIndex.getConstArray();
    1632                 :          0 :     sal_uInt32 nLen = OutParamIndex.getLength();
    1633         [ #  # ]:          0 :     if( nLen )
    1634                 :            :     {
    1635                 :          0 :         const Any* pNewValues = OutParam.getConstArray();
    1636         [ #  # ]:          0 :         for( sal_uInt32 j = 0 ; j < nLen ; j++ )
    1637                 :            :         {
    1638                 :          0 :             sal_Int16 iTarget = pIndices[ j ];
    1639         [ #  # ]:          0 :             if( iTarget >= (sal_Int16)nParamCount )
    1640                 :          0 :                 break;
    1641 [ #  # ][ #  # ]:          0 :             unoToSbxValue( (SbxVariable*)pParams->Get( (sal_uInt16)(j+1) ), pNewValues[ j ] );
    1642                 :            :         }
    1643                 :            :     }
    1644 [ #  # ][ #  # ]:          0 :     return aRetAny;
    1645                 :            : }
    1646                 :            : 
    1647                 :            : // Debugging help method to readout the imlemented interfaces of an object
    1648                 :          0 : rtl::OUString Impl_GetInterfaceInfo( const Reference< XInterface >& x, const Reference< XIdlClass >& xClass, sal_uInt16 nRekLevel )
    1649                 :            : {
    1650         [ #  # ]:          0 :     Type aIfaceType = ::getCppuType( (const Reference< XInterface > *)0 );
    1651 [ #  # ][ #  # ]:          0 :     static Reference< XIdlClass > xIfaceClass = TypeToIdlClass( aIfaceType );
         [ #  # ][ #  # ]
    1652                 :            : 
    1653                 :          0 :     rtl::OUStringBuffer aRetStr;
    1654         [ #  # ]:          0 :     for( sal_uInt16 i = 0 ; i < nRekLevel ; i++ )
    1655         [ #  # ]:          0 :         aRetStr.appendAscii( "    " );
    1656 [ #  # ][ #  # ]:          0 :     aRetStr.append( xClass->getName() );
                 [ #  # ]
    1657 [ #  # ][ #  # ]:          0 :     ::rtl::OUString aClassName = xClass->getName();
    1658 [ #  # ][ #  # ]:          0 :     Type aClassType( xClass->getTypeClass(), aClassName.getStr() );
    1659                 :            : 
    1660                 :            :     // checking if the interface is realy supported
    1661 [ #  # ][ #  # ]:          0 :     if( !x->queryInterface( aClassType ).hasValue() )
                 [ #  # ]
    1662                 :            :     {
    1663         [ #  # ]:          0 :         aRetStr.appendAscii( " (ERROR: Not really supported!)\n" );
    1664                 :            :     }
    1665                 :            :     // Are there super interfaces?
    1666                 :            :     else
    1667                 :            :     {
    1668         [ #  # ]:          0 :         aRetStr.appendAscii( "\n" );
    1669                 :            : 
    1670                 :            :         // get the super interfaces
    1671 [ #  # ][ #  # ]:          0 :         Sequence< Reference< XIdlClass > > aSuperClassSeq = xClass->getSuperclasses();
    1672                 :          0 :         const Reference< XIdlClass >* pClasses = aSuperClassSeq.getConstArray();
    1673                 :          0 :         sal_uInt32 nSuperIfaceCount = aSuperClassSeq.getLength();
    1674         [ #  # ]:          0 :         for( sal_uInt32 j = 0 ; j < nSuperIfaceCount ; j++ )
    1675                 :            :         {
    1676                 :          0 :             const Reference< XIdlClass >& rxIfaceClass = pClasses[j];
    1677 [ #  # ][ #  # ]:          0 :             if( !rxIfaceClass->equals( xIfaceClass ) )
                 [ #  # ]
    1678 [ #  # ][ #  # ]:          0 :                 aRetStr.append( Impl_GetInterfaceInfo( x, rxIfaceClass, nRekLevel + 1 ) );
    1679         [ #  # ]:          0 :         }
    1680                 :            :     }
    1681         [ #  # ]:          0 :     return aRetStr.makeStringAndClear();
    1682                 :            : }
    1683                 :            : 
    1684                 :          0 : ::rtl::OUString getDbgObjectNameImpl( SbUnoObject* pUnoObj )
    1685                 :            : {
    1686                 :          0 :     ::rtl::OUString aName;
    1687         [ #  # ]:          0 :     if( pUnoObj )
    1688                 :            :     {
    1689         [ #  # ]:          0 :         aName = pUnoObj->GetClassName();
    1690         [ #  # ]:          0 :         if( aName.isEmpty() )
    1691                 :            :         {
    1692         [ #  # ]:          0 :             Any aToInspectObj = pUnoObj->getUnoAny();
    1693                 :          0 :             TypeClass eType = aToInspectObj.getValueType().getTypeClass();
    1694                 :          0 :             Reference< XInterface > xObj;
    1695         [ #  # ]:          0 :             if( eType == TypeClass_INTERFACE )
    1696         [ #  # ]:          0 :                 xObj = *(Reference< XInterface >*)aToInspectObj.getValue();
    1697         [ #  # ]:          0 :             if( xObj.is() )
    1698                 :            :             {
    1699         [ #  # ]:          0 :                 Reference< XServiceInfo > xServiceInfo( xObj, UNO_QUERY );
    1700         [ #  # ]:          0 :                 if( xServiceInfo.is() )
    1701 [ #  # ][ #  # ]:          0 :                     aName = xServiceInfo->getImplementationName();
    1702                 :          0 :             }
    1703                 :            :         }
    1704                 :            :     }
    1705                 :          0 :     return aName;
    1706                 :            : }
    1707                 :            : 
    1708                 :          0 : ::rtl::OUString getDbgObjectName( SbUnoObject* pUnoObj )
    1709                 :            : {
    1710         [ #  # ]:          0 :     ::rtl::OUString aName = getDbgObjectNameImpl( pUnoObj );
    1711         [ #  # ]:          0 :     if( aName.isEmpty() )
    1712                 :          0 :         aName += ::rtl::OUString("Unknown");
    1713                 :            : 
    1714                 :          0 :     ::rtl::OUStringBuffer aRet;
    1715         [ #  # ]:          0 :     if( aName.getLength() > 20 )
    1716         [ #  # ]:          0 :         aRet.appendAscii( "\n" );
    1717         [ #  # ]:          0 :     aRet.appendAscii( "\"" );
    1718         [ #  # ]:          0 :     aRet.append( aName );
    1719         [ #  # ]:          0 :     aRet.appendAscii( "\":" );
    1720         [ #  # ]:          0 :     return aRet.makeStringAndClear();
    1721                 :            : }
    1722                 :            : 
    1723                 :          0 : ::rtl::OUString getBasicObjectTypeName( SbxObject* pObj )
    1724                 :            : {
    1725                 :          0 :     ::rtl::OUString aName;
    1726         [ #  # ]:          0 :     if( pObj )
    1727                 :            :     {
    1728 [ #  # ][ #  # ]:          0 :         SbUnoObject* pUnoObj = PTR_CAST(SbUnoObject,pObj);
                 [ #  # ]
    1729 [ #  # ][ #  # ]:          0 :         SbUnoStructRefObject* pUnoStructObj = PTR_CAST(SbUnoStructRefObject,pObj);
                 [ #  # ]
    1730         [ #  # ]:          0 :         if( pUnoObj )
    1731         [ #  # ]:          0 :             aName = getDbgObjectNameImpl( pUnoObj );
    1732         [ #  # ]:          0 :         else if ( pUnoStructObj )
    1733         [ #  # ]:          0 :             aName = pUnoStructObj->GetClassName();
    1734                 :            :     }
    1735                 :          0 :     return aName;
    1736                 :            : }
    1737                 :            : 
    1738                 :          0 : bool checkUnoObjectType( SbUnoObject* pUnoObj, const ::rtl::OUString& rClass )
    1739                 :            : {
    1740         [ #  # ]:          0 :     Any aToInspectObj = pUnoObj->getUnoAny();
    1741                 :          0 :     TypeClass eType = aToInspectObj.getValueType().getTypeClass();
    1742         [ #  # ]:          0 :     if( eType != TypeClass_INTERFACE )
    1743                 :          0 :         return false;
    1744                 :          0 :     const Reference< XInterface > x = *(Reference< XInterface >*)aToInspectObj.getValue();
    1745                 :            : 
    1746                 :            :     // Return true for XInvocation based objects as interface type names don't count then
    1747         [ #  # ]:          0 :     Reference< XInvocation > xInvocation( x, UNO_QUERY );
    1748         [ #  # ]:          0 :     if( xInvocation.is() )
    1749                 :          0 :         return true;
    1750                 :            : 
    1751                 :          0 :     bool result = false;
    1752         [ #  # ]:          0 :     Reference< XTypeProvider > xTypeProvider( x, UNO_QUERY );
    1753         [ #  # ]:          0 :     if( xTypeProvider.is() )
    1754                 :            :     {
    1755                 :            :         /*  Although interfaces in the ooo.vba namespace obey the IDL rules and
    1756                 :            :             have a leading 'X', in Basic we want to be able to do something
    1757                 :            :             like 'Dim wb As Workbooks' or 'Dim lb As MSForms.Label'. Here we
    1758                 :            :             add a leading 'X' to the class name and a leading dot to the entire
    1759                 :            :             type name. This results e.g. in '.XWorkbooks' or '.MSForms.XLabel'
    1760                 :            :             which matches the interface names 'ooo.vba.excel.XWorkbooks' or
    1761                 :            :             'ooo.vba.msforms.XLabel'.
    1762                 :            :          */
    1763                 :          0 :         ::rtl::OUString aClassName( sal_Unicode( '.' ) );
    1764                 :          0 :         sal_Int32 nClassNameDot = rClass.lastIndexOf( '.' );
    1765         [ #  # ]:          0 :         if( nClassNameDot >= 0 )
    1766                 :          0 :             aClassName += rClass.copy( 0, nClassNameDot + 1 ) + ::rtl::OUString( sal_Unicode( 'X' ) ) + rClass.copy( nClassNameDot + 1 );
    1767                 :            :         else
    1768                 :          0 :             aClassName += ::rtl::OUString( sal_Unicode( 'X' ) ) + rClass;
    1769                 :            : 
    1770 [ #  # ][ #  # ]:          0 :         Sequence< Type > aTypeSeq = xTypeProvider->getTypes();
    1771                 :          0 :         const Type* pTypeArray = aTypeSeq.getConstArray();
    1772                 :          0 :         sal_uInt32 nIfaceCount = aTypeSeq.getLength();
    1773         [ #  # ]:          0 :         for( sal_uInt32 j = 0 ; j < nIfaceCount ; j++ )
    1774                 :            :         {
    1775                 :          0 :             const Type& rType = pTypeArray[j];
    1776                 :            : 
    1777         [ #  # ]:          0 :             Reference<XIdlClass> xClass = TypeToIdlClass( rType );
    1778         [ #  # ]:          0 :             if( !xClass.is() )
    1779                 :            :             {
    1780                 :            :                 OSL_FAIL("failed to get XIdlClass for type");
    1781                 :            :                 break;
    1782                 :            :             }
    1783 [ #  # ][ #  # ]:          0 :             ::rtl::OUString aInterfaceName = xClass->getName();
    1784         [ #  # ]:          0 :             if ( aInterfaceName == "com.sun.star.bridge.oleautomation.XAutomationObject" )
    1785                 :            :             {
    1786                 :            :                 // there is a hack in the extensions/source/ole/oleobj.cxx  to return the typename of the automation object, lets check if it
    1787                 :            :                 // matches
    1788         [ #  # ]:          0 :                 Reference< XInvocation > xInv( aToInspectObj, UNO_QUERY );
    1789         [ #  # ]:          0 :                 if ( xInv.is() )
    1790                 :            :                 {
    1791                 :          0 :                     rtl::OUString sTypeName;
    1792 [ #  # ][ #  # ]:          0 :                     xInv->getValue( rtl::OUString( "$GetTypeName" ) ) >>= sTypeName;
    1793 [ #  # ][ #  # ]:          0 :                     if ( sTypeName.isEmpty() || sTypeName == "IDispatch" )
                 [ #  # ]
    1794                 :            :                         // can't check type, leave it pass
    1795                 :          0 :                         result = true;
    1796                 :            :                     else
    1797                 :          0 :                         result = sTypeName.equals( rClass );
    1798                 :            :                 }
    1799                 :          0 :                 break; // finished checking automation object
    1800                 :            :             }
    1801                 :            : 
    1802                 :            :             // match interface name with passed class name
    1803                 :            :             OSL_TRACE("Checking if object implements %s", OUStringToOString( aClassName, RTL_TEXTENCODING_UTF8 ).getStr() );
    1804   [ #  #  #  # ]:          0 :             if ( (aClassName.getLength() < aInterfaceName.getLength()) &&
                 [ #  # ]
    1805                 :          0 :                     aInterfaceName.matchIgnoreAsciiCase( aClassName, aInterfaceName.getLength() - aClassName.getLength() ) )
    1806                 :            :             {
    1807                 :          0 :                 result = true;
    1808                 :            :                 break;
    1809                 :            :             }
    1810 [ #  # ][ #  # ]:          0 :         }
                 [ #  # ]
    1811                 :            :     }
    1812                 :          0 :     return result;
    1813                 :            : }
    1814                 :            : 
    1815                 :            : // Debugging help method to readout the imlemented interfaces of an object
    1816                 :          0 : ::rtl::OUString Impl_GetSupportedInterfaces( SbUnoObject* pUnoObj )
    1817                 :            : {
    1818         [ #  # ]:          0 :     Any aToInspectObj = pUnoObj->getUnoAny();
    1819                 :            : 
    1820                 :            :     // allow only TypeClass interface
    1821                 :          0 :     TypeClass eType = aToInspectObj.getValueType().getTypeClass();
    1822                 :          0 :     ::rtl::OUStringBuffer aRet;
    1823         [ #  # ]:          0 :     if( eType != TypeClass_INTERFACE )
    1824                 :            :     {
    1825         [ #  # ]:          0 :         aRet.appendAscii( RTL_CONSTASCII_STRINGPARAM(ID_DBG_SUPPORTEDINTERFACES) );
    1826         [ #  # ]:          0 :         aRet.appendAscii( " not available.\n(TypeClass is not TypeClass_INTERFACE)\n" );
    1827                 :            :     }
    1828                 :            :     else
    1829                 :            :     {
    1830                 :            :         // get the interface from the Any
    1831                 :          0 :         const Reference< XInterface > x = *(Reference< XInterface >*)aToInspectObj.getValue();
    1832                 :            : 
    1833         [ #  # ]:          0 :         Reference< XTypeProvider > xTypeProvider( x, UNO_QUERY );
    1834                 :            : 
    1835         [ #  # ]:          0 :         aRet.appendAscii( "Supported interfaces by object " );
    1836 [ #  # ][ #  # ]:          0 :         aRet.append( getDbgObjectName( pUnoObj ) );
    1837         [ #  # ]:          0 :         aRet.appendAscii( "\n" );
    1838         [ #  # ]:          0 :         if( xTypeProvider.is() )
    1839                 :            :         {
    1840                 :            :             // get the interfaces of the implementation
    1841 [ #  # ][ #  # ]:          0 :             Sequence< Type > aTypeSeq = xTypeProvider->getTypes();
    1842                 :          0 :             const Type* pTypeArray = aTypeSeq.getConstArray();
    1843                 :          0 :             sal_uInt32 nIfaceCount = aTypeSeq.getLength();
    1844         [ #  # ]:          0 :             for( sal_uInt32 j = 0 ; j < nIfaceCount ; j++ )
    1845                 :            :             {
    1846                 :          0 :                 const Type& rType = pTypeArray[j];
    1847                 :            : 
    1848         [ #  # ]:          0 :                 Reference<XIdlClass> xClass = TypeToIdlClass( rType );
    1849         [ #  # ]:          0 :                 if( xClass.is() )
    1850                 :            :                 {
    1851 [ #  # ][ #  # ]:          0 :                     aRet.append( Impl_GetInterfaceInfo( x, xClass, 1 ) );
    1852                 :            :                 }
    1853                 :            :                 else
    1854                 :            :                 {
    1855                 :          0 :                     typelib_TypeDescription * pTD = 0;
    1856                 :          0 :                     rType.getDescription( &pTD );
    1857                 :            : 
    1858         [ #  # ]:          0 :                     aRet.appendAscii( "*** ERROR: No IdlClass for type \"" );
    1859         [ #  # ]:          0 :                     aRet.append( pTD->pTypeName );
    1860         [ #  # ]:          0 :                     aRet.appendAscii( "\"\n*** Please check type library\n" );
    1861                 :            :                 }
    1862         [ #  # ]:          0 :             }
    1863                 :          0 :         }
    1864                 :            :     }
    1865         [ #  # ]:          0 :     return aRet.makeStringAndClear();
    1866                 :            : }
    1867                 :            : 
    1868                 :            : 
    1869                 :            : 
    1870                 :            : // Debugging help method SbxDataType -> String
    1871                 :          0 : ::rtl::OUString Dbg_SbxDataType2String( SbxDataType eType )
    1872                 :            : {
    1873                 :          0 :     ::rtl::OUStringBuffer aRet;
    1874   [ #  #  #  #  :          0 :     switch( +eType )
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
             #  #  #  #  
                      # ]
    1875                 :            :     {
    1876         [ #  # ]:          0 :         case SbxEMPTY:      aRet.appendAscii("SbxEMPTY"); break;
    1877         [ #  # ]:          0 :         case SbxNULL:       aRet.appendAscii("SbxNULL"); break;
    1878         [ #  # ]:          0 :         case SbxINTEGER:    aRet.appendAscii("SbxINTEGER"); break;
    1879         [ #  # ]:          0 :         case SbxLONG:       aRet.appendAscii("SbxLONG"); break;
    1880         [ #  # ]:          0 :         case SbxSINGLE:     aRet.appendAscii("SbxSINGLE"); break;
    1881         [ #  # ]:          0 :         case SbxDOUBLE:     aRet.appendAscii("SbxDOUBLE"); break;
    1882         [ #  # ]:          0 :         case SbxCURRENCY:   aRet.appendAscii("SbxCURRENCY"); break;
    1883         [ #  # ]:          0 :         case SbxDECIMAL:    aRet.appendAscii("SbxDECIMAL"); break;
    1884         [ #  # ]:          0 :         case SbxDATE:       aRet.appendAscii("SbxDATE"); break;
    1885         [ #  # ]:          0 :         case SbxSTRING:     aRet.appendAscii("SbxSTRING"); break;
    1886         [ #  # ]:          0 :         case SbxOBJECT:     aRet.appendAscii("SbxOBJECT"); break;
    1887         [ #  # ]:          0 :         case SbxERROR:      aRet.appendAscii("SbxERROR"); break;
    1888         [ #  # ]:          0 :         case SbxBOOL:       aRet.appendAscii("SbxBOOL"); break;
    1889         [ #  # ]:          0 :         case SbxVARIANT:    aRet.appendAscii("SbxVARIANT"); break;
    1890         [ #  # ]:          0 :         case SbxDATAOBJECT: aRet.appendAscii("SbxDATAOBJECT"); break;
    1891         [ #  # ]:          0 :         case SbxCHAR:       aRet.appendAscii("SbxCHAR"); break;
    1892         [ #  # ]:          0 :         case SbxBYTE:       aRet.appendAscii("SbxBYTE"); break;
    1893         [ #  # ]:          0 :         case SbxUSHORT:     aRet.appendAscii("SbxUSHORT"); break;
    1894         [ #  # ]:          0 :         case SbxULONG:      aRet.appendAscii("SbxULONG"); break;
    1895         [ #  # ]:          0 :         case SbxSALINT64:   aRet.appendAscii("SbxINT64"); break;
    1896         [ #  # ]:          0 :         case SbxSALUINT64:  aRet.appendAscii("SbxUINT64"); break;
    1897         [ #  # ]:          0 :         case SbxINT:        aRet.appendAscii("SbxINT"); break;
    1898         [ #  # ]:          0 :         case SbxUINT:       aRet.appendAscii("SbxUINT"); break;
    1899         [ #  # ]:          0 :         case SbxVOID:       aRet.appendAscii("SbxVOID"); break;
    1900         [ #  # ]:          0 :         case SbxHRESULT:    aRet.appendAscii("SbxHRESULT"); break;
    1901         [ #  # ]:          0 :         case SbxPOINTER:    aRet.appendAscii("SbxPOINTER"); break;
    1902         [ #  # ]:          0 :         case SbxDIMARRAY:   aRet.appendAscii("SbxDIMARRAY"); break;
    1903         [ #  # ]:          0 :         case SbxCARRAY:     aRet.appendAscii("SbxCARRAY"); break;
    1904         [ #  # ]:          0 :         case SbxUSERDEF:    aRet.appendAscii("SbxUSERDEF"); break;
    1905         [ #  # ]:          0 :         case SbxLPSTR:      aRet.appendAscii("SbxLPSTR"); break;
    1906         [ #  # ]:          0 :         case SbxLPWSTR:     aRet.appendAscii("SbxLPWSTR"); break;
    1907         [ #  # ]:          0 :         case SbxCoreSTRING: aRet.appendAscii("SbxCoreSTRING"); break;
    1908         [ #  # ]:          0 :         case SbxOBJECT | SbxARRAY: aRet.appendAscii("SbxARRAY"); break;
    1909         [ #  # ]:          0 :         default: aRet.appendAscii("Unknown Sbx-Type!");break;
    1910                 :            :     }
    1911         [ #  # ]:          0 :     return aRet.makeStringAndClear();
    1912                 :            : }
    1913                 :            : 
    1914                 :            : // Debugging help method to display the properties of a SbUnoObjects
    1915                 :          0 : ::rtl::OUString Impl_DumpProperties( SbUnoObject* pUnoObj )
    1916                 :            : {
    1917                 :          0 :     ::rtl::OUStringBuffer aRet;
    1918         [ #  # ]:          0 :     aRet.appendAscii("Properties of object ");
    1919 [ #  # ][ #  # ]:          0 :     aRet.append( getDbgObjectName( pUnoObj ) );
    1920                 :            : 
    1921                 :            :     // analyse the Uno-Infos to recognise the arrays
    1922         [ #  # ]:          0 :     Reference< XIntrospectionAccess > xAccess = pUnoObj->getIntrospectionAccess();
    1923         [ #  # ]:          0 :     if( !xAccess.is() )
    1924                 :            :     {
    1925         [ #  # ]:          0 :         Reference< XInvocation > xInvok = pUnoObj->getInvocation();
    1926         [ #  # ]:          0 :         if( xInvok.is() )
    1927 [ #  # ][ #  # ]:          0 :             xAccess = xInvok->getIntrospection();
                 [ #  # ]
    1928                 :            :     }
    1929         [ #  # ]:          0 :     if( !xAccess.is() )
    1930                 :            :     {
    1931         [ #  # ]:          0 :         aRet.appendAscii( "\nUnknown, no introspection available\n" );
    1932         [ #  # ]:          0 :         return aRet.makeStringAndClear();
    1933                 :            :     }
    1934                 :            : 
    1935 [ #  # ][ #  # ]:          0 :     Sequence<Property> props = xAccess->getProperties( PropertyConcept::ALL - PropertyConcept::DANGEROUS );
    1936                 :          0 :     sal_uInt32 nUnoPropCount = props.getLength();
    1937                 :          0 :     const Property* pUnoProps = props.getConstArray();
    1938                 :            : 
    1939                 :          0 :     SbxArray* pProps = pUnoObj->GetProperties();
    1940         [ #  # ]:          0 :     sal_uInt16 nPropCount = pProps->Count();
    1941                 :          0 :     sal_uInt16 nPropsPerLine = 1 + nPropCount / 30;
    1942         [ #  # ]:          0 :     for( sal_uInt16 i = 0; i < nPropCount; i++ )
    1943                 :            :     {
    1944         [ #  # ]:          0 :         SbxVariable* pVar = pProps->Get( i );
    1945         [ #  # ]:          0 :         if( pVar )
    1946                 :            :         {
    1947                 :          0 :             ::rtl::OUStringBuffer aPropStr;
    1948         [ #  # ]:          0 :             if( (i % nPropsPerLine) == 0 )
    1949         [ #  # ]:          0 :                 aPropStr.appendAscii( "\n" );
    1950                 :            : 
    1951                 :            :             // output the type and name
    1952                 :            :             // Is it in Uno a sequence?
    1953         [ #  # ]:          0 :             SbxDataType eType = pVar->GetFullType();
    1954                 :            : 
    1955                 :          0 :             sal_Bool bMaybeVoid = sal_False;
    1956         [ #  # ]:          0 :             if( i < nUnoPropCount )
    1957                 :            :             {
    1958                 :          0 :                 const Property& rProp = pUnoProps[ i ];
    1959                 :            : 
    1960                 :            :                 // By MAYBEVOID convert the type out of Uno newly,
    1961                 :            :                 // so that not only SbxEMPTY were outputed.
    1962         [ #  # ]:          0 :                 if( rProp.Attributes & PropertyAttribute::MAYBEVOID )
    1963                 :            :                 {
    1964                 :          0 :                     eType = unoToSbxType( rProp.Type.getTypeClass() );
    1965                 :          0 :                     bMaybeVoid = sal_True;
    1966                 :            :                 }
    1967         [ #  # ]:          0 :                 if( eType == SbxOBJECT )
    1968                 :            :                 {
    1969                 :          0 :                     Type aType = rProp.Type;
    1970         [ #  # ]:          0 :                     if( aType.getTypeClass() == TypeClass_SEQUENCE )
    1971                 :          0 :                         eType = (SbxDataType) ( SbxOBJECT | SbxARRAY );
    1972                 :            :                 }
    1973                 :            :             }
    1974 [ #  # ][ #  # ]:          0 :             aPropStr.append( Dbg_SbxDataType2String( eType ) );
    1975         [ #  # ]:          0 :             if( bMaybeVoid )
    1976         [ #  # ]:          0 :                 aPropStr.appendAscii( "/void" );
    1977         [ #  # ]:          0 :             aPropStr.appendAscii( " " );
    1978 [ #  # ][ #  # ]:          0 :             aPropStr.append( pVar->GetName() );
                 [ #  # ]
    1979                 :            : 
    1980         [ #  # ]:          0 :             if( i == nPropCount - 1 )
    1981         [ #  # ]:          0 :                 aPropStr.appendAscii( "\n" );
    1982                 :            :             else
    1983         [ #  # ]:          0 :                 aPropStr.appendAscii( "; " );
    1984                 :            : 
    1985 [ #  # ][ #  # ]:          0 :             aRet.append( aPropStr.makeStringAndClear() );
    1986                 :            :         }
    1987                 :            :     }
    1988 [ #  # ][ #  # ]:          0 :     return aRet.makeStringAndClear();
    1989                 :            : }
    1990                 :            : 
    1991                 :            : // Debugging help method to display the methods of an SbUnoObjects
    1992                 :          0 : ::rtl::OUString Impl_DumpMethods( SbUnoObject* pUnoObj )
    1993                 :            : {
    1994                 :          0 :     ::rtl::OUStringBuffer aRet;
    1995         [ #  # ]:          0 :     aRet.appendAscii("Methods of object ");
    1996 [ #  # ][ #  # ]:          0 :     aRet.append( getDbgObjectName( pUnoObj ) );
    1997                 :            : 
    1998                 :            :     // XIntrospectionAccess, so that the types of the parameter could be outputed
    1999         [ #  # ]:          0 :     Reference< XIntrospectionAccess > xAccess = pUnoObj->getIntrospectionAccess();
    2000         [ #  # ]:          0 :     if( !xAccess.is() )
    2001                 :            :     {
    2002         [ #  # ]:          0 :         Reference< XInvocation > xInvok = pUnoObj->getInvocation();
    2003         [ #  # ]:          0 :         if( xInvok.is() )
    2004 [ #  # ][ #  # ]:          0 :             xAccess = xInvok->getIntrospection();
                 [ #  # ]
    2005                 :            :     }
    2006         [ #  # ]:          0 :     if( !xAccess.is() )
    2007                 :            :     {
    2008         [ #  # ]:          0 :         aRet.appendAscii( "\nUnknown, no introspection available\n" );
    2009         [ #  # ]:          0 :         return aRet.makeStringAndClear();
    2010                 :            :     }
    2011         [ #  # ]:          0 :     Sequence< Reference< XIdlMethod > > methods = xAccess->getMethods
    2012         [ #  # ]:          0 :         ( MethodConcept::ALL - MethodConcept::DANGEROUS );
    2013                 :          0 :     const Reference< XIdlMethod >* pUnoMethods = methods.getConstArray();
    2014                 :            : 
    2015                 :          0 :     SbxArray* pMethods = pUnoObj->GetMethods();
    2016         [ #  # ]:          0 :     sal_uInt16 nMethodCount = pMethods->Count();
    2017         [ #  # ]:          0 :     if( !nMethodCount )
    2018                 :            :     {
    2019         [ #  # ]:          0 :         aRet.appendAscii( "\nNo methods found\n" );
    2020         [ #  # ]:          0 :         return aRet.makeStringAndClear();
    2021                 :            :     }
    2022                 :          0 :     sal_uInt16 nPropsPerLine = 1 + nMethodCount / 30;
    2023         [ #  # ]:          0 :     for( sal_uInt16 i = 0; i < nMethodCount; i++ )
    2024                 :            :     {
    2025         [ #  # ]:          0 :         SbxVariable* pVar = pMethods->Get( i );
    2026         [ #  # ]:          0 :         if( pVar )
    2027                 :            :         {
    2028         [ #  # ]:          0 :             if( (i % nPropsPerLine) == 0 )
    2029         [ #  # ]:          0 :                 aRet.appendAscii( "\n" );
    2030                 :            : 
    2031                 :            :             // address the method
    2032                 :          0 :             const Reference< XIdlMethod >& rxMethod = pUnoMethods[i];
    2033                 :            : 
    2034                 :            :             // Is it in Uno a sequence?
    2035         [ #  # ]:          0 :             SbxDataType eType = pVar->GetFullType();
    2036         [ #  # ]:          0 :             if( eType == SbxOBJECT )
    2037                 :            :             {
    2038 [ #  # ][ #  # ]:          0 :                 Reference< XIdlClass > xClass = rxMethod->getReturnType();
    2039 [ #  # ][ #  # ]:          0 :                 if( xClass.is() && xClass->getTypeClass() == TypeClass_SEQUENCE )
         [ #  # ][ #  # ]
                 [ #  # ]
    2040                 :          0 :                     eType = (SbxDataType) ( SbxOBJECT | SbxARRAY );
    2041                 :            :             }
    2042                 :            :             // output the name and the type
    2043 [ #  # ][ #  # ]:          0 :             aRet.append( Dbg_SbxDataType2String( eType ) );
    2044         [ #  # ]:          0 :             aRet.appendAscii( " " );
    2045 [ #  # ][ #  # ]:          0 :             aRet.append ( pVar->GetName() );
                 [ #  # ]
    2046         [ #  # ]:          0 :             aRet.appendAscii( " ( " );
    2047                 :            : 
    2048                 :            :             // the get-method mustn't have a parameter
    2049 [ #  # ][ #  # ]:          0 :             Sequence< Reference< XIdlClass > > aParamsSeq = rxMethod->getParameterTypes();
    2050                 :          0 :             sal_uInt32 nParamCount = aParamsSeq.getLength();
    2051                 :          0 :             const Reference< XIdlClass >* pParams = aParamsSeq.getConstArray();
    2052                 :            : 
    2053         [ #  # ]:          0 :             if( nParamCount > 0 )
    2054                 :            :             {
    2055         [ #  # ]:          0 :                 for( sal_uInt16 j = 0; j < nParamCount; j++ )
    2056                 :            :                 {
    2057 [ #  # ][ #  # ]:          0 :                     aRet.append ( Dbg_SbxDataType2String( unoToSbxType( pParams[ j ] ) ) );
                 [ #  # ]
    2058         [ #  # ]:          0 :                     if( j < nParamCount - 1 )
    2059         [ #  # ]:          0 :                         aRet.appendAscii( ", " );
    2060                 :            :                 }
    2061                 :            :             }
    2062                 :            :             else
    2063         [ #  # ]:          0 :                 aRet.appendAscii( "void" );
    2064                 :            : 
    2065         [ #  # ]:          0 :             aRet.appendAscii( " ) " );
    2066                 :            : 
    2067         [ #  # ]:          0 :             if( i == nMethodCount - 1 )
    2068         [ #  # ]:          0 :                 aRet.appendAscii( "\n" );
    2069                 :            :             else
    2070 [ #  # ][ #  # ]:          0 :                 aRet.appendAscii( "; " );
    2071                 :            :         }
    2072                 :            :     }
    2073 [ #  # ][ #  # ]:          0 :     return aRet.makeStringAndClear();
    2074                 :            : }
    2075                 :            : 
    2076 [ #  # ][ #  # ]:          0 : TYPEINIT1(AutomationNamedArgsSbxArray,SbxArray)
    2077                 :            : 
    2078                 :            : // Implementation SbUnoObject
    2079                 :        784 : void SbUnoObject::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType,
    2080                 :            :                            const SfxHint& rHint, const TypeId& rHintType )
    2081                 :            : {
    2082         [ -  + ]:        784 :     if( bNeedIntrospection )
    2083                 :          0 :         doIntrospection();
    2084                 :            : 
    2085 [ +  - ][ +  - ]:        784 :     const SbxHint* pHint = PTR_CAST(SbxHint,&rHint);
    2086         [ +  - ]:        784 :     if( pHint )
    2087                 :            :     {
    2088                 :        784 :         SbxVariable* pVar = pHint->GetVar();
    2089                 :        784 :         SbxArray* pParams = pVar->GetParameters();
    2090 [ +  + ][ +  - ]:        784 :         SbUnoProperty* pProp = PTR_CAST(SbUnoProperty,pVar);
    2091 [ +  - ][ +  + ]:        784 :         SbUnoMethod* pMeth = PTR_CAST(SbUnoMethod,pVar);
    2092         [ +  + ]:        784 :         if( pProp )
    2093                 :            :         {
    2094                 :        338 :             bool bInvocation = pProp->isInvocationBased();
    2095         [ +  + ]:        338 :             if( pHint->GetId() == SBX_HINT_DATAWANTED )
    2096                 :            :             {
    2097                 :            :                 // Test-Properties
    2098                 :        141 :                 sal_Int32 nId = pProp->nId;
    2099         [ -  + ]:        141 :                 if( nId < 0 )
    2100                 :            :                 {
    2101                 :            :                     // Id == -1: Display implemented interfaces according the ClassProvider
    2102         [ #  # ]:          0 :                     if( nId == -1 )     // Property ID_DBG_SUPPORTEDINTERFACES"
    2103                 :            :                     {
    2104         [ #  # ]:          0 :                         ::rtl::OUString aRetStr = Impl_GetSupportedInterfaces( this );
    2105         [ #  # ]:          0 :                         pVar->PutString( aRetStr );
    2106                 :            :                     }
    2107                 :            :                     // Id == -2: output properties
    2108         [ #  # ]:          0 :                     else if( nId == -2 )        // Property ID_DBG_PROPERTIES
    2109                 :            :                     {
    2110                 :            :                         // by now all properties must be established
    2111         [ #  # ]:          0 :                         implCreateAll();
    2112         [ #  # ]:          0 :                         ::rtl::OUString aRetStr = Impl_DumpProperties( this );
    2113         [ #  # ]:          0 :                         pVar->PutString( aRetStr );
    2114                 :            :                     }
    2115                 :            :                     // Id == -3: output the methods
    2116         [ #  # ]:          0 :                     else if( nId == -3 )        // Property ID_DBG_METHODS
    2117                 :            :                     {
    2118                 :            :                         // y now all properties must be established
    2119         [ #  # ]:          0 :                         implCreateAll();
    2120         [ #  # ]:          0 :                         ::rtl::OUString aRetStr = Impl_DumpMethods( this );
    2121         [ #  # ]:          0 :                         pVar->PutString( aRetStr );
    2122                 :            :                     }
    2123                 :          0 :                     return;
    2124                 :            :                 }
    2125                 :            : 
    2126 [ +  - ][ +  - ]:        141 :                 if( !bInvocation && mxUnoAccess.is() )
                 [ +  - ]
    2127                 :            :                 {
    2128                 :            :                     try
    2129                 :            :                     {
    2130 [ +  + ][ +  - ]:        141 :                         if ( pProp->isUnoStruct() && maStructInfo.get()  )
                 [ +  + ]
    2131                 :            :                         {
    2132 [ +  - ][ +  - ]:         39 :                             StructRefInfo aMemberStruct = maStructInfo->getStructMember( pProp->GetName() );
                 [ +  - ]
    2133         [ -  + ]:         39 :                             if ( aMemberStruct.isEmpty() )
    2134                 :            :                             {
    2135         [ #  # ]:          0 :                                  StarBASIC::Error( SbERR_PROPERTY_NOT_FOUND );
    2136                 :            :                             }
    2137                 :            :                             else
    2138                 :            :                             {
    2139 [ +  - ][ +  - ]:         39 :                                 SbUnoStructRefObject* pSbUnoObject = new SbUnoStructRefObject( pProp->GetName(), aMemberStruct );
         [ +  - ][ +  - ]
    2140                 :         39 :                                 SbxObjectRef xWrapper = (SbxObject*)pSbUnoObject;
    2141         [ +  - ]:         39 :                                 pVar->PutObject( xWrapper );
    2142         [ +  - ]:         39 :                                 return;
    2143                 :            :                             }
    2144                 :            :                         }
    2145                 :            :                         // get the value
    2146 [ +  - ][ +  - ]:        102 :                         Reference< XPropertySet > xPropSet( mxUnoAccess->queryAdapter( ::getCppuType( (const Reference< XPropertySet > *)0 ) ), UNO_QUERY );
         [ +  - ][ +  - ]
    2147 [ +  - ][ +  - ]:        102 :                         Any aRetAny = xPropSet->getPropertyValue( pProp->GetName() );
         [ +  - ][ +  - ]
    2148                 :            :                         // The use of getPropertyValue (instead of using the index) is
    2149                 :            :                         // suboptimal, but the refactoring to XInvocation is already pending
    2150                 :            :                         // Otherwise it is posible to use FastPropertySet
    2151                 :            : 
    2152                 :            :                         // take over the value from Uno to Sbx
    2153         [ +  - ]:        102 :                         unoToSbxValue( pVar, aRetAny );
    2154                 :            :                     }
    2155         [ #  # ]:          0 :                     catch( const Exception& )
    2156                 :            :                     {
    2157   [ #  #  #  # ]:          0 :                         implHandleAnyException( ::cppu::getCaughtException() );
    2158                 :            :                     }
    2159                 :            :                 }
    2160 [ #  # ][ #  # ]:          0 :                 else if( bInvocation && mxInvocation.is() )
                 [ #  # ]
    2161                 :            :                 {
    2162                 :            :                     try
    2163                 :            :                     {
    2164 [ #  # ][ #  # ]:          0 :                         sal_uInt32 nParamCount = pParams ? ((sal_uInt32)pParams->Count() - 1) : 0;
    2165 [ #  # ][ #  # ]:          0 :                         sal_Bool bCanBeConsideredAMethod = mxInvocation->hasMethod( pProp->GetName() );
         [ #  # ][ #  # ]
    2166                 :          0 :                         Any aRetAny;
    2167 [ #  # ][ #  # ]:          0 :                         if ( bCanBeConsideredAMethod && nParamCount )
    2168                 :            :                         {
    2169                 :            :                             // Automation properties have methods, so.. we need to invoke this through
    2170                 :            :                             // XInvocation
    2171         [ #  # ]:          0 :                             Sequence<Any> args;
    2172         [ #  # ]:          0 :                             processAutomationParams( pParams, args, true, nParamCount );
    2173 [ #  # ][ #  # ]:          0 :                             aRetAny = invokeAutomationMethod( pProp->GetName(), args, pParams, nParamCount, mxInvocation, GetProp );
         [ #  # ][ #  # ]
    2174                 :            :                         }
    2175                 :            :                         else
    2176 [ #  # ][ #  # ]:          0 :                             aRetAny = mxInvocation->getValue( pProp->GetName() );
         [ #  # ][ #  # ]
    2177                 :            :                         // take over the value from Uno to Sbx
    2178         [ #  # ]:          0 :                         unoToSbxValue( pVar, aRetAny );
    2179 [ #  # ][ #  # ]:          0 :                         if( pParams && bCanBeConsideredAMethod )
    2180         [ #  # ]:          0 :                             pVar->SetParameters( NULL );
    2181                 :            : 
    2182                 :            :                     }
    2183         [ #  # ]:          0 :                     catch( const Exception& )
    2184                 :            :                     {
    2185   [ #  #  #  # ]:          0 :                         implHandleAnyException( ::cppu::getCaughtException() );
    2186                 :            :                     }
    2187                 :            :                 }
    2188                 :            :             }
    2189         [ +  - ]:        197 :             else if( pHint->GetId() == SBX_HINT_DATACHANGED )
    2190                 :            :             {
    2191 [ +  - ][ +  - ]:        197 :                 if( !bInvocation && mxUnoAccess.is() )
                 [ +  - ]
    2192                 :            :                 {
    2193         [ -  + ]:        197 :                     if( pProp->aUnoProp.Attributes & PropertyAttribute::READONLY )
    2194                 :            :                     {
    2195         [ #  # ]:          0 :                         StarBASIC::Error( SbERR_PROP_READONLY );
    2196                 :            :                         return;
    2197                 :            :                     }
    2198                 :            : 
    2199                 :            :                     // take over the value from Uno to Sbx
    2200         [ +  - ]:        197 :                     Any aAnyValue = sbxToUnoValue( pVar, pProp->aUnoProp.Type, &pProp->aUnoProp );
    2201                 :            :                     try
    2202                 :            :                     {
    2203                 :            :                         // set the value
    2204 [ +  - ][ +  - ]:        197 :                         Reference< XPropertySet > xPropSet( mxUnoAccess->queryAdapter( ::getCppuType( (const Reference< XPropertySet > *)0 ) ), UNO_QUERY );
         [ +  - ][ +  - ]
    2205 [ +  - ][ +  - ]:        197 :                         xPropSet->setPropertyValue( pProp->GetName(), aAnyValue );
         [ +  - ][ +  - ]
    2206                 :            :                         // The use of getPropertyValue (instead of using the index) is
    2207                 :            :                         // suboptimal, but the refactoring to XInvocation is already pending
    2208                 :            :                         // Otherwise it is posible to use FastPropertySet
    2209                 :            :                     }
    2210   [ #  #  #  # ]:          0 :                     catch( const Exception& )
    2211                 :            :                     {
    2212   [ #  #  #  # ]:          0 :                         implHandleAnyException( ::cppu::getCaughtException() );
    2213                 :        197 :                     }
    2214                 :            :                 }
    2215 [ #  # ][ #  # ]:          0 :                 else if( bInvocation && mxInvocation.is() )
                 [ #  # ]
    2216                 :            :                 {
    2217                 :            :                     // take over the value from Uno to Sbx
    2218         [ #  # ]:          0 :                     Any aAnyValue = sbxToUnoValueImpl( pVar );
    2219                 :            :                     try
    2220                 :            :                     {
    2221                 :            :                         // set the value
    2222 [ #  # ][ #  # ]:          0 :                         mxInvocation->setValue( pProp->GetName(), aAnyValue );
         [ #  # ][ #  # ]
    2223                 :            :                     }
    2224   [ #  #  #  # ]:          0 :                     catch( const Exception& )
    2225                 :            :                     {
    2226   [ #  #  #  # ]:          0 :                         implHandleAnyException( ::cppu::getCaughtException() );
    2227                 :          0 :                     }
    2228                 :            :                 }
    2229                 :            :             }
    2230                 :            :         }
    2231         [ +  - ]:        446 :         else if( pMeth )
    2232                 :            :         {
    2233                 :        446 :             bool bInvocation = pMeth->isInvocationBased();
    2234         [ +  + ]:        446 :             if( pHint->GetId() == SBX_HINT_DATAWANTED )
    2235                 :            :             {
    2236                 :            :                 // number of Parameter -1 because of Param0 == this
    2237 [ +  + ][ +  - ]:        442 :                 sal_uInt32 nParamCount = pParams ? ((sal_uInt32)pParams->Count() - 1) : 0;
    2238         [ +  - ]:        442 :                 Sequence<Any> args;
    2239                 :        442 :                 sal_Bool bOutParams = sal_False;
    2240                 :            :                 sal_uInt32 i;
    2241                 :            : 
    2242 [ +  - ][ +  - ]:        442 :                 if( !bInvocation && mxUnoAccess.is() )
                 [ +  - ]
    2243                 :            :                 {
    2244                 :            :                     // get info
    2245         [ +  - ]:        442 :                     const Sequence<ParamInfo>& rInfoSeq = pMeth->getParamInfos();
    2246                 :        442 :                     const ParamInfo* pParamInfos = rInfoSeq.getConstArray();
    2247                 :        442 :                     sal_uInt32 nUnoParamCount = rInfoSeq.getLength();
    2248                 :        442 :                     sal_uInt32 nAllocParamCount = nParamCount;
    2249                 :            : 
    2250                 :            :                     // ignore surplus parameter; alternative: throw an error
    2251         [ -  + ]:        442 :                     if( nParamCount > nUnoParamCount )
    2252                 :            :                     {
    2253                 :          0 :                         nParamCount = nUnoParamCount;
    2254                 :          0 :                         nAllocParamCount = nParamCount;
    2255                 :            :                     }
    2256         [ +  + ]:        442 :                     else if( nParamCount < nUnoParamCount )
    2257                 :            :                     {
    2258         [ +  - ]:        170 :                         SbiInstance* pInst = GetSbData()->pInst;
    2259 [ +  - ][ +  - ]:        170 :                         if( pInst && pInst->IsCompatibility() )
                 [ +  - ]
    2260                 :            :                         {
    2261                 :            :                             // Check types
    2262                 :        170 :                             bool bError = false;
    2263         [ +  + ]:        616 :                             for( i = nParamCount ; i < nUnoParamCount ; i++ )
    2264                 :            :                             {
    2265                 :        446 :                                 const ParamInfo& rInfo = pParamInfos[i];
    2266                 :        446 :                                 const Reference< XIdlClass >& rxClass = rInfo.aType;
    2267 [ +  - ][ +  - ]:        446 :                                 if( rxClass->getTypeClass() != TypeClass_ANY )
                 [ -  + ]
    2268                 :            :                                 {
    2269                 :          0 :                                     bError = true;
    2270         [ #  # ]:          0 :                                     StarBASIC::Error( SbERR_NOT_OPTIONAL );
    2271                 :            :                                 }
    2272                 :            :                             }
    2273         [ +  - ]:        170 :                             if( !bError )
    2274                 :        170 :                                 nAllocParamCount = nUnoParamCount;
    2275                 :            :                         }
    2276                 :            :                     }
    2277                 :            : 
    2278         [ +  + ]:        442 :                     if( nAllocParamCount > 0 )
    2279                 :            :                     {
    2280         [ +  - ]:        412 :                         args.realloc( nAllocParamCount );
    2281         [ +  - ]:        412 :                         Any* pAnyArgs = args.getArray();
    2282         [ +  + ]:       1014 :                         for( i = 0 ; i < nParamCount ; i++ )
    2283                 :            :                         {
    2284                 :        602 :                             const ParamInfo& rInfo = pParamInfos[i];
    2285                 :        602 :                             const Reference< XIdlClass >& rxClass = rInfo.aType;
    2286                 :            : 
    2287 [ +  - ][ +  - ]:        602 :                             com::sun::star::uno::Type aType( rxClass->getTypeClass(), rxClass->getName() );
         [ +  - ][ +  - ]
    2288                 :            : 
    2289                 :            :                             // ATTENTION: Don't forget for Sbx-Parameter the offset!
    2290 [ +  - ][ +  - ]:        602 :                             pAnyArgs[i] = sbxToUnoValue( pParams->Get( (sal_uInt16)(i+1) ), aType );
    2291                 :            : 
    2292                 :            :                             // If it is not certain check whether the out-parameter are available.
    2293         [ +  - ]:        602 :                             if( !bOutParams )
    2294                 :            :                             {
    2295                 :        602 :                                 ParamMode aParamMode = rInfo.aMode;
    2296         [ +  + ]:        602 :                                 if( aParamMode != ParamMode_IN )
    2297                 :         16 :                                     bOutParams = sal_True;
    2298                 :            :                             }
    2299                 :        602 :                         }
    2300                 :            :                     }
    2301                 :            :                 }
    2302 [ #  # ][ #  # ]:          0 :                 else if( bInvocation && pParams && mxInvocation.is() )
         [ #  # ][ #  # ]
    2303                 :            :                 {
    2304                 :          0 :                     bool bOLEAutomation = true;
    2305         [ #  # ]:          0 :                     processAutomationParams( pParams, args, bOLEAutomation, nParamCount );
    2306                 :            :                 }
    2307                 :            : 
    2308                 :            :                 // call the method
    2309         [ +  - ]:        442 :                 GetSbData()->bBlockCompilerError = true;  // #106433 Block compiler errors for API calls
    2310                 :            :                 try
    2311                 :            :                 {
    2312 [ +  - ][ +  - ]:        442 :                     if( !bInvocation && mxUnoAccess.is() )
                 [ +  - ]
    2313                 :            :                     {
    2314 [ +  - ][ +  - ]:        442 :                         Any aRetAny = pMeth->m_xUnoMethod->invoke( getUnoAny(), args );
                 [ +  + ]
    2315                 :            : 
    2316                 :            :                         // take over the value from Uno to Sbx
    2317         [ +  - ]:        438 :                         unoToSbxValue( pVar, aRetAny );
    2318                 :            : 
    2319                 :            :                         // Did we to copy back the Out-Parameter?
    2320         [ +  + ]:        438 :                         if( bOutParams )
    2321                 :            :                         {
    2322                 :         16 :                             const Any* pAnyArgs = args.getConstArray();
    2323                 :            : 
    2324                 :            :                             // get info
    2325         [ +  - ]:         16 :                             const Sequence<ParamInfo>& rInfoSeq = pMeth->getParamInfos();
    2326                 :         16 :                             const ParamInfo* pParamInfos = rInfoSeq.getConstArray();
    2327                 :            : 
    2328                 :            :                             sal_uInt32 j;
    2329         [ +  + ]:         32 :                             for( j = 0 ; j < nParamCount ; j++ )
    2330                 :            :                             {
    2331                 :         16 :                                 const ParamInfo& rInfo = pParamInfos[j];
    2332                 :         16 :                                 ParamMode aParamMode = rInfo.aMode;
    2333         [ +  - ]:         16 :                                 if( aParamMode != ParamMode_IN )
    2334 [ +  - ][ +  - ]:         16 :                                     unoToSbxValue( (SbxVariable*)pParams->Get( (sal_uInt16)(j+1) ), pAnyArgs[ j ] );
    2335                 :            :                             }
    2336                 :        442 :                         }
    2337                 :            :                     }
    2338 [ #  # ][ #  # ]:          0 :                     else if( bInvocation && mxInvocation.is() )
                 [ #  # ]
    2339                 :            :                     {
    2340 [ #  # ][ #  # ]:          0 :                         Any aRetAny = invokeAutomationMethod( pMeth->GetName(), args, pParams, nParamCount, mxInvocation );
                 [ #  # ]
    2341         [ #  # ]:          0 :                         unoToSbxValue( pVar, aRetAny );
    2342                 :            :                         }
    2343                 :            : 
    2344                 :            :                     // remove parameter here, because this was not done anymore in unoToSbxValue()
    2345                 :            :                     // for arrays
    2346         [ +  + ]:        438 :                     if( pParams )
    2347         [ +  - ]:        344 :                         pVar->SetParameters( NULL );
    2348                 :            :                 }
    2349 [ -  + ][ +  - ]:          8 :                 catch( const Exception& )
    2350                 :            :                 {
    2351 [ -  + ][ -  + ]:          4 :                     implHandleAnyException( ::cppu::getCaughtException() );
    2352                 :            :                 }
    2353 [ +  - ][ +  - ]:        442 :                 GetSbData()->bBlockCompilerError = false;  // #106433 Unblock compiler errors
    2354                 :            :             }
    2355                 :            :         }
    2356                 :            :         else
    2357                 :        784 :             SbxObject::SFX_NOTIFY( rBC, rBCType, rHint, rHintType );
    2358                 :            :     }
    2359                 :            : }
    2360                 :            : 
    2361                 :            : 
    2362                 :       4738 : SbUnoObject::SbUnoObject( const rtl::OUString& aName_, const Any& aUnoObj_ )
    2363                 :            :     : SbxObject( aName_ )
    2364                 :            :     , bNeedIntrospection( true )
    2365 [ +  - ][ +  - ]:       4738 :     , bNativeCOMObject( false )
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
    2366                 :            : {
    2367 [ +  + ][ +  - ]:       4738 :     static Reference< XIntrospection > xIntrospection;
         [ -  + ][ #  # ]
    2368                 :            : 
    2369                 :            :     // beat out again the default properties of Sbx
    2370 [ +  - ][ +  - ]:       4738 :     Remove( rtl::OUString("Name"), SbxCLASS_DONTCARE );
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
    2371 [ +  - ][ +  - ]:       4738 :     Remove( rtl::OUString("Parent"), SbxCLASS_DONTCARE );
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
    2372                 :            : 
    2373                 :            :     // check the type of the ojekts
    2374                 :       4738 :     TypeClass eType = aUnoObj_.getValueType().getTypeClass();
    2375                 :       4738 :     Reference< XInterface > x;
    2376   [ +  +  +  - ]:       4738 :     if( eType == TypeClass_INTERFACE )
    2377                 :            :     {
    2378                 :            :         // get the interface from the Any
    2379 [ +  - ][ +  - ]:       4411 :         x = *(Reference< XInterface >*)aUnoObj_.getValue();
    2380 [ +  + ][ -  + ]:       4411 :         if( !x.is() )
    2381                 :            :             return;
    2382                 :            :     }
    2383                 :            : 
    2384                 :       2933 :     Reference< XTypeProvider > xTypeProvider;
    2385                 :            :     // Did the object have an invocation itself?
    2386 [ +  - ][ +  - ]:       2933 :     mxInvocation = Reference< XInvocation >( x, UNO_QUERY );
         [ +  - ][ +  - ]
    2387                 :            : 
    2388 [ +  - ][ +  - ]:       2933 :     xTypeProvider = Reference< XTypeProvider >( x, UNO_QUERY );
         [ +  - ][ +  - ]
    2389                 :            : 
    2390   [ +  +  -  + ]:       2933 :     if( mxInvocation.is() )
    2391                 :            :     {
    2392                 :            : 
    2393                 :            :         // get the ExactName
    2394 [ +  - ][ +  - ]:         34 :         mxExactNameInvocation = Reference< XExactName >::query( mxInvocation );
         [ #  # ][ #  # ]
    2395                 :            : 
    2396                 :            :         // The remainder refers only to the introspection
    2397   [ -  +  #  # ]:         34 :         if( !xTypeProvider.is() )
    2398                 :            :         {
    2399                 :          0 :             bNeedIntrospection = false;
    2400                 :            :             return;
    2401                 :            :         }
    2402                 :            : 
    2403                 :            :         // Ignore introspection based members for COM objects to avoid
    2404                 :            :         // hiding of equally named COM symbols, e.g. XInvocation::getValue
    2405 [ +  - ][ #  # ]:         34 :         Reference< oleautomation::XAutomationObject > xAutomationObject( aUnoObj_, UNO_QUERY );
    2406 [ -  + ][ #  # ]:         34 :         if( xAutomationObject.is() )
    2407                 :         34 :             bNativeCOMObject = true;
    2408                 :            :     }
    2409                 :            : 
    2410                 :       2933 :     maTmpUnoObj = aUnoObj_;
    2411                 :            : 
    2412                 :            : 
    2413                 :            :     //*** Define the name ***
    2414                 :       2933 :     sal_Bool bFatalError = sal_True;
    2415                 :            : 
    2416                 :            :     // Is it an interface or a struct?
    2417                 :       2933 :     sal_Bool bSetClassName = sal_False;
    2418                 :       2933 :     rtl::OUString aClassName_;
    2419   [ -  +  +  - ]:       2933 :     if( eType == TypeClass_STRUCT || eType == TypeClass_EXCEPTION )
         [ -  + ][ +  + ]
    2420                 :            :     {
    2421                 :            :         // Struct is Ok
    2422                 :        327 :         bFatalError = sal_False;
    2423                 :            : 
    2424                 :            :         // insert the real name of the class
    2425 [ +  + ][ #  # ]:        327 :         if( aName_.isEmpty() )
    2426                 :            :         {
    2427                 :         66 :             aClassName_ = aUnoObj_.getValueType().getTypeName();
    2428                 :         66 :             bSetClassName = sal_True;
    2429                 :            :         }
    2430                 :        327 :         typelib_TypeDescription * pDeclTD = 0;
    2431                 :        327 :         typelib_typedescription_getByName( &pDeclTD, maTmpUnoObj.getValueTypeName().pData );
    2432                 :        327 :         StructRefInfo aThisStruct( maTmpUnoObj, pDeclTD, 0 );
    2433 [ +  - ][ +  - ]:        327 :         maStructInfo.reset( new SbUnoStructRefObject( GetName(), aThisStruct ) );
         [ +  - ][ +  - ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ +  - ]
    2434                 :            :     }
    2435 [ +  - ][ +  - ]:       2606 :     else if( eType == TypeClass_INTERFACE )
    2436                 :            :     {
    2437                 :            :         // Interface works always through the type in the Any
    2438                 :       2606 :         bFatalError = sal_False;
    2439                 :            :     }
    2440 [ +  + ][ -  + ]:       2933 :     if( bSetClassName )
    2441 [ +  - ][ +  - ]:         66 :         SetClassName( aClassName_ );
         [ +  - ][ #  # ]
         [ #  # ][ #  # ]
    2442                 :            : 
    2443                 :            :     // Neither interface nor Struct -> FatalError
    2444 [ -  + ][ -  + ]:       2933 :     if( bFatalError )
    2445                 :            :     {
    2446 [ #  # ][ #  # ]:       2933 :         StarBASIC::FatalError( ERRCODE_BASIC_EXCEPTION );
    2447                 :            :         return;
    2448 [ -  + ][ -  + ]:       4738 :     }
         [ +  + ][ -  + ]
         [ -  + ][ +  - ]
    2449                 :            : 
    2450                 :            :     // pass the introspection primal on demand
    2451                 :            : }
    2452                 :            : 
    2453 [ +  - ][ +  - ]:       8922 : SbUnoObject::~SbUnoObject()
         [ +  - ][ +  - ]
    2454                 :            : {
    2455 [ +  - ][ -  + ]:      13381 : }
         [ #  # ][ -  + ]
         [ -  + ][ #  # ]
    2456                 :            : 
    2457                 :            : 
    2458                 :            : // pass the introspection on Demand
    2459                 :       4127 : void SbUnoObject::doIntrospection( void )
    2460                 :            : {
    2461 [ +  + ][ +  - ]:       4127 :     static Reference< XIntrospection > xIntrospection;
    2462                 :            : 
    2463         [ -  + ]:       4127 :     if( !bNeedIntrospection )
    2464                 :          0 :         return;
    2465                 :       4127 :     bNeedIntrospection = false;
    2466                 :            : 
    2467         [ +  + ]:       4127 :     if( !xIntrospection.is() )
    2468                 :            :     {
    2469                 :            :         // get the introspection service
    2470         [ +  - ]:        122 :         Reference< XMultiServiceFactory > xFactory( comphelper::getProcessServiceFactory() );
    2471         [ +  - ]:        122 :         if ( xFactory.is() )
    2472                 :            :         {
    2473 [ +  - ][ +  - ]:        122 :             Reference< XInterface > xI = xFactory->createInstance( rtl::OUString("com.sun.star.beans.Introspection") );
    2474         [ +  - ]:        122 :             if (xI.is())
    2475 [ +  - ][ +  - ]:        122 :                 xIntrospection = Reference< XIntrospection >::query( xI );
    2476                 :        122 :         }
    2477                 :            :     }
    2478         [ -  + ]:       4127 :     if( !xIntrospection.is() )
    2479                 :            :     {
    2480                 :          0 :         StarBASIC::FatalError( ERRCODE_BASIC_EXCEPTION );
    2481                 :          0 :         return;
    2482                 :            :     }
    2483                 :            : 
    2484                 :            :     // pass the introspection
    2485                 :            :     try
    2486                 :            :     {
    2487 [ +  - ][ +  - ]:       4127 :         mxUnoAccess = xIntrospection->inspect( maTmpUnoObj );
                 [ +  - ]
    2488                 :            :     }
    2489         [ #  # ]:          0 :     catch( const RuntimeException& e )
    2490                 :            :     {
    2491   [ #  #  #  #  :          0 :         StarBASIC::Error( ERRCODE_BASIC_EXCEPTION, implGetExceptionMsg( e ) );
             #  #  #  # ]
    2492                 :            :     }
    2493                 :            : 
    2494         [ +  + ]:       4127 :     if( !mxUnoAccess.is() )
    2495                 :            :     {
    2496                 :            :         // #51475 mark to indicate an invalid object (no mxMaterialHolder)
    2497                 :       1689 :         return;
    2498                 :            :     }
    2499                 :            : 
    2500                 :            :     // get MaterialHolder from access
    2501         [ +  - ]:       2438 :     mxMaterialHolder = Reference< XMaterialHolder >::query( mxUnoAccess );
    2502                 :            : 
    2503                 :            :     // get ExactName from access
    2504         [ +  - ]:       4127 :     mxExactName = Reference< XExactName >::query( mxUnoAccess );
    2505                 :            : }
    2506                 :            : 
    2507                 :            : 
    2508                 :            : 
    2509                 :            : 
    2510                 :            : // Start of a list of all SbUnoMethod-Instances
    2511                 :            : static SbUnoMethod* pFirst = NULL;
    2512                 :            : 
    2513                 :        715 : void clearUnoMethodsForBasic( StarBASIC* pBasic )
    2514                 :            : {
    2515                 :        715 :     SbUnoMethod* pMeth = pFirst;
    2516         [ +  + ]:        801 :     while( pMeth )
    2517                 :            :     {
    2518                 :         86 :         SbxObject* pObject = dynamic_cast< SbxObject* >( pMeth->GetParent() );
    2519         [ +  - ]:         86 :         if ( pObject )
    2520                 :            :         {
    2521         [ +  + ]:         86 :             StarBASIC* pModBasic = dynamic_cast< StarBASIC* >( pObject->GetParent() );
    2522         [ +  + ]:         86 :             if ( pModBasic == pBasic )
    2523                 :            :             {
    2524                 :            :                 // for now the solution is to remove the method from the list and to clear it,
    2525                 :            :                 // but in case the element should be correctly transfered to another StarBASIC,
    2526                 :            :                 // we should either set module parent to NULL without clearing it, or even
    2527                 :            :                 // set the new StarBASIC as the parent of the module
    2528                 :            :                 // pObject->SetParent( NULL );
    2529                 :            : 
    2530         [ +  + ]:         16 :                 if( pMeth == pFirst )
    2531                 :         14 :                     pFirst = pMeth->pNext;
    2532         [ +  - ]:          2 :                 else if( pMeth->pPrev )
    2533                 :          2 :                     pMeth->pPrev->pNext = pMeth->pNext;
    2534         [ +  + ]:         16 :                 if( pMeth->pNext )
    2535                 :          8 :                     pMeth->pNext->pPrev = pMeth->pPrev;
    2536                 :            : 
    2537                 :         16 :                 pMeth->pPrev = NULL;
    2538                 :         16 :                 pMeth->pNext = NULL;
    2539                 :            : 
    2540                 :         16 :                 pMeth->SbxValue::Clear();
    2541                 :         16 :                 pObject->SbxValue::Clear();
    2542                 :            : 
    2543                 :            :                 // start from the beginning after object clearing, the cycle will end since the method is removed each time
    2544                 :         16 :                 pMeth = pFirst;
    2545                 :            :             }
    2546                 :            :             else
    2547                 :         70 :                 pMeth = pMeth->pNext;
    2548                 :            :         }
    2549                 :            :         else
    2550                 :          0 :             pMeth = pMeth->pNext;
    2551                 :            :     }
    2552                 :        715 : }
    2553                 :            : 
    2554                 :         31 : void clearUnoMethods( void )
    2555                 :            : {
    2556                 :         31 :     SbUnoMethod* pMeth = pFirst;
    2557         [ +  + ]:         75 :     while( pMeth )
    2558                 :            :     {
    2559                 :         44 :         pMeth->SbxValue::Clear();
    2560                 :         44 :         pMeth = pMeth->pNext;
    2561                 :            :     }
    2562                 :         31 : }
    2563                 :            : 
    2564                 :            : 
    2565                 :        288 : SbUnoMethod::SbUnoMethod
    2566                 :            : (
    2567                 :            :     const rtl::OUString& aName_,
    2568                 :            :     SbxDataType eSbxType,
    2569                 :            :     Reference< XIdlMethod > xUnoMethod_,
    2570                 :            :     bool bInvocation,
    2571                 :            :     bool bDirect
    2572                 :            : )
    2573                 :            :     : SbxMethod( aName_, eSbxType )
    2574                 :            :     , mbInvocation( bInvocation )
    2575 [ +  - ][ +  - ]:        288 :     , mbDirectInvocation( bDirect )
         [ +  - ][ #  # ]
         [ #  # ][ #  # ]
    2576                 :            : {
    2577   [ +  -  #  # ]:        288 :     m_xUnoMethod = xUnoMethod_;
    2578                 :        288 :     pParamInfoSeq = NULL;
    2579                 :            : 
    2580                 :            :     // enregister the method in a list
    2581                 :        288 :     pNext = pFirst;
    2582                 :        288 :     pPrev = NULL;
    2583                 :        288 :     pFirst = this;
    2584 [ +  + ][ #  # ]:        288 :     if( pNext )
    2585                 :        270 :         pNext->pPrev = this;
    2586                 :        288 : }
    2587                 :            : 
    2588 [ +  - ][ #  # ]:        576 : SbUnoMethod::~SbUnoMethod()
    2589                 :            : {
    2590 [ +  - ][ +  - ]:        288 :     delete pParamInfoSeq;
         [ #  # ][ #  # ]
    2591                 :            : 
    2592 [ +  + ][ #  # ]:        288 :     if( this == pFirst )
    2593                 :        136 :         pFirst = pNext;
    2594 [ +  + ][ #  # ]:        152 :     else if( pPrev )
    2595                 :        136 :         pPrev->pNext = pNext;
    2596 [ +  + ][ #  # ]:        288 :     if( pNext )
    2597                 :        258 :         pNext->pPrev = pPrev;
    2598 [ +  - ][ -  + ]:        864 : }
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    2599                 :            : 
    2600                 :         38 : SbxInfo* SbUnoMethod::GetInfo()
    2601                 :            : {
    2602 [ +  + ][ +  - ]:         38 :     if( !pInfo && m_xUnoMethod.is() )
                 [ +  + ]
    2603                 :            :     {
    2604                 :         34 :         SbiInstance* pInst = GetSbData()->pInst;
    2605 [ +  - ][ +  - ]:         34 :         if( pInst && pInst->IsCompatibility() )
                 [ +  - ]
    2606                 :            :         {
    2607         [ +  - ]:         34 :             pInfo = new SbxInfo();
    2608                 :            : 
    2609                 :         34 :             const Sequence<ParamInfo>& rInfoSeq = getParamInfos();
    2610                 :         34 :             const ParamInfo* pParamInfos = rInfoSeq.getConstArray();
    2611                 :         34 :             sal_uInt32 nParamCount = rInfoSeq.getLength();
    2612                 :            : 
    2613         [ +  + ]:        204 :             for( sal_uInt32 i = 0 ; i < nParamCount ; i++ )
    2614                 :            :             {
    2615                 :        170 :                 const ParamInfo& rInfo = pParamInfos[i];
    2616                 :        170 :                 ::rtl::OUString aParamName = rInfo.aName;
    2617                 :            : 
    2618                 :        170 :                 SbxDataType t = SbxVARIANT;
    2619                 :        170 :                 sal_uInt16 nFlags_ = SBX_READ;
    2620         [ +  - ]:        170 :                 pInfo->AddParam( aParamName, t, nFlags_ );
    2621                 :        170 :             }
    2622                 :            :         }
    2623                 :            :     }
    2624                 :         38 :     return pInfo;
    2625                 :            : }
    2626                 :            : 
    2627                 :        492 : const Sequence<ParamInfo>& SbUnoMethod::getParamInfos( void )
    2628                 :            : {
    2629 [ +  + ][ +  - ]:        492 :     if( !pParamInfoSeq && m_xUnoMethod.is() )
                 [ +  + ]
    2630                 :            :     {
    2631 [ +  - ][ +  - ]:        288 :         Sequence<ParamInfo> aTmp = m_xUnoMethod->getParameterInfos() ;
    2632 [ +  - ][ +  - ]:        288 :         pParamInfoSeq = new Sequence<ParamInfo>( aTmp );
    2633                 :            :     }
    2634                 :        492 :     return *pParamInfoSeq;
    2635                 :            : }
    2636                 :            : 
    2637                 :        260 : SbUnoProperty::SbUnoProperty
    2638                 :            : (
    2639                 :            :     const rtl::OUString& aName_,
    2640                 :            :     SbxDataType eSbxType,
    2641                 :            :     SbxDataType eRealSbxType,
    2642                 :            :     const Property& aUnoProp_,
    2643                 :            :     sal_Int32 nId_,
    2644                 :            :     bool bInvocation,
    2645                 :            :     bool bUnoStruct
    2646                 :            : )
    2647                 :            :     : SbxProperty( aName_, eSbxType )
    2648                 :            :     , aUnoProp( aUnoProp_ )
    2649                 :            :     , nId( nId_ )
    2650                 :            :     , mbInvocation( bInvocation )
    2651                 :            :     , mRealType( eRealSbxType )
    2652 [ +  - ][ +  - ]:        260 :     , mbUnoStruct( bUnoStruct )
         [ +  - ][ #  # ]
         [ #  # ][ #  # ]
    2653                 :            : {
    2654                 :            :     // as needed establish an dummy array so that SbiRuntime::CheckArray() works
    2655 [ +  - ][ +  - ]:        260 :     static SbxArrayRef xDummyArray = new SbxArray( SbxVARIANT );
                 [ +  - ]
           [ #  #  #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ +  + ]
    2656 [ +  + ][ #  # ]:        260 :     if( eSbxType & SbxARRAY )
    2657 [ +  - ][ #  # ]:          2 :         PutObject( xDummyArray );
    2658                 :        260 : }
    2659                 :            : 
    2660 [ +  - ][ #  # ]:        520 : SbUnoProperty::~SbUnoProperty()
    2661 [ +  - ][ -  + ]:        780 : {}
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    2662                 :            : 
    2663                 :            : 
    2664                 :        720 : SbxVariable* SbUnoObject::Find( const rtl::OUString& rName, SbxClassType t )
    2665                 :            : {
    2666 [ +  + ][ +  - ]:        720 :     static Reference< XIdlMethod > xDummyMethod;
    2667 [ +  + ][ +  - ]:        720 :     static Property aDummyProp;
    2668                 :            : 
    2669                 :        720 :     SbxVariable* pRes = SbxObject::Find( rName, t );
    2670                 :            : 
    2671         [ +  + ]:        720 :     if( bNeedIntrospection )
    2672                 :        135 :         doIntrospection();
    2673                 :            : 
    2674                 :            :     // New 1999-03-04: Create properties on demand. Therefore search now perIntrospectionAccess,
    2675                 :            :     // if a property or a method of the required name exist
    2676         [ +  + ]:        720 :     if( !pRes )
    2677                 :            :     {
    2678                 :        541 :         ::rtl::OUString aUName( rName );
    2679 [ +  - ][ +  - ]:        541 :         if( mxUnoAccess.is() && !bNativeCOMObject )
                 [ +  - ]
    2680                 :            :         {
    2681         [ +  - ]:        541 :             if( mxExactName.is() )
    2682                 :            :             {
    2683 [ +  - ][ +  - ]:        541 :                 ::rtl::OUString aUExactName = mxExactName->getExactName( aUName );
    2684         [ +  + ]:        541 :                 if( !aUExactName.isEmpty() )
    2685                 :        541 :                     aUName = aUExactName;
    2686                 :            :             }
    2687 [ +  - ][ +  - ]:        541 :             if( mxUnoAccess->hasProperty( aUName, PropertyConcept::ALL - PropertyConcept::DANGEROUS ) )
                 [ +  + ]
    2688                 :            :             {
    2689         [ +  - ]:        245 :                 const Property& rProp = mxUnoAccess->
    2690         [ +  - ]:        245 :                     getProperty( aUName, PropertyConcept::ALL - PropertyConcept::DANGEROUS );
    2691                 :            : 
    2692                 :            :                 // If the property could be void the type had to be set to Variant
    2693                 :            :                 SbxDataType eSbxType;
    2694         [ +  + ]:        245 :                 if( rProp.Attributes & PropertyAttribute::MAYBEVOID )
    2695                 :          2 :                     eSbxType = SbxVARIANT;
    2696                 :            :                 else
    2697                 :        243 :                     eSbxType = unoToSbxType( rProp.Type.getTypeClass() );
    2698                 :            : 
    2699         [ +  + ]:        245 :                 SbxDataType eRealSbxType = ( ( rProp.Attributes & PropertyAttribute::MAYBEVOID ) ? unoToSbxType( rProp.Type.getTypeClass() ) : eSbxType );
    2700                 :            :                 // create the property and superimpose it
    2701 [ +  - ][ +  - ]:        245 :                 SbUnoProperty* pProp = new SbUnoProperty( rProp.Name, eSbxType, eRealSbxType, rProp, 0, false, ( rProp.Type.getTypeClass() ==  com::sun::star::uno::TypeClass_STRUCT  ) );
    2702                 :        245 :                 SbxVariableRef xVarRef = pProp;
    2703         [ +  - ]:        245 :                 QuickInsert( (SbxVariable*)xVarRef );
    2704         [ +  - ]:        245 :                 pRes = xVarRef;
    2705                 :            :             }
    2706 [ +  - ][ +  + ]:        592 :             else if( mxUnoAccess->hasMethod( aUName,
    2707         [ +  - ]:        296 :                 MethodConcept::ALL - MethodConcept::DANGEROUS ) )
    2708                 :            :             {
    2709                 :            :                 // address the method
    2710         [ +  - ]:        288 :                 const Reference< XIdlMethod >& rxMethod = mxUnoAccess->
    2711         [ +  - ]:        288 :                     getMethod( aUName, MethodConcept::ALL - MethodConcept::DANGEROUS );
    2712                 :            : 
    2713                 :            :                 // create SbUnoMethod and superimpose it
    2714         [ +  - ]:        288 :                 SbxVariableRef xMethRef = new SbUnoMethod( rxMethod->getName(),
    2715 [ +  - ][ +  - ]:        288 :                     unoToSbxType( rxMethod->getReturnType() ), rxMethod, false );
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
    2716         [ +  - ]:        288 :                 QuickInsert( (SbxVariable*)xMethRef );
    2717         [ +  - ]:        288 :                 pRes = xMethRef;
    2718                 :            :             }
    2719                 :            : 
    2720                 :            :             // Elsewise nothing would be found it had to be checked, if NameAccess is existent
    2721         [ +  + ]:        541 :             if( !pRes )
    2722                 :            :             {
    2723                 :            :                 try
    2724                 :            :                 {
    2725 [ +  - ][ +  - ]:          8 :                     Reference< XNameAccess > xNameAccess( mxUnoAccess->queryAdapter( ::getCppuType( (const Reference< XPropertySet > *)0 ) ), UNO_QUERY );
         [ +  - ][ +  - ]
    2726                 :          8 :                     ::rtl::OUString aUName2( rName );
    2727                 :            : 
    2728 [ #  # ][ #  # ]:          8 :                     if( xNameAccess.is() && xNameAccess->hasByName( aUName2 ) )
         [ #  # ][ -  + ]
                 [ -  + ]
    2729                 :            :                     {
    2730 [ #  # ][ #  # ]:          0 :                         Any aAny = xNameAccess->getByName( aUName2 );
    2731                 :            : 
    2732                 :            :                         // ATTENTION: Because of XNameAccess, the variable generated here
    2733                 :            :                         // may not be included as a fixed property in the object and therefore
    2734                 :            :                         // won't be stored anywhere.
    2735                 :            :                         // If this leads to problems, it has to be created synthetically or
    2736                 :            :                         // a class SbUnoNameAccessProperty, whose existence had to be checked
    2737                 :            :                         // constantly and which were if necessary thrown away
    2738                 :            :                         // if the name was not found anymore.
    2739 [ #  # ][ #  # ]:          0 :                         pRes = new SbxVariable( SbxVARIANT );
    2740         [ #  # ]:          0 :                         unoToSbxValue( pRes, aAny );
    2741                 :          8 :                     }
    2742                 :            :                 }
    2743         [ #  # ]:          0 :                 catch( const NoSuchElementException& e )
    2744                 :            :                 {
    2745   [ #  #  #  #  :          0 :                     StarBASIC::Error( ERRCODE_BASIC_EXCEPTION, implGetExceptionMsg( e ) );
             #  #  #  # ]
    2746                 :            :                 }
    2747   [ #  #  #  #  :          0 :                 catch( const Exception& )
                      # ]
    2748                 :            :                 {
    2749                 :            :                     // Establish so that the exeption error will not be overwriten
    2750         [ #  # ]:          0 :                     if( !pRes )
    2751   [ #  #  #  # ]:          0 :                         pRes = new SbxVariable( SbxVARIANT );
    2752                 :            : 
    2753   [ #  #  #  # ]:          0 :                     implHandleAnyException( ::cppu::getCaughtException() );
    2754                 :            :                 }
    2755                 :            :             }
    2756                 :            :         }
    2757 [ +  + ][ -  + ]:        541 :         if( !pRes && mxInvocation.is() )
                 [ -  + ]
    2758                 :            :         {
    2759         [ #  # ]:          0 :             if( mxExactNameInvocation.is() )
    2760                 :            :             {
    2761 [ #  # ][ #  # ]:          0 :                 ::rtl::OUString aUExactName = mxExactNameInvocation->getExactName( aUName );
    2762         [ #  # ]:          0 :                 if( !aUExactName.isEmpty() )
    2763                 :          0 :                     aUName = aUExactName;
    2764                 :            :             }
    2765                 :            : 
    2766                 :            :             try
    2767                 :            :             {
    2768 [ #  # ][ #  # ]:          0 :                 if( mxInvocation->hasProperty( aUName ) )
                 [ #  # ]
    2769                 :            :                 {
    2770                 :            :                     // create a property and superimpose it
    2771 [ #  # ][ #  # ]:          0 :                     SbxVariableRef xVarRef = new SbUnoProperty( aUName, SbxVARIANT, SbxVARIANT, aDummyProp, 0, true, false );
    2772         [ #  # ]:          0 :                     QuickInsert( (SbxVariable*)xVarRef );
    2773         [ #  # ]:          0 :                     pRes = xVarRef;
    2774                 :            :                 }
    2775 [ #  # ][ #  # ]:          0 :                 else if( mxInvocation->hasMethod( aUName ) )
                 [ #  # ]
    2776                 :            :                 {
    2777                 :            :                     // create SbUnoMethode and superimpose it
    2778 [ #  # ][ #  # ]:          0 :                     SbxVariableRef xMethRef = new SbUnoMethod( aUName, SbxVARIANT, xDummyMethod, true );
    2779         [ #  # ]:          0 :                     QuickInsert( (SbxVariable*)xMethRef );
    2780         [ #  # ]:          0 :                     pRes = xMethRef;
    2781                 :            :                 }
    2782                 :            :                 else
    2783                 :            :                 {
    2784         [ #  # ]:          0 :                     Reference< XDirectInvocation > xDirectInvoke( mxInvocation, UNO_QUERY );
    2785 [ #  # ][ #  # ]:          0 :                     if ( xDirectInvoke.is() && xDirectInvoke->hasMember( aUName ) )
         [ #  # ][ #  # ]
                 [ #  # ]
    2786                 :            :                     {
    2787 [ #  # ][ #  # ]:          0 :                         SbxVariableRef xMethRef = new SbUnoMethod( aUName, SbxVARIANT, xDummyMethod, true, true );
    2788         [ #  # ]:          0 :                         QuickInsert( (SbxVariable*)xMethRef );
    2789         [ #  # ]:          0 :                         pRes = xMethRef;
    2790                 :          0 :                     }
    2791                 :            : 
    2792                 :            :                 }
    2793                 :            :             }
    2794   [ #  #  #  # ]:          0 :             catch( const RuntimeException& e )
    2795                 :            :             {
    2796                 :            :                 // Establish so that the exeption error will not be overwriten
    2797         [ #  # ]:          0 :                 if( !pRes )
    2798   [ #  #  #  # ]:          0 :                     pRes = new SbxVariable( SbxVARIANT );
    2799                 :            : 
    2800   [ #  #  #  #  :          0 :                 StarBASIC::Error( ERRCODE_BASIC_EXCEPTION, implGetExceptionMsg( e ) );
             #  #  #  # ]
    2801                 :            :             }
    2802                 :        541 :         }
    2803                 :            :     }
    2804                 :            : 
    2805                 :            :     // At the very end checking if the Dbg_-Properties are meant
    2806                 :            : 
    2807         [ +  + ]:        720 :     if( !pRes )
    2808                 :            :     {
    2809   [ +  -  +  -  :         24 :         if( rName.equalsIgnoreAsciiCase(ID_DBG_SUPPORTEDINTERFACES) ||
           -  + ][ -  + ]
    2810                 :          8 :             rName.equalsIgnoreAsciiCase(ID_DBG_PROPERTIES) ||
    2811                 :          8 :             rName.equalsIgnoreAsciiCase(ID_DBG_METHODS) )
    2812                 :            :         {
    2813                 :            :             // Create
    2814                 :          0 :             implCreateDbgProperties();
    2815                 :            : 
    2816                 :            :             // Now they have to be found regular
    2817                 :          0 :             pRes = SbxObject::Find( rName, SbxCLASS_DONTCARE );
    2818                 :            :         }
    2819                 :            :     }
    2820                 :        720 :     return pRes;
    2821                 :            : }
    2822                 :            : 
    2823                 :            : 
    2824                 :            : // help method to create the dbg_-Properties
    2825                 :          0 : void SbUnoObject::implCreateDbgProperties( void )
    2826                 :            : {
    2827                 :          0 :     Property aProp;
    2828                 :            : 
    2829                 :            :     // Id == -1: display the implemented interfaces corresponding the ClassProvider
    2830 [ #  # ][ #  # ]:          0 :     SbxVariableRef xVarRef = new SbUnoProperty( ::rtl::OUString(ID_DBG_SUPPORTEDINTERFACES), SbxSTRING, SbxSTRING, aProp, -1, false, false );
    2831         [ #  # ]:          0 :     QuickInsert( (SbxVariable*)xVarRef );
    2832                 :            : 
    2833                 :            :     // Id == -2: output the properties
    2834 [ #  # ][ #  # ]:          0 :     xVarRef = new SbUnoProperty( ::rtl::OUString(ID_DBG_PROPERTIES), SbxSTRING, SbxSTRING, aProp, -2, false, false );
                 [ #  # ]
    2835         [ #  # ]:          0 :     QuickInsert( (SbxVariable*)xVarRef );
    2836                 :            : 
    2837                 :            :     // Id == -3: output the Methods
    2838 [ #  # ][ #  # ]:          0 :     xVarRef = new SbUnoProperty( ::rtl::OUString(ID_DBG_METHODS), SbxSTRING, SbxSTRING, aProp, -3, false, false );
                 [ #  # ]
    2839 [ #  # ][ #  # ]:          0 :     QuickInsert( (SbxVariable*)xVarRef );
    2840                 :          0 : }
    2841                 :            : 
    2842                 :          0 : void SbUnoObject::implCreateAll( void )
    2843                 :            : {
    2844                 :            :     // throw away all existing methods and properties
    2845 [ #  # ][ #  # ]:          0 :     pMethods   = new SbxArray;
                 [ #  # ]
    2846 [ #  # ][ #  # ]:          0 :     pProps     = new SbxArray;
                 [ #  # ]
    2847                 :            : 
    2848 [ #  # ][ #  # ]:          0 :     if( bNeedIntrospection ) doIntrospection();
    2849                 :            : 
    2850                 :            :     // get instrospection
    2851                 :          0 :     Reference< XIntrospectionAccess > xAccess = mxUnoAccess;
    2852 [ #  # ][ #  # ]:          0 :     if( !xAccess.is() || bNativeCOMObject )
                 [ #  # ]
    2853                 :            :     {
    2854         [ #  # ]:          0 :         if( mxInvocation.is() )
    2855 [ #  # ][ #  # ]:          0 :             xAccess = mxInvocation->getIntrospection();
                 [ #  # ]
    2856         [ #  # ]:          0 :         else if( bNativeCOMObject )
    2857                 :            :             return;
    2858                 :            :     }
    2859         [ #  # ]:          0 :     if( !xAccess.is() )
    2860                 :            :         return;
    2861                 :            : 
    2862                 :            :     // Establish properties
    2863 [ #  # ][ #  # ]:          0 :     Sequence<Property> props = xAccess->getProperties( PropertyConcept::ALL - PropertyConcept::DANGEROUS );
    2864                 :          0 :     sal_uInt32 nPropCount = props.getLength();
    2865                 :          0 :     const Property* pProps_ = props.getConstArray();
    2866                 :            : 
    2867                 :            :     sal_uInt32 i;
    2868         [ #  # ]:          0 :     for( i = 0 ; i < nPropCount ; i++ )
    2869                 :            :     {
    2870                 :          0 :         const Property& rProp = pProps_[ i ];
    2871                 :            : 
    2872                 :            :         // If the property could be void the type had to be set to Variant
    2873                 :            :         SbxDataType eSbxType;
    2874         [ #  # ]:          0 :         if( rProp.Attributes & PropertyAttribute::MAYBEVOID )
    2875                 :          0 :             eSbxType = SbxVARIANT;
    2876                 :            :         else
    2877                 :          0 :             eSbxType = unoToSbxType( rProp.Type.getTypeClass() );
    2878                 :            : 
    2879         [ #  # ]:          0 :         SbxDataType eRealSbxType = ( ( rProp.Attributes & PropertyAttribute::MAYBEVOID ) ? unoToSbxType( rProp.Type.getTypeClass() ) : eSbxType );
    2880                 :            :         // Create property and superimpose it
    2881 [ #  # ][ #  # ]:          0 :         SbxVariableRef xVarRef = new SbUnoProperty( rProp.Name, eSbxType, eRealSbxType, rProp, i, false, ( rProp.Type.getTypeClass() == com::sun::star::uno::TypeClass_STRUCT   ) );
    2882         [ #  # ]:          0 :         QuickInsert( (SbxVariable*)xVarRef );
    2883         [ #  # ]:          0 :     }
    2884                 :            : 
    2885                 :            :     // Create Dbg_-Properties
    2886         [ #  # ]:          0 :     implCreateDbgProperties();
    2887                 :            : 
    2888                 :            :     // Create methods
    2889         [ #  # ]:          0 :     Sequence< Reference< XIdlMethod > > aMethodSeq = xAccess->getMethods
    2890         [ #  # ]:          0 :         ( MethodConcept::ALL - MethodConcept::DANGEROUS );
    2891                 :          0 :     sal_uInt32 nMethCount = aMethodSeq.getLength();
    2892                 :          0 :     const Reference< XIdlMethod >* pMethods_ = aMethodSeq.getConstArray();
    2893         [ #  # ]:          0 :     for( i = 0 ; i < nMethCount ; i++ )
    2894                 :            :     {
    2895                 :            :         // address method
    2896                 :          0 :         const Reference< XIdlMethod >& rxMethod = pMethods_[i];
    2897                 :            : 
    2898                 :            :         // Create SbUnoMethod and superimpose it
    2899                 :            :         SbxVariableRef xMethRef = new SbUnoMethod
    2900 [ #  # ][ #  # ]:          0 :             ( rxMethod->getName(), unoToSbxType( rxMethod->getReturnType() ), rxMethod, false );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    2901         [ #  # ]:          0 :         QuickInsert( (SbxVariable*)xMethRef );
    2902 [ #  # ][ #  # ]:          0 :     }
         [ #  # ][ #  # ]
    2903                 :            : }
    2904                 :            : 
    2905                 :            : 
    2906                 :            : // output the value
    2907                 :       7742 : Any SbUnoObject::getUnoAny( void )
    2908                 :            : {
    2909                 :       7742 :     Any aRetAny;
    2910 [ +  - ][ +  + ]:       7742 :     if( bNeedIntrospection ) doIntrospection();
    2911         [ +  + ]:       7742 :     if( mxMaterialHolder.is() )
    2912 [ +  - ][ +  - ]:       5416 :         aRetAny = mxMaterialHolder->getMaterial();
    2913         [ -  + ]:       2326 :     else if( mxInvocation.is() )
    2914         [ #  # ]:          0 :         aRetAny <<= mxInvocation;
    2915                 :       7742 :     return aRetAny;
    2916                 :            : }
    2917                 :            : 
    2918                 :            : // help method to create an Uno-Struct per CoreReflection
    2919                 :        128 : SbUnoObject* Impl_CreateUnoStruct( const ::rtl::OUString& aClassName )
    2920                 :            : {
    2921                 :            :     // get CoreReflection
    2922         [ +  - ]:        128 :     Reference< XIdlReflection > xCoreReflection = getCoreReflection_Impl();
    2923         [ -  + ]:        128 :     if( !xCoreReflection.is() )
    2924                 :          0 :         return NULL;
    2925                 :            : 
    2926                 :            :     // search for the class
    2927                 :        128 :     Reference< XIdlClass > xClass;
    2928                 :            :     Reference< XHierarchicalNameAccess > xHarryName =
    2929         [ +  - ]:        128 :         getCoreReflection_HierarchicalNameAccess_Impl();
    2930 [ +  - ][ +  - ]:        128 :     if( xHarryName.is() && xHarryName->hasByHierarchicalName( aClassName ) )
         [ +  - ][ +  - ]
                 [ +  - ]
    2931 [ +  - ][ +  - ]:        128 :         xClass = xCoreReflection->forName( aClassName );
                 [ +  - ]
    2932         [ -  + ]:        128 :     if( !xClass.is() )
    2933                 :          0 :         return NULL;
    2934                 :            : 
    2935                 :            :     // Is it realy a struct?
    2936 [ +  - ][ +  - ]:        128 :     TypeClass eType = xClass->getTypeClass();
    2937 [ -  + ][ #  # ]:        128 :     if ( ( eType != TypeClass_STRUCT ) && ( eType != TypeClass_EXCEPTION ) )
    2938                 :          0 :         return NULL;
    2939                 :            : 
    2940                 :            :     // create an instance
    2941                 :        128 :     Any aNewAny;
    2942 [ +  - ][ +  - ]:        128 :     xClass->createObject( aNewAny );
    2943                 :            :     // make a SbUnoObject out of it
    2944 [ +  - ][ +  - ]:        128 :     SbUnoObject* pUnoObj = new SbUnoObject( aClassName, aNewAny );
    2945                 :        128 :     return pUnoObj;
    2946                 :            : }
    2947                 :            : 
    2948                 :            : 
    2949                 :            : // Factory-Class to create Uno-Structs per DIM AS NEW
    2950                 :          0 : SbxBase* SbUnoFactory::Create( sal_uInt16, sal_uInt32 )
    2951                 :            : {
    2952                 :            :     // Via SbxId nothing works in Uno
    2953                 :          0 :     return NULL;
    2954                 :            : }
    2955                 :            : 
    2956                 :         24 : SbxObject* SbUnoFactory::CreateObject( const rtl::OUString& rClassName )
    2957                 :            : {
    2958                 :         24 :     return Impl_CreateUnoStruct( rClassName );
    2959                 :            : }
    2960                 :            : 
    2961                 :            : 
    2962                 :            : // Provisional interface for the UNO-Connection
    2963                 :            : // Deliver a SbxObject, that wrap an Uno-Interface
    2964                 :       4081 : SbxObjectRef GetSbUnoObject( const ::rtl::OUString& aName, const Any& aUnoObj_ )
    2965                 :            : {
    2966         [ +  - ]:       4081 :     return new SbUnoObject( aName, aUnoObj_ );
    2967                 :            : }
    2968                 :            : 
    2969                 :            : // Force creation of all properties for debugging
    2970                 :          0 : void createAllObjectProperties( SbxObject* pObj )
    2971                 :            : {
    2972         [ #  # ]:          0 :     if( !pObj )
    2973                 :          0 :         return;
    2974                 :            : 
    2975 [ #  # ][ #  # ]:          0 :     SbUnoObject* pUnoObj = PTR_CAST(SbUnoObject,pObj);
    2976 [ #  # ][ #  # ]:          0 :     SbUnoStructRefObject* pUnoStructObj = PTR_CAST(SbUnoStructRefObject,pObj);
    2977         [ #  # ]:          0 :     if( pUnoObj )
    2978                 :          0 :         pUnoObj->createAllProperties();
    2979         [ #  # ]:          0 :     else if ( pUnoStructObj )
    2980                 :          0 :         pUnoStructObj->createAllProperties();
    2981                 :            :     else
    2982                 :          0 :         pObj->GetAll( SbxCLASS_DONTCARE );
    2983                 :            : }
    2984                 :            : 
    2985                 :            : 
    2986                 :        104 : void RTL_Impl_CreateUnoStruct( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrite )
    2987                 :            : {
    2988                 :            :     (void)pBasic;
    2989                 :            :     (void)bWrite;
    2990                 :            : 
    2991                 :            :     // We need 1 parameter minimum
    2992 [ +  - ][ -  + ]:        104 :     if ( rPar.Count() < 2 )
    2993                 :            :     {
    2994         [ #  # ]:          0 :         StarBASIC::Error( SbERR_BAD_ARGUMENT );
    2995                 :            :         return;
    2996                 :            :     }
    2997                 :            : 
    2998                 :            :     // get the name of the class of the struct
    2999 [ +  - ][ +  - ]:        104 :     ::rtl::OUString aClassName = rPar.Get(1)->GetString();
                 [ +  - ]
    3000                 :            : 
    3001                 :            :     // try to create Struct with the same name
    3002         [ +  - ]:        104 :     SbUnoObjectRef xUnoObj = Impl_CreateUnoStruct( aClassName );
    3003         [ -  + ]:        104 :     if( !xUnoObj )
    3004                 :            :         return;
    3005                 :            : 
    3006                 :            :     // return the object
    3007         [ +  - ]:        104 :     SbxVariableRef refVar = rPar.Get(0);
    3008 [ +  - ][ +  - ]:        104 :     refVar->PutObject( (SbUnoObject*)xUnoObj );
         [ -  + ][ +  - ]
                 [ +  - ]
    3009                 :            : }
    3010                 :            : 
    3011                 :         78 : void RTL_Impl_CreateUnoService( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrite )
    3012                 :            : {
    3013                 :            :     (void)pBasic;
    3014                 :            :     (void)bWrite;
    3015                 :            : 
    3016                 :            :     // We need 1 Parameter minimum
    3017 [ +  - ][ -  + ]:         78 :     if ( rPar.Count() < 2 )
    3018                 :            :     {
    3019         [ #  # ]:          0 :         StarBASIC::Error( SbERR_BAD_ARGUMENT );
    3020                 :         78 :         return;
    3021                 :            :     }
    3022                 :            : 
    3023                 :            :     // get the name of the class of the struct
    3024 [ +  - ][ +  - ]:         78 :     ::rtl::OUString aServiceName = rPar.Get(1)->GetString();
                 [ +  - ]
    3025                 :            : 
    3026                 :            :     // search for the service and instatiate it
    3027         [ +  - ]:         78 :     Reference< XMultiServiceFactory > xFactory( comphelper::getProcessServiceFactory() );
    3028                 :         78 :     Reference< XInterface > xInterface;
    3029         [ +  - ]:         78 :     if ( xFactory.is() )
    3030                 :            :     {
    3031                 :            :         try
    3032                 :            :         {
    3033 [ +  - ][ +  - ]:         78 :             xInterface = xFactory->createInstance( aServiceName );
                 [ +  - ]
    3034                 :            :         }
    3035   [ #  #  #  # ]:          0 :         catch( const Exception& )
    3036                 :            :         {
    3037   [ #  #  #  # ]:          0 :             implHandleAnyException( ::cppu::getCaughtException() );
    3038                 :            :         }
    3039                 :            :     }
    3040                 :            : 
    3041         [ +  - ]:         78 :     SbxVariableRef refVar = rPar.Get(0);
    3042         [ +  + ]:         78 :     if( xInterface.is() )
    3043                 :            :     {
    3044                 :         74 :         Any aAny;
    3045         [ +  - ]:         74 :         aAny <<= xInterface;
    3046                 :            : 
    3047                 :            :         // Create a SbUnoObject out of it and return it
    3048 [ +  - ][ +  - ]:         74 :         SbUnoObjectRef xUnoObj = new SbUnoObject( aServiceName, aAny );
    3049 [ +  - ][ +  - ]:         74 :         if( xUnoObj->getUnoAny().getValueType().getTypeClass() != TypeClass_VOID )
    3050                 :            :         {
    3051                 :            :             // return the object
    3052         [ +  - ]:         74 :             refVar->PutObject( (SbUnoObject*)xUnoObj );
    3053                 :            :         }
    3054                 :            :         else
    3055                 :            :         {
    3056         [ #  # ]:          0 :             refVar->PutObject( NULL );
    3057         [ +  - ]:         74 :         }
    3058                 :            :     }
    3059                 :            :     else
    3060                 :            :     {
    3061         [ +  - ]:          4 :         refVar->PutObject( NULL );
    3062         [ +  - ]:         78 :     }
    3063                 :            : }
    3064                 :            : 
    3065                 :          0 : void RTL_Impl_CreateUnoServiceWithArguments( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrite )
    3066                 :            : {
    3067                 :            :     (void)pBasic;
    3068                 :            :     (void)bWrite;
    3069                 :            : 
    3070                 :            :     // We need 2 parameter minimum
    3071 [ #  # ][ #  # ]:          0 :     if ( rPar.Count() < 3 )
    3072                 :            :     {
    3073         [ #  # ]:          0 :         StarBASIC::Error( SbERR_BAD_ARGUMENT );
    3074                 :          0 :         return;
    3075                 :            :     }
    3076                 :            : 
    3077                 :            :     // get the name of the class of the struct
    3078 [ #  # ][ #  # ]:          0 :     ::rtl::OUString aServiceName = rPar.Get(1)->GetString();
                 [ #  # ]
    3079                 :            :     Any aArgAsAny = sbxToUnoValue( rPar.Get(2),
    3080 [ #  # ][ #  # ]:          0 :                 getCppuType( (Sequence<Any>*)0 ) );
                 [ #  # ]
    3081         [ #  # ]:          0 :     Sequence< Any > aArgs;
    3082         [ #  # ]:          0 :     aArgAsAny >>= aArgs;
    3083                 :            : 
    3084                 :            :     // search for the service and instatiate it
    3085         [ #  # ]:          0 :     Reference< XMultiServiceFactory > xFactory( comphelper::getProcessServiceFactory() );
    3086                 :          0 :     Reference< XInterface > xInterface;
    3087         [ #  # ]:          0 :     if ( xFactory.is() )
    3088                 :            :     {
    3089                 :            :         try
    3090                 :            :         {
    3091 [ #  # ][ #  # ]:          0 :             xInterface = xFactory->createInstanceWithArguments( aServiceName, aArgs );
                 [ #  # ]
    3092                 :            :         }
    3093   [ #  #  #  # ]:          0 :         catch( const Exception& )
    3094                 :            :         {
    3095   [ #  #  #  # ]:          0 :             implHandleAnyException( ::cppu::getCaughtException() );
    3096                 :            :         }
    3097                 :            :     }
    3098                 :            : 
    3099         [ #  # ]:          0 :     SbxVariableRef refVar = rPar.Get(0);
    3100         [ #  # ]:          0 :     if( xInterface.is() )
    3101                 :            :     {
    3102                 :          0 :         Any aAny;
    3103         [ #  # ]:          0 :         aAny <<= xInterface;
    3104                 :            : 
    3105                 :            :         // Create a SbUnoObject out of it and return it
    3106 [ #  # ][ #  # ]:          0 :         SbUnoObjectRef xUnoObj = new SbUnoObject( aServiceName, aAny );
    3107 [ #  # ][ #  # ]:          0 :         if( xUnoObj->getUnoAny().getValueType().getTypeClass() != TypeClass_VOID )
    3108                 :            :         {
    3109                 :            :             // return the object
    3110         [ #  # ]:          0 :             refVar->PutObject( (SbUnoObject*)xUnoObj );
    3111                 :            :         }
    3112                 :            :         else
    3113                 :            :         {
    3114         [ #  # ]:          0 :             refVar->PutObject( NULL );
    3115         [ #  # ]:          0 :         }
    3116                 :            :     }
    3117                 :            :     else
    3118                 :            :     {
    3119         [ #  # ]:          0 :         refVar->PutObject( NULL );
    3120 [ #  # ][ #  # ]:          0 :     }
    3121                 :            : }
    3122                 :            : 
    3123                 :          0 : void RTL_Impl_GetProcessServiceManager( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrite )
    3124                 :            : {
    3125                 :            :     (void)pBasic;
    3126                 :            :     (void)bWrite;
    3127                 :            : 
    3128         [ #  # ]:          0 :     SbxVariableRef refVar = rPar.Get(0);
    3129                 :            : 
    3130                 :            :     // get the global service manager
    3131         [ #  # ]:          0 :     Reference< XMultiServiceFactory > xFactory( comphelper::getProcessServiceFactory() );
    3132         [ #  # ]:          0 :     if( xFactory.is() )
    3133                 :            :     {
    3134                 :          0 :         Any aAny;
    3135         [ #  # ]:          0 :         aAny <<= xFactory;
    3136                 :            : 
    3137                 :            :         // Create a SbUnoObject out of it and return it
    3138 [ #  # ][ #  # ]:          0 :         SbUnoObjectRef xUnoObj = new SbUnoObject( ::rtl::OUString( "ProcessServiceManager" ), aAny );
    3139 [ #  # ][ #  # ]:          0 :         refVar->PutObject( (SbUnoObject*)xUnoObj );
    3140                 :            :     }
    3141                 :            :     else
    3142                 :            :     {
    3143         [ #  # ]:          0 :         refVar->PutObject( NULL );
    3144         [ #  # ]:          0 :     }
    3145                 :          0 : }
    3146                 :            : 
    3147                 :          0 : void RTL_Impl_HasInterfaces( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrite )
    3148                 :            : {
    3149                 :            :     (void)pBasic;
    3150                 :            :     (void)bWrite;
    3151                 :            : 
    3152                 :            :     // We need 2 parameter minimum
    3153         [ #  # ]:          0 :     sal_uInt16 nParCount = rPar.Count();
    3154         [ #  # ]:          0 :     if( nParCount < 3 )
    3155                 :            :     {
    3156         [ #  # ]:          0 :         StarBASIC::Error( SbERR_BAD_ARGUMENT );
    3157                 :            :         return;
    3158                 :            :     }
    3159                 :            : 
    3160                 :            :     // variable for the return value
    3161         [ #  # ]:          0 :     SbxVariableRef refVar = rPar.Get(0);
    3162         [ #  # ]:          0 :     refVar->PutBool( sal_False );
    3163                 :            : 
    3164                 :            :     // get the Uno-Object
    3165 [ #  # ][ #  # ]:          0 :     SbxBaseRef pObj = (SbxBase*)rPar.Get( 1 )->GetObject();
    3166 [ #  # ][ #  # ]:          0 :     if( !(pObj && pObj->ISA(SbUnoObject)) )
         [ #  # ][ #  # ]
    3167                 :            :         return;
    3168         [ #  # ]:          0 :     Any aAny = ((SbUnoObject*)(SbxBase*)pObj)->getUnoAny();
    3169                 :          0 :     TypeClass eType = aAny.getValueType().getTypeClass();
    3170         [ #  # ]:          0 :     if( eType != TypeClass_INTERFACE )
    3171                 :            :         return;
    3172                 :            : 
    3173                 :            :     // get the interface out of the Any
    3174                 :          0 :     Reference< XInterface > x = *(Reference< XInterface >*)aAny.getValue();
    3175                 :            : 
    3176                 :            :     // get CoreReflection
    3177         [ #  # ]:          0 :     Reference< XIdlReflection > xCoreReflection = getCoreReflection_Impl();
    3178         [ #  # ]:          0 :     if( !xCoreReflection.is() )
    3179                 :            :         return;
    3180                 :            : 
    3181         [ #  # ]:          0 :     for( sal_uInt16 i = 2 ; i < nParCount ; i++ )
    3182                 :            :     {
    3183                 :            :         // get the name of the interface of the struct
    3184 [ #  # ][ #  # ]:          0 :         rtl::OUString aIfaceName = rPar.Get( i )->GetString();
                 [ #  # ]
    3185                 :            : 
    3186                 :            :         // search for the class
    3187 [ #  # ][ #  # ]:          0 :         Reference< XIdlClass > xClass = xCoreReflection->forName( aIfaceName );
    3188         [ #  # ]:          0 :         if( !xClass.is() )
    3189                 :            :             return;
    3190                 :            : 
    3191                 :            :         // check if the interface will be supported
    3192 [ #  # ][ #  # ]:          0 :         ::rtl::OUString aClassName = xClass->getName();
    3193 [ #  # ][ #  # ]:          0 :         Type aClassType( xClass->getTypeClass(), aClassName.getStr() );
    3194 [ #  # ][ #  # ]:          0 :         if( !x->queryInterface( aClassType ).hasValue() )
                 [ #  # ]
    3195                 :            :             return;
    3196 [ #  # ][ #  # ]:          0 :     }
         [ #  # ][ #  # ]
    3197                 :            : 
    3198                 :            :     // Every thing works; then return TRUE
    3199 [ #  # ][ #  # ]:          0 :     refVar->PutBool( sal_True );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    3200                 :            : }
    3201                 :            : 
    3202                 :          0 : void RTL_Impl_IsUnoStruct( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrite )
    3203                 :            : {
    3204                 :            :     (void)pBasic;
    3205                 :            :     (void)bWrite;
    3206                 :            : 
    3207                 :            :     // We need 1 parameter minimum
    3208 [ #  # ][ #  # ]:          0 :     if ( rPar.Count() < 2 )
    3209                 :            :     {
    3210         [ #  # ]:          0 :         StarBASIC::Error( SbERR_BAD_ARGUMENT );
    3211                 :            :         return;
    3212                 :            :     }
    3213                 :            : 
    3214                 :            :     // variable for the return value
    3215         [ #  # ]:          0 :     SbxVariableRef refVar = rPar.Get(0);
    3216         [ #  # ]:          0 :     refVar->PutBool( sal_False );
    3217                 :            : 
    3218                 :            :     // get the Uno-Object
    3219         [ #  # ]:          0 :     SbxVariableRef xParam = rPar.Get( 1 );
    3220 [ #  # ][ #  # ]:          0 :     if( !xParam->IsObject() )
    3221                 :            :         return;
    3222 [ #  # ][ #  # ]:          0 :     SbxBaseRef pObj = (SbxBase*)rPar.Get( 1 )->GetObject();
    3223 [ #  # ][ #  # ]:          0 :     if( !(pObj && pObj->ISA(SbUnoObject)) )
         [ #  # ][ #  # ]
    3224                 :            :         return;
    3225         [ #  # ]:          0 :     Any aAny = ((SbUnoObject*)(SbxBase*)pObj)->getUnoAny();
    3226                 :          0 :     TypeClass eType = aAny.getValueType().getTypeClass();
    3227         [ #  # ]:          0 :     if( eType == TypeClass_STRUCT )
    3228 [ #  # ][ #  # ]:          0 :         refVar->PutBool( sal_True );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    3229                 :            : }
    3230                 :            : 
    3231                 :            : 
    3232                 :          0 : void RTL_Impl_EqualUnoObjects( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrite )
    3233                 :            : {
    3234                 :            :     (void)pBasic;
    3235                 :            :     (void)bWrite;
    3236                 :            : 
    3237 [ #  # ][ #  # ]:          0 :     if ( rPar.Count() < 3 )
    3238                 :            :     {
    3239         [ #  # ]:          0 :         StarBASIC::Error( SbERR_BAD_ARGUMENT );
    3240                 :            :         return;
    3241                 :            :     }
    3242                 :            : 
    3243                 :            :     // variable for the return value
    3244         [ #  # ]:          0 :     SbxVariableRef refVar = rPar.Get(0);
    3245         [ #  # ]:          0 :     refVar->PutBool( sal_False );
    3246                 :            : 
    3247                 :            :     // get the Uno-Objects
    3248         [ #  # ]:          0 :     SbxVariableRef xParam1 = rPar.Get( 1 );
    3249 [ #  # ][ #  # ]:          0 :     if( !xParam1->IsObject() )
    3250                 :            :         return;
    3251         [ #  # ]:          0 :     SbxBaseRef pObj1 = (SbxBase*)xParam1->GetObject();
    3252 [ #  # ][ #  # ]:          0 :     if( !(pObj1 && pObj1->ISA(SbUnoObject)) )
         [ #  # ][ #  # ]
    3253                 :            :         return;
    3254         [ #  # ]:          0 :     Any aAny1 = ((SbUnoObject*)(SbxBase*)pObj1)->getUnoAny();
    3255                 :          0 :     TypeClass eType1 = aAny1.getValueType().getTypeClass();
    3256         [ #  # ]:          0 :     if( eType1 != TypeClass_INTERFACE )
    3257                 :            :         return;
    3258                 :          0 :     Reference< XInterface > x1;
    3259         [ #  # ]:          0 :     aAny1 >>= x1;
    3260                 :            : 
    3261         [ #  # ]:          0 :     SbxVariableRef xParam2 = rPar.Get( 2 );
    3262 [ #  # ][ #  # ]:          0 :     if( !xParam2->IsObject() )
    3263                 :            :         return;
    3264         [ #  # ]:          0 :     SbxBaseRef pObj2 = (SbxBase*)xParam2->GetObject();
    3265 [ #  # ][ #  # ]:          0 :     if( !(pObj2 && pObj2->ISA(SbUnoObject)) )
         [ #  # ][ #  # ]
    3266                 :            :         return;
    3267         [ #  # ]:          0 :     Any aAny2 = ((SbUnoObject*)(SbxBase*)pObj2)->getUnoAny();
    3268                 :          0 :     TypeClass eType2 = aAny2.getValueType().getTypeClass();
    3269         [ #  # ]:          0 :     if( eType2 != TypeClass_INTERFACE )
    3270                 :            :         return;
    3271                 :          0 :     Reference< XInterface > x2;
    3272         [ #  # ]:          0 :     aAny2 >>= x2;
    3273                 :            : 
    3274 [ #  # ][ #  # ]:          0 :     if( x1 == x2 )
    3275 [ #  # ][ #  # ]:          0 :         refVar->PutBool( sal_True );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    3276                 :            : }
    3277                 :            : 
    3278                 :            : 
    3279                 :            : // helper wrapper function to interact with TypeProvider and
    3280                 :            : // XTypeDescriptionEnumerationAccess.
    3281                 :            : // if it fails for whatever reason
    3282                 :            : // returned Reference<> be null e.g. .is() will be false
    3283                 :            : 
    3284                 :            : Reference< XTypeDescriptionEnumeration >
    3285                 :          5 : getTypeDescriptorEnumeration( const ::rtl::OUString& sSearchRoot,
    3286                 :            :     const Sequence< TypeClass >& types, TypeDescriptionSearchDepth depth )
    3287                 :            : {
    3288                 :          5 :     Reference< XTypeDescriptionEnumeration > xEnum;
    3289 [ +  - ][ +  - ]:          5 :     Reference< XTypeDescriptionEnumerationAccess> xTypeEnumAccess( getTypeProvider_Impl(), UNO_QUERY );
    3290         [ +  - ]:          5 :     if ( xTypeEnumAccess.is() )
    3291                 :            :     {
    3292                 :            :         try
    3293                 :            :         {
    3294         [ +  - ]:          5 :             xEnum = xTypeEnumAccess->createTypeDescriptionEnumeration(
    3295 [ +  - ][ +  - ]:          5 :                 sSearchRoot, types, depth );
              [ #  #  # ]
    3296                 :            :         }
    3297         [ #  # ]:          0 :         catch(const NoSuchTypeNameException& /*nstne*/ ) {}
    3298         [ #  # ]:          0 :         catch(const InvalidTypeNameException& /*nstne*/ ) {}
    3299                 :            :     }
    3300                 :          5 :     return xEnum;
    3301                 :            : }
    3302                 :            : 
    3303                 :            : typedef boost::unordered_map< ::rtl::OUString, Any, ::rtl::OUStringHash, ::std::equal_to< ::rtl::OUString > > VBAConstantsHash;
    3304                 :            : 
    3305                 :            : VBAConstantHelper&
    3306                 :         14 : VBAConstantHelper::instance()
    3307                 :            : {
    3308 [ +  + ][ +  - ]:         14 :     static VBAConstantHelper aHelper;
         [ +  - ][ #  # ]
    3309                 :         14 :     return aHelper;
    3310                 :            : }
    3311                 :            : 
    3312                 :            : void
    3313                 :         14 : VBAConstantHelper::init()
    3314                 :            : {
    3315         [ +  + ]:         14 :     if ( !isInited )
    3316                 :            :     {
    3317         [ +  - ]:          5 :         Sequence< TypeClass > types(1);
    3318         [ +  - ]:          5 :         types[ 0 ] = TypeClass_CONSTANTS;
    3319         [ +  - ]:          5 :         Reference< XTypeDescriptionEnumeration > xEnum = getTypeDescriptorEnumeration( rtl::OUString(defaultNameSpace), types, TypeDescriptionSearchDepth_INFINITE  );
    3320                 :            : 
    3321         [ -  + ]:          5 :         if ( !xEnum.is() )
    3322                 :         14 :             return; //NULL;
    3323                 :            : 
    3324 [ +  - ][ +  - ]:       1657 :         while ( xEnum->hasMoreElements() )
                 [ +  + ]
    3325                 :            :         {
    3326 [ +  - ][ +  - ]:       1652 :             Reference< XConstantsTypeDescription > xConstants( xEnum->nextElement(), UNO_QUERY );
                 [ +  - ]
    3327         [ +  - ]:       1652 :             if ( xConstants.is() )
    3328                 :            :             {
    3329                 :            :                 // store constant group name
    3330 [ +  - ][ +  - ]:       1652 :                 ::rtl::OUString sFullName = xConstants->getName();
    3331                 :       1652 :                 sal_Int32 indexLastDot = sFullName.lastIndexOf('.');
    3332                 :       1652 :                 ::rtl::OUString sLeafName( sFullName );
    3333         [ +  - ]:       1652 :                 if ( indexLastDot > -1 )
    3334                 :       1652 :                     sLeafName = sFullName.copy( indexLastDot + 1);
    3335         [ +  - ]:       1652 :                 aConstCache.push_back( sLeafName ); // assume constant group names are unique
    3336 [ +  - ][ +  - ]:       1652 :                 Sequence< Reference< XConstantTypeDescription > > aConsts = xConstants->getConstants();
    3337         [ +  - ]:       1652 :                 Reference< XConstantTypeDescription >* pSrc = aConsts.getArray();
    3338                 :       1652 :                 sal_Int32 nLen = aConsts.getLength();
    3339         [ +  + ]:      18400 :                 for ( sal_Int32 index =0;  index<nLen; ++pSrc, ++index )
    3340                 :            :                 {
    3341                 :            :                     // store constant member name
    3342                 :            :                     Reference< XConstantTypeDescription >& rXConst =
    3343                 :      16748 :                         *pSrc;
    3344 [ +  - ][ +  - ]:      16748 :                     sFullName = rXConst->getName();
    3345                 :      16748 :                     indexLastDot = sFullName.lastIndexOf('.');
    3346                 :      16748 :                     sLeafName = sFullName;
    3347         [ +  - ]:      16748 :                     if ( indexLastDot > -1 )
    3348                 :      16748 :                         sLeafName = sFullName.copy( indexLastDot + 1);
    3349 [ +  - ][ +  - ]:      16748 :                     aConstHash[ sLeafName.toAsciiLowerCase() ] = rXConst->getConstantValue();
                 [ +  - ]
    3350         [ +  - ]:       1652 :                 }
    3351                 :            :             }
    3352                 :       1652 :         }
    3353 [ -  + ][ +  - ]:          5 :         isInited = true;
                 [ +  - ]
    3354                 :            :     }
    3355                 :            : }
    3356                 :            : 
    3357                 :            : bool
    3358                 :          6 : VBAConstantHelper::isVBAConstantType( const ::rtl::OUString& rName )
    3359                 :            : {
    3360         [ +  - ]:          6 :     init();
    3361                 :          6 :     bool bConstant = false;
    3362                 :          6 :     ::rtl::OUString sKey( rName );
    3363         [ +  - ]:          6 :     VBAConstantsVector::const_iterator it = aConstCache.begin();
    3364                 :            : 
    3365 [ +  - ][ -  + ]:          6 :     for( ; it != aConstCache.end(); ++it )
    3366                 :            :     {
    3367         [ #  # ]:          0 :         if( sKey.equalsIgnoreAsciiCase( *it ) )
    3368                 :            :         {
    3369                 :          0 :             bConstant = true;
    3370                 :          0 :             break;
    3371                 :            :         }
    3372                 :            :     }
    3373                 :          6 :     return bConstant;
    3374                 :            : }
    3375                 :            : 
    3376                 :            : SbxVariable*
    3377                 :          8 : VBAConstantHelper::getVBAConstant( const ::rtl::OUString& rName )
    3378                 :            : {
    3379                 :          8 :     SbxVariable* pConst = NULL;
    3380         [ +  - ]:          8 :     init();
    3381                 :            : 
    3382                 :          8 :     ::rtl::OUString sKey( rName );
    3383                 :            : 
    3384         [ +  - ]:          8 :     VBAConstantsHash::const_iterator it = aConstHash.find( sKey.toAsciiLowerCase() );
    3385                 :            : 
    3386 [ +  + ][ +  - ]:          8 :     if ( it != aConstHash.end() )
    3387                 :            :     {
    3388 [ +  - ][ +  - ]:          2 :         pConst = new SbxVariable( SbxVARIANT );
    3389 [ +  - ][ +  - ]:          2 :         pConst->SetName( rName );
                 [ +  - ]
    3390 [ +  - ][ +  - ]:          2 :         unoToSbxValue( pConst, it->second );
    3391                 :            :     }
    3392                 :            : 
    3393                 :          8 :     return pConst;
    3394                 :            : }
    3395                 :            : 
    3396                 :            : // Function to search for a global identifier in the
    3397                 :            : // UnoScope and to wrap it for Sbx
    3398                 :        101 : SbUnoClass* findUnoClass( const ::rtl::OUString& rName )
    3399                 :            : {
    3400                 :            :     // #105550 Check if module exists
    3401                 :        101 :     SbUnoClass* pUnoClass = NULL;
    3402                 :            : 
    3403         [ +  - ]:        101 :     Reference< XHierarchicalNameAccess > xTypeAccess = getTypeProvider_Impl();
    3404 [ +  - ][ +  - ]:        101 :     if( xTypeAccess->hasByHierarchicalName( rName ) )
                 [ +  + ]
    3405                 :            :     {
    3406 [ +  - ][ +  - ]:         10 :         Any aRet = xTypeAccess->getByHierarchicalName( rName );
    3407                 :         10 :         Reference< XTypeDescription > xTypeDesc;
    3408         [ +  - ]:         10 :         aRet >>= xTypeDesc;
    3409                 :            : 
    3410         [ +  - ]:         10 :         if( xTypeDesc.is() )
    3411                 :            :         {
    3412 [ +  - ][ +  - ]:         10 :             TypeClass eTypeClass = xTypeDesc->getTypeClass();
    3413 [ +  + ][ +  - ]:         10 :             if( eTypeClass == TypeClass_MODULE || eTypeClass == TypeClass_CONSTANTS )
    3414 [ +  - ][ +  - ]:         10 :                 pUnoClass = new SbUnoClass( rName );
         [ +  - ][ +  - ]
    3415                 :         10 :         }
    3416                 :            :     }
    3417                 :        101 :     return pUnoClass;
    3418                 :            : }
    3419                 :            : 
    3420                 :         10 : SbxVariable* SbUnoClass::Find( const rtl::OUString& rName, SbxClassType )
    3421                 :            : {
    3422                 :         10 :     SbxVariable* pRes = SbxObject::Find( rName, SbxCLASS_VARIABLE );
    3423                 :            : 
    3424                 :            :     // If nothing were located the submodule isn't known yet
    3425         [ +  - ]:         10 :     if( !pRes )
    3426                 :            :     {
    3427                 :            :         // If it is already a class, ask for the field
    3428         [ -  + ]:         10 :         if( m_xClass.is() )
    3429                 :            :         {
    3430                 :            :             // Is it a field(?)
    3431                 :          0 :             ::rtl::OUString aUStr( rName );
    3432 [ #  # ][ #  # ]:          0 :             Reference< XIdlField > xField = m_xClass->getField( aUStr );
    3433                 :          0 :             Reference< XIdlClass > xClass;
    3434         [ #  # ]:          0 :             if( xField.is() )
    3435                 :            :             {
    3436                 :            :                 try
    3437                 :            :                 {
    3438                 :          0 :                     Any aAny;
    3439 [ #  # ][ #  # ]:          0 :                     aAny = xField->get( aAny );
    3440                 :            : 
    3441                 :            :                     // Convert to Sbx
    3442 [ #  # ][ #  # ]:          0 :                     pRes = new SbxVariable( SbxVARIANT );
    3443 [ #  # ][ #  # ]:          0 :                     pRes->SetName( rName );
                 [ #  # ]
    3444         [ #  # ]:          0 :                     unoToSbxValue( pRes, aAny );
    3445                 :            :                 }
    3446   [ #  #  #  # ]:          0 :                 catch( const Exception& )
    3447                 :            :                 {
    3448   [ #  #  #  # ]:          0 :                     implHandleAnyException( ::cppu::getCaughtException() );
    3449                 :            :                 }
    3450                 :          0 :             }
    3451                 :            :         }
    3452                 :            :         else
    3453                 :            :         {
    3454                 :            :             // expand fully qualified name
    3455 [ +  - ][ +  - ]:         10 :             ::rtl::OUString aNewName = GetName();
    3456                 :         10 :             aNewName += ::rtl::OUString(".");
    3457                 :         10 :             aNewName += rName;
    3458                 :            : 
    3459                 :            :             // get CoreReflection
    3460         [ +  - ]:         10 :             Reference< XIdlReflection > xCoreReflection = getCoreReflection_Impl();
    3461         [ +  - ]:         10 :             if( xCoreReflection.is() )
    3462                 :            :             {
    3463                 :            :                 // Is it a constant?
    3464         [ +  - ]:         10 :                 Reference< XHierarchicalNameAccess > xHarryName( xCoreReflection, UNO_QUERY );
    3465         [ +  - ]:         10 :                 if( xHarryName.is() )
    3466                 :            :                 {
    3467                 :            :                     try
    3468                 :            :                     {
    3469 [ +  - ][ +  + ]:         10 :                         Any aValue = xHarryName->getByHierarchicalName( aNewName );
    3470                 :          2 :                         TypeClass eType = aValue.getValueType().getTypeClass();
    3471                 :            : 
    3472                 :            :                         // Interface located? Then it is a class
    3473         [ -  + ]:          2 :                         if( eType == TypeClass_INTERFACE )
    3474                 :            :                         {
    3475                 :          0 :                             Reference< XInterface > xIface = *(Reference< XInterface >*)aValue.getValue();
    3476         [ #  # ]:          0 :                             Reference< XIdlClass > xClass( xIface, UNO_QUERY );
    3477         [ #  # ]:          0 :                             if( xClass.is() )
    3478                 :            :                             {
    3479 [ #  # ][ #  # ]:          0 :                                 pRes = new SbxVariable( SbxVARIANT );
    3480 [ #  # ][ #  # ]:          0 :                                 SbxObjectRef xWrapper = (SbxObject*)new SbUnoClass( aNewName, xClass );
         [ #  # ][ #  # ]
    3481 [ #  # ][ #  # ]:          0 :                                 pRes->PutObject( xWrapper );
    3482                 :          0 :                             }
    3483                 :            :                         }
    3484                 :            :                         else
    3485                 :            :                         {
    3486 [ +  - ][ +  - ]:          2 :                             pRes = new SbxVariable( SbxVARIANT );
    3487         [ +  - ]:          2 :                             unoToSbxValue( pRes, aValue );
    3488         [ -  + ]:         10 :                         }
    3489                 :            :                     }
    3490         [ +  - ]:          8 :                     catch( const NoSuchElementException& )
    3491                 :            :                     {
    3492                 :            :                     }
    3493                 :            :                 }
    3494                 :            : 
    3495                 :            :                 // Otherwise take it again as class
    3496         [ +  + ]:         10 :                 if( !pRes )
    3497                 :            :                 {
    3498         [ +  - ]:          8 :                     SbUnoClass* pNewClass = findUnoClass( aNewName );
    3499         [ +  - ]:          8 :                     if( pNewClass )
    3500                 :            :                     {
    3501 [ +  - ][ +  - ]:          8 :                         pRes = new SbxVariable( SbxVARIANT );
    3502                 :          8 :                         SbxObjectRef xWrapper = (SbxObject*)pNewClass;
    3503 [ +  - ][ +  - ]:          8 :                         pRes->PutObject( xWrapper );
    3504                 :            :                     }
    3505                 :            :                 }
    3506                 :            : 
    3507                 :            :                 // An UNO service?
    3508         [ -  + ]:         10 :                 if( !pRes )
    3509                 :            :                 {
    3510         [ #  # ]:          0 :                     SbUnoService* pUnoService = findUnoService( aNewName );
    3511         [ #  # ]:          0 :                     if( pUnoService )
    3512                 :            :                     {
    3513 [ #  # ][ #  # ]:          0 :                         pRes = new SbxVariable( SbxVARIANT );
    3514                 :          0 :                         SbxObjectRef xWrapper = (SbxObject*)pUnoService;
    3515 [ #  # ][ #  # ]:          0 :                         pRes->PutObject( xWrapper );
    3516                 :            :                     }
    3517                 :            :                 }
    3518                 :            : 
    3519                 :            :                 // An UNO singleton?
    3520         [ -  + ]:         10 :                 if( !pRes )
    3521                 :            :                 {
    3522         [ #  # ]:          0 :                     SbUnoSingleton* pUnoSingleton = findUnoSingleton( aNewName );
    3523         [ #  # ]:          0 :                     if( pUnoSingleton )
    3524                 :            :                     {
    3525 [ #  # ][ #  # ]:          0 :                         pRes = new SbxVariable( SbxVARIANT );
    3526                 :          0 :                         SbxObjectRef xWrapper = (SbxObject*)pUnoSingleton;
    3527 [ #  # ][ #  # ]:          0 :                         pRes->PutObject( xWrapper );
    3528                 :            :                     }
    3529                 :         10 :                 }
    3530                 :         10 :             }
    3531                 :            :         }
    3532                 :            : 
    3533         [ +  - ]:         10 :         if( pRes )
    3534                 :            :         {
    3535         [ +  - ]:         10 :             pRes->SetName( rName );
    3536                 :            : 
    3537                 :            :             // Insert variable, so that it could be found later
    3538                 :         10 :             QuickInsert( pRes );
    3539                 :            : 
    3540                 :            :             // Take us out as listener at once,
    3541                 :            :             // the values are all constant
    3542         [ +  - ]:         10 :             if( pRes->IsBroadcaster() )
    3543                 :         10 :                 EndListening( pRes->GetBroadcaster(), sal_True );
    3544                 :            :         }
    3545                 :            :     }
    3546                 :         10 :     return pRes;
    3547                 :            : }
    3548                 :            : 
    3549                 :            : 
    3550                 :          0 : SbUnoService* findUnoService( const ::rtl::OUString& rName )
    3551                 :            : {
    3552                 :          0 :     SbUnoService* pSbUnoService = NULL;
    3553                 :            : 
    3554         [ #  # ]:          0 :     Reference< XHierarchicalNameAccess > xTypeAccess = getTypeProvider_Impl();
    3555 [ #  # ][ #  # ]:          0 :     if( xTypeAccess->hasByHierarchicalName( rName ) )
                 [ #  # ]
    3556                 :            :     {
    3557 [ #  # ][ #  # ]:          0 :         Any aRet = xTypeAccess->getByHierarchicalName( rName );
    3558                 :          0 :         Reference< XTypeDescription > xTypeDesc;
    3559         [ #  # ]:          0 :         aRet >>= xTypeDesc;
    3560                 :            : 
    3561         [ #  # ]:          0 :         if( xTypeDesc.is() )
    3562                 :            :         {
    3563 [ #  # ][ #  # ]:          0 :             TypeClass eTypeClass = xTypeDesc->getTypeClass();
    3564         [ #  # ]:          0 :             if( eTypeClass == TypeClass_SERVICE )
    3565                 :            :             {
    3566         [ #  # ]:          0 :                 Reference< XServiceTypeDescription2 > xServiceTypeDesc( xTypeDesc, UNO_QUERY );
    3567         [ #  # ]:          0 :                 if( xServiceTypeDesc.is() )
    3568 [ #  # ][ #  # ]:          0 :                     pSbUnoService = new SbUnoService( rName, xServiceTypeDesc );
         [ #  # ][ #  # ]
    3569                 :            :             }
    3570                 :          0 :         }
    3571                 :            :     }
    3572                 :          0 :     return pSbUnoService;
    3573                 :            : }
    3574                 :            : 
    3575                 :          0 : SbxVariable* SbUnoService::Find( const rtl::OUString& rName, SbxClassType )
    3576                 :            : {
    3577                 :          0 :     SbxVariable* pRes = SbxObject::Find( rName, SbxCLASS_METHOD );
    3578                 :            : 
    3579         [ #  # ]:          0 :     if( !pRes )
    3580                 :            :     {
    3581                 :            :         // If it is already a class ask for a field
    3582 [ #  # ][ #  # ]:          0 :         if( m_bNeedsInit && m_xServiceTypeDesc.is() )
                 [ #  # ]
    3583                 :            :         {
    3584                 :          0 :             m_bNeedsInit = false;
    3585                 :            : 
    3586 [ #  # ][ #  # ]:          0 :             Sequence< Reference< XServiceConstructorDescription > > aSCDSeq = m_xServiceTypeDesc->getConstructors();
    3587                 :          0 :             const Reference< XServiceConstructorDescription >* pCtorSeq = aSCDSeq.getConstArray();
    3588                 :          0 :             int nCtorCount = aSCDSeq.getLength();
    3589         [ #  # ]:          0 :             for( int i = 0 ; i < nCtorCount ; ++i )
    3590                 :            :             {
    3591                 :          0 :                 Reference< XServiceConstructorDescription > xCtor = pCtorSeq[i];
    3592                 :            : 
    3593 [ #  # ][ #  # ]:          0 :                 ::rtl::OUString aName( xCtor->getName() );
    3594         [ #  # ]:          0 :                 if( aName.isEmpty() )
    3595                 :            :                 {
    3596 [ #  # ][ #  # ]:          0 :                     if( xCtor->isDefaultConstructor() )
                 [ #  # ]
    3597                 :          0 :                         aName = ::rtl::OUString("create");
    3598                 :            :                 }
    3599                 :            : 
    3600         [ #  # ]:          0 :                 if( !aName.isEmpty() )
    3601                 :            :                 {
    3602                 :            :                     // Create and insert SbUnoServiceCtor
    3603 [ #  # ][ #  # ]:          0 :                     SbxVariableRef xSbCtorRef = new SbUnoServiceCtor( aName, xCtor );
    3604 [ #  # ][ #  # ]:          0 :                     QuickInsert( (SbxVariable*)xSbCtorRef );
    3605                 :            :                 }
    3606                 :          0 :             }
    3607                 :            : 
    3608 [ #  # ][ #  # ]:          0 :             pRes = SbxObject::Find( rName, SbxCLASS_METHOD );
    3609                 :            :         }
    3610                 :            :     }
    3611                 :            : 
    3612                 :          0 :     return pRes;
    3613                 :            : }
    3614                 :            : 
    3615                 :          0 : void SbUnoService::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType,
    3616                 :            :                            const SfxHint& rHint, const TypeId& rHintType )
    3617                 :            : {
    3618 [ #  # ][ #  # ]:          0 :     const SbxHint* pHint = PTR_CAST(SbxHint,&rHint);
    3619         [ #  # ]:          0 :     if( pHint )
    3620                 :            :     {
    3621                 :          0 :         SbxVariable* pVar = pHint->GetVar();
    3622                 :          0 :         SbxArray* pParams = pVar->GetParameters();
    3623 [ #  # ][ #  # ]:          0 :         SbUnoServiceCtor* pUnoCtor = PTR_CAST(SbUnoServiceCtor,pVar);
    3624 [ #  # ][ #  # ]:          0 :         if( pUnoCtor && pHint->GetId() == SBX_HINT_DATAWANTED )
                 [ #  # ]
    3625                 :            :         {
    3626                 :            :             // Parameter count -1 because of Param0 == this
    3627 [ #  # ][ #  # ]:          0 :             sal_uInt32 nParamCount = pParams ? ((sal_uInt32)pParams->Count() - 1) : 0;
    3628         [ #  # ]:          0 :             Sequence<Any> args;
    3629                 :          0 :             sal_Bool bOutParams = sal_False;
    3630                 :            : 
    3631         [ #  # ]:          0 :             Reference< XServiceConstructorDescription > xCtor = pUnoCtor->getServiceCtorDesc();
    3632 [ #  # ][ #  # ]:          0 :             Sequence< Reference< XParameter > > aParameterSeq = xCtor->getParameters();
    3633                 :          0 :             const Reference< XParameter >* pParameterSeq = aParameterSeq.getConstArray();
    3634                 :          0 :             sal_uInt32 nUnoParamCount = aParameterSeq.getLength();
    3635                 :            : 
    3636                 :            :             // Default: Ignore not needed parameters
    3637                 :          0 :             bool bParameterError = false;
    3638                 :            : 
    3639                 :            :             // Is the last parameter a rest parameter?
    3640                 :          0 :             bool bRestParameterMode = false;
    3641         [ #  # ]:          0 :             if( nUnoParamCount > 0 )
    3642                 :            :             {
    3643                 :          0 :                 Reference< XParameter > xLastParam = pParameterSeq[ nUnoParamCount - 1 ];
    3644         [ #  # ]:          0 :                 if( xLastParam.is() )
    3645                 :            :                 {
    3646 [ #  # ][ #  # ]:          0 :                     if( xLastParam->isRestParameter() )
                 [ #  # ]
    3647                 :          0 :                         bRestParameterMode = true;
    3648                 :          0 :                 }
    3649                 :            :             }
    3650                 :            : 
    3651                 :            :             // Too many parameters with context as first parameter?
    3652                 :          0 :             sal_uInt16 nSbxParameterOffset = 1;
    3653                 :          0 :             sal_uInt16 nParameterOffsetByContext = 0;
    3654                 :          0 :             Reference < XComponentContext > xFirstParamContext;
    3655         [ #  # ]:          0 :             if( nParamCount > nUnoParamCount )
    3656                 :            :             {
    3657                 :            :                 // Check if first parameter is a context and use it
    3658                 :            :                 // then in createInstanceWithArgumentsAndContext
    3659 [ #  # ][ #  # ]:          0 :                 Any aArg0 = sbxToUnoValue( pParams->Get( nSbxParameterOffset ) );
    3660 [ #  # ][ #  # ]:          0 :                 if( (aArg0 >>= xFirstParamContext) && xFirstParamContext.is() )
         [ #  # ][ #  # ]
    3661                 :          0 :                     nParameterOffsetByContext = 1;
    3662                 :            :             }
    3663                 :            : 
    3664                 :          0 :             sal_uInt32 nEffectiveParamCount = nParamCount - nParameterOffsetByContext;
    3665                 :          0 :             sal_uInt32 nAllocParamCount = nEffectiveParamCount;
    3666         [ #  # ]:          0 :             if( nEffectiveParamCount > nUnoParamCount )
    3667                 :            :             {
    3668         [ #  # ]:          0 :                 if( !bRestParameterMode )
    3669                 :            :                 {
    3670                 :          0 :                     nEffectiveParamCount = nUnoParamCount;
    3671                 :          0 :                     nAllocParamCount = nUnoParamCount;
    3672                 :            :                 }
    3673                 :            :             }
    3674                 :            :             // Not enough parameters?
    3675         [ #  # ]:          0 :             else if( nUnoParamCount > nEffectiveParamCount )
    3676                 :            :             {
    3677                 :            :                 // RestParameterMode only helps if one (the last) parameter is missing
    3678                 :          0 :                 int nDiff = nUnoParamCount - nEffectiveParamCount;
    3679 [ #  # ][ #  # ]:          0 :                 if( !bRestParameterMode || nDiff > 1 )
    3680                 :            :                 {
    3681                 :          0 :                     bParameterError = true;
    3682         [ #  # ]:          0 :                     StarBASIC::Error( SbERR_NOT_OPTIONAL );
    3683                 :            :                 }
    3684                 :            :             }
    3685                 :            : 
    3686         [ #  # ]:          0 :             if( !bParameterError )
    3687                 :            :             {
    3688         [ #  # ]:          0 :                 if( nAllocParamCount > 0 )
    3689                 :            :                 {
    3690         [ #  # ]:          0 :                     args.realloc( nAllocParamCount );
    3691         [ #  # ]:          0 :                     Any* pAnyArgs = args.getArray();
    3692         [ #  # ]:          0 :                     for( sal_uInt32 i = 0 ; i < nEffectiveParamCount ; i++ )
    3693                 :            :                     {
    3694                 :          0 :                         sal_uInt16 iSbx = (sal_uInt16)(i + nSbxParameterOffset + nParameterOffsetByContext);
    3695                 :            : 
    3696                 :            :                         // bRestParameterMode allows nEffectiveParamCount > nUnoParamCount
    3697                 :          0 :                         Reference< XParameter > xParam;
    3698         [ #  # ]:          0 :                         if( i < nUnoParamCount )
    3699                 :            :                         {
    3700         [ #  # ]:          0 :                             xParam = pParameterSeq[i];
    3701         [ #  # ]:          0 :                             if( !xParam.is() )
    3702                 :          0 :                                 continue;
    3703                 :            : 
    3704 [ #  # ][ #  # ]:          0 :                             Reference< XTypeDescription > xParamTypeDesc = xParam->getType();
    3705         [ #  # ]:          0 :                             if( !xParamTypeDesc.is() )
    3706                 :          0 :                                 continue;
    3707 [ #  # ][ #  # ]:          0 :                             com::sun::star::uno::Type aType( xParamTypeDesc->getTypeClass(), xParamTypeDesc->getName() );
         [ #  # ][ #  # ]
    3708                 :            : 
    3709                 :            :                             // sbx paramter needs offset 1
    3710 [ #  # ][ #  # ]:          0 :                             pAnyArgs[i] = sbxToUnoValue( pParams->Get( iSbx ), aType );
    3711                 :            : 
    3712                 :            :                             // Check for out parameter if not already done
    3713         [ #  # ]:          0 :                             if( !bOutParams )
    3714                 :            :                             {
    3715 [ #  # ][ #  # ]:          0 :                                 if( xParam->isOut() )
                 [ #  # ]
    3716                 :          0 :                                     bOutParams = sal_True;
    3717         [ #  # ]:          0 :                             }
    3718                 :            :                         }
    3719                 :            :                         else
    3720                 :            :                         {
    3721 [ #  # ][ #  # ]:          0 :                             pAnyArgs[i] = sbxToUnoValue( pParams->Get( iSbx ) );
    3722                 :            :                         }
    3723         [ #  # ]:          0 :                     }
    3724                 :            :                 }
    3725                 :            : 
    3726                 :            :                 // "Call" ctor using createInstanceWithArgumentsAndContext
    3727                 :          0 :                 Reference < XComponentContext > xContext;
    3728         [ #  # ]:          0 :                 if( xFirstParamContext.is() )
    3729                 :            :                 {
    3730         [ #  # ]:          0 :                     xContext = xFirstParamContext;
    3731                 :            :                 }
    3732                 :            :                 else
    3733                 :            :                 {
    3734 [ #  # ][ #  # ]:          0 :                     Reference < XPropertySet > xProps( ::comphelper::getProcessServiceFactory(), UNO_QUERY_THROW );
    3735 [ #  # ][ #  # ]:          0 :                     xContext.set( xProps->getPropertyValue( rtl::OUString( "DefaultContext" ) ), UNO_QUERY_THROW );
                 [ #  # ]
    3736                 :            :                 }
    3737 [ #  # ][ #  # ]:          0 :                 Reference< XMultiComponentFactory > xServiceMgr( xContext->getServiceManager() );
    3738                 :            : 
    3739                 :          0 :                 Any aRetAny;
    3740         [ #  # ]:          0 :                 if( xServiceMgr.is() )
    3741                 :            :                 {
    3742 [ #  # ][ #  # ]:          0 :                     ::rtl::OUString aServiceName = GetName();
    3743                 :          0 :                     Reference < XInterface > xRet;
    3744                 :            :                     try
    3745                 :            :                     {
    3746 [ #  # ][ #  # ]:          0 :                         xRet = xServiceMgr->createInstanceWithArgumentsAndContext( aServiceName, args, xContext );
                 [ #  # ]
    3747                 :            :                     }
    3748   [ #  #  #  # ]:          0 :                     catch( const Exception& )
    3749                 :            :                     {
    3750   [ #  #  #  # ]:          0 :                         implHandleAnyException( ::cppu::getCaughtException() );
    3751                 :            :                     }
    3752         [ #  # ]:          0 :                     aRetAny <<= xRet;
    3753                 :            :                 }
    3754         [ #  # ]:          0 :                 unoToSbxValue( pVar, aRetAny );
    3755                 :            : 
    3756                 :            :                 // Copy back out parameters?
    3757         [ #  # ]:          0 :                 if( bOutParams )
    3758                 :            :                 {
    3759                 :          0 :                     const Any* pAnyArgs = args.getConstArray();
    3760                 :            : 
    3761         [ #  # ]:          0 :                     for( sal_uInt32 j = 0 ; j < nUnoParamCount ; j++ )
    3762                 :            :                     {
    3763                 :          0 :                         Reference< XParameter > xParam = pParameterSeq[j];
    3764         [ #  # ]:          0 :                         if( !xParam.is() )
    3765                 :          0 :                             continue;
    3766                 :            : 
    3767 [ #  # ][ #  # ]:          0 :                         if( xParam->isOut() )
                 [ #  # ]
    3768 [ #  # ][ #  # ]:          0 :                             unoToSbxValue( (SbxVariable*)pParams->Get( (sal_uInt16)(j+1) ), pAnyArgs[ j ] );
    3769         [ #  # ]:          0 :                     }
    3770                 :          0 :                 }
    3771 [ #  # ][ #  # ]:          0 :             }
    3772                 :            :         }
    3773                 :            :         else
    3774                 :          0 :             SbxObject::SFX_NOTIFY( rBC, rBCType, rHint, rHintType );
    3775                 :            :     }
    3776                 :          0 : }
    3777                 :            : 
    3778                 :            : 
    3779                 :            : 
    3780                 :            : static SbUnoServiceCtor* pFirstCtor = NULL;
    3781                 :            : 
    3782                 :         31 : void clearUnoServiceCtors( void )
    3783                 :            : {
    3784                 :         31 :     SbUnoServiceCtor* pCtor = pFirstCtor;
    3785         [ -  + ]:         31 :     while( pCtor )
    3786                 :            :     {
    3787                 :          0 :         pCtor->SbxValue::Clear();
    3788                 :          0 :         pCtor = pCtor->pNext;
    3789                 :            :     }
    3790                 :         31 : }
    3791                 :            : 
    3792                 :          0 : SbUnoServiceCtor::SbUnoServiceCtor( const ::rtl::OUString& aName_, Reference< XServiceConstructorDescription > xServiceCtorDesc )
    3793                 :            :     : SbxMethod( aName_, SbxOBJECT )
    3794 [ #  # ][ #  # ]:          0 :     , m_xServiceCtorDesc( xServiceCtorDesc )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    3795                 :            : {
    3796                 :          0 : }
    3797                 :            : 
    3798 [ #  # ][ #  # ]:          0 : SbUnoServiceCtor::~SbUnoServiceCtor()
    3799                 :            : {
    3800 [ #  # ][ #  # ]:          0 : }
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    3801                 :            : 
    3802                 :          0 : SbxInfo* SbUnoServiceCtor::GetInfo()
    3803                 :            : {
    3804                 :          0 :     SbxInfo* pRet = NULL;
    3805                 :            : 
    3806                 :          0 :     return pRet;
    3807                 :            : }
    3808                 :            : 
    3809                 :            : 
    3810                 :          0 : SbUnoSingleton* findUnoSingleton( const ::rtl::OUString& rName )
    3811                 :            : {
    3812                 :          0 :     SbUnoSingleton* pSbUnoSingleton = NULL;
    3813                 :            : 
    3814         [ #  # ]:          0 :     Reference< XHierarchicalNameAccess > xTypeAccess = getTypeProvider_Impl();
    3815 [ #  # ][ #  # ]:          0 :     if( xTypeAccess->hasByHierarchicalName( rName ) )
                 [ #  # ]
    3816                 :            :     {
    3817 [ #  # ][ #  # ]:          0 :         Any aRet = xTypeAccess->getByHierarchicalName( rName );
    3818                 :          0 :         Reference< XTypeDescription > xTypeDesc;
    3819         [ #  # ]:          0 :         aRet >>= xTypeDesc;
    3820                 :            : 
    3821         [ #  # ]:          0 :         if( xTypeDesc.is() )
    3822                 :            :         {
    3823 [ #  # ][ #  # ]:          0 :             TypeClass eTypeClass = xTypeDesc->getTypeClass();
    3824         [ #  # ]:          0 :             if( eTypeClass == TypeClass_SINGLETON )
    3825                 :            :             {
    3826         [ #  # ]:          0 :                 Reference< XSingletonTypeDescription > xSingletonTypeDesc( xTypeDesc, UNO_QUERY );
    3827         [ #  # ]:          0 :                 if( xSingletonTypeDesc.is() )
    3828 [ #  # ][ #  # ]:          0 :                     pSbUnoSingleton = new SbUnoSingleton( rName, xSingletonTypeDesc );
    3829                 :            :             }
    3830                 :          0 :         }
    3831                 :            :     }
    3832                 :          0 :     return pSbUnoSingleton;
    3833                 :            : }
    3834                 :            : 
    3835                 :          0 : SbUnoSingleton::SbUnoSingleton( const ::rtl::OUString& aName_,
    3836                 :            :     const Reference< XSingletonTypeDescription >& xSingletonTypeDesc )
    3837                 :            :         : SbxObject( aName_ )
    3838 [ #  # ][ #  # ]:          0 :         , m_xSingletonTypeDesc( xSingletonTypeDesc )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    3839                 :            : {
    3840                 :            :     SbxVariableRef xGetMethodRef =
    3841 [ #  # ][ #  # ]:          0 :         new SbxMethod( ::rtl::OUString( "get"  ), SbxOBJECT );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    3842   [ #  #  #  # ]:          0 :     QuickInsert( (SbxVariable*)xGetMethodRef );
         [ #  # ][ #  # ]
    3843                 :          0 : }
    3844                 :            : 
    3845                 :          0 : void SbUnoSingleton::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType,
    3846                 :            :                            const SfxHint& rHint, const TypeId& rHintType )
    3847                 :            : {
    3848 [ #  # ][ #  # ]:          0 :     const SbxHint* pHint = PTR_CAST(SbxHint,&rHint);
    3849         [ #  # ]:          0 :     if( pHint )
    3850                 :            :     {
    3851                 :          0 :         SbxVariable* pVar = pHint->GetVar();
    3852         [ #  # ]:          0 :         SbxArray* pParams = pVar->GetParameters();
    3853 [ #  # ][ #  # ]:          0 :         sal_uInt32 nParamCount = pParams ? ((sal_uInt32)pParams->Count() - 1) : 0;
    3854                 :          0 :         sal_uInt32 nAllowedParamCount = 1;
    3855                 :            : 
    3856                 :          0 :         Reference < XComponentContext > xContextToUse;
    3857         [ #  # ]:          0 :         if( nParamCount > 0 )
    3858                 :            :         {
    3859                 :            :             // Check if first parameter is a context and use it then
    3860                 :          0 :             Reference < XComponentContext > xFirstParamContext;
    3861 [ #  # ][ #  # ]:          0 :             Any aArg1 = sbxToUnoValue( pParams->Get( 1 ) );
    3862 [ #  # ][ #  # ]:          0 :             if( (aArg1 >>= xFirstParamContext) && xFirstParamContext.is() )
         [ #  # ][ #  # ]
    3863         [ #  # ]:          0 :                 xContextToUse = xFirstParamContext;
    3864                 :            :         }
    3865                 :            : 
    3866         [ #  # ]:          0 :         if( !xContextToUse.is() )
    3867                 :            :         {
    3868 [ #  # ][ #  # ]:          0 :             Reference < XPropertySet > xProps( ::comphelper::getProcessServiceFactory(), UNO_QUERY_THROW );
    3869 [ #  # ][ #  # ]:          0 :             xContextToUse.set( xProps->getPropertyValue( rtl::OUString( "DefaultContext" ) ), UNO_QUERY_THROW );
                 [ #  # ]
    3870                 :          0 :             --nAllowedParamCount;
    3871                 :            :         }
    3872                 :            : 
    3873         [ #  # ]:          0 :         if( nParamCount > nAllowedParamCount )
    3874                 :            :         {
    3875         [ #  # ]:          0 :             StarBASIC::Error( SbERR_BAD_ARGUMENT );
    3876                 :          0 :             return;
    3877                 :            :         }
    3878                 :            : 
    3879                 :          0 :         Any aRetAny;
    3880         [ #  # ]:          0 :         if( xContextToUse.is() )
    3881                 :            :         {
    3882                 :          0 :             ::rtl::OUString aSingletonName( "/singletons/" );
    3883 [ #  # ][ #  # ]:          0 :             aSingletonName += GetName();
    3884                 :          0 :             Reference < XInterface > xRet;
    3885 [ #  # ][ #  # ]:          0 :             xContextToUse->getValueByName( aSingletonName ) >>= xRet;
                 [ #  # ]
    3886         [ #  # ]:          0 :             aRetAny <<= xRet;
    3887                 :            :         }
    3888 [ #  # ][ #  # ]:          0 :         unoToSbxValue( pVar, aRetAny );
    3889                 :            :     }
    3890                 :            :     else
    3891                 :          0 :         SbxObject::SFX_NOTIFY( rBC, rBCType, rHint, rHintType );
    3892                 :            : }
    3893                 :            : 
    3894                 :            : 
    3895                 :            : //========================================================================
    3896                 :            : 
    3897                 :            : // Implementation of an EventAttacher-drawn AllListener, which
    3898                 :            : // solely transmits several events to an general AllListener
    3899                 :            : class BasicAllListener_Impl : public BasicAllListenerHelper
    3900                 :            : {
    3901                 :            :     virtual void firing_impl(const AllEventObject& Event, Any* pRet);
    3902                 :            : 
    3903                 :            : public:
    3904                 :            :     SbxObjectRef    xSbxObj;
    3905                 :            :     ::rtl::OUString     aPrefixName;
    3906                 :            : 
    3907                 :            :     BasicAllListener_Impl( const ::rtl::OUString& aPrefixName );
    3908                 :            :     ~BasicAllListener_Impl();
    3909                 :            : 
    3910                 :            :     // Methods of XAllListener
    3911                 :            :     virtual void SAL_CALL firing(const AllEventObject& Event) throw ( RuntimeException );
    3912                 :            :     virtual Any SAL_CALL approveFiring(const AllEventObject& Event) throw ( RuntimeException );
    3913                 :            : 
    3914                 :            :     // Methods of XEventListener
    3915                 :            :     virtual void SAL_CALL disposing(const EventObject& Source) throw ( RuntimeException );
    3916                 :            : };
    3917                 :            : 
    3918                 :            : 
    3919                 :            : //========================================================================
    3920                 :         12 : BasicAllListener_Impl::BasicAllListener_Impl
    3921                 :            : (
    3922                 :            :     const ::rtl::OUString   & aPrefixName_
    3923                 :            : )
    3924                 :         12 :     : aPrefixName( aPrefixName_ )
    3925                 :            : {
    3926                 :         12 : }
    3927                 :            : 
    3928                 :            : //========================================================================
    3929         [ #  # ]:          0 : BasicAllListener_Impl::~BasicAllListener_Impl()
    3930                 :            : {
    3931         [ #  # ]:          0 : }
    3932                 :            : 
    3933                 :            : //========================================================================
    3934                 :            : 
    3935                 :         36 : void BasicAllListener_Impl::firing_impl( const AllEventObject& Event, Any* pRet )
    3936                 :            : {
    3937         [ +  - ]:         36 :     SolarMutexGuard guard;
    3938                 :            : 
    3939         [ +  - ]:         36 :     if( xSbxObj.Is() )
    3940                 :            :     {
    3941                 :         36 :         ::rtl::OUString aMethodName = aPrefixName;
    3942                 :         36 :         aMethodName = aMethodName + Event.MethodName;
    3943                 :            : 
    3944                 :         36 :         SbxVariable * pP = xSbxObj;
    3945 [ +  - ][ +  - ]:         36 :         while( pP->GetParent() )
    3946                 :            :         {
    3947         [ +  - ]:         36 :             pP = pP->GetParent();
    3948 [ +  - ][ +  - ]:         36 :             StarBASIC * pLib = PTR_CAST(StarBASIC,pP);
         [ +  - ][ +  - ]
    3949         [ +  - ]:         36 :             if( pLib )
    3950                 :            :             {
    3951                 :            :                 // Create in a Basic Array
    3952 [ +  - ][ +  - ]:         36 :                 SbxArrayRef xSbxArray = new SbxArray( SbxVARIANT );
    3953                 :         36 :                 const Any * pArgs = Event.Arguments.getConstArray();
    3954                 :         36 :                 sal_Int32 nCount = Event.Arguments.getLength();
    3955         [ +  + ]:         84 :                 for( sal_Int32 i = 0; i < nCount; i++ )
    3956                 :            :                 {
    3957                 :            :                     // Convert elements
    3958 [ +  - ][ +  - ]:         48 :                     SbxVariableRef xVar = new SbxVariable( SbxVARIANT );
    3959         [ +  - ]:         48 :                     unoToSbxValue( (SbxVariable*)xVar, pArgs[i] );
    3960         [ +  - ]:         48 :                     xSbxArray->Put( xVar, sal::static_int_cast< sal_uInt16 >(i+1) );
    3961         [ +  - ]:         48 :                 }
    3962                 :            : 
    3963 [ +  - ][ +  - ]:         36 :                 pLib->Call( aMethodName, xSbxArray );
                 [ +  - ]
    3964                 :            : 
    3965                 :            :                 // get the return value from the Param-Array, if requestet
    3966         [ +  + ]:         36 :                 if( pRet )
    3967                 :            :                 {
    3968         [ +  - ]:         24 :                     SbxVariable* pVar = xSbxArray->Get( 0 );
    3969         [ +  - ]:         24 :                     if( pVar )
    3970                 :            :                     {
    3971                 :            :                         // #95792 Avoid a second call
    3972                 :         24 :                         sal_uInt16 nFlags = pVar->GetFlags();
    3973                 :         24 :                         pVar->SetFlag( SBX_NO_BROADCAST );
    3974         [ +  - ]:         24 :                         *pRet = sbxToUnoValueImpl( pVar );
    3975                 :         24 :                         pVar->SetFlags( nFlags );
    3976                 :            :                     }
    3977                 :            :                 }
    3978         [ +  - ]:         36 :                 break;
    3979                 :            :             }
    3980                 :         36 :         }
    3981         [ +  - ]:         36 :     }
    3982                 :         36 : }
    3983                 :            : 
    3984                 :            : 
    3985                 :            : // Methods of Listener
    3986                 :         12 : void BasicAllListener_Impl::firing( const AllEventObject& Event ) throw ( RuntimeException )
    3987                 :            : {
    3988                 :         12 :     firing_impl( Event, NULL );
    3989                 :         12 : }
    3990                 :            : 
    3991                 :         24 : Any BasicAllListener_Impl::approveFiring( const AllEventObject& Event ) throw ( RuntimeException )
    3992                 :            : {
    3993                 :         24 :     Any aRetAny;
    3994         [ +  - ]:         24 :     firing_impl( Event, &aRetAny );
    3995                 :         24 :     return aRetAny;
    3996                 :            : }
    3997                 :            : 
    3998                 :            : //========================================================================
    3999                 :            : // Methods of XEventListener
    4000                 :          0 : void BasicAllListener_Impl ::disposing(const EventObject& ) throw ( RuntimeException )
    4001                 :            : {
    4002         [ #  # ]:          0 :     SolarMutexGuard guard;
    4003                 :            : 
    4004 [ #  # ][ #  # ]:          0 :     xSbxObj.Clear();
    4005                 :          0 : }
    4006                 :            : 
    4007                 :            : 
    4008                 :            : 
    4009                 :            : //*************************************************************************
    4010                 :            : //  class InvocationToAllListenerMapper
    4011                 :            : //  helper class to map XInvocation to XAllListener (also in project eventattacher!)
    4012                 :            : //*************************************************************************
    4013         [ #  # ]:          0 : class InvocationToAllListenerMapper : public WeakImplHelper1< XInvocation >
    4014                 :            : {
    4015                 :            : public:
    4016                 :            :     InvocationToAllListenerMapper( const Reference< XIdlClass >& ListenerType,
    4017                 :            :         const Reference< XAllListener >& AllListener, const Any& Helper );
    4018                 :            : 
    4019                 :            :     // XInvocation
    4020                 :            :     virtual Reference< XIntrospectionAccess > SAL_CALL getIntrospection(void) throw( RuntimeException );
    4021                 :            :     virtual Any SAL_CALL invoke(const ::rtl::OUString& FunctionName, const Sequence< Any >& Params, Sequence< sal_Int16 >& OutParamIndex, Sequence< Any >& OutParam)
    4022                 :            :         throw( IllegalArgumentException, CannotConvertException, InvocationTargetException, RuntimeException );
    4023                 :            :     virtual void SAL_CALL setValue(const ::rtl::OUString& PropertyName, const Any& Value)
    4024                 :            :         throw( UnknownPropertyException, CannotConvertException, InvocationTargetException, RuntimeException );
    4025                 :            :     virtual Any SAL_CALL getValue(const ::rtl::OUString& PropertyName) throw( UnknownPropertyException, RuntimeException );
    4026                 :            :     virtual sal_Bool SAL_CALL hasMethod(const ::rtl::OUString& Name) throw( RuntimeException );
    4027                 :            :     virtual sal_Bool SAL_CALL hasProperty(const ::rtl::OUString& Name) throw( RuntimeException );
    4028                 :            : 
    4029                 :            : private:
    4030                 :            :     Reference< XIdlReflection >  m_xCoreReflection;
    4031                 :            :     Reference< XAllListener >    m_xAllListener;
    4032                 :            :     Reference< XIdlClass >       m_xListenerType;
    4033                 :            :     Any                          m_Helper;
    4034                 :            : };
    4035                 :            : 
    4036                 :            : 
    4037                 :            : // Function to replace AllListenerAdapterService::createAllListerAdapter
    4038                 :         12 : Reference< XInterface > createAllListenerAdapter
    4039                 :            : (
    4040                 :            :     const Reference< XInvocationAdapterFactory >& xInvocationAdapterFactory,
    4041                 :            :     const Reference< XIdlClass >& xListenerType,
    4042                 :            :     const Reference< XAllListener >& xListener,
    4043                 :            :     const Any& Helper
    4044                 :            : )
    4045                 :            : {
    4046                 :         12 :     Reference< XInterface > xAdapter;
    4047 [ +  - ][ +  - ]:         12 :     if( xInvocationAdapterFactory.is() && xListenerType.is() && xListener.is() )
         [ +  - ][ +  - ]
    4048                 :            :     {
    4049                 :            :        Reference< XInvocation > xInvocationToAllListenerMapper =
    4050 [ +  - ][ +  - ]:         12 :             (XInvocation*)new InvocationToAllListenerMapper( xListenerType, xListener, Helper );
                 [ +  - ]
    4051 [ +  - ][ +  - ]:         12 :         Type aListenerType( xListenerType->getTypeClass(), xListenerType->getName() );
         [ +  - ][ +  - ]
    4052 [ +  - ][ +  - ]:         12 :         xAdapter = xInvocationAdapterFactory->createAdapter( xInvocationToAllListenerMapper, aListenerType );
                 [ +  - ]
    4053                 :            :     }
    4054                 :         12 :     return xAdapter;
    4055                 :            : }
    4056                 :            : 
    4057                 :            : 
    4058                 :            : //--------------------------------------------------------------------------------------------------
    4059                 :            : // InvocationToAllListenerMapper
    4060                 :         12 : InvocationToAllListenerMapper::InvocationToAllListenerMapper
    4061                 :            :     ( const Reference< XIdlClass >& ListenerType, const Reference< XAllListener >& AllListener, const Any& Helper )
    4062                 :            :         : m_xAllListener( AllListener )
    4063                 :            :         , m_xListenerType( ListenerType )
    4064                 :         12 :         , m_Helper( Helper )
    4065                 :            : {
    4066                 :         12 : }
    4067                 :            : 
    4068                 :            : //*************************************************************************
    4069                 :          0 : Reference< XIntrospectionAccess > SAL_CALL InvocationToAllListenerMapper::getIntrospection(void)
    4070                 :            :     throw( RuntimeException )
    4071                 :            : {
    4072                 :          0 :     return Reference< XIntrospectionAccess >();
    4073                 :            : }
    4074                 :            : 
    4075                 :            : //*************************************************************************
    4076                 :         36 : Any SAL_CALL InvocationToAllListenerMapper::invoke(const ::rtl::OUString& FunctionName, const Sequence< Any >& Params,
    4077                 :            :     Sequence< sal_Int16 >& OutParamIndex, Sequence< Any >& OutParam)
    4078                 :            :         throw( IllegalArgumentException, CannotConvertException,
    4079                 :            :         InvocationTargetException, RuntimeException )
    4080                 :            : {
    4081                 :            :     (void)OutParamIndex;
    4082                 :            :     (void)OutParam     ;
    4083                 :            : 
    4084                 :         36 :     Any aRet;
    4085                 :            : 
    4086                 :            :     // Check if to firing or approveFiring has to be called
    4087 [ +  - ][ +  - ]:         36 :     Reference< XIdlMethod > xMethod = m_xListenerType->getMethod( FunctionName );
    4088                 :         36 :     sal_Bool bApproveFiring = sal_False;
    4089         [ +  - ]:         36 :     if( !xMethod.is() )
    4090                 :            :         return aRet;
    4091 [ +  - ][ +  - ]:         36 :     Reference< XIdlClass > xReturnType = xMethod->getReturnType();
    4092 [ +  - ][ +  - ]:         36 :     Sequence< Reference< XIdlClass > > aExceptionSeq = xMethod->getExceptionTypes();
    4093 [ +  - ][ +  - ]:         72 :     if( ( xReturnType.is() && xReturnType->getTypeClass() != TypeClass_VOID ) ||
                 [ +  - ]
           [ +  -  +  + ]
                 [ +  + ]
    4094                 :         36 :         aExceptionSeq.getLength() > 0 )
    4095                 :            :     {
    4096                 :         24 :         bApproveFiring = sal_True;
    4097                 :            :     }
    4098                 :            :     else
    4099                 :            :     {
    4100 [ +  - ][ +  - ]:         12 :         Sequence< ParamInfo > aParamSeq = xMethod->getParameterInfos();
    4101                 :         12 :         sal_uInt32 nParamCount = aParamSeq.getLength();
    4102         [ -  + ]:         12 :         if( nParamCount > 1 )
    4103                 :            :         {
    4104                 :          0 :             const ParamInfo* pInfos = aParamSeq.getConstArray();
    4105         [ #  # ]:          0 :             for( sal_uInt32 i = 0 ; i < nParamCount ; i++ )
    4106                 :            :             {
    4107         [ #  # ]:          0 :                 if( pInfos[ i ].aMode != ParamMode_IN )
    4108                 :            :                 {
    4109                 :          0 :                     bApproveFiring = sal_True;
    4110                 :          0 :                     break;
    4111                 :            :                 }
    4112                 :            :             }
    4113         [ +  - ]:         12 :         }
    4114                 :            :     }
    4115                 :            : 
    4116         [ +  - ]:         36 :     AllEventObject aAllEvent;
    4117         [ +  - ]:         36 :     aAllEvent.Source = (OWeakObject*) this;
    4118                 :         36 :     aAllEvent.Helper = m_Helper;
    4119 [ +  - ][ +  - ]:         36 :     aAllEvent.ListenerType = Type(m_xListenerType->getTypeClass(), m_xListenerType->getName() );
         [ +  - ][ +  - ]
    4120                 :         36 :     aAllEvent.MethodName = FunctionName;
    4121         [ +  - ]:         36 :     aAllEvent.Arguments = Params;
    4122         [ +  + ]:         36 :     if( bApproveFiring )
    4123 [ +  - ][ +  - ]:         24 :         aRet = m_xAllListener->approveFiring( aAllEvent );
    4124                 :            :     else
    4125 [ +  - ][ +  - ]:         12 :         m_xAllListener->firing( aAllEvent );
    4126 [ +  - ][ +  - ]:         36 :     return aRet;
    4127                 :            : }
    4128                 :            : 
    4129                 :            : //*************************************************************************
    4130                 :          0 : void SAL_CALL InvocationToAllListenerMapper::setValue(const ::rtl::OUString& PropertyName, const Any& Value)
    4131                 :            :     throw( UnknownPropertyException, CannotConvertException,
    4132                 :            :            InvocationTargetException, RuntimeException )
    4133                 :            : {
    4134                 :            :     (void)PropertyName;
    4135                 :            :     (void)Value;
    4136                 :          0 : }
    4137                 :            : 
    4138                 :            : //*************************************************************************
    4139                 :          0 : Any SAL_CALL InvocationToAllListenerMapper::getValue(const ::rtl::OUString& PropertyName)
    4140                 :            :     throw( UnknownPropertyException, RuntimeException )
    4141                 :            : {
    4142                 :            :     (void)PropertyName;
    4143                 :            : 
    4144                 :          0 :     return Any();
    4145                 :            : }
    4146                 :            : 
    4147                 :            : //*************************************************************************
    4148                 :          0 : sal_Bool SAL_CALL InvocationToAllListenerMapper::hasMethod(const ::rtl::OUString& Name)
    4149                 :            :     throw( RuntimeException )
    4150                 :            : {
    4151 [ #  # ][ #  # ]:          0 :     Reference< XIdlMethod > xMethod = m_xListenerType->getMethod( Name );
    4152                 :          0 :     return xMethod.is();
    4153                 :            : }
    4154                 :            : 
    4155                 :            : //*************************************************************************
    4156                 :          0 : sal_Bool SAL_CALL InvocationToAllListenerMapper::hasProperty(const ::rtl::OUString& Name)
    4157                 :            :     throw( RuntimeException )
    4158                 :            : {
    4159 [ #  # ][ #  # ]:          0 :     Reference< XIdlField > xField = m_xListenerType->getField( Name );
    4160                 :          0 :     return xField.is();
    4161                 :            : }
    4162                 :            : 
    4163                 :            : //========================================================================
    4164                 :            : // create Uno-Service
    4165                 :            : // 1. Parameter == Prefix-Name of the macro
    4166                 :            : // 2. Parameter == fully qualified name of the listener
    4167                 :         12 : void SbRtl_CreateUnoListener( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrite )
    4168                 :            : //RTLFUNC(CreateUnoListener)
    4169                 :            : {
    4170                 :            :     (void)bWrite;
    4171                 :            : 
    4172                 :            :     // We need 2 parameters
    4173 [ +  - ][ -  + ]:         12 :     if ( rPar.Count() != 3 )
    4174                 :            :     {
    4175         [ #  # ]:          0 :         StarBASIC::Error( SbERR_BAD_ARGUMENT );
    4176                 :            :         return;
    4177                 :            :     }
    4178                 :            : 
    4179                 :            :     // get the name of the class of the struct
    4180 [ +  - ][ +  - ]:         12 :     ::rtl::OUString aPrefixName = rPar.Get(1)->GetString();
                 [ +  - ]
    4181 [ +  - ][ +  - ]:         12 :     ::rtl::OUString aListenerClassName = rPar.Get(2)->GetString();
                 [ +  - ]
    4182                 :            : 
    4183                 :            :     // get the CoreReflection
    4184         [ +  - ]:         12 :     Reference< XIdlReflection > xCoreReflection = getCoreReflection_Impl();
    4185         [ -  + ]:         12 :     if( !xCoreReflection.is() )
    4186                 :            :         return;
    4187                 :            : 
    4188                 :            :     // get the AllListenerAdapterService
    4189         [ +  - ]:         12 :     Reference< XMultiServiceFactory > xFactory( comphelper::getProcessServiceFactory() );
    4190         [ -  + ]:         12 :     if( !xFactory.is() )
    4191                 :            :         return;
    4192                 :            : 
    4193                 :            :     // search the class
    4194 [ +  - ][ +  - ]:         12 :     Reference< XIdlClass > xClass = xCoreReflection->forName( aListenerClassName );
    4195         [ -  + ]:         12 :     if( !xClass.is() )
    4196                 :            :         return;
    4197                 :            : 
    4198                 :            :     // From 1999-11-30: get the InvocationAdapterFactory
    4199                 :            :     Reference< XInvocationAdapterFactory > xInvocationAdapterFactory = Reference< XInvocationAdapterFactory >(
    4200 [ +  - ][ +  - ]:         12 :         xFactory->createInstance( rtl::OUString("com.sun.star.script.InvocationAdapterFactory") ), UNO_QUERY );
                 [ +  - ]
    4201                 :            : 
    4202                 :            :     BasicAllListener_Impl * p;
    4203 [ +  - ][ +  - ]:         12 :     Reference< XAllListener > xAllLst = p = new BasicAllListener_Impl( aPrefixName );
                 [ +  - ]
    4204                 :         12 :     Any aTmp;
    4205         [ +  - ]:         12 :     Reference< XInterface > xLst = createAllListenerAdapter( xInvocationAdapterFactory, xClass, xAllLst, aTmp );
    4206         [ -  + ]:         12 :     if( !xLst.is() )
    4207                 :            :         return;
    4208                 :            : 
    4209 [ +  - ][ +  - ]:         12 :     ::rtl::OUString aClassName = xClass->getName();
    4210 [ +  - ][ +  - ]:         12 :     Type aClassType( xClass->getTypeClass(), aClassName.getStr() );
    4211 [ +  - ][ +  - ]:         12 :     aTmp = xLst->queryInterface( aClassType );
    4212         [ -  + ]:         12 :     if( !aTmp.hasValue() )
    4213                 :            :         return;
    4214                 :            : 
    4215 [ +  - ][ +  - ]:         12 :     SbUnoObject* pUnoObj = new SbUnoObject( aListenerClassName, aTmp );
    4216         [ +  - ]:         12 :     p->xSbxObj = pUnoObj;
    4217         [ +  - ]:         12 :     p->xSbxObj->SetParent( pBasic );
    4218                 :            : 
    4219                 :            :     // #100326 Register listener object to set Parent NULL in Dtor
    4220         [ +  - ]:         12 :     SbxArrayRef xBasicUnoListeners = pBasic->getUnoListeners();
    4221 [ +  - ][ +  - ]:         12 :     xBasicUnoListeners->Insert( pUnoObj, xBasicUnoListeners->Count() );
    4222                 :            : 
    4223                 :            :     // return the object
    4224         [ +  - ]:         12 :     SbxVariableRef refVar = rPar.Get(0);
    4225 [ +  - ][ +  - ]:         12 :     refVar->PutObject( p->xSbxObj );
         [ -  + ][ -  + ]
         [ -  + ][ -  + ]
         [ -  + ][ -  + ]
         [ -  + ][ -  + ]
         [ -  + ][ -  + ]
         [ +  - ][ +  - ]
    4226                 :            : }
    4227                 :            : 
    4228                 :            : //========================================================================
    4229                 :            : // Represents the DefaultContext property of the ProcessServiceManager
    4230                 :            : // in the Basic runtime system.
    4231                 :          2 : void RTL_Impl_GetDefaultContext( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrite )
    4232                 :            : {
    4233                 :            :     (void)pBasic;
    4234                 :            :     (void)bWrite;
    4235                 :            : 
    4236         [ +  - ]:          2 :     SbxVariableRef refVar = rPar.Get(0);
    4237                 :            : 
    4238         [ +  - ]:          2 :     Reference< XMultiServiceFactory > xFactory = comphelper::getProcessServiceFactory();
    4239         [ +  - ]:          2 :     Reference< XPropertySet> xPSMPropertySet( xFactory, UNO_QUERY );
    4240         [ +  - ]:          2 :     if( xPSMPropertySet.is() )
    4241                 :            :     {
    4242         [ +  - ]:          2 :         Any aContextAny = xPSMPropertySet->getPropertyValue(
    4243         [ +  - ]:          2 :             ::rtl::OUString( "DefaultContext" ) );
    4244                 :            : 
    4245                 :            :         SbUnoObjectRef xUnoObj = new SbUnoObject
    4246                 :            :             ( ::rtl::OUString( "DefaultContext" ),
    4247 [ +  - ][ +  - ]:          2 :               aContextAny );
    4248 [ +  - ][ +  - ]:          2 :         refVar->PutObject( (SbUnoObject*)xUnoObj );
    4249                 :            :     }
    4250                 :            :     else
    4251                 :            :     {
    4252         [ #  # ]:          0 :         refVar->PutObject( NULL );
    4253         [ +  - ]:          2 :     }
    4254                 :          2 : }
    4255                 :            : 
    4256                 :            : //========================================================================
    4257                 :            : // Creates a Basic wrapper object for a strongly typed Uno value
    4258                 :            : // 1. parameter: Uno type as full qualified type name, e.g. "byte[]"
    4259                 :          0 : void RTL_Impl_CreateUnoValue( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrite )
    4260                 :            : {
    4261                 :            :     (void)pBasic;
    4262                 :            :     (void)bWrite;
    4263                 :            : 
    4264 [ #  # ][ #  # ]:          0 :     static rtl::OUString aTypeTypeString( "type" );
    4265                 :            : 
    4266                 :            :     // 2 parameters needed
    4267 [ #  # ][ #  # ]:          0 :     if ( rPar.Count() != 3 )
    4268                 :            :     {
    4269         [ #  # ]:          0 :         StarBASIC::Error( SbERR_BAD_ARGUMENT );
    4270                 :            :         return;
    4271                 :            :     }
    4272                 :            : 
    4273                 :            :     // get the name of the class of the struct
    4274 [ #  # ][ #  # ]:          0 :     rtl::OUString aTypeName = rPar.Get(1)->GetString();
                 [ #  # ]
    4275         [ #  # ]:          0 :     SbxVariable* pVal = rPar.Get(2);
    4276                 :            : 
    4277         [ #  # ]:          0 :     if( aTypeName == aTypeTypeString )
    4278                 :            :     {
    4279         [ #  # ]:          0 :         SbxDataType eBaseType = pVal->SbxValue::GetType();
    4280         [ #  # ]:          0 :         String aValTypeName;
    4281         [ #  # ]:          0 :         if( eBaseType == SbxSTRING )
    4282                 :            :         {
    4283 [ #  # ][ #  # ]:          0 :             aValTypeName = pVal->GetString();
    4284                 :            :         }
    4285         [ #  # ]:          0 :         else if( eBaseType == SbxOBJECT )
    4286                 :            :         {
    4287                 :            :             // XIdlClass?
    4288                 :          0 :             Reference< XIdlClass > xIdlClass;
    4289                 :            : 
    4290         [ #  # ]:          0 :             SbxBaseRef pObj = (SbxBase*)pVal->GetObject();
    4291 [ #  # ][ #  # ]:          0 :             if( pObj && pObj->ISA(SbUnoObject) )
         [ #  # ][ #  # ]
    4292                 :            :             {
    4293         [ #  # ]:          0 :                 Any aUnoAny = ((SbUnoObject*)(SbxBase*)pObj)->getUnoAny();
    4294         [ #  # ]:          0 :                 aUnoAny >>= xIdlClass;
    4295                 :            :             }
    4296                 :            : 
    4297         [ #  # ]:          0 :             if( xIdlClass.is() )
    4298 [ #  # ][ #  # ]:          0 :                 aValTypeName = xIdlClass->getName();
         [ #  # ][ #  # ]
    4299                 :            :         }
    4300                 :          0 :         Type aType;
    4301         [ #  # ]:          0 :         bool bSuccess = implGetTypeByName( aValTypeName, aType );
    4302         [ #  # ]:          0 :         if( bSuccess )
    4303                 :            :         {
    4304         [ #  # ]:          0 :             Any aTypeAny( aType );
    4305         [ #  # ]:          0 :             SbxVariableRef refVar = rPar.Get(0);
    4306 [ #  # ][ #  # ]:          0 :             SbxObjectRef xUnoAnyObject = new SbUnoAnyObject( aTypeAny );
    4307 [ #  # ][ #  # ]:          0 :             refVar->PutObject( xUnoAnyObject );
                 [ #  # ]
    4308                 :            :         }
    4309         [ #  # ]:          0 :         return;
    4310                 :            :     }
    4311                 :            : 
    4312                 :            :     // Check the type
    4313         [ #  # ]:          0 :     Reference< XHierarchicalNameAccess > xTypeAccess = getTypeProvider_Impl();
    4314                 :          0 :     Any aRet;
    4315                 :            :     try
    4316                 :            :     {
    4317 [ #  # ][ #  # ]:          0 :         aRet = xTypeAccess->getByHierarchicalName( aTypeName );
    4318                 :            :     }
    4319   [ #  #  #  # ]:          0 :     catch( const NoSuchElementException& e1 )
    4320                 :            :     {
    4321                 :            :         ::rtl::OUString aNoSuchElementExceptionName
    4322                 :          0 :             ( "com.sun.star.container.NoSuchElementException"  );
    4323                 :            :         StarBASIC::Error( ERRCODE_BASIC_EXCEPTION,
    4324   [ #  #  #  #  :          0 :             implGetExceptionMsg( e1, aNoSuchElementExceptionName ) );
             #  #  #  # ]
    4325                 :          0 :         return;
    4326                 :            :     }
    4327                 :          0 :     Reference< XTypeDescription > xTypeDesc;
    4328         [ #  # ]:          0 :     aRet >>= xTypeDesc;
    4329 [ #  # ][ #  # ]:          0 :     TypeClass eTypeClass = xTypeDesc->getTypeClass();
    4330                 :          0 :     Type aDestType( eTypeClass, aTypeName );
    4331                 :            : 
    4332                 :            : 
    4333                 :            :     // Preconvert value
    4334         [ #  # ]:          0 :     Any aVal = sbxToUnoValueImpl( pVal );
    4335         [ #  # ]:          0 :     Any aConvertedVal = convertAny( aVal, aDestType );
    4336                 :            : 
    4337                 :            : 
    4338         [ #  # ]:          0 :     SbxVariableRef refVar = rPar.Get(0);
    4339 [ #  # ][ #  # ]:          0 :     SbxObjectRef xUnoAnyObject = new SbUnoAnyObject( aConvertedVal );
    4340 [ #  # ][ #  # ]:          0 :     refVar->PutObject( xUnoAnyObject );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    4341                 :            : }
    4342                 :            : 
    4343                 :            : //==========================================================================
    4344                 :            : 
    4345                 :            : namespace {
    4346                 :          0 : class OMutexBasis
    4347                 :            : {
    4348                 :            : protected:
    4349                 :            :     // this mutex is necessary for OInterfaceContainerHelper
    4350                 :            :     ::osl::Mutex m_aMutex;
    4351                 :            : };
    4352                 :            : } // namespace
    4353                 :            : 
    4354                 :            : typedef WeakImplHelper2< XInvocation, XComponent > ModuleInvocationProxyHelper;
    4355                 :            : 
    4356                 :            : class ModuleInvocationProxy : public OMutexBasis,
    4357                 :            :                               public ModuleInvocationProxyHelper
    4358                 :            : {
    4359                 :            :     ::rtl::OUString     m_aPrefix;
    4360                 :            :     SbxObjectRef        m_xScopeObj;
    4361                 :            :     bool                m_bProxyIsClassModuleObject;
    4362                 :            : 
    4363                 :            :     ::cppu::OInterfaceContainerHelper m_aListeners;
    4364                 :            : 
    4365                 :            : public:
    4366                 :            :     ModuleInvocationProxy( const ::rtl::OUString& aPrefix, SbxObjectRef xScopeObj );
    4367                 :          0 :     ~ModuleInvocationProxy()
    4368 [ #  # ][ #  # ]:          0 :     {}
         [ #  # ][ #  # ]
    4369                 :            : 
    4370                 :            :     // XInvocation
    4371                 :            :     virtual Reference< XIntrospectionAccess > SAL_CALL getIntrospection() throw();
    4372                 :            :     virtual void SAL_CALL setValue( const ::rtl::OUString& rProperty, const Any& rValue )
    4373                 :            :         throw( UnknownPropertyException );
    4374                 :            :     virtual Any SAL_CALL getValue( const ::rtl::OUString& rProperty )
    4375                 :            :         throw( UnknownPropertyException );
    4376                 :            :     virtual sal_Bool SAL_CALL hasMethod( const ::rtl::OUString& rName ) throw();
    4377                 :            :     virtual sal_Bool SAL_CALL hasProperty( const ::rtl::OUString& rProp ) throw();
    4378                 :            : 
    4379                 :            :     virtual Any SAL_CALL invoke( const ::rtl::OUString& rFunction,
    4380                 :            :                                  const Sequence< Any >& rParams,
    4381                 :            :                                  Sequence< sal_Int16 >& rOutParamIndex,
    4382                 :            :                                  Sequence< Any >& rOutParam )
    4383                 :            :         throw( CannotConvertException, InvocationTargetException );
    4384                 :            : 
    4385                 :            :     // XComponent
    4386                 :            :     virtual void SAL_CALL dispose() throw(RuntimeException);
    4387                 :            :     virtual void SAL_CALL addEventListener( const Reference< XEventListener >& xListener ) throw (RuntimeException);
    4388                 :            :     virtual void SAL_CALL removeEventListener( const Reference< XEventListener >& aListener ) throw (RuntimeException);
    4389                 :            : };
    4390                 :            : 
    4391                 :          0 : ModuleInvocationProxy::ModuleInvocationProxy( const ::rtl::OUString& aPrefix, SbxObjectRef xScopeObj )
    4392                 :            :     : m_aPrefix( aPrefix + ::rtl::OUString( "_" ) )
    4393                 :            :     , m_xScopeObj( xScopeObj )
    4394 [ #  # ][ #  # ]:          0 :     , m_aListeners( m_aMutex )
    4395                 :            : {
    4396 [ #  # ][ #  # ]:          0 :     m_bProxyIsClassModuleObject = xScopeObj.Is() ? xScopeObj->ISA(SbClassModuleObject) : false;
         [ #  # ][ #  # ]
    4397                 :          0 : }
    4398                 :            : 
    4399                 :          0 : Reference< XIntrospectionAccess > SAL_CALL ModuleInvocationProxy::getIntrospection() throw()
    4400                 :            : {
    4401                 :          0 :     return Reference< XIntrospectionAccess >();
    4402                 :            : }
    4403                 :            : 
    4404                 :          0 : void SAL_CALL ModuleInvocationProxy::setValue( const ::rtl::OUString& rProperty, const Any& rValue ) throw( UnknownPropertyException )
    4405                 :            : {
    4406         [ #  # ]:          0 :     if( !m_bProxyIsClassModuleObject )
    4407         [ #  # ]:          0 :         throw UnknownPropertyException();
    4408                 :            : 
    4409         [ #  # ]:          0 :     SolarMutexGuard guard;
    4410                 :            : 
    4411                 :          0 :     ::rtl::OUString aPropertyFunctionName( "Property Set " );
    4412                 :          0 :     aPropertyFunctionName += m_aPrefix;
    4413                 :          0 :     aPropertyFunctionName += rProperty;
    4414                 :            : 
    4415         [ #  # ]:          0 :     SbxVariable* p = m_xScopeObj->Find( aPropertyFunctionName, SbxCLASS_METHOD );
    4416 [ #  # ][ #  # ]:          0 :     SbMethod* pMeth = p != NULL ? PTR_CAST(SbMethod,p) : NULL;
         [ #  # ][ #  # ]
                 [ #  # ]
    4417         [ #  # ]:          0 :     if( pMeth == NULL )
    4418                 :            :     {
    4419                 :            :         // TODO: Check vba behavior concernig missing function
    4420                 :            :         //StarBASIC::Error( SbERR_NO_METHOD, aFunctionName );
    4421         [ #  # ]:          0 :         throw UnknownPropertyException();
    4422                 :            :     }
    4423                 :            : 
    4424                 :            :     // Setup parameter
    4425 [ #  # ][ #  # ]:          0 :     SbxArrayRef xArray = new SbxArray;
    4426 [ #  # ][ #  # ]:          0 :     SbxVariableRef xVar = new SbxVariable( SbxVARIANT );
    4427         [ #  # ]:          0 :     unoToSbxValue( (SbxVariable*)xVar, rValue );
    4428         [ #  # ]:          0 :     xArray->Put( xVar, 1 );
    4429                 :            : 
    4430                 :            :     // Call property method
    4431 [ #  # ][ #  # ]:          0 :     SbxVariableRef xValue = new SbxVariable;
    4432         [ #  # ]:          0 :     pMeth->SetParameters( xArray );
    4433         [ #  # ]:          0 :     pMeth->Call( xValue );
    4434 [ #  # ][ #  # ]:          0 :     pMeth->SetParameters( NULL );
         [ #  # ][ #  # ]
                 [ #  # ]
    4435                 :            : 
    4436                 :            :     // TODO: OutParameter?
    4437                 :            : 
    4438                 :            : 
    4439                 :            : 
    4440                 :          0 : }
    4441                 :            : 
    4442                 :          0 : Any SAL_CALL ModuleInvocationProxy::getValue( const ::rtl::OUString& rProperty ) throw( UnknownPropertyException )
    4443                 :            : {
    4444         [ #  # ]:          0 :     if( !m_bProxyIsClassModuleObject )
    4445         [ #  # ]:          0 :         throw UnknownPropertyException();
    4446                 :            : 
    4447         [ #  # ]:          0 :     SolarMutexGuard guard;
    4448                 :            : 
    4449                 :          0 :     ::rtl::OUString aPropertyFunctionName( "Property Get " );
    4450                 :          0 :     aPropertyFunctionName += m_aPrefix;
    4451                 :          0 :     aPropertyFunctionName += rProperty;
    4452                 :            : 
    4453         [ #  # ]:          0 :     SbxVariable* p = m_xScopeObj->Find( aPropertyFunctionName, SbxCLASS_METHOD );
    4454 [ #  # ][ #  # ]:          0 :     SbMethod* pMeth = p != NULL ? PTR_CAST(SbMethod,p) : NULL;
         [ #  # ][ #  # ]
                 [ #  # ]
    4455         [ #  # ]:          0 :     if( pMeth == NULL )
    4456                 :            :     {
    4457                 :            :         // TODO: Check vba behavior concernig missing function
    4458                 :            :         //StarBASIC::Error( SbERR_NO_METHOD, aFunctionName );
    4459         [ #  # ]:          0 :         throw UnknownPropertyException();
    4460                 :            :     }
    4461                 :            : 
    4462                 :            :     // Call method
    4463 [ #  # ][ #  # ]:          0 :     SbxVariableRef xValue = new SbxVariable;
    4464         [ #  # ]:          0 :     pMeth->Call( xValue );
    4465         [ #  # ]:          0 :     Any aRet = sbxToUnoValue( xValue );
    4466 [ #  # ][ #  # ]:          0 :     return aRet;
    4467                 :            : }
    4468                 :            : 
    4469                 :          0 : sal_Bool SAL_CALL ModuleInvocationProxy::hasMethod( const ::rtl::OUString& ) throw()
    4470                 :            : {
    4471                 :          0 :     return sal_False;
    4472                 :            : }
    4473                 :            : 
    4474                 :          0 : sal_Bool SAL_CALL ModuleInvocationProxy::hasProperty( const ::rtl::OUString& ) throw()
    4475                 :            : {
    4476                 :          0 :     return sal_False;
    4477                 :            : }
    4478                 :            : 
    4479                 :          0 : Any SAL_CALL ModuleInvocationProxy::invoke( const ::rtl::OUString& rFunction,
    4480                 :            :                                             const Sequence< Any >& rParams,
    4481                 :            :                                             Sequence< sal_Int16 >&,
    4482                 :            :                                             Sequence< Any >& )
    4483                 :            :     throw( CannotConvertException, InvocationTargetException )
    4484                 :            : {
    4485         [ #  # ]:          0 :     SolarMutexGuard guard;
    4486                 :            : 
    4487                 :          0 :     Any aRet;
    4488                 :          0 :     SbxObjectRef xScopeObj = m_xScopeObj;
    4489         [ #  # ]:          0 :     if( !xScopeObj.Is() )
    4490                 :            :         return aRet;
    4491                 :            : 
    4492                 :          0 :     ::rtl::OUString aFunctionName = m_aPrefix;
    4493                 :          0 :     aFunctionName += rFunction;
    4494                 :            : 
    4495                 :          0 :     sal_Bool bSetRescheduleBack = sal_False;
    4496                 :          0 :     sal_Bool bOldReschedule = sal_True;
    4497         [ #  # ]:          0 :     SbiInstance* pInst = GetSbData()->pInst;
    4498 [ #  # ][ #  # ]:          0 :     if( pInst && pInst->IsCompatibility() )
                 [ #  # ]
    4499                 :            :     {
    4500                 :          0 :         bOldReschedule = pInst->IsReschedule();
    4501         [ #  # ]:          0 :         if ( bOldReschedule )
    4502                 :            :         {
    4503                 :          0 :             pInst->EnableReschedule( sal_False );
    4504                 :          0 :             bSetRescheduleBack = sal_True;
    4505                 :            :         }
    4506                 :            :     }
    4507                 :            : 
    4508         [ #  # ]:          0 :     SbxVariable* p = xScopeObj->Find( aFunctionName, SbxCLASS_METHOD );
    4509 [ #  # ][ #  # ]:          0 :     SbMethod* pMeth = p != NULL ? PTR_CAST(SbMethod,p) : NULL;
         [ #  # ][ #  # ]
                 [ #  # ]
    4510         [ #  # ]:          0 :     if( pMeth == NULL )
    4511                 :            :     {
    4512                 :            :         // TODO: Check vba behavior concernig missing function
    4513                 :            :         //StarBASIC::Error( SbERR_NO_METHOD, aFunctionName );
    4514                 :            :         return aRet;
    4515                 :            :     }
    4516                 :            : 
    4517                 :            :     // Setup parameters
    4518                 :          0 :     SbxArrayRef xArray;
    4519                 :          0 :     sal_Int32 nParamCount = rParams.getLength();
    4520         [ #  # ]:          0 :     if( nParamCount )
    4521                 :            :     {
    4522 [ #  # ][ #  # ]:          0 :         xArray = new SbxArray;
                 [ #  # ]
    4523                 :          0 :         const Any *pArgs = rParams.getConstArray();
    4524         [ #  # ]:          0 :         for( sal_Int32 i = 0 ; i < nParamCount ; i++ )
    4525                 :            :         {
    4526 [ #  # ][ #  # ]:          0 :             SbxVariableRef xVar = new SbxVariable( SbxVARIANT );
    4527         [ #  # ]:          0 :             unoToSbxValue( (SbxVariable*)xVar, pArgs[i] );
    4528         [ #  # ]:          0 :             xArray->Put( xVar, sal::static_int_cast< sal_uInt16 >(i+1) );
    4529         [ #  # ]:          0 :         }
    4530                 :            :     }
    4531                 :            : 
    4532                 :            :     // Call method
    4533 [ #  # ][ #  # ]:          0 :     SbxVariableRef xValue = new SbxVariable;
    4534         [ #  # ]:          0 :     if( xArray.Is() )
    4535         [ #  # ]:          0 :         pMeth->SetParameters( xArray );
    4536         [ #  # ]:          0 :     pMeth->Call( xValue );
    4537         [ #  # ]:          0 :     aRet = sbxToUnoValue( xValue );
    4538         [ #  # ]:          0 :     pMeth->SetParameters( NULL );
    4539                 :            : 
    4540         [ #  # ]:          0 :     if( bSetRescheduleBack )
    4541                 :          0 :         pInst->EnableReschedule( bOldReschedule );
    4542                 :            : 
    4543                 :            :     // TODO: OutParameter?
    4544                 :            : 
    4545 [ #  # ][ #  # ]:          0 :     return aRet;
         [ #  # ][ #  # ]
    4546                 :            : }
    4547                 :            : 
    4548                 :          0 : void SAL_CALL ModuleInvocationProxy::dispose()
    4549                 :            :     throw(RuntimeException)
    4550                 :            : {
    4551         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( m_aMutex );
    4552                 :            : 
    4553 [ #  # ][ #  # ]:          0 :     EventObject aEvent( (XComponent*)this );
    4554         [ #  # ]:          0 :     m_aListeners.disposeAndClear( aEvent );
    4555                 :            : 
    4556 [ #  # ][ #  # ]:          0 :     m_xScopeObj = NULL;
                 [ #  # ]
    4557                 :          0 : }
    4558                 :            : 
    4559                 :          0 : void SAL_CALL ModuleInvocationProxy::addEventListener( const Reference< XEventListener >& xListener )
    4560                 :            :     throw (RuntimeException)
    4561                 :            : {
    4562                 :          0 :     m_aListeners.addInterface( xListener );
    4563                 :          0 : }
    4564                 :            : 
    4565                 :          0 : void SAL_CALL ModuleInvocationProxy::removeEventListener( const Reference< XEventListener >& xListener )
    4566                 :            :     throw (RuntimeException)
    4567                 :            : {
    4568                 :          0 :     m_aListeners.removeInterface( xListener );
    4569                 :          0 : }
    4570                 :            : 
    4571                 :            : 
    4572                 :          0 : Reference< XInterface > createComListener( const Any& aControlAny, const ::rtl::OUString& aVBAType,
    4573                 :            :                                            const ::rtl::OUString& aPrefix, SbxObjectRef xScopeObj )
    4574                 :            : {
    4575                 :          0 :     Reference< XInterface > xRet;
    4576                 :            : 
    4577         [ #  # ]:          0 :     Reference< XComponentContext > xContext = getComponentContext_Impl();
    4578 [ #  # ][ #  # ]:          0 :     Reference< XMultiComponentFactory > xServiceMgr( xContext->getServiceManager() );
    4579                 :            : 
    4580 [ #  # ][ #  # ]:          0 :     Reference< XInvocation > xProxy = new ModuleInvocationProxy( aPrefix, xScopeObj );
         [ #  # ][ #  # ]
    4581                 :            : 
    4582         [ #  # ]:          0 :     Sequence<Any> args( 3 );
    4583 [ #  # ][ #  # ]:          0 :     args[0] <<= aControlAny;
    4584 [ #  # ][ #  # ]:          0 :     args[1] <<= aVBAType;
    4585 [ #  # ][ #  # ]:          0 :     args[2] <<= xProxy;
    4586                 :            : 
    4587                 :            :     try
    4588                 :            :     {
    4589         [ #  # ]:          0 :         xRet = xServiceMgr->createInstanceWithArgumentsAndContext(
    4590                 :            :             ::rtl::OUString( "com.sun.star.custom.UnoComListener"),
    4591 [ #  # ][ #  # ]:          0 :             args, xContext );
    4592                 :            :     }
    4593   [ #  #  #  # ]:          0 :     catch( const Exception& )
    4594                 :            :     {
    4595   [ #  #  #  # ]:          0 :         implHandleAnyException( ::cppu::getCaughtException() );
    4596                 :            :     }
    4597                 :            : 
    4598         [ #  # ]:          0 :     return xRet;
    4599                 :            : }
    4600                 :            : 
    4601                 :            : typedef std::vector< WeakReference< XComponent > >  ComponentRefVector;
    4602                 :            : 
    4603                 :          0 : struct StarBasicDisposeItem
    4604                 :            : {
    4605                 :            :     StarBASIC*              m_pBasic;
    4606                 :            :     SbxArrayRef             m_pRegisteredVariables;
    4607                 :            :     ComponentRefVector      m_vComImplementsObjects;
    4608                 :            : 
    4609                 :          0 :     StarBasicDisposeItem( StarBASIC* pBasic )
    4610         [ #  # ]:          0 :         : m_pBasic( pBasic )
    4611                 :            :     {
    4612 [ #  # ][ #  # ]:          0 :         m_pRegisteredVariables = new SbxArray();
                 [ #  # ]
    4613                 :          0 :     }
    4614                 :            : };
    4615                 :            : 
    4616                 :            : typedef std::vector< StarBasicDisposeItem* > DisposeItemVector;
    4617                 :            : 
    4618                 :        257 : static DisposeItemVector GaDisposeItemVector;
    4619                 :            : 
    4620                 :        715 : DisposeItemVector::iterator lcl_findItemForBasic( StarBASIC* pBasic )
    4621                 :            : {
    4622                 :        715 :     DisposeItemVector::iterator it;
    4623 [ +  - ][ -  + ]:        715 :     for( it = GaDisposeItemVector.begin() ; it != GaDisposeItemVector.end() ; ++it )
    4624                 :            :     {
    4625                 :          0 :         StarBasicDisposeItem* pItem = *it;
    4626         [ #  # ]:          0 :         if( pItem->m_pBasic == pBasic )
    4627                 :          0 :             return it;
    4628                 :            :     }
    4629                 :        715 :     return GaDisposeItemVector.end();
    4630                 :            : }
    4631                 :            : 
    4632                 :          0 : StarBasicDisposeItem* lcl_getOrCreateItemForBasic( StarBASIC* pBasic )
    4633                 :            : {
    4634         [ #  # ]:          0 :     DisposeItemVector::iterator it = lcl_findItemForBasic( pBasic );
    4635 [ #  # ][ #  # ]:          0 :     StarBasicDisposeItem* pItem = (it != GaDisposeItemVector.end()) ? *it : NULL;
    4636         [ #  # ]:          0 :     if( pItem == NULL )
    4637                 :            :     {
    4638 [ #  # ][ #  # ]:          0 :         pItem = new StarBasicDisposeItem( pBasic );
    4639         [ #  # ]:          0 :         GaDisposeItemVector.push_back( pItem );
    4640                 :            :     }
    4641                 :          0 :     return pItem;
    4642                 :            : }
    4643                 :            : 
    4644                 :          0 : void registerComponentToBeDisposedForBasic
    4645                 :            :     ( Reference< XComponent > xComponent, StarBASIC* pBasic )
    4646                 :            : {
    4647                 :          0 :     StarBasicDisposeItem* pItem = lcl_getOrCreateItemForBasic( pBasic );
    4648         [ #  # ]:          0 :     pItem->m_vComImplementsObjects.push_back( xComponent );
    4649                 :          0 : }
    4650                 :            : 
    4651                 :          0 : void registerComListenerVariableForBasic( SbxVariable* pVar, StarBASIC* pBasic )
    4652                 :            : {
    4653                 :          0 :     StarBasicDisposeItem* pItem = lcl_getOrCreateItemForBasic( pBasic );
    4654                 :          0 :     SbxArray* pArray = pItem->m_pRegisteredVariables;
    4655                 :          0 :     pArray->Put( pVar, pArray->Count() );
    4656                 :          0 : }
    4657                 :            : 
    4658                 :        715 : void disposeComVariablesForBasic( StarBASIC* pBasic )
    4659                 :            : {
    4660         [ +  - ]:        715 :     DisposeItemVector::iterator it = lcl_findItemForBasic( pBasic );
    4661 [ +  - ][ -  + ]:        715 :     if( it != GaDisposeItemVector.end() )
    4662                 :            :     {
    4663                 :          0 :         StarBasicDisposeItem* pItem = *it;
    4664                 :            : 
    4665                 :          0 :         SbxArray* pArray = pItem->m_pRegisteredVariables;
    4666         [ #  # ]:          0 :         sal_uInt16 nCount = pArray->Count();
    4667         [ #  # ]:          0 :         for( sal_uInt16 i = 0 ; i < nCount ; ++i )
    4668                 :            :         {
    4669         [ #  # ]:          0 :             SbxVariable* pVar = pArray->Get( i );
    4670         [ #  # ]:          0 :             pVar->ClearComListener();
    4671                 :            :         }
    4672                 :            : 
    4673                 :          0 :         ComponentRefVector& rv = pItem->m_vComImplementsObjects;
    4674                 :          0 :         ComponentRefVector::iterator itCRV;
    4675 [ #  # ][ #  # ]:          0 :         for( itCRV = rv.begin() ; itCRV != rv.end() ; ++itCRV )
    4676                 :            :         {
    4677                 :            :             try
    4678                 :            :             {
    4679 [ #  # ][ #  # ]:          0 :                 Reference< XComponent > xComponent( (*itCRV).get(), UNO_QUERY_THROW );
    4680 [ #  # ][ #  # ]:          0 :                 xComponent->dispose();
                 [ #  # ]
    4681                 :            :             }
    4682         [ #  # ]:          0 :             catch(const Exception& )
    4683                 :            :             {}
    4684                 :            :         }
    4685                 :            : 
    4686 [ #  # ][ #  # ]:          0 :         delete pItem;
    4687         [ #  # ]:          0 :         GaDisposeItemVector.erase( it );
    4688                 :            :     }
    4689                 :        715 : }
    4690                 :            : 
    4691                 :            : 
    4692                 :            : // Handle module implements mechanism for OLE types
    4693                 :          0 : bool SbModule::createCOMWrapperForIface( Any& o_rRetAny, SbClassModuleObject* pProxyClassModuleObject )
    4694                 :            : {
    4695                 :            :     // For now: Take first interface that allows to instantiate COM wrapper
    4696                 :            :     // TODO: Check if support for multiple interfaces is needed
    4697                 :            : 
    4698         [ #  # ]:          0 :     Reference< XComponentContext > xContext = getComponentContext_Impl();
    4699 [ #  # ][ #  # ]:          0 :     Reference< XMultiComponentFactory > xServiceMgr( xContext->getServiceManager() );
    4700                 :            :     Reference< XSingleServiceFactory > xComImplementsFactory
    4701                 :            :     (
    4702         [ #  # ]:          0 :         xServiceMgr->createInstanceWithContext(
    4703                 :          0 :             ::rtl::OUString( "com.sun.star.custom.ComImplementsFactory"), xContext ),
    4704                 :            :         UNO_QUERY
    4705 [ #  # ][ #  # ]:          0 :     );
    4706         [ #  # ]:          0 :     if( !xComImplementsFactory.is() )
    4707                 :          0 :         return false;
    4708                 :            : 
    4709                 :          0 :     bool bSuccess = false;
    4710                 :            : 
    4711                 :          0 :     SbxArray* pModIfaces = pClassData->mxIfaces;
    4712         [ #  # ]:          0 :     sal_uInt16 nCount = pModIfaces->Count();
    4713         [ #  # ]:          0 :     for( sal_uInt16 i = 0 ; i < nCount ; ++i )
    4714                 :            :     {
    4715         [ #  # ]:          0 :         SbxVariable* pVar = pModIfaces->Get( i );
    4716 [ #  # ][ #  # ]:          0 :         ::rtl::OUString aIfaceName = pVar->GetName();
    4717                 :            : 
    4718         [ #  # ]:          0 :         if( !aIfaceName.isEmpty() )
    4719                 :            :         {
    4720                 :          0 :             ::rtl::OUString aPureIfaceName = aIfaceName;
    4721                 :          0 :             sal_Int32 indexLastDot = aIfaceName.lastIndexOf('.');
    4722         [ #  # ]:          0 :             if ( indexLastDot > -1 )
    4723                 :          0 :                 aPureIfaceName = aIfaceName.copy( indexLastDot + 1 );
    4724                 :            : 
    4725 [ #  # ][ #  # ]:          0 :             Reference< XInvocation > xProxy = new ModuleInvocationProxy( aPureIfaceName, pProxyClassModuleObject );
         [ #  # ][ #  # ]
    4726                 :            : 
    4727         [ #  # ]:          0 :             Sequence<Any> args( 2 );
    4728 [ #  # ][ #  # ]:          0 :             args[0] <<= aIfaceName;
    4729 [ #  # ][ #  # ]:          0 :             args[1] <<= xProxy;
    4730                 :            : 
    4731                 :          0 :             Reference< XInterface > xRet;
    4732                 :          0 :             bSuccess = false;
    4733                 :            :             try
    4734                 :            :             {
    4735 [ #  # ][ #  # ]:          0 :                 xRet = xComImplementsFactory->createInstanceWithArguments( args );
                 [ #  # ]
    4736                 :          0 :                 bSuccess = true;
    4737                 :            :             }
    4738   [ #  #  #  # ]:          0 :             catch( const Exception& )
    4739                 :            :             {
    4740   [ #  #  #  # ]:          0 :                 implHandleAnyException( ::cppu::getCaughtException() );
    4741                 :            :             }
    4742                 :            : 
    4743         [ #  # ]:          0 :             if( bSuccess )
    4744                 :            :             {
    4745         [ #  # ]:          0 :                 Reference< XComponent > xComponent( xProxy, UNO_QUERY );
    4746         [ #  # ]:          0 :                 if( xComponent.is() )
    4747                 :            :                 {
    4748                 :          0 :                     StarBASIC* pParentBasic = NULL;
    4749                 :          0 :                     SbxObject* pCurObject = this;
    4750 [ #  # ][ #  # ]:          0 :                     do
                 [ #  # ]
    4751                 :            :                     {
    4752         [ #  # ]:          0 :                         SbxObject* pObjParent = pCurObject->GetParent();
    4753 [ #  # ][ #  # ]:          0 :                         pParentBasic = PTR_CAST( StarBASIC, pObjParent );
         [ #  # ][ #  # ]
    4754                 :          0 :                         pCurObject = pObjParent;
    4755                 :            :                     }
    4756                 :            :                     while( pParentBasic == NULL && pCurObject != NULL );
    4757                 :            : 
    4758                 :            :                     OSL_ASSERT( pParentBasic != NULL );
    4759         [ #  # ]:          0 :                     registerComponentToBeDisposedForBasic( xComponent, pParentBasic );
    4760                 :            :                 }
    4761                 :            : 
    4762         [ #  # ]:          0 :                 o_rRetAny <<= xRet;
    4763                 :          0 :                 break;
    4764 [ #  # ][ #  # ]:          0 :             }
         [ #  # ][ #  # ]
                 [ #  # ]
    4765                 :            :         }
    4766         [ #  # ]:          0 :      }
    4767                 :            : 
    4768                 :          0 :     return bSuccess;
    4769                 :            : }
    4770                 :            : 
    4771                 :            : 
    4772                 :            : // Due to an incorrect behavior IE returns an object instead of a string
    4773                 :            : // in some scenarios. Calling toString at the object may correct this.
    4774                 :            : // Helper function used in sbxvalue.cxx
    4775                 :          0 : bool handleToStringForCOMObjects( SbxObject* pObj, SbxValue* pVal )
    4776                 :            : {
    4777                 :          0 :     bool bSuccess = false;
    4778                 :            : 
    4779                 :          0 :     SbUnoObject* pUnoObj = NULL;
    4780 [ #  # ][ #  # ]:          0 :     if( pObj != NULL && (pUnoObj = PTR_CAST(SbUnoObject,(SbxObject*)pObj)) != NULL )
         [ #  # ][ #  # ]
                 [ #  # ]
    4781                 :            :     {
    4782                 :            :         // Only for native COM objects
    4783         [ #  # ]:          0 :         if( pUnoObj->isNativeCOMObject() )
    4784                 :            :         {
    4785         [ #  # ]:          0 :             SbxVariableRef pMeth = pObj->Find( ::rtl::OUString( "toString"  ), SbxCLASS_METHOD );
    4786         [ #  # ]:          0 :             if ( pMeth.Is() )
    4787                 :            :             {
    4788                 :          0 :                 SbxValues aRes;
    4789         [ #  # ]:          0 :                 pMeth->Get( aRes );
    4790         [ #  # ]:          0 :                 pVal->Put( aRes );
    4791                 :          0 :                 bSuccess = true;
    4792         [ #  # ]:          0 :             }
    4793                 :            :         }
    4794                 :            :     }
    4795                 :          0 :     return bSuccess;
    4796                 :            : }
    4797                 :            : 
    4798                 :         21 : Any StructRefInfo::getValue()
    4799                 :            : {
    4800                 :         21 :     Any aRet;
    4801                 :            :     uno_any_destruct(
    4802                 :         21 :         &aRet, reinterpret_cast< uno_ReleaseFunc >(cpp_release) );
    4803                 :            :     uno_any_construct(
    4804                 :            :         &aRet, getInst(), mpTD,
    4805                 :         21 :                 reinterpret_cast< uno_AcquireFunc >(cpp_acquire) );
    4806                 :         21 :     return aRet;
    4807                 :            : }
    4808                 :            : 
    4809                 :         12 : void StructRefInfo::setValue( const Any& rValue )
    4810                 :            : {
    4811                 :            :     uno_type_assignData( getInst(),
    4812                 :            :         mpTD->pWeakRef,
    4813                 :         12 :        (void*)rValue.getValue(),
    4814                 :            :        rValue.getValueTypeRef(),
    4815                 :            :        reinterpret_cast< uno_QueryInterfaceFunc >(cpp_queryInterface),
    4816                 :            :        reinterpret_cast< uno_AcquireFunc >(cpp_acquire),
    4817                 :         24 :        reinterpret_cast< uno_ReleaseFunc >(cpp_release) );
    4818                 :         12 : }
    4819                 :            : 
    4820                 :        381 : rtl::OUString StructRefInfo::getTypeName() const
    4821                 :            : {
    4822                 :        381 :     rtl::OUString sTypeName;
    4823         [ +  - ]:        381 :     if ( mpTD )
    4824                 :        381 :         sTypeName = mpTD->pTypeName;
    4825                 :        381 :     return sTypeName;
    4826                 :            : }
    4827                 :            : 
    4828                 :         33 : void* StructRefInfo::getInst()
    4829                 :            : {
    4830                 :         33 :     return ((char*)maAny.getValue() + mnPos );
    4831                 :            : }
    4832                 :            : 
    4833                 :         30 : TypeClass StructRefInfo::getTypeClass() const
    4834                 :            : {
    4835                 :         30 :     TypeClass t = TypeClass_VOID;
    4836         [ +  - ]:         30 :     if ( mpTD )
    4837                 :         30 :         t =  (TypeClass)mpTD->eTypeClass;
    4838                 :         30 :     return t;
    4839                 :            : }
    4840                 :            : 
    4841 [ +  - ][ +  - ]:        366 : SbUnoStructRefObject::SbUnoStructRefObject( const ::rtl::OUString& aName_, const StructRefInfo& rMemberInfo ) :  SbxObject( aName_ ), maMemberInfo( rMemberInfo ), mbMemberCacheInit( false )
         [ +  - ][ +  - ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    4842                 :            : {
    4843 [ +  - ][ +  - ]:        366 :    SetClassName( rtl::OUString( maMemberInfo.getTypeName() ) );
         [ +  - ][ #  # ]
         [ #  # ][ #  # ]
    4844                 :        366 : }
    4845                 :            : 
    4846 [ +  - ][ #  # ]:        732 : SbUnoStructRefObject::~SbUnoStructRefObject()
    4847                 :            : {
    4848 [ +  + ][ #  # ]:        594 :     for ( StructFieldInfo::iterator it = maFields.begin(), it_end = maFields.end(); it != it_end; ++it )
    4849                 :        228 :         delete it->second;
    4850 [ +  - ][ -  + ]:       1098 : }
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    4851                 :            : 
    4852                 :         27 : void SbUnoStructRefObject::initMemberCache()
    4853                 :            : {
    4854         [ -  + ]:         27 :     if ( mbMemberCacheInit )
    4855                 :         27 :         return;
    4856                 :         27 :     sal_Int32 nAll = 0;
    4857                 :         27 :     typelib_TypeDescription * pTD = maMemberInfo.getTD();
    4858                 :         27 :     typelib_CompoundTypeDescription * pCompTypeDescr = (typelib_CompoundTypeDescription *)pTD;
    4859         [ +  + ]:         54 :     for ( ; pCompTypeDescr; pCompTypeDescr = pCompTypeDescr->pBaseTypeDescription )
    4860                 :         27 :         nAll += pCompTypeDescr->nMembers;
    4861         [ +  + ]:         54 :     for ( pCompTypeDescr = (typelib_CompoundTypeDescription *)pTD; pCompTypeDescr;
    4862                 :            :         pCompTypeDescr = pCompTypeDescr->pBaseTypeDescription )
    4863                 :            :     {
    4864                 :         27 :         typelib_TypeDescriptionReference ** ppTypeRefs = pCompTypeDescr->ppTypeRefs;
    4865                 :         27 :         rtl_uString ** ppNames                         = pCompTypeDescr->ppMemberNames;
    4866                 :         27 :         sal_Int32 * pMemberOffsets                     = pCompTypeDescr->pMemberOffsets;
    4867         [ +  + ]:        255 :         for ( sal_Int32 nPos = pCompTypeDescr->nMembers; nPos--; )
    4868                 :            :         {
    4869                 :        228 :             typelib_TypeDescription * pMemberTD = 0;
    4870 [ +  - ][ -  + ]:        228 :             TYPELIB_DANGER_GET( &pMemberTD, ppTypeRefs[nPos] );
         [ +  - ][ -  + ]
                 [ #  # ]
    4871                 :            :             OSL_ENSURE( pMemberTD, "### cannot get field in struct!" );
    4872         [ +  - ]:        228 :             if (pMemberTD)
    4873                 :            :             {
    4874                 :        228 :                 rtl::OUString aName( ppNames[nPos] );
    4875 [ -  + ][ +  - ]:        228 :                 TYPELIB_DANGER_RELEASE( pMemberTD );
    4876 [ +  - ][ +  - ]:        228 :                 maFields[ aName ] = new StructRefInfo( maMemberInfo.getRootAnyRef(), pMemberTD, maMemberInfo.getPos() + pMemberOffsets[nPos] );
    4877                 :            :             }
    4878                 :            :         }
    4879                 :            :     }
    4880                 :         27 :     mbMemberCacheInit = true;
    4881                 :            : }
    4882                 :            : 
    4883                 :         15 : SbxVariable* SbUnoStructRefObject::Find( const rtl::OUString& rName, SbxClassType t )
    4884                 :            : {
    4885                 :         15 :     SbxVariable* pRes = SbxObject::Find( rName, t );
    4886         [ +  - ]:         15 :     if ( !pRes )
    4887                 :            :     {
    4888         [ +  - ]:         15 :         if ( !mbMemberCacheInit )
    4889         [ +  - ]:         15 :             initMemberCache();
    4890 [ +  - ][ +  - ]:         15 :         StructFieldInfo::iterator it = maFields.find( String( rName ).ToUpperAscii() );
         [ +  - ][ +  - ]
                 [ +  - ]
    4891         [ +  - ]:         15 :         if ( it != maFields.end() )
    4892                 :            :         {
    4893                 :            :             SbxDataType eSbxType;
    4894                 :         15 :             eSbxType = unoToSbxType( it->second->getTypeClass() );
    4895                 :         15 :             SbxDataType eRealSbxType = eSbxType;
    4896                 :         15 :             Property aProp;
    4897                 :         15 :             aProp.Name = rName;
    4898                 :         15 :             aProp.Type = com::sun::star::uno::Type( it->second->getTypeClass(), it->second->getTypeName() );
    4899 [ +  - ][ +  - ]:         15 :             SbUnoProperty* pProp = new SbUnoProperty( rName, eSbxType, eRealSbxType, aProp, 0, false, ( aProp.Type.getTypeClass() == com::sun::star::uno::TypeClass_STRUCT) );
    4900                 :         15 :             SbxVariableRef xVarRef = pProp;
    4901         [ +  - ]:         15 :             QuickInsert( (SbxVariable*)xVarRef );
    4902         [ +  - ]:         15 :             pRes = xVarRef;
    4903                 :            :         }
    4904                 :            :     }
    4905                 :            : 
    4906         [ -  + ]:         15 :     if( !pRes )
    4907                 :            :     {
    4908   [ #  #  #  #  :          0 :         if( rName.equalsIgnoreAsciiCase(ID_DBG_SUPPORTEDINTERFACES) ||
           #  # ][ #  # ]
    4909                 :          0 :             rName.equalsIgnoreAsciiCase(ID_DBG_PROPERTIES) ||
    4910                 :          0 :             rName.equalsIgnoreAsciiCase(ID_DBG_METHODS) )
    4911                 :            :         {
    4912                 :            :             // Create
    4913                 :          0 :             implCreateDbgProperties();
    4914                 :            : 
    4915                 :            :             // Now they have to be found regular
    4916                 :          0 :             pRes = SbxObject::Find( rName, SbxCLASS_DONTCARE );
    4917                 :            :         }
    4918                 :            :     }
    4919                 :            : 
    4920                 :         15 :     return pRes;
    4921                 :            : }
    4922                 :            : 
    4923                 :            : // help method to create the dbg_-Properties
    4924                 :          0 : void SbUnoStructRefObject::implCreateDbgProperties( void )
    4925                 :            : {
    4926                 :          0 :     Property aProp;
    4927                 :            : 
    4928                 :            :     // Id == -1: display the implemented interfaces corresponding the ClassProvider
    4929 [ #  # ][ #  # ]:          0 :     SbxVariableRef xVarRef = new SbUnoProperty( ::rtl::OUString(ID_DBG_SUPPORTEDINTERFACES), SbxSTRING, SbxSTRING, aProp, -1, false, false );
    4930         [ #  # ]:          0 :     QuickInsert( (SbxVariable*)xVarRef );
    4931                 :            : 
    4932                 :            :     // Id == -2: output the properties
    4933 [ #  # ][ #  # ]:          0 :     xVarRef = new SbUnoProperty( ::rtl::OUString(ID_DBG_PROPERTIES), SbxSTRING, SbxSTRING, aProp, -2, false, false );
                 [ #  # ]
    4934         [ #  # ]:          0 :     QuickInsert( (SbxVariable*)xVarRef );
    4935                 :            : 
    4936                 :            :     // Id == -3: output the Methods
    4937 [ #  # ][ #  # ]:          0 :     xVarRef = new SbUnoProperty( ::rtl::OUString(ID_DBG_METHODS), SbxSTRING, SbxSTRING, aProp, -3, false, false );
                 [ #  # ]
    4938 [ #  # ][ #  # ]:          0 :     QuickInsert( (SbxVariable*)xVarRef );
    4939                 :          0 : }
    4940                 :            : 
    4941                 :          0 : void SbUnoStructRefObject::implCreateAll()
    4942                 :            : {
    4943                 :            :      // throw away all existing methods and properties
    4944         [ #  # ]:          0 :     pMethods   = new SbxArray;
    4945         [ #  # ]:          0 :     pProps     = new SbxArray;
    4946                 :            : 
    4947         [ #  # ]:          0 :     if (!mbMemberCacheInit)
    4948                 :          0 :         initMemberCache();
    4949                 :            : 
    4950         [ #  # ]:          0 :     for ( StructFieldInfo::iterator it = maFields.begin(), it_end = maFields.end(); it != it_end; ++it )
    4951                 :            :     {
    4952                 :          0 :         const rtl::OUString& rName = it->first;
    4953                 :            :         SbxDataType eSbxType;
    4954                 :          0 :         eSbxType = unoToSbxType( it->second->getTypeClass() );
    4955                 :          0 :         SbxDataType eRealSbxType = eSbxType;
    4956                 :          0 :         Property aProp;
    4957                 :          0 :         aProp.Name = rName;
    4958                 :          0 :         aProp.Type = com::sun::star::uno::Type( it->second->getTypeClass(), it->second->getTypeName() );
    4959 [ #  # ][ #  # ]:          0 :         SbUnoProperty* pProp = new SbUnoProperty( rName, eSbxType, eRealSbxType, aProp, 0, false, ( aProp.Type.getTypeClass() == com::sun::star::uno::TypeClass_STRUCT) );
    4960                 :          0 :         SbxVariableRef xVarRef = pProp;
    4961         [ #  # ]:          0 :         QuickInsert( (SbxVariable*)xVarRef );
    4962         [ #  # ]:          0 :     }
    4963                 :            : 
    4964                 :            :     // Create Dbg_-Properties
    4965                 :          0 :     implCreateDbgProperties();
    4966                 :          0 : }
    4967                 :            : 
    4968                 :            :  // output the value
    4969                 :          9 : Any SbUnoStructRefObject::getUnoAny( void )
    4970                 :            : {
    4971                 :          9 :     return maMemberInfo.getValue();
    4972                 :            : }
    4973                 :            : 
    4974                 :          0 : ::rtl::OUString SbUnoStructRefObject::Impl_DumpProperties()
    4975                 :            : {
    4976                 :          0 :     ::rtl::OUStringBuffer aRet;
    4977         [ #  # ]:          0 :     aRet.appendAscii("Properties of object ");
    4978 [ #  # ][ #  # ]:          0 :     aRet.append( getDbgObjectName() );
    4979                 :            : 
    4980         [ #  # ]:          0 :     sal_uInt16 nPropCount = pProps->Count();
    4981                 :          0 :     sal_uInt16 nPropsPerLine = 1 + nPropCount / 30;
    4982         [ #  # ]:          0 :     for( sal_uInt16 i = 0; i < nPropCount; i++ )
    4983                 :            :     {
    4984         [ #  # ]:          0 :         SbxVariable* pVar = pProps->Get( i );
    4985         [ #  # ]:          0 :         if( pVar )
    4986                 :            :         {
    4987                 :          0 :             ::rtl::OUStringBuffer aPropStr;
    4988         [ #  # ]:          0 :             if( (i % nPropsPerLine) == 0 )
    4989         [ #  # ]:          0 :                 aPropStr.appendAscii( "\n" );
    4990                 :            : 
    4991                 :            :             // output the type and name
    4992                 :            :             // Is it in Uno a sequence?
    4993         [ #  # ]:          0 :             SbxDataType eType = pVar->GetFullType();
    4994                 :            : 
    4995                 :          0 :             sal_Bool bMaybeVoid = sal_False;
    4996 [ #  # ][ #  # ]:          0 :             rtl::OUString aName( pVar->GetName() );
    4997         [ #  # ]:          0 :             StructFieldInfo::iterator it = maFields.find( aName );
    4998                 :            : 
    4999         [ #  # ]:          0 :             if ( it != maFields.end() )
    5000                 :            :             {
    5001                 :          0 :                 const StructRefInfo& rPropInfo = *it->second;
    5002                 :            : 
    5003         [ #  # ]:          0 :                 if( eType == SbxOBJECT )
    5004                 :            :                 {
    5005         [ #  # ]:          0 :                     if( rPropInfo.getTypeClass() == TypeClass_SEQUENCE )
    5006                 :          0 :                         eType = (SbxDataType) ( SbxOBJECT | SbxARRAY );
    5007                 :            :                 }
    5008                 :            :             }
    5009 [ #  # ][ #  # ]:          0 :             aPropStr.append( Dbg_SbxDataType2String( eType ) );
    5010         [ #  # ]:          0 :             if( bMaybeVoid )
    5011         [ #  # ]:          0 :                 aPropStr.appendAscii( "/void" );
    5012         [ #  # ]:          0 :             aPropStr.appendAscii( " " );
    5013 [ #  # ][ #  # ]:          0 :             aPropStr.append( pVar->GetName() );
                 [ #  # ]
    5014                 :            : 
    5015         [ #  # ]:          0 :             if( i == nPropCount - 1 )
    5016         [ #  # ]:          0 :                 aPropStr.appendAscii( "\n" );
    5017                 :            :             else
    5018         [ #  # ]:          0 :                 aPropStr.appendAscii( "; " );
    5019                 :            : 
    5020 [ #  # ][ #  # ]:          0 :             aRet.append( aPropStr.makeStringAndClear() );
    5021                 :            :         }
    5022                 :            :     }
    5023         [ #  # ]:          0 :     return aRet.makeStringAndClear();
    5024                 :            : }
    5025                 :            : 
    5026                 :         15 : void SbUnoStructRefObject::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType,
    5027                 :            :                            const SfxHint& rHint, const TypeId& rHintType )
    5028                 :            : {
    5029         [ -  + ]:         15 :     if ( !mbMemberCacheInit )
    5030                 :          0 :         initMemberCache();
    5031 [ +  - ][ +  - ]:         15 :     const SbxHint* pHint = PTR_CAST(SbxHint,&rHint);
    5032         [ +  - ]:         15 :     if( pHint )
    5033                 :            :     {
    5034                 :         15 :         SbxVariable* pVar = pHint->GetVar();
    5035 [ +  - ][ +  - ]:         15 :         SbUnoProperty* pProp = PTR_CAST(SbUnoProperty,pVar);
    5036         [ +  - ]:         15 :         if( pProp )
    5037                 :            :         {
    5038 [ +  - ][ +  - ]:         15 :              StructFieldInfo::iterator it =  maFields.find(  pProp->GetName() );
                 [ +  - ]
    5039                 :            :             // handle get/set of members of struct
    5040         [ +  + ]:         15 :             if( pHint->GetId() == SBX_HINT_DATAWANTED )
    5041                 :            :             {
    5042                 :            :                 // Test-Properties
    5043                 :         12 :                 sal_Int32 nId = pProp->nId;
    5044         [ -  + ]:         12 :                 if( nId < 0 )
    5045                 :            :                 {
    5046                 :            :                     // Id == -1: Display implemented interfaces according the ClassProvider
    5047         [ #  # ]:          0 :                     if( nId == -1 )     // Property ID_DBG_SUPPORTEDINTERFACES"
    5048                 :            :                     {
    5049                 :          0 :                         ::rtl::OUStringBuffer aRet;
    5050         [ #  # ]:          0 :                         aRet.appendAscii( RTL_CONSTASCII_STRINGPARAM(ID_DBG_SUPPORTEDINTERFACES) );
    5051         [ #  # ]:          0 :                         aRet.appendAscii( " not available.\n(TypeClass is not TypeClass_INTERFACE)\n" );
    5052                 :            : 
    5053 [ #  # ][ #  # ]:          0 :                         pVar->PutString( aRet.makeStringAndClear() );
    5054                 :            :                     }
    5055                 :            :                     // Id == -2: output properties
    5056         [ #  # ]:          0 :                     else if( nId == -2 )        // Property ID_DBG_PROPERTIES
    5057                 :            :                     {
    5058                 :            :                         // by now all properties must be established
    5059         [ #  # ]:          0 :                         implCreateAll();
    5060         [ #  # ]:          0 :                         ::rtl::OUString aRetStr = Impl_DumpProperties();
    5061         [ #  # ]:          0 :                         pVar->PutString( aRetStr );
    5062                 :            :                     }
    5063                 :            :                     // Id == -3: output the methods
    5064         [ #  # ]:          0 :                     else if( nId == -3 )        // Property ID_DBG_METHODS
    5065                 :            :                     {
    5066                 :            :                         // by now all properties must be established
    5067         [ #  # ]:          0 :                         implCreateAll();
    5068                 :          0 :                         ::rtl::OUStringBuffer aRet;
    5069         [ #  # ]:          0 :                         aRet.appendAscii("Methods of object ");
    5070 [ #  # ][ #  # ]:          0 :                         aRet.append( getDbgObjectName() );
    5071         [ #  # ]:          0 :                         aRet.appendAscii( "\nNo methods found\n" );
    5072 [ #  # ][ #  # ]:          0 :                         pVar->PutString( aRet.makeStringAndClear() );
    5073                 :            :                     }
    5074                 :         15 :                     return;
    5075                 :            :                 }
    5076                 :            : 
    5077         [ +  - ]:         12 :                 if ( it != maFields.end() )
    5078                 :            :                 {
    5079         [ +  - ]:         12 :                     Any aRetAny = it->second->getValue();
    5080         [ +  - ]:         12 :                     unoToSbxValue( pVar, aRetAny );
    5081                 :            :                 }
    5082                 :            :                 else
    5083         [ #  # ]:          0 :                     StarBASIC::Error( SbERR_PROPERTY_NOT_FOUND );
    5084                 :            :             }
    5085         [ +  - ]:          3 :             else if( pHint->GetId() == SBX_HINT_DATACHANGED )
    5086                 :            :             {
    5087         [ +  - ]:          3 :                 if ( it != maFields.end() )
    5088                 :            :                 {
    5089                 :            :                     // take over the value from Uno to Sbx
    5090         [ +  - ]:          3 :                     Any aAnyValue = sbxToUnoValue( pVar, pProp->aUnoProp.Type, &pProp->aUnoProp );
    5091         [ +  - ]:          3 :                     it->second->setValue( aAnyValue );
    5092                 :            :                 }
    5093                 :            :                 else
    5094         [ #  # ]:         15 :                     StarBASIC::Error( SbERR_PROPERTY_NOT_FOUND );
    5095                 :            :             }
    5096                 :            :         }
    5097                 :            :         else
    5098                 :          0 :            SbxObject::SFX_NOTIFY( rBC, rBCType, rHint, rHintType );
    5099                 :            :     }
    5100                 :            : }
    5101                 :            : 
    5102                 :         39 : StructRefInfo SbUnoStructRefObject::getStructMember( const rtl::OUString& rMemberName )
    5103                 :            : {
    5104         [ +  + ]:         39 :     if (!mbMemberCacheInit)
    5105         [ +  - ]:         12 :         initMemberCache();
    5106         [ +  - ]:         39 :     StructFieldInfo::iterator it = maFields.find( rMemberName );
    5107                 :            : 
    5108                 :         39 :     typelib_TypeDescription * pFoundTD = NULL;
    5109                 :         39 :     sal_Int32 nFoundPos = -1;
    5110                 :            : 
    5111         [ +  - ]:         39 :     if ( it != maFields.end() )
    5112                 :            :     {
    5113                 :         39 :         pFoundTD = it->second->getTD();
    5114                 :         39 :         nFoundPos = it->second->getPos();
    5115                 :            :     }
    5116                 :         39 :     StructRefInfo aRet( maMemberInfo.getRootAnyRef(), pFoundTD, nFoundPos );
    5117                 :         39 :     return aRet;
    5118                 :            : }
    5119                 :            : 
    5120                 :          0 : rtl::OUString SbUnoStructRefObject::getDbgObjectName()
    5121                 :            : {
    5122         [ #  # ]:          0 :     ::rtl::OUString aName = GetClassName();
    5123         [ #  # ]:          0 :     if( aName.isEmpty() )
    5124                 :          0 :         aName += ::rtl::OUString("Unknown");
    5125                 :            : 
    5126                 :          0 :     ::rtl::OUStringBuffer aRet;
    5127         [ #  # ]:          0 :     if( aName.getLength() > 20 )
    5128         [ #  # ]:          0 :         aRet.appendAscii( "\n" );
    5129         [ #  # ]:          0 :     aRet.appendAscii( "\"" );
    5130         [ #  # ]:          0 :     aRet.append( aName );
    5131         [ #  # ]:          0 :     aRet.appendAscii( "\":" );
    5132         [ #  # ]:          0 :     return aRet.makeStringAndClear();
    5133 [ +  - ][ +  - ]:        771 : }
    5134                 :            : 
    5135                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10