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 09:07:48 +0000
commitfcf417a77369853195d6727b2db8df290663256e (patch)
tree9905acc11d39f87e75833eb1b5ed0873b6bb14bf
parentb8ee524330d924456931ad602eb4701b55a2aa85 (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>
-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 8dec1acb1eb2..3ff46d09460f 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 161f159f4290..7f311dca5228 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 68546489be89..2aef68d7c3f3 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 94d38beb07cb..220cd6f7f31f 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 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: */