LCOV - code coverage report
Current view: top level - basic/source/sbx - sbxobj.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 212 489 43.4 %
Date: 2012-08-25 Functions: 43 61 70.5 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 224 1017 22.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*
       3                 :            :  * This file is part of the LibreOffice project.
       4                 :            :  *
       5                 :            :  * This Source Code Form is subject to the terms of the Mozilla Public
       6                 :            :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7                 :            :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8                 :            :  *
       9                 :            :  * This file incorporates work covered by the following license notice:
      10                 :            :  *
      11                 :            :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12                 :            :  *   contributor license agreements. See the NOTICE file distributed
      13                 :            :  *   with this work for additional information regarding copyright
      14                 :            :  *   ownership. The ASF licenses this file to you under the Apache
      15                 :            :  *   License, Version 2.0 (the "License"); you may not use this file
      16                 :            :  *   except in compliance with the License. You may obtain a copy of
      17                 :            :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18                 :            :  */
      19                 :            : 
      20                 :            : #include <tools/stream.hxx>
      21                 :            : #include <basic/sbx.hxx>
      22                 :            : #include "sbxres.hxx"
      23                 :            : #include <svl/brdcst.hxx>
      24                 :            : 
      25 [ +  + ][ +  + ]:      60021 : TYPEINIT1(SbxMethod,SbxVariable)
      26 [ +  + ][ +  + ]:      45257 : TYPEINIT1(SbxProperty,SbxVariable)
      27 [ +  + ][ -  + ]:      54668 : TYPEINIT2(SbxObject,SbxVariable,SfxListener)
                 [ -  + ]
      28                 :            : 
      29                 :            : static const char* pNameProp;               // Name-Property
      30                 :            : static const char* pParentProp;             // Parent-Property
      31                 :            : 
      32                 :            : static sal_uInt16 nNameHash = 0, nParentHash = 0;
      33                 :            : 
      34                 :            : 
      35                 :            : 
      36                 :       7827 : SbxObject::SbxObject( const XubString& rClass )
      37 [ +  - ][ +  - ]:       7827 :          : SbxVariable( SbxOBJECT ), aClassName( rClass )
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
      38                 :            : {
      39                 :       7827 :     aData.pObj = this;
      40 [ -  + ][ +  + ]:       7827 :     if( !nNameHash )
      41                 :            :     {
      42 [ #  # ][ +  - ]:        128 :         pNameProp = GetSbxRes( STRING_NAMEPROP );
      43 [ #  # ][ +  - ]:        128 :         pParentProp = GetSbxRes( STRING_PARENTPROP );
      44 [ #  # ][ #  # ]:        128 :         nNameHash = MakeHashCode( rtl::OUString::createFromAscii( pNameProp ) );
         [ #  # ][ +  - ]
         [ +  - ][ +  - ]
      45 [ #  # ][ #  # ]:        128 :         nParentHash = MakeHashCode( rtl::OUString::createFromAscii( pParentProp ) );
         [ +  - ][ +  - ]
         [ +  - ][ #  # ]
      46                 :            :     }
      47 [ +  - ][ +  - ]:       7827 :     SbxObject::Clear();
      48 [ +  - ][ +  - ]:       7827 :     SbxObject::SetName( rClass );
      49                 :       7827 : }
      50                 :            : 
      51                 :          0 : SbxObject::SbxObject( const SbxObject& rObj )
      52                 :          0 :     : SvRefBase( rObj ), SbxVariable( rObj.GetType() ),
      53 [ #  # ][ #  # ]:          0 :       SfxListener( rObj )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
      54                 :            : {
      55 [ #  # ][ #  # ]:          0 :     *this = rObj;
      56                 :          0 : }
      57                 :            : 
      58                 :          0 : SbxObject& SbxObject::operator=( const SbxObject& r )
      59                 :            : {
      60         [ #  # ]:          0 :     if( &r != this )
      61                 :            :     {
      62                 :          0 :         SbxVariable::operator=( r );
      63                 :          0 :         aClassName = r.aClassName;
      64         [ #  # ]:          0 :         pMethods   = new SbxArray;
      65         [ #  # ]:          0 :         pProps     = new SbxArray;
      66         [ #  # ]:          0 :         pObjs      = new SbxArray( SbxOBJECT );
      67                 :            :         // The arrays were copied, the content taken over
      68                 :          0 :         *pMethods  = *r.pMethods;
      69                 :          0 :         *pProps    = *r.pProps;
      70                 :          0 :         *pObjs     = *r.pObjs;
      71                 :            :         // Because the variables were taken over, this is OK
      72                 :          0 :         pDfltProp  = r.pDfltProp;
      73                 :          0 :         SetName( r.GetName() );
      74                 :          0 :         SetFlags( r.GetFlags() );
      75                 :          0 :         SetModified( sal_True );
      76                 :            :     }
      77                 :          0 :     return *this;
      78                 :            : }
      79                 :            : 
      80                 :      22056 : static void CheckParentsOnDelete( SbxObject* pObj, SbxArray* p )
      81                 :            : {
      82         [ +  + ]:      33851 :     for( sal_uInt16 i = 0; i < p->Count(); i++ )
      83                 :            :     {
      84                 :      11795 :         SbxVariableRef& rRef = p->GetRef( i );
      85         [ +  - ]:      11795 :         if( rRef->IsBroadcaster() )
      86                 :      11795 :             pObj->EndListening( rRef->GetBroadcaster(), sal_True );
      87                 :            :         // Did the element have more then one reference and still a Listener?
      88         [ +  + ]:      11795 :         if( rRef->GetRefCount() > 1 )
      89                 :            :         {
      90                 :        583 :             rRef->SetParent( NULL );
      91                 :            :             DBG_ASSERT( !rRef->IsBroadcaster() || rRef->GetBroadcaster().GetListenerCount(), "Object element with dangling parent" );
      92                 :            :         }
      93                 :            :     }
      94                 :      22056 : }
      95                 :            : 
      96 [ +  - ][ +  - ]:       7563 : SbxObject::~SbxObject()
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
      97                 :            : {
      98 [ +  - ][ +  - ]:       7352 :     CheckParentsOnDelete( this, pProps );
      99 [ +  - ][ +  - ]:       7352 :     CheckParentsOnDelete( this, pMethods );
     100 [ +  - ][ +  - ]:       7352 :     CheckParentsOnDelete( this, pObjs );
     101                 :            : 
     102                 :            :     // avoid handling in ~SbxVariable as SBX_DIM_AS_NEW == SBX_GBLSEARCH
     103                 :       7352 :     ResetFlag( SBX_DIM_AS_NEW );
     104 [ +  - ][ -  + ]:       7774 : }
         [ #  # ][ -  + ]
         [ -  + ][ #  # ]
     105                 :            : 
     106                 :       6133 : SbxDataType SbxObject::GetType() const
     107                 :            : {
     108                 :       6133 :     return SbxOBJECT;
     109                 :            : }
     110                 :            : 
     111                 :      55757 : SbxClassType SbxObject::GetClass() const
     112                 :            : {
     113                 :      55757 :     return SbxCLASS_OBJECT;
     114                 :            : }
     115                 :            : 
     116                 :       7827 : void SbxObject::Clear()
     117                 :            : {
     118         [ +  - ]:       7827 :     pMethods   = new SbxArray;
     119         [ +  - ]:       7827 :     pProps     = new SbxArray;
     120         [ +  - ]:       7827 :     pObjs      = new SbxArray( SbxOBJECT );
     121                 :            :     SbxVariable* p;
     122 [ +  - ][ +  - ]:       7827 :     p = Make( rtl::OUString::createFromAscii( pNameProp ), SbxCLASS_PROPERTY, SbxSTRING );
                 [ +  - ]
     123                 :       7827 :     p->SetFlag( SBX_DONTSTORE );
     124 [ +  - ][ +  - ]:       7827 :     p = Make( rtl::OUString::createFromAscii( pParentProp ), SbxCLASS_PROPERTY, SbxOBJECT );
                 [ +  - ]
     125                 :       7827 :     p->ResetFlag( SBX_WRITE );
     126                 :       7827 :     p->SetFlag( SBX_DONTSTORE );
     127                 :       7827 :     pDfltProp  = NULL;
     128                 :       7827 :     SetModified( sal_False );
     129                 :       7827 : }
     130                 :            : 
     131                 :      19793 : void SbxObject::SFX_NOTIFY( SfxBroadcaster&, const TypeId&,
     132                 :            :                             const SfxHint& rHint, const TypeId& )
     133                 :            : {
     134 [ +  - ][ +  - ]:      19793 :     const SbxHint* p = PTR_CAST(SbxHint,&rHint);
     135         [ +  - ]:      19793 :     if( p )
     136                 :            :     {
     137                 :      19793 :         sal_uIntPtr nId = p->GetId();
     138                 :      19793 :         bool bRead  = ( nId == SBX_HINT_DATAWANTED );
     139                 :      19793 :         bool bWrite = ( nId == SBX_HINT_DATACHANGED );
     140                 :      19793 :         SbxVariable* pVar = p->GetVar();
     141 [ +  + ][ +  + ]:      19793 :         if( bRead || bWrite )
     142                 :            :         {
     143 [ +  - ][ +  - ]:      19631 :             XubString aVarName( pVar->GetName() );
     144         [ +  - ]:      19631 :             sal_uInt16 nHash_ = MakeHashCode( aVarName );
     145 [ -  + ][ #  # ]:      19631 :             if( nHash_ == nNameHash
                 [ -  + ]
     146         [ #  # ]:          0 :              && aVarName.EqualsIgnoreCaseAscii( pNameProp ) )
     147                 :            :             {
     148         [ #  # ]:          0 :                 if( bRead )
     149 [ #  # ][ #  # ]:          0 :                     pVar->PutString( GetName() );
                 [ #  # ]
     150                 :            :                 else
     151 [ #  # ][ #  # ]:          0 :                     SetName( pVar->GetString() );
     152                 :            :             }
     153 [ -  + ][ #  # ]:      19631 :             else if( nHash_ == nParentHash
                 [ -  + ]
     154         [ #  # ]:          0 :              && aVarName.EqualsIgnoreCaseAscii( pParentProp ) )
     155                 :            :             {
     156         [ #  # ]:          0 :                 SbxObject* p_ = GetParent();
     157         [ #  # ]:          0 :                 if( !p_ )
     158                 :          0 :                     p_ = this;
     159         [ #  # ]:          0 :                 pVar->PutObject( p_ );
     160         [ +  - ]:      19631 :             }
     161                 :            :         }
     162                 :            :     }
     163                 :      19793 : }
     164                 :            : 
     165                 :          6 : sal_Bool SbxObject::IsClass( const rtl::OUString& rName ) const
     166                 :            : {
     167         [ +  - ]:          6 :     return sal_Bool( aClassName.EqualsIgnoreCaseAscii( rName ) );
     168                 :            : }
     169                 :            : 
     170                 :          0 : SbxVariable* SbxObject::FindUserData( sal_uInt32 nData )
     171                 :            : {
     172         [ #  # ]:          0 :     if( !GetAll( SbxCLASS_DONTCARE ) )
     173                 :          0 :         return NULL;
     174                 :            : 
     175                 :          0 :     SbxVariable* pRes = pMethods->FindUserData( nData );
     176         [ #  # ]:          0 :     if( !pRes )
     177                 :          0 :         pRes = pProps->FindUserData( nData );
     178         [ #  # ]:          0 :     if( !pRes )
     179                 :          0 :         pRes = pObjs->FindUserData( nData );
     180                 :            :     // Search in the parents?
     181 [ #  # ][ #  # ]:          0 :     if( !pRes && IsSet( SBX_GBLSEARCH ) )
                 [ #  # ]
     182                 :            :     {
     183                 :          0 :         SbxObject* pCur = this;
     184 [ #  # ][ #  # ]:          0 :         while( !pRes && pCur->pParent )
                 [ #  # ]
     185                 :            :         {
     186                 :            :             // I myself was already searched through!
     187                 :          0 :             sal_uInt16 nOwn = pCur->GetFlags();
     188                 :          0 :             pCur->ResetFlag( SBX_EXTSEARCH );
     189                 :            :             // I search already global!
     190                 :          0 :             sal_uInt16 nPar = pCur->pParent->GetFlags();
     191                 :          0 :             pCur->pParent->ResetFlag( SBX_GBLSEARCH );
     192                 :          0 :             pRes = pCur->pParent->FindUserData( nData );
     193                 :          0 :             pCur->SetFlags( nOwn );
     194                 :          0 :             pCur->pParent->SetFlags( nPar );
     195                 :          0 :             pCur = pCur->pParent;
     196                 :            :         }
     197                 :            :     }
     198                 :          0 :     return pRes;
     199                 :            : }
     200                 :            : 
     201                 :     143304 : SbxVariable* SbxObject::Find( const rtl::OUString& rName, SbxClassType t )
     202                 :            : {
     203                 :            : #ifdef DBG_UTIL
     204                 :            :     static sal_uInt16 nLvl = 0;
     205                 :            :     static const char* pCls[] =
     206                 :            :     { "DontCare","Array","Value","Variable","Method","Property","Object" };
     207                 :            :     rtl::OString aNameStr1(rtl::OUStringToOString(rName, RTL_TEXTENCODING_ASCII_US));
     208                 :            :     rtl::OString aNameStr2(rtl::OUStringToOString(SbxVariable::GetName(), RTL_TEXTENCODING_ASCII_US));
     209                 :            :     DbgOutf( "SBX: Search %.*s %s %s in %s",
     210                 :            :         nLvl++, "                              ",
     211                 :            :         ( t >= SbxCLASS_DONTCARE && t <= SbxCLASS_OBJECT )
     212                 :            :          ? pCls[ t-1 ] : "Unknown class", aNameStr1.getStr(), aNameStr1.getStr() );
     213                 :            : #endif
     214                 :            : 
     215         [ -  + ]:     143304 :     if( !GetAll( t ) )
     216                 :          0 :         return NULL;
     217                 :     143304 :     SbxVariable* pRes = NULL;
     218                 :     143304 :     pObjs->SetFlag( SBX_EXTSEARCH );
     219         [ +  + ]:     143304 :     if( t == SbxCLASS_DONTCARE )
     220                 :            :     {
     221                 :      76137 :         pRes = pMethods->Find( rName, SbxCLASS_METHOD );
     222         [ +  + ]:      76137 :         if( !pRes )
     223                 :      74693 :             pRes = pProps->Find( rName, SbxCLASS_PROPERTY );
     224         [ +  + ]:      76137 :         if( !pRes )
     225                 :      57132 :             pRes = pObjs->Find( rName, t );
     226                 :            :     }
     227                 :            :     else
     228                 :            :     {
     229                 :      67167 :         SbxArray* pArray = NULL;
     230   [ +  +  +  - ]:      67167 :         switch( t )
     231                 :            :         {
     232                 :            :             case SbxCLASS_VARIABLE:
     233                 :       7750 :             case SbxCLASS_PROPERTY: pArray = pProps;    break;
     234                 :        545 :             case SbxCLASS_METHOD:   pArray = pMethods;  break;
     235                 :      58872 :             case SbxCLASS_OBJECT:   pArray = pObjs;     break;
     236                 :            :             default:
     237                 :            :                 DBG_ASSERT( !this, "Ungueltige SBX-Klasse" );
     238                 :            :         }
     239         [ +  - ]:      67167 :         if( pArray )
     240                 :      67167 :             pRes = pArray->Find( rName, t );
     241                 :            :     }
     242                 :            :     // ExtendedsSearch in the Object-Array?
     243                 :            :     // For objects and DontCare is the array of objects already
     244                 :            :     // searched through
     245 [ +  + ][ +  + ]:     143304 :     if( !pRes && ( t == SbxCLASS_METHOD || t == SbxCLASS_PROPERTY ) )
                 [ +  + ]
     246                 :       7286 :         pRes = pObjs->Find( rName, t );
     247                 :            :     // Search in the parents?
     248 [ +  + ][ +  + ]:     143304 :     if( !pRes && IsSet( SBX_GBLSEARCH ) )
                 [ +  + ]
     249                 :            :     {
     250                 :      11585 :         SbxObject* pCur = this;
     251 [ +  + ][ +  + ]:      19250 :         while( !pRes && pCur->pParent )
                 [ +  + ]
     252                 :            :         {
     253                 :            :             // I myself was already searched through!
     254                 :       7665 :             sal_uInt16 nOwn = pCur->GetFlags();
     255                 :       7665 :             pCur->ResetFlag( SBX_EXTSEARCH );
     256                 :            :             // I search already global!
     257                 :       7665 :             sal_uInt16 nPar = pCur->pParent->GetFlags();
     258                 :       7665 :             pCur->pParent->ResetFlag( SBX_GBLSEARCH );
     259                 :       7665 :             pRes = pCur->pParent->Find( rName, t );
     260                 :       7665 :             pCur->SetFlags( nOwn );
     261                 :       7665 :             pCur->pParent->SetFlags( nPar );
     262                 :       7665 :             pCur = pCur->pParent;
     263                 :            :         }
     264                 :            :     }
     265                 :            : #ifdef DBG_UTIL
     266                 :            :     nLvl--;
     267                 :            :     if( pRes )
     268                 :            :     {
     269                 :            :         rtl::OString aNameStr3(rtl::OUStringToOString(rName, RTL_TEXTENCODING_ASCII_US));
     270                 :            :         rtl::OString aNameStr4(rtl::OUStringToOString(SbxVariable::GetName(), RTL_TEXTENCODING_ASCII_US));
     271                 :            :         DbgOutf( "SBX: Found %.*s %s in %s",
     272                 :            :             nLvl, "                              ", aNameStr3.getStr(), aNameStr4.getStr() );
     273                 :            :     }
     274                 :            : #endif
     275                 :     143304 :     return pRes;
     276                 :            : }
     277                 :            : 
     278                 :            : // Abbreviated version: The parent-string will be searched through
     279                 :            : // The whole thing recursive, because Call() might be overloaded
     280                 :            : // Qualified names are allowed
     281                 :            : 
     282                 :         36 : sal_Bool SbxObject::Call( const XubString& rName, SbxArray* pParam )
     283                 :            : {
     284                 :         36 :     SbxVariable* pMeth = FindQualified( rName, SbxCLASS_DONTCARE);
     285 [ +  - ][ +  - ]:         36 :     if( pMeth && pMeth->ISA(SbxMethod) )
                 [ +  - ]
     286                 :            :     {
     287                 :            :         // FindQualified() might have been stroked!
     288         [ +  - ]:         36 :         if( pParam )
     289                 :         36 :             pMeth->SetParameters( pParam );
     290                 :         36 :         pMeth->Broadcast( SBX_HINT_DATAWANTED );
     291                 :         36 :         pMeth->SetParameters( NULL );
     292                 :         36 :         return sal_True;
     293                 :            :     }
     294                 :          0 :     SetError( SbxERR_NO_METHOD );
     295                 :         36 :     return sal_False;
     296                 :            : }
     297                 :            : 
     298                 :         14 : SbxProperty* SbxObject::GetDfltProperty()
     299                 :            : {
     300 [ +  - ][ +  + ]:         14 :     if ( !pDfltProp && aDfltPropName.Len() )
                 [ +  + ]
     301                 :            :     {
     302         [ +  - ]:          8 :         pDfltProp = (SbxProperty*) Find( aDfltPropName, SbxCLASS_PROPERTY );
     303         [ -  + ]:          8 :         if( !pDfltProp )
     304                 :          0 :             pDfltProp = (SbxProperty*) Make( aDfltPropName, SbxCLASS_PROPERTY, SbxVARIANT );
     305                 :            :     }
     306                 :         14 :     return pDfltProp;
     307                 :            : }
     308                 :        132 : void SbxObject::SetDfltProperty( const XubString& rName )
     309                 :            : {
     310         [ +  - ]:        132 :     if ( rName != aDfltPropName )
     311                 :        132 :         pDfltProp = NULL;
     312                 :        132 :     aDfltPropName = rName;
     313                 :        132 :     SetModified( sal_True );
     314                 :        132 : }
     315                 :            : 
     316                 :            : // Search of a already available variable. If she was located,
     317                 :            : // the index will be set, elsewise will be delivered the Count of the Array.
     318                 :            : // In any case it will be delivered the correct Array.
     319                 :            : 
     320                 :      16529 : SbxArray* SbxObject::FindVar( SbxVariable* pVar, sal_uInt16& nArrayIdx )
     321                 :            : {
     322                 :      16529 :     SbxArray* pArray = NULL;
     323         [ +  - ]:      16529 :     if( pVar ) switch( pVar->GetClass() )
           [ +  -  +  - ]
     324                 :            :     {
     325                 :            :         case SbxCLASS_VARIABLE:
     326                 :      11032 :         case SbxCLASS_PROPERTY: pArray = pProps;    break;
     327                 :          0 :         case SbxCLASS_METHOD:   pArray = pMethods;  break;
     328                 :      16529 :         case SbxCLASS_OBJECT:   pArray = pObjs;     break;
     329                 :            :         default:
     330                 :            :             DBG_ASSERT( !this, "Ungueltige SBX-Klasse" );
     331                 :            :     }
     332         [ +  - ]:      16529 :     if( pArray )
     333                 :            :     {
     334                 :      16529 :         nArrayIdx = pArray->Count();
     335                 :            :         // Is the variable per name available?
     336                 :      16529 :         pArray->ResetFlag( SBX_EXTSEARCH );
     337         [ +  - ]:      16529 :         SbxVariable* pOld = pArray->Find( pVar->GetName(), pVar->GetClass() );
     338         [ +  + ]:      16529 :         if( pOld )
     339         [ +  - ]:      59035 :           for( sal_uInt16 i = 0; i < pArray->Count(); i++ )
     340                 :            :         {
     341                 :      44646 :             SbxVariableRef& rRef = pArray->GetRef( i );
     342         [ +  + ]:      44646 :             if( (SbxVariable*) rRef == pOld )
     343                 :            :             {
     344                 :      14389 :                 nArrayIdx = i; break;
     345                 :            :             }
     346                 :            :         }
     347                 :            :     }
     348                 :      16529 :     return pArray;
     349                 :            : }
     350                 :            : 
     351                 :            : // If a new object will be established, this object will be indexed,
     352                 :            : // if an object of this name exists already.
     353                 :            : 
     354                 :      20910 : SbxVariable* SbxObject::Make( const XubString& rName, SbxClassType ct, SbxDataType dt )
     355                 :            : {
     356                 :            :     // Is the object already available?
     357                 :      20910 :     SbxArray* pArray = NULL;
     358   [ +  +  -  - ]:      20910 :     switch( ct )
     359                 :            :     {
     360                 :            :         case SbxCLASS_VARIABLE:
     361                 :      15914 :         case SbxCLASS_PROPERTY: pArray = pProps;    break;
     362                 :       4996 :         case SbxCLASS_METHOD:   pArray = pMethods;  break;
     363                 :          0 :         case SbxCLASS_OBJECT:   pArray = pObjs;     break;
     364                 :            :         default:
     365                 :            :             DBG_ASSERT( !this, "Ungueltige SBX-Klasse" );
     366                 :            :     }
     367         [ -  + ]:      20910 :     if( !pArray )
     368                 :          0 :         return NULL;
     369                 :            :     // Collections may contain objects of the same name
     370 [ -  + ][ #  # ]:      20910 :     if( !( ct == SbxCLASS_OBJECT && ISA(SbxCollection) ) )
                 [ +  - ]
     371                 :            :     {
     372         [ +  - ]:      20910 :         SbxVariable* pRes = pArray->Find( rName, ct );
     373         [ -  + ]:      20910 :         if( pRes )
     374                 :            :         {
     375                 :          0 :             return pRes;
     376                 :            :         }
     377                 :            :     }
     378                 :      20910 :     SbxVariable* pVar = NULL;
     379   [ +  +  -  - ]:      20910 :     switch( ct )
     380                 :            :     {
     381                 :            :         case SbxCLASS_VARIABLE:
     382                 :            :         case SbxCLASS_PROPERTY:
     383         [ +  - ]:      15914 :             pVar = new SbxProperty( rName, dt );
     384                 :      15914 :             break;
     385                 :            :         case SbxCLASS_METHOD:
     386         [ +  - ]:       4996 :             pVar = new SbxMethod( rName, dt );
     387                 :       4996 :             break;
     388                 :            :         case SbxCLASS_OBJECT:
     389         [ #  # ]:          0 :             pVar = CreateObject( rName );
     390                 :          0 :             break;
     391                 :          0 :         default: break;
     392                 :            :     }
     393                 :      20910 :     pVar->SetParent( this );
     394                 :      20910 :     pArray->Put( pVar, pArray->Count() );
     395                 :      20910 :     SetModified( sal_True );
     396                 :            :     // The object listen always
     397                 :      20910 :     StartListening( pVar->GetBroadcaster(), sal_True );
     398                 :      20910 :     Broadcast( SBX_HINT_OBJECTCHANGED );
     399                 :      20910 :     return pVar;
     400                 :            : }
     401                 :            : 
     402                 :          0 : SbxObject* SbxObject::MakeObject( const XubString& rName, const XubString& rClass )
     403                 :            : {
     404                 :            :     // Is the object already available?
     405         [ #  # ]:          0 :     if( !ISA(SbxCollection) )
     406                 :            :     {
     407         [ #  # ]:          0 :         SbxVariable* pRes = pObjs->Find( rName, SbxCLASS_OBJECT );
     408         [ #  # ]:          0 :         if( pRes )
     409                 :            :         {
     410 [ #  # ][ #  # ]:          0 :             return PTR_CAST(SbxObject,pRes);
     411                 :            :         }
     412                 :            :     }
     413         [ #  # ]:          0 :     SbxObject* pVar = CreateObject( rClass );
     414         [ #  # ]:          0 :     if( pVar )
     415                 :            :     {
     416                 :          0 :         pVar->SetName( rName );
     417                 :          0 :         pVar->SetParent( this );
     418                 :          0 :         pObjs->Put( pVar, pObjs->Count() );
     419                 :          0 :         SetModified( sal_True );
     420                 :            :         // The object listen always
     421                 :          0 :         StartListening( pVar->GetBroadcaster(), sal_True );
     422                 :          0 :         Broadcast( SBX_HINT_OBJECTCHANGED );
     423                 :            :     }
     424                 :          0 :     return pVar;
     425                 :            : }
     426                 :            : 
     427                 :       5432 : void SbxObject::Insert( SbxVariable* pVar )
     428                 :            : {
     429                 :            :     sal_uInt16 nIdx;
     430         [ +  - ]:       5432 :     SbxArray* pArray = FindVar( pVar, nIdx );
     431         [ +  - ]:       5432 :     if( pArray )
     432                 :            :     {
     433                 :            :         // Into with it. But you should pay attention at the Pointer!
     434 [ +  - ][ +  + ]:       5432 :         if( nIdx < pArray->Count() )
     435                 :            :         {
     436                 :            :             // Then this element exists already
     437                 :            :             // There are objects of the same name allowed at collections
     438 [ +  - ][ +  - ]:       3357 :             if( pArray == pObjs && ISA(SbxCollection) )
         [ +  - ][ -  + ]
                 [ -  + ]
     439         [ #  # ]:          0 :                 nIdx = pArray->Count();
     440                 :            :             else
     441                 :            :             {
     442         [ +  - ]:       3357 :                 SbxVariable* pOld = pArray->Get( nIdx );
     443                 :            :                 // already inside: overwrite
     444         [ +  - ]:       3357 :                 if( pOld == pVar )
     445                 :       5432 :                     return;
     446                 :            : 
     447 [ +  - ][ +  - ]:       3357 :                 EndListening( pOld->GetBroadcaster(), sal_True );
     448 [ +  - ][ -  + ]:       3357 :                 if( pVar->GetClass() == SbxCLASS_PROPERTY )
     449                 :            :                 {
     450         [ #  # ]:          0 :                     if( pOld == pDfltProp )
     451                 :          0 :                         pDfltProp = (SbxProperty*) pVar;
     452                 :            :                 }
     453                 :            :             }
     454                 :            :         }
     455 [ +  - ][ +  - ]:       5432 :         StartListening( pVar->GetBroadcaster(), sal_True );
     456         [ +  - ]:       5432 :         pArray->Put( pVar, nIdx );
     457 [ +  - ][ +  + ]:       5432 :         if( pVar->GetParent() != this )
     458         [ +  - ]:       4859 :             pVar->SetParent( this );
     459         [ +  - ]:       5432 :         SetModified( sal_True );
     460         [ +  - ]:       5432 :         Broadcast( SBX_HINT_OBJECTCHANGED );
     461                 :            : #ifdef DBG_UTIL
     462                 :            :     static const char* pCls[] =
     463                 :            :     { "DontCare","Array","Value","Variable","Method","Property","Object" };
     464                 :            :     XubString aVarName( pVar->GetName() );
     465                 :            :     if ( !aVarName.Len() && pVar->ISA(SbxObject) )
     466                 :            :         aVarName = PTR_CAST(SbxObject,pVar)->GetClassName();
     467                 :            :     rtl::OString aNameStr1(rtl::OUStringToOString(aVarName, RTL_TEXTENCODING_ASCII_US));
     468                 :            :     rtl::OString aNameStr2(rtl::OUStringToOString(SbxVariable::GetName(), RTL_TEXTENCODING_ASCII_US));
     469                 :            :     DbgOutf( "SBX: Insert %s %s in %s",
     470                 :            :         ( pVar->GetClass() >= SbxCLASS_DONTCARE &&
     471                 :            :           pVar->GetClass() <= SbxCLASS_OBJECT )
     472                 :            :             ? pCls[ pVar->GetClass()-1 ] : "Unknown class", aNameStr1.getStr(), aNameStr1.getStr() );
     473                 :            : #endif
     474                 :            :     }
     475                 :            : }
     476                 :            : 
     477                 :            : // Optimisation, Insertion without checking about
     478                 :            : // double entry and without broadcasts, will only be used in SO2/auto.cxx
     479                 :        558 : void SbxObject::QuickInsert( SbxVariable* pVar )
     480                 :            : {
     481                 :        558 :     SbxArray* pArray = NULL;
     482         [ +  - ]:        558 :     if( pVar )
     483                 :            :     {
     484   [ +  +  -  - ]:        558 :         switch( pVar->GetClass() )
     485                 :            :         {
     486                 :            :             case SbxCLASS_VARIABLE:
     487                 :        270 :             case SbxCLASS_PROPERTY: pArray = pProps;    break;
     488                 :        288 :             case SbxCLASS_METHOD:   pArray = pMethods;  break;
     489                 :        558 :             case SbxCLASS_OBJECT:   pArray = pObjs;     break;
     490                 :            :             default:
     491                 :            :                 DBG_ASSERT( !this, "Ungueltige SBX-Klasse" );
     492                 :            :         }
     493                 :            :     }
     494         [ +  - ]:        558 :     if( pArray )
     495                 :            :     {
     496                 :        558 :         StartListening( pVar->GetBroadcaster(), sal_True );
     497                 :        558 :         pArray->Put( pVar, pArray->Count() );
     498         [ +  - ]:        558 :         if( pVar->GetParent() != this )
     499                 :        558 :             pVar->SetParent( this );
     500                 :        558 :         SetModified( sal_True );
     501                 :            : #ifdef DBG_UTIL
     502                 :            :     static const char* pCls[] =
     503                 :            :     { "DontCare","Array","Value","Variable","Method","Property","Object" };
     504                 :            :     XubString aVarName( pVar->GetName() );
     505                 :            :     if ( !aVarName.Len() && pVar->ISA(SbxObject) )
     506                 :            :         aVarName = PTR_CAST(SbxObject,pVar)->GetClassName();
     507                 :            :     rtl::OString aNameStr1(rtl::OUStringToOString(aVarName, RTL_TEXTENCODING_ASCII_US));
     508                 :            :     rtl::OString aNameStr2(rtl::OUStringToOString(SbxVariable::GetName(), RTL_TEXTENCODING_ASCII_US));
     509                 :            :     DbgOutf( "SBX: Insert %s %s in %s",
     510                 :            :         ( pVar->GetClass() >= SbxCLASS_DONTCARE &&
     511                 :            :           pVar->GetClass() <= SbxCLASS_OBJECT )
     512                 :            :             ? pCls[ pVar->GetClass()-1 ] : "Unknown class", aNameStr1.getStr(), aNameStr1.getStr() );
     513                 :            : #endif
     514                 :            :     }
     515                 :        558 : }
     516                 :            : 
     517                 :      11032 : void SbxObject::Remove( const XubString& rName, SbxClassType t )
     518                 :            : {
     519 [ +  - ][ +  - ]:      11032 :     Remove( SbxObject::Find( rName, t ) );
     520                 :      11032 : }
     521                 :            : 
     522                 :      11097 : void SbxObject::Remove( SbxVariable* pVar )
     523                 :            : {
     524                 :            :     sal_uInt16 nIdx;
     525         [ +  - ]:      11097 :     SbxArray* pArray = FindVar( pVar, nIdx );
     526 [ +  - ][ +  - ]:      11097 :     if( pArray && nIdx < pArray->Count() )
         [ +  + ][ +  + ]
     527                 :            :     {
     528                 :            : #ifdef DBG_UTIL
     529                 :            :     XubString aVarName( pVar->GetName() );
     530                 :            :     if ( !aVarName.Len() && pVar->ISA(SbxObject) )
     531                 :            :         aVarName = PTR_CAST(SbxObject,pVar)->GetClassName();
     532                 :            :     rtl::OString aNameStr1(rtl::OUStringToOString(aVarName, RTL_TEXTENCODING_ASCII_US));
     533                 :            :     rtl::OString aNameStr2(rtl::OUStringToOString(SbxVariable::GetName(), RTL_TEXTENCODING_ASCII_US));
     534                 :            : #endif
     535         [ +  - ]:      11032 :         SbxVariableRef pVar_ = pArray->Get( nIdx );
     536         [ +  - ]:      11032 :         if( pVar_->IsBroadcaster() )
     537 [ +  - ][ +  - ]:      11032 :             EndListening( pVar_->GetBroadcaster(), sal_True );
     538         [ -  + ]:      11032 :         if( (SbxVariable*) pVar_ == pDfltProp )
     539                 :          0 :             pDfltProp = NULL;
     540         [ +  - ]:      11032 :         pArray->Remove( nIdx );
     541 [ +  - ][ +  - ]:      11032 :         if( pVar_->GetParent() == this )
     542         [ +  - ]:      11032 :             pVar_->SetParent( NULL );
     543         [ +  - ]:      11032 :         SetModified( sal_True );
     544 [ +  - ][ +  - ]:      11032 :         Broadcast( SBX_HINT_OBJECTCHANGED );
     545                 :            :     }
     546                 :      11097 : }
     547                 :            : 
     548                 :          0 : static sal_Bool LoadArray( SvStream& rStrm, SbxObject* pThis, SbxArray* pArray )
     549                 :            : {
     550         [ #  # ]:          0 :     SbxArrayRef p = (SbxArray*) SbxBase::Load( rStrm );
     551         [ #  # ]:          0 :     if( !p.Is() )
     552                 :          0 :         return sal_False;
     553 [ #  # ][ #  # ]:          0 :     for( sal_uInt16 i = 0; i < p->Count(); i++ )
     554                 :            :     {
     555         [ #  # ]:          0 :         SbxVariableRef& r = p->GetRef( i );
     556                 :          0 :         SbxVariable* pVar = r;
     557         [ #  # ]:          0 :         if( pVar )
     558                 :            :         {
     559         [ #  # ]:          0 :             pVar->SetParent( pThis );
     560 [ #  # ][ #  # ]:          0 :             pThis->StartListening( pVar->GetBroadcaster(), sal_True );
     561                 :            :         }
     562                 :            :     }
     563         [ #  # ]:          0 :     pArray->Merge( p );
     564         [ #  # ]:          0 :     return sal_True;
     565                 :            : }
     566                 :            : 
     567                 :            : // The load of an object is additive!
     568                 :            : 
     569                 :          0 : sal_Bool SbxObject::LoadData( SvStream& rStrm, sal_uInt16 nVer )
     570                 :            : {
     571                 :            :     // Help for the read in of old objects: just TRUE back,
     572                 :            :     // LoadPrivateData() had to set the default status up
     573         [ #  # ]:          0 :     if( !nVer )
     574                 :          0 :         return sal_True;
     575                 :            : 
     576                 :          0 :     pDfltProp = NULL;
     577 [ #  # ][ #  # ]:          0 :     if( !SbxVariable::LoadData( rStrm, nVer ) )
     578                 :          0 :         return sal_False;
     579                 :            :     // If  it contains no alien object, insert ourselves
     580 [ #  # ][ #  # ]:          0 :     if( aData.eType == SbxOBJECT && !aData.pObj )
     581                 :          0 :         aData.pObj = this;
     582                 :            :     sal_uInt32 nSize;
     583         [ #  # ]:          0 :     XubString aDfltProp;
     584                 :            :     aClassName = read_lenPrefixed_uInt8s_ToOUString<sal_uInt16>(rStrm,
     585 [ #  # ][ #  # ]:          0 :         RTL_TEXTENCODING_ASCII_US);
     586                 :            :     aDfltProp = read_lenPrefixed_uInt8s_ToOUString<sal_uInt16>(rStrm,
     587 [ #  # ][ #  # ]:          0 :         RTL_TEXTENCODING_ASCII_US);
     588                 :          0 :     sal_uIntPtr nPos = rStrm.Tell();
     589         [ #  # ]:          0 :     rStrm >> nSize;
     590 [ #  # ][ #  # ]:          0 :     if( !LoadPrivateData( rStrm, nVer ) )
     591                 :          0 :         return sal_False;
     592                 :          0 :     sal_uIntPtr nNewPos = rStrm.Tell();
     593                 :          0 :     nPos += nSize;
     594                 :            :     DBG_ASSERT( nPos >= nNewPos, "SBX: Zu viele Daten eingelesen" );
     595         [ #  # ]:          0 :     if( nPos != nNewPos )
     596         [ #  # ]:          0 :         rStrm.Seek( nPos );
     597 [ #  # ][ #  # ]:          0 :     if( !LoadArray( rStrm, this, pMethods )
         [ #  # ][ #  # ]
                 [ #  # ]
     598         [ #  # ]:          0 :      || !LoadArray( rStrm, this, pProps )
     599         [ #  # ]:          0 :      || !LoadArray( rStrm, this, pObjs ) )
     600                 :          0 :         return sal_False;
     601                 :            :     // Set properties
     602         [ #  # ]:          0 :     if( aDfltProp.Len() )
     603 [ #  # ][ #  # ]:          0 :         pDfltProp = (SbxProperty*) pProps->Find( aDfltProp, SbxCLASS_PROPERTY );
     604         [ #  # ]:          0 :     SetModified( sal_False );
     605         [ #  # ]:          0 :     return sal_True;
     606                 :            : }
     607                 :            : 
     608                 :          0 : sal_Bool SbxObject::StoreData( SvStream& rStrm ) const
     609                 :            : {
     610 [ #  # ][ #  # ]:          0 :     if( !SbxVariable::StoreData( rStrm ) )
     611                 :          0 :         return sal_False;
     612         [ #  # ]:          0 :     XubString aDfltProp;
     613         [ #  # ]:          0 :     if( pDfltProp )
     614 [ #  # ][ #  # ]:          0 :         aDfltProp = pDfltProp->GetName();
     615 [ #  # ][ #  # ]:          0 :     write_lenPrefixed_uInt8s_FromOUString<sal_uInt16>(rStrm, aClassName, RTL_TEXTENCODING_ASCII_US);
     616 [ #  # ][ #  # ]:          0 :     write_lenPrefixed_uInt8s_FromOUString<sal_uInt16>(rStrm, aDfltProp, RTL_TEXTENCODING_ASCII_US);
     617                 :          0 :     sal_uIntPtr nPos = rStrm.Tell();
     618         [ #  # ]:          0 :     rStrm << (sal_uInt32) 0L;
     619 [ #  # ][ #  # ]:          0 :     if( !StorePrivateData( rStrm ) )
     620                 :          0 :         return sal_False;
     621                 :          0 :     sal_uIntPtr nNew = rStrm.Tell();
     622         [ #  # ]:          0 :     rStrm.Seek( nPos );
     623         [ #  # ]:          0 :     rStrm << (sal_uInt32) ( nNew - nPos );
     624         [ #  # ]:          0 :     rStrm.Seek( nNew );
     625 [ #  # ][ #  # ]:          0 :     if( !pMethods->Store( rStrm ) )
     626                 :          0 :         return sal_False;
     627 [ #  # ][ #  # ]:          0 :     if( !pProps->Store( rStrm ) )
     628                 :          0 :         return sal_False;
     629 [ #  # ][ #  # ]:          0 :     if( !pObjs->Store( rStrm ) )
     630                 :          0 :         return sal_False;
     631         [ #  # ]:          0 :     ((SbxObject*) this)->SetModified( sal_False );
     632         [ #  # ]:          0 :     return sal_True;
     633                 :            : }
     634                 :            : 
     635                 :          0 : XubString SbxObject::GenerateSource( const XubString &rLinePrefix,
     636                 :            :                                   const SbxObject* )
     637                 :            : {
     638                 :            :     // Collect the properties in a String
     639         [ #  # ]:          0 :     XubString aSource;
     640                 :          0 :     SbxArrayRef xProps( GetProperties() );
     641                 :          0 :     bool bLineFeed = false;
     642 [ #  # ][ #  # ]:          0 :     for ( sal_uInt16 nProp = 0; nProp < xProps->Count(); ++nProp )
     643                 :            :     {
     644         [ #  # ]:          0 :         SbxPropertyRef xProp = (SbxProperty*) xProps->Get(nProp);
     645 [ #  # ][ #  # ]:          0 :         XubString aPropName( xProp->GetName() );
     646   [ #  #  #  # ]:          0 :         if ( xProp->CanWrite()
                 [ #  # ]
     647                 :          0 :          && !( xProp->GetHashCode() == nNameHash
     648 [ #  # ][ #  # ]:          0 :             && aPropName.EqualsIgnoreCaseAscii( pNameProp ) ) )
     649                 :            :         {
     650                 :            :             // Insert a break except in front of the first property
     651         [ #  # ]:          0 :             if ( bLineFeed )
     652         [ #  # ]:          0 :                 aSource.AppendAscii( "\n" );
     653                 :            :             else
     654                 :          0 :                 bLineFeed = true;
     655                 :            : 
     656         [ #  # ]:          0 :             aSource += rLinePrefix;
     657         [ #  # ]:          0 :             aSource += '.';
     658         [ #  # ]:          0 :             aSource += aPropName;
     659         [ #  # ]:          0 :             aSource.AppendAscii( " = " );
     660                 :            : 
     661                 :            :             // Display the property value textual
     662         [ #  # ]:          0 :             switch ( xProp->GetType() )
              [ #  #  # ]
     663                 :            :             {
     664                 :            :                 case SbxEMPTY:
     665                 :            :                 case SbxNULL:
     666                 :            :                     // no value
     667                 :          0 :                     break;
     668                 :            : 
     669                 :            :                 case SbxSTRING:
     670                 :            :                 {
     671                 :            :                     // Strings in quotation mark
     672         [ #  # ]:          0 :                     aSource.AppendAscii( "\"" );
     673 [ #  # ][ #  # ]:          0 :                     aSource += xProp->GetString();
     674         [ #  # ]:          0 :                     aSource.AppendAscii( "\"" );
     675                 :          0 :                     break;
     676                 :            :                 }
     677                 :            : 
     678                 :            :                 default:
     679                 :            :                 {
     680                 :            :                     // miscellaneous, such as e.g.numerary directly
     681 [ #  # ][ #  # ]:          0 :                     aSource += xProp->GetString();
     682                 :          0 :                     break;
     683                 :            :                 }
     684                 :            :             }
     685                 :            :         }
     686 [ #  # ][ #  # ]:          0 :     }
     687         [ #  # ]:          0 :     return aSource;
     688                 :            : }
     689                 :            : 
     690                 :          0 : static sal_Bool CollectAttrs( const SbxBase* p, XubString& rRes )
     691                 :            : {
     692         [ #  # ]:          0 :     XubString aAttrs;
     693         [ #  # ]:          0 :     if( p->IsHidden() )
     694         [ #  # ]:          0 :         aAttrs.AssignAscii( "Hidden" );
     695         [ #  # ]:          0 :     if( p->IsSet( SBX_EXTSEARCH ) )
     696                 :            :     {
     697         [ #  # ]:          0 :         if( aAttrs.Len() )
     698         [ #  # ]:          0 :             aAttrs += ',';
     699         [ #  # ]:          0 :         aAttrs.AppendAscii( "ExtSearch" );
     700                 :            :     }
     701         [ #  # ]:          0 :     if( !p->IsVisible() )
     702                 :            :     {
     703         [ #  # ]:          0 :         if( aAttrs.Len() )
     704         [ #  # ]:          0 :             aAttrs += ',';
     705         [ #  # ]:          0 :         aAttrs.AppendAscii( "Invisible" );
     706                 :            :     }
     707         [ #  # ]:          0 :     if( p->IsSet( SBX_DONTSTORE ) )
     708                 :            :     {
     709         [ #  # ]:          0 :         if( aAttrs.Len() )
     710         [ #  # ]:          0 :             aAttrs += ',';
     711         [ #  # ]:          0 :         aAttrs.AppendAscii( "DontStore" );
     712                 :            :     }
     713         [ #  # ]:          0 :     if( aAttrs.Len() )
     714                 :            :     {
     715         [ #  # ]:          0 :         rRes.AssignAscii( " (" );
     716         [ #  # ]:          0 :         rRes += aAttrs;
     717         [ #  # ]:          0 :         rRes += ')';
     718                 :          0 :         return sal_True;
     719                 :            :     }
     720                 :            :     else
     721                 :            :     {
     722         [ #  # ]:          0 :         rRes.Erase();
     723                 :          0 :         return sal_False;
     724         [ #  # ]:          0 :     }
     725                 :            : }
     726                 :            : 
     727                 :          0 : void SbxObject::Dump( SvStream& rStrm, sal_Bool bFill )
     728                 :            : {
     729                 :            :     // Shifting
     730                 :            :     static sal_uInt16 nLevel = 0;
     731         [ #  # ]:          0 :     if ( nLevel > 10 )
     732                 :            :     {
     733 [ #  # ][ #  # ]:          0 :         rStrm << "<too deep>" << endl;
     734                 :          0 :         return;
     735                 :            :     }
     736                 :          0 :     ++nLevel;
     737         [ #  # ]:          0 :     String aIndent;
     738         [ #  # ]:          0 :     for ( sal_uInt16 n = 1; n < nLevel; ++n )
     739         [ #  # ]:          0 :         aIndent.AppendAscii( "    " );
     740                 :            : 
     741                 :            :     // if necessary complete the object
     742         [ #  # ]:          0 :     if ( bFill )
     743         [ #  # ]:          0 :         GetAll( SbxCLASS_DONTCARE );
     744                 :            : 
     745                 :            :     // Output the data of the object itself
     746 [ #  # ][ #  # ]:          0 :     rtl::OString aNameStr(rtl::OUStringToOString(GetName(), RTL_TEXTENCODING_ASCII_US));
                 [ #  # ]
     747 [ #  # ][ #  # ]:          0 :     rtl::OString aClassNameStr(rtl::OUStringToOString(aClassName, RTL_TEXTENCODING_ASCII_US));
     748         [ #  # ]:          0 :     rStrm << "Object( "
     749 [ #  # ][ #  # ]:          0 :           << rtl::OString::valueOf(reinterpret_cast<sal_Int64>(this)).getStr()<< "=='"
     750 [ #  # ][ #  # ]:          0 :           << ( aNameStr.isEmpty() ?  "<unnamed>" : aNameStr.getStr() ) << "', "
                 [ #  # ]
     751 [ #  # ][ #  # ]:          0 :           << "of class '" << aClassNameStr.getStr() << "', "
                 [ #  # ]
     752         [ #  # ]:          0 :           << "counts "
     753         [ #  # ]:          0 :           << rtl::OString::valueOf(static_cast<sal_Int64>(GetRefCount())).getStr()
     754         [ #  # ]:          0 :           << " refs, ";
     755 [ #  # ][ #  # ]:          0 :     if ( GetParent() )
     756                 :            :     {
     757 [ #  # ][ #  # ]:          0 :         rtl::OString aParentNameStr(rtl::OUStringToOString(GetName(), RTL_TEXTENCODING_ASCII_US));
                 [ #  # ]
     758         [ #  # ]:          0 :         rStrm << "in parent "
     759 [ #  # ][ #  # ]:          0 :               << rtl::OString::valueOf(reinterpret_cast<sal_Int64>(GetParent())).getStr()
     760 [ #  # ][ #  # ]:          0 :               << "=='" << ( aParentNameStr.isEmpty() ? "<unnamed>" : aParentNameStr.getStr()  ) << "'";
         [ #  # ][ #  # ]
     761                 :            :     }
     762                 :            :     else
     763         [ #  # ]:          0 :         rStrm << "no parent ";
     764 [ #  # ][ #  # ]:          0 :     rStrm << " )" << endl;
     765 [ #  # ][ #  # ]:          0 :     rtl::OString aIndentNameStr(rtl::OUStringToOString(aIndent, RTL_TEXTENCODING_ASCII_US));
     766 [ #  # ][ #  # ]:          0 :     rStrm << aIndentNameStr.getStr() << "{" << endl;
                 [ #  # ]
     767                 :            : 
     768                 :            :     // Flags
     769         [ #  # ]:          0 :     XubString aAttrs;
     770 [ #  # ][ #  # ]:          0 :     if( CollectAttrs( this, aAttrs ) )
     771                 :            :     {
     772 [ #  # ][ #  # ]:          0 :         rtl::OString aAttrStr(rtl::OUStringToOString(aAttrs, RTL_TEXTENCODING_ASCII_US));
     773 [ #  # ][ #  # ]:          0 :         rStrm << aIndentNameStr.getStr() << "- Flags: " << aAttrStr.getStr() << endl;
         [ #  # ][ #  # ]
     774                 :            :     }
     775                 :            : 
     776                 :            :     // Methods
     777 [ #  # ][ #  # ]:          0 :     rStrm << aIndentNameStr.getStr() << "- Methods:" << endl;
                 [ #  # ]
     778 [ #  # ][ #  # ]:          0 :     for( sal_uInt16 i = 0; i < pMethods->Count(); i++ )
     779                 :            :     {
     780         [ #  # ]:          0 :         SbxVariableRef& r = pMethods->GetRef( i );
     781                 :          0 :         SbxVariable* pVar = r;
     782         [ #  # ]:          0 :         if( pVar )
     783                 :            :         {
     784         [ #  # ]:          0 :             XubString aLine( aIndent );
     785         [ #  # ]:          0 :             aLine.AppendAscii( "  - " );
     786 [ #  # ][ #  # ]:          0 :             aLine += pVar->GetName( SbxNAME_SHORT_TYPES );
     787         [ #  # ]:          0 :             XubString aAttrs2;
     788 [ #  # ][ #  # ]:          0 :             if( CollectAttrs( pVar, aAttrs2 ) )
     789         [ #  # ]:          0 :                 aLine += aAttrs2;
     790 [ #  # ][ #  # ]:          0 :             if( !pVar->IsA( TYPE(SbxMethod) ) )
                 [ #  # ]
     791         [ #  # ]:          0 :                 aLine.AppendAscii( "  !! Not a Method !!" );
     792 [ #  # ][ #  # ]:          0 :             write_lenPrefixed_uInt8s_FromOUString<sal_uInt16>(rStrm, aLine, RTL_TEXTENCODING_ASCII_US);
     793                 :            : 
     794                 :            :             // Output also the object at object-methods
     795 [ #  # ][ #  # ]:          0 :             if ( pVar->GetValues_Impl().eType == SbxOBJECT &&
           [ #  #  #  #  
                   #  # ]
     796                 :          0 :                     pVar->GetValues_Impl().pObj &&
     797                 :          0 :                     pVar->GetValues_Impl().pObj != this &&
     798         [ #  # ]:          0 :                     pVar->GetValues_Impl().pObj != GetParent() )
     799                 :            :             {
     800         [ #  # ]:          0 :                 rStrm << " contains ";
     801         [ #  # ]:          0 :                 ((SbxObject*) pVar->GetValues_Impl().pObj)->Dump( rStrm, bFill );
     802                 :            :             }
     803                 :            :             else
     804 [ #  # ][ #  # ]:          0 :                 rStrm << endl;
                 [ #  # ]
     805                 :            :         }
     806                 :            :     }
     807                 :            : 
     808                 :            :     // Properties
     809 [ #  # ][ #  # ]:          0 :     rStrm << aIndentNameStr.getStr() << "- Properties:" << endl;
                 [ #  # ]
     810                 :            :     {
     811 [ #  # ][ #  # ]:          0 :         for( sal_uInt16 i = 0; i < pProps->Count(); i++ )
     812                 :            :         {
     813         [ #  # ]:          0 :             SbxVariableRef& r = pProps->GetRef( i );
     814                 :          0 :             SbxVariable* pVar = r;
     815         [ #  # ]:          0 :             if( pVar )
     816                 :            :             {
     817         [ #  # ]:          0 :                 XubString aLine( aIndent );
     818         [ #  # ]:          0 :                 aLine.AppendAscii( "  - " );
     819 [ #  # ][ #  # ]:          0 :                 aLine += pVar->GetName( SbxNAME_SHORT_TYPES );
     820         [ #  # ]:          0 :                 XubString aAttrs3;
     821 [ #  # ][ #  # ]:          0 :                 if( CollectAttrs( pVar, aAttrs3 ) )
     822         [ #  # ]:          0 :                     aLine += aAttrs3;
     823 [ #  # ][ #  # ]:          0 :                 if( !pVar->IsA( TYPE(SbxProperty) ) )
                 [ #  # ]
     824         [ #  # ]:          0 :                     aLine.AppendAscii( "  !! Not a Property !!" );
     825 [ #  # ][ #  # ]:          0 :                 write_lenPrefixed_uInt8s_FromOUString<sal_uInt16>(rStrm, aLine, RTL_TEXTENCODING_ASCII_US);
     826                 :            : 
     827                 :            :                 // output also the object at object properties
     828 [ #  # ][ #  # ]:          0 :                 if ( pVar->GetValues_Impl().eType == SbxOBJECT &&
           [ #  #  #  #  
                   #  # ]
     829                 :          0 :                         pVar->GetValues_Impl().pObj &&
     830                 :          0 :                         pVar->GetValues_Impl().pObj != this &&
     831         [ #  # ]:          0 :                         pVar->GetValues_Impl().pObj != GetParent() )
     832                 :            :                 {
     833         [ #  # ]:          0 :                     rStrm << " contains ";
     834         [ #  # ]:          0 :                     ((SbxObject*) pVar->GetValues_Impl().pObj)->Dump( rStrm, bFill );
     835                 :            :                 }
     836                 :            :                 else
     837 [ #  # ][ #  # ]:          0 :                     rStrm << endl;
                 [ #  # ]
     838                 :            :             }
     839                 :            :         }
     840                 :            :     }
     841                 :            : 
     842                 :            :     // Objects
     843 [ #  # ][ #  # ]:          0 :     rStrm << aIndentNameStr.getStr() << "- Objects:" << endl;
                 [ #  # ]
     844                 :            :     {
     845 [ #  # ][ #  # ]:          0 :         for( sal_uInt16 i = 0; i < pObjs->Count(); i++ )
     846                 :            :         {
     847         [ #  # ]:          0 :             SbxVariableRef& r = pObjs->GetRef( i );
     848                 :          0 :             SbxVariable* pVar = r;
     849         [ #  # ]:          0 :             if ( pVar )
     850                 :            :             {
     851 [ #  # ][ #  # ]:          0 :                 rStrm << aIndentNameStr.getStr() << "  - Sub";
     852 [ #  # ][ #  # ]:          0 :                 if ( pVar->ISA(SbxObject) )
                 [ #  # ]
     853         [ #  # ]:          0 :                     ((SbxObject*) pVar)->Dump( rStrm, bFill );
     854 [ #  # ][ #  # ]:          0 :                 else if ( pVar->ISA(SbxVariable) )
                 [ #  # ]
     855         [ #  # ]:          0 :                     ((SbxVariable*) pVar)->Dump( rStrm, bFill );
     856                 :            :             }
     857                 :            :         }
     858                 :            :     }
     859                 :            : 
     860 [ #  # ][ #  # ]:          0 :     rStrm << aIndentNameStr.getStr() << "}" << endl << endl;
         [ #  # ][ #  # ]
     861 [ #  # ][ #  # ]:          0 :     --nLevel;
     862                 :            : }
     863                 :            : 
     864                 :       5560 : SbxMethod::SbxMethod( const String& r, SbxDataType t )
     865 [ +  - ][ +  - ]:       5560 :     : SbxVariable( t )
     866                 :            : {
     867 [ +  - ][ +  - ]:       5560 :     SetName( r );
     868                 :       5560 : }
     869                 :            : 
     870                 :       2672 : SbxMethod::SbxMethod( const SbxMethod& r )
     871 [ +  - ][ +  - ]:       2672 :     : SvRefBase( r ), SbxVariable( r )
     872                 :            : {
     873                 :       2672 : }
     874                 :            : 
     875 [ +  - ][ +  - ]:      14199 : SbxMethod::~SbxMethod()
     876                 :            : {
     877 [ +  - ][ -  + ]:      20568 : }
         [ #  # ][ -  + ]
         [ -  + ][ #  # ]
     878                 :            : 
     879                 :       4767 : SbxClassType SbxMethod::GetClass() const
     880                 :            : {
     881                 :       4767 :     return SbxCLASS_METHOD;
     882                 :            : }
     883                 :            : 
     884                 :      16184 : SbxProperty::SbxProperty( const String& r, SbxDataType t )
     885 [ +  - ][ +  - ]:      16184 :     : SbxVariable( t )
     886                 :            : {
     887 [ +  - ][ +  - ]:      16184 :     SetName( r );
     888                 :      16184 : }
     889                 :            : 
     890 [ +  - ][ +  - ]:      31550 : SbxProperty::~SbxProperty()
     891                 :            : {
     892 [ +  - ][ -  + ]:      47190 : }
         [ #  # ][ -  + ]
         [ -  + ][ #  # ]
     893                 :            : 
     894                 :      53410 : SbxClassType SbxProperty::GetClass() const
     895                 :            : {
     896                 :      53410 :     return SbxCLASS_PROPERTY;
     897                 :            : }
     898                 :            : 
     899                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10