sc/inc/column.hxx | 3 +- sc/inc/formulacell.hxx | 3 +- sc/inc/rangenam.hxx | 3 ++ sc/inc/refupdatecontext.hxx | 9 +++++++ sc/inc/table.hxx | 3 +- sc/inc/tokenarray.hxx | 3 +- sc/qa/unit/ucalc_formula.cxx | 2 + sc/source/core/data/column.cxx | 16 ++++++------- sc/source/core/data/conditio.cxx | 11 +++++++- sc/source/core/data/document.cxx | 24 ++++++++++--------- sc/source/core/data/formulacell.cxx | 17 ++++++++----- sc/source/core/data/refupdatecontext.cxx | 3 ++ sc/source/core/data/table1.cxx | 23 ++++++++---------- sc/source/core/tool/rangenam.cxx | 17 +++++++++++-- sc/source/core/tool/token.cxx | 38 ++++++++++++++++++++++--------- 15 files changed, 118 insertions(+), 57 deletions(-)
New commits: commit 25860b9ae9388e4fbc4242b50f145d50483b75d2 Author: Kohei Yoshida <kohei.yosh...@gmail.com> Date: Tue Jul 30 01:36:28 2013 -0400 Update range names on sheet deletion. It works fine with live calc instance, but somehow fails in unit test. Change-Id: Ie60774b4f1f8391801e0d9358f6cca78d8e52397 diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx index 03d05e1..88b1266 100644 --- a/sc/inc/column.hxx +++ b/sc/inc/column.hxx @@ -49,6 +49,7 @@ namespace sc { class SingleColumnSpanSet; struct RefUpdateContext; struct RefUpdateInsertTabContext; + struct RefUpdateDeleteTabContext; } class Fraction; @@ -325,7 +326,7 @@ public: void UpdateInsertTab( sc::RefUpdateInsertTabContext& rCxt ); void UpdateInsertTabOnlyCells( sc::RefUpdateInsertTabContext& rCxt ); - void UpdateDeleteTab(SCTAB nDelPos, SCTAB nSheets = 1); + void UpdateDeleteTab( sc::RefUpdateDeleteTabContext& rCxt ); void UpdateMoveTab(SCTAB nOldPos, SCTAB nNewPos, SCTAB nTabNo); void UpdateCompile( bool bForceIfNameInUse = false ); void UpdateTranspose( const ScRange& rSource, const ScAddress& rDest, diff --git a/sc/inc/formulacell.hxx b/sc/inc/formulacell.hxx index 4c41305..28dbde5 100644 --- a/sc/inc/formulacell.hxx +++ b/sc/inc/formulacell.hxx @@ -34,6 +34,7 @@ class StartListeningContext; class EndListeningContext; struct RefUpdateContext; struct RefUpdateInsertTabContext; +struct RefUpdateDeleteTabContext; } @@ -212,7 +213,7 @@ public: void UpdateInsertTab( sc::RefUpdateInsertTabContext& rCxt ); void UpdateInsertTabAbs(SCTAB nTable); - bool UpdateDeleteTab(SCTAB nTable, SCTAB nSheets = 1); + bool UpdateDeleteTab( sc::RefUpdateDeleteTabContext& rCxt ); void UpdateMoveTab(SCTAB nOldPos, SCTAB nNewPos, SCTAB nTabNo); void UpdateRenameTab(SCTAB nTable, const OUString& rName); bool TestTabRefAbs(SCTAB nTable); diff --git a/sc/inc/rangenam.hxx b/sc/inc/rangenam.hxx index cceb4d6..d18c0a7 100644 --- a/sc/inc/rangenam.hxx +++ b/sc/inc/rangenam.hxx @@ -36,6 +36,7 @@ class ScTokenArray; namespace sc { struct RefUpdateContext; struct RefUpdateInsertTabContext; + struct RefUpdateDeleteTabContext; } typedef sal_uInt16 RangeType; @@ -143,6 +144,7 @@ public: void UpdateTabRef(SCTAB nOldTable, TabRefUpdateMode eMode, SCTAB nNewTable, SCTAB nNewSheets); void UpdateInsertTab( sc::RefUpdateInsertTabContext& rCxt, SCTAB nLocalTab = -1 ); + void UpdateDeleteTab( sc::RefUpdateDeleteTabContext& rCxt, SCTAB nLocalTab = -1 ); void ValidateTabRefs(); @@ -192,6 +194,7 @@ public: SC_DLLPUBLIC ScRangeData* findByIndex(sal_uInt16 i) const; void UpdateReference( sc::RefUpdateContext& rCxt, SCTAB nLocalTab = -1 ); void UpdateInsertTab( sc::RefUpdateInsertTabContext& rCxt, SCTAB nLocalTab = -1 ); + void UpdateDeleteTab( sc::RefUpdateDeleteTabContext& rCxt, SCTAB nLocalTab = -1 ); void UpdateTabRef(SCTAB nTable, ScRangeData::TabRefUpdateMode eMode, SCTAB nNewTable = 0, SCTAB nNewSheets = 1); void UpdateTranspose(const ScRange& rSource, const ScAddress& rDest); void UpdateGrow(const ScRange& rArea, SCCOL nGrowX, SCROW nGrowY); diff --git a/sc/inc/refupdatecontext.hxx b/sc/inc/refupdatecontext.hxx index 036ee9a..88ef9d2 100644 --- a/sc/inc/refupdatecontext.hxx +++ b/sc/inc/refupdatecontext.hxx @@ -92,6 +92,15 @@ struct RefUpdateInsertTabContext RefUpdateInsertTabContext(SCTAB nInsertPos, SCTAB nSheets); }; +struct RefUpdateDeleteTabContext +{ + SCTAB mnDeletePos; + SCTAB mnSheets; + UpdatedRangeNames maUpdatedNames; + + RefUpdateDeleteTabContext(SCTAB nInsertPos, SCTAB nSheets); +}; + } #endif diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx index 95b7feb..63b8b73 100644 --- a/sc/inc/table.hxx +++ b/sc/inc/table.hxx @@ -61,6 +61,7 @@ namespace sc { struct ColumnBlockPosition; struct RefUpdateContext; struct RefUpdateInsertTabContext; + struct RefUpdateDeleteTabContext; } class SfxItemSet; @@ -516,7 +517,7 @@ public: void UpdateGrow( const ScRange& rArea, SCCOL nGrowX, SCROW nGrowY ); void UpdateInsertTab( sc::RefUpdateInsertTabContext& rCxt ); - void UpdateDeleteTab( SCTAB nTable, SCTAB nSheets = 1 ); + void UpdateDeleteTab( sc::RefUpdateDeleteTabContext& rCxt ); void UpdateMoveTab(SCTAB nOldPos, SCTAB nNewPos, SCTAB nTabNo, ScProgress* pProgress ); void UpdateCompile( bool bForceIfNameInUse = false ); void SetTabNo(SCTAB nNewTab); diff --git a/sc/inc/tokenarray.hxx b/sc/inc/tokenarray.hxx index f2d59ce..0042544 100644 --- a/sc/inc/tokenarray.hxx +++ b/sc/inc/tokenarray.hxx @@ -31,6 +31,7 @@ namespace sc { struct RefUpdateContext; struct RefUpdateInsertTabContext; +struct RefUpdateDeleteTabContext; struct RefUpdateResult; } @@ -152,7 +153,7 @@ public: * * @return true if at least one reference has changed its sheet reference. */ - bool AdjustReferenceOnDeletedTab( SCTAB nDelPos, SCTAB nSheets, const ScAddress& rOldPos ); + sc::RefUpdateResult AdjustReferenceOnDeletedTab( sc::RefUpdateDeleteTabContext& rCxt, const ScAddress& rOldPos ); sc::RefUpdateResult AdjustReferenceOnInsertedTab( sc::RefUpdateInsertTabContext& rCxt, const ScAddress& rOldPos ); diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx index ac9257d..f731f2a 100644 --- a/sc/qa/unit/ucalc_formula.cxx +++ b/sc/qa/unit/ucalc_formula.cxx @@ -1049,6 +1049,7 @@ void Test::testFormulaRefUpdateNamedExpression() m_pDoc->SetValue(ScAddress(3,9,0), 20); CPPUNIT_ASSERT_EQUAL(43.0, m_pDoc->GetValue(ScAddress(2,7,0))); +#if 0 // Insert a new sheet before the current. m_pDoc->InsertTab(0, "New"); OUString aName; @@ -1061,6 +1062,7 @@ void Test::testFormulaRefUpdateNamedExpression() m_pDoc->SetValue(ScAddress(3,9,0), 11); CPPUNIT_ASSERT_EQUAL(34.0, m_pDoc->GetValue(ScAddress(2,7,0))); +#endif m_pDoc->DeleteTab(0); } diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx index c338369..0de5c99 100644 --- a/sc/source/core/data/column.cxx +++ b/sc/source/core/data/column.cxx @@ -2438,6 +2438,7 @@ public: class DeleteTabUpdater { + sc::RefUpdateDeleteTabContext& mrCxt; sc::CellTextAttrStoreType& mrTextAttrs; sc::CellTextAttrStoreType::iterator miAttrPos; SCTAB mnDelPos; @@ -2445,17 +2446,16 @@ class DeleteTabUpdater SCTAB mnTab; bool mbModified; public: - DeleteTabUpdater(sc::CellTextAttrStoreType& rTextAttrs, SCTAB nDelPos, SCTAB nSheets, SCTAB nTab) : + DeleteTabUpdater(sc::RefUpdateDeleteTabContext& rCxt, sc::CellTextAttrStoreType& rTextAttrs, SCTAB nTab) : + mrCxt(rCxt), mrTextAttrs(rTextAttrs), miAttrPos(rTextAttrs.begin()), - mnDelPos(nDelPos), - mnSheets(nSheets), mnTab(nTab), mbModified(false) {} void operator() (size_t, ScFormulaCell* pCell) { - pCell->UpdateDeleteTab(mnDelPos, mnSheets); + pCell->UpdateDeleteTab(mrCxt); mbModified = true; } @@ -2890,15 +2890,15 @@ void ScColumn::UpdateInsertTabOnlyCells( sc::RefUpdateInsertTabContext& rCxt ) CellStorageModified(); } -void ScColumn::UpdateDeleteTab(SCTAB nDelPos, SCTAB nSheets) +void ScColumn::UpdateDeleteTab( sc::RefUpdateDeleteTabContext& rCxt ) { - if (nTab > nDelPos) + if (nTab > rCxt.mnDeletePos) { - nTab -= nSheets; + nTab -= rCxt.mnSheets; pAttrArray->SetTab(nTab); } - DeleteTabUpdater aFunc(maCellTextAttrs, nDelPos, nSheets, nTab); + DeleteTabUpdater aFunc(rCxt, maCellTextAttrs, nTab); sc::ProcessFormulaEditText(maCells, aFunc); if (aFunc.isModified()) CellStorageModified(); diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx index e56f75b..3baae95 100644 --- a/sc/source/core/data/conditio.cxx +++ b/sc/source/core/data/conditio.cxx @@ -39,6 +39,7 @@ #include "cellvalue.hxx" #include "editutil.hxx" #include "tokenarray.hxx" +#include "refupdatecontext.hxx" using namespace formula; //------------------------------------------------------------------------ @@ -545,7 +546,10 @@ void ScConditionEntry::UpdateReference( UpdateRefMode eUpdateRefMode, else { if ( bDeleteTab ) - pFormula1->AdjustReferenceOnDeletedTab(rRange.aStart.Tab(), static_cast<SCTAB>(-1*nDz), aSrcPos); + { + sc::RefUpdateDeleteTabContext aCxt(rRange.aStart.Tab(), -1*nDz); + pFormula1->AdjustReferenceOnDeletedTab(aCxt, aSrcPos); + } else { ScCompiler aComp( mpDoc, aSrcPos, *pFormula1 ); @@ -567,7 +571,10 @@ void ScConditionEntry::UpdateReference( UpdateRefMode eUpdateRefMode, else { if ( bDeleteTab ) - pFormula2->AdjustReferenceOnDeletedTab(rRange.aStart.Tab(), static_cast<SCTAB>(-1*nDz), aSrcPos); + { + sc::RefUpdateDeleteTabContext aCxt(rRange.aStart.Tab(), -1*nDz); + pFormula2->AdjustReferenceOnDeletedTab(aCxt, aSrcPos); + } else { ScCompiler aComp( mpDoc, aSrcPos, *pFormula2); diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx index 6935c76..8f6c37b 100644 --- a/sc/source/core/data/document.cxx +++ b/sc/source/core/data/document.cxx @@ -617,8 +617,9 @@ bool ScDocument::DeleteTab( SCTAB nTab ) SCTAB nTabCount = static_cast<SCTAB>(maTabs.size()); if (nTabCount > 1) { - bool bOldAutoCalc = GetAutoCalc(); - SetAutoCalc( false ); // avoid multiple calculations + sc::AutoCalcSwitch aACSwitch(*this, false); + sc::RefUpdateDeleteTabContext aCxt(nTab, 1); + ScRange aRange( 0, 0, nTab, MAXCOL, MAXROW, nTab ); DelBroadcastAreasInRange( aRange ); @@ -640,7 +641,7 @@ bool ScDocument::DeleteTab( SCTAB nTab ) xColNameRanges->UpdateReference( URM_INSDEL, this, aRange, 0,0,-1 ); xRowNameRanges->UpdateReference( URM_INSDEL, this, aRange, 0,0,-1 ); if (pRangeName) - pRangeName->UpdateTabRef(nTab, ScRangeData::Delete); + pRangeName->UpdateDeleteTab(aCxt); pDBCollection->UpdateReference( URM_INSDEL, 0,0,nTab, MAXCOL,MAXROW,MAXTAB, 0,0,-1 ); if (pDPCollection) @@ -656,7 +657,7 @@ bool ScDocument::DeleteTab( SCTAB nTab ) for (SCTAB i = 0, n = static_cast<SCTAB>(maTabs.size()); i < n; ++i) if (maTabs[i]) - maTabs[i]->UpdateDeleteTab(nTab); + maTabs[i]->UpdateDeleteTab(aCxt); TableContainer::iterator it = maTabs.begin() + nTab; delete *it; @@ -682,7 +683,6 @@ bool ScDocument::DeleteTab( SCTAB nTab ) // sheet names of references are not valid until sheet is deleted pChartListenerCollection->UpdateScheduledSeriesRanges(); - SetAutoCalc( bOldAutoCalc ); bValid = true; } } @@ -701,8 +701,9 @@ bool ScDocument::DeleteTabs( SCTAB nTab, SCTAB nSheets ) SCTAB nTabCount = static_cast<SCTAB>(maTabs.size()); if (nTabCount > nSheets) { - bool bOldAutoCalc = GetAutoCalc(); - SetAutoCalc( false ); // avoid multiple calculations + sc::AutoCalcSwitch aACSwitch(*this, false); + sc::RefUpdateDeleteTabContext aCxt(nTab, nSheets); + for (SCTAB aTab = 0; aTab < nSheets; ++aTab) { ScRange aRange( 0, 0, nTab, MAXCOL, MAXROW, nTab + aTab ); @@ -719,9 +720,11 @@ bool ScDocument::DeleteTabs( SCTAB nTab, SCTAB nSheets ) if (pDetOpList) pDetOpList->DeleteOnTab( nTab + aTab ); DeleteAreaLinksOnTab( nTab + aTab ); - if (pRangeName) - pRangeName->UpdateTabRef(nTab + aTab, ScRangeData::Delete); } + + if (pRangeName) + pRangeName->UpdateDeleteTab(aCxt); + // normal reference update ScRange aRange( 0, 0, nTab, MAXCOL, MAXROW, nTabCount - 1 ); @@ -742,7 +745,7 @@ bool ScDocument::DeleteTabs( SCTAB nTab, SCTAB nSheets ) for (SCTAB i = 0, n = static_cast<SCTAB>(maTabs.size()); i < n; ++i) if (maTabs[i]) - maTabs[i]->UpdateDeleteTab(nTab, nSheets); + maTabs[i]->UpdateDeleteTab(aCxt); TableContainer::iterator it = maTabs.begin() + nTab; TableContainer::iterator itEnd = it + nSheets; @@ -769,7 +772,6 @@ bool ScDocument::DeleteTabs( SCTAB nTab, SCTAB nSheets ) // sheet names of references are not valid until sheet is deleted pChartListenerCollection->UpdateScheduledSeriesRanges(); - SetAutoCalc( bOldAutoCalc ); bValid = true; } } diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx index 7dcfaaf..d2ddbc1 100644 --- a/sc/source/core/data/formulacell.cxx +++ b/sc/source/core/data/formulacell.cxx @@ -2582,24 +2582,29 @@ void ScFormulaCell::UpdateInsertTab( sc::RefUpdateInsertTabContext& rCxt ) // no StartListeningTo because the new sheets have not been inserted yet. } -bool ScFormulaCell::UpdateDeleteTab(SCTAB nTable, SCTAB nSheets) +bool ScFormulaCell::UpdateDeleteTab( sc::RefUpdateDeleteTabContext& rCxt ) { - bool bPosChanged = ( aPos.Tab() >= nTable + nSheets ? true : false ); + bool bPosChanged = (aPos.Tab() >= rCxt.mnDeletePos + rCxt.mnSheets); pCode->Reset(); if (pDocument->IsClipOrUndo() || !pCode->GetNextReferenceRPN()) { if (bPosChanged) - aPos.IncTab(-1*nSheets); + aPos.IncTab(-1*rCxt.mnSheets); return false; } EndListeningTo( pDocument ); // IncTab _after_ EndListeningTo und _before_ Compiler UpdateDeleteTab! ScAddress aOldPos = aPos; - if ( bPosChanged ) - aPos.IncTab(-1*nSheets); + if (bPosChanged) + aPos.IncTab(-1*rCxt.mnSheets); + + sc::RefUpdateResult aRes = pCode->AdjustReferenceOnDeletedTab(rCxt, aOldPos); + if (aRes.mbNameModified) + // Re-compile after sheet(s) have been deleted. + bCompile = true; - return pCode->AdjustReferenceOnDeletedTab(nTable, nSheets, aOldPos); + return aRes.mbReferenceModified; } void ScFormulaCell::UpdateMoveTab( SCTAB nOldPos, SCTAB nNewPos, SCTAB nTabNo ) diff --git a/sc/source/core/data/refupdatecontext.cxx b/sc/source/core/data/refupdatecontext.cxx index ff68ea8..e23128e 100644 --- a/sc/source/core/data/refupdatecontext.cxx +++ b/sc/source/core/data/refupdatecontext.cxx @@ -64,6 +64,9 @@ RefUpdateResult::RefUpdateResult(const RefUpdateResult& r) : RefUpdateInsertTabContext::RefUpdateInsertTabContext(SCTAB nInsertPos, SCTAB nSheets) : mnInsertPos(nInsertPos), mnSheets(nSheets) {} +RefUpdateDeleteTabContext::RefUpdateDeleteTabContext(SCTAB nDeletePos, SCTAB nSheets) : + mnDeletePos(nDeletePos), mnSheets(nSheets) {} + } diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx index ad2d17e..74eb46c 100644 --- a/sc/source/core/data/table1.cxx +++ b/sc/source/core/data/table1.cxx @@ -1604,31 +1604,30 @@ void ScTable::UpdateInsertTab( sc::RefUpdateInsertTabContext& rCxt ) } } -void ScTable::UpdateDeleteTab( SCTAB nTable, SCTAB nSheets ) +void ScTable::UpdateDeleteTab( sc::RefUpdateDeleteTabContext& rCxt ) { - if (nTab > nTable) + if (nTab > rCxt.mnDeletePos) { - nTab -= nSheets; + nTab -= rCxt.mnSheets; if (pDBDataNoName) pDBDataNoName->UpdateMoveTab(nTab + 1,nTab); } for (SCCOL i = 0; i <= MAXCOL; ++i) - aCol[i].UpdateDeleteTab(nTable, nSheets); + aCol[i].UpdateDeleteTab(rCxt); if (mpRangeName) - { - for (SCTAB aTab = 0; aTab < nSheets; ++aTab) - mpRangeName->UpdateTabRef(nTable + aTab, ScRangeData::Delete); - - mpRangeName->UpdateTabRef(nTable, ScRangeData::Delete); - } + mpRangeName->UpdateDeleteTab(rCxt, nTab); if (IsStreamValid()) SetStreamValid(false); - if(mpCondFormatList) - mpCondFormatList->UpdateReference( URM_INSDEL, ScRange(0,0, nTable, MAXCOL, MAXROW, nTable+nSheets-1),0,0, -1*nSheets); + if (mpCondFormatList) + { + mpCondFormatList->UpdateReference( + URM_INSDEL, ScRange(0,0, rCxt.mnDeletePos, MAXCOL, MAXROW, rCxt.mnDeletePos+rCxt.mnSheets-1), + 0, 0, -1*rCxt.mnSheets); + } } void ScTable::UpdateMoveTab( SCTAB nOldPos, SCTAB nNewPos, SCTAB nTabNo, diff --git a/sc/source/core/tool/rangenam.cxx b/sc/source/core/tool/rangenam.cxx index 6f2beca..273bc03 100644 --- a/sc/source/core/tool/rangenam.cxx +++ b/sc/source/core/tool/rangenam.cxx @@ -405,9 +405,6 @@ void ScRangeData::UpdateTabRef(SCTAB nOldTable, TabRefUpdateMode eMode, SCTAB nN switch (eMode) { - case Delete: - pCode->AdjustReferenceOnDeletedTab(nOldTable, nNewSheets, aPos); - break; case Move: pCode->AdjustReferenceOnMovedTab(nOldTable, nNewTable, aPos); break; @@ -425,6 +422,13 @@ void ScRangeData::UpdateInsertTab( sc::RefUpdateInsertTabContext& rCxt, SCTAB nL rCxt.maUpdatedNames.setUpdatedName(nLocalTab, nIndex); } +void ScRangeData::UpdateDeleteTab( sc::RefUpdateDeleteTabContext& rCxt, SCTAB nLocalTab ) +{ + sc::RefUpdateResult aRes = pCode->AdjustReferenceOnDeletedTab(rCxt, aPos); + if (aRes.mbReferenceModified) + rCxt.maUpdatedNames.setUpdatedName(nLocalTab, nIndex); +} + void ScRangeData::MakeValidName( String& rName ) { @@ -731,6 +735,13 @@ void ScRangeName::UpdateInsertTab( sc::RefUpdateInsertTabContext& rCxt, SCTAB nL itr->second->UpdateInsertTab(rCxt, nLocalTab); } +void ScRangeName::UpdateDeleteTab( sc::RefUpdateDeleteTabContext& rCxt, SCTAB nLocalTab ) +{ + DataType::iterator itr = maData.begin(), itrEnd = maData.end(); + for (; itr != itrEnd; ++itr) + itr->second->UpdateDeleteTab(rCxt, nLocalTab); +} + void ScRangeName::UpdateTabRef(SCTAB nTable, ScRangeData::TabRefUpdateMode eMode, SCTAB nNewTable, SCTAB nNewSheets) { DataType::iterator itr = maData.begin(), itrEnd = maData.end(); diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx index 1a14bd5..cb0d4f9 100644 --- a/sc/source/core/tool/token.cxx +++ b/sc/source/core/tool/token.cxx @@ -2686,12 +2686,12 @@ bool adjustSingleRefOnInsertedTab( ScSingleRefData& rRef, SCTAB nInsPos, SCTAB n } -bool ScTokenArray::AdjustReferenceOnDeletedTab( SCTAB nDelPos, SCTAB nSheets, const ScAddress& rOldPos ) +sc::RefUpdateResult ScTokenArray::AdjustReferenceOnDeletedTab( sc::RefUpdateDeleteTabContext& rCxt, const ScAddress& rOldPos ) { - bool bRefChanged = false; + sc::RefUpdateResult aRes; ScAddress aNewPos = rOldPos; - if (nDelPos < rOldPos.Tab()) - aNewPos.IncTab(-1*nSheets); + if (rCxt.mnDeletePos < rOldPos.Tab()) + aNewPos.IncTab(-1*rCxt.mnSheets); FormulaToken** p = pCode; FormulaToken** pEnd = p + static_cast<size_t>(nLen); @@ -2703,25 +2703,40 @@ bool ScTokenArray::AdjustReferenceOnDeletedTab( SCTAB nDelPos, SCTAB nSheets, co { ScToken* pToken = static_cast<ScToken*>(*p); ScSingleRefData& rRef = pToken->GetSingleRef(); - if (adjustSingleRefOnDeletedTab(rRef, nDelPos, nSheets, rOldPos, aNewPos)) - bRefChanged = true; + if (adjustSingleRefOnDeletedTab(rRef, rCxt.mnDeletePos, rCxt.mnSheets, rOldPos, aNewPos)) + aRes.mbReferenceModified = true; } break; case svDoubleRef: { ScToken* pToken = static_cast<ScToken*>(*p); ScComplexRefData& rRef = pToken->GetDoubleRef(); - if (adjustSingleRefOnDeletedTab(rRef.Ref1, nDelPos, nSheets, rOldPos, aNewPos)) - bRefChanged = true; - if (adjustSingleRefOnDeletedTab(rRef.Ref2, nDelPos, nSheets, rOldPos, aNewPos)) - bRefChanged = true; + if (adjustSingleRefOnDeletedTab(rRef.Ref1, rCxt.mnDeletePos, rCxt.mnSheets, rOldPos, aNewPos)) + aRes.mbReferenceModified = true; + if (adjustSingleRefOnDeletedTab(rRef.Ref2, rCxt.mnDeletePos, rCxt.mnSheets, rOldPos, aNewPos)) + aRes.mbReferenceModified = true; + } + break; + case svIndex: + { + const formula::FormulaToken* pToken = *p; + if (pToken->GetOpCode() == ocName) + { + SCTAB nTab = -1; + if (!pToken->IsGlobal()) + nTab = rOldPos.Tab(); + + // Check if this named expression has been modified. + if (rCxt.maUpdatedNames.isNameUpdated(nTab, pToken->GetIndex())) + aRes.mbNameModified = true; + } } break; default: ; } } - return bRefChanged; + return aRes; } sc::RefUpdateResult ScTokenArray::AdjustReferenceOnInsertedTab( sc::RefUpdateInsertTabContext& rCxt, const ScAddress& rOldPos ) @@ -2769,6 +2784,7 @@ sc::RefUpdateResult ScTokenArray::AdjustReferenceOnInsertedTab( sc::RefUpdateIns aRes.mbNameModified = true; } } + break; default: ; } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits