sc/source/core/tool/token.cxx |   38 ++++++++++++++++++++++++++++++++++----
 1 file changed, 34 insertions(+), 4 deletions(-)

New commits:
commit caf9c2a4423119f553a4c9ef3846cbfa6e8fe029
Author: Kohei Yoshida <kohei.yosh...@gmail.com>
Date:   Wed Jul 31 21:10:50 2013 -0400

    Fix reference update on range references in named expressions.
    
    This fixes the macro test failure.
    
    Change-Id: I8ddaaaa49d1faf36cc37212895c21023a4ab6135

diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 93cf603..e60780a 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -2598,6 +2598,20 @@ bool adjustSingleRefInName(
     return bChanged;
 }
 
+bool adjustDoubleRefInName(
+    ScComplexRefData& rRef, const sc::RefUpdateContext& rCxt, const ScAddress& 
rPos )
+{
+    bool bRefChanged = false;
+
+    if (adjustSingleRefInName(rRef.Ref1, rCxt, rPos))
+        bRefChanged = true;
+
+    if (adjustSingleRefInName(rRef.Ref2, rCxt, rPos))
+        bRefChanged = true;
+
+    return bRefChanged;
+}
+
 }
 
 sc::RefUpdateResult ScTokenArray::AdjustReferenceInName(
@@ -2623,10 +2637,26 @@ sc::RefUpdateResult ScTokenArray::AdjustReferenceInName(
             {
                 ScToken* pToken = static_cast<ScToken*>(*p);
                 ScComplexRefData& rRef = pToken->GetDoubleRef();
-                if (adjustSingleRefInName(rRef.Ref1, rCxt, rPos))
-                    aRes.mbReferenceModified = true;
-                if (adjustSingleRefInName(rRef.Ref2, rCxt, rPos))
-                    aRes.mbReferenceModified = true;
+                ScRange aAbs = rRef.toAbs(rPos);
+                if (rCxt.maRange.In(aAbs))
+                {
+                    // This range is entirely within the shifted region.
+                    if (adjustDoubleRefInName(rRef, rCxt, rPos))
+                        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())
+                    {
+                        if (adjustDoubleRefInName(rRef, rCxt, rPos))
+                            aRes.mbReferenceModified = true;
+                    }
+                    if (rCxt.mnRowDelta && rCxt.maRange.aStart.Col() <= 
aAbs.aStart.Col() && aAbs.aEnd.Col() <= rCxt.maRange.aEnd.Col())
+                    {
+                        if (adjustDoubleRefInName(rRef, rCxt, rPos))
+                            aRes.mbReferenceModified = true;
+                    }
+                }
             }
             break;
             default:
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to