You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
77 lines
3.5 KiB
77 lines
3.5 KiB
From ab5ff775b5b197a11a76a5e91859c31421ff559f Mon Sep 17 00:00:00 2001
|
|
From: Kohei Yoshida <kohei.yoshida@collabora.com>
|
|
Date: Sat, 18 Oct 2014 20:22:53 -0400
|
|
Subject: [PATCH] fdo#82047: Correctly adjust references in range names on row
|
|
deletion.
|
|
|
|
Change-Id: Iac924b0b6932863f7f9cc088f996e0b07c340d2c
|
|
(cherry picked from commit 281847613bd3ae472523822f4be9c21cc353867e)
|
|
Reviewed-on: https://gerrit.libreoffice.org/12025
|
|
Reviewed-by: Eike Rathke <erack@redhat.com>
|
|
Tested-by: Eike Rathke <erack@redhat.com>
|
|
---
|
|
sc/source/core/tool/token.cxx | 47 +++++++++++++++++++++++++++++++++++++++++++
|
|
1 file changed, 47 insertions(+)
|
|
|
|
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
|
|
index 916a88e..84c8ccc 100644
|
|
--- a/sc/source/core/tool/token.cxx
|
|
+++ b/sc/source/core/tool/token.cxx
|
|
@@ -3170,6 +3170,53 @@ sc::RefUpdateResult ScTokenArray::AdjustReferenceInName(
|
|
if (adjustDoubleRefInName(rRef, rCxt, rPos))
|
|
aRes.mbReferenceModified = true;
|
|
}
|
|
+ else if (rCxt.mnRowDelta < 0)
|
|
+ {
|
|
+ // row(s) deleted.
|
|
+ if (rRef.Ref1.IsRowRel() || rRef.Ref2.IsRowRel())
|
|
+ // Don't modify relative references in names.
|
|
+ break;
|
|
+
|
|
+ if (aAbs.aStart.Col() < rCxt.maRange.aStart.Col() || rCxt.maRange.aEnd.Col() < aAbs.aEnd.Col())
|
|
+ // column range of the reference is not entirely in the deleted column range.
|
|
+ break;
|
|
+
|
|
+ ScRange aDeleted = rCxt.maRange;
|
|
+ aDeleted.aStart.IncRow(rCxt.mnRowDelta);
|
|
+ aDeleted.aEnd.SetRow(aDeleted.aStart.Row()-rCxt.mnRowDelta-1);
|
|
+
|
|
+ if (aAbs.aEnd.Row() < aDeleted.aStart.Row() || aDeleted.aEnd.Row() < aAbs.aStart.Row())
|
|
+ // reference range doesn't intersect with the deleted range.
|
|
+ break;
|
|
+
|
|
+ if (aDeleted.aStart.Row() <= aAbs.aStart.Row() && aAbs.aEnd.Row() <= aDeleted.aEnd.Row())
|
|
+ {
|
|
+ // This reference is entirely deleted.
|
|
+ rRef.Ref1.SetRowDeleted(true);
|
|
+ rRef.Ref2.SetRowDeleted(true);
|
|
+ aRes.mbReferenceModified = true;
|
|
+ break;
|
|
+ }
|
|
+
|
|
+ if (aAbs.aStart.Row() < aDeleted.aStart.Row())
|
|
+ {
|
|
+ if (aDeleted.aEnd.Row() < aAbs.aEnd.Row())
|
|
+ // Deleted in the middle. Make the reference shorter.
|
|
+ rRef.Ref2.IncRow(rCxt.mnRowDelta);
|
|
+ else
|
|
+ // Deleted at tail end. Cut off the lower part.
|
|
+ rRef.Ref2.SetAbsRow(aDeleted.aStart.Row()-1);
|
|
+ }
|
|
+ else
|
|
+ {
|
|
+ // Deleted at the top. Cut the top off and shift up.
|
|
+ rRef.Ref1.SetAbsRow(aDeleted.aEnd.Row()+1);
|
|
+ rRef.Ref1.IncRow(rCxt.mnRowDelta);
|
|
+ rRef.Ref2.IncRow(rCxt.mnRowDelta);
|
|
+ }
|
|
+
|
|
+ aRes.mbReferenceModified = true;
|
|
+ }
|
|
else if (rCxt.maRange.Intersects(aAbs))
|
|
{
|
|
if (rCxt.mnColDelta && rCxt.maRange.aStart.Row() <= aAbs.aStart.Row() && aAbs.aEnd.Row() <= rCxt.maRange.aEnd.Row())
|
|
--
|
|
1.9.3
|
|
|