diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-08-31 17:19:13 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-09-01 10:16:51 +0200 |
commit | 2a38d1b186428f0b23722f304addfae43e00677e (patch) | |
tree | 26e71cec5ccdf08d2880f3c1327db430002d5fb2 /sfx2 | |
parent | bc4a592baa01279bf9718a80fef8eb1410f16831 (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!
Reviewed-on: https://gerrit.libreoffice.org/28557
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Jenkins <ci@libreoffice.org>
(cherry picked from commit 7167c2b6548830b82280f2f3943d445e9afd6f5e)
Conflicts:
sw/inc/viscrs.hxx
sw/source/core/crsr/viscrs.cxx
Change-Id: I38510fa4962f405b1b96a79024206c9e7f33cad2
Diffstat (limited to 'sfx2')
-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 41131604709a..68707875bf0d 100644 --- a/sfx2/source/view/lokhelper.cxx +++ b/sfx2/source/view/lokhelper.cxx @@ -88,6 +88,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) @@ -97,17 +110,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 694ea7d6dc58..de2f3e82a547 100644 --- a/sfx2/source/view/viewsh.cxx +++ b/sfx2/source/view/viewsh.cxx @@ -1609,12 +1609,11 @@ void SfxViewShell::registerLibreOfficeKitViewCallback(LibreOfficeKitCallback pCa pImp->m_pLibreOfficeKitViewCallback = pCallback; pImp->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); } } @@ -1642,6 +1641,10 @@ void SfxViewShell::libreOfficeKitViewCallback(int nType, const char* pPayload) c pImp->m_pLibreOfficeKitViewCallback(nType, pPayload, pImp->m_pLibreOfficeKitViewData); } +void SfxViewShell::NotifyCursor(SfxViewShell* /*pViewShell*/) const +{ +} + void SfxViewShell::setTiledSearching(bool bTiledSearching) { pImp->m_bTiledSearching = bTiledSearching; |