dev/null                               |binary
 sc/qa/unit/subsequent_export_test2.cxx |   26 --------------------------
 sc/source/filter/excel/xestream.cxx    |    5 +----
 sc/source/filter/excel/xetable.cxx     |    4 ++--
 sc/source/filter/excel/xltools.cxx     |   10 ----------
 sc/source/filter/inc/xestream.hxx      |    3 +--
 sc/source/filter/inc/xltools.hxx       |    2 --
 7 files changed, 4 insertions(+), 46 deletions(-)

New commits:
commit c838032f2ffdfd53e51986477ad09ab2086a3d03
Author:     Aron Budea <[email protected]>
AuthorDate: Wed Feb 18 03:37:36 2026 +1030
Commit:     Christian Lohmaier <[email protected]>
CommitDate: Thu Feb 19 14:20:42 2026 +0100

    Revert "tdf#170515 sc: formula with invalid parameters saved into XLSX"
    
    Invalid XML gets exported with problematic matrix formula,
    eg. fdo73235-1.ods as found by crashtesting.
    
    Revert in LO 26.2.1 for now.
    
    This reverts commit f613919aeb8401abe48e7b5fcef507093649f7fa.
    
    Change-Id: I19aca20cc447871d89f462af874e46993ed6f4ce
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/199565
    Reviewed-by: Adolfo Jayme Barrientos <[email protected]>
    Reviewed-by: Xisco Fauli <[email protected]>
    Tested-by: Christian Lohmaier <[email protected]>
    Reviewed-by: Christian Lohmaier <[email protected]>

diff --git a/sc/qa/unit/data/ods/tdf170515_invalid_parameters.ods 
b/sc/qa/unit/data/ods/tdf170515_invalid_parameters.ods
deleted file mode 100644
index 35ac902111e6..000000000000
Binary files a/sc/qa/unit/data/ods/tdf170515_invalid_parameters.ods and 
/dev/null differ
diff --git a/sc/qa/unit/subsequent_export_test2.cxx 
b/sc/qa/unit/subsequent_export_test2.cxx
index e2d2bdfeab50..9c6400375cd9 100644
--- a/sc/qa/unit/subsequent_export_test2.cxx
+++ b/sc/qa/unit/subsequent_export_test2.cxx
@@ -1566,32 +1566,6 @@ CPPUNIT_TEST_FIXTURE(ScExportTest2, testTdf137543XLSX)
         u"_xlfn.LET(_xlpm.first,B5:E15,_xlfn.CHOOSEROWS(_xlpm.first, 1, 3, 5, 
7, 9, 11))");
 }
 
-CPPUNIT_TEST_FIXTURE(ScExportTest2, testTdf170515_invalid_parameters)
-{
-    createScDoc("ods/tdf170515_invalid_parameters.ods");
-
-    save(TestFilter::XLSX);
-    xmlDocUniquePtr pSheet = parseExport(u"xl/worksheets/sheet1.xml"_ustr);
-    CPPUNIT_ASSERT(pSheet);
-
-    // No function must be saved into the XLSX, the parameters are invalid 
(Err:504 in Calc),
-    // and Excel fails to open the result
-    // Function with invalid parameter: =COUNTIF(BASE(1;14);"VV")
-    CPPUNIT_ASSERT_EQUAL(0,
-                         countXPathNodes(pSheet, 
"/x:worksheet/x:sheetData/x:row[1]/x:c[1]/x:f"));
-    // Function with invalid parameter: =COUNTIF("hello";"VV")
-    CPPUNIT_ASSERT_EQUAL(0,
-                         countXPathNodes(pSheet, 
"/x:worksheet/x:sheetData/x:row[2]/x:c[1]/x:f"));
-    // Function with invalid parameter: =COUNTIF(1;"VV")
-    CPPUNIT_ASSERT_EQUAL(0,
-                         countXPathNodes(pSheet, 
"/x:worksheet/x:sheetData/x:row[3]/x:c[1]/x:f"));
-    // Function with invalid parameter: =COUNTIF(TEXT(1;"#");"VV")
-    CPPUNIT_ASSERT_EQUAL(0,
-                         countXPathNodes(pSheet, 
"/x:worksheet/x:sheetData/x:row[4]/x:c[1]/x:f"));
-    // Just check one of them that it has the right text
-    assertXPathContent(pSheet, "/x:worksheet/x:sheetData/x:row[1]/x:c[1]/x:v", 
u"#VALUE!");
-}
-
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/filter/excel/xestream.cxx 
b/sc/source/filter/excel/xestream.cxx
index a53570ee50a4..db04d2d6812c 100644
--- a/sc/source/filter/excel/xestream.cxx
+++ b/sc/source/filter/excel/xestream.cxx
@@ -665,8 +665,7 @@ static const char* lcl_GetErrorString( FormulaError 
nScErrCode )
     }
 }
 
