formula/source/core/api/token.cxx | 21 +++++++++++++++++++-- sc/qa/unit/data/ods/tdf170565_empty_functions.ods |binary sc/qa/unit/subsequent_export_test4.cxx | 6 ++++++ sc/source/filter/excel/tokstack.cxx | 6 ++++++ 4 files changed, 31 insertions(+), 2 deletions(-)
New commits: commit bb6619ee75afa0a2982cbb1c0b1a3a698955e899 Author: Karthik Godha <[email protected]> AuthorDate: Fri Feb 13 18:02:30 2026 +0530 Commit: Michael Stahl <[email protected]> CommitDate: Fri Feb 27 12:06:02 2026 +0100 tdf#170565: Handle empty aggregate functions in XLSX This is an extension of 3cbf4957d33c7414b5cd02481136679b5c6a834e, handle AVERAGE, COUNT and PRODUCT functions without parameters in XLSX Change-Id: I6c669e58f4d1ca87b557d11cd16cfd284531360f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/199345 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Aron Budea <[email protected]> (cherry picked from commit 8855ba150b5783ae0ac36063e5ceb4baa5350676) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200406 Reviewed-by: Michael Stahl <[email protected]> diff --git a/formula/source/core/api/token.cxx b/formula/source/core/api/token.cxx index 9c41f2986c9f..ceebc87e9ec5 100644 --- a/formula/source/core/api/token.cxx +++ b/formula/source/core/api/token.cxx @@ -1077,9 +1077,12 @@ inline bool MissingConventionOOXML::isRewriteNeeded( OpCode eOp ) { switch (eOp) { + case ocAverage: + case ocCount: case ocIf: case ocMax: case ocMin: + case ocProduct: case ocSum: case ocExternal: @@ -1213,11 +1216,25 @@ void FormulaMissingContext::AddMoreArgs( FormulaTokenArray *pNewArr, const Missi } break; + case ocCount: + if (mnCurArg == 0 && mbEmpty) + { + // Excel expects at least one parameter in COUNT function + pNewArr->AddString(svl::SharedString::getEmptyString()); + } + break; + + case ocAverage: + if (mnCurArg == 0 && mbEmpty) + pNewArr->AddError(FormulaError::DivisionByZero); + break; + + case ocProduct: case ocSum: if ( mnCurArg == 0 && mbEmpty ) { - // Excel needs at least one parameter in SUM function - pNewArr->AddDouble( 0.0 ); // SUM() = 0 + // Excel needs at least one parameter in aggregate functions + pNewArr->AddDouble( 0.0 ); } break; diff --git a/sc/qa/unit/data/ods/tdf170565_empty_functions.ods b/sc/qa/unit/data/ods/tdf170565_empty_functions.ods index 2297a76f9e62..d909554f4cba 100644 Binary files a/sc/qa/unit/data/ods/tdf170565_empty_functions.ods and b/sc/qa/unit/data/ods/tdf170565_empty_functions.ods differ diff --git a/sc/qa/unit/subsequent_export_test4.cxx b/sc/qa/unit/subsequent_export_test4.cxx index fe87656c10ac..bb7d8bdcf834 100644 --- a/sc/qa/unit/subsequent_export_test4.cxx +++ b/sc/qa/unit/subsequent_export_test4.cxx @@ -2514,6 +2514,9 @@ CPPUNIT_TEST_FIXTURE(ScExportTest4, testTdf170565_empty_functions) assertXPathContent(pSheet, "/x:worksheet/x:sheetData/x:row[1]/x:c[1]/x:f", u"SUM(0)"); assertXPathContent(pSheet, "/x:worksheet/x:sheetData/x:row[2]/x:c[1]/x:f", u"MIN(#VALUE!)"); assertXPathContent(pSheet, "/x:worksheet/x:sheetData/x:row[3]/x:c[1]/x:f", u"MAX(#VALUE!)"); + assertXPathContent(pSheet, "/x:worksheet/x:sheetData/x:row[4]/x:c[1]/x:f", u"AVERAGE(#DIV/0!)"); + assertXPathContent(pSheet, "/x:worksheet/x:sheetData/x:row[5]/x:c[1]/x:f", u"COUNT(\"\")"); + assertXPathContent(pSheet, "/x:worksheet/x:sheetData/x:row[6]/x:c[1]/x:f", u"PRODUCT(0)"); // Further checks to ensure there are no regressions assertXPathContent(pSheet, "/x:worksheet/x:sheetData/x:row[1]/x:c[2]/x:f", u"SUM(,)"); assertXPathContent(pSheet, "/x:worksheet/x:sheetData/x:row[1]/x:c[3]/x:f", u"SUM(100)"); @@ -2524,6 +2527,9 @@ CPPUNIT_TEST_FIXTURE(ScExportTest4, testTdf170565_empty_functions) assertXPathContent(pSheet, "/x:worksheet/x:sheetData/x:row[3]/x:c[2]/x:f", u"MAX(,)"); assertXPathContent(pSheet, "/x:worksheet/x:sheetData/x:row[3]/x:c[3]/x:f", u"MAX(-100)"); assertXPathContent(pSheet, "/x:worksheet/x:sheetData/x:row[3]/x:c[4]/x:f", u"MAX(C1:C3)"); + assertXPathContent(pSheet, "/x:worksheet/x:sheetData/x:row[4]/x:c[2]/x:f", u"AVERAGE(,)"); + assertXPathContent(pSheet, "/x:worksheet/x:sheetData/x:row[5]/x:c[2]/x:f", u"COUNT(,)"); + assertXPathContent(pSheet, "/x:worksheet/x:sheetData/x:row[6]/x:c[2]/x:f", u"PRODUCT(,)"); } CPPUNIT_PLUGIN_IMPLEMENT(); commit c8ed0cfd623169921d0633297e86a715ab6c4249 Author: Karthik Godha <[email protected]> AuthorDate: Thu Feb 12 14:37:38 2026 +0530 Commit: Michael Stahl <[email protected]> CommitDate: Fri Feb 27 12:05:54 2026 +0100 sc: XLS - Import external Named-Range functions External Named-Range could be a function, these are not handled during XLS import. bug-document: forum-mso-en4-31562.xls Change-Id: I75bea0a595b717b7af8f555dedfe582752a3db7c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/199240 Reviewed-by: Michael Stahl <[email protected]> Tested-by: Jenkins CollaboraOffice <[email protected]> (cherry picked from commit 086bc31ef7058c91a2003aa00dcb6563e5562308) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200405 diff --git a/sc/source/filter/excel/tokstack.cxx b/sc/source/filter/excel/tokstack.cxx index a0e3974caafb..548848972287 100644 --- a/sc/source/filter/excel/tokstack.cxx +++ b/sc/source/filter/excel/tokstack.cxx @@ -723,6 +723,12 @@ const OUString* TokenPool::GetExternal( const TokenId& rId ) const if ( nExt < ppP_Ext.m_writemark && ppP_Ext[ nExt ] ) p = &ppP_Ext[ nExt ]->aText; } + else if (pType[n] == T_ExtName) + { + sal_uInt16 nExt = pElement[n]; + if (nExt < maExtNames.size()) + p = &maExtNames[nExt].maName; + } } return p;
