diff -cNr yuan/interpr1.cxx xiugai/interpr1.cxx *** sc/source/core/tool/interpr1.cxx Mon Dec 10 14:59:32 2007 --- sc/source/core/tool/interpr1.cxx Mon Dec 10 15:00:16 2007 *************** *** 2768,2773 **** --- 2768,2776 ---- double nVal = 0.0; ScAddress aAdr; ScRange aRange; + SCSIZE nEmptySingleRefCount = 0; + SCSIZE nEmptyDoubleRefCount = 0; + SCSIZE nEmptyMatCount = 0; for (short i = 0; i < nParamCount; i++) { switch (GetStackType()) *************** *** 2794,2799 **** --- 2797,2804 ---- if ( nMin > 0.0 ) nMin = 0.0; } + else if ( ( pCell && pCell->GetStringData().Len() == 0) || !pCell ) + nEmptySingleRefCount++; } break; case svDoubleRef : *************** *** 2801,2806 **** --- 2806,2812 ---- USHORT nErr = 0; PopDoubleRef( aRange ); ScValueIterator aValIter( pDok, aRange, glSubTotal, bTextAsZero ); + ScValueIterator aValIterWithText( pDok, aRange, glSubTotal, TRUE ); if (aValIter.GetFirst(nVal, nErr)) { if (nMin > nVal) *************** *** 2813,2818 **** --- 2819,2826 ---- } SetError(nErr); } + else if (!aValIterWithText.GetFirst(nVal, nErr)) + nEmptyDoubleRefCount++; } break; case svMatrix : *************** *** 2834,2841 **** --- 2842,2851 ---- } else { + SCSIZE nEmpSubMatCol = 0; for (SCSIZE nMatCol = 0; nMatCol < nC; nMatCol++) { + SCSIZE nEmpSubMatRow = 0; for (SCSIZE nMatRow = 0; nMatRow < nR; nMatRow++) { if (!pMat->IsString(nMatCol,nMatRow)) *************** *** 2848,2855 **** --- 2858,2871 ---- if ( nMin > 0.0 ) nMin = 0.0; } + else if ( pMat->IsEmpty(nMatCol,nMatRow) ) + nEmpSubMatRow++; } + if (nEmpSubMatRow == nR) + nEmpSubMatCol++; } + if (nEmpSubMatCol == nC) + nEmptyMatCount++; } } } *************** *** 2872,2878 **** } } if (nMin == SC_DOUBLE_MAXVALUE) ! SetIllegalArgument(); else PushDouble(nMin); } --- 2888,2900 ---- } } if (nMin == SC_DOUBLE_MAXVALUE) ! { ! if ((nEmptySingleRefCount+nEmptyMatCount+nEmptyDoubleRefCount) == nParamCount ! && 0!= nParamCount) ! PushDouble(0.0); ! else ! SetIllegalArgument(); ! } else PushDouble(nMin); } *************** *** 2888,2893 **** --- 2910,2918 ---- double nVal = 0.0; ScAddress aAdr; ScRange aRange; + SCSIZE nEmptySingleRefCount = 0; + SCSIZE nEmptyDoubleRefCount = 0; + SCSIZE nEmptyMatCount = 0; for (short i = 0; i < nParamCount; i++) { switch (GetStackType()) *************** *** 2914,2919 **** --- 2939,2946 ---- if ( nMax < 0.0 ) nMax = 0.0; } + else if ( ( pCell && pCell->GetStringData().Len() == 0) || !pCell ) + nEmptySingleRefCount++; } break; case svDoubleRef : *************** *** 2921,2926 **** --- 2948,2954 ---- USHORT nErr = 0; PopDoubleRef( aRange ); ScValueIterator aValIter( pDok, aRange, glSubTotal, bTextAsZero ); + ScValueIterator aValIterWithText( pDok, aRange, glSubTotal, TRUE ); if (aValIter.GetFirst(nVal, nErr)) { if (nMax < nVal) *************** *** 2933,2938 **** --- 2961,2968 ---- } SetError(nErr); } + else if (!aValIterWithText.GetFirst(nVal, nErr)) + nEmptyDoubleRefCount++; } break; case svMatrix : *************** *** 2954,2961 **** --- 2984,2993 ---- } else { + SCSIZE nEmpSubMatCol = 0; for (SCSIZE nMatCol = 0; nMatCol < nC; nMatCol++) { + SCSIZE nEmpSubMatRow = 0; for (SCSIZE nMatRow = 0; nMatRow < nR; nMatRow++) { if (!pMat->IsString(nMatCol,nMatRow)) *************** *** 2968,2975 **** --- 3000,3013 ---- if ( nMax < 0.0 ) nMax = 0.0; } + else if ( pMat->IsEmpty(nMatCol,nMatRow) ) + nEmpSubMatRow++; } + if (nEmpSubMatRow == nR) + nEmpSubMatCol++; } + if (nEmpSubMatCol == nC) + nEmptyMatCount++; } } } *************** *** 2992,2998 **** } } if (nMax == -SC_DOUBLE_MAXVALUE) ! SetIllegalArgument(); else PushDouble(nMax); } --- 3030,3042 ---- } } if (nMax == -SC_DOUBLE_MAXVALUE) ! { ! if ((nEmptySingleRefCount+nEmptyMatCount+nEmptyDoubleRefCount) == nParamCount ! && 0!= nParamCount) ! PushDouble(0.0); ! else ! SetIllegalArgument(); ! } else PushDouble(nMax); }