-void XclXmlUtils::GetFormulaTypeAndValue( ScFormulaCell& rCell, const char*& 
rsType,
-                                          OUString& rsValue, bool* 
pbWriteFormula )
+void XclXmlUtils::GetFormulaTypeAndValue( ScFormulaCell& rCell, const char*& 
rsType, OUString& rsValue )
 {
     sc::FormulaResultValue aResValue = rCell.GetResult();
 
@@ -675,8 +674,6 @@ void XclXmlUtils::GetFormulaTypeAndValue( ScFormulaCell& 
rCell, const char*& rsT
         case sc::FormulaResultValue::Error:
             rsType = "e";
             rsValue = ToOUString(lcl_GetErrorString(aResValue.mnError));
-            if ( pbWriteFormula )
-                *pbWriteFormula = 
XclTools::IsFormulaWithErrorValid(aResValue.mnError);
         break;
         case sc::FormulaResultValue::Value:
             rsType = rCell.GetFormatType() == SvNumFormatType::LOGICAL
diff --git a/sc/source/filter/excel/xetable.cxx 
b/sc/source/filter/excel/xetable.cxx
index 5467d332cbd6..3b3981f118c5 100644
--- a/sc/source/filter/excel/xetable.cxx
+++ b/sc/source/filter/excel/xetable.cxx
@@ -943,8 +943,7 @@ void XclExpFormulaCell::SaveXml( XclExpXmlStream& rStrm )
 {
     const char* sType = nullptr;
     OUString    sValue;
-    bool bWriteFormula = true;
-    XclXmlUtils::GetFormulaTypeAndValue( mrScFmlaCell, sType, sValue, 
&bWriteFormula );
+    XclXmlUtils::GetFormulaTypeAndValue( mrScFmlaCell, sType, sValue );
     sax_fastparser::FSHelperPtr& rWorksheet = rStrm.GetCurrentStream();
     rWorksheet->startElement( XML_c,
             XML_r, XclXmlUtils::ToOString(rStrm.GetRoot().GetStringBuf(), 
GetXclPos()).getStr(),
@@ -953,6 +952,7 @@ void XclExpFormulaCell::SaveXml( XclExpXmlStream& rStrm )
             // OOXTODO: XML_cm, XML_vm, XML_ph
     );
 
+    bool bWriteFormula = true;
     bool bTagStarted = false;
     ScAddress aScPos( static_cast< SCCOL >( GetXclPos().mnCol ),
             static_cast< SCROW >( GetXclPos().mnRow ), 
rStrm.GetRoot().GetCurrScTab() );
diff --git a/sc/source/filter/excel/xltools.cxx 
b/sc/source/filter/excel/xltools.cxx
index 84e637e034c8..c6ecb31ed6d5 100644
--- a/sc/source/filter/excel/xltools.cxx
+++ b/sc/source/filter/excel/xltools.cxx
@@ -218,16 +218,6 @@ sal_uInt8 XclTools::GetXclErrorCode( FormulaError nScError 
)
     return EXC_ERR_NA;
 }
 
-bool XclTools::IsFormulaWithErrorValid( FormulaError nScError )
-{
-    switch ( nScError )
-    {
-        // illegal parameter, eg. COUNTIF(1, "x")
-        case FormulaError::IllegalParameter:       return false;
-        default:                                   return true;
-    }
-}
-
 FormulaError XclTools::GetScErrorCode( sal_uInt8 nXclError )
 {
     switch( nXclError )
diff --git a/sc/source/filter/inc/xestream.hxx 
b/sc/source/filter/inc/xestream.hxx
index 15082cc7abc8..4da0e0b6067a 100644
--- a/sc/source/filter/inc/xestream.hxx
+++ b/sc/source/filter/inc/xestream.hxx
@@ -251,8 +251,7 @@ public:
     XclXmlUtils(const XclXmlUtils&) = delete;
     XclXmlUtils& operator=(const XclXmlUtils&) = delete;
 
-    static void GetFormulaTypeAndValue( ScFormulaCell& rCell, const char*& 
sType, OUString& rValue,
-                                       bool* pbWriteFormula = nullptr );
+    static void                     GetFormulaTypeAndValue( ScFormulaCell& 
rCell, const char*& sType, OUString& rValue);
     static OUString          GetStreamName( const char* sStreamDir, const 
char* sStream, sal_Int32 nId );
 
     static OString ToOString( const Color& rColor );
diff --git a/sc/source/filter/inc/xltools.hxx b/sc/source/filter/inc/xltools.hxx
index 057b1a684864..f67d896af949 100644
--- a/sc/source/filter/inc/xltools.hxx
+++ b/sc/source/filter/inc/xltools.hxx
@@ -119,8 +119,6 @@ public:
 
     /** Converts a Calc error code to an Excel error code. */
     static sal_uInt8    GetXclErrorCode( FormulaError nScError );
-    /** Checks if erroneous formula is valid (file can be opened) in Excel */
-    static bool         IsFormulaWithErrorValid( FormulaError nScError );
     /** Converts an Excel error code to a Calc error code. */
     static FormulaError GetScErrorCode( sal_uInt8 nXclError );
 

Reply via email to