diff options
author | Eike Rathke <erack@redhat.com> | 2016-10-18 19:30:24 +0200 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2016-11-05 20:29:45 +0000 |
commit | 0230a4eccd3884ef3c3d6b7b4c6d54e5582a1268 (patch) | |
tree | 8ddeef3b1611c6a3436319640386204f1672946d | |
parent | 18ef4766a97340fb9e0adc4ac7ee4feb90213a64 (diff) |
Resolves: tdf#101583 references to be expanded must be at least 2 cols/rows
... wide/tall also in named expressions.
Change-Id: If0c192def74812cc9405ae633b6f83f7021344d0
(cherry picked from commit 6b9804b8f2ca85e9eb42d344d17cfee7a7a9414c)
Reviewed-on: https://gerrit.libreoffice.org/30023
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | sc/source/core/tool/token.cxx | 50 |
1 files changed, 32 insertions, 18 deletions
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx index a0eb39bef8af..f17e8eb991fb 100644 --- a/sc/source/core/tool/token.cxx +++ b/sc/source/core/tool/token.cxx @@ -3538,28 +3538,36 @@ bool adjustDoubleRefInName( { if (rCxt.mnRowDelta > 0 && !rRef.Ref1.IsRowRel() && !rRef.Ref2.IsRowRel()) { - // Check and see if we should expand the range at the top. - ScRange aSelectedRange = getSelectedRange(rCxt); ScRange aAbs = rRef.toAbs(rPos); - if (aSelectedRange.Intersects(aAbs)) + // Expand only if at least two rows tall. + if (aAbs.aStart.Row() < aAbs.aEnd.Row()) { - // Selection intersects the referenced range. Only expand the - // bottom position. - rRef.IncEndRowSticky(rCxt.mnRowDelta, rPos); - return true; + // Check and see if we should expand the range at the top. + ScRange aSelectedRange = getSelectedRange(rCxt); + if (aSelectedRange.Intersects(aAbs)) + { + // Selection intersects the referenced range. Only expand the + // bottom position. + rRef.IncEndRowSticky(rCxt.mnRowDelta, rPos); + return true; + } } } if (rCxt.mnColDelta > 0 && !rRef.Ref1.IsColRel() && !rRef.Ref2.IsColRel()) { - // Check and see if we should expand the range at the left. - ScRange aSelectedRange = getSelectedRange(rCxt); ScRange aAbs = rRef.toAbs(rPos); - if (aSelectedRange.Intersects(aAbs)) + // Expand only if at least two columns wide. + if (aAbs.aStart.Col() < aAbs.aEnd.Col()) { - // Selection intersects the referenced range. Only expand the - // right position. - rRef.IncEndColSticky(rCxt.mnColDelta, rPos); - return true; + // Check and see if we should expand the range at the left. + ScRange aSelectedRange = getSelectedRange(rCxt); + if (aSelectedRange.Intersects(aAbs)) + { + // Selection intersects the referenced range. Only expand the + // right position. + rRef.IncEndColSticky(rCxt.mnColDelta, rPos); + return true; + } } } } @@ -3783,8 +3791,11 @@ sc::RefUpdateResult ScTokenArray::AdjustReferenceInName( { // Check if we could expand range reference by the bottom // edge. For named expressions, we only expand absolute - // references. - if (!rRef.Ref1.IsRowRel() && !rRef.Ref2.IsRowRel() && aAbs.aEnd.Row()+1 == rCxt.maRange.aStart.Row()) + // references. Reference must be at least two rows + // tall. + if (!rRef.Ref1.IsRowRel() && !rRef.Ref2.IsRowRel() && + aAbs.aStart.Row() < aAbs.aEnd.Row() && + aAbs.aEnd.Row()+1 == rCxt.maRange.aStart.Row()) { // Expand by the bottom edge. rRef.Ref2.IncRow(rCxt.mnRowDelta); @@ -3795,8 +3806,11 @@ sc::RefUpdateResult ScTokenArray::AdjustReferenceInName( { // Check if we could expand range reference by the right // edge. For named expressions, we only expand absolute - // references. - if (!rRef.Ref1.IsColRel() && !rRef.Ref2.IsColRel() && aAbs.aEnd.Col()+1 == rCxt.maRange.aStart.Col()) + // references. Reference must be at least two + // columns wide. + if (!rRef.Ref1.IsColRel() && !rRef.Ref2.IsColRel() && + aAbs.aStart.Col() < aAbs.aEnd.Col() && + aAbs.aEnd.Col()+1 == rCxt.maRange.aStart.Col()) { // Expand by the right edge. rRef.Ref2.IncCol(rCxt.mnColDelta); |