From a439cb5aba49d01df20f67a2c84b68542e4d3d5a Mon Sep 17 00:00:00 2001 From: Eike Rathke Date: Wed, 18 Jul 2012 17:04:33 +0200 Subject: resolved fdo#50345 accept empty string as scalar numeric 0 argument For OOo/AOOi interoperability convert an empty string or string containing only spaces to numeric 0 for scalar numeric arguments. Change-Id: I551d10b647c961df08ca8c936ca8fed5de14d99f --- sc/source/core/tool/interpr4.cxx | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'sc') diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx index bca2977b8b92..566d0b363647 100644 --- a/sc/source/core/tool/interpr4.cxx +++ b/sc/source/core/tool/interpr4.cxx @@ -243,6 +243,21 @@ double ScInterpreter::ConvertStringToValue( const String& rStr ) SetError( mnStringNoValueError); return fValue; } + // The number scanner does not accept empty strings or strings containing + // only spaces, be on par in these cases with what was accepted in OOo and + // is in AOO (see also the #else branch below) and convert to 0 to prevent + // interoperability nightmares. + if (!rStr.Len()) + return fValue; + else if (rStr.GetChar(0) == ' ') + { + const sal_Unicode* p = rStr.GetBuffer() + 1; + const sal_Unicode* const pStop = p - 1 + rStr.Len(); + while (p < pStop && *p == ' ') + ++p; + if (p == pStop) + return fValue; + } sal_uInt32 nFIndex = 0; if (!pFormatter->IsNumberFormat(rStr, nFIndex, fValue)) { -- cgit