sw/inc/swtable.hxx                |    2 +-
 sw/source/core/table/swtable.cxx  |   11 +++++++----
 sw/source/core/unocore/unotbl.cxx |    3 +--
 sw/source/filter/xml/xmltble.cxx  |    6 ++----
 4 files changed, 11 insertions(+), 11 deletions(-)

New commits:
commit 16bf64fc7691d22162036f3f9bef37ffb1fbd9c8
Author:     Michael Weghorn <[email protected]>
AuthorDate: Tue Mar 3 11:48:33 2026 +0100
Commit:     Michael Weghorn <[email protected]>
CommitDate: Wed Mar 4 07:19:04 2026 +0100

    tdf#171086 sw: Only return col name in sw_GetTableBoxColStr
    
    So far, sw_GetTableBoxColStr was taking a string ref
    in/out param and prepending the column name to
    that existing string.
    
    Instead, just return the column name and let the only
    caller that wants to prepend it to an existing string
    do so itself.
    
    This makes the method's semantic clearer and simplifies
    the other callers.
    
    Change-Id: I7b5fa2f38a82cc6a191d29e26aef62f8169a2eec
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200878
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <[email protected]>

diff --git a/sw/inc/swtable.hxx b/sw/inc/swtable.hxx
index 9401e43e42f5..0e82d80ebb72 100644
--- a/sw/inc/swtable.hxx
+++ b/sw/inc/swtable.hxx
@@ -57,7 +57,7 @@ struct Parm;
 class SwServerObject;
 class SwHistory;
 
-void sw_GetTableBoxColStr( sal_uInt16 nCol, OUString& rNm );
+OUString sw_GetTableBoxColStr(sal_uInt16 nCol);
 
 class SwTableLines
 {
diff --git a/sw/source/core/table/swtable.cxx b/sw/source/core/table/swtable.cxx
index 25979b7d66eb..ce3da88f56c0 100644
--- a/sw/source/core/table/swtable.cxx
+++ b/sw/source/core/table/swtable.cxx
@@ -2187,16 +2187,17 @@ void SwTableBox::ChgFrameFormat(SwTableBoxFormat* 
pNewFormat, bool bNeedToReregi
 
 // Return the name of this box. This is determined dynamically
 // resulting from the position in the lines/boxes/tables.
-void sw_GetTableBoxColStr( sal_uInt16 nCol, OUString& rNm )
+OUString sw_GetTableBoxColStr(sal_uInt16 nCol)
 {
     const sal_uInt16 coDiff = 52;   // 'A'-'Z' 'a' - 'z'
 
+    OUString sName;
     do {
         const sal_uInt16 nCalc = nCol % coDiff;
         if( nCalc >= 26 )
-            rNm = OUStringChar( sal_Unicode('a' - 26 + nCalc) ) + rNm;
+            sName = OUStringChar(sal_Unicode('a' - 26 + nCalc)) + sName;
         else
-            rNm = OUStringChar( sal_Unicode('A' + nCalc) ) + rNm;
+            sName = OUStringChar(sal_Unicode('A' + nCalc)) + sName;
 
         nCol = nCol - nCalc;
         if( 0 == nCol )
@@ -2204,6 +2205,8 @@ void sw_GetTableBoxColStr( sal_uInt16 nCol, OUString& rNm 
)
         nCol /= coDiff;
         --nCol;
     } while( true );
+
+    return sName;
 }
 
 Point SwTableBox::GetCoordinates() const
@@ -2260,7 +2263,7 @@ OUString SwTableBox::GetName() const
         if( nullptr != pBox )
             sNm = sTmp + "." + sNm;
         else
-            sw_GetTableBoxColStr( nPos, sNm );
+            sNm = sw_GetTableBoxColStr(nPos) + sNm;
 
     } while( pBox );
     return sNm;
diff --git a/sw/source/core/unocore/unotbl.cxx 
b/sw/source/core/unocore/unotbl.cxx
index 26e9e0682cb7..a2cd1f205739 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -493,8 +493,7 @@ OUString sw_GetCellName( sal_Int32 nColumn, sal_Int32 nRow )
 {
     if (nColumn < 0 || nRow < 0)
         return OUString();
-    OUString sCellName;
-    sw_GetTableBoxColStr( static_cast< sal_uInt16 >(nColumn), sCellName );
+    const OUString sCellName = 
sw_GetTableBoxColStr(static_cast<sal_uInt16>(nColumn));
     return sCellName + OUString::number( nRow + 1 );
 }
 
diff --git a/sw/source/filter/xml/xmltble.cxx b/sw/source/filter/xml/xmltble.cxx
index 45b882b8f0d7..b35a33a7a8d5 100644
--- a/sw/source/filter/xml/xmltble.cxx
+++ b/sw/source/filter/xml/xmltble.cxx
@@ -312,8 +312,7 @@ static OUString 
lcl_xmltble_appendBoxPrefix(std::u16string_view rNamePrefix,
 {
     if( bTop )
     {
-        OUString sTmp;
-        sw_GetTableBoxColStr( o3tl::narrowing<sal_uInt16>(nCol), sTmp );
+        const OUString sTmp = 
sw_GetTableBoxColStr(o3tl::narrowing<sal_uInt16>(nCol));
         return OUString::Concat(rNamePrefix) + "." + sTmp + 
OUString::number(nRow + 1);
     }
     return OUString::Concat(rNamePrefix)
@@ -645,8 +644,7 @@ void SwXMLExport::ExportTableLinesAutoStyles( const 
SwTableLines& rLines,
             {
                 if( bTop )
                 {
-                    OUString sTmp;
-                    sw_GetTableBoxColStr( nColumn, sTmp );
+                    const OUString sTmp = sw_GetTableBoxColStr(nColumn);
                     pColumn->SetStyleName( OUString::Concat(rNamePrefix) + "." 
+ sTmp );
                 }
                 else

Reply via email to