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 56bf56009e97..2cd025858d9a 100644 --- a/sc/qa/unit/subsequent_export_test2.cxx +++ b/sc/qa/unit/subsequent_export_test2.cxx @@ -1608,32 +1608,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 a0aea0032b00..67e3caad51ef 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 652b19174604..4e329d8a9b65 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 daab0f76f32b..cb2671b385a8 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 );