connectivity/source/drivers/flat/ETable.cxx     |    6 +++---
 dbaccess/qa/unit/embeddeddb_performancetest.cxx |    6 +++---
 editeng/source/editeng/impedit4.cxx             |    4 ++--
 include/tools/stream.hxx                        |    8 ++++----
 sc/source/filter/dif/difimp.cxx                 |    4 ++--
 sc/source/ui/docshell/impex.cxx                 |    6 +++---
 sfx2/source/doc/objstor.cxx                     |    3 ++-
 sw/qa/filter/md/md.cxx                          |    8 ++++----
 sw/source/ui/dbui/createaddresslistdialog.cxx   |    4 ++--
 sw/source/ui/index/cnttab.cxx                   |    7 +++----
 tools/qa/cppunit/test_stream.cxx                |    3 ++-
 tools/source/stream/stream.cxx                  |   12 ++++++------
 12 files changed, 36 insertions(+), 35 deletions(-)

New commits:
commit 4e6f8e76bfffb2613848345fea50aa4317dd25c5
Author:     Noel Grandin <[email protected]>
AuthorDate: Wed Feb 25 13:58:02 2026 +0200
Commit:     Noel Grandin <[email protected]>
CommitDate: Thu Feb 26 20:19:02 2026 +0100

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

diff --git a/connectivity/source/drivers/flat/ETable.cxx 
b/connectivity/source/drivers/flat/ETable.cxx
index 097c152afe75..6c4f3584e909 100644
--- a/connectivity/source/drivers/flat/ETable.cxx
+++ b/connectivity/source/drivers/flat/ETable.cxx
@@ -436,6 +436,7 @@ void OFlatTable::construct()
     m_pFileStream->SetBufferSize(nSize > 1000000 ? 32768 :
                                 nSize > 100000  ? 16384 :
                                 nSize > 10000   ? 4096  : 1024);
+    m_pFileStream->SetStreamEncoding(m_pConnection->getTextEncoding());
 
     fillColumns(aAppLocale);
 
