sc/inc/column.hxx                |    2 +-
 sc/inc/compiler.hxx              |    1 +
 sc/inc/document.hxx              |    6 ++++--
 sc/inc/table.hxx                 |    3 ++-
 sc/source/core/data/column3.cxx  |    7 ++++---
 sc/source/core/data/document.cxx |    8 ++++----
 sc/source/core/data/table2.cxx   |    4 ++--
 sc/source/core/tool/compiler.cxx |    8 ++++++--
 8 files changed, 24 insertions(+), 15 deletions(-)

New commits:
commit 4d37e0d5dd22343a3b7942649f460db544ae536c
Author: Luboš Luňák <l.lu...@collabora.com>
Date:   Tue Jun 26 17:07:45 2018 +0200

    use optional ScInterpreterContext in ScColumn::GetString()
    
    Otherwise calc's threading asserts with fdo#37765-1.
    
    Change-Id: Ic2500f2218bf62c4d05f1c5284e62a53c0598b53
    Reviewed-on: https://gerrit.libreoffice.org/56484
    Tested-by: Jenkins
    Reviewed-by: Luboš Luňák <l.lu...@collabora.com>

diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 5da349006538..93d5384dfcc0 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -357,7 +357,7 @@ public:
     void SetValue( sc::ColumnBlockPosition& rBlockPos, SCROW nRow, double 
fVal, bool bBroadcast = true );
     void        SetError( SCROW nRow, const FormulaError nError);
 
-    void        GetString( SCROW nRow, OUString& rString ) const;
+    void        GetString( SCROW nRow, OUString& rString, const 
ScInterpreterContext* pContext = nullptr ) const;
     double* GetValueCell( SCROW nRow );
     void        GetInputString( SCROW nRow, OUString& rString ) const;
     double      GetValue( SCROW nRow ) const;
diff --git a/sc/inc/compiler.hxx b/sc/inc/compiler.hxx
index 767d08b36e62..2b10a67ef3ab 100644
--- a/sc/inc/compiler.hxx
+++ b/sc/inc/compiler.hxx
@@ -269,6 +269,7 @@ private:
     ScAddress   aPos;
 
     SvNumberFormatter* mpFormatter;
+    const ScInterpreterContext* mpInterpreterContext;
 
     SCTAB       mnCurrentSheetTab;      // indicates current sheet number 
parsed so far
     sal_Int32   mnCurrentSheetEndPos;   // position after current sheet name 
if parsed
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 8ac5166c6aa3..4d106792c290 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -1088,8 +1088,10 @@ public:
                                     SCCOL nCol1, SCROW nRow1,
                                     SCCOL nCol2, SCROW nRow2, const 
ScMarkData& rMark);
 
