sc/qa/unit/data/xlsx/tdf123353.xlsx |binary sc/qa/unit/subsequent_export-test.cxx | 21 +++++++++++++++++++++ sc/source/filter/excel/excrecds.cxx | 12 ++++++++++-- sc/source/filter/inc/excrecds.hxx | 2 +- 4 files changed, 32 insertions(+), 3 deletions(-)
New commits: commit ad9a1c8dc9b7c267126b8d7591812c6db3188fc9 Author: Tibor Nagy <nagy.tib...@nisz.hu> AuthorDate: Tue Sep 1 13:55:25 2020 +0200 Commit: Gabor Kelemen <kelemen.gab...@nisz.hu> CommitDate: Fri Sep 18 10:15:06 2020 +0200 tdf#123353 XLSX export: fix lost AutoFilter on empty cells The AutoFilter button was lost during export when only the rows with empty cells were visible and everything else was hidden. The filter itself was still active, but the button itself was gone. Co-authored-by: Attila Szűcs (NISZ) Change-Id: Ia0b16bf4f15303d1320081cb62090368a0ce3908 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101847 Tested-by: László Németh <nem...@numbertext.org> Reviewed-by: László Németh <nem...@numbertext.org> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102938 Tested-by: Gabor Kelemen <kelemen.gab...@nisz.hu> Reviewed-by: Gabor Kelemen <kelemen.gab...@nisz.hu> diff --git a/sc/qa/unit/data/xlsx/tdf123353.xlsx b/sc/qa/unit/data/xlsx/tdf123353.xlsx new file mode 100644 index 000000000000..f37f0724ca98 Binary files /dev/null and b/sc/qa/unit/data/xlsx/tdf123353.xlsx differ diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx index 9fdf9419f515..39c5027cc676 100644 --- a/sc/qa/unit/subsequent_export-test.cxx +++ b/sc/qa/unit/subsequent_export-test.cxx @@ -238,6 +238,7 @@ public: void testTdf134817_HeaderFooterTextWith2SectionXLSX(); void testHeaderFontStyleXLSX(); void testTdf135828_Shape_Rect(); + void testTdf123353(); CPPUNIT_TEST_SUITE(ScExportTest); CPPUNIT_TEST(test); @@ -374,6 +375,7 @@ public: CPPUNIT_TEST(testTdf134817_HeaderFooterTextWith2SectionXLSX); CPPUNIT_TEST(testHeaderFontStyleXLSX); CPPUNIT_TEST(testTdf135828_Shape_Rect); + CPPUNIT_TEST(testTdf123353); CPPUNIT_TEST_SUITE_END(); @@ -4716,12 +4718,31 @@ void ScExportTest::testTdf135828_Shape_Rect() std::shared_ptr<utl::TempFile> pXPathFile = ScBootstrapFixture::exportTo(&(*xDocSh), FORMAT_XLSX); xmlDocPtr pDrawing = XPathHelper::parseExport(pXPathFile, m_xSFactory, "xl/drawings/drawing1.xml"); + CPPUNIT_ASSERT(pDrawing); assertXPath(pDrawing, "/xdr:wsDr/xdr:twoCellAnchor/xdr:sp/xdr:spPr/a:xfrm/a:ext", "cx", "294480"); // width assertXPath(pDrawing, "/xdr:wsDr/xdr:twoCellAnchor/xdr:sp/xdr:spPr/a:xfrm/a:ext", "cy", "1990440"); // height } +void ScExportTest::testTdf123353() +{ + ScDocShellRef xShell = loadDoc("tdf123353.", FORMAT_XLSX); + CPPUNIT_ASSERT(xShell.is()); + + ScDocShellRef xDocSh = saveAndReload(&(*xShell), FORMAT_XLSX); + CPPUNIT_ASSERT(xDocSh.is()); + + std::shared_ptr<utl::TempFile> pXPathFile = ScBootstrapFixture::exportTo(&(*xDocSh), FORMAT_XLSX); + + xmlDocPtr pDoc = XPathHelper::parseExport(pXPathFile, m_xSFactory, "xl/worksheets/sheet1.xml"); + CPPUNIT_ASSERT(pDoc); + + assertXPath(pDoc, "/x:worksheet/x:autoFilter/x:filterColumn/x:filters", "blank", "1"); + + xShell->DoClose(); +} + CPPUNIT_TEST_SUITE_REGISTRATION(ScExportTest); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sc/source/filter/excel/excrecds.cxx b/sc/source/filter/excel/excrecds.cxx index 4fbe955d8b52..eb60a71e5040 100644 --- a/sc/source/filter/excel/excrecds.cxx +++ b/sc/source/filter/excel/excrecds.cxx @@ -649,9 +649,12 @@ bool XclExpAutofilter::HasCondition() const bool XclExpAutofilter::AddEntry( const ScQueryEntry& rEntry ) { const ScQueryEntry::QueryItemsType& rItems = rEntry.GetQueryItems(); - if (rItems.empty()) - return true; + if (GetOutput() != EXC_OUTPUT_BINARY && rItems.empty()) + { + meType = BlankValue; + return false; + } if (GetOutput() != EXC_OUTPUT_BINARY && rItems.size() > 1) { AddMultiValueEntry(rEntry); @@ -817,6 +820,11 @@ void XclExpAutofilter::SaveXml( XclExpXmlStream& rStrm ) // XML_extLst, XML_filters, XML_iconFilter, XML_top10 } break; + case BlankValue: + { + rWorksheet->singleElement(XML_filters, XML_blank, "1"); + } + break; case MultiValue: { rWorksheet->startElement(XML_filters); diff --git a/sc/source/filter/inc/excrecds.hxx b/sc/source/filter/inc/excrecds.hxx index 74a21cbfa563..65cc880f4051 100644 --- a/sc/source/filter/inc/excrecds.hxx +++ b/sc/source/filter/inc/excrecds.hxx @@ -361,7 +361,7 @@ public: class XclExpAutofilter : public XclExpRecord, protected XclExpRoot { private: - enum FilterType { FilterCondition, MultiValue }; + enum FilterType { FilterCondition, MultiValue, BlankValue }; FilterType meType; sal_uInt16 nCol; sal_uInt16 nFlags; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits