From be714ddd3048ab41d653c3fbd13c83079e44c198 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Mon, 14 Sep 2020 09:34:04 +0100 Subject: ScFormulaListener dtor always dereferences its ScDocument* member MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I7eb22d693fc61a8ce46bb14c4fc421e7d0454684 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102654 Tested-by: Jenkins Reviewed-by: Caolán McNamara --- sc/inc/conditio.hxx | 10 ++--- sc/inc/validat.hxx | 2 +- sc/qa/unit/subsequent_filters-test.cxx | 2 +- sc/qa/unit/ucalc_condformat.cxx | 58 +++++++++++++------------- sc/qa/unit/ucalc_formula.cxx | 2 +- sc/source/core/data/colorscale.cxx | 40 +++++++++--------- sc/source/core/data/conditio.cxx | 16 +++---- sc/source/core/data/validat.cxx | 6 +-- sc/source/filter/oox/extlstcontext.cxx | 2 +- sc/source/filter/xml/xmlcelli.cxx | 2 +- sc/source/filter/xml/xmlcondformat.cxx | 2 +- sc/source/filter/xml/xmlstyli.cxx | 2 +- sc/source/ui/condformat/condformatdlgentry.cxx | 4 +- sc/source/ui/unoobj/condformatuno.cxx | 12 +++--- sc/source/ui/unoobj/fmtuno.cxx | 4 +- sc/source/ui/view/cellsh2.cxx | 2 +- 16 files changed, 83 insertions(+), 83 deletions(-) diff --git a/sc/inc/conditio.hxx b/sc/inc/conditio.hxx index dce4563d0c90..cd49a361a324 100644 --- a/sc/inc/conditio.hxx +++ b/sc/inc/conditio.hxx @@ -184,7 +184,7 @@ class ScFormulaListener final : public SvtListener { private: mutable bool mbDirty; - ScDocument* mpDoc; + ScDocument& mrDoc; std::function maCallbackFunction; void startListening(const ScTokenArray* pTokens, const ScRange& rPos); @@ -192,8 +192,8 @@ private: public: explicit ScFormulaListener(ScFormulaCell* pCell); - explicit ScFormulaListener(ScDocument* pDoc); - explicit ScFormulaListener(ScDocument* pDoc, const ScRangeList& rRange); + explicit ScFormulaListener(ScDocument& rDoc); + explicit ScFormulaListener(ScDocument& rDoc, const ScRangeList& rRange); virtual ~ScFormulaListener() override; void Notify( const SfxHint& rHint ) override; @@ -348,7 +348,7 @@ class SC_DLLPUBLIC ScConditionEntry : public ScFormatEntry public: ScConditionEntry( ScConditionMode eOper, const OUString& rExpr1, const OUString& rExpr2, - ScDocument* pDocument, const ScAddress& rPos, + ScDocument& rDocument, const ScAddress& rPos, const OUString& rExprNmsp1, const OUString& rExprNmsp2, formula::FormulaGrammar::Grammar eGrammar1, formula::FormulaGrammar::Grammar eGrammar2, @@ -454,7 +454,7 @@ class SC_DLLPUBLIC ScCondFormatEntry final : public ScConditionEntry public: ScCondFormatEntry( ScConditionMode eOper, const OUString& rExpr1, const OUString& rExpr2, - ScDocument* pDocument, const ScAddress& rPos, + ScDocument& rDocument, const ScAddress& rPos, const OUString& rStyle, const OUString& rExprNmsp1 = EMPTY_OUSTRING, const OUString& rExprNmsp2 = EMPTY_OUSTRING, diff --git a/sc/inc/validat.hxx b/sc/inc/validat.hxx index d4e92bd9ce4e..36b3ee5a1584 100644 --- a/sc/inc/validat.hxx +++ b/sc/inc/validat.hxx @@ -83,7 +83,7 @@ private: public: ScValidationData( ScValidationMode eMode, ScConditionMode eOper, const OUString& rExpr1, const OUString& rExpr2, - ScDocument* pDocument, const ScAddress& rPos, + ScDocument& rDocument, const ScAddress& rPos, const OUString& rExprNmsp1 = EMPTY_OUSTRING, const OUString& rExprNmsp2 = EMPTY_OUSTRING, formula::FormulaGrammar::Grammar eGrammar1 = formula::FormulaGrammar::GRAM_DEFAULT, formula::FormulaGrammar::Grammar eGrammar2 = formula::FormulaGrammar::GRAM_DEFAULT ); diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx index 459f72ea95f6..81a222051835 100644 --- a/sc/qa/unit/subsequent_filters-test.cxx +++ b/sc/qa/unit/subsequent_filters-test.cxx @@ -1327,7 +1327,7 @@ void checkValiditationEntries( const ValDataTestParams& rVDTParams ) //create expected data validation entry ScValidationData aValData( rVDTParams.eValMode, rVDTParams.eCondOp, rVDTParams.aStrVal1, - rVDTParams.aStrVal2, &rDoc, rVDTParams.aPosition, EMPTY_OUSTRING, + rVDTParams.aStrVal2, rDoc, rVDTParams.aPosition, EMPTY_OUSTRING, EMPTY_OUSTRING, rDoc.GetStorageGrammar(), rDoc.GetStorageGrammar() ); aValData.SetIgnoreBlank( true ); diff --git a/sc/qa/unit/ucalc_condformat.cxx b/sc/qa/unit/ucalc_condformat.cxx index 3c9fcefee6d2..d6f32d13b7c4 100644 --- a/sc/qa/unit/ucalc_condformat.cxx +++ b/sc/qa/unit/ucalc_condformat.cxx @@ -101,7 +101,7 @@ void Test::testCondFormatINSDEL() auto pFormat = std::make_unique(1, m_pDoc); ScRangeList aRangeList(ScRange(0,0,0,0,3,0)); pFormat->SetRange(aRangeList); - ScCondFormatEntry* pEntry = new ScCondFormatEntry(ScConditionMode::Direct,"=B2","",m_pDoc,ScAddress(0,0,0),ScResId(STR_STYLENAME_RESULT)); + ScCondFormatEntry* pEntry = new ScCondFormatEntry(ScConditionMode::Direct,"=B2","",*m_pDoc,ScAddress(0,0,0),ScResId(STR_STYLENAME_RESULT)); pFormat->AddEntry(pEntry); m_pDoc->AddCondFormatData(pFormat->GetRange(), 0, 1); @@ -127,7 +127,7 @@ void Test::testCondFormatInsertCol() ScRangeList aRangeList(ScRange(0,0,0,3,3,0)); pFormat->SetRange(aRangeList); - ScCondFormatEntry* pEntry = new ScCondFormatEntry(ScConditionMode::Direct,"=B2","",m_pDoc,ScAddress(0,0,0),ScResId(STR_STYLENAME_RESULT)); + ScCondFormatEntry* pEntry = new ScCondFormatEntry(ScConditionMode::Direct,"=B2","",*m_pDoc,ScAddress(0,0,0),ScResId(STR_STYLENAME_RESULT)); pFormat->AddEntry(pEntry); m_pDoc->AddCondFormatData(pFormat->GetRange(), 0, 1); @@ -150,7 +150,7 @@ void Test::testCondFormatInsertRow() ScRangeList aRangeList(ScRange(0,0,0,3,3,0)); pFormat->SetRange(aRangeList); - ScCondFormatEntry* pEntry = new ScCondFormatEntry(ScConditionMode::Direct,"=B2","",m_pDoc,ScAddress(0,0,0),ScResId(STR_STYLENAME_RESULT)); + ScCondFormatEntry* pEntry = new ScCondFormatEntry(ScConditionMode::Direct,"=B2","",*m_pDoc,ScAddress(0,0,0),ScResId(STR_STYLENAME_RESULT)); pFormat->AddEntry(pEntry); m_pDoc->AddCondFormatData(pFormat->GetRange(), 0, 1); @@ -177,7 +177,7 @@ void Test::testCondFormatInsertDeleteSheets() // Add condition in which if the value equals 2, set the "Result" style. ScCondFormatEntry* pEntry = new ScCondFormatEntry( - ScConditionMode::Equal, "=2", "" , m_pDoc, ScAddress(0,0,0), ScResId(STR_STYLENAME_RESULT)); + ScConditionMode::Equal, "=2", "" , *m_pDoc, ScAddress(0,0,0), ScResId(STR_STYLENAME_RESULT)); pFormatTmp->AddEntry(pEntry); // Apply the format to the range. @@ -280,7 +280,7 @@ void Test::testCondCopyPaste() ScRangeList aRangeList(aCondFormatRange); pFormat->SetRange(aRangeList); - ScCondFormatEntry* pEntry = new ScCondFormatEntry(ScConditionMode::Direct,"=B2","",m_pDoc,ScAddress(0,0,0),ScResId(STR_STYLENAME_RESULT)); + ScCondFormatEntry* pEntry = new ScCondFormatEntry(ScConditionMode::Direct,"=B2","",*m_pDoc,ScAddress(0,0,0),ScResId(STR_STYLENAME_RESULT)); pFormat->AddEntry(pEntry); sal_uLong nIndex = m_pDoc->AddCondFormat(std::move(pFormat), 0); @@ -319,7 +319,7 @@ void Test::testCondCopyPasteSingleCell() ScRangeList aRangeList(aCondFormatRange); pFormat->SetRange(aRangeList); - ScCondFormatEntry* pEntry = new ScCondFormatEntry(ScConditionMode::Direct,"=B2","",m_pDoc,ScAddress(0,0,0),ScResId(STR_STYLENAME_RESULT)); + ScCondFormatEntry* pEntry = new ScCondFormatEntry(ScConditionMode::Direct,"=B2","",*m_pDoc,ScAddress(0,0,0),ScResId(STR_STYLENAME_RESULT)); pFormat->AddEntry(pEntry); sal_uLong nIndex = m_pDoc->AddCondFormat(std::move(pFormat), 0); @@ -358,7 +358,7 @@ void Test::testCondCopyPasteSingleCellToRange() ScRangeList aRangeList(aCondFormatRange); pFormat->SetRange(aRangeList); - ScCondFormatEntry* pEntry = new ScCondFormatEntry(ScConditionMode::Direct,"=B2","",m_pDoc,ScAddress(0,0,0),ScResId(STR_STYLENAME_RESULT)); + ScCondFormatEntry* pEntry = new ScCondFormatEntry(ScConditionMode::Direct,"=B2","",*m_pDoc,ScAddress(0,0,0),ScResId(STR_STYLENAME_RESULT)); pFormat->AddEntry(pEntry); sal_uLong nIndex = m_pDoc->AddCondFormat(std::move(pFormat), 0); @@ -403,7 +403,7 @@ void Test::testCondCopyPasteSingleCellIntoSameFormatRange() ScRangeList aRangeList(aCondFormatRange); pFormat->SetRange(aRangeList); - ScCondFormatEntry* pEntry = new ScCondFormatEntry(ScConditionMode::Direct, "=B2", "", m_pDoc, ScAddress(0, 0, 0), ScResId(STR_STYLENAME_RESULT)); + ScCondFormatEntry* pEntry = new ScCondFormatEntry(ScConditionMode::Direct, "=B2", "", *m_pDoc, ScAddress(0, 0, 0), ScResId(STR_STYLENAME_RESULT)); pFormat->AddEntry(pEntry); sal_uLong nIndex = m_pDoc->AddCondFormat(std::move(pFormat), 0); @@ -440,7 +440,7 @@ void Test::testCondCopyPasteSingleRowToRange() ScRangeList aRangeList(aCondFormatRange); pFormat->SetRange(aRangeList); - ScCondFormatEntry* pEntry = new ScCondFormatEntry(ScConditionMode::Direct,"=B2","",m_pDoc,ScAddress(0,0,0),ScResId(STR_STYLENAME_RESULT)); + ScCondFormatEntry* pEntry = new ScCondFormatEntry(ScConditionMode::Direct,"=B2","",*m_pDoc,ScAddress(0,0,0),ScResId(STR_STYLENAME_RESULT)); pFormat->AddEntry(pEntry); auto pFormatTmp = pFormat.get(); m_pDoc->AddCondFormat(std::move(pFormat), 0); @@ -472,7 +472,7 @@ void Test::testCondCopyPasteSingleRowToRange2() ScRangeList aRangeList(aCondFormatRange); pFormat->SetRange(aRangeList); - ScCondFormatEntry* pEntry = new ScCondFormatEntry(ScConditionMode::Direct,"=B2","",m_pDoc,ScAddress(0,0,0),ScResId(STR_STYLENAME_RESULT)); + ScCondFormatEntry* pEntry = new ScCondFormatEntry(ScConditionMode::Direct,"=B2","",*m_pDoc,ScAddress(0,0,0),ScResId(STR_STYLENAME_RESULT)); pFormat->AddEntry(pEntry); m_pDoc->AddCondFormat(std::move(pFormat), 0); @@ -502,7 +502,7 @@ void Test::testCondCopyPasteSheetBetweenDoc() ScRangeList aRangeList(aCondFormatRange); pFormat->SetRange(aRangeList); - ScCondFormatEntry* pEntry = new ScCondFormatEntry(ScConditionMode::Direct,"=B2","",m_pDoc,ScAddress(0,0,0),ScResId(STR_STYLENAME_RESULT)); + ScCondFormatEntry* pEntry = new ScCondFormatEntry(ScConditionMode::Direct,"=B2","",*m_pDoc,ScAddress(0,0,0),ScResId(STR_STYLENAME_RESULT)); pFormat->AddEntry(pEntry); m_pDoc->AddCondFormat(std::move(pFormat), 0); @@ -524,7 +524,7 @@ void Test::testCondCopyPasteSheet() ScRangeList aRangeList(aCondFormatRange); pFormat->SetRange(aRangeList); - ScCondFormatEntry* pEntry = new ScCondFormatEntry(ScConditionMode::Direct,"=B2","",m_pDoc,ScAddress(0,0,0),ScResId(STR_STYLENAME_RESULT)); + ScCondFormatEntry* pEntry = new ScCondFormatEntry(ScConditionMode::Direct,"=B2","",*m_pDoc,ScAddress(0,0,0),ScResId(STR_STYLENAME_RESULT)); pFormat->AddEntry(pEntry); m_pDoc->AddCondFormat(std::move(pFormat), 0); @@ -749,7 +749,7 @@ void Test::testCondFormatEndsWithStr() { m_pDoc->InsertTab(0, "Test"); - ScConditionEntry aEntry(ScConditionMode::EndsWith, "\"TestString\"", "", m_pDoc, ScAddress(), + ScConditionEntry aEntry(ScConditionMode::EndsWith, "\"TestString\"", "", *m_pDoc, ScAddress(), "", "", formula::FormulaGrammar::GRAM_DEFAULT, formula::FormulaGrammar::GRAM_DEFAULT); svl::SharedStringPool& rStringPool = m_pDoc->GetSharedStringPool(); @@ -767,7 +767,7 @@ void Test::testCondFormatEndsWithVal() { m_pDoc->InsertTab(0, "Test"); - ScConditionEntry aEntry(ScConditionMode::EndsWith, "2", "", m_pDoc, ScAddress(), + ScConditionEntry aEntry(ScConditionMode::EndsWith, "2", "", *m_pDoc, ScAddress(), "", "", formula::FormulaGrammar::GRAM_DEFAULT, formula::FormulaGrammar::GRAM_DEFAULT); for (sal_Int32 i = 0; i < 15; ++i) @@ -791,7 +791,7 @@ void Test::testFormulaListenerSingleCellToSingleCell() std::unique_ptr pTokenArray(aCompiler.CompileString("A1")); - ScFormulaListener aListener(m_pDoc); + ScFormulaListener aListener(*m_pDoc); aListener.addTokenArray(pTokenArray.get(), ScAddress(10, 10, 0)); @@ -809,7 +809,7 @@ void Test::testFormulaListenerSingleCellToMultipleCells() std::unique_ptr pTokenArray(aCompiler.CompileString("A1")); - ScFormulaListener aListener(m_pDoc); + ScFormulaListener aListener(*m_pDoc); aListener.addTokenArray(pTokenArray.get(), ScAddress(10, 10, 0)); @@ -827,7 +827,7 @@ void Test::testFormulaListenerMultipleCellsToSingleCell() std::unique_ptr pTokenArray(aCompiler.CompileString("A1")); - ScFormulaListener aListener(m_pDoc); + ScFormulaListener aListener(*m_pDoc); aListener.addTokenArray(pTokenArray.get(), ScAddress(10, 10, 0)); @@ -845,7 +845,7 @@ void Test::testFormulaListenerMultipleCellsToMultipleCells() std::unique_ptr pTokenArray(aCompiler.CompileString("A1")); - ScFormulaListener aListener(m_pDoc); + ScFormulaListener aListener(*m_pDoc); aListener.addTokenArray(pTokenArray.get(), ScAddress(10, 10, 0)); @@ -862,7 +862,7 @@ void Test::testFormulaListenerUpdateInsertTab() ScCompiler aCompiler(m_pDoc, ScAddress(10, 10, 0), formula::FormulaGrammar::GRAM_ENGLISH); std::unique_ptr pTokenArray(aCompiler.CompileString("A1")); - ScFormulaListener aListener(m_pDoc); + ScFormulaListener aListener(*m_pDoc); aListener.addTokenArray(pTokenArray.get(), ScAddress(10, 10, 0)); CPPUNIT_ASSERT(!aListener.NeedsRepaint()); @@ -887,7 +887,7 @@ void Test::testFormulaListenerUpdateDeleteTab() ScCompiler aCompiler(m_pDoc, ScAddress(10, 10, 1), formula::FormulaGrammar::GRAM_ENGLISH); std::unique_ptr pTokenArray(aCompiler.CompileString("A1")); - ScFormulaListener aListener(m_pDoc); + ScFormulaListener aListener(*m_pDoc); aListener.addTokenArray(pTokenArray.get(), ScAddress(10, 10, 1)); CPPUNIT_ASSERT(!aListener.NeedsRepaint()); @@ -905,7 +905,7 @@ void Test::testCondFormatUpdateMoveTab() m_pDoc->InsertTab(0, "test"); m_pDoc->InsertTab(1, "Test2"); - ScConditionEntry* pEntry = new ScConditionEntry(ScConditionMode::Equal, "A1", "", m_pDoc, ScAddress(10, 10, 0), "", "", formula::FormulaGrammar::GRAM_DEFAULT, formula::FormulaGrammar::GRAM_DEFAULT); + ScConditionEntry* pEntry = new ScConditionEntry(ScConditionMode::Equal, "A1", "", *m_pDoc, ScAddress(10, 10, 0), "", "", formula::FormulaGrammar::GRAM_DEFAULT, formula::FormulaGrammar::GRAM_DEFAULT); auto pFormat = std::make_unique(0, m_pDoc); pFormat->SetRange(ScRange(10, 10, 0, 10, 12, 0)); @@ -941,7 +941,7 @@ void Test::testCondFormatUpdateInsertTab() { m_pDoc->InsertTab(0, "test"); - ScConditionEntry* pEntry = new ScConditionEntry(ScConditionMode::Equal, "A1", "", m_pDoc, ScAddress(10, 10, 0), "", "", formula::FormulaGrammar::GRAM_DEFAULT, formula::FormulaGrammar::GRAM_DEFAULT); + ScConditionEntry* pEntry = new ScConditionEntry(ScConditionMode::Equal, "A1", "", *m_pDoc, ScAddress(10, 10, 0), "", "", formula::FormulaGrammar::GRAM_DEFAULT, formula::FormulaGrammar::GRAM_DEFAULT); auto pFormat = std::make_unique(0, m_pDoc); pFormat->SetRange(ScRange(10, 10, 0, 10, 12, 0)); @@ -981,7 +981,7 @@ void Test::testCondFormatUpdateDeleteTab() m_pDoc->InsertTab(0, "test"); m_pDoc->InsertTab(1, "Test2"); - ScConditionEntry* pEntry = new ScConditionEntry(ScConditionMode::Equal, "A1", "", m_pDoc, ScAddress(10, 10, 1), "", "", formula::FormulaGrammar::GRAM_DEFAULT, formula::FormulaGrammar::GRAM_DEFAULT); + ScConditionEntry* pEntry = new ScConditionEntry(ScConditionMode::Equal, "A1", "", *m_pDoc, ScAddress(10, 10, 1), "", "", formula::FormulaGrammar::GRAM_DEFAULT, formula::FormulaGrammar::GRAM_DEFAULT); auto pFormat = std::make_unique(0, m_pDoc); pFormat->SetRange(ScRange(10, 10, 1, 10, 12, 1)); @@ -1014,7 +1014,7 @@ void Test::testCondFormatUpdateReference() m_pDoc->InsertTab(0, "test"); m_pDoc->InsertTab(1, "Test2"); - ScConditionEntry* pEntry = new ScConditionEntry(ScConditionMode::Equal, "A1", "", m_pDoc, ScAddress(10, 10, 0), "", "", formula::FormulaGrammar::GRAM_DEFAULT, formula::FormulaGrammar::GRAM_DEFAULT); + ScConditionEntry* pEntry = new ScConditionEntry(ScConditionMode::Equal, "A1", "", *m_pDoc, ScAddress(10, 10, 0), "", "", formula::FormulaGrammar::GRAM_DEFAULT, formula::FormulaGrammar::GRAM_DEFAULT); auto pFormat = std::make_unique(0, m_pDoc); pFormat->SetRange(ScRange(10, 10, 0, 10, 12, 0)); @@ -1038,7 +1038,7 @@ void Test::testCondFormatUpdateReferenceDelRow() { m_pDoc->InsertTab(0, "test"); - ScConditionEntry* pEntry = new ScConditionEntry(ScConditionMode::Equal, "B6", "", m_pDoc, ScAddress(0, 5, 0), "", "", formula::FormulaGrammar::GRAM_DEFAULT, formula::FormulaGrammar::GRAM_DEFAULT); + ScConditionEntry* pEntry = new ScConditionEntry(ScConditionMode::Equal, "B6", "", *m_pDoc, ScAddress(0, 5, 0), "", "", formula::FormulaGrammar::GRAM_DEFAULT, formula::FormulaGrammar::GRAM_DEFAULT); auto pFormat = std::make_unique(0, m_pDoc); pFormat->SetRange(ScRange(0, 5, 0, 0, 5, 0)); @@ -1059,7 +1059,7 @@ void Test::testCondFormatUpdateReferenceInsRow() { m_pDoc->InsertTab(0, "test"); - ScConditionEntry* pEntry = new ScConditionEntry(ScConditionMode::Equal, "B6", "", m_pDoc, ScAddress(0, 5, 0), "", "", formula::FormulaGrammar::GRAM_DEFAULT, formula::FormulaGrammar::GRAM_DEFAULT); + ScConditionEntry* pEntry = new ScConditionEntry(ScConditionMode::Equal, "B6", "", *m_pDoc, ScAddress(0, 5, 0), "", "", formula::FormulaGrammar::GRAM_DEFAULT, formula::FormulaGrammar::GRAM_DEFAULT); auto pFormat = std::make_unique(0, m_pDoc); pFormat->SetRange(ScRange(0, 5, 0, 0, 5, 0)); @@ -1080,7 +1080,7 @@ void Test::testCondFormatUndoList() { m_pDoc->InsertTab(0, "test"); - ScConditionEntry* pEntry = new ScConditionEntry(ScConditionMode::Equal, "B6", "", m_pDoc, ScAddress(0, 5, 0), "", "", formula::FormulaGrammar::GRAM_DEFAULT, formula::FormulaGrammar::GRAM_DEFAULT); + ScConditionEntry* pEntry = new ScConditionEntry(ScConditionMode::Equal, "B6", "", *m_pDoc, ScAddress(0, 5, 0), "", "", formula::FormulaGrammar::GRAM_DEFAULT, formula::FormulaGrammar::GRAM_DEFAULT); auto pFormat = std::make_unique(0, m_pDoc); pFormat->AddEntry(pEntry); @@ -1128,7 +1128,7 @@ sal_uInt32 addSingleCellCondFormat(ScDocument* pDoc, const ScAddress& rAddr, sal pFormat->SetRange(aRangeList); ScCondFormatEntry* pEntry = new ScCondFormatEntry(ScConditionMode::Direct, rCondition, "", - pDoc, ScAddress(0,0,0), ScResId(STR_STYLENAME_RESULT)); + *pDoc, ScAddress(0,0,0), ScResId(STR_STYLENAME_RESULT)); pFormat->AddEntry(pEntry); return pDoc->AddCondFormat(std::move(pFormat), 0); } @@ -1245,7 +1245,7 @@ void Test::testCondFormatVolatileFunctionRecalc() ScRangeList aRangeList(ScRange(0,0,0,10,0,0)); pFormat->SetRange(aRangeList); - ScCondFormatEntry* pEntry = new ScCondFormatEntry(ScConditionMode::Greater,"RAND()","",m_pDoc,ScAddress(0,0,0),ScResId(STR_STYLENAME_RESULT)); + ScCondFormatEntry* pEntry = new ScCondFormatEntry(ScConditionMode::Greater,"RAND()","",*m_pDoc,ScAddress(0,0,0),ScResId(STR_STYLENAME_RESULT)); pEntry->SetParent(pFormat.get()); m_pDoc->AddCondFormatData(pFormat->GetRange(), 0, 1); diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx index 13e6263e7da8..709b99afdbe5 100644 --- a/sc/qa/unit/ucalc_formula.cxx +++ b/sc/qa/unit/ucalc_formula.cxx @@ -4226,7 +4226,7 @@ void Test::testFormulaRefUpdateValidity() // Set validity in A2. ScValidationData aData( - SC_VALID_LIST, ScConditionMode::Equal, "C2:C4", "", m_pDoc, ScAddress(0,1,0), "", "", + SC_VALID_LIST, ScConditionMode::Equal, "C2:C4", "", *m_pDoc, ScAddress(0,1,0), "", "", m_pDoc->GetGrammar(), m_pDoc->GetGrammar()); sal_uLong nIndex = m_pDoc->AddValidationEntry(aData); diff --git a/sc/source/core/data/colorscale.cxx b/sc/source/core/data/colorscale.cxx index cb887d70a2a7..298d15d2cf51 100644 --- a/sc/source/core/data/colorscale.cxx +++ b/sc/source/core/data/colorscale.cxx @@ -25,27 +25,27 @@ ScFormulaListener::ScFormulaListener(ScFormulaCell* pCell): mbDirty(false), - mpDoc(pCell->GetDocument()) + mrDoc(*pCell->GetDocument()) { startListening( pCell->GetCode(), pCell->aPos ); } -ScFormulaListener::ScFormulaListener(ScDocument* pDoc): +ScFormulaListener::ScFormulaListener(ScDocument& rDoc): mbDirty(false), - mpDoc(pDoc) + mrDoc(rDoc) { } -ScFormulaListener::ScFormulaListener(ScDocument* pDoc, const ScRangeList& rRange): +ScFormulaListener::ScFormulaListener(ScDocument& rDoc, const ScRangeList& rRange): mbDirty(false), - mpDoc(pDoc) + mrDoc(rDoc) { startListening(rRange); } void ScFormulaListener::startListening(const ScTokenArray* pArr, const ScRange& rRange) { - if (!pArr || mpDoc->IsClipOrUndo()) + if (!pArr || mrDoc.IsClipOrUndo()) return; for ( auto t: pArr->References() ) @@ -54,21 +54,21 @@ void ScFormulaListener::startListening(const ScTokenArray* pArr, const ScRange& { case formula::svSingleRef: { - ScAddress aCell = t->GetSingleRef()->toAbs(*mpDoc, rRange.aStart); - ScAddress aCell2 = t->GetSingleRef()->toAbs(*mpDoc, rRange.aEnd); + ScAddress aCell = t->GetSingleRef()->toAbs(mrDoc, rRange.aStart); + ScAddress aCell2 = t->GetSingleRef()->toAbs(mrDoc, rRange.aEnd); ScRange aRange(aCell, aCell2); if (aRange.IsValid()) - mpDoc->StartListeningArea(aRange, false, this); + mrDoc.StartListeningArea(aRange, false, this); } break; case formula::svDoubleRef: { const ScSingleRefData& rRef1 = *t->GetSingleRef(); const ScSingleRefData& rRef2 = *t->GetSingleRef2(); - ScAddress aCell1 = rRef1.toAbs(*mpDoc, rRange.aStart); - ScAddress aCell2 = rRef2.toAbs(*mpDoc, rRange.aStart); - ScAddress aCell3 = rRef1.toAbs(*mpDoc, rRange.aEnd); - ScAddress aCell4 = rRef2.toAbs(*mpDoc, rRange.aEnd); + ScAddress aCell1 = rRef1.toAbs(mrDoc, rRange.aStart); + ScAddress aCell2 = rRef2.toAbs(mrDoc, rRange.aStart); + ScAddress aCell3 = rRef1.toAbs(mrDoc, rRange.aEnd); + ScAddress aCell4 = rRef2.toAbs(mrDoc, rRange.aEnd); ScRange aRange1(aCell1, aCell3); ScRange aRange2(aCell2, aCell4); aRange1.ExtendTo(aRange2); @@ -78,14 +78,14 @@ void ScFormulaListener::startListening(const ScTokenArray* pArr, const ScRange& { // automagically if ( rRef1.IsColRel() ) { // ColName - aRange1.aEnd.SetRow(mpDoc->MaxRow()); + aRange1.aEnd.SetRow(mrDoc.MaxRow()); } else { // RowName - aRange1.aEnd.SetCol(mpDoc->MaxCol()); + aRange1.aEnd.SetCol(mrDoc.MaxCol()); } } - mpDoc->StartListeningArea(aRange1, false, this); + mrDoc.StartListeningArea(aRange1, false, this); } } break; @@ -97,14 +97,14 @@ void ScFormulaListener::startListening(const ScTokenArray* pArr, const ScRange& void ScFormulaListener::startListening(const ScRangeList& rRange) { - if (mpDoc->IsClipOrUndo()) + if (mrDoc.IsClipOrUndo()) return; size_t nLength = rRange.size(); for (size_t i = 0; i < nLength; ++i) { const ScRange& aRange = rRange[i]; - mpDoc->StartListeningArea(aRange, false, this); + mrDoc.StartListeningArea(aRange, false, this); } } @@ -120,7 +120,7 @@ void ScFormulaListener::setCallback(const std::function& aCallback) void ScFormulaListener::stopListening() { - if (mpDoc->IsClipOrUndo()) + if (mrDoc.IsClipOrUndo()) return; EndListeningAll(); @@ -341,7 +341,7 @@ void ScColorScaleEntry::setListener() || meType == COLORSCALE_MIN || meType == COLORSCALE_MAX || meType == COLORSCALE_AUTO) { - mpListener.reset(new ScFormulaListener(mpFormat->GetDocument(), mpFormat->GetRange())); + mpListener.reset(new ScFormulaListener(*mpFormat->GetDocument(), mpFormat->GetRange())); mpListener->setCallback([&]() { mpFormat->DoRepaint();}); } } diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx index c981579a2104..a76cebed65f8 100644 --- a/sc/source/core/data/conditio.cxx +++ b/sc/source/core/data/conditio.cxx @@ -188,7 +188,7 @@ ScConditionEntry::ScConditionEntry( const ScConditionEntry& r ) : bRelRef1(r.bRelRef1), bRelRef2(r.bRelRef2), bFirstRun(true), - mpListener(new ScFormulaListener(r.mpDoc)), + mpListener(new ScFormulaListener(*r.mpDoc)), eConditionType( r.eConditionType ), pCondFormat(r.pCondFormat) { @@ -221,7 +221,7 @@ ScConditionEntry::ScConditionEntry( ScDocument* pDocument, const ScConditionEntr bRelRef1(r.bRelRef1), bRelRef2(r.bRelRef2), bFirstRun(true), - mpListener(new ScFormulaListener(pDocument)), + mpListener(new ScFormulaListener(*pDocument)), eConditionType( r.eConditionType), pCondFormat(r.pCondFormat) { @@ -236,11 +236,11 @@ ScConditionEntry::ScConditionEntry( ScDocument* pDocument, const ScConditionEntr } ScConditionEntry::ScConditionEntry( ScConditionMode eOper, - const OUString& rExpr1, const OUString& rExpr2, ScDocument* pDocument, const ScAddress& rPos, + const OUString& rExpr1, const OUString& rExpr2, ScDocument& rDocument, const ScAddress& rPos, const OUString& rExprNmsp1, const OUString& rExprNmsp2, FormulaGrammar::Grammar eGrammar1, FormulaGrammar::Grammar eGrammar2, Type eType ) : - ScFormatEntry(pDocument), + ScFormatEntry(&rDocument), eOp(eOper), nOptions(0), nVal1(0.0), @@ -255,7 +255,7 @@ ScConditionEntry::ScConditionEntry( ScConditionMode eOper, bRelRef1(false), bRelRef2(false), bFirstRun(true), - mpListener(new ScFormulaListener(pDocument)), + mpListener(new ScFormulaListener(rDocument)), eConditionType(eType), pCondFormat(nullptr) { @@ -280,7 +280,7 @@ ScConditionEntry::ScConditionEntry( ScConditionMode eOper, bRelRef1(false), bRelRef2(false), bFirstRun(true), - mpListener(new ScFormulaListener(pDocument)), + mpListener(new ScFormulaListener(*pDocument)), eConditionType(ScFormatEntry::Type::Condition), pCondFormat(nullptr) { @@ -1454,13 +1454,13 @@ bool ScConditionEntry::NeedsRepaint() const ScCondFormatEntry::ScCondFormatEntry( ScConditionMode eOper, const OUString& rExpr1, const OUString& rExpr2, - ScDocument* pDocument, const ScAddress& rPos, + ScDocument& rDocument, const ScAddress& rPos, const OUString& rStyle, const OUString& rExprNmsp1, const OUString& rExprNmsp2, FormulaGrammar::Grammar eGrammar1, FormulaGrammar::Grammar eGrammar2, ScFormatEntry::Type eType ) : - ScConditionEntry( eOper, rExpr1, rExpr2, pDocument, rPos, rExprNmsp1, rExprNmsp2, eGrammar1, eGrammar2, eType ), + ScConditionEntry( eOper, rExpr1, rExpr2, rDocument, rPos, rExprNmsp1, rExprNmsp2, eGrammar1, eGrammar2, eType ), aStyleName( rStyle ), eCondFormatType( eType ) { diff --git a/sc/source/core/data/validat.cxx b/sc/source/core/data/validat.cxx index 31ed337047e9..75d9e4f0e27d 100644 --- a/sc/source/core/data/validat.cxx +++ b/sc/source/core/data/validat.cxx @@ -61,11 +61,11 @@ using namespace formula; ScValidationData::ScValidationData( ScValidationMode eMode, ScConditionMode eOper, const OUString& rExpr1, const OUString& rExpr2, - ScDocument* pDocument, const ScAddress& rPos, + ScDocument& rDocument, const ScAddress& rPos, const OUString& rExprNmsp1, const OUString& rExprNmsp2, FormulaGrammar::Grammar eGrammar1, FormulaGrammar::Grammar eGrammar2 ) - : ScConditionEntry( eOper, rExpr1, rExpr2, pDocument, rPos, rExprNmsp1, + : ScConditionEntry( eOper, rExpr1, rExpr2, rDocument, rPos, rExprNmsp1, rExprNmsp2, eGrammar1, eGrammar2 ) , nKey( 0 ) , eDataMode( eMode ) @@ -127,7 +127,7 @@ ScValidationData::~ScValidationData() bool ScValidationData::IsEmpty() const { - ScValidationData aDefault( SC_VALID_ANY, ScConditionMode::Equal, "", "", GetDocument(), ScAddress() ); + ScValidationData aDefault( SC_VALID_ANY, ScConditionMode::Equal, "", "", *GetDocument(), ScAddress() ); return EqualEntries( aDefault ); } diff --git a/sc/source/filter/oox/extlstcontext.cxx b/sc/source/filter/oox/extlstcontext.cxx index 4d81695a20ef..50191a94717c 100644 --- a/sc/source/filter/oox/extlstcontext.cxx +++ b/sc/source/filter/oox/extlstcontext.cxx @@ -210,7 +210,7 @@ void ExtConditionalFormattingContext::onEndElement() { ScAddress rPos = aRange.GetTopLeftCorner(); rStyle = getStyles().createExtDxfStyle(rStyleIdx); - ScCondFormatEntry* pEntry = new ScCondFormatEntry(eOperator, rFormula, "", &rDoc, + ScCondFormatEntry* pEntry = new ScCondFormatEntry(eOperator, rFormula, "", rDoc, rPos, rStyle, "", "", formula::FormulaGrammar::GRAM_OOXML , formula::FormulaGrammar::GRAM_OOXML, diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx index c5a2b79d938e..d78796bf75a9 100644 --- a/sc/source/filter/xml/xmlcelli.cxx +++ b/sc/source/filter/xml/xmlcelli.cxx @@ -793,7 +793,7 @@ void ScXMLTableRowCellContext::SetContentValidation( const ScRange& rScRange ) ScValidationData aScValidationData( validationTypeToMode(aValidation.aValidationType), ScConditionEntry::GetModeFromApi(aValidation.aOperator), - aValidation.sFormula1, aValidation.sFormula2, pDoc, ScAddress(), + aValidation.sFormula1, aValidation.sFormula2, *pDoc, ScAddress(), aValidation.sFormulaNmsp1, aValidation.sFormulaNmsp2, aValidation.eGrammar1, aValidation.eGrammar2 ); diff --git a/sc/source/filter/xml/xmlcondformat.cxx b/sc/source/filter/xml/xmlcondformat.cxx index 77baf12b60d5..41c8bbee7f3a 100644 --- a/sc/source/filter/xml/xmlcondformat.cxx +++ b/sc/source/filter/xml/xmlcondformat.cxx @@ -823,7 +823,7 @@ ScXMLCondContext::ScXMLCondContext( ScXMLImport& rImport, ScConditionMode eMode; GetConditionData(sExpression, eMode, aExpr1, aExpr2); - ScCondFormatEntry* pFormatEntry = new ScCondFormatEntry(eMode, aExpr1, aExpr2, GetScImport().GetDocument(), ScAddress(), sStyle, + ScCondFormatEntry* pFormatEntry = new ScCondFormatEntry(eMode, aExpr1, aExpr2, *GetScImport().GetDocument(), ScAddress(), sStyle, OUString(), OUString(), formula::FormulaGrammar::GRAM_ODFF, formula::FormulaGrammar::GRAM_ODFF); pFormatEntry->SetSrcString(sAddress); diff --git a/sc/source/filter/xml/xmlstyli.cxx b/sc/source/filter/xml/xmlstyli.cxx index 356acf8101f4..bd928fb9a9e8 100644 --- a/sc/source/filter/xml/xmlstyli.cxx +++ b/sc/source/filter/xml/xmlstyli.cxx @@ -394,7 +394,7 @@ ScCondFormatEntry* ScXMLMapContext::CreateConditionEntry() ScConditionMode eMode = ScConditionEntry::GetModeFromApi(aParseResult.meOperator); ScDocument* pDoc = GetScImport().GetDocument(); - ScCondFormatEntry* pEntry = new ScCondFormatEntry(eMode, aParseResult.maOperand1, aParseResult.maOperand2, pDoc, ScAddress(), msApplyStyle, + ScCondFormatEntry* pEntry = new ScCondFormatEntry(eMode, aParseResult.maOperand1, aParseResult.maOperand2, *pDoc, ScAddress(), msApplyStyle, OUString(), OUString(), eGrammar, eGrammar); pEntry->SetSrcString(msBaseCell); diff --git a/sc/source/ui/condformat/condformatdlgentry.cxx b/sc/source/ui/condformat/condformatdlgentry.cxx index 746cbeb67bc9..589b9c50f5ca 100644 --- a/sc/source/ui/condformat/condformatdlgentry.cxx +++ b/sc/source/ui/condformat/condformatdlgentry.cxx @@ -239,7 +239,7 @@ ScFormatEntry* ScConditionFrmtEntry::createConditionEntry() const } } - ScFormatEntry* pEntry = new ScCondFormatEntry(eMode, aExpr1, aExpr2, mpDoc, maPos, mxLbStyle->get_active_text()); + ScFormatEntry* pEntry = new ScCondFormatEntry(eMode, aExpr1, aExpr2, *mpDoc, maPos, mxLbStyle->get_active_text()); return pEntry; } @@ -543,7 +543,7 @@ ScFormatEntry* ScFormulaFrmtEntry::createFormulaEntry() const if(aFormula.isEmpty()) return nullptr; - ScFormatEntry* pEntry = new ScCondFormatEntry(ScConditionMode::Direct, aFormula, OUString(), mpDoc, maPos, mxLbStyle->get_active_text()); + ScFormatEntry* pEntry = new ScCondFormatEntry(ScConditionMode::Direct, aFormula, OUString(), *mpDoc, maPos, mxLbStyle->get_active_text()); return pEntry; } diff --git a/sc/source/ui/unoobj/condformatuno.cxx b/sc/source/ui/unoobj/condformatuno.cxx index 5d96b9a9c50b..ed037323e819 100644 --- a/sc/source/ui/unoobj/condformatuno.cxx +++ b/sc/source/ui/unoobj/condformatuno.cxx @@ -477,27 +477,27 @@ void ScCondFormatObj::createEntry(const sal_Int32 nType, const sal_Int32 nPos) throw lang::IllegalArgumentException(); ScFormatEntry* pNewEntry = nullptr; - ScDocument* pDoc = &mpDocShell->GetDocument(); + ScDocument& rDoc = mpDocShell->GetDocument(); switch (nType) { case sheet::ConditionEntryType::CONDITION: pNewEntry = new ScCondFormatEntry(ScConditionMode::Equal, "", "", - pDoc, pFormat->GetRange().GetTopLeftCorner(), ""); + rDoc, pFormat->GetRange().GetTopLeftCorner(), ""); break; case sheet::ConditionEntryType::COLORSCALE: - pNewEntry = new ScColorScaleFormat(pDoc); + pNewEntry = new ScColorScaleFormat(&rDoc); static_cast(pNewEntry)->EnsureSize(); break; case sheet::ConditionEntryType::DATABAR: - pNewEntry = new ScDataBarFormat(pDoc); + pNewEntry = new ScDataBarFormat(&rDoc); static_cast(pNewEntry)->EnsureSize(); break; case sheet::ConditionEntryType::ICONSET: - pNewEntry = new ScIconSetFormat(pDoc); + pNewEntry = new ScIconSetFormat(&rDoc); static_cast(pNewEntry)->EnsureSize(); break; case sheet::ConditionEntryType::DATE: - pNewEntry = new ScCondDateFormatEntry(pDoc); + pNewEntry = new ScCondDateFormatEntry(&rDoc); break; default: SAL_WARN("sc", "unknown conditional format type"); diff --git a/sc/source/ui/unoobj/fmtuno.cxx b/sc/source/ui/unoobj/fmtuno.cxx index 766438ee9d2e..0a1ef95a31f7 100644 --- a/sc/source/ui/unoobj/fmtuno.cxx +++ b/sc/source/ui/unoobj/fmtuno.cxx @@ -208,7 +208,7 @@ void ScTableConditionalFormat::FillFormat( ScConditionalFormat& rFormat, FormulaGrammar::Grammar eGrammar2 = lclResolveGrammar( eGrammar, aData.meGrammar2 ); ScCondFormatEntry* pCoreEntry = new ScCondFormatEntry( aData.meMode, aData.maExpr1, aData.maExpr2, - &rDoc, aData.maPos, aData.maStyle, aData.maExprNmsp1, aData.maExprNmsp2, eGrammar1, eGrammar2 ); + rDoc, aData.maPos, aData.maStyle, aData.maExprNmsp1, aData.maExprNmsp2, eGrammar1, eGrammar2 ); if ( !aData.maPosStr.isEmpty() ) pCoreEntry->SetSrcString( aData.maPosStr ); @@ -593,7 +593,7 @@ ScValidationData* ScTableValidationObj::CreateValidationData( ScDocument& rDoc, ScValidationData* pRet = new ScValidationData( static_cast(nValMode), nMode, - aExpr1, aExpr2, &rDoc, aSrcPos, + aExpr1, aExpr2, rDoc, aSrcPos, maExprNmsp1, maExprNmsp2, eGrammar1, eGrammar2 ); pRet->SetIgnoreBlank(bIgnoreBlank); diff --git a/sc/source/ui/view/cellsh2.cxx b/sc/source/ui/view/cellsh2.cxx index 7f527796c899..a3da043a8fe3 100644 --- a/sc/source/ui/view/cellsh2.cxx +++ b/sc/source/ui/view/cellsh2.cxx @@ -938,7 +938,7 @@ void ScCellShell::ExecuteDB( SfxRequest& rReq ) if ( pOutSet->GetItemState( FID_VALID_ERRTEXT, true, &pItem ) == SfxItemState::SET ) aErrText = static_cast(pItem)->GetValue(); - ScValidationData aData( eMode, eOper, aExpr1, aExpr2, pDoc, aCursorPos ); + ScValidationData aData( eMode, eOper, aExpr1, aExpr2, *pDoc, aCursorPos ); aData.SetIgnoreBlank( bBlank ); aData.SetListType( nListType ); -- cgit