diff options
author | Balazs Varga <balazs.varga991@gmail.com> | 2021-03-02 22:46:33 +0100 |
---|---|---|
committer | Gabor Kelemen <kelemen.gabor2@nisz.hu> | 2021-04-29 08:47:17 +0200 |
commit | 2cc05be5213ccedb673f5e06278d65b0cdbe890b (patch) | |
tree | efcd6ee39802cd12dd5e6b6111a582c2eb7ab892 | |
parent | 337f86e5023a2d2ddc4fdbc82a3a5d986db90110 (diff) |
tdf#137626 XLSX import: fix missing datetime filters
by convert string representation of the datetime data
to ISO 8601 (with blank instead of T) datetime to
eliminate locale dependent behaviour when filtering
for datetimes.
Follow-up of commit 0e751d0cb816197f15a2448ec36c57df17387e40
(tdf#116818 sc,offapi,XLSX import: fix autofiltered date columns).
Change-Id: I3a0f41dbbf28a1a60a54fe7b2c8c338516edb079
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111851
Tested-by: László Németh <nemeth@numbertext.org>
Reviewed-by: László Németh <nemeth@numbertext.org>
(cherry picked from commit 26032e63abd01c3d5941a2728ef024da290d6b0a)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114730
Tested-by: Gabor Kelemen <kelemen.gabor2@nisz.hu>
Reviewed-by: Gabor Kelemen <kelemen.gabor2@nisz.hu>
-rw-r--r-- | sc/qa/uitest/autofilter/autofilter.py | 15 | ||||
-rw-r--r-- | sc/qa/uitest/data/autofilter/tdf137626.xlsx | bin | 0 -> 11284 bytes | |||
-rw-r--r-- | sc/source/core/data/column3.cxx | 8 | ||||
-rw-r--r-- | sc/source/filter/oox/autofilterbuffer.cxx | 33 | ||||
-rw-r--r-- | sc/source/ui/unoobj/datauno.cxx | 5 |
5 files changed, 56 insertions, 5 deletions
diff --git a/sc/qa/uitest/autofilter/autofilter.py b/sc/qa/uitest/autofilter/autofilter.py index 149fa3400134..b968a06a8f74 100644 --- a/sc/qa/uitest/autofilter/autofilter.py +++ b/sc/qa/uitest/autofilter/autofilter.py @@ -174,4 +174,19 @@ class AutofilterTest(UITestCase): xOkBtn.executeAction("CLICK", tuple()) self.ui_test.close_doc() + + def test_tdf137626(self): + doc = self.ui_test.load_file(get_url_for_data_file("tdf137626.xlsx")) + + xGridWin = self.xUITest.getTopFocusWindow().getChild("grid_window") + + xGridWin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "1", "ROW": "0"})) + xFloatWindow = self.xUITest.getFloatWindow() + xCheckListMenu = xFloatWindow.getChild("check_list_menu") + xTreeList = xCheckListMenu.getChild("check_list_box") + self.assertEqual(3, len(xTreeList.getChildren())) + xOkBtn = xFloatWindow.getChild("cancel") + xOkBtn.executeAction("CLICK", tuple()) + + self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/data/autofilter/tdf137626.xlsx b/sc/qa/uitest/data/autofilter/tdf137626.xlsx Binary files differnew file mode 100644 index 000000000000..eb5ce4da7b98 --- /dev/null +++ b/sc/qa/uitest/data/autofilter/tdf137626.xlsx diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx index 0f4f3d8e76ab..d8f5c0a4224f 100644 --- a/sc/source/core/data/column3.cxx +++ b/sc/source/core/data/column3.cxx @@ -2470,6 +2470,14 @@ class FilterEntriesHandler sal_uInt32 nIndex = pFormatter->GetFormatIndex( NF_DATE_DIN_YYYYMMDD); pFormatter->GetInputLineString( fVal, nIndex, aStr); } + else if (nType == SvNumFormatType::DATETIME) + { + // special case for datetime values. + // Convert string representation to ISO 8601 (with blank instead of T) datetime + // to eliminate locale dependent behaviour later when filtering for datetimes. + sal_uInt32 nIndex = pFormatter->GetFormatIndex(NF_DATETIME_ISO_YYYYMMDD_HHMMSS); + pFormatter->GetInputLineString(fVal, nIndex, aStr); + } // maybe extend ScTypedStrData enum is also an option here mrFilterEntries.push_back(ScTypedStrData(aStr, fVal, ScTypedStrData::Value,bDate)); } diff --git a/sc/source/filter/oox/autofilterbuffer.cxx b/sc/source/filter/oox/autofilterbuffer.cxx index f8a860e27f80..0e5807a5cc32 100644 --- a/sc/source/filter/oox/autofilterbuffer.cxx +++ b/sc/source/filter/oox/autofilterbuffer.cxx @@ -240,23 +240,50 @@ void DiscreteFilter::importAttribs( sal_Int32 nElement, const AttributeList& rAt // it is just a fallback, we do not need the XML_day as default value, // because if the dateGroupItem exists also XML_dateTimeGrouping exists! sal_uInt16 nToken = rAttribs.getToken(XML_dateTimeGrouping, XML_day); - if( nToken == XML_year || nToken == XML_month || nToken == XML_day ) + if( nToken == XML_year || nToken == XML_month || nToken == XML_day || + nToken == XML_hour || nToken == XML_min || nToken == XML_second ) { aDateValue = rAttribs.getString(XML_year, OUString()); - if( nToken == XML_month || nToken == XML_day ) + if( nToken == XML_month || nToken == XML_day || nToken == XML_hour || + nToken == XML_min || nToken == XML_second ) { OUString aMonthName = rAttribs.getString(XML_month, OUString()); if( aMonthName.getLength() == 1 ) aMonthName = "0" + aMonthName; aDateValue += "-" + aMonthName; - if( nToken == XML_day ) + if( nToken == XML_day || nToken == XML_hour || nToken == XML_min || + nToken == XML_second ) { OUString aDayName = rAttribs.getString(XML_day, OUString()); if( aDayName.getLength() == 1 ) aDayName = "0" + aDayName; aDateValue += "-" + aDayName; + + if( nToken == XML_hour || nToken == XML_min || nToken == XML_second ) + { + OUString aHourName = rAttribs.getString(XML_hour, OUString()); + if( aHourName.getLength() == 1 ) + aHourName = "0" + aHourName; + aDateValue += " " + aHourName; + + if( nToken == XML_min || nToken == XML_second ) + { + OUString aMinName = rAttribs.getString(XML_min, OUString()); + if( aMinName.getLength() == 1 ) + aMinName = "0" + aMinName; + aDateValue += ":" + aMinName; + + if( nToken == XML_second ) + { + OUString aSecName = rAttribs.getString(XML_second, OUString()); + if( aSecName.getLength() == 1 ) + aSecName = "0" + aSecName; + aDateValue += ":" + aSecName; + } + } + } } } } diff --git a/sc/source/ui/unoobj/datauno.cxx b/sc/source/ui/unoobj/datauno.cxx index e20141e00eed..d502f2f65a63 100644 --- a/sc/source/ui/unoobj/datauno.cxx +++ b/sc/source/ui/unoobj/datauno.cxx @@ -1134,8 +1134,9 @@ void fillQueryParam( aItem.maString = rPool.intern(aStr); } - // filter all dates starting with the given date filter YYYY or YYYY-MM - if( aItem.meType == ScQueryEntry::ByDate && aItem.maString.getLength() < 10 ) + // filter all dates starting with the given date filter YYYY or YYYY-MM and filter all datetimes + // starting with the given datetime filter YYYY-MM-DD, YYYY-MM-DD HH, or YYYY-MM-DD HH:MM + if( aItem.meType == ScQueryEntry::ByDate && aItem.maString.getLength() < 19 ) { ScFilterEntries aFilterEntries; pDoc->GetFilterEntries(rEntry.nField, rParam.nRow1, rParam.nTab, aFilterEntries); |