[Libreoffice-commits] core.git: Branch 'libreoffice-5-2' - sc/source

Eike Rathke erack at redhat.com
Sat Nov 5 20:30:04 UTC 2016


 sc/source/core/tool/token.cxx |   50 ++++++++++++++++++++++++++----------------
 1 file changed, 32 insertions(+), 18 deletions(-)

New commits:
commit 0230a4eccd3884ef3c3d6b7b4c6d54e5582a1268
Author: Eike Rathke <erack at redhat.com>
Date:   Tue Oct 18 19:30:24 2016 +0200

    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 at libreoffice.org>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index a0eb39b..f17e8eb 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);


More information about the Libreoffice-commits mailing list