[Libreoffice-commits] core.git: sc/source

Michael Meeks (via logerrit) logerrit at kemper.freedesktop.org
Mon Dec 9 09:43:09 UTC 2019


 sc/source/ui/inc/gridwin.hxx   |    6 ++-
 sc/source/ui/unoobj/docuno.cxx |    3 +
 sc/source/ui/view/gridwin.cxx  |   75 +++++++++++++++++++++++++++--------------
 sc/source/ui/view/tabvwshc.cxx |    2 -
 4 files changed, 60 insertions(+), 26 deletions(-)

New commits:
commit 53a647afa68264422d556156b4e77e1b6f46a996
Author:     Michael Meeks <michael.meeks at collabora.com>
AuthorDate: Wed Dec 4 22:29:10 2019 +0000
Commit:     Michael Meeks <michael.meeks at collabora.com>
CommitDate: Mon Dec 9 10:42:14 2019 +0100

    lok: calc - update our version of the other view's selections on zoom.
    
    Change-Id: I8487f28d762c8bf5be4f00a331263218dc71d179
    Reviewed-on: https://gerrit.libreoffice.org/84694
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Michael Meeks <michael.meeks at collabora.com>
    (cherry picked from commit 2986620074d104611a6e78c98ee5a09941866125)
    Reviewed-on: https://gerrit.libreoffice.org/84698
    Tested-by: Jenkins

diff --git a/sc/source/ui/inc/gridwin.hxx b/sc/source/ui/inc/gridwin.hxx
index f64bfaa8d667..375e6e3cad2b 100644
--- a/sc/source/ui/inc/gridwin.hxx
+++ b/sc/source/ui/inc/gridwin.hxx
@@ -432,7 +432,11 @@ public:
 
     /// get Cell cursor in this view's co-ordinate system @see ScModelObj::getCellCursor().
     OString getCellCursor() const;
-    void updateLibreOfficeKitCellCursor(const SfxViewShell* pOtherShell) const;
+    void notifyKitCellCursor() const;
+    void notifyKitCellViewCursor(const SfxViewShell* pForShell) const;
+    void updateKitCellCursor(const SfxViewShell* pOtherShell) const;
+    /// notify this view with new positions for other view's cursors (after zoom)
+    void updateKitOtherCursors() const;
 
     /// Same as MouseButtonDown(), but coordinates are in logic unit.
     virtual void LogicMouseButtonDown(const MouseEvent& rMouseEvent) override;
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index 04c5bcbe400f..cae9343550f6 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -886,6 +886,9 @@ void ScModelObj::setClientZoom(int nTilePixelWidth_, int nTilePixelHeight_, int
 
     pViewData->SetZoom(Fraction(nTilePixelWidth_ * TWIPS_PER_PIXEL, nTileTwipWidth_),
                        Fraction(nTilePixelHeight_ * TWIPS_PER_PIXEL, nTileTwipHeight_), true);
+
+    // refresh our view's take on other view's cursors
+    pViewData->GetActiveWin()->updateKitOtherCursors();
 }
 
 OUString ScModelObj::getRowColumnHeaders(const tools::Rectangle& rRectangle)
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index 46c47bd46ecd..894f3d3f8e94 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -5692,42 +5692,69 @@ OString ScGridWindow::getCellCursor() const
     return pViewData->describeCellCursor();
 }
 
-// Send our cursor details to a view described by @pOtherShell, or all views
-// if @pOtherShell is null. In each case send the current view a cell-cursor
+void ScGridWindow::notifyKitCellCursor() const
+{
+    ScTabViewShell* pViewShell = pViewData->GetViewShell();
+
+    pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_CELL_CURSOR, getCellCursor().getStr());
+    if (bListValButton && aListValPos == pViewData->GetCurPos())
+        updateLOKValListButton(true, aListValPos);
+}
+
+void ScGridWindow::notifyKitCellViewCursor(const SfxViewShell* pForShell) const
+{
+    ScTabViewShell* pViewShell = pViewData->GetViewShell();
+
+    OString aCursor("EMPTY");
+    if (mpOOCursors) // cf. getCellCursor above
+    {
+        auto pForTabView = dynamic_cast<const ScTabViewShell *>(pForShell);
+        assert(pForTabView);
+        if (!pForTabView)
+            return;
+        aCursor = pForTabView->GetViewData().describeCellCursorAt(
+            pViewData->GetCurX(), pViewData->GetCurY()); // our position.
+    }
+    SfxLokHelper::notifyOtherView(pViewShell, pForShell, LOK_CALLBACK_CELL_VIEW_CURSOR, "rectangle", aCursor);
+}
+
+// Send our cursor details to a view described by @pForShell, or all views
+// if @pForShell is null. In each case send the current view a cell-cursor
 // event, and others a cell_view_cursor event.
 //
 // NB. we need to re-construct the cursor details for each other view in their
 // own zoomed co-ordinate system.