-    SC_DLLPUBLIC OUString GetString( SCCOL nCol, SCROW nRow, SCTAB nTab ) 
const;
-    SC_DLLPUBLIC OUString GetString( const ScAddress& rPos ) const;
+    SC_DLLPUBLIC OUString GetString( SCCOL nCol, SCROW nRow, SCTAB nTab,
+                                     const ScInterpreterContext* pContext = 
nullptr ) const;
+    SC_DLLPUBLIC OUString GetString( const ScAddress& rPos,
+                                     const ScInterpreterContext* pContext = 
nullptr ) const;
 
     /**
      * Return a pointer to the double value stored in value cell.
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index a0978122ca88..2065ce2b130f 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -434,7 +434,8 @@ public:
     bool        ReservePatternCount( SCCOL nCol, SCSIZE nReserve );
 
     void        SetRawString( SCCOL nCol, SCROW nRow, const svl::SharedString& 
rStr );
-    void        GetString( SCCOL nCol, SCROW nRow, OUString& rString ) const;
+    void        GetString( SCCOL nCol, SCROW nRow, OUString& rString,
+                           const ScInterpreterContext* pContext = nullptr ) 
const;
     double*     GetValueCell( SCCOL nCol, SCROW nRow );
     void        GetInputString( SCCOL nCol, SCROW nRow, OUString& rString ) 
const;
     double      GetValue( SCCOL nCol, SCROW nRow ) const;
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index 3b5c11fb5c8d..5ef13e7a951a 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -2558,7 +2558,7 @@ void ScColumn::SetValue(
         BroadcastNewCell(nRow);
 }
 
-void ScColumn::GetString( SCROW nRow, OUString& rString ) const
+void ScColumn::GetString( SCROW nRow, OUString& rString, const 
ScInterpreterContext* pContext ) const
 {
     ScRefCellValue aCell = GetCellValue(nRow);
 
@@ -2566,9 +2566,10 @@ void ScColumn::GetString( SCROW nRow, OUString& rString 
) const
     if (aCell.meType == CELLTYPE_FORMULA)
         aCell.mpFormula->MaybeInterpret();
 
-    sal_uInt32 nFormat = GetNumberFormat(GetDoc()->GetNonThreadedContext(), 
nRow);
+    sal_uInt32 nFormat = GetNumberFormat( pContext ? *pContext : 
GetDoc()->GetNonThreadedContext(), nRow);
     Color* pColor = nullptr;
-    ScCellFormat::GetString(aCell, nFormat, rString, &pColor, 
*(GetDoc()->GetFormatTable()), GetDoc());
+    ScCellFormat::GetString(aCell, nFormat, rString, &pColor,
+        pContext ? *(pContext->GetFormatTable()) : 
*(GetDoc()->GetFormatTable()), GetDoc());
 }
 
 double* ScColumn::GetValueCell( SCROW nRow )
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 3f0886805fdc..9f10b761ffed 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -3498,25 +3498,25 @@ void ScDocument::SetValue( const ScAddress& rPos, 
double fVal )
     }
 }
 
-OUString ScDocument::GetString( SCCOL nCol, SCROW nRow, SCTAB nTab ) const
+OUString ScDocument::GetString( SCCOL nCol, SCROW nRow, SCTAB nTab, const 
ScInterpreterContext* pContext ) const
 {
     if (TableExists(nTab))
     {
         OUString aStr;
-        maTabs[nTab]->GetString(nCol, nRow, aStr);
+        maTabs[nTab]->GetString(nCol, nRow, aStr, pContext);
         return aStr;
     }
     else
         return EMPTY_OUSTRING;
 }
 
-OUString ScDocument::GetString( const ScAddress& rPos ) const
+OUString ScDocument::GetString( const ScAddress& rPos, const 
ScInterpreterContext* pContext ) const
 {
     if (!TableExists(rPos.Tab()))
         return EMPTY_OUSTRING;
 
     OUString aStr;
-    maTabs[rPos.Tab()]->GetString(rPos.Col(), rPos.Row(), aStr);
+    maTabs[rPos.Tab()]->GetString(rPos.Col(), rPos.Row(), aStr, pContext);
     return aStr;
 }
 
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index c6c88e44a9b7..fe8b69035ad6 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -1524,10 +1524,10 @@ void ScTable::SetRawString( SCCOL nCol, SCROW nRow, 
const svl::SharedString& rSt
         aCol[nCol].SetRawString(nRow, rStr);
 }
 
-void ScTable::GetString( SCCOL nCol, SCROW nRow, OUString& rString ) const
+void ScTable::GetString( SCCOL nCol, SCROW nRow, OUString& rString, const 
ScInterpreterContext* pContext ) const
 {
     if (ValidColRow(nCol,nRow))
-        aCol[nCol].GetString( nRow, rString );
+        aCol[nCol].GetString( nRow, rString, pContext );
     else
         rString.clear();
 }
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index d8a68b50fb43..cab029d5e78b 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -1738,6 +1738,7 @@ ScCompiler::ScCompiler( sc::CompileFormulaContext& rCxt, 
const ScAddress& rPos,
     pDoc(rCxt.getDoc()),
     aPos(rPos),
     mpFormatter(pContext? pContext->GetFormatTable() : pDoc->GetFormatTable()),
+    mpInterpreterContext(pContext),
     mnCurrentSheetTab(-1),
     mnCurrentSheetEndPos(0),
     pCharClass(ScGlobal::pCharClass),
@@ -1759,6 +1760,7 @@ ScCompiler::ScCompiler( ScDocument* pDocument, const 
ScAddress& rPos, ScTokenArr
         pDoc( pDocument ),
         aPos( rPos ),
         mpFormatter(pContext ? pContext->GetFormatTable() : 
pDoc->GetFormatTable()),
+        mpInterpreterContext(pContext),
         mnCurrentSheetTab(-1),
         mnCurrentSheetEndPos(0),
         nSrcPos(0),
@@ -1781,6 +1783,7 @@ ScCompiler::ScCompiler( sc::CompileFormulaContext& rCxt, 
const ScAddress& rPos,
     pDoc(rCxt.getDoc()),
     aPos(rPos),
     mpFormatter(pContext ? pContext->GetFormatTable() : pDoc ? 
pDoc->GetFormatTable() : nullptr),
+    mpInterpreterContext(pContext),
     mnCurrentSheetTab(-1),
     mnCurrentSheetEndPos(0),
     pCharClass(ScGlobal::pCharClass),
@@ -1802,6 +1805,7 @@ ScCompiler::ScCompiler( ScDocument* pDocument, const 
ScAddress& rPos,
         pDoc( pDocument ),
         aPos( rPos ),
         mpFormatter(pContext ? pContext->GetFormatTable() : pDoc ? 
pDoc->GetFormatTable() : nullptr),
+        mpInterpreterContext(pContext),
         mnCurrentSheetTab(-1),
         mnCurrentSheetEndPos(0),
         nSrcPos(0),
@@ -5043,7 +5047,7 @@ void ScCompiler::CreateStringFromSingleRef( 
OUStringBuffer& rBuffer, const Formu
         ScAddress aAbs = rRef.toAbs(aPos);
         if (pDoc->HasStringData(aAbs.Col(), aAbs.Row(), aAbs.Tab()))
         {
-            OUString aStr = pDoc->GetString(aAbs);
+            OUString aStr = pDoc->GetString(aAbs, mpInterpreterContext);
             EnQuote( aStr );
             rBuffer.append(aStr);
         }
@@ -5069,7 +5073,7 @@ void ScCompiler::CreateStringFromSingleRef( 
OUStringBuffer& rBuffer, const Formu
             {
                 SAL_WARN("sc.core", "ScCompiler::CreateStringFromSingleRef - 
TableRef falling back to cell: " <<
                         aAbs.Format( ScRefFlags::VALID | ScRefFlags::TAB_3D, 
pDoc));
-                aStr = pDoc->GetString(aAbs);
+                aStr = pDoc->GetString(aAbs, mpInterpreterContext);
             }
             else
             {
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to