dbaccess/source/ui/tabledesign/TableRow.cxx |    8 ++++----
 editeng/source/items/legacyitem.cxx         |    4 ++--
 include/tools/stream.hxx                    |    4 ++++
 sc/source/core/tool/ddelink.cxx             |    7 +++----
 svl/source/inc/stringio.hxx                 |    9 ---------
 svl/source/items/macitem.cxx                |    4 ++--
 svl/source/items/stringio.cxx               |    4 +---
 svtools/source/misc/templatefoldercache.cxx |    2 +-
 tools/source/stream/stream.cxx              |    5 +++++
 vcl/source/font/font.cxx                    |    4 ++--
 vcl/source/gdi/TypeSerializer.cxx           |    2 +-
 vcl/source/treelist/transfer.cxx            |    4 ++--
 12 files changed, 27 insertions(+), 30 deletions(-)

New commits:
commit 98174967dba88bcce18d9c8866b1330b8185f871
Author:     Noel Grandin <[email protected]>
AuthorDate: Thu Feb 26 14:48:20 2026 +0200
Commit:     Noel Grandin <[email protected]>
CommitDate: Fri Feb 27 07:49:07 2026 +0100

    SvStream::WriteUniOrByteString should not need to specify encoding
    
    Instead, rely on the stream being set into the correct encoding
    during stream initialisation.
    
    Change-Id: If141ba09afe1b04f5d836024975f00e8b20d1447
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200462
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <[email protected]>

diff --git a/dbaccess/source/ui/tabledesign/TableRow.cxx 
b/dbaccess/source/ui/tabledesign/TableRow.cxx
index 20c868067a45..dc014bd2fabd 100644
--- a/dbaccess/source/ui/tabledesign/TableRow.cxx
+++ b/dbaccess/source/ui/tabledesign/TableRow.cxx
@@ -92,9 +92,9 @@ namespace dbaui
         if(pFieldDesc)
         {
             _rStr.WriteInt32( 1 );
-            _rStr.WriteUniOrByteString(pFieldDesc->GetName(), 
_rStr.GetStreamEncoding());
-            _rStr.WriteUniOrByteString(pFieldDesc->GetDescription(), 
_rStr.GetStreamEncoding());
-            _rStr.WriteUniOrByteString(pFieldDesc->GetHelpText(), 
_rStr.GetStreamEncoding());
+            _rStr.WriteUniOrByteString(pFieldDesc->GetName());
+            _rStr.WriteUniOrByteString(pFieldDesc->GetDescription());
+            _rStr.WriteUniOrByteString(pFieldDesc->GetHelpText());
             double nValue = 0.0;
             Any aValue = pFieldDesc->GetControlDefault();
             if ( aValue >>= nValue )
@@ -105,7 +105,7 @@ namespace dbaui
             else
             {
                 _rStr.WriteInt32( 2 );
-                _rStr.WriteUniOrByteString(::comphelper::getString(aValue), 
_rStr.GetStreamEncoding());
+                _rStr.WriteUniOrByteString(::comphelper::getString(aValue));
             }
 
             _rStr.WriteInt32( pFieldDesc->GetType() );
diff --git a/editeng/source/items/legacyitem.cxx 
b/editeng/source/items/legacyitem.cxx
index 23fe71101e57..be298d61c500 100644
--- a/editeng/source/items/legacyitem.cxx
+++ b/editeng/source/items/legacyitem.cxx
@@ -189,12 +189,12 @@ namespace legacy
                 // TODO/MBA: how to get a BaseURL?!
                 OUString aRel = INetURLObject::GetRelURL( u"", 
rItem.GetGraphicLink() );
                 // UNICODE: rStrm << aRel;
-                rStrm.WriteUniOrByteString(aRel, rStrm.GetStreamEncoding());
+                rStrm.WriteUniOrByteString(aRel);
             }
             if ( !rItem.GetGraphicFilter().isEmpty() )
             {
                 // UNICODE: rStrm << rItem.GetGraphicFilter();
-                rStrm.WriteUniOrByteString(rItem.GetGraphicFilter(), 
rStrm.GetStreamEncoding());
+                rStrm.WriteUniOrByteString(rItem.GetGraphicFilter());
             }
             rStrm.WriteSChar( rItem.GetGraphicPos() );
             return rStrm;
diff --git a/include/tools/stream.hxx b/include/tools/stream.hxx
index dce4457d7303..afccefb79c23 100644
--- a/include/tools/stream.hxx
+++ b/include/tools/stream.hxx
@@ -353,6 +353,10 @@ public:
         eDestEncoding==RTL_TEXTENCODING_UNICODE, otherwise convert to 
