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 4a2b187503de7425150528faab568e520bd2474f Author: Eike Rathke <er...@redhat.com> Date: Fri Feb 22 00:27:26 2013 +0100 resolved fdo#57841 ignore embedded NULL characters in CSV import Change-Id: Ib0eb044f009227c0aa6e1bc520905d605323c3db (cherry picked from commit 8970e14d7494859c6079ef2a976416598823ba50) Reviewed-on: https://gerrit.libreoffice.org/2336 Reviewed-by: Markus Mohrhard <markus.mohrh...@googlemail.com> Tested-by: Markus Mohrhard <markus.mohrh...@googlemail.com> diff --git a/sc/source/ui/dbgui/scuiasciiopt.cxx b/sc/source/ui/dbgui/scuiasciiopt.cxx index d39c258..54d5e92 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 09ec1cd..9734f72 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; @@ -1478,6 +1480,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, _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits