formula/source/core/api/FormulaCompiler.cxx | 5 +++-- sc/source/core/tool/compiler.cxx | 21 +++++++++++++-------- 2 files changed, 16 insertions(+), 10 deletions(-)
New commits: commit cae01f2bb02cf920b0bf33d6de2e316c61abbf5d Author: Karthik Godha <[email protected]> AuthorDate: Wed Feb 11 16:38:38 2026 +0530 Commit: Xisco Fauli <[email protected]> CommitDate: Thu Mar 5 22:34:02 2026 +0100 XLSX: Discard formulas with invalid external reference A formula can contain `ocExternal` token without a valid external reference. Discard them in OOXML export bug-document: forum-mso-en4-31562.xls Change-Id: I7049ad2966c8d14d12b7845b32616ad262a25f99 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/199154 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Michael Stahl <[email protected]> (cherry picked from commit ea98a7cf6ed8c97993f60e9f8a07b09d1cc57ffc) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200495 Tested-by: Jenkins Reviewed-by: Karthik Godha <[email protected]> (cherry picked from commit c83b79b0bdde4abd2196e4f7ab55a37a1943606f) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/201020 Reviewed-by: Xisco Fauli <[email protected]> diff --git a/formula/source/core/api/FormulaCompiler.cxx b/formula/source/core/api/FormulaCompiler.cxx index c3b7e4398214..680f8c5835cc 100644 --- a/formula/source/core/api/FormulaCompiler.cxx +++ b/formula/source/core/api/FormulaCompiler.cxx @@ -2520,8 +2520,9 @@ void FormulaCompiler::CreateStringFromTokenArray( OUStringBuffer& rBuffer ) while( t ) { // Discard writing unknown functions without a name in OOXML ex: #NAME!() - if (t->GetOpCode() == ocNoName && t->GetType() == svByte - && FormulaGrammar::isOOXML(meGrammar)) + if (FormulaGrammar::isOOXML(meGrammar) + && (t->GetOpCode() == ocNoName || t->GetOpCode() == ocExternal) + && t->GetType() == svByte) { rBuffer.setLength(0); rBuffer.append(GetNativeSymbol(ocErrRef)); commit 8ff269da0f251e3882ac9d379bafa57f7df44075 Author: Karthik Godha <[email protected]> AuthorDate: Mon Feb 9 14:56:56 2026 +0530 Commit: Xisco Fauli <[email protected]> CommitDate: Thu Mar 5 22:33:48 2026 +0100 XLSX: Properly handle quotes in 3D references This is related to 472f17d203207f1ef9d75ecfc9facda2d5f43384. bug-document: forum-mso-en4-254252.xls Change-Id: I748ea3aa920d560085398aab08cd35deeb2818d3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/198963 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Michael Stahl <[email protected]> (cherry picked from commit 6868442d97773bccabeb50b12b0f373a262933d0) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200493 Reviewed-by: Karthik Godha <[email protected]> Tested-by: Jenkins (cherry picked from commit 87b12b54cd20703437b4bc2b13c0445ee376191e) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/201019 Reviewed-by: Xisco Fauli <[email protected]> diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx index 5cdc87198bc9..04e0de4e058a 100644 --- a/sc/source/core/tool/compiler.cxx +++ b/sc/source/core/tool/compiler.cxx @@ -2058,18 +2058,23 @@ void ScCompiler::FormExcelSheetRange( OUStringBuffer& rBuf, sal_Int32 nQuotePos, OUString aEndTabName(rEndTabName); if (nQuotePos < rBuf.getLength()) { + const bool bQuoted1 = rBuf[nQuotePos] == '\''; const bool bQuoted2 = (!aEndTabName.isEmpty() && aEndTabName[0] == '\''); - if (bQuoted2) - aEndTabName = aEndTabName.subView(1); // Sheet2' - if (rBuf[nQuotePos] == '\'') // 'Sheet1' + if (bQuoted1 && bQuoted2) // Both sheets are quoted { - const sal_Int32 nLast = rBuf.getLength() - 1; - if (rBuf[nLast] == '\'') - rBuf.remove(nLast, 1); // 'Sheet1 + rBuf.remove(rBuf.getLength() - 1, 1); + aEndTabName = aEndTabName.subView(1); } - else if (bQuoted2) // Sheet1 + else if (bQuoted1) // Only Sheet1 is quoted { - rBuf.insert(nQuotePos, '\''); // 'Sheet1 + rBuf.remove(rBuf.getLength() - 1, 1); + if (!aEndTabName.isEmpty()) + aEndTabName += "\'"; + } + else if (bQuoted2) // Only Sheet2 is quoted + { + rBuf.insert(nQuotePos, '\''); + aEndTabName = aEndTabName.subView(1); } } rBuf.append( ':' );
