diff options
author | Dennis Francis <dennis.francis@collabora.co.uk> | 2017-12-15 13:04:18 +0530 |
---|---|---|
committer | Michael Meeks <michael.meeks@collabora.com> | 2017-12-19 14:08:49 +0100 |
commit | ced2f083483e2d60c077177b8a359d310e0976c3 (patch) | |
tree | cd59e55655b46ba1310b605c605a808da59a2bf2 | |
parent | 748627dc7e88a0ec375f4e103906929cf99eb676 (diff) |
tdf#114479 : Use the SvNumberFormatter from ScInterpreterContext
This fixes one of the crash mentioned in the bug report, during
loading of the bug document. The crash being the assert failure
in ScDocument::GetFormatTable().
Change-Id: Iffb8ede1416f34f0cd9852fa3f8d1f199406c013
Reviewed-on: https://gerrit.libreoffice.org/46549
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
-rw-r--r-- | sc/inc/table.hxx | 2 | ||||
-rw-r--r-- | sc/source/core/data/dociter.cxx | 3 | ||||
-rw-r--r-- | sc/source/core/data/table3.cxx | 25 |
3 files changed, 19 insertions, 11 deletions
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx index 0f6c10621b9b..9cd2342ce103 100644 --- a/sc/inc/table.hxx +++ b/sc/inc/table.hxx @@ -926,7 +926,7 @@ public: bool ValidQuery( SCROW nRow, const ScQueryParam& rQueryParam, const ScRefCellValue* pCell = nullptr, - bool* pbTestEqualCondition = nullptr); + bool* pbTestEqualCondition = nullptr, const ScInterpreterContext* pContext = nullptr); void TopTenQuery( ScQueryParam& ); SCSIZE Query(const ScQueryParam& rQueryParam, bool bKeepSub); bool CreateQueryParam(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ScQueryParam& rQueryParam); diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx index 02e7b776ceef..13abb17a9fc4 100644 --- a/sc/source/core/data/dociter.cxx +++ b/sc/source/core/data/dociter.cxx @@ -1184,7 +1184,8 @@ bool ScQueryCellIterator::GetThis() bool bTestEqualCondition = false; if ( pDoc->maTabs[nTab]->ValidQuery( nRow, *mpParam, (nCol == static_cast<SCCOL>(nFirstQueryField) ? &aCell : nullptr), - (nTestEqualCondition ? &bTestEqualCondition : nullptr) ) ) + (nTestEqualCondition ? &bTestEqualCondition : nullptr), + &mrContext) ) { if ( nTestEqualCondition && bTestEqualCondition ) nTestEqualCondition |= nTestEqualConditionMatched; diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx index a562093cfdd6..b973dd8fd6bc 100644 --- a/sc/source/core/data/table3.cxx +++ b/sc/source/core/data/table3.cxx @@ -2362,7 +2362,8 @@ public: std::pair<bool,bool> compareByValue( const ScRefCellValue& rCell, SCCOL nCol, SCROW nRow, - const ScQueryEntry& rEntry, const ScQueryEntry::Item& rItem) + const ScQueryEntry& rEntry, const ScQueryEntry::Item& rItem, + const ScInterpreterContext* pContext = nullptr) { bool bOk = false; bool bTestEqual = false; @@ -2393,8 +2394,10 @@ public: * stripped here. */ if (rItem.meType == ScQueryEntry::ByDate) { - sal_uInt32 nNumFmt = mrTab.GetNumberFormat(nCol, nRow); - const SvNumberformat* pEntry = mrDoc.GetFormatTable()->GetEntry(nNumFmt); + sal_uInt32 nNumFmt = pContext ? mrTab.GetNumberFormat(*pContext, ScAddress(nCol, nRow, mrTab.GetTab())) : + mrTab.GetNumberFormat(nCol, nRow); + SvNumberFormatter* pFormatter = pContext ? pContext->mpFormatter : mrDoc.GetFormatTable(); + const SvNumberformat* pEntry = pFormatter->GetEntry(nNumFmt); if (pEntry) { short nNumFmtType = pEntry->GetType(); @@ -2447,7 +2450,8 @@ public: } std::pair<bool,bool> compareByString( - ScRefCellValue& rCell, SCROW nRow, const ScQueryEntry& rEntry, const ScQueryEntry::Item& rItem) + ScRefCellValue& rCell, SCROW nRow, const ScQueryEntry& rEntry, const ScQueryEntry::Item& rItem, + const ScInterpreterContext* pContext = nullptr) { bool bOk = false; bool bTestEqual = false; @@ -2468,9 +2472,11 @@ public: aCellStr = *rCell.mpString; else { - sal_uInt32 nFormat = mrTab.GetNumberFormat( static_cast<SCCOL>(rEntry.nField), nRow ); + sal_uInt32 nFormat = pContext ? mrTab.GetNumberFormat( *pContext, ScAddress(static_cast<SCCOL>(rEntry.nField), nRow, mrTab.GetTab()) ) : + mrTab.GetNumberFormat( static_cast<SCCOL>(rEntry.nField), nRow ); OUString aStr; - ScCellFormat::GetInputString(rCell, nFormat, aStr, *mrDoc.GetFormatTable(), &mrDoc); + SvNumberFormatter* pFormatter = pContext ? pContext->mpFormatter : mrDoc.GetFormatTable(); + ScCellFormat::GetInputString(rCell, nFormat, aStr, *pFormatter, &mrDoc); aCellStr = mrStrPool.intern(aStr); } } @@ -2678,7 +2684,8 @@ public: } bool ScTable::ValidQuery( - SCROW nRow, const ScQueryParam& rParam, const ScRefCellValue* pCell, bool* pbTestEqualCondition) + SCROW nRow, const ScQueryParam& rParam, const ScRefCellValue* pCell, bool* pbTestEqualCondition, + const ScInterpreterContext* pContext) { if (!rParam.GetEntry(0).bDoQuery) return true; @@ -2726,14 +2733,14 @@ bool ScTable::ValidQuery( if (aEval.isQueryByValue(*itr, nCol, nRow, aCell)) { std::pair<bool,bool> aThisRes = - aEval.compareByValue(aCell, nCol, nRow, rEntry, *itr); + aEval.compareByValue(aCell, nCol, nRow, rEntry, *itr, pContext); aRes.first |= aThisRes.first; aRes.second |= aThisRes.second; } else if (aEval.isQueryByString(rEntry, *itr, nCol, nRow, aCell)) { std::pair<bool,bool> aThisRes = - aEval.compareByString(aCell, nRow, rEntry, *itr); + aEval.compareByString(aCell, nRow, rEntry, *itr, pContext); aRes.first |= aThisRes.first; aRes.second |= aThisRes.second; } |