summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2011-09-18 13:36:11 +0100
committerCaolán McNamara <caolanm@redhat.com>2011-09-19 09:59:21 +0100
commit94d8c0975852d7b12e4c8acf4ab1c7f1c1a73f61 (patch)
tree1d83a03cca3e821eb88b53146367bb3995c577a5
parent5d73752cc7d66edae26392f84e72e32a8cf598ca (diff)
rework this in terms of read_uInt8s_AsOString
-rw-r--r--connectivity/source/drivers/dbase/dindexnode.cxx15
-rw-r--r--sfx2/source/bastyp/sfxhtml.cxx6
-rw-r--r--svtools/source/filter/igif/gifread.cxx11
-rw-r--r--vcl/source/gdi/cvtsvm.cxx35
4 files changed, 34 insertions, 33 deletions
diff --git a/connectivity/source/drivers/dbase/dindexnode.cxx b/connectivity/source/drivers/dbase/dindexnode.cxx
index b2fea12ab294..1844e2708d87 100644
--- a/connectivity/source/drivers/dbase/dindexnode.cxx
+++ b/connectivity/source/drivers/dbase/dindexnode.cxx
@@ -674,16 +674,13 @@ void ONDXNode::Read(SvStream &rStream, ODbaseIndex& rIndex)
}
else
{
- ByteString aBuf;
sal_uInt16 nLen = rIndex.getHeader().db_keylen;
- char* pStr = aBuf.AllocBuffer(nLen+1);
-
- rStream.Read(pStr,nLen);
- pStr[nLen] = 0;
- aBuf.ReleaseBufferAccess();
- aBuf.EraseTrailingChars();
-
- aKey = ONDXKey(::rtl::OUString(aBuf.GetBuffer(),aBuf.Len(),rIndex.m_pTable->getConnection()->getTextEncoding()) ,aKey.nRecord);
+ rtl::OString aBuf = read_uInt8s_AsOString(rStream, nLen);
+ //get length minus trailing whitespace
+ sal_Int32 nContentLen = aBuf.getLength();
+ while (nContentLen && aBuf[nContentLen-1] == ' ')
+ --nContentLen;
+ aKey = ONDXKey(::rtl::OUString(aBuf.getStr(), nContentLen, rIndex.m_pTable->getConnection()->getTextEncoding()) ,aKey.nRecord);
}
rStream >> aChild;
}
diff --git a/sfx2/source/bastyp/sfxhtml.cxx b/sfx2/source/bastyp/sfxhtml.cxx
index c575b7f755f0..002e2cebcb42 100644
--- a/sfx2/source/bastyp/sfxhtml.cxx
+++ b/sfx2/source/bastyp/sfxhtml.cxx
@@ -277,11 +277,9 @@ sal_Bool SfxHTMLParser::FinishFileDownload( String& rStr )
? (xub_StrLen)aStream.Tell()
: STRING_MAXLEN;
- ByteString sBuffer;
- sal_Char* pBuffer = sBuffer.AllocBuffer(nLen);
aStream.Seek( 0 );
- aStream.Read((void*)pBuffer, nLen);
- rStr = String( S2U(pBuffer) );
+ rtl::OString sBuffer = read_uInt8s_AsOString(aStream, nLen);
+ rStr = S2U(sBuffer);
}
delete pDLMedium;
diff --git a/svtools/source/filter/igif/gifread.cxx b/svtools/source/filter/igif/gifread.cxx
index 6765937081d7..8e488e72c064 100644
--- a/svtools/source/filter/igif/gifread.cxx
+++ b/svtools/source/filter/igif/gifread.cxx
@@ -259,15 +259,12 @@ sal_Bool GIFReader::ReadExtension()
// Appl.-Extension hat Laenge 11
if ( cSize == 0x0b )
{
- ByteString aAppId;
- ByteString aAppCode;
-
- rIStm.Read( aAppId.AllocBuffer( 8 ), 8 );
- rIStm.Read( aAppCode.AllocBuffer( 3 ), 3 );
+ rtl::OString aAppId = read_uInt8s_AsOString(rIStm, 8);
+ rtl::OString aAppCode = read_uInt8s_AsOString(rIStm, 3);
rIStm >> cSize;
// NetScape-Extension
- if( aAppId == "NETSCAPE" && aAppCode == "2.0" && cSize == 3 )
+ if( aAppId.equalsL(RTL_CONSTASCII_STRINGPARAM("NETSCAPE")) && aAppCode.equalsL(RTL_CONSTASCII_STRINGPARAM("2.0")) && cSize == 3 )
{
rIStm >> cByte;
@@ -294,7 +291,7 @@ sal_Bool GIFReader::ReadExtension()
else
rIStm.SeekRel( -1 );
}
- else if ( aAppId == "STARDIV " && aAppCode == "5.0" && cSize == 9 )
+ else if ( aAppId.equalsL(RTL_CONSTASCII_STRINGPARAM("STARDIV ")) && aAppCode.equalsL(RTL_CONSTASCII_STRINGPARAM("5.0")) && cSize == 9 )
{
rIStm >> cByte;
diff --git a/vcl/source/gdi/cvtsvm.cxx b/vcl/source/gdi/cvtsvm.cxx
index 119029068b3c..b09e9d4e9eb3 100644
--- a/vcl/source/gdi/cvtsvm.cxx
+++ b/vcl/source/gdi/cvtsvm.cxx
@@ -882,33 +882,39 @@ void SVMConverter::ImplConvertFromSVM1( SvStream& rIStm, GDIMetaFile& rMtf )
case( GDI_TEXT_ACTION ):
{
- ByteString aByteStr;
sal_Int32 nIndex, nLen;
rIStm >> aPt >> nIndex >> nLen >> nTmp;
if ( nTmp && ( static_cast< sal_uInt32 >( nTmp ) < ( SAL_MAX_UINT16 - 1 ) ) )
- {
- rIStm.Read( aByteStr.AllocBuffer( (sal_uInt16)nTmp ), nTmp + 1 );
- UniString aStr( aByteStr, eActualCharSet );
+ {
+ rtl::OString aByteStr = read_uInt8s_AsOString(rIStm, nTmp);
+ sal_uInt8 nTerminator = 0;
+ rIStm >> nTerminator;
+ DBG_ASSERT( nTerminator == 0, "expected string to be NULL terminated" );
+
+ UniString aStr(rtl::OStringToOUString(aByteStr, eActualCharSet));
if ( nUnicodeCommentActionNumber == i )
ImplReadUnicodeComment( nUnicodeCommentStreamPos, rIStm, aStr );
rMtf.AddAction( new MetaTextAction( aPt, aStr, (sal_uInt16) nIndex, (sal_uInt16) nLen ) );
}
- rIStm.Seek( nActBegin + nActionSize );
+ rIStm.Seek( nActBegin + nActionSize );
}
break;
case( GDI_TEXTARRAY_ACTION ):
{
- ByteString aByteStr;
sal_Int32* pDXAry = NULL;
sal_Int32 nIndex, nLen, nAryLen;
rIStm >> aPt >> nIndex >> nLen >> nTmp >> nAryLen;
if ( nTmp && ( static_cast< sal_uInt32 >( nTmp ) < ( SAL_MAX_UINT16 - 1 ) ) )
{
- rIStm.Read( aByteStr.AllocBuffer( (sal_uInt16)nTmp ), nTmp + 1 );
- UniString aStr( aByteStr, eActualCharSet );
+ rtl::OString aByteStr = read_uInt8s_AsOString(rIStm, nTmp);
+ sal_uInt8 nTerminator = 0;
+ rIStm >> nTerminator;
+ DBG_ASSERT( nTerminator == 0, "expected string to be NULL terminated" );
+
+ UniString aStr(rtl::OStringToOUString(aByteStr, eActualCharSet));
if( nAryLen > 0L )
{
@@ -955,25 +961,28 @@ void SVMConverter::ImplConvertFromSVM1( SvStream& rIStm, GDIMetaFile& rMtf )
if( pDXAry )
delete[] pDXAry;
}
- rIStm.Seek( nActBegin + nActionSize );
+ rIStm.Seek( nActBegin + nActionSize );
}
break;
case( GDI_STRETCHTEXT_ACTION ):
{
- ByteString aByteStr;
sal_Int32 nIndex, nLen, nWidth;
rIStm >> aPt >> nIndex >> nLen >> nTmp >> nWidth;
if ( nTmp && ( static_cast< sal_uInt32 >( nTmp ) < ( SAL_MAX_INT16 - 1 ) ) )
{
- rIStm.Read( aByteStr.AllocBuffer( (sal_uInt16)nTmp ), nTmp + 1 );
- UniString aStr( aByteStr, eActualCharSet );
+ rtl::OString aByteStr = read_uInt8s_AsOString(rIStm, nTmp);
+ sal_uInt8 nTerminator = 0;
+ rIStm >> nTerminator;
+ DBG_ASSERT( nTerminator == 0, "expected string to be NULL terminated" );
+
+ UniString aStr(rtl::OStringToOUString(aByteStr, eActualCharSet));
if ( nUnicodeCommentActionNumber == i )
ImplReadUnicodeComment( nUnicodeCommentStreamPos, rIStm, aStr );
rMtf.AddAction( new MetaStretchTextAction( aPt, nWidth, aStr, (sal_uInt16) nIndex, (sal_uInt16) nLen ) );
}
- rIStm.Seek( nActBegin + nActionSize );
+ rIStm.Seek( nActBegin + nActionSize );
}
break;