summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2016-09-01 09:11:37 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-09-01 12:04:05 +0200
commit2da960dbf792f07cc16b2b2743f83041286de1a1 (patch)
treeabb4a15d8c6b912c943cf7e8c2b7431f2916fd9c
parentf502cdb7000f8e61e3530370b28f160e6ef499c6 (diff)
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@collabora.co.uk> Tested-by: Jenkins <ci@libreoffice.org> (cherry picked from commit fcf417a77369853195d6727b2db8df290663256e)
-rw-r--r--sc/qa/unit/tiledrendering/tiledrendering.cxx6
-rw-r--r--sc/source/ui/inc/gridwin.hxx4
-rw-r--r--sc/source/ui/inc/tabvwsh.hxx2
-rw-r--r--sc/source/ui/view/gridwin.cxx21
-rw-r--r--sc/source/ui/view/tabvwshc.cxx9
5 files changed, 35 insertions, 7 deletions
diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx
index e738807fbff5..a61397a4067d 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -410,8 +410,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 017ca86156e5..0432532c7cd0 100644
--- a/sc/source/ui/inc/gridwin.hxx
+++ b/sc/source/ui/inc/gridwin.hxx
@@ -288,7 +288,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;
@@ -429,11 +428,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;
protected:
void ImpCreateOverlayObjects();
diff --git a/sc/source/ui/inc/tabvwsh.hxx b/sc/source/ui/inc/tabvwsh.hxx
index 6a2ae9b82ab1..cd0f3e08faf6 100644
--- a/sc/source/ui/inc/tabvwsh.hxx
+++ b/sc/source/ui/inc/tabvwsh.hxx
@@ -387,6 +387,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 205a9e6829e5..bbb18e0eb666 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -5817,7 +5817,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.
@@ -5849,12 +5850,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()
@@ -6145,7 +6156,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 9cdc11ebaf82..e84893b2f062 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: */