[Libreoffice-commits] core.git: sc/inc sc/qa sc/source
Balazs Varga (via logerrit)
logerrit at kemper.freedesktop.org
Mon Mar 1 15:39:48 UTC 2021
sc/inc/document.hxx | 1
sc/inc/table.hxx | 1
sc/qa/uitest/autofilter/autofilter.py | 31 +++++++++++++++++++++++++++++
sc/qa/uitest/data/autofilter/tdf140462.ods |binary
sc/source/core/data/documen3.cxx | 11 ++++++++++
sc/source/core/data/table3.cxx | 24 +++++++++++++++++-----
sc/source/filter/xml/xmldrani.cxx | 2 +
7 files changed, 65 insertions(+), 5 deletions(-)
New commits:
commit f37f159f2e0c7abe45ac7a3eec447f1234ad1662
Author: Balazs Varga <balazs.varga991 at gmail.com>
AuthorDate: Wed Feb 17 15:20:34 2021 +0100
Commit: László Németh <nemeth at numbertext.org>
CommitDate: Mon Mar 1 16:39:10 2021 +0100
tdf#140462 sc ODF import: fix empty autofilter columns
(followed a date type autofilter column) by setting
QueryType to ByDate at ODF import.
Change-Id: Ie78cb15885dfb1e40c9e8ac993ff79b19fe17993
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111070
Tested-by: László Németh <nemeth at numbertext.org>
Reviewed-by: László Németh <nemeth at numbertext.org>
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index ae66e0a0fb8e..111956304334 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -2063,6 +2063,7 @@ public:
void Reorder( const sc::ReorderParam& rParam );
+ void PrepareQuery( SCTAB nTab, ScQueryParam& rQueryParam );
SCSIZE Query( SCTAB nTab, const ScQueryParam& rQueryParam, bool bKeepSub );
SC_DLLPUBLIC bool CreateQueryParam( const ScRange& rRange, ScQueryParam& rQueryParam );
void GetUpperCellString(SCCOL nCol, SCROW nRow, SCTAB nTab, OUString& rStr);
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index fed4d4b12388..9e8e6233295a 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -949,6 +949,7 @@ public:
bool* pbTestEqualCondition = nullptr, const ScInterpreterContext* pContext = nullptr,
sc::TableColumnBlockPositionSet* pBlockPos = nullptr );
void TopTenQuery( ScQueryParam& );
+ void PrepareQuery( ScQueryParam& rQueryParam );
SCSIZE Query(const ScQueryParam& rQueryParam, bool bKeepSub);
bool CreateQueryParam(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ScQueryParam& rQueryParam);
diff --git a/sc/qa/uitest/autofilter/autofilter.py b/sc/qa/uitest/autofilter/autofilter.py
index 1eedfe4b22a7..ca1871ee933c 100644
--- a/sc/qa/uitest/autofilter/autofilter.py
+++ b/sc/qa/uitest/autofilter/autofilter.py
@@ -277,5 +277,36 @@ class AutofilterTest(UITestCase):
xOkBtn = xFloatWindow.getChild("cancel")
xOkBtn.executeAction("CLICK", tuple())
+ self.ui_test.close_doc()
+
+ def test_tdf140462(self):
+ doc = self.ui_test.load_file(get_url_for_data_file("tdf140462.ods"))
+
+ xGridWin = self.xUITest.getTopFocusWindow().getChild("grid_window")
+
+ xGridWin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "0", "ROW": "0"}))
+ xFloatWindow = self.xUITest.getFloatWindow()
+ xCheckListMenu = xFloatWindow.getChild("check_list_menu")
+ xTreeList = xCheckListMenu.getChild("check_tree_box")
+ self.assertEqual(3, len(xTreeList.getChildren()))
+ xOkBtn = xFloatWindow.getChild("cancel")
+ xOkBtn.executeAction("CLICK", tuple())
+
+ 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())
+
+ xGridWin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "2", "ROW": "0"}))
+ xFloatWindow = self.xUITest.getFloatWindow()
+ xCheckListMenu = xFloatWindow.getChild("check_list_menu")
+ xTreeList = xCheckListMenu.getChild("check_list_box")
+ self.assertEqual(4, 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/tdf140462.ods b/sc/qa/uitest/data/autofilter/tdf140462.ods
new file mode 100644
index 000000000000..8fe7ed8a9705
Binary files /dev/null and b/sc/qa/uitest/data/autofilter/tdf140462.ods differ
diff --git a/sc/source/core/data/documen3.cxx b/sc/source/core/data/documen3.cxx
index b7ece0dfbc0a..f7dfad201bd2 100644
--- a/sc/source/core/data/documen3.cxx
+++ b/sc/source/core/data/documen3.cxx
@@ -1442,6 +1442,17 @@ void ScDocument::Reorder( const sc::ReorderParam& rParam )
EnableIdle(bOldEnableIdle);
}
+void ScDocument::PrepareQuery( SCTAB nTab, ScQueryParam& rQueryParam )
+{
+ if( ValidTab(nTab) && nTab < static_cast<SCTAB>(maTabs.size()) && maTabs[nTab] )
+ maTabs[nTab]->PrepareQuery(rQueryParam);
+ else
+ {
+ OSL_FAIL("missing tab");
+ return;
+ }
+}
+
SCSIZE ScDocument::Query(SCTAB nTab, const ScQueryParam& rQueryParam, bool bKeepSub)
{
if ( ValidTab(nTab) && nTab < static_cast<SCTAB>(maTabs.size()) && maTabs[nTab] )
diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index b4967a9a31dd..fe2c2785d8f4 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -2978,7 +2978,7 @@ void ScTable::TopTenQuery( ScQueryParam& rParam )
namespace {
-bool CanOptimizeQueryStringToNumber( SvNumberFormatter* pFormatter, sal_uInt32 nFormatIndex )
+bool CanOptimizeQueryStringToNumber( SvNumberFormatter* pFormatter, sal_uInt32 nFormatIndex, bool& bDateFormat )
{
// tdf#105629: ScQueryEntry::ByValue queries are faster than ScQueryEntry::ByString.
// The problem with this optimization is that the autofilter dialog apparently converts
@@ -2994,6 +2994,10 @@ bool CanOptimizeQueryStringToNumber( SvNumberFormatter* pFormatter, sal_uInt32 n
case SvNumFormatType::FRACTION:
case SvNumFormatType::SCIENTIFIC:
return true;
+ case SvNumFormatType::DATE:
+ case SvNumFormatType::DATETIME:
+ bDateFormat = true;
+ break;
default:
break;
}
@@ -3022,9 +3026,11 @@ public:
if (rItem.meType == ScQueryEntry::ByString)
{
- if (bNumber && CanOptimizeQueryStringToNumber( mrDoc.GetFormatTable(), nIndex ))
+ bool bDateFormat = false;
+ if (bNumber && CanOptimizeQueryStringToNumber( mrDoc.GetFormatTable(), nIndex, bDateFormat ))
rItem.meType = ScQueryEntry::ByValue;
- return;
+ if (!bDateFormat)
+ return;
}
// Double-check if the query by date is really appropriate.
@@ -3037,6 +3043,8 @@ public:
SvNumFormatType nNumFmtType = pEntry->GetType();
if (!(nNumFmtType & SvNumFormatType::DATE) || (nNumFmtType & SvNumFormatType::TIME))
rItem.meType = ScQueryEntry::ByValue; // not a date only
+ else
+ rItem.meType = ScQueryEntry::ByDate; // date only
}
else
rItem.meType = ScQueryEntry::ByValue; // what the ... not a date
@@ -3087,6 +3095,11 @@ void lcl_PrepareQuery( const ScDocument* pDoc, ScTable* pTab, ScQueryParam& rPar
}
+void ScTable::PrepareQuery( ScQueryParam& rQueryParam )
+{
+ lcl_PrepareQuery(&rDocument, this, rQueryParam);
+}
+
SCSIZE ScTable::Query(const ScQueryParam& rParamOrg, bool bKeepSub)
{
ScQueryParam aParam( rParamOrg );
@@ -3403,8 +3416,9 @@ bool ScTable::CreateQueryParam(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow
sal_uInt32 nIndex = 0;
bool bNumber = pFormatter->IsNumberFormat(
rItem.maString.getString(), nIndex, rItem.mfVal);
- rItem.meType = bNumber && CanOptimizeQueryStringToNumber( pFormatter, nIndex )
- ? ScQueryEntry::ByValue : ScQueryEntry::ByString;
+ bool bDateFormat = false;
+ rItem.meType = bNumber && CanOptimizeQueryStringToNumber( pFormatter, nIndex, bDateFormat )
+ ? ScQueryEntry::ByValue : (bDateFormat ? ScQueryEntry::ByDate : ScQueryEntry::ByString);
}
}
else
diff --git a/sc/source/filter/xml/xmldrani.cxx b/sc/source/filter/xml/xmldrani.cxx
index 422ea7f30421..756e874f91c7 100644
--- a/sc/source/filter/xml/xmldrani.cxx
+++ b/sc/source/filter/xml/xmldrani.cxx
@@ -254,6 +254,8 @@ std::unique_ptr<ScDBData> ScXMLDatabaseRangeContext::ConvertToDBData(const OUStr
pData->SetDoSize(bMoveCells);
pData->SetStripData(bStripData);
+ pDoc->PrepareQuery(mpQueryParam->nTab, *mpQueryParam);
+
pData->SetQueryParam(*mpQueryParam);
if (bFilterConditionSourceRange)
More information about the Libreoffice-commits
mailing list