diff options
Diffstat (limited to 'sc/source/ui/docshell/impex.cxx')
-rw-r--r-- | sc/source/ui/docshell/impex.cxx | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/sc/source/ui/docshell/impex.cxx b/sc/source/ui/docshell/impex.cxx index 09ec1cd750cb..9734f72be791 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 ) |