[Libreoffice-commits] .: sc/source

Eike Rathke erack at kemper.freedesktop.org
Tue Aug 16 16:38:48 PDT 2011


 sc/source/ui/docshell/impex.cxx |   18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

New commits:
commit acd31343d1a346f045a8145894c7e4451910cbf8
Author: Eike Rathke <erack at erack.de>
Date:   Tue Aug 16 12:16:23 2011 +0200

    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

diff --git a/sc/source/ui/docshell/impex.cxx b/sc/source/ui/docshell/impex.cxx
index 72b09a2..23f7b37 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++;


More information about the Libreoffice-commits mailing list