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

Tünde Tóth (via logerrit) logerrit at kemper.freedesktop.org
Wed Sep 1 12:18:36 UTC 2021


 sc/qa/unit/data/xlsx/tdf143068_top10filter.xlsx |binary
 sc/qa/unit/subsequent_export-test.cxx           |   16 ++++++++++++++++
 sc/source/filter/excel/excrecds.cxx             |   19 ++++++++++---------
 3 files changed, 26 insertions(+), 9 deletions(-)

New commits:
commit 44dd8fe9094ea006867879ed1becf36f0c2d0758
Author:     Tünde Tóth <toth.tunde at nisz.hu>
AuthorDate: Fri Jul 2 14:19:16 2021 +0200
Commit:     Gabor Kelemen <kelemen.gabor2 at nisz.hu>
CommitDate: Wed Sep 1 14:18:01 2021 +0200

    tdf#143068 XLSX: fix export of top10 filter condition
    
    Top10 filter condition lost after XLSX export.
    
    Change-Id: I5f9974e7d73f9ada84e284790c2928547f9ec7e7
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118291
    Tested-by: Jenkins
    Tested-by: László Németh <nemeth at numbertext.org>
    Reviewed-by: László Németh <nemeth at numbertext.org>
    (cherry picked from commit d79de2a2975db6b34f47b7ccfe8d18692373d6f0)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118808
    Reviewed-by: Xisco Fauli <xiscofauli at libreoffice.org>
    (cherry picked from commit b17df21168796c0b6907200f8600b065d7e602ad)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121424
    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/tdf143068_top10filter.xlsx b/sc/qa/unit/data/xlsx/tdf143068_top10filter.xlsx
new file mode 100644
index 000000000000..8626e74e60dc
Binary files /dev/null and b/sc/qa/unit/data/xlsx/tdf143068_top10filter.xlsx differ
diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx
index da114d4334d8..c83dd75a6c49 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -287,6 +287,7 @@ public:
     void testTdf140431();
     void testDateStandardfilterXLSX();
     void testTdf142929_filterLessThanXLSX();
+    void testAutofilterTop10XLSX();
 
     CPPUNIT_TEST_SUITE(ScExportTest);
     CPPUNIT_TEST(test);
@@ -473,6 +474,7 @@ public:
 
     CPPUNIT_TEST(testDateStandardfilterXLSX);
     CPPUNIT_TEST(testTdf142929_filterLessThanXLSX);
+    CPPUNIT_TEST(testAutofilterTop10XLSX);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -5964,6 +5966,20 @@ void ScExportTest::testTdf142929_filterLessThanXLSX()
     xDocSh->DoClose();
 }
 
+void ScExportTest::testAutofilterTop10XLSX()
+{
+    ScDocShellRef xDocSh = loadDoc(u"tdf143068_top10filter.", FORMAT_XLSX);
+    CPPUNIT_ASSERT(xDocSh.is());
+
+    xmlDocUniquePtr pDoc = XPathHelper::parseExport2(*this, *xDocSh, m_xSFactory,
+                                                     "xl/worksheets/sheet1.xml", FORMAT_XLSX);
+    CPPUNIT_ASSERT(pDoc);
+    assertXPath(pDoc, "//x:autoFilter/x:filterColumn", "colId", "0");
+    assertXPath(pDoc, "//x:autoFilter/x:filterColumn/x:top10", "val", "4");
+
+    xDocSh->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 1ef6f60c6cf4..5773ad65beed 100644
--- a/sc/source/filter/excel/excrecds.cxx
+++ b/sc/source/filter/excel/excrecds.cxx
@@ -793,7 +793,7 @@ void XclExpAutofilter::WriteBody( XclExpStream& rStrm )
 
 void XclExpAutofilter::SaveXml( XclExpXmlStream& rStrm )
 {
-    if (meType == FilterCondition && !HasCondition())
+    if (meType == FilterCondition && !HasCondition() && !HasTop10())
         return;
 
     sax_fastparser::FSHelperPtr& rWorksheet = rStrm.GetCurrentStream();
@@ -817,14 +817,15 @@ void XclExpAutofilter::SaveXml( XclExpXmlStream& rStrm )
                         // OOXTODO: XML_filterVal
                 );
             }
-
-            rWorksheet->startElement( XML_customFilters,
-                    XML_and, ToPsz((nFlags & EXC_AFFLAG_ANDORMASK) == EXC_AFFLAG_AND) );
-            aCond[ 0 ].SaveXml( rStrm );
-            aCond[ 1 ].SaveXml( rStrm );
-            rWorksheet->endElement( XML_customFilters );
-            // OOXTODO: XLM_colorFilter, XML_dynamicFilter,
-            // XML_extLst, XML_filters, XML_iconFilter, XML_top10
+            else
+            {
+                rWorksheet->startElement(XML_customFilters, XML_and,
+                                         ToPsz((nFlags & EXC_AFFLAG_ANDORMASK) == EXC_AFFLAG_AND));
+                aCond[0].SaveXml(rStrm);
+                aCond[1].SaveXml(rStrm);
+                rWorksheet->endElement(XML_customFilters);
+            }
+            // OOXTODO: XML_dynamicFilter, XML_extLst, XML_filters, XML_iconFilter
         }
         break;
         case BlankValue:


More information about the Libreoffice-commits mailing list