diff options
author | Balazs Varga <balazs.varga991@gmail.com> | 2021-02-17 15:20:34 +0100 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2021-03-01 16:39:10 +0100 |
commit | f37f159f2e0c7abe45ac7a3eec447f1234ad1662 (patch) | |
tree | 5fae50ec3efa6e25783cff95cce12257e102c0a4 /sc/source/core/data/table3.cxx | |
parent | 493a916a3113e877835c9bc7c93faef0d29f9a33 (diff) |
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@numbertext.org>
Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'sc/source/core/data/table3.cxx')
-rw-r--r-- | sc/source/core/data/table3.cxx | 24 |
1 files changed, 19 insertions, 5 deletions
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 |