[Libreoffice-commits] .: 2 commits - sc/source

Kohei Yoshida kohei at kemper.freedesktop.org
Fri May 27 22:06:55 PDT 2011


 sc/source/ui/inc/tabview.hxx   |    2 
 sc/source/ui/view/tabview2.cxx |  192 +++++++++++++++++++----------------------
 2 files changed, 91 insertions(+), 103 deletions(-)

New commits:
commit 90a74bd9ce9e604c0172337ae2e4c509acb6c060
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Sat May 28 01:04:22 2011 -0400

    Revert "Removed unnecessary data members."
    
    This reverts commit ed2aa8e1ebd4bea03d958b86e721400ef59cb76d.
    
    These data members were indeed necessary. Let's not remove them.

diff --git a/sc/source/ui/inc/tabview.hxx b/sc/source/ui/inc/tabview.hxx
index f523c53..23a7aa5 100644
--- a/sc/source/ui/inc/tabview.hxx
+++ b/sc/source/ui/inc/tabview.hxx
@@ -147,9 +147,11 @@ private:
     BlockMode           meBlockMode;           // Block markieren
 
     SCCOL				nBlockStartX;
+    SCCOL               nBlockStartXOrig;
     SCCOL				nBlockEndX;
 
     SCROW				nBlockStartY;
+    SCROW               nBlockStartYOrig;
     SCROW				nBlockEndY;
 
     SCTAB				nBlockStartZ;
