[Libreoffice-commits] core.git: sc/source
Eike Rathke
erack at redhat.com
Fri Feb 22 04:57:24 PST 2013
sc/source/ui/dbgui/scuiasciiopt.cxx | 2 ++
sc/source/ui/docshell/impex.cxx | 19 +++++++++++++++++++
sc/source/ui/inc/impex.hxx | 2 ++
3 files changed, 23 insertions(+)
New commits:
commit 8970e14d7494859c6079ef2a976416598823ba50
Author: Eike Rathke <erack at redhat.com>
Date: Fri Feb 22 00:27:26 2013 +0100
resolved fdo#57841 ignore embedded NULL characters in CSV import
Change-Id: Ib0eb044f009227c0aa6e1bc520905d605323c3db
diff --git a/sc/source/ui/dbgui/scuiasciiopt.cxx b/sc/source/ui/dbgui/scuiasciiopt.cxx
index cfa4d4e..9624fde 100644
--- a/sc/source/ui/dbgui/scuiasciiopt.cxx
+++ b/sc/source/ui/dbgui/scuiasciiopt.cxx
@@ -540,6 +540,8 @@ bool ScImportAsciiDlg::GetLine( sal_uLong nLine, rtl::OUString &rText )
if ( mpDatStream->GetError() == ERRCODE_IO_CANTSEEK )
mpDatStream->ResetError();
+ ScImportExport::EmbeddedNullTreatment( rText);
+
return bRet;
}
diff --git a/sc/source/ui/docshell/impex.cxx b/sc/source/ui/docshell/impex.cxx
index 6e7e16c..8cff0c9 100644
--- a/sc/source/ui/docshell/impex.cxx
+++ b/sc/source/ui/docshell/impex.cxx
@@ -1335,6 +1335,8 @@ bool ScImportExport::ExtText2Doc( SvStream& rStrm )
if ( rStrm.IsEof() && aLine.isEmpty() )
break;
+ EmbeddedNullTreatment( aLine);
+
sal_Int32 nLineLen = aLine.getLength();
SCCOL nCol = nStartCol;
bool bMultiLine = false;
@@ -1473,6 +1475,23 @@ bool ScImportExport::ExtText2Doc( SvStream& rStrm )
}
+void ScImportExport::EmbeddedNullTreatment( OUString & rStr )
+{
+ // A nasty workaround for data with embedded NULL characters. As long as we
+ // can't handle them properly as cell content (things assume 0-terminated
+ // strings at too many places) simply strip all NULL characters from raw
+ // data. Excel does the same. See fdo#57841 for sample data.
+
+ // The normal case is no embedded NULL, check first before de-/allocating
+ // ustring stuff.
+ sal_Unicode cNull = 0;
+ if (rStr.indexOf( cNull) >= 0)
+ {
+ rStr = rStr.replaceAll( OUString( &cNull, 1), OUString());
+ }
+}
+
+
const sal_Unicode* ScImportExport::ScanNextFieldFromString( const sal_Unicode* p,
String& rField, sal_Unicode cStr, const sal_Unicode* pSeps, bool bMergeSeps, bool& rbIsQuoted,
bool& rbOverflowCell )
diff --git a/sc/source/ui/inc/impex.hxx b/sc/source/ui/inc/impex.hxx
index c427206..8c7e36b 100644
--- a/sc/source/ui/inc/impex.hxx
+++ b/sc/source/ui/inc/impex.hxx
@@ -102,6 +102,8 @@ public:
bool IsUndo() const { return bUndo; }
void SetUndo( bool b ) { bUndo = b; }
+ SC_DLLPUBLIC static void EmbeddedNullTreatment( OUString & rStr );
+
static bool IsFormatSupported( sal_uLong nFormat );
static const sal_Unicode* ScanNextFieldFromString( const sal_Unicode* p,
String& rField, sal_Unicode cStr, const sal_Unicode* pSeps,
More information about the Libreoffice-commits
mailing list