[Libreoffice-commits] core.git: sc/inc sc/source

Luboš Luňák l.lunak at collabora.com
Fri Jun 22 15:01:07 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 e7792c4bf270d5a98ec5b8d2be2e25c11a8ecf02
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>

diff --git a/sc/inc/dociter.hxx b/sc/inc/dociter.hxx
index a702c392d738..5ceacf4a9b26 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;
@@ -52,6 +53,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;
@@ -92,6 +94,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 9b1598e17b80..a5d78bb20859 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