sc/source/ui/view/gridwin.cxx |   61 +-----------------------------------------
 1 file changed, 2 insertions(+), 59 deletions(-)

New commits:
commit 657ddc1a8631418f39f587e448954ec47996cf75
Author:     Jan Holesovsky <ke...@collabora.com>
AuthorDate: Mon Oct 24 16:27:17 2022 +0200
Commit:     Gülşah Köse <gulsah.k...@collabora.com>
CommitDate: Tue Nov 8 16:04:45 2022 +0100

    sc lok: Double-click should behave more like on desktop
    
    When editing was introduced in Calc LibreOfficeKit, there were lots of
    limitations.  Particularly the thinking was that it would be good if a
    double-click into any text (even if spanning over more cells)
    actually started editing that text.
    
    These days, the LOK behaves much more consistently, so it is better to
    behave as the LibreOffice on desktop (or other tools, like gdocs) do:
    
    If the cell:
    
    * Is empty
    
        -> single click places the cell cursor
        -> double click places the cell cursor & shows the text caret
    
    * Is empty, but covered by text bleeding from other cell
    
        -> same as if it was empty
    
    * Isn't empty
    
        -> single click places the cell cursor
        -> double click places the cell cursor & places the text caret
           inside the text where the user clicked
    
            + this is actually different in gdocs - there the caret is
              placed at the end of the text; in LO it is where the user has
              double-clicked
    
    Change-Id: Ib5884f887c98f803b06d8bed5057ec435be480ef
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141772
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Gülşah Köse <gulsah.k...@collabora.com>

diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index 32573c92b8a2..93522adc4bdb 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -1809,49 +1809,6 @@ 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
-    if (bIsTiledRendering)
-    {
-        Point aPos(rMEvt.GetPosPixel());
-        SCCOL nPosX, nNonEmptyX(0);
-        SCROW nPosY;
-        SCTAB nTab = mrViewData.GetTabNo();
-        mrViewData.GetPosFromPixel(aPos.X(), aPos.Y(), eWhich, nPosX, nPosY);
-
-        ScRefCellValue aCell(rDoc, ScAddress(nPosX, nPosY, nTab));
-        bool bIsEmpty = aCell.isEmpty();
-        bool bIsCoveredByText = bIsEmpty && IsCellCoveredByText(nPosX, nPosY, 
nTab, nNonEmptyX);
-
-        if (bIsCoveredByText)
-        {
-            // if there's any text flowing to this cell, activate the
-            // editengine, so that the text actually gets the events
-            if (bDouble)
-            {
-                ScViewFunc* pView = mrViewData.GetView();
-
-                pView->SetCursor(nNonEmptyX, nPosY);
-                SC_MOD()->SetInputMode(SC_INPUT_TABLE);
-
-                bEditMode = mrViewData.HasEditView(eWhich);
-                assert(bEditMode);
-
-                // synthesize the 1st click
-                EditView* pEditView = mrViewData.GetEditView(eWhich);
-                MouseEvent aEditEvt(rMEvt.GetPosPixel(), 1, 
MouseEventModifiers::SYNTHETIC, MOUSE_LEFT, 0);
-                pEditView->MouseButtonDown(aEditEvt);
-                pEditView->MouseButtonUp(aEditEvt);
-            }
-        }
-        else if (bIsEmpty && bEditMode && bDouble)
-        {
-            // double-click in an empty cell: the entire cell is selected
-            SetCellSelectionPixel(LOK_SETTEXTSELECTION_START, aPos.X(), 
aPos.Y());
-            SetCellSelectionPixel(LOK_SETTEXTSELECTION_END, aPos.X(), 
aPos.Y());
-            return;
-        }
-    }
-
     if ( ( bEditMode && mrViewData.GetActivePart() == eWhich ) || 
!bFormulaMode )
         GrabFocus();
 
@@ -2382,14 +2339,11 @@ void ScGridWindow::MouseButtonUp( const MouseEvent& 
rMEvt )
     mrViewData.GetPosFromPixel( aPos.X(), aPos.Y(), eWhich, nPosX, nPosY );
     ScDPObject* pDPObj  = rDoc.GetDPAtCursor( nPosX, nPosY, nTab );
 
-    bool bInDataPilotTable = (pDPObj != nullptr);
-
     // double click (only left button)
-    // in the tiled rendering case, single click works this way too
 
     bool bIsTiledRendering = comphelper::LibreOfficeKit::isActive();
     bool bDouble = ( rMEvt.GetClicks() == 2 && rMEvt.IsLeft() );
-    if ((bDouble || (bIsTiledRendering && !bInDataPilotTable))
+    if ( bDouble
             && !bRefMode
             && (nMouseStatus == SC_GM_DBLDOWN || (bIsTiledRendering && 
nMouseStatus != SC_GM_URLDOWN))
             && !pScMod->IsRefDialogOpen())
@@ -2449,19 +2403,8 @@ void ScGridWindow::MouseButtonUp( const MouseEvent& 
rMEvt )
                 bEditAllowed = false;
         }
 
-        // We don't want to activate the edit view for a single click in tiled 
rendering
-        // (but we should probably keep the same behaviour for double clicks).
-        if ( bEditAllowed && (!bIsTiledRendering || bDouble) )
+        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 && bDouble)
-            {
-                ScRefCellValue aCell(mrViewData.GetDocument(), 
ScAddress(nPosX, nPosY, nTab));
-                if (aCell.isEmpty())
-                    return;
-            }
-
             //  edit cell contents
             mrViewData.GetViewShell()->UpdateInputHandler();
             pScMod->SetInputMode( SC_INPUT_TABLE );

Reply via email to