summaryrefslogtreecommitdiff
path: root/svtools
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2011-12-21 10:44:56 +0000
committerCaolán McNamara <caolanm@redhat.com>2011-12-21 13:44:52 +0000
commitc4f0efc2378cebc3b581bc949da70a2b2f149961 (patch)
tree3c0a330f7811c9407a787cec45382993b4037a6f /svtools
parent073431d26d39216a7f5f85489ecd4eb60806ee88 (diff)
convert ReadByteString/WriteByteString from ByteString to OString
Nobody ever used the return values anyway, so for reading just return the string and for writing the number of bytes written Doesn't need to be members, make standalone functions Rename to read_lenPrefixed_uInt8s_ToO[U]String and write_lenPrefixed_uInt8s_FromO[U]String, lengthy, but much less unambiguous, seeing as a lot of users of it don't seem to be aware that they read/write pascal-style length prefixed strings, which isn't surprising given the apparent simplicity of their original name. added a unit test
Diffstat (limited to 'svtools')
-rw-r--r--svtools/source/filter/igif/gifread.cxx4
-rw-r--r--svtools/source/graphic/grfmgr.cxx7
-rw-r--r--svtools/source/misc/imap.cxx37
-rw-r--r--svtools/source/urlobj/inetimg.cxx8
4 files changed, 25 insertions, 31 deletions
diff --git a/svtools/source/filter/igif/gifread.cxx b/svtools/source/filter/igif/gifread.cxx
index 81dee55fabf5..607b6a877af3 100644
--- a/svtools/source/filter/igif/gifread.cxx
+++ b/svtools/source/filter/igif/gifread.cxx
@@ -257,8 +257,8 @@ sal_Bool GIFReader::ReadExtension()
// Appl.-Extension hat Laenge 11
if ( cSize == 0x0b )
{
- rtl::OString aAppId = read_uInt8s_AsOString(rIStm, 8);
- rtl::OString aAppCode = read_uInt8s_AsOString(rIStm, 3);
+ rtl::OString aAppId = read_uInt8s_ToOString(rIStm, 8);
+ rtl::OString aAppCode = read_uInt8s_ToOString(rIStm, 3);
rIStm >> cSize;
// NetScape-Extension
diff --git a/svtools/source/graphic/grfmgr.cxx b/svtools/source/graphic/grfmgr.cxx
index f259ccb06af4..db3e8728f8d2 100644
--- a/svtools/source/graphic/grfmgr.cxx
+++ b/svtools/source/graphic/grfmgr.cxx
@@ -1125,7 +1125,6 @@ SvStream& operator>>( SvStream& rIStm, GraphicObject& rGraphicObj )
VersionCompat aCompat( rIStm, STREAM_READ );
Graphic aGraphic;
GraphicAttr aAttr;
- ByteString aLink;
sal_Bool bLink;
rIStm >> aGraphic >> aAttr >> bLink;
@@ -1135,8 +1134,8 @@ SvStream& operator>>( SvStream& rIStm, GraphicObject& rGraphicObj )
if( bLink )
{
- rIStm.ReadByteString(aLink);
- rGraphicObj.SetLink( UniString( aLink, RTL_TEXTENCODING_UTF8 ) );
+ rtl::OUString aLink = read_lenPrefixed_uInt8s_ToOUString(rIStm, RTL_TEXTENCODING_UTF8);
+ rGraphicObj.SetLink(aLink);
}
else
rGraphicObj.SetLink();
@@ -1154,7 +1153,7 @@ SvStream& operator<<( SvStream& rOStm, const GraphicObject& rGraphicObj )
rOStm << rGraphicObj.GetGraphic() << rGraphicObj.GetAttr() << bLink;
if( bLink )
- rOStm.WriteByteString(rtl::OUStringToOString(rGraphicObj.GetLink(), RTL_TEXTENCODING_UTF8));
+ write_lenPrefixed_uInt8s_FromOUString(rOStm, rGraphicObj.GetLink(), RTL_TEXTENCODING_UTF8);
return rOStm;
}
diff --git a/svtools/source/misc/imap.cxx b/svtools/source/misc/imap.cxx
index 016250c23c8c..bb720f6838e7 100644
--- a/svtools/source/misc/imap.cxx
+++ b/svtools/source/misc/imap.cxx
@@ -104,16 +104,16 @@ void IMapObject::Write( SvStream& rOStm, const String& rBaseURL ) const
const rtl::OString aRelURL = rtl::OUStringToOString(
URIHelper::simpleNormalizedMakeRelative(rBaseURL, aURL), eEncoding);
- rOStm.WriteByteString(aRelURL);
- rOStm.WriteByteString(rtl::OUStringToOString(aAltText, eEncoding));
+ write_lenPrefixed_uInt8s_FromOString(rOStm, aRelURL);
+ write_lenPrefixed_uInt8s_FromOUString(rOStm, aAltText, eEncoding);
rOStm << bActive;
- rOStm.WriteByteString(rtl::OUStringToOString(aTarget, eEncoding));
+ write_lenPrefixed_uInt8s_FromOUString(rOStm, aTarget, eEncoding);
pCompat = new IMapCompat( rOStm, STREAM_WRITE );
WriteIMapObject( rOStm );
- aEventList.Write( rOStm ); // V4
- rOStm.WriteByteString(rtl::OUStringToOString(aName, eEncoding)); // V5
+ aEventList.Write( rOStm ); // V4
+ write_lenPrefixed_uInt8s_FromOUString(rOStm, aName, eEncoding); // V5
delete pCompat;
}
@@ -129,16 +129,15 @@ void IMapObject::Read( SvStream& rIStm, const String& rBaseURL )
{
IMapCompat* pCompat;
rtl_TextEncoding nTextEncoding;
- ByteString aString;
// Typ und Version ueberlesen wir
rIStm.SeekRel( 2 );
rIStm >> nReadVersion;
rIStm >> nTextEncoding;
- rIStm.ReadByteString( aString ); aURL = String( aString.GetBuffer(), nTextEncoding );
- rIStm.ReadByteString( aString ); aAltText = String( aString.GetBuffer(), nTextEncoding );
+ aURL = read_lenPrefixed_uInt8s_ToOUString(rIStm, nTextEncoding);
+ aAltText = read_lenPrefixed_uInt8s_ToOUString(rIStm, nTextEncoding);
rIStm >> bActive;
- rIStm.ReadByteString( aString ); aTarget = String( aString.GetBuffer(), nTextEncoding );
+ aTarget = read_lenPrefixed_uInt8s_ToOUString(rIStm, nTextEncoding);
// URL absolut machen
aURL = URIHelper::SmartRel2Abs( INetURLObject(rBaseURL), aURL, URIHelper::GetMaybeFileHdl(), true, false, INetURLObject::WAS_ENCODED, INetURLObject::DECODE_UNAMBIGUOUS );
@@ -153,9 +152,7 @@ void IMapObject::Read( SvStream& rIStm, const String& rBaseURL )
// ab Version 5 kann ein Objektname vorhanden sein
if ( nReadVersion >= 0x0005 )
- {
- rIStm.ReadByteString( aString ); aName = String( aString.GetBuffer(), nTextEncoding );
- }
+ aName = read_lenPrefixed_uInt8s_ToOUString(rIStm, nTextEncoding);
}
delete pCompat;
@@ -1117,20 +1114,19 @@ void ImageMap::Write( SvStream& rOStm, const String& rBaseURL ) const
{
IMapCompat* pCompat;
String aImageName( GetName() );
- String aDummy;
sal_uInt16 nOldFormat = rOStm.GetNumberFormatInt();
sal_uInt16 nCount = (sal_uInt16) GetIMapObjectCount();
- const rtl_TextEncoding eEncoding = osl_getThreadTextEncoding();
+ const rtl_TextEncoding eEncoding = osl_getThreadTextEncoding(); //vomit!
rOStm.SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
// MagicCode schreiben
rOStm << IMAPMAGIC;
rOStm << GetVersion();
- rOStm.WriteByteString(rtl::OUStringToOString(aImageName, eEncoding));
- rOStm.WriteByteString(rtl::OUStringToOString(aDummy, eEncoding));
+ write_lenPrefixed_uInt8s_FromOUString(rOStm, aImageName, eEncoding);
+ write_lenPrefixed_uInt8s_FromOString(rOStm, rtl::OString()); //dummy
rOStm << nCount;
- rOStm.WriteByteString(rtl::OUStringToOString(aImageName, eEncoding));
+ write_lenPrefixed_uInt8s_FromOUString(rOStm, aImageName, eEncoding);
pCompat = new IMapCompat( rOStm, STREAM_WRITE );
@@ -1152,7 +1148,6 @@ void ImageMap::Write( SvStream& rOStm, const String& rBaseURL ) const
void ImageMap::Read( SvStream& rIStm, const String& rBaseURL )
{
- ByteString aString;
char cMagic[6];
sal_uInt16 nOldFormat = rIStm.GetNumberFormatInt();
sal_uInt16 nCount;
@@ -1170,10 +1165,10 @@ void ImageMap::Read( SvStream& rIStm, const String& rBaseURL )
// Version ueberlesen wir
rIStm.SeekRel( 2 );
- rIStm.ReadByteString( aString ); aName = String( aString, osl_getThreadTextEncoding() );
- rIStm.ReadByteString( aString ); // Dummy
+ aName = read_lenPrefixed_uInt8s_ToOUString(rIStm, osl_getThreadTextEncoding());
+ read_lenPrefixed_uInt8s_ToOString(rIStm); // Dummy
rIStm >> nCount;
- rIStm.ReadByteString( aString ); // Dummy
+ read_lenPrefixed_uInt8s_ToOString(rIStm); // Dummy
pCompat = new IMapCompat( rIStm, STREAM_READ );
diff --git a/svtools/source/urlobj/inetimg.cxx b/svtools/source/urlobj/inetimg.cxx
index fff9d170399a..8ed7996c16d0 100644
--- a/svtools/source/urlobj/inetimg.cxx
+++ b/svtools/source/urlobj/inetimg.cxx
@@ -73,7 +73,7 @@ sal_Bool INetImage::Read( SvStream& rIStm, sal_uLong nFormat )
{
case SOT_FORMATSTR_ID_INET_IMAGE:
{
- String sINetImg = read_zeroTerminated_uInt8s_AsOUString(rIStm, RTL_TEXTENCODING_UTF8);
+ String sINetImg = read_zeroTerminated_uInt8s_ToOUString(rIStm, RTL_TEXTENCODING_UTF8);
xub_StrLen nStart = 0;
aImageURL = sINetImg.GetToken( 0, TOKEN_SEPARATOR, nStart );
aTargetURL = sINetImg.GetToken( 0, TOKEN_SEPARATOR, nStart );
@@ -119,11 +119,11 @@ sal_Bool INetImage::Read( SvStream& rIStm, sal_uLong nFormat )
// skip over iExtraHTML_Offset
rIStm.SeekRel( sizeof( int ) );
- aImageURL = read_zeroTerminated_uInt8s_AsOUString(rIStm, eSysCSet);
+ aImageURL = read_zeroTerminated_uInt8s_ToOUString(rIStm, eSysCSet);
if( nAltOffset )
{
rIStm.Seek( nFilePos + nAltOffset );
- aAlternateText = read_zeroTerminated_uInt8s_AsOUString(rIStm, eSysCSet);
+ aAlternateText = read_zeroTerminated_uInt8s_ToOUString(rIStm, eSysCSet);
}
else if( aAlternateText.Len() )
aAlternateText.Erase();
@@ -131,7 +131,7 @@ sal_Bool INetImage::Read( SvStream& rIStm, sal_uLong nFormat )
if( nAnchorOffset )
{
rIStm.Seek( nFilePos + nAnchorOffset );
- aTargetURL = read_zeroTerminated_uInt8s_AsOUString(rIStm, eSysCSet);
+ aTargetURL = read_zeroTerminated_uInt8s_ToOUString(rIStm, eSysCSet);
}
else if( aTargetURL.Len() )
aTargetURL.Erase();