LCOV - code coverage report
Current view: top level - rsc/source/tools - rscdef.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 97 362 26.8 %
Date: 2012-08-25 Functions: 21 53 39.6 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 49 310 15.8 %

           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                 :            : /****************** I N C L U D E S **************************************/
      21                 :            : 
      22                 :            : // Programmuebergreifende Includes.
      23                 :            : #include <rscdef.hxx>
      24                 :            : 
      25                 :            : /****************** C o d e **********************************************/
      26                 :            : /****************** R s c I d ********************************************/
      27                 :            : sal_Bool RscId::bNames = sal_True;
      28                 :            : 
      29                 :            : /*************************************************************************
      30                 :            : |*
      31                 :            : |*    static RscId::SetNames
      32                 :            : |*    static RscId::SetNoNames
      33                 :            : |*
      34                 :            : *************************************************************************/
      35                 :       2640 : void RscId::SetNames( sal_Bool bSet )  { bNames = bSet;  }
      36                 :            : 
      37                 :            : /*************************************************************************
      38                 :            : |*
      39                 :            : |*    RscId::GetNumber
      40                 :            : |*
      41                 :            : *************************************************************************/
      42                 :    4808574 : sal_Int32 RscId::GetNumber() const{
      43                 :            :     sal_Int32 lVal;
      44         [ +  - ]:    4808574 :     aExp.Evaluate( &lVal );
      45                 :    4808574 :     return lVal;
      46                 :            : }
      47                 :            : 
      48                 :            : /*************************************************************************
      49                 :            : |*
      50                 :            : |*    RscId::Create()
      51                 :            : |*
      52                 :            : *************************************************************************/
      53                 :      42476 : void RscId::Create( const RscExpType & rExpType )
      54                 :            : {
      55                 :      42476 :     aExp = rExpType;
      56         [ -  + ]:      42476 :     if( aExp.IsDefinition() )
      57                 :          0 :         aExp.aExp.pDef->IncRef();
      58         [ -  + ]:      42476 :     else if( aExp.IsExpression() ){
      59                 :            :         sal_Int32 lValue;
      60                 :            : 
      61         [ #  # ]:          0 :         aExp.Evaluate( &lValue );
      62                 :          0 :         aExp.SetLong( lValue );
      63                 :            :     }
      64                 :      42476 : }
      65                 :            : 
      66                 :            : /*************************************************************************
      67                 :            : |*
      68                 :            : |*    RscId::Destroy()
      69                 :            : |*
      70                 :            : *************************************************************************/
      71                 :    2232796 : void RscId::Destroy(){
      72         [ -  + ]:    2232796 :     if( aExp.IsDefinition() )
      73                 :          0 :         aExp.aExp.pDef->DecRef();
      74                 :    2232796 :     aExp.cType = RSCEXP_NOTHING;
      75                 :    2232796 : }
      76                 :            : 
      77                 :            : /*************************************************************************
      78                 :            : |*
      79                 :            : |*    RscId::RscId()
      80                 :            : |*
      81                 :            : *************************************************************************/
      82                 :      36744 : RscId::RscId( const RscId& rRscId ){
      83                 :      36744 :     aExp = rRscId.aExp;
      84         [ -  + ]:      36744 :     if( aExp.IsDefinition() )
      85                 :          0 :         aExp.aExp.pDef->IncRef();
      86                 :      36744 : }
      87                 :            : 
      88                 :            : /*************************************************************************
      89                 :            : |*
      90                 :            : |*    RscId::RscId()
      91                 :            : |*
      92                 :            : *************************************************************************/
      93                 :          0 : RscId::RscId( RscDefine * pDef ){
      94                 :            :     RscExpType aExpType;
      95                 :            : 
      96                 :          0 :     aExpType.aExp.pDef = pDef;
      97                 :          0 :     aExpType.cType = RSCEXP_DEF;
      98         [ #  # ]:          0 :     Create( aExpType );
      99                 :          0 : }
     100                 :            : 
     101                 :            : /*************************************************************************
     102                 :            : |*
     103                 :            : |*    RscId:: =
     104                 :            : |*
     105                 :            : *************************************************************************/
     106                 :     366176 : RscId& RscId::operator = ( const RscId& rRscId ){
     107         [ -  + ]:     366176 :     if( rRscId.aExp.IsDefinition() )
     108                 :          0 :         rRscId.aExp.aExp.pDef->IncRef();
     109                 :     366176 :     Destroy();
     110                 :     366176 :     aExp = rRscId.aExp;
     111                 :     366176 :     return *this;
     112                 :            : }
     113                 :            : 
     114                 :            : /*************************************************************************
     115                 :            : |*
     116                 :            : |*    RscId::operator ==
     117                 :            : |*
     118                 :            : *************************************************************************/
     119                 :    1812242 : sal_Bool RscId::operator == ( const RscId& rRscId ) const
     120                 :            : {
     121                 :    1812242 :     return( GetNumber() == rRscId.GetNumber() );
     122                 :            : }
     123                 :            : 
     124                 :            : /*************************************************************************
     125                 :            : |*
     126                 :            : |*    RscId::operator <
     127                 :            : |*
     128                 :            : *************************************************************************/
     129                 :          0 : sal_Bool RscId::operator < ( const RscId& rRscId ) const
     130                 :            : {
     131                 :          0 :     return( GetNumber() < rRscId.GetNumber() );
     132                 :            : }
     133                 :            : 
     134                 :            : /*************************************************************************
     135                 :            : |*
     136                 :            : |*    RscId::operator >
     137                 :            : |*
     138                 :            : *************************************************************************/
     139                 :          0 : sal_Bool RscId::operator > ( const RscId& rRscId ) const
     140                 :            : {
     141                 :          0 :     return( GetNumber() > rRscId.GetNumber() );
     142                 :            : }
     143                 :            : 
     144                 :            : /*************************************************************************
     145                 :            : |*
     146                 :            : |*    RscId::sal_Int32()
     147                 :            : |*
     148                 :            : *************************************************************************/
     149                 :    1087270 : RscId::operator sal_Int32() const
     150                 :            : {
     151                 :    1087270 :     return( GetNumber() );
     152                 :            : }
     153                 :            : 
     154                 :            : /*************************************************************************
     155                 :            : |*
     156                 :            : |*    RscId::GetNames()
     157                 :            : |*
     158                 :            : *************************************************************************/
     159                 :      74614 : rtl::OString RscId::GetName() const
     160                 :            : {
     161                 :      74614 :     rtl::OStringBuffer aStr;
     162                 :            : 
     163         [ +  + ]:      74614 :     if ( !aExp.IsNothing() )
     164                 :            :     {
     165         [ -  + ]:      62746 :         if( bNames )
     166         [ #  # ]:          0 :             aExp.AppendMacro(aStr);
     167                 :            :         else
     168 [ +  - ][ +  - ]:      62746 :             aStr.append(GetNumber());
     169                 :            :     }
     170                 :            : 
     171                 :      74614 :     return aStr.makeStringAndClear();
     172                 :            : }
     173                 :            : 
     174                 :            : /****************** R s c D e f i n e ************************************/
     175                 :            : /*************************************************************************
     176                 :            : |*
     177                 :            : |*    RscDefine::RscDefine()
     178                 :            : |*
     179                 :            : *************************************************************************/
     180                 :          0 : RscDefine::RscDefine( sal_uLong lKey, const rtl::OString& rDefName, sal_Int32 lDefId )
     181                 :          0 :     : StringNode( rDefName )
     182                 :            : {
     183                 :          0 :     nRefCount = 0;
     184                 :          0 :     lFileKey  = lKey;
     185                 :          0 :     lId       = lDefId;
     186                 :          0 :     pExp      = NULL;
     187                 :          0 : }
     188                 :            : 
     189                 :          0 : RscDefine::RscDefine( sal_uLong lKey, const rtl::OString& rDefName,
     190                 :            :                       RscExpression * pExpression  )
     191                 :          0 :     : StringNode( rDefName )
     192                 :            : {
     193                 :          0 :     nRefCount = 0;
     194                 :          0 :     lFileKey  = lKey;
     195         [ #  # ]:          0 :     pExpression->Evaluate( &lId );
     196                 :          0 :     pExp      = pExpression;
     197                 :          0 : }
     198                 :            : 
     199                 :            : /*************************************************************************
     200                 :            : |*
     201                 :            : |*    RscDefine::~RscDefine()
     202                 :            : |*
     203                 :            : *************************************************************************/
     204                 :          0 : RscDefine::~RscDefine(){
     205         [ #  # ]:          0 :     if( pExp )
     206 [ #  # ][ #  # ]:          0 :         delete pExp;
     207         [ #  # ]:          0 :     if( nRefCount )
     208         [ #  # ]:          0 :         RscExit( 14 );
     209         [ #  # ]:          0 : }
     210                 :            : 
     211                 :            : /*************************************************************************
     212                 :            : |*
     213                 :            : |*    RscDefine::DecRef()
     214                 :            : |*
     215                 :            : *************************************************************************/
     216                 :          0 : void RscDefine::DecRef(){
     217                 :          0 :     nRefCount--;
     218         [ #  # ]:          0 :     if( 0 == nRefCount ){
     219         [ #  # ]:          0 :         delete this;
     220                 :            :     }
     221                 :          0 : }
     222                 :            : 
     223                 :            : /*************************************************************************
     224                 :            : |*
     225                 :            : |*    RscDefine::DefineToNumber()
     226                 :            : |*
     227                 :            : *************************************************************************/
     228                 :          0 : void RscDefine::DefineToNumber()
     229                 :            : {
     230         [ #  # ]:          0 :     if( pExp )
     231         [ #  # ]:          0 :         delete pExp;
     232                 :          0 :     pExp = NULL;
     233                 :          0 :     SetName(rtl::OString::valueOf(lId));
     234                 :          0 : }
     235                 :            : 
     236                 :            : /*************************************************************************
     237                 :            : |*
     238                 :            : |*    RscDefine::Evaluate()
     239                 :            : |*
     240                 :            : *************************************************************************/
     241                 :          0 : sal_Bool RscDefine::Evaluate(){
     242                 :          0 :     sal_Bool    bRet = sal_True;
     243                 :            : 
     244         [ #  # ]:          0 :     if( pExp )
     245                 :          0 :         bRet = !pExp->Evaluate( &lId );
     246                 :            : 
     247                 :          0 :     return bRet;
     248                 :            : }
     249                 :            : 
     250                 :            : /*************************************************************************
     251                 :            : |*
     252                 :            : |*    RscDefine::Search()
     253                 :            : |*
     254                 :            : *************************************************************************/
     255                 :          0 : RscDefine * RscDefine::Search( const char * pStr ){
     256                 :          0 :     return (RscDefine *)StringNode::Search( pStr );
     257                 :            : }
     258                 :            : 
     259                 :            : /*************************************************************************
     260                 :            : |*
     261                 :            : |*    RscDefine::GetMacro()
     262                 :            : |*
     263                 :            : *************************************************************************/
     264                 :          0 : rtl::OString RscDefine::GetMacro()
     265                 :            : {
     266         [ #  # ]:          0 :     if( pExp )
     267                 :          0 :         return pExp->GetMacro();
     268                 :          0 :     return rtl::OString::valueOf(lId);
     269                 :            : }
     270                 :            : 
     271                 :            : /****************** R s c D e f i n e L i s t ****************************/
     272                 :            : /*************************************************************************
     273                 :            : |*
     274                 :            : |*    RscDefineList::New()
     275                 :            : |*
     276                 :            : *************************************************************************/
     277                 :          0 : RscDefine * RscDefineList::New( sal_uLong lFileKey, const rtl::OString& rDefName,
     278                 :            :                                 sal_Int32 lDefId, size_t lPos )
     279                 :            : {
     280                 :            :     RscDefine * pDef;
     281                 :            : 
     282 [ #  # ][ #  # ]:          0 :     pDef = new RscDefine( lFileKey, rDefName, lDefId );
     283                 :          0 :     pDef->IncRef();
     284         [ #  # ]:          0 :     if ( lPos < maList.size() )
     285                 :            :     {
     286                 :          0 :         RscSubDefList::iterator it = maList.begin();
     287         [ #  # ]:          0 :         ::std::advance( it, lPos );
     288         [ #  # ]:          0 :         maList.insert( it, pDef );
     289                 :            :     } else {
     290         [ #  # ]:          0 :         maList.push_back( pDef );
     291                 :            :     }
     292                 :          0 :     return pDef;
     293                 :            : }
     294                 :            : 
     295                 :          0 : RscDefine * RscDefineList::New( sal_uLong lFileKey, const rtl::OString& rDefName,
     296                 :            :                                 RscExpression * pExpression, size_t lPos )
     297                 :            : {
     298                 :            :     RscDefine * pDef;
     299                 :            : 
     300 [ #  # ][ #  # ]:          0 :     pDef = new RscDefine( lFileKey, rDefName, pExpression );
     301                 :          0 :     pDef->IncRef();
     302         [ #  # ]:          0 :     if ( lPos < maList.size() )
     303                 :            :     {
     304                 :          0 :         RscSubDefList::iterator it = maList.begin();
     305         [ #  # ]:          0 :         ::std::advance( it, lPos );
     306         [ #  # ]:          0 :         maList.insert( it, pDef );
     307                 :            :     } else {
     308         [ #  # ]:          0 :         maList.push_back( pDef );
     309                 :            :     }
     310                 :          0 :     return pDef;
     311                 :            : }
     312                 :            : 
     313                 :       2886 : sal_Bool RscDefineList::Remove() {
     314         [ +  - ]:       2886 :     if ( maList.empty() )
     315                 :       2886 :         return sal_False;
     316                 :            : 
     317                 :          0 :     maList[ 0 ]->DefineToNumber();
     318                 :          0 :     maList[ 0 ]->DecRef();
     319                 :          0 :     maList.erase( maList.begin() );
     320                 :       2886 :     return sal_True;
     321                 :            : }
     322                 :            : 
     323                 :            : /*************************************************************************
     324                 :            : |*
     325                 :            : |*    RscDefineList::WriteAll()
     326                 :            : |*
     327                 :            : *************************************************************************/
     328                 :          0 : void RscDefineList::WriteAll( FILE * fOutput )
     329                 :            : {
     330         [ #  # ]:          0 :     for ( size_t i = 0, n = maList.size(); i < n; ++i ) {
     331                 :          0 :         RscDefine* pDefEle = maList[ i ];
     332                 :            :         fprintf( fOutput, "#define %s %s\n",
     333                 :            :                  pDefEle->GetName().getStr(),
     334                 :            :                  pDefEle->GetMacro().getStr()
     335         [ #  # ]:          0 :         );
     336                 :            :     };
     337                 :          0 : }
     338                 :            : 
     339                 :            : /****************** R s c E x p T y p e **********************************/
     340                 :            : /*************************************************************************
     341                 :            : |*
     342                 :            : |*    RscExpType::Evaluate()
     343                 :            : |*
     344                 :            : *************************************************************************/
     345                 :    5107634 : sal_Bool RscExpType::Evaluate( sal_Int32 * plValue ) const{
     346         [ -  + ]:    5107634 :     if( IsDefinition() ){
     347                 :          0 :         aExp.pDef->Evaluate();
     348                 :            :         // Eventuellen Fehler ignorieren
     349                 :          0 :         *plValue = aExp.pDef->GetNumber();
     350                 :            :     }
     351         [ -  + ]:    5107634 :     else if( IsExpression() )
     352                 :          0 :         return( aExp.pExp->Evaluate( plValue ) );
     353         [ +  + ]:    5107634 :     else if( IsNothing() )
     354                 :      29654 :         *plValue = 0;
     355                 :            :     else
     356                 :    5077980 :         *plValue = GetLong();
     357                 :            : 
     358                 :    5107634 :     return sal_True;
     359                 :            : }
     360                 :            : 
     361                 :          0 : void RscExpType::AppendMacro(rtl::OStringBuffer& rStr) const
     362                 :            : {
     363         [ #  # ]:          0 :     if( IsDefinition() )
     364         [ #  # ]:          0 :         rStr.append(aExp.pDef->GetName());
     365         [ #  # ]:          0 :     else if( IsExpression() )
     366         [ #  # ]:          0 :         rStr.append(aExp.pExp->GetMacro());
     367         [ #  # ]:          0 :     else if( IsNumber() )
     368                 :          0 :         rStr.append(GetLong());
     369                 :          0 : }
     370                 :            : 
     371                 :            : 
     372                 :            : /****************** R s c E x p r e s s i o n ****************************/
     373                 :            : /*************************************************************************
     374                 :            : |*
     375                 :            : |*    RscExpression::RscExpression()
     376                 :            : |*
     377                 :            : *************************************************************************/
     378                 :          0 : RscExpression::RscExpression( RscExpType aLE, char cOp, RscExpType aRE )
     379                 :            : {
     380                 :          0 :     aLeftExp   = aLE;
     381                 :          0 :     cOperation = cOp;
     382                 :          0 :     aRightExp  = aRE;
     383         [ #  # ]:          0 :     if( aLeftExp.IsDefinition() )
     384                 :          0 :         aLeftExp.aExp.pDef->IncRef();
     385         [ #  # ]:          0 :     if( aRightExp.IsDefinition() )
     386                 :          0 :         aRightExp.aExp.pDef->IncRef();
     387                 :          0 : }
     388                 :            : 
     389                 :            : /*************************************************************************
     390                 :            : |*
     391                 :            : |*    RscExpression::~RscExpression()
     392                 :            : |*
     393                 :            : *************************************************************************/
     394                 :          0 : RscExpression::~RscExpression(){
     395         [ #  # ]:          0 :     if( aLeftExp.IsDefinition() )
     396                 :          0 :         aLeftExp.aExp.pDef->DecRef();
     397         [ #  # ]:          0 :     else if( aLeftExp.IsExpression() )
     398         [ #  # ]:          0 :         delete aLeftExp.aExp.pExp;
     399                 :            : 
     400         [ #  # ]:          0 :     if( aRightExp.IsDefinition() )
     401                 :          0 :         aRightExp.aExp.pDef->DecRef();
     402         [ #  # ]:          0 :     else if( aRightExp.IsExpression() )
     403         [ #  # ]:          0 :         delete aRightExp.aExp.pExp;
     404                 :          0 : }
     405                 :            : 
     406                 :            : /*************************************************************************
     407                 :            : |*
     408                 :            : |*    RscExpression::Evaluate()
     409                 :            : |*
     410                 :            : *************************************************************************/
     411                 :          0 : sal_Bool RscExpression::Evaluate( sal_Int32 * plValue ){
     412                 :            :     sal_Int32 lLeft;
     413                 :            :     sal_Int32 lRight;
     414                 :            : 
     415                 :            :     // linken und rechten Zweig auswerten
     416 [ #  # ][ #  # ]:          0 :     if( aLeftExp.Evaluate( &lLeft ) && aRightExp.Evaluate( &lRight ) ){
         [ #  # ][ #  # ]
                 [ #  # ]
     417         [ #  # ]:          0 :         if( cOperation == '&' )
     418                 :          0 :             *plValue = lLeft & lRight;
     419         [ #  # ]:          0 :         else if( cOperation == '|' )
     420                 :          0 :             *plValue = lLeft | lRight;
     421         [ #  # ]:          0 :         else if( cOperation == '+' )
     422                 :          0 :             *plValue = lLeft + lRight;
     423         [ #  # ]:          0 :         else if( cOperation == '-' )
     424                 :          0 :             *plValue = lLeft - lRight;
     425         [ #  # ]:          0 :         else if( cOperation == '*' )
     426                 :          0 :             *plValue = lLeft * lRight;
     427         [ #  # ]:          0 :         else if( cOperation == 'r' )
     428                 :          0 :             *plValue = lLeft >> lRight;
     429         [ #  # ]:          0 :         else if( cOperation == 'l' )
     430                 :          0 :             *plValue = lLeft << lRight;
     431                 :            :         else{
     432         [ #  # ]:          0 :             if( 0L == lRight )
     433                 :          0 :                 return sal_False;
     434                 :          0 :             *plValue = lLeft / lRight;
     435                 :            :         };
     436                 :          0 :         return sal_True;
     437                 :            :     }
     438                 :          0 :     return sal_False;
     439                 :            : }
     440                 :            : 
     441                 :            : /*************************************************************************
     442                 :            : |*
     443                 :            : |*    RscExpression::GetMacro()
     444                 :            : |*
     445                 :            : *************************************************************************/
     446                 :          0 : rtl::OString RscExpression::GetMacro()
     447                 :            : {
     448                 :          0 :     rtl::OStringBuffer aLeft;
     449                 :            : 
     450                 :            :     // Ausgabeoptimierung
     451         [ #  # ]:          0 :     if( aLeftExp.IsNothing() )
     452                 :            :     {
     453         [ #  # ]:          0 :         if ( '-' == cOperation )
     454                 :            :         {
     455         [ #  # ]:          0 :             aLeft.append('(');
     456         [ #  # ]:          0 :             aLeft.append('-');
     457                 :            :         }
     458         [ #  # ]:          0 :         aRightExp.AppendMacro(aLeft);
     459         [ #  # ]:          0 :         if( '-' == cOperation )
     460         [ #  # ]:          0 :             aLeft.append(')');
     461                 :            :     }
     462         [ #  # ]:          0 :     else if( aRightExp.IsNothing() )
     463         [ #  # ]:          0 :         aLeftExp.AppendMacro(aLeft);
     464                 :            :     else{
     465         [ #  # ]:          0 :         aLeft.append('(');
     466                 :            :         // linken Zweig auswerten
     467         [ #  # ]:          0 :         aLeftExp.AppendMacro(aLeft);
     468                 :            : 
     469         [ #  # ]:          0 :         aLeft.append(cOperation);
     470                 :            : 
     471         [ #  # ]:          0 :         aLeft.append('(');
     472                 :            :         // rechten Zweig auswerten
     473         [ #  # ]:          0 :         aRightExp.AppendMacro(aLeft);
     474         [ #  # ]:          0 :         aLeft.append(')');
     475                 :            : 
     476         [ #  # ]:          0 :         aLeft.append(')');
     477                 :            :     }
     478                 :            : 
     479                 :          0 :     return aLeft.makeStringAndClear();
     480                 :            : }
     481                 :            : 
     482                 :            : /****************** R s c F i l e ****************************************/
     483                 :            : /*************************************************************************
     484                 :            : |*
     485                 :            : |*    RscFile::RscFile()
     486                 :            : |*
     487                 :            : *************************************************************************/
     488 [ +  - ][ +  - ]:       2764 : RscFile :: RscFile(){
     489                 :       2764 :     bLoaded  = sal_False;
     490                 :       2764 :     bIncFile = sal_False;
     491                 :       2764 :     bDirty   = sal_False;
     492                 :       2764 :     bScanned = sal_False;
     493                 :       2764 : }
     494                 :            : 
     495                 :            : /*************************************************************************
     496                 :            : |*
     497                 :            : |*    RscFile::~RscFile()
     498                 :            : |*
     499                 :            : *************************************************************************/
     500                 :       2764 : RscFile :: ~RscFile() {
     501         [ +  + ]:       5528 :     for ( size_t i = 0, n = aDepLst.size(); i < n; ++i )
     502                 :       2764 :         delete aDepLst[ i ];
     503                 :       2764 :     aDepLst.clear();
     504                 :            : 
     505                 :            :     //von hinten nach vorne ist besser wegen der Abhaengigkeiten
     506                 :            :     //Objekte zerstoeren sich, wenn Referenzzaehler NULL
     507 [ +  - ][ -  + ]:       2764 :     while( aDefLst.Remove() ) ;
     508                 :       2764 : }
     509                 :            : 
     510                 :            : /*************************************************************************
     511                 :            : |*
     512                 :            : |*    RscFile::Depend()
     513                 :            : |*
     514                 :            : |*    Beschreibung      Diese Methode gibt sal_True zurueck, wenn lDepend
     515                 :            : |*                      existiert und hinter lFree steht, oder wenn
     516                 :            : |*                      lDepend nicht existiert.
     517                 :            : |*
     518                 :            : *************************************************************************/
     519                 :          0 : sal_Bool RscFile::Depend( sal_uLong lDepend, sal_uLong lFree ){
     520                 :            :     RscDepend * pDep;
     521                 :            : 
     522         [ #  # ]:          0 :     for ( size_t i = aDepLst.size(); i > 0; )
     523                 :            :     {
     524                 :          0 :         pDep = aDepLst[ --i ];
     525         [ #  # ]:          0 :         if( pDep->GetFileKey() == lDepend ) {
     526 [ #  # ][ #  # ]:          0 :             for ( size_t j = i ? --i : 0; j > 0; )
     527                 :            :             {
     528                 :          0 :                 pDep = aDepLst[ --j ];
     529         [ #  # ]:          0 :                 if( pDep->GetFileKey() == lFree )
     530                 :          0 :                     return sal_True;
     531                 :            :             }
     532                 :          0 :             return sal_False;
     533                 :            :         }
     534                 :            :     }
     535                 :          0 :     return sal_True;
     536                 :            : }
     537                 :            : 
     538                 :            : /*************************************************************************
     539                 :            : |*
     540                 :            : |*    RscFile::InsertDependFile()
     541                 :            : |*
     542                 :            : *************************************************************************/
     543                 :       2764 : sal_Bool RscFile :: InsertDependFile( sal_uLong lIncFile, size_t lPos )
     544                 :            : {
     545         [ -  + ]:       2764 :     for ( size_t i = 0, n = aDepLst.size(); i < n; ++i )
     546                 :            :     {
     547                 :          0 :         RscDepend* pDep = aDepLst[ i ];
     548         [ #  # ]:          0 :         if( pDep->GetFileKey() == lIncFile )
     549                 :          0 :             return sal_True;
     550                 :            :     }
     551                 :            : 
     552                 :            :     // Current-Zeiger steht auf letztem Element
     553         [ +  - ]:       2764 :     if( lPos >= aDepLst.size() ) { //letztes Element muss immer letztes bleiben
     554                 :            :         // Abhaengigkeit vor der letzten Position eintragen
     555         [ +  - ]:       2764 :         aDepLst.push_back( new RscDepend( lIncFile ) );
     556                 :            :     }
     557                 :            :     else {
     558                 :          0 :         RscDependList::iterator it = aDepLst.begin();
     559         [ #  # ]:          0 :         ::std::advance( it, lPos );
     560 [ #  # ][ #  # ]:          0 :         aDepLst.insert( it, new RscDepend( lIncFile ) );
     561                 :            :     }
     562                 :       2764 :     return sal_True;
     563                 :            : }
     564                 :            : 
     565                 :            : /****************** R s c D e f T r e e **********************************/
     566                 :            : /*************************************************************************
     567                 :            : |*
     568                 :            : |*    RscDefTree::~RscDefTree()
     569                 :            : |*
     570                 :            : *************************************************************************/
     571                 :       1440 : RscDefTree::~RscDefTree(){
     572                 :       1440 :     Remove();
     573                 :       1440 : }
     574                 :            : 
     575                 :            : /*************************************************************************
     576                 :            : |*
     577                 :            : |*    RscDefTree::Remove()
     578                 :            : |*
     579                 :            : *************************************************************************/
     580                 :       2880 : void RscDefTree::Remove(){
     581                 :            :     RscDefine * pDef;
     582         [ -  + ]:       2880 :     while( pDefRoot ){
     583                 :          0 :         pDef = pDefRoot;
     584                 :          0 :         pDefRoot = (RscDefine *)pDefRoot->Remove( pDefRoot );
     585                 :          0 :         pDef->DecRef();
     586                 :            :     }
     587                 :       2880 : }
     588                 :            : 
     589                 :            : /*************************************************************************
     590                 :            : |*
     591                 :            : |*    RscDefTree::~Search()
     592                 :            : |*
     593                 :            : *************************************************************************/
     594                 :          0 : RscDefine * RscDefTree::Search( const char * pName ){
     595         [ #  # ]:          0 :     if( pDefRoot )
     596                 :          0 :         return pDefRoot->Search( pName );
     597                 :          0 :     return NULL;
     598                 :            : }
     599                 :            : 
     600                 :            : /*************************************************************************
     601                 :            : |*
     602                 :            : |*    RscDefTree::Insert()
     603                 :            : |*
     604                 :            : *************************************************************************/
     605                 :          0 : void RscDefTree::Insert( RscDefine * pDef ){
     606         [ #  # ]:          0 :     if( pDefRoot )
     607                 :          0 :         pDefRoot->Insert( pDef );
     608                 :            :     else
     609                 :          0 :         pDefRoot = pDef;
     610                 :          0 :     pDef->IncRef();
     611                 :          0 : }
     612                 :            : 
     613                 :            : /*************************************************************************
     614                 :            : |*
     615                 :            : |*    RscDefTree::Remove()
     616                 :            : |*
     617                 :            : *************************************************************************/
     618                 :          0 : void RscDefTree::Remove( RscDefine * pDef ){
     619         [ #  # ]:          0 :     if( pDefRoot ){
     620                 :            :         //falls pDef == pDefRoot
     621                 :          0 :         pDefRoot = (RscDefine *)pDefRoot->Remove( pDef );
     622                 :            :     }
     623                 :          0 :     pDef->DecRef();
     624                 :          0 : }
     625                 :            : 
     626                 :            : /*************************************************************************
     627                 :            : |*
     628                 :            : |*    RscDefTree::Evaluate()
     629                 :            : |*
     630                 :            : *************************************************************************/
     631                 :          0 : sal_Bool RscDefTree::Evaluate( RscDefine * pDef ){
     632         [ #  # ]:          0 :     if( pDef ){
     633         [ #  # ]:          0 :         if( !Evaluate( (RscDefine *)pDef->Left() ) )
     634                 :          0 :             return sal_False;
     635         [ #  # ]:          0 :         if( !Evaluate( (RscDefine *)pDef->Right() ) )
     636                 :          0 :             return sal_False;
     637                 :            :     };
     638                 :          0 :     return sal_True;
     639                 :            : }
     640                 :            : 
     641                 :            : /****************** R s c F i l e T a b **********************************/
     642                 :            : /*************************************************************************
     643                 :            : |*
     644                 :            : |*    RscFileTab::RscFileTab()
     645                 :            : |*
     646                 :            : *************************************************************************/
     647                 :       1440 : RscFileTab::RscFileTab(){
     648                 :       1440 : }
     649                 :            : 
     650                 :            : /*************************************************************************
     651                 :            : |*
     652                 :            : |*    RscFileTab::~RscFileTab()
     653                 :            : |*
     654                 :            : *************************************************************************/
     655         [ +  - ]:       1440 : RscFileTab :: ~RscFileTab(){
     656                 :            : 
     657         [ +  - ]:       1440 :     aDefTree.Remove();
     658                 :            : 
     659         [ +  - ]:       1440 :     sal_uIntPtr aIndex = LastIndex();
     660         [ +  + ]:       4204 :     while( aIndex != UNIQUEINDEX_ENTRY_NOTFOUND ) {
     661 [ +  - ][ +  - ]:       2764 :         delete Remove( aIndex );
                 [ +  - ]
     662         [ +  - ]:       2764 :         aIndex = LastIndex();
     663                 :            :     };
     664                 :       1440 : }
     665                 :            : 
     666                 :            : /*************************************************************************
     667                 :            : |*
     668                 :            : |*    RscFileTab::Find()
     669                 :            : |*
     670                 :            : *************************************************************************/
     671                 :       2766 : sal_uLong  RscFileTab :: Find( const rtl::OString& rName )
     672                 :            : {
     673                 :       2766 :     sal_uIntPtr aIndex = FirstIndex();
     674 [ +  + ][ +  + ]:       4094 :     while( aIndex != UNIQUEINDEX_ENTRY_NOTFOUND && (Get(aIndex)->aFileName != rName) )
                 [ +  + ]
     675                 :       1328 :         aIndex = NextIndex(aIndex);
     676                 :            : 
     677         [ +  + ]:       2766 :     if( aIndex != UNIQUEINDEX_ENTRY_NOTFOUND )
     678                 :          2 :         return aIndex;
     679                 :            :     else
     680                 :       2766 :         return NOFILE_INDEX;
     681                 :            : }
     682                 :            : 
     683                 :            : /*************************************************************************
     684                 :            : |*
     685                 :            : |*    RscFileTab::FindDef()
     686                 :            : |*
     687                 :            : *************************************************************************/
     688                 :          0 : RscDefine * RscFileTab::FindDef( const char * pName ){
     689                 :          0 :     return aDefTree.Search( pName );
     690                 :            : }
     691                 :            : 
     692                 :            : /*************************************************************************
     693                 :            : |*
     694                 :            : |*    RscFileTab::Depend()
     695                 :            : |*
     696                 :            : *************************************************************************/
     697                 :          0 : sal_Bool RscFileTab::Depend( sal_uLong lDepend, sal_uLong lFree ){
     698         [ #  # ]:          0 :     if( lDepend == lFree )
     699                 :          0 :         return sal_True;
     700                 :            : 
     701                 :          0 :     sal_uIntPtr aIndex = FirstIndex();
     702         [ #  # ]:          0 :     while( aIndex != UNIQUEINDEX_ENTRY_NOTFOUND ){
     703                 :          0 :         RscFile * pFile = Get(aIndex);
     704         [ #  # ]:          0 :         if( !pFile->IsIncFile() ){
     705         [ #  # ]:          0 :             if( !pFile->Depend( lDepend, lFree ) )
     706                 :          0 :                 return sal_False;
     707                 :            :         };
     708                 :          0 :         aIndex = NextIndex(aIndex);
     709                 :            :     };
     710                 :            : 
     711                 :          0 :     return sal_True;
     712                 :            : }
     713                 :            : 
     714                 :            : /*************************************************************************
     715                 :            : |*
     716                 :            : |*    RscFileTab::TestDef()
     717                 :            : |*
     718                 :            : *************************************************************************/
     719                 :          0 : sal_Bool RscFileTab::TestDef( sal_uLong lFileKey, size_t lPos,
     720                 :            :                           const RscDefine * pDefDec )
     721                 :            : {
     722         [ #  # ]:          0 :     if( lFileKey == pDefDec->GetFileKey() ) {
     723                 :          0 :         RscFile * pFile = GetFile( pDefDec->GetFileKey() );
     724 [ #  # ][ #  # ]:          0 :         if( pFile && (lPos <= pFile->aDefLst.GetPos( (RscDefine *)pDefDec ))
         [ #  # ][ #  # ]
     725                 :            :           && (lPos != ULONG_MAX ) )
     726                 :          0 :             return sal_False;
     727                 :            :     }
     728         [ #  # ]:          0 :     else if( !Depend( lFileKey, pDefDec->GetFileKey() ) )
     729                 :          0 :         return sal_False;
     730                 :            : 
     731                 :          0 :     return TestDef( lFileKey, lPos, pDefDec->pExp );
     732                 :            : }
     733                 :            : 
     734                 :            : /*************************************************************************
     735                 :            : |*
     736                 :            : |*    RscFileTab::TestDef()
     737                 :            : |*
     738                 :            : *************************************************************************/
     739                 :          0 : sal_Bool RscFileTab::TestDef( sal_uLong lFileKey, size_t lPos,
     740                 :            :                           const RscExpression * pExpDec )
     741                 :            : {
     742         [ #  # ]:          0 :     if( !pExpDec )
     743                 :          0 :         return sal_True;
     744                 :            : 
     745         [ #  # ]:          0 :     if( pExpDec->aLeftExp.IsExpression() )
     746         [ #  # ]:          0 :         if( !TestDef( lFileKey, lPos, pExpDec->aLeftExp.aExp.pExp ) )
     747                 :          0 :             return sal_False;
     748                 :            : 
     749         [ #  # ]:          0 :     if( pExpDec->aLeftExp.IsDefinition() )
     750         [ #  # ]:          0 :         if( !TestDef( lFileKey, lPos, pExpDec->aLeftExp.aExp.pDef ) )
     751                 :          0 :             return sal_False;
     752                 :            : 
     753         [ #  # ]:          0 :     if( pExpDec->aRightExp.IsExpression() )
     754         [ #  # ]:          0 :         if( !TestDef( lFileKey, lPos, pExpDec->aRightExp.aExp.pExp ) )
     755                 :          0 :             return sal_False;
     756                 :            : 
     757         [ #  # ]:          0 :     if( pExpDec->aRightExp.IsDefinition() )
     758         [ #  # ]:          0 :         if( !TestDef( lFileKey, lPos, pExpDec->aRightExp.aExp.pDef ) )
     759                 :          0 :             return sal_False;
     760                 :            : 
     761                 :          0 :     return sal_True;
     762                 :            : }
     763                 :            : 
     764                 :            : /*************************************************************************
     765                 :            : |*
     766                 :            : |*    RscFileTab::NewDef()
     767                 :            : |*
     768                 :            : *************************************************************************/
     769                 :          0 : RscDefine * RscFileTab::NewDef( sal_uLong lFileKey, const rtl::OString& rDefName,
     770                 :            :                                 sal_Int32 lId, sal_uLong lPos )
     771                 :            : {
     772                 :          0 :     RscDefine * pDef = FindDef( rDefName );
     773                 :            : 
     774         [ #  # ]:          0 :     if( !pDef ){
     775                 :          0 :         RscFile * pFile = GetFile( lFileKey );
     776                 :            : 
     777         [ #  # ]:          0 :         if( pFile ){
     778                 :          0 :             pDef = pFile->aDefLst.New( lFileKey, rDefName, lId, lPos );
     779                 :          0 :             aDefTree.Insert( pDef );
     780                 :            :         }
     781                 :            :     }
     782                 :            :     else
     783                 :          0 :         pDef = NULL;
     784                 :            : 
     785                 :          0 :     return( pDef );
     786                 :            : }
     787                 :            : 
     788                 :            : /*************************************************************************
     789                 :            : |*
     790                 :            : |*    RscFileTab::NewDef()
     791                 :            : |*
     792                 :            : *************************************************************************/
     793                 :          0 : RscDefine * RscFileTab::NewDef( sal_uLong lFileKey, const rtl::OString& rDefName,
     794                 :            :                                 RscExpression * pExp, sal_uLong lPos )
     795                 :            : {
     796                 :          0 :     RscDefine * pDef = FindDef( rDefName );
     797                 :            : 
     798         [ #  # ]:          0 :     if( !pDef ){
     799                 :            :         //Macros in den Expressions sind definiert ?
     800         [ #  # ]:          0 :         if( TestDef( lFileKey, lPos, pExp ) ){
     801                 :          0 :             RscFile * pFile = GetFile( lFileKey );
     802                 :            : 
     803         [ #  # ]:          0 :             if( pFile ){
     804                 :          0 :                 pDef = pFile->aDefLst.New( lFileKey, rDefName, pExp, lPos );
     805                 :          0 :                 aDefTree.Insert( pDef );
     806                 :            :             }
     807                 :            :         }
     808                 :            :     }
     809                 :            :     else
     810                 :          0 :         pDef = NULL;
     811                 :            : 
     812         [ #  # ]:          0 :     if( !pDef ){
     813                 :            :         // pExp wird immer Eigentum und muss, wenn es nicht benoetigt wird
     814                 :            :         // geloescht werden
     815         [ #  # ]:          0 :         delete pExp;
     816                 :            :     }
     817                 :          0 :     return( pDef );
     818                 :            : }
     819                 :            : 
     820                 :            : /*************************************************************************
     821                 :            : |*
     822                 :            : |*    RscFileTab::DeleteFileContext()
     823                 :            : |*
     824                 :            : *************************************************************************/
     825                 :        122 : void RscFileTab :: DeleteFileContext( sal_uLong lFileKey ){
     826                 :            :     RscFile     * pFName;
     827                 :            : 
     828                 :        122 :     pFName = GetFile( lFileKey );
     829         [ +  - ]:        122 :     if( pFName ){
     830                 :            :         RscDefine * pDef;
     831                 :            : 
     832         [ -  + ]:        122 :         for ( size_t i = 0, n = pFName->aDefLst.maList.size(); i < n; ++i ) {
     833                 :          0 :             pDef = pFName->aDefLst.maList[ i ];
     834                 :          0 :             aDefTree.Remove( pDef );
     835                 :            :         };
     836         [ -  + ]:        122 :         while( pFName->aDefLst.Remove() ) ;
     837                 :            :     }
     838                 :        122 : }
     839                 :            : 
     840                 :            : /*************************************************************************
     841                 :            : |*
     842                 :            : |*    RscFileTab::NewCodeFile()
     843                 :            : |*
     844                 :            : *************************************************************************/
     845                 :       2766 : sal_uLong  RscFileTab :: NewCodeFile( const rtl::OString& rName )
     846                 :            : {
     847                 :            :     sal_uLong       lKey;
     848                 :            :     RscFile *   pFName;
     849                 :            : 
     850                 :       2766 :     lKey = Find( rName );
     851         [ +  + ]:       2766 :     if( UNIQUEINDEX_ENTRY_NOTFOUND == lKey )
     852                 :            :     {
     853         [ +  - ]:       2764 :         pFName = new RscFile();
     854                 :       2764 :         pFName->aFileName = rName;
     855                 :       2764 :         pFName->aPathName = rName;
     856                 :       2764 :         lKey = Insert( pFName );
     857                 :       2764 :         pFName->InsertDependFile( lKey, ULONG_MAX );
     858                 :            :     }
     859                 :       2766 :     return lKey;
     860                 :            : }
     861                 :            : 
     862                 :            : /*************************************************************************
     863                 :            : |*
     864                 :            : |*    RscFileTab::NewIncFile()
     865                 :            : |*
     866                 :            : *************************************************************************/
     867                 :          0 : sal_uLong  RscFileTab :: NewIncFile(const rtl::OString& rName,
     868                 :            :     const rtl::OString& rPath)
     869                 :            : {
     870                 :            :     sal_uLong         lKey;
     871                 :            :     RscFile * pFName;
     872                 :            : 
     873                 :          0 :     lKey = Find( rName );
     874         [ #  # ]:          0 :     if( UNIQUEINDEX_ENTRY_NOTFOUND == lKey )
     875                 :            :     {
     876         [ #  # ]:          0 :         pFName = new RscFile();
     877                 :          0 :         pFName->aFileName = rName;
     878                 :          0 :         pFName->aPathName = rPath;
     879                 :          0 :         pFName->SetIncFlag();
     880                 :          0 :         lKey = Insert( pFName );
     881                 :          0 :         pFName->InsertDependFile( lKey, ULONG_MAX );
     882                 :            :     }
     883                 :          0 :     return lKey;
     884                 :            : }
     885                 :            : 
     886                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10