diff options
author | Eike Rathke <erack@redhat.com> | 2016-10-18 19:30:24 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2016-10-18 19:33:42 +0200 |
commit | 6b9804b8f2ca85e9eb42d344d17cfee7a7a9414c (patch) | |
tree | 19b267d8dbf2c5853d59f75bdbf808f61395f753 | |
parent | 7596535983dfe6978d624cf0ff31b40e85e14a6b (diff) |
Resolves: tdf#101583 references to be expanded must be at least 2 cols/rows
... wide/tall also in named expressions.
Change-Id: If0c192def74812cc9405ae633b6f83f7021344d0
-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 407a1006d5d9..44dbe384e6e5 100644 --- a/sc/source/core/tool/token.cxx +++ b/sc/source/core/tool/token.cxx @@ -3491,28 +3491,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; + } } } } @@ -3736,8 +3744,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); @@ -3748,8 +3759,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); |