LCOV - code coverage report
Current view: top level - idl/source/objects - object.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 251 324 77.5 %
Date: 2012-08-25 Functions: 20 37 54.1 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 254 540 47.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                 :            : 
      21                 :            : #include <ctype.h>
      22                 :            : #include <stdio.h>
      23                 :            : 
      24                 :            : #include <rtl/strbuf.hxx>
      25                 :            : 
      26                 :            : #include <object.hxx>
      27                 :            : #include <globals.hxx>
      28                 :            : #include <database.hxx>
      29                 :            : 
      30 [ #  # ][ #  # ]:        222 : SV_IMPL_PERSIST1( SvClassElement, SvPersistBase );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
      31                 :            : 
      32                 :        222 : SvClassElement::SvClassElement()
      33                 :            : {
      34                 :        222 : };
      35                 :            : 
      36                 :          0 : void SvClassElement::Load( SvPersistStream & rStm )
      37                 :            : {
      38                 :            :     sal_uInt8 nMask;
      39         [ #  # ]:          0 :     rStm >> nMask;
      40         [ #  # ]:          0 :     if( nMask >= 0x08 )
      41                 :            :     {
      42         [ #  # ]:          0 :         rStm.SetError( SVSTREAM_FILEFORMAT_ERROR );
      43                 :            :         OSL_FAIL( "wrong format" );
      44                 :          0 :         return;
      45                 :            :     }
      46 [ #  # ][ #  # ]:          0 :     if( nMask & 0x01 ) rStm >> aAutomation;
      47 [ #  # ][ #  # ]:          0 :     if( nMask & 0x02 ) aPrefix = read_lenPrefixed_uInt8s_ToOString<sal_uInt16>(rStm);
      48         [ #  # ]:          0 :     if( nMask & 0x04 )
      49                 :            :     {
      50                 :            :         SvMetaClass * p;
      51         [ #  # ]:          0 :         rStm >> p;
      52         [ #  # ]:          0 :         xClass = p;
      53                 :            :     }
      54                 :            : }
      55                 :            : 
      56                 :        222 : void SvClassElement::Save( SvPersistStream & rStm )
      57                 :            : {
      58                 :            :     // create mask
      59                 :        222 :     sal_uInt8 nMask = 0;
      60         [ +  + ]:        222 :     if( aAutomation.IsSet() )       nMask |= 0x1;
      61         [ +  + ]:        222 :     if( !aPrefix.isEmpty() )        nMask |= 0x2;
      62         [ +  - ]:        222 :     if( xClass.Is() )               nMask |= 0x4;
      63                 :            : 
      64                 :            :     // write data
      65                 :        222 :     rStm << nMask;
      66         [ +  + ]:        222 :     if( nMask & 0x01 ) rStm << aAutomation;
      67         [ +  + ]:        222 :     if( nMask & 0x02 ) write_lenPrefixed_uInt8s_FromOString<sal_uInt16>(rStm, aPrefix);
      68         [ +  - ]:        222 :     if( nMask & 0x04 ) rStm << xClass;
      69                 :        222 : }
      70                 :            : 
      71 [ #  # ][ #  # ]:       1234 : SV_IMPL_META_FACTORY1( SvMetaClass, SvMetaType );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
      72                 :        386 : SvMetaClass::SvMetaClass()
      73 [ +  - ][ +  - ]:        386 :     : aAutomation( sal_True, sal_False )
      74                 :            : {
      75                 :        386 : }
      76                 :            : 
      77                 :          0 : void SvMetaClass::Load( SvPersistStream & rStm )
      78                 :            : {
      79         [ #  # ]:          0 :     SvMetaType::Load( rStm );
      80                 :            : 
      81                 :            :     sal_uInt8 nMask;
      82         [ #  # ]:          0 :     rStm >> nMask;
      83         [ #  # ]:          0 :     if( nMask >= 0x20 )
      84                 :            :     {
      85         [ #  # ]:          0 :         rStm.SetError( SVSTREAM_FILEFORMAT_ERROR );
      86                 :            :         OSL_FAIL( "wrong format" );
      87                 :          0 :         return;
      88                 :            :     }
      89 [ #  # ][ #  # ]:          0 :     if( nMask & 0x01 ) rStm >> aAttrList;
      90         [ #  # ]:          0 :     if( nMask & 0x02 )
      91                 :            :     {
      92                 :            :         SvMetaClass * pSuper;
      93         [ #  # ]:          0 :          rStm >> pSuper;
      94         [ #  # ]:          0 :         aSuperClass = pSuper;
      95                 :            :     }
      96 [ #  # ][ #  # ]:          0 :     if( nMask & 0x04 ) rStm >> aClassList;
      97         [ #  # ]:          0 :     if( nMask & 0x8 )
      98                 :            :     {
      99                 :            :         SvMetaClass * p;
     100         [ #  # ]:          0 :         rStm >> p;
     101         [ #  # ]:          0 :         xAutomationInterface = p;
     102                 :            :     }
     103 [ #  # ][ #  # ]:          0 :     if( nMask & 0x10 ) rStm >> aAutomation;
     104                 :            : }
     105                 :            : 
     106                 :        386 : void SvMetaClass::Save( SvPersistStream & rStm )
     107                 :            : {
     108                 :        386 :     SvMetaType::Save( rStm );
     109                 :            : 
     110                 :            :     // create mask
     111                 :        386 :     sal_uInt8 nMask = 0;
     112         [ +  + ]:        386 :     if( !aAttrList.empty() )        nMask |= 0x1;
     113         [ +  + ]:        386 :     if( aSuperClass.Is() )          nMask |= 0x2;
     114         [ +  + ]:        386 :     if( !aClassList.empty() )       nMask |= 0x4;
     115         [ +  + ]:        386 :     if( xAutomationInterface.Is() ) nMask |= 0x8;
     116         [ +  + ]:        386 :     if( aAutomation.IsSet() )       nMask |= 0x10;
     117                 :            : 
     118                 :            :     // write data
     119                 :        386 :     rStm << nMask;
     120         [ +  + ]:        386 :     if( nMask & 0x01 ) rStm << aAttrList;
     121         [ +  + ]:        386 :     if( nMask & 0x02 ) rStm << aSuperClass;
     122         [ +  + ]:        386 :     if( nMask & 0x04 ) rStm << aClassList;
     123         [ +  + ]:        386 :     if( nMask & 0x08 ) rStm << xAutomationInterface;
     124         [ +  + ]:        386 :     if( nMask & 0x10 ) rStm << aAutomation;
     125                 :        386 : }
     126                 :            : 
     127                 :        364 : void SvMetaClass::ReadAttributesSvIdl( SvIdlDataBase & rBase,
     128                 :            :                                         SvTokenStream & rInStm )
     129                 :            : {
     130                 :        364 :     SvMetaType::ReadAttributesSvIdl( rBase, rInStm );
     131                 :        364 :     aAutomation.ReadSvIdl( SvHash_Automation(), rInStm );
     132                 :        364 : }
     133                 :            : 
     134                 :        386 : void SvMetaClass::WriteAttributesSvIdl( SvIdlDataBase & rBase,
     135                 :            :                                  SvStream & rOutStm, sal_uInt16 nTab )
     136                 :            : {
     137                 :        386 :     SvMetaType::WriteAttributesSvIdl( rBase, rOutStm, nTab );
     138                 :            : 
     139         [ +  + ]:        386 :     if( !aAutomation )
     140                 :            :     {
     141                 :         46 :         WriteTab( rOutStm, nTab );
     142                 :         46 :         rOutStm << "//class SvMetaClass" << endl;
     143         [ +  - ]:         46 :         if( !aAutomation )
     144                 :            :         {
     145                 :         46 :             WriteTab( rOutStm, nTab );
     146                 :         46 :             aAutomation.WriteSvIdl( SvHash_Automation(), rOutStm );
     147                 :         46 :             rOutStm << ';' << endl;
     148                 :            :         }
     149                 :            :     }
     150                 :        386 : }
     151                 :            : 
     152                 :       8236 : void SvMetaClass::ReadContextSvIdl( SvIdlDataBase & rBase,
     153                 :            :                                     SvTokenStream & rInStm )
     154                 :            : {
     155                 :       8236 :     sal_uInt32  nTokPos = rInStm.Tell();
     156                 :       8236 :     SvToken * pTok = rInStm.GetToken_Next();
     157                 :            : 
     158         [ +  + ]:       8236 :     if( pTok->Is( SvHash_import() ) )
     159                 :            :     {
     160                 :        222 :         SvMetaClass * pClass = rBase.ReadKnownClass( rInStm );
     161         [ +  - ]:        222 :         if( pClass )
     162                 :            :         {
     163 [ +  - ][ +  - ]:        222 :             SvClassElementRef xEle = new SvClassElement();
     164         [ +  - ]:        222 :             xEle->SetClass( pClass );
     165         [ +  - ]:        222 :             aClassList.push_back( xEle );
     166                 :            : 
     167 [ +  - ][ +  + ]:        222 :             if( rInStm.Read( '[' ) )
     168                 :            :             {
     169         [ +  - ]:        122 :                 pTok = rInStm.GetToken_Next();
     170 [ +  - ][ +  - ]:        122 :                 if( pTok->Is( SvHash_Automation() ) )
     171                 :            :                 {
     172 [ +  - ][ +  - ]:        122 :                     if( rInStm.Read( ']' ) )
     173                 :            :                     {
     174         [ -  + ]:        122 :                         if( xAutomationInterface.Is() )
     175                 :            :                         {
     176                 :            :                             // set error
     177                 :            :                             rBase.SetError( "Automation allready set",
     178 [ #  # ][ #  # ]:          0 :                                             rInStm.GetToken() );
     179         [ #  # ]:          0 :                             rBase.WriteError( rInStm );
     180                 :            :                         }
     181         [ +  - ]:        122 :                         xAutomationInterface = pClass;
     182                 :        122 :                         xEle->SetAutomation( sal_True );
     183                 :            :                     }
     184                 :            :                     else
     185                 :            :                     {
     186                 :            :                         // set error
     187 [ #  # ][ #  # ]:          0 :                         rBase.SetError( "missing ]", rInStm.GetToken() );
     188         [ #  # ]:          0 :                         rBase.WriteError( rInStm );
     189                 :            :                     }
     190                 :            :                 }
     191                 :            :                 else
     192                 :            :                 {
     193                 :            :                     // set error
     194                 :            :                     rBase.SetError( "only attribute Automation allowed",
     195 [ #  # ][ #  # ]:          0 :                                     rInStm.GetToken() );
     196         [ #  # ]:          0 :                     rBase.WriteError( rInStm );
     197                 :            :                 }
     198                 :            :             }
     199         [ +  - ]:        222 :             pTok = rInStm.GetToken();
     200         [ +  + ]:        222 :             if( pTok->IsString() )
     201                 :            :             {
     202                 :         14 :                 xEle->SetPrefix( pTok->GetString() );
     203         [ +  - ]:         14 :                 rInStm.GetToken_Next();
     204                 :            :             }
     205         [ +  - ]:        222 :             return;
     206                 :            :         }
     207                 :            :         else
     208                 :            :         {
     209                 :            :             // set error
     210         [ #  # ]:          0 :             rBase.SetError( "unknown imported interface", rInStm.GetToken() );
     211                 :          0 :             rBase.WriteError( rInStm );
     212                 :            :         }
     213                 :            :     }
     214                 :            :     else
     215                 :            :     {
     216         [ +  - ]:       8014 :         rInStm.Seek( nTokPos );
     217         [ +  - ]:       8014 :         SvMetaType * pType = rBase.ReadKnownType( rInStm );
     218                 :            : 
     219                 :       8014 :         sal_Bool bOk = sal_False;
     220                 :       8014 :         SvMetaAttributeRef xAttr;
     221 [ +  + ][ +  + ]:       8014 :         if( !pType || pType->IsItem() )
                 [ +  + ]
     222                 :            :         {
     223 [ +  - ][ +  - ]:       7982 :             xAttr = new SvMetaSlot( pType );
                 [ +  - ]
     224 [ +  - ][ +  + ]:       7982 :             if( xAttr->ReadSvIdl( rBase, rInStm ) )
     225         [ +  - ]:       7596 :                 bOk = xAttr->Test( rBase, rInStm );
     226                 :            :         }
     227                 :            :         else
     228                 :            :         {
     229 [ +  - ][ +  - ]:         32 :             xAttr = new SvMetaAttribute( pType );
                 [ +  - ]
     230 [ +  - ][ +  - ]:         32 :             if( xAttr->ReadSvIdl( rBase, rInStm ) )
     231         [ +  - ]:         32 :                 bOk = xAttr->Test( rBase, rInStm );
     232                 :            :         }
     233                 :            : 
     234         [ +  + ]:       8014 :         if( bOk )
     235         [ +  - ]:       7628 :             bOk = TestAttribute( rBase, rInStm, *xAttr );
     236         [ +  + ]:       8014 :         if( bOk )
     237                 :            :         {
     238 [ +  - ][ +  + ]:       7628 :             if( !xAttr->GetSlotId().IsSet() )
     239                 :            :             {
     240                 :         10 :                 SvNumberIdentifier aI;
     241                 :         10 :                 aI.SetValue( rBase.GetUniqueId() );
     242                 :         10 :                 xAttr->SetSlotId( aI );
     243                 :            :             }
     244         [ +  - ]:       8014 :             aAttrList.push_back( xAttr );
     245                 :            :             return;
     246 [ +  - ][ +  + ]:       8014 :         }
     247                 :            :     }
     248                 :       8236 :     rInStm.Seek( nTokPos );
     249                 :            : }
     250                 :            : 
     251                 :        386 : void SvMetaClass::WriteContextSvIdl
     252                 :            : (
     253                 :            :     SvIdlDataBase & rBase,
     254                 :            :     SvStream & rOutStm,
     255                 :            :     sal_uInt16 nTab
     256                 :            : )
     257                 :            : {
     258                 :            :     sal_uLong n;
     259         [ +  + ]:       8014 :     for( n = 0; n < aAttrList.size(); n++ )
     260                 :            :     {
     261                 :       7628 :         WriteTab( rOutStm, nTab );
     262                 :       7628 :         aAttrList[n]->WriteSvIdl( rBase, rOutStm, nTab );
     263                 :       7628 :         rOutStm << ';' << endl;
     264                 :            :     }
     265         [ +  + ]:        608 :     for( n = 0; n < aClassList.size(); n++ )
     266                 :            :     {
     267                 :        222 :         SvClassElement * pEle = aClassList[n];
     268                 :        222 :         WriteTab( rOutStm, nTab );
     269                 :        222 :         rOutStm << SvHash_import()->GetName().getStr() << ' '
     270                 :        444 :                 << pEle->GetPrefix().getStr();
     271         [ +  + ]:        222 :         if( pEle->GetAutomation() )
     272                 :        122 :             rOutStm << " [ " << SvHash_Automation()->GetName().getStr()
     273                 :        122 :                     << " ]";
     274         [ +  + ]:        222 :         if( !pEle->GetPrefix().isEmpty() )
     275                 :         14 :             rOutStm << ' ' << pEle->GetPrefix().getStr();
     276                 :        222 :         rOutStm << ';' << endl;
     277                 :            :     }
     278                 :        386 : }
     279                 :            : 
     280                 :        386 : sal_Bool SvMetaClass::ReadSvIdl( SvIdlDataBase & rBase, SvTokenStream & rInStm )
     281                 :            : {
     282                 :        386 :     sal_uLong nTokPos = rInStm.Tell();
     283 [ +  - ][ +  - ]:        386 :     if( SvMetaType::ReadHeaderSvIdl( rBase, rInStm ) && GetType() == TYPE_CLASS )
                 [ +  - ]
     284                 :            :     {
     285                 :        386 :         sal_Bool bOk = sal_True;
     286         [ +  + ]:        386 :         if( rInStm.Read( ':' ) )
     287                 :            :         {
     288                 :        118 :             aSuperClass = rBase.ReadKnownClass( rInStm );
     289                 :        118 :             bOk = aSuperClass.Is();
     290         [ -  + ]:        118 :             if( !bOk )
     291                 :            :             {
     292                 :            :                 // set error
     293                 :            :                 rBase.SetError( "unknown super class",
     294         [ #  # ]:          0 :                                 rInStm.GetToken() );
     295                 :          0 :                 rBase.WriteError( rInStm );
     296                 :            :             }
     297                 :            :         }
     298         [ +  - ]:        386 :         if( bOk )
     299                 :            :         {
     300         [ +  - ]:        386 :             rBase.Write(rtl::OString('.'));
     301                 :        386 :             bOk = SvMetaName::ReadSvIdl( rBase, rInStm );
     302                 :            :         }
     303         [ +  - ]:        386 :         if( bOk )
     304                 :        386 :             return bOk;
     305                 :            :     }
     306                 :          0 :     rInStm.Seek( nTokPos );
     307                 :        386 :     return sal_False;
     308                 :            : }
     309                 :            : 
     310                 :       8334 : sal_Bool SvMetaClass::TestAttribute( SvIdlDataBase & rBase, SvTokenStream & rInStm,
     311                 :            :                                  SvMetaAttribute & rAttr ) const
     312                 :            : {
     313 [ +  + ][ -  + ]:       8334 :     if ( !rAttr.GetRef() && rAttr.IsA( TYPE( SvMetaSlot ) ) )
     314                 :            :     {
     315                 :            :         OSL_FAIL( "Neuer Slot : " );
     316                 :            :         OSL_FAIL( rAttr.GetSlotId().getString().getStr() );
     317                 :            :     }
     318                 :            : 
     319         [ +  + ]:     740664 :     for( sal_uLong n = 0; n < aAttrList.size(); n++ )
     320                 :            :     {
     321                 :     732330 :         SvMetaAttribute * pS = aAttrList[n];
     322         [ +  + ]:     732330 :         if( pS->GetName().getString() == rAttr.GetName().getString() )
     323                 :            :         {
     324                 :            :             // values have to match
     325         [ -  + ]:         20 :             if( pS->GetSlotId().GetValue() != rAttr.GetSlotId().GetValue() )
     326                 :            :             {
     327                 :            :                 OSL_FAIL( "Gleicher Name in MetaClass : " );
     328                 :            :                 OSL_FAIL( pS->GetName().getString().getStr() );
     329                 :            :                 OSL_FAIL( pS->GetSlotId().getString().getStr() );
     330                 :            :                 OSL_FAIL( rAttr.GetSlotId().getString().getStr() );
     331                 :            : 
     332         [ #  # ]:          0 :                 rtl::OStringBuffer aStr(RTL_CONSTASCII_STRINGPARAM("Attribute's "));
     333 [ #  # ][ #  # ]:          0 :                 aStr.append(pS->GetName().getString());
     334         [ #  # ]:          0 :                 aStr.append(RTL_CONSTASCII_STRINGPARAM(" with different id's"));
     335 [ #  # ][ #  # ]:          0 :                 rBase.SetError(aStr.makeStringAndClear(), rInStm.GetToken());
     336         [ #  # ]:          0 :                 rBase.WriteError( rInStm );
     337                 :          0 :                 return sal_False;
     338                 :            :              }
     339                 :            :         }
     340                 :            :         else
     341                 :            :         {
     342                 :     732310 :             sal_uInt32 nId1 = pS->GetSlotId().GetValue();
     343                 :     732310 :             sal_uInt32 nId2 = rAttr.GetSlotId().GetValue();
     344 [ #  # ][ -  + ]:     732310 :             if( nId1 == nId2 && nId1 != 0 )
     345                 :            :             {
     346                 :            :                 OSL_FAIL( "Gleiche Id in MetaClass : " );
     347                 :            :                 OSL_FAIL(rtl::OString::valueOf(static_cast<sal_Int32>(
     348                 :            :                     pS->GetSlotId().GetValue())).getStr());
     349                 :            :                 OSL_FAIL( pS->GetSlotId().getString().getStr() );
     350                 :            :                 OSL_FAIL( rAttr.GetSlotId().getString().getStr() );
     351                 :            : 
     352         [ #  # ]:          0 :                 rtl::OStringBuffer aStr(RTL_CONSTASCII_STRINGPARAM("Attribute "));
     353 [ #  # ][ #  # ]:          0 :                 aStr.append(pS->GetName().getString());
     354         [ #  # ]:          0 :                 aStr.append(RTL_CONSTASCII_STRINGPARAM(" and Attribute "));
     355 [ #  # ][ #  # ]:          0 :                 aStr.append(rAttr.GetName().getString());
     356         [ #  # ]:          0 :                 aStr.append(RTL_CONSTASCII_STRINGPARAM(" with equal id's"));
     357 [ #  # ][ #  # ]:          0 :                 rBase.SetError(aStr.makeStringAndClear(), rInStm.GetToken());
     358         [ #  # ]:          0 :                 rBase.WriteError( rInStm );
     359                 :          0 :                 return sal_False;
     360                 :            :              }
     361                 :            :         }
     362                 :            :     }
     363                 :       8334 :     SvMetaClass * pSC = aSuperClass;
     364         [ +  + ]:       8334 :     if( pSC )
     365                 :        706 :         return pSC->TestAttribute( rBase, rInStm, rAttr );
     366                 :       8334 :     return sal_True;
     367                 :            : }
     368                 :            : 
     369                 :        386 : void SvMetaClass::WriteSvIdl( SvIdlDataBase & rBase, SvStream & rOutStm,
     370                 :            :                               sal_uInt16 nTab )
     371                 :            : {
     372                 :        386 :     WriteHeaderSvIdl( rBase, rOutStm, nTab );
     373         [ +  + ]:        386 :     if( aSuperClass.Is() )
     374                 :        118 :         rOutStm << " : " << aSuperClass->GetName().getString().getStr();
     375                 :        386 :     rOutStm << endl;
     376                 :        386 :     SvMetaName::WriteSvIdl( rBase, rOutStm, nTab );
     377                 :        386 :     rOutStm << endl;
     378                 :        386 : }
     379                 :            : 
     380                 :          0 : void SvMetaClass::Write( SvIdlDataBase & rBase, SvStream & rOutStm,
     381                 :            :                         sal_uInt16 nTab,
     382                 :            :                          WriteType nT, WriteAttribute )
     383                 :            : {
     384                 :          0 :     rBase.aIFaceName = GetName().getString();
     385   [ #  #  #  # ]:          0 :     switch( nT )
     386                 :            :     {
     387                 :            :         case WRITE_ODL:
     388                 :            :         {
     389                 :            :             OSL_FAIL( "Not supported anymore!" );
     390                 :          0 :             break;
     391                 :            :         }
     392                 :            :         case WRITE_C_SOURCE:
     393                 :            :         case WRITE_C_HEADER:
     394                 :            :         {
     395                 :            :             OSL_FAIL( "Not supported anymore!" );
     396                 :          0 :             break;
     397                 :            :         }
     398                 :            :         case WRITE_DOCU:
     399                 :            :         {
     400                 :          0 :             rOutStm << "<INTERFACE>" << endl
     401                 :          0 :                     << GetName().getString().getStr();
     402         [ #  # ]:          0 :             if ( GetAutomation() )
     403                 :          0 :                 rOutStm << " ( Automation ) ";
     404                 :          0 :             rOutStm << endl;
     405                 :          0 :             WriteDescription( rOutStm );
     406                 :          0 :             rOutStm << "</INTERFACE>" << endl << endl;
     407                 :            : 
     408                 :            :             // write all attributes
     409                 :            :             sal_uLong n;
     410         [ #  # ]:          0 :             for( n = 0; n < aAttrList.size(); n++ )
     411                 :            :             {
     412                 :          0 :                 SvMetaAttribute * pAttr = aAttrList[n];
     413         [ #  # ]:          0 :                 if( !pAttr->GetHidden() )
     414                 :            :                 {
     415         [ #  # ]:          0 :                     if( pAttr->IsMethod() )
     416                 :          0 :                         pAttr->Write( rBase, rOutStm, nTab, nT, WA_METHOD );
     417                 :            : 
     418         [ #  # ]:          0 :                     if( pAttr->IsVariable() )
     419                 :          0 :                         pAttr->Write( rBase, rOutStm, nTab, nT, WA_VARIABLE );
     420                 :            :                 }
     421                 :            :             }
     422                 :            : 
     423                 :          0 :             break;
     424                 :            :         }
     425                 :            :         default:
     426                 :          0 :             break;
     427                 :            :     }
     428                 :          0 : }
     429                 :            : 
     430                 :        172 : sal_uInt16 SvMetaClass::WriteSlotParamArray( SvIdlDataBase & rBase,
     431                 :            :                                         SvSlotElementList & rSlotList,
     432                 :            :                                         SvStream & rOutStm )
     433                 :            : {
     434                 :        172 :     sal_uInt16 nCount = 0;
     435         [ +  + ]:      11126 :     for ( size_t i = 0, n = rSlotList.size(); i < n; ++i )
     436                 :            :     {
     437                 :      10954 :         SvSlotElement *pEle = rSlotList[ i ];
     438                 :      10954 :         SvMetaSlot *pAttr = pEle->xSlot;
     439                 :      10954 :         nCount = nCount + pAttr->WriteSlotParamArray( rBase, rOutStm );
     440                 :            :     }
     441                 :            : 
     442                 :        172 :     return nCount;
     443                 :            : }
     444                 :            : 
     445                 :        172 : sal_uInt16 SvMetaClass::WriteSlots( const rtl::OString& rShellName,
     446                 :            :                                 sal_uInt16 nCount, SvSlotElementList & rSlotList,
     447                 :            :                                 SvIdlDataBase & rBase,
     448                 :            :                                 SvStream & rOutStm )
     449                 :            : {
     450                 :        172 :     sal_uInt16 nSCount = 0;
     451         [ +  + ]:      11126 :     for ( size_t i = 0, n = rSlotList.size(); i < n; ++i )
     452                 :            :     {
     453                 :      10954 :         SvSlotElement * pEle = rSlotList[ i ];
     454                 :      10954 :         SvMetaSlot * pAttr = pEle->xSlot;
     455                 :            :         nSCount = nSCount + pAttr->WriteSlotMap( rShellName, nCount + nSCount,
     456                 :            :                                         rSlotList, i, pEle->aPrefix, rBase,
     457                 :      10954 :                                         rOutStm );
     458                 :            :     }
     459                 :            : 
     460                 :        172 :     return nSCount;
     461                 :            : }
     462                 :            : 
     463                 :        426 : void SvMetaClass::InsertSlots( SvSlotElementList& rList, std::vector<sal_uLong>& rSuperList,
     464                 :            :                             SvMetaClassList &rClassList,
     465                 :            :                             const rtl::OString& rPrefix, SvIdlDataBase& rBase)
     466                 :            : {
     467                 :            :     // was this class already written?
     468         [ +  + ]:       1116 :     for ( size_t i = 0, n = rClassList.size(); i < n ; ++i )
     469         [ +  + ]:        724 :         if ( rClassList[ i ] == this )
     470                 :        426 :             return;
     471                 :            : 
     472         [ +  - ]:        392 :     rClassList.push_back( this );
     473                 :            : 
     474                 :            :     // write all direct attributes
     475                 :            :     sal_uLong n;
     476         [ +  + ]:      11266 :     for( n = 0; n < aAttrList.size(); n++ )
     477                 :            :     {
     478                 :      10874 :         SvMetaAttribute * pAttr = aAttrList[n];
     479                 :            : 
     480         [ +  - ]:      10874 :         sal_uLong nId = pAttr->GetSlotId().GetValue();
     481                 :            : 
     482                 :            :         std::vector<sal_uLong>::iterator iter = std::find(rSuperList.begin(),
     483         [ +  - ]:      10874 :                                                       rSuperList.end(),nId);
     484                 :            : 
     485 [ +  - ][ +  + ]:      10874 :         if( iter == rSuperList.end() )
     486                 :            :         {
     487                 :            :             // Write only if not already written by subclass or
     488                 :            :             // imported interface.
     489         [ +  - ]:      10836 :             rSuperList.push_back(nId);
     490         [ +  - ]:      10836 :             pAttr->Insert(rList, rPrefix, rBase);
     491                 :            :         }
     492                 :            :     }
     493                 :            : 
     494                 :            :     // All Interfaces already imported by SuperShells should not be
     495                 :            :     // written any more.
     496                 :            :     // It is prohibited that Shell and SuperShell directly import the same
     497                 :            :     //class.
     498 [ +  + ][ +  + ]:        392 :     if( IsShell() && aSuperClass.Is() )
                 [ +  + ]
     499                 :         54 :         aSuperClass->FillClasses( rClassList );
     500                 :            : 
     501                 :            :     // Write all attributes of the imported classes, as long as they have
     502                 :            :     // not already been imported by the superclass.
     503         [ +  + ]:        578 :     for( n = 0; n < aClassList.size(); n++ )
     504                 :            :     {
     505                 :        186 :         SvClassElement * pEle = aClassList[n];
     506                 :        186 :         SvMetaClass * pCl = pEle->GetClass();
     507         [ +  - ]:        186 :         rtl::OStringBuffer rPre(rPrefix);
     508 [ #  # ][ -  + ]:        186 :         if( rPre.getLength() && pEle->GetPrefix().getLength() )
                 [ -  + ]
     509         [ #  # ]:          0 :             rPre.append('.');
     510         [ +  - ]:        186 :         rPre.append(pEle->GetPrefix());
     511                 :            : 
     512                 :            :         // first of all write direct imported interfaces
     513                 :            :         pCl->InsertSlots( rList, rSuperList, rClassList,
     514         [ +  - ]:        186 :             rPre.makeStringAndClear(), rBase );
     515                 :        186 :     }
     516                 :            : 
     517                 :            :     // only write superclass if no shell and not in the list
     518 [ +  + ][ +  + ]:        392 :     if( !IsShell() && aSuperClass.Is() )
                 [ +  + ]
     519                 :            :     {
     520                 :         68 :         aSuperClass->InsertSlots( rList, rSuperList, rClassList, rPrefix, rBase );
     521                 :            :     }
     522                 :            : }
     523                 :            : 
     524                 :        192 : void SvMetaClass::FillClasses( SvMetaClassList & rList )
     525                 :            : {
     526                 :            :     // Am I not yet in?
     527         [ +  + ]:        666 :     for ( size_t i = 0, n = rList.size(); i < n; ++i )
     528         [ +  + ]:        484 :         if ( rList[ i ] == this )
     529                 :        192 :             return;
     530                 :            : 
     531         [ +  - ]:        182 :     rList.push_back( this );
     532                 :            : 
     533                 :            :     // my imports
     534         [ +  + ]:        258 :     for( sal_uInt32 n = 0; n < aClassList.size(); n++ )
     535                 :            :     {
     536                 :         76 :         SvClassElement * pEle = aClassList[n];
     537                 :         76 :         SvMetaClass * pCl = pEle->GetClass();
     538                 :         76 :         pCl->FillClasses( rList );
     539                 :            :     }
     540                 :            : 
     541                 :            :     // my superclass
     542         [ +  + ]:        182 :     if( aSuperClass.Is() )
     543                 :         62 :         aSuperClass->FillClasses( rList );
     544                 :            : }
     545                 :            : 
     546                 :            : 
     547                 :        172 : void SvMetaClass::WriteSlotStubs( const rtl::OString& rShellName,
     548                 :            :                                 SvSlotElementList & rSlotList,
     549                 :            :                                 ByteStringList & rList,
     550                 :            :                                 SvStream & rOutStm )
     551                 :            : {
     552                 :            :     // write all attributes
     553         [ +  + ]:      11126 :     for ( size_t i = 0, n = rSlotList.size(); i < n; ++i )
     554                 :            :     {
     555                 :      10954 :         SvSlotElement *pEle = rSlotList[ i ];
     556                 :      10954 :         SvMetaSlot *pAttr = pEle->xSlot;
     557                 :      10954 :         pAttr->WriteSlotStubs( rShellName, rList, rOutStm );
     558                 :            :     }
     559                 :        172 : }
     560                 :            : 
     561                 :        386 : void SvMetaClass::WriteSfx( SvIdlDataBase & rBase, SvStream & rOutStm )
     562                 :            : {
     563         [ +  - ]:        386 :     WriteStars( rOutStm );
     564                 :            :     // define class
     565 [ +  - ][ +  - ]:        386 :     rOutStm << "#ifdef " << GetName().getString().getStr() << endl;
         [ +  - ][ +  - ]
     566 [ +  - ][ +  - ]:        386 :     rOutStm << "#undef ShellClass" << endl;
     567 [ +  - ][ +  - ]:        386 :     rOutStm << "#undef " << GetName().getString().getStr() << endl;
         [ +  - ][ +  - ]
     568 [ +  - ][ +  - ]:        386 :     rOutStm << "#define ShellClass " << GetName().getString().getStr() << endl;
         [ +  - ][ +  - ]
     569                 :            : 
     570                 :            :     // no slotmaps get written for interfaces
     571         [ +  + ]:        386 :     if( !IsShell() )
     572                 :            :     {
     573 [ +  - ][ +  - ]:        214 :         rOutStm << "#endif" << endl << endl;
                 [ +  - ]
     574                 :        386 :         return;
     575                 :            :     }
     576                 :            :     // write parameter array
     577 [ +  - ][ +  - ]:        172 :     rOutStm << "SFX_ARGUMENTMAP(" << GetName().getString().getStr() << ')' << endl
         [ +  - ][ +  - ]
                 [ +  - ]
     578 [ +  - ][ +  - ]:        172 :         << '{' << endl;
     579                 :            : 
     580         [ +  - ]:        172 :     std::vector<sal_uLong> aSuperList;
     581         [ +  - ]:        172 :     SvMetaClassList classList;
     582         [ +  - ]:        172 :     SvSlotElementList aSlotList;
     583         [ +  - ]:        172 :     InsertSlots(aSlotList, aSuperList, classList, rtl::OString(), rBase);
     584         [ +  + ]:      11126 :     for ( size_t i = 0, n = aSlotList.size(); i < n; ++i )
     585                 :            :     {
     586                 :      10954 :         SvSlotElement *pEle = aSlotList[ i ];
     587                 :      10954 :         SvMetaSlot *pSlot = pEle->xSlot;
     588                 :      10954 :         pSlot->SetListPos( i );
     589                 :            :     }
     590                 :            : 
     591                 :        172 :     size_t nSlotCount = aSlotList.size();
     592                 :            : 
     593                 :            :     // write all attributes
     594         [ +  - ]:        172 :     sal_uInt16 nArgCount = WriteSlotParamArray( rBase, aSlotList, rOutStm );
     595         [ +  + ]:        172 :     if( nArgCount )
     596         [ +  - ]:        124 :         Back2Delemitter( rOutStm );
     597                 :            :     else
     598                 :            :     {
     599                 :            :         // at leaast one dummy
     600         [ +  - ]:         48 :         WriteTab( rOutStm, 1 );
     601 [ +  - ][ +  - ]:         48 :         rOutStm << "SFX_ARGUMENT( 0, 0, SfxVoidItem )" << endl;
     602                 :            :     }
     603 [ +  - ][ +  - ]:        172 :     rOutStm << endl << "};" << endl << endl;
         [ +  - ][ +  - ]
     604                 :            : 
     605         [ +  - ]:        172 :     ByteStringList aStringList;
     606 [ +  - ][ +  - ]:        172 :     WriteSlotStubs( GetName().getString(), aSlotList, aStringList, rOutStm );
     607         [ +  + ]:       1378 :     for ( size_t i = 0, n = aStringList.size(); i < n; ++i )
     608         [ +  - ]:       1206 :         delete aStringList[ i ];
     609                 :        172 :     aStringList.clear();
     610                 :            : 
     611         [ +  - ]:        172 :     rOutStm << endl;
     612                 :            : 
     613                 :            :     // write slotmap
     614 [ +  - ][ +  - ]:        172 :     rOutStm << "SFX_SLOTMAP_ARG(" << GetName().getString().getStr() << ')' << endl
         [ +  - ][ +  - ]
                 [ +  - ]
     615 [ +  - ][ +  - ]:        172 :         << '{' << endl;
     616                 :            : 
     617                 :            :     // write all attributes
     618 [ +  - ][ +  - ]:        172 :     WriteSlots( GetName().getString(), 0, aSlotList, rBase, rOutStm );
     619         [ +  + ]:        172 :     if( nSlotCount )
     620         [ +  - ]:        154 :         Back2Delemitter( rOutStm );
     621                 :            :     else
     622                 :            :     {
     623                 :            :         // at least one dummy
     624         [ +  - ]:         18 :         WriteTab( rOutStm, 1 );
     625 [ +  - ][ +  - ]:         18 :         rOutStm << "SFX_SLOT_ARG(" << GetName().getString().getStr()
                 [ +  - ]
     626         [ +  - ]:         18 :                 << ", 0, 0, "
     627         [ +  - ]:         18 :                 << "SFX_STUB_PTR_EXEC_NONE,"
     628         [ +  - ]:         18 :                 << "SFX_STUB_PTR_STATE_NONE,"
     629 [ +  - ][ +  - ]:         18 :                 << "0, SfxVoidItem, 0, 0, \"\", 0 )" << endl;
     630                 :            :     }
     631 [ +  - ][ +  - ]:        172 :     rOutStm << endl << "};" << endl << "#endif" << endl << endl;
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     632                 :            : 
     633         [ +  + ]:      11126 :     for( size_t i = 0, n = aSlotList.size(); i < n; ++i )
     634                 :            :     {
     635                 :      10954 :         SvSlotElement* pEle = aSlotList[ i ];
     636                 :      10954 :         SvMetaSlot* pAttr = pEle->xSlot;
     637                 :      10954 :         pAttr->ResetSlotPointer();
     638                 :            :     }
     639                 :            : 
     640         [ +  + ]:      11126 :     for( size_t i = 0, n = aSlotList.size(); i < n; ++i )
     641 [ +  - ][ +  - ]:      10954 :         delete aSlotList[ i ];
     642                 :        386 :     aSlotList.clear();
     643                 :            : }
     644                 :            : 
     645                 :        386 : void SvMetaClass::WriteHelpIds( SvIdlDataBase & rBase, SvStream & rOutStm,
     646                 :            :                             HelpIdTable& rTable )
     647                 :            : {
     648         [ +  + ]:       8014 :     for( sal_uLong n=0; n<aAttrList.size(); n++ )
     649                 :            :     {
     650                 :       7628 :         SvMetaAttribute * pAttr = aAttrList[n];
     651                 :       7628 :         pAttr->WriteHelpId( rBase, rOutStm, rTable );
     652                 :            :     }
     653                 :        386 : }
     654                 :            : 
     655                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10