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 1f270b7e1c01396450c9fb518e324e2cf29e65ed Author: Balazs Varga <balazs.varga...@gmail.com> AuthorDate: Wed Feb 17 15:20:34 2021 +0100 Commit: Gabor Kelemen <kelemen.gab...@nisz.hu> CommitDate: Fri Apr 23 09:23:47 2021 +0200 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 <nem...@numbertext.org> Reviewed-by: László Németh <nem...@numbertext.org> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114500 Tested-by: Gabor Kelemen <kelemen.gab...@nisz.hu> Reviewed-by: Gabor Kelemen <kelemen.gab...@nisz.hu> diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx index e31d9fd1a0de..fa13d9bae60e 100644 --- a/sc/inc/document.hxx +++ b/sc/inc/document.hxx @@ -2058,6 +2058,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 7141f2652bfa..218c768ec241 100644 --- a/sc/inc/table.hxx +++ b/sc/inc/table.hxx @@ -945,6 +945,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 bf01911f62b4..149fa3400134 100644 --- a/sc/qa/uitest/autofilter/autofilter.py +++ b/sc/qa/uitest/autofilter/autofilter.py @@ -142,5 +142,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 25cf69d0d55d..125bbf82d7f2 100644 --- a/sc/source/core/data/documen3.cxx +++ b/sc/source/core/data/documen3.cxx @@ -1444,6 +1444,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 3ac587fe1580..0388467330c6 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 7e7a61d50f6a..b20b9ce44375 100644 --- a/sc/source/filter/xml/xmldrani.cxx +++ b/sc/source/filter/xml/xmldrani.cxx @@ -253,6 +253,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) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits