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

Jan Holesovsky kendy at collabora.com
Wed Apr 8 13:19:28 PDT 2015


 sc/source/ui/unoobj/docuno.cxx |    9 -----
 sc/source/ui/view/gridwin.cxx  |   64 ++++++++++++++++++++++++++---------------
 sc/source/ui/view/gridwin4.cxx |   15 ++++++++-
 3 files changed, 55 insertions(+), 33 deletions(-)

New commits:
commit 08f4e8517bb450db82f9d4b51f8825b6c3d7c54d
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Wed Apr 8 22:16:21 2015 +0200

    sc tiled editing: Reuse the selection method.
    
    Change-Id: I05175f0d8c37994658e0dcdf355a753bf7c840b8

diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index 7b9c7ca..f216ad4 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -622,14 +622,7 @@ void ScModelObj::setTextSelection(int nType, int nX, int nY)
 
         Point aPoint(convertTwipToMm100(nX), convertTwipToMm100(nY));
 
-        if (!pTableView->GetOutputArea().IsInside(aPoint))
-        {
-            // 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
+        if (pTableView->GetOutputArea().IsInside(aPoint))
         {
             switch (nType)
             {
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index b351c4c..6c15dd1 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -1718,18 +1718,8 @@ void ScGridWindow::HandleMouseButtonDown( const MouseEvent& rMEvt, MouseEventSta
         aCell.assign(*pViewData->GetDocument(), ScAddress(nPosX, nPosY, nTab));
         if (aCell.isEmpty())
         {
-            // stop editing
-            ScTabViewShell* pViewShell = pViewData->GetViewShell();
-            pViewShell->UpdateInputLine();
-            pViewShell->UpdateInputHandler();
-
-            // select the given cell
-            ScTabView* pTabView = pViewData->GetView();
-            pTabView->SetCursor(nPosX, nPosY);
-            pTabView->DoneBlockMode();
-            pTabView->InitBlockMode(nPosX, nPosY, nTab, true);
-            pTabView->MarkCursor(nPosX, nPosY, nTab);
-            pTabView->SelectionChanged();
+            SetCellSelectionPixel(LOK_SETTEXTSELECTION_START, aPos.X(), aPos.Y());
+            SetCellSelectionPixel(LOK_SETTEXTSELECTION_END, aPos.X(), aPos.Y());
             return;
         }
     }
diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index a14c04e..e9d2185 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -1010,6 +1010,15 @@ void ScGridWindow::LogicInvalidate(const Rectangle* pRectangle)
 void ScGridWindow::SetCellSelectionPixel(int nType, int nPixelX, int nPixelY)
 {
     ScTabView* pTabView = pViewData->GetView();
+    ScTabViewShell* pViewShell = pViewData->GetViewShell();
+    ScInputHandler* pInputHandler = SC_MOD()->GetInputHdl(pViewShell);
+
+    if (pInputHandler && pInputHandler->IsInputMode())
+    {
+        // we need to switch off the editeng
+        pViewShell->UpdateInputLine();
+        pViewShell->UpdateInputHandler();
+    }
 
     if (nType == LOK_SETTEXTSELECTION_RESET)
     {
@@ -1024,10 +1033,12 @@ void ScGridWindow::SetCellSelectionPixel(int nType, int nPixelX, int nPixelY)
     SCROW nRow1, nRow2;
     SCTAB nTab1, nTab2;
 
+    bool bWasEmpty = false;
     if (aRangeList.empty())
     {
         nCol1 = nCol2 = pViewData->GetCurX();
         nRow1 = nRow2 = pViewData->GetCurY();
+        bWasEmpty = true;
     }
     else
         aRangeList.Combine().GetVars(nCol1, nRow1, nTab1, nCol2, nRow2, nTab2);
@@ -1042,7 +1053,7 @@ void ScGridWindow::SetCellSelectionPixel(int nType, int nPixelX, int nPixelY)
     switch (nType)
     {
         case LOK_SETTEXTSELECTION_START:
-            if (nNewPosX != nCol1 || nNewPosY != nRow1)
+            if (nNewPosX != nCol1 || nNewPosY != nRow1 || bWasEmpty)
             {
                 pTabView->SetCursor(nNewPosX, nNewPosY);
                 pTabView->DoneBlockMode();
@@ -1051,7 +1062,7 @@ void ScGridWindow::SetCellSelectionPixel(int nType, int nPixelX, int nPixelY)
             }
             break;
         case LOK_SETTEXTSELECTION_END:
-            if (nNewPosX != nCol2 || nNewPosY != nRow2)
+            if (nNewPosX != nCol2 || nNewPosY != nRow2 || bWasEmpty)
             {
                 pTabView->SetCursor(nCol1, nRow1);
                 pTabView->DoneBlockMode();
commit 9c33fc5fd93869922da4b84fd01037998c1d741d
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Wed Apr 8 22:05:33 2015 +0200

    sc tiled editing: Double click in the cell selects the entire cell.
    
    Change-Id: Ib537d5e4a0c7c9ed6a6b2520512d32da6c651188

diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index 770166d..b351c4c 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -1694,6 +1694,7 @@ void ScGridWindow::HandleMouseButtonDown( const MouseEvent& rMEvt, MouseEventSta
     bool bFormulaMode = pScMod->IsFormulaMode();            // naechster Klick -> Referenz
     bool bEditMode = pViewData->HasEditView(eWhich);        // auch bei Mode==SC_INPUT_TYPE
     bool bDouble = (rMEvt.GetClicks() == 2);
+    bool bIsTiledRendering = pViewData->GetDocument()->GetDrawLayer()->isTiledRendering();
 
     //  DeactivateIP passiert nur noch bei MarkListHasChanged
 
@@ -1703,6 +1704,36 @@ void ScGridWindow::HandleMouseButtonDown( const MouseEvent& rMEvt, MouseEventSta
     if ( !nButtonDown || !bDouble )             // single (first) click is always valid
         nButtonDown = rMEvt.GetButtons();       // set nButtonDown first, so StopMarking works
 
+    // special handling of empty cells with tiled rendering - with double
+    // click, the entire cell is selected
+    if (bIsTiledRendering && bDouble)
+    {
+        Point aPos = rMEvt.GetPosPixel();
+        SCsCOL nPosX;
+        SCsROW nPosY;
+        SCTAB nTab = pViewData->GetTabNo();
+        pViewData->GetPosFromPixel(aPos.X(), aPos.Y(), eWhich, nPosX, nPosY);
+
+        ScRefCellValue aCell;
+        aCell.assign(*pViewData->GetDocument(), ScAddress(nPosX, nPosY, nTab));
+        if (aCell.isEmpty())
+        {
+            // stop editing
+            ScTabViewShell* pViewShell = pViewData->GetViewShell();
+            pViewShell->UpdateInputLine();
+            pViewShell->UpdateInputHandler();
+
+            // select the given cell
+            ScTabView* pTabView = pViewData->GetView();
+            pTabView->SetCursor(nPosX, nPosY);
+            pTabView->DoneBlockMode();
+            pTabView->InitBlockMode(nPosX, nPosY, nTab, true);
+            pTabView->MarkCursor(nPosX, nPosY, nTab);
+            pTabView->SelectionChanged();
+            return;
+        }
+    }
+
     if ( ( bEditMode && pViewData->GetActivePart() == eWhich ) || !bFormulaMode )
         GrabFocus();
 
@@ -1825,7 +1856,9 @@ void ScGridWindow::HandleMouseButtonDown( const MouseEvent& rMEvt, MouseEventSta
         }
     }
 
-    if (!bFormulaMode && !bEditMode && rMEvt.IsLeft())
+    // in the tiled rendering case, single clicks into drawing objects take
+    // precedence over bEditMode
+    if (((!bFormulaMode && !bEditMode) || bIsTiledRendering) && rMEvt.IsLeft())
     {
         if ( !bCrossPointer && DrawMouseButtonDown(rMEvt) )
         {
@@ -1837,17 +1870,6 @@ void ScGridWindow::HandleMouseButtonDown( const MouseEvent& rMEvt, MouseEventSta
         //  TestMouse schon oben passiert
     }
 
-    // In the tiled rendering case, select shapes
-    if (rMEvt.IsLeft() && pViewData->GetDocument()->GetDrawLayer()->isTiledRendering())
-    {
-        if ( !bCrossPointer && DrawMouseButtonDown(rMEvt) )
-        {
-            return;
-        }
-
-        pViewData->GetViewShell()->SetDrawShell( false );
-    }
-
     Point aPos = rMEvt.GetPosPixel();
     SCsCOL nPosX;
     SCsROW nPosY;
@@ -1927,10 +1949,6 @@ void ScGridWindow::HandleMouseButtonDown( const MouseEvent& rMEvt, MouseEventSta
         }
         else
             nMouseStatus = SC_GM_TABDOWN;
-
-        // In the tiled rendering case, fake mouse status to double click
-        if ( nMouseStatus == SC_GM_TABDOWN && pDoc->GetDrawLayer()->isTiledRendering() )
-            nMouseStatus = SC_GM_DBLDOWN;
     }
 
             //      Links in Edit-Zellen
@@ -2215,9 +2233,12 @@ void ScGridWindow::MouseButtonUp( const MouseEvent& rMEvt )
             pView->ResetBrushDocument();            // invalidates pBrushDoc pointer
     }
 
-    // In the tiled rendering case, change double click to single click (only left button)
-    bool bDouble = ( pDoc->GetDrawLayer()->isTiledRendering() && rMEvt.IsLeft() ) || ( rMEvt.GetClicks() == 2 && rMEvt.IsLeft() );
-    if ( bDouble && !bRefMode && nMouseStatus == SC_GM_DBLDOWN && !pScMod->IsRefDialogOpen() )
+    // double click (only left button)
+    // in the tiled rendering case, single click works this way too
+
+    bool bIsTiledRendering = pViewData->GetDocument()->GetDrawLayer()->isTiledRendering();
+    bool bDouble = ( rMEvt.GetClicks() == 2 && rMEvt.IsLeft() );
+    if ((bDouble || bIsTiledRendering) && !bRefMode && (nMouseStatus == SC_GM_DBLDOWN || bIsTiledRendering) && !pScMod->IsRefDialogOpen())
     {
         //  data pilot table
         Point aPos = rMEvt.GetPosPixel();
@@ -2282,6 +2303,16 @@ void ScGridWindow::MouseButtonUp( const MouseEvent& rMEvt )
 
         if ( bEditAllowed )
         {
+            // don't forward the event to an empty cell, causes deselection in
+            // case we used the double-click to select the empty cell
+            if (bIsTiledRendering)
+            {
+                ScRefCellValue aCell;
+                aCell.assign(*pViewData->GetDocument(), ScAddress(nPosX, nPosY, nTab));
+                if (aCell.isEmpty())
+                    return;
+            }
+
             //  edit cell contents
             pViewData->GetViewShell()->UpdateInputHandler();
             pScMod->SetInputMode( SC_INPUT_TABLE );
@@ -2765,10 +2796,7 @@ void ScGridWindow::Tracking( const TrackingEvent& rTEvt )
 
         MouseEvent aUpEvt( rMEvt.GetPosPixel(), rMEvt.GetClicks(),
                             rMEvt.GetMode(), nButtonDown, rMEvt.GetModifier() );
-
-        // In the tiled rendering case, do not spawn fake mouse up
-        if (!pViewData->GetDocument()->GetDrawLayer()->isTiledRendering())
-            MouseButtonUp( aUpEvt );
+        MouseButtonUp( aUpEvt );
     }
     else
         MouseMove( rMEvt );


More information about the Libreoffice-commits mailing list