[Libreoffice-commits] core.git: Branch 'libreoffice-6-0' - sc/inc sc/source

Dennis Francis dennis.francis at collabora.co.uk
Tue Dec 19 14:58:48 UTC 2017


 sc/inc/table.hxx                |    2 +-
 sc/source/core/data/dociter.cxx |    3 ++-
 sc/source/core/data/table3.cxx  |   25 ++++++++++++++++---------
 3 files changed, 19 insertions(+), 11 deletions(-)

New commits:
commit 7a4bbce22fff8155825447eb0e28c5b09d659fcc
Author: Dennis Francis <dennis.francis at collabora.co.uk>
Date:   Fri Dec 15 13:04:18 2017 +0530

    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 at libreoffice.org>
    Reviewed-by: Michael Meeks <michael.meeks at collabora.com>
    (cherry picked from commit ced2f083483e2d60c077177b8a359d310e0976c3)
    Reviewed-on: https://gerrit.libreoffice.org/46792

diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index 3721e2226a5a..2ec2cd87e892 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -924,7 +924,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;
                 }


More information about the Libreoffice-commits mailing list