[Libreoffice-commits] .: sc/source

Kohei Yoshida kohei at kemper.freedesktop.org
Tue Jan 11 20:54:31 PST 2011


 sc/source/core/tool/interpr1.cxx |  644 +++++++++++++++++++--------------------
 1 file changed, 322 insertions(+), 322 deletions(-)

New commits:
commit bfc378b61bc7a9404c359d75ddfed035ccd65a60
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Tue Jan 11 23:54:03 2011 -0500

    Prefer early bail out in order to reduce indentation levels.

diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index ae31357..c26abb0 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -4756,380 +4756,326 @@ void ScInterpreter::ScCountIf()
 
 void ScInterpreter::ScSumIf()
 {
-    RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er", "ScInterpreter::ScSumIf" );
     BYTE nParamCount = GetByte();
-    if ( MustHaveParamCount( nParamCount, 2, 3 ) )
-    {
-        SCCOL nCol3 = 0;
-        SCROW nRow3 = 0;
-        SCTAB nTab3 = 0;
+    if ( !MustHaveParamCount( nParamCount, 2, 3 ) )
+        return;
 
-        ScMatrixRef pSumExtraMatrix;
-        bool bSumExtraRange = (nParamCount == 3);
-        if (bSumExtraRange)
-        {
-            // Save only the upperleft cell in case of cell range.  The geometry
-            // of the 3rd parameter is taken from the 1st parameter.
+    SCCOL nCol3 = 0;
+    SCROW nRow3 = 0;
+    SCTAB nTab3 = 0;
 
-            switch ( GetStackType() )
-            {
-                case svDoubleRef :
-                {
-                    SCCOL nColJunk = 0;
-                    SCROW nRowJunk = 0;
-                    SCTAB nTabJunk = 0;
-                    PopDoubleRef( nCol3, nRow3, nTab3, nColJunk, nRowJunk, nTabJunk );
-                    if ( nTabJunk != nTab3 )
-                    {
-                        PushIllegalParameter();
-                        return;
-                    }
-                }
-                break;
-                case svSingleRef :
-                    PopSingleRef( nCol3, nRow3, nTab3 );
-                break;
-                case svMatrix:
-                    pSumExtraMatrix = PopMatrix();
-                    //! nCol3, nRow3, nTab3 remain 0
-                break;
-                case svExternalSingleRef:
-                {
-                    pSumExtraMatrix = new ScMatrix(1, 1);
-                    ScExternalRefCache::TokenRef pToken;
-                    PopExternalSingleRef(pToken);
-                    if (!pToken)
-                    {
-                        PushIllegalParameter();
-                        return;
-                    }
+    ScMatrixRef pSumExtraMatrix;
+    bool bSumExtraRange = (nParamCount == 3);
+    if (bSumExtraRange)
+    {
+        // Save only the upperleft cell in case of cell range.  The geometry
+        // of the 3rd parameter is taken from the 1st parameter.
 
-                    if (pToken->GetType() == svDouble)
-                        pSumExtraMatrix->PutDouble(pToken->GetDouble(), 0, 0);
-                    else
-                        pSumExtraMatrix->PutString(pToken->GetString(), 0, 0);
-                }
-                break;
-                case svExternalDoubleRef:
-                    PopExternalDoubleRef(pSumExtraMatrix);
-                break;
-                default:
-                    PushIllegalParameter();
-                    return ;
-            }
-        }
-        String aString;
-        double fVal = 0.0;
-        bool bIsString = true;
         switch ( GetStackType() )
         {
             case svDoubleRef :
-            case svSingleRef :
             {
-                ScAddress aAdr;
-                if ( !PopDoubleRefOrSingleRef( aAdr ) )
+                SCCOL nColJunk = 0;
+                SCROW nRowJunk = 0;
+                SCTAB nTabJunk = 0;
+                PopDoubleRef( nCol3, nRow3, nTab3, nColJunk, nRowJunk, nTabJunk );
+                if ( nTabJunk != nTab3 )
                 {
-                    PushInt(0);
-                    return ;
-                }
-                ScBaseCell* pCell = GetCell( aAdr );
-                switch ( GetCellType( pCell ) )
-                {
-                    case CELLTYPE_VALUE :
-                        fVal = GetCellValue( aAdr, pCell );
-                        bIsString = false;
-                        break;
-                    case CELLTYPE_FORMULA :
-                        if( ((ScFormulaCell*)pCell)->IsValue() )
-                        {
-                            fVal = GetCellValue( aAdr, pCell );
-                            bIsString = false;
-                        }
-                        else
-                            GetCellString(aString, pCell);
-                        break;
-                    case CELLTYPE_STRING :
-                    case CELLTYPE_EDIT :
-                        GetCellString(aString, pCell);
-                        break;
-                    default:
-                        fVal = 0.0;
-                        bIsString = false;
+                    PushIllegalParameter();
+                    return;
                 }
             }
             break;
-            case svString:
-                aString = GetString();
+            case svSingleRef :
+                PopSingleRef( nCol3, nRow3, nTab3 );
             break;
-            case svMatrix :
-            case svExternalDoubleRef:
-            {
-                ScMatValType nType = GetDoubleOrStringFromMatrix(fVal, aString);
-                bIsString = ScMatrix::IsNonValueType( nType);
-            }
+            case svMatrix:
+                pSumExtraMatrix = PopMatrix();
+                //! nCol3, nRow3, nTab3 remain 0
             break;
             case svExternalSingleRef:
             {
+                pSumExtraMatrix = new ScMatrix(1, 1);
                 ScExternalRefCache::TokenRef pToken;
                 PopExternalSingleRef(pToken);
-                if (pToken)
+                if (!pToken)
                 {
-                    if (pToken->GetType() == svDouble)
-                    {
-                        fVal = pToken->GetDouble();
-                        bIsString = false;
-                    }
-                    else
-                        aString = pToken->GetString();
+                    PushIllegalParameter();
+                    return;
                 }
+
+                if (pToken->GetType() == svDouble)
+                    pSumExtraMatrix->PutDouble(pToken->GetDouble(), 0, 0);
+                else
+                    pSumExtraMatrix->PutString(pToken->GetString(), 0, 0);
             }
             break;
+            case svExternalDoubleRef:
+                PopExternalDoubleRef(pSumExtraMatrix);
+            break;
             default:
-            {
-                fVal = GetDouble();
-                bIsString = false;
-            }
+                PushIllegalParameter();
+                return ;
         }
+    }
 
-        double fSum = 0.0;
-        double fMem = 0.0;
-        BOOL bNull = TRUE;
-        short nParam = 1;
-        size_t nRefInList = 0;
-        while (nParam-- > 0)
+    String aString;
+    double fVal = 0.0;
+    bool bIsString = true;
+    switch ( GetStackType() )
+    {
+        case svDoubleRef :
+        case svSingleRef :
         {
-            SCCOL nCol1;
-            SCROW nRow1;
-            SCTAB nTab1;
-            SCCOL nCol2;
-            SCROW nRow2;
-            SCTAB nTab2;
-            ScMatrixRef pQueryMatrix;
-            switch ( GetStackType() )
+            ScAddress aAdr;
+            if ( !PopDoubleRefOrSingleRef( aAdr ) )
             {
-                case svRefList :
-                    if (bSumExtraRange)
+                PushInt(0);
+                return ;
+            }
+            ScBaseCell* pCell = GetCell( aAdr );
+            switch ( GetCellType( pCell ) )
+            {
+                case CELLTYPE_VALUE :
+                    fVal = GetCellValue( aAdr, pCell );
+                    bIsString = false;
+                    break;
+                case CELLTYPE_FORMULA :
+                    if( ((ScFormulaCell*)pCell)->IsValue() )
                     {
-                        PushIllegalParameter();
-                        return;
+                        fVal = GetCellValue( aAdr, pCell );
+                        bIsString = false;
                     }
                     else
-                    {
-                        ScRange aRange;
-                        PopDoubleRef( aRange, nParam, nRefInList);
-                        aRange.GetVars( nCol1, nRow1, nTab1, nCol2, nRow2, nTab2);
-                    }
-                    break;
-                case svDoubleRef :
-                    PopDoubleRef( nCol1, nRow1, nTab1, nCol2, nRow2, nTab2 );
+                        GetCellString(aString, pCell);
                     break;
-                case svSingleRef :
-                    PopSingleRef( nCol1, nRow1, nTab1 );
-                    nCol2 = nCol1;
-                    nRow2 = nRow1;
-                    nTab2 = nTab1;
+                case CELLTYPE_STRING :
+                case CELLTYPE_EDIT :
+                    GetCellString(aString, pCell);
                     break;
-                case svMatrix:
-                case svExternalSingleRef:
-                case svExternalDoubleRef:
-                {
-                    if (GetStackType() == svMatrix)
-                        pQueryMatrix = PopMatrix();
-                    else if (GetStackType() == svExternalDoubleRef)
-                        PopExternalDoubleRef(pQueryMatrix);
-                    else
-                    {
-                        OSL_ENSURE(GetStackType() == svExternalSingleRef, "external single ref is expected, but that's not what we found.");
-                        ScExternalRefCache::TokenRef pToken;
-                        PopExternalSingleRef(pToken);
-                        if (pToken)
-                        {
-                            pQueryMatrix = new ScMatrix(1, 1);
-                            if (pToken->GetType() == svDouble)
-                                pQueryMatrix->PutDouble(pToken->GetDouble(), 0, 0);
-                            else
-                                pQueryMatrix->PutString(pToken->GetString(), 0, 0);
-                        }
-                    }
-
-                    if (!pQueryMatrix)
-                    {
-                        PushIllegalParameter();
-                        return;
-                    }
-                    nCol1 = 0;
-                    nRow1 = 0;
-                    nTab1 = 0;
-                    SCSIZE nC, nR;
-                    pQueryMatrix->GetDimensions( nC, nR);
-                    nCol2 = static_cast<SCCOL>(nC - 1);
-                    nRow2 = static_cast<SCROW>(nR - 1);
-                    nTab2 = 0;
-                }
-                break;
                 default:
-                    PushIllegalParameter();
-                    return ;
+                    fVal = 0.0;
+                    bIsString = false;
             }
-            if ( nTab1 != nTab2 )
+        }
+        break;
+        case svString:
+            aString = GetString();
+        break;
+        case svMatrix :
+        case svExternalDoubleRef:
+        {
+            ScMatValType nType = GetDoubleOrStringFromMatrix(fVal, aString);
+            bIsString = ScMatrix::IsNonValueType( nType);
+        }
+        break;
+        case svExternalSingleRef:
+        {
+            ScExternalRefCache::TokenRef pToken;
+            PopExternalSingleRef(pToken);
+            if (pToken)
             {
-                PushIllegalArgument();
-                return;
+                if (pToken->GetType() == svDouble)
+                {
+                    fVal = pToken->GetDouble();
+                    bIsString = false;
+                }
+                else
+                    aString = pToken->GetString();
             }
+        }
+        break;
+        default:
+        {
+            fVal = GetDouble();
+            bIsString = false;
+        }
+    }
 
-            if (bSumExtraRange)
-            {
-                // Take the range geometry of the 1st parameter and apply it to
-                // the 3rd. If parts of the resulting range would point outside
-                // the sheet, don't complain but silently ignore and simply cut
-                // them away, this is what Xcl does :-/
-
-                // For the cut-away part we also don't need to determine the
-                // criteria match, so shrink the source range accordingly,
-                // instead of the result range.
-                SCCOL nColDelta = nCol2 - nCol1;
-                SCROW nRowDelta = nRow2 - nRow1;
-                SCCOL nMaxCol;
-                SCROW nMaxRow;
-                if (pSumExtraMatrix)
+    double fSum = 0.0;
+    double fMem = 0.0;
+    BOOL bNull = TRUE;
+    short nParam = 1;
+    size_t nRefInList = 0;
+    while (nParam-- > 0)
+    {
+        SCCOL nCol1;
+        SCROW nRow1;
+        SCTAB nTab1;
+        SCCOL nCol2;
+        SCROW nRow2;
+        SCTAB nTab2;
+        ScMatrixRef pQueryMatrix;
+        switch ( GetStackType() )
+        {
+            case svRefList :
+                if (bSumExtraRange)
                 {
-                    SCSIZE nC, nR;
-                    pSumExtraMatrix->GetDimensions( nC, nR);
-                    nMaxCol = static_cast<SCCOL>(nC - 1);
-                    nMaxRow = static_cast<SCROW>(nR - 1);
+                    PushIllegalParameter();
+                    return;
                 }
                 else
                 {
-                    nMaxCol = MAXCOL;
-                    nMaxRow = MAXROW;
+                    ScRange aRange;
+                    PopDoubleRef( aRange, nParam, nRefInList);
+                    aRange.GetVars( nCol1, nRow1, nTab1, nCol2, nRow2, nTab2);
                 }
-                if (nCol3 + nColDelta > nMaxCol)
+                break;
+            case svDoubleRef :
+                PopDoubleRef( nCol1, nRow1, nTab1, nCol2, nRow2, nTab2 );
+                break;
+            case svSingleRef :
+                PopSingleRef( nCol1, nRow1, nTab1 );
+                nCol2 = nCol1;
+                nRow2 = nRow1;
+                nTab2 = nTab1;
+                break;
+            case svMatrix:
+            case svExternalSingleRef:
+            case svExternalDoubleRef:
+            {
+                if (GetStackType() == svMatrix)
+                    pQueryMatrix = PopMatrix();
+                else if (GetStackType() == svExternalDoubleRef)
+                    PopExternalDoubleRef(pQueryMatrix);
+                else
                 {
-                    SCCOL nNewDelta = nMaxCol - nCol3;
-                    nCol2 = nCol1 + nNewDelta;
+                    OSL_ENSURE(GetStackType() == svExternalSingleRef, "external single ref is expected, but that's not what we found.");
+                    ScExternalRefCache::TokenRef pToken;
+                    PopExternalSingleRef(pToken);
+                    if (pToken)
+                    {
+                        pQueryMatrix = new ScMatrix(1, 1);
+                        if (pToken->GetType() == svDouble)
+                            pQueryMatrix->PutDouble(pToken->GetDouble(), 0, 0);
+                        else
+                            pQueryMatrix->PutString(pToken->GetString(), 0, 0);
+                    }
                 }
 
-                if (nRow3 + nRowDelta > nMaxRow)
+                if (!pQueryMatrix)
                 {
-                    SCROW nNewDelta = nMaxRow - nRow3;
-                    nRow2 = nRow1 + nNewDelta;
+                    PushIllegalParameter();
+                    return;
                 }
+                nCol1 = 0;
+                nRow1 = 0;
+                nTab1 = 0;
+                SCSIZE nC, nR;
+                pQueryMatrix->GetDimensions( nC, nR);
+                nCol2 = static_cast<SCCOL>(nC - 1);
+                nRow2 = static_cast<SCROW>(nR - 1);
+                nTab2 = 0;
+            }
+            break;
+            default:
+                PushIllegalParameter();
+                return ;
+        }
+        if ( nTab1 != nTab2 )
+        {
+            PushIllegalArgument();
+            return;
+        }
+
+        if (bSumExtraRange)
+        {
+            // Take the range geometry of the 1st parameter and apply it to
+            // the 3rd. If parts of the resulting range would point outside
+            // the sheet, don't complain but silently ignore and simply cut
+            // them away, this is what Xcl does :-/
+
+            // For the cut-away part we also don't need to determine the
+            // criteria match, so shrink the source range accordingly,
+            // instead of the result range.
+            SCCOL nColDelta = nCol2 - nCol1;
+            SCROW nRowDelta = nRow2 - nRow1;
+            SCCOL nMaxCol;
+            SCROW nMaxRow;
+            if (pSumExtraMatrix)
+            {
+                SCSIZE nC, nR;
+                pSumExtraMatrix->GetDimensions( nC, nR);
+                nMaxCol = static_cast<SCCOL>(nC - 1);
+                nMaxRow = static_cast<SCROW>(nR - 1);
             }
             else
             {
-                nCol3 = nCol1;
-                nRow3 = nRow1;
-                nTab3 = nTab1;
+                nMaxCol = MAXCOL;
+                nMaxRow = MAXROW;
+            }
+            if (nCol3 + nColDelta > nMaxCol)
+            {
+                SCCOL nNewDelta = nMaxCol - nCol3;
+                nCol2 = nCol1 + nNewDelta;
             }
 
-            if (nGlobalError == 0)
+            if (nRow3 + nRowDelta > nMaxRow)
             {
-                ScQueryParam rParam;
-                rParam.nRow1       = nRow1;
-                rParam.nRow2       = nRow2;
+                SCROW nNewDelta = nMaxRow - nRow3;
+                nRow2 = nRow1 + nNewDelta;
+            }
+        }
+        else
+        {
+            nCol3 = nCol1;
+            nRow3 = nRow1;
+            nTab3 = nTab1;
+        }
 
-                ScQueryEntry& rEntry = rParam.GetEntry(0);
-                rEntry.bDoQuery = TRUE;
-                if (!bIsString)
-                {
-                    rEntry.bQueryByString = FALSE;
-                    rEntry.nVal = fVal;
-                    rEntry.eOp = SC_EQUAL;
-                }
-                else
+        if (nGlobalError == 0)
+        {
+            ScQueryParam rParam;
+            rParam.nRow1       = nRow1;
+            rParam.nRow2       = nRow2;
+
+            ScQueryEntry& rEntry = rParam.GetEntry(0);
+            rEntry.bDoQuery = TRUE;
+            if (!bIsString)
+            {
+                rEntry.bQueryByString = FALSE;
+                rEntry.nVal = fVal;
+                rEntry.eOp = SC_EQUAL;
+            }
+            else
+            {
+                rParam.FillInExcelSyntax(aString, 0);
+                sal_uInt32 nIndex = 0;
+                rEntry.bQueryByString =
+                    !(pFormatter->IsNumberFormat(
+                                *rEntry.pStr, nIndex, rEntry.nVal));
+                if ( rEntry.bQueryByString )
+                    rParam.bRegExp = MayBeRegExp( *rEntry.pStr, pDok );
+            }
+            ScAddress aAdr;
+            aAdr.SetTab( nTab3 );
+            rParam.nCol1  = nCol1;
+            rParam.nCol2  = nCol2;
+            rEntry.nField = nCol1;
+            SCsCOL nColDiff = nCol3 - nCol1;
+            SCsROW nRowDiff = nRow3 - nRow1;
+            if (pQueryMatrix)
+            {
+                // Never case-sensitive.
+                ScCompareOptions aOptions( pDok, rEntry, rParam.bRegExp);
+                ScMatrixRef pResultMatrix = QueryMat( pQueryMatrix, aOptions);
+                if (nGlobalError || !pResultMatrix)
                 {
-                    rParam.FillInExcelSyntax(aString, 0);
-                    sal_uInt32 nIndex = 0;
-                    rEntry.bQueryByString =
-                        !(pFormatter->IsNumberFormat(
-                                    *rEntry.pStr, nIndex, rEntry.nVal));
-                    if ( rEntry.bQueryByString )
-                        rParam.bRegExp = MayBeRegExp( *rEntry.pStr, pDok );
+                    PushIllegalParameter();
+                    return;
                 }
-                ScAddress aAdr;
-                aAdr.SetTab( nTab3 );
-                rParam.nCol1  = nCol1;
-                rParam.nCol2  = nCol2;
-                rEntry.nField = nCol1;
-                SCsCOL nColDiff = nCol3 - nCol1;
-                SCsROW nRowDiff = nRow3 - nRow1;
-                if (pQueryMatrix)
-                {
-                    // Never case-sensitive.
-                    ScCompareOptions aOptions( pDok, rEntry, rParam.bRegExp);
-                    ScMatrixRef pResultMatrix = QueryMat( pQueryMatrix, aOptions);
-                    if (nGlobalError || !pResultMatrix)
-                    {
-                        PushIllegalParameter();
-                        return;
-                    }
 
-                    if (pSumExtraMatrix)
-                    {
-                        for (SCCOL nCol = nCol1; nCol <= nCol2; ++nCol)
-                        {
-                            for (SCROW nRow = nRow1; nRow <= nRow2; ++nRow)
-                            {
-                                if (pResultMatrix->IsValue( nCol, nRow) &&
-                                        pResultMatrix->GetDouble( nCol, nRow))
-                                {
-                                    SCSIZE nC = nCol + nColDiff;
-                                    SCSIZE nR = nRow + nRowDiff;
-                                    if (pSumExtraMatrix->IsValue( nC, nR))
-                                    {
-                                        fVal = pSumExtraMatrix->GetDouble( nC, nR);
-                                        if ( bNull && fVal != 0.0 )
-                                        {
-                                            bNull = FALSE;
-                                            fMem = fVal;
-                                        }
-                                        else
-                                            fSum += fVal;
-                                    }
-                                }
-                            }
-                        }
-                    }
-                    else
-                    {
-                        for (SCCOL nCol = nCol1; nCol <= nCol2; ++nCol)
-                        {
-                            for (SCROW nRow = nRow1; nRow <= nRow2; ++nRow)
-                            {
-                                if (pResultMatrix->GetDouble( nCol, nRow))
-                                {
-                                    aAdr.SetCol( nCol + nColDiff);
-                                    aAdr.SetRow( nRow + nRowDiff);
-                                    ScBaseCell* pCell = GetCell( aAdr );
-                                    if ( HasCellValueData(pCell) )
-                                    {
-                                        fVal = GetCellValue( aAdr, pCell );
-                                        if ( bNull && fVal != 0.0 )
-                                        {
-                                            bNull = FALSE;
-                                            fMem = fVal;
-                                        }
-                                        else
-                                            fSum += fVal;
-                                    }
-                                }
-                            }
-                        }
-                    }
-                }
-                else
+                if (pSumExtraMatrix)
                 {
-                    ScQueryCellIterator aCellIter(pDok, nTab1, rParam, FALSE);
-                    // Increment Entry.nField in iterator when switching to next column.
-                    aCellIter.SetAdvanceQueryParamEntryField( TRUE );
-                    if ( aCellIter.GetFirst() )
+                    for (SCCOL nCol = nCol1; nCol <= nCol2; ++nCol)
                     {
-                        if (pSumExtraMatrix)
+                        for (SCROW nRow = nRow1; nRow <= nRow2; ++nRow)
                         {
-                            do
+                            if (pResultMatrix->IsValue( nCol, nRow) &&
+                                    pResultMatrix->GetDouble( nCol, nRow))
                             {
-                                SCSIZE nC = aCellIter.GetCol() + nColDiff;
-                                SCSIZE nR = aCellIter.GetRow() + nRowDiff;
+                                SCSIZE nC = nCol + nColDiff;
+                                SCSIZE nR = nRow + nRowDiff;
                                 if (pSumExtraMatrix->IsValue( nC, nR))
                                 {
                                     fVal = pSumExtraMatrix->GetDouble( nC, nR);
@@ -5141,14 +5087,20 @@ void ScInterpreter::ScSumIf()
                                     else
                                         fSum += fVal;
                                 }
-                            } while ( aCellIter.GetNext() );
+                            }
                         }
-                        else
+                    }
+                }
+                else
+                {
+                    for (SCCOL nCol = nCol1; nCol <= nCol2; ++nCol)
+                    {
+                        for (SCROW nRow = nRow1; nRow <= nRow2; ++nRow)
                         {
-                            do
+                            if (pResultMatrix->GetDouble( nCol, nRow))
                             {
-                                aAdr.SetCol( aCellIter.GetCol() + nColDiff);
-                                aAdr.SetRow( aCellIter.GetRow() + nRowDiff);
+                                aAdr.SetCol( nCol + nColDiff);
+                                aAdr.SetRow( nRow + nRowDiff);
                                 ScBaseCell* pCell = GetCell( aAdr );
                                 if ( HasCellValueData(pCell) )
                                 {
@@ -5161,19 +5113,67 @@ void ScInterpreter::ScSumIf()
                                     else
                                         fSum += fVal;
                                 }
-                            } while ( aCellIter.GetNext() );
+                            }
                         }
                     }
                 }
             }
             else
             {
-                PushIllegalParameter();
-                return;
+                ScQueryCellIterator aCellIter(pDok, nTab1, rParam, FALSE);
+                // Increment Entry.nField in iterator when switching to next column.
+                aCellIter.SetAdvanceQueryParamEntryField( TRUE );
+                if ( aCellIter.GetFirst() )
+                {
+                    if (pSumExtraMatrix)
+                    {
+                        do
+                        {
+                            SCSIZE nC = aCellIter.GetCol() + nColDiff;
+                            SCSIZE nR = aCellIter.GetRow() + nRowDiff;
+                            if (pSumExtraMatrix->IsValue( nC, nR))
+                            {
+                                fVal = pSumExtraMatrix->GetDouble( nC, nR);
+                                if ( bNull && fVal != 0.0 )
+                                {
+                                    bNull = FALSE;
+                                    fMem = fVal;
+                                }
+                                else
+                                    fSum += fVal;
+                            }
+                        } while ( aCellIter.GetNext() );
+                    }
+                    else
+                    {
+                        do
+                        {
+                            aAdr.SetCol( aCellIter.GetCol() + nColDiff);
+                            aAdr.SetRow( aCellIter.GetRow() + nRowDiff);
+                            ScBaseCell* pCell = GetCell( aAdr );
+                            if ( HasCellValueData(pCell) )
+                            {
+                                fVal = GetCellValue( aAdr, pCell );
+                                if ( bNull && fVal != 0.0 )
+                                {
+                                    bNull = FALSE;
+                                    fMem = fVal;
+                                }
+                                else
+                                    fSum += fVal;
+                            }
+                        } while ( aCellIter.GetNext() );
+                    }
+                }
             }
         }
-        PushDouble( ::rtl::math::approxAdd( fSum, fMem ) );
+        else
+        {
+            PushIllegalParameter();
+            return;
+        }
     }
+    PushDouble( ::rtl::math::approxAdd( fSum, fMem ) );
 }
 
 


More information about the Libreoffice-commits mailing list