diff options
Diffstat (limited to 'sc')
-rw-r--r-- | sc/qa/unit/ucalc.cxx | 32 | ||||
-rw-r--r-- | sc/source/core/tool/interpr1.cxx | 45 | ||||
-rw-r--r-- | sc/source/core/tool/parclass.cxx | 11 |
3 files changed, 41 insertions, 47 deletions
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx index 1db6294caec1..a86a3a0bcfd0 100644 --- a/sc/qa/unit/ucalc.cxx +++ b/sc/qa/unit/ucalc.cxx @@ -433,25 +433,37 @@ void testFuncN(ScDocument* pDoc) pDoc->SetString(1, 13, 0, OUString("=N(\"foo\")")); // Range references - pDoc->SetString(1, 14, 0, OUString("=N(A1:A8)")); - pDoc->SetString(1, 15, 0, OUString("=N(A4:B8)")); - pDoc->SetString(1, 16, 0, OUString("=N(A6:B8)")); - pDoc->SetString(1, 17, 0, OUString("=N(A2:B8)")); + pDoc->SetString(2, 2, 0, OUString("=N(A1:A8)")); + pDoc->SetString(2, 3, 0, OUString("=N(A1:A8)")); + pDoc->SetString(2, 4, 0, OUString("=N(A1:A8)")); + pDoc->SetString(2, 5, 0, OUString("=N(A1:A8)")); // Calculate and check the results. pDoc->CalcAll(); - double checks[] = { + double checks1[] = { 0, 0, 0, 1, -1, 12.3, 0, // cell reference - 0, 1, -1, 123, 0, 0, 0, // in-line values - 0, 1, 12.3, 0 // range references + 0, 1, -1, 123, 0, 0, 0 // in-line values }; - for (size_t i = 0; i < SAL_N_ELEMENTS(checks); ++i) + for (size_t i = 0; i < SAL_N_ELEMENTS(checks1); ++i) { pDoc->GetValue(1, i, 0, result); - bool bGood = result == checks[i]; + bool bGood = result == checks1[i]; if (!bGood) { - cerr << "row " << (i+1) << ": expected=" << checks[i] << " actual=" << result << endl; + cerr << "row " << (i+1) << ": expected=" << checks1[i] << " actual=" << result << endl; + CPPUNIT_ASSERT_MESSAGE("Unexpected result for N", false); + } + } + double checks2[] = { + 0, 1, -1, 12.3 // range references + }; + for (size_t i = 0; i < SAL_N_ELEMENTS(checks2); ++i) + { + pDoc->GetValue(1, i+2, 0, result); + bool bGood = result == checks2[i]; + if (!bGood) + { + cerr << "row " << (i+2+1) << ": expected=" << checks2[i] << " actual=" << result << endl; CPPUNIT_ASSERT_MESSAGE("Unexpected result for N", false); } } diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx index 42f645761156..f3090bf8f200 100644 --- a/sc/source/core/tool/interpr1.cxx +++ b/sc/source/core/tool/interpr1.cxx @@ -2952,40 +2952,19 @@ void ScInterpreter::ScIsOdd() void ScInterpreter::ScN() { - switch (GetRawStackType()) - { - case svSingleRef: - case svDoubleRef: - case svMatrix: - case svExternalSingleRef: - case svExternalDoubleRef: - { - ScMatrixRef pMat = GetMatrix(); - SCSIZE nC, nR; - pMat->GetDimensions(nC, nR); - if (!nC || !nR) - PushDouble(0); - else - PushDouble(pMat->GetDouble(0, 0)); - return; - } - case svString: - PopError(); - PushDouble(0); - return; - default: - ; - } - - // Default action + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er", "ScInterpreter::ScN" ); + sal_uInt16 nErr = nGlobalError; + nGlobalError = 0; + // Temporarily override the ConvertStringToValue() error for + // GetCellValue() / GetCellValueOrZero() + sal_uInt16 nSErr = mnStringNoValueError; + mnStringNoValueError = errCellNoValue; double fVal = GetDouble(); - if (nGlobalError) - { - // Don't propagate the error. Push 0 instead. - nGlobalError = 0; - PushDouble(0); - return; - } + mnStringNoValueError = nSErr; + if (nErr) + nGlobalError = nErr; // preserve previous error if any + else if (nGlobalError == errCellNoValue) + nGlobalError = 0; // reset temporary detection error PushDouble(fVal); } diff --git a/sc/source/core/tool/parclass.cxx b/sc/source/core/tool/parclass.cxx index 03775bf34016..754038b69945 100644 --- a/sc/source/core/tool/parclass.cxx +++ b/sc/source/core/tool/parclass.cxx @@ -142,7 +142,6 @@ const ScParameterClassification::RawData ScParameterClassification::pRawData[] = { ocModalValue, {{ ForceArray }, true }}, { ocMul, {{ Array, Array }, false }}, { ocMultiArea, {{ Reference }, true }}, - { ocN, {{ Reference }, false }}, { ocNPV, {{ Value, Reference }, true }}, { ocNeg, {{ Array }, false }}, { ocNegSub, {{ Array }, false }}, @@ -194,9 +193,13 @@ const ScParameterClassification::RawData ScParameterClassification::pRawData[] = { ocXor, {{ Reference }, true }}, { ocZTest, {{ Reference, Value, Value }, false }}, // Excel doubts: - // ocT: Excel says (and handles) Reference, error? This means no position - // dependent SingleRef if DoubleRef, and no array calculation, just the - // upper left corner. We never did that. + // ocN, ocT: Excel says (and handles) Reference, error? This means no + // position dependent SingleRef if DoubleRef, and no array calculation, + // just the upper left corner. We never did that for ocT and now also not + // for ocN (position dependent intersection worked before but array + // didn't). No specifics in ODFF, so the general rule applies. Gnumeric + // does the same. + { ocN, {{ Value }, false }}, { ocT, {{ Value }, false }}, // The stopper. { ocNone, {{ Bounds }, false } } |