[Libreoffice-commits] .: 4 commits - basic/source connectivity/source dbaccess/source editeng/source filter/source idl/source l10ntools/source sc/inc sc/source sd/source sfx2/source sot/source svl/source svtools/source svx/inc svx/source sw/source tools/inc tools/qa tools/source unusedcode.easy vcl/source vcl/win

Caolán McNamara caolan at kemper.freedesktop.org
Wed Dec 21 02:12:36 PST 2011


 basic/source/basmgr/basmgr.cxx                   |   11 +-
 basic/source/classes/image.cxx                   |   16 +--
 basic/source/classes/sbxmod.cxx                  |    4 
 basic/source/runtime/iosys.cxx                   |    2 
 basic/source/runtime/methods1.cxx                |    4 
 basic/source/sbx/sbxbase.cxx                     |   18 ++--
 basic/source/sbx/sbxcoll.cxx                     |    6 -
 basic/source/sbx/sbxobj.cxx                      |   14 +--
 basic/source/sbx/sbxvalue.cxx                    |   23 ++---
 basic/source/sbx/sbxvar.cxx                      |   19 ++--
 connectivity/source/drivers/dbase/DTable.cxx     |    2 
 connectivity/source/drivers/dbase/dindexnode.cxx |    2 
 dbaccess/source/ui/tabledesign/TableRow.cxx      |   16 +--
 editeng/source/editeng/editobj.cxx               |   15 +--
 editeng/source/items/bulitem.cxx                 |   12 +-
 editeng/source/items/flditem.cxx                 |    4 
 editeng/source/items/frmitems.cxx                |    8 -
 editeng/source/items/numitem.cxx                 |    6 -
 editeng/source/items/textitem.cxx                |   16 +--
 filter/source/msfilter/mstoolbar.cxx             |    2 
 idl/source/objects/bastype.cxx                   |    8 -
 idl/source/objects/module.cxx                    |   20 ++--
 idl/source/objects/object.cxx                    |    4 
 idl/source/objects/types.cxx                     |    8 -
 l10ntools/source/export2.cxx                     |    6 -
 sc/inc/scmod.hxx                                 |    1 
 sc/source/core/data/patattr.cxx                  |    8 -
 sc/source/core/tool/autoform.cxx                 |   14 ++-
 sc/source/core/tool/ddelink.cxx                  |   12 +-
 sc/source/core/tool/zforauto.cxx                 |    4 
 sc/source/filter/ftools/ftools.cxx               |    6 -
 sc/source/filter/inc/ftools.hxx                  |    6 -
 sc/source/filter/lotus/lotform.cxx               |    6 -
 sc/source/filter/qpro/qproform.cxx               |    2 
 sc/source/ui/app/scmod.cxx                       |   16 ---
 sc/source/ui/unoobj/scdetect.cxx                 |    2 
 sd/source/filter/eppt/epptso.cxx                 |    2 
 sd/source/filter/html/pubdlg.cxx                 |   48 +++++++----
 sfx2/source/appl/appmisc.cxx                     |    4 
 sfx2/source/bastyp/sfxhtml.cxx                   |    2 
 sot/source/sdstor/ucbstorage.cxx                 |    5 -
 svl/source/items/cntwall.cxx                     |    3 
 svl/source/items/poolitem.cxx                    |    8 -
 svl/source/numbers/zformat.cxx                   |   13 +--
 svtools/source/filter/igif/gifread.cxx           |    4 
 svtools/source/graphic/grfmgr.cxx                |    7 -
 svtools/source/misc/imap.cxx                     |   37 +++-----
 svtools/source/misc/templatefoldercache.cxx      |    6 -
 svtools/source/misc/transfer.cxx                 |    8 -
 svtools/source/urlobj/inetimg.cxx                |    8 -
 svx/inc/svx/gallery1.hxx                         |   48 +++++------
 svx/inc/svx/galmisc.hxx                          |   14 +--
 svx/inc/svx/galtheme.hxx                         |   18 ++--
 svx/source/gallery2/gallery1.cxx                 |   51 ++++--------
 svx/source/gallery2/galobj.cxx                   |   36 ++------
 svx/source/gallery2/galtheme.cxx                 |   19 +---
 svx/source/items/hlnkitem.cxx                    |   32 +++----
 svx/source/items/pageitem.cxx                    |    4 
 sw/source/core/doc/tblafmt.cxx                   |   14 +--
 sw/source/filter/ww1/w1class.cxx                 |    2 
 sw/source/filter/ww8/ww8par.cxx                  |    2 
 sw/source/filter/ww8/ww8par2.cxx                 |    2 
 sw/source/filter/ww8/ww8scan.cxx                 |   21 +----
 sw/source/filter/ww8/ww8scan.hxx                 |    5 -
 sw/source/filter/ww8/ww8toolbar.cxx              |    2 
 sw/source/ui/config/uinums.cxx                   |   24 ++---
 sw/source/ui/dochdl/swdtflvr.cxx                 |    6 -
 tools/inc/tools/inetmsg.hxx                      |   96 +++++++++++------------
 tools/inc/tools/stream.hxx                       |   70 ++++++++++++++--
 tools/qa/cppunit/test_stream.cxx                 |   59 ++++++++++++--
 tools/source/inet/inetmsg.cxx                    |   22 ++---
 tools/source/inet/inetstrm.cxx                   |    2 
 tools/source/stream/stream.cxx                   |   40 ++-------
 unusedcode.easy                                  |    1 
 vcl/source/gdi/animate.cxx                       |    6 -
 vcl/source/gdi/cvtsvm.cxx                        |   11 +-
 vcl/source/gdi/font.cxx                          |    8 -
 vcl/source/gdi/jobset.cxx                        |   27 ++++--
 vcl/source/gdi/metaact.cxx                       |   25 ++---
 vcl/source/gdi/print.cxx                         |   21 +----
 vcl/source/gdi/rendergraphic.cxx                 |    6 -
 vcl/win/source/gdi/salgdi3.cxx                   |   13 +--
 82 files changed, 613 insertions(+), 572 deletions(-)

New commits:
commit d00fc0e293852cfc019ffaffa65bee327397677b
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Mon Dec 19 22:19:52 2011 +0000

    disentangle Read/WriteByteString OUString variants
    
    The ones which use a definite 8-bit encoding read/write pascal-style
    strings with a 16bit length prefix.
    
    The ones which use a definite 16-bit encoding read/write pascal-style
    UTF-16 strings with a 32bit length prefix, i.e. not ByteStrings at all
    
    The "I dunno" ones might be UTF-16 strings or 8-bit strings, depending
    on the charset. Rename to ReadUniOrByteString like the other
    similar horrors to flag this misery

diff --git a/basic/source/basmgr/basmgr.cxx b/basic/source/basmgr/basmgr.cxx
index e6c829a..9052458 100644
--- a/basic/source/basmgr/basmgr.cxx
+++ b/basic/source/basmgr/basmgr.cxx
@@ -643,17 +643,17 @@ BasicLibInfo* BasicLibInfo::Create( SotStorageStream& rSStream )
 
         // The name of the lib...
         String aName;
-        rSStream.ReadByteString(aName);
+        rSStream.ReadUniOrByteString(aName, rSStream.GetStreamCharSet());
         pInfo->SetLibName( aName );
 
         // Absolute path...
         String aStorageName;
-        rSStream.ReadByteString(aStorageName);
+        rSStream.ReadUniOrByteString(aStorageName, rSStream.GetStreamCharSet());
         pInfo->SetStorageName( aStorageName );
 
         // Relative path...
         String aRelStorageName;
-        rSStream.ReadByteString(aRelStorageName);
+        rSStream.ReadUniOrByteString(aRelStorageName, rSStream.GetStreamCharSet());
         pInfo->SetRelStorageName( aRelStorageName );
 
         if ( nVer >= 2 )
@@ -1041,7 +1041,7 @@ void BasicManager::LoadOldBasicManager( SotStorage& rStorage )
     }
     xManagerStream->Seek( nBasicEndOff+1 ); // +1: 0x00 as separator
     String aLibs;
-    xManagerStream->ReadByteString(aLibs);
+    xManagerStream->ReadUniOrByteString(aLibs, xManagerStream->GetStreamCharSet());
     xManagerStream->SetBufferSize( 0 );
     xManagerStream.Clear(); // Close stream
 
@@ -1235,7 +1235,8 @@ sal_Bool BasicManager::ImpLoadLibary( BasicLibInfo* pLibInfo, SotStorage* pCurSt
                 if ( ( nPasswordMarker == PASSWORD_MARKER ) && !xBasicStream->IsEof() )
                 {
                     String aPassword;
-                    xBasicStream->ReadByteString(aPassword);
+                    xBasicStream->ReadUniOrByteString(aPassword,
+                        xBasicStream->GetStreamCharSet());
                     pLibInfo->SetPassword( aPassword );
                 }
                 xBasicStream->SetCryptMaskKey(rtl::OString());
diff --git a/basic/source/classes/image.cxx b/basic/source/classes/image.cxx
index 1208184..79b3765 100644
--- a/basic/source/classes/image.cxx
+++ b/basic/source/classes/image.cxx
@@ -147,15 +147,15 @@ sal_Bool SbiImage::Load( SvStream& r, sal_uInt32& nVersion )
           switch( nSign )
         {
             case B_NAME:
-                r.ReadByteString( aName, eCharSet );
+                r.ReadUniOrByteString( aName, eCharSet );
                 break;
             case B_COMMENT:
-                r.ReadByteString( aComment, eCharSet );
+                r.ReadUniOrByteString( aComment, eCharSet );
                 break;
             case B_SOURCE:
             {
                 String aTmp;
-                r.ReadByteString( aTmp, eCharSet );
+                r.ReadUniOrByteString( aTmp, eCharSet );
                 aOUSource = aTmp;
                 break;
             }
@@ -164,7 +164,7 @@ sal_Bool SbiImage::Load( SvStream& r, sal_uInt32& nVersion )
                 for( sal_uInt16 j = 0 ; j < nCount ; j++ )
                 {
                     String aTmp;
-                    r.ReadByteString( aTmp, eCharSet );
+                    r.ReadUniOrByteString( aTmp, eCharSet );
                     aOUSource += aTmp;
                 }
                 break;
@@ -274,14 +274,14 @@ sal_Bool SbiImage::Save( SvStream& r, sal_uInt32 nVer )
     if( aName.Len() && SbiGood( r ) )
     {
         nPos = SbiOpenRecord( r, B_NAME, 1 );
-        r.WriteByteString( aName, eCharSet );
+        r.WriteUniOrByteString( aName, eCharSet );
         SbiCloseRecord( r, nPos );
     }
     // Comment?
     if( aComment.Len() && SbiGood( r ) )
     {
         nPos = SbiOpenRecord( r, B_COMMENT, 1 );
-        r.WriteByteString( aComment, eCharSet );
+        r.WriteUniOrByteString( aComment, eCharSet );
         SbiCloseRecord( r, nPos );
     }
     // Source?
@@ -295,7 +295,7 @@ sal_Bool SbiImage::Save( SvStream& r, sal_uInt32 nVer )
             aTmp = aOUSource.copy( 0, nMaxUnitSize );
         else
             aTmp = aOUSource;
-        r.WriteByteString( aTmp, eCharSet );
+        r.WriteUniOrByteString( aTmp, eCharSet );
         SbiCloseRecord( r, nPos );
 
         if( nLen > STRING_MAXLEN )
@@ -309,7 +309,7 @@ sal_Bool SbiImage::Save( SvStream& r, sal_uInt32 nVer )
                     (nRemainingLen > nMaxUnitSize) ? nMaxUnitSize : nRemainingLen;
                 String aTmp2 = aOUSource.copy( (i+1) * nMaxUnitSize, nCopyLen );
                 nRemainingLen -= nCopyLen;
-                r.WriteByteString( aTmp2, eCharSet );
+                r.WriteUniOrByteString( aTmp2, eCharSet );
             }
             SbiCloseRecord( r, nPos );
         }
diff --git a/basic/source/classes/sbxmod.cxx b/basic/source/classes/sbxmod.cxx
index 07194fa..975ecc2 100644
--- a/basic/source/classes/sbxmod.cxx
+++ b/basic/source/classes/sbxmod.cxx
@@ -2002,7 +2002,7 @@ sal_Bool SbJScriptModule::LoadData( SvStream& rStrm, sal_uInt16 nVer )
 
     // Get the source string
     String aTmp;
-    rStrm.ReadByteString( aTmp, osl_getThreadTextEncoding() );
+    rStrm.ReadUniOrByteString( aTmp, osl_getThreadTextEncoding() );
     aOUSource = aTmp;
     return sal_True;
 }
@@ -2014,7 +2014,7 @@ sal_Bool SbJScriptModule::StoreData( SvStream& rStrm ) const
 
     // Write the source string
     String aTmp = aOUSource;
-    rStrm.WriteByteString( aTmp, osl_getThreadTextEncoding() );
+    rStrm.WriteUniOrByteString( aTmp, osl_getThreadTextEncoding() );
     return sal_True;
 }
 