diff --git a/sc/source/ui/view/tabview2.cxx b/sc/source/ui/view/tabview2.cxx
index 4c2e0c9..9c0bf0d 100644
--- a/sc/source/ui/view/tabview2.cxx
+++ b/sc/source/ui/view/tabview2.cxx
@@ -363,8 +363,8 @@ void ScTabView::InitBlockMode( SCCOL nCurX, SCROW nCurY, SCTAB nCurZ,
         meBlockMode = Normal;
         bBlockCols = bCols;
         bBlockRows = bRows;
-        nBlockStartX = nCurX;
-        nBlockStartY = nCurY;
+        nBlockStartX = nBlockStartXOrig = nCurX;
+        nBlockStartY = nBlockStartYOrig = nCurY;
         nBlockStartZ = nCurZ;
         nBlockEndX = nOldCurX = nBlockStartX;
         nBlockEndY = nOldCurY = nBlockStartY;
@@ -372,13 +372,13 @@ void ScTabView::InitBlockMode( SCCOL nCurX, SCROW nCurY, SCTAB nCurZ,
 
         if (bBlockCols)
         {
-            nBlockStartY = 0;
+            nBlockStartY = nBlockStartYOrig = 0;
             nBlockEndY = MAXROW;
         }
 
         if (bBlockRows)
         {
-            nBlockStartX = 0;
+            nBlockStartX = nBlockStartXOrig = 0;
             nBlockEndX = MAXCOL;
         }
 
@@ -478,8 +478,6 @@ void ScTabView::MarkCursor( SCCOL nCurX, SCROW nCurY, SCTAB nCurZ,
         {
             // Expand selection area accordingly when the current selection ends
             // with a merged cell.
-            SCsCOL nBlockStartXOld = nBlockStartX;
-            SCsROW nBlockStartYOld = nBlockStartY;
             SCsCOL nCurXOffset = 0;
             SCsCOL nBlockStartXOffset = 0;
             SCsROW nCurYOffset = 0;
@@ -496,20 +494,20 @@ void ScTabView::MarkCursor( SCCOL nCurX, SCROW nCurY, SCTAB nCurZ,
             // move to the lower-right corner of the merged anchor cell, and so on.
 
             pMergeAttr = static_cast<const ScMergeAttr*>(
-                pDocument->GetAttr( nBlockStartX, nBlockStartY, nTab, ATTR_MERGE ) );
+                pDocument->GetAttr( nBlockStartXOrig, nBlockStartYOrig, nTab, ATTR_MERGE ) );
             if ( pMergeAttr->IsMerged() )
             {
                 SCsCOL nColSpan = pMergeAttr->GetColMerge();
                 SCsROW nRowSpan = pMergeAttr->GetRowMerge();
 
-                if ( !( nCurX >= nBlockStartXOld + nColSpan - 1 && nCurY >= nBlockStartYOld + nRowSpan - 1 ) )
+                if ( !( nCurX >= nBlockStartXOrig + nColSpan - 1 && nCurY >= nBlockStartYOrig + nRowSpan - 1 ) )
                 {
-                    nBlockStartX = nCurX >= nBlockStartXOld ? nBlockStartXOld : nBlockStartXOld + nColSpan - 1;
-                    nBlockStartY = nCurY >= nBlockStartYOld ? nBlockStartYOld : nBlockStartYOld + nRowSpan - 1;
-                    nCurXOffset  = nCurX >= nBlockStartXOld && nCurX < nBlockStartXOld + nColSpan - 1 ?
-                        nBlockStartXOld - nCurX + nColSpan - 1 : 0;
-                    nCurYOffset  = nCurY >= nBlockStartYOld && nCurY < nBlockStartYOld + nRowSpan - 1 ?
-                        nBlockStartYOld - nCurY + nRowSpan - 1 : 0;
+                    nBlockStartX = nCurX >= nBlockStartXOrig ? nBlockStartXOrig : nBlockStartXOrig + nColSpan - 1;
+                    nBlockStartY = nCurY >= nBlockStartYOrig ? nBlockStartYOrig : nBlockStartYOrig + nRowSpan - 1;
+                    nCurXOffset  = nCurX >= nBlockStartXOrig && nCurX < nBlockStartXOrig + nColSpan - 1 ?
+                        nBlockStartXOrig - nCurX + nColSpan - 1 : 0;
+                    nCurYOffset  = nCurY >= nBlockStartYOrig && nCurY < nBlockStartYOrig + nRowSpan - 1 ?
+                        nBlockStartYOrig - nCurY + nRowSpan - 1 : 0;
                     bBlockStartMerged = sal_True;
                 }
             }
@@ -554,8 +552,8 @@ void ScTabView::MarkCursor( SCCOL nCurX, SCROW nCurY, SCTAB nCurZ,
                 // original position.
                 if ( !bBlockStartMerged )
                 {
-                    nBlockStartX = nBlockStartXOld;
-                    nBlockStartY = nBlockStartYOld;
+                    nBlockStartX = nBlockStartXOrig;
+                    nBlockStartY = nBlockStartYOrig;
                 }
             }
 
commit 487150953af168ff740fa4fe321279db6f8eff1a
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Sat May 28 01:03:59 2011 -0400

    Revert "Extracted a method from a code block."
    
    This reverts commit 4f46e40020699ea79d0d7254431aff27b087e4e2.

diff --git a/sc/source/ui/view/tabview2.cxx b/sc/source/ui/view/tabview2.cxx
index 644710d..4c2e0c9 100644
--- a/sc/source/ui/view/tabview2.cxx
+++ b/sc/source/ui/view/tabview2.cxx
@@ -58,102 +58,6 @@
 
 namespace {
 
-/**
- * Expand selection area accordingly when the current selection ends with a
- * merged cell.
- */
-void expandSelectionByMergedCell(
-    SCsCOL& rBlockStartX, SCsROW& rBlockStartY, SCsCOL& rBlockEndX, SCsROW& rBlockEndY,
-    SCCOL nCurX, SCROW nCurY, SCTAB nTab, ScDocument* pDoc)
-{
-    SCsCOL nBlockStartXOld = rBlockStartX;
-    SCsROW nBlockStartYOld = rBlockStartY;
-
-    SCsCOL nCurXOffset = 0;
-    SCsCOL nBlockStartXOffset = 0;
-    SCsROW nCurYOffset = 0;
-    SCsROW nBlockStartYOffset = 0;
-    bool bBlockStartMerged = false;
-    const ScMergeAttr* pMergeAttr = NULL;
-
-    // The following block checks whether or not the "BlockStart" (anchor)
-    // cell is merged.  If it's merged, it'll then move the position of the
-    // anchor cell to the corner that's diagonally opposite of the
-    // direction of a current selection area.  For instance, if a current
-    // selection is moving in the upperleft direction, the anchor cell will
-    // move to the lower-right corner of the merged anchor cell, and so on.
-
-    pMergeAttr = static_cast<const ScMergeAttr*>(
-        pDoc->GetAttr(rBlockStartX, rBlockStartY, nTab, ATTR_MERGE));
-
-    if (pMergeAttr->IsMerged())
-    {
-        SCsCOL nColSpan = pMergeAttr->GetColMerge();
-        SCsROW nRowSpan = pMergeAttr->GetRowMerge();
-
-        if ( !(nCurX >= nBlockStartXOld + nColSpan - 1 && nCurY >= nBlockStartYOld + nRowSpan - 1) )
-        {
-            rBlockStartX = nCurX >= nBlockStartXOld ? nBlockStartXOld : nBlockStartXOld + nColSpan - 1;
-            rBlockStartY = nCurY >= nBlockStartYOld ? nBlockStartYOld : nBlockStartYOld + nRowSpan - 1;
-            nCurXOffset  = nCurX >= nBlockStartXOld && nCurX < nBlockStartXOld + nColSpan - 1 ?
-                nBlockStartXOld - nCurX + nColSpan - 1 : 0;
-            nCurYOffset  = nCurY >= nBlockStartYOld && nCurY < nBlockStartYOld + nRowSpan - 1 ?
-                nBlockStartYOld - nCurY + nRowSpan - 1 : 0;
-            bBlockStartMerged = true;
-        }
-    }
-
-    // The following block checks whether or not the current cell is
-    // merged.  If it is, it'll then set the appropriate X & Y offset
-    // values (nCurXOffset & nCurYOffset) such that the selection area will
-    // grow by those specified offset amounts.  Note that the values of
-    // nCurXOffset/nCurYOffset may also be specified in the previous code
-    // block, in which case whichever value is greater will take on.
-
-    pMergeAttr = static_cast<const ScMergeAttr*>(
-        pDoc->GetAttr(nCurX, nCurY, nTab, ATTR_MERGE));
-    if ( pMergeAttr->IsMerged() )
-    {
-        SCsCOL nColSpan = pMergeAttr->GetColMerge();
-        SCsROW nRowSpan = pMergeAttr->GetRowMerge();
-
-        if ( !(rBlockStartX >= nCurX + nColSpan - 1 && rBlockStartY >= nCurY + nRowSpan - 1) )
-        {
-            if ( rBlockStartX <= nCurX + nColSpan - 1 )
-            {
-                SCsCOL nCurXOffsetTemp = nCurX < nCurX + nColSpan - 1 ? nColSpan - 1 : 0;
-                nCurXOffset = nCurXOffset > nCurXOffsetTemp ? nCurXOffset : nCurXOffsetTemp;
-            }
-            if ( rBlockStartY <= nCurY + nRowSpan - 1 )
-            {
-                SCsROW nCurYOffsetTemp = nCurY < nCurY + nRowSpan - 1 ? nRowSpan - 1 : 0;
-                nCurYOffset = nCurYOffset > nCurYOffsetTemp ? nCurYOffset : nCurYOffsetTemp;
-            }
-            if ( !( rBlockStartX <= nCurX && rBlockStartY <= nCurY ) &&
-                 !( rBlockStartX > nCurX + nColSpan - 1 && rBlockStartY > nCurY + nRowSpan - 1 ) )
-            {
-                nBlockStartXOffset = rBlockStartX > nCurX && rBlockStartX <= nCurX + nColSpan - 1 ? nCurX - rBlockStartX : 0;
-                nBlockStartYOffset = rBlockStartY > nCurY && rBlockStartY <= nCurY + nRowSpan - 1 ? nCurY - rBlockStartY : 0;
-            }
-        }
-    }
-    else
-    {
-        // The current cell is not merged.  Move the anchor cell to its
-        // original position.
-        if (!bBlockStartMerged)
-        {
-            rBlockStartX = nBlockStartXOld;
-            rBlockStartY = nBlockStartYOld;
-        }
-    }
-
-    rBlockStartX = rBlockStartX + nBlockStartXOffset >= 0 ? rBlockStartX + nBlockStartXOffset : 0;
-    rBlockStartY = rBlockStartY + nBlockStartYOffset >= 0 ? rBlockStartY + nBlockStartYOffset : 0;
-    rBlockEndX = nCurX + nCurXOffset > MAXCOL ? MAXCOL : nCurX + nCurXOffset;
-    rBlockEndY = nCurY + nCurYOffset > MAXROW ? MAXROW : nCurY + nCurYOffset;
-}
-
 bool isCellQualified(ScDocument* pDoc, SCCOL nCol, SCROW nRow, SCTAB nTab, bool bSelectLocked, bool bSelectUnlocked)
 {
     bool bCellProtected = pDoc->HasAttrib(
@@ -572,9 +476,93 @@ void ScTabView::MarkCursor( SCCOL nCurX, SCROW nCurY, SCTAB nCurZ,
 
         if ( bCellSelection )
         {
-            expandSelectionByMergedCell(
-                nBlockStartX, nBlockStartY, nBlockEndX, nBlockEndY,
-                nCurX, nCurY, nTab, aViewData.GetDocument());
+            // Expand selection area accordingly when the current selection ends
+            // with a merged cell.
+            SCsCOL nBlockStartXOld = nBlockStartX;
+            SCsROW nBlockStartYOld = nBlockStartY;
+            SCsCOL nCurXOffset = 0;
+            SCsCOL nBlockStartXOffset = 0;
+            SCsROW nCurYOffset = 0;
+            SCsROW nBlockStartYOffset = 0;
+            bool bBlockStartMerged = false;
+            const ScMergeAttr* pMergeAttr = NULL;
+            ScDocument* pDocument = aViewData.GetDocument();
+
+            // The following block checks whether or not the "BlockStart" (anchor)
+            // cell is merged.  If it's merged, it'll then move the position of the
+            // anchor cell to the corner that's diagonally opposite of the
+            // direction of a current selection area.  For instance, if a current
+            // selection is moving in the upperleft direction, the anchor cell will
+            // move to the lower-right corner of the merged anchor cell, and so on.
+
+            pMergeAttr = static_cast<const ScMergeAttr*>(
+                pDocument->GetAttr( nBlockStartX, nBlockStartY, nTab, ATTR_MERGE ) );
+            if ( pMergeAttr->IsMerged() )
+            {
+                SCsCOL nColSpan = pMergeAttr->GetColMerge();
+                SCsROW nRowSpan = pMergeAttr->GetRowMerge();
+
+                if ( !( nCurX >= nBlockStartXOld + nColSpan - 1 && nCurY >= nBlockStartYOld + nRowSpan - 1 ) )
+                {
+                    nBlockStartX = nCurX >= nBlockStartXOld ? nBlockStartXOld : nBlockStartXOld + nColSpan - 1;
+                    nBlockStartY = nCurY >= nBlockStartYOld ? nBlockStartYOld : nBlockStartYOld + nRowSpan - 1;
+                    nCurXOffset  = nCurX >= nBlockStartXOld && nCurX < nBlockStartXOld + nColSpan - 1 ?
+                        nBlockStartXOld - nCurX + nColSpan - 1 : 0;
+                    nCurYOffset  = nCurY >= nBlockStartYOld && nCurY < nBlockStartYOld + nRowSpan - 1 ?
+                        nBlockStartYOld - nCurY + nRowSpan - 1 : 0;
+                    bBlockStartMerged = sal_True;
+                }
+            }
+
+            // The following block checks whether or not the current cell is
+            // merged.  If it is, it'll then set the appropriate X & Y offset
+            // values (nCurXOffset & nCurYOffset) such that the selection area will
+            // grow by those specified offset amounts.  Note that the values of
+            // nCurXOffset/nCurYOffset may also be specified in the previous code
+            // block, in which case whichever value is greater will take on.
+
+            pMergeAttr = static_cast<const ScMergeAttr*>(
+                pDocument->GetAttr( nCurX, nCurY, nTab, ATTR_MERGE ) );
+            if ( pMergeAttr->IsMerged() )
+            {
+                SCsCOL nColSpan = pMergeAttr->GetColMerge();
+                SCsROW nRowSpan = pMergeAttr->GetRowMerge();
+
+                if ( !( nBlockStartX >= nCurX + nColSpan - 1 && nBlockStartY >= nCurY + nRowSpan - 1 ) )
+                {
+                    if ( nBlockStartX <= nCurX + nColSpan - 1 )
+                    {
+                        SCsCOL nCurXOffsetTemp = nCurX < nCurX + nColSpan - 1 ? nColSpan - 1 : 0;
+                        nCurXOffset = nCurXOffset > nCurXOffsetTemp ? nCurXOffset : nCurXOffsetTemp;
+                    }
+                    if ( nBlockStartY <= nCurY + nRowSpan - 1 )
+                    {
+                        SCsROW nCurYOffsetTemp = nCurY < nCurY + nRowSpan - 1 ? nRowSpan - 1 : 0;
+                        nCurYOffset = nCurYOffset > nCurYOffsetTemp ? nCurYOffset : nCurYOffsetTemp;
+                    }
+                    if ( !( nBlockStartX <= nCurX && nBlockStartY <= nCurY ) &&
+                         !( nBlockStartX > nCurX + nColSpan - 1 && nBlockStartY > nCurY + nRowSpan - 1 ) )
+                    {
+                        nBlockStartXOffset = nBlockStartX > nCurX && nBlockStartX <= nCurX + nColSpan - 1 ? nCurX - nBlockStartX : 0;
+                        nBlockStartYOffset = nBlockStartY > nCurY && nBlockStartY <= nCurY + nRowSpan - 1 ? nCurY - nBlockStartY : 0;
+                    }
+                }
+            }
+            else
+            {
+                // The current cell is not merged.  Move the anchor cell to its
+                // original position.
+                if ( !bBlockStartMerged )
+                {
+                    nBlockStartX = nBlockStartXOld;
+                    nBlockStartY = nBlockStartYOld;
+                }
+            }
+
+            nBlockStartX = nBlockStartX + nBlockStartXOffset >= 0 ? nBlockStartX + nBlockStartXOffset : 0;
+            nBlockStartY = nBlockStartY + nBlockStartYOffset >= 0 ? nBlockStartY + nBlockStartYOffset : 0;
+            nBlockEndX = nCurX + nCurXOffset > MAXCOL ? MAXCOL : nCurX + nCurXOffset;
+            nBlockEndY = nCurY + nCurYOffset > MAXROW ? MAXROW : nCurY + nCurYOffset;
         }
         else
         {


More information about the Libreoffice-commits mailing list