sc/inc/formulacell.hxx              |    2 +-
 sc/source/core/data/clipcontext.cxx |    2 +-
 sc/source/core/data/column.cxx      |    2 +-
 sc/source/core/data/column3.cxx     |    6 +++---
 sc/source/core/data/conditio.cxx    |    4 ++--
 sc/source/core/data/formulacell.cxx |    6 +++---
 sc/source/filter/excel/impop.cxx    |    2 +-
 sc/source/filter/excel/xipivot.cxx  |    2 +-
 sc/source/filter/lotus/lotimpop.cxx |    2 +-
 sc/source/ui/unoobj/cellsuno.cxx    |    2 +-
 10 files changed, 15 insertions(+), 15 deletions(-)

New commits:
commit 399609c352b3f354e6857ae1beee6283018516e2
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Sun Sep 13 16:56:14 2020 +0100
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Sun Sep 13 22:12:13 2020 +0200

    ScFormulaCell ctor variant always dereferences its ScDocument arg
    
    Change-Id: Ibf626d52cc7a5968c60a3ec1ea2b34e0331b7ef2
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102589
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/sc/inc/formulacell.hxx b/sc/inc/formulacell.hxx
index 0f77f5aa72cf..d57dda491d11 100644
--- a/sc/inc/formulacell.hxx
+++ b/sc/inc/formulacell.hxx
@@ -178,7 +178,7 @@ public:
     ScFormulaCell* Clone() const;
     ScFormulaCell* Clone( const ScAddress& rPos ) const;
 