@@ -845,13 +846,12 @@ bool OFlatTable::seekRow(IResultSetHelper::Movement 
eCursorPosition, sal_Int32 n
 
 bool OFlatTable::readLine(sal_Int32 * const pEndPos, sal_Int32 * const 
pStartPos, const bool nonEmpty)
 {
-    const rtl_TextEncoding nEncoding = m_pConnection->getTextEncoding();
     m_aCurrentLine = QuotedTokenizedString();
     do
     {
         if (pStartPos)
             *pStartPos = static_cast<sal_Int32>(m_pFileStream->Tell());
-        m_pFileStream->ReadByteStringLine(m_aCurrentLine, nEncoding, 262144);
+        m_pFileStream->ReadByteStringLine(m_aCurrentLine, 262144);
         if (m_pFileStream->eof())
             return false;
 
@@ -902,7 +902,7 @@ bool OFlatTable::readLine(sal_Int32 * const pEndPos, 
sal_Int32 * const pStartPos
             if (isQuoted)
             {
                 nLastOffset = sLine.Len();
-                m_pFileStream->ReadByteStringLine(sLine,nEncoding);
+                m_pFileStream->ReadByteStringLine(sLine);
                 if ( !m_pFileStream->eof() )
                 {
                     OUString aStr = m_aCurrentLine.GetString() + "
" + sLine.GetString();
diff --git a/dbaccess/qa/unit/embeddeddb_performancetest.cxx 
b/dbaccess/qa/unit/embeddeddb_performancetest.cxx
index 0a1d88e764e9..1968e21f4ac0 100644
--- a/dbaccess/qa/unit/embeddeddb_performancetest.cxx
+++ b/dbaccess/qa/unit/embeddeddb_performancetest.cxx
@@ -116,7 +116,7 @@ public:
 SvFileStream* EmbeddedDBPerformanceTest::getWordListStream()
 {
     OUString wlPath = createFileURL(u"wordlist");
-    return new SvFileStream(wlPath, StreamMode::READ);
+    return new SvFileStream(wlPath, StreamMode::READ, RTL_TEXTENCODING_UTF8);
 }
 
 void EmbeddedDBPerformanceTest::printTimes(
@@ -233,7 +233,7 @@ void 
EmbeddedDBPerformanceTest::performPreparedStatementInsertTest(
     TimeValue aStart, aMiddle, aEnd;
     osl_getSystemTime(&aStart);
 
-    while (pFile->ReadByteStringLine(aWord, RTL_TEXTENCODING_UTF8))
+    while (pFile->ReadByteStringLine(aWord))
     {
         xParameters->setInt(1, aID++);
         xParameters->setString(2, aWord);
@@ -269,7 +269,7 @@ void EmbeddedDBPerformanceTest::performStatementInsertTest(
     TimeValue aStart, aMiddle, aEnd;
     osl_getSystemTime(&aStart);
 
-    while (pFile->ReadByteStringLine(aWord, RTL_TEXTENCODING_UTF8))
+    while (pFile->ReadByteStringLine(aWord))
     {
         xStatement->execute(
             "INSERT INTO \"PFTESTTABLE\" ( \"ID\", "
diff --git a/editeng/source/editeng/impedit4.cxx 
b/editeng/source/editeng/impedit4.cxx
index ce5201c17b68..0e4b6934308d 100644
--- a/editeng/source/editeng/impedit4.cxx
+++ b/editeng/source/editeng/impedit4.cxx
@@ -128,12 +128,12 @@ EditPaM ImpEditEngine::ReadText( SvStream& rInput, 
EditSelection aSel )
     EditPaM aPaM = aSel.Max();
 
     OUString aTmpStr;
-    bool bDone = rInput.ReadByteStringLine( aTmpStr, 
rInput.GetStreamEncoding() );
+    bool bDone = rInput.ReadByteStringLine( aTmpStr );
     while ( bDone )
     {
         aPaM = ImpInsertText( EditSelection( aPaM, aPaM ), aTmpStr );
         aPaM = ImpInsertParaBreak( aPaM );
-        bDone = rInput.ReadByteStringLine( aTmpStr, rInput.GetStreamEncoding() 
);
+        bDone = rInput.ReadByteStringLine( aTmpStr );
     }
     return aPaM;
 }
diff --git a/include/tools/stream.hxx b/include/tools/stream.hxx
index 3fde39e839c1..6729412bc267 100644
--- a/include/tools/stream.hxx
+++ b/include/tools/stream.hxx
@@ -307,7 +307,7 @@ public:
               @endcode
               causing endless loops ...
     */
-    bool            ReadByteStringLine( OUString& rStr, rtl_TextEncoding 
eSrcEncoding,
+    bool            ReadByteStringLine( OUString& rStr,
                                         sal_Int32 nMaxBytesToRead = 0xFFFE );
 
     /** Write a line of bytes. Uses stream encoding set on the stream.
diff --git a/sw/source/ui/dbui/createaddresslistdialog.cxx 
b/sw/source/ui/dbui/createaddresslistdialog.cxx
index f5b7d1cedf58..627acdd2ba2c 100644
--- a/sw/source/ui/dbui/createaddresslistdialog.cxx
+++ b/sw/source/ui/dbui/createaddresslistdialog.cxx
@@ -262,7 +262,7 @@ SwCreateAddressListDialog::SwCreateAddressListDialog(
             pStream->SetStreamEncoding(RTL_TEXTENCODING_UTF8);
 
             OUString sLine;
-            bool bRead = pStream->ReadByteStringLine( sLine, 
RTL_TEXTENCODING_UTF8 );
+            bool bRead = pStream->ReadByteStringLine( sLine );
 
             if(bRead && !sLine.isEmpty())
             {
@@ -280,7 +280,7 @@ SwCreateAddressListDialog::SwCreateAddressListDialog(
                 }
                 while (nIndex > 0);
             }
-            while(pStream->ReadByteStringLine( sLine, RTL_TEXTENCODING_UTF8 ))
+            while(pStream->ReadByteStringLine( sLine ))
             {
                 std::vector<OUString> aNewData;
                 //analyze data line
diff --git a/sw/source/ui/index/cnttab.cxx b/sw/source/ui/index/cnttab.cxx
index 9f15955d6fee..664d4bb6dc69 100644
--- a/sw/source/ui/index/cnttab.cxx
+++ b/sw/source/ui/index/cnttab.cxx
@@ -4007,13 +4007,12 @@ void SwEntryBrowseBox::ReadEntries(SvStream& rInStr)
     AutoMarkEntry* pToInsert = nullptr;
     // tdf#108910, tdf#125496 - read index entries using the appropriate 
character set
     rInStr.DetectEncoding();
-    rtl_TextEncoding eTEnc = rInStr.GetStreamEncoding();
-    if (eTEnc == RTL_TEXTENCODING_DONTKNOW)
-        eTEnc = osl_getThreadTextEncoding();
+    if (rInStr.GetStreamEncoding() == RTL_TEXTENCODING_DONTKNOW)
+        rInStr.SetStreamEncoding(osl_getThreadTextEncoding());
     while (rInStr.good())
     {
         OUString sLine;
-        rInStr.ReadByteStringLine( sLine, eTEnc );
+        rInStr.ReadByteStringLine( sLine );
 
         // # -> comment
         // ; -> delimiter between entries ->
diff --git a/tools/source/stream/stream.cxx b/tools/source/stream/stream.cxx
index 4f24149e8fa7..617a02684b40 100644
--- a/tools/source/stream/stream.cxx
+++ b/tools/source/stream/stream.cxx
@@ -386,12 +386,11 @@ void SvStream::ResetError()
     ClearError();
 }
 
-bool SvStream::ReadByteStringLine( OUString& rStr, rtl_TextEncoding 
eSrcEncoding,
-                                       sal_Int32 nMaxBytesToRead )
+bool SvStream::ReadByteStringLine( OUString& rStr, sal_Int32 nMaxBytesToRead )
 {
     OStringBuffer aStr;
     bool bRet = ReadLine( aStr, nMaxBytesToRead);
-    rStr = OStringToOUString(aStr, eSrcEncoding);
+    rStr = OStringToOUString(aStr, GetStreamEncoding());
     return bRet;
 }
 
@@ -569,7 +568,7 @@ bool SvStream::ReadUniOrByteStringLine( OUString& rStr,
     if (eSrcEncoding == RTL_TEXTENCODING_UNICODE)
         return ReadUniStringLine( rStr, nMaxCodepointsToRead );
     else
-        return ReadByteStringLine(rStr, eSrcEncoding, nMaxCodepointsToRead);
+        return ReadByteStringLine(rStr, nMaxCodepointsToRead);
 }
 
 OString read_zeroTerminated_uInt8s_ToOString(SvStream& rStream)
commit 3c5f8e3dea0b3f352519ab3e361369a65f92aedb
Author:     Noel Grandin <[email protected]>
AuthorDate: Wed Feb 25 13:29:00 2026 +0200
Commit:     Noel Grandin <[email protected]>
CommitDate: Thu Feb 26 20:18:50 2026 +0100

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

diff --git a/include/tools/stream.hxx b/include/tools/stream.hxx
index 878c555ff78a..3fde39e839c1 100644
--- a/include/tools/stream.hxx
+++ b/include/tools/stream.hxx
@@ -350,8 +350,8 @@ public:
         and write a 16bit length prefixed sequence of bytes */
     SvStream& WriteUniOrByteString(std::u16string_view rStr, rtl_TextEncoding 
eDestEncoding);
 
-    /** Read a line of Unicode if eSrcEncoding==RTL_TEXTENCODING_UNICODE,
-        otherwise read a line of Bytecode and convert from eSrcEncoding
+    /** Read a line of Unicode if 
GetStreamEncoding()==RTL_TEXTENCODING_UNICODE,
+        otherwise read a line of Bytecode and convert from GetStreamEncoding().
 
         @param nMaxCodepointsToRead
                    Maximum of codepoints (2 bytes if Unicode, bytes if not
@@ -365,7 +365,7 @@ public:
               @endcode
               causing endless loops ...
     */
-    bool            ReadUniOrByteStringLine( OUString& rStr, rtl_TextEncoding 
eSrcEncoding,
+    bool            ReadUniOrByteStringLine( OUString& rStr,
                                              sal_Int32 nMaxCodepointsToRead = 
0xFFFE );
     /** Write a sequence of Unicode characters if
         eDestEncoding==RTL_TEXTENCODING_UNICODE, otherwise write a sequence of
diff --git a/sc/source/filter/dif/difimp.cxx b/sc/source/filter/dif/difimp.cxx
index 01973a6766d4..fa64a29a9661 100644
--- a/sc/source/filter/dif/difimp.cxx
+++ b/sc/source/filter/dif/difimp.cxx
@@ -396,7 +396,7 @@ bool DifParser::ReadNextLine( OUString& rStr )
 {
     if( aLookAheadLine.isEmpty() )
     {
-        return rIn.ReadUniOrByteStringLine( rStr, rIn.GetStreamEncoding() );
+        return rIn.ReadUniOrByteStringLine( rStr );
     }
     else
     {
@@ -414,7 +414,7 @@ bool DifParser::LookAhead()
     bool bValidStructure = false;
 
     OSL_ENSURE( aLookAheadLine.isEmpty(), "*DifParser::LookAhead(): LookAhead 
called twice in a row" );
-    rIn.ReadUniOrByteStringLine( aLookAheadLine, rIn.GetStreamEncoding() );
+    rIn.ReadUniOrByteStringLine( aLookAheadLine );
 
     pCurrentBuffer = aLookAheadLine.getStr();
 
diff --git a/sc/source/ui/docshell/impex.cxx b/sc/source/ui/docshell/impex.cxx
index 63475eef4e09..6a42e856d4a9 100644
--- a/sc/source/ui/docshell/impex.cxx
+++ b/sc/source/ui/docshell/impex.cxx
@@ -923,7 +923,7 @@ bool ScImportExport::Text2Doc( SvStream& rStrm )
         rStrm.Seek( nOldPos );
         for( ;; )
         {
-            rStrm.ReadUniOrByteStringLine( aLine, rStrm.GetStreamEncoding(), 
nArbitraryLineLengthLimit );
+            rStrm.ReadUniOrByteStringLine( aLine, nArbitraryLineLengthLimit );
             // tdf#125440 When inserting tab separated string, consider quotes 
as field markers
             DoubledQuoteMode mode = aLine.indexOf("    ") >= 0 ? 
DoubledQuoteMode::ESCAPE : DoubledQuoteMode::KEEP_ALL;
             if( rStrm.eof() )
@@ -2714,7 +2714,7 @@ Label_RetryWithNewSep:
     }
 
     OUString aStr;
-    rStream.ReadUniOrByteStringLine(aStr, rStream.GetStreamEncoding(), 
nArbitraryLineLengthLimit);
+    rStream.ReadUniOrByteStringLine(aStr, nArbitraryLineLengthLimit);
 
     if (bEmbeddedLineBreak)
     {
@@ -2832,7 +2832,7 @@ Label_RetryWithNewSep:
             {
                 nLastOffset = aStr.getLength();
                 OUString aNext;
-                rStream.ReadUniOrByteStringLine(aNext, 
rStream.GetStreamEncoding(), nArbitraryLineLengthLimit);
+                rStream.ReadUniOrByteStringLine(aNext, 
nArbitraryLineLengthLimit);
                 if (!rStream.eof())
                     aStr += "
" + aNext;
             }
diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx
index d8e0eae2206e..ca37026ee8ad 100644
--- a/sfx2/source/doc/objstor.cxx
+++ b/sfx2/source/doc/objstor.cxx
@@ -907,7 +907,8 @@ void SfxObjectShell::DetectCsvSeparators(SvStream& stream, 
rtl_TextEncoding eCha
     separators = "";
 
     stream.StartReadingUnicodeText(eCharSet);
-    while (stream.ReadUniOrByteStringLine(sLine, eCharSet) && 
(tools::Time::GetSystemTicks() - nStartTime < nTimeout))
+    stream.SetStreamEncoding(eCharSet);
+    while (stream.ReadUniOrByteStringLine(sLine) && 
(tools::Time::GetSystemTicks() - nStartTime < nTimeout))
     {
         if (sLine.isEmpty())
             continue;
diff --git a/sw/qa/filter/md/md.cxx b/sw/qa/filter/md/md.cxx
index a7d2dc20e906..5a76b873a258 100644
--- a/sw/qa/filter/md/md.cxx
+++ b/sw/qa/filter/md/md.cxx
@@ -173,10 +173,10 @@ CPPUNIT_TEST_FIXTURE(Test, testExportingRedlines)
 
     // Save as a markdown document
     save(TestFilter::MD);
-    SvFileStream fileStream(maTempFile.GetURL(), StreamMode::READ);
+    SvFileStream fileStream(maTempFile.GetURL(), StreamMode::READ, 
RTL_TEXTENCODING_UTF8);
     OUString aParagraph;
     // 1st paragraph
-    CPPUNIT_ASSERT(fileStream.ReadUniOrByteStringLine(aParagraph, 
RTL_TEXTENCODING_UTF8));
+    CPPUNIT_ASSERT(fileStream.ReadUniOrByteStringLine(aParagraph));
     // Check that the insert/delete redlines were exported as <del>/<ins> 
elements
     std::u16string_view expected
         = uR"(<del title="Author: Author 1" datetime="2019-04-23T09:25:00"> 
</del>)";
@@ -186,10 +186,10 @@ CPPUNIT_TEST_FIXTURE(Test, testExportingRedlines)
     // The insert starts on the first paragraph, and ends on the second
     CPPUNIT_ASSERT(aParagraph.indexOf("</ins>") < 0);
     // An empty line between paragraphs
-    CPPUNIT_ASSERT(fileStream.ReadUniOrByteStringLine(aParagraph, 
RTL_TEXTENCODING_UTF8));
+    CPPUNIT_ASSERT(fileStream.ReadUniOrByteStringLine(aParagraph));
     CPPUNIT_ASSERT(aParagraph.isEmpty());
     // 2nd paragraph
-    CPPUNIT_ASSERT(fileStream.ReadUniOrByteStringLine(aParagraph, 
RTL_TEXTENCODING_UTF8));
+    CPPUNIT_ASSERT(fileStream.ReadUniOrByteStringLine(aParagraph));
     CPPUNIT_ASSERT(aParagraph.indexOf("</ins>") >= 0);
 }
 
diff --git a/tools/qa/cppunit/test_stream.cxx b/tools/qa/cppunit/test_stream.cxx
index b1e8ec3402f8..2e9a934d64d9 100644
--- a/tools/qa/cppunit/test_stream.cxx
+++ b/tools/qa/cppunit/test_stream.cxx
@@ -343,7 +343,8 @@ namespace
             CPPUNIT_ASSERT(!s.IsEndianSwap());
             CPPUNIT_ASSERT_EQUAL(sal_uInt64(2), s.Tell()); // after BOM
             OUString read;
-            CPPUNIT_ASSERT(s.ReadUniOrByteStringLine(read, 
RTL_TEXTENCODING_UNICODE));
+            s.SetStreamEncoding(RTL_TEXTENCODING_UNICODE);
+            CPPUNIT_ASSERT(s.ReadUniOrByteStringLine(read));
             // Without the fix in place, this would fail with
             // - Expected: abc
             // - Actual  : 愀戀挀
diff --git a/tools/source/stream/stream.cxx b/tools/source/stream/stream.cxx
index 15baf7bfdbd6..4f24149e8fa7 100644
--- a/tools/source/stream/stream.cxx
+++ b/tools/source/stream/stream.cxx
@@ -562,9 +562,10 @@ bool SvStream::ReadUniStringLine( OUString& rStr, 
sal_Int32 nMaxCodepointsToRead
     return bEnd;
 }
 
-bool SvStream::ReadUniOrByteStringLine( OUString& rStr, rtl_TextEncoding 
eSrcEncoding,
-                                            sal_Int32 nMaxCodepointsToRead )
+bool SvStream::ReadUniOrByteStringLine( OUString& rStr,
+                                        sal_Int32 nMaxCodepointsToRead )
 {
+    auto eSrcEncoding = GetStreamEncoding();
     if (eSrcEncoding == RTL_TEXTENCODING_UNICODE)
         return ReadUniStringLine( rStr, nMaxCodepointsToRead );
     else

Reply via email to