LCOV - code coverage report
Current view: top level - sc/source/filter/excel - tokstack.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 264 504 52.4 %
Date: 2012-08-25 Functions: 20 32 62.5 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 148 385 38.4 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include <string.h>
      30                 :            : 
      31                 :            : #include "compiler.hxx"
      32                 :            : #include "tokstack.hxx"
      33                 :            : #include "global.hxx"
      34                 :            : #include "scmatrix.hxx"
      35                 :            : 
      36                 :            : #include <stdio.h> // printf
      37                 :            : 
      38                 :            : const sal_uInt16    TokenPool::nScTokenOff = 8192;
      39                 :            : 
      40                 :            : 
      41                 :        113 : TokenStack::TokenStack( sal_uInt16 nNewSize )
      42                 :            : {
      43         [ +  + ]:     115825 :     pStack = new TokenId[ nNewSize ];
      44                 :            : 
      45                 :        113 :     Reset();
      46                 :        113 :     nSize = nNewSize;
      47                 :        113 : }
      48                 :            : 
      49                 :            : 
      50                 :        113 : TokenStack::~TokenStack()
      51                 :            : {
      52         [ +  - ]:        113 :     delete[] pStack;
      53                 :        113 : }
      54                 :            : 
      55                 :            : 
      56                 :            : 
      57                 :            : 
      58                 :            : //------------------------------------------------------------------------
      59                 :            : 
      60                 :            : // !ACHTUNG!: nach Aussen hin beginnt die Nummerierung mit 1!
      61                 :            : // !ACHTUNG!: SC-Token werden mit einem Offset nScTokenOff abgelegt
      62                 :            : //              -> Unterscheidung von anderen Token
      63                 :            : 
      64                 :            : 
      65 [ +  - ][ +  - ]:        113 : TokenPool::TokenPool( void )
                 [ +  - ]
      66                 :            : {
      67                 :        113 :     sal_uInt16  nLauf = nScTokenOff;
      68                 :            : 
      69                 :            :     // Sammelstelle fuer Id-Folgen
      70                 :        113 :     nP_Id = 256;
      71         [ +  - ]:        113 :     pP_Id = new sal_uInt16[ nP_Id ];
      72                 :            : 
      73                 :            :     // Sammelstelle fuer Ids
      74                 :        113 :     nElement = 32;
      75         [ +  - ]:        113 :     pElement = new sal_uInt16[ nElement ];
      76         [ +  - ]:        113 :     pType = new E_TYPE[ nElement ];
      77         [ +  - ]:        113 :     pSize = new sal_uInt16[ nElement ];
      78                 :        113 :     nP_IdLast = 0;
      79                 :            : 
      80                 :            :     // Sammelstelle fuer Strings
      81                 :        113 :     nP_Str = 4;
      82         [ +  - ]:        113 :     ppP_Str = new String *[ nP_Str ];
      83         [ +  + ]:        565 :     for( nLauf = 0 ; nLauf < nP_Str ; nLauf++ )
      84                 :        452 :         ppP_Str[ nLauf ] = NULL;
      85                 :            : 
      86                 :            :     // Sammelstelle fuer double
      87                 :        113 :     nP_Dbl = 8;
      88         [ +  - ]:        113 :     pP_Dbl = new double[ nP_Dbl ];
      89                 :            : 
      90                 :            :     // Sammelstelle fuer error codes
      91                 :        113 :     nP_Err = 8;
      92         [ +  - ]:        113 :     pP_Err = new sal_uInt16[ nP_Err ];
      93                 :            : 
      94                 :            :     // Sammelstellen fuer Referenzen
      95                 :        113 :     nP_RefTr = 32;
      96         [ +  - ]:        113 :     ppP_RefTr = new ScSingleRefData *[ nP_RefTr ];
      97         [ +  + ]:       3729 :     for( nLauf = 0 ; nLauf < nP_RefTr ; nLauf++ )
      98                 :       3616 :         ppP_RefTr[ nLauf ] = NULL;
      99                 :            : 
     100                 :        113 :     nP_Ext = 32;
     101         [ +  - ]:        113 :     ppP_Ext = new EXTCONT*[ nP_Ext ];
     102                 :        113 :     memset( ppP_Ext, 0, sizeof( EXTCONT* ) * nP_Ext );
     103                 :            : 
     104                 :        113 :     nP_Nlf = 16;
     105         [ +  - ]:        113 :     ppP_Nlf = new NLFCONT*[ nP_Nlf ];
     106                 :        113 :     memset( ppP_Nlf, 0, sizeof( NLFCONT* ) * nP_Nlf );
     107                 :            : 
     108                 :        113 :     nP_Matrix = 16;
     109         [ +  - ]:        113 :     ppP_Matrix = new ScMatrix*[ nP_Matrix ];
     110                 :        113 :     memset( ppP_Matrix, 0, sizeof( ScMatrix* ) * nP_Matrix );
     111                 :            : 
     112 [ +  - ][ +  - ]:        113 :     pScToken = new ScTokenArray;
     113                 :            : 
     114                 :        113 :     Reset();
     115                 :        113 : }
     116                 :            : 
     117                 :            : 
     118                 :        113 : TokenPool::~TokenPool()
     119                 :            : {
     120                 :            :     sal_uInt16 n;
     121                 :            : 
     122         [ +  - ]:        113 :     delete[] pP_Id;
     123         [ +  - ]:        113 :     delete[] pElement;
     124         [ +  - ]:        113 :     delete[] pType;
     125         [ +  - ]:        113 :     delete[] pSize;
     126         [ +  - ]:        113 :     delete[] pP_Dbl;
     127         [ +  - ]:        113 :     delete[] pP_Err;
     128                 :            : 
     129         [ +  + ]:       3729 :     for( n = 0 ; n < nP_RefTr ; n++ )
     130                 :       3616 :         delete ppP_RefTr[ n ];
     131         [ +  - ]:        113 :     delete[] ppP_RefTr;
     132                 :            : 
     133         [ +  + ]:        577 :     for( n = 0 ; n < nP_Str ; n++ )
     134 [ +  + ][ +  - ]:        464 :         delete ppP_Str[ n ];
     135         [ +  - ]:        113 :     delete[] ppP_Str;
     136                 :            : 
     137         [ +  + ]:       3729 :     for( n = 0 ; n < nP_Ext ; n++ )
     138 [ +  + ][ +  - ]:       3616 :         delete ppP_Ext[ n ];
     139         [ +  - ]:        113 :     delete[] ppP_Ext;
     140                 :            : 
     141         [ +  + ]:       1921 :     for( n = 0 ; n < nP_Nlf ; n++ )
     142                 :       1808 :         delete ppP_Nlf[ n ];
     143         [ +  - ]:        113 :     delete[] ppP_Nlf;
     144                 :            : 
     145         [ +  + ]:       1921 :     for( n = 0 ; n < nP_Matrix ; n++ )
     146                 :            :     {
     147         [ +  + ]:       1808 :         if( ppP_Matrix[ n ] )
     148         [ +  - ]:          3 :             ppP_Matrix[ n ]->DecRef( );
     149                 :            :     }
     150         [ +  - ]:        113 :     delete[] ppP_Matrix;
     151                 :            : 
     152 [ +  - ][ +  - ]:        113 :     delete pScToken;
     153                 :        113 : }
     154                 :            : 
     155                 :            : 
     156                 :            : /** Returns the new number of elements, or 0 if overflow. */
     157                 :          3 : static sal_uInt16 lcl_canGrow( sal_uInt16 nOld, sal_uInt16 nByMin = 1 )
     158                 :            : {
     159         [ -  + ]:          3 :     if (!nOld)
     160         [ #  # ]:          0 :         return nByMin ? nByMin : 1;
     161         [ -  + ]:          3 :     if (nOld == SAL_MAX_UINT16)
     162                 :          0 :         return 0;
     163                 :            :     sal_uInt32 nNew = ::std::max( static_cast<sal_uInt32>(nOld) * 2,
     164         [ +  - ]:          3 :             static_cast<sal_uInt32>(nOld) + nByMin);
     165         [ -  + ]:          3 :     if (nNew > SAL_MAX_UINT16)
     166                 :          0 :         nNew = SAL_MAX_UINT16;
     167         [ -  + ]:          3 :     if (nNew - nByMin < nOld)
     168                 :          0 :         nNew = 0;
     169                 :          3 :     return static_cast<sal_uInt16>(nNew);
     170                 :            : }
     171                 :            : 
     172                 :            : 
     173                 :          3 : bool TokenPool::GrowString( void )
     174                 :            : {
     175                 :          3 :     sal_uInt16 nP_StrNew = lcl_canGrow( nP_Str);
     176         [ -  + ]:          3 :     if (!nP_StrNew)
     177                 :          0 :         return false;
     178                 :            : 
     179                 :            :     sal_uInt16      nL;
     180                 :            : 
     181                 :          3 :     String** ppP_StrNew = new (::std::nothrow) String *[ nP_StrNew ];
     182         [ -  + ]:          3 :     if (!ppP_StrNew)
     183                 :          0 :         return false;
     184                 :            : 
     185         [ +  + ]:         15 :     for( nL = 0 ; nL < nP_Str ; nL++ )
     186                 :         12 :         ppP_StrNew[ nL ] = ppP_Str[ nL ];
     187         [ +  + ]:         15 :     for( nL = nP_Str ; nL < nP_StrNew ; nL++ )
     188                 :         12 :         ppP_StrNew[ nL ] = NULL;
     189                 :            : 
     190                 :          3 :     nP_Str = nP_StrNew;
     191                 :            : 
     192         [ +  - ]:          3 :     delete[]    ppP_Str;
     193                 :          3 :     ppP_Str = ppP_StrNew;
     194                 :          3 :     return true;
     195                 :            : }
     196                 :            : 
     197                 :            : 
     198                 :          0 : bool TokenPool::GrowDouble( void )
     199                 :            : {
     200                 :          0 :     sal_uInt16 nP_DblNew = lcl_canGrow( nP_Dbl);
     201         [ #  # ]:          0 :     if (!nP_DblNew)
     202                 :          0 :         return false;
     203                 :            : 
     204                 :            : 
     205                 :          0 :     double* pP_DblNew = new (::std::nothrow) double[ nP_DblNew ];
     206         [ #  # ]:          0 :     if (!pP_DblNew)
     207                 :          0 :         return false;
     208                 :            : 
     209         [ #  # ]:          0 :     for( sal_uInt16 nL = 0 ; nL < nP_Dbl ; nL++ )
     210                 :          0 :         pP_DblNew[ nL ] = pP_Dbl[ nL ];
     211                 :            : 
     212                 :          0 :     nP_Dbl = nP_DblNew;
     213                 :            : 
     214         [ #  # ]:          0 :     delete[] pP_Dbl;
     215                 :          0 :     pP_Dbl = pP_DblNew;
     216                 :          0 :     return true;
     217                 :            : }
     218                 :            : 
     219                 :            : 
     220                 :            : /* TODO: in case we had FormulaTokenArray::AddError() */
     221                 :            : #if 0
     222                 :            : void TokenPool::GrowError( void )
     223                 :            : {
     224                 :            :     sal_uInt16 nP_ErrNew = lcl_canGrow( nP_Err);
     225                 :            :     if (!nP_ErrNew)
     226                 :            :         return false;
     227                 :            : 
     228                 :            : 
     229                 :            :     sal_uInt16*     pP_ErrNew = new (::std::nothrow) sal_uInt16[ nP_ErrNew ];
     230                 :            :     if (!pP_ErrNew)
     231                 :            :         return false;
     232                 :            : 
     233                 :            :     for( sal_uInt16 nL = 0 ; nL < nP_Err ; nL++ )
     234                 :            :         pP_ErrNew[ nL ] = pP_Err[ nL ];
     235                 :            : 
     236                 :            :     nP_Err = nP_ErrNew;
     237                 :            : 
     238                 :            :     delete[] pP_Err;
     239                 :            :     pP_Err = pP_ErrNew;
     240                 :            :     return true;
     241                 :            : }
     242                 :            : #endif
     243                 :            : 
     244                 :            : 
     245                 :          0 : bool TokenPool::GrowTripel( sal_uInt16 nByMin )
     246                 :            : {
     247                 :          0 :     sal_uInt16 nP_RefTrNew = lcl_canGrow( nP_RefTr, nByMin);
     248         [ #  # ]:          0 :     if (!nP_RefTrNew)
     249                 :          0 :         return false;
     250                 :            : 
     251                 :            :     sal_uInt16          nL;
     252                 :            : 
     253                 :          0 :     ScSingleRefData** ppP_RefTrNew = new (::std::nothrow) ScSingleRefData *[ nP_RefTrNew ];
     254         [ #  # ]:          0 :     if (!ppP_RefTrNew)
     255                 :          0 :         return false;
     256                 :            : 
     257         [ #  # ]:          0 :     for( nL = 0 ; nL < nP_RefTr ; nL++ )
     258                 :          0 :         ppP_RefTrNew[ nL ] = ppP_RefTr[ nL ];
     259         [ #  # ]:          0 :     for( nL = nP_RefTr ; nL < nP_RefTrNew ; nL++ )
     260                 :          0 :         ppP_RefTrNew[ nL ] = NULL;
     261                 :            : 
     262                 :          0 :     nP_RefTr = nP_RefTrNew;
     263                 :            : 
     264         [ #  # ]:          0 :     delete[] ppP_RefTr;
     265                 :          0 :     ppP_RefTr = ppP_RefTrNew;
     266                 :          0 :     return true;
     267                 :            : }
     268                 :            : 
     269                 :            : 
     270                 :          0 : bool TokenPool::GrowId( void )
     271                 :            : {
     272                 :          0 :     sal_uInt16 nP_IdNew = lcl_canGrow( nP_Id);
     273         [ #  # ]:          0 :     if (!nP_IdNew)
     274                 :          0 :         return false;
     275                 :            : 
     276                 :            : 
     277                 :          0 :     sal_uInt16* pP_IdNew = new (::std::nothrow) sal_uInt16[ nP_IdNew ];
     278         [ #  # ]:          0 :     if (!pP_IdNew)
     279                 :          0 :         return false;
     280                 :            : 
     281         [ #  # ]:          0 :     for( sal_uInt16 nL = 0 ; nL < nP_Id ; nL++ )
     282                 :          0 :         pP_IdNew[ nL ] = pP_Id[ nL ];
     283                 :            : 
     284                 :          0 :     nP_Id = nP_IdNew;
     285                 :            : 
     286         [ #  # ]:          0 :     delete[] pP_Id;
     287                 :          0 :     pP_Id = pP_IdNew;
     288                 :          0 :     return true;
     289                 :            : }
     290                 :            : 
     291                 :            : 
     292                 :          0 : bool TokenPool::GrowElement( void )
     293                 :            : {
     294                 :          0 :     sal_uInt16 nElementNew = lcl_canGrow( nElement);
     295         [ #  # ]:          0 :     if (!nElementNew)
     296                 :          0 :         return false;
     297                 :            : 
     298                 :            : 
     299                 :          0 :     sal_uInt16* pElementNew = new (::std::nothrow) sal_uInt16[ nElementNew ];
     300                 :          0 :     E_TYPE* pTypeNew = new (::std::nothrow) E_TYPE[ nElementNew ];
     301                 :          0 :     sal_uInt16* pSizeNew = new (::std::nothrow) sal_uInt16[ nElementNew ];
     302 [ #  # ][ #  # ]:          0 :     if (!pElementNew || !pTypeNew || !pSizeNew)
                 [ #  # ]
     303                 :            :     {
     304         [ #  # ]:          0 :         delete [] pElementNew;
     305         [ #  # ]:          0 :         delete [] pTypeNew;
     306         [ #  # ]:          0 :         delete [] pSizeNew;
     307                 :          0 :         return false;
     308                 :            :     }
     309                 :            : 
     310         [ #  # ]:          0 :     for( sal_uInt16 nL = 0 ; nL < nElement ; nL++ )
     311                 :            :     {
     312                 :          0 :         pElementNew[ nL ] = pElement[ nL ];
     313                 :          0 :         pTypeNew[ nL ] = pType[ nL ];
     314                 :          0 :         pSizeNew[ nL ] = pSize[ nL ];
     315                 :            :     }
     316                 :            : 
     317                 :          0 :     nElement = nElementNew;
     318                 :            : 
     319         [ #  # ]:          0 :     delete[] pElement;
     320         [ #  # ]:          0 :     delete[] pType;
     321         [ #  # ]:          0 :     delete[] pSize;
     322                 :          0 :     pElement = pElementNew;
     323                 :          0 :     pType = pTypeNew;
     324                 :          0 :     pSize = pSizeNew;
     325                 :          0 :     return true;
     326                 :            : }
     327                 :            : 
     328                 :            : 
     329                 :          0 : bool TokenPool::GrowExt( void )
     330                 :            : {
     331                 :          0 :     sal_uInt16 nNewSize = lcl_canGrow( nP_Ext);
     332         [ #  # ]:          0 :     if (!nNewSize)
     333                 :          0 :         return false;
     334                 :            : 
     335                 :          0 :     EXTCONT** ppNew = new (::std::nothrow) EXTCONT*[ nNewSize ];
     336         [ #  # ]:          0 :     if (!ppNew)
     337                 :          0 :         return false;
     338                 :            : 
     339                 :          0 :     memset( ppNew, 0, sizeof( EXTCONT* ) * nNewSize );
     340                 :          0 :     memcpy( ppNew, ppP_Ext, sizeof( EXTCONT* ) * nP_Ext );
     341                 :            : 
     342         [ #  # ]:          0 :     delete[] ppP_Ext;
     343                 :          0 :     ppP_Ext = ppNew;
     344                 :          0 :     nP_Ext = nNewSize;
     345                 :          0 :     return true;
     346                 :            : }
     347                 :            : 
     348                 :            : 
     349                 :          0 : bool TokenPool::GrowNlf( void )
     350                 :            : {
     351                 :          0 :     sal_uInt16 nNewSize = lcl_canGrow( nP_Nlf);
     352         [ #  # ]:          0 :     if (!nNewSize)
     353                 :          0 :         return false;
     354                 :            : 
     355                 :          0 :     NLFCONT** ppNew = new (::std::nothrow) NLFCONT*[ nNewSize ];
     356         [ #  # ]:          0 :     if (!ppNew)
     357                 :          0 :         return false;
     358                 :            : 
     359                 :          0 :     memset( ppNew, 0, sizeof( NLFCONT* ) * nNewSize );
     360                 :          0 :     memcpy( ppNew, ppP_Nlf, sizeof( NLFCONT* ) * nP_Nlf );
     361                 :            : 
     362         [ #  # ]:          0 :     delete[] ppP_Nlf;
     363                 :          0 :     ppP_Nlf = ppNew;
     364                 :          0 :     nP_Nlf = nNewSize;
     365                 :          0 :     return true;
     366                 :            : }
     367                 :            : 
     368                 :            : 
     369                 :          0 : bool TokenPool::GrowMatrix( void )
     370                 :            : {
     371                 :          0 :     sal_uInt16 nNewSize = lcl_canGrow( nP_Matrix);
     372         [ #  # ]:          0 :     if (!nNewSize)
     373                 :          0 :         return false;
     374                 :            : 
     375                 :          0 :     ScMatrix**  ppNew = new (::std::nothrow) ScMatrix*[ nNewSize ];
     376         [ #  # ]:          0 :     if (!ppNew)
     377                 :          0 :         return false;
     378                 :            : 
     379                 :          0 :     memset( ppNew, 0, sizeof( ScMatrix* ) * nNewSize );
     380                 :          0 :     memcpy( ppNew, ppP_Matrix, sizeof( ScMatrix* ) * nP_Matrix );
     381                 :            : 
     382         [ #  # ]:          0 :     delete[] ppP_Matrix;
     383                 :          0 :     ppP_Matrix = ppNew;
     384                 :          0 :     nP_Matrix = nNewSize;
     385                 :          0 :     return true;
     386                 :            : }
     387                 :            : 
     388                 :      18567 : bool TokenPool::GetElement( const sal_uInt16 nId )
     389                 :            : {
     390                 :            :     OSL_ENSURE( nId < nElementAkt, "*TokenPool::GetElement(): Id too large!?" );
     391         [ -  + ]:      18567 :     if (nId >= nElementAkt)
     392                 :          0 :         return false;
     393                 :            : 
     394                 :      18567 :     bool bRet = true;
     395         [ +  + ]:      18567 :     if( pType[ nId ] == T_Id )
     396                 :       1707 :         bRet = GetElementRek( nId );
     397                 :            :     else
     398                 :            :     {
     399   [ +  +  -  +  :      16860 :         switch( pType[ nId ] )
          +  +  +  -  +  
             -  -  -  - ]
     400                 :            :         {
     401                 :            :             case T_Str:
     402                 :            :                 {
     403                 :       8070 :                     sal_uInt16 n = pElement[ nId ];
     404         [ +  - ]:       8070 :                     String* p = ( n < nP_Str )? ppP_Str[ n ] : NULL;
     405         [ +  - ]:       8070 :                     if (p)
     406                 :       8070 :                         pScToken->AddString( *p );
     407                 :            :                     else
     408                 :          0 :                         bRet = false;
     409                 :            :                 }
     410                 :       8070 :                 break;
     411                 :            :             case T_D:
     412                 :            :                 {
     413                 :         54 :                     sal_uInt16 n = pElement[ nId ];
     414         [ +  - ]:         54 :                     if (n < nP_Dbl)
     415                 :         54 :                         pScToken->AddDouble( pP_Dbl[ n ] );
     416                 :            :                     else
     417                 :          0 :                         bRet = false;
     418                 :            :                 }
     419                 :         54 :                 break;
     420                 :            :             case T_Err:
     421                 :            : /* TODO: in case we had FormulaTokenArray::AddError() */
     422                 :            : #if 0
     423                 :            :                 {
     424                 :            :                     sal_uInt16 n = pElement[ nId ];
     425                 :            :                     if (n < nP_Err)
     426                 :            :                         pScToken->AddError( pP_Err[ n ] );
     427                 :            :                     else
     428                 :            :                         bRet = false;
     429                 :            :                 }
     430                 :            : #endif
     431                 :          0 :                 break;
     432                 :            :             case T_RefC:
     433                 :            :                 {
     434                 :       3534 :                     sal_uInt16 n = pElement[ nId ];
     435         [ +  - ]:       3534 :                     ScSingleRefData* p = ( n < nP_RefTr )? ppP_RefTr[ n ] : NULL;
     436         [ +  - ]:       3534 :                     if (p)
     437                 :       3534 :                         pScToken->AddSingleReference( *p );
     438                 :            :                     else
     439                 :          0 :                         bRet = false;
     440                 :            :                 }
     441                 :       3534 :                 break;
     442                 :            :             case T_RefA:
     443                 :            :                 {
     444                 :       5154 :                     sal_uInt16 n = pElement[ nId ];
     445 [ +  - ][ +  - ]:       5154 :                     if (n < nP_RefTr && ppP_RefTr[ n ] && n+1 < nP_RefTr && ppP_RefTr[ n + 1 ])
         [ +  - ][ +  - ]
     446                 :            :                     {
     447                 :            :                         ScComplexRefData aScComplexRefData;
     448                 :       5154 :                         aScComplexRefData.Ref1 = *ppP_RefTr[ n ];
     449                 :       5154 :                         aScComplexRefData.Ref2 = *ppP_RefTr[ n + 1 ];
     450         [ +  - ]:       5154 :                         pScToken->AddDoubleReference( aScComplexRefData );
     451                 :            :                     }
     452                 :            :                     else
     453                 :          0 :                         bRet = false;
     454                 :            :                 }
     455                 :       5154 :                 break;
     456                 :            :             case T_RN:
     457                 :            :             {
     458                 :         42 :                 sal_uInt16 n = pElement[nId];
     459         [ +  - ]:         42 :                 if (n < maRangeNames.size())
     460                 :            :                 {
     461                 :         42 :                     const RangeName& r = maRangeNames[n];
     462                 :         42 :                     pScToken->AddRangeName(r.mnIndex, r.mbGlobal);
     463                 :            :                 }
     464                 :            :             }
     465                 :         42 :             break;
     466                 :            :             case T_Ext:
     467                 :            :                 {
     468                 :          3 :                     sal_uInt16      n = pElement[ nId ];
     469         [ +  - ]:          3 :                     EXTCONT*        p = ( n < nP_Ext )? ppP_Ext[ n ] : NULL;
     470                 :            : 
     471         [ +  - ]:          3 :                     if( p )
     472                 :            :                     {
     473         [ -  + ]:          3 :                         if( p->eId == ocEuroConvert )
     474                 :          0 :                             pScToken->AddOpCode( p->eId );
     475                 :            :                         else
     476                 :          3 :                             pScToken->AddExternal( p->aText, p->eId );
     477                 :            :                     }
     478                 :            :                     else
     479                 :          0 :                         bRet = false;
     480                 :            :                 }
     481                 :          3 :                 break;
     482                 :            :             case T_Nlf:
     483                 :            :                 {
     484                 :          0 :                     sal_uInt16      n = pElement[ nId ];
     485         [ #  # ]:          0 :                     NLFCONT*        p = ( n < nP_Nlf )? ppP_Nlf[ n ] : NULL;
     486                 :            : 
     487         [ #  # ]:          0 :                     if( p )
     488                 :          0 :                         pScToken->AddColRowName( p->aRef );
     489                 :            :                     else
     490                 :          0 :                         bRet = false;
     491                 :            :                 }
     492                 :          0 :                 break;
     493                 :            :             case T_Matrix:
     494                 :            :                 {
     495                 :          3 :                     sal_uInt16      n = pElement[ nId ];
     496         [ +  - ]:          3 :                     ScMatrix*       p = ( n < nP_Matrix )? ppP_Matrix[ n ] : NULL;
     497                 :            : 
     498         [ +  - ]:          3 :                     if( p )
     499         [ +  - ]:          3 :                         pScToken->AddMatrix( p );
     500                 :            :                     else
     501                 :          0 :                         bRet = false;
     502                 :            :                 }
     503                 :          3 :                 break;
     504                 :            :             case T_ExtName:
     505                 :            :             {
     506                 :          0 :                 sal_uInt16 n = pElement[nId];
     507         [ #  # ]:          0 :                 if (n < maExtNames.size())
     508                 :            :                 {
     509                 :          0 :                     const ExtName& r = maExtNames[n];
     510                 :          0 :                     pScToken->AddExternalName(r.mnFileId, r.maName);
     511                 :            :                 }
     512                 :            :                 else
     513                 :          0 :                     bRet = false;
     514                 :            :             }
     515                 :          0 :             break;
     516                 :            :             case T_ExtRefC:
     517                 :            :             {
     518                 :          0 :                 sal_uInt16 n = pElement[nId];
     519         [ #  # ]:          0 :                 if (n < maExtCellRefs.size())
     520                 :            :                 {
     521                 :          0 :                     const ExtCellRef& r = maExtCellRefs[n];
     522                 :          0 :                     pScToken->AddExternalSingleReference(r.mnFileId, r.maTabName, r.maRef);
     523                 :            :                 }
     524                 :            :                 else
     525                 :          0 :                     bRet = false;
     526                 :            :             }
     527                 :          0 :             break;
     528                 :            :             case T_ExtRefA:
     529                 :            :             {
     530                 :          0 :                 sal_uInt16 n = pElement[nId];
     531         [ #  # ]:          0 :                 if (n < maExtAreaRefs.size())
     532                 :            :                 {
     533                 :          0 :                     const ExtAreaRef& r = maExtAreaRefs[n];
     534                 :          0 :                     pScToken->AddExternalDoubleReference(r.mnFileId, r.maTabName, r.maRef);
     535                 :            :                 }
     536                 :            :                 else
     537                 :          0 :                     bRet = false;
     538                 :            :             }
     539                 :          0 :             break;
     540                 :            :             default:
     541                 :            :                 OSL_FAIL("-TokenPool::GetElement(): undefined state!?");
     542                 :          0 :                 bRet = false;
     543                 :            :         }
     544                 :            :     }
     545                 :      18567 :     return bRet;
     546                 :            : }
     547                 :            : 
     548                 :            : 
     549                 :      14895 : bool TokenPool::GetElementRek( const sal_uInt16 nId )
     550                 :            : {
     551                 :            : #ifdef DBG_UTIL
     552                 :            :     m_nRek++;
     553                 :            :     OSL_ENSURE(m_nRek <= nP_Id, "*TokenPool::GetElement(): recursion loops!?");
     554                 :            : #endif
     555                 :            : 
     556                 :            :     OSL_ENSURE( nId < nElementAkt, "*TokenPool::GetElementRek(): nId >= nElementAkt" );
     557                 :            : 
     558         [ -  + ]:      14895 :     if (nId >= nElementAkt)
     559                 :            :     {
     560                 :            :         DBG_ERRORFILE( "*TokenPool::GetElementRek(): nId >= nElementAkt" );
     561                 :            : #ifdef DBG_UTIL
     562                 :            :         m_nRek--;
     563                 :            : #endif
     564                 :          0 :         return false;
     565                 :            :     }
     566                 :            : 
     567         [ -  + ]:      14895 :     if (pType[ nId ] != T_Id)
     568                 :            :     {
     569                 :            :         DBG_ERRORFILE( "-TokenPool::GetElementRek(): pType[ nId ] != T_Id" );
     570                 :            : #ifdef DBG_UTIL
     571                 :            :         m_nRek--;
     572                 :            : #endif
     573                 :          0 :         return false;
     574                 :            :     }
     575                 :            : 
     576                 :            : 
     577                 :      14895 :     bool bRet = true;
     578                 :      14895 :     sal_uInt16      nAnz = pSize[ nId ];
     579                 :      14895 :     sal_uInt16 nFirstId = pElement[ nId ];
     580         [ -  + ]:      14895 :     if (nFirstId >= nP_Id)
     581                 :            :     {
     582                 :            :         DBG_ERRORFILE( "TokenPool::GetElementRek: nFirstId >= nP_Id");
     583                 :          0 :         nAnz = 0;
     584                 :          0 :         bRet = false;
     585                 :            :     }
     586         [ +  - ]:      14895 :     sal_uInt16* pAkt = nAnz ? &pP_Id[ nFirstId ] : NULL;
     587         [ -  + ]:      14895 :     if (nAnz > nP_Id - nFirstId)
     588                 :            :     {
     589                 :            :         DBG_ERRORFILE( "TokenPool::GetElementRek: nAnz > nP_Id - nFirstId");
     590                 :          0 :         nAnz = nP_Id - nFirstId;
     591                 :          0 :         bRet = false;
     592                 :            :     }
     593         [ +  + ]:      84447 :     for( ; nAnz > 0 ; nAnz--, pAkt++ )
     594                 :            :     {
     595         [ +  + ]:      69552 :         if( *pAkt < nScTokenOff )
     596                 :            :         {// Rekursion oder nicht?
     597         [ -  + ]:      29937 :             if (*pAkt >= nElementAkt)
     598                 :            :             {
     599                 :            :                 DBG_ERRORFILE( "TokenPool::GetElementRek: *pAkt >= nElementAkt");
     600                 :          0 :                 bRet = false;
     601                 :            :             }
     602                 :            :             else
     603                 :            :             {
     604         [ +  + ]:      29937 :                 if (pType[ *pAkt ] == T_Id)
     605                 :      13188 :                     bRet = GetElementRek( *pAkt );
     606                 :            :                 else
     607                 :      16749 :                     bRet = GetElement( *pAkt );
     608                 :            :             }
     609                 :            :         }
     610                 :            :         else    // elementarer SC_Token
     611                 :      39615 :             pScToken->AddOpCode( ( DefTokenId ) ( *pAkt - nScTokenOff ) );
     612                 :            :     }
     613                 :            : 
     614                 :            : 
     615                 :            : #ifdef DBG_UTIL
     616                 :            :     m_nRek--;
     617                 :            : #endif
     618                 :      14895 :     return bRet;
     619                 :            : }
     620                 :            : 
     621                 :            : 
     622                 :      14898 : void TokenPool::operator >>( TokenId& rId )
     623                 :            : {
     624                 :      14898 :     rId = ( TokenId ) ( nElementAkt + 1 );
     625                 :            : 
     626         [ -  + ]:      14898 :     if( nElementAkt >= nElement )
     627         [ #  # ]:          0 :         if (!GrowElement())
     628                 :      14898 :             return;
     629                 :            : 
     630                 :      14898 :     pElement[ nElementAkt ] = nP_IdLast;    // Start der Token-Folge
     631                 :      14898 :     pType[ nElementAkt ] = T_Id;            // Typinfo eintragen
     632                 :      14898 :     pSize[ nElementAkt ] = nP_IdAkt - nP_IdLast;
     633                 :            :         // von nP_IdLast bis nP_IdAkt-1 geschrieben -> Laenge der Folge
     634                 :            : 
     635                 :      14898 :     nElementAkt++;          // Startwerte fuer naechste Folge
     636                 :      14898 :     nP_IdLast = nP_IdAkt;
     637                 :            : }
     638                 :            : 
     639                 :            : 
     640                 :         54 : const TokenId TokenPool::Store( const double& rDouble )
     641                 :            : {
     642         [ -  + ]:         54 :     if( nElementAkt >= nElement )
     643         [ #  # ]:          0 :         if (!GrowElement())
     644                 :          0 :             return (const TokenId) nElementAkt+1;
     645                 :            : 
     646         [ -  + ]:         54 :     if( nP_DblAkt >= nP_Dbl )
     647         [ #  # ]:          0 :         if (!GrowDouble())
     648                 :          0 :             return (const TokenId) nElementAkt+1;
     649                 :            : 
     650                 :         54 :     pElement[ nElementAkt ] = nP_DblAkt;    // Index in Double-Array
     651                 :         54 :     pType[ nElementAkt ] = T_D;             // Typinfo Double eintragen
     652                 :            : 
     653                 :         54 :     pP_Dbl[ nP_DblAkt ] = rDouble;
     654                 :            : 
     655                 :         54 :     pSize[ nElementAkt ] = 1;           // eigentlich Banane
     656                 :            : 
     657                 :         54 :     nElementAkt++;
     658                 :         54 :     nP_DblAkt++;
     659                 :            : 
     660                 :         54 :     return ( const TokenId ) nElementAkt; // Ausgabe von altem Wert + 1!
     661                 :            : }
     662                 :            : 
     663                 :            : 
     664                 :          0 : const TokenId TokenPool::Store( const sal_uInt16 nIndex )
     665                 :            : {
     666                 :          0 :     return StoreName(nIndex, true);
     667                 :            : }
     668                 :            : 
     669                 :            : 
     670                 :       8073 : const TokenId TokenPool::Store( const String& rString )
     671                 :            : {
     672                 :            :     // weitgehend nach Store( const sal_Char* ) kopiert, zur Vermeidung
     673                 :            :     //  eines temporaeren Strings in "
     674         [ -  + ]:       8073 :     if( nElementAkt >= nElement )
     675         [ #  # ]:          0 :         if (!GrowElement())
     676                 :          0 :             return (const TokenId) nElementAkt+1;
     677                 :            : 
     678                 :            : 
     679         [ +  + ]:       8073 :     if( nP_StrAkt >= nP_Str )
     680         [ -  + ]:          3 :         if (!GrowString())
     681                 :          0 :             return (const TokenId) nElementAkt+1;
     682                 :            : 
     683                 :            : 
     684                 :       8073 :     pElement[ nElementAkt ] = nP_StrAkt;    // Index in String-Array
     685                 :       8073 :     pType[ nElementAkt ] = T_Str;           // Typinfo String eintragen
     686                 :            : 
     687                 :            :     // String anlegen
     688         [ +  + ]:       8073 :     if( !ppP_Str[ nP_StrAkt ] )
     689                 :            :         //...aber nur, wenn noch nicht vorhanden
     690 [ +  - ][ +  - ]:         33 :         ppP_Str[ nP_StrAkt ] = new (::std::nothrow) String( rString );
     691                 :            :     else
     692                 :            :         //...ansonsten nur kopieren
     693                 :       8040 :         *ppP_Str[ nP_StrAkt ] = rString;
     694                 :            : 
     695         [ +  - ]:       8073 :     if (ppP_Str[ nP_StrAkt ])
     696                 :            :     {
     697                 :            :         DBG_ASSERT( sizeof( xub_StrLen ) <= 2, "*TokenPool::Store(): StrLen doesn't match!" );
     698                 :       8073 :         pSize[ nElementAkt ] = ( sal_uInt16 ) ppP_Str[ nP_StrAkt ]->Len();
     699                 :            :     }
     700                 :            : 
     701                 :       8073 :     nElementAkt++;
     702                 :       8073 :     nP_StrAkt++;
     703                 :            : 
     704                 :       8073 :     return ( const TokenId ) nElementAkt; // Ausgabe von altem Wert + 1!
     705                 :            : }
     706                 :            : 
     707                 :            : 
     708                 :       3534 : const TokenId TokenPool::Store( const ScSingleRefData& rTr )
     709                 :            : {
     710         [ -  + ]:       3534 :     if( nElementAkt >= nElement )
     711         [ #  # ]:          0 :         if (!GrowElement())
     712                 :          0 :             return (const TokenId) nElementAkt+1;
     713                 :            : 
     714         [ -  + ]:       3534 :     if( nP_RefTrAkt >= nP_RefTr )
     715         [ #  # ]:          0 :         if (!GrowTripel())
     716                 :          0 :             return (const TokenId) nElementAkt+1;
     717                 :            : 
     718                 :       3534 :     pElement[ nElementAkt ] = nP_RefTrAkt;
     719                 :       3534 :     pType[ nElementAkt ] = T_RefC;          // Typinfo Cell-Reff eintragen
     720                 :            : 
     721         [ +  + ]:       3534 :     if( !ppP_RefTr[ nP_RefTrAkt ] )
     722                 :         60 :         ppP_RefTr[ nP_RefTrAkt ] = new ScSingleRefData( rTr );
     723                 :            :     else
     724                 :       3474 :         *ppP_RefTr[ nP_RefTrAkt ] = rTr;
     725                 :            : 
     726                 :       3534 :     nElementAkt++;
     727                 :       3534 :     nP_RefTrAkt++;
     728                 :            : 
     729                 :       3534 :     return ( const TokenId ) nElementAkt; // Ausgabe von altem Wert + 1!
     730                 :            : }
     731                 :            : 
     732                 :            : 
     733                 :       5157 : const TokenId TokenPool::Store( const ScComplexRefData& rTr )
     734                 :            : {
     735         [ -  + ]:       5157 :     if( nElementAkt >= nElement )
     736         [ #  # ]:          0 :         if (!GrowElement())
     737                 :          0 :             return (const TokenId) nElementAkt+1;
     738                 :            : 
     739         [ -  + ]:       5157 :     if( nP_RefTrAkt + 1 >= nP_RefTr )
     740         [ #  # ]:          0 :         if (!GrowTripel( 2))
     741                 :          0 :             return (const TokenId) nElementAkt+1;
     742                 :            : 
     743                 :       5157 :     pElement[ nElementAkt ] = nP_RefTrAkt;
     744                 :       5157 :     pType[ nElementAkt ] = T_RefA;          // Typinfo Area-Reff eintragen
     745                 :            : 
     746         [ +  + ]:       5157 :     if( !ppP_RefTr[ nP_RefTrAkt ] )
     747                 :         24 :         ppP_RefTr[ nP_RefTrAkt ] = new ScSingleRefData( rTr.Ref1 );
     748                 :            :     else
     749                 :       5133 :         *ppP_RefTr[ nP_RefTrAkt ] = rTr.Ref1;
     750                 :       5157 :     nP_RefTrAkt++;
     751                 :            : 
     752         [ +  + ]:       5157 :     if( !ppP_RefTr[ nP_RefTrAkt ] )
     753                 :         27 :         ppP_RefTr[ nP_RefTrAkt ] = new ScSingleRefData( rTr.Ref2 );
     754                 :            :     else
     755                 :       5130 :         *ppP_RefTr[ nP_RefTrAkt ] = rTr.Ref2;
     756                 :       5157 :     nP_RefTrAkt++;
     757                 :            : 
     758                 :       5157 :     nElementAkt++;
     759                 :            : 
     760                 :       5157 :     return ( const TokenId ) nElementAkt; // Ausgabe von altem Wert + 1!
     761                 :            : }
     762                 :            : 
     763                 :            : 
     764                 :          3 : const TokenId TokenPool::Store( const DefTokenId e, const String& r )
     765                 :            : {
     766         [ -  + ]:          3 :     if( nElementAkt >= nElement )
     767         [ #  # ]:          0 :         if (!GrowElement())
     768                 :          0 :             return (const TokenId) nElementAkt+1;
     769                 :            : 
     770         [ -  + ]:          3 :     if( nP_ExtAkt >= nP_Ext )
     771         [ #  # ]:          0 :         if (!GrowExt())
     772                 :          0 :             return (const TokenId) nElementAkt+1;
     773                 :            : 
     774                 :          3 :     pElement[ nElementAkt ] = nP_ExtAkt;
     775                 :          3 :     pType[ nElementAkt ] = T_Ext;           // Typinfo String eintragen
     776                 :            : 
     777         [ -  + ]:          3 :     if( ppP_Ext[ nP_ExtAkt ] )
     778                 :            :     {
     779                 :          0 :         ppP_Ext[ nP_ExtAkt ]->eId = e;
     780                 :          0 :         ppP_Ext[ nP_ExtAkt ]->aText = r;
     781                 :            :     }
     782                 :            :     else
     783         [ +  - ]:          3 :         ppP_Ext[ nP_ExtAkt ] = new EXTCONT( e, r );
     784                 :            : 
     785                 :          3 :     nElementAkt++;
     786                 :          3 :     nP_ExtAkt++;
     787                 :            : 
     788                 :          3 :     return ( const TokenId ) nElementAkt; // Ausgabe von altem Wert + 1!
     789                 :            : }
     790                 :            : 
     791                 :            : 
     792                 :          0 : const TokenId TokenPool::StoreNlf( const ScSingleRefData& rTr )
     793                 :            : {
     794         [ #  # ]:          0 :     if( nElementAkt >= nElement )
     795         [ #  # ]:          0 :         if (!GrowElement())
     796                 :          0 :             return (const TokenId) nElementAkt+1;
     797                 :            : 
     798         [ #  # ]:          0 :     if( nP_NlfAkt >= nP_Nlf )
     799         [ #  # ]:          0 :         if (!GrowNlf())
     800                 :          0 :             return (const TokenId) nElementAkt+1;
     801                 :            : 
     802                 :          0 :     pElement[ nElementAkt ] = nP_NlfAkt;
     803                 :          0 :     pType[ nElementAkt ] = T_Nlf;
     804                 :            : 
     805         [ #  # ]:          0 :     if( ppP_Nlf[ nP_NlfAkt ] )
     806                 :            :     {
     807                 :          0 :         ppP_Nlf[ nP_NlfAkt ]->aRef = rTr;
     808                 :            :     }
     809                 :            :     else
     810                 :          0 :         ppP_Nlf[ nP_NlfAkt ] = new NLFCONT( rTr );
     811                 :            : 
     812                 :          0 :     nElementAkt++;
     813                 :          0 :     nP_NlfAkt++;
     814                 :            : 
     815                 :          0 :     return ( const TokenId ) nElementAkt;
     816                 :            : }
     817                 :            : 
     818                 :          3 : const TokenId TokenPool::StoreMatrix()
     819                 :            : {
     820                 :            :     ScMatrix* pM;
     821                 :            : 
     822         [ -  + ]:          3 :     if( nElementAkt >= nElement )
     823         [ #  # ]:          0 :         if (!GrowElement())
     824                 :          0 :             return (const TokenId) nElementAkt+1;
     825                 :            : 
     826         [ -  + ]:          3 :     if( nP_MatrixAkt >= nP_Matrix )
     827         [ #  # ]:          0 :         if (!GrowMatrix())
     828                 :          0 :             return (const TokenId) nElementAkt+1;
     829                 :            : 
     830                 :          3 :     pElement[ nElementAkt ] = nP_MatrixAkt;
     831                 :          3 :     pType[ nElementAkt ] = T_Matrix;
     832                 :            : 
     833         [ +  - ]:          3 :     pM = new ScMatrix( 0, 0 );
     834                 :          3 :     pM->IncRef( );
     835                 :          3 :     ppP_Matrix[ nP_MatrixAkt ] = pM;
     836                 :            : 
     837                 :          3 :     nElementAkt++;
     838                 :          3 :     nP_MatrixAkt++;
     839                 :            : 
     840                 :          3 :     return ( const TokenId ) nElementAkt;
     841                 :            : }
     842                 :            : 
     843                 :         42 : const TokenId TokenPool::StoreName( sal_uInt16 nIndex, bool bGlobal )
     844                 :            : {
     845         [ -  + ]:         42 :     if ( nElementAkt >= nElement )
     846         [ #  # ]:          0 :         if (!GrowElement())
     847                 :          0 :             return (const TokenId) nElementAkt+1;
     848                 :            : 
     849                 :         42 :     pElement[nElementAkt] = static_cast<sal_uInt16>(maRangeNames.size());
     850                 :         42 :     pType[nElementAkt] = T_RN;
     851                 :            : 
     852         [ +  - ]:         42 :     maRangeNames.push_back(RangeName());
     853                 :         42 :     RangeName& r = maRangeNames.back();
     854                 :         42 :     r.mnIndex = nIndex;
     855                 :         42 :     r.mbGlobal = bGlobal;
     856                 :            : 
     857                 :         42 :     ++nElementAkt;
     858                 :            : 
     859                 :         42 :     return static_cast<const TokenId>(nElementAkt);
     860                 :            : }
     861                 :            : 
     862                 :          0 : const TokenId TokenPool::StoreExtName( sal_uInt16 nFileId, const String& rName )
     863                 :            : {
     864         [ #  # ]:          0 :     if ( nElementAkt >= nElement )
     865         [ #  # ]:          0 :         if (!GrowElement())
     866                 :          0 :             return (const TokenId) nElementAkt+1;
     867                 :            : 
     868                 :          0 :     pElement[nElementAkt] = static_cast<sal_uInt16>(maExtNames.size());
     869                 :          0 :     pType[nElementAkt] = T_ExtName;
     870                 :            : 
     871         [ #  # ]:          0 :     maExtNames.push_back(ExtName());
     872                 :          0 :     ExtName& r = maExtNames.back();
     873                 :          0 :     r.mnFileId = nFileId;
     874                 :          0 :     r.maName = rName;
     875                 :            : 
     876                 :          0 :     ++nElementAkt;
     877                 :            : 
     878                 :          0 :     return static_cast<const TokenId>(nElementAkt);
     879                 :            : }
     880                 :            : 
     881                 :          0 : const TokenId TokenPool::StoreExtRef( sal_uInt16 nFileId, const String& rTabName, const ScSingleRefData& rRef )
     882                 :            : {
     883         [ #  # ]:          0 :     if ( nElementAkt >= nElement )
     884         [ #  # ]:          0 :         if (!GrowElement())
     885                 :          0 :             return (const TokenId) nElementAkt+1;
     886                 :            : 
     887                 :          0 :     pElement[nElementAkt] = static_cast<sal_uInt16>(maExtCellRefs.size());
     888                 :          0 :     pType[nElementAkt] = T_ExtRefC;
     889                 :            : 
     890         [ #  # ]:          0 :     maExtCellRefs.push_back(ExtCellRef());
     891                 :          0 :     ExtCellRef& r = maExtCellRefs.back();
     892                 :          0 :     r.mnFileId = nFileId;
     893                 :          0 :     r.maTabName = rTabName;
     894                 :          0 :     r.maRef = rRef;
     895                 :            : 
     896                 :          0 :     ++nElementAkt;
     897                 :            : 
     898                 :          0 :     return static_cast<const TokenId>(nElementAkt);
     899                 :            : }
     900                 :            : 
     901                 :          0 : const TokenId TokenPool::StoreExtRef( sal_uInt16 nFileId, const String& rTabName, const ScComplexRefData& rRef )
     902                 :            : {
     903         [ #  # ]:          0 :     if ( nElementAkt >= nElement )
     904         [ #  # ]:          0 :         if (!GrowElement())
     905                 :          0 :             return (const TokenId) nElementAkt+1;
     906                 :            : 
     907                 :          0 :     pElement[nElementAkt] = static_cast<sal_uInt16>(maExtAreaRefs.size());
     908                 :          0 :     pType[nElementAkt] = T_ExtRefA;
     909                 :            : 
     910         [ #  # ]:          0 :     maExtAreaRefs.push_back(ExtAreaRef());
     911                 :          0 :     ExtAreaRef& r = maExtAreaRefs.back();
     912                 :          0 :     r.mnFileId = nFileId;
     913                 :          0 :     r.maTabName = rTabName;
     914                 :          0 :     r.maRef = rRef;
     915                 :            : 
     916                 :          0 :     ++nElementAkt;
     917                 :            : 
     918                 :          0 :     return static_cast<const TokenId>(nElementAkt);
     919                 :            : }
     920                 :            : 
     921                 :       2027 : void TokenPool::Reset( void )
     922                 :            : {
     923                 :       2027 :     nP_IdAkt = nP_IdLast = nElementAkt = nP_StrAkt = nP_DblAkt = nP_ErrAkt = nP_RefTrAkt = nP_ExtAkt = nP_NlfAkt = nP_MatrixAkt = 0;
     924                 :       2027 :     maRangeNames.clear();
     925                 :       2027 :     maExtNames.clear();
     926                 :       2027 :     maExtCellRefs.clear();
     927                 :       2027 :     maExtAreaRefs.clear();
     928                 :       2027 : }
     929                 :            : 
     930                 :            : 
     931                 :          9 : sal_Bool TokenPool::IsSingleOp( const TokenId& rId, const DefTokenId eId ) const
     932                 :            : {
     933                 :          9 :     sal_uInt16 nId = (sal_uInt16) rId;
     934 [ +  - ][ +  - ]:          9 :     if( nId && nId <= nElementAkt )
     935                 :            :     {// existent?
     936                 :          9 :         nId--;
     937         [ +  + ]:          9 :         if( T_Id == pType[ nId ] )
     938                 :            :         {// Tokenfolge?
     939         [ -  + ]:          6 :             if( pSize[ nId ] == 1 )
     940                 :            :             {// GENAU 1 Token
     941                 :          0 :                 sal_uInt16 nPid = pElement[ nId ];
     942         [ #  # ]:          0 :                 if (nPid < nP_Id)
     943                 :            :                 {
     944                 :          0 :                     sal_uInt16 nSecId = pP_Id[ nPid ];
     945         [ #  # ]:          0 :                     if( nSecId >= nScTokenOff )
     946                 :            :                     {// Default-Token?
     947                 :          0 :                         return ( DefTokenId ) ( nSecId - nScTokenOff ) == eId;  // Gesuchter?
     948                 :            :                     }
     949                 :            :                 }
     950                 :            :             }
     951                 :            :         }
     952                 :            :     }
     953                 :            : 
     954                 :          9 :     return false;
     955                 :            : }
     956                 :            : 
     957                 :          3 : const String* TokenPool::GetExternal( const TokenId& rId ) const
     958                 :            : {
     959                 :          3 :     const String*   p = NULL;
     960                 :          3 :     sal_uInt16 n = (sal_uInt16) rId;
     961 [ +  - ][ +  - ]:          3 :     if( n && n <= nElementAkt )
     962                 :            :     {
     963                 :          3 :         n--;
     964         [ +  - ]:          3 :         if( pType[ n ] == T_Ext )
     965                 :            :         {
     966                 :          3 :             sal_uInt16 nExt = pElement[ n ];
     967 [ +  - ][ +  - ]:          3 :             if ( nExt < nP_Ext && ppP_Ext[ nExt ] )
     968                 :          3 :                 p = &ppP_Ext[ nExt ]->aText;
     969                 :            :         }
     970                 :            :     }
     971                 :            : 
     972                 :          3 :     return p;
     973                 :            : }
     974                 :            : 
     975                 :          3 : ScMatrix* TokenPool::GetMatrix( unsigned int n ) const
     976                 :            : {
     977         [ +  - ]:          3 :     if( n < nP_MatrixAkt )
     978                 :          3 :         return ppP_Matrix[ n ];
     979                 :            :     else
     980                 :          0 :         printf ("GETMATRIX %d >= %d\n", n, nP_MatrixAkt);
     981                 :          3 :     return NULL;
     982                 :            : }
     983                 :            : 
     984                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10