diff options
Diffstat (limited to 'sc/source/core')
-rw-r--r-- | sc/source/core/data/column4.cxx | 2 | ||||
-rw-r--r-- | sc/source/core/data/table3.cxx | 4 | ||||
-rw-r--r-- | sc/source/core/tool/token.cxx | 43 |
3 files changed, 49 insertions, 0 deletions
diff --git a/sc/source/core/data/column4.cxx b/sc/source/core/data/column4.cxx index 568b5b64ec19..10bec05bc2a3 100644 --- a/sc/source/core/data/column4.cxx +++ b/sc/source/core/data/column4.cxx @@ -454,6 +454,8 @@ public: pCell->aPos.SetRow(nRow); if (mbUpdateRefs) pCell->GetCode()->AdjustReferenceOnMovedOrigin(aOldPos, pCell->aPos); + else + pCell->GetCode()->AdjustReferenceOnMovedOriginIfOtherSheet(aOldPos, pCell->aPos); } else { diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx index 99d6239a0262..e49a4dcdefbd 100644 --- a/sc/source/core/data/table3.cxx +++ b/sc/source/core/data/table3.cxx @@ -870,6 +870,10 @@ void ScTable::SortReorderByRow( pNew->CopyAllBroadcasters(*rCell.maCell.mpFormula); pNew->GetCode()->AdjustReferenceOnMovedOrigin(aOldPos, aCellPos); } + else + { + pNew->GetCode()->AdjustReferenceOnMovedOriginIfOtherSheet(aOldPos, aCellPos); + } sc::CellStoreType::iterator itBlk = rCellStore.push_back(pNew); } diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx index 03ecc495a5f3..f56161430b04 100644 --- a/sc/source/core/tool/token.cxx +++ b/sc/source/core/tool/token.cxx @@ -3548,6 +3548,49 @@ void ScTokenArray::AdjustReferenceOnMovedOrigin( const ScAddress& rOldPos, const } } +void ScTokenArray::AdjustReferenceOnMovedOriginIfOtherSheet( const ScAddress& rOldPos, const ScAddress& rNewPos ) +{ + FormulaToken** p = pCode; + FormulaToken** pEnd = p + static_cast<size_t>(nLen); + for (; p != pEnd; ++p) + { + bool bAdjust = false; + switch ((*p)->GetType()) + { + case svExternalSingleRef: + bAdjust = true; // always + // fallthru + case svSingleRef: + { + ScToken* pToken = static_cast<ScToken*>(*p); + ScSingleRefData& rRef = pToken->GetSingleRef(); + ScAddress aAbs = rRef.toAbs(rOldPos); + if (!bAdjust) + bAdjust = (aAbs.Tab() != rOldPos.Tab()); + if (bAdjust) + rRef.SetAddress(aAbs, rNewPos); + } + break; + case svExternalDoubleRef: + bAdjust = true; // always + // fallthru + case svDoubleRef: + { + ScToken* pToken = static_cast<ScToken*>(*p); + ScComplexRefData& rRef = pToken->GetDoubleRef(); + ScRange aAbs = rRef.toAbs(rOldPos); + if (!bAdjust) + bAdjust = (rOldPos.Tab() < aAbs.aStart.Tab() || aAbs.aEnd.Tab() < rOldPos.Tab()); + if (bAdjust) + rRef.SetRange(aAbs, rNewPos); + } + break; + default: + ; + } + } +} + namespace { void clearTabDeletedFlag( ScSingleRefData& rRef, const ScAddress& rPos, SCTAB nStartTab, SCTAB nEndTab ) |