summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2015-12-11 19:59:06 +0100
committerEike Rathke <erack@redhat.com>2015-12-11 21:15:41 +0100
commit478917a2c0fe7e7e3c79d9a12b4488128e6da969 (patch)
tree036f72867982a744ccfc406f605f1f8e5345393e /sc
parent208c247edbef4449b8614dd3709e627edc546e46 (diff)
separate ScRange::Move() and MoveSticky(), tdf#92779
To selectively use the sticky mechanism, i.e. not in an actual move of a range during cut&paste or drag&drop. Actually currently only in ScTokenArray::AdjustReferenceOnShift() Change-Id: I223e5013e4b820efb4ecb9e8ce8aa04a8bc01e27 (cherry picked from commit 21dfe37aca134b22cdbdb73fc29d30a89cd85524)
Diffstat (limited to 'sc')
-rw-r--r--sc/inc/address.hxx5
-rw-r--r--sc/source/core/tool/address.cxx11
-rw-r--r--sc/source/core/tool/token.cxx2
3 files changed, 17 insertions, 1 deletions
diff --git a/sc/inc/address.hxx b/sc/inc/address.hxx
index 34d49fbb714b..8ac565c2ac65 100644
--- a/sc/inc/address.hxx
+++ b/sc/inc/address.hxx
@@ -551,6 +551,11 @@ public:
*/
SC_DLLPUBLIC SAL_WARN_UNUSED_RESULT bool Move( SCsCOL aDeltaX, SCsROW aDeltaY, SCsTAB aDeltaZ,
ScRange& rErrorRange, ScDocument* pDocument = nullptr );
+
+ /** Same as Move() but with sticky end col/row anchors. */
+ SC_DLLPUBLIC SAL_WARN_UNUSED_RESULT bool MoveSticky( SCsCOL aDeltaX, SCsROW aDeltaY, SCsTAB aDeltaZ,
+ ScRange& rErrorRange, ScDocument* pDocument = nullptr );
+
SC_DLLPUBLIC void ExtendTo( const ScRange& rRange );
SC_DLLPUBLIC bool Intersects( const ScRange& rRange ) const; // do two ranges intersect?
diff --git a/sc/source/core/tool/address.cxx b/sc/source/core/tool/address.cxx
index e060f0aac735..f3df92328b5e 100644
--- a/sc/source/core/tool/address.cxx
+++ b/sc/source/core/tool/address.cxx
@@ -2148,6 +2148,17 @@ bool ScAddress::Move( SCsCOL dx, SCsROW dy, SCsTAB dz, ScAddress& rErrorPos, ScD
bool ScRange::Move( SCsCOL dx, SCsROW dy, SCsTAB dz, ScRange& rErrorRange, ScDocument* pDoc )
{
+ if (dy && aStart.Row() == 0 && aEnd.Row() == MAXROW)
+ dy = 0; // Entire column not to be moved.
+ if (dx && aStart.Col() == 0 && aEnd.Col() == MAXCOL)
+ dx = 0; // Entire row not to be moved.
+ bool b = aStart.Move( dx, dy, dz, rErrorRange.aStart, pDoc );
+ b &= aEnd.Move( dx, dy, dz, rErrorRange.aEnd, pDoc );
+ return b;
+}
+
+bool ScRange::MoveSticky( SCsCOL dx, SCsROW dy, SCsTAB dz, ScRange& rErrorRange, ScDocument* pDoc )
+{
bool bColRange = (aStart.Col() < aEnd.Col());
bool bRowRange = (aStart.Row() < aEnd.Row());
if (dy && aStart.Row() == 0 && aEnd.Row() == MAXROW)
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 29274aebc844..05221e7554fb 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -2969,7 +2969,7 @@ sc::RefUpdateResult ScTokenArray::AdjustReferenceOnShift( const sc::RefUpdateCon
if (rCxt.maRange.In(aAbs))
{
ScRange aErrorRange( ScAddress::UNINITIALIZED );
- if (!aAbs.Move(rCxt.mnColDelta, rCxt.mnRowDelta, rCxt.mnTabDelta, aErrorRange))
+ if (!aAbs.MoveSticky(rCxt.mnColDelta, rCxt.mnRowDelta, rCxt.mnTabDelta, aErrorRange))
aAbs = aErrorRange;
aRes.mbReferenceModified = true;
}