diff options
author | Markus Mohrhard <markus.mohrhard@collabora.co.uk> | 2015-03-28 05:43:33 +0100 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2015-03-28 16:38:51 +0100 |
commit | be1b3daeeb64a44e577510561d02147b87db72c2 (patch) | |
tree | b020f68a53bf7c9bd9d94c0ccc0eb0d7725c4168 | |
parent | 1efe5fe38031f7bc23150c35e4c68940621a1d5b (diff) |
3D refs with more than one sheet should not set sheets deleted, tdf#90001
Change-Id: I501ad421c283ec6a1f2629aa424f4d4c32228516
-rw-r--r-- | sc/source/core/tool/token.cxx | 40 |
1 files changed, 36 insertions, 4 deletions
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx index 6b582ecc25a0..ada4f9123945 100644 --- a/sc/source/core/tool/token.cxx +++ b/sc/source/core/tool/token.cxx @@ -3373,6 +3373,41 @@ bool adjustSingleRefOnInsertedTab( ScSingleRefData& rRef, SCTAB nInsPos, SCTAB n return false; } +bool adjustDoubleRefOnDeleteTab(ScComplexRefData& rRef, SCTAB nDelPos, SCTAB nSheets, const ScAddress& rOldPos, const ScAddress& rNewPos) +{ + ScSingleRefData& rRef1 = rRef.Ref1; + ScSingleRefData& rRef2 = rRef.Ref2; + ScAddress aStartPos = rRef1.toAbs(rOldPos); + ScAddress aEndPos = rRef2.toAbs(rOldPos); + bool bMoreThanOneTab = aStartPos.Tab() != aEndPos.Tab(); + bool bModified = false; + if (bMoreThanOneTab && aStartPos.Tab() == nDelPos) + { + if (rRef1.IsTabRel()) + { + aStartPos.IncTab(nSheets); + rRef1.SetAddress(aStartPos, rOldPos); + } + bModified = true; + } + else + { + bModified = adjustSingleRefOnDeletedTab(rRef1, nDelPos, nSheets, rOldPos, rNewPos); + } + + if (bMoreThanOneTab && aEndPos.Tab() == nDelPos) + { + aEndPos.IncTab(-nSheets); + rRef2.SetAddress(aEndPos, rNewPos); + bModified = true; + } + else + { + bModified |= adjustSingleRefOnDeletedTab(rRef2, nDelPos, nSheets, rOldPos, rNewPos); + } + return bModified; +} + } sc::RefUpdateResult ScTokenArray::AdjustReferenceOnDeletedTab( sc::RefUpdateDeleteTabContext& rCxt, const ScAddress& rOldPos ) @@ -3400,10 +3435,7 @@ sc::RefUpdateResult ScTokenArray::AdjustReferenceOnDeletedTab( sc::RefUpdateDele { formula::FormulaToken* pToken = *p; ScComplexRefData& rRef = *pToken->GetDoubleRef(); - 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; + aRes.mbReferenceModified |= adjustDoubleRefOnDeleteTab(rRef, rCxt.mnDeletePos, rCxt.mnSheets, rOldPos, aNewPos); } break; case svIndex: |