LCOV - code coverage report
Current view: top level - basic/source/classes - sbxmod.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 564 1398 40.3 %
Date: 2012-08-25 Functions: 77 217 35.5 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 619 2682 23.1 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*
       3                 :            :  * This file is part of the LibreOffice project.
       4                 :            :  *
       5                 :            :  * This Source Code Form is subject to the terms of the Mozilla Public
       6                 :            :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7                 :            :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8                 :            :  *
       9                 :            :  * This file incorporates work covered by the following license notice:
      10                 :            :  *
      11                 :            :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12                 :            :  *   contributor license agreements. See the NOTICE file distributed
      13                 :            :  *   with this work for additional information regarding copyright
      14                 :            :  *   ownership. The ASF licenses this file to you under the Apache
      15                 :            :  *   License, Version 2.0 (the "License"); you may not use this file
      16                 :            :  *   except in compliance with the License. You may obtain a copy of
      17                 :            :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18                 :            :  */
      19                 :            : 
      20                 :            : 
      21                 :            : #include <list>
      22                 :            : 
      23                 :            : #include <vcl/svapp.hxx>
      24                 :            : #include <tools/stream.hxx>
      25                 :            : #include <svl/brdcst.hxx>
      26                 :            : #include <tools/shl.hxx>
      27                 :            : #include <basic/sbx.hxx>
      28                 :            : #include "sbdiagnose.hxx"
      29                 :            : #include "sb.hxx"
      30                 :            : #include <sbjsmeth.hxx>
      31                 :            : #include "sbjsmod.hxx"
      32                 :            : #include "sbintern.hxx"
      33                 :            : #include "image.hxx"
      34                 :            : #include "opcodes.hxx"
      35                 :            : #include "runtime.hxx"
      36                 :            : #include "token.hxx"
      37                 :            : #include "sbunoobj.hxx"
      38                 :            : 
      39                 :            : #include <svtools/syntaxhighlight.hxx>
      40                 :            : 
      41                 :            : #include <basic/basrdll.hxx>
      42                 :            : #include <osl/mutex.hxx>
      43                 :            : #include <basic/sbobjmod.hxx>
      44                 :            : #include <basic/vbahelper.hxx>
      45                 :            : #include <cppuhelper/implbase3.hxx>
      46                 :            : #include <unotools/eventcfg.hxx>
      47                 :            : #include <com/sun/star/lang/XServiceInfo.hpp>
      48                 :            : #include <com/sun/star/script/ModuleType.hpp>
      49                 :            : #include <com/sun/star/script/vba/XVBACompatibility.hpp>
      50                 :            : #include <com/sun/star/document/XVbaMethodParameter.hpp>
      51                 :            : #include <com/sun/star/script/vba/VBAScriptEventId.hpp>
      52                 :            : #include <com/sun/star/beans/XPropertySet.hpp>
      53                 :            : #include <com/sun/star/document/XEventBroadcaster.hpp>
      54                 :            : #include <com/sun/star/document/XEventListener.hpp>
      55                 :            : 
      56                 :            : using namespace com::sun::star;
      57                 :            : 
      58                 :            : // for the bsearch
      59                 :            : #ifdef WNT
      60                 :            : #define CDECL _cdecl
      61                 :            : #endif
      62                 :            : #if defined(UNX)
      63                 :            : #define CDECL
      64                 :            : #endif
      65                 :            : #ifdef UNX
      66                 :            : #include <sys/resource.h>
      67                 :            : #endif
      68                 :            : 
      69                 :            : #include <stdio.h>
      70                 :            : #include <com/sun/star/frame/XDesktop.hpp>
      71                 :            : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      72                 :            : #include <comphelper/processfactory.hxx>
      73                 :            : #include <map>
      74                 :            : #include <com/sun/star/reflection/XProxyFactory.hpp>
      75                 :            : #include <cppuhelper/implbase1.hxx>
      76                 :            : #include <com/sun/star/uno/XAggregation.hpp>
      77                 :            : #include <com/sun/star/script/XInvocation.hpp>
      78                 :            : 
      79                 :            : using namespace ::com::sun::star;
      80                 :            : using namespace com::sun::star::lang;
      81                 :            : using namespace com::sun::star::reflection;
      82                 :            : using namespace com::sun::star::beans;
      83                 :            : using namespace com::sun::star::script;
      84                 :            : 
      85                 :            : 
      86                 :            : #include <com/sun/star/script/XLibraryContainer.hpp>
      87                 :            : #include <com/sun/star/awt/XDialogProvider.hpp>
      88                 :            : #include <com/sun/star/awt/XTopWindow.hpp>
      89                 :            : #include <com/sun/star/awt/XWindow.hpp>
      90                 :            : #include <com/sun/star/awt/XControl.hpp>
      91                 :            : #include <comphelper/anytostring.hxx>
      92                 :            : #include <ooo/vba/VbQueryClose.hpp>
      93                 :            : 
      94                 :            : typedef ::cppu::WeakImplHelper1< XInvocation > DocObjectWrapper_BASE;
      95                 :            : typedef ::std::map< sal_Int16, Any, ::std::less< sal_Int16 > > OutParamMap;
      96                 :            : ::com::sun::star::uno::Any sbxToUnoValue( SbxVariable* pVar );
      97                 :            : void unoToSbxValue( SbxVariable* pVar, const ::com::sun::star::uno::Any& aValue );
      98                 :            : 
      99                 :            : class DocObjectWrapper : public DocObjectWrapper_BASE
     100                 :            : {
     101                 :            :     Reference< XAggregation >  m_xAggProxy;
     102                 :            :     Reference< XInvocation >  m_xAggInv;
     103                 :            :     Reference< XTypeProvider > m_xAggregateTypeProv;
     104                 :            :     Sequence< Type >           m_Types;
     105                 :            :     SbModule*                m_pMod;
     106                 :            :     SbMethodRef getMethod( const rtl::OUString& aName ) throw (RuntimeException);
     107                 :            :     SbPropertyRef getProperty( const rtl::OUString& aName ) throw (RuntimeException);
     108                 :            :     String mName; // for debugging
     109                 :            : 
     110                 :            : public:
     111                 :            :     DocObjectWrapper( SbModule* pMod );
     112                 :            :     virtual ~DocObjectWrapper();
     113                 :            : 
     114                 :            :     virtual void SAL_CALL acquire() throw();
     115                 :            :     virtual void SAL_CALL release() throw();
     116                 :            : 
     117                 :         22 :     virtual Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (RuntimeException)
     118                 :            :     {
     119         [ -  + ]:         22 :         if( !m_xAggregateTypeProv.is() )
     120         [ #  # ]:          0 :             throw RuntimeException();
     121                 :         22 :         return m_xAggregateTypeProv->getImplementationId();
     122                 :            :     }
     123                 :            : 
     124                 :            :     virtual Reference< XIntrospectionAccess > SAL_CALL getIntrospection(  ) throw (RuntimeException);
     125                 :            : 
     126                 :            :     virtual Any SAL_CALL invoke( const ::rtl::OUString& aFunctionName, const Sequence< Any >& aParams, Sequence< ::sal_Int16 >& aOutParamIndex, Sequence< Any >& aOutParam ) throw (IllegalArgumentException, CannotConvertException, InvocationTargetException, RuntimeException);
     127                 :            :     virtual void SAL_CALL setValue( const ::rtl::OUString& aPropertyName, const Any& aValue ) throw (UnknownPropertyException, CannotConvertException, InvocationTargetException, RuntimeException);
     128                 :            :     virtual Any SAL_CALL getValue( const ::rtl::OUString& aPropertyName ) throw (UnknownPropertyException, RuntimeException);
     129                 :            :     virtual ::sal_Bool SAL_CALL hasMethod( const ::rtl::OUString& aName ) throw (RuntimeException);
     130                 :            :     virtual ::sal_Bool SAL_CALL hasProperty( const ::rtl::OUString& aName ) throw (RuntimeException);
     131                 :            :     virtual  Any SAL_CALL queryInterface( const Type& aType ) throw ( RuntimeException );
     132                 :            : 
     133                 :            :     virtual Sequence< Type > SAL_CALL getTypes() throw ( RuntimeException );
     134                 :            : };
     135                 :            : 
     136 [ +  - ][ +  - ]:          8 : DocObjectWrapper::DocObjectWrapper( SbModule* pVar ) : m_pMod( pVar ), mName( pVar->GetName() )
                 [ +  - ]
     137                 :            : {
     138 [ +  - ][ +  - ]:          8 :     SbObjModule* pMod = PTR_CAST(SbObjModule,pVar);
         [ +  - ][ +  - ]
     139         [ +  - ]:          8 :     if ( pMod )
     140                 :            :     {
     141         [ +  - ]:          8 :         if ( pMod->GetModuleType() == ModuleType::DOCUMENT )
     142                 :            :         {
     143         [ +  - ]:          8 :             Reference< XMultiServiceFactory > xFactory = comphelper::getProcessServiceFactory();
     144                 :            :             // Use proxy factory service to create aggregatable proxy.
     145 [ +  - ][ +  - ]:          8 :             SbUnoObject* pUnoObj = PTR_CAST(SbUnoObject,pMod->GetObject() );
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
                 [ +  - ]
     146                 :          8 :             Reference< XInterface > xIf;
     147         [ +  - ]:          8 :             if ( pUnoObj )
     148                 :            :             {
     149         [ +  - ]:          8 :                    Any aObj = pUnoObj->getUnoAny();
     150         [ +  - ]:          8 :                    aObj >>= xIf;
     151         [ +  - ]:          8 :                    if ( xIf.is() )
     152                 :            :                    {
     153         [ +  - ]:          8 :                        m_xAggregateTypeProv.set( xIf, UNO_QUERY );
     154         [ +  - ]:          8 :                        m_xAggInv.set( xIf, UNO_QUERY );
     155                 :          8 :                    }
     156                 :            :             }
     157         [ +  - ]:          8 :             if ( xIf.is() )
     158                 :            :             {
     159                 :            :                 try
     160                 :            :                 {
     161         [ +  - ]:          8 :                     Reference< XMultiComponentFactory > xMFac( xFactory, UNO_QUERY_THROW );
     162         [ +  - ]:          8 :                     Reference< XPropertySet> xPSMPropertySet( xMFac, UNO_QUERY_THROW );
     163                 :          8 :                     Reference< XComponentContext >  xCtx;
     164         [ +  - ]:          8 :                     xPSMPropertySet->getPropertyValue(
     165 [ +  - ][ +  - ]:          8 :                     String( RTL_CONSTASCII_USTRINGPARAM("DefaultContext") ) ) >>= xCtx;
         [ +  - ][ +  - ]
                 [ +  - ]
     166 [ +  - ][ +  - ]:          8 :                     Reference< XProxyFactory > xProxyFac( xMFac->createInstanceWithContext( rtl::OUString( "com.sun.star.reflection.ProxyFactory"  ), xCtx  ), UNO_QUERY_THROW );
                 [ +  - ]
     167 [ +  - ][ +  - ]:          8 :                     m_xAggProxy = xProxyFac->createProxy( xIf );
         [ #  # ][ +  - ]
     168                 :            :                 }
     169         [ #  # ]:          0 :                 catch(const Exception& )
     170                 :            :                 {
     171                 :            :                     OSL_FAIL( "DocObjectWrapper::DocObjectWrapper: Caught exception!" );
     172                 :            :                 }
     173                 :            :             }
     174                 :            : 
     175         [ +  - ]:          8 :             if ( m_xAggProxy.is() )
     176                 :            :             {
     177         [ +  - ]:          8 :                 osl_incrementInterlockedCount( &m_refCount );
     178                 :            : 
     179                 :            :                 /* i35609 - Fix crash on Solaris. The setDelegator call needs
     180                 :            :                     to be in its own block to ensure that all temporary Reference
     181                 :            :                     instances that are acquired during the call are released
     182                 :            :                     before m_refCount is decremented again */
     183                 :            :                 {
     184 [ +  - ][ +  - ]:          8 :                     m_xAggProxy->setDelegator( static_cast< cppu::OWeakObject * >( this ) );
                 [ +  - ]
     185                 :            :                 }
     186                 :            : 
     187         [ +  - ]:          8 :                  osl_decrementInterlockedCount( &m_refCount );
     188                 :          8 :             }
     189                 :            :         }
     190                 :            :     }
     191                 :          8 : }
     192                 :            : 
     193                 :            : void SAL_CALL
     194                 :       6728 : DocObjectWrapper::acquire() throw ()
     195                 :            : {
     196                 :       6728 :     osl_incrementInterlockedCount( &m_refCount );
     197                 :            :     OSL_TRACE("DocObjectWrapper::acquire(%s) 0x%x refcount is now %d", rtl::OUStringToOString( mName, RTL_TEXTENCODING_UTF8 ).getStr(), this, m_refCount );
     198                 :       6728 : }
     199                 :            : void SAL_CALL
     200                 :       6728 : DocObjectWrapper::release() throw ()
     201                 :            : {
     202         [ +  + ]:       6728 :     if ( osl_decrementInterlockedCount( &m_refCount ) == 0 )
     203                 :            :     {
     204                 :            :         OSL_TRACE("DocObjectWrapper::release(%s) 0x%x refcount is now %d", rtl::OUStringToOString( mName, RTL_TEXTENCODING_UTF8 ).getStr(), this, m_refCount );
     205         [ +  - ]:          8 :         delete this;
     206                 :            :     }
     207                 :            :     else
     208                 :            :         OSL_TRACE("DocObjectWrapper::release(%s) 0x%x refcount is now %d", rtl::OUStringToOString( mName, RTL_TEXTENCODING_UTF8 ).getStr(), this, m_refCount );
     209                 :       6728 : }
     210                 :            : 
     211 [ +  - ][ +  - ]:          8 : DocObjectWrapper::~DocObjectWrapper()
     212                 :            : {
     213         [ -  + ]:         16 : }
     214                 :            : 
     215                 :         22 : Sequence< Type > SAL_CALL DocObjectWrapper::getTypes()
     216                 :            :     throw ( RuntimeException )
     217                 :            : {
     218         [ +  + ]:         22 :     if ( m_Types.getLength() == 0 )
     219                 :            :     {
     220         [ +  - ]:          2 :         Sequence< Type > sTypes;
     221         [ +  - ]:          2 :         if ( m_xAggregateTypeProv.is() )
     222 [ +  - ][ +  - ]:          2 :             sTypes = m_xAggregateTypeProv->getTypes();
         [ +  - ][ +  - ]
     223         [ +  - ]:          2 :         m_Types.realloc( sTypes.getLength() + 1 );
     224         [ +  - ]:          2 :         Type* pPtr = m_Types.getArray();
     225         [ +  + ]:         10 :         for ( int i=0; i<m_Types.getLength(); ++i, ++pPtr )
     226                 :            :         {
     227         [ +  + ]:          8 :             if ( i == 0 )
     228         [ +  - ]:          2 :                 *pPtr = XInvocation::static_type( NULL );
     229                 :            :             else
     230         [ +  - ]:          6 :                 *pPtr = sTypes[ i - 1 ];
     231         [ +  - ]:          2 :         }
     232                 :            :     }
     233                 :         22 :     return m_Types;
     234                 :            : }
     235                 :            : 
     236                 :            : Reference< XIntrospectionAccess > SAL_CALL
     237                 :          0 : DocObjectWrapper::getIntrospection(  ) throw (RuntimeException)
     238                 :            : {
     239                 :          0 :     return NULL;
     240                 :            : }
     241                 :            : 
     242                 :            : Any SAL_CALL
     243                 :          0 : DocObjectWrapper::invoke( const ::rtl::OUString& aFunctionName, const Sequence< Any >& aParams, Sequence< ::sal_Int16 >& aOutParamIndex, Sequence< Any >& aOutParam ) throw (IllegalArgumentException, CannotConvertException, InvocationTargetException, RuntimeException)
     244                 :            : {
     245 [ #  # ][ #  # ]:          0 :     if ( m_xAggInv.is() &&  m_xAggInv->hasMethod( aFunctionName ) )
         [ #  # ][ #  # ]
                 [ #  # ]
     246 [ #  # ][ #  # ]:          0 :             return m_xAggInv->invoke( aFunctionName, aParams, aOutParamIndex, aOutParam );
     247         [ #  # ]:          0 :     SbMethodRef pMethod = getMethod( aFunctionName );
     248         [ #  # ]:          0 :     if ( !pMethod )
     249         [ #  # ]:          0 :         throw RuntimeException();
     250                 :            :     // check number of parameters
     251                 :          0 :     sal_Int32 nParamsCount = aParams.getLength();
     252         [ #  # ]:          0 :     SbxInfo* pInfo = pMethod->GetInfo();
     253         [ #  # ]:          0 :     if ( pInfo )
     254                 :            :     {
     255                 :          0 :         sal_Int32 nSbxOptional = 0;
     256                 :          0 :         sal_uInt16 n = 1;
     257 [ #  # ][ #  # ]:          0 :         for ( const SbxParamInfo* pParamInfo = pInfo->GetParam( n ); pParamInfo; pParamInfo = pInfo->GetParam( ++n ) )
                 [ #  # ]
     258                 :            :         {
     259         [ #  # ]:          0 :             if ( ( pParamInfo->nFlags & SBX_OPTIONAL ) != 0 )
     260                 :          0 :                 ++nSbxOptional;
     261                 :            :             else
     262                 :          0 :                 nSbxOptional = 0;
     263                 :            :         }
     264                 :          0 :         sal_Int32 nSbxCount = n - 1;
     265         [ #  # ]:          0 :         if ( nParamsCount < nSbxCount - nSbxOptional )
     266                 :            :         {
     267         [ #  # ]:          0 :             throw RuntimeException( ::rtl::OUString( "wrong number of parameters!"  ), Reference< XInterface >() );
     268                 :            :         }
     269                 :            :     }
     270                 :            :     // set parameters
     271                 :          0 :     SbxArrayRef xSbxParams;
     272         [ #  # ]:          0 :     if ( nParamsCount > 0 )
     273                 :            :     {
     274 [ #  # ][ #  # ]:          0 :         xSbxParams = new SbxArray;
                 [ #  # ]
     275                 :          0 :         const Any* pParams = aParams.getConstArray();
     276         [ #  # ]:          0 :         for ( sal_Int32 i = 0; i < nParamsCount; ++i )
     277                 :            :         {
     278 [ #  # ][ #  # ]:          0 :             SbxVariableRef xSbxVar = new SbxVariable( SbxVARIANT );
     279         [ #  # ]:          0 :             unoToSbxValue( static_cast< SbxVariable* >( xSbxVar ), pParams[i] );
     280         [ #  # ]:          0 :             xSbxParams->Put( xSbxVar, static_cast< sal_uInt16 >( i ) + 1 );
     281                 :            : 
     282                 :            :             // Enable passing by ref
     283 [ #  # ][ #  # ]:          0 :             if ( xSbxVar->GetType() != SbxVARIANT )
     284                 :          0 :                 xSbxVar->SetFlag( SBX_FIXED );
     285         [ #  # ]:          0 :         }
     286                 :            :     }
     287         [ #  # ]:          0 :     if ( xSbxParams.Is() )
     288         [ #  # ]:          0 :         pMethod->SetParameters( xSbxParams );
     289                 :            : 
     290                 :            :     // call method
     291 [ #  # ][ #  # ]:          0 :     SbxVariableRef xReturn = new SbxVariable;
     292                 :            : 
     293         [ #  # ]:          0 :     pMethod->Call( xReturn );
     294                 :          0 :     Any aReturn;
     295                 :            :     // get output parameters
     296         [ #  # ]:          0 :     if ( xSbxParams.Is() )
     297                 :            :     {
     298         [ #  # ]:          0 :         SbxInfo* pInfo_ = pMethod->GetInfo();
     299         [ #  # ]:          0 :         if ( pInfo_ )
     300                 :            :         {
     301         [ #  # ]:          0 :             OutParamMap aOutParamMap;
     302 [ #  # ][ #  # ]:          0 :             for ( sal_uInt16 n = 1, nCount = xSbxParams->Count(); n < nCount; ++n )
     303                 :            :             {
     304         [ #  # ]:          0 :                 const SbxParamInfo* pParamInfo = pInfo_->GetParam( n );
     305 [ #  # ][ #  # ]:          0 :                 if ( pParamInfo && ( pParamInfo->eType & SbxBYREF ) != 0 )
     306                 :            :                 {
     307         [ #  # ]:          0 :                     SbxVariable* pVar = xSbxParams->Get( n );
     308         [ #  # ]:          0 :                     if ( pVar )
     309                 :            :                     {
     310                 :          0 :                         SbxVariableRef xVar = pVar;
     311 [ #  # ][ #  # ]:          0 :                         aOutParamMap.insert( OutParamMap::value_type( n - 1, sbxToUnoValue( xVar ) ) );
                 [ #  # ]
     312                 :            :                     }
     313                 :            :                 }
     314                 :            :             }
     315                 :          0 :             sal_Int32 nOutParamCount = aOutParamMap.size();
     316         [ #  # ]:          0 :             aOutParamIndex.realloc( nOutParamCount );
     317         [ #  # ]:          0 :             aOutParam.realloc( nOutParamCount );
     318         [ #  # ]:          0 :             sal_Int16* pOutParamIndex = aOutParamIndex.getArray();
     319         [ #  # ]:          0 :             Any* pOutParam = aOutParam.getArray();
     320         [ #  # ]:          0 :             for ( OutParamMap::iterator aIt = aOutParamMap.begin(); aIt != aOutParamMap.end(); ++aIt, ++pOutParamIndex, ++pOutParam )
     321                 :            :             {
     322                 :          0 :                 *pOutParamIndex = aIt->first;
     323                 :          0 :                 *pOutParam = aIt->second;
     324                 :          0 :             }
     325                 :            :         }
     326                 :            :     }
     327                 :            : 
     328                 :            :     // get return value
     329         [ #  # ]:          0 :     aReturn = sbxToUnoValue( xReturn );
     330                 :            : 
     331         [ #  # ]:          0 :     pMethod->SetParameters( NULL );
     332                 :            : 
     333 [ #  # ][ #  # ]:          0 :     return aReturn;
                 [ #  # ]
     334                 :            : }
     335                 :            : 
     336                 :            : void SAL_CALL
     337                 :          0 : DocObjectWrapper::setValue( const ::rtl::OUString& aPropertyName, const Any& aValue ) throw (UnknownPropertyException, CannotConvertException, InvocationTargetException, RuntimeException)
     338                 :            : {
     339 [ #  # ][ #  # ]:          0 :     if ( m_xAggInv.is() &&  m_xAggInv->hasProperty( aPropertyName ) )
         [ #  # ][ #  # ]
                 [ #  # ]
     340 [ #  # ][ #  # ]:          0 :             return m_xAggInv->setValue( aPropertyName, aValue );
     341                 :            : 
     342         [ #  # ]:          0 :     SbPropertyRef pProperty = getProperty( aPropertyName );
     343         [ #  # ]:          0 :     if ( !pProperty.Is() )
     344         [ #  # ]:          0 :        throw UnknownPropertyException();
     345 [ #  # ][ #  # ]:          0 :     unoToSbxValue( (SbxVariable*) pProperty, aValue );
     346                 :            : }
     347                 :            : 
     348                 :            : Any SAL_CALL
     349                 :          0 : DocObjectWrapper::getValue( const ::rtl::OUString& aPropertyName ) throw (UnknownPropertyException, RuntimeException)
     350                 :            : {
     351 [ #  # ][ #  # ]:          0 :     if ( m_xAggInv.is() &&  m_xAggInv->hasProperty( aPropertyName ) )
         [ #  # ][ #  # ]
                 [ #  # ]
     352 [ #  # ][ #  # ]:          0 :             return m_xAggInv->getValue( aPropertyName );
     353                 :            : 
     354         [ #  # ]:          0 :     SbPropertyRef pProperty = getProperty( aPropertyName );
     355         [ #  # ]:          0 :     if ( !pProperty.Is() )
     356         [ #  # ]:          0 :        throw UnknownPropertyException();
     357                 :            : 
     358                 :          0 :     SbxVariable* pProp = ( SbxVariable* ) pProperty;
     359 [ #  # ][ #  # ]:          0 :     if ( pProp->GetType() == SbxEMPTY )
     360         [ #  # ]:          0 :         pProperty->Broadcast( SBX_HINT_DATAWANTED );
     361                 :            : 
     362         [ #  # ]:          0 :     Any aRet = sbxToUnoValue( pProp );
     363         [ #  # ]:          0 :     return aRet;
     364                 :            : }
     365                 :            : 
     366                 :            : ::sal_Bool SAL_CALL
     367                 :          0 : DocObjectWrapper::hasMethod( const ::rtl::OUString& aName ) throw (RuntimeException)
     368                 :            : {
     369 [ #  # ][ #  # ]:          0 :     if ( m_xAggInv.is() && m_xAggInv->hasMethod( aName ) )
                 [ #  # ]
     370                 :          0 :         return sal_True;
     371                 :          0 :     return getMethod( aName ).Is();
     372                 :            : }
     373                 :            : 
     374                 :            : ::sal_Bool SAL_CALL
     375                 :          0 : DocObjectWrapper::hasProperty( const ::rtl::OUString& aName ) throw (RuntimeException)
     376                 :            : {
     377                 :          0 :     sal_Bool bRes = sal_False;
     378 [ #  # ][ #  # ]:          0 :     if ( m_xAggInv.is() && m_xAggInv->hasProperty( aName ) )
                 [ #  # ]
     379                 :          0 :         bRes = sal_True;
     380                 :          0 :     else bRes = getProperty( aName ).Is();
     381                 :          0 :     return bRes;
     382                 :            : }
     383                 :            : 
     384                 :       1880 : Any SAL_CALL DocObjectWrapper::queryInterface( const Type& aType )
     385                 :            :     throw ( RuntimeException )
     386                 :            : {
     387                 :       1880 :     Any aRet = DocObjectWrapper_BASE::queryInterface( aType );
     388         [ +  + ]:       1880 :     if ( aRet.hasValue() )
     389                 :       1144 :         return aRet;
     390         [ +  - ]:        736 :     else if ( m_xAggProxy.is() )
     391 [ +  - ][ +  - ]:        736 :         aRet = m_xAggProxy->queryAggregation( aType );
     392                 :       1880 :     return aRet;
     393                 :            : }
     394                 :            : 
     395                 :          0 : SbMethodRef DocObjectWrapper::getMethod( const rtl::OUString& aName ) throw (RuntimeException)
     396                 :            : {
     397                 :          0 :     SbMethodRef pMethod = NULL;
     398         [ #  # ]:          0 :     if ( m_pMod )
     399                 :            :     {
     400                 :          0 :         sal_uInt16 nSaveFlgs = m_pMod->GetFlags();
     401                 :            :         // Limit search to this module
     402                 :          0 :         m_pMod->ResetFlag( SBX_GBLSEARCH );
     403 [ #  # ][ #  # ]:          0 :         pMethod = (SbMethod*) m_pMod->SbModule::Find( aName,  SbxCLASS_METHOD );
     404                 :          0 :         m_pMod->SetFlags( nSaveFlgs );
     405                 :            :     }
     406                 :            : 
     407                 :          0 :     return pMethod;
     408                 :            : }
     409                 :            : 
     410                 :          0 : SbPropertyRef DocObjectWrapper::getProperty( const rtl::OUString& aName ) throw (RuntimeException)
     411                 :            : {
     412                 :          0 :     SbPropertyRef pProperty = NULL;
     413         [ #  # ]:          0 :     if ( m_pMod )
     414                 :            :     {
     415                 :          0 :         sal_uInt16 nSaveFlgs = m_pMod->GetFlags();
     416                 :            :         // Limit search to this module.
     417                 :          0 :         m_pMod->ResetFlag( SBX_GBLSEARCH );
     418 [ #  # ][ #  # ]:          0 :         pProperty = (SbProperty*)m_pMod->SbModule::Find( aName,  SbxCLASS_PROPERTY );
     419                 :          0 :         m_pMod->SetFlag( nSaveFlgs );
     420                 :            :     }
     421                 :            : 
     422                 :          0 :     return pProperty;
     423                 :            : }
     424                 :            : 
     425 [ -  + ][ +  + ]:       5590 : TYPEINIT1(SbModule,SbxObject)
     426 [ +  + ][ +  + ]:      18756 : TYPEINIT1(SbMethod,SbxMethod)
     427 [ +  + ][ -  + ]:       5624 : TYPEINIT1(SbProperty,SbxProperty)
     428 [ #  # ][ #  # ]:       5875 : TYPEINIT1(SbProcedureProperty,SbxProperty)
     429 [ #  # ][ #  # ]:          0 : TYPEINIT1(SbJScriptModule,SbModule)
     430 [ #  # ][ #  # ]:          0 : TYPEINIT1(SbJScriptMethod,SbMethod)
     431 [ +  - ][ #  # ]:        368 : TYPEINIT1(SbObjModule,SbModule)
     432 [ #  # ][ #  # ]:          0 : TYPEINIT1(SbUserFormModule,SbObjModule)
     433                 :            : 
     434                 :        228 : uno::Reference< frame::XModel > getDocumentModel( StarBASIC* pb )
     435                 :            : {
     436                 :        228 :     uno::Reference< frame::XModel > xModel;
     437 [ +  - ][ +  + ]:        228 :     if( pb && pb->IsDocBasic() )
                 [ +  + ]
     438                 :            :     {
     439                 :          4 :         uno::Any aDoc;
     440 [ +  - ][ +  - ]:          4 :         if( pb->GetUNOConstant( "ThisComponent", aDoc ) )
     441         [ +  - ]:          4 :             xModel.set( aDoc, uno::UNO_QUERY );
     442                 :            :     }
     443                 :        228 :     return xModel;
     444                 :            : }
     445                 :            : 
     446                 :        163 : uno::Reference< vba::XVBACompatibility > getVBACompatibility( const uno::Reference< frame::XModel >& rxModel )
     447                 :            : {
     448                 :        163 :     uno::Reference< vba::XVBACompatibility > xVBACompat;
     449                 :            :     try
     450                 :            :     {
     451         [ +  + ]:        163 :         uno::Reference< beans::XPropertySet > xModelProps( rxModel, uno::UNO_QUERY_THROW );
     452 [ +  - ][ +  - ]:        163 :         xVBACompat.set( xModelProps->getPropertyValue( ::rtl::OUString( "BasicLibraries"  ) ), uno::UNO_QUERY );
         [ +  - ][ -  + ]
     453                 :            :     }
     454         [ +  - ]:        159 :     catch(const uno::Exception& )
     455                 :            :     {
     456                 :            :     }
     457                 :        163 :     return xVBACompat;
     458                 :            : }
     459                 :            : 
     460                 :        159 : bool getDefaultVBAMode( StarBASIC* pb )
     461                 :            : {
     462 [ +  - ][ +  - ]:        159 :     uno::Reference< vba::XVBACompatibility > xVBACompat = getVBACompatibility( getDocumentModel( pb ) );
     463 [ #  # ][ #  # ]:        159 :     return xVBACompat.is() && xVBACompat->getVBACompatibilityMode();
         [ #  # ][ -  + ]
     464                 :            : }
     465                 :            : 
     466                 :            : class AsyncQuitHandler
     467                 :            : {
     468                 :          0 :     AsyncQuitHandler() {}
     469                 :            :     AsyncQuitHandler( const AsyncQuitHandler&);
     470                 :            : public:
     471                 :          0 :     static AsyncQuitHandler& instance()
     472                 :            :     {
     473 [ #  # ][ #  # ]:          0 :         static AsyncQuitHandler dInst;
     474                 :          0 :         return dInst;
     475                 :            :     }
     476                 :            : 
     477                 :          0 :     void QuitApplication()
     478                 :            :     {
     479         [ #  # ]:          0 :         uno::Reference< lang::XMultiServiceFactory > xFactory = comphelper::getProcessServiceFactory();
     480         [ #  # ]:          0 :         if ( xFactory.is() )
     481                 :            :     {
     482 [ #  # ][ #  # ]:          0 :             uno::Reference< frame::XDesktop > xDeskTop( xFactory->createInstance( rtl::OUString( "com.sun.star.frame.Desktop" ) ), uno::UNO_QUERY );
                 [ #  # ]
     483         [ #  # ]:          0 :            if ( xDeskTop.is() )
     484 [ #  # ][ #  # ]:          0 :                xDeskTop->terminate();
     485                 :          0 :         }
     486                 :          0 :     }
     487                 :            :     DECL_LINK( OnAsyncQuit, void* );
     488                 :            : };
     489                 :            : 
     490                 :          0 : IMPL_LINK( AsyncQuitHandler, OnAsyncQuit, void*, /*pNull*/ )
     491                 :            : {
     492                 :          0 :     QuitApplication();
     493                 :          0 :     return 0L;
     494                 :            : }
     495                 :            : 
     496                 :            : // A Basic module has set EXTSEARCH, so that the elements, that the modul contains,
     497                 :            : // could be found from other module.
     498                 :            : 
     499                 :        159 : SbModule::SbModule( const String& rName,  sal_Bool bVBACompat )
     500                 :            :          : SbxObject( String( RTL_CONSTASCII_USTRINGPARAM("StarBASICModule") ) ),
     501 [ +  - ][ +  - ]:        159 :            pImage( NULL ), pBreaks( NULL ), pClassData( NULL ), mbVBACompat( bVBACompat ),  pDocObject( NULL ), bIsProxyModule( false )
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     502                 :            : {
     503   [ +  -  +  - ]:        159 :     SetName( rName );
     504                 :        159 :     SetFlag( SBX_EXTSEARCH | SBX_GBLSEARCH );
     505                 :        159 :     SetModuleType( script::ModuleType::NORMAL );
     506                 :            : 
     507                 :            :     // #i92642: Set name property to intitial name
     508 [ +  - ][ +  - ]:        159 :     SbxVariable* pNameProp = pProps->Find( String( RTL_CONSTASCII_USTRINGPARAM("Name") ), SbxCLASS_PROPERTY );
           [ +  -  +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     509 [ +  - ][ +  - ]:        159 :     if( pNameProp != NULL )
     510 [ +  - ][ +  - ]:        159 :         pNameProp->PutString( GetName() );
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     511                 :        159 : }
     512                 :            : 
     513 [ +  - ][ +  - ]:        259 : SbModule::~SbModule()
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     514                 :            : {
     515                 :            :     OSL_TRACE("Module named %s is destructing", rtl::OUStringToOString( GetName(), RTL_TEXTENCODING_UTF8 ).getStr() );
     516 [ +  + ][ +  - ]:        157 :     delete pImage;
         [ +  + ][ +  - ]
     517 [ -  + ][ -  + ]:        157 :     delete pBreaks;
     518 [ -  + ][ #  # ]:        157 :     delete pClassData;
         [ -  + ][ #  # ]
     519 [ +  - ][ +  - ]:        157 :     mxWrapper = NULL;
     520 [ +  - ][ -  + ]:        361 : }
         [ #  # ][ -  + ]
         [ -  + ][ #  # ]
     521                 :            : 
     522                 :            : uno::Reference< script::XInvocation >
     523                 :        180 : SbModule::GetUnoModule()
     524                 :            : {
     525         [ +  + ]:        180 :     if ( !mxWrapper.is() )
     526 [ +  - ][ +  - ]:          8 :         mxWrapper = new DocObjectWrapper( this );
     527                 :            : 
     528                 :            :     OSL_TRACE("Module named %s returning wrapper mxWrapper (0x%x)", rtl::OUStringToOString( GetName(), RTL_TEXTENCODING_UTF8 ).getStr(), mxWrapper.get() );
     529                 :        180 :     return mxWrapper;
     530                 :            : }
     531                 :            : 
     532                 :       1104 : sal_Bool SbModule::IsCompiled() const
     533                 :            : {
     534                 :       1104 :     return sal_Bool( pImage != 0 );
     535                 :            : }
     536                 :            : 
     537                 :         24 : const SbxObject* SbModule::FindType( String aTypeName ) const
     538                 :            : {
     539 [ +  - ][ +  - ]:         24 :     return pImage ? pImage->FindType( aTypeName ) : NULL;
         [ +  - ][ +  - ]
                 [ #  # ]
     540                 :            : }
     541                 :            : 
     542                 :            : 
     543                 :            : // From the code generator: deletion of images and the oposite of validation for entries
     544                 :            : 
     545                 :        224 : void SbModule::StartDefinitions()
     546                 :            : {
     547         [ -  + ]:        224 :     delete pImage; pImage = NULL;
     548         [ -  + ]:        224 :     if( pClassData )
     549                 :          0 :         pClassData->clear();
     550                 :            : 
     551                 :            :     // methods and properties persist, but they are invalid;
     552                 :            :     // at least are the information under certain conditions clogged
     553                 :            :     sal_uInt16 i;
     554         [ +  + ]:        421 :     for( i = 0; i < pMethods->Count(); i++ )
     555                 :            :     {
     556 [ +  - ][ +  - ]:        197 :         SbMethod* p = PTR_CAST(SbMethod,pMethods->Get( i ) );
     557         [ +  - ]:        197 :         if( p )
     558                 :        197 :             p->bInvalid = sal_True;
     559                 :            :     }
     560         [ +  + ]:        672 :     for( i = 0; i < pProps->Count(); )
     561                 :            :     {
     562 [ +  - ][ -  + ]:        448 :         SbProperty* p = PTR_CAST(SbProperty,pProps->Get( i ) );
     563         [ -  + ]:        448 :         if( p )
     564                 :          0 :             pProps->Remove( i );
     565                 :            :         else
     566                 :        448 :             i++;
     567                 :            :     }
     568                 :        224 : }
     569                 :            : 
     570                 :            : // request/create method
     571                 :            : 
     572                 :        473 : SbMethod* SbModule::GetMethod( const String& rName, SbxDataType t )
     573                 :            : {
     574         [ +  - ]:        473 :     SbxVariable* p = pMethods->Find( rName, SbxCLASS_METHOD );
     575 [ +  - ][ +  - ]:        473 :     SbMethod* pMeth = p ? PTR_CAST(SbMethod,p) : NULL;
                 [ +  + ]
     576 [ +  + ][ -  + ]:        473 :     if( p && !pMeth )
     577                 :          0 :         pMethods->Remove( p );
     578         [ +  + ]:        473 :     if( !pMeth )
     579                 :            :     {
     580         [ +  - ]:        276 :         pMeth = new SbMethod( rName, t, this );
     581                 :        276 :         pMeth->SetParent( this );
     582                 :        276 :         pMeth->SetFlags( SBX_READ );
     583                 :        276 :         pMethods->Put( pMeth, pMethods->Count() );
     584                 :        276 :         StartListening( pMeth->GetBroadcaster(), sal_True );
     585                 :            :     }
     586                 :            :     // The method is per default valid, because it could be
     587                 :            :     // created from the compiler (code generator) as well.
     588                 :        473 :     pMeth->bInvalid = sal_False;
     589                 :        473 :     pMeth->ResetFlag( SBX_FIXED );
     590                 :        473 :     pMeth->SetFlag( SBX_WRITE );
     591                 :        473 :     pMeth->SetType( t );
     592                 :        473 :     pMeth->ResetFlag( SBX_WRITE );
     593         [ +  + ]:        473 :     if( t != SbxVARIANT )
     594                 :        392 :         pMeth->SetFlag( SBX_FIXED );
     595                 :        473 :     return pMeth;
     596                 :            : }
     597                 :            : 
     598                 :            : // request/create property
     599                 :            : 
     600                 :         10 : SbProperty* SbModule::GetProperty( const String& rName, SbxDataType t )
     601                 :            : {
     602         [ +  - ]:         10 :     SbxVariable* p = pProps->Find( rName, SbxCLASS_PROPERTY );
     603 [ #  # ][ #  # ]:         10 :     SbProperty* pProp = p ? PTR_CAST(SbProperty,p) : NULL;
                 [ -  + ]
     604 [ -  + ][ #  # ]:         10 :     if( p && !pProp )
     605                 :          0 :         pProps->Remove( p );
     606         [ +  - ]:         10 :     if( !pProp )
     607                 :            :     {
     608         [ +  - ]:         10 :         pProp = new SbProperty( rName, t, this );
     609                 :         10 :         pProp->SetFlag( SBX_READWRITE );
     610                 :         10 :         pProp->SetParent( this );
     611                 :         10 :         pProps->Put( pProp, pProps->Count() );
     612                 :         10 :         StartListening( pProp->GetBroadcaster(), sal_True );
     613                 :            :     }
     614                 :         10 :     return pProp;
     615                 :            : }
     616                 :            : 
     617                 :          0 : SbProcedureProperty* SbModule::GetProcedureProperty
     618                 :            :     ( const String& rName, SbxDataType t )
     619                 :            : {
     620         [ #  # ]:          0 :     SbxVariable* p = pProps->Find( rName, SbxCLASS_PROPERTY );
     621 [ #  # ][ #  # ]:          0 :     SbProcedureProperty* pProp = p ? PTR_CAST(SbProcedureProperty,p) : NULL;
                 [ #  # ]
     622 [ #  # ][ #  # ]:          0 :     if( p && !pProp )
     623                 :          0 :         pProps->Remove( p );
     624         [ #  # ]:          0 :     if( !pProp )
     625                 :            :     {
     626         [ #  # ]:          0 :         pProp = new SbProcedureProperty( rName, t );
     627                 :          0 :         pProp->SetFlag( SBX_READWRITE );
     628                 :          0 :         pProp->SetParent( this );
     629                 :          0 :         pProps->Put( pProp, pProps->Count() );
     630                 :          0 :         StartListening( pProp->GetBroadcaster(), sal_True );
     631                 :            :     }
     632                 :          0 :     return pProp;
     633                 :            : }
     634                 :            : 
     635                 :          0 : SbIfaceMapperMethod* SbModule::GetIfaceMapperMethod
     636                 :            :     ( const String& rName, SbMethod* pImplMeth )
     637                 :            : {
     638         [ #  # ]:          0 :     SbxVariable* p = pMethods->Find( rName, SbxCLASS_METHOD );
     639 [ #  # ][ #  # ]:          0 :     SbIfaceMapperMethod* pMapperMethod = p ? PTR_CAST(SbIfaceMapperMethod,p) : NULL;
                 [ #  # ]
     640 [ #  # ][ #  # ]:          0 :     if( p && !pMapperMethod )
     641                 :          0 :         pMethods->Remove( p );
     642         [ #  # ]:          0 :     if( !pMapperMethod )
     643                 :            :     {
     644         [ #  # ]:          0 :         pMapperMethod = new SbIfaceMapperMethod( rName, pImplMeth );
     645                 :          0 :         pMapperMethod->SetParent( this );
     646                 :          0 :         pMapperMethod->SetFlags( SBX_READ );
     647                 :          0 :         pMethods->Put( pMapperMethod, pMethods->Count() );
     648                 :            :     }
     649                 :          0 :     pMapperMethod->bInvalid = sal_False;
     650                 :          0 :     return pMapperMethod;
     651                 :            : }
     652                 :            : 
     653 [ #  # ][ #  # ]:          0 : SbIfaceMapperMethod::~SbIfaceMapperMethod()
         [ #  # ][ #  # ]
     654                 :            : {
     655 [ #  # ][ #  # ]:          0 : }
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     656                 :            : 
     657 [ #  # ][ #  # ]:          0 : TYPEINIT1(SbIfaceMapperMethod,SbMethod)
     658                 :            : 
     659                 :            : 
     660                 :            : // From the code generator: remove invalid entries
     661                 :            : 
     662                 :        224 : void SbModule::EndDefinitions( sal_Bool bNewState )
     663                 :            : {
     664         [ +  + ]:        697 :     for( sal_uInt16 i = 0; i < pMethods->Count(); )
     665                 :            :     {
     666 [ +  - ][ +  - ]:        473 :         SbMethod* p = PTR_CAST(SbMethod,pMethods->Get( i ) );
     667         [ +  - ]:        473 :         if( p )
     668                 :            :         {
     669         [ -  + ]:        473 :             if( p->bInvalid )
     670                 :          0 :                 pMethods->Remove( p );
     671                 :            :             else
     672                 :            :             {
     673                 :        473 :                 p->bInvalid = bNewState;
     674                 :        473 :                 i++;
     675                 :            :             }
     676                 :            :         }
     677                 :            :         else
     678                 :          0 :             i++;
     679                 :            :     }
     680                 :        224 :     SetModified( sal_True );
     681                 :        224 : }
     682                 :            : 
     683                 :          0 : void SbModule::Clear()
     684                 :            : {
     685         [ #  # ]:          0 :     delete pImage; pImage = NULL;
     686         [ #  # ]:          0 :     if( pClassData )
     687                 :          0 :         pClassData->clear();
     688                 :          0 :     SbxObject::Clear();
     689                 :          0 : }
     690                 :            : 
     691                 :            : 
     692                 :      43291 : SbxVariable* SbModule::Find( const rtl::OUString& rName, SbxClassType t )
     693                 :            : {
     694                 :            :     // make sure a search in an uninstatiated class module will fail
     695                 :      43291 :     SbxVariable* pRes = SbxObject::Find( rName, t );
     696 [ #  # ][ -  + ]:      43291 :     if ( bIsProxyModule && !GetSbData()->bRunInit )
                 [ -  + ]
     697                 :          0 :         return NULL;
     698 [ +  + ][ +  + ]:      43291 :     if( !pRes && pImage )
     699                 :            :     {
     700                 :      32840 :         SbiInstance* pInst = GetSbData()->pInst;
     701 [ +  + ][ +  + ]:      32840 :         if( pInst && pInst->IsCompatibility() )
                 [ +  + ]
     702                 :            :         {
     703                 :            :             // Put enum types as objects into module,
     704                 :            :             // allows MyEnum.First notation
     705         [ +  - ]:         86 :             SbxArrayRef xArray = pImage->GetEnums();
     706         [ -  + ]:         86 :             if( xArray.Is() )
     707                 :            :             {
     708         [ #  # ]:          0 :                 SbxVariable* pEnumVar = xArray->Find( rName, SbxCLASS_DONTCARE );
     709 [ #  # ][ #  # ]:          0 :                 SbxObject* pEnumObject = PTR_CAST( SbxObject, pEnumVar );
         [ #  # ][ #  # ]
     710         [ #  # ]:          0 :                 if( pEnumObject )
     711                 :            :                 {
     712                 :          0 :                     bool bPrivate = pEnumObject->IsSet( SBX_PRIVATE );
     713 [ #  # ][ #  # ]:          0 :                     String aEnumName = pEnumObject->GetName();
     714                 :            : 
     715 [ #  # ][ #  # ]:          0 :                     pRes = new SbxVariable( SbxOBJECT );
     716         [ #  # ]:          0 :                     pRes->SetName( aEnumName );
     717         [ #  # ]:          0 :                     pRes->SetParent( this );
     718                 :          0 :                     pRes->SetFlag( SBX_READ );
     719         [ #  # ]:          0 :                     if( bPrivate )
     720                 :          0 :                         pRes->SetFlag( SBX_PRIVATE );
     721 [ #  # ][ #  # ]:          0 :                     pRes->PutObject( pEnumObject );
     722                 :            :                 }
     723         [ +  - ]:         86 :             }
     724                 :            :         }
     725                 :            :     }
     726                 :      43291 :     return pRes;
     727                 :            : }
     728                 :            : 
     729                 :         65 : const ::rtl::OUString& SbModule::GetSource32() const
     730                 :            : {
     731                 :         65 :     return aOUSource;
     732                 :            : }
     733                 :            : 
     734                 :          0 : const String& SbModule::GetSource() const
     735                 :            : {
     736 [ #  # ][ #  # ]:          0 :     static String aRetStr;
         [ #  # ][ #  # ]
     737                 :          0 :     aRetStr = aOUSource;
     738                 :          0 :     return aRetStr;
     739                 :            : }
     740                 :            : 
     741                 :            : // Parent and BASIC are one!
     742                 :            : 
     743                 :        159 : void SbModule::SetParent( SbxObject* p )
     744                 :            : {
     745                 :        159 :     pParent = p;
     746                 :        159 : }
     747                 :            : 
     748                 :       1288 : void SbModule::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType,
     749                 :            :                            const SfxHint& rHint, const TypeId& rHintType )
     750                 :            : {
     751 [ +  - ][ +  - ]:       1288 :     const SbxHint* pHint = PTR_CAST(SbxHint,&rHint);
     752         [ +  - ]:       1288 :     if( pHint )
     753                 :            :     {
     754                 :       1288 :         SbxVariable* pVar = pHint->GetVar();
     755 [ +  + ][ +  - ]:       1288 :         SbProperty* pProp = PTR_CAST(SbProperty,pVar);
     756 [ +  - ][ +  + ]:       1288 :         SbMethod* pMeth = PTR_CAST(SbMethod,pVar);
     757 [ +  - ][ -  + ]:       1288 :         SbProcedureProperty* pProcProperty = PTR_CAST( SbProcedureProperty, pVar );
     758         [ -  + ]:       1288 :         if( pProcProperty )
     759                 :            :         {
     760                 :            : 
     761         [ #  # ]:          0 :             if( pHint->GetId() == SBX_HINT_DATAWANTED )
     762                 :            :             {
     763         [ #  # ]:          0 :                 String aProcName;
     764         [ #  # ]:          0 :                 aProcName.AppendAscii( "Property Get " );
     765 [ #  # ][ #  # ]:          0 :                 aProcName += pProcProperty->GetName();
     766                 :            : 
     767 [ #  # ][ #  # ]:          0 :                 SbxVariable* pMethVar = Find( aProcName, SbxCLASS_METHOD );
     768         [ #  # ]:          0 :                 if( pMethVar )
     769                 :            :                 {
     770                 :          0 :                     SbxValues aVals;
     771                 :          0 :                     aVals.eType = SbxVARIANT;
     772                 :            : 
     773         [ #  # ]:          0 :                     SbxArray* pArg = pVar->GetParameters();
     774 [ #  # ][ #  # ]:          0 :                     sal_uInt16 nVarParCount = (pArg != NULL) ? pArg->Count() : 0;
     775         [ #  # ]:          0 :                     if( nVarParCount > 1 )
     776                 :            :                     {
     777 [ #  # ][ #  # ]:          0 :                         SbxArrayRef xMethParameters = new SbxArray;
     778         [ #  # ]:          0 :                         xMethParameters->Put( pMethVar, 0 );    // Method as parameter 0
     779         [ #  # ]:          0 :                         for( sal_uInt16 i = 1 ; i < nVarParCount ; ++i )
     780                 :            :                         {
     781         [ #  # ]:          0 :                             SbxVariable* pPar = pArg->Get( i );
     782         [ #  # ]:          0 :                             xMethParameters->Put( pPar, i );
     783                 :            :                         }
     784                 :            : 
     785         [ #  # ]:          0 :                         pMethVar->SetParameters( xMethParameters );
     786         [ #  # ]:          0 :                         pMethVar->Get( aVals );
     787 [ #  # ][ #  # ]:          0 :                         pMethVar->SetParameters( NULL );
     788                 :            :                     }
     789                 :            :                     else
     790                 :            :                     {
     791         [ #  # ]:          0 :                         pMethVar->Get( aVals );
     792                 :            :                     }
     793                 :            : 
     794         [ #  # ]:          0 :                     pVar->Put( aVals );
     795         [ #  # ]:          0 :                 }
     796                 :            :             }
     797         [ #  # ]:          0 :             else if( pHint->GetId() == SBX_HINT_DATACHANGED )
     798                 :            :             {
     799                 :          0 :                 SbxVariable* pMethVar = NULL;
     800                 :            : 
     801                 :          0 :                 bool bSet = pProcProperty->isSet();
     802         [ #  # ]:          0 :                 if( bSet )
     803                 :            :                 {
     804                 :          0 :                     pProcProperty->setSet( false );
     805                 :            : 
     806         [ #  # ]:          0 :                     String aProcName;
     807         [ #  # ]:          0 :                     aProcName.AppendAscii( "Property Set " );
     808 [ #  # ][ #  # ]:          0 :                     aProcName += pProcProperty->GetName();
     809 [ #  # ][ #  # ]:          0 :                     pMethVar = Find( aProcName, SbxCLASS_METHOD );
                 [ #  # ]
     810                 :            :                 }
     811         [ #  # ]:          0 :                 if( !pMethVar ) // Let
     812                 :            :                 {
     813         [ #  # ]:          0 :                     String aProcName;
     814         [ #  # ]:          0 :                     aProcName.AppendAscii( "Property Let " );
     815 [ #  # ][ #  # ]:          0 :                     aProcName += pProcProperty->GetName();
     816 [ #  # ][ #  # ]:          0 :                     pMethVar = Find( aProcName, SbxCLASS_METHOD );
                 [ #  # ]
     817                 :            :                 }
     818                 :            : 
     819         [ #  # ]:          0 :                 if( pMethVar )
     820                 :            :                 {
     821                 :            :                     // Setup parameters
     822 [ #  # ][ #  # ]:          0 :                     SbxArrayRef xArray = new SbxArray;
     823         [ #  # ]:          0 :                     xArray->Put( pMethVar, 0 ); // Method as parameter 0
     824         [ #  # ]:          0 :                     xArray->Put( pVar, 1 );
     825         [ #  # ]:          0 :                     pMethVar->SetParameters( xArray );
     826                 :            : 
     827                 :          0 :                     SbxValues aVals;
     828         [ #  # ]:          0 :                     pMethVar->Get( aVals );
     829 [ #  # ][ #  # ]:          0 :                     pMethVar->SetParameters( NULL );
     830                 :            :                 }
     831                 :            :             }
     832                 :            :         }
     833         [ +  + ]:       1288 :         if( pProp )
     834                 :            :         {
     835         [ -  + ]:        216 :             if( pProp->GetModule() != this )
     836                 :          0 :                 SetError( SbxERR_BAD_ACTION );
     837                 :            :         }
     838         [ +  + ]:       1072 :         else if( pMeth )
     839                 :            :         {
     840         [ +  - ]:        913 :             if( pHint->GetId() == SBX_HINT_DATAWANTED )
     841                 :            :             {
     842 [ -  + ][ #  # ]:        913 :                 if( pMeth->bInvalid && !Compile() )
                 [ -  + ]
     843                 :            :                     // auto compile has not worked!
     844                 :          0 :                     StarBASIC::Error( SbERR_BAD_PROP_VALUE );
     845                 :            :                 else
     846                 :            :                 {
     847                 :            :                     // Call of a subprogram
     848                 :        913 :                     SbModule* pOld = GetSbData()->pMod;
     849                 :        913 :                     GetSbData()->pMod = this;
     850                 :        913 :                     Run( (SbMethod*) pVar );
     851                 :        913 :                     GetSbData()->pMod = pOld;
     852                 :            :                 }
     853                 :            :             }
     854                 :            :         }
     855                 :            :         else
     856                 :            :         {
     857                 :            :             // #i92642: Special handling for name property to avoid
     858                 :            :             // side effects when using name as variable implicitely
     859                 :        159 :             bool bForwardToSbxObject = true;
     860                 :            : 
     861                 :        159 :             sal_uIntPtr nId = pHint->GetId();
     862   [ +  -  +  - ]:        318 :             if( (nId == SBX_HINT_DATAWANTED || nId == SBX_HINT_DATACHANGED) &&
         [ +  - ][ +  - ]
     863                 :        159 :                 pVar->GetName().EqualsIgnoreCaseAscii( "name" ) )
     864                 :        159 :                     bForwardToSbxObject = false;
     865                 :            : 
     866         [ -  + ]:        159 :             if( bForwardToSbxObject )
     867                 :          0 :                 SbxObject::SFX_NOTIFY( rBC, rBCType, rHint, rHintType );
     868                 :            :         }
     869                 :            :     }
     870                 :       1288 : }
     871                 :            : 
     872                 :            : // The setting of the source makes the image invalid
     873                 :            : // and scans the method definitions newly in
     874                 :            : 
     875                 :          0 : void SbModule::SetSource( const String& r )
     876                 :            : {
     877         [ #  # ]:          0 :     SetSource32( r );
     878                 :          0 : }
     879                 :            : 
     880                 :        159 : void SbModule::SetSource32( const ::rtl::OUString& r )
     881                 :            : {
     882                 :            :     // Default basic mode to library container mode, but.. allow Option VBASupport 0/1 override
     883 [ +  - ][ +  - ]:        159 :     SetVBACompat( getDefaultVBAMode( static_cast< StarBASIC*>( GetParent() ) ) );
                 [ +  - ]
     884                 :        159 :     aOUSource = r;
     885         [ +  - ]:        159 :     StartDefinitions();
     886         [ +  - ]:        159 :     SbiTokenizer aTok( r );
     887         [ +  - ]:        159 :         aTok.SetCompatible( IsVBACompat() );
     888         [ +  + ]:        594 :     while( !aTok.IsEof() )
     889                 :            :     {
     890                 :        435 :         SbiToken eEndTok = NIL;
     891                 :            : 
     892                 :            :         // Searching for SUB or FUNCTION
     893                 :        435 :         SbiToken eLastTok = NIL;
     894         [ +  + ]:       3227 :         while( !aTok.IsEof() )
     895                 :            :         {
     896                 :            :             // #32385: not by declare
     897         [ +  - ]:       3068 :             SbiToken eCurTok = aTok.Next();
     898         [ +  - ]:       3068 :             if( eLastTok != DECLARE )
     899                 :            :             {
     900         [ +  + ]:       3068 :                 if( eCurTok == SUB )
     901                 :            :                 {
     902                 :        212 :                     eEndTok = ENDSUB; break;
     903                 :            :                 }
     904         [ +  + ]:       2856 :                 if( eCurTok == FUNCTION )
     905                 :            :                 {
     906                 :         64 :                     eEndTok = ENDFUNC; break;
     907                 :            :                 }
     908         [ -  + ]:       2792 :                 if( eCurTok == PROPERTY )
     909                 :            :                 {
     910                 :          0 :                     eEndTok = ENDPROPERTY; break;
     911                 :            :                 }
     912         [ +  + ]:       2792 :                 if( eCurTok == OPTION )
     913                 :            :                 {
     914         [ +  - ]:         76 :                     eCurTok = aTok.Next();
     915         [ -  + ]:         76 :                     if( eCurTok == COMPATIBLE )
     916                 :          0 :                         aTok.SetCompatible( true );
     917 [ +  + ][ +  - ]:         76 :                     else if ( ( eCurTok == VBASUPPORT ) && ( aTok.Next() == NUMBER ) )
         [ +  - ][ +  + ]
     918                 :            :                     {
     919                 :         65 :                             sal_Bool bIsVBA = ( aTok.GetDbl()== 1 );
     920         [ +  - ]:         65 :                             SetVBACompat( bIsVBA );
     921                 :         65 :                         aTok.SetCompatible( bIsVBA );
     922                 :            :                     }
     923                 :            :                 }
     924                 :            :             }
     925                 :       2792 :             eLastTok = eCurTok;
     926                 :            :         }
     927                 :            :         // Definition of the method
     928                 :        435 :         SbMethod* pMeth = NULL;
     929         [ +  + ]:        435 :         if( eEndTok != NIL )
     930                 :            :         {
     931                 :        276 :             sal_uInt16 nLine1 = aTok.GetLine();
     932 [ +  - ][ +  - ]:        276 :             if( aTok.Next() == SYMBOL )
     933                 :            :             {
     934         [ +  - ]:        276 :                 String aName_( aTok.GetSym() );
     935                 :        276 :                 SbxDataType t = aTok.GetType();
     936 [ +  + ][ +  - ]:        276 :                 if( t == SbxVARIANT && eEndTok == ENDSUB )
     937                 :        212 :                     t = SbxVOID;
     938         [ +  - ]:        276 :                 pMeth = GetMethod( aName_, t );
     939                 :        276 :                 pMeth->nLine1 = pMeth->nLine2 = nLine1;
     940                 :            :                 // The method is for a start VALID
     941         [ +  - ]:        276 :                 pMeth->bInvalid = sal_False;
     942                 :            :             }
     943                 :            :             else
     944                 :          0 :                 eEndTok = NIL;
     945                 :            :         }
     946                 :            :         // Skip up to END SUB/END FUNCTION
     947         [ +  + ]:        435 :         if( eEndTok != NIL )
     948                 :            :         {
     949         [ +  - ]:      26232 :             while( !aTok.IsEof() )
     950                 :            :             {
     951 [ +  - ][ +  + ]:      26232 :                 if( aTok.Next() == eEndTok )
     952                 :            :                 {
     953                 :        276 :                     pMeth->nLine2 = aTok.GetLine();
     954                 :        276 :                     break;
     955                 :            :                 }
     956                 :            :             }
     957         [ -  + ]:        276 :             if( aTok.IsEof() )
     958                 :          0 :                 pMeth->nLine2 = aTok.GetLine();
     959                 :            :         }
     960                 :            :     }
     961 [ +  - ][ +  - ]:        159 :     EndDefinitions( sal_True );
     962                 :        159 : }
     963                 :            : 
     964                 :          0 : SbMethod* SbModule::GetFunctionForLine( sal_uInt16 nLine )
     965                 :            : {
     966         [ #  # ]:          0 :     for( sal_uInt16 i = 0; i < pMethods->Count(); i++ )
     967                 :            :     {
     968                 :          0 :         SbMethod* p = (SbMethod*) pMethods->Get( i );
     969         [ #  # ]:          0 :         if( p->GetSbxId() == SBXID_BASICMETHOD )
     970                 :            :         {
     971 [ #  # ][ #  # ]:          0 :             if( nLine >= p->nLine1 && nLine <= p->nLine2 )
     972                 :          0 :                 return p;
     973                 :            :         }
     974                 :            :     }
     975                 :          0 :     return NULL;
     976                 :            : }
     977                 :            : 
     978                 :            : // Broadcast of a hint to all Basics
     979                 :            : 
     980                 :        352 : static void _SendHint( SbxObject* pObj, sal_uIntPtr nId, SbMethod* p )
     981                 :            : {
     982                 :            :     // Self a BASIC?
     983 [ +  + ][ +  + ]:        352 :     if( pObj->IsA( TYPE(StarBASIC) ) && pObj->IsBroadcaster() )
                 [ +  + ]
     984 [ +  - ][ +  - ]:        164 :         pObj->GetBroadcaster().Broadcast( SbxHint( nId, p ) );
     985                 :            :     // Then ask for the subobjects
     986                 :        352 :     SbxArray* pObjs = pObj->GetObjects();
     987         [ +  + ]:        642 :     for( sal_uInt16 i = 0; i < pObjs->Count(); i++ )
     988                 :            :     {
     989                 :        290 :         SbxVariable* pVar = pObjs->Get( i );
     990         [ +  - ]:        290 :         if( pVar->IsA( TYPE(SbxObject) ) )
     991 [ +  - ][ +  - ]:        290 :             _SendHint( PTR_CAST(SbxObject,pVar), nId, p );
     992                 :            :     }
     993                 :        352 : }
     994                 :            : 
     995                 :         62 : static void SendHint( SbxObject* pObj, sal_uIntPtr nId, SbMethod* p )
     996                 :            : {
     997         [ +  + ]:        114 :     while( pObj->GetParent() )
     998                 :         52 :         pObj = pObj->GetParent();
     999                 :         62 :     _SendHint( pObj, nId, p );
    1000                 :         62 : }
    1001                 :            : 
    1002                 :            : // #57841 Clear Uno-Objects, which were helt in RTL functions,
    1003                 :            : // at the end of the program, so that nothing were helt.
    1004                 :        117 : void ClearUnoObjectsInRTL_Impl_Rek( StarBASIC* pBasic )
    1005                 :            : {
    1006                 :            :     // delete the return value of CreateUnoService
    1007 [ +  + ][ +  - ]:        117 :     static String aName( RTL_CONSTASCII_USTRINGPARAM("CreateUnoService") );
         [ +  - ][ #  # ]
    1008         [ +  - ]:        117 :     SbxVariable* pVar = pBasic->GetRtl()->Find( aName, SbxCLASS_METHOD );
    1009         [ +  - ]:        117 :     if( pVar )
    1010                 :        117 :         pVar->SbxValue::Clear();
    1011                 :            : 
    1012                 :            :     // delete the return value of CreateUnoDialog
    1013 [ +  + ][ +  - ]:        117 :     static String aName2( RTL_CONSTASCII_USTRINGPARAM("CreateUnoDialog") );
         [ +  - ][ #  # ]
    1014         [ +  - ]:        117 :     pVar = pBasic->GetRtl()->Find( aName2, SbxCLASS_METHOD );
    1015         [ +  - ]:        117 :     if( pVar )
    1016                 :        117 :         pVar->SbxValue::Clear();
    1017                 :            : 
    1018                 :            :     // delete the return value of CDec
    1019 [ +  + ][ +  - ]:        117 :     static String aName3( RTL_CONSTASCII_USTRINGPARAM("CDec") );
         [ +  - ][ #  # ]
    1020         [ +  - ]:        117 :     pVar = pBasic->GetRtl()->Find( aName3, SbxCLASS_METHOD );
    1021         [ +  - ]:        117 :     if( pVar )
    1022                 :        117 :         pVar->SbxValue::Clear();
    1023                 :            : 
    1024                 :            :     // delete return value of CreateObject
    1025 [ +  + ][ +  - ]:        117 :     static String aName4( RTL_CONSTASCII_USTRINGPARAM("CreateObject") );
         [ +  - ][ #  # ]
    1026         [ +  - ]:        117 :     pVar = pBasic->GetRtl()->Find( aName4, SbxCLASS_METHOD );
    1027         [ +  - ]:        117 :     if( pVar )
    1028                 :        117 :         pVar->SbxValue::Clear();
    1029                 :            : 
    1030                 :            :     // Go over all Sub-Basics
    1031                 :        117 :     SbxArray* pObjs = pBasic->GetObjects();
    1032                 :        117 :     sal_uInt16 nCount = pObjs->Count();
    1033         [ +  + ]:        261 :     for( sal_uInt16 i = 0 ; i < nCount ; i++ )
    1034                 :            :     {
    1035                 :        144 :         SbxVariable* pObjVar = pObjs->Get( i );
    1036 [ +  + ][ +  - ]:        144 :         StarBASIC* pSubBasic = PTR_CAST( StarBASIC, pObjVar );
    1037         [ +  + ]:        144 :         if( pSubBasic )
    1038                 :         72 :             ClearUnoObjectsInRTL_Impl_Rek( pSubBasic );
    1039                 :            :     }
    1040                 :        117 : }
    1041                 :            : 
    1042                 :         31 : void ClearUnoObjectsInRTL_Impl( StarBASIC* pBasic )
    1043                 :            : {
    1044                 :            :     // #67781 Delete return values of the Uno-methods
    1045                 :         31 :     clearUnoMethods();
    1046                 :         31 :     clearUnoServiceCtors();
    1047                 :            : 
    1048                 :         31 :     ClearUnoObjectsInRTL_Impl_Rek( pBasic );
    1049                 :            : 
    1050                 :            :     // Search for the topmost Basic
    1051                 :         31 :     SbxObject* p = pBasic;
    1052         [ +  + ]:         55 :     while( p->GetParent() )
    1053                 :         24 :         p = p->GetParent();
    1054         [ +  + ]:         31 :     if( ((StarBASIC*)p) != pBasic )
    1055                 :         14 :         ClearUnoObjectsInRTL_Impl_Rek( (StarBASIC*)p );
    1056                 :         31 : }
    1057                 :            : 
    1058                 :       1174 : bool SbModule::IsVBACompat() const
    1059                 :            : {
    1060                 :       1174 :     return mbVBACompat;
    1061                 :            : }
    1062                 :            : 
    1063                 :        224 : void SbModule::SetVBACompat( bool bCompat )
    1064                 :            : {
    1065         [ +  + ]:        224 :     if( mbVBACompat != bCompat )
    1066                 :            :     {
    1067                 :         65 :         mbVBACompat = bCompat;
    1068                 :            :         // initialize VBA document API
    1069         [ +  - ]:         65 :         if( mbVBACompat ) try
    1070                 :            :         {
    1071         [ +  - ]:         65 :             StarBASIC* pBasic = static_cast< StarBASIC* >( GetParent() );
    1072 [ +  - ][ -  + ]:         65 :             uno::Reference< lang::XMultiServiceFactory > xFactory( getDocumentModel( pBasic ), uno::UNO_QUERY_THROW );
    1073 [ #  # ][ #  # ]:         65 :             xFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.VBAGlobals" ) ) );
         [ -  + ][ #  # ]
    1074                 :            :         }
    1075                 :         65 :         catch( Exception& )
    1076                 :            :         {
    1077                 :            :         }
    1078                 :            :     }
    1079                 :        224 : }
    1080                 :            : 
    1081                 :            : // Run a Basic-subprogram
    1082                 :        913 : sal_uInt16 SbModule::Run( SbMethod* pMeth )
    1083                 :            : {
    1084                 :            :     OSL_TRACE("About to run %s, vba compatmode is %d", rtl::OUStringToOString( pMeth->GetName(), RTL_TEXTENCODING_UTF8 ).getStr(), mbVBACompat );
    1085                 :            :     static sal_uInt16 nMaxCallLevel = 0;
    1086                 :            : 
    1087                 :        913 :     sal_uInt16 nRes = 0;
    1088         [ +  - ]:        913 :     sal_Bool bDelInst = sal_Bool( GetSbData()->pInst == NULL );
    1089                 :        913 :         bool bQuit = false;
    1090                 :        913 :     StarBASICRef xBasic;
    1091                 :        913 :     uno::Reference< frame::XModel > xModel;
    1092                 :        913 :     uno::Reference< script::vba::XVBACompatibility > xVBACompat;
    1093         [ +  + ]:        913 :     if( bDelInst )
    1094                 :            :     {
    1095                 :            :         // #32779: Hold Basic during the execution
    1096 [ +  - ][ +  - ]:         31 :         xBasic = (StarBASIC*) GetParent();
    1097                 :            : 
    1098 [ +  - ][ +  - ]:         31 :         GetSbData()->pInst = new SbiInstance( (StarBASIC*) GetParent() );
         [ +  - ][ +  - ]
    1099                 :            : 
    1100                 :            :         /*  If a VBA script in a document is started, get the VBA compatibility
    1101                 :            :             interface from the document Basic library container, and notify all
    1102                 :            :             VBA script listeners about the started script. */
    1103         [ +  + ]:         31 :         if( mbVBACompat )
    1104                 :            :         {
    1105         [ +  - ]:          4 :             StarBASIC* pBasic = static_cast< StarBASIC* >( GetParent() );
    1106 [ +  - ][ +  - ]:          4 :             if( pBasic && pBasic->IsDocBasic() ) try
                 [ +  - ]
    1107                 :            :             {
    1108 [ +  - ][ +  - ]:          4 :                 xModel.set( getDocumentModel( pBasic ), uno::UNO_SET_THROW );
    1109 [ +  - ][ +  - ]:          4 :                 xVBACompat.set( getVBACompatibility( xModel ), uno::UNO_SET_THROW );
    1110 [ +  - ][ +  - ]:          4 :                 xVBACompat->broadcastVBAScriptEvent( script::vba::VBAScriptEventId::SCRIPT_STARTED, GetName() );
         [ +  - ][ #  # ]
                 [ +  - ]
    1111                 :            :             }
    1112         [ #  # ]:          0 :             catch(const uno::Exception& )
    1113                 :            :             {
    1114                 :            :             }
    1115                 :            :         }
    1116                 :            : 
    1117                 :            :         // Launcher problem
    1118                 :            :         // i80726 The Find below will genarate an error in Testtool so we reset it unless there was one before already
    1119         [ +  - ]:         31 :         sal_Bool bWasError = SbxBase::GetError() != 0;
    1120         [ +  - ]:         31 :         SbxVariable* pMSOMacroRuntimeLibVar = Find( rtl::OUString("Launcher"), SbxCLASS_OBJECT );
    1121 [ +  - ][ -  + ]:         31 :         if ( !bWasError && (SbxBase::GetError() == SbxERR_PROC_UNDEFINED) )
         [ -  + ][ +  - ]
    1122         [ #  # ]:          0 :             SbxBase::ResetError();
    1123         [ -  + ]:         31 :         if( pMSOMacroRuntimeLibVar )
    1124                 :            :         {
    1125 [ #  # ][ #  # ]:          0 :             StarBASIC* pMSOMacroRuntimeLib = PTR_CAST(StarBASIC,pMSOMacroRuntimeLibVar);
         [ #  # ][ #  # ]
    1126         [ #  # ]:          0 :             if( pMSOMacroRuntimeLib )
    1127                 :            :             {
    1128                 :          0 :                 sal_uInt16 nGblFlag = pMSOMacroRuntimeLib->GetFlags() & SBX_GBLSEARCH;
    1129                 :          0 :                 pMSOMacroRuntimeLib->ResetFlag( SBX_GBLSEARCH );
    1130         [ #  # ]:          0 :                 SbxVariable* pAppSymbol = pMSOMacroRuntimeLib->Find( rtl::OUString("Application"), SbxCLASS_METHOD );
    1131                 :          0 :                 pMSOMacroRuntimeLib->SetFlag( nGblFlag );
    1132         [ #  # ]:          0 :                 if( pAppSymbol )
    1133                 :            :                 {
    1134                 :          0 :                     pMSOMacroRuntimeLib->SetFlag( SBX_EXTSEARCH );      // Could have been disabled before
    1135         [ #  # ]:          0 :                     GetSbData()->pMSOMacroRuntimLib = pMSOMacroRuntimeLib;
    1136                 :            :                 }
    1137                 :            :             }
    1138                 :            :         }
    1139                 :            : 
    1140         [ +  + ]:         31 :         if( nMaxCallLevel == 0 )
    1141                 :            :         {
    1142                 :            : #ifdef UNX
    1143                 :            :           struct rlimit rl;
    1144                 :         12 :           getrlimit ( RLIMIT_STACK, &rl );
    1145                 :            : #endif
    1146                 :            : #if defined LINUX
    1147                 :            :           // Empiric value, 900 = needed bytes/Basic call level
    1148                 :            :           // for Linux including 10% safety margin
    1149                 :         12 :           nMaxCallLevel = rl.rlim_cur / 900;
    1150                 :            : #elif defined SOLARIS
    1151                 :            :           // Empiric value, 1650 = needed bytes/Basic call level
    1152                 :            :           // for Solaris including 10% safety margin
    1153                 :            :           nMaxCallLevel = rl.rlim_cur / 1650;
    1154                 :            : #elif defined WIN32
    1155                 :            :           nMaxCallLevel = 5800;
    1156                 :            : #else
    1157                 :            :           nMaxCallLevel = MAXRECURSION;
    1158                 :            : #endif
    1159                 :            :         }
    1160                 :            :     }
    1161                 :            : 
    1162                 :            :     // Recursion to deep?
    1163 [ +  - ][ +  - ]:        913 :     if( ++GetSbData()->pInst->nCallLvl <= nMaxCallLevel )
    1164                 :            :     {
    1165                 :            :         // Define a globale variable in all Mods
    1166         [ +  - ]:        913 :         GlobalRunInit( /* bBasicStart = */ bDelInst );
    1167                 :            : 
    1168                 :            :         // Appeared a compiler error? Then we don't launch
    1169 [ +  - ][ +  - ]:        913 :         if( !GetSbData()->bGlobalInitErr )
    1170                 :            :         {
    1171         [ +  + ]:        913 :             if( bDelInst )
    1172                 :            :             {
    1173 [ +  - ][ +  - ]:         31 :                 SendHint( GetParent(), SBX_HINT_BASICSTART, pMeth );
    1174                 :            : 
    1175                 :            :                 // 1996-10-16: #31460 New concept for StepInto/Over/Out
    1176                 :            :                 // For an explanation see runtime.cxx at SbiInstance::CalcBreakCallLevel()
    1177                 :            :                 // Identify the BreakCallLevel
    1178 [ +  - ][ +  - ]:         31 :                 GetSbData()->pInst->CalcBreakCallLevel( pMeth->GetDebugFlags() );
    1179                 :            :             }
    1180                 :            : 
    1181         [ +  - ]:        913 :             SbModule* pOldMod = GetSbData()->pMod;
    1182         [ +  - ]:        913 :             GetSbData()->pMod = this;
    1183 [ +  - ][ +  - ]:        913 :             SbiRuntime* pRt = new SbiRuntime( this, pMeth, pMeth->nStart );
    1184                 :            : 
    1185         [ +  - ]:        913 :             pRt->pNext = GetSbData()->pInst->pRun;
    1186         [ +  + ]:        913 :             if( pRt->pNext )
    1187                 :        882 :                 pRt->pNext->block();
    1188         [ +  - ]:        913 :             GetSbData()->pInst->pRun = pRt;
    1189         [ +  + ]:        913 :             if ( mbVBACompat )
    1190                 :            :             {
    1191         [ +  - ]:        118 :                 GetSbData()->pInst->EnableCompatibility( sal_True );
    1192                 :            :             }
    1193 [ +  - ][ +  + ]:      52292 :             while( pRt->Step() ) {}
    1194         [ +  + ]:        913 :             if( pRt->pNext )
    1195                 :        882 :                 pRt->pNext->unblock();
    1196                 :            : 
    1197                 :            :             // #63710 It can happen by an another thread handling at events,
    1198                 :            :             // that the show call returns to an dialog (by closing the
    1199                 :            :             // dialog per UI), before a by an event triggered further call returned,
    1200                 :            :             // which stands in Basic more top in the stack and that had been run on
    1201                 :            :             // a  Basic-Breakpoint. Then would the instance below destroyed. And if the Basic,
    1202                 :            :             // that stand still in the call, further runs, there is a GPF.
    1203                 :            :             // Thus here had to be wait until the other call comes back.
    1204         [ +  + ]:        913 :             if( bDelInst )
    1205                 :            :             {
    1206                 :            :                 // Compare here with 1 instead of 0, because before nCallLvl--
    1207 [ +  - ][ -  + ]:         31 :                 while( GetSbData()->pInst->nCallLvl != 1 )
    1208 [ #  # ][ #  # ]:          0 :                     GetpApp()->Yield();
    1209                 :            :             }
    1210                 :            : 
    1211                 :        913 :             nRes = sal_True;
    1212         [ +  - ]:        913 :             GetSbData()->pInst->pRun = pRt->pNext;
    1213         [ +  - ]:        913 :             GetSbData()->pInst->nCallLvl--;          // Call-Level down again
    1214                 :            : 
    1215                 :            :             // Exist an higher-ranking runtime instance?
    1216                 :            :             // Then take over SbDEBUG_BREAK, if set
    1217                 :        913 :             SbiRuntime* pRtNext = pRt->pNext;
    1218 [ +  + ][ -  + ]:        913 :             if( pRtNext && (pRt->GetDebugFlags() & SbDEBUG_BREAK) )
                 [ -  + ]
    1219                 :          0 :                 pRtNext->SetDebugFlags( SbDEBUG_BREAK );
    1220                 :            : 
    1221 [ +  - ][ +  - ]:        913 :             delete pRt;
    1222         [ +  - ]:        913 :             GetSbData()->pMod = pOldMod;
    1223         [ +  + ]:        913 :             if( bDelInst )
    1224                 :            :             {
    1225                 :            :                 // #57841 Clear Uno-Objects, which were helt in RTL functions,
    1226                 :            :                 // at the end of the program, so that nothing were helt.
    1227         [ +  - ]:         31 :                 ClearUnoObjectsInRTL_Impl( xBasic );
    1228                 :            : 
    1229         [ +  - ]:         31 :                 clearNativeObjectWrapperVector();
    1230                 :            : 
    1231                 :            :                 DBG_ASSERT(GetSbData()->pInst->nCallLvl==0,"BASIC-Call-Level > 0");
    1232 [ +  - ][ +  - ]:         31 :                 delete GetSbData()->pInst, GetSbData()->pInst = NULL, bDelInst = sal_False;
         [ +  - ][ +  - ]
    1233                 :            : 
    1234                 :            :                 // #i30690
    1235         [ +  - ]:         31 :                 SolarMutexGuard aSolarGuard;
    1236 [ +  - ][ +  - ]:         31 :                 SendHint( GetParent(), SBX_HINT_BASICSTOP, pMeth );
    1237                 :            : 
    1238         [ +  - ]:         31 :                 GlobalRunDeInit();
    1239                 :            : 
    1240                 :            : #ifdef DBG_UTIL
    1241                 :            :                 ResetCapturedAssertions();
    1242                 :            : #endif
    1243                 :            : 
    1244         [ +  + ]:         31 :                 if( xVBACompat.is() )
    1245                 :            :                 {
    1246                 :            :                     // notify all VBA script listeners about the stopped script
    1247                 :            :                     try
    1248                 :            :                     {
    1249 [ +  - ][ +  - ]:          4 :                         xVBACompat->broadcastVBAScriptEvent( script::vba::VBAScriptEventId::SCRIPT_STOPPED, GetName() );
         [ +  - ][ +  - ]
                 [ #  # ]
    1250                 :            :                     }
    1251         [ #  # ]:          0 :                     catch(const uno::Exception& )
    1252                 :            :                     {
    1253                 :            :                     }
    1254                 :            :                     // VBA always ensures screenupdating is enabled after completing
    1255         [ +  - ]:          4 :                     ::basic::vba::lockControllersOfAllDocuments( xModel, sal_False );
    1256         [ +  - ]:          4 :                     ::basic::vba::enableContainerWindowsOfAllDocuments( xModel, sal_True );
    1257         [ +  - ]:         31 :                 }
    1258                 :            : 
    1259                 :            : #ifdef DBG_TRACE_BASIC
    1260                 :            :                 dbg_DeInitTrace();
    1261                 :            : #endif
    1262                 :            :             }
    1263                 :            :         }
    1264                 :            :         else
    1265         [ #  # ]:          0 :                GetSbData()->pInst->nCallLvl--;           // Call-Level down again
    1266                 :            :     }
    1267                 :            :     else
    1268                 :            :     {
    1269         [ #  # ]:          0 :         GetSbData()->pInst->nCallLvl--;          // Call-Level down again
    1270         [ #  # ]:          0 :         StarBASIC::FatalError( SbERR_STACK_OVERFLOW );
    1271                 :            :     }
    1272                 :            : 
    1273 [ +  - ][ +  - ]:        913 :     StarBASIC* pBasic = PTR_CAST(StarBASIC,GetParent());
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
                 [ +  - ]
    1274         [ -  + ]:        913 :     if( bDelInst )
    1275                 :            :     {
    1276                 :            :        // #57841 Clear Uno-Objects, which were helt in RTL functions,
    1277                 :            :        // the end of the program, so that nothing were helt.
    1278         [ #  # ]:          0 :         ClearUnoObjectsInRTL_Impl( xBasic );
    1279                 :            : 
    1280 [ #  # ][ #  # ]:          0 :         delete GetSbData()->pInst;
                 [ #  # ]
    1281         [ #  # ]:          0 :         GetSbData()->pInst = NULL;
    1282                 :            :     }
    1283 [ +  - ][ +  + ]:        913 :     if ( pBasic && pBasic->IsDocBasic() && pBasic->IsQuitApplication() && !GetSbData()->pInst )
         [ -  + ][ #  # ]
         [ #  # ][ -  + ]
    1284                 :          0 :             bQuit = true;
    1285         [ -  + ]:        913 :         if ( bQuit )
    1286                 :            :     {
    1287 [ #  # ][ #  # ]:          0 :         Application::PostUserEvent( LINK( &AsyncQuitHandler::instance(), AsyncQuitHandler, OnAsyncQuit ), NULL );
    1288                 :            :     }
    1289                 :            : 
    1290         [ +  - ]:        913 :     return nRes;
    1291                 :            : }
    1292                 :            : 
    1293                 :            : // Execute of the init method of a module after the loading
    1294                 :            : // or the compilation
    1295                 :            : 
    1296                 :         89 : void SbModule::RunInit()
    1297                 :            : {
    1298         [ +  - ]:        166 :     if( pImage
           [ +  +  +  + ]
                 [ +  + ]
    1299                 :         89 :      && !pImage->bInit
    1300                 :         77 :      && pImage->GetFlag( SBIMG_INITCODE ) )
    1301                 :            :     {
    1302                 :            :         // Set flag, so that RunInit get activ (Testtool)
    1303                 :          8 :         GetSbData()->bRunInit = true;
    1304                 :            : 
    1305                 :          8 :         SbModule* pOldMod = GetSbData()->pMod;
    1306                 :          8 :         GetSbData()->pMod = this;
    1307                 :            :         // The init code starts always here
    1308         [ +  - ]:          8 :         SbiRuntime* pRt = new SbiRuntime( this, NULL, 0 );
    1309                 :            : 
    1310                 :          8 :         pRt->pNext = GetSbData()->pInst->pRun;
    1311                 :          8 :         GetSbData()->pInst->pRun = pRt;
    1312         [ +  + ]:        888 :         while( pRt->Step() ) {}
    1313                 :            : 
    1314                 :          8 :         GetSbData()->pInst->pRun = pRt->pNext;
    1315         [ +  - ]:          8 :         delete pRt;
    1316                 :          8 :         GetSbData()->pMod = pOldMod;
    1317                 :          8 :         pImage->bInit = true;
    1318                 :          8 :         pImage->bFirstInit = false;
    1319                 :            : 
    1320                 :            :         // RunInit is not activ anymore
    1321                 :          8 :         GetSbData()->bRunInit = false;
    1322                 :            :     }
    1323                 :         89 : }
    1324                 :            : 
    1325                 :            : // Delete with private/dim declared variables
    1326                 :            : 
    1327                 :          0 : void SbModule::AddVarName( const String& aName )
    1328                 :            : {
    1329                 :            :     // see if the name is added allready
    1330                 :          0 :     std::vector< String >::iterator it_end = mModuleVariableNames.end();
    1331 [ #  # ][ #  # ]:          0 :     for ( std::vector< String >::iterator it = mModuleVariableNames.begin(); it != it_end; ++it )
                 [ #  # ]
    1332                 :            :     {
    1333 [ #  # ][ #  # ]:          0 :         if ( aName == *it )
                 [ #  # ]
    1334                 :          0 :             return;
    1335                 :            :     }
    1336         [ #  # ]:          0 :     mModuleVariableNames.push_back( aName );
    1337                 :            : }
    1338                 :            : 
    1339                 :         65 : void SbModule::RemoveVars()
    1340                 :            : {
    1341                 :         65 :     std::vector< String >::iterator it_end = mModuleVariableNames.end();
    1342 [ #  # ][ +  - ]:         65 :     for ( std::vector< String >::iterator it = mModuleVariableNames.begin(); it != it_end; ++it )
                 [ -  + ]
    1343                 :            :     {
    1344                 :            :     // We don't want a Find being called in a derived class ( e.g.
    1345                 :            :     // SbUserform because it could trigger say an initialise event
    1346                 :            :     // which would cause basic to be re-run in the middle of the init ( and remember RemoveVars is called from compile and we don't want code to run as part of the compile )
    1347 [ #  # ][ #  # ]:          0 :     SbxVariableRef p = SbModule::Find( *it, SbxCLASS_PROPERTY );
                 [ #  # ]
    1348         [ #  # ]:          0 :     if( p.Is() )
    1349         [ #  # ]:          0 :         Remove (p);
    1350         [ #  # ]:          0 :     }
    1351                 :         65 : }
    1352                 :            : 
    1353                 :          0 : void SbModule::ClearPrivateVars()
    1354                 :            : {
    1355         [ #  # ]:          0 :     for( sal_uInt16 i = 0 ; i < pProps->Count() ; i++ )
    1356                 :            :     {
    1357 [ #  # ][ #  # ]:          0 :         SbProperty* p = PTR_CAST(SbProperty,pProps->Get( i ) );
    1358         [ #  # ]:          0 :         if( p )
    1359                 :            :         {
    1360                 :            :             // Delete not the arrays, only their content
    1361         [ #  # ]:          0 :             if( p->GetType() & SbxARRAY )
    1362                 :            :             {
    1363 [ #  # ][ #  # ]:          0 :                 SbxArray* pArray = PTR_CAST(SbxArray,p->GetObject());
    1364         [ #  # ]:          0 :                 if( pArray )
    1365                 :            :                 {
    1366         [ #  # ]:          0 :                     for( sal_uInt16 j = 0 ; j < pArray->Count() ; j++ )
    1367                 :            :                     {
    1368 [ #  # ][ #  # ]:          0 :                         SbxVariable* pj = PTR_CAST(SbxVariable,pArray->Get( j ));
    1369                 :          0 :                         pj->SbxValue::Clear();
    1370                 :            :                     }
    1371                 :            :                 }
    1372                 :            :             }
    1373                 :            :             else
    1374                 :            :             {
    1375                 :          0 :                 p->SbxValue::Clear();
    1376                 :            :             }
    1377                 :            :         }
    1378                 :            :     }
    1379                 :          0 : }
    1380                 :            : 
    1381                 :         18 : void SbModule::implClearIfVarDependsOnDeletedBasic( SbxVariable* pVar, StarBASIC* pDeletedBasic )
    1382                 :            : {
    1383 [ -  + ][ #  # ]:         18 :     if( pVar->SbxValue::GetType() != SbxOBJECT || pVar->ISA( SbProcedureProperty ) )
                 [ +  - ]
    1384                 :         18 :         return;
    1385                 :            : 
    1386 [ #  # ][ #  # ]:          0 :     SbxObject* pObj = PTR_CAST(SbxObject,pVar->GetObject());
    1387         [ #  # ]:          0 :     if( pObj != NULL )
    1388                 :            :     {
    1389                 :          0 :         SbxObject* p = pObj;
    1390                 :            : 
    1391 [ #  # ][ #  # ]:          0 :         SbModule* pMod = PTR_CAST( SbModule, p );
    1392         [ #  # ]:          0 :         if( pMod != NULL )
    1393                 :          0 :             pMod->ClearVarsDependingOnDeletedBasic( pDeletedBasic );
    1394                 :            : 
    1395         [ #  # ]:          0 :         while( (p = p->GetParent()) != NULL )
    1396                 :            :         {
    1397 [ #  # ][ #  # ]:          0 :             StarBASIC* pBasic = PTR_CAST( StarBASIC, p );
    1398 [ #  # ][ #  # ]:          0 :             if( pBasic != NULL && pBasic == pDeletedBasic )
    1399                 :            :             {
    1400                 :          0 :                 pVar->SbxValue::Clear();
    1401                 :          0 :                 break;
    1402                 :            :             }
    1403                 :            :         }
    1404                 :            :     }
    1405                 :            : }
    1406                 :            : 
    1407                 :        117 : void SbModule::ClearVarsDependingOnDeletedBasic( StarBASIC* pDeletedBasic )
    1408                 :            : {
    1409                 :            :     (void)pDeletedBasic;
    1410                 :            : 
    1411         [ +  + ]:        369 :     for( sal_uInt16 i = 0 ; i < pProps->Count() ; i++ )
    1412                 :            :     {
    1413 [ +  - ][ +  + ]:        252 :         SbProperty* p = PTR_CAST(SbProperty,pProps->Get( i ) );
    1414         [ +  + ]:        252 :         if( p )
    1415                 :            :         {
    1416         [ -  + ]:         18 :             if( p->GetType() & SbxARRAY )
    1417                 :            :             {
    1418 [ #  # ][ #  # ]:          0 :                 SbxArray* pArray = PTR_CAST(SbxArray,p->GetObject());
    1419         [ #  # ]:          0 :                 if( pArray )
    1420                 :            :                 {
    1421         [ #  # ]:          0 :                     for( sal_uInt16 j = 0 ; j < pArray->Count() ; j++ )
    1422                 :            :                     {
    1423 [ #  # ][ #  # ]:          0 :                         SbxVariable* pVar = PTR_CAST(SbxVariable,pArray->Get( j ));
    1424                 :          0 :                         implClearIfVarDependsOnDeletedBasic( pVar, pDeletedBasic );
    1425                 :            :                     }
    1426                 :            :                 }
    1427                 :            :             }
    1428                 :            :             else
    1429                 :            :             {
    1430                 :         18 :                 implClearIfVarDependsOnDeletedBasic( p, pDeletedBasic );
    1431                 :            :             }
    1432                 :            :         }
    1433                 :            :     }
    1434                 :        117 : }
    1435                 :            : 
    1436                 :         81 : void StarBASIC::ClearAllModuleVars( void )
    1437                 :            : {
    1438                 :            :     // Initialise the own module
    1439         [ +  + ]:        197 :     for ( sal_uInt16 nMod = 0; nMod < pModules->Count(); nMod++ )
    1440                 :            :     {
    1441                 :        116 :         SbModule* pModule = (SbModule*)pModules->Get( nMod );
    1442                 :            :         // Initialise only, if the startcode was already executed
    1443 [ -  + ][ #  # ]:        116 :         if( pModule->pImage && pModule->pImage->bInit && !pModule->isProxyModule() && !pModule->ISA(SbObjModule) )
         [ #  # ][ -  + ]
                 [ +  + ]
    1444                 :          0 :             pModule->ClearPrivateVars();
    1445                 :            :     }
    1446                 :            : 
    1447                 :         81 : }
    1448                 :            : 
    1449                 :            : // Execution of the init-code of all module
    1450                 :        913 : void SbModule::GlobalRunInit( sal_Bool bBasicStart )
    1451                 :            : {
    1452                 :            :     // If no Basic-Start, only initialise, if the module is not initialised
    1453         [ +  + ]:        913 :     if( !bBasicStart )
    1454 [ +  - ][ +  + ]:        882 :         if( !(pImage && !pImage->bInit) )
    1455                 :        913 :             return;
    1456                 :            : 
    1457                 :            :     // Initialise GlobalInitErr-Flag for Compiler-Error
    1458                 :            :     // With the help of this flags could be located in SbModule::Run() after the call of
    1459                 :            :     // GlobalRunInit, if at the intialising of the module
    1460                 :            :     // an error occurred. Then it will not be launched.
    1461                 :         35 :     GetSbData()->bGlobalInitErr = false;
    1462                 :            : 
    1463                 :            :     // Parent of the module is a Basic
    1464 [ +  - ][ +  - ]:         35 :     StarBASIC *pBasic = PTR_CAST(StarBASIC,GetParent());
    1465         [ +  - ]:         35 :     if( pBasic )
    1466                 :            :     {
    1467                 :         35 :         pBasic->InitAllModules();
    1468                 :            : 
    1469                 :         35 :         SbxObject* pParent_ = pBasic->GetParent();
    1470         [ +  + ]:         35 :         if( pParent_ )
    1471                 :            :         {
    1472 [ +  - ][ +  - ]:         20 :             StarBASIC * pParentBasic = PTR_CAST(StarBASIC,pParent_);
    1473         [ +  - ]:         20 :             if( pParentBasic )
    1474                 :            :             {
    1475                 :         20 :                 pParentBasic->InitAllModules( pBasic );
    1476                 :            : 
    1477                 :            :                 // #109018 Parent can also have a parent (library in doc)
    1478                 :         20 :                 SbxObject* pParentParent = pParentBasic->GetParent();
    1479         [ +  + ]:         20 :                 if( pParentParent )
    1480                 :            :                 {
    1481 [ +  - ][ +  - ]:         12 :                     StarBASIC * pParentParentBasic = PTR_CAST(StarBASIC,pParentParent);
    1482         [ +  - ]:         12 :                     if( pParentParentBasic )
    1483                 :         12 :                         pParentParentBasic->InitAllModules( pParentBasic );
    1484                 :            :                 }
    1485                 :            :             }
    1486                 :            :         }
    1487                 :            :     }
    1488                 :            : }
    1489                 :            : 
    1490                 :         31 : void SbModule::GlobalRunDeInit( void )
    1491                 :            : {
    1492 [ +  - ][ +  - ]:         31 :     StarBASIC *pBasic = PTR_CAST(StarBASIC,GetParent());
    1493         [ +  - ]:         31 :     if( pBasic )
    1494                 :            :     {
    1495                 :         31 :         pBasic->DeInitAllModules();
    1496                 :            : 
    1497                 :         31 :         SbxObject* pParent_ = pBasic->GetParent();
    1498         [ +  + ]:         31 :         if( pParent_ )
    1499 [ +  - ][ +  - ]:         14 :             pBasic = PTR_CAST(StarBASIC,pParent_);
    1500         [ +  - ]:         31 :         if( pBasic )
    1501                 :         31 :             pBasic->DeInitAllModules();
    1502                 :            :     }
    1503                 :         31 : }
    1504                 :            : 
    1505                 :            : // Search for the next STMNT-Command in the code. This was used from the STMNT-
    1506                 :            : // Opcode to set the endcolumn.
    1507                 :            : 
    1508                 :       9754 : const sal_uInt8* SbModule::FindNextStmnt( const sal_uInt8* p, sal_uInt16& nLine, sal_uInt16& nCol ) const
    1509                 :            : {
    1510                 :       9754 :     return FindNextStmnt( p, nLine, nCol, sal_False );
    1511                 :            : }
    1512                 :            : 
    1513                 :       9754 : const sal_uInt8* SbModule::FindNextStmnt( const sal_uInt8* p, sal_uInt16& nLine, sal_uInt16& nCol,
    1514                 :            :     sal_Bool bFollowJumps, const SbiImage* pImg ) const
    1515                 :            : {
    1516                 :       9754 :     sal_uInt32 nPC = (sal_uInt32) ( p - (const sal_uInt8*) pImage->GetCode() );
    1517         [ +  + ]:      52858 :     while( nPC < pImage->GetCodeSize() )
    1518                 :            :     {
    1519                 :      52783 :         SbiOpcode eOp = (SbiOpcode ) ( *p++ );
    1520                 :      52783 :         nPC++;
    1521 [ -  + ][ #  # ]:      52783 :         if( bFollowJumps && eOp == _JUMP && pImg )
                 [ #  # ]
    1522                 :            :         {
    1523                 :            :             DBG_ASSERT( pImg, "FindNextStmnt: pImg==NULL with FollowJumps option" );
    1524                 :          0 :             sal_uInt32 nOp1 = *p++; nOp1 |= *p++ << 8;
    1525                 :          0 :             nOp1 |= *p++ << 16; nOp1 |= *p++ << 24;
    1526                 :          0 :             p = (const sal_uInt8*) pImg->GetCode() + nOp1;
    1527                 :            :         }
    1528 [ +  + ][ +  + ]:      52783 :         else if( eOp >= SbOP1_START && eOp <= SbOP1_END )
    1529                 :       8800 :             p += 4, nPC += 4;
    1530         [ +  + ]:      43983 :         else if( eOp == _STMNT )
    1531                 :            :         {
    1532                 :            :             sal_uInt32 nl, nc;
    1533                 :       9679 :             nl = *p++; nl |= *p++ << 8;
    1534                 :       9679 :             nl |= *p++ << 16 ; nl |= *p++ << 24;
    1535                 :       9679 :             nc = *p++; nc |= *p++ << 8;
    1536                 :       9679 :             nc |= *p++ << 16 ; nc |= *p++ << 24;
    1537                 :       9679 :             nLine = (sal_uInt16)nl; nCol = (sal_uInt16)nc;
    1538                 :       9679 :             return p;
    1539                 :            :         }
    1540 [ +  + ][ +  - ]:      34304 :         else if( eOp >= SbOP2_START && eOp <= SbOP2_END )
    1541                 :      18127 :             p += 8, nPC += 8;
    1542 [ +  - ][ -  + ]:      16177 :         else if( !( eOp >= SbOP0_START && eOp <= SbOP0_END ) )
    1543                 :            :         {
    1544                 :          0 :             StarBASIC::FatalError( SbERR_INTERNAL_ERROR );
    1545                 :          0 :             break;
    1546                 :            :         }
    1547                 :            :     }
    1548                 :       9754 :     return NULL;
    1549                 :            : }
    1550                 :            : 
    1551                 :            : // Test, if a line contains STMNT-Opcodes
    1552                 :            : 
    1553                 :          0 : sal_Bool SbModule::IsBreakable( sal_uInt16 nLine ) const
    1554                 :            : {
    1555         [ #  # ]:          0 :     if( !pImage )
    1556                 :          0 :         return sal_False;
    1557                 :          0 :     const sal_uInt8* p = (const sal_uInt8* ) pImage->GetCode();
    1558                 :            :     sal_uInt16 nl, nc;
    1559 [ #  # ][ #  # ]:          0 :     while( ( p = FindNextStmnt( p, nl, nc ) ) != NULL )
    1560         [ #  # ]:          0 :         if( nl == nLine )
    1561                 :          0 :             return sal_True;
    1562                 :          0 :     return sal_False;
    1563                 :            : }
    1564                 :            : 
    1565                 :          0 : size_t SbModule::GetBPCount() const
    1566                 :            : {
    1567         [ #  # ]:          0 :     return pBreaks ? pBreaks->size() : 0;
    1568                 :            : }
    1569                 :            : 
    1570                 :          0 : sal_uInt16 SbModule::GetBP( size_t n ) const
    1571                 :            : {
    1572 [ #  # ][ #  # ]:          0 :     if( pBreaks && n < pBreaks->size() )
                 [ #  # ]
    1573                 :          0 :         return pBreaks->operator[]( n );
    1574                 :            :     else
    1575                 :          0 :         return 0;
    1576                 :            : }
    1577                 :            : 
    1578                 :          0 : sal_Bool SbModule::IsBP( sal_uInt16 nLine ) const
    1579                 :            : {
    1580         [ #  # ]:          0 :     if( pBreaks )
    1581                 :            :     {
    1582         [ #  # ]:          0 :         for( size_t i = 0; i < pBreaks->size(); i++ )
    1583                 :            :         {
    1584                 :          0 :             sal_uInt16 b = pBreaks->operator[]( i );
    1585         [ #  # ]:          0 :             if( b == nLine )
    1586                 :          0 :                 return sal_True;
    1587         [ #  # ]:          0 :             if( b < nLine )
    1588                 :          0 :                 break;
    1589                 :            :         }
    1590                 :            :     }
    1591                 :          0 :     return sal_False;
    1592                 :            : }
    1593                 :            : 
    1594                 :          0 : sal_Bool SbModule::SetBP( sal_uInt16 nLine )
    1595                 :            : {
    1596         [ #  # ]:          0 :     if( !IsBreakable( nLine ) )
    1597                 :          0 :         return sal_False;
    1598         [ #  # ]:          0 :     if( !pBreaks )
    1599         [ #  # ]:          0 :         pBreaks = new SbiBreakpoints;
    1600                 :            :     size_t i;
    1601         [ #  # ]:          0 :     for( i = 0; i < pBreaks->size(); i++ )
    1602                 :            :     {
    1603                 :          0 :         sal_uInt16 b = pBreaks->operator[]( i );
    1604         [ #  # ]:          0 :         if( b == nLine )
    1605                 :          0 :             return sal_True;
    1606         [ #  # ]:          0 :         if( b < nLine )
    1607                 :          0 :             break;
    1608                 :            :     }
    1609 [ #  # ][ #  # ]:          0 :     pBreaks->insert( pBreaks->begin() + i, nLine );
    1610                 :            : 
    1611                 :            :     // #38568: Set during runtime as well here SbDEBUG_BREAK
    1612 [ #  # ][ #  # ]:          0 :     if( GetSbData()->pInst && GetSbData()->pInst->pRun )
                 [ #  # ]
    1613                 :          0 :         GetSbData()->pInst->pRun->SetDebugFlags( SbDEBUG_BREAK );
    1614                 :            : 
    1615                 :          0 :     return IsBreakable( nLine );
    1616                 :            : }
    1617                 :            : 
    1618                 :          0 : sal_Bool SbModule::ClearBP( sal_uInt16 nLine )
    1619                 :            : {
    1620                 :          0 :     sal_Bool bRes = sal_False;
    1621         [ #  # ]:          0 :     if( pBreaks )
    1622                 :            :     {
    1623         [ #  # ]:          0 :         for( size_t i = 0; i < pBreaks->size(); i++ )
    1624                 :            :         {
    1625                 :          0 :             sal_uInt16 b = pBreaks->operator[]( i );
    1626         [ #  # ]:          0 :             if( b == nLine )
    1627                 :            :             {
    1628 [ #  # ][ #  # ]:          0 :                 pBreaks->erase( pBreaks->begin() + i );
    1629                 :          0 :                 bRes = sal_True;
    1630                 :          0 :                 break;
    1631                 :            :             }
    1632         [ #  # ]:          0 :             if( b < nLine )
    1633                 :          0 :                 break;
    1634                 :            :         }
    1635         [ #  # ]:          0 :         if( pBreaks->empty() )
    1636         [ #  # ]:          0 :             delete pBreaks, pBreaks = NULL;
    1637                 :            :     }
    1638                 :          0 :     return bRes;
    1639                 :            : }
    1640                 :            : 
    1641                 :          0 : void SbModule::ClearAllBP()
    1642                 :            : {
    1643         [ #  # ]:          0 :     delete pBreaks;
    1644                 :          0 :     pBreaks = NULL;
    1645                 :          0 : }
    1646                 :            : 
    1647                 :            : void
    1648                 :          0 : SbModule::fixUpMethodStart( bool bCvtToLegacy, SbiImage* pImg ) const
    1649                 :            : {
    1650         [ #  # ]:          0 :         if ( !pImg )
    1651                 :          0 :             pImg = pImage;
    1652         [ #  # ]:          0 :         for( sal_uInt32 i = 0; i < pMethods->Count(); i++ )
    1653                 :            :         {
    1654 [ #  # ][ #  # ]:          0 :             SbMethod* pMeth = PTR_CAST(SbMethod,pMethods->Get( (sal_uInt16)i ) );
    1655         [ #  # ]:          0 :             if( pMeth )
    1656                 :            :             {
    1657                 :            :                 //fixup method start positions
    1658         [ #  # ]:          0 :                 if ( bCvtToLegacy )
    1659                 :          0 :                     pMeth->nStart = pImg->CalcLegacyOffset( pMeth->nStart );
    1660                 :            :                 else
    1661                 :          0 :                     pMeth->nStart = pImg->CalcNewOffset( (sal_uInt16)pMeth->nStart );
    1662                 :            :             }
    1663                 :            :         }
    1664                 :            : 
    1665                 :          0 : }
    1666                 :            : 
    1667                 :          0 : sal_Bool SbModule::LoadData( SvStream& rStrm, sal_uInt16 nVer )
    1668                 :            : {
    1669         [ #  # ]:          0 :     Clear();
    1670 [ #  # ][ #  # ]:          0 :     if( !SbxObject::LoadData( rStrm, 1 ) )
    1671                 :          0 :         return sal_False;
    1672                 :            :     // As a precaution...
    1673                 :          0 :     SetFlag( SBX_EXTSEARCH | SBX_GBLSEARCH );
    1674                 :            :     sal_uInt8 bImage;
    1675         [ #  # ]:          0 :     rStrm >> bImage;
    1676         [ #  # ]:          0 :     if( bImage )
    1677                 :            :     {
    1678 [ #  # ][ #  # ]:          0 :         SbiImage* p = new SbiImage;
    1679                 :          0 :         sal_uInt32 nImgVer = 0;
    1680                 :            : 
    1681 [ #  # ][ #  # ]:          0 :         if( !p->Load( rStrm, nImgVer ) )
    1682                 :            :         {
    1683 [ #  # ][ #  # ]:          0 :             delete p;
    1684                 :          0 :             return sal_False;
    1685                 :            :         }
    1686                 :            :         // If the image is in old format, we fix up the method start offsets
    1687         [ #  # ]:          0 :         if ( nImgVer < B_EXT_IMG_VERSION )
    1688                 :            :         {
    1689         [ #  # ]:          0 :             fixUpMethodStart( false, p );
    1690         [ #  # ]:          0 :             p->ReleaseLegacyBuffer();
    1691                 :            :         }
    1692         [ #  # ]:          0 :         aComment = p->aComment;
    1693         [ #  # ]:          0 :         SetName( p->aName );
    1694         [ #  # ]:          0 :         if( p->GetCodeSize() )
    1695                 :            :         {
    1696                 :          0 :             aOUSource = p->aOUSource;
    1697                 :            :             // Old version: image away
    1698         [ #  # ]:          0 :             if( nVer == 1 )
    1699                 :            :             {
    1700         [ #  # ]:          0 :                 SetSource32( p->aOUSource );
    1701 [ #  # ][ #  # ]:          0 :                 delete p;
    1702                 :            :             }
    1703                 :            :             else
    1704                 :          0 :                 pImage = p;
    1705                 :            :         }
    1706                 :            :         else
    1707                 :            :         {
    1708         [ #  # ]:          0 :             SetSource32( p->aOUSource );
    1709 [ #  # ][ #  # ]:          0 :             delete p;
    1710                 :            :         }
    1711                 :            :     }
    1712                 :          0 :     return sal_True;
    1713                 :            : }
    1714                 :            : 
    1715                 :          0 : sal_Bool SbModule::StoreData( SvStream& rStrm ) const
    1716                 :            : {
    1717 [ #  # ][ #  # ]:          0 :     bool bFixup = ( pImage && !pImage->ExceedsLegacyLimits() );
    1718         [ #  # ]:          0 :     if ( bFixup )
    1719                 :          0 :         fixUpMethodStart( true );
    1720                 :          0 :     sal_Bool bRet = SbxObject::StoreData( rStrm );
    1721         [ #  # ]:          0 :     if ( !bRet )
    1722                 :          0 :         return sal_False;
    1723                 :            : 
    1724         [ #  # ]:          0 :     if( pImage )
    1725                 :            :     {
    1726                 :          0 :         pImage->aOUSource = aOUSource;
    1727                 :          0 :         pImage->aComment = aComment;
    1728                 :          0 :         pImage->aName = GetName();
    1729                 :          0 :         rStrm << (sal_uInt8) 1;
    1730                 :            :         // # PCode is saved only for legacy formats only
    1731                 :            :         // It should be noted that it probably isn't necessary
    1732                 :            :         // It would be better not to store the image ( more flexible with
    1733                 :            :         // formats )
    1734                 :          0 :         bool bRes = pImage->Save( rStrm, B_LEGACYVERSION );
    1735         [ #  # ]:          0 :         if ( bFixup )
    1736                 :          0 :             fixUpMethodStart( false ); // restore method starts
    1737                 :          0 :         return bRes;
    1738                 :            : 
    1739                 :            :     }
    1740                 :            :     else
    1741                 :            :     {
    1742         [ #  # ]:          0 :         SbiImage aImg;
    1743                 :          0 :         aImg.aOUSource = aOUSource;
    1744         [ #  # ]:          0 :         aImg.aComment = aComment;
    1745 [ #  # ][ #  # ]:          0 :         aImg.aName = GetName();
    1746         [ #  # ]:          0 :         rStrm << (sal_uInt8) 1;
    1747 [ #  # ][ #  # ]:          0 :         return aImg.Save( rStrm );
    1748                 :            :     }
    1749                 :            : }
    1750                 :            : 
    1751                 :          0 : sal_Bool SbModule::ExceedsLegacyModuleSize()
    1752                 :            : {
    1753         [ #  # ]:          0 :     if ( !IsCompiled() )
    1754                 :          0 :         Compile();
    1755 [ #  # ][ #  # ]:          0 :     if ( pImage && pImage->ExceedsLegacyLimits() )
                 [ #  # ]
    1756                 :          0 :         return true;
    1757                 :          0 :     return false;
    1758                 :            : }
    1759                 :            : 
    1760                 :            : class ErrorHdlResetter
    1761                 :            : {
    1762                 :            :     Link    mErrHandler;
    1763                 :            :     bool mbError;
    1764                 :            :     public:
    1765                 :         15 :     ErrorHdlResetter() : mbError( false )
    1766                 :            :     {
    1767                 :            :         // save error handler
    1768                 :         15 :         mErrHandler = StarBASIC::GetGlobalErrorHdl();
    1769                 :            :         // set new error handler
    1770         [ +  - ]:         15 :         StarBASIC::SetGlobalErrorHdl( LINK( this, ErrorHdlResetter, BasicErrorHdl ) );
    1771                 :         15 :     }
    1772                 :         15 :     ~ErrorHdlResetter()
    1773                 :            :     {
    1774                 :            :         // restore error handler
    1775                 :         15 :         StarBASIC::SetGlobalErrorHdl(mErrHandler);
    1776                 :         15 :     }
    1777                 :            :     DECL_LINK( BasicErrorHdl, StarBASIC * );
    1778                 :         15 :     bool HasError() { return mbError; }
    1779                 :            : };
    1780                 :          0 : IMPL_LINK( ErrorHdlResetter, BasicErrorHdl, StarBASIC *, /*pBasic*/)
    1781                 :            : {
    1782                 :          0 :     mbError = true;
    1783                 :          0 :     return 0;
    1784                 :            : }
    1785                 :            : 
    1786                 :         21 : bool SbModule::HasExeCode()
    1787                 :            : {
    1788                 :            :     // And empty Image always has the Global Chain set up
    1789                 :            :     static const unsigned char pEmptyImage[] = { 0x45, 0x0 , 0x0, 0x0, 0x0 };
    1790                 :            :     // lets be stricter for the moment than VBA
    1791                 :            : 
    1792         [ +  + ]:         21 :     if (!IsCompiled())
    1793                 :            :     {
    1794         [ +  - ]:         15 :         ErrorHdlResetter aGblErrHdl;
    1795         [ +  - ]:         15 :         Compile();
    1796         [ -  + ]:         15 :         if (aGblErrHdl.HasError()) //assume unsafe on compile error
    1797 [ +  - ][ +  - ]:         15 :             return true;
    1798                 :            :     }
    1799                 :            : 
    1800                 :         21 :     bool bRes = false;
    1801 [ +  - ][ +  + ]:         21 :     if (pImage && !(pImage->GetCodeSize() == 5 && (memcmp(pImage->GetCode(), pEmptyImage, pImage->GetCodeSize()) == 0 )))
         [ -  + ][ +  + ]
    1802                 :         17 :         bRes = true;
    1803                 :            : 
    1804                 :         21 :     return bRes;
    1805                 :            : }
    1806                 :            : 
    1807                 :            : // Store only image, no source
    1808                 :          0 : sal_Bool SbModule::StoreBinaryData( SvStream& rStrm )
    1809                 :            : {
    1810                 :          0 :     return StoreBinaryData( rStrm, 0 );
    1811                 :            : }
    1812                 :            : 
    1813                 :          0 : sal_Bool SbModule::StoreBinaryData( SvStream& rStrm, sal_uInt16 nVer )
    1814                 :            : {
    1815                 :          0 :     sal_Bool bRet = Compile();
    1816         [ #  # ]:          0 :     if( bRet )
    1817                 :            :     {
    1818 [ #  # ][ #  # ]:          0 :         bool bFixup = ( !nVer && !pImage->ExceedsLegacyLimits() );// save in old image format, fix up method starts
    1819                 :            : 
    1820         [ #  # ]:          0 :         if ( bFixup ) // save in old image format, fix up method starts
    1821                 :          0 :             fixUpMethodStart( true );
    1822                 :          0 :          bRet = SbxObject::StoreData( rStrm );
    1823         [ #  # ]:          0 :         if( bRet )
    1824                 :            :         {
    1825                 :          0 :             pImage->aOUSource = ::rtl::OUString();
    1826                 :          0 :             pImage->aComment = aComment;
    1827                 :          0 :             pImage->aName = GetName();
    1828                 :            : 
    1829                 :          0 :             rStrm << (sal_uInt8) 1;
    1830         [ #  # ]:          0 :                     if ( nVer )
    1831                 :          0 :                         bRet = pImage->Save( rStrm, B_EXT_IMG_VERSION );
    1832                 :            :                     else
    1833                 :          0 :                         bRet = pImage->Save( rStrm, B_LEGACYVERSION );
    1834         [ #  # ]:          0 :                     if ( bFixup )
    1835                 :          0 :                         fixUpMethodStart( false ); // restore method starts
    1836                 :            : 
    1837                 :          0 :             pImage->aOUSource = aOUSource;
    1838                 :            :         }
    1839                 :            :     }
    1840                 :          0 :     return bRet;
    1841                 :            : }
    1842                 :            : 
    1843                 :            : // Called for >= OO 1.0 passwd protected libraries only
    1844                 :            : 
    1845                 :          0 : sal_Bool SbModule::LoadBinaryData( SvStream& rStrm )
    1846                 :            : {
    1847                 :          0 :     ::rtl::OUString aKeepSource = aOUSource;
    1848         [ #  # ]:          0 :     bool bRet = LoadData( rStrm, 2 );
    1849         [ #  # ]:          0 :     LoadCompleted();
    1850                 :          0 :     aOUSource = aKeepSource;
    1851                 :          0 :     return bRet;
    1852                 :            : }
    1853                 :            : 
    1854                 :          0 : sal_Bool SbModule::LoadCompleted()
    1855                 :            : {
    1856                 :          0 :     SbxArray* p = GetMethods();
    1857                 :            :     sal_uInt16 i;
    1858         [ #  # ]:          0 :     for( i = 0; i < p->Count(); i++ )
    1859                 :            :     {
    1860 [ #  # ][ #  # ]:          0 :         SbMethod* q = PTR_CAST(SbMethod,p->Get( i ) );
    1861         [ #  # ]:          0 :         if( q )
    1862                 :          0 :             q->pMod = this;
    1863                 :            :     }
    1864                 :          0 :     p = GetProperties();
    1865         [ #  # ]:          0 :     for( i = 0; i < p->Count(); i++ )
    1866                 :            :     {
    1867 [ #  # ][ #  # ]:          0 :         SbProperty* q = PTR_CAST(SbProperty,p->Get( i ) );
    1868         [ #  # ]:          0 :         if( q )
    1869                 :          0 :             q->pMod = this;
    1870                 :            :     }
    1871                 :          0 :     return sal_True;
    1872                 :            : }
    1873                 :            : 
    1874                 :          0 : void SbModule::handleProcedureProperties( SfxBroadcaster& rBC, const SfxHint& rHint )
    1875                 :            : {
    1876                 :          0 :     bool bDone = false;
    1877                 :            : 
    1878 [ #  # ][ #  # ]:          0 :     const SbxHint* pHint = PTR_CAST(SbxHint,&rHint);
    1879         [ #  # ]:          0 :     if( pHint )
    1880                 :            :     {
    1881                 :          0 :         SbxVariable* pVar = pHint->GetVar();
    1882 [ #  # ][ #  # ]:          0 :         SbProcedureProperty* pProcProperty = PTR_CAST( SbProcedureProperty, pVar );
    1883         [ #  # ]:          0 :         if( pProcProperty )
    1884                 :            :         {
    1885                 :          0 :             bDone = true;
    1886                 :            : 
    1887         [ #  # ]:          0 :             if( pHint->GetId() == SBX_HINT_DATAWANTED )
    1888                 :            :             {
    1889         [ #  # ]:          0 :                 String aProcName;
    1890         [ #  # ]:          0 :                 aProcName.AppendAscii( "Property Get " );
    1891 [ #  # ][ #  # ]:          0 :                 aProcName += pProcProperty->GetName();
    1892                 :            : 
    1893 [ #  # ][ #  # ]:          0 :                 SbxVariable* pMeth = Find( aProcName, SbxCLASS_METHOD );
    1894         [ #  # ]:          0 :                 if( pMeth )
    1895                 :            :                 {
    1896                 :          0 :                     SbxValues aVals;
    1897                 :          0 :                     aVals.eType = SbxVARIANT;
    1898                 :            : 
    1899         [ #  # ]:          0 :                     SbxArray* pArg = pVar->GetParameters();
    1900 [ #  # ][ #  # ]:          0 :                     sal_uInt16 nVarParCount = (pArg != NULL) ? pArg->Count() : 0;
    1901         [ #  # ]:          0 :                     if( nVarParCount > 1 )
    1902                 :            :                     {
    1903 [ #  # ][ #  # ]:          0 :                         SbxArrayRef xMethParameters = new SbxArray;
    1904         [ #  # ]:          0 :                         xMethParameters->Put( pMeth, 0 );   // Method as parameter 0
    1905         [ #  # ]:          0 :                         for( sal_uInt16 i = 1 ; i < nVarParCount ; ++i )
    1906                 :            :                         {
    1907         [ #  # ]:          0 :                             SbxVariable* pPar = pArg->Get( i );
    1908         [ #  # ]:          0 :                             xMethParameters->Put( pPar, i );
    1909                 :            :                         }
    1910                 :            : 
    1911         [ #  # ]:          0 :                         pMeth->SetParameters( xMethParameters );
    1912         [ #  # ]:          0 :                         pMeth->Get( aVals );
    1913 [ #  # ][ #  # ]:          0 :                         pMeth->SetParameters( NULL );
    1914                 :            :                     }
    1915                 :            :                     else
    1916                 :            :                     {
    1917         [ #  # ]:          0 :                         pMeth->Get( aVals );
    1918                 :            :                     }
    1919                 :            : 
    1920         [ #  # ]:          0 :                     pVar->Put( aVals );
    1921         [ #  # ]:          0 :                 }
    1922                 :            :             }
    1923         [ #  # ]:          0 :             else if( pHint->GetId() == SBX_HINT_DATACHANGED )
    1924                 :            :             {
    1925                 :          0 :                 SbxVariable* pMeth = NULL;
    1926                 :            : 
    1927                 :          0 :                 bool bSet = pProcProperty->isSet();
    1928         [ #  # ]:          0 :                 if( bSet )
    1929                 :            :                 {
    1930                 :          0 :                     pProcProperty->setSet( false );
    1931                 :            : 
    1932         [ #  # ]:          0 :                     String aProcName;
    1933         [ #  # ]:          0 :                     aProcName.AppendAscii( "Property Set " );
    1934 [ #  # ][ #  # ]:          0 :                     aProcName += pProcProperty->GetName();
    1935 [ #  # ][ #  # ]:          0 :                     pMeth = Find( aProcName, SbxCLASS_METHOD );
                 [ #  # ]
    1936                 :            :                 }
    1937         [ #  # ]:          0 :                 if( !pMeth )    // Let
    1938                 :            :                 {
    1939         [ #  # ]:          0 :                     String aProcName;
    1940         [ #  # ]:          0 :                     aProcName.AppendAscii( "Property Let " );
    1941 [ #  # ][ #  # ]:          0 :                     aProcName += pProcProperty->GetName();
    1942 [ #  # ][ #  # ]:          0 :                     pMeth = Find( aProcName, SbxCLASS_METHOD );
                 [ #  # ]
    1943                 :            :                 }
    1944                 :            : 
    1945         [ #  # ]:          0 :                 if( pMeth )
    1946                 :            :                 {
    1947                 :            :                     // Setup parameters
    1948 [ #  # ][ #  # ]:          0 :                     SbxArrayRef xArray = new SbxArray;
    1949         [ #  # ]:          0 :                     xArray->Put( pMeth, 0 );    // Method as parameter 0
    1950         [ #  # ]:          0 :                     xArray->Put( pVar, 1 );
    1951         [ #  # ]:          0 :                     pMeth->SetParameters( xArray );
    1952                 :            : 
    1953                 :          0 :                     SbxValues aVals;
    1954         [ #  # ]:          0 :                     pMeth->Get( aVals );
    1955 [ #  # ][ #  # ]:          0 :                     pMeth->SetParameters( NULL );
    1956                 :            :                 }
    1957                 :            :             }
    1958                 :            :         }
    1959                 :            :     }
    1960                 :            : 
    1961         [ #  # ]:          0 :     if( !bDone )
    1962                 :          0 :         SbModule::Notify( rBC, rHint );
    1963                 :          0 : }
    1964                 :            : 
    1965                 :            : 
    1966                 :            : // Implementation SbJScriptModule (Basic module for JavaScript source code)
    1967                 :          0 : SbJScriptModule::SbJScriptModule( const String& rName )
    1968 [ #  # ][ #  # ]:          0 :     :SbModule( rName )
    1969                 :            : {
    1970                 :          0 : }
    1971                 :            : 
    1972                 :          0 : sal_Bool SbJScriptModule::LoadData( SvStream& rStrm, sal_uInt16 nVer )
    1973                 :            : {
    1974                 :            :     (void)nVer;
    1975                 :            : 
    1976                 :          0 :     Clear();
    1977         [ #  # ]:          0 :     if( !SbxObject::LoadData( rStrm, 1 ) )
    1978                 :          0 :         return sal_False;
    1979                 :            : 
    1980                 :            :     // Get the source string
    1981                 :          0 :     aOUSource = rStrm.ReadUniOrByteString( osl_getThreadTextEncoding() );
    1982                 :          0 :     return sal_True;
    1983                 :            : }
    1984                 :            : 
    1985                 :          0 : sal_Bool SbJScriptModule::StoreData( SvStream& rStrm ) const
    1986                 :            : {
    1987 [ #  # ][ #  # ]:          0 :     if( !SbxObject::StoreData( rStrm ) )
    1988                 :          0 :         return sal_False;
    1989                 :            : 
    1990                 :            :     // Write the source string
    1991         [ #  # ]:          0 :     String aTmp = aOUSource;
    1992 [ #  # ][ #  # ]:          0 :     rStrm.WriteUniOrByteString( aTmp, osl_getThreadTextEncoding() );
                 [ #  # ]
    1993         [ #  # ]:          0 :     return sal_True;
    1994                 :            : }
    1995                 :            : 
    1996                 :            : 
    1997                 :            : /////////////////////////////////////////////////////////////////////////
    1998                 :            : 
    1999                 :        276 : SbMethod::SbMethod( const String& r, SbxDataType t, SbModule* p )
    2000 [ +  - ][ #  # ]:        276 :         : SbxMethod( r, t ), pMod( p )
    2001                 :            : {
    2002                 :        276 :     bInvalid     = sal_True;
    2003                 :            :     nStart       =
    2004                 :            :     nDebugFlags  =
    2005                 :            :     nLine1       =
    2006                 :        276 :     nLine2       = 0;
    2007         [ +  - ]:        276 :     refStatics = new SbxArray;
           [ +  -  #  # ]
         [ #  # ][ #  # ]
                 [ +  - ]
    2008                 :        276 :     mCaller          = 0;
    2009                 :            :     // HACK due to 'Referenz could not be saved'
    2010                 :        276 :     SetFlag( SBX_NO_MODIFY );
    2011                 :        276 : }
    2012                 :            : 
    2013                 :        913 : SbMethod::SbMethod( const SbMethod& r )
    2014 [ +  - ][ #  # ]:        913 :     : SvRefBase( r ), SbxMethod( r )
    2015                 :            : {
    2016                 :        913 :     pMod         = r.pMod;
    2017                 :        913 :     bInvalid     = r.bInvalid;
    2018                 :        913 :     nStart       = r.nStart;
    2019                 :        913 :     nDebugFlags  = r.nDebugFlags;
    2020                 :        913 :     nLine1       = r.nLine1;
    2021                 :        913 :     nLine2       = r.nLine2;
    2022   [ +  -  #  # ]:        913 :         refStatics = r.refStatics;
    2023                 :        913 :     mCaller          = r.mCaller;
    2024                 :        913 :     SetFlag( SBX_NO_MODIFY );
    2025                 :        913 : }
    2026                 :            : 
    2027 [ +  - ][ +  - ]:       2346 : SbMethod::~SbMethod()
         [ #  # ][ #  # ]
    2028                 :            : {
    2029 [ +  - ][ -  + ]:       3519 : }
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    2030                 :            : 
    2031                 :        197 : void SbMethod::ClearStatics()
    2032                 :            : {
    2033         [ +  - ]:        197 :     refStatics = new SbxArray;
    2034                 :            : 
    2035                 :        197 : }
    2036                 :          0 : SbxArray* SbMethod::GetStatics()
    2037                 :            : {
    2038                 :          0 :     return refStatics;
    2039                 :            : }
    2040                 :            : 
    2041                 :          0 : sal_Bool SbMethod::LoadData( SvStream& rStrm, sal_uInt16 nVer )
    2042                 :            : {
    2043 [ #  # ][ #  # ]:          0 :     if( !SbxMethod::LoadData( rStrm, 1 ) )
    2044                 :          0 :         return sal_False;
    2045                 :            :     sal_Int16 n;
    2046         [ #  # ]:          0 :     rStrm >> n;
    2047                 :          0 :     sal_Int16 nTempStart = (sal_Int16)nStart;
    2048         [ #  # ]:          0 :     if( nVer == 2 )
    2049 [ #  # ][ #  # ]:          0 :         rStrm >> nLine1 >> nLine2 >> nTempStart >> bInvalid;
         [ #  # ][ #  # ]
    2050                 :            :     // HACK ue to 'Referenz could not be saved'
    2051                 :          0 :     SetFlag( SBX_NO_MODIFY );
    2052                 :          0 :     nStart = nTempStart;
    2053                 :          0 :     return sal_True;
    2054                 :            : }
    2055                 :            : 
    2056                 :          0 : sal_Bool SbMethod::StoreData( SvStream& rStrm ) const
    2057                 :            : {
    2058         [ #  # ]:          0 :     if( !SbxMethod::StoreData( rStrm ) )
    2059                 :          0 :         return sal_False;
    2060                 :          0 :     rStrm << (sal_Int16) nDebugFlags
    2061                 :          0 :           << (sal_Int16) nLine1
    2062                 :          0 :           << (sal_Int16) nLine2
    2063                 :          0 :           << (sal_Int16) nStart
    2064                 :          0 :           << (sal_uInt8)  bInvalid;
    2065                 :          0 :     return sal_True;
    2066                 :            : }
    2067                 :            : 
    2068                 :          0 : void SbMethod::GetLineRange( sal_uInt16& l1, sal_uInt16& l2 )
    2069                 :            : {
    2070                 :          0 :     l1 = nLine1; l2 = nLine2;
    2071                 :          0 : }
    2072                 :            : 
    2073                 :            : // Could later be deleted
    2074                 :            : 
    2075                 :       1130 : SbxInfo* SbMethod::GetInfo()
    2076                 :            : {
    2077                 :       1130 :     return pInfo;
    2078                 :            : }
    2079                 :            : 
    2080                 :            : // Interface to execute a method of the applications
    2081                 :            : // With special RefCounting, so that the Basic was not fired of by CloseDocument()
    2082                 :            : // The return value will be delivered as string.
    2083                 :         16 : ErrCode SbMethod::Call( SbxValue* pRet, SbxVariable* pCaller )
    2084                 :            : {
    2085         [ +  + ]:         16 :     if ( pCaller )
    2086                 :            :     {
    2087                 :            :         OSL_TRACE("SbMethod::Call Have been passed a caller 0x%x", pCaller );
    2088                 :          2 :         mCaller = pCaller;
    2089                 :            :     }
    2090                 :            :     // RefCount vom Modul hochzaehlen
    2091         [ +  - ]:         16 :     SbModule* pMod_ = (SbModule*)GetParent();
    2092                 :         16 :     pMod_->AddRef();
    2093                 :            : 
    2094                 :            :     // Increment the RefCount of the Basic
    2095         [ +  - ]:         16 :     StarBASIC* pBasic = (StarBASIC*)pMod_->GetParent();
    2096                 :         16 :     pBasic->AddRef();
    2097                 :            : 
    2098                 :            :     // Establish the values to get the return value
    2099                 :         16 :     SbxValues aVals;
    2100                 :         16 :     aVals.eType = SbxVARIANT;
    2101                 :            : 
    2102                 :            :     // #104083: Compile BEFORE get
    2103 [ #  # ][ #  # ]:         16 :     if( bInvalid && !pMod_->Compile() )
         [ -  + ][ -  + ]
    2104         [ #  # ]:          0 :         StarBASIC::Error( SbERR_BAD_PROP_VALUE );
    2105                 :            : 
    2106         [ +  - ]:         16 :     Get( aVals );
    2107         [ +  - ]:         16 :     if ( pRet )
    2108         [ +  - ]:         16 :         pRet->Put( aVals );
    2109                 :            : 
    2110                 :            :     // Was there an error
    2111         [ +  - ]:         16 :     ErrCode nErr = SbxBase::GetError();
    2112         [ +  - ]:         16 :     SbxBase::ResetError();
    2113                 :            : 
    2114                 :            :     // Release objects
    2115         [ +  - ]:         16 :     pMod_->ReleaseRef();
    2116         [ +  - ]:         16 :     pBasic->ReleaseRef();
    2117                 :         16 :     mCaller = 0;
    2118                 :         16 :     return nErr;
    2119                 :            : }
    2120                 :            : 
    2121                 :            : 
    2122                 :            : // #100883 Own Broadcast for SbMethod
    2123                 :       3580 : void SbMethod::Broadcast( sal_uIntPtr nHintId )
    2124                 :            : {
    2125 [ +  + ][ +  + ]:       3580 :     if( pCst && !IsSet( SBX_NO_BROADCAST ) )
                 [ +  + ]
    2126                 :            :     {
    2127                 :            :         // Because the method could be called from outside, test here once again
    2128                 :            :         // the authorisation
    2129         [ +  - ]:        913 :         if( nHintId & SBX_HINT_DATAWANTED )
    2130         [ +  - ]:        913 :             if( !CanRead() )
    2131                 :            :                 return;
    2132         [ -  + ]:        913 :         if( nHintId & SBX_HINT_DATACHANGED )
    2133         [ #  # ]:          0 :             if( !CanWrite() )
    2134                 :            :                 return;
    2135                 :            : 
    2136 [ +  - ][ +  - ]:        913 :         if( pMod && !pMod->IsCompiled() )
         [ -  + ][ -  + ]
    2137         [ #  # ]:          0 :             pMod->Compile();
    2138                 :            : 
    2139                 :            :         // Block broadcasts while creating new method
    2140                 :        913 :         SfxBroadcaster* pSave = pCst;
    2141                 :        913 :         pCst = NULL;
    2142 [ +  - ][ +  - ]:        913 :         SbMethod* pThisCopy = new SbMethod( *this );
    2143                 :        913 :         SbMethodRef xHolder = pThisCopy;
    2144         [ +  + ]:        913 :         if( mpPar.Is() )
    2145                 :            :         {
    2146                 :            :             // Enrigister this as element 0, but don't reset the parent!
    2147 [ +  - ][ +  + ]:        808 :             if( GetType() != SbxVOID )
    2148         [ +  - ]:        524 :                 mpPar->PutDirect( pThisCopy, 0 );
    2149         [ +  - ]:        808 :                SetParameters( NULL );
    2150                 :            :         }
    2151                 :            : 
    2152                 :        913 :         pCst = pSave;
    2153 [ +  - ][ +  - ]:        913 :         pSave->Broadcast( SbxHint( nHintId, pThisCopy ) );
                 [ +  - ]
    2154                 :            : 
    2155                 :        913 :         sal_uInt16 nSaveFlags = GetFlags();
    2156                 :        913 :         SetFlag( SBX_READWRITE );
    2157                 :        913 :         pCst = NULL;
    2158         [ +  - ]:        913 :         Put( pThisCopy->GetValues_Impl() );
    2159                 :        913 :         pCst = pSave;
    2160         [ +  - ]:       3580 :         SetFlags( nSaveFlags );
    2161                 :            :     }
    2162                 :            : }
    2163                 :            : 
    2164                 :            : 
    2165                 :            : // Implementation of SbJScriptMethod (method class as a wrapper for JavaScript-functions)
    2166                 :            : 
    2167                 :          0 : SbJScriptMethod::SbJScriptMethod( const String& r, SbxDataType t, SbModule* p )
    2168 [ #  # ][ #  # ]:          0 :         : SbMethod( r, t, p )
    2169                 :            : {
    2170                 :          0 : }
    2171                 :            : 
    2172 [ #  # ][ #  # ]:          0 : SbJScriptMethod::~SbJScriptMethod()
    2173 [ #  # ][ #  # ]:          0 : {}
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    2174                 :            : 
    2175                 :            : 
    2176                 :         55 : SbObjModule::SbObjModule( const String& rName, const com::sun::star::script::ModuleInfo& mInfo, bool bIsVbaCompatible )
    2177 [ +  - ][ #  # ]:         55 :     : SbModule( rName, bIsVbaCompatible )
    2178                 :            : {
    2179                 :         55 :     SetModuleType( mInfo.ModuleType );
    2180   [ -  +  #  # ]:         55 :     if ( mInfo.ModuleType == script::ModuleType::FORM )
    2181                 :            :     {
    2182 [ #  # ][ #  # ]:          0 :         SetClassName( rtl::OUString("Form" ) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    2183                 :            :     }
    2184 [ +  + ][ #  # ]:         55 :     else if ( mInfo.ModuleObject.is() )
    2185 [ +  - ][ +  - ]:         16 :         SetUnoObject( uno::makeAny( mInfo.ModuleObject ) );
         [ #  # ][ #  # ]
    2186                 :         55 : }
    2187                 :            : 
    2188 [ +  - ][ #  # ]:        110 : SbObjModule::~SbObjModule()
    2189                 :            : {
    2190 [ +  - ][ -  + ]:        165 : }
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    2191                 :            : 
    2192                 :            : void
    2193                 :         16 : SbObjModule::SetUnoObject( const uno::Any& aObj ) throw ( uno::RuntimeException )
    2194                 :            : {
    2195 [ -  + ][ #  # ]:         16 :     SbUnoObject* pUnoObj = PTR_CAST(SbUnoObject,(SbxVariable*)pDocObject);
         [ #  # ][ #  # ]
    2196 [ -  + ][ #  # ]:         16 :     if ( pUnoObj && pUnoObj->getUnoAny() == aObj ) // object is equal, nothing to do
         [ #  # ][ -  + ]
           [ +  -  #  # ]
    2197                 :         16 :         return;
    2198 [ +  - ][ +  - ]:         16 :     pDocObject = new SbUnoObject( GetName(), uno::makeAny( aObj ) );
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
    2199                 :            : 
    2200         [ +  - ]:         16 :     com::sun::star::uno::Reference< com::sun::star::lang::XServiceInfo > xServiceInfo( aObj, com::sun::star::uno::UNO_QUERY_THROW );
    2201 [ +  - ][ +  - ]:         16 :     if( xServiceInfo->supportsService( rtl::OUString("ooo.vba.excel.Worksheet" ) ) )
                 [ +  + ]
    2202                 :            :     {
    2203 [ +  - ][ +  - ]:         12 :         SetClassName( rtl::OUString("Worksheet" ) );
                 [ +  - ]
    2204                 :            :     }
    2205 [ +  - ][ +  - ]:          4 :     else if( xServiceInfo->supportsService( rtl::OUString("ooo.vba.excel.Workbook" ) ) )
                 [ +  - ]
    2206                 :            :     {
    2207 [ +  - ][ +  - ]:          4 :         SetClassName( rtl::OUString("Workbook" ) );
                 [ +  - ]
    2208                 :         16 :     }
    2209                 :            : }
    2210                 :            : 
    2211                 :            : SbxVariable*
    2212                 :         24 : SbObjModule::GetObject()
    2213                 :            : {
    2214                 :         24 :     return pDocObject;
    2215                 :            : }
    2216                 :            : SbxVariable*
    2217                 :          0 : SbObjModule::Find( const rtl::OUString& rName, SbxClassType t )
    2218                 :            : {
    2219                 :          0 :     SbxVariable* pVar = NULL;
    2220         [ #  # ]:          0 :     if ( pDocObject)
    2221                 :          0 :         pVar = pDocObject->Find( rName, t );
    2222         [ #  # ]:          0 :     if ( !pVar )
    2223                 :          0 :         pVar = SbModule::Find( rName, t );
    2224                 :          0 :     return pVar;
    2225                 :            : }
    2226                 :            : 
    2227                 :          0 : void SbObjModule::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType,
    2228                 :            :                          const SfxHint& rHint, const TypeId& rHintType )
    2229                 :            : {
    2230                 :          0 :     SbModule::handleProcedureProperties( rBC, rHint );
    2231                 :          0 : }
    2232                 :            : 
    2233                 :            : 
    2234                 :            : typedef ::cppu::WeakImplHelper3<
    2235                 :            :     awt::XTopWindowListener,
    2236                 :            :     awt::XWindowListener,
    2237                 :            :     document::XEventListener > FormObjEventListener_BASE;
    2238                 :            : 
    2239                 :            : class FormObjEventListenerImpl : public FormObjEventListener_BASE
    2240                 :            : {
    2241                 :            :     SbUserFormModule* mpUserForm;
    2242                 :            :     uno::Reference< lang::XComponent > mxComponent;
    2243                 :            :     uno::Reference< frame::XModel > mxModel;
    2244                 :            :     bool mbDisposed;
    2245                 :            :     sal_Bool mbOpened;
    2246                 :            :     sal_Bool mbActivated;
    2247                 :            :     sal_Bool mbShowing;
    2248                 :            : 
    2249                 :            :     FormObjEventListenerImpl(const FormObjEventListenerImpl&); // not defined
    2250                 :            :     FormObjEventListenerImpl& operator=(const FormObjEventListenerImpl&); // not defined
    2251                 :            : 
    2252                 :            : public:
    2253                 :          0 :     FormObjEventListenerImpl( SbUserFormModule* pUserForm, const uno::Reference< lang::XComponent >& xComponent, const uno::Reference< frame::XModel >& xModel ) :
    2254                 :            :         mpUserForm( pUserForm ), mxComponent( xComponent), mxModel( xModel ),
    2255                 :          0 :         mbDisposed( false ), mbOpened( sal_False ), mbActivated( sal_False ), mbShowing( sal_False )
    2256                 :            :     {
    2257         [ #  # ]:          0 :         if ( mxComponent.is() )
    2258                 :            :         {
    2259                 :            :             OSL_TRACE("*********** Registering the listeners");
    2260                 :            :             try
    2261                 :            :             {
    2262 [ #  # ][ #  # ]:          0 :                 uno::Reference< awt::XTopWindow >( mxComponent, uno::UNO_QUERY_THROW )->addTopWindowListener( this );
         [ #  # ][ #  # ]
                 [ #  # ]
    2263                 :            :             }
    2264         [ #  # ]:          0 :             catch(const uno::Exception& ) {}
    2265                 :            :             try
    2266                 :            :             {
    2267 [ #  # ][ #  # ]:          0 :                 uno::Reference< awt::XWindow >( mxComponent, uno::UNO_QUERY_THROW )->addWindowListener( this );
         [ #  # ][ #  # ]
                 [ #  # ]
    2268                 :            :             }
    2269         [ #  # ]:          0 :             catch(const uno::Exception& ) {}
    2270                 :            :         }
    2271                 :            : 
    2272         [ #  # ]:          0 :         if ( mxModel.is() )
    2273                 :            :         {
    2274                 :            :             try
    2275                 :            :             {
    2276 [ #  # ][ #  # ]:          0 :                 uno::Reference< document::XEventBroadcaster >( mxModel, uno::UNO_QUERY_THROW )->addEventListener( this );
         [ #  # ][ #  # ]
                 [ #  # ]
    2277                 :            :             }
    2278         [ #  # ]:          0 :             catch(const uno::Exception& ) {}
    2279                 :            :         }
    2280                 :          0 :     }
    2281                 :            : 
    2282                 :          0 :     virtual ~FormObjEventListenerImpl()
    2283                 :          0 :     {
    2284         [ #  # ]:          0 :         removeListener();
    2285         [ #  # ]:          0 :     }
    2286                 :            : 
    2287                 :          0 :     sal_Bool isShowing() const { return mbShowing; }
    2288                 :            : 
    2289                 :          0 :     void removeListener()
    2290                 :            :     {
    2291 [ #  # ][ #  # ]:          0 :         if ( mxComponent.is() && !mbDisposed )
                 [ #  # ]
    2292                 :            :         {
    2293                 :            :             OSL_TRACE("*********** Removing the listeners");
    2294                 :            :             try
    2295                 :            :             {
    2296 [ #  # ][ #  # ]:          0 :                 uno::Reference< awt::XTopWindow >( mxComponent, uno::UNO_QUERY_THROW )->removeTopWindowListener( this );
         [ #  # ][ #  # ]
                 [ #  # ]
    2297                 :            :             }
    2298                 :          0 :             catch(const uno::Exception& ) {}
    2299                 :            :             try
    2300                 :            :             {
    2301 [ #  # ][ #  # ]:          0 :                 uno::Reference< awt::XWindow >( mxComponent, uno::UNO_QUERY_THROW )->removeWindowListener( this );
         [ #  # ][ #  # ]
                 [ #  # ]
    2302                 :            :             }
    2303                 :          0 :             catch(const uno::Exception& ) {}
    2304                 :            :         }
    2305                 :          0 :         mxComponent.clear();
    2306                 :            : 
    2307 [ #  # ][ #  # ]:          0 :         if ( mxModel.is() && !mbDisposed )
                 [ #  # ]
    2308                 :            :         {
    2309                 :            :             try
    2310                 :            :             {
    2311 [ #  # ][ #  # ]:          0 :                 uno::Reference< document::XEventBroadcaster >( mxModel, uno::UNO_QUERY_THROW )->removeEventListener( this );
         [ #  # ][ #  # ]
                 [ #  # ]
    2312                 :            :             }
    2313                 :          0 :             catch(const uno::Exception& ) {}
    2314                 :            :         }
    2315                 :          0 :         mxModel.clear();
    2316                 :          0 :     }
    2317                 :            : 
    2318                 :          0 :     virtual void SAL_CALL windowOpened( const lang::EventObject& /*e*/ ) throw (uno::RuntimeException)
    2319                 :            :     {
    2320         [ #  # ]:          0 :         if ( mpUserForm )
    2321                 :            :         {
    2322                 :          0 :             mbOpened = sal_True;
    2323                 :          0 :             mbShowing = sal_True;
    2324         [ #  # ]:          0 :             if ( mbActivated )
    2325                 :            :             {
    2326                 :          0 :                 mbOpened = mbActivated = sal_False;
    2327                 :          0 :                 mpUserForm->triggerActivateEvent();
    2328                 :            :             }
    2329                 :            :         }
    2330                 :          0 :     }
    2331                 :            : 
    2332                 :            : 
    2333                 :          0 :     virtual void SAL_CALL windowClosing( const lang::EventObject& e ) throw (uno::RuntimeException)
    2334                 :            :     {
    2335         [ #  # ]:          0 :         uno::Reference< awt::XDialog > xDialog( e.Source, uno::UNO_QUERY );
    2336         [ #  # ]:          0 :         if ( xDialog.is() )
    2337                 :            :         {
    2338         [ #  # ]:          0 :             uno::Reference< awt::XControl > xControl( xDialog, uno::UNO_QUERY );
    2339 [ #  # ][ #  # ]:          0 :             if ( xControl->getPeer().is() )
                 [ #  # ]
    2340                 :            :             {
    2341 [ #  # ][ #  # ]:          0 :                 uno::Reference< document::XVbaMethodParameter > xVbaMethodParameter( xControl->getPeer(), uno::UNO_QUERY );
                 [ #  # ]
    2342         [ #  # ]:          0 :                 if ( xVbaMethodParameter.is() )
    2343                 :            :                 {
    2344                 :          0 :                     sal_Int8 nCancel = 0;
    2345                 :          0 :                     sal_Int8 nCloseMode = ::ooo::vba::VbQueryClose::vbFormControlMenu;
    2346                 :            : 
    2347         [ #  # ]:          0 :                     Sequence< Any > aParams;
    2348         [ #  # ]:          0 :                     aParams.realloc(2);
    2349 [ #  # ][ #  # ]:          0 :                     aParams[0] <<= nCancel;
    2350 [ #  # ][ #  # ]:          0 :                     aParams[1] <<= nCloseMode;
    2351                 :            : 
    2352                 :            :                     mpUserForm->triggerMethod( rtl::OUString("Userform_QueryClose" ),
    2353 [ #  # ][ #  # ]:          0 :                                                 aParams);
                 [ #  # ]
    2354 [ #  # ][ #  # ]:          0 :                     xVbaMethodParameter->setVbaMethodParameter( rtl::OUString( "Cancel"), aParams[0]);
                 [ #  # ]
    2355                 :            :                     // If we don't cancel then we want to make sure the dialog
    2356                 :            :                     // really is gone to make sure when we attempt to raise it again
    2357                 :            :                     // it will actually generate an initialise event
    2358         [ #  # ]:          0 :                     if  ( !nCancel )
    2359                 :            :                     {
    2360         [ #  # ]:          0 :                         removeListener(); // presumably we need to do this
    2361         [ #  # ]:          0 :                         mpUserForm->ResetApiObj();
    2362                 :            :                     }
    2363         [ #  # ]:          0 :                     return;
    2364                 :            : 
    2365         [ #  # ]:          0 :                 }
    2366         [ #  # ]:          0 :             }
    2367                 :            :         }
    2368                 :            : 
    2369 [ #  # ][ #  # ]:          0 :         mpUserForm->triggerMethod( rtl::OUString("Userform_QueryClose" ) );
         [ #  # ][ #  # ]
    2370                 :            :     }
    2371                 :            : 
    2372                 :            : 
    2373                 :          0 :     virtual void SAL_CALL windowClosed( const lang::EventObject& /*e*/ ) throw (uno::RuntimeException)
    2374                 :            :     {
    2375                 :          0 :         mbOpened = sal_False;
    2376                 :          0 :         mbShowing = sal_False;
    2377                 :          0 :     }
    2378                 :            : 
    2379                 :          0 :     virtual void SAL_CALL windowMinimized( const lang::EventObject& /*e*/ ) throw (uno::RuntimeException)
    2380                 :            :     {
    2381                 :          0 :     }
    2382                 :            : 
    2383                 :          0 :     virtual void SAL_CALL windowNormalized( const lang::EventObject& /*e*/ ) throw (uno::RuntimeException)
    2384                 :            :     {
    2385                 :          0 :     }
    2386                 :            : 
    2387                 :          0 :     virtual void SAL_CALL windowActivated( const lang::EventObject& /*e*/ ) throw (uno::RuntimeException)
    2388                 :            :     {
    2389         [ #  # ]:          0 :         if ( mpUserForm )
    2390                 :            :         {
    2391                 :          0 :             mbActivated = sal_True;
    2392         [ #  # ]:          0 :             if ( mbOpened )
    2393                 :            :             {
    2394                 :          0 :                 mbOpened = mbActivated = sal_False;
    2395                 :          0 :                 mpUserForm->triggerActivateEvent();
    2396                 :            :             }
    2397                 :            :         }
    2398                 :          0 :     }
    2399                 :            : 
    2400                 :          0 :     virtual void SAL_CALL windowDeactivated( const lang::EventObject& /*e*/ ) throw (uno::RuntimeException)
    2401                 :            :     {
    2402         [ #  # ]:          0 :         if ( mpUserForm )
    2403                 :          0 :             mpUserForm->triggerDeactivateEvent();
    2404                 :          0 :     }
    2405                 :            : 
    2406                 :          0 :     virtual void SAL_CALL windowResized( const awt::WindowEvent& /*e*/ ) throw (uno::RuntimeException)
    2407                 :            :     {
    2408         [ #  # ]:          0 :         if ( mpUserForm )
    2409                 :            :         {
    2410                 :          0 :             mpUserForm->triggerResizeEvent();
    2411                 :          0 :             mpUserForm->triggerLayoutEvent();
    2412                 :            :         }
    2413                 :          0 :     }
    2414                 :            : 
    2415                 :          0 :     virtual void SAL_CALL windowMoved( const awt::WindowEvent& /*e*/ ) throw (uno::RuntimeException)
    2416                 :            :     {
    2417         [ #  # ]:          0 :         if ( mpUserForm )
    2418                 :          0 :             mpUserForm->triggerLayoutEvent();
    2419                 :          0 :     }
    2420                 :            : 
    2421                 :          0 :     virtual void SAL_CALL windowShown( const lang::EventObject& /*e*/ ) throw (uno::RuntimeException)
    2422                 :            :     {
    2423                 :          0 :     }
    2424                 :            : 
    2425                 :          0 :     virtual void SAL_CALL windowHidden( const lang::EventObject& /*e*/ ) throw (uno::RuntimeException)
    2426                 :            :     {
    2427                 :          0 :     }
    2428                 :            : 
    2429                 :          0 :     virtual void SAL_CALL notifyEvent( const document::EventObject& rEvent ) throw (uno::RuntimeException)
    2430                 :            :     {
    2431                 :            :         // early dosposing on document event "OnUnload", to be sure Basic still exists when calling VBA "UserForm_Terminate"
    2432         [ #  # ]:          0 :         if( rEvent.EventName == GlobalEventConfig::GetEventName( STR_EVENT_CLOSEDOC ) )
    2433                 :            :         {
    2434                 :          0 :             removeListener();
    2435                 :          0 :             mbDisposed = true;
    2436         [ #  # ]:          0 :             if ( mpUserForm )
    2437                 :          0 :                 mpUserForm->ResetApiObj();   // will trigger "UserForm_Terminate"
    2438                 :            :         }
    2439                 :          0 :     }
    2440                 :            : 
    2441                 :          0 :     virtual void SAL_CALL disposing( const lang::EventObject& /*Source*/ ) throw (uno::RuntimeException)
    2442                 :            :     {
    2443                 :            :         OSL_TRACE("** Userform/Dialog disposing");
    2444                 :          0 :         removeListener();
    2445                 :          0 :         mbDisposed = true;
    2446         [ #  # ]:          0 :         if ( mpUserForm )
    2447                 :          0 :             mpUserForm->ResetApiObj( false );   // pass false (too late to trigger VBA events here)
    2448                 :          0 :     }
    2449                 :            : };
    2450                 :            : 
    2451                 :          0 : SbUserFormModule::SbUserFormModule( const String& rName, const com::sun::star::script::ModuleInfo& mInfo, bool bIsCompat )
    2452                 :            :     : SbObjModule( rName, mInfo, bIsCompat )
    2453                 :            :     , m_mInfo( mInfo )
    2454 [ #  # ][ #  # ]:          0 :     , mbInit( false )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    2455                 :            : {
    2456 [ #  # ][ #  # ]:          0 :     m_xModel.set( mInfo.ModuleObject, uno::UNO_QUERY_THROW );
    2457                 :          0 : }
    2458                 :            : 
    2459 [ #  # ][ #  # ]:          0 : SbUserFormModule::~SbUserFormModule()
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    2460                 :            : {
    2461 [ #  # ][ #  # ]:          0 : }
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    2462                 :            : 
    2463                 :          0 : void SbUserFormModule::ResetApiObj(  bool bTriggerTerminateEvent )
    2464                 :            : {
    2465                 :            :     OSL_TRACE(" SbUserFormModule::ResetApiObj( %s )", bTriggerTerminateEvent ? "true" : "false" );
    2466 [ #  # ][ #  # ]:          0 :     if ( bTriggerTerminateEvent && m_xDialog.is() ) // probably someone close the dialog window
                 [ #  # ]
    2467                 :            :     {
    2468                 :          0 :         triggerTerminateEvent();
    2469                 :            :     }
    2470                 :          0 :     pDocObject = NULL;
    2471                 :          0 :     m_xDialog = NULL;
    2472                 :          0 : }
    2473                 :            : 
    2474                 :          0 : void SbUserFormModule::triggerMethod( const String& aMethodToRun )
    2475                 :            : {
    2476         [ #  # ]:          0 :     Sequence< Any > aArguments;
    2477 [ #  # ][ #  # ]:          0 :     triggerMethod( aMethodToRun, aArguments );
    2478                 :          0 : }
    2479                 :            : 
    2480                 :          0 : void SbUserFormModule::triggerMethod( const String& aMethodToRun, Sequence< Any >& aArguments )
    2481                 :            : {
    2482                 :            :     OSL_TRACE("*** trigger %s ***", rtl::OUStringToOString( aMethodToRun, RTL_TEXTENCODING_UTF8 ).getStr() );
    2483                 :            :     // Search method
    2484         [ #  # ]:          0 :     SbxVariable* pMeth = SbObjModule::Find( aMethodToRun, SbxCLASS_METHOD );
    2485         [ #  # ]:          0 :     if( pMeth )
    2486                 :            :     {
    2487         [ #  # ]:          0 :         if ( aArguments.getLength() > 0 )   // Setup parameters
    2488                 :            :         {
    2489 [ #  # ][ #  # ]:          0 :             SbxArrayRef xArray = new SbxArray;
    2490         [ #  # ]:          0 :             xArray->Put( pMeth, 0 );    // Method as parameter 0
    2491                 :            : 
    2492         [ #  # ]:          0 :             for ( sal_Int32 i = 0; i < aArguments.getLength(); ++i )
    2493                 :            :             {
    2494 [ #  # ][ #  # ]:          0 :                 SbxVariableRef xSbxVar = new SbxVariable( SbxVARIANT );
    2495 [ #  # ][ #  # ]:          0 :                 unoToSbxValue( static_cast< SbxVariable* >( xSbxVar ), aArguments[i] );
    2496         [ #  # ]:          0 :                 xArray->Put( xSbxVar, static_cast< sal_uInt16 >( i ) + 1 );
    2497                 :            : 
    2498                 :            :                 // Enable passing by ref
    2499 [ #  # ][ #  # ]:          0 :                 if ( xSbxVar->GetType() != SbxVARIANT )
    2500                 :          0 :                     xSbxVar->SetFlag( SBX_FIXED );
    2501         [ #  # ]:          0 :             }
    2502         [ #  # ]:          0 :             pMeth->SetParameters( xArray );
    2503                 :            : 
    2504                 :          0 :             SbxValues aVals;
    2505         [ #  # ]:          0 :             pMeth->Get( aVals );
    2506                 :            : 
    2507         [ #  # ]:          0 :             for ( sal_Int32 i = 0; i < aArguments.getLength(); ++i )
    2508                 :            :             {
    2509 [ #  # ][ #  # ]:          0 :                 aArguments[i] = sbxToUnoValue( xArray->Get( static_cast< sal_uInt16 >(i) + 1) );
                 [ #  # ]
    2510                 :            :             }
    2511 [ #  # ][ #  # ]:          0 :             pMeth->SetParameters( NULL );
    2512                 :            :         }
    2513                 :            :         else
    2514                 :            :         {
    2515                 :          0 :             SbxValues aVals;
    2516         [ #  # ]:          0 :             pMeth->Get( aVals );
    2517                 :            :         }
    2518                 :            :     }
    2519                 :          0 : }
    2520                 :            : 
    2521                 :          0 : void SbUserFormModule::triggerActivateEvent( void )
    2522                 :            : {
    2523                 :            :     OSL_TRACE("**** entering SbUserFormModule::triggerActivate");
    2524 [ #  # ][ #  # ]:          0 :     triggerMethod( rtl::OUString( "UserForm_Activate" ) );
                 [ #  # ]
    2525                 :            :     OSL_TRACE("**** leaving SbUserFormModule::triggerActivate");
    2526                 :          0 : }
    2527                 :            : 
    2528                 :          0 : void SbUserFormModule::triggerDeactivateEvent( void )
    2529                 :            : {
    2530                 :            :     OSL_TRACE("**** SbUserFormModule::triggerDeactivate");
    2531 [ #  # ][ #  # ]:          0 :     triggerMethod( rtl::OUString("Userform_Deactivate" ) );
                 [ #  # ]
    2532                 :          0 : }
    2533                 :            : 
    2534                 :          0 : void SbUserFormModule::triggerInitializeEvent( void )
    2535                 :            : {
    2536         [ #  # ]:          0 :     if ( mbInit )
    2537                 :          0 :         return;
    2538                 :            :     OSL_TRACE("**** SbUserFormModule::triggerInitializeEvent");
    2539 [ #  # ][ #  # ]:          0 :     static String aInitMethodName( RTL_CONSTASCII_USTRINGPARAM("Userform_Initialize") );
         [ #  # ][ #  # ]
    2540                 :          0 :     triggerMethod( aInitMethodName );
    2541                 :          0 :     mbInit = true;
    2542                 :            : }
    2543                 :            : 
    2544                 :          0 : void SbUserFormModule::triggerTerminateEvent( void )
    2545                 :            : {
    2546                 :            :     OSL_TRACE("**** SbUserFormModule::triggerTerminateEvent");
    2547 [ #  # ][ #  # ]:          0 :     static String aTermMethodName( RTL_CONSTASCII_USTRINGPARAM("Userform_Terminate") );
         [ #  # ][ #  # ]
    2548                 :          0 :     triggerMethod( aTermMethodName );
    2549                 :          0 :     mbInit=false;
    2550                 :          0 : }
    2551                 :            : 
    2552                 :          0 : void SbUserFormModule::triggerLayoutEvent( void )
    2553                 :            : {
    2554 [ #  # ][ #  # ]:          0 :     static String aMethodName( RTL_CONSTASCII_USTRINGPARAM("Userform_Layout") );
         [ #  # ][ #  # ]
    2555                 :          0 :     triggerMethod( aMethodName );
    2556                 :          0 : }
    2557                 :            : 
    2558                 :          0 : void SbUserFormModule::triggerResizeEvent( void )
    2559                 :            : {
    2560 [ #  # ][ #  # ]:          0 :     static String aMethodName( RTL_CONSTASCII_USTRINGPARAM("Userform_Resize") );
         [ #  # ][ #  # ]
    2561                 :          0 :     triggerMethod( aMethodName );
    2562                 :          0 : }
    2563                 :            : 
    2564                 :          0 : SbUserFormModuleInstance* SbUserFormModule::CreateInstance()
    2565                 :            : {
    2566 [ #  # ][ #  # ]:          0 :     SbUserFormModuleInstance* pInstance = new SbUserFormModuleInstance( this, GetName(), m_mInfo, IsVBACompat() );
                 [ #  # ]
    2567                 :          0 :     return pInstance;
    2568                 :            : }
    2569                 :            : 
    2570                 :          0 : SbUserFormModuleInstance::SbUserFormModuleInstance( SbUserFormModule* pParentModule,
    2571                 :            :     const rtl::OUString& rName, const com::sun::star::script::ModuleInfo& mInfo, bool bIsVBACompat )
    2572                 :            :         : SbUserFormModule( rName, mInfo, bIsVBACompat )
    2573 [ #  # ][ #  # ]:          0 :         , m_pParentModule( pParentModule )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    2574                 :            : {
    2575                 :          0 : }
    2576                 :            : 
    2577                 :          0 : sal_Bool SbUserFormModuleInstance::IsClass( const rtl::OUString& rName ) const
    2578                 :            : {
    2579 [ #  # ][ #  # ]:          0 :     sal_Bool bParentNameMatches = m_pParentModule->GetName().EqualsIgnoreCaseAscii( rName );
    2580 [ #  # ][ #  # ]:          0 :     sal_Bool bRet = bParentNameMatches || SbxObject::IsClass( rName );
    2581                 :          0 :     return bRet;
    2582                 :            : }
    2583                 :            : 
    2584                 :          0 : SbxVariable* SbUserFormModuleInstance::Find( const rtl::OUString& rName, SbxClassType t )
    2585                 :            : {
    2586                 :          0 :     SbxVariable* pVar = m_pParentModule->Find( rName, t );
    2587                 :          0 :     return pVar;
    2588                 :            : }
    2589                 :            : 
    2590                 :            : 
    2591                 :          0 : void SbUserFormModule::Load()
    2592                 :            : {
    2593                 :            :     OSL_TRACE("** load() ");
    2594                 :            :     // forces a load
    2595         [ #  # ]:          0 :     if ( !pDocObject )
    2596                 :          0 :         InitObject();
    2597                 :          0 : }
    2598                 :            : 
    2599                 :            : 
    2600                 :          0 : void SbUserFormModule::Unload()
    2601                 :            : {
    2602                 :            :     OSL_TRACE("** Unload() ");
    2603                 :            : 
    2604                 :          0 :     sal_Int8 nCancel = 0;
    2605                 :          0 :     sal_Int8 nCloseMode = ::ooo::vba::VbQueryClose::vbFormCode;
    2606                 :            : 
    2607         [ #  # ]:          0 :     Sequence< Any > aParams;
    2608         [ #  # ]:          0 :     aParams.realloc(2);
    2609 [ #  # ][ #  # ]:          0 :     aParams[0] <<= nCancel;
    2610 [ #  # ][ #  # ]:          0 :     aParams[1] <<= nCloseMode;
    2611                 :            : 
    2612 [ #  # ][ #  # ]:          0 :     triggerMethod( rtl::OUString("Userform_QueryClose" ), aParams);
                 [ #  # ]
    2613                 :            : 
    2614         [ #  # ]:          0 :     aParams[0] >>= nCancel;
    2615                 :            :     // basic boolean ( and what the user might use ) can be ambiguous ( e.g. basic true = -1 )
    2616                 :            :     // test agains 0 ( false ) and assume anything else is true
    2617                 :            :     // ( Note: ) this used to work ( something changes somewhere )
    2618         [ #  # ]:          0 :     if (nCancel != 0)
    2619                 :            :     {
    2620                 :          0 :         return;
    2621                 :            :     }
    2622                 :            : 
    2623         [ #  # ]:          0 :     if ( m_xDialog.is() )
    2624                 :            :     {
    2625         [ #  # ]:          0 :         triggerTerminateEvent();
    2626                 :            :     }
    2627                 :            :     // Search method
    2628         [ #  # ]:          0 :     SbxVariable* pMeth = SbObjModule::Find( rtl::OUString("UnloadObject"), SbxCLASS_METHOD );
    2629         [ #  # ]:          0 :     if( pMeth )
    2630                 :            :     {
    2631                 :            :         OSL_TRACE("Attempting too run the UnloadObjectMethod");
    2632                 :          0 :         m_xDialog.clear(); //release ref to the uno object
    2633                 :          0 :         SbxValues aVals;
    2634                 :          0 :         bool bWaitForDispose = true; // assume dialog is showing
    2635         [ #  # ]:          0 :         if ( m_DialogListener.get() )
    2636                 :            :         {
    2637                 :          0 :             bWaitForDispose = m_DialogListener->isShowing();
    2638                 :            :             OSL_TRACE("Showing %d", bWaitForDispose );
    2639                 :            :         }
    2640         [ #  # ]:          0 :         pMeth->Get( aVals);
    2641         [ #  # ]:          0 :         if ( !bWaitForDispose )
    2642                 :            :         {
    2643                 :            :             // we've either already got a dispose or we'er never going to get one
    2644         [ #  # ]:          0 :             ResetApiObj();
    2645                 :            :         } // else wait for dispose
    2646                 :            :         OSL_TRACE("UnloadObject completed ( we hope )");
    2647 [ #  # ][ #  # ]:          0 :     }
    2648                 :            : }
    2649                 :            : 
    2650                 :            : 
    2651                 :            : void registerComponentToBeDisposedForBasic( Reference< XComponent > xComponent, StarBASIC* pBasic );
    2652                 :            : 
    2653                 :          0 : void SbUserFormModule::InitObject()
    2654                 :            : {
    2655                 :            :     try
    2656                 :            :     {
    2657         [ #  # ]:          0 :         String aHook( RTL_CONSTASCII_USTRINGPARAM( "VBAGlobals" ) );
    2658 [ #  # ][ #  # ]:          0 :         SbUnoObject* pGlobs = (SbUnoObject*)GetParent()->Find( aHook, SbxCLASS_DONTCARE );
                 [ #  # ]
    2659 [ #  # ][ #  # ]:          0 :         if ( m_xModel.is() && pGlobs )
                 [ #  # ]
    2660                 :            :         {
    2661                 :            :             // broadcast INITIALIZE_USERFORM script event before the dialog is created
    2662 [ #  # ][ #  # ]:          0 :             Reference< script::vba::XVBACompatibility > xVBACompat( getVBACompatibility( m_xModel ), uno::UNO_SET_THROW );
    2663 [ #  # ][ #  # ]:          0 :             xVBACompat->broadcastVBAScriptEvent( script::vba::VBAScriptEventId::INITIALIZE_USERFORM, GetName() );
         [ #  # ][ #  # ]
    2664                 :            : 
    2665 [ #  # ][ #  # ]:          0 :             uno::Reference< lang::XMultiServiceFactory > xVBAFactory( pGlobs->getUnoAny(), uno::UNO_QUERY_THROW );
    2666         [ #  # ]:          0 :             uno::Reference< lang::XMultiServiceFactory > xFactory = comphelper::getProcessServiceFactory();
    2667         [ #  # ]:          0 :             uno::Sequence< uno::Any > aArgs(1);
    2668 [ #  # ][ #  # ]:          0 :             aArgs[ 0 ] <<= m_xModel;
    2669                 :          0 :             rtl::OUString sDialogUrl( "vnd.sun.star.script:"  );
    2670                 :          0 :             rtl::OUString sProjectName( "Standard" );
    2671                 :            : 
    2672                 :            :             try
    2673                 :            :             {
    2674         [ #  # ]:          0 :                 Reference< beans::XPropertySet > xProps( m_xModel, UNO_QUERY_THROW );
    2675 [ #  # ][ #  # ]:          0 :                 uno::Reference< script::vba::XVBACompatibility > xVBAMode( xProps->getPropertyValue( rtl::OUString( "BasicLibraries" ) ), uno::UNO_QUERY_THROW );
                 [ #  # ]
    2676 [ #  # ][ #  # ]:          0 :                 sProjectName = xVBAMode->getProjectName();
                 [ #  # ]
    2677                 :            :             }
    2678         [ #  # ]:          0 :             catch(const Exception& ) {}
    2679                 :            : 
    2680 [ #  # ][ #  # ]:          0 :             sDialogUrl = sDialogUrl.concat( sProjectName ).concat( rtl::OUString( '.') ).concat( GetName() ).concat( rtl::OUString( "?location=document" ) );
    2681                 :            : 
    2682 [ #  # ][ #  # ]:          0 :             uno::Reference< awt::XDialogProvider > xProvider( xFactory->createInstanceWithArguments( rtl::OUString( "com.sun.star.awt.DialogProvider"), aArgs  ), uno::UNO_QUERY_THROW );
                 [ #  # ]
    2683 [ #  # ][ #  # ]:          0 :             m_xDialog = xProvider->createDialog( sDialogUrl );
                 [ #  # ]
    2684                 :            : 
    2685                 :            :             // create vba api object
    2686         [ #  # ]:          0 :             aArgs.realloc( 4 );
    2687         [ #  # ]:          0 :             aArgs[ 0 ] = uno::Any();
    2688 [ #  # ][ #  # ]:          0 :             aArgs[ 1 ] <<= m_xDialog;
    2689 [ #  # ][ #  # ]:          0 :             aArgs[ 2 ] <<= m_xModel;
    2690 [ #  # ][ #  # ]:          0 :             aArgs[ 3 ] <<= sProjectName;
    2691 [ #  # ][ #  # ]:          0 :             pDocObject = new SbUnoObject( GetName(), uno::makeAny( xVBAFactory->createInstanceWithArguments( rtl::OUString( "ooo.vba.msforms.UserForm"), aArgs  ) ) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    2692                 :            : 
    2693         [ #  # ]:          0 :             uno::Reference< lang::XComponent > xComponent( m_xDialog, uno::UNO_QUERY_THROW );
    2694                 :            : 
    2695                 :            :             // the dialog must be disposed at the end!
    2696                 :          0 :             StarBASIC* pParentBasic = NULL;
    2697                 :          0 :             SbxObject* pCurObject = this;
    2698 [ #  # ][ #  # ]:          0 :             do
                 [ #  # ]
    2699                 :            :             {
    2700         [ #  # ]:          0 :                 SbxObject* pObjParent = pCurObject->GetParent();
    2701 [ #  # ][ #  # ]:          0 :                 pParentBasic = PTR_CAST( StarBASIC, pObjParent );
         [ #  # ][ #  # ]
    2702                 :          0 :                 pCurObject = pObjParent;
    2703                 :            :             }
    2704                 :            :             while( pParentBasic == NULL && pCurObject != NULL );
    2705                 :            : 
    2706                 :            :             OSL_ASSERT( pParentBasic != NULL );
    2707         [ #  # ]:          0 :             registerComponentToBeDisposedForBasic( xComponent, pParentBasic );
    2708                 :            : 
    2709                 :            :             // if old listener object exists, remove it from dialog and document model
    2710         [ #  # ]:          0 :             if( m_DialogListener.is() )
    2711         [ #  # ]:          0 :                 m_DialogListener->removeListener();
    2712         [ #  # ]:          0 :             m_DialogListener.set( new FormObjEventListenerImpl( this, xComponent, m_xModel ) );
    2713                 :            : 
    2714 [ #  # ][ #  # ]:          0 :             triggerInitializeEvent();
    2715 [ #  # ][ #  # ]:          0 :         }
    2716                 :            :     }
    2717                 :          0 :     catch(const uno::Exception& )
    2718                 :            :     {
    2719                 :            :     }
    2720                 :            : 
    2721                 :          0 : }
    2722                 :            : 
    2723                 :            : SbxVariable*
    2724                 :          0 : SbUserFormModule::Find( const rtl::OUString& rName, SbxClassType t )
    2725                 :            : {
    2726 [ #  # ][ #  # ]:          0 :     if ( !pDocObject && !GetSbData()->bRunInit && GetSbData()->pInst )
         [ #  # ][ #  # ]
    2727                 :          0 :         InitObject();
    2728                 :          0 :     return SbObjModule::Find( rName, t );
    2729                 :            : }
    2730                 :            : 
    2731                 :         10 : SbProperty::SbProperty( const String& r, SbxDataType t, SbModule* p )
    2732 [ +  - ][ #  # ]:         10 :         : SbxProperty( r, t ), pMod( p )
    2733                 :            : {
    2734                 :         10 :     bInvalid = sal_False;
    2735                 :         10 : }
    2736                 :            : 
    2737 [ +  - ][ #  # ]:         20 : SbProperty::~SbProperty()
    2738 [ +  - ][ -  + ]:         30 : {}
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    2739                 :            : 
    2740                 :            : 
    2741 [ #  # ][ #  # ]:          0 : SbProcedureProperty::~SbProcedureProperty()
    2742 [ #  # ][ #  # ]:          0 : {}
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    2743                 :            : 
    2744                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10