diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2023-12-10 15:08:32 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2023-12-10 17:07:50 +0100 |
commit | 1d21ecc90cc14cc40ebee5de2f45fb6a8cb35c77 (patch) | |
tree | 456e28773a82226a1b2a6342b442ea9932637a33 /sc | |
parent | 3f02996475aef76f4e4c7fbe1701534a154d3fe1 (diff) |
Use SvStream methods
Change-Id: I11a98b32ab176c1e30480186123b21bc04b9500f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160536
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/ui/docshell/impex.cxx | 63 | ||||
-rw-r--r-- | sc/source/ui/inc/impex.hxx | 1 |
2 files changed, 9 insertions, 55 deletions
diff --git a/sc/source/ui/docshell/impex.cxx b/sc/source/ui/docshell/impex.cxx index 4a585657de1a..ab62a6f8f2d8 100644 --- a/sc/source/ui/docshell/impex.cxx +++ b/sc/source/ui/docshell/impex.cxx @@ -85,15 +85,6 @@ constexpr sal_Int32 nArbitraryLineLengthLimit = 2 * MAXCOLCOUNT * nArbitraryCell namespace { const char SYLK_LF[] = "\x1b :"; - - bool lcl_IsEndianSwap( const SvStream& rStrm ) - { - #ifdef OSL_BIGENDIAN - return rStrm.GetEndian() != SvStreamEndian::BIG; - #else - return rStrm.GetEndian() != SvStreamEndian::LITTLE; - #endif - } } namespace { @@ -508,52 +499,16 @@ bool ScImportExport::ExportStream( SvStream& rStrm, const OUString& rBaseURL, So void ScImportExport::WriteUnicodeOrByteString( SvStream& rStrm, std::u16string_view rString, bool bZero ) { rtl_TextEncoding eEnc = rStrm.GetStreamCharSet(); - if ( eEnc == RTL_TEXTENCODING_UNICODE ) + rStrm.WriteUnicodeOrByteText(rString, eEnc); + if (bZero) { - if ( !lcl_IsEndianSwap( rStrm ) ) - rStrm.WriteBytes(rString.data(), rString.size() * sizeof(sal_Unicode)); + if (eEnc == RTL_TEXTENCODING_UNICODE) + rStrm.WriteUnicode(0); else - { - const sal_Unicode* p = rString.data(); - const sal_Unicode* const pStop = p + rString.size(); - while ( p < pStop ) - { - rStrm.WriteUInt16( *p ); - } - } - if ( bZero ) - rStrm.WriteUInt16( 0 ); - } - else - { - OString aByteStr(OUStringToOString(rString, eEnc)); - rStrm.WriteOString( aByteStr ); - if ( bZero ) - rStrm.WriteChar( 0 ); + rStrm.WriteChar(0); } } -// This function could be replaced by endlub() -void ScImportExport::WriteUnicodeOrByteEndl( SvStream& rStrm ) -{ - if ( rStrm.GetStreamCharSet() == RTL_TEXTENCODING_UNICODE ) - { // same as endl() but unicode - switch ( rStrm.GetLineDelimiter() ) - { - case LINEEND_CR : - rStrm.WriteUInt16( '\r' ); - break; - case LINEEND_LF : - rStrm.WriteUInt16( '\n' ); - break; - default: - rStrm.WriteUInt16( '\r' ).WriteUInt16( '\n' ); - } - } - else - endl( rStrm ); -} - // tdf#104927 // http://www.unicode.org/reports/tr11/ sal_Int32 ScImportExport::CountVisualWidth(const OUString& rStr, sal_Int32& nIdx, sal_Int32 nMaxWidth) @@ -2078,7 +2033,7 @@ bool ScImportExport::Doc2Text( SvStream& rStrm ) // NOTE: this Doc2Text() is only called for clipboard via // ScImportExport::ExportStream(). if (nStartRow != nEndRow || nStartCol != nEndCol) - WriteUnicodeOrByteEndl( rStrm ); + endlub(rStrm); if( rStrm.GetError() != ERRCODE_NONE ) break; if( nSizeLimit && rStrm.Tell() > nSizeLimit ) @@ -2431,7 +2386,7 @@ bool ScImportExport::Doc2Sylk( SvStream& rStrm ) OUString aCellStr; OUString aValStr; lcl_WriteSimpleString( rStrm, u"ID;PCALCOOO32" ); - WriteUnicodeOrByteEndl( rStrm ); + endlub(rStrm); for (nRow = nStartRow; nRow <= nEndRow; nRow++) { @@ -2544,7 +2499,7 @@ bool ScImportExport::Doc2Sylk( SvStream& rStrm ) if ( !aCellStr.isEmpty() ) lcl_WriteString( rStrm, aCellStr, 0, ';' ); } - WriteUnicodeOrByteEndl( rStrm ); + endlub(rStrm); break; default: @@ -2555,7 +2510,7 @@ bool ScImportExport::Doc2Sylk( SvStream& rStrm ) } } lcl_WriteSimpleString( rStrm, rtl::OUStringChar( 'E' ) ); - WriteUnicodeOrByteEndl( rStrm ); + endlub(rStrm); return rStrm.GetError() == ERRCODE_NONE; } diff --git a/sc/source/ui/inc/impex.hxx b/sc/source/ui/inc/impex.hxx index c33c151f81c8..7084839943ab 100644 --- a/sc/source/ui/inc/impex.hxx +++ b/sc/source/ui/inc/impex.hxx @@ -110,7 +110,6 @@ public: OUString& rField, sal_Unicode cStr, const sal_Unicode* pSeps, bool bMergeSeps, bool& rbIsQuoted, bool& rbOverflowCell, bool bRemoveSpace ); static void WriteUnicodeOrByteString( SvStream& rStrm, std::u16string_view rString, bool bZero = false ); - static void WriteUnicodeOrByteEndl( SvStream& rStrm ); /** ScImportExport::CountVisualWidth Count the width of string visually ( in multiple of western characters), considering CJK |