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

Miklos Vajna vmiklos at collabora.co.uk
Thu Sep 1 09:08:12 UTC 2016


 sc/qa/unit/tiledrendering/tiledrendering.cxx |    6 ++++++
 sc/source/ui/inc/gridwin.hxx                 |    4 ++--
 sc/source/ui/inc/tabvwsh.hxx                 |    2 ++
 sc/source/ui/view/gridwin.cxx                |   21 ++++++++++++++++-----
 sc/source/ui/view/tabvwshc.cxx               |    9 +++++++++
 5 files changed, 35 insertions(+), 7 deletions(-)

New commits:
commit fcf417a77369853195d6727b2db8df290663256e
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Sep 1 09:11:37 2016 +0200

    sc lok: implement SfxViewShell::NotifyCursor() API
    
    This way a new Calc view gets the cell cursors of existing views even if
    they don't move after registering the LOK callback in the new view.
    
    Change-Id: I5babc9921d37217ac199d4c19ed33cbb9620d119
    Reviewed-on: https://gerrit.libreoffice.org/28581
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
    Tested-by: Jenkins <ci at libreoffice.org>

diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx
index 8dec1ac..3ff46d0 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -432,8 +432,14 @@ void ScTiledRenderingTest::testViewCursors()
     ViewCallback aView1;
     SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView1);
     SfxLokHelper::createView();
+    pModelObj->initializeForTiledRendering(uno::Sequence<beans::PropertyValue>());
     ViewCallback aView2;
+    aView2.m_bViewCursorInvalidated = false;
+    aView2.m_bOwnCursorInvalidated = false;
     SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView2);
+    // This was false, the new view did not get the view (cell) cursor of the old view.
+    CPPUNIT_ASSERT(aView2.m_bViewCursorInvalidated);
+    CPPUNIT_ASSERT(aView2.m_bOwnCursorInvalidated);
     pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, awt::Key::DOWN);
     pModelObj->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::DOWN);
     Scheduler::ProcessEventsToIdle();
diff --git a/sc/source/ui/inc/gridwin.hxx b/sc/source/ui/inc/gridwin.hxx
index 161f159..7f311dc 100644
--- a/sc/source/ui/inc/gridwin.hxx
+++ b/sc/source/ui/inc/gridwin.hxx
@@ -285,7 +285,6 @@ class ScGridWindow : public vcl::Window, public DropTargetHelper, public DragSou
     void            GetSelectionRects( ::std::vector< Rectangle >& rPixelRects );
 
 
-    void            updateLibreOfficeKitCellCursor();
 protected:
     virtual void    PrePaint(vcl::RenderContext& rRenderContext) override;
     virtual void    Paint(vcl::RenderContext& rRenderContext, const Rectangle& rRect) override;
@@ -426,11 +425,12 @@ public:
 
     /// @see ScModelObj::getCellCursor().
     OString         getCellCursor(const Fraction& rZoomX,
-                                  const Fraction& rZoomY);
+                                  const Fraction& rZoomY) const;
     OString         getCellCursor(int nOutputWidth,
                                   int nOutputHeight,
                                   long nTileWidth,
                                   long nTileHeight);
+    void updateLibreOfficeKitCellCursor(SfxViewShell* pOtherShell) const;
 
     ScViewData* getViewData();
     virtual FactoryFunction GetUITestFactory() const override;
diff --git a/sc/source/ui/inc/tabvwsh.hxx b/sc/source/ui/inc/tabvwsh.hxx
index 6854648..2aef68d 100644
--- a/sc/source/ui/inc/tabvwsh.hxx
+++ b/sc/source/ui/inc/tabvwsh.hxx
@@ -386,6 +386,8 @@ public:
     void SetForceFocusOnCurCell(bool bFlag) { bForceFocusOnCurCell=bFlag; }
     /// See SfxViewShell::getPart().
     int getPart() const override;
+    /// See SfxViewShell::NotifyCursor().
+    void NotifyCursor(SfxViewShell* pViewShell) const override;
 };
 
 #endif
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index 94d38be..220cd6f 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -5682,7 +5682,8 @@ OString ScGridWindow::getCellCursor( int nOutputWidth, int nOutputHeight,
     return getCellCursor(zoomX, zoomY);
 }
 
-OString ScGridWindow::getCellCursor(const Fraction& rZoomX, const Fraction& rZoomY) {
+OString ScGridWindow::getCellCursor(const Fraction& rZoomX, const Fraction& rZoomY) const
+{
     // GridWindow stores a shown cell cursor in mpOOCursors, hence
     // we can use that to determine whether we would want to be showing
     // one (client-side) for tiled rendering too.
@@ -5714,12 +5715,22 @@ OString ScGridWindow::getCellCursor(const Fraction& rZoomX, const Fraction& rZoo
     return aRect.toString();
 }
 
-void ScGridWindow::updateLibreOfficeKitCellCursor()
+void ScGridWindow::updateLibreOfficeKitCellCursor(SfxViewShell* pOtherShell) const
 {
     OString aCursor = getCellCursor(pViewData->GetZoomX(), pViewData->GetZoomY());
     ScTabViewShell* pViewShell = pViewData->GetViewShell();
-    pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_CELL_CURSOR, aCursor.getStr());
-    SfxLokHelper::notifyOtherViews(pViewShell, LOK_CALLBACK_CELL_VIEW_CURSOR, "rectangle", aCursor);
+    if (pOtherShell)
+    {
+        if (pOtherShell == pViewShell)
+            pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_CELL_CURSOR, aCursor.getStr());
+        else
+            SfxLokHelper::notifyOtherView(pViewShell, pOtherShell, LOK_CALLBACK_CELL_VIEW_CURSOR, "rectangle", aCursor);
+    }
+    else
+    {
+        pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_CELL_CURSOR, aCursor.getStr());
+        SfxLokHelper::notifyOtherViews(pViewShell, LOK_CALLBACK_CELL_VIEW_CURSOR, "rectangle", aCursor);
+    }
 }
 
 void ScGridWindow::CursorChanged()
@@ -6010,7 +6021,7 @@ void ScGridWindow::UpdateCursorOverlay()
         if (comphelper::LibreOfficeKit::isActive())
         {
             mpOOCursors.reset(new sdr::overlay::OverlayObjectList);
-            updateLibreOfficeKitCellCursor();
+            updateLibreOfficeKitCellCursor(nullptr);
         }
         else
         {
diff --git a/sc/source/ui/view/tabvwshc.cxx b/sc/source/ui/view/tabvwshc.cxx
index 9cdc11e..e84893b 100644
--- a/sc/source/ui/view/tabvwshc.cxx
+++ b/sc/source/ui/view/tabvwshc.cxx
@@ -541,4 +541,13 @@ int ScTabViewShell::getPart() const
     return GetViewData().GetTabNo();
 }
 
+void ScTabViewShell::NotifyCursor(SfxViewShell* pViewShell) const
+{
+    const ScGridWindow* pGridWindow = GetViewData().GetActiveWin();
+    if (!pGridWindow)
+        return;
+
+    pGridWindow->updateLibreOfficeKitCellCursor(pViewShell);
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list