diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-08-31 17:19:13 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-08-31 17:18:57 +0000 |
commit | 7167c2b6548830b82280f2f3943d445e9afd6f5e (patch) | |
tree | 230ffd5a218cfe2ead02504b0aaff0696e638c3a /sfx2/source/view | |
parent | f322c52b89f514b792179c4d7e6ee2c3aa893a4e (diff) |
sfx2 lok: introduce SfxViewShell::NotifyCursor()
It allows removing the hide/show cursor hack in
SfxViewShell::registerLibreOfficeKitViewCallback() introduced in commit
4d211384f048b689f20e46d4d586f342b110cb5c (sfx2 lok: fix missing view
cursors in a new view, 2016-06-20), and instead let the application code
in sw/sc/sd implement the best way to show existing cursors in a new
view.
This way the per-app cleanup of view cursors introduced in commit
bc9b4fd4c83af3532204237157821d4884c42d8e (lok::Document::destroyView:
clean up view cursors/selections, 2016-07-15) has matching per-app init
code.
This commit just adds the API + adapts existing sw code to use it, sc/sd
still has to be implemented.
Based on a patch by Marco Cecchetti, thanks!
Change-Id: I38510fa4962f405b1b96a79024206c9e7f33cad2
Reviewed-on: https://gerrit.libreoffice.org/28557
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'sfx2/source/view')
-rw-r--r-- | sfx2/source/view/lokhelper.cxx | 26 | ||||
-rw-r--r-- | sfx2/source/view/viewsh.cxx | 9 |
2 files changed, 21 insertions, 14 deletions
diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx index 7a23e1b5dbee..c5fb171f246b 100644 --- a/sfx2/source/view/lokhelper.cxx +++ b/sfx2/source/view/lokhelper.cxx @@ -92,6 +92,19 @@ std::size_t SfxLokHelper::getViews() return rViewArr.size(); } +void SfxLokHelper::notifyOtherView(SfxViewShell* pThisView, SfxViewShell* pOtherView, int nType, const OString& rKey, const OString& rPayload) +{ + boost::property_tree::ptree aTree; + aTree.put("viewId", SfxLokHelper::getView(pThisView)); + aTree.put(rKey.getStr(), rPayload.getStr()); + aTree.put("part", pThisView->getPart()); + aTree.put(rKey.getStr(), rPayload.getStr()); + std::stringstream aStream; + boost::property_tree::write_json(aStream, aTree); + OString aPayload = aStream.str().c_str(); + pOtherView->libreOfficeKitViewCallback(nType, aPayload.getStr()); +} + void SfxLokHelper::notifyOtherViews(SfxViewShell* pThisView, int nType, const OString& rKey, const OString& rPayload) { if (SfxLokHelper::getViews() <= 1) @@ -101,17 +114,8 @@ void SfxLokHelper::notifyOtherViews(SfxViewShell* pThisView, int nType, const OS while (pViewShell) { if (pViewShell != pThisView) - { - boost::property_tree::ptree aTree; - aTree.put("viewId", SfxLokHelper::getView(pThisView)); - aTree.put(rKey.getStr(), rPayload.getStr()); - aTree.put("part", pThisView->getPart()); - aTree.put(rKey.getStr(), rPayload.getStr()); - std::stringstream aStream; - boost::property_tree::write_json(aStream, aTree); - OString aPayload = aStream.str().c_str(); - pViewShell->libreOfficeKitViewCallback(nType, aPayload.getStr()); - } + notifyOtherView(pThisView, pViewShell, nType, rKey, rPayload); + pViewShell = SfxViewShell::GetNext(*pViewShell); } } diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx index f2d8e4875b2a..710c9cbb1189 100644 --- a/sfx2/source/view/viewsh.cxx +++ b/sfx2/source/view/viewsh.cxx @@ -1462,12 +1462,11 @@ void SfxViewShell::registerLibreOfficeKitViewCallback(LibreOfficeKitCallback pCa pImpl->m_pLibreOfficeKitViewCallback = pCallback; pImpl->m_pLibreOfficeKitViewData = pData; - // Ask other views to send their cursor position to the new view. + // Ask other views to tell us about their cursors. SfxViewShell* pViewShell = SfxViewShell::GetFirst(); while (pViewShell) { - pViewShell->ShowCursor(false); - pViewShell->ShowCursor(); + pViewShell->NotifyCursor(this); pViewShell = SfxViewShell::GetNext(*pViewShell); } } @@ -1495,6 +1494,10 @@ void SfxViewShell::libreOfficeKitViewCallback(int nType, const char* pPayload) c pImpl->m_pLibreOfficeKitViewCallback(nType, pPayload, pImpl->m_pLibreOfficeKitViewData); } +void SfxViewShell::NotifyCursor(SfxViewShell* /*pViewShell*/) const +{ +} + void SfxViewShell::setTiledSearching(bool bTiledSearching) { pImpl->m_bTiledSearching = bTiledSearching; |