diff options
author | Eike Rathke <erack@redhat.com> | 2023-12-05 20:58:49 +0100 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2023-12-05 22:40:50 +0100 |
commit | f35b540279b00575ff79eda1c65fb0f8caad86bf (patch) | |
tree | 027955845a418a76d5aa007e40b205779b42608e | |
parent | 8286c9ebe47aaf24b055f51136a8cb06f1e6429c (diff) |
Resolves: tdf#158223 Revert "fix" for tdf#156174 and follow-up
... introducing a real fix.
commit 94ca402cd1fe2fd9776d08448f7216b7f638e69a
CommitDate: Tue Jul 25 15:04:01 2023 +0200
tdf#156174 sc DBData: fix regression of database ranges
just cured a symptom by removing a condition that shouldn't had been
removed, instead of getting to the real cause of an odd reference
update.
Shrinking the end of a sheet reference range and thus moving it one
before the previously referenced relative position is only possible if
the deleted sheet actually touches the referenced range, which here the
start value points to and thus checking ref>=start+delta is not
necessary and subtracting 1 even harms. This is different from deleting
columns or rows where the start value points behind the deleted area of
moving the following area.
Change-Id: If9ae5dd6f6ae5cd248ad5d999f1aa7577d4ec035
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160374
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Jenkins
-rw-r--r-- | sc/source/core/tool/refupdat.cxx | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/sc/source/core/tool/refupdat.cxx b/sc/source/core/tool/refupdat.cxx index e05a14d0137f..95f738c4ed84 100644 --- a/sc/source/core/tool/refupdat.cxx +++ b/sc/source/core/tool/refupdat.cxx @@ -25,12 +25,12 @@ #include <osl/diagnose.h> template< typename R, typename S, typename U > -static bool lcl_MoveStart( R& rRef, U nStart, S nDelta, U nMask ) +static bool lcl_MoveStart( R& rRef, U nStart, S nDelta, U nMask, bool bShrink = true ) { bool bCut = false; if ( rRef >= nStart ) rRef = sal::static_int_cast<R>( rRef + nDelta ); - else if ( nDelta < 0 && rRef >= nStart + nDelta ) + else if ( nDelta < 0 && bShrink && rRef >= nStart + nDelta ) rRef = nStart + nDelta; //TODO: limit ??? if ( rRef < 0 ) { @@ -46,12 +46,12 @@ static bool lcl_MoveStart( R& rRef, U nStart, S nDelta, U nMask ) } template< typename R, typename S, typename U > -static bool lcl_MoveEnd( R& rRef, U nStart, S nDelta, U nMask ) +static bool lcl_MoveEnd( R& rRef, U nStart, S nDelta, U nMask, bool bShrink = true ) { bool bCut = false; if ( rRef >= nStart ) rRef = sal::static_int_cast<R>( rRef + nDelta ); - else if ( nDelta < 0 && rRef >= nStart + nDelta ) + else if ( nDelta < 0 && bShrink && rRef >= nStart + nDelta ) rRef = nStart + nDelta - 1; //TODO: limit ??? if (rRef < 0) { @@ -284,9 +284,14 @@ ScRefUpdateRes ScRefUpdate::Update( const ScDocument* pDoc, UpdateRefMode eUpdat SCTAB nMaxTab = pDoc->GetTableCount() - 1; nMaxTab = sal::static_int_cast<SCTAB>(nMaxTab + nDz); // adjust to new count bool bExp = (bExpand && IsExpand( theTab1, theTab2, nTab1, nDz )); - bCut1 = lcl_MoveStart( theTab1, nTab1, nDz, nMaxTab ); - bCut2 = lcl_MoveEnd( theTab2, nTab1, nDz, nMaxTab ); - if ( bCut1 || bCut2 ) + bCut1 = lcl_MoveStart( theTab1, nTab1, nDz, nMaxTab, false /*bShrink*/); + bCut2 = lcl_MoveEnd( theTab2, nTab1, nDz, nMaxTab, false /*bShrink*/); + if ( theTab2 < theTab1 ) + { + eRet = UR_INVALID; + theTab2 = theTab1; + } + else if ( bCut1 || bCut2 ) eRet = UR_UPDATED; if ( bExp ) { |