Resolves: tdf#130825 Compare exclusive end, not inclusive end sheet number

Change-Id: Id5c3056f4e4466ccb5ea3654e60869bf7788b7ca
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89471
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Jenkins
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index a1f6e58..9ba5f2f 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -4163,7 +4163,7 @@ sc::RefUpdateResult ScTokenArray::AdjustReferenceOnDeletedTab( const sc::RefUpda
                            if (rCxt.mnDeletePos <= nOldTab)
                            {
                                aRes.mbNameModified = true;
                                if (rCxt.mnDeletePos + rCxt.mnSheets < nOldTab)
                                if (rCxt.mnDeletePos + rCxt.mnSheets <= nOldTab)
                                    (*pp)->SetSheet( nOldTab - rCxt.mnSheets);
                                else
                                    // Would point to a deleted sheet. Invalidate.