[Libreoffice-commits] core.git: Branch 'feature/tiled-editing' - 2 commits - sc/source

Jan Holesovsky kendy at collabora.com
Tue Apr 7 14:58:21 PDT 2015


 sc/source/ui/unoobj/docuno.cxx |   46 ++++++++++++++++--------
 sc/source/ui/view/gridwin.cxx  |   78 +++++++++++++++--------------------------
 2 files changed, 61 insertions(+), 63 deletions(-)

New commits:
commit 2881957867cc32c792fcc68c47b087d18a1c8efe
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Tue Apr 7 23:54:49 2015 +0200

    sc tiled editing: Never show the cell cursor.
    
    With the current behavior, showing the cell cursor is counter-intuitive and
    counter productive - we focus more on the editing itself.
    
    It is still possible to select just one cell though - it is the cell selection
    that starts and ends in the same cell.
    
    Change-Id: Ie6d96783d486c6fcda5b4c4f6acf91c1926cdf6c

diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index d7d56e0..770166d 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -5782,21 +5782,12 @@ static void updateLibreOfficeKitSelection(ScViewData* pViewData, ScDrawLayer* pD
 void ScGridWindow::UpdateCursorOverlay()
 {
     ScDocument* pDoc = pViewData->GetDocument();
-    bool bIsTiledRendering = pDoc->GetDrawLayer()->isTiledRendering();
-
-    // in the tiled rendering case, exit early if we are not supposed to draw
-    // the cell cursor:
-    // - there is a selection (either cell selection, or graphic object)
-    // - the user is typing inside a shape or so
-    if (bIsTiledRendering &&
-        (pViewData->GetMarkData().IsMarked() || pViewData->GetMarkData().IsMultiMarked() ||
-         pViewData->GetViewShell()->GetScDrawView()->IsMarking() ||
-         pViewData->GetViewShell()->GetScDrawView()->IsTextEdit() ||
-         pViewData->GetViewShell()->GetScDrawView()->GetDragStat().IsShown() ||
-         pViewData->HasEditView(eWhich)))
-    {
+
+    // never show the cell cursor when the tiled rendering is going on; either
+    // we want to show the editeng selection, or the cell selection, but not
+    // the cell cursor by itself
+    if (pDoc->GetDrawLayer()->isTiledRendering())
         return;
-    }
 
     MapMode aDrawMode = GetDrawMapMode();
     MapMode aOldMode = GetMapMode();
@@ -5873,7 +5864,7 @@ void ScGridWindow::UpdateCursorOverlay()
         }
 
         // in the tiled rendering case, don't limit to the screen size
-        if (bMaybeVisible || bIsTiledRendering)
+        if (bMaybeVisible)
         {
             long nSizeXPix;
             long nSizeYPix;
@@ -5882,46 +5873,37 @@ void ScGridWindow::UpdateCursorOverlay()
             if (bLayoutRTL)
                 aScrPos.X() -= nSizeXPix - 2;       // move instead of mirroring
 
-            if (bIsTiledRendering)
-            {
-                // just forward the area to LOK
-                Rectangle aRect(aScrPos, Size(nSizeXPix, nSizeYPix));
-                aPixelRects.push_back(aRect);
-            }
-            else
-            {
-                // show the cursor as 4 (thin) rectangles
-                Rectangle aRect(aScrPos, Size(nSizeXPix - 1, nSizeYPix - 1));
+            // show the cursor as 4 (thin) rectangles
+            Rectangle aRect(aScrPos, Size(nSizeXPix - 1, nSizeYPix - 1));
 
-                sal_Int32 nScale = GetDPIScaleFactor();
+            sal_Int32 nScale = GetDPIScaleFactor();
 
-                long aCursorWidth = 1 * nScale;
+            long aCursorWidth = 1 * nScale;
 
-                Rectangle aLeft = Rectangle(aRect);
-                aLeft.Top()    -= aCursorWidth;
-                aLeft.Bottom() += aCursorWidth;
-                aLeft.Right()   = aLeft.Left();
-                aLeft.Left()   -= aCursorWidth;
+            Rectangle aLeft = Rectangle(aRect);
+            aLeft.Top()    -= aCursorWidth;
+            aLeft.Bottom() += aCursorWidth;
+            aLeft.Right()   = aLeft.Left();
+            aLeft.Left()   -= aCursorWidth;
 
-                Rectangle aRight = Rectangle(aRect);
-                aRight.Top()    -= aCursorWidth;
-                aRight.Bottom() += aCursorWidth;
-                aRight.Left()    = aRight.Right();
-                aRight.Right()  += aCursorWidth;
+            Rectangle aRight = Rectangle(aRect);
+            aRight.Top()    -= aCursorWidth;
+            aRight.Bottom() += aCursorWidth;
+            aRight.Left()    = aRight.Right();
+            aRight.Right()  += aCursorWidth;
 
-                Rectangle aTop = Rectangle(aRect);
-                aTop.Bottom()  = aTop.Top();
-                aTop.Top()    -= aCursorWidth;
+            Rectangle aTop = Rectangle(aRect);
+            aTop.Bottom()  = aTop.Top();
+            aTop.Top()    -= aCursorWidth;
 
-                Rectangle aBottom = Rectangle(aRect);
-                aBottom.Top()     = aBottom.Bottom();
-                aBottom.Bottom() += aCursorWidth;
+            Rectangle aBottom = Rectangle(aRect);
+            aBottom.Top()     = aBottom.Bottom();
+            aBottom.Bottom() += aCursorWidth;
 
-                aPixelRects.push_back(aLeft);
-                aPixelRects.push_back(aRight);
-                aPixelRects.push_back(aTop);
-                aPixelRects.push_back(aBottom);
-            }
+            aPixelRects.push_back(aLeft);
+            aPixelRects.push_back(aRight);
+            aPixelRects.push_back(aTop);
+            aPixelRects.push_back(aBottom);
         }
     }
 
