diff options
author | Tibor Nagy <nagy.tibor2@nisz.hu> | 2020-09-01 13:55:25 +0200 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2020-09-04 08:47:21 +0200 |
commit | 487df0c8f307500029b06c89985a1148ebc784b5 (patch) | |
tree | 2b303551524a015f0234582dc4d4f16f898731e9 | |
parent | 88da6b7b62dc0c391e28a920bb2d355bce89f8bf (diff) |
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 <nemeth@numbertext.org>
Reviewed-by: László Németh <nemeth@numbertext.org>
-rw-r--r-- | sc/qa/unit/data/xlsx/tdf123353.xlsx | bin | 0 -> 8489 bytes | |||
-rw-r--r-- | sc/qa/unit/subsequent_export-test.cxx | 21 | ||||
-rw-r--r-- | sc/source/filter/excel/excrecds.cxx | 12 | ||||
-rw-r--r-- | sc/source/filter/inc/excrecds.hxx | 2 |
4 files changed, 32 insertions, 3 deletions
diff --git a/sc/qa/unit/data/xlsx/tdf123353.xlsx b/sc/qa/unit/data/xlsx/tdf123353.xlsx Binary files differnew file mode 100644 index 000000000000..f37f0724ca98 --- /dev/null +++ b/sc/qa/unit/data/xlsx/tdf123353.xlsx diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx index 8172ae52da05..efe44fc22f2b 100644 --- a/sc/qa/unit/subsequent_export-test.cxx +++ b/sc/qa/unit/subsequent_export-test.cxx @@ -259,6 +259,7 @@ public: void testTdf121718_UseFirstPageNumberXLSX(); void testHeaderFontStyleXLSX(); void testTdf135828_Shape_Rect(); + void testTdf123353(); CPPUNIT_TEST_SUITE(ScExportTest); CPPUNIT_TEST(test); @@ -416,6 +417,7 @@ public: CPPUNIT_TEST(testTdf121718_UseFirstPageNumberXLSX); CPPUNIT_TEST(testHeaderFontStyleXLSX); CPPUNIT_TEST(testTdf135828_Shape_Rect); + CPPUNIT_TEST(testTdf123353); CPPUNIT_TEST_SUITE_END(); @@ -5314,6 +5316,7 @@ void ScExportTest::testTdf135828_Shape_Rect() CPPUNIT_ASSERT(xDocSh.is()); std::shared_ptr<utl::TempFile> pXPathFile = ScBootstrapFixture::exportTo(&(*xDocSh), FORMAT_XLSX); + xmlDocUniquePtr pDrawing = XPathHelper::parseExport(pXPathFile, m_xSFactory, "xl/drawings/drawing1.xml"); CPPUNIT_ASSERT(pDrawing); @@ -5321,6 +5324,24 @@ void ScExportTest::testTdf135828_Shape_Rect() 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); + + xmlDocUniquePtr 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 3298d4244dff..945748ba9dca 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 147808e4e758..33c24eb428a1 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; |