From d8e0001fd8b4702f78ade095b8b2ce09ac2451e2 Mon Sep 17 00:00:00 2001 From: Serge Krot Date: Mon, 29 Jun 2020 13:23:34 +0200 Subject: tdf#95640 XLSX: import/export of custom sort lists Conflicts: sc/source/filter/excel/excrecds.cxx sc/source/filter/oox/autofilterbuffer.cxx sc/source/filter/oox/tablebuffer.cxx Change-Id: If5ffef39770bf7abd6e75e8de998d4a2b4749a0d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97399 Tested-by: Jenkins Tested-by: Serge Krot Reviewed-by: Serge Krot Reviewed-by: Thorsten Behrens Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102254 Reviewed-by: Samuel Mehrbrodt --- sc/qa/unit/data/ods/tdf95640.ods | Bin 0 -> 8406 bytes sc/qa/unit/data/ods/tdf95640_standard_list.ods | Bin 0 -> 9684 bytes sc/qa/unit/data/xlsx/tdf95640.xlsx | Bin 0 -> 8500 bytes sc/qa/unit/subsequent_export-test.cxx | 63 +++++++++++++++++++++++++ 4 files changed, 63 insertions(+) create mode 100644 sc/qa/unit/data/ods/tdf95640.ods create mode 100644 sc/qa/unit/data/ods/tdf95640_standard_list.ods create mode 100644 sc/qa/unit/data/xlsx/tdf95640.xlsx (limited to 'sc/qa') diff --git a/sc/qa/unit/data/ods/tdf95640.ods b/sc/qa/unit/data/ods/tdf95640.ods new file mode 100644 index 000000000000..5d435c61cc85 Binary files /dev/null and b/sc/qa/unit/data/ods/tdf95640.ods differ diff --git a/sc/qa/unit/data/ods/tdf95640_standard_list.ods b/sc/qa/unit/data/ods/tdf95640_standard_list.ods new file mode 100644 index 000000000000..37bea8a0c93e Binary files /dev/null and b/sc/qa/unit/data/ods/tdf95640_standard_list.ods differ diff --git a/sc/qa/unit/data/xlsx/tdf95640.xlsx b/sc/qa/unit/data/xlsx/tdf95640.xlsx new file mode 100644 index 000000000000..78c2d32c2cf6 Binary files /dev/null and b/sc/qa/unit/data/xlsx/tdf95640.xlsx differ diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx index bf0d74cdf830..80a888f42c39 100644 --- a/sc/qa/unit/subsequent_export-test.cxx +++ b/sc/qa/unit/subsequent_export-test.cxx @@ -195,6 +195,12 @@ public: void testPreserveTextWhitespace2XLSX(); void testTextDirectionXLSX(); + xmlDocPtr testTdf95640(const OUString& rFileName, sal_Int32 nSourceFormat, + sal_Int32 nDestFormat); + void testTdf95640_ods_to_xlsx(); + void testTdf95640_ods_to_xlsx_with_standard_list(); + void testTdf95640_xlsx_to_xlsx(); + void testRefStringXLSX(); void testRefStringConfigXLSX(); void testRefStringUnspecified(); @@ -327,6 +333,9 @@ public: CPPUNIT_TEST(testMoveCellAnchoredShapesODS); CPPUNIT_TEST(testMatrixMultiplicationXLSX); CPPUNIT_TEST(testTextDirectionXLSX); + CPPUNIT_TEST(testTdf95640_ods_to_xlsx); + CPPUNIT_TEST(testTdf95640_ods_to_xlsx_with_standard_list); + CPPUNIT_TEST(testTdf95640_xlsx_to_xlsx); CPPUNIT_TEST(testRefStringXLSX); CPPUNIT_TEST(testRefStringConfigXLSX); @@ -3956,6 +3965,60 @@ void ScExportTest::testTextDirectionXLSX() assertXPath(pDoc, "/x:styleSheet/x:cellXfs/x:xf[3]/x:alignment", "readingOrder", "2");//RTL } +xmlDocPtr ScExportTest::testTdf95640(const OUString& rFileName, sal_Int32 nSourceFormat, + sal_Int32 nDestFormat) +{ + ScDocShellRef xShell = loadDoc(rFileName, nSourceFormat); + CPPUNIT_ASSERT(xShell); + + auto pXPathFile = ScBootstrapFixture::exportTo(&(*xShell), nDestFormat); + xShell->DoClose(); + + return XPathHelper::parseExport(pXPathFile, m_xSFactory, "xl/worksheets/sheet1.xml"); +} + +void ScExportTest::testTdf95640_ods_to_xlsx() +{ + // Roundtripping sort options with user defined list to XLSX + xmlDocPtr pDoc = testTdf95640("tdf95640.", FORMAT_ODS, FORMAT_XLSX); + + assertXPath(pDoc, "//x:worksheet/x:autoFilter", "ref", "A1:B4"); + + assertXPath(pDoc, "//x:worksheet/x:autoFilter/x:sortState/x:sortCondition", "ref", "A2:A4"); + + assertXPath(pDoc, "//x:worksheet/x:autoFilter/x:sortState/x:sortCondition", "customList", + "Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec"); +} + +void ScExportTest::testTdf95640_ods_to_xlsx_with_standard_list() +{ + // Roundtripping sort options with user defined list to XLSX + xmlDocPtr pDoc = testTdf95640("tdf95640_standard_list.", FORMAT_ODS, FORMAT_XLSX); + + assertXPath(pDoc, "//x:worksheet/x:autoFilter", "ref", "A1:B4"); + + assertXPath(pDoc, "//x:worksheet/x:autoFilter/x:sortState/x:sortCondition", "ref", "A2:A4"); + + assertXPath(pDoc, "//x:worksheet/x:autoFilter/x:sortState/x:sortCondition", "customList", + "Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday"); +} + +void ScExportTest::testTdf95640_xlsx_to_xlsx() +{ + // XLSX Roundtripping sort options with custom sort list - note + // that compared to ODS source documents above, here we _actually_ + // can use custom lists (beyond the global user defines), like + // low, medium, high + xmlDocPtr pDoc = testTdf95640("tdf95640.", FORMAT_XLSX, FORMAT_XLSX); + + assertXPath(pDoc, "//x:worksheet/x:autoFilter", "ref", "A1:B4"); + + assertXPath(pDoc, "//x:worksheet/x:autoFilter/x:sortState/x:sortCondition", "ref", "A2:A4"); + + assertXPath(pDoc, "//x:worksheet/x:autoFilter/x:sortState/x:sortCondition", "customList", + "Low,Medium,High"); +} + void ScExportTest::testTdf88657ODS() { ScDocShellRef xDocSh = loadDoc("tdf88657.", FORMAT_ODS); -- cgit