diff --git a/basic/source/runtime/methods1.cxx b/basic/source/runtime/methods1.cxx
index 2ff6990..5b25252 100644
--- a/basic/source/runtime/methods1.cxx
+++ b/basic/source/runtime/methods1.cxx
@@ -991,7 +991,7 @@ sal_Bool lcl_WriteSbxVariable( const SbxVariable& rVar, SvStream* pStrm,
                 {
                     if( bIsVariant )
                         *pStrm << (sal_uInt16)SbxSTRING;
-                    pStrm->WriteByteString( rStr, osl_getThreadTextEncoding() );
+                    pStrm->WriteUniOrByteString( rStr, osl_getThreadTextEncoding() );
                 }
                 else
                 {
@@ -1107,7 +1107,7 @@ sal_Bool lcl_ReadSbxVariable( SbxVariable& rVar, SvStream* pStrm,
         case SbxLPSTR:
                 {
                 String aStr;
-                pStrm->ReadByteString( aStr, osl_getThreadTextEncoding() );
+                pStrm->ReadUniOrByteString( aStr, osl_getThreadTextEncoding() );
                 rVar.PutString( aStr );
                 }
                 break;
diff --git a/basic/source/sbx/sbxbase.cxx b/basic/source/sbx/sbxbase.cxx
index 711efdc..7ab2d6c 100644
--- a/basic/source/sbx/sbxbase.cxx
+++ b/basic/source/sbx/sbxbase.cxx
@@ -383,15 +383,18 @@ sal_Bool SbxInfo::LoadData( SvStream& rStrm, sal_uInt16 nVer )
 {
     aParams.Remove( 0, aParams.Count() );
     sal_uInt16 nParam;
-    rStrm.ReadByteString( aComment, RTL_TEXTENCODING_ASCII_US );
-    rStrm.ReadByteString( aHelpFile, RTL_TEXTENCODING_ASCII_US );
+    aComment = read_lenPrefixed_uInt8s_ToOUString(rStrm,
+        RTL_TEXTENCODING_ASCII_US);
+    aHelpFile = read_lenPrefixed_uInt8s_ToOUString(rStrm,
+        RTL_TEXTENCODING_ASCII_US);
     rStrm >> nHelpId >> nParam;
     while( nParam-- )
     {
         XubString aName;
         sal_uInt16 nType, nFlags;
         sal_uInt32 nUserData = 0;
-        rStrm.ReadByteString( aName, RTL_TEXTENCODING_ASCII_US );
+        aName = read_lenPrefixed_uInt8s_ToOUString(rStrm,
+            RTL_TEXTENCODING_ASCII_US);
         rStrm >> nType >> nFlags;
         if( nVer > 1 )
             rStrm >> nUserData;
@@ -404,13 +407,16 @@ sal_Bool SbxInfo::LoadData( SvStream& rStrm, sal_uInt16 nVer )
 
 sal_Bool SbxInfo::StoreData( SvStream& rStrm ) const
 {
-    rStrm.WriteByteString( aComment, RTL_TEXTENCODING_ASCII_US );
-    rStrm.WriteByteString( aHelpFile, RTL_TEXTENCODING_ASCII_US );
+    write_lenPrefixed_uInt8s_FromOUString(rStrm, aComment,
+        RTL_TEXTENCODING_ASCII_US );
+    write_lenPrefixed_uInt8s_FromOUString(rStrm, aHelpFile,
+        RTL_TEXTENCODING_ASCII_US);
     rStrm << nHelpId << aParams.Count();
     for( sal_uInt16 i = 0; i < aParams.Count(); i++ )
     {
         SbxParamInfo* p = aParams.GetObject( i );
-        rStrm.WriteByteString( p->aName, RTL_TEXTENCODING_ASCII_US );
+        write_lenPrefixed_uInt8s_FromOUString(rStrm, p->aName,
+            RTL_TEXTENCODING_ASCII_US);
         rStrm << (sal_uInt16) p->eType
               << (sal_uInt16) p->nFlags
               << (sal_uInt32) p->nUserData;
diff --git a/basic/source/sbx/sbxcoll.cxx b/basic/source/sbx/sbxcoll.cxx
index 7803ee0..9757387 100644
--- a/basic/source/sbx/sbxcoll.cxx
+++ b/basic/source/sbx/sbxcoll.cxx
@@ -279,7 +279,8 @@ sal_Bool SbxStdCollection::LoadData( SvStream& rStrm, sal_uInt16 nVer )
     sal_Bool bRes = SbxCollection::LoadData( rStrm, nVer );
     if( bRes )
     {
-        rStrm.ReadByteString( aElemClass, RTL_TEXTENCODING_ASCII_US );
+        aElemClass = read_lenPrefixed_uInt8s_ToOUString(rStrm,
+            RTL_TEXTENCODING_ASCII_US);
         rStrm >> bAddRemoveOk;
     }
     return bRes;
@@ -290,7 +291,8 @@ sal_Bool SbxStdCollection::StoreData( SvStream& rStrm ) const
     sal_Bool bRes = SbxCollection::StoreData( rStrm );
     if( bRes )
     {
-        rStrm.WriteByteString( aElemClass, RTL_TEXTENCODING_ASCII_US );
+        write_lenPrefixed_uInt8s_FromOUString(rStrm, aElemClass,
+            RTL_TEXTENCODING_ASCII_US);
         rStrm << bAddRemoveOk;
     }
     return bRes;
diff --git a/basic/source/sbx/sbxobj.cxx b/basic/source/sbx/sbxobj.cxx
index 81574ef..0c98fca 100644
--- a/basic/source/sbx/sbxobj.cxx
+++ b/basic/source/sbx/sbxobj.cxx
@@ -591,8 +591,10 @@ sal_Bool SbxObject::LoadData( SvStream& rStrm, sal_uInt16 nVer )
         aData.pObj = this;
     sal_uInt32 nSize;
     XubString aDfltProp;
-    rStrm.ReadByteString( aClassName, RTL_TEXTENCODING_ASCII_US );
-    rStrm.ReadByteString( aDfltProp, RTL_TEXTENCODING_ASCII_US );
+    aClassName = read_lenPrefixed_uInt8s_ToOUString(rStrm,
+        RTL_TEXTENCODING_ASCII_US);
+    aDfltProp = read_lenPrefixed_uInt8s_ToOUString(rStrm,
+        RTL_TEXTENCODING_ASCII_US);
     sal_uIntPtr nPos = rStrm.Tell();
     rStrm >> nSize;
     if( !LoadPrivateData( rStrm, nVer ) )
@@ -620,8 +622,8 @@ sal_Bool SbxObject::StoreData( SvStream& rStrm ) const
     XubString aDfltProp;
     if( pDfltProp )
         aDfltProp = pDfltProp->GetName();
-    rStrm.WriteByteString( aClassName, RTL_TEXTENCODING_ASCII_US );
-    rStrm.WriteByteString( aDfltProp, RTL_TEXTENCODING_ASCII_US );
+    write_lenPrefixed_uInt8s_FromOUString(rStrm, aClassName, RTL_TEXTENCODING_ASCII_US);
+    write_lenPrefixed_uInt8s_FromOUString(rStrm, aDfltProp, RTL_TEXTENCODING_ASCII_US);
     sal_uIntPtr nPos = rStrm.Tell();
     rStrm << (sal_uInt32) 0L;
     if( !StorePrivateData( rStrm ) )
@@ -797,7 +799,7 @@ void SbxObject::Dump( SvStream& rStrm, sal_Bool bFill )
                 aLine += aAttrs2;
             if( !pVar->IsA( TYPE(SbxMethod) ) )
                 aLine.AppendAscii( "  !! Not a Method !!" );
-            rStrm.WriteByteString( aLine, RTL_TEXTENCODING_ASCII_US );
+            write_lenPrefixed_uInt8s_FromOUString(rStrm, aLine, RTL_TEXTENCODING_ASCII_US);
 
             // Output also the object at object-methods
             if ( pVar->GetValues_Impl().eType == SbxOBJECT &&
@@ -830,7 +832,7 @@ void SbxObject::Dump( SvStream& rStrm, sal_Bool bFill )
                     aLine += aAttrs3;
                 if( !pVar->IsA( TYPE(SbxProperty) ) )
                     aLine.AppendAscii( "  !! Not a Property !!" );
-                rStrm.WriteByteString( aLine, RTL_TEXTENCODING_ASCII_US );
+                write_lenPrefixed_uInt8s_FromOUString(rStrm, aLine, RTL_TEXTENCODING_ASCII_US);
 
                 // output also the object at object properties
                 if ( pVar->GetValues_Impl().eType == SbxOBJECT &&
diff --git a/basic/source/sbx/sbxvalue.cxx b/basic/source/sbx/sbxvalue.cxx
index 0d6aa84..692959a 100644
--- a/basic/source/sbx/sbxvalue.cxx
+++ b/basic/source/sbx/sbxvalue.cxx
@@ -1479,8 +1479,8 @@ sal_Bool SbxValue::LoadData( SvStream& r, sal_uInt16 )
         case SbxSINGLE:
         {
             // Floats as ASCII
-            XubString aVal;
-            r.ReadByteString( aVal, RTL_TEXTENCODING_ASCII_US );
+            XubString aVal = read_lenPrefixed_uInt8s_ToOUString(r,
+                RTL_TEXTENCODING_ASCII_US);
             double d;
             SbxDataType t;
             if( ImpScan( aVal, d, t, NULL ) != SbxERR_OK || t == SbxDOUBLE )
@@ -1495,8 +1495,8 @@ sal_Bool SbxValue::LoadData( SvStream& r, sal_uInt16 )
         case SbxDOUBLE:
         {
             // Floats as ASCII
-            XubString aVal;
-            r.ReadByteString( aVal, RTL_TEXTENCODING_ASCII_US );
+            XubString aVal = read_lenPrefixed_uInt8s_ToOUString(r,
+                RTL_TEXTENCODING_ASCII_US);
             SbxDataType t;
             if( ImpScan( aVal, aData.nDouble, t, NULL ) != SbxERR_OK )
             {
@@ -1524,9 +1524,9 @@ sal_Bool SbxValue::LoadData( SvStream& r, sal_uInt16 )
         }
         case SbxSTRING:
         {
-            XubString aVal;
-            r.ReadByteString( aVal, RTL_TEXTENCODING_ASCII_US );
-            if( aVal.Len() )
+            rtl::OUString aVal = read_lenPrefixed_uInt8s_ToOUString(r,
+                RTL_TEXTENCODING_ASCII_US);
+            if( aVal.getLength() )
                 aData.pOUString = new ::rtl::OUString( aVal );
             else
                 aData.pOUString = NULL; // JSM 1995-09-22
@@ -1621,12 +1621,12 @@ sal_Bool SbxValue::StoreData( SvStream& r ) const
         case SbxDATE:
             // #49935: Save as double, elsewise an error during the read in
             ((SbxValue*)this)->aData.eType = (SbxDataType)( ( nType & 0xF000 ) | SbxDOUBLE );
-            r.WriteByteString( GetCoreString(), RTL_TEXTENCODING_ASCII_US );
+            write_lenPrefixed_uInt8s_FromOUString(r, GetCoreString(), RTL_TEXTENCODING_ASCII_US);
             ((SbxValue*)this)->aData.eType = (SbxDataType)nType;
             break;
         case SbxSINGLE:
         case SbxDOUBLE:
-            r.WriteByteString( GetCoreString(), RTL_TEXTENCODING_ASCII_US );
+            write_lenPrefixed_uInt8s_FromOUString(r, GetCoreString(), RTL_TEXTENCODING_ASCII_US);
             break;
         case SbxSALUINT64:
         case SbxSALINT64:
@@ -1643,12 +1643,11 @@ sal_Bool SbxValue::StoreData( SvStream& r ) const
         case SbxSTRING:
             if( aData.pOUString )
             {
-                r.WriteByteString( *aData.pOUString, RTL_TEXTENCODING_ASCII_US );
+                write_lenPrefixed_uInt8s_FromOUString(r, *aData.pOUString, RTL_TEXTENCODING_ASCII_US);
             }
             else
             {
-                String aEmpty;
-                r.WriteByteString( aEmpty, RTL_TEXTENCODING_ASCII_US );
+                write_lenPrefixed_uInt8s_FromOUString(r, rtl::OUString(), RTL_TEXTENCODING_ASCII_US);
             }
             break;
         case SbxERROR:
diff --git a/basic/source/sbx/sbxvar.cxx b/basic/source/sbx/sbxvar.cxx
index 58b3cb7..6ca2533 100644
--- a/basic/source/sbx/sbxvar.cxx
+++ b/basic/source/sbx/sbxvar.cxx
@@ -445,7 +445,8 @@ sal_Bool SbxVariable::LoadData( SvStream& rStrm, sal_uInt16 nVer )
     {
         if( !SbxValue::LoadData( rStrm, nVer ) )
             return sal_False;
-        rStrm.ReadByteString( maName, RTL_TEXTENCODING_ASCII_US );
+        maName = read_lenPrefixed_uInt8s_ToOUString(rStrm,
+            RTL_TEXTENCODING_ASCII_US);
         sal_uInt32 nTemp;
         rStrm >> nTemp;
         nUserData = nTemp;
@@ -454,7 +455,8 @@ sal_Bool SbxVariable::LoadData( SvStream& rStrm, sal_uInt16 nVer )
     {
         rStrm.SeekRel( -1L );
         rStrm >> nType;
-        rStrm.ReadByteString( maName, RTL_TEXTENCODING_ASCII_US );
+        maName = read_lenPrefixed_uInt8s_ToOUString(rStrm,
+            RTL_TEXTENCODING_ASCII_US);
         sal_uInt32 nTemp;
         rStrm >> nTemp;
         nUserData = nTemp;
@@ -477,7 +479,8 @@ sal_Bool SbxVariable::LoadData( SvStream& rStrm, sal_uInt16 nVer )
             case SbxSINGLE:
             {
                 // Floats as ASCII
-                rStrm.ReadByteString( aTmpString, RTL_TEXTENCODING_ASCII_US );
+                aTmpString = read_lenPrefixed_uInt8s_ToOUString(
+                    rStrm, RTL_TEXTENCODING_ASCII_US);
                 double d;
                 SbxDataType t;
                 if( ImpScan( aTmpString, d, t, NULL ) != SbxERR_OK || t == SbxDOUBLE )
@@ -492,7 +495,8 @@ sal_Bool SbxVariable::LoadData( SvStream& rStrm, sal_uInt16 nVer )
             case SbxDOUBLE:
             {
                 // Floats as ASCII
-                rStrm.ReadByteString( aTmpString, RTL_TEXTENCODING_ASCII_US );
+                aTmpString = read_lenPrefixed_uInt8s_ToOUString(rStrm,
+                    RTL_TEXTENCODING_ASCII_US);
                 SbxDataType t;
                 if( ImpScan( aTmpString, aTmp.nDouble, t, NULL ) != SbxERR_OK )
                 {
@@ -502,8 +506,8 @@ sal_Bool SbxVariable::LoadData( SvStream& rStrm, sal_uInt16 nVer )
                 break;
             }
             case SbxSTRING:
-                rStrm.ReadByteString( aTmpString, RTL_TEXTENCODING_ASCII_US );
-                aVal = aTmpString;
+                aVal = read_lenPrefixed_uInt8s_ToOUString(rStrm,
+                    RTL_TEXTENCODING_ASCII_US);
                 break;
             case SbxEMPTY:
             case SbxNULL:
@@ -561,7 +565,8 @@ sal_Bool SbxVariable::StoreData( SvStream& rStrm ) const
         bValStore = SbxValue::StoreData( rStrm );
     if( !bValStore )
         return sal_False;
-    rStrm.WriteByteString( maName, RTL_TEXTENCODING_ASCII_US );
+    write_lenPrefixed_uInt8s_FromOUString(rStrm, maName,
+        RTL_TEXTENCODING_ASCII_US);
     rStrm << (sal_uInt32)nUserData;
     if( pInfo.Is() )
     {
diff --git a/dbaccess/source/ui/tabledesign/TableRow.cxx b/dbaccess/source/ui/tabledesign/TableRow.cxx
index b4ed28a..35be52c 100644
--- a/dbaccess/source/ui/tabledesign/TableRow.cxx
+++ b/dbaccess/source/ui/tabledesign/TableRow.cxx
@@ -128,9 +128,9 @@ namespace dbaui
         if(pFieldDesc)
         {
             _rStr << (sal_Int32)1;
-            _rStr.WriteByteString(pFieldDesc->GetName());
-            _rStr.WriteByteString(pFieldDesc->GetDescription());
-            _rStr.WriteByteString(pFieldDesc->GetHelpText());
+            _rStr.WriteUniOrByteString(pFieldDesc->GetName(), _rStr.GetStreamCharSet());
+            _rStr.WriteUniOrByteString(pFieldDesc->GetDescription(), _rStr.GetStreamCharSet());
+            _rStr.WriteUniOrByteString(pFieldDesc->GetHelpText(), _rStr.GetStreamCharSet());
             double nValue = 0.0;
             Any aValue = pFieldDesc->GetControlDefault();
             if ( aValue >>= nValue )
@@ -141,7 +141,7 @@ namespace dbaui
             else
             {
                 _rStr << sal_Int32(2);
-                _rStr.WriteByteString(::comphelper::getString(aValue));
+                _rStr.WriteUniOrByteString(::comphelper::getString(aValue), _rStr.GetStreamCharSet());
             }
 
             _rStr << pFieldDesc->GetType();
@@ -170,12 +170,12 @@ namespace dbaui
             OFieldDescription* pFieldDesc = new OFieldDescription();
             _rRow.m_pActFieldDescr = pFieldDesc;
             String sValue;
-            _rStr.ReadByteString(sValue);
+            _rStr.ReadUniOrByteString(sValue, _rStr.GetStreamCharSet());
             pFieldDesc->SetName(sValue);
 
-            _rStr.ReadByteString(sValue);
+            _rStr.ReadUniOrByteString(sValue, _rStr.GetStreamCharSet());
             pFieldDesc->SetDescription(sValue);
-            _rStr.ReadByteString(sValue);
+            _rStr.ReadUniOrByteString(sValue, _rStr.GetStreamCharSet());
             pFieldDesc->SetHelpText(sValue);
 
             _rStr >> nValue;
@@ -190,7 +190,7 @@ namespace dbaui
                     break;
                 }
                 case 2:
-                    _rStr.ReadByteString(sValue);
+                    _rStr.ReadUniOrByteString(sValue, _rStr.GetStreamCharSet());
                     aControlDefault <<= ::rtl::OUString(sValue);
                     break;
             }
diff --git a/editeng/source/editeng/editobj.cxx b/editeng/source/editeng/editobj.cxx
index 0fd144b..8435e66 100644
--- a/editeng/source/editeng/editobj.cxx
+++ b/editeng/source/editeng/editobj.cxx
@@ -1230,7 +1230,7 @@ void BinTextObject::CreateData( SvStream& rIStream )
         pC->GetText() = rtl::OStringToOUString(aByteString, eSrcEncoding);
 
         // StyleName and Family...
-        rIStream.ReadByteString( pC->GetStyle(), eSrcEncoding );
+        rIStream.ReadUniOrByteString( pC->GetStyle(), eSrcEncoding );
         sal_uInt16 nStyleFamily;
         rIStream >> nStyleFamily;
         pC->GetFamily() = (SfxStyleFamily)nStyleFamily;
@@ -1522,10 +1522,10 @@ void BinTextObject::CreateData300( SvStream& rIStream )
         ContentInfo* pC = CreateAndInsertContent();
 
         // The Text...
-        rIStream.ReadByteString( pC->GetText() );
+        rIStream.ReadUniOrByteString( pC->GetText(), rIStream.GetStreamCharSet() );
 
         // StyleName and Family...
-        rIStream.ReadByteString( pC->GetStyle() );
+        rIStream.ReadUniOrByteString( pC->GetStyle(), rIStream.GetStreamCharSet() );
         sal_uInt16 nStyleFamily;
         rIStream >> nStyleFamily;
         pC->GetFamily() = (SfxStyleFamily)nStyleFamily;
diff --git a/editeng/source/items/bulitem.cxx b/editeng/source/items/bulitem.cxx
index 2d0e066..caca392 100644
--- a/editeng/source/items/bulitem.cxx
+++ b/editeng/source/items/bulitem.cxx
@@ -64,7 +64,7 @@ void SvxBulletItem::StoreFont( SvStream& rStream, const Font& rFont )
     nTemp = (sal_uInt16)rFont.GetItalic(); rStream << nTemp;
 
     // UNICODE: rStream << rFont.GetName();
-    rStream.WriteByteString(rFont.GetName());
+    rStream.WriteUniOrByteString(rFont.GetName(), rStream.GetStreamCharSet());
 
     rStream << rFont.IsOutline();
     rStream << rFont.IsShadow();
@@ -94,7 +94,7 @@ Font SvxBulletItem::CreateFont( SvStream& rStream, sal_uInt16 nVer )
 
     // UNICODE: rStream >> aName; aFont.SetName( aName );
     String aName;
-    rStream.ReadByteString(aName);
+    rStream.ReadUniOrByteString(aName, rStream.GetStreamCharSet());
     aFont.SetName( aName );
 
     if( nVer == 1 )
@@ -217,10 +217,10 @@ SvxBulletItem::SvxBulletItem( SvStream& rStrm, sal_uInt16 _nWhich ) :
     rStrm >> nScale;
 
     // UNICODE: rStrm >> aPrevText;
-    rStrm.ReadByteString(aPrevText);
+    rStrm.ReadUniOrByteString(aPrevText, rStrm.GetStreamCharSet());
 
     // UNICODE: rStrm >> aFollowText;
-    rStrm.ReadByteString(aFollowText);
+    rStrm.ReadUniOrByteString(aFollowText, rStrm.GetStreamCharSet());
 
     nValidMask = 0xFFFF;
 }
@@ -416,10 +416,10 @@ SvStream& SvxBulletItem::Store( SvStream& rStrm, sal_uInt16 /*nItemVersion*/ ) c
     rStrm << nScale;
 
     // UNICODE: rStrm << aPrevText;
-    rStrm.WriteByteString(aPrevText);
+    rStrm.WriteUniOrByteString(aPrevText, rStrm.GetStreamCharSet());
 
     // UNICODE: rStrm << aFollowText;
-    rStrm.WriteByteString(aFollowText);
+    rStrm.WriteUniOrByteString(aFollowText, rStrm.GetStreamCharSet());
 
     return rStrm;
 }
diff --git a/editeng/source/items/flditem.cxx b/editeng/source/items/flditem.cxx
index 56b2d71..bafb976 100644
--- a/editeng/source/items/flditem.cxx
+++ b/editeng/source/items/flditem.cxx
@@ -735,7 +735,7 @@ void SvxExtFileField::Load( SvPersistStream & rStm )
     sal_uInt16 nType, nFormat;
 
     // UNICODE: rStm >> aFile;
-    rStm.ReadByteString(aFile);
+    rStm.ReadUniOrByteString(aFile, rStm.GetStreamCharSet());
 
     rStm >> nType;
     rStm >> nFormat;
@@ -749,7 +749,7 @@ void SvxExtFileField::Load( SvPersistStream & rStm )
 void SvxExtFileField::Save( SvPersistStream & rStm )
 {
     // UNICODE: rStm << aFile;
-    rStm.WriteByteString(aFile);
+    rStm.WriteUniOrByteString(aFile, rStm.GetStreamCharSet());
 
     rStm << (sal_uInt16) eType;
     rStm << (sal_uInt16) eFormat;
diff --git a/editeng/source/items/frmitems.cxx b/editeng/source/items/frmitems.cxx
index addb3f6..18af4a6 100644
--- a/editeng/source/items/frmitems.cxx
+++ b/editeng/source/items/frmitems.cxx
@@ -3443,7 +3443,7 @@ SvxBrushItem::SvxBrushItem( SvStream& rStream, sal_uInt16 nVersion,
         {
             String aRel;
             // UNICODE: rStream >> aRel;
-            rStream.ReadByteString(aRel);
+            rStream.ReadUniOrByteString(aRel, rStream.GetStreamCharSet());
 
             // TODO/MBA: how can we get a BaseURL here?!
             OSL_FAIL("No BaseURL!");
@@ -3456,7 +3456,7 @@ SvxBrushItem::SvxBrushItem( SvStream& rStream, sal_uInt16 nVersion,
         {
             pStrFilter = new String;
             // UNICODE: rStream >> *pStrFilter;
-            rStream.ReadByteString(*pStrFilter);
+            rStream.ReadUniOrByteString(*pStrFilter, rStream.GetStreamCharSet());
         }
 
         rStream >> nPos;
@@ -3834,12 +3834,12 @@ SvStream& SvxBrushItem::Store( SvStream& rStream , sal_uInt16 /*nItemVersion*/ )
         // TODO/MBA: how to get a BaseURL?!
         String aRel = INetURLObject::GetRelURL( String(), *pStrLink );
         // UNICODE: rStream << aRel;
-        rStream.WriteByteString(aRel);
+        rStream.WriteUniOrByteString(aRel, rStream.GetStreamCharSet());
     }
     if ( pStrFilter )
     {
         // UNICODE: rStream << *pStrFilter;
-        rStream.WriteByteString(*pStrFilter);
+        rStream.WriteUniOrByteString(*pStrFilter, rStream.GetStreamCharSet());
     }
     rStream << (sal_Int8)eGraphicPos;
     return rStream;
diff --git a/editeng/source/items/numitem.cxx b/editeng/source/items/numitem.cxx
index 8f71ff2..01fc463 100644
--- a/editeng/source/items/numitem.cxx
+++ b/editeng/source/items/numitem.cxx
@@ -219,9 +219,9 @@ SvStream&   SvxNumberFormat::Store(SvStream &rStream, FontToSubsFontConverter pC
 
     rStream << nCharTextDistance;
     rtl_TextEncoding eEnc = osl_getThreadTextEncoding();
-    rStream.WriteByteString(sPrefix, eEnc);
-    rStream.WriteByteString(sSuffix, eEnc);
-    rStream.WriteByteString(sCharStyleName, eEnc);
+    rStream.WriteUniOrByteString(sPrefix, eEnc);
+    rStream.WriteUniOrByteString(sSuffix, eEnc);
+    rStream.WriteUniOrByteString(sCharStyleName, eEnc);
     if(pGraphicBrush)
     {
         rStream << (sal_uInt16)1;
diff --git a/editeng/source/items/textitem.cxx b/editeng/source/items/textitem.cxx
index 4f5dc8d..e306907 100644
--- a/editeng/source/items/textitem.cxx
+++ b/editeng/source/items/textitem.cxx
@@ -398,16 +398,16 @@ SvStream& SvxFontItem::Store( SvStream& rStrm , sal_uInt16 /*nItemVersion*/ ) co
     String aStoreFamilyName( GetFamilyName() );
     if( bToBats )
         aStoreFamilyName = String( "StarBats", sizeof("StarBats")-1, RTL_TEXTENCODING_ASCII_US );
-    rStrm.WriteByteString(aStoreFamilyName);
-    rStrm.WriteByteString(GetStyleName());
+    rStrm.WriteUniOrByteString(aStoreFamilyName, rStrm.GetStreamCharSet());
+    rStrm.WriteUniOrByteString(GetStyleName(), rStrm.GetStreamCharSet());
 
     // cach for EditEngine, only set while creating clipboard stream.
     if ( bEnableStoreUnicodeNames )
     {
         sal_uInt32 nMagic = STORE_UNICODE_MAGIC_MARKER;
         rStrm << nMagic;
-        rStrm.WriteByteString( aStoreFamilyName, RTL_TEXTENCODING_UNICODE );
-        rStrm.WriteByteString( GetStyleName(), RTL_TEXTENCODING_UNICODE );
+        rStrm.WriteUniOrByteString( aStoreFamilyName, RTL_TEXTENCODING_UNICODE );
+        rStrm.WriteUniOrByteString( GetStyleName(), RTL_TEXTENCODING_UNICODE );
     }
 
     return rStrm;
@@ -424,10 +424,10 @@ SfxPoolItem* SvxFontItem::Create(SvStream& rStrm, sal_uInt16) const
     rStrm >> eFontTextEncoding;
 
     // UNICODE: rStrm >> aName;
-    rStrm.ReadByteString(aName);
+    rStrm.ReadUniOrByteString(aName, rStrm.GetStreamCharSet());
 
     // UNICODE: rStrm >> aStyle;
-    rStrm.ReadByteString(aStyle);
+    rStrm.ReadUniOrByteString(aStyle, rStrm.GetStreamCharSet());
 
     // Set the "correct" textencoding
     eFontTextEncoding = (sal_uInt8)GetSOLoadTextEncoding( eFontTextEncoding, (sal_uInt16)rStrm.GetVersion() );
@@ -442,8 +442,8 @@ SfxPoolItem* SvxFontItem::Create(SvStream& rStrm, sal_uInt16) const
     rStrm >> nMagic;
     if ( nMagic == STORE_UNICODE_MAGIC_MARKER )
     {
-        rStrm.ReadByteString( aName, RTL_TEXTENCODING_UNICODE );
-        rStrm.ReadByteString( aStyle, RTL_TEXTENCODING_UNICODE );
+        rStrm.ReadUniOrByteString( aName, RTL_TEXTENCODING_UNICODE );
+        rStrm.ReadUniOrByteString( aStyle, RTL_TEXTENCODING_UNICODE );
     }
     else
     {
diff --git a/idl/source/objects/module.cxx b/idl/source/objects/module.cxx
index 4fd5c78..e8e6542 100644
--- a/idl/source/objects/module.cxx
+++ b/idl/source/objects/module.cxx
@@ -65,7 +65,7 @@ void SvMetaModule::Load( SvPersistStream & rStm )
     rStm >> aTypeList;
     rStm >> aAttrList;
     // browser
-    rStm.ReadByteString( aIdlFileName );
+    rStm.ReadUniOrByteString( aIdlFileName, rStm.GetStreamCharSet() );
     aHelpFileName = read_lenPrefixed_uInt8s_ToOString(rStm);
     aSlotIdFile = read_lenPrefixed_uInt8s_ToOString(rStm);
     aModulePrefix = read_lenPrefixed_uInt8s_ToOString(rStm);
@@ -90,7 +90,7 @@ void SvMetaModule::Save( SvPersistStream & rStm )
     rStm << aTypeList;
     rStm << aAttrList;
     // browser
-    rStm.WriteByteString( aIdlFileName );
+    rStm.WriteUniOrByteString( aIdlFileName, rStm.GetStreamCharSet() );
     write_lenPrefixed_uInt8s_FromOString(rStm, aHelpFileName);
     write_lenPrefixed_uInt8s_FromOString(rStm, aSlotIdFile);
     write_lenPrefixed_uInt8s_FromOString(rStm, aModulePrefix);
@@ -368,9 +368,9 @@ void SvMetaModule::WriteSvIdl( SvIdlDataBase & rBase, SvStream & rOutStm,
 {
     rOutStm << SvHash_module()->GetName().GetBuffer() << endl
             << '\"';
-    rOutStm.WriteByteString( aBeginName.GetHexName() );
+    rOutStm.WriteUniOrByteString( aBeginName.GetHexName(), rOutStm.GetStreamCharSet() );
     rOutStm << '\"' << endl << '\"';
-    rOutStm.WriteByteString( aEndName.GetHexName() );
+    rOutStm.WriteUniOrByteString( aEndName.GetHexName(), rOutStm.GetStreamCharSet() );
     rOutStm << '\"' << endl;
     SvMetaExtern::WriteSvIdl( rBase, rOutStm, nTab );
 }
diff --git a/sc/source/core/data/patattr.cxx b/sc/source/core/data/patattr.cxx
index fbd982d..93adcfe 100644
--- a/sc/source/core/data/patattr.cxx
+++ b/sc/source/core/data/patattr.cxx
@@ -172,7 +172,7 @@ SfxPoolItem* ScPatternAttr::Create( SvStream& rStream, sal_uInt16 /* nVersion */
     {
         short   eFamDummy;
         pStr = new String;
-        rStream.ReadByteString( *pStr, rStream.GetStreamCharSet() );
+        rStream.ReadUniOrByteString( *pStr, rStream.GetStreamCharSet() );
         rStream >> eFamDummy; // wg. altem Dateiformat
     }
     else
@@ -194,11 +194,11 @@ SvStream& ScPatternAttr::Store(SvStream& rStream, sal_uInt16 /* nItemVersion */)
     rStream << (sal_Bool)sal_True;
 
     if ( pStyle )
-        rStream.WriteByteString( pStyle->GetName(), rStream.GetStreamCharSet() );
+        rStream.WriteUniOrByteString( pStyle->GetName(), rStream.GetStreamCharSet() );
     else if ( pName )                   // wenn Style geloescht ist/war
-        rStream.WriteByteString( *pName, rStream.GetStreamCharSet() );
+        rStream.WriteUniOrByteString( *pName, rStream.GetStreamCharSet() );
     else
-        rStream.WriteByteString( ScGlobal::GetRscString(STR_STYLENAME_STANDARD),
+        rStream.WriteUniOrByteString( ScGlobal::GetRscString(STR_STYLENAME_STANDARD),
                                     rStream.GetStreamCharSet() );
 
     rStream << (short)SFX_STYLE_FAMILY_PARA;  // wg. altem Dateiformat
diff --git a/sc/source/core/tool/autoform.cxx b/sc/source/core/tool/autoform.cxx
index fa7836b..61b8355 100644
--- a/sc/source/core/tool/autoform.cxx
+++ b/sc/source/core/tool/autoform.cxx
@@ -797,8 +797,14 @@ sal_Bool ScAutoFormatData::Load( SvStream& rStream, const ScAfVersions& rVersion
             (AUTOFORMAT_DATA_ID_504 <= nVer && nVer <= AUTOFORMAT_DATA_ID)) )
     {
         // --- from 680/dr25 on: store strings as UTF-8
-        CharSet eCharSet = (nVer >= AUTOFORMAT_ID_680DR25) ? RTL_TEXTENCODING_UTF8 : rStream.GetStreamCharSet();
-        rStream.ReadByteString( aName, eCharSet );
+        if (nVer >= AUTOFORMAT_ID_680DR25)
+        {
+            aName = read_lenPrefixed_uInt8s_ToOUString(rStream,
+                RTL_TEXTENCODING_UTF8);
+        }
+        else
+            rStream.ReadUniOrByteString( aName, rStream.GetStreamCharSet() );
+
         if( AUTOFORMAT_DATA_ID_552 <= nVer )
         {
             rStream >> nStrResId;
@@ -838,7 +844,7 @@ sal_Bool ScAutoFormatData::LoadOld( SvStream& rStream, const ScAfVersions& rVers
     bRet = (rStream.GetError() == 0);
     if (bRet && (nVal == AUTOFORMAT_OLD_DATA_ID))
     {
-        rStream.ReadByteString( aName, rStream.GetStreamCharSet() );
+        rStream.ReadUniOrByteString( aName, rStream.GetStreamCharSet() );
         sal_Bool b;
         rStream >> b; bIncludeFont = b;
         rStream >> b; bIncludeJustify = b;
@@ -863,7 +869,7 @@ sal_Bool ScAutoFormatData::Save(SvStream& rStream)
     sal_Bool b;
     rStream << nVal;
     // --- from 680/dr25 on: store strings as UTF-8
-    rStream.WriteByteString( aName, RTL_TEXTENCODING_UTF8 );
+    write_lenPrefixed_uInt8s_FromOUString(rStream, aName, RTL_TEXTENCODING_UTF8);
 
     rStream << nStrResId;
     rStream << ( b = bIncludeFont );
diff --git a/sc/source/core/tool/ddelink.cxx b/sc/source/core/tool/ddelink.cxx
index 7fbb58b..ca95681 100644
--- a/sc/source/core/tool/ddelink.cxx
+++ b/sc/source/core/tool/ddelink.cxx
@@ -92,9 +92,9 @@ ScDdeLink::ScDdeLink( ScDocument* pD, SvStream& rStream, ScMultipleReadHeader& r
     rHdr.StartEntry();
 
     rtl_TextEncoding eCharSet = rStream.GetStreamCharSet();
-    rStream.ReadByteString( aAppl, eCharSet );
-    rStream.ReadByteString( aTopic, eCharSet );
-    rStream.ReadByteString( aItem, eCharSet );
+    rStream.ReadUniOrByteString( aAppl, eCharSet );
+    rStream.ReadUniOrByteString( aTopic, eCharSet );
+    rStream.ReadUniOrByteString( aItem, eCharSet );
 
     sal_Bool bHasValue;
     rStream >> bHasValue;
@@ -114,9 +114,9 @@ void ScDdeLink::Store( SvStream& rStream, ScMultipleWriteHeader& rHdr ) const
     rHdr.StartEntry();
 
     rtl_TextEncoding eCharSet = rStream.GetStreamCharSet();
-    rStream.WriteByteString( aAppl, eCharSet );
-    rStream.WriteByteString( aTopic, eCharSet );
-    rStream.WriteByteString( aItem, eCharSet );
+    rStream.WriteUniOrByteString( aAppl, eCharSet );
+    rStream.WriteUniOrByteString( aTopic, eCharSet );
+    rStream.WriteUniOrByteString( aItem, eCharSet );
 
     sal_Bool bHasValue = ( pResult != NULL );
     rStream << bHasValue;
diff --git a/sc/source/core/tool/zforauto.cxx b/sc/source/core/tool/zforauto.cxx
index 4ebbee3..048c981 100644
--- a/sc/source/core/tool/zforauto.cxx
+++ b/sc/source/core/tool/zforauto.cxx
@@ -61,7 +61,7 @@ ScNumFormatAbbrev::ScNumFormatAbbrev(sal_uLong nFormat,
 void ScNumFormatAbbrev::Load( SvStream& rStream, CharSet eByteStrSet )
 {
     sal_uInt16 nSysLang, nLang;
-    rStream.ReadByteString( sFormatstring, eByteStrSet );
+    rStream.ReadUniOrByteString( sFormatstring, eByteStrSet );
     rStream >> nSysLang >> nLang;
     eLnge = (LanguageType) nLang;
     eSysLnge = (LanguageType) nSysLang;
@@ -71,7 +71,7 @@ void ScNumFormatAbbrev::Load( SvStream& rStream, CharSet eByteStrSet )
 
 void ScNumFormatAbbrev::Save( SvStream& rStream, CharSet eByteStrSet ) const
 {
-    rStream.WriteByteString( sFormatstring, eByteStrSet );
+    rStream.WriteUniOrByteString( sFormatstring, eByteStrSet );
     rStream << (sal_uInt16) eSysLnge << (sal_uInt16) eLnge;
 }
 
diff --git a/sd/source/filter/html/pubdlg.cxx b/sd/source/filter/html/pubdlg.cxx
index 6a9515d..5571461 100644
--- a/sd/source/filter/html/pubdlg.cxx
+++ b/sd/source/filter/html/pubdlg.cxx
@@ -267,19 +267,25 @@ SvStream& operator >> (SvStream& rIn, SdPublishingDesign& rDesign)
 
     sal_uInt16 nTemp16;
 
-    rIn.ReadByteString( rDesign.m_aDesignName, RTL_TEXTENCODING_UTF8 );
+    rDesign.m_aDesignName = read_lenPrefixed_uInt8s_ToOUString(rIn,
+        RTL_TEXTENCODING_UTF8);
     rIn >> nTemp16;
     rDesign.m_eMode = (HtmlPublishMode)nTemp16;
     rIn >> rDesign.m_bContentPage;
     rIn >> rDesign.m_bNotes;
     rIn >> rDesign.m_nResolution;
-    rIn.ReadByteString( rDesign.m_aCompression, RTL_TEXTENCODING_UTF8 );
+    rDesign.m_aCompression = read_lenPrefixed_uInt8s_ToOUString(rIn,
+        RTL_TEXTENCODING_UTF8);
     rIn >> nTemp16;
     rDesign.m_eFormat = (PublishingFormat)nTemp16;
-    rIn.ReadByteString( rDesign.m_aAuthor, RTL_TEXTENCODING_UTF8 );
-    rIn.ReadByteString( rDesign.m_aEMail, RTL_TEXTENCODING_UTF8 );
-    rIn.ReadByteString( rDesign.m_aWWW, RTL_TEXTENCODING_UTF8 );
-    rIn.ReadByteString( rDesign.m_aMisc, RTL_TEXTENCODING_UTF8 );
+    rDesign.m_aAuthor = read_lenPrefixed_uInt8s_ToOUString(rIn,
+        RTL_TEXTENCODING_UTF8);
+    rDesign.m_aEMail = read_lenPrefixed_uInt8s_ToOUString(rIn,
+        RTL_TEXTENCODING_UTF8);
+    rDesign.m_aWWW = read_lenPrefixed_uInt8s_ToOUString(rIn,
+        RTL_TEXTENCODING_UTF8);
+    rDesign.m_aMisc = read_lenPrefixed_uInt8s_ToOUString(rIn,
+        RTL_TEXTENCODING_UTF8);
     rIn >> rDesign.m_bDownload;
     rIn >> rDesign.m_bCreated;      // not used
     rIn >> rDesign.m_nButtonThema;
@@ -294,8 +300,10 @@ SvStream& operator >> (SvStream& rIn, SdPublishingDesign& rDesign)
 
     rIn >> nTemp16;
     rDesign.m_eScript = (PublishingScript)nTemp16;
-    rIn.ReadByteString( rDesign.m_aURL, RTL_TEXTENCODING_UTF8 );
-    rIn.ReadByteString( rDesign.m_aCGI, RTL_TEXTENCODING_UTF8 );
+    rDesign.m_aURL = read_lenPrefixed_uInt8s_ToOUString(rIn,
+        RTL_TEXTENCODING_UTF8);
+    rDesign.m_aCGI = read_lenPrefixed_uInt8s_ToOUString(rIn,
+        RTL_TEXTENCODING_UTF8);
 
     rIn >> rDesign.m_bAutoSlide;
     rIn >> rDesign.m_nSlideDuration;
@@ -315,18 +323,24 @@ SvStream& operator << (SvStream& rOut, const SdPublishingDesign& rDesign)
     SdIOCompat aIO(rOut, STREAM_WRITE, 0);
 
     // Name
-    rOut.WriteByteString( rDesign.m_aDesignName, RTL_TEXTENCODING_UTF8 );
+    write_lenPrefixed_uInt8s_FromOUString(rOut, rDesign.m_aDesignName,
+        RTL_TEXTENCODING_UTF8);
 
     rOut << (sal_uInt16)rDesign.m_eMode;
     rOut << rDesign.m_bContentPage;
     rOut << rDesign.m_bNotes;
     rOut << rDesign.m_nResolution;
-    rOut.WriteByteString( rDesign.m_aCompression, RTL_TEXTENCODING_UTF8 );
+    write_lenPrefixed_uInt8s_FromOUString(rOut, rDesign.m_aCompression,
+        RTL_TEXTENCODING_UTF8);
     rOut << (sal_uInt16)rDesign.m_eFormat;
-    rOut.WriteByteString( rDesign.m_aAuthor, RTL_TEXTENCODING_UTF8 );
-    rOut.WriteByteString( rDesign.m_aEMail, RTL_TEXTENCODING_UTF8 );
-    rOut.WriteByteString( rDesign.m_aWWW, RTL_TEXTENCODING_UTF8 );
-    rOut.WriteByteString( rDesign.m_aMisc, RTL_TEXTENCODING_UTF8 );
+    write_lenPrefixed_uInt8s_FromOUString(rOut, rDesign.m_aAuthor,
+        RTL_TEXTENCODING_UTF8);
+    write_lenPrefixed_uInt8s_FromOUString(rOut, rDesign.m_aEMail,
+        RTL_TEXTENCODING_UTF8);
+    write_lenPrefixed_uInt8s_FromOUString(rOut, rDesign.m_aWWW,
+        RTL_TEXTENCODING_UTF8);
+    write_lenPrefixed_uInt8s_FromOUString(rOut, rDesign.m_aMisc,
+        RTL_TEXTENCODING_UTF8);
     rOut << rDesign.m_bDownload;
     rOut << rDesign.m_bCreated;     // not used
     rOut << rDesign.m_nButtonThema;
@@ -340,8 +354,10 @@ SvStream& operator << (SvStream& rOut, const SdPublishingDesign& rDesign)
     rOut << rDesign.m_bUseColor;
 
     rOut << (sal_uInt16)rDesign.m_eScript;
-    rOut.WriteByteString( rDesign.m_aURL, RTL_TEXTENCODING_UTF8 );
-    rOut.WriteByteString( rDesign.m_aCGI, RTL_TEXTENCODING_UTF8 );
+    write_lenPrefixed_uInt8s_FromOUString(rOut, rDesign.m_aURL,
+        RTL_TEXTENCODING_UTF8);
+    write_lenPrefixed_uInt8s_FromOUString(rOut, rDesign.m_aCGI,
+        RTL_TEXTENCODING_UTF8);
 
     rOut << rDesign.m_bAutoSlide;
     rOut << rDesign.m_nSlideDuration;
diff --git a/sfx2/source/appl/appmisc.cxx b/sfx2/source/appl/appmisc.cxx
index e323361..eaef4b4 100644
--- a/sfx2/source/appl/appmisc.cxx
+++ b/sfx2/source/appl/appmisc.cxx
@@ -192,7 +192,7 @@ std::vector<sal_uInt16>* SfxApplication::GetDisabledSlotList_Impl()
         {
             // Read Slot file
             String aTitle;
-            pStream->ReadByteString(aTitle);
+            pStream->ReadUniOrByteString(aTitle, pStream->GetStreamCharSet());
             if ( aTitle.CompareToAscii("SfxSlotFile" ) == COMPARE_EQUAL )
             {
                 sal_uInt16 nCount;
@@ -207,7 +207,7 @@ std::vector<sal_uInt16>* SfxApplication::GetDisabledSlotList_Impl()
                     pList->push_back( nSlot );
                 }
 
-                pStream->ReadByteString(aTitle);
+                pStream->ReadUniOrByteString(aTitle, pStream->GetStreamCharSet());
                 if ( aTitle.CompareToAscii("END" ) != COMPARE_EQUAL || pStream->GetError() )
                 {
                     // Read failed
diff --git a/sot/source/sdstor/ucbstorage.cxx b/sot/source/sdstor/ucbstorage.cxx
index f1cf5c0..49c7bd3 100644
--- a/sot/source/sdstor/ucbstorage.cxx
+++ b/sot/source/sdstor/ucbstorage.cxx
@@ -3375,7 +3375,7 @@ String UCBStorage::CreateLinkFile( const String& rName )
         // store it as key/value pair
         String aLink = String::CreateFromAscii("ContentURL=");
         aLink += aURL;
-        pStream->WriteByteString( aLink, RTL_TEXTENCODING_UTF8 );
+        write_lenPrefixed_uInt8s_FromOUString(*pStream, aLink, RTL_TEXTENCODING_UTF8);
         pStream->Flush();
 
         // move the stream to its desired location
diff --git a/svl/source/items/poolitem.cxx b/svl/source/items/poolitem.cxx
index e6dab39..8970688 100644
--- a/svl/source/items/poolitem.cxx
+++ b/svl/source/items/poolitem.cxx
@@ -187,7 +187,7 @@ SvStream& SfxPoolItem::Store(SvStream &rStream, sal_uInt16 ) const
 // static
 bool SfxPoolItem::readByteString(SvStream & rStream, UniString & rString)
 {
-    rStream.ReadByteString(rString);
+    rStream.ReadUniOrByteString(rString, rStream.GetStreamCharSet());
     return rStream.GetError() == ERRCODE_NONE;
 }
 
@@ -196,7 +196,7 @@ bool SfxPoolItem::readByteString(SvStream & rStream, UniString & rString)
 void SfxPoolItem::writeByteString(SvStream & rStream,
                                   UniString const & rString)
 {
-    rStream.WriteByteString(rString);
+    rStream.WriteUniOrByteString(rString, rStream.GetStreamCharSet());
 }
 
 //============================================================================
@@ -204,7 +204,7 @@ void SfxPoolItem::writeByteString(SvStream & rStream,
 bool SfxPoolItem::readUnicodeString(SvStream & rStream, UniString & rString,
                                     bool bUnicode)
 {
-    rStream.ReadByteString(rString,
+    rStream.ReadUniOrByteString(rString,
                            bUnicode ? RTL_TEXTENCODING_UCS2 :
                                       rStream.GetStreamCharSet());
     return rStream.GetError() == ERRCODE_NONE;
@@ -215,7 +215,7 @@ bool SfxPoolItem::readUnicodeString(SvStream & rStream, UniString & rString,
 void SfxPoolItem::writeUnicodeString(SvStream & rStream,
                                      UniString const & rString)
 {
-    rStream.WriteByteString(rString, RTL_TEXTENCODING_UCS2);
+    rStream.WriteUniOrByteString(rString, RTL_TEXTENCODING_UCS2);
 }
 
 // ------------------------------------------------------------------------
diff --git a/svl/source/numbers/zformat.cxx b/svl/source/numbers/zformat.cxx
index 424aaa0..852e16d 100644
--- a/svl/source/numbers/zformat.cxx
+++ b/svl/source/numbers/zformat.cxx
@@ -154,7 +154,7 @@ void ImpSvNumberformatInfo::Save(SvStream& rStream, sal_uInt16 nAnz) const
 {
     for (sal_uInt16 i = 0; i < nAnz; i++)
     {
-        rStream.WriteByteString( sStrArray[i], rStream.GetStreamCharSet() );
+        rStream.WriteUniOrByteString( sStrArray[i], rStream.GetStreamCharSet() );
         short nType = nTypeArray[i];
         switch ( nType )
         {   // der Krampf fuer Versionen vor SV_NUMBERFORMATTER_VERSION_NEW_CURR
@@ -392,7 +392,7 @@ void ImpSvNumFor::Save(SvStream& rStream) const
 {
     rStream << nAnzStrings;
     aI.Save(rStream, nAnzStrings);
-    rStream.WriteByteString( sColorName, rStream.GetStreamCharSet() );
+    rStream.WriteUniOrByteString( sColorName, rStream.GetStreamCharSet() );
 }
 
 void ImpSvNumFor::Load(SvStream& rStream, ImpSvNumberformatScan& rSc,
@@ -402,7 +402,7 @@ void ImpSvNumFor::Load(SvStream& rStream, ImpSvNumberformatScan& rSc,
     rStream >> nAnz;        //! noch nicht direkt nAnzStrings wg. Enlarge
     Enlarge( nAnz );
     aI.Load( rStream, nAnz );
-    rStream.ReadByteString( sColorName, rStream.GetStreamCharSet() );
+    rStream.ReadUniOrByteString( sColorName, rStream.GetStreamCharSet() );
     rLoadedColorName = sColorName;
     pColor = rSc.GetColor(sColorName);
 }
@@ -1828,13 +1828,13 @@ void SvNumberformat::Save( SvStream& rStream, ImpSvNumMultipleWriteHeader& rHdr
     }
 
     rHdr.StartEntry();
-    rStream.WriteByteString( aFormatstring, rStream.GetStreamCharSet() );
+    rStream.WriteUniOrByteString( aFormatstring, rStream.GetStreamCharSet() );
     rStream << eType << fLimit1 << fLimit2 << (sal_uInt16) eOp1 << (sal_uInt16) eOp2
             << sal_Bool(bOldStandard) << sal_Bool(bIsUsed);
     for (sal_uInt16 i = 0; i < 4; i++)
         NumFor[i].Save(rStream);
     // ab SV_NUMBERFORMATTER_VERSION_NEWSTANDARD
-    rStream.WriteByteString( aComment, rStream.GetStreamCharSet() );
+    rStream.WriteUniOrByteString( aComment, rStream.GetStreamCharSet() );
     rStream << nNewStandardDefined;
     // ab SV_NUMBERFORMATTER_VERSION_NEW_CURR
     rStream << nNewCurrencyVersionId;
diff --git a/svtools/source/misc/templatefoldercache.cxx b/svtools/source/misc/templatefoldercache.cxx
index 41f0af0..e2a340a 100644
--- a/svtools/source/misc/templatefoldercache.cxx
+++ b/svtools/source/misc/templatefoldercache.cxx
@@ -292,7 +292,7 @@ namespace svt
 
         void operator() ( const String& _rString ) const
         {
-            m_rStorage.WriteByteString( _rString );
+            m_rStorage.WriteUniOrByteString( _rString, m_rStorage.GetStreamCharSet() );
         }
     };
 
@@ -418,7 +418,7 @@ namespace svt
             while ( nChildren-- )
             {
                 String sURL;
-                m_rStorage.ReadByteString( sURL );
+                m_rStorage.ReadUniOrByteString( sURL, m_rStorage.GetStreamCharSet() );
                 sURL = m_xOfficeInstDirs->makeAbsoluteURL( sURL );
                 INetURLObject aChildURL( sURL );
                 rChildren.push_back( new TemplateContent( aChildURL ) );
@@ -736,7 +736,7 @@ namespace svt
         while ( nRootDirectories-- )
         {
             String sURL;
-            m_pCacheStream->ReadByteString( sURL );
+            m_pCacheStream->ReadUniOrByteString( sURL, m_pCacheStream->GetStreamCharSet() );
             // #116281# Keep office installtion relocatable. Never store
             // any direct references to office installation directory.
             sURL = getOfficeInstDirs()->makeAbsoluteURL( sURL );
diff --git a/svtools/source/misc/transfer.cxx b/svtools/source/misc/transfer.cxx
index aac7126..c8158d1 100644
--- a/svtools/source/misc/transfer.cxx
+++ b/svtools/source/misc/transfer.cxx
@@ -96,8 +96,8 @@ SvStream& operator>>( SvStream& rIStm, TransferableObjectDescriptor& rObjDesc )
     rIStm >> rObjDesc.maSize.Height();
     rIStm >> rObjDesc.maDragStartPos.X();
     rIStm >> rObjDesc.maDragStartPos.Y();
-    rIStm.ReadByteString( rObjDesc.maTypeName, osl_getThreadTextEncoding() );
-    rIStm.ReadByteString( rObjDesc.maDisplayName, osl_getThreadTextEncoding() );
+    rIStm.ReadUniOrByteString( rObjDesc.maTypeName, osl_getThreadTextEncoding() );
+    rIStm.ReadUniOrByteString( rObjDesc.maDisplayName, osl_getThreadTextEncoding() );
     rIStm >> nSig1 >> nSig2;
 
     rObjDesc.mnViewAspect = static_cast< sal_uInt16 >( nViewAspect );
@@ -126,8 +126,8 @@ SvStream& operator<<( SvStream& rOStm, const TransferableObjectDescriptor& rObjD
     rOStm << rObjDesc.maSize.Height();
     rOStm << rObjDesc.maDragStartPos.X();
     rOStm << rObjDesc.maDragStartPos.Y();
-    rOStm.WriteByteString( rObjDesc.maTypeName, osl_getThreadTextEncoding() );
-    rOStm.WriteByteString( rObjDesc.maDisplayName, osl_getThreadTextEncoding() );
+    rOStm.WriteUniOrByteString( rObjDesc.maTypeName, osl_getThreadTextEncoding() );
+    rOStm.WriteUniOrByteString( rObjDesc.maDisplayName, osl_getThreadTextEncoding() );
     rOStm << nSig1 << nSig2;
 
     const sal_uInt32 nLastPos = rOStm.Tell();
diff --git a/svx/source/items/hlnkitem.cxx b/svx/source/items/hlnkitem.cxx
index 11a26aa..1f6dfa8 100644
--- a/svx/source/items/hlnkitem.cxx
+++ b/svx/source/items/hlnkitem.cxx
@@ -49,13 +49,13 @@ SvStream& SvxHyperlinkItem::Store( SvStream& rStrm, sal_uInt16 /*nItemVersion*/
 {
     // store 'simple' data
     // UNICODE: rStrm << sName;
-    rStrm.WriteByteString(sName);
+    rStrm.WriteUniOrByteString(sName, rStrm.GetStreamCharSet());
 
     // UNICODE: rStrm << sURL;
-    rStrm.WriteByteString(sURL);
+    rStrm.WriteUniOrByteString(sURL, rStrm.GetStreamCharSet());
 
     // UNICODE: rStrm << sTarget;
-    rStrm.WriteByteString(sTarget);
+    rStrm.WriteUniOrByteString(sTarget, rStrm.GetStreamCharSet());
 
     rStrm << (sal_uInt32) eType;
 
@@ -64,7 +64,7 @@ SvStream& SvxHyperlinkItem::Store( SvStream& rStrm, sal_uInt16 /*nItemVersion*/
 
     // new data
     // UNICODE: rStrm << sIntName;
-    rStrm.WriteByteString(sIntName);
+    rStrm.WriteUniOrByteString(sIntName, rStrm.GetStreamCharSet());
 
     // macro-events
     rStrm << nMacroEvents;
@@ -91,10 +91,10 @@ SvStream& SvxHyperlinkItem::Store( SvStream& rStrm, sal_uInt16 /*nItemVersion*/
                 rStrm << (sal_uInt16)pMacroTable->GetCurKey();
 
                 // UNICODE: rStrm << pMac->GetLibName();
-                rStrm.WriteByteString(pMac->GetLibName());
+                rStrm.WriteUniOrByteString(pMac->GetLibName(), rStrm.GetStreamCharSet());
 
                 // UNICODE: rStrm << pMac->GetMacName();
-                rStrm.WriteByteString(pMac->GetMacName());
+                rStrm.WriteUniOrByteString(pMac->GetMacName(), rStrm.GetStreamCharSet());
             }
         }
     }
@@ -111,10 +111,10 @@ SvStream& SvxHyperlinkItem::Store( SvStream& rStrm, sal_uInt16 /*nItemVersion*/
                 rStrm << (sal_uInt16)pMacroTable->GetCurKey();
 
                 // UNICODE: rStrm << pMac->GetLibName();
-                rStrm.WriteByteString(pMac->GetLibName());
+                rStrm.WriteUniOrByteString(pMac->GetLibName(), rStrm.GetStreamCharSet());
 
                 // UNICODE: rStrm << pMac->GetMacName();
-                rStrm.WriteByteString(pMac->GetMacName());
+                rStrm.WriteUniOrByteString(pMac->GetMacName(), rStrm.GetStreamCharSet());
 
                 rStrm << (sal_uInt16)pMac->GetScriptType();
             }
@@ -131,13 +131,13 @@ SfxPoolItem*    SvxHyperlinkItem::Create( SvStream &rStrm, sal_uInt16 /*nItemVer
 
     // simple data-types
     // UNICODE: rStrm >> pNew->sName;
-    rStrm.ReadByteString(pNew->sName);
+    rStrm.ReadUniOrByteString(pNew->sName, rStrm.GetStreamCharSet());
 
     // UNICODE: rStrm >> pNew->sURL;
-    rStrm.ReadByteString(pNew->sURL);
+    rStrm.ReadUniOrByteString(pNew->sURL, rStrm.GetStreamCharSet());
 
     // UNICODE: rStrm >> pNew->sTarget;
-    rStrm.ReadByteString(pNew->sTarget);
+    rStrm.ReadUniOrByteString(pNew->sTarget, rStrm.GetStreamCharSet());
 
     rStrm >> nType;
     pNew->eType = (SvxLinkInsertMode) nType;
@@ -149,7 +149,7 @@ SfxPoolItem*    SvxHyperlinkItem::Create( SvStream &rStrm, sal_uInt16 /*nItemVer
     {
         // new data
         // UNICODE: rStrm >> pNew->sIntName;
-        rStrm.ReadByteString(pNew->sIntName);
+        rStrm.ReadUniOrByteString(pNew->sIntName, rStrm.GetStreamCharSet());
 
         // macro-events
         rStrm >> pNew->nMacroEvents;
@@ -164,10 +164,10 @@ SfxPoolItem*    SvxHyperlinkItem::Create( SvStream &rStrm, sal_uInt16 /*nItemVer
 
             rStrm >> nCurKey;
             // UNICODE: rStrm >> aLibName;
-            rStrm.ReadByteString(aLibName);
+            rStrm.ReadUniOrByteString(aLibName, rStrm.GetStreamCharSet());
 
             // UNICODE: rStrm >> aMacName;
-            rStrm.ReadByteString(aMacName);
+            rStrm.ReadUniOrByteString(aMacName, rStrm.GetStreamCharSet());
 
             pNew->SetMacro( nCurKey, SvxMacro( aMacName, aLibName, STARBASIC ) );
         }
@@ -181,10 +181,10 @@ SfxPoolItem*    SvxHyperlinkItem::Create( SvStream &rStrm, sal_uInt16 /*nItemVer
             rStrm >> nCurKey;
 
             // UNICODE: rStrm >> aLibName;
-            rStrm.ReadByteString(aLibName);
+            rStrm.ReadUniOrByteString(aLibName, rStrm.GetStreamCharSet());
 
             // UNICODE: rStrm >> aMacName;
-            rStrm.ReadByteString(aMacName);
+            rStrm.ReadUniOrByteString(aMacName, rStrm.GetStreamCharSet());
 
             rStrm >> nScriptType;
 
diff --git a/svx/source/items/pageitem.cxx b/svx/source/items/pageitem.cxx
index 0ac676d..7dcffd0 100644
--- a/svx/source/items/pageitem.cxx
+++ b/svx/source/items/pageitem.cxx
@@ -251,7 +251,7 @@ SfxPoolItem* SvxPageItem::Create( SvStream& rStream, sal_uInt16 ) const
     sal_uInt16 nUse;
 
     // UNICODE: rStream >> sStr;
-    rStream.ReadByteString( sStr );
+    rStream.ReadUniOrByteString( sStr, rStream.GetStreamCharSet() );
 
     rStream >> eType;
     rStream >> bLand;
@@ -270,7 +270,7 @@ SfxPoolItem* SvxPageItem::Create( SvStream& rStream, sal_uInt16 ) const
 SvStream& SvxPageItem::Store( SvStream &rStrm, sal_uInt16 /*nItemVersion*/ ) const
 {
     // UNICODE: rStrm << aDescName;
-    rStrm.WriteByteString(aDescName);
+    rStrm.WriteUniOrByteString(aDescName, rStrm.GetStreamCharSet());
 
     rStrm << (sal_uInt8)eNumType << bLandscape << eUse;
     return rStrm;
diff --git a/sw/source/core/doc/tblafmt.cxx b/sw/source/core/doc/tblafmt.cxx
index d9c3a01..be2d325 100644
--- a/sw/source/core/doc/tblafmt.cxx
+++ b/sw/source/core/doc/tblafmt.cxx
@@ -401,7 +401,7 @@ sal_Bool SwBoxAutoFmt::Load( SvStream& rStream, const SwAfVersions& rVersions, s
         sal_uInt16 eSys, eLge;
         // --- from 680/dr25 on: store strings as UTF-8
         CharSet eCharSet = (nVer >= AUTOFORMAT_ID_680DR25) ? RTL_TEXTENCODING_UTF8 : rStream.GetStreamCharSet();
-        rStream.ReadByteString( sNumFmtString, eCharSet )
+        rStream.ReadUniOrByteString( sNumFmtString, eCharSet )
                 >> eSys >> eLge;
         eSysLanguage = (LanguageType) eSys;
         eNumFmtLanguage = (LanguageType) eLge;
@@ -486,8 +486,9 @@ sal_Bool SwBoxAutoFmt::Save( SvStream& rStream ) const
     aRotateMode.Store( rStream, aRotateMode.GetVersion(SOFFICE_FILEFORMAT_40) );
 
     // --- from 680/dr25 on: store strings as UTF-8
-    rStream.WriteByteString( sNumFmtString, RTL_TEXTENCODING_UTF8 )
-        << (sal_uInt16)eSysLanguage << (sal_uInt16)eNumFmtLanguage;
+    write_lenPrefixed_uInt8s_FromOUString(rStream, sNumFmtString,
+        RTL_TEXTENCODING_UTF8);
+    rStream << (sal_uInt16)eSysLanguage << (sal_uInt16)eNumFmtLanguage;
 
     return 0 == rStream.GetError();
 }
@@ -779,7 +780,7 @@ sal_Bool SwTableAutoFmt::Load( SvStream& rStream, const SwAfVersions& rVersions
         sal_Bool b;
         // --- from 680/dr25 on: store strings as UTF-8
         CharSet eCharSet = (nVal >= AUTOFORMAT_ID_680DR25) ? RTL_TEXTENCODING_UTF8 : rStream.GetStreamCharSet();
-        rStream.ReadByteString( aName, eCharSet );
+        rStream.ReadUniOrByteString( aName, eCharSet );
         if( AUTOFORMAT_DATA_ID_552 <= nVal )
         {
             rStream >> nStrResId;
@@ -829,7 +830,7 @@ sal_Bool SwTableAutoFmt::LoadOld( SvStream& rStream, sal_uInt16 aLoadVer[] )
     if( bRet && ( AUTOFORMAT_OLD_DATA_ID == nVal ))
     {
         sal_Bool b;
-        rStream.ReadByteString( aName, rStream.GetStreamCharSet() );
+        rStream.ReadUniOrByteString( aName, rStream.GetStreamCharSet() );
         rStream >> b; bInclFont = b;
         rStream >> b; bInclJustify = b;
         rStream >> b; bInclFrame = b;
@@ -860,7 +861,8 @@ sal_Bool SwTableAutoFmt::Save( SvStream& rStream ) const
     sal_Bool b;
     rStream << nVal;
     // --- from 680/dr25 on: store strings as UTF-8
-    rStream.WriteByteString( aName, RTL_TEXTENCODING_UTF8 );
+    write_lenPrefixed_uInt8s_FromOUString(rStream, aName,
+        RTL_TEXTENCODING_UTF8 );
     rStream << nStrResId;
     rStream << ( b = bInclFont );
     rStream << ( b = bInclJustify );
diff --git a/sw/source/ui/config/uinums.cxx b/sw/source/ui/config/uinums.cxx
index b521578..c43a2f4 100644
--- a/sw/source/ui/config/uinums.cxx
+++ b/sw/source/ui/config/uinums.cxx
@@ -235,7 +235,7 @@ const SwNumRulesWithName& SwNumRulesWithName::operator=(const SwNumRulesWithName
 SwNumRulesWithName::SwNumRulesWithName( SvStream &rStream, sal_uInt16 nVersion )
 {
     CharSet eEncoding = osl_getThreadTextEncoding();
-    rStream.ReadByteString(aName, eEncoding);
+    rStream.ReadUniOrByteString(aName, eEncoding);
 
     char c;
     for(sal_uInt16 n = 0; n < MAXLEVEL; ++n )
@@ -274,7 +274,7 @@ void SwNumRulesWithName::MakeNumRule( SwWrtShell& rSh, SwNumRule& rChg ) const
 void SwNumRulesWithName::Store( SvStream &rStream )
 {
     CharSet eEncoding = osl_getThreadTextEncoding();
-    rStream.WriteByteString(aName, eEncoding);
+    rStream.WriteUniOrByteString(aName, eEncoding);
 
     for( sal_uInt16 n = 0; n < MAXLEVEL; ++n )
     {
@@ -354,9 +354,9 @@ SwNumRulesWithName::_SwNumFmtGlobal::_SwNumFmtGlobal( SvStream& rStream,
             long nL;
             rStream >> cChar;       aFmt.SetStart( (sal_uInt16)cChar );
 
-            rStream.ReadByteString(sStr, eEncoding);
+            rStream.ReadUniOrByteString(sStr, eEncoding);
             aFmt.SetPrefix( sStr );
-            rStream.ReadByteString(sStr, eEncoding);
+            rStream.ReadUniOrByteString(sStr, eEncoding);
             aFmt.SetSuffix( sStr );
             rStream >> nUS;         aFmt.SetNumAdjust( SvxAdjust( nUS ) );
             rStream >> nL;          aFmt.SetLSpace( lNumIndent );
@@ -366,9 +366,9 @@ SwNumRulesWithName::_SwNumFmtGlobal::_SwNumFmtGlobal( SvStream& rStream,
         {
             short nShort;
             rStream >> nUS;         aFmt.SetStart( nUS );
-            rStream.ReadByteString(sStr, eEncoding);
+            rStream.ReadUniOrByteString(sStr, eEncoding);
             aFmt.SetPrefix( sStr );
-            rStream.ReadByteString(sStr, eEncoding);
+            rStream.ReadUniOrByteString(sStr, eEncoding);
             aFmt.SetSuffix( sStr );
             rStream >> nUS;         aFmt.SetNumAdjust( SvxAdjust( nUS ) );
             rStream >> nUS;         aFmt.SetAbsLSpace( nUS );
@@ -385,7 +385,7 @@ SwNumRulesWithName::_SwNumFmtGlobal::_SwNumFmtGlobal( SvStream& rStream,
         sal_uInt16  nPitch;
         String aName;
 
-        rStream.ReadByteString(aName, eEncoding);
+        rStream.ReadUniOrByteString(aName, eEncoding);
         rStream >> nFamily >> nCharSet >> nWidth >> nHeight >> nPitch;
 
         if( aName.Len() )
@@ -411,7 +411,7 @@ SwNumRulesWithName::_SwNumFmtGlobal::_SwNumFmtGlobal( SvStream& rStream,
     {
         sal_uInt16 nItemCount;
         rStream >> nCharPoolId;
-        rStream.ReadByteString(sCharFmtName, eEncoding);
+        rStream.ReadUniOrByteString(sCharFmtName, eEncoding);
         rStream >> nItemCount;
 
         while( nItemCount-- )
@@ -485,15 +485,15 @@ void SwNumRulesWithName::_SwNumFmtGlobal::Store( SvStream& rStream )
                 << aFmt.GetBulletChar()
                 << static_cast<sal_Bool>(aFmt.GetIncludeUpperLevels() > 0)
                 << aFmt.GetStart();
-        rStream.WriteByteString( aFmt.GetPrefix(), eEncoding );
-        rStream.WriteByteString( aFmt.GetSuffix(), eEncoding );
+        rStream.WriteUniOrByteString( aFmt.GetPrefix(), eEncoding );
+        rStream.WriteUniOrByteString( aFmt.GetSuffix(), eEncoding );
         rStream << sal_uInt16( aFmt.GetNumAdjust() )
                 << aFmt.GetAbsLSpace()
                 << aFmt.GetFirstLineOffset()
                 << aFmt.GetCharTextDistance()
                 << aFmt.GetLSpace()
                 << sal_False;//aFmt.IsRelLSpace();
-        rStream.WriteByteString( aName, eEncoding );
+        rStream.WriteUniOrByteString( aName, eEncoding );
         rStream << nFamily
                 << nCharSet
                 << nWidth
@@ -501,7 +501,7 @@ void SwNumRulesWithName::_SwNumFmtGlobal::Store( SvStream& rStream )
                 << nPitch;
     }
     rStream << nCharPoolId;
-    rStream.WriteByteString( sCharFmtName, eEncoding );
+    rStream.WriteUniOrByteString( sCharFmtName, eEncoding );
     rStream << aItems.Count();
 
     for( sal_uInt16 n = aItems.Count(); n; )
diff --git a/tools/inc/tools/stream.hxx b/tools/inc/tools/stream.hxx
index e6e939b..4d31670 100644
--- a/tools/inc/tools/stream.hxx
+++ b/tools/inc/tools/stream.hxx
@@ -363,11 +363,6 @@ public:
     SvStream&       operator<<( const unsigned char* pBuf );
     SvStream&       operator<<( SvStream& rStream );
 
-    SvStream&       ReadByteString( UniString& rStr, rtl_TextEncoding eSrcCharSet );
-    SvStream&       ReadByteString( UniString& rStr ) { return ReadByteString( rStr, GetStreamCharSet() ); }
-    SvStream&       WriteByteString( const UniString& rStr, rtl_TextEncoding eDestCharSet );
-    SvStream&       WriteByteString( const UniString& rStr ) { return WriteByteString( rStr, GetStreamCharSet() ); }
-
     SvStream&       WriteNumber( sal_uInt32 nUInt32 );
     SvStream&       WriteNumber( sal_Int32 nInt32 );
 
@@ -412,6 +407,12 @@ public:
 
                 /// Read a line of Unicode
     sal_Bool        ReadUniStringLine( String& rStr );
+                /// Read a 32bit length prefixed sequence of utf-16 if eSrcCharSet==RTL_TEXTENCODING_UNICODE,
+                /// otherwise read a 16bit length prefixed sequence of bytes and convert from eSrcCharSet
+    SvStream&       ReadUniOrByteString( UniString& rStr, rtl_TextEncoding eSrcCharSet );
+                /// Write a 32bit length prefixed sequence of utf-16 if eSrcCharSet==RTL_TEXTENCODING_UNICODE,
+                /// otherwise convert to eSrcCharSet and write a 16bit length prefixed sequence of bytes
+    SvStream&       WriteUniOrByteString( const UniString& rStr, rtl_TextEncoding eDestCharSet );
                 /// Read a line of Unicode if eSrcCharSet==RTL_TEXTENCODING_UNICODE,
                 /// otherwise read a line of Bytecode and convert from eSrcCharSet
     sal_Bool        ReadUniOrByteStringLine( String& rStr, rtl_TextEncoding eSrcCharSet );
diff --git a/tools/source/inet/inetmsg.cxx b/tools/source/inet/inetmsg.cxx
index f626dcc..a49d382 100644
--- a/tools/source/inet/inetmsg.cxx
+++ b/tools/source/inet/inetmsg.cxx
@@ -137,7 +137,7 @@ sal_uIntPtr INetMessage::SetHeaderField (
 SvStream& INetMessage::operator<< (SvStream& rStrm) const
 {
     rStrm << static_cast<sal_uInt32>(m_nDocSize);
-    rStrm.WriteByteString (m_aDocName, RTL_TEXTENCODING_UTF8);
+    write_lenPrefixed_uInt8s_FromOUString(rStrm, m_aDocName, RTL_TEXTENCODING_UTF8);
 
     sal_uIntPtr i, n = m_aHeaderList.size();
     rStrm << static_cast<sal_uInt32>(n);
@@ -163,7 +163,7 @@ SvStream& INetMessage::operator>> (SvStream& rStrm)
     // Copy.
     rStrm >> nTemp;
     m_nDocSize = nTemp;
-    rStrm.ReadByteString (m_aDocName, RTL_TEXTENCODING_UTF8);
+    m_aDocName = read_lenPrefixed_uInt8s_ToOUString(rStrm, RTL_TEXTENCODING_UTF8);
 
     sal_uIntPtr i, n = 0;
     rStrm >> nTemp;
diff --git a/tools/source/stream/stream.cxx b/tools/source/stream/stream.cxx
index b701959..aab11a6 100644
--- a/tools/source/stream/stream.cxx
+++ b/tools/source/stream/stream.cxx
@@ -1489,7 +1489,7 @@ SvStream& SvStream::operator<< ( SvStream& rStream )
 
 // -----------------------------------------------------------------------
 
-SvStream& SvStream::ReadByteString( UniString& rStr, rtl_TextEncoding eSrcCharSet )
+SvStream& SvStream::ReadUniOrByteString( UniString& rStr, rtl_TextEncoding eSrcCharSet )
 {
     // read UTF-16 string directly from stream ?
     if (eSrcCharSet == RTL_TEXTENCODING_UNICODE)
@@ -1523,7 +1523,7 @@ SvStream& SvStream::ReadByteString( UniString& rStr, rtl_TextEncoding eSrcCharSe
 
 // -----------------------------------------------------------------------
 
-SvStream& SvStream::WriteByteString( const UniString& rStr, rtl_TextEncoding eDestCharSet )
+SvStream& SvStream::WriteUniOrByteString( const UniString& rStr, rtl_TextEncoding eDestCharSet )
 {
     // write UTF-16 string directly into stream ?
     if (eDestCharSet == RTL_TEXTENCODING_UNICODE)
diff --git a/vcl/source/gdi/font.cxx b/vcl/source/gdi/font.cxx
index 0170426..059b1fe 100644
--- a/vcl/source/gdi/font.cxx
+++ b/vcl/source/gdi/font.cxx
@@ -780,8 +780,8 @@ SvStream& operator>>( SvStream& rIStm, Impl_Font& rImpl_Font )
     sal_Bool            bTmp;
     sal_uInt8           nTmp8;
 
-    rIStm.ReadByteString( rImpl_Font.maFamilyName, rIStm.GetStreamCharSet() );
-    rIStm.ReadByteString( rImpl_Font.maStyleName, rIStm.GetStreamCharSet() );
+    rIStm.ReadUniOrByteString( rImpl_Font.maFamilyName, rIStm.GetStreamCharSet() );
+    rIStm.ReadUniOrByteString( rImpl_Font.maStyleName, rIStm.GetStreamCharSet() );
     rIStm >> rImpl_Font.maSize;
 
     rIStm >> nTmp16; rImpl_Font.meCharSet = (rtl_TextEncoding) nTmp16;
@@ -823,8 +823,8 @@ SvStream& operator>>( SvStream& rIStm, Impl_Font& rImpl_Font )
 SvStream& operator<<( SvStream& rOStm, const Impl_Font& rImpl_Font )
 {
     VersionCompat aCompat( rOStm, STREAM_WRITE, 3 );
-    rOStm.WriteByteString( rImpl_Font.maFamilyName, rOStm.GetStreamCharSet() );
-    rOStm.WriteByteString( rImpl_Font.maStyleName, rOStm.GetStreamCharSet() );
+    rOStm.WriteUniOrByteString( rImpl_Font.maFamilyName, rOStm.GetStreamCharSet() );
+    rOStm.WriteUniOrByteString( rImpl_Font.maStyleName, rOStm.GetStreamCharSet() );
     rOStm << rImpl_Font.maSize;
 
     rOStm << (sal_uInt16) GetStoreCharSet( rImpl_Font.meCharSet );
diff --git a/vcl/source/gdi/jobset.cxx b/vcl/source/gdi/jobset.cxx
index 796659c..8d3ef57 100644
--- a/vcl/source/gdi/jobset.cxx
+++ b/vcl/source/gdi/jobset.cxx
@@ -334,9 +334,8 @@ SvStream& operator>>( SvStream& rIStream, JobSetup& rJobSetup )
                     rIStream.Seek( nFirstPos + sizeof( ImplOldJobSetupData ) + 4 + sizeof( Impl364JobSetupData ) + pJobData->mnDriverDataLen );
                     while( rIStream.Tell() < nFirstPos + nLen )
                     {
-                        String aKey, aValue;
-                        rIStream.ReadByteString( aKey, RTL_TEXTENCODING_UTF8 );
-                        rIStream.ReadByteString( aValue, RTL_TEXTENCODING_UTF8 );
+                        String aKey = read_lenPrefixed_uInt8s_ToOUString(rIStream, RTL_TEXTENCODING_UTF8);
+                        String aValue = read_lenPrefixed_uInt8s_ToOUString(rIStream, RTL_TEXTENCODING_UTF8);
                         if( aKey.EqualsAscii( "COMPAT_DUPLEX_MODE" ) )
                         {
                             if( aValue.EqualsAscii( "DUPLEX_UNKNOWN" ) )
@@ -407,8 +406,8 @@ SvStream& operator<<( SvStream& rOStream, const JobSetup& rJobSetup )
             ::boost::unordered_map< ::rtl::OUString, ::rtl::OUString, ::rtl::OUStringHash >::const_iterator it;
             for( it = pJobData->maValueMap.begin(); it != pJobData->maValueMap.end(); ++it )
             {
-                rOStream.WriteByteString( it->first, RTL_TEXTENCODING_UTF8 );
-                rOStream.WriteByteString( it->second, RTL_TEXTENCODING_UTF8 );
+                write_lenPrefixed_uInt8s_FromOUString(rOStream, it->first, RTL_TEXTENCODING_UTF8);
+                write_lenPrefixed_uInt8s_FromOUString(rOStream, it->second, RTL_TEXTENCODING_UTF8);
             }
             write_lenPrefixed_uInt8s_FromOString(rOStream, "COMPAT_DUPLEX_MODE");
             switch( pJobData->meDuplexMode )
diff --git a/vcl/source/gdi/metaact.cxx b/vcl/source/gdi/metaact.cxx
index 9961705..2fd96e8 100644
--- a/vcl/source/gdi/metaact.cxx
+++ b/vcl/source/gdi/metaact.cxx
@@ -1259,7 +1259,7 @@ void MetaTextAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
 {
     WRITE_BASE_COMPAT( rOStm, 2, pData );
     rOStm   << maPt;
-    rOStm.WriteByteString( maStr, pData->meActualCharSet );
+    rOStm.WriteUniOrByteString( maStr, pData->meActualCharSet );
     rOStm   << mnIndex;
     rOStm   << mnLen;
 
@@ -1278,7 +1278,7 @@ void MetaTextAction::Read( SvStream& rIStm, ImplMetaReadData* pData )
 {
     COMPAT( rIStm );
     rIStm   >> maPt;
-    rIStm.ReadByteString( maStr, pData->meActualCharSet );
+    rIStm.ReadUniOrByteString( maStr, pData->meActualCharSet );
     rIStm   >> mnIndex;
     rIStm   >> mnLen;
 
@@ -1408,7 +1408,7 @@ void MetaTextArrayAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
 
     WRITE_BASE_COMPAT( rOStm, 2, pData );
     rOStm   << maStartPt;
-    rOStm.WriteByteString( maStr, pData->meActualCharSet );
+    rOStm.WriteUniOrByteString( maStr, pData->meActualCharSet );
     rOStm   << mnIndex;
     rOStm   << mnLen;
     rOStm   << nAryLen;
@@ -1435,7 +1435,7 @@ void MetaTextArrayAction::Read( SvStream& rIStm, ImplMetaReadData* pData )
 
     COMPAT( rIStm );
     rIStm   >> maStartPt;
-    rIStm.ReadByteString( maStr, pData->meActualCharSet );
+    rIStm.ReadUniOrByteString( maStr, pData->meActualCharSet );
     rIStm   >> mnIndex;
     rIStm   >> mnLen;
     rIStm   >> nAryLen;
@@ -1555,7 +1555,7 @@ void MetaStretchTextAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
 {
     WRITE_BASE_COMPAT( rOStm, 2, pData );
     rOStm   << maPt;
-    rOStm.WriteByteString( maStr, pData->meActualCharSet );
+    rOStm.WriteUniOrByteString( maStr, pData->meActualCharSet );
     rOStm   << mnWidth;
     rOStm   << mnIndex;
     rOStm   << mnLen;
@@ -1575,7 +1575,7 @@ void MetaStretchTextAction::Read( SvStream& rIStm, ImplMetaReadData* pData )
 {
     COMPAT( rIStm );
     rIStm   >> maPt;
-    rIStm.ReadByteString( maStr, pData->meActualCharSet );
+    rIStm.ReadUniOrByteString( maStr, pData->meActualCharSet );
     rIStm   >> mnWidth;
     rIStm   >> mnIndex;
     rIStm   >> mnLen;
@@ -1650,7 +1650,7 @@ void MetaTextRectAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
 {
     WRITE_BASE_COMPAT( rOStm, 2, pData );
     rOStm   << maRect;
-    rOStm.WriteByteString( maStr, pData->meActualCharSet );
+    rOStm.WriteUniOrByteString( maStr, pData->meActualCharSet );
     rOStm   << mnStyle;
 
     sal_uInt16 i, nLen = maStr.Len();                           // version 2
@@ -1668,7 +1668,7 @@ void MetaTextRectAction::Read( SvStream& rIStm, ImplMetaReadData* pData )
 {
     COMPAT( rIStm );
     rIStm   >> maRect;
-    rIStm.ReadByteString( maStr, pData->meActualCharSet );
+    rIStm.ReadUniOrByteString( maStr, pData->meActualCharSet );
     rIStm   >> mnStyle;
 
     if ( aCompat.GetVersion() >= 2 )                            // Version 2
diff --git a/vcl/source/gdi/print.cxx b/vcl/source/gdi/print.cxx
index 6a4caba..9cede25 100644
--- a/vcl/source/gdi/print.cxx
+++ b/vcl/source/gdi/print.cxx
@@ -280,10 +280,10 @@ SvStream& operator<<( SvStream& rOStream, const QueueInfo& rInfo )
 {
     VersionCompat aCompat( rOStream, STREAM_WRITE, 1 );
 
-    rOStream.WriteByteString( rInfo.maPrinterName, RTL_TEXTENCODING_UTF8 );
-    rOStream.WriteByteString( rInfo.maDriver, RTL_TEXTENCODING_UTF8 );
-    rOStream.WriteByteString( rInfo.maLocation, RTL_TEXTENCODING_UTF8 );
-    rOStream.WriteByteString( rInfo.maComment, RTL_TEXTENCODING_UTF8 );
+    write_lenPrefixed_uInt8s_FromOUString(rOStream, rInfo.maPrinterName, RTL_TEXTENCODING_UTF8);
+    write_lenPrefixed_uInt8s_FromOUString(rOStream, rInfo.maDriver, RTL_TEXTENCODING_UTF8);
+    write_lenPrefixed_uInt8s_FromOUString(rOStream, rInfo.maLocation, RTL_TEXTENCODING_UTF8);
+    write_lenPrefixed_uInt8s_FromOUString(rOStream, rInfo.maComment, RTL_TEXTENCODING_UTF8);
     rOStream << rInfo.mnStatus;
     rOStream << rInfo.mnJobs;
 
@@ -296,15 +296,10 @@ SvStream& operator>>( SvStream& rIStream, QueueInfo& rInfo )
 {
     VersionCompat aCompat( rIStream, STREAM_READ );
 
-    String aTmp;
-    rIStream.ReadByteString( aTmp, RTL_TEXTENCODING_UTF8 );
-    rInfo.maPrinterName = aTmp;
-    rIStream.ReadByteString( aTmp, RTL_TEXTENCODING_UTF8 );
-    rInfo.maDriver = aTmp;
-    rIStream.ReadByteString( aTmp, RTL_TEXTENCODING_UTF8 );
-    rInfo.maLocation = aTmp;
-    rIStream.ReadByteString( aTmp, RTL_TEXTENCODING_UTF8 );
-    rInfo.maComment = aTmp;
+    rInfo.maPrinterName = read_lenPrefixed_uInt8s_ToOUString(rIStream, RTL_TEXTENCODING_UTF8);
+    rInfo.maDriver = read_lenPrefixed_uInt8s_ToOUString(rIStream, RTL_TEXTENCODING_UTF8);
+    rInfo.maLocation = read_lenPrefixed_uInt8s_ToOUString(rIStream, RTL_TEXTENCODING_UTF8);
+    rInfo.maComment = read_lenPrefixed_uInt8s_ToOUString(rIStream, RTL_TEXTENCODING_UTF8);
     rIStream >> rInfo.mnStatus;
     rIStream >> rInfo.mnJobs;
 
diff --git a/vcl/source/gdi/rendergraphic.cxx b/vcl/source/gdi/rendergraphic.cxx
index 2077eed..16b08c4 100644
--- a/vcl/source/gdi/rendergraphic.cxx
+++ b/vcl/source/gdi/rendergraphic.cxx
@@ -192,10 +192,9 @@ void RenderGraphic::ImplGetDefaults() const
 ::SvStream& operator>>( ::SvStream& rIStm, RenderGraphic& rRenderGraphic )
 {
     ::VersionCompat aVCompat( rIStm, STREAM_READ );
-    String          aGraphicDataMimeType;
     sal_uInt32      nGraphicDataLength = 0;
 
-    rIStm.ReadByteString( aGraphicDataMimeType, RTL_TEXTENCODING_ASCII_US );
+    rtl::OUString aGraphicDataMimeType = read_lenPrefixed_uInt8s_ToOUString(rIStm, RTL_TEXTENCODING_ASCII_US);
     rIStm >> nGraphicDataLength;
 
     rRenderGraphic = RenderGraphic( aGraphicDataMimeType, nGraphicDataLength );
@@ -215,7 +214,8 @@ void RenderGraphic::ImplGetDefaults() const
     ::VersionCompat     aVCompat( rOStm, STREAM_WRITE, 1 );
     const sal_uInt32    nGraphicDataLength = rRenderGraphic.GetGraphicDataLength();
 
-    rOStm.WriteByteString( rRenderGraphic.GetGraphicDataMimeType(), RTL_TEXTENCODING_ASCII_US );
+    write_lenPrefixed_uInt8s_FromOUString(rOStm, rRenderGraphic.GetGraphicDataMimeType(),
+        RTL_TEXTENCODING_ASCII_US);
     rOStm << nGraphicDataLength;
 
     if( nGraphicDataLength )
diff --git a/vcl/win/source/gdi/salgdi3.cxx b/vcl/win/source/gdi/salgdi3.cxx
index cf7941e..44ca911 100644
--- a/vcl/win/source/gdi/salgdi3.cxx
+++ b/vcl/win/source/gdi/salgdi3.cxx
@@ -160,10 +160,10 @@ ImplFontAttrCache::ImplFontAttrCache( const String& rFileNameURL, const String&
     ImplDevFontAttributes aDFA;
     for(;;)
     {
-        aCacheFile.ReadByteString( aFontFileURL, RTL_TEXTENCODING_UTF8 );
+        aFontFileURL = read_lenPrefixed_uInt8s_ToOUString(aCacheFile, RTL_TEXTENCODING_UTF8);
         if( !aFontFileURL.Len() )
             break;
-        aCacheFile.ReadByteString( aDFA.maName, RTL_TEXTENCODING_UTF8 );
+        aDFA.maName = read_lenPrefixed_uInt8s_ToOUString(aCacheFile, RTL_TEXTENCODING_UTF8);
 
         short n;
         aCacheFile >> n; aDFA.meWeight     = static_cast<FontWeight>(n);
@@ -195,8 +195,8 @@ ImplFontAttrCache::~ImplFontAttrCache()
             {
                 const String rFontFileURL( (*aIter).first );
                 const ImplDevFontAttributes& rDFA( (*aIter).second );
-                aCacheFile.WriteByteString( rFontFileURL, RTL_TEXTENCODING_UTF8 );
-                aCacheFile.WriteByteString( rDFA.maName, RTL_TEXTENCODING_UTF8 );
+                write_lenPrefixed_uInt8s_FromOUString(aCacheFile, rFontFileURL, RTL_TEXTENCODING_UTF8);
+                write_lenPrefixed_uInt8s_FromOUString(aCacheFile, rDFA.maName, RTL_TEXTENCODING_UTF8);
 
                 aCacheFile << static_cast<short>(rDFA.meWeight);
                 aCacheFile << static_cast<short>(rDFA.meItalic);
@@ -205,13 +205,12 @@ ImplFontAttrCache::~ImplFontAttrCache()
                 aCacheFile << static_cast<short>(rDFA.meFamily);
                 aCacheFile << static_cast<short>(rDFA.mbSymbolFlag != false);
 
-                aCacheFile.WriteByteStringLine( rDFA.maStyleName, RTL_TEXTENCODING_UTF8 );
+                write_lenPrefixed_uInt8s_FromOUString(aCacheFile, rDFA.maStyleName, RTL_TEXTENCODING_UTF8);
 
                 ++aIter;
             }
             // EOF Marker
-            String aEmptyStr;
-            aCacheFile.WriteByteString( aEmptyStr, RTL_TEXTENCODING_UTF8 );
+            write_lenPrefixed_uInt8s_FromOString(aCacheFile, rtl::OString(), RTL_TEXTENCODING_UTF8);
         }
     }
 }
commit 92f396733ebc518bcb7a9eae2dd3169d333b82b9
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Sat Dec 17 15:53:11 2011 +0000

    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

diff --git a/basic/source/runtime/iosys.cxx b/basic/source/runtime/iosys.cxx
index a2fe3bd..1a63f94 100644
--- a/basic/source/runtime/iosys.cxx
+++ b/basic/source/runtime/iosys.cxx
@@ -656,7 +656,7 @@ SbError SbiStream::Read( ByteString& rBuf, sal_uInt16 n, bool bForceReadingPerBy
             n = nLen;
         if( !n )
             return nError = SbERR_BAD_RECORD_LENGTH;
-        rtl::OStringBuffer aBuffer(read_uInt8s_AsOString(*pStrm, n));
+        rtl::OStringBuffer aBuffer(read_uInt8s_ToOString(*pStrm, n));
         //Pad it out with ' ' to the requested length on short read
         sal_Int32 nRequested = sal::static_int_cast<sal_Int32>(n);
         comphelper::string::padToLength(aBuffer, nRequested, ' ');
diff --git a/connectivity/source/drivers/dbase/DTable.cxx b/connectivity/source/drivers/dbase/DTable.cxx
index fc5afcd..cfabfbf 100644
--- a/connectivity/source/drivers/dbase/DTable.cxx
+++ b/connectivity/source/drivers/dbase/DTable.cxx
@@ -2739,7 +2739,7 @@ sal_Bool ODbaseTable::ReadMemo(sal_uIntPtr nBlockNo, ORowSetValue& aVariable)
             {
                 if ( bIsText )
                 {
-                    rtl::OStringBuffer aBuffer(read_uInt8s_AsOString(*m_pMemoStream, nLength));
+                    rtl::OStringBuffer aBuffer(read_uInt8s_ToOString(*m_pMemoStream, nLength));
                     //pad it out with ' ' to expected length on short read
                     sal_Int32 nRequested = sal::static_int_cast<sal_Int32>(nLength);
                     comphelper::string::padToLength(aBuffer, nRequested, ' ');
diff --git a/connectivity/source/drivers/dbase/dindexnode.cxx b/connectivity/source/drivers/dbase/dindexnode.cxx
index 1117457..046b457 100644
--- a/connectivity/source/drivers/dbase/dindexnode.cxx
+++ b/connectivity/source/drivers/dbase/dindexnode.cxx
@@ -673,7 +673,7 @@ void ONDXNode::Read(SvStream &rStream, ODbaseIndex& rIndex)
     else
     {
         sal_uInt16 nLen = rIndex.getHeader().db_keylen;
-        rtl::OString aBuf = read_uInt8s_AsOString(rStream, nLen);
+        rtl::OString aBuf = read_uInt8s_ToOString(rStream, nLen);
         //get length minus trailing whitespace
         sal_Int32 nContentLen = aBuf.getLength();
         while (nContentLen && aBuf[nContentLen-1] == ' ')
diff --git a/editeng/source/editeng/editobj.cxx b/editeng/source/editeng/editobj.cxx
index 678f31a..0fd144b 100644
--- a/editeng/source/editeng/editobj.cxx
+++ b/editeng/source/editeng/editobj.cxx
@@ -1131,10 +1131,10 @@ void BinTextObject::StoreData( SvStream& rOStream ) const
 
         // Convert CH_FEATURE to CH_FEATURE_OLD
         aText.SearchAndReplaceAll( cFeatureConverted, CH_FEATURE_OLD );
-        rOStream.WriteByteString( aText );
+        write_lenPrefixed_uInt8s_FromOString(rOStream, aText);
 
         // StyleName and Family...
-        rOStream.WriteByteString( rtl::OUStringToOString(pC->GetStyle(), eEncoding) );
+        write_lenPrefixed_uInt8s_FromOUString(rOStream, pC->GetStyle(), eEncoding);
         rOStream << (sal_uInt16)pC->GetFamily();
 
         // Paragraph attributes ...
@@ -1226,9 +1226,8 @@ void BinTextObject::CreateData( SvStream& rIStream )
         ContentInfo* pC = CreateAndInsertContent();
 
         // The Text...
-        ByteString aByteString;
-        rIStream.ReadByteString( aByteString );
-        pC->GetText() = String( aByteString, eSrcEncoding );
+        ByteString aByteString = read_lenPrefixed_uInt8s_ToOString(rIStream);
+        pC->GetText() = rtl::OStringToOUString(aByteString, eSrcEncoding);
 
         // StyleName and Family...
         rIStream.ReadByteString( pC->GetStyle(), eSrcEncoding );
diff --git a/filter/source/msfilter/mstoolbar.cxx b/filter/source/msfilter/mstoolbar.cxx
index 2776e72..ed1c986 100644
--- a/filter/source/msfilter/mstoolbar.cxx
+++ b/filter/source/msfilter/mstoolbar.cxx
@@ -412,7 +412,7 @@ WString::Read( SvStream &rS )
     nOffSet = rS.Tell();
     sal_uInt8 nChars = 0;
     rS >> nChars;
-    sString = read_LEuInt16s_AsOUString(rS, nChars);
+    sString = read_LEuInt16s_ToOUString(rS, nChars);
     return true;
 }
 
diff --git a/idl/source/objects/bastype.cxx b/idl/source/objects/bastype.cxx
index 15c56c0..afeb004 100644
--- a/idl/source/objects/bastype.cxx
+++ b/idl/source/objects/bastype.cxx
@@ -228,13 +228,13 @@ sal_Bool SvIdentifier::WriteSvIdl( SvStringHashEntry * pName,
 
 SvStream& operator << (SvStream & rStm, const SvIdentifier & r )
 {
-    rStm.WriteByteString( r );
+    write_lenPrefixed_uInt8s_FromOString(rStm, r);
     return rStm;
 }
 
 SvStream& operator >> (SvStream & rStm, SvIdentifier & r )
 {
-    rStm.ReadByteString( r );
+    r = read_lenPrefixed_uInt8s_ToOString(rStm);
     return rStm;
 }
 
@@ -343,13 +343,13 @@ sal_Bool SvString::WriteSvIdl( SvStringHashEntry * pName, SvStream & rOutStm,
 
 SvStream& operator << (SvStream & rStm, const SvString & r )
 {
-    rStm.WriteByteString( r );
+    write_lenPrefixed_uInt8s_FromOString(rStm, r);
     return rStm;
 }
 
 SvStream& operator >> (SvStream & rStm, SvString & r )
 {
-    rStm.ReadByteString( r );
+    r = read_lenPrefixed_uInt8s_ToOString(rStm);
     return rStm;
 }
 
diff --git a/idl/source/objects/module.cxx b/idl/source/objects/module.cxx
index c2be3e2..4fd5c78 100644
--- a/idl/source/objects/module.cxx
+++ b/idl/source/objects/module.cxx
@@ -66,9 +66,9 @@ void SvMetaModule::Load( SvPersistStream & rStm )
     rStm >> aAttrList;
     // browser
     rStm.ReadByteString( aIdlFileName );
-    rStm.ReadByteString( aHelpFileName );
-    rStm.ReadByteString( aSlotIdFile );
-    rStm.ReadByteString( aModulePrefix );
+    aHelpFileName = read_lenPrefixed_uInt8s_ToOString(rStm);
+    aSlotIdFile = read_lenPrefixed_uInt8s_ToOString(rStm);
+    aModulePrefix = read_lenPrefixed_uInt8s_ToOString(rStm);
 
     // read compiler data
     sal_uInt16 nCmpLen;
@@ -91,9 +91,9 @@ void SvMetaModule::Save( SvPersistStream & rStm )
     rStm << aAttrList;
     // browser
     rStm.WriteByteString( aIdlFileName );
-    rStm.WriteByteString( aHelpFileName );
-    rStm.WriteByteString( aSlotIdFile );
-    rStm.WriteByteString( aModulePrefix );
+    write_lenPrefixed_uInt8s_FromOString(rStm, aHelpFileName);
+    write_lenPrefixed_uInt8s_FromOString(rStm, aSlotIdFile);
+    write_lenPrefixed_uInt8s_FromOString(rStm, aModulePrefix);
 
     // write compiler data
     sal_uInt16 nCmpLen = 0;
diff --git a/idl/source/objects/object.cxx b/idl/source/objects/object.cxx
index 0b3e1cf..798acbc 100644
--- a/idl/source/objects/object.cxx
+++ b/idl/source/objects/object.cxx
@@ -55,7 +55,7 @@ void SvClassElement::Load( SvPersistStream & rStm )
         return;
     }
     if( nMask & 0x01 ) rStm >> aAutomation;
-    if( nMask & 0x02 ) rStm.ReadByteString( aPrefix );
+    if( nMask & 0x02 ) aPrefix = read_lenPrefixed_uInt8s_ToOString(rStm);
     if( nMask & 0x04 )
     {
         SvMetaClass * p;
@@ -75,7 +75,7 @@ void SvClassElement::Save( SvPersistStream & rStm )
     // write data
     rStm << nMask;
     if( nMask & 0x01 ) rStm << aAutomation;
-    if( nMask & 0x02 ) rStm.WriteByteString( aPrefix );
+    if( nMask & 0x02 ) write_lenPrefixed_uInt8s_FromOString(rStm, aPrefix);
     if( nMask & 0x04 ) rStm << xClass;
 }
 
diff --git a/idl/source/objects/types.cxx b/idl/source/objects/types.cxx
index 06db9ed..f2488aa 100644
--- a/idl/source/objects/types.cxx
+++ b/idl/source/objects/types.cxx
@@ -1780,7 +1780,7 @@ void SvMetaEnumValue::Load( SvPersistStream & rStm )
         OSL_FAIL( "wrong format" );
         return;
     }
-    if( nMask & 0x01 ) rStm.ReadByteString( aEnumValue );
+    if( nMask & 0x01 ) aEnumValue = read_lenPrefixed_uInt8s_ToOString(rStm);
 }
 
 void SvMetaEnumValue::Save( SvPersistStream & rStm )
@@ -1793,7 +1793,7 @@ void SvMetaEnumValue::Save( SvPersistStream & rStm )
 
     // write data
     rStm << nMask;
-    if( nMask & 0x01 ) rStm.WriteByteString( aEnumValue );
+    if( nMask & 0x01 ) write_lenPrefixed_uInt8s_FromOString(rStm, aEnumValue);
 }
 
 sal_Bool SvMetaEnumValue::ReadSvIdl( SvIdlDataBase & rBase,
@@ -1837,7 +1837,7 @@ void SvMetaTypeEnum::Load( SvPersistStream & rStm )
         return;
     }
     if( nMask & 0x01 ) rStm >> aEnumValueList;
-    if( nMask & 0x02 ) rStm.ReadByteString( aPrefix );
+    if( nMask & 0x02 ) aPrefix = read_lenPrefixed_uInt8s_ToOString(rStm);
 }
 
 void SvMetaTypeEnum::Save( SvPersistStream & rStm )
@@ -1852,7 +1852,7 @@ void SvMetaTypeEnum::Save( SvPersistStream & rStm )
     // write data
     rStm << nMask;
     if( nMask & 0x01 ) rStm << aEnumValueList;
-    if( nMask & 0x02 ) rStm.WriteByteString( aPrefix );
+    if( nMask & 0x02 ) write_lenPrefixed_uInt8s_FromOString(rStm, aPrefix);
 }
 
 void SvMetaTypeEnum::ReadContextSvIdl( SvIdlDataBase & rBase,
diff --git a/sc/source/filter/ftools/ftools.cxx b/sc/source/filter/ftools/ftools.cxx
index 21d3e12..bbfbe41 100644
--- a/sc/source/filter/ftools/ftools.cxx
+++ b/sc/source/filter/ftools/ftools.cxx
@@ -276,9 +276,9 @@ ScStyleSheet& ScfTools::MakePageStyleSheet( ScStyleSheetPool& rPool, const Strin
 
 // *** byte string import operations *** --------------------------------------
 
-rtl::OString ScfTools::read_zeroTerminated_uInt8s_AsOString(SvStream& rStrm, sal_Int32& rnBytesLeft)
+rtl::OString ScfTools::read_zeroTerminated_uInt8s_ToOString(SvStream& rStrm, sal_Int32& rnBytesLeft)
 {
-    rtl::OString aRet(::read_zeroTerminated_uInt8s_AsOString(rStrm));
+    rtl::OString aRet(::read_zeroTerminated_uInt8s_ToOString(rStrm));
     rnBytesLeft -= aRet.getLength(); //we read this number of bytes anyway
     if (rStrm.good()) //if the stream is happy we read the null terminator as well
         --rnBytesLeft;
@@ -287,7 +287,7 @@ rtl::OString ScfTools::read_zeroTerminated_uInt8s_AsOString(SvStream& rStrm, sal
 
 void ScfTools::AppendCString( SvStream& rStrm, String& rString, rtl_TextEncoding eTextEnc )
 {
-    rString += ::read_zeroTerminated_uInt8s_AsOUString(rStrm, eTextEnc);
+    rString += ::read_zeroTerminated_uInt8s_ToOUString(rStrm, eTextEnc);
 }
 
 // *** HTML table names <-> named range names *** -----------------------------
diff --git a/sc/source/filter/inc/ftools.hxx b/sc/source/filter/inc/ftools.hxx
index e57d42c..4bfac09 100644
--- a/sc/source/filter/inc/ftools.hxx
+++ b/sc/source/filter/inc/ftools.hxx
@@ -237,11 +237,11 @@ public:
 // *** byte string import operations *** --------------------------------------
 
     /** Reads and returns a zero terminated byte string and decreases a stream counter. */
-    static rtl::OString read_zeroTerminated_uInt8s_AsOString(SvStream& rStrm, sal_Int32& rnBytesLeft);
+    static rtl::OString read_zeroTerminated_uInt8s_ToOString(SvStream& rStrm, sal_Int32& rnBytesLeft);
     /** Reads and returns a zero terminated byte string and decreases a stream counter. */
-    inline static rtl::OUString read_zeroTerminated_uInt8s_AsOUString(SvStream& rStrm, sal_Int32& rnBytesLeft, rtl_TextEncoding eTextEnc)
+    inline static rtl::OUString read_zeroTerminated_uInt8s_ToOUString(SvStream& rStrm, sal_Int32& rnBytesLeft, rtl_TextEncoding eTextEnc)
     {
-        return rtl::OStringToOUString(read_zeroTerminated_uInt8s_AsOString(rStrm, rnBytesLeft), eTextEnc);
+        return rtl::OStringToOUString(read_zeroTerminated_uInt8s_ToOString(rStrm, rnBytesLeft), eTextEnc);
     }
 
     /** Appends a zero terminated byte string. */
diff --git a/sc/source/filter/lotus/lotform.cxx b/sc/source/filter/lotus/lotform.cxx
index 5bd02b1..d649c44 100644
--- a/sc/source/filter/lotus/lotform.cxx
+++ b/sc/source/filter/lotus/lotform.cxx
@@ -542,7 +542,7 @@ ConvErr LotusToSc::Convert( const ScTokenArray*& rpErg, sal_Int32& rRest,
                 break;
             case FT_ConstString:
             {
-                String  aTmp(ScfTools::read_zeroTerminated_uInt8s_AsOUString(aIn, nBytesLeft, eSrcChar));
+                String  aTmp(ScfTools::read_zeroTerminated_uInt8s_ToOUString(aIn, nBytesLeft, eSrcChar));
                 aStack << aPool.Store( aTmp );
             }
                 break;
@@ -561,7 +561,7 @@ ConvErr LotusToSc::Convert( const ScTokenArray*& rpErg, sal_Int32& rRest,
                 break;
             case FT_Nrref:
             {
-                String  aTmp(ScfTools::read_zeroTerminated_uInt8s_AsOUString(aIn, nBytesLeft, eSrcChar));
+                String  aTmp(ScfTools::read_zeroTerminated_uInt8s_ToOUString(aIn, nBytesLeft, eSrcChar));
                 if( rRangeNameBufferWK3.FindRel( aTmp, nRngIndex ) )
                     aStack << aPool.Store( nRngIndex );
                 else
@@ -574,7 +574,7 @@ ConvErr LotusToSc::Convert( const ScTokenArray*& rpErg, sal_Int32& rRest,
                 break;
             case FT_Absnref:
             {
-                String aTmp(ScfTools::read_zeroTerminated_uInt8s_AsOUString(aIn, nBytesLeft, eSrcChar));
+                String aTmp(ScfTools::read_zeroTerminated_uInt8s_ToOUString(aIn, nBytesLeft, eSrcChar));
                 if( rRangeNameBufferWK3.FindAbs( aTmp, nRngIndex ) )
                     aStack << aPool.Store( nRngIndex );
                 else
diff --git a/sc/source/filter/qpro/qproform.cxx b/sc/source/filter/qpro/qproform.cxx
index 30b7d60..6c8e8b7 100644
--- a/sc/source/filter/qpro/qproform.cxx
+++ b/sc/source/filter/qpro/qproform.cxx
@@ -249,7 +249,7 @@ ConvErr QProToSc::Convert( const ScTokenArray*& pArray, sal_uInt16 /*nLen*/, con
             }
             if( nFmla[ i ] == 0x06 )
             {
-                String aTmp(::read_zeroTerminated_uInt8s_AsOUString(maIn, maIn.GetStreamCharSet()));
+                String aTmp(::read_zeroTerminated_uInt8s_ToOUString(maIn, maIn.GetStreamCharSet()));
                 sStringArray[ nStringCount ] = aTmp;
                 nStringCount++;
         SAFEDEC_OR_RET(nRef, aTmp.Len() + 1, ConvErrCount);
diff --git a/sc/source/ui/unoobj/scdetect.cxx b/sc/source/ui/unoobj/scdetect.cxx
index 9d33f09..fd3b0d2 100644
--- a/sc/source/ui/unoobj/scdetect.cxx
+++ b/sc/source/ui/unoobj/scdetect.cxx
@@ -734,7 +734,7 @@ static sal_Bool lcl_MayBeDBase( SvStream& rStream )
                             // get file header
                             rStr.Seek( 0 );
                             const sal_Size nTrySize = 80;
-                            ByteString aHeader = read_uInt8s_AsOString(rStr, nTrySize);
+                            ByteString aHeader = read_uInt8s_ToOString(rStr, nTrySize);
 
                             if ( HTMLParser::IsHTMLFormat( aHeader.GetBuffer() ) )
                             {
diff --git a/sd/source/filter/eppt/epptso.cxx b/sd/source/filter/eppt/epptso.cxx
index 7e8064f..c320f0c 100644
--- a/sd/source/filter/eppt/epptso.cxx
+++ b/sd/source/filter/eppt/epptso.cxx
@@ -2605,7 +2605,7 @@ void PPTWriter::ImplWritePage( const PHLayout& rLayout, EscherSolverContainer& a
                                 *xCompObj   >> nStringLen;
                                 if ( ( nStringLen > 1 ) && ( ( xCompObj->Tell() + nStringLen ) < nStreamLen ) )
                                 {   // i think that the OleIdentifier will follow
-                                    rtl::OString aTemp = read_uInt8s_AsOString(*xCompObj, nStringLen - 1);
+                                    rtl::OString aTemp = read_uInt8s_ToOString(*xCompObj, nStringLen - 1);
                                     aOleIdentifier = rtl::OStringToOUString(aTemp, RTL_TEXTENCODING_MS_1252);
                                 }
                             }
diff --git a/sfx2/source/bastyp/sfxhtml.cxx b/sfx2/source/bastyp/sfxhtml.cxx
index 18214c5..acf6918 100644
--- a/sfx2/source/bastyp/sfxhtml.cxx
+++ b/sfx2/source/bastyp/sfxhtml.cxx
@@ -274,7 +274,7 @@ sal_Bool SfxHTMLParser::FinishFileDownload( String& rStr )
                         : STRING_MAXLEN;
 
         aStream.Seek( 0 );
-        rtl::OString sBuffer = read_uInt8s_AsOString(aStream, nLen);
+        rtl::OString sBuffer = read_uInt8s_ToOString(aStream, nLen);
         rStr = S2U(sBuffer);
     }
 
diff --git a/sot/source/sdstor/ucbstorage.cxx b/sot/source/sdstor/ucbstorage.cxx
index b6fb581..f1cf5c0 100644
--- a/sot/source/sdstor/ucbstorage.cxx
+++ b/sot/source/sdstor/ucbstorage.cxx
@@ -3303,8 +3303,7 @@ String UCBStorage::GetLinkedFile( SvStream &rStream )
     rStream >> nBytes;
     if( nBytes == 0x04034b50 )
     {
-        ByteString aTmp;
-        rStream.ReadByteString( aTmp );
+        ByteString aTmp = read_lenPrefixed_uInt8s_ToOString(rStream);
         if ( aTmp.CompareTo( "ContentURL=", 11 ) == COMPARE_EQUAL )
         {
             aTmp.Erase( 0, 11 );
diff --git a/svl/source/items/cntwall.cxx b/svl/source/items/cntwall.cxx
index f81bd48..31ef07e 100644
--- a/svl/source/items/cntwall.cxx
+++ b/svl/source/items/cntwall.cxx
@@ -80,8 +80,7 @@ CntWallpaperItem::CntWallpaperItem( sal_uInt16 which, SvStream& rStream, sal_uIn
         readUnicodeString(rStream, _aURL, false);
 
         // "Read" SfxWallpaperItem's string member _aFilter.
-        ByteString aDummy;
-        rStream.ReadByteString(aDummy);
+        read_lenPrefixed_uInt8s_ToOString(rStream);
     }
 }
 
diff --git a/svl/source/numbers/zformat.cxx b/svl/source/numbers/zformat.cxx
index a85491e..424aaa0 100644
--- a/svl/source/numbers/zformat.cxx
+++ b/svl/source/numbers/zformat.cxx
@@ -1768,8 +1768,7 @@ void SvNumberformat::ConvertLanguage( SvNumberFormatter& rConverter,
 void SvNumberformat::LoadString( SvStream& rStream, String& rStr )
 {
     CharSet eStream = rStream.GetStreamCharSet();
-    ByteString aStr;
-    rStream.ReadByteString( aStr );
+    ByteString aStr = read_lenPrefixed_uInt8s_ToOString(rStream);
     sal_Char cStream = NfCurrencyEntry::GetEuroSymbol( eStream );
     if ( aStr.Search( cStream ) == STRING_NOTFOUND )
     {   // simple conversion to unicode
diff --git a/svtools/source/filter/igif/gifread.cxx b/svtools/source/filter/igif/gifread.cxx
index 81dee55..607b6a8 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 f259ccb..db3e872 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 016250c..bb720f6 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;

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list