[Libreoffice-commits] .: sc/source

David Tardon dtardon at kemper.freedesktop.org
Sun May 22 22:38:22 PDT 2011


 sc/source/core/data/column3.cxx |   12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

New commits:
commit 66ac561d255ab92a43dcf933ac9bc76577ba7659
Author: David Tardon <dtardon at redhat.com>
Date:   Mon May 23 07:38:02 2011 +0200

    compensate for already shifted segments

diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index 25706e6..c281a35 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -526,6 +526,11 @@ void ScColumn::DeleteRange( SCSIZE nStartIndex, SCSIZE nEndIndex, sal_uInt16 nDe
         {
             SCSIZE nStartSegment(aIt->first);
             bool bMoveSegment(aIt->second);
+            // The indexes in aRemovedSegments denote cell positions in the
+            // original array. But as we are shifting it from the left, we have
+            // to compensate for already performed shifts for latter segments.
+            // TODO: use reverse iterators instead
+            SCSIZE nShift(0);
             ++aIt;
             do
             {
@@ -533,9 +538,12 @@ void ScColumn::DeleteRange( SCSIZE nStartIndex, SCSIZE nEndIndex, sal_uInt16 nDe
                 if (bMoveSegment)
                 {
                     memmove(
-                            &pItems[nStartSegment], &pItems[nEndSegment],
+                            &pItems[nStartSegment - nShift],
+                            &pItems[nEndSegment - nShift],
                             (nCount - nEndSegment) * sizeof(ColEntry));
-                    nCount -= nEndSegment - nStartSegment;
+                    SCSIZE const nNewShift(nEndSegment - nStartSegment);
+                    nShift += nNewShift;
+                    nCount -= nNewShift;
                 }
                 nStartSegment = nEndSegment;
                 bMoveSegment = aIt->second;


More information about the Libreoffice-commits mailing list