diff options
-rw-r--r-- | sc/source/core/data/table3.cxx | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx index 5bf37f7d62c4..afe21d794e5a 100644 --- a/sc/source/core/data/table3.cxx +++ b/sc/source/core/data/table3.cxx @@ -2839,26 +2839,15 @@ public: void operator() (ScQueryEntry::Item& rItem) { - if (rItem.meType != ScQueryEntry::ByString && rItem.meType != ScQueryEntry::ByDate) + // Double-check if the query by date is really appropriate. + + if (rItem.meType != ScQueryEntry::ByDate) return; sal_uInt32 nIndex = 0; bool bNumber = mrDoc.GetFormatTable()-> IsNumberFormat(rItem.maString.getString(), nIndex, rItem.mfVal); - // Advanced Filter creates only ByString queries that need to be - // converted to ByValue if appropriate. rItem.mfVal now holds the value - // if bNumber==true. - - if (rItem.meType == ScQueryEntry::ByString) - { - if (bNumber) - rItem.meType = ScQueryEntry::ByValue; - return; - } - - // Double-check if the query by date is really appropriate. - if (bNumber && ((nIndex % SV_COUNTRY_LANGUAGE_OFFSET) != 0)) { const SvNumberformat* pEntry = mrDoc.GetFormatTable()->GetEntry(nIndex); @@ -3223,12 +3212,22 @@ bool ScTable::CreateQueryParam(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow if (!bValid) bValid = CreateExcelQuery(nCol1, nRow1, nCol2, nRow2, rQueryParam); + SvNumberFormatter* pFormatter = pDocument->GetFormatTable(); nCount = rQueryParam.GetEntryCount(); + if (bValid) { // bQueryByString must be set for (i=0; i < nCount; i++) - rQueryParam.GetEntry(i).GetQueryItem().meType = ScQueryEntry::ByString; + { + ScQueryEntry::Item& rItem = rQueryParam.GetEntry(i).GetQueryItem(); + + sal_uInt32 nIndex = 0; + bool bNumber = pFormatter->IsNumberFormat( + rItem.maString.getString(), nIndex, rItem.mfVal); + + rItem.meType = bNumber ? ScQueryEntry::ByValue : ScQueryEntry::ByString; + } } else { |