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

Balazs Varga (via logerrit) logerrit at kemper.freedesktop.org
Thu Apr 29 06:48:13 UTC 2021


 sc/qa/uitest/autofilter/autofilter.py       |   15 ++++++++++++
 sc/qa/uitest/data/autofilter/tdf137626.xlsx |binary
 sc/source/core/data/column3.cxx             |    8 ++++++
 sc/source/filter/oox/autofilterbuffer.cxx   |   33 +++++++++++++++++++++++++---
 sc/source/ui/unoobj/datauno.cxx             |    5 ++--
 5 files changed, 56 insertions(+), 5 deletions(-)

New commits:
commit 2cc05be5213ccedb673f5e06278d65b0cdbe890b
Author:     Balazs Varga <balazs.varga991 at gmail.com>
AuthorDate: Tue Mar 2 22:46:33 2021 +0100
Commit:     Gabor Kelemen <kelemen.gabor2 at nisz.hu>
CommitDate: Thu Apr 29 08:47:17 2021 +0200

    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 at numbertext.org>
    Reviewed-by: László Németh <nemeth at numbertext.org>
    (cherry picked from commit 26032e63abd01c3d5941a2728ef024da290d6b0a)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114730
    Tested-by: Gabor Kelemen <kelemen.gabor2 at nisz.hu>
    Reviewed-by: Gabor Kelemen <kelemen.gabor2 at nisz.hu>

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
@@ -173,5 +173,20 @@ class AutofilterTest(UITestCase):
         xOkBtn = xFloatWindow.getChild("cancel")
         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
new file mode 100644
index 000000000000..eb5ce4da7b98
Binary files /dev/null and b/sc/qa/uitest/data/autofilter/tdf137626.xlsx differ
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);


More information about the Libreoffice-commits mailing list