[Libreoffice-commits] core.git: Branch 'distro/nisz/libreoffice-7-0' - sc/qa sc/source

Tibor Nagy (via logerrit) logerrit at kemper.freedesktop.org
Wed Jan 6 15:32:28 UTC 2021


 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 6a2f504986d1947d6f14f8dcb653d7c46f5ca464
Author:     Tibor Nagy <nagy.tibor2 at nisz.hu>
AuthorDate: Tue Sep 1 13:55:25 2020 +0200
Commit:     Gabor Kelemen <kelemen.gabor2 at nisz.hu>
CommitDate: Wed Jan 6 16:31:55 2021 +0100

    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 at numbertext.org>
    Reviewed-by: László Németh <nemeth at numbertext.org>
    (cherry picked from commit 487df0c8f307500029b06c89985a1148ebc784b5)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108892
    Tested-by: Gabor Kelemen <kelemen.gabor2 at nisz.hu>
    Reviewed-by: Gabor Kelemen <kelemen.gabor2 at 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 316af342f200..38231f8dab98 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -261,6 +261,7 @@ public:
     void testTdf134459_HeaderFooterColorXLSX();
     void testHeaderFontStyleXLSX();
     void testTdf135828_Shape_Rect();
+    void testTdf123353();
 
     CPPUNIT_TEST_SUITE(ScExportTest);
     CPPUNIT_TEST(test);
@@ -416,6 +417,7 @@ public:
     CPPUNIT_TEST(testTdf134459_HeaderFooterColorXLSX);
     CPPUNIT_TEST(testHeaderFontStyleXLSX);
     CPPUNIT_TEST(testTdf135828_Shape_Rect);
+    CPPUNIT_TEST(testTdf123353);
 
     CPPUNIT_TEST_SUITE_END();
 
@@ -5266,6 +5268,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);
 
@@ -5273,6 +5276,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 b8e1e375e3d8..ce6b05970e6d 100644
--- a/sc/source/filter/excel/excrecds.cxx
+++ b/sc/source/filter/excel/excrecds.cxx
@@ -651,9 +651,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);
@@ -819,6 +822,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 20c9425822f1..986654fbd335 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;


More information about the Libreoffice-commits mailing list