From bbae556d12e4edf7795b0b5643df77fd8cdbdacd Mon Sep 17 00:00:00 2001 From: Marco Cecchetti Date: Sat, 10 Sep 2016 21:02:36 +0200 Subject: LOK: we use callbacks latch for not missing messages sent very early - lok::Document::setCallbackLatch: used on document load for set/unset the latch - now cell cursors of other views are correctly notified to the new view Change-Id: Ife6dca0e3e329b801d44070f55869afe95a2f313 Reviewed-on: https://gerrit.libreoffice.org/28811 Reviewed-by: Marco Cecchetti Tested-by: Marco Cecchetti --- desktop/source/lib/init.cxx | 19 ++++++++++++++++++- include/LibreOfficeKit/LibreOfficeKit.h | 4 ++++ include/LibreOfficeKit/LibreOfficeKit.hxx | 11 +++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index cb86a63d8ff6..f678d6944ac2 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -392,7 +392,6 @@ static void doc_getDocumentSize(LibreOfficeKitDocument* pThis, long* pHeight); static void doc_initializeForRendering(LibreOfficeKitDocument* pThis, const char* pArguments); - static void doc_registerCallback(LibreOfficeKitDocument* pThis, LibreOfficeKitCallback pCallback, void* pData); @@ -444,6 +443,9 @@ static unsigned char* doc_renderFont(LibreOfficeKitDocument* pThis, int* pFontWidth, int* pFontHeight); static char* doc_getPartHash(LibreOfficeKitDocument* pThis, int nPart); +static void doc_setCallbackLatch(LibreOfficeKitDocument* pThis, + bool bCallbackLatch); + LibLODocument_Impl::LibLODocument_Impl(const uno::Reference &xComponent) : mxComponent(xComponent) @@ -490,6 +492,8 @@ LibLODocument_Impl::LibLODocument_Impl(const uno::Reference renderFont = doc_renderFont; m_pDocumentClass->getPartHash = doc_getPartHash; + m_pDocumentClass->setCallbackLatch = doc_setCallbackLatch; + gDocumentClass = m_pDocumentClass; } pClass = m_pDocumentClass.get(); @@ -2341,6 +2345,19 @@ unsigned char* doc_renderFont(LibreOfficeKitDocument* /*pThis*/, return nullptr; } +static void doc_setCallbackLatch(LibreOfficeKitDocument* pThis, bool bCallbackLatch) +{ + SolarMutexGuard aGuard; + LibLODocument_Impl* pDocument = static_cast(pThis); + + int nView = SfxLokHelper::getView(); + if (nView < 0) + return; + + if (pDocument->mpCallbackFlushHandlers[nView]) + pDocument->mpCallbackFlushHandlers[nView]->setEventLatch(bCallbackLatch); +} + static char* lo_getError (LibreOfficeKit *pThis) { LibLibreOffice_Impl* pLib = static_cast(pThis); diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h index 81d65c1ace38..53162a35e7f6 100644 --- a/include/LibreOfficeKit/LibreOfficeKit.h +++ b/include/LibreOfficeKit/LibreOfficeKit.h @@ -244,6 +244,10 @@ struct _LibreOfficeKitDocumentClass const int nTileWidth, const int nTileHeight); + /// @see lok::Document::setCallbackLatch(). + void (*setCallbackLatch) (LibreOfficeKitDocument* pThis, + bool bCallbackLatch); + #endif // defined LOK_USE_UNSTABLE_API || defined LIBO_INTERNAL_ONLY }; diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx index aae5f3806a64..d2d68775254c 100644 --- a/include/LibreOfficeKit/LibreOfficeKit.hxx +++ b/include/LibreOfficeKit/LibreOfficeKit.hxx @@ -435,6 +435,17 @@ public: nTileWidth, nTileHeight); } + /** + * Enable/disable callbacks latch. LOK will set the latch when it wants to + * queue new callbacks but not flush them. + * + * @param bCallbackLatch: true enables the latch, false disables it. + */ + inline void setCallbackLatch(bool bCallbackLatch) + { + mpDoc->pClass->setCallbackLatch(mpDoc, bCallbackLatch); + } + #endif // defined LOK_USE_UNSTABLE_API || defined LIBO_INTERNAL_ONLY }; -- cgit v1.2.3