Kaydet (Commit) d3685608 authored tarafından Miklos Vajna's avatar Miklos Vajna

desktop lok: implement per-view CallbackFlushHandler

With this, per-view cursor callbacks work again, as they did after
commit 32f419fe (sw: implement per-view
LOK_CALLBACK_CURSOR_VISIBLE, 2015-09-18).

Change-Id: Ic589276f99164a1a8d46f7a029d1a59ab6e971f3
Reviewed-on: https://gerrit.libreoffice.org/26102Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.co.uk>
Tested-by: 's avatarJenkins <ci@libreoffice.org>
üst 8561f8bf
...@@ -54,7 +54,7 @@ namespace desktop { ...@@ -54,7 +54,7 @@ namespace desktop {
{ {
css::uno::Reference<css::lang::XComponent> mxComponent; css::uno::Reference<css::lang::XComponent> mxComponent;
std::shared_ptr< LibreOfficeKitDocumentClass > m_pDocumentClass; 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); explicit LibLODocument_Impl(const css::uno::Reference <css::lang::XComponent> &xComponent);
~LibLODocument_Impl(); ~LibLODocument_Impl();
......
...@@ -1264,7 +1264,8 @@ void doc_paintPartTile(LibreOfficeKitDocument* pThis, ...@@ -1264,7 +1264,8 @@ void doc_paintPartTile(LibreOfficeKitDocument* pThis,
// Disable callbacks while we are painting. // Disable callbacks while we are painting.
LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis); LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis);
pDocument->mpCallbackFlushHandler->setPartTilePainting(true); std::size_t nView = SfxLokHelper::getView();
pDocument->mpCallbackFlushHandlers[nView]->setPartTilePainting(true);
try try
{ {
// Text documents have a single coordinate system; don't change part. // Text documents have a single coordinate system; don't change part.
...@@ -1291,7 +1292,7 @@ void doc_paintPartTile(LibreOfficeKitDocument* pThis, ...@@ -1291,7 +1292,7 @@ void doc_paintPartTile(LibreOfficeKitDocument* pThis,
// Nothing to do but restore the PartTilePainting flag. // Nothing to do but restore the PartTilePainting flag.
} }
pDocument->mpCallbackFlushHandler->setPartTilePainting(false); pDocument->mpCallbackFlushHandlers[nView]->setPartTilePainting(false);
} }
static int doc_getTileMode(LibreOfficeKitDocument* /*pThis*/) static int doc_getTileMode(LibreOfficeKitDocument* /*pThis*/)
...@@ -1333,14 +1334,16 @@ static void doc_registerCallback(LibreOfficeKitDocument* pThis, ...@@ -1333,14 +1334,16 @@ static void doc_registerCallback(LibreOfficeKitDocument* pThis,
LibreOfficeKitCallback pCallback, LibreOfficeKitCallback pCallback,
void* pData) void* pData)
{ {
SolarMutexGuard aGuard;
LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis); 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 (comphelper::LibreOfficeKit::isViewCallback())
{ {
if (SfxViewShell* pViewShell = SfxViewFrame::Current()->GetViewShell()) if (SfxViewShell* pViewShell = SfxViewFrame::Current()->GetViewShell())
pViewShell->registerLibreOfficeKitViewCallback(CallbackFlushHandler::callback, pDocument->mpCallbackFlushHandler.get()); pViewShell->registerLibreOfficeKitViewCallback(CallbackFlushHandler::callback, pDocument->mpCallbackFlushHandlers[nView].get());
} }
else else
{ {
...@@ -1351,7 +1354,7 @@ static void doc_registerCallback(LibreOfficeKitDocument* pThis, ...@@ -1351,7 +1354,7 @@ static void doc_registerCallback(LibreOfficeKitDocument* pThis,
return; 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 ...@@ -1433,10 +1436,11 @@ static void doc_postUnoCommand(LibreOfficeKitDocument* pThis, const char* pComma
bool bResult = false; 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), bResult = comphelper::dispatchCommand(aCommand, comphelper::containerToSequence(aPropertyValuesVector),
new DispatchResultListener(pCommand, pDocument->mpCallbackFlushHandler)); new DispatchResultListener(pCommand, pDocument->mpCallbackFlushHandlers[nView]));
} }
else else
bResult = comphelper::dispatchCommand(aCommand, comphelper::containerToSequence(aPropertyValuesVector)); bResult = comphelper::dispatchCommand(aCommand, comphelper::containerToSequence(aPropertyValuesVector));
...@@ -1468,9 +1472,10 @@ static void doc_postMouseEvent(LibreOfficeKitDocument* pThis, int nType, int nX, ...@@ -1468,9 +1472,10 @@ static void doc_postMouseEvent(LibreOfficeKitDocument* pThis, int nType, int nX,
} }
LibLODocument_Impl* pLib = static_cast<LibLODocument_Impl*>(pThis); 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());
} }
} }
......
...@@ -38,6 +38,8 @@ ...@@ -38,6 +38,8 @@
#include <../../inc/lib/init.hxx> #include <../../inc/lib/init.hxx>
#include <LibreOfficeKit/LibreOfficeKitEnums.h> #include <LibreOfficeKit/LibreOfficeKitEnums.h>
#include <sfx2/lokhelper.hxx>
#include <comphelper/lok.hxx>
using namespace com::sun::star; using namespace com::sun::star;
...@@ -114,8 +116,9 @@ void LOKInteractionHandler::postError(css::task::InteractionClassification class ...@@ -114,8 +116,9 @@ void LOKInteractionHandler::postError(css::task::InteractionClassification class
std::stringstream aStream; std::stringstream aStream;
boost::property_tree::write_json(aStream, aTree); boost::property_tree::write_json(aStream, aTree);
if (m_pLOKDocument && m_pLOKDocument->mpCallbackFlushHandler) std::size_t nView = comphelper::LibreOfficeKit::isViewCallback() ? SfxLokHelper::getView() : 0;
m_pLOKDocument->mpCallbackFlushHandler->queue(LOK_CALLBACK_ERROR, aStream.str().c_str()); if (m_pLOKDocument && m_pLOKDocument->mpCallbackFlushHandlers[nView])
m_pLOKDocument->mpCallbackFlushHandlers[nView]->queue(LOK_CALLBACK_ERROR, aStream.str().c_str());
else if (m_pLOKit->mpCallback) else if (m_pLOKit->mpCallback)
m_pLOKit->mpCallback(LOK_CALLBACK_ERROR, aStream.str().c_str(), m_pLOKit->mpCallbackData); m_pLOKit->mpCallback(LOK_CALLBACK_ERROR, aStream.str().c_str(), m_pLOKit->mpCallbackData);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment