diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-06-09 14:17:57 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-06-09 13:17:21 +0000 |
commit | d368560882e8a4567f3328ce877b6e5242d18620 (patch) | |
tree | e69f544d90ed6fb07275b105e96cf057c99ab9ac /desktop | |
parent | 8561f8bfccb73ce4ac834598c4c32ac5c81774e5 (diff) |
desktop lok: implement per-view CallbackFlushHandler
With this, per-view cursor callbacks work again, as they did after
commit 32f419fee5f9df4facb7a9b3ec910471d2a20247 (sw: implement per-view
LOK_CALLBACK_CURSOR_VISIBLE, 2015-09-18).
Change-Id: Ic589276f99164a1a8d46f7a029d1a59ab6e971f3
Reviewed-on: https://gerrit.libreoffice.org/26102
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'desktop')
-rw-r--r-- | desktop/inc/lib/init.hxx | 2 | ||||
-rw-r--r-- | desktop/source/lib/init.cxx | 23 | ||||
-rw-r--r-- | desktop/source/lib/lokinteractionhandler.cxx | 7 |
3 files changed, 20 insertions, 12 deletions
diff --git a/desktop/inc/lib/init.hxx b/desktop/inc/lib/init.hxx index 3a5c5b7333c9..2f18223793cc 100644 --- a/desktop/inc/lib/init.hxx +++ b/desktop/inc/lib/init.hxx @@ -54,7 +54,7 @@ namespace desktop { { css::uno::Reference<css::lang::XComponent> mxComponent; std::shared_ptr< LibreOfficeKitDocumentClass > m_pDocumentClass; - std::shared_ptr<CallbackFlushHandler> mpCallbackFlushHandler; + std::map<size_t, std::shared_ptr<CallbackFlushHandler>> mpCallbackFlushHandlers; explicit LibLODocument_Impl(const css::uno::Reference <css::lang::XComponent> &xComponent); ~LibLODocument_Impl(); diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index caa6cd2fe62a..051362d8b739 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -1264,7 +1264,8 @@ void doc_paintPartTile(LibreOfficeKitDocument* pThis, // Disable callbacks while we are painting. LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis); - pDocument->mpCallbackFlushHandler->setPartTilePainting(true); + std::size_t nView = SfxLokHelper::getView(); + pDocument->mpCallbackFlushHandlers[nView]->setPartTilePainting(true); try { // Text documents have a single coordinate system; don't change part. @@ -1291,7 +1292,7 @@ void doc_paintPartTile(LibreOfficeKitDocument* pThis, // Nothing to do but restore the PartTilePainting flag. } - pDocument->mpCallbackFlushHandler->setPartTilePainting(false); + pDocument->mpCallbackFlushHandlers[nView]->setPartTilePainting(false); } static int doc_getTileMode(LibreOfficeKitDocument* /*pThis*/) @@ -1333,14 +1334,16 @@ static void doc_registerCallback(LibreOfficeKitDocument* pThis, LibreOfficeKitCallback pCallback, void* pData) { + SolarMutexGuard aGuard; LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis); - pDocument->mpCallbackFlushHandler.reset(new CallbackFlushHandler(pCallback, pData)); + std::size_t nView = comphelper::LibreOfficeKit::isViewCallback() ? SfxLokHelper::getView() : 0; + pDocument->mpCallbackFlushHandlers[nView].reset(new CallbackFlushHandler(pCallback, pData)); if (comphelper::LibreOfficeKit::isViewCallback()) { if (SfxViewShell* pViewShell = SfxViewFrame::Current()->GetViewShell()) - pViewShell->registerLibreOfficeKitViewCallback(CallbackFlushHandler::callback, pDocument->mpCallbackFlushHandler.get()); + pViewShell->registerLibreOfficeKitViewCallback(CallbackFlushHandler::callback, pDocument->mpCallbackFlushHandlers[nView].get()); } else { @@ -1351,7 +1354,7 @@ static void doc_registerCallback(LibreOfficeKitDocument* pThis, return; } - pDoc->registerCallback(CallbackFlushHandler::callback, pDocument->mpCallbackFlushHandler.get()); + pDoc->registerCallback(CallbackFlushHandler::callback, pDocument->mpCallbackFlushHandlers[nView].get()); } } @@ -1433,10 +1436,11 @@ static void doc_postUnoCommand(LibreOfficeKitDocument* pThis, const char* pComma bool bResult = false; - if (bNotifyWhenFinished && pDocument->mpCallbackFlushHandler) + std::size_t nView = comphelper::LibreOfficeKit::isViewCallback() ? SfxLokHelper::getView() : 0; + if (bNotifyWhenFinished && pDocument->mpCallbackFlushHandlers[nView]) { bResult = comphelper::dispatchCommand(aCommand, comphelper::containerToSequence(aPropertyValuesVector), - new DispatchResultListener(pCommand, pDocument->mpCallbackFlushHandler)); + new DispatchResultListener(pCommand, pDocument->mpCallbackFlushHandlers[nView])); } else bResult = comphelper::dispatchCommand(aCommand, comphelper::containerToSequence(aPropertyValuesVector)); @@ -1468,9 +1472,10 @@ static void doc_postMouseEvent(LibreOfficeKitDocument* pThis, int nType, int nX, } LibLODocument_Impl* pLib = static_cast<LibLODocument_Impl*>(pThis); - if (pLib->mpCallbackFlushHandler) + std::size_t nView = comphelper::LibreOfficeKit::isViewCallback() ? SfxLokHelper::getView() : 0; + if (pLib->mpCallbackFlushHandlers[nView]) { - pLib->mpCallbackFlushHandler->queue(LOK_CALLBACK_MOUSE_POINTER, aPointerString.getStr()); + pLib->mpCallbackFlushHandlers[nView]->queue(LOK_CALLBACK_MOUSE_POINTER, aPointerString.getStr()); } } diff --git a/desktop/source/lib/lokinteractionhandler.cxx b/desktop/source/lib/lokinteractionhandler.cxx index bb1b495a292e..76a7e847fadf 100644 --- a/desktop/source/lib/lokinteractionhandler.cxx +++ b/desktop/source/lib/lokinteractionhandler.cxx @@ -38,6 +38,8 @@ #include <../../inc/lib/init.hxx> #include <LibreOfficeKit/LibreOfficeKitEnums.h> +#include <sfx2/lokhelper.hxx> +#include <comphelper/lok.hxx> using namespace com::sun::star; @@ -114,8 +116,9 @@ void LOKInteractionHandler::postError(css::task::InteractionClassification class std::stringstream aStream; boost::property_tree::write_json(aStream, aTree); - if (m_pLOKDocument && m_pLOKDocument->mpCallbackFlushHandler) - m_pLOKDocument->mpCallbackFlushHandler->queue(LOK_CALLBACK_ERROR, aStream.str().c_str()); + std::size_t nView = comphelper::LibreOfficeKit::isViewCallback() ? SfxLokHelper::getView() : 0; + if (m_pLOKDocument && m_pLOKDocument->mpCallbackFlushHandlers[nView]) + m_pLOKDocument->mpCallbackFlushHandlers[nView]->queue(LOK_CALLBACK_ERROR, aStream.str().c_str()); else if (m_pLOKit->mpCallback) m_pLOKit->mpCallback(LOK_CALLBACK_ERROR, aStream.str().c_str(), m_pLOKit->mpCallbackData); } |