summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2012-07-18 17:04:33 +0200
committerEike Rathke <erack@redhat.com>2012-07-18 17:25:47 +0200
commita439cb5aba49d01df20f67a2c84b68542e4d3d5a (patch)
tree976c041532414204b929434fc6ca965ad3c98ffc /sc
parent16ea22333c85aa37699a4968bd3d5b4c8df9cb71 (diff)
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
Diffstat (limited to 'sc')
-rw-r--r--sc/source/core/tool/interpr4.cxx15
1 files changed, 15 insertions, 0 deletions
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))
{