From baf2bc036dfee6821478f67f551ec296b0fb4381 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Fri, 9 Feb 2018 15:35:29 +0000 Subject: use read_uInt8s_ToOUString MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I3575019373632f476737b00d8616d01867970ae6 Reviewed-on: https://gerrit.libreoffice.org/49506 Tested-by: Jenkins Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- sc/source/filter/inc/qpro.hxx | 2 +- sc/source/filter/qpro/qpro.cxx | 12 ++++-------- 2 files changed, 5 insertions(+), 9 deletions(-) (limited to 'sc') diff --git a/sc/source/filter/inc/qpro.hxx b/sc/source/filter/inc/qpro.hxx index bc74b9ad81d0..5410b8145d64 100644 --- a/sc/source/filter/inc/qpro.hxx +++ b/sc/source/filter/inc/qpro.hxx @@ -48,7 +48,7 @@ public: bool nextRecord(); sal_uInt16 getId() { return mnId; } sal_uInt16 getLength() { return mnLength; } - void readString( OUString &rString, sal_uInt16 nLength ); + OUString readString(sal_uInt16 nLength); ErrCode import( ScDocument *pDoc ); ErrCode readSheet( SCTAB nTab, ScDocument* pDoc, ScQProStyle *pStyle ); diff --git a/sc/source/filter/qpro/qpro.cxx b/sc/source/filter/qpro/qpro.cxx index 3d663a515000..676c297900d6 100644 --- a/sc/source/filter/qpro/qpro.cxx +++ b/sc/source/filter/qpro/qpro.cxx @@ -49,12 +49,11 @@ ErrCode ScQProReader::readSheet( SCTAB nTab, ScDocument* pDoc, ScQProStyle *pSty switch( getId() ) { case 0x000f:{ // Label cell - OUString aLabel; mpStream->ReadUChar( nCol ).ReadUChar( nDummy ).ReadUInt16( nRow ).ReadUInt16( nStyle ).ReadUChar( nDummy ); sal_uInt16 nLen = getLength(); if (nLen >= 7) { - readString( aLabel, nLen - 7 ); + OUString aLabel(readString(nLen - 7)); nStyle = nStyle >> 3; pStyle->SetFormat( pDoc, nCol, nRow, nTab, nStyle ); pDoc->EnsureTable(nTab); @@ -215,7 +214,7 @@ ErrCode ScQProReader::import( ScDocument *pDoc ) pStyleElement->setFontRecord( j, nFontAttr, nPtSize ); sal_uInt16 nLen = getLength(); if (nLen >= 4) - readString( aLabel, nLen - 4 ); + aLabel = readString(nLen - 4); else eRet = SCERR_IMPORT_FORMAT; pStyleElement->setFontType( j, aLabel ); @@ -275,12 +274,9 @@ bool ScQProReader::nextRecord() return true; } -void ScQProReader::readString( OUString &rString, sal_uInt16 nLength ) +OUString ScQProReader::readString(sal_uInt16 nLength) { - std::unique_ptr pText(new sal_Char[ nLength + 1 ]); - nLength = mpStream->ReadBytes(pText.get(), nLength); - pText[ nLength ] = 0; - rString = OUString( pText.get(), strlen(pText.get()), mpStream->GetStreamCharSet() ); + return read_uInt8s_ToOUString(*mpStream, nLength, mpStream->GetStreamCharSet()); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit v1.2.3