diff options
35 files changed, 204 insertions, 207 deletions
diff --git a/sc/inc/chgtrack.hxx b/sc/inc/chgtrack.hxx index 94062c846836..c5af0df88064 100644 --- a/sc/inc/chgtrack.hxx +++ b/sc/inc/chgtrack.hxx @@ -851,7 +851,7 @@ class SAL_DLLPUBLIC_RTTI ScChangeTrack : public utl::ConfigurationListener ScChangeActionLinkEntry* pLinkInsertTab; ScChangeActionLinkEntry* pLinkMove; std::optional<ScChangeTrackMsgInfo> xBlockModifyMsg; - ScDocument* pDoc; + ScDocument& rDoc; sal_uLong nActionMax; sal_uLong nGeneratedMin; sal_uLong nMarkLastSaved; @@ -950,8 +950,8 @@ public: SCSIZE ComputeContentSlot( sal_Int32 nRow ) const; - SC_DLLPUBLIC ScChangeTrack( ScDocument* ); - ScChangeTrack(ScDocument* pDocP, const std::set<OUString>& aTempUserCollection); // only to use in the XML import + SC_DLLPUBLIC ScChangeTrack( ScDocument& ); + ScChangeTrack(ScDocument& rDocP, const std::set<OUString>& aTempUserCollection); // only to use in the XML import SC_DLLPUBLIC virtual ~ScChangeTrack() override; void Clear(); @@ -977,7 +977,7 @@ public: SC_DLLPUBLIC void SetUser( const OUString& rUser ); const OUString& GetUser() const { return maUser;} const std::set<OUString>& GetUserCollection() const { return maUserCollection;} - ScDocument* GetDocument() const { return pDoc; } + ScDocument& GetDocument() const { return rDoc; } // for import filter const DateTime& GetFixDateTime() const { return aFixDateTime; } diff --git a/sc/inc/formulacell.hxx b/sc/inc/formulacell.hxx index 296211687c39..e959b976d4da 100644 --- a/sc/inc/formulacell.hxx +++ b/sc/inc/formulacell.hxx @@ -201,7 +201,7 @@ public: formula::FormulaGrammar::GRAM_DEFAULT effectively isformula::FormulaGrammar::GRAM_NATIVE_UI that also includes formula::FormulaGrammar::CONV_UNSPECIFIED, therefore uses the address convention associated with rPos::nTab by default. */ - ScFormulaCell( ScDocument* pDoc, const ScAddress& rPos, + ScFormulaCell( ScDocument& rDoc, const ScAddress& rPos, const OUString& rFormula, const formula::FormulaGrammar::Grammar = formula::FormulaGrammar::GRAM_DEFAULT, ScMatrixMode cMatInd = ScMatrixMode::NONE ); diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx index 709b99afdbe5..08fe30987e7f 100644 --- a/sc/qa/unit/ucalc_formula.cxx +++ b/sc/qa/unit/ucalc_formula.cxx @@ -911,8 +911,8 @@ void Test::testFormulaTokenEquality() formula::FormulaGrammar::Grammar eGram = formula::FormulaGrammar::GRAM_ENGLISH_XL_R1C1; for (size_t i = 0; i < SAL_N_ELEMENTS(aTests); ++i) { - ScFormulaCell aCell1(m_pDoc, ScAddress(), OUString::createFromAscii(aTests[i].mpFormula1), eGram); - ScFormulaCell aCell2(m_pDoc, ScAddress(), OUString::createFromAscii(aTests[i].mpFormula2), eGram); + ScFormulaCell aCell1(*m_pDoc, ScAddress(), OUString::createFromAscii(aTests[i].mpFormula1), eGram); + ScFormulaCell aCell2(*m_pDoc, ScAddress(), OUString::createFromAscii(aTests[i].mpFormula2), eGram); ScFormulaCell::CompareState eComp = aCell1.CompareByTokenArray(aCell2); if (aTests[i].mbEqual) @@ -9142,7 +9142,7 @@ void Test::testInsertColCellStoreEventSwap() // ScDocument::SetString() can't be used as it doesn't expose the behavior // in question, use ScDocFunc::SetFormulaCell() instead which actually is // also called when editing a cell and creating a formula cell. - ScFormulaCell* pCell = new ScFormulaCell( m_pDoc, aPos, "=A1+1"); + ScFormulaCell* pCell = new ScFormulaCell(*m_pDoc, aPos, "=A1+1"); ScDocFunc& rDocFunc = getDocShell().GetDocFunc(); rDocFunc.SetFormulaCell( aPos, pCell, false); // C1, change formula CPPUNIT_ASSERT_EQUAL_MESSAGE( "Initial calculation failed", 2.0, m_pDoc->GetValue(aPos)); diff --git a/sc/qa/unit/ucalc_sharedformula.cxx b/sc/qa/unit/ucalc_sharedformula.cxx index e1dc8b71867e..3595b568b105 100644 --- a/sc/qa/unit/ucalc_sharedformula.cxx +++ b/sc/qa/unit/ucalc_sharedformula.cxx @@ -1760,7 +1760,7 @@ void Test::testSharedFormulaUnshareAreaListeners() // Directly set a different formula cell, which bypasses // ScDocument::SetString(), mimicking formula input in view. { - ScFormulaCell* pCell = new ScFormulaCell( m_pDoc, aPos, "=B4"); + ScFormulaCell* pCell = new ScFormulaCell( *m_pDoc, aPos, "=B4"); ScDocFunc& rDocFunc = getDocShell().GetDocFunc(); rDocFunc.SetFormulaCell( aPos, pCell, false); } @@ -1783,7 +1783,7 @@ void Test::testSharedFormulaUnshareAreaListeners() case 6: // Set formula cell vector. { - ScFormulaCell* pCell = new ScFormulaCell( m_pDoc, aPos, "=B4"); + ScFormulaCell* pCell = new ScFormulaCell( *m_pDoc, aPos, "=B4"); std::vector<ScFormulaCell*> aCells; aCells.push_back(pCell); m_pDoc->SetFormulaCells( aPos, aCells); @@ -1847,10 +1847,10 @@ void Test::testSharedFormulaUnshareAreaListeners() // Add grouping formulas in A1:A2, keep A3:A7 aPos = ScAddress(0,0,0); std::vector<ScFormulaCell*>().swap( aCells); - pCell = new ScFormulaCell( m_pDoc, aPos, "=SUM(B1:C1)"); + pCell = new ScFormulaCell( *m_pDoc, aPos, "=SUM(B1:C1)"); aCells.push_back(pCell); aPos.IncRow(); - pCell = new ScFormulaCell( m_pDoc, aPos, "=SUM(B2:C2)"); + pCell = new ScFormulaCell( *m_pDoc, aPos, "=SUM(B2:C2)"); aCells.push_back(pCell); aPos.IncRow(-1); m_pDoc->SetFormulaCells( aPos, aCells); @@ -1872,10 +1872,10 @@ void Test::testSharedFormulaUnshareAreaListeners() // Add formulas in A1:A2, keep A3:A7 aPos = ScAddress(0,0,0); std::vector<ScFormulaCell*>().swap( aCells); - pCell = new ScFormulaCell( m_pDoc, aPos, "=B1+C1"); + pCell = new ScFormulaCell( *m_pDoc, aPos, "=B1+C1"); aCells.push_back(pCell); aPos.IncRow(); - pCell = new ScFormulaCell( m_pDoc, aPos, "=B2+C2"); + pCell = new ScFormulaCell( *m_pDoc, aPos, "=B2+C2"); aCells.push_back(pCell); aPos.IncRow(-1); m_pDoc->SetFormulaCells( aPos, aCells); @@ -1903,10 +1903,10 @@ void Test::testSharedFormulaUnshareAreaListeners() // Add formula in A2, overwrite A3, keep A4:A7 aPos = ScAddress(0,1,0); std::vector<ScFormulaCell*>().swap( aCells); - pCell = new ScFormulaCell( m_pDoc, aPos, "=B2+C2"); + pCell = new ScFormulaCell( *m_pDoc, aPos, "=B2+C2"); aCells.push_back(pCell); aPos.IncRow(); - pCell = new ScFormulaCell( m_pDoc, aPos, "=B3+C3"); + pCell = new ScFormulaCell( *m_pDoc, aPos, "=B3+C3"); aCells.push_back(pCell); aPos.IncRow(-1); m_pDoc->SetFormulaCells( aPos, aCells); @@ -1934,10 +1934,10 @@ void Test::testSharedFormulaUnshareAreaListeners() // Overwrite A3:A4, keep A5:A7 aPos = ScAddress(0,2,0); std::vector<ScFormulaCell*>().swap( aCells); - pCell = new ScFormulaCell( m_pDoc, aPos, "=B3+C3"); + pCell = new ScFormulaCell( *m_pDoc, aPos, "=B3+C3"); aCells.push_back(pCell); aPos.IncRow(); - pCell = new ScFormulaCell( m_pDoc, aPos, "=B4+C4"); + pCell = new ScFormulaCell( *m_pDoc, aPos, "=B4+C4"); aCells.push_back(pCell); aPos.IncRow(-1); m_pDoc->SetFormulaCells( aPos, aCells); @@ -1966,10 +1966,10 @@ void Test::testSharedFormulaUnshareAreaListeners() // Keep A3, overwrite A4:A5, keep A6:A7 aPos = ScAddress(0,3,0); std::vector<ScFormulaCell*>().swap( aCells); - pCell = new ScFormulaCell( m_pDoc, aPos, "=B4+C4"); + pCell = new ScFormulaCell( *m_pDoc, aPos, "=B4+C4"); aCells.push_back(pCell); aPos.IncRow(); - pCell = new ScFormulaCell( m_pDoc, aPos, "=B5+C5"); + pCell = new ScFormulaCell( *m_pDoc, aPos, "=B5+C5"); aCells.push_back(pCell); aPos.IncRow(-1); m_pDoc->SetFormulaCells( aPos, aCells); @@ -2002,10 +2002,10 @@ void Test::testSharedFormulaUnshareAreaListeners() // Keep A3:A4, overwrite A5:A6, keep A7 aPos = ScAddress(0,4,0); std::vector<ScFormulaCell*>().swap( aCells); - pCell = new ScFormulaCell( m_pDoc, aPos, "=B5+C5"); + pCell = new ScFormulaCell( *m_pDoc, aPos, "=B5+C5"); aCells.push_back(pCell); aPos.IncRow(); - pCell = new ScFormulaCell( m_pDoc, aPos, "=B6+C6"); + pCell = new ScFormulaCell( *m_pDoc, aPos, "=B6+C6"); aCells.push_back(pCell); aPos.IncRow(-1); m_pDoc->SetFormulaCells( aPos, aCells); @@ -2038,10 +2038,10 @@ void Test::testSharedFormulaUnshareAreaListeners() // Keep A3:A5, overwrite A6:A7 aPos = ScAddress(0,5,0); std::vector<ScFormulaCell*>().swap( aCells); - pCell = new ScFormulaCell( m_pDoc, aPos, "=B6+C6"); + pCell = new ScFormulaCell( *m_pDoc, aPos, "=B6+C6"); aCells.push_back(pCell); aPos.IncRow(); - pCell = new ScFormulaCell( m_pDoc, aPos, "=B7+C7"); + pCell = new ScFormulaCell( *m_pDoc, aPos, "=B7+C7"); aCells.push_back(pCell); aPos.IncRow(-1); m_pDoc->SetFormulaCells( aPos, aCells); @@ -2070,10 +2070,10 @@ void Test::testSharedFormulaUnshareAreaListeners() // Keep A3:A6, overwrite A7, add A8 aPos = ScAddress(0,6,0); std::vector<ScFormulaCell*>().swap( aCells); - pCell = new ScFormulaCell( m_pDoc, aPos, "=B7+C7"); + pCell = new ScFormulaCell( *m_pDoc, aPos, "=B7+C7"); aCells.push_back(pCell); aPos.IncRow(); - pCell = new ScFormulaCell( m_pDoc, aPos, "=B8+C8"); + pCell = new ScFormulaCell( *m_pDoc, aPos, "=B8+C8"); aCells.push_back(pCell); aPos.IncRow(-1); m_pDoc->SetFormulaCells( aPos, aCells); @@ -2102,10 +2102,10 @@ void Test::testSharedFormulaUnshareAreaListeners() // Keep A3:A7, add A8:A9 aPos = ScAddress(0,7,0); std::vector<ScFormulaCell*>().swap( aCells); - pCell = new ScFormulaCell( m_pDoc, aPos, "=B8+C8"); + pCell = new ScFormulaCell( *m_pDoc, aPos, "=B8+C8"); aCells.push_back(pCell); aPos.IncRow(); - pCell = new ScFormulaCell( m_pDoc, aPos, "=B9+C9"); + pCell = new ScFormulaCell( *m_pDoc, aPos, "=B9+C9"); aCells.push_back(pCell); aPos.IncRow(-1); m_pDoc->SetFormulaCells( aPos, aCells); @@ -2134,10 +2134,10 @@ void Test::testSharedFormulaUnshareAreaListeners() // Keep A3:A7, add grouping formulas in A8:A9 aPos = ScAddress(0,7,0); std::vector<ScFormulaCell*>().swap( aCells); - pCell = new ScFormulaCell( m_pDoc, aPos, "=SUM(B8:C8)"); + pCell = new ScFormulaCell( *m_pDoc, aPos, "=SUM(B8:C8)"); aCells.push_back(pCell); aPos.IncRow(); - pCell = new ScFormulaCell( m_pDoc, aPos, "=SUM(B9:C9)"); + pCell = new ScFormulaCell( *m_pDoc, aPos, "=SUM(B9:C9)"); aCells.push_back(pCell); aPos.IncRow(-1); m_pDoc->SetFormulaCells( aPos, aCells); @@ -2160,10 +2160,10 @@ void Test::testSharedFormulaUnshareAreaListeners() // Overwrite grouping formulas in A4:A5 aPos = ScAddress(0,3,0); std::vector<ScFormulaCell*>().swap( aCells); - pCell = new ScFormulaCell( m_pDoc, aPos, "=SUM(B4:C4)"); + pCell = new ScFormulaCell( *m_pDoc, aPos, "=SUM(B4:C4)"); aCells.push_back(pCell); aPos.IncRow(); - pCell = new ScFormulaCell( m_pDoc, aPos, "=SUM(B5:C5)"); + pCell = new ScFormulaCell( *m_pDoc, aPos, "=SUM(B5:C5)"); aCells.push_back(pCell); aPos.IncRow(-1); m_pDoc->SetFormulaCells( aPos, aCells); diff --git a/sc/source/core/data/colorscale.cxx b/sc/source/core/data/colorscale.cxx index a9b047ae8274..16386a16370e 100644 --- a/sc/source/core/data/colorscale.cxx +++ b/sc/source/core/data/colorscale.cxx @@ -205,7 +205,7 @@ ScColorScaleEntry::~ScColorScaleEntry() COVERITY_NOEXCEPT_FALSE void ScColorScaleEntry::SetFormula( const OUString& rFormula, ScDocument& rDoc, const ScAddress& rAddr, formula::FormulaGrammar::Grammar eGrammar ) { - mpCell.reset(new ScFormulaCell( &rDoc, rAddr, rFormula, eGrammar )); + mpCell.reset(new ScFormulaCell( rDoc, rAddr, rFormula, eGrammar )); mpCell->StartListeningTo( rDoc ); mpListener.reset(new ScFormulaListener(mpCell.get())); if (mpFormat) diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx index f01d82c1058a..b963b1040806 100644 --- a/sc/source/core/data/column3.cxx +++ b/sc/source/core/data/column3.cxx @@ -2002,7 +2002,7 @@ bool ScColumn::ParseString( else // = Formula { ScFormulaCell* pFormulaCell = new ScFormulaCell( - &GetDoc(), ScAddress(nCol, nRow, nTabP), rString, + GetDoc(), ScAddress(nCol, nRow, nTabP), rString, formula::FormulaGrammar::mergeToGrammar(formula::FormulaGrammar::GRAM_DEFAULT, eConv), ScMatrixMode::NONE); if (aParam.mbCheckLinkFormula) @@ -2293,7 +2293,7 @@ void ScColumn::SetFormula( SCROW nRow, const OUString& rFormula, formula::Formul std::vector<SCROW> aNewSharedRows; sc::CellStoreType::iterator it = GetPositionToInsert(nRow, aNewSharedRows, true); - ScFormulaCell* pCell = new ScFormulaCell(&GetDoc(), aPos, rFormula, eGram); + ScFormulaCell* pCell = new ScFormulaCell(GetDoc(), aPos, rFormula, eGram); sal_uInt32 nCellFormat = GetNumberFormat(GetDoc().GetNonThreadedContext(), nRow); if( (nCellFormat % SV_COUNTRY_LANGUAGE_OFFSET) == 0) pCell->SetNeedNumberFormat(true); diff --git a/sc/source/core/data/column4.cxx b/sc/source/core/data/column4.cxx index 7d8ab951eb9e..3c7339573e89 100644 --- a/sc/source/core/data/column4.cxx +++ b/sc/source/core/data/column4.cxx @@ -2050,7 +2050,7 @@ void ScColumn::RestoreFromCache(SvStream& rStrm) OUString aStr = OStringToOUString(aOStr, RTL_TEXTENCODING_UTF8); for (sal_uInt64 i = 0; i < nFormulaGroupSize; ++i) { - aFormulaCells[nRow + i] = new ScFormulaCell(&rDocument, aAddr, aStr, eGrammar); + aFormulaCells[nRow + i] = new ScFormulaCell(rDocument, aAddr, aStr, eGrammar); aAddr.IncRow(); } diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx index 6015aa596b55..18c55028f082 100644 --- a/sc/source/core/data/documen2.cxx +++ b/sc/source/core/data/documen2.cxx @@ -261,7 +261,7 @@ sal_uInt32 ScDocument::GetDocumentID() const void ScDocument::StartChangeTracking() { if (!pChangeTrack) - pChangeTrack.reset( new ScChangeTrack( this ) ); + pChangeTrack.reset( new ScChangeTrack( *this ) ); } void ScDocument::EndChangeTracking() @@ -271,8 +271,8 @@ void ScDocument::EndChangeTracking() void ScDocument::SetChangeTrack( std::unique_ptr<ScChangeTrack> pTrack ) { - OSL_ENSURE( pTrack->GetDocument() == this, "SetChangeTrack: different documents" ); - if ( !pTrack || pTrack == pChangeTrack || pTrack->GetDocument() != this ) + OSL_ENSURE( &pTrack->GetDocument() == this, "SetChangeTrack: different documents" ); + if ( !pTrack || pTrack == pChangeTrack || &pTrack->GetDocument() != this ) return ; EndChangeTracking(); pChangeTrack = std::move(pTrack); diff --git a/sc/source/core/data/documen4.cxx b/sc/source/core/data/documen4.cxx index e3c8e55e0cd2..c7ba80d4ab31 100644 --- a/sc/source/core/data/documen4.cxx +++ b/sc/source/core/data/documen4.cxx @@ -281,7 +281,7 @@ void ScDocument::InsertMatrixFormula(SCCOL nCol1, SCROW nRow1, if (pArr) pCell = new ScFormulaCell(this, aPos, *pArr, eGram, ScMatrixMode::Formula); else - pCell = new ScFormulaCell( this, aPos, rFormula, eGram, ScMatrixMode::Formula ); + pCell = new ScFormulaCell(*this, aPos, rFormula, eGram, ScMatrixMode::Formula); pCell->SetMatColsRows( nCol2 - nCol1 + 1, nRow2 - nRow1 + 1 ); SCTAB nMax = static_cast<SCTAB>(maTabs.size()); for (const auto& rTab : rMark) @@ -434,7 +434,7 @@ void ScDocument::InsertTableOp(const ScTabOpParam& rParam, // multiple (repeate } aForString.append(ScCompiler::GetNativeSymbol( ocClose )); - ScFormulaCell aRefCell( this, ScAddress( nCol1, nRow1, nTab1 ), aForString.makeStringAndClear(), + ScFormulaCell aRefCell( *this, ScAddress( nCol1, nRow1, nTab1 ), aForString.makeStringAndClear(), formula::FormulaGrammar::GRAM_NATIVE, ScMatrixMode::NONE ); for( j = nCol1; j <= nCol2; j++ ) for( k = nRow1; k <= nRow2; k++ ) diff --git a/sc/source/core/data/documentimport.cxx b/sc/source/core/data/documentimport.cxx index 3b6a1e5315bf..fb44fb958545 100644 --- a/sc/source/core/data/documentimport.cxx +++ b/sc/source/core/data/documentimport.cxx @@ -290,7 +290,7 @@ void ScDocumentImport::setFormulaCell( return; std::unique_ptr<ScFormulaCell> pFC = - std::make_unique<ScFormulaCell>(&mpImpl->mrDoc, rPos, rFormula, eGrammar); + std::make_unique<ScFormulaCell>(mpImpl->mrDoc, rPos, rFormula, eGrammar); mpImpl->mrDoc.CheckLinkFormulaNeedingCheck( *pFC->GetCode()); @@ -319,7 +319,7 @@ void ScDocumentImport::setFormulaCell( return; std::unique_ptr<ScFormulaCell> pFC = - std::make_unique<ScFormulaCell>(&mpImpl->mrDoc, rPos, rFormula, eGrammar); + std::make_unique<ScFormulaCell>(mpImpl->mrDoc, rPos, rFormula, eGrammar); mpImpl->mrDoc.CheckLinkFormulaNeedingCheck( *pFC->GetCode()); @@ -461,7 +461,7 @@ void ScDocumentImport::setTableOpCells(const ScRange& rRange, const ScTabOpParam if (!pTab) return; - ScDocument* pDoc = &mpImpl->mrDoc; + ScDocument& rDoc = mpImpl->mrDoc; ScRefAddress aRef; OUStringBuffer aFormulaBuf; aFormulaBuf.append('='); @@ -472,12 +472,12 @@ void ScDocumentImport::setTableOpCells(const ScRange& rRange, const ScTabOpParam if (rParam.meMode == ScTabOpParam::Column) // column only { aRef.Set(rParam.aRefFormulaCell.GetAddress(), true, false, false); - aFormulaBuf.append(aRef.GetRefString(pDoc, nTab)); + aFormulaBuf.append(aRef.GetRefString(&rDoc, nTab)); aFormulaBuf.append(aSep); - aFormulaBuf.append(rParam.aRefColCell.GetRefString(pDoc, nTab)); + aFormulaBuf.append(rParam.aRefColCell.GetRefString(&rDoc, nTab)); aFormulaBuf.append(aSep); aRef.Set(nCol1, nRow1, nTab, false, true, true); - aFormulaBuf.append(aRef.GetRefString(pDoc, nTab)); + aFormulaBuf.append(aRef.GetRefString(&rDoc, nTab)); nCol1++; nCol2 = std::min( nCol2, static_cast<SCCOL>(rParam.aRefFormulaEnd.Col() - rParam.aRefFormulaCell.Col() + nCol1 + 1)); @@ -485,29 +485,29 @@ void ScDocumentImport::setTableOpCells(const ScRange& rRange, const ScTabOpParam else if (rParam.meMode == ScTabOpParam::Row) // row only { aRef.Set(rParam.aRefFormulaCell.GetAddress(), false, true, false); - aFormulaBuf.append(aRef.GetRefString(pDoc, nTab)); + aFormulaBuf.append(aRef.GetRefString(&rDoc, nTab)); aFormulaBuf.append(aSep); - aFormulaBuf.append(rParam.aRefRowCell.GetRefString(pDoc, nTab)); + aFormulaBuf.append(rParam.aRefRowCell.GetRefString(&rDoc, nTab)); aFormulaBuf.append(aSep); aRef.Set(nCol1, nRow1, nTab, true, false, true); - aFormulaBuf.append(aRef.GetRefString(pDoc, nTab)); + aFormulaBuf.append(aRef.GetRefString(&rDoc, nTab)); ++nRow1; nRow2 = std::min( nRow2, rParam.aRefFormulaEnd.Row() - rParam.aRefFormulaCell.Row() + nRow1 + 1); } else // both { - aFormulaBuf.append(rParam.aRefFormulaCell.GetRefString(pDoc, nTab)); + aFormulaBuf.append(rParam.aRefFormulaCell.GetRefString(&rDoc, nTab)); aFormulaBuf.append(aSep); - aFormulaBuf.append(rParam.aRefColCell.GetRefString(pDoc, nTab)); + aFormulaBuf.append(rParam.aRefColCell.GetRefString(&rDoc, nTab)); aFormulaBuf.append(aSep); aRef.Set(nCol1, nRow1 + 1, nTab, false, true, true); - aFormulaBuf.append(aRef.GetRefString(pDoc, nTab)); + aFormulaBuf.append(aRef.GetRefString(&rDoc, nTab)); aFormulaBuf.append(aSep); - aFormulaBuf.append(rParam.aRefRowCell.GetRefString(pDoc, nTab)); + aFormulaBuf.append(rParam.aRefRowCell.GetRefString(&rDoc, nTab)); aFormulaBuf.append(aSep); aRef.Set(nCol1 + 1, nRow1, nTab, true, false, true); - aFormulaBuf.append(aRef.GetRefString(pDoc, nTab)); + aFormulaBuf.append(aRef.GetRefString(&rDoc, nTab)); ++nCol1; ++nRow1; } @@ -515,7 +515,7 @@ void ScDocumentImport::setTableOpCells(const ScRange& rRange, const ScTabOpParam aFormulaBuf.append(ScCompiler::GetNativeSymbol(ocClose)); ScFormulaCell aRefCell( - pDoc, ScAddress(nCol1, nRow1, nTab), aFormulaBuf.makeStringAndClear(), + rDoc, ScAddress(nCol1, nRow1, nTab), aFormulaBuf.makeStringAndClear(), formula::FormulaGrammar::GRAM_NATIVE, ScMatrixMode::NONE); for (SCCOL nCol = nCol1; nCol <= nCol2; ++nCol) @@ -531,7 +531,7 @@ void ScDocumentImport::setTableOpCells(const ScRange& rRange, const ScTabOpParam for (SCROW nRow = nRow1; nRow <= nRow2; ++nRow) { ScAddress aPos(nCol, nRow, nTab); - ScFormulaCell* pCell = new ScFormulaCell(aRefCell, *pDoc, aPos); + ScFormulaCell* pCell = new ScFormulaCell(aRefCell, rDoc, aPos); pBlockPos->miCellPos = rColCells.set(pBlockPos->miCellPos, nRow, pCell); } diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx index 5d3502c2dfcf..98ea70caac6a 100644 --- a/sc/source/core/data/formulacell.cxx +++ b/sc/source/core/data/formulacell.cxx @@ -632,7 +632,7 @@ ScFormulaCell::ScFormulaCell( ScDocument& rDoc, const ScAddress& rPos ) : { } -ScFormulaCell::ScFormulaCell( ScDocument* pDoc, const ScAddress& rPos, +ScFormulaCell::ScFormulaCell( ScDocument& rDoc, const ScAddress& rPos, const OUString& rFormula, const FormulaGrammar::Grammar eGrammar, ScMatrixMode cMatInd ) : @@ -655,7 +655,7 @@ ScFormulaCell::ScFormulaCell( ScDocument* pDoc, const ScAddress& rPos, nFormatType ( SvNumFormatType::NUMBER ), eTempGrammar( eGrammar), pCode( nullptr ), - pDocument( pDoc ), + pDocument( &rDoc ), pPrevious(nullptr), pNext(nullptr), pPreviousTrack(nullptr), @@ -665,7 +665,7 @@ ScFormulaCell::ScFormulaCell( ScDocument* pDoc, const ScAddress& rPos, Compile( rFormula, true, eGrammar ); // bNoListening, Insert does that if (!pCode) // We need to have a non-NULL token array instance at all times. - pCode = new ScTokenArray(*pDoc); + pCode = new ScTokenArray(rDoc); } ScFormulaCell::ScFormulaCell( diff --git a/sc/source/core/data/table6.cxx b/sc/source/core/data/table6.cxx index df3777abe02a..b52247f35e14 100644 --- a/sc/source/core/data/table6.cxx +++ b/sc/source/core/data/table6.cxx @@ -256,7 +256,7 @@ bool ScTable::SearchCell(const SvxSearchItem& rSearchItem, SCCOL nCol, sc::Colum aString = aString.copy( 1 ); } ScAddress aAdr( nCol, nRow, nTab ); - ScFormulaCell* pFCell = new ScFormulaCell( &rDocument, aAdr, + ScFormulaCell* pFCell = new ScFormulaCell( rDocument, aAdr, aString, rDocument.GetGrammar(), cMatrixFlag ); SCCOL nMatCols; SCROW nMatRows; diff --git a/sc/source/core/tool/chgtrack.cxx b/sc/source/core/tool/chgtrack.cxx index fcd282c243eb..6761837109bc 100644 --- a/sc/source/core/tool/chgtrack.cxx +++ b/sc/source/core/tool/chgtrack.cxx @@ -609,12 +609,12 @@ void ScChangeAction::RejectRestoreContents( ScChangeTrack* pTrack, OSL_ENSURE( !pLinkDeleted, "ScChangeAction::RejectRestoreContents: pLinkDeleted != NULL" ); // Work through list of Contents and delete - ScDocument* pDoc = pTrack->GetDocument(); + ScDocument& rDoc = pTrack->GetDocument(); for (ScChangeActionContent* pContent : aContentsList) { if ( !pContent->IsDeletedIn() && - pContent->GetBigRange().aStart.IsValid( pDoc ) ) - pContent->PutNewValueToDoc( pDoc, nDx, nDy ); + pContent->GetBigRange().aStart.IsValid( &rDoc ) ) + pContent->PutNewValueToDoc( &rDoc, nDx, nDy ); } DeleteCellEntries(); // Remove generated ones } @@ -1407,7 +1407,7 @@ void ScChangeActionContent::SetValueString( rValue = EMPTY_OUSTRING; rCell.meType = CELLTYPE_FORMULA; rCell.mpFormula = new ScFormulaCell( - pDoc, aBigRange.aStart.MakeAddress(), rStr, + *pDoc, aBigRange.aStart.MakeAddress(), rStr, pDoc->GetGrammar() ); rCell.mpFormula->SetInChangeTrack(true); } @@ -1851,14 +1851,14 @@ void ScChangeActionContent::PutValueToDoc( } } -static void lcl_InvalidateReference( const ScDocument* pDoc, formula::FormulaToken& rTok, const ScBigAddress& rPos ) +static void lcl_InvalidateReference( const ScDocument& rDoc, formula::FormulaToken& rTok, const ScBigAddress& rPos ) { ScSingleRefData& rRef1 = *rTok.GetSingleRef(); - if ( rPos.Col() < 0 || pDoc->MaxCol() < rPos.Col() ) + if ( rPos.Col() < 0 || rDoc.MaxCol() < rPos.Col() ) { rRef1.SetColDeleted( true ); } - if ( rPos.Row() < 0 || pDoc->MaxRow() < rPos.Row() ) + if ( rPos.Row() < 0 || rDoc.MaxRow() < rPos.Row() ) { rRef1.SetRowDeleted( true ); } @@ -1870,11 +1870,11 @@ static void lcl_InvalidateReference( const ScDocument* pDoc, formula::FormulaTok return; ScSingleRefData& rRef2 = rTok.GetDoubleRef()->Ref2; - if ( rPos.Col() < 0 || pDoc->MaxCol() < rPos.Col() ) + if ( rPos.Col() < 0 || rDoc.MaxCol() < rPos.Col() ) { rRef2.SetColDeleted( true ); } - if ( rPos.Row() < 0 || pDoc->MaxRow() < rPos.Row() ) + if ( rPos.Row() < 0 || rDoc.MaxRow() < rPos.Row() ) { rRef2.SetRowDeleted( true ); } @@ -1967,7 +1967,7 @@ void ScChangeActionContent::UpdateReference( const ScChangeTrack* pTrack, } ScRange aRange( aTmpRange.MakeRange() ); - sc::RefUpdateContext aRefCxt(*pTrack->GetDocument()); + sc::RefUpdateContext aRefCxt(pTrack->GetDocument()); aRefCxt.meMode = eMode; aRefCxt.maRange = aRange; aRefCxt.mnColDelta = nDx; @@ -1979,7 +1979,7 @@ void ScChangeActionContent::UpdateReference( const ScChangeTrack* pTrack, if ( bNewFormula ) maNewCell.mpFormula->UpdateReference(aRefCxt); - if ( aBigRange.aStart.IsValid( pTrack->GetDocument() ) ) + if ( aBigRange.aStart.IsValid( &pTrack->GetDocument() ) ) return; //FIXME: @@ -2038,7 +2038,7 @@ bool ScChangeActionReject::Reject(ScDocument* /*pDoc*/) SCSIZE ScChangeTrack::ComputeContentSlot( sal_Int32 nRow ) const { - if ( nRow < 0 || nRow > pDoc->GetSheetLimits().mnMaxRow ) + if ( nRow < 0 || nRow > rDoc.GetSheetLimits().mnMaxRow ) return mnContentSlots - 1; return static_cast< SCSIZE >( nRow / mnContentRowsPerSlot ); } @@ -2046,15 +2046,15 @@ SCSIZE ScChangeTrack::ComputeContentSlot( sal_Int32 nRow ) const SCROW ScChangeTrack::InitContentRowsPerSlot() { const SCSIZE nMaxSlots = 0xffe0 / sizeof( ScChangeActionContent* ) - 2; - SCROW nRowsPerSlot = pDoc->GetSheetLimits().GetMaxRowCount() / nMaxSlots; - if ( nRowsPerSlot * nMaxSlots < sal::static_int_cast<SCSIZE>(pDoc->GetSheetLimits().GetMaxRowCount()) ) + SCROW nRowsPerSlot = rDoc.GetSheetLimits().GetMaxRowCount() / nMaxSlots; + if ( nRowsPerSlot * nMaxSlots < sal::static_int_cast<SCSIZE>(rDoc.GetSheetLimits().GetMaxRowCount()) ) ++nRowsPerSlot; return nRowsPerSlot; } -ScChangeTrack::ScChangeTrack( ScDocument* pDocP ) : +ScChangeTrack::ScChangeTrack( ScDocument& rDocP ) : aFixDateTime( DateTime::SYSTEM ), - pDoc( pDocP ) + rDoc( rDocP ) { Init(); SC_MOD()->GetUserOptions().AddListener(this); @@ -2063,10 +2063,10 @@ ScChangeTrack::ScChangeTrack( ScDocument* pDocP ) : memset( ppContentSlots.get(), 0, mnContentSlots * sizeof( ScChangeActionContent* ) ); } -ScChangeTrack::ScChangeTrack( ScDocument* pDocP, const std::set<OUString>& aTempUserCollection) : +ScChangeTrack::ScChangeTrack( ScDocument& rDocP, const std::set<OUString>& aTempUserCollection) : maUserCollection(aTempUserCollection), aFixDateTime( DateTime::SYSTEM ), - pDoc( pDocP ) + rDoc( rDocP ) { Init(); SC_MOD()->GetUserOptions().AddListener(this); @@ -2083,7 +2083,7 @@ ScChangeTrack::~ScChangeTrack() void ScChangeTrack::Init() { mnContentRowsPerSlot = InitContentRowsPerSlot(); - mnContentSlots = pDoc->GetSheetLimits().GetMaxRowCount() / InitContentRowsPerSlot() + 2; + mnContentSlots = rDoc.GetSheetLimits().GetMaxRowCount() / InitContentRowsPerSlot() + 2; pFirst = nullptr; pLast = nullptr; @@ -2208,7 +2208,7 @@ ScChangeAction* ScChangeTrack::GetLastSaved() const void ScChangeTrack::ConfigurationChanged( utl::ConfigurationBroadcaster*, ConfigurationHints ) { - if ( pDoc->IsInDtorClear() ) + if ( rDoc.IsInDtorClear() ) return; const SvtUserOptions& rUserOptions = SC_MOD()->GetUserOptions(); @@ -2227,9 +2227,9 @@ void ScChangeTrack::ConfigurationChanged( utl::ConfigurationBroadcaster*, Config // (Has to be done in the Notify handler, to be sure // the user collection has already been updated) - SfxObjectShell* pDocSh = pDoc->GetDocumentShell(); + SfxObjectShell* pDocSh = rDoc.GetDocumentShell(); if (pDocSh) - pDocSh->Broadcast( ScPaintHint( ScRange(0,0,0,pDoc->MaxCol(),pDoc->MaxRow(),MAXTAB), PaintPartFlags::Grid ) ); + pDocSh->Broadcast( ScPaintHint( ScRange(0,0,0,rDoc.MaxCol(),rDoc.MaxRow(),MAXTAB), PaintPartFlags::Grid ) ); } } @@ -2457,12 +2457,12 @@ void ScChangeTrack::AppendDeleteRange( const ScRange& rRange, { if ( !pRefDoc || nTab < pRefDoc->GetTableCount() ) { - if ( nCol1 == 0 && nCol2 == pDoc->MaxCol() ) + if ( nCol1 == 0 && nCol2 == rDoc.MaxCol() ) { // Whole Row and/or Tables - if ( nRow1 == 0 && nRow2 == pDoc->MaxRow() ) + if ( nRow1 == 0 && nRow2 == rDoc.MaxRow() ) { // Whole Table // TODO: Can't we do the whole Table as a whole? - ScRange aRange( 0, 0, nTab, 0, pDoc->MaxRow(), nTab ); + ScRange aRange( 0, 0, nTab, 0, rDoc.MaxRow(), nTab ); for ( SCCOL nCol = nCol1; nCol <= nCol2; nCol++ ) { // Column by column is less than row by row aRange.aStart.SetCol( nCol ); @@ -2478,7 +2478,7 @@ void ScChangeTrack::AppendDeleteRange( const ScRange& rRange, } else { // Whole rows - ScRange aRange( 0, 0, nTab, pDoc->MaxCol(), 0, nTab ); + ScRange aRange( 0, 0, nTab, rDoc.MaxCol(), 0, nTab ); for ( SCROW nRow = nRow1; nRow <= nRow2; nRow++ ) { aRange.aStart.SetRow( nRow ); @@ -2490,9 +2490,9 @@ void ScChangeTrack::AppendDeleteRange( const ScRange& rRange, } } } - else if ( nRow1 == 0 && nRow2 == pDoc->MaxRow() ) + else if ( nRow1 == 0 && nRow2 == rDoc.MaxRow() ) { // Whole columns - ScRange aRange( 0, 0, nTab, 0, pDoc->MaxRow(), nTab ); + ScRange aRange( 0, 0, nTab, 0, rDoc.MaxRow(), nTab ); for ( SCCOL nCol = nCol1; nCol <= nCol2; nCol++ ) { aRange.aStart.SetCol( nCol ); @@ -2533,11 +2533,11 @@ void ScChangeTrack::AppendOneDeleteRange( const ScRange& rOrgRange, aTrackRange.aStart.IncTab( -nDz ); aTrackRange.aEnd.IncTab( -nDz ); } - ScChangeActionDel* pAct = new ScChangeActionDel( pDoc, aTrackRange, nDx, nDy, + ScChangeActionDel* pAct = new ScChangeActionDel( &rDoc, aTrackRange, nDx, nDy, this ); // TabDelete not Contents; they are in separate columns if ( !(rOrgRange.aStart.Col() == 0 && rOrgRange.aStart.Row() == 0 && - rOrgRange.aEnd.Col() == pDoc->MaxCol() && rOrgRange.aEnd.Row() == pDoc->MaxRow()) ) + rOrgRange.aEnd.Col() == rDoc.MaxCol() && rOrgRange.aEnd.Row() == rDoc.MaxRow()) ) LookUpContents( rOrgRange, pRefDoc, -nDx, -nDy, -nDz ); if ( nRejectingInsert ) { @@ -2606,22 +2606,22 @@ void ScChangeTrack::AppendContent( const ScAddress& rPos, const ScCellValue& rOldCell, sal_uLong nOldFormat, ScDocument* pRefDoc ) { if ( !pRefDoc ) - pRefDoc = pDoc; + pRefDoc = &rDoc; OUString aOldValue; ScChangeActionContent::GetStringOfCell(aOldValue, rOldCell, pRefDoc, nOldFormat); OUString aNewValue; ScCellValue aNewCell; - aNewCell.assign(*pDoc, rPos); - ScChangeActionContent::GetStringOfCell(aNewValue, aNewCell, pDoc, rPos); + aNewCell.assign(rDoc, rPos); + ScChangeActionContent::GetStringOfCell(aNewValue, aNewCell, &rDoc, rPos); if (aOldValue != aNewValue || IsMatrixFormulaRangeDifferent(rOldCell, aNewCell)) { // Only track real changes ScRange aRange( rPos ); ScChangeActionContent* pAct = new ScChangeActionContent( aRange ); - pAct->SetOldValue(rOldCell, pRefDoc, pDoc, nOldFormat); - pAct->SetNewValue(aNewCell, pDoc); + pAct->SetOldValue(rOldCell, pRefDoc, &rDoc, nOldFormat); + pAct->SetNewValue(aNewCell, &rDoc); Append( pAct ); } } @@ -2636,15 +2636,15 @@ void ScChangeTrack::AppendContent( const ScAddress& rPos, OUString aNewValue; ScCellValue aNewCell; - aNewCell.assign(*pDoc, rPos); - ScChangeActionContent::GetStringOfCell(aNewValue, aNewCell, pDoc, rPos); + aNewCell.assign(rDoc, rPos); + ScChangeActionContent::GetStringOfCell(aNewValue, aNewCell, &rDoc, rPos); if (aOldValue != aNewValue || IsMatrixFormulaRangeDifferent(aOldCell, aNewCell)) { // Only track real changes ScRange aRange( rPos ); ScChangeActionContent* pAct = new ScChangeActionContent( aRange ); - pAct->SetOldValue(aOldCell, pRefDoc, pDoc); - pAct->SetNewValue(aNewCell, pDoc); + pAct->SetOldValue(aOldCell, pRefDoc, &rDoc); + pAct->SetNewValue(aNewCell, &rDoc); Append( pAct ); } } @@ -2652,9 +2652,9 @@ void ScChangeTrack::AppendContent( const ScAddress& rPos, void ScChangeTrack::AppendContent( const ScAddress& rPos, const ScCellValue& rOldCell ) { if (ScChangeActionContent::NeedsNumberFormat(rOldCell)) - AppendContent(rPos, rOldCell, pDoc->GetNumberFormat(rPos), pDoc); + AppendContent(rPos, rOldCell, rDoc.GetNumberFormat(rPos), &rDoc); else - AppendContent(rPos, rOldCell, 0, pDoc); + AppendContent(rPos, rOldCell, 0, &rDoc); } void ScChangeTrack::SetLastCutMoveRange( const ScRange& rRange, @@ -2771,7 +2771,7 @@ void ScChangeTrack::AppendContentRange( const ScRange& rRange, void ScChangeTrack::AppendContentsIfInRefDoc( ScDocument* pRefDoc, sal_uLong& nStartAction, sal_uLong& nEndAction ) { - ScCellIterator aIter(pRefDoc, ScRange(0,0,0,pDoc->MaxCol(),pDoc->MaxRow(),MAXTAB)); + ScCellIterator aIter(pRefDoc, ScRange(0,0,0,rDoc.MaxCol(),rDoc.MaxRow(),MAXTAB)); if (aIter.first()) { nStartAction = GetActionMax() + 1; @@ -2799,14 +2799,14 @@ ScChangeActionContent* ScChangeTrack::AppendContentOnTheFly( { ScRange aRange( rPos ); ScChangeActionContent* pAct = new ScChangeActionContent( aRange ); - pAct->SetOldNewCells(rOldCell, nOldFormat, rNewCell, nNewFormat, pDoc); + pAct->SetOldNewCells(rOldCell, nOldFormat, rNewCell, nNewFormat, &rDoc); Append( pAct ); return pAct; } void ScChangeTrack::AppendInsert( const ScRange& rRange, bool bEndOfList ) { - ScChangeActionIns* pAct = new ScChangeActionIns(pDoc, rRange, bEndOfList); + ScChangeActionIns* pAct = new ScChangeActionIns(&rDoc, rRange, bEndOfList); Append( pAct ); } @@ -2831,7 +2831,7 @@ ScChangeActionContent* ScChangeTrack::GenerateDelContent( pContent->SetActionNumber( --nGeneratedMin ); // Only NewValue ScChangeActionContent::SetValue( pContent->maNewValue, pContent->maNewCell, - rPos, rCell, pFromDoc, pDoc ); + rPos, rCell, pFromDoc, &rDoc ); // pNextContent and pPrevContent are not set if ( pFirstGeneratedDelContent ) { // Insert at front @@ -2917,7 +2917,7 @@ void ScChangeTrack::Dependencies( ScChangeAction* pAct ) if ( ScChangeActionContent::GetContentCellType(rCell) == SC_CACCT_MATREF ) { ScAddress aOrg; - bool bOrgFound = rCell.mpFormula->GetMatrixOrigin(pDoc, aOrg); + bool bOrgFound = rCell.mpFormula->GetMatrixOrigin(&rDoc, aOrg); ScChangeActionContent* pContent = (bOrgFound ? SearchContentAt( aOrg, pAct ) : nullptr); if ( pContent && pContent->IsMatrixOrigin() ) { @@ -3159,7 +3159,7 @@ void ScChangeTrack::Undo( sal_uLong nStartAction, sal_uLong nEndAction, bool bMe nEndLastCut = nEnd; pLastCutMove.reset(pMove); SetLastCutMoveRange( - pMove->GetFromRange().MakeRange(), pDoc ); + pMove->GetFromRange().MakeRange(), &rDoc ); } else delete pMove; @@ -3248,15 +3248,15 @@ void ScChangeTrack::UpdateReference( ScChangeAction* pAct, bool bUndo ) return ; // Formula cells are not in the Document! - bool bOldAutoCalc = pDoc->GetAutoCalc(); - pDoc->SetAutoCalc( false ); - bool bOldNoListening = pDoc->GetNoListening(); - pDoc->SetNoListening( true ); + bool bOldAutoCalc = rDoc.GetAutoCalc(); + rDoc.SetAutoCalc( false ); + bool bOldNoListening = rDoc.GetNoListening(); + rDoc.SetNoListening( true ); // Formula cells ExpandRefs synchronized to the ones in the Document! - bool bOldExpandRefs = pDoc->IsExpandRefs(); + bool bOldExpandRefs = rDoc.IsExpandRefs(); if ( (!bUndo && pAct->IsInsertType()) || (bUndo && pAct->IsDeleteType()) ) - pDoc->SetExpandRefs( SC_MOD()->GetInputOptions().GetExpandRefs() ); + rDoc.SetExpandRefs( SC_MOD()->GetInputOptions().GetExpandRefs() ); if ( pAct->IsDeleteType() ) { @@ -3280,9 +3280,9 @@ void ScChangeTrack::UpdateReference( ScChangeAction* pAct, bool bUndo ) SetInDelete( false ); SetInDeleteUndo( false ); - pDoc->SetExpandRefs( bOldExpandRefs ); - pDoc->SetNoListening( bOldNoListening ); - pDoc->SetAutoCalc( bOldAutoCalc ); + rDoc.SetExpandRefs( bOldExpandRefs ); + rDoc.SetNoListening( bOldNoListening ); + rDoc.SetAutoCalc( bOldAutoCalc ); } void ScChangeTrack::UpdateReference( ScChangeAction** ppFirstAction, @@ -4070,11 +4070,11 @@ bool ScChangeTrack::SelectContent( ScChangeAction* pAct, bool bOldest ) aBigRange.aEnd.IncRow( nR-1 ); } - if ( !aBigRange.IsValid( pDoc ) ) + if ( !aBigRange.IsValid( &rDoc ) ) return false; ScRange aRange( aBigRange.MakeRange() ); - if ( !pDoc->IsBlockEditable( aRange.aStart.Tab(), aRange.aStart.Col(), + if ( !rDoc.IsBlockEditable( aRange.aStart.Tab(), aRange.aStart.Col(), aRange.aStart.Row(), aRange.aEnd.Col(), aRange.aEnd.Row() ) ) return false; @@ -4091,7 +4091,7 @@ bool ScChangeTrack::SelectContent( ScChangeAction* pAct, bool bOldest ) if ( p->GetType() == SC_CAT_CONTENT ) { // we don't need no recursion here, do we? - bOk &= static_cast<ScChangeActionContent*>(p)->Select( pDoc, this, + bOk &= static_cast<ScChangeActionContent*>(p)->Select( &rDoc, this, bOldest, &aRejectActions ); } else @@ -4102,7 +4102,7 @@ bool ScChangeTrack::SelectContent( ScChangeAction* pAct, bool bOldest ) pL = pL->GetNext(); } - bOk &= pContent->Select( pDoc, this, bOldest, nullptr ); + bOk &= pContent->Select( &rDoc, this, bOldest, nullptr ); // now the matrix is inserted and new content values are ready while ( !aRejectActions.empty() ) @@ -4111,14 +4111,14 @@ bool ScChangeTrack::SelectContent( ScChangeAction* pAct, bool bOldest ) aRejectActions.pop(); ScAddress aPos( pNew->GetBigRange().aStart.MakeAddress() ); ScCellValue aCell; - aCell.assign(*pDoc, aPos); - pNew->SetNewValue(aCell, pDoc); + aCell.assign(rDoc, aPos); + pNew->SetNewValue(aCell, &rDoc); Append( pNew ); } return bOk; } else - return pContent->Select( pDoc, this, bOldest, nullptr ); + return pContent->Select( &rDoc, this, bOldest, nullptr ); } void ScChangeTrack::AcceptAll() @@ -4208,7 +4208,7 @@ bool ScChangeTrack::Reject( } if ( bOk ) { - bRejected = pAct->Reject( pDoc ); + bRejected = pAct->Reject( &rDoc ); if ( bRejected ) { // pRefDoc NULL := Do not save deleted Cells @@ -4227,7 +4227,7 @@ bool ScChangeTrack::Reject( { bTabDel = true; aDelRange = pAct->GetBigRange(); - bTabDelOk = pAct->Reject( pDoc ); + bTabDelOk = pAct->Reject( &rDoc ); bOk = bTabDelOk; if ( bOk ) { @@ -4241,7 +4241,7 @@ bool ScChangeTrack::Reject( if ( bOk ) { aDelRange = pDel->GetOverAllRange(); - bOk = aDelRange.IsValid( pDoc ); + bOk = aDelRange.IsValid( &rDoc ); } bool bOneOk = false; if ( bOk ) @@ -4268,7 +4268,7 @@ bool ScChangeTrack::Reject( do { pDel = static_cast<ScChangeActionDel*>(p); - bOk = pDel->Reject( pDoc ); + bOk = pDel->Reject( &rDoc ); if ( bOk ) { if ( bOneOk ) @@ -4304,7 +4304,7 @@ bool ScChangeTrack::Reject( if ( bOneOk || (bTabDel && bTabDelOk) ) { // Delete Reject made UpdateReference Undo - ScChangeActionIns* pReject = new ScChangeActionIns( pDoc, + ScChangeActionIns* pReject = new ScChangeActionIns( &rDoc, aDelRange.MakeRange() ); pReject->SetRejectAction( nRejectAction ); pReject->SetState( SC_CAS_ACCEPTED ); @@ -4325,7 +4325,7 @@ bool ScChangeTrack::Reject( } if ( bOk ) { - bRejected = pAct->Reject( pDoc ); + bRejected = pAct->Reject( &rDoc ); if ( bRejected ) { ScChangeActionMove* pReject = new ScChangeActionMove( @@ -4348,15 +4348,15 @@ bool ScChangeTrack::Reject( aRange = pAct->GetBigRange().aStart.MakeAddress(); pReject = new ScChangeActionContent( aRange ); ScCellValue aCell; - aCell.assign(*pDoc, aRange.aStart); - pReject->SetOldValue(aCell, pDoc, pDoc); + aCell.assign(rDoc, aRange.aStart); + pReject->SetOldValue(aCell, &rDoc, &rDoc); } - bRejected = pAct->Reject( pDoc ); + bRejected = pAct->Reject( &rDoc ); if ( bRejected && !bRecursion ) { ScCellValue aCell; - aCell.assign(*pDoc, aRange.aStart); - pReject->SetNewValue(aCell, pDoc); + aCell.assign(rDoc, aRange.aStart); + pReject->SetNewValue(aCell, &rDoc); pReject->SetRejectAction( pAct->GetActionNumber() ); pReject->SetState( SC_CAS_ACCEPTED ); Append( pReject ); @@ -4380,7 +4380,7 @@ bool ScChangeTrack::IsLastAction( sal_uLong nNum ) const sal_uLong ScChangeTrack::AddLoadedGenerated( const ScCellValue& rNewCell, const ScBigRange& aBigRange, const OUString& sNewValue ) { - ScChangeActionContent* pAct = new ScChangeActionContent( --nGeneratedMin, rNewCell, aBigRange, pDoc, sNewValue ); + ScChangeActionContent* pAct = new ScChangeActionContent( --nGeneratedMin, rNewCell, aBigRange, &rDoc, sNewValue ); if ( pFirstGeneratedDelContent ) pFirstGeneratedDelContent->pPrev = pAct; pAct->pNext = pFirstGeneratedDelContent; @@ -4409,7 +4409,7 @@ ScChangeTrack* ScChangeTrack::Clone( ScDocument* pDocument ) const return nullptr; } - std::unique_ptr<ScChangeTrack> pClonedTrack(new ScChangeTrack( pDocument )); + std::unique_ptr<ScChangeTrack> pClonedTrack(new ScChangeTrack( *pDocument )); pClonedTrack->SetTimeNanoSeconds( IsTimeNanoSeconds() ); // clone generated actions @@ -4685,7 +4685,7 @@ void ScChangeTrack::MergeActionState( ScChangeAction* pAct, const ScChangeAction } /// Get info about a single ScChangeAction element. -static void lcl_getTrackedChange(ScDocument* pDoc, int nIndex, const ScChangeAction* pAction, tools::JsonWriter& rRedlines) +static void lcl_getTrackedChange(ScDocument& rDoc, int nIndex, const ScChangeAction* pAction, tools::JsonWriter& rRedlines) { if (pAction->GetType() != SC_CAT_CONTENT) return; @@ -4700,7 +4700,7 @@ static void lcl_getTrackedChange(ScDocument* pDoc, int nIndex, const ScChangeAct rRedlines.put("comment", pAction->GetComment()); OUString aDescription; - pAction->GetDescription(aDescription, pDoc, true); + pAction->GetDescription(aDescription, &rDoc, true); rRedlines.put("description", aDescription); OUString sDateTime = utl::toISO8601(pAction->GetDateTimeUTC().GetUNODateTime()); @@ -4715,12 +4715,12 @@ void ScChangeTrack::GetChangeTrackInfo(tools::JsonWriter& aRedlines) if (pAction) { int i = 0; - lcl_getTrackedChange(pDoc, i++, pAction, aRedlines); + lcl_getTrackedChange(rDoc, i++, pAction, aRedlines); ScChangeAction* pLastAction = GetLast(); while (pAction != pLastAction) { pAction = pAction->GetNext(); - lcl_getTrackedChange(pDoc, i++, pAction, aRedlines); + lcl_getTrackedChange(rDoc, i++, pAction, aRedlines); } } } diff --git a/sc/source/filter/oox/revisionfragment.cxx b/sc/source/filter/oox/revisionfragment.cxx index bb3f686e0ef8..ed0e5ddd9be6 100644 --- a/sc/source/filter/oox/revisionfragment.cxx +++ b/sc/source/filter/oox/revisionfragment.cxx @@ -245,7 +245,7 @@ void RevisionHeadersFragment::onEndElement() void RevisionHeadersFragment::finalizeImport() { ScDocument& rDoc = getScDocument(); - std::unique_ptr<ScChangeTrack> pCT(new ScChangeTrack(&rDoc)); + std::unique_ptr<ScChangeTrack> pCT(new ScChangeTrack(rDoc)); OUString aSelfUser = pCT->GetUser(); // owner of this document. pCT->SetUseFixDateTime(true); diff --git a/sc/source/filter/xcl97/XclImpChangeTrack.cxx b/sc/source/filter/xcl97/XclImpChangeTrack.cxx index 6157de77435f..435cca766496 100644 --- a/sc/source/filter/xcl97/XclImpChangeTrack.cxx +++ b/sc/source/filter/xcl97/XclImpChangeTrack.cxx @@ -59,7 +59,7 @@ XclImpChangeTrack::XclImpChangeTrack( const XclImpRoot& rRoot, const XclImpStrea xInStrm->Seek( STREAM_SEEK_TO_BEGIN ); pStrm.reset( new XclImpStream( *xInStrm, GetRoot() ) ); pStrm->CopyDecrypterFrom( rBookStrm ); - pChangeTrack.reset(new ScChangeTrack( &GetDoc() )); + pChangeTrack.reset(new ScChangeTrack( GetDoc() )); sOldUsername = pChangeTrack->GetUser(); pChangeTrack->SetUseFixDateTime( true ); diff --git a/sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx b/sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx index c3d505143536..37becac3a72d 100644 --- a/sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx +++ b/sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx @@ -48,7 +48,7 @@ ScMyCellInfo::ScMyCellInfo( ScMyCellInfo::~ScMyCellInfo() {} -const ScCellValue& ScMyCellInfo::CreateCell( ScDocument* pDoc ) +const ScCellValue& ScMyCellInfo::CreateCell(ScDocument& rDoc) { if (!maCell.isEmpty()) return maCell; @@ -57,9 +57,9 @@ const ScCellValue& ScMyCellInfo::CreateCell( ScDocument* pDoc ) { ScAddress aPos; sal_Int32 nOffset(0); - ScRangeStringConverter::GetAddressFromString(aPos, sFormulaAddress, pDoc, ::formula::FormulaGrammar::CONV_OOO, nOffset); + ScRangeStringConverter::GetAddressFromString(aPos, sFormulaAddress, &rDoc, ::formula::FormulaGrammar::CONV_OOO, nOffset); maCell.meType = CELLTYPE_FORMULA; - maCell.mpFormula = new ScFormulaCell(pDoc, aPos, sFormula, eGrammar, nMatrixFlag); + maCell.mpFormula = new ScFormulaCell(rDoc, aPos, sFormula, eGrammar, nMatrixFlag); maCell.mpFormula->SetMatColsRows(static_cast<SCCOL>(nMatrixCols), static_cast<SCROW>(nMatrixRows)); } @@ -67,10 +67,10 @@ const ScCellValue& ScMyCellInfo::CreateCell( ScDocument* pDoc ) { sal_uInt32 nFormat(0); if (nType == css::util::NumberFormat::DATE) - nFormat = pDoc->GetFormatTable()->GetStandardFormat( SvNumFormatType::DATE, ScGlobal::eLnge ); + nFormat = rDoc.GetFormatTable()->GetStandardFormat( SvNumFormatType::DATE, ScGlobal::eLnge ); else if (nType == css::util::NumberFormat::TIME) - nFormat = pDoc->GetFormatTable()->GetStandardFormat( SvNumFormatType::TIME, ScGlobal::eLnge ); - pDoc->GetFormatTable()->GetInputLineString(fValue, nFormat, sInputString); + nFormat = rDoc.GetFormatTable()->GetStandardFormat( SvNumFormatType::TIME, ScGlobal::eLnge ); + rDoc.GetFormatTable()->GetInputLineString(fValue, nFormat, sInputString); } return maCell; @@ -142,7 +142,6 @@ ScMyRejAction::~ScMyRejAction() ScXMLChangeTrackingImportHelper::ScXMLChangeTrackingImportHelper() : aActions(), - pDoc(nullptr), pTrack(nullptr), nMultiSpanned(0), nMultiSpannedSlaveCount(0) @@ -458,13 +457,13 @@ std::unique_ptr<ScChangeAction> ScXMLChangeTrackingImportHelper::CreateRejection pAction->aBigRange, aUser, aDateTime, sComment); } -std::unique_ptr<ScChangeAction> ScXMLChangeTrackingImportHelper::CreateContentAction(const ScMyContentAction* pAction) +std::unique_ptr<ScChangeAction> ScXMLChangeTrackingImportHelper::CreateContentAction(const ScMyContentAction* pAction, ScDocument& rDoc) { ScCellValue aCell; OUString sInputString; if (pAction->pCellInfo) { - aCell = pAction->pCellInfo->CreateCell(pDoc); + aCell = pAction->pCellInfo->CreateCell(rDoc); sInputString = pAction->pCellInfo->sInputString; } @@ -475,10 +474,10 @@ std::unique_ptr<ScChangeAction> ScXMLChangeTrackingImportHelper::CreateContentAc OUString sComment (pAction->aInfo.sComment); return std::make_unique<ScChangeActionContent>(pAction->nActionNumber, pAction->nActionState, pAction->nRejectingNumber, - pAction->aBigRange, aUser, aDateTime, sComment, aCell, pDoc, sInputString); + pAction->aBigRange, aUser, aDateTime, sComment, aCell, &rDoc, sInputString); } -void ScXMLChangeTrackingImportHelper::CreateGeneratedActions(std::vector<ScMyGenerated>& rList) +void ScXMLChangeTrackingImportHelper::CreateGeneratedActions(std::vector<ScMyGenerated>& rList, ScDocument& rDoc) { for (ScMyGenerated & rGenerated : rList) { @@ -486,7 +485,7 @@ void ScXMLChangeTrackingImportHelper::CreateGeneratedActions(std::vector<ScMyGen { ScCellValue aCell; if (rGenerated.pCellInfo) - aCell = rGenerated.pCellInfo->CreateCell(pDoc); + aCell = rGenerated.pCellInfo->CreateCell(rDoc); if (!aCell.isEmpty()) { @@ -575,7 +574,7 @@ void ScXMLChangeTrackingImportHelper::SetMovementDependencies(ScMyMoveAction* pA } } -void ScXMLChangeTrackingImportHelper::SetContentDependencies(const ScMyContentAction* pAction, ScChangeActionContent* pActContent) +void ScXMLChangeTrackingImportHelper::SetContentDependencies(const ScMyContentAction* pAction, ScChangeActionContent* pActContent, ScDocument& rDoc) { if (!pActContent || !pAction->nPreviousAction) return; @@ -593,10 +592,10 @@ void ScXMLChangeTrackingImportHelper::SetContentDependencies(const ScMyContentAc if (rOldCell.isEmpty()) return; - pPrevActContent->SetNewCell(rOldCell, pDoc, EMPTY_OUSTRING); + pPrevActContent->SetNewCell(rOldCell, &rDoc, EMPTY_OUSTRING); } -void ScXMLChangeTrackingImportHelper::SetDependencies(ScMyBaseAction* pAction) +void ScXMLChangeTrackingImportHelper::SetDependencies(ScMyBaseAction* pAction, ScDocument& rDoc) { ScChangeAction* pAct = pTrack->GetAction(pAction->nActionNumber); if (pAct) @@ -619,12 +618,12 @@ void ScXMLChangeTrackingImportHelper::SetDependencies(ScMyBaseAction* pAction) ScChangeActionContent* pContentAct = static_cast<ScChangeActionContent*>(pDeletedAct); if (rDeleted.pCellInfo) { - const ScCellValue& rCell = rDeleted.pCellInfo->CreateCell(pDoc); + const ScCellValue& rCell = rDeleted.pCellInfo->CreateCell(rDoc); if (!rCell.equalsWithoutFormat(pContentAct->GetNewCell())) { // #i40704# Don't overwrite SetNewCell result by calling SetNewValue, // instead pass the input string to SetNewCell. - pContentAct->SetNewCell(rCell, pDoc, rDeleted.pCellInfo->sInputString); + pContentAct->SetNewCell(rCell, &rDoc, rDeleted.pCellInfo->sInputString); } } } @@ -637,7 +636,7 @@ void ScXMLChangeTrackingImportHelper::SetDependencies(ScMyBaseAction* pAction) else if (pAction->nActionType == SC_CAT_MOVE) SetMovementDependencies(static_cast<ScMyMoveAction*>(pAction), static_cast<ScChangeActionMove*>(pAct)); else if (pAction->nActionType == SC_CAT_CONTENT) - SetContentDependencies(static_cast<ScMyContentAction*>(pAction), static_cast<ScChangeActionContent*>(pAct)); + SetContentDependencies(static_cast<ScMyContentAction*>(pAction), static_cast<ScChangeActionContent*>(pAct), rDoc); } else { @@ -645,7 +644,7 @@ void ScXMLChangeTrackingImportHelper::SetDependencies(ScMyBaseAction* pAction) } } -void ScXMLChangeTrackingImportHelper::SetNewCell(const ScMyContentAction* pAction) +void ScXMLChangeTrackingImportHelper::SetNewCell(const ScMyContentAction* pAction, ScDocument& rDoc) { ScChangeAction* pChangeAction = pTrack->GetAction(pAction->nActionNumber); if (!pChangeAction) @@ -658,23 +657,23 @@ void ScXMLChangeTrackingImportHelper::SetNewCell(const ScMyContentAction* pActio sal_Int32 nCol, nRow, nTab, nCol2, nRow2, nTab2; pAction->aBigRange.GetVars(nCol, nRow, nTab, nCol2, nRow2, nTab2); - if ((nCol >= 0) && (nCol <= pDoc->MaxCol()) && - (nRow >= 0) && (nRow <= pDoc->MaxRow()) && + if ((nCol >= 0) && (nCol <= rDoc.MaxCol()) && + (nRow >= 0) && (nRow <= rDoc.MaxRow()) && (nTab >= 0) && (nTab <= MAXTAB)) { ScAddress aAddress (static_cast<SCCOL>(nCol), static_cast<SCROW>(nRow), static_cast<SCTAB>(nTab)); ScCellValue aCell; - aCell.assign(*pDoc, aAddress); + aCell.assign(rDoc, aAddress); if (!aCell.isEmpty()) { ScCellValue aNewCell; if (aCell.meType != CELLTYPE_FORMULA) { aNewCell = aCell; - pChangeActionContent->SetNewCell(aNewCell, pDoc, EMPTY_OUSTRING); - pChangeActionContent->SetNewValue(aCell, pDoc); + pChangeActionContent->SetNewCell(aNewCell, &rDoc, EMPTY_OUSTRING); + pChangeActionContent->SetNewValue(aCell, &rDoc); } else { @@ -700,7 +699,7 @@ void ScXMLChangeTrackingImportHelper::SetNewCell(const ScMyContentAction* pActio } aNewCell.meType = CELLTYPE_FORMULA; - aNewCell.mpFormula = new ScFormulaCell(pDoc, aAddress, sFormula2,formula::FormulaGrammar::GRAM_ODFF, nMatrixFlag); + aNewCell.mpFormula = new ScFormulaCell(rDoc, aAddress, sFormula2,formula::FormulaGrammar::GRAM_ODFF, nMatrixFlag); if (nMatrixFlag == ScMatrixMode::Formula) { SCCOL nCols; @@ -709,7 +708,7 @@ void ScXMLChangeTrackingImportHelper::SetNewCell(const ScMyContentAction* pActio aNewCell.mpFormula->SetMatColsRows(nCols, nRows); } aNewCell.mpFormula->SetInChangeTrack(true); - pChangeActionContent->SetNewCell(aNewCell, pDoc, EMPTY_OUSTRING); + pChangeActionContent->SetNewCell(aNewCell, &rDoc, EMPTY_OUSTRING); // #i40704# don't overwrite the formula string via SetNewValue() } } @@ -720,13 +719,12 @@ void ScXMLChangeTrackingImportHelper::SetNewCell(const ScMyContentAction* pActio } } -void ScXMLChangeTrackingImportHelper::CreateChangeTrack(ScDocument* pTempDoc) +void ScXMLChangeTrackingImportHelper::CreateChangeTrack(ScDocument* pDoc) { - pDoc = pTempDoc; if (!pDoc) return; - pTrack = new ScChangeTrack(pDoc, aUsers); + pTrack = new ScChangeTrack(*pDoc, aUsers); // old files didn't store nanoseconds, disable until encountered pTrack->SetTimeNanoSeconds( false ); @@ -749,19 +747,19 @@ void ScXMLChangeTrackingImportHelper::CreateChangeTrack(ScDocument* pTempDoc) { ScMyDelAction* pDelAct = static_cast<ScMyDelAction*>(rAction.get()); pAction = CreateDeleteAction(pDelAct); - CreateGeneratedActions(pDelAct->aGeneratedList); + CreateGeneratedActions(pDelAct->aGeneratedList, *pDoc); } break; case SC_CAT_MOVE: { ScMyMoveAction* pMovAct = static_cast<ScMyMoveAction*>(rAction.get()); pAction = CreateMoveAction(pMovAct); - CreateGeneratedActions(pMovAct->aGeneratedList); + CreateGeneratedActions(pMovAct->aGeneratedList, *pDoc); } break; case SC_CAT_CONTENT: { - pAction = CreateContentAction(static_cast<ScMyContentAction*>(rAction.get())); + pAction = CreateContentAction(static_cast<ScMyContentAction*>(rAction.get()), *pDoc); } break; case SC_CAT_REJECT: @@ -788,7 +786,7 @@ void ScXMLChangeTrackingImportHelper::CreateChangeTrack(ScDocument* pTempDoc) auto aItr = aActions.begin(); while (aItr != aActions.end()) { - SetDependencies(aItr->get()); + SetDependencies(aItr->get(), *pDoc); if ((*aItr)->nActionType == SC_CAT_CONTENT) ++aItr; @@ -799,7 +797,7 @@ void ScXMLChangeTrackingImportHelper::CreateChangeTrack(ScDocument* pTempDoc) for (const auto& rxAction : aActions) { OSL_ENSURE(rxAction->nActionType == SC_CAT_CONTENT, "wrong action type"); - SetNewCell(static_cast<ScMyContentAction*>(rxAction.get())); + SetNewCell(static_cast<ScMyContentAction*>(rxAction.get()), *pDoc); } aActions.clear(); if (aProtect.hasElements()) diff --git a/sc/source/filter/xml/XMLChangeTrackingImportHelper.hxx b/sc/source/filter/xml/XMLChangeTrackingImportHelper.hxx index 58a4a87147c4..4c318df17919 100644 --- a/sc/source/filter/xml/XMLChangeTrackingImportHelper.hxx +++ b/sc/source/filter/xml/XMLChangeTrackingImportHelper.hxx @@ -55,7 +55,7 @@ struct ScMyCellInfo const sal_Int32 nMatrixCols, const sal_Int32 nMatrixRows ); ~ScMyCellInfo(); - const ScCellValue& CreateCell( ScDocument* pDoc ); + const ScCellValue& CreateCell( ScDocument& rDoc ); }; struct ScMyDeleted @@ -165,7 +165,6 @@ class ScXMLChangeTrackingImportHelper std::set<OUString> aUsers; std::vector<std::unique_ptr<ScMyBaseAction>> aActions; css::uno::Sequence<sal_Int8> aProtect; - ScDocument* pDoc; ScChangeTrack* pTrack; std::unique_ptr<ScMyBaseAction> pCurrentAction; sal_Int16 nMultiSpanned; @@ -177,9 +176,9 @@ private: std::unique_ptr<ScChangeAction> CreateDeleteAction(const ScMyDelAction* pAction); std::unique_ptr<ScChangeAction> CreateMoveAction(const ScMyMoveAction* pAction); std::unique_ptr<ScChangeAction> CreateRejectionAction(const ScMyRejAction* pAction); - std::unique_ptr<ScChangeAction> CreateContentAction(const ScMyContentAction* pAction); + std::unique_ptr<ScChangeAction> CreateContentAction(const ScMyContentAction* pAction, ScDocument& rDoc); - void CreateGeneratedActions(std::vector<ScMyGenerated>& rList); + void CreateGeneratedActions(std::vector<ScMyGenerated>& rList, ScDocument& rDoc); public: ScXMLChangeTrackingImportHelper(); @@ -211,10 +210,10 @@ public: void SetDeletionDependencies(ScMyDelAction* pAction, ScChangeActionDel* pDelAct); void SetMovementDependencies(ScMyMoveAction* pAction, ScChangeActionMove* pMoveAct); - void SetContentDependencies(const ScMyContentAction* pAction, ScChangeActionContent* pActContent); - void SetDependencies(ScMyBaseAction* pAction); + void SetContentDependencies(const ScMyContentAction* pAction, ScChangeActionContent* pActContent, ScDocument& rDoc); + void SetDependencies(ScMyBaseAction* pAction, ScDocument& rDoc); - void SetNewCell(const ScMyContentAction* pAction); + void SetNewCell(const ScMyContentAction* pAction, ScDocument& rDoc); void CreateChangeTrack(ScDocument* pDoc); }; diff --git a/sc/source/filter/xml/xmlimprt.cxx b/sc/source/filter/xml/xmlimprt.cxx index 4270c73f7adc..142d794c26da 100644 --- a/sc/source/filter/xml/xmlimprt.cxx +++ b/sc/source/filter/xml/xmlimprt.cxx @@ -986,7 +986,7 @@ void ScXMLImport::SetConfigurationSettings(const uno::Sequence<beans::PropertyVa else { std::set<OUString> aUsers; - std::unique_ptr<ScChangeTrack> pTrack( new ScChangeTrack(pDoc, aUsers) ); + std::unique_ptr<ScChangeTrack> pTrack( new ScChangeTrack(*pDoc, aUsers) ); pTrack->SetProtection(aPass); pDoc->SetChangeTrack(std::move(pTrack)); } diff --git a/sc/source/ui/StatisticsDialogs/AnalysisOfVarianceDialog.cxx b/sc/source/ui/StatisticsDialogs/AnalysisOfVarianceDialog.cxx index 23f9659c68c5..2ea07a95cbb1 100644 --- a/sc/source/ui/StatisticsDialogs/AnalysisOfVarianceDialog.cxx +++ b/sc/source/ui/StatisticsDialogs/AnalysisOfVarianceDialog.cxx @@ -539,7 +539,7 @@ void ScAnalysisOfVarianceDialog::AnovaTwoFactor(AddressWalkerWriter& output, For ScRange ScAnalysisOfVarianceDialog::ApplyOutput(ScDocShell* pDocShell) { - AddressWalkerWriter output(mOutputAddress, pDocShell, &mDocument, + AddressWalkerWriter output(mOutputAddress, pDocShell, mDocument, formula::FormulaGrammar::mergeToGrammar(formula::FormulaGrammar::GRAM_ENGLISH, mAddressDetails.eConv)); FormulaTemplate aTemplate(&mDocument); diff --git a/sc/source/ui/StatisticsDialogs/ChiSquareTestDialog.cxx b/sc/source/ui/StatisticsDialogs/ChiSquareTestDialog.cxx index e2de2db8246d..da12b328d5fb 100644 --- a/sc/source/ui/StatisticsDialogs/ChiSquareTestDialog.cxx +++ b/sc/source/ui/StatisticsDialogs/ChiSquareTestDialog.cxx @@ -39,7 +39,7 @@ const char* ScChiSquareTestDialog::GetUndoNameId() ScRange ScChiSquareTestDialog::ApplyOutput(ScDocShell* pDocShell) { - AddressWalkerWriter aOutput(mOutputAddress, pDocShell, &mDocument, + AddressWalkerWriter aOutput(mOutputAddress, pDocShell, mDocument, formula::FormulaGrammar::mergeToGrammar( formula::FormulaGrammar::GRAM_ENGLISH, mAddressDetails.eConv)); FormulaTemplate aTemplate(&mDocument); diff --git a/sc/source/ui/StatisticsDialogs/DescriptiveStatisticsDialog.cxx b/sc/source/ui/StatisticsDialogs/DescriptiveStatisticsDialog.cxx index f82b04bdf17a..9c3d7fba1f8e 100644 --- a/sc/source/ui/StatisticsDialogs/DescriptiveStatisticsDialog.cxx +++ b/sc/source/ui/StatisticsDialogs/DescriptiveStatisticsDialog.cxx @@ -70,7 +70,7 @@ const char* ScDescriptiveStatisticsDialog::GetUndoNameId() ScRange ScDescriptiveStatisticsDialog::ApplyOutput(ScDocShell* pDocShell) { - AddressWalkerWriter aOutput(mOutputAddress, pDocShell, &mDocument, + AddressWalkerWriter aOutput(mOutputAddress, pDocShell, mDocument, formula::FormulaGrammar::mergeToGrammar( formula::FormulaGrammar::GRAM_ENGLISH, mAddressDetails.eConv)); FormulaTemplate aTemplate(&mDocument); diff --git a/sc/source/ui/StatisticsDialogs/ExponentialSmoothingDialog.cxx b/sc/source/ui/StatisticsDialogs/ExponentialSmoothingDialog.cxx index 8e87c11fb80f..376b9db3b6d7 100644 --- a/sc/source/ui/StatisticsDialogs/ExponentialSmoothingDialog.cxx +++ b/sc/source/ui/StatisticsDialogs/ExponentialSmoothingDialog.cxx @@ -43,7 +43,7 @@ const char* ScExponentialSmoothingDialog::GetUndoNameId() ScRange ScExponentialSmoothingDialog::ApplyOutput(ScDocShell* pDocShell) { - AddressWalkerWriter output(mOutputAddress, pDocShell, &mDocument, + AddressWalkerWriter output(mOutputAddress, pDocShell, mDocument, formula::FormulaGrammar::mergeToGrammar( formula::FormulaGrammar::GRAM_ENGLISH, mAddressDetails.eConv)); FormulaTemplate aTemplate(&mDocument); diff --git a/sc/source/ui/StatisticsDialogs/FTestDialog.cxx b/sc/source/ui/StatisticsDialogs/FTestDialog.cxx index 1fc75ee7f2b2..f84c7807e537 100644 --- a/sc/source/ui/StatisticsDialogs/FTestDialog.cxx +++ b/sc/source/ui/StatisticsDialogs/FTestDialog.cxx @@ -41,7 +41,7 @@ const char* ScFTestDialog::GetUndoNameId() ScRange ScFTestDialog::ApplyOutput(ScDocShell* pDocShell) { - AddressWalkerWriter aOutput(mOutputAddress, pDocShell, &mDocument, + AddressWalkerWriter aOutput(mOutputAddress, pDocShell, mDocument, formula::FormulaGrammar::mergeToGrammar(formula::FormulaGrammar::GRAM_ENGLISH, mAddressDetails.eConv)); FormulaTemplate aTemplate(&mDocument); diff --git a/sc/source/ui/StatisticsDialogs/FourierAnalysisDialog.cxx b/sc/source/ui/StatisticsDialogs/FourierAnalysisDialog.cxx index c5bf54464450..cfd42a02d28c 100644 --- a/sc/source/ui/StatisticsDialogs/FourierAnalysisDialog.cxx +++ b/sc/source/ui/StatisticsDialogs/FourierAnalysisDialog.cxx @@ -63,7 +63,7 @@ const char* ScFourierAnalysisDialog::GetUndoNameId() { return STR_FOURIER_ANALYS ScRange ScFourierAnalysisDialog::ApplyOutput(ScDocShell* pDocShell) { getOptions(); - AddressWalkerWriter aOutput(mOutputAddress, pDocShell, &mDocument, + AddressWalkerWriter aOutput(mOutputAddress, pDocShell, mDocument, formula::FormulaGrammar::mergeToGrammar( formula::FormulaGrammar::GRAM_ENGLISH, mAddressDetails.eConv)); FormulaTemplate aTemplate(&mDocument); diff --git a/sc/source/ui/StatisticsDialogs/MatrixComparisonGenerator.cxx b/sc/source/ui/StatisticsDialogs/MatrixComparisonGenerator.cxx index bb8e43efeded..447a89c78608 100644 --- a/sc/source/ui/StatisticsDialogs/MatrixComparisonGenerator.cxx +++ b/sc/source/ui/StatisticsDialogs/MatrixComparisonGenerator.cxx @@ -57,7 +57,7 @@ const char* ScMatrixComparisonGenerator::GetUndoNameId() ScRange ScMatrixComparisonGenerator::ApplyOutput(ScDocShell* pDocShell) { - AddressWalkerWriter output(mOutputAddress, pDocShell, &mDocument, + AddressWalkerWriter output(mOutputAddress, pDocShell, mDocument, formula::FormulaGrammar::mergeToGrammar( formula::FormulaGrammar::GRAM_ENGLISH, mAddressDetails.eConv)); FormulaTemplate aTemplate(&mDocument); diff --git a/sc/source/ui/StatisticsDialogs/MovingAverageDialog.cxx b/sc/source/ui/StatisticsDialogs/MovingAverageDialog.cxx index 07e104f39328..343e4512f891 100644 --- a/sc/source/ui/StatisticsDialogs/MovingAverageDialog.cxx +++ b/sc/source/ui/StatisticsDialogs/MovingAverageDialog.cxx @@ -44,7 +44,7 @@ const char* ScMovingAverageDialog::GetUndoNameId() ScRange ScMovingAverageDialog::ApplyOutput(ScDocShell* pDocShell) { - AddressWalkerWriter output(mOutputAddress, pDocShell, &mDocument, + AddressWalkerWriter output(mOutputAddress, pDocShell, mDocument, formula::FormulaGrammar::mergeToGrammar( formula::FormulaGrammar::GRAM_ENGLISH, mAddressDetails.eConv)); FormulaTemplate aTemplate(&mDocument); diff --git a/sc/source/ui/StatisticsDialogs/RegressionDialog.cxx b/sc/source/ui/StatisticsDialogs/RegressionDialog.cxx index f3ba7ab8a7b4..ef5cd8f28a76 100644 --- a/sc/source/ui/StatisticsDialogs/RegressionDialog.cxx +++ b/sc/source/ui/StatisticsDialogs/RegressionDialog.cxx @@ -170,7 +170,7 @@ const char* ScRegressionDialog::GetUndoNameId() ScRange ScRegressionDialog::ApplyOutput(ScDocShell* pDocShell) { - AddressWalkerWriter aOutput(mOutputAddress, pDocShell, &mDocument, + AddressWalkerWriter aOutput(mOutputAddress, pDocShell, mDocument, formula::FormulaGrammar::mergeToGrammar( formula::FormulaGrammar::GRAM_ENGLISH, mAddressDetails.eConv)); FormulaTemplate aTemplate(&mDocument); aTemplate.autoReplaceUses3D(mbUse3DAddresses); diff --git a/sc/source/ui/StatisticsDialogs/TTestDialog.cxx b/sc/source/ui/StatisticsDialogs/TTestDialog.cxx index 80cb6608e31d..6d720a1f273f 100644 --- a/sc/source/ui/StatisticsDialogs/TTestDialog.cxx +++ b/sc/source/ui/StatisticsDialogs/TTestDialog.cxx @@ -41,7 +41,7 @@ const char* ScTTestDialog::GetUndoNameId() ScRange ScTTestDialog::ApplyOutput(ScDocShell* pDocShell) { - AddressWalkerWriter aOutput(mOutputAddress, pDocShell, &mDocument, + AddressWalkerWriter aOutput(mOutputAddress, pDocShell, mDocument, formula::FormulaGrammar::mergeToGrammar( formula::FormulaGrammar::GRAM_ENGLISH, mAddressDetails.eConv)); FormulaTemplate aTemplate(&mDocument); diff --git a/sc/source/ui/StatisticsDialogs/TableFillingAndNavigationTools.cxx b/sc/source/ui/StatisticsDialogs/TableFillingAndNavigationTools.cxx index 4ac9ee4d2f76..1d2d087bfc7a 100644 --- a/sc/source/ui/StatisticsDialogs/TableFillingAndNavigationTools.cxx +++ b/sc/source/ui/StatisticsDialogs/TableFillingAndNavigationTools.cxx @@ -149,18 +149,18 @@ void AddressWalker::push(SCCOL aRelativeCol, SCROW aRelativeRow, SCTAB aRelative mAddressStack.push_back(mCurrentAddress); } -AddressWalkerWriter::AddressWalkerWriter(const ScAddress& aInitialAddress, ScDocShell* pDocShell, ScDocument* pDocument, +AddressWalkerWriter::AddressWalkerWriter(const ScAddress& aInitialAddress, ScDocShell* pDocShell, ScDocument& rDocument, formula::FormulaGrammar::Grammar eGrammar ) : AddressWalker(aInitialAddress), mpDocShell(pDocShell), - mpDocument(pDocument), + mrDocument(rDocument), meGrammar(eGrammar) {} void AddressWalkerWriter::writeFormula(const OUString& aFormula) { mpDocShell->GetDocFunc().SetFormulaCell(mCurrentAddress, - new ScFormulaCell(mpDocument, mCurrentAddress, aFormula, meGrammar), true); + new ScFormulaCell(mrDocument, mCurrentAddress, aFormula, meGrammar), true); } void AddressWalkerWriter::writeFormulas(const std::vector<OUString>& rFormulas) @@ -178,7 +178,7 @@ void AddressWalkerWriter::writeFormulas(const std::vector<OUString>& rFormulas) ScAddress aAddr(mCurrentAddress); for (size_t nIdx = 0; nIdx < nLength; ++nIdx) { - aFormulaCells[nIdx] = new ScFormulaCell(mpDocument, aAddr, rFormulas[nIdx], meGrammar); + aFormulaCells[nIdx] = new ScFormulaCell(mrDocument, aAddr, rFormulas[nIdx], meGrammar); aAddr.IncRow(1); } @@ -209,7 +209,7 @@ void AddressWalkerWriter::writeString(const char* aCharArray) void AddressWalkerWriter::writeBoldString(const OUString& aString) { - ScFieldEditEngine& rEngine = mpDocument->GetEditEngine(); + ScFieldEditEngine& rEngine = mrDocument.GetEditEngine(); rEngine.SetTextCurrentDefaults(aString); SfxItemSet aItemSet = rEngine.GetEmptyItemSet(); SvxWeightItem aWeight(WEIGHT_BOLD, EE_CHAR_WEIGHT); diff --git a/sc/source/ui/StatisticsDialogs/ZTestDialog.cxx b/sc/source/ui/StatisticsDialogs/ZTestDialog.cxx index 6eb11ac5732f..974a47989283 100644 --- a/sc/source/ui/StatisticsDialogs/ZTestDialog.cxx +++ b/sc/source/ui/StatisticsDialogs/ZTestDialog.cxx @@ -41,7 +41,7 @@ const char* ScZTestDialog::GetUndoNameId() ScRange ScZTestDialog::ApplyOutput(ScDocShell* pDocShell) { - AddressWalkerWriter aOutput(mOutputAddress, pDocShell, &mDocument, + AddressWalkerWriter aOutput(mOutputAddress, pDocShell, mDocument, formula::FormulaGrammar::mergeToGrammar( formula::FormulaGrammar::GRAM_ENGLISH, mAddressDetails.eConv)); FormulaTemplate aTemplate(&mDocument); diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx index 57184a3223e7..a3bfe3096566 100644 --- a/sc/source/ui/docshell/docfunc.cxx +++ b/sc/source/ui/docshell/docfunc.cxx @@ -1238,7 +1238,7 @@ bool ScDocFunc::SetCellText( switch (aRes.meType) { case ScInputStringType::Formula: - bSet = SetFormulaCell(rPos, new ScFormulaCell(&rDoc, rPos, aRes.maText, eGrammar), !bApi); + bSet = SetFormulaCell(rPos, new ScFormulaCell(rDoc, rPos, aRes.maText, eGrammar), !bApi); break; case ScInputStringType::Number: bSet = SetValueCell(rPos, aRes.mfValue, !bApi); diff --git a/sc/source/ui/inc/TableFillingAndNavigationTools.hxx b/sc/source/ui/inc/TableFillingAndNavigationTools.hxx index 9d4e82956a66..d24535c54298 100644 --- a/sc/source/ui/inc/TableFillingAndNavigationTools.hxx +++ b/sc/source/ui/inc/TableFillingAndNavigationTools.hxx @@ -73,10 +73,10 @@ class AddressWalkerWriter : public AddressWalker { public: ScDocShell* mpDocShell; - ScDocument* mpDocument; + ScDocument& mrDocument; formula::FormulaGrammar::Grammar meGrammar; - AddressWalkerWriter(const ScAddress& aInitialAddress, ScDocShell* pDocShell, ScDocument* pDocument, + AddressWalkerWriter(const ScAddress& aInitialAddress, ScDocShell* pDocShell, ScDocument& rDocument, formula::FormulaGrammar::Grammar eGrammar ); void writeFormula(const OUString& aFormula); diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx index a641502d6975..997f953e806c 100644 --- a/sc/source/ui/unoobj/cellsuno.cxx +++ b/sc/source/ui/unoobj/cellsuno.cxx @@ -5986,7 +5986,7 @@ void ScCellObj::InputEnglishString( const OUString& rText ) case ScInputStringType::Formula: rFunc.SetFormulaCell( aCellPos, - new ScFormulaCell(&rDoc, aCellPos, aRes.maText, formula::FormulaGrammar::GRAM_API), + new ScFormulaCell(rDoc, aCellPos, aRes.maText, formula::FormulaGrammar::GRAM_API), false); break; case ScInputStringType::Number: diff --git a/sc/source/ui/view/viewfun2.cxx b/sc/source/ui/view/viewfun2.cxx index 048181f3cb7e..fcf925afaad9 100644 --- a/sc/source/ui/view/viewfun2.cxx +++ b/sc/source/ui/view/viewfun2.cxx @@ -905,7 +905,7 @@ void ScViewFunc::EnterBlock( const OUString& rString, const EditTextObject* pDat if (aNewStr[0] == '=') // Formula ? { // SetString not possible, because in Clipboard-Documents nothing will be compiled! - pInsDoc->SetFormulaCell(aPos, new ScFormulaCell(&rDoc, aPos, aNewStr)); + pInsDoc->SetFormulaCell(aPos, new ScFormulaCell(rDoc, aPos, aNewStr)); } else if ( pData ) { diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx index 0f363c0bd970..b60bf2c35a64 100644 --- a/sc/source/ui/view/viewfunc.cxx +++ b/sc/source/ui/view/viewfunc.cxx @@ -769,7 +769,7 @@ void ScViewFunc::EnterMatrix( const OUString& rString, ::formula::FormulaGrammar ScDocument& rDoc = rData.GetDocument(); SCTAB nTab = rData.GetTabNo(); - ScFormulaCell aFormCell( &rDoc, ScAddress(nCol,nRow,nTab), rString, eGram, ScMatrixMode::Formula ); + ScFormulaCell aFormCell( rDoc, ScAddress(nCol,nRow,nTab), rString, eGram, ScMatrixMode::Formula ); SCSIZE nSizeX; SCSIZE nSizeY; |