[PATCH libreoffice-4-0] URM_INSDEL we need to update the src position, fdo#62206

Markus Mohrhard (via Code Review) gerrit at gerrit.libreoffice.org
Mon Mar 25 02:58:16 PDT 2013


Hi,

I have submitted a patch for review:

    https://gerrit.libreoffice.org/2986

To pull it, you can do:

    git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/86/2986/1

URM_INSDEL we need to update the src position, fdo#62206

See ScFormulaCell::UpdateReference for a similar update

Change-Id: I1f98d26adb5085e4bdab63cc23f97a81928d6b13
(cherry picked from commit 9261c0bf6ecf6633a5577879f003edfcb569f4d7)
---
M sc/source/core/data/conditio.cxx
1 file changed, 15 insertions(+), 6 deletions(-)



diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx
index a6ba736..d37891a 100644
--- a/sc/source/core/data/conditio.cxx
+++ b/sc/source/core/data/conditio.cxx
@@ -526,6 +526,15 @@
 {
     bool bInsertTab = ( eUpdateRefMode == URM_INSDEL && nDz >= 1 );
     bool bDeleteTab = ( eUpdateRefMode == URM_INSDEL && nDz <= -1 );
+    if(pCondFormat)
+        aSrcPos = pCondFormat->GetRange().Combine().aStart;
+    ScAddress aOldSrcPos = aSrcPos;
+    bool bChangedPos = false;
+    if(eUpdateRefMode == URM_INSDEL && rRange.In(aSrcPos))
+    {
+        aSrcPos.Move(nDx, nDy, nDz);
+        bChangedPos = aSrcPos != aOldSrcPos;
+    }
 
     bool bChanged1 = false;
     bool bChanged2 = false;
@@ -533,7 +542,7 @@
     if (pFormula1)
     {
         if ( bInsertTab )
-            lcl_CondUpdateInsertTab( *pFormula1, rRange.aStart.Tab(), aSrcPos.Tab(), bChanged1, nDz );
+            lcl_CondUpdateInsertTab( *pFormula1, rRange.aStart.Tab(), aOldSrcPos.Tab(), bChanged1, nDz );
         else
         {
             ScCompiler aComp( mpDoc, aSrcPos, *pFormula1 );
@@ -543,18 +552,18 @@
             else
             {
                 bool bSizeChanged;
-                aComp.UpdateReference( eUpdateRefMode, aSrcPos, rRange, nDx,
+                aComp.UpdateReference( eUpdateRefMode, aOldSrcPos, rRange, nDx,
                         nDy, nDz, bChanged1, bSizeChanged );
             }
         }
 
-        if (bChanged1)
+        if (bChanged1 || bChangedPos)
             DELETEZ(pFCell1);       // is created again in IsValid
     }
     if (pFormula2)
     {
         if ( bInsertTab )
-            lcl_CondUpdateInsertTab( *pFormula2, rRange.aStart.Tab(), aSrcPos.Tab(), bChanged2, nDz );
+            lcl_CondUpdateInsertTab( *pFormula2, rRange.aStart.Tab(), aOldSrcPos.Tab(), bChanged2, nDz );
         else
         {
             ScCompiler aComp( mpDoc, aSrcPos, *pFormula2);
@@ -564,12 +573,12 @@
             else
             {
                 bool bSizeChanged;
-                aComp.UpdateReference( eUpdateRefMode, aSrcPos, rRange, nDx,
+                aComp.UpdateReference( eUpdateRefMode, aOldSrcPos, rRange, nDx,
                         nDy, nDz, bChanged2, bSizeChanged );
             }
         }
 
-        if (bChanged2)
+        if (bChanged2 || bChangedPos)
             DELETEZ(pFCell2);       // is created again in IsValid
     }
 }

-- 
To view, visit https://gerrit.libreoffice.org/2986
To unsubscribe, visit https://gerrit.libreoffice.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1f98d26adb5085e4bdab63cc23f97a81928d6b13
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: libreoffice-4-0
Gerrit-Owner: Markus Mohrhard <markus.mohrhard at googlemail.com>



More information about the LibreOffice mailing list