formula/source/core/api/FormulaCompiler.cxx |   26 +++++++++++++++++++++++++-
 sc/source/filter/excel/xestream.cxx         |   17 ++++++++++++++++-
 2 files changed, 41 insertions(+), 2 deletions(-)

New commits:
commit 84c1427aca2dca7189840160c4e877cd73ae0d4c
Author:     Karthik Godha <[email protected]>
AuthorDate: Sat Jan 10 17:15:47 2026 +0530
Commit:     Xisco Fauli <[email protected]>
CommitDate: Fri Feb 6 11:42:13 2026 +0100

    tdf#170287: XLS->XLSX Limit font-name length to 31
    
    Change-Id: I4bb731afaf2f741181ee525af473d6bf4dfac5c2
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/196963
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    Reviewed-by: Michael Stahl <[email protected]>
    (cherry picked from commit 30e2c72cf63ba6fae8bd2948518169e7d5159e4c)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/198411
    Tested-by: Jenkins
    Signed-off-by: Xisco Fauli <[email protected]>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/198783

diff --git a/sc/source/filter/excel/xestream.cxx 
b/sc/source/filter/excel/xestream.cxx
index a53570ee50a4..16fc9929ef88 100644
--- a/sc/source/filter/excel/xestream.cxx
+++ b/sc/source/filter/excel/xestream.cxx
@@ -904,7 +904,22 @@ sax_fastparser::FSHelperPtr XclXmlUtils::WriteFontData( 
sax_fastparser::FSHelper
     }
 
     assert(!rFontData.maName.isEmpty() && "Font Name can't be empty");
-    pStream->singleElement(nFontId, XML_val, rFontData.maName);
+
+    constexpr sal_Int32 MAX_FONT_LENGTH = 31;
+    OUString sFont = rFontData.maName;
+    if (sFont.getLength() > MAX_FONT_LENGTH)
+    {
+        sFont = sFont.copy(0, MAX_FONT_LENGTH);
+        // Truncate till last semi-colon
+        if (rFontData.maName[MAX_FONT_LENGTH] != ';')
+        {
+            sal_Int32 nIndex = sFont.lastIndexOf(';');
+            if (nIndex != -1)
+                sFont = sFont.copy(0, nIndex);
+        }
+    }
+
+    pStream->singleElement(nFontId, XML_val, sFont);
     pStream->singleElement(XML_family, XML_val, OString::number(  
rFontData.mnFamily ));
     if (rFontData.mnCharSet != 0)
         pStream->singleElement(XML_charset, XML_val, 
OString::number(rFontData.mnCharSet));
commit 78966e5cd07496b2c6e8e0cd5ef456d4383197f9
Author:     Karthik Godha <[email protected]>
AuthorDate: Mon Jan 12 19:15:00 2026 +0530
Commit:     Xisco Fauli <[email protected]>
CommitDate: Fri Feb 6 11:42:01 2026 +0100

    XLSX - Skip unknown functions in definedName
    
    Skip export of ocNoName token during XLSX export, which is associated
    with unknown functions
    
    bug document: forum-de2-3313.xls
    
    Change-Id: I3db50028cd7a0f78d214d2af7e73b71e8e5f233a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/197113
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    Reviewed-by: Michael Stahl <[email protected]>
    (cherry picked from commit edf7db8d90410cf3ee4098823e3c21e5e8e83e79)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/198419
    Tested-by: Jenkins
    Signed-off-by: Xisco Fauli <[email protected]>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/198782

diff --git a/formula/source/core/api/FormulaCompiler.cxx 
b/formula/source/core/api/FormulaCompiler.cxx
index 9e9e90cd67c3..62900e0d3f46 100644
--- a/formula/source/core/api/FormulaCompiler.cxx
+++ b/formula/source/core/api/FormulaCompiler.cxx
@@ -2518,7 +2518,31 @@ void FormulaCompiler::CreateStringFromTokenArray( 
OUStringBuffer& rBuffer )
         rBuffer.append( '=');
     const FormulaToken* t = maArrIterator.First();
     while( t )
-        t = CreateStringFromToken( rBuffer, t, true );
+    {
+        // Skip writing unknown functions without a name in OOXML ex: #NAME!()
+        if (t->GetOpCode() == ocNoName && t->GetType() == svByte
+            && FormulaGrammar::isOOXML(meGrammar))
+        {
+            t = maArrIterator.Next();
+            sal_uInt16 nParenthesis = 0;
+            // traverse the array to match parentheses
+            if (t && t->GetOpCode() == ocOpen)
+            {
+                do
+                {
+                    if (t->GetOpCode() == ocOpen)
+                        nParenthesis++;
+                    else if (t->GetOpCode() == ocClose)
+                        nParenthesis--;
+
+                    t = maArrIterator.Next();
+
+                } while (nParenthesis > 0 && t);
+            }
+            continue;
+        }
+        t = CreateStringFromToken(rBuffer, t, true);
+    }
 
     if (pSaveArr != pArr)
     {

Reply via email to