formula/source/core/api/FormulaCompiler.cxx |   26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)

New commits:
commit edf7db8d90410cf3ee4098823e3c21e5e8e83e79
Author:     Karthik Godha <[email protected]>
AuthorDate: Mon Jan 12 19:15:00 2026 +0530
Commit:     Michael Stahl <[email protected]>
CommitDate: Thu Jan 15 13:26:55 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]>

diff --git a/formula/source/core/api/FormulaCompiler.cxx 
b/formula/source/core/api/FormulaCompiler.cxx
index d817fae353ce..4be78a4a47bd 100644
--- a/formula/source/core/api/FormulaCompiler.cxx
+++ b/formula/source/core/api/FormulaCompiler.cxx
@@ -2521,7 +2521,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