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

Luboš Luňák l.lunak at collabora.com
Mon Jun 25 13:38:54 UTC 2018


 sc/inc/dociter.hxx               |    4 ++++
 sc/source/core/data/dociter.cxx  |    9 +++++----
 sc/source/core/tool/interpr6.cxx |    1 +
 3 files changed, 10 insertions(+), 4 deletions(-)

New commits:
commit 0b77d890bcbc189ff12cf5dab683c6aed881c177
Author: Luboš Luňák <l.lunak at collabora.com>
Date:   Fri Jun 22 10:43:22 2018 +0200

    use ScInterpreterContext in ScValueIterator
    
    Otherwise GetFormatTable() asserts with fdo#74507-1 (and
    mnOpenCLMinimumFormulaGroupSize disabled).
    
    Change-Id: Ic624076bd552a2f8370f942063e8b79ca703d9fc
    Reviewed-on: https://gerrit.libreoffice.org/56288
    Reviewed-by: Luboš Luňák <l.lunak at collabora.com>
    Tested-by: Luboš Luňák <l.lunak at collabora.com>
    (cherry picked from commit e7792c4bf270d5a98ec5b8d2be2e25c11a8ecf02)
    Reviewed-on: https://gerrit.libreoffice.org/56373
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/sc/inc/dociter.hxx b/sc/inc/dociter.hxx
index ac76f7412a9a..18b9d7826c2a 100644
--- a/sc/inc/dociter.hxx
+++ b/sc/inc/dociter.hxx
@@ -37,6 +37,7 @@ class ScPatternAttr;
 class ScAttrArray;
 class ScAttrIterator;
 class ScFlatBoolRowSegments;
+struct ScInterpreterContext;
 class ScMatrix;
 struct ScDBQueryParamBase;
 struct ScQueryParam;
@@ -51,6 +52,7 @@ class ScValueIterator            // walk through all values in an area
     typedef sc::CellStoreType::const_position_type PositionType;
 
     ScDocument*     pDoc;
+    ScInterpreterContext* pContext;
     const ScAttrArray*  pAttrArray;
     sal_uInt32      nNumFormat;     // for CalcAsShown
     sal_uInt32      nNumFmtIndex;
@@ -91,6 +93,8 @@ public:
 
     /// Does NOT reset rValue if no value found!
     bool GetNext( double& rValue, FormulaError& rErr );
+
+    void SetInterpreterContext( ScInterpreterContext* context ) { pContext = context; }
 };
 
 class ScDBQueryDataIterator
diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx
index 374a4914d7b8..959ffd24610e 100644
--- a/sc/source/core/data/dociter.cxx
+++ b/sc/source/core/data/dociter.cxx
@@ -77,7 +77,7 @@ void decBlock(std::pair<Iter, size_t>& rPos)
 
 void ScAttrArray_IterGetNumberFormat( sal_uInt32& nFormat, const ScAttrArray*& rpArr,
         SCROW& nAttrEndRow, const ScAttrArray* pNewArr, SCROW nRow,
-        const ScDocument* pDoc )
+        const ScDocument* pDoc, ScInterpreterContext* pContext = nullptr )
 {
     if ( rpArr != pNewArr || nAttrEndRow < nRow )
     {
@@ -90,7 +90,7 @@ void ScAttrArray_IterGetNumberFormat( sal_uInt32& nFormat, const ScAttrArray*& r
             nRowEnd = MAXROW;
         }
 
-        nFormat = pPattern->GetNumberFormat( pDoc->GetFormatTable() );
+        nFormat = pPattern->GetNumberFormat( pContext ? pContext->GetFormatTable() : pDoc->GetFormatTable() );
         rpArr = pNewArr;
         nAttrEndRow = nRowEnd;
     }
@@ -99,6 +99,7 @@ void ScAttrArray_IterGetNumberFormat( sal_uInt32& nFormat, const ScAttrArray*& r
 ScValueIterator::ScValueIterator( ScDocument* pDocument, const ScRange& rRange,
             SubtotalFlags nSubTotalFlags, bool bTextZero )
     : pDoc(pDocument)
+    , pContext(nullptr)
     , pAttrArray(nullptr)
     , nNumFormat(0) // Initialized in GetNumberFormat
     , nNumFmtIndex(0)
@@ -205,8 +206,8 @@ bool ScValueIterator::GetThis(double& rValue, FormulaError& rErr)
                 if (bCalcAsShown)
                 {
                     ScAttrArray_IterGetNumberFormat(nNumFormat, pAttrArray,
-                        nAttrEndRow, pCol->pAttrArray.get(), nCurRow, pDoc);
-                    rValue = pDoc->RoundValueAsShown(rValue, nNumFormat);
+                        nAttrEndRow, pCol->pAttrArray.get(), nCurRow, pDoc, pContext);
+                    rValue = pDoc->RoundValueAsShown(rValue, nNumFormat, pContext);
                 }
                 return true; // Found it!
             }
diff --git a/sc/source/core/tool/interpr6.cxx b/sc/source/core/tool/interpr6.cxx
index c7554699bfa9..e1769e27b091 100644
--- a/sc/source/core/tool/interpr6.cxx
+++ b/sc/source/core/tool/interpr6.cxx
@@ -853,6 +853,7 @@ void ScInterpreter::IterateParameters( ScIterFunc eFunc, bool bTextAsZero )
                 else
                 {
                     ScValueIterator aValIter( pDok, aRange, mnSubTotalFlags, bTextAsZero );
+                    aValIter.SetInterpreterContext( &mrContext );
                     FormulaError nErr = FormulaError::NONE;
                     if (aValIter.GetFirst(fVal, nErr))
                     {


More information about the Libreoffice-commits mailing list