-    ScFormulaCell( ScDocument* pDoc, const ScAddress& rPos );
+    ScFormulaCell( ScDocument& rDoc, const ScAddress& rPos );
 
     /**
      * Transfer the ownership of the passed token array instance to the
diff --git a/sc/source/core/data/clipcontext.cxx 
b/sc/source/core/data/clipcontext.cxx
index d2733fad4517..f40b6f921898 100644
--- a/sc/source/core/data/clipcontext.cxx
+++ b/sc/source/core/data/clipcontext.cxx
@@ -216,7 +216,7 @@ void CopyFromClipContext::setSingleCell( const ScAddress& 
rSrcPos, const ScColum
                 else
                 {
                     // Turn this into a formula cell with just the error code.
-                    ScFormulaCell* pErrCell = new ScFormulaCell(mpClipDoc, 
rSrcPos);
+                    ScFormulaCell* pErrCell = new ScFormulaCell(*mpClipDoc, 
rSrcPos);
                     pErrCell->SetErrCode(nErr);
                     rSrcCell.set(pErrCell);
                 }
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index 31b1630e219f..f2f8374df0c8 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -1466,7 +1466,7 @@ class CopyByCloneHandler
             if (nErr != FormulaError::NONE)
             {
                 // error codes are cloned with values
-                ScFormulaCell* pErrCell = new 
ScFormulaCell(mrDestCol.GetDoc(), aDestPos);
+                ScFormulaCell* pErrCell = new 
ScFormulaCell(*mrDestCol.GetDoc(), aDestPos);
                 pErrCell->SetErrCode(nErr);
                 mrDestCol.SetFormulaCell(maDestPos, nRow, pErrCell, 
meListenType);
                 setDefaultAttrToDest(nRow);
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index cbd69dc2b5cd..f37ab25d2c51 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -1275,7 +1275,7 @@ public:
                                     insertRefCell(nSrcRow, nSrcRow + 
mnRowOffset);
                                 else
                                 {
-                                    ScFormulaCell* pErrCell = new 
ScFormulaCell(mrDestCol.GetDoc(), aDestPos);
+                                    ScFormulaCell* pErrCell = new 
ScFormulaCell(*mrDestCol.GetDoc(), aDestPos);
                                     pErrCell->SetErrCode(nErr);
                                     mrDestCol.SetFormulaCell(
                                         maDestBlockPos, nSrcRow + mnRowOffset, 
pErrCell);
@@ -1542,7 +1542,7 @@ class MixDataHandler
         {
             ScAddress aPos(mrDestColumn.GetCol(), nDestRow, 
mrDestColumn.GetTab());
 
-            ScFormulaCell* pFC = new ScFormulaCell(mrDestColumn.GetDoc(), 
aPos);
+            ScFormulaCell* pFC = new ScFormulaCell(*mrDestColumn.GetDoc(), 
aPos);
             pFC->SetErrCode(FormulaError::NoValue);
 
             miNewCellsPos = maNewCells.set(miNewCellsPos, 
nDestRow-mnRowOffset, pFC);
@@ -2811,7 +2811,7 @@ void ScColumn::SetError( SCROW nRow, const FormulaError 
nError)
     if (!GetDoc()->ValidRow(nRow))
         return;
 
-    ScFormulaCell* pCell = new ScFormulaCell(GetDoc(), ScAddress(nCol, nRow, 
nTab));
+    ScFormulaCell* pCell = new ScFormulaCell(*GetDoc(), ScAddress(nCol, nRow, 
nTab));
     pCell->SetErrCode(nError);
 
     std::vector<SCROW> aNewSharedRows;
diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx
index 975e232ca0dd..c981579a2104 100644
--- a/sc/source/core/data/conditio.cxx
+++ b/sc/source/core/data/conditio.cxx
@@ -650,7 +650,7 @@ void ScConditionEntry::Interpret( const ScAddress& rPos )
     ScFormulaCell* pEff1 = pFCell1.get();
     if ( bRelRef1 )
     {
-        pTemp1.reset(pFormula1 ? new ScFormulaCell(mpDoc, rPos, *pFormula1) : 
new ScFormulaCell(mpDoc, rPos));
+        pTemp1.reset(pFormula1 ? new ScFormulaCell(mpDoc, rPos, *pFormula1) : 
new ScFormulaCell(*mpDoc, rPos));
         pEff1 = pTemp1.get();
     }
     if ( pEff1 )
@@ -680,7 +680,7 @@ void ScConditionEntry::Interpret( const ScAddress& rPos )
     ScFormulaCell* pEff2 = pFCell2.get(); //@ 1!=2
     if ( bRelRef2 )
     {
-        pTemp2.reset(pFormula2 ? new ScFormulaCell(mpDoc, rPos, *pFormula2) : 
new ScFormulaCell(mpDoc, rPos));
+        pTemp2.reset(pFormula2 ? new ScFormulaCell(mpDoc, rPos, *pFormula2) : 
new ScFormulaCell(*mpDoc, rPos));
         pEff2 = pTemp2.get();
     }
     if ( pEff2 )
diff --git a/sc/source/core/data/formulacell.cxx 
b/sc/source/core/data/formulacell.cxx
index 107d0569b03c..b9886d3abda2 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -603,7 +603,7 @@ void ScFormulaCellGroup::endAllGroupListening( ScDocument& 
rDoc )
     mpImpl->m_AreaListeners.clear();
 }
 
-ScFormulaCell::ScFormulaCell( ScDocument* pDoc, const ScAddress& rPos ) :
+ScFormulaCell::ScFormulaCell( ScDocument& rDoc, const ScAddress& rPos ) :
     bDirty(false),
     bTableOpDirty(false),
     bChanged(false),
@@ -622,8 +622,8 @@ ScFormulaCell::ScFormulaCell( ScDocument* pDoc, const 
ScAddress& rPos ) :
     nSeenInIteration(0),
     nFormatType(SvNumFormatType::NUMBER),
     eTempGrammar(formula::FormulaGrammar::GRAM_DEFAULT),
-    pCode(new ScTokenArray(*pDoc)),
-    pDocument(pDoc),
+    pCode(new ScTokenArray(rDoc)),
+    pDocument(&rDoc),
     pPrevious(nullptr),
     pNext(nullptr),
     pPreviousTrack(nullptr),
diff --git a/sc/source/filter/excel/impop.cxx b/sc/source/filter/excel/impop.cxx
index e6d194dc513e..2f1cddf17a53 100644
--- a/sc/source/filter/excel/impop.cxx
+++ b/sc/source/filter/excel/impop.cxx
@@ -363,7 +363,7 @@ void ImportExcel::ReadBoolErr()
     std::unique_ptr<ScTokenArray> pScTokArr = ErrorToFormula( nType != 
EXC_BOOLERR_BOOL, nValue, fValue );
     ScFormulaCell* pCell = pScTokArr
         ? new ScFormulaCell(pD, aScPos, std::move(pScTokArr))
-        : new ScFormulaCell(pD, aScPos);
+        : new ScFormulaCell(*pD, aScPos);
     pCell->SetHybridDouble( fValue );
     GetDocImport().setFormulaCell(aScPos, pCell);
 }
diff --git a/sc/source/filter/excel/xipivot.cxx 
b/sc/source/filter/excel/xipivot.cxx
index 685a03b8997b..8d822d10daf6 100644
--- a/sc/source/filter/excel/xipivot.cxx
+++ b/sc/source/filter/excel/xipivot.cxx
@@ -121,7 +121,7 @@ void XclImpPCItem::WriteToSource( XclImpRoot& rRoot, const 
ScAddress& rScPos ) c
             XclTools::ErrorToEnum( fValue, true, nErrCode ) );
         ScFormulaCell* pCell = pScTokArr
             ? new ScFormulaCell(&rDoc.getDoc(), rScPos, std::move(pScTokArr))
-            : new ScFormulaCell(&rDoc.getDoc(), rScPos);
+            : new ScFormulaCell(rDoc.getDoc(), rScPos);
         pCell->SetHybridDouble( fValue );
         rDoc.setFormulaCell(rScPos, pCell);
     }
diff --git a/sc/source/filter/lotus/lotimpop.cxx 
b/sc/source/filter/lotus/lotimpop.cxx
index 69cea998aa91..00f64cfd596f 100644
--- a/sc/source/filter/lotus/lotimpop.cxx
+++ b/sc/source/filter/lotus/lotimpop.cxx
@@ -254,7 +254,7 @@ void ImportLotus::Formulacell( sal_uInt16 n )
     if (!aConv.good())
         return;
 
-    ScFormulaCell* pCell = pErg ? new ScFormulaCell(pD, aAddr, 
std::move(pErg)) : new ScFormulaCell(pD, aAddr);
+    ScFormulaCell* pCell = pErg ? new ScFormulaCell(pD, aAddr, 
std::move(pErg)) : new ScFormulaCell(*pD, aAddr);
     pCell->AddRecalcMode( ScRecalcMode::ONLOAD_ONCE );
     pD->EnsureTable(aAddr.Tab());
     pD->SetFormulaCell(aAddr, pCell);
diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx
index e1d90d36a14e..cb906b447aa5 100644
--- a/sc/source/ui/unoobj/cellsuno.cxx
+++ b/sc/source/ui/unoobj/cellsuno.cxx
@@ -6200,7 +6200,7 @@ void SAL_CALL ScCellObj::setFormulaString( const 
OUString& aFormula)
     ScDocShell *pDocSh = GetDocShell();
     if( pDocSh )
     {
-        ScFormulaCell* pCell = new ScFormulaCell( &pDocSh->GetDocument(), 
aCellPos );
+        ScFormulaCell* pCell = new ScFormulaCell( pDocSh->GetDocument(), 
aCellPos );
         pCell->SetHybridFormula( aFormula, 
formula::FormulaGrammar::GRAM_NATIVE );
         pDocSh->GetDocFunc().SetFormulaCell(aCellPos, pCell, false);
     }
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to