summaryrefslogtreecommitdiff
path: root/sc/source
diff options
context:
space:
mode:
authorDennis Francis <dennis.francis@collabora.co.uk>2017-12-15 13:04:18 +0530
committerMichael Meeks <michael.meeks@collabora.com>2017-12-19 15:55:28 +0100
commit7a4bbce22fff8155825447eb0e28c5b09d659fcc (patch)
treef46fe9e0e85a776a4b8c98f2426e50ef9a98adf8 /sc/source
parente63deefec4796d82059df5e7cc2cdfc5d072cb47 (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> (cherry picked from commit ced2f083483e2d60c077177b8a359d310e0976c3) Reviewed-on: https://gerrit.libreoffice.org/46792
Diffstat (limited to 'sc/source')
-rw-r--r--sc/source/core/data/dociter.cxx3
-rw-r--r--sc/source/core/data/table3.cxx25
2 files changed, 18 insertions, 10 deletions
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;
}