eDestEncoding
         and write a 16bit length prefixed sequence of bytes */
     SvStream& WriteUniOrByteString(std::u16string_view rStr, rtl_TextEncoding 
eDestEncoding);
+    /** Write a 32bit length prefixed sequence of utf-16 if
+        GetStreamEncoding()==RTL_TEXTENCODING_UNICODE, otherwise convert to 
GetStreamEncoding()
+        and write a 16bit length prefixed sequence of bytes */
+    SvStream& WriteUniOrByteString(std::u16string_view rStr);
 
     /** Read a line of Unicode if 
GetStreamEncoding()==RTL_TEXTENCODING_UNICODE,
         otherwise read a line of Bytecode and convert from GetStreamEncoding().
diff --git a/sc/source/core/tool/ddelink.cxx b/sc/source/core/tool/ddelink.cxx
index 3e71fa3f3b10..ffb1804cfe58 100644
--- a/sc/source/core/tool/ddelink.cxx
+++ b/sc/source/core/tool/ddelink.cxx
@@ -104,10 +104,9 @@ void ScDdeLink::Store( SvStream& rStream, 
ScMultipleWriteHeader& rHdr ) const
 {
     rHdr.StartEntry();
 
-    rtl_TextEncoding eCharSet = rStream.GetStreamEncoding();
-    rStream.WriteUniOrByteString( aAppl, eCharSet );
-    rStream.WriteUniOrByteString( aTopic, eCharSet );
-    rStream.WriteUniOrByteString( aItem, eCharSet );
+    rStream.WriteUniOrByteString( aAppl );
+    rStream.WriteUniOrByteString( aTopic );
+    rStream.WriteUniOrByteString( aItem );
 
     bool bHasValue = ( pResult != nullptr );
     rStream.WriteBool( bHasValue );
diff --git a/svl/source/items/stringio.cxx b/svl/source/items/stringio.cxx
index e4ac2f9fa77f..d0e735e28aaf 100644
--- a/svl/source/items/stringio.cxx
+++ b/svl/source/items/stringio.cxx
@@ -23,7 +23,7 @@
 
 void writeByteString(SvStream& rStream, std::u16string_view rString)
 {
-    rStream.WriteUniOrByteString(rString, rStream.GetStreamEncoding());
+    rStream.WriteUniOrByteString(rString);
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svtools/source/misc/templatefoldercache.cxx 
b/svtools/source/misc/templatefoldercache.cxx
index 200f5fe46ce9..7bef2bab085f 100644
--- a/svtools/source/misc/templatefoldercache.cxx
+++ b/svtools/source/misc/templatefoldercache.cxx
@@ -278,7 +278,7 @@ namespace svt
             // #116281# Keep office installation relocatable. Never store
             // any direct references to office installation directory.
             sURL = m_xOfficeInstDirs->makeRelocatableURL( sURL );
-            m_rStorage.WriteUniOrByteString( sURL, 
m_rStorage.GetStreamEncoding() );
+            m_rStorage.WriteUniOrByteString( sURL );
         }
     };
 
diff --git a/tools/source/stream/stream.cxx b/tools/source/stream/stream.cxx
index 9926979b0b17..b8a6530a8590 100644
--- a/tools/source/stream/stream.cxx
+++ b/tools/source/stream/stream.cxx
@@ -1149,6 +1149,11 @@ OUString SvStream::ReadUniOrByteString(rtl_TextEncoding 
eSrcEncoding)
     return read_uInt16_lenPrefixed_uInt8s_ToOUString(*this, eSrcEncoding);
 }
 
+SvStream& SvStream::WriteUniOrByteString(std::u16string_view rStr)
+{
+    return WriteUniOrByteString(rStr, GetStreamEncoding());
+}
+
 SvStream& SvStream::WriteUniOrByteString(std::u16string_view rStr, 
rtl_TextEncoding eDestEncoding)
 {
     // write UTF-16 string directly into stream ?
diff --git a/vcl/source/font/font.cxx b/vcl/source/font/font.cxx
index 22016e7f0b84..296dff6b2e08 100644
--- a/vcl/source/font/font.cxx
+++ b/vcl/source/font/font.cxx
@@ -552,8 +552,8 @@ SvStream& WriteImplFont( SvStream& rOStm, const ImplFont& 
rImplFont, tools::Long
     VersionCompatWrite aCompat( rOStm, 5 );
 
     TypeSerializer aSerializer(rOStm);
-    rOStm.WriteUniOrByteString( rImplFont.GetFamilyName(), 
rOStm.GetStreamEncoding() );
-    rOStm.WriteUniOrByteString( rImplFont.GetStyleName(), 
rOStm.GetStreamEncoding() );
+    rOStm.WriteUniOrByteString( rImplFont.GetFamilyName() );
+    rOStm.WriteUniOrByteString( rImplFont.GetStyleName() );
     aSerializer.writeSize(rImplFont.maAverageFontSize);
 
     rOStm.WriteUInt16( GetStoreCharSet( rImplFont.GetCharSet() ) );
diff --git a/vcl/source/gdi/TypeSerializer.cxx 
b/vcl/source/gdi/TypeSerializer.cxx
index da83303cfdbc..2cb21cba49d2 100644
--- a/vcl/source/gdi/TypeSerializer.cxx
+++ b/vcl/source/gdi/TypeSerializer.cxx
@@ -399,7 +399,7 @@ void TypeSerializer::writeGraphic(const Graphic& rGraphic)
                     
pVectorGraphicData->getBinaryDataContainer().writeToStream(mrStream);
 
                     // For backwards compatibility, used to serialize path
-                    mrStream.WriteUniOrByteString(u"", 
mrStream.GetStreamEncoding());
+                    mrStream.WriteUniOrByteString(u"");
                 }
                 else if (aGraphic.IsAnimated())
                 {
diff --git a/vcl/source/treelist/transfer.cxx b/vcl/source/treelist/transfer.cxx
index 5b5e765eb188..e5b5f21efb02 100644
--- a/vcl/source/treelist/transfer.cxx
+++ b/vcl/source/treelist/transfer.cxx
@@ -99,8 +99,8 @@ SvStream& WriteTransferableObjectDescriptor( SvStream& rOStm, 
const Transferable
     rOStm.WriteInt32( rObjDesc.maSize.Height() );
     rOStm.WriteInt32( rObjDesc.maDragStartPos.X() );
     rOStm.WriteInt32( rObjDesc.maDragStartPos.Y() );
-    rOStm.WriteUniOrByteString( rObjDesc.maTypeName, 
osl_getThreadTextEncoding() );
-    rOStm.WriteUniOrByteString( rObjDesc.maDisplayName, 
osl_getThreadTextEncoding() );
+    rOStm.WriteUniOrByteString( rObjDesc.maTypeName );
+    rOStm.WriteUniOrByteString( rObjDesc.maDisplayName );
     rOStm.WriteUInt32( nSig1 ).WriteUInt32( nSig2 );
 
     const sal_uInt64 nLastPos = rOStm.Tell();
commit c60a4d5b1e005f893e618d7d9c25f13b4b15e409
Author:     Noel Grandin <[email protected]>
AuthorDate: Thu Feb 26 14:17:31 2026 +0200
Commit:     Noel Grandin <[email protected]>
CommitDate: Fri Feb 27 07:48:56 2026 +0100

    inline readByteString
    
    no longer serves a purpose
    
    Change-Id: I142f643530a7e65dfe69b8db6afc92eb98885a3c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200461
    Reviewed-by: Noel Grandin <[email protected]>
    Tested-by: Jenkins

diff --git a/svl/source/inc/stringio.hxx b/svl/source/inc/stringio.hxx
index 51d52abeb336..b41d4d482113 100644
--- a/svl/source/inc/stringio.hxx
+++ b/svl/source/inc/stringio.hxx
@@ -24,15 +24,6 @@
 
 class SvStream;
 
-/** Read in a Unicode string from a streamed byte string representation.
-
-    @param rStream  Some (input) stream.  Its Stream/TargetCharSets must
-    be set to correct values!
-
-    @return  On success, returns the reconstructed Unicode string.
- */
-OUString readByteString(SvStream& rStream);
-
 /** Write a byte string representation of a Unicode string into a stream.
 
     @param rStream  Some (output) stream.  Its Stream/TargetCharSets must
diff --git a/svl/source/items/macitem.cxx b/svl/source/items/macitem.cxx
index 1a538e164a25..b71399384b14 100644
--- a/svl/source/items/macitem.cxx
+++ b/svl/source/items/macitem.cxx
@@ -115,8 +115,8 @@ void SvxMacroTableDtor::Read( SvStream& rStrm )
         sal_uInt16 nCurKey, eType = STARBASIC;
         OUString aLibName, aMacName;
         rStrm.ReadUInt16( nCurKey );
-        aLibName = readByteString(rStrm);
-        aMacName = readByteString(rStrm);
+        aLibName = rStrm.ReadUniOrByteString();
+        aMacName = rStrm.ReadUniOrByteString();
 
         if( SVX_MACROTBL_VERSION40 <= nVersion )
             rStrm.ReadUInt16( eType );
diff --git a/svl/source/items/stringio.cxx b/svl/source/items/stringio.cxx
index 03476a5c456f..e4ac2f9fa77f 100644
--- a/svl/source/items/stringio.cxx
+++ b/svl/source/items/stringio.cxx
@@ -21,8 +21,6 @@
 
 #include <tools/stream.hxx>
 
-OUString readByteString(SvStream& rStream) { return 
rStream.ReadUniOrByteString(); }
-
 void writeByteString(SvStream& rStream, std::u16string_view rString)
 {
     rStream.WriteUniOrByteString(rString, rStream.GetStreamEncoding());

Reply via email to