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

Eike Rathke erack at redhat.com
Fri Nov 11 08:52:31 UTC 2016


 sc/source/core/data/column.cxx |   16 ++++++++++++++--
 sc/source/core/tool/token.cxx  |    3 +++
 2 files changed, 17 insertions(+), 2 deletions(-)

New commits:
commit 560469473f8485da4be1e9cedcb7f5399799a485
Author: Eike Rathke <erack at redhat.com>
Date:   Wed Oct 19 23:04:34 2016 +0200

    Resolves: tdf#97968 adjust references during Cut&Paste of formula groups
    
    ... and split groups for cases where references point outside or into the moved
    range.
    
    Change-Id: Iab799e94eed1677f266413b6304651ac4d330e95
    (cherry picked from commit dfa92e106f7eaa8c3fc6cda034001197ecc53a8f)
    Reviewed-on: https://gerrit.libreoffice.org/30067
    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/data/column.cxx b/sc/source/core/data/column.cxx
index bb1f564..ed04ccd 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -2072,6 +2072,7 @@ class UpdateRefOnNonCopy : public std::unary_function<sc::FormulaGroupEntry, voi
     const sc::RefUpdateContext* mpCxt;
     ScDocument* mpUndoDoc;
     bool mbUpdated;
+    bool mbClipboardSource;
 
     void recompileTokenArray( ScFormulaCell& rTopCell )
     {
@@ -2176,8 +2177,11 @@ class UpdateRefOnNonCopy : public std::unary_function<sc::FormulaGroupEntry, voi
         ScAddress aPos = pTop->aPos;
         ScAddress aOldPos = aPos;
 
+        bool bCellMoved;
         if (mpCxt->maRange.In(aPos))
         {
+            bCellMoved = true;
+
             // The cell is being moved or copied to a new position. The
             // position has already been updated prior to this call.
             // Determine its original position before the move which will be
@@ -2188,6 +2192,10 @@ class UpdateRefOnNonCopy : public std::unary_function<sc::FormulaGroupEntry, voi
                 aPos.Row() - mpCxt->mnRowDelta,
                 aPos.Tab() - mpCxt->mnTabDelta);
         }
+        else
+        {
+            bCellMoved = false;
+        }
 
         bool bRecalcOnMove = pCode->IsRecalcModeOnRefMove();
         if (bRecalcOnMove)
@@ -2224,7 +2232,10 @@ class UpdateRefOnNonCopy : public std::unary_function<sc::FormulaGroupEntry, voi
                 p->SetDirty();
             }
 
-            fillUndoDoc(aOldPos, rGroup.mnLength, *pOldCode);
+            // Move from clipboard is Cut&Paste, then do not copy the original
+            // positions' formula cells to the Undo document.
+            if (!mbClipboardSource || !bCellMoved)
+                fillUndoDoc(aOldPos, rGroup.mnLength, *pOldCode);
         }
     }
 
@@ -2264,7 +2275,8 @@ public:
         SCCOL nCol, SCTAB nTab, const sc::RefUpdateContext* pCxt,
         ScDocument* pUndoDoc) :
         mnCol(nCol), mnTab(nTab), mpCxt(pCxt),
-        mpUndoDoc(pUndoDoc), mbUpdated(false) {}
+        mpUndoDoc(pUndoDoc), mbUpdated(false),
+        mbClipboardSource(pCxt->mrDoc.IsClipboardSource()){}
 
     void operator() ( sc::FormulaGroupEntry& rGroup )
     {
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index f17e8eb..28fdcad 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -4476,6 +4476,9 @@ void checkBounds(
         {
             assert(!"can't move");
         }
+
+        // Check bounds also against the range moved into.
+        pDeletedRange = &rCxt.maRange;
     }
     else if (rCxt.meMode == URM_INSDEL &&
             ((rCxt.mnColDelta < 0 && rCxt.maRange.aStart.Col() > 0) ||


More information about the Libreoffice-commits mailing list