commit f129b1b0e028fd362ddfd6670975e51cc5a995ae
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Tue Apr 7 23:09:50 2015 +0200

    sc tiled editing: Allow turning the text selection into cell selection.
    
    When moving the handle outside of the cell editeng, we want to turn the text
    selection into the cell selection.
    
    This patch includes work by Henry Castro - thanks!
    
    Change-Id: I081480b7d8b0fde8276f63c261d91bb9f2dc3b96

diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index 07a79c6..7b9c7ca 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -612,6 +612,8 @@ void ScModelObj::setTextSelection(int nType, int nX, int nY)
     // update the aLogicMode in ScViewData to something predictable
     pViewData->SetZoom(Fraction(1, 1), Fraction(1, 1), true);
 
+    bool bHandled = false;
+
     if (pInputHandler && pInputHandler->IsInputMode())
     {
         // forwarding to editeng - we are editing the cell content
@@ -619,20 +621,32 @@ void ScModelObj::setTextSelection(int nType, int nX, int nY)
         assert(pTableView);
 
         Point aPoint(convertTwipToMm100(nX), convertTwipToMm100(nY));
-        switch (nType)
+
+        if (!pTableView->GetOutputArea().IsInside(aPoint))
         {
-            case LOK_SETTEXTSELECTION_START:
-                pTableView->SetCursorLogicPosition(aPoint, /*bPoint=*/false, /*bClearMark=*/false);
-                break;
-            case LOK_SETTEXTSELECTION_END:
-                pTableView->SetCursorLogicPosition(aPoint, /*bPoint=*/true, /*bClearMark=*/false);
-                break;
-            case LOK_SETTEXTSELECTION_RESET:
-                pTableView->SetCursorLogicPosition(aPoint, /*bPoint=*/true, /*bClearMark=*/true);
-                break;
-            default:
-                assert(false);
-                break;
+            // if the handle does not stay in the editeng area, we want to turn
+            // the selection into the cell selection
+            pViewShell->UpdateInputLine();
+            pViewShell->UpdateInputHandler();
+        }
+        else
+        {
+            switch (nType)
+            {
+                case LOK_SETTEXTSELECTION_START:
+                    pTableView->SetCursorLogicPosition(aPoint, /*bPoint=*/false, /*bClearMark=*/false);
+                    break;
+                case LOK_SETTEXTSELECTION_END:
+                    pTableView->SetCursorLogicPosition(aPoint, /*bPoint=*/true, /*bClearMark=*/false);
+                    break;
+                case LOK_SETTEXTSELECTION_RESET:
+                    pTableView->SetCursorLogicPosition(aPoint, /*bPoint=*/true, /*bClearMark=*/true);
+                    break;
+                default:
+                    assert(false);
+                    break;
+            }
+            bHandled = true;
         }
     }
     else if (pDrawView && pDrawView->IsTextEdit())
@@ -657,10 +671,12 @@ void ScModelObj::setTextSelection(int nType, int nX, int nY)
                 assert(false);
                 break;
         }
+        bHandled = true;
     }
-    else
+
+    if (!bHandled)
     {
-        // just updating the cell selection
+        // just update the cell selection
         ScGridWindow* pGridWindow = pViewData->GetActiveWin();
         if (!pGridWindow)
             return;


More information about the Libreoffice-commits mailing list