Blame SOURCES/0278-sc-lok-make-cell-cursor-behaviour-consistent-with-de.patch

135360
From 21fcedc3a2989b6b979296164f014b59ae74d450 Mon Sep 17 00:00:00 2001
135360
From: Andrzej Hunt <andrzej@ahunt.org>
135360
Date: Tue, 3 Nov 2015 10:14:02 +0100
135360
Subject: [PATCH 278/398] sc lok: make cell cursor behaviour consistent with
135360
 desktop
135360
135360
I.e. single click selects cell, typing activates the EditView
135360
(and hides the cell cursor). (Previously: single click activates
135360
the edit view, text cursor is shown, and no clean way of hiding
135360
the cell cursor again.)
135360
135360
(cherry picked from commit f859dac52e40759fb8202d891df4e1442bc35803)
135360
135360
Change-Id: I184630277e8935e9f8a97a856191497ec5d62111
135360
---
135360
 sc/source/ui/view/gridwin.cxx | 75 +++++++++++++++++++++++--------------------
135360
 1 file changed, 40 insertions(+), 35 deletions(-)
135360
135360
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
135360
index dd958e519249..daca987b14b2 100644
135360
--- a/sc/source/ui/view/gridwin.cxx
135360
+++ b/sc/source/ui/view/gridwin.cxx
135360
@@ -2412,7 +2412,9 @@ void ScGridWindow::MouseButtonUp( const MouseEvent& rMEvt )
135360
                 bEditAllowed = false;
135360
         }
135360
 
135360
-        if ( bEditAllowed )
135360
+        // We don't want to activate the edit view for a single click in tiled rendering
135360
+        // (but we should probably keep the same behaviour for double clicks).
135360
+        if ( bEditAllowed && (!bIsTiledRendering || bDouble) )
135360
         {
135360
             // don't forward the event to an empty cell, causes deselection in
135360
             // case we used the double-click to select the empty cell
135360
@@ -5809,7 +5811,6 @@ void ScGridWindow::updateLibreOfficeKitCellCursor() {
135360
     pViewData->SetZoom(defaultZoomX, defaultZoomY, true);
135360
 
135360
     pDrawLayer->libreOfficeKitCallback(LOK_CALLBACK_CELL_CURSOR, aRect.toString().getStr());
135360
-
135360
 }
135360
 
135360
 void ScGridWindow::CursorChanged()
135360
@@ -5818,8 +5819,6 @@ void ScGridWindow::CursorChanged()
135360
     // now, just re-create them
135360
 
135360
     UpdateCursorOverlay();
135360
-
135360
-    updateLibreOfficeKitCellCursor();
135360
 }
135360
 
135360
 // #114409#
135360
@@ -5856,6 +5855,9 @@ void ScGridWindow::UpdateAllOverlays()
135360
 
135360
 void ScGridWindow::DeleteCursorOverlay()
135360
 {
135360
+    ScDocument* pDoc = pViewData->GetDocument();
135360
+    ScDrawLayer* pDrawLayer = pDoc->GetDrawLayer();
135360
+    pDrawLayer->libreOfficeKitCallback(LOK_CALLBACK_CELL_CURSOR, "EMPTY");
135360
     mpOOCursors.reset();
135360
 }
135360
 
135360
@@ -5973,11 +5975,6 @@ void ScGridWindow::UpdateCursorOverlay()
135360
 {
135360
     ScDocument* pDoc = pViewData->GetDocument();
135360
 
135360
-    // The cursor is rendered client-side in tiled rendering -
135360
-    // see updateLibreOfficeKitCellCursor.
135360
-    if (pDoc->GetDrawLayer()->isTiledRendering())
135360
-        return;
135360
-
135360
     MapMode aDrawMode = GetDrawMapMode();
135360
     MapMode aOldMode = GetMapMode();
135360
     if ( aOldMode != aDrawMode )
135360
@@ -6096,40 +6093,48 @@ void ScGridWindow::UpdateCursorOverlay()
135360
         }
135360
     }
135360
 
135360
+    ScDrawLayer* pDrawLayer = pDoc->GetDrawLayer();
135360
+
135360
     if ( !aPixelRects.empty() )
