diff options
author | Eike Rathke <erack@redhat.com> | 2015-05-06 17:15:12 +0200 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2015-05-07 13:56:08 +0000 |
commit | b6697facb33f3149673e683921aeb069a2fa4e96 (patch) | |
tree | 7f11a2dbace64e6b07d0bf7a0c8705544cb438f8 | |
parent | 021943dad044076c10b9b032d4e0b243e64f631c (diff) |
Resolves: tdf#91078 check also DBData modified, not only named expressions
This adds ScDocument& to all RefUpdate...Context; another approach could
had been to add an UpdatedDBData similar to UpdatedRangeNames and gather
those in the ScDBData::Update...() methods, but as long as
ScDBData::IsModified() works that isn't necessary.
(cherry picked from commit 848dc76e76c1c4a9040be4a0088c4d4527af6f40)
Conflicts:
sc/source/core/tool/token.cxx
assume modified if an index has no corresponding ScDBData (anymore)
(cherry picked from commit 4a53021f0662e08b56fd076f78ac182634fcec4c)
16cbc7d772f39c8778b8ba21a629ced6b0dbedeb
Change-Id: Iae3ec6c8b8356cbd8acb2445489e91e7d6922fb3
Reviewed-on: https://gerrit.libreoffice.org/15654
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | sc/inc/refupdatecontext.hxx | 9 | ||||
-rw-r--r-- | sc/source/core/data/documen2.cxx | 4 | ||||
-rw-r--r-- | sc/source/core/data/document.cxx | 8 | ||||
-rw-r--r-- | sc/source/core/data/refupdatecontext.cxx | 12 | ||||
-rw-r--r-- | sc/source/core/tool/token.cxx | 32 |
5 files changed, 41 insertions, 24 deletions
diff --git a/sc/inc/refupdatecontext.hxx b/sc/inc/refupdatecontext.hxx index 393a85511406..3b4db92628e8 100644 --- a/sc/inc/refupdatecontext.hxx +++ b/sc/inc/refupdatecontext.hxx @@ -103,29 +103,32 @@ struct RefUpdateResult struct RefUpdateInsertTabContext { + ScDocument& mrDoc; SCTAB mnInsertPos; SCTAB mnSheets; UpdatedRangeNames maUpdatedNames; - RefUpdateInsertTabContext(SCTAB nInsertPos, SCTAB nSheets); + RefUpdateInsertTabContext(ScDocument& rDoc, SCTAB nInsertPos, SCTAB nSheets); }; struct RefUpdateDeleteTabContext { + ScDocument& mrDoc; SCTAB mnDeletePos; SCTAB mnSheets; UpdatedRangeNames maUpdatedNames; - RefUpdateDeleteTabContext(SCTAB nInsertPos, SCTAB nSheets); + RefUpdateDeleteTabContext(ScDocument& rDoc, SCTAB nInsertPos, SCTAB nSheets); }; struct RefUpdateMoveTabContext { + ScDocument& mrDoc; SCTAB mnOldPos; SCTAB mnNewPos; UpdatedRangeNames maUpdatedNames; - RefUpdateMoveTabContext(SCTAB nOldPos, SCTAB nNewPos); + RefUpdateMoveTabContext(ScDocument& rDoc, SCTAB nOldPos, SCTAB nNewPos); SCTAB getNewTab(SCTAB nOldTab) const; }; diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx index 02e19929871a..0c5f212106cc 100644 --- a/sc/source/core/data/documen2.cxx +++ b/sc/source/core/data/documen2.cxx @@ -731,7 +731,7 @@ bool ScDocument::MoveTab( SCTAB nOldPos, SCTAB nNewPos, ScProgress* pProgress ) // Update Reference // TODO: combine with UpdateReference! - sc::RefUpdateMoveTabContext aCxt(nOldPos, nNewPos); + sc::RefUpdateMoveTabContext aCxt( *this, nOldPos, nNewPos); SCsTAB nDz = ((SCsTAB)nNewPos) - (SCsTAB)nOldPos; ScRange aSourceRange( 0,0,nOldPos, MAXCOL,MAXROW,nOldPos ); @@ -804,7 +804,7 @@ bool ScDocument::CopyTab( SCTAB nOldPos, SCTAB nNewPos, const ScMarkData* pOnlyM bValid = !GetTable( aName, nDummy ); sc::AutoCalcSwitch aACSwitch(*this, false); - sc::RefUpdateInsertTabContext aCxt(nNewPos, 1); + sc::RefUpdateInsertTabContext aCxt( *this, nNewPos, 1); sc::StartListeningContext aSLCxt(*this); if (bValid) diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx index 5a215878a794..58899165be62 100644 --- a/sc/source/core/data/document.cxx +++ b/sc/source/core/data/document.cxx @@ -491,7 +491,7 @@ bool ScDocument::InsertTab( { if (ValidTab(nPos) && (nPos < nTabCount)) { - sc::RefUpdateInsertTabContext aCxt(nPos, 1); + sc::RefUpdateInsertTabContext aCxt( *this, nPos, 1); ScRange aRange( 0,0,nPos, MAXCOL,MAXROW,MAXTAB ); xColNameRanges->UpdateReference( URM_INSDEL, this, aRange, 0,0,1 ); @@ -582,7 +582,7 @@ bool ScDocument::InsertTabs( SCTAB nPos, const std::vector<OUString>& rNames, { if (ValidTab(nPos) && (nPos < nTabCount)) { - sc::RefUpdateInsertTabContext aCxt(nPos, nNewSheets); + sc::RefUpdateInsertTabContext aCxt( *this, nPos, nNewSheets); ScRange aRange( 0,0,nPos, MAXCOL,MAXROW,MAXTAB ); xColNameRanges->UpdateReference( URM_INSDEL, this, aRange, 0,0,nNewSheets ); xRowNameRanges->UpdateReference( URM_INSDEL, this, aRange, 0,0,nNewSheets ); @@ -657,7 +657,7 @@ bool ScDocument::DeleteTab( SCTAB nTab ) if (nTabCount > 1) { sc::AutoCalcSwitch aACSwitch(*this, false); - sc::RefUpdateDeleteTabContext aCxt(nTab, 1); + sc::RefUpdateDeleteTabContext aCxt( *this, nTab, 1); ScRange aRange( 0, 0, nTab, MAXCOL, MAXROW, nTab ); DelBroadcastAreasInRange( aRange ); @@ -739,7 +739,7 @@ bool ScDocument::DeleteTabs( SCTAB nTab, SCTAB nSheets ) if (nTabCount > nSheets) { sc::AutoCalcSwitch aACSwitch(*this, false); - sc::RefUpdateDeleteTabContext aCxt(nTab, nSheets); + sc::RefUpdateDeleteTabContext aCxt( *this, nTab, nSheets); for (SCTAB aTab = 0; aTab < nSheets; ++aTab) { diff --git a/sc/source/core/data/refupdatecontext.cxx b/sc/source/core/data/refupdatecontext.cxx index d63c745c961a..b5f539136a48 100644 --- a/sc/source/core/data/refupdatecontext.cxx +++ b/sc/source/core/data/refupdatecontext.cxx @@ -61,14 +61,14 @@ RefUpdateResult::RefUpdateResult(const RefUpdateResult& r) : mbReferenceModified(r.mbReferenceModified), mbNameModified(r.mbNameModified) {} -RefUpdateInsertTabContext::RefUpdateInsertTabContext(SCTAB nInsertPos, SCTAB nSheets) : - mnInsertPos(nInsertPos), mnSheets(nSheets) {} +RefUpdateInsertTabContext::RefUpdateInsertTabContext(ScDocument& rDoc, SCTAB nInsertPos, SCTAB nSheets) : + mrDoc(rDoc), mnInsertPos(nInsertPos), mnSheets(nSheets) {} -RefUpdateDeleteTabContext::RefUpdateDeleteTabContext(SCTAB nDeletePos, SCTAB nSheets) : - mnDeletePos(nDeletePos), mnSheets(nSheets) {} +RefUpdateDeleteTabContext::RefUpdateDeleteTabContext(ScDocument& rDoc, SCTAB nDeletePos, SCTAB nSheets) : + mrDoc(rDoc), mnDeletePos(nDeletePos), mnSheets(nSheets) {} -RefUpdateMoveTabContext::RefUpdateMoveTabContext(SCTAB nOldPos, SCTAB nNewPos) : - mnOldPos(nOldPos), mnNewPos(nNewPos) {} +RefUpdateMoveTabContext::RefUpdateMoveTabContext(ScDocument& rDoc, SCTAB nOldPos, SCTAB nNewPos) : + mrDoc(rDoc), mnOldPos(nOldPos), mnNewPos(nNewPos) {} SCTAB RefUpdateMoveTabContext::getNewTab(SCTAB nOldTab) const { diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx index 1d2a0a63e798..9500a2841149 100644 --- a/sc/source/core/tool/token.cxx +++ b/sc/source/core/tool/token.cxx @@ -43,6 +43,7 @@ #include "types.hxx" #include "globstr.hrc" #include "addincol.hxx" +#include "dbdata.hxx" #include <svl/sharedstring.hxx> using ::std::vector; @@ -2588,9 +2589,6 @@ bool expandRangeByEdge( const sc::RefUpdateContext& rCxt, ScRange& rRefRange, co bool isNameModified( const sc::UpdatedRangeNames& rUpdatedNames, SCTAB nOldTab, const formula::FormulaToken& rToken ) { - if (rToken.GetOpCode() != ocName) - return false; - SCTAB nTab = -1; if (!rToken.IsGlobal()) nTab = nOldTab; @@ -2599,6 +2597,16 @@ bool isNameModified( const sc::UpdatedRangeNames& rUpdatedNames, SCTAB nOldTab, return rUpdatedNames.isNameUpdated(nTab, rToken.GetIndex()); } +bool isDBDataModified( const ScDocument& rDoc, const formula::FormulaToken& rToken ) +{ + // Check if this DBData has been modified. + const ScDBData* pDBData = rDoc.GetDBCollection()->getNamedDBs().findByIndex( rToken.GetIndex()); + if (!pDBData) + return true; + + return pDBData->IsModified(); +} + } sc::RefUpdateResult ScTokenArray::AdjustReferenceOnShift( const sc::RefUpdateContext& rCxt, const ScAddress& rOldPos ) @@ -2737,7 +2745,8 @@ sc::RefUpdateResult ScTokenArray::AdjustReferenceOnShift( const sc::RefUpdateCon break; case svIndex: { - if (isNameModified(rCxt.maUpdatedNames, rOldPos.Tab(), **p)) + if (((*p)->GetOpCode() == ocName && isNameModified(rCxt.maUpdatedNames, rOldPos.Tab(), **p)) || + ((*p)->GetOpCode() == ocDBArea && isDBDataModified(rCxt.mrDoc, **p))) aRes.mbNameModified = true; } break; @@ -2805,7 +2814,8 @@ sc::RefUpdateResult ScTokenArray::AdjustReferenceOnMove( break; case svIndex: { - if (isNameModified(rCxt.maUpdatedNames, rOldPos.Tab(), **p)) + if (((*p)->GetOpCode() == ocName && isNameModified(rCxt.maUpdatedNames, rOldPos.Tab(), **p)) || + ((*p)->GetOpCode() == ocDBArea && isDBDataModified(rCxt.mrDoc, **p))) aRes.mbNameModified = true; } break; @@ -2860,7 +2870,8 @@ sc::RefUpdateResult ScTokenArray::MoveReference( const ScAddress& rPos, const sc break; case svIndex: { - if (isNameModified(rCxt.maUpdatedNames, aOldRange.aStart.Tab(), **p)) + if (((*p)->GetOpCode() == ocName && isNameModified(rCxt.maUpdatedNames, aOldRange.aStart.Tab(), **p)) || + ((*p)->GetOpCode() == ocDBArea && isDBDataModified(rCxt.mrDoc, **p))) aRes.mbNameModified = true; } break; @@ -3344,7 +3355,8 @@ sc::RefUpdateResult ScTokenArray::AdjustReferenceOnDeletedTab( sc::RefUpdateDele break; case svIndex: { - if (isNameModified(rCxt.maUpdatedNames, rOldPos.Tab(), **p)) + if (((*p)->GetOpCode() == ocName && isNameModified(rCxt.maUpdatedNames, rOldPos.Tab(), **p)) || + ((*p)->GetOpCode() == ocDBArea && isDBDataModified(rCxt.mrDoc, **p))) aRes.mbNameModified = true; } break; @@ -3388,7 +3400,8 @@ sc::RefUpdateResult ScTokenArray::AdjustReferenceOnInsertedTab( sc::RefUpdateIns break; case svIndex: { - if (isNameModified(rCxt.maUpdatedNames, rOldPos.Tab(), **p)) + if (((*p)->GetOpCode() == ocName && isNameModified(rCxt.maUpdatedNames, rOldPos.Tab(), **p)) || + ((*p)->GetOpCode() == ocDBArea && isDBDataModified(rCxt.mrDoc, **p))) aRes.mbNameModified = true; } break; @@ -3453,7 +3466,8 @@ sc::RefUpdateResult ScTokenArray::AdjustReferenceOnMovedTab( sc::RefUpdateMoveTa break; case svIndex: { - if (isNameModified(rCxt.maUpdatedNames, rOldPos.Tab(), **p)) + if (((*p)->GetOpCode() == ocName && isNameModified(rCxt.maUpdatedNames, rOldPos.Tab(), **p)) || + ((*p)->GetOpCode() == ocDBArea && isDBDataModified(rCxt.mrDoc, **p))) aRes.mbNameModified = true; } break; |