diff -upr old/sc/source/core/tool/interpr1.cxx new/sc/source/core/tool/interpr1.cxx --- old/sc/source/core/tool/interpr1.cxx 2008-02-25 10:02:14.000000000 +0800 +++ new/sc/source/core/tool/interpr1.cxx 2008-03-20 11:29:50.000000000 +0800 @@ -3054,6 +3054,8 @@ double ScInterpreter::IterateParameters( ScAddress aAdr; ScRange aRange; size_t nRefInList = 0; + if ( nGlobalError && ( eFunc == ifCOUNT2 || eFunc == ifCOUNT ) ) + nGlobalError = 0; while (nParamCount-- > 0) { switch (GetStackType()) @@ -3123,6 +3125,13 @@ double ScInterpreter::IterateParameters( case svSingleRef : { PopSingleRef( aAdr ); + if ( nGlobalError && ( eFunc == ifCOUNT2 || eFunc == ifCOUNT ) ) + { + nGlobalError = 0; + if ( eFunc == ifCOUNT2 ) + ++nCount; + break; + } ScBaseCell* pCell = GetCell( aAdr ); if ( pCell ) { @@ -3131,6 +3140,8 @@ double ScInterpreter::IterateParameters( CellType eCellType = pCell->GetCellType(); if (eCellType != CELLTYPE_NONE && eCellType != CELLTYPE_NOTE) nCount++; + if ( nGlobalError ) + nGlobalError = 0; } else if ( pCell->HasValueData() ) { @@ -3151,6 +3162,13 @@ double ScInterpreter::IterateParameters( break; case ifSUMSQ: fRes += fVal * fVal; break; case ifPRODUCT: fRes *= fVal; break; + case ifCOUNT: + if ( nGlobalError ) + { + nGlobalError = 0; + nCount--; + } + break; default: ; // nothing } } @@ -3168,6 +3186,13 @@ double ScInterpreter::IterateParameters( { USHORT nErr = 0; PopDoubleRef( aRange, nParamCount, nRefInList); + if ( nGlobalError && ( eFunc == ifCOUNT2 || eFunc == ifCOUNT ) ) + { + nGlobalError = 0; + if ( eFunc == ifCOUNT2 ) + ++nCount; + break; + } if( eFunc == ifCOUNT2 ) { ScBaseCell* pCell; @@ -3182,6 +3207,8 @@ double ScInterpreter::IterateParameters( } while ( (pCell = aIter.GetNext()) != NULL ); } + if ( nGlobalError ) + nGlobalError = 0; } else { @@ -3226,14 +3253,15 @@ double ScInterpreter::IterateParameters( } while (aValIter.GetNext(fVal, nErr)); break; - default: // count + case ifCOUNT: do { - SetError(nErr); - nCount++; + if ( !nErr ) + nCount++; } while (aValIter.GetNext(fVal, nErr)); break; + default: ; } SetError( nErr ); } @@ -3289,6 +3317,20 @@ double ScInterpreter::IterateParameters( } } break; + case svError: + { + Pop(); + if ( eFunc == ifCOUNT ) + { + nGlobalError = 0; + } + else if ( eFunc == ifCOUNT2 ) + { + nCount++; + nGlobalError = 0; + } + } + break; default : while (nParamCount-- > 0) PopError(); diff -upr old/sc/source/core/tool/interpr4.cxx new/sc/source/core/tool/interpr4.cxx --- old/sc/source/core/tool/interpr4.cxx 2008-02-25 10:02:52.000000000 +0800 +++ new/sc/source/core/tool/interpr4.cxx 2008-03-07 14:44:46.000000000 +0800 @@ -3710,6 +3710,8 @@ StackVar ScInterpreter::Interpret() // Functions that evaluate an error code and directly set nGlobalError to 0, // usage: switch( OpCode ) { CASE_OCERRFUNC statements; } #define CASE_OCERRFUNC \ + case ocCount : \ + case ocCount2 : \ case ocErrorType : \ case ocIsEmpty : \ case ocIsErr : \