135360
     {
135360
-        // #i70788# get the OverlayManager safely
135360
-        rtl::Reference<sdr::overlay::OverlayManager> xOverlayManager = getOverlayManager();
135360
-
135360
-        if (xOverlayManager.is())
135360
+        if (pDrawLayer->isTiledRendering()) {
135360
+            updateLibreOfficeKitCellCursor();
135360
+        }
135360
+        else
135360
         {
135360
-            Color aCursorColor( SC_MOD()->GetColorConfig().GetColorValue(svtools::FONTCOLOR).nColor );
135360
-            if (pViewData->GetActivePart() != eWhich)
135360
-                // non-active pane uses a different color.
135360
-                aCursorColor = SC_MOD()->GetColorConfig().GetColorValue(svtools::CALCPAGEBREAKAUTOMATIC).nColor;
135360
-            std::vector< basegfx::B2DRange > aRanges;
135360
-            const basegfx::B2DHomMatrix aTransform(GetInverseViewTransformation());
135360
+            // #i70788# get the OverlayManager safely
135360
+            rtl::Reference<sdr::overlay::OverlayManager> xOverlayManager = getOverlayManager();
135360
 
135360
-            for(sal_uInt32 a(0); a < aPixelRects.size(); a++)
135360
+            if (xOverlayManager.is())
135360
             {
135360
-                const Rectangle aRA(aPixelRects[a]);
135360
-                basegfx::B2DRange aRB(aRA.Left(), aRA.Top(), aRA.Right() + 1, aRA.Bottom() + 1);
135360
-                aRB.transform(aTransform);
135360
-                aRanges.push_back(aRB);
135360
-            }
135360
+                Color aCursorColor( SC_MOD()->GetColorConfig().GetColorValue(svtools::FONTCOLOR).nColor );
135360
+                if (pViewData->GetActivePart() != eWhich)
135360
+                    // non-active pane uses a different color.
135360
+                    aCursorColor = SC_MOD()->GetColorConfig().GetColorValue(svtools::CALCPAGEBREAKAUTOMATIC).nColor;
135360
+                std::vector< basegfx::B2DRange > aRanges;
135360
+                const basegfx::B2DHomMatrix aTransform(GetInverseViewTransformation());
135360
+
135360
+                for(size_t a(0); a < aPixelRects.size(); a++)
135360
+                {
135360
+                    const Rectangle aRA(aPixelRects[a]);
135360
+                    basegfx::B2DRange aRB(aRA.Left(), aRA.Top(), aRA.Right() + 1, aRA.Bottom() + 1);
135360
+                    aRB.transform(aTransform);
135360
+                    aRanges.push_back(aRB);
135360
+                }
135360
 
135360
-            sdr::overlay::OverlayObject* pOverlay = new sdr::overlay::OverlaySelection(
135360
-                sdr::overlay::OVERLAY_SOLID,
135360
-                aCursorColor,
135360
-                aRanges,
135360
-                false);
135360
+                sdr::overlay::OverlayObject* pOverlay = new sdr::overlay::OverlaySelection(
135360
+                    sdr::overlay::OVERLAY_SOLID,
135360
+                    aCursorColor,
135360
+                    aRanges,
135360
+                    false);
135360
 
135360
-            xOverlayManager->add(*pOverlay);
135360
-            mpOOCursors.reset(new sdr::overlay::OverlayObjectList);
135360
-            mpOOCursors->append(*pOverlay);
135360
+                xOverlayManager->add(*pOverlay);
135360
+                mpOOCursors.reset(new sdr::overlay::OverlayObjectList);
135360
+                mpOOCursors->append(*pOverlay);
135360
 
135360
-            // notify the LibreOfficeKit too
135360
-            updateLibreOfficeKitSelection(pViewData, pDoc->GetDrawLayer(), aPixelRects);
135360
+                // notify the LibreOfficeKit too
135360
+                updateLibreOfficeKitSelection(pViewData, pDoc->GetDrawLayer(), aPixelRects);
135360
+            }
135360
         }
135360
     }
135360
 
135360
-- 
135360
2.12.0
135360