summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorEike Rathke <erack@erack.de>2011-08-16 12:16:23 +0200
committerEike Rathke <erack@erack.de>2011-08-17 01:38:10 +0200
commitacd31343d1a346f045a8145894c7e4451910cbf8 (patch)
tree67ec308d9198e72c6f7c4281c198a1742dcf7c1e /sc
parent74070a021389534b9e791980bd33ede45be9fd81 (diff)
fdo#32703 make CSV import ignore leading spaces before quoted field content
Make CSV import ignore leading spaces if the field content without them is quoted. Cope with broken generators that put leading blanks before a quoted field, like "field1", "field2", "..." ignoring CSV specification http://tools.ietf.org/html/rfc4180
Diffstat (limited to 'sc')
-rw-r--r--sc/source/ui/docshell/impex.cxx18
1 files changed, 15 insertions, 3 deletions
diff --git a/sc/source/ui/docshell/impex.cxx b/sc/source/ui/docshell/impex.cxx
index 72b09a253cbf..23f7b379f740 100644
--- a/sc/source/ui/docshell/impex.cxx
+++ b/sc/source/ui/docshell/impex.cxx
@@ -1363,7 +1363,19 @@ const sal_Unicode* ScImportExport::ScanNextFieldFromString( const sal_Unicode* p
{
rbIsQuoted = false;
rField.Erase();
- if ( *p == cStr ) // String in Anfuehrungszeichen
+ const sal_Unicode cBlank = ' ';
+ if (!ScGlobal::UnicodeStrChr( pSeps, cBlank))
+ {
+ // Cope with broken generators that put leading blanks before a quoted
+ // field, like "field1", "field2", "..."
+ // NOTE: this is not in conformance with http://tools.ietf.org/html/rfc4180
+ const sal_Unicode* pb = p;
+ while (*pb == cBlank)
+ ++pb;
+ if (*pb == cStr)
+ p = pb;
+ }
+ if ( *p == cStr ) // String in quotes
{
rbIsQuoted = true;
const sal_Unicode* p1;
@@ -1377,7 +1389,7 @@ const sal_Unicode* ScImportExport::ScanNextFieldFromString( const sal_Unicode* p
if( *p )
p++;
}
- else // bis zum Trennzeichen
+ else // up to delimiter
{
const sal_Unicode* p0 = p;
while ( *p && !ScGlobal::UnicodeStrChr( pSeps, *p ) )
@@ -1386,7 +1398,7 @@ const sal_Unicode* ScImportExport::ScanNextFieldFromString( const sal_Unicode* p
if( *p )
p++;
}
- if ( bMergeSeps ) // folgende Trennzeichen ueberspringen
+ if ( bMergeSeps ) // skip following delimiters
{
while ( *p && ScGlobal::UnicodeStrChr( pSeps, *p ) )
p++;