-void ScGridWindow::updateLibreOfficeKitCellCursor(const SfxViewShell* pForShell) const
+void ScGridWindow::updateKitCellCursor(const SfxViewShell* pForShell) const
 {
-    if (!pForShell) // recurse with it set
+    if (!pForShell)
     {
         for (SfxViewShell* it = SfxViewShell::GetFirst(); it;
              it = SfxViewShell::GetNext(*it))
-            updateLibreOfficeKitCellCursor(it);
+            updateKitCellCursor(it);
         return;
     }
 
-    ScTabViewShell* pViewShell = pViewData->GetViewShell();
-    if (pForShell == pViewShell)
-    {
-        pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_CELL_CURSOR, getCellCursor().getStr());
-        if (bListValButton && aListValPos == pViewData->GetCurPos())
-            updateLOKValListButton(true, aListValPos);
-    }
+    if (pForShell == pViewData->GetViewShell())
+        notifyKitCellCursor();
     else
+        notifyKitCellViewCursor(pForShell);
+}
+
+void ScGridWindow::updateKitOtherCursors() const
+{
+    for (SfxViewShell* it = SfxViewShell::GetFirst(); it;
+         it = SfxViewShell::GetNext(*it))
     {
-        OString aCursor("EMPTY");
-        if (mpOOCursors) // cf. getCellCursor above
-        {
-            auto pOther = dynamic_cast<const ScTabViewShell *>(pForShell);
-            assert(pOther);
-            if (!pOther)
-                return;
-            aCursor = pOther->GetViewData().describeCellCursorAt(
-                pViewData->GetCurX(), pViewData->GetCurY()); // our position.
-        }
-        SfxLokHelper::notifyOtherView(pViewShell, pForShell, LOK_CALLBACK_CELL_VIEW_CURSOR, "rectangle", aCursor);
+        auto pOther = dynamic_cast<const ScTabViewShell *>(it);
+        assert(pOther);
+        if (!pOther)
+            continue;
+        const ScGridWindow *pGrid = pOther->GetViewData().GetActiveWin();
+        assert(pGrid);
+        if (pGrid == this)
+            notifyKitCellCursor();
+        else
+            pGrid->notifyKitCellViewCursor(pViewData->GetViewShell());
     }
 }
 
@@ -6039,7 +6066,7 @@ void ScGridWindow::UpdateCursorOverlay()
         if (comphelper::LibreOfficeKit::isActive())
         {
             mpOOCursors.reset(new sdr::overlay::OverlayObjectList);
-            updateLibreOfficeKitCellCursor(nullptr);
+            updateKitCellCursor(nullptr);
         }
         else
         {
diff --git a/sc/source/ui/view/tabvwshc.cxx b/sc/source/ui/view/tabvwshc.cxx
index b936e5553a0d..b9ba63505887 100644
--- a/sc/source/ui/view/tabvwshc.cxx
+++ b/sc/source/ui/view/tabvwshc.cxx
@@ -462,7 +462,7 @@ void ScTabViewShell::NotifyCursor(SfxViewShell* pOtherShell) const
 
     const ScGridWindow* pWin = GetViewData().GetActiveWin();
     if (pWin)
-        pWin->updateLibreOfficeKitCellCursor(pOtherShell);
+        pWin->updateKitCellCursor(pOtherShell);
 }
 
 css::uno::Reference<css::datatransfer::XTransferable2> ScTabViewShell::GetClipData(vcl::Window* pWin)


More information about the Libreoffice-commits mailing list