summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarco Cecchetti <marco.cecchetti@collabora.com>2016-09-09 22:21:07 +0200
committerMarco Cecchetti <mrcekets@gmail.com>2016-09-09 20:50:36 +0000
commit404feac7e9212c57124a1e6219b6d6125c2bbd14 (patch)
tree718bfc3f8700c56e9bb349cb979cf0938e234265
parentf40a986345e91dcb01c7da565615e19ff002043b (diff)
LOK: we use callbacks latch for not missing messages sent very early
- lok::Document::setCallbackLatch: used by a child session for set/unset the latch - lok::Document::registerCallback has a new boolean parameter used for setting the latch state just before the callback is actually registered for a (new) view - now cell cursors of other views are correctly notified to the new view Change-Id: I80ae5556f61b1a41e703688491cca1faa8621a43 Reviewed-on: https://gerrit.libreoffice.org/28789 Reviewed-by: Marco Cecchetti <mrcekets@gmail.com> Tested-by: Marco Cecchetti <mrcekets@gmail.com>
-rw-r--r--desktop/qa/desktop_lib/test_desktop_lib.cxx22
-rw-r--r--desktop/source/lib/init.cxx24
-rw-r--r--include/LibreOfficeKit/LibreOfficeKit.h7
-rw-r--r--include/LibreOfficeKit/LibreOfficeKit.hxx16
-rw-r--r--libreofficekit/source/gtk/lokdocview.cxx4
5 files changed, 54 insertions, 19 deletions
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 5485da30cb67..9080f4aba333 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -365,7 +365,7 @@ void DesktopLOKTest::testSearchCalc()
comphelper::LibreOfficeKit::setActive();
LibLODocument_Impl* pDocument = loadDoc("search.ods");
pDocument->pClass->initializeForRendering(pDocument, nullptr);
- pDocument->pClass->registerCallback(pDocument, &DesktopLOKTest::callback, this);
+ pDocument->pClass->registerCallback(pDocument, &DesktopLOKTest::callback, this, /*callback latch*/ false);
uno::Sequence<beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence(
{
@@ -400,7 +400,7 @@ void DesktopLOKTest::testSearchAllNotificationsCalc()
comphelper::LibreOfficeKit::setActive();
LibLODocument_Impl* pDocument = loadDoc("search.ods");
pDocument->pClass->initializeForRendering(pDocument, nullptr);
- pDocument->pClass->registerCallback(pDocument, &DesktopLOKTest::callback, this);
+ pDocument->pClass->registerCallback(pDocument, &DesktopLOKTest::callback, this, /*callback latch*/ false);
uno::Sequence<beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence(
{
@@ -684,7 +684,7 @@ void DesktopLOKTest::testCommandResult()
CPPUNIT_ASSERT(m_aCommandResult.isEmpty());
// but we get some real values when the callback is set up
- pDocument->pClass->registerCallback(pDocument, &DesktopLOKTest::callback, this);
+ pDocument->pClass->registerCallback(pDocument, &DesktopLOKTest::callback, this, /*callback latch*/ false);
m_aCommandResultCondition.reset();
pDocument->pClass->postUnoCommand(pDocument, ".uno:Bold", nullptr, true);
@@ -703,7 +703,7 @@ void DesktopLOKTest::testWriterComments()
{
comphelper::LibreOfficeKit::setActive();
LibLODocument_Impl* pDocument = loadDoc("blank_text.odt");
- pDocument->pClass->registerCallback(pDocument, &DesktopLOKTest::callback, this);
+ pDocument->pClass->registerCallback(pDocument, &DesktopLOKTest::callback, this, /*callback latch*/ false);
uno::Reference<awt::XReschedule> xToolkit(com::sun::star::awt::Toolkit::create(comphelper::getProcessComponentContext()), uno::UNO_QUERY);
// Insert a comment at the beginning of the document and wait till the main
@@ -747,7 +747,7 @@ void DesktopLOKTest::testModifiedStatus()
comphelper::LibreOfficeKit::setActive();
LibLODocument_Impl* pDocument = loadDoc("blank_text.odt");
pDocument->pClass->initializeForRendering(pDocument, nullptr);
- pDocument->pClass->registerCallback(pDocument, &DesktopLOKTest::callback, this);
+ pDocument->pClass->registerCallback(pDocument, &DesktopLOKTest::callback, this, /*callback latch*/ false);
// Type "t" and check that the document was set as modified
m_bModified = false;
@@ -811,10 +811,10 @@ void DesktopLOKTest::testTrackChanges()
comphelper::LibreOfficeKit::setActive();
LibLODocument_Impl* pDocument = loadDoc("blank_text.odt");
pDocument->pClass->initializeForRendering(pDocument, nullptr);
- pDocument->pClass->registerCallback(pDocument, &DesktopLOKTest::callback, this);
+ pDocument->pClass->registerCallback(pDocument, &DesktopLOKTest::callback, this, /*callback latch*/ false);
pDocument->pClass->createView(pDocument);
pDocument->pClass->initializeForRendering(pDocument, nullptr);
- pDocument->pClass->registerCallback(pDocument, &DesktopLOKTest::callback, this);
+ pDocument->pClass->registerCallback(pDocument, &DesktopLOKTest::callback, this, /*callback latch*/ false);
Scheduler::ProcessEventsToIdle();
// Enable trak changes and assert that both views get notified.
@@ -864,7 +864,7 @@ void DesktopLOKTest::testSheetSelections()
comphelper::LibreOfficeKit::setActive();
LibLODocument_Impl* pDocument = loadDoc("sheets.ods", LOK_DOCTYPE_SPREADSHEET);
pDocument->pClass->initializeForRendering(pDocument, nullptr);
- pDocument->pClass->registerCallback(pDocument, &DesktopLOKTest::callback, this);
+ pDocument->pClass->registerCallback(pDocument, &DesktopLOKTest::callback, this, /*callback latch*/ false);
/*
* Check if selection data is correct
@@ -1025,7 +1025,7 @@ void DesktopLOKTest::testContextMenuCalc()
comphelper::LibreOfficeKit::setActive();
LibLODocument_Impl* pDocument = loadDoc("sheets.ods", LOK_DOCTYPE_SPREADSHEET);
pDocument->pClass->initializeForRendering(pDocument, nullptr);
- pDocument->pClass->registerCallback(pDocument, &DesktopLOKTest::callback, this);
+ pDocument->pClass->registerCallback(pDocument, &DesktopLOKTest::callback, this, /*callback latch*/ false);
// Values in twips
int row5 = 1150;
@@ -1053,7 +1053,7 @@ void DesktopLOKTest::testContextMenuWriter()
comphelper::LibreOfficeKit::setActive();
LibLODocument_Impl* pDocument = loadDoc("blank_text.odt", LOK_DOCTYPE_TEXT);
pDocument->pClass->initializeForRendering(pDocument, nullptr);
- pDocument->pClass->registerCallback(pDocument, &DesktopLOKTest::callback, this);
+ pDocument->pClass->registerCallback(pDocument, &DesktopLOKTest::callback, this, /*callback latch*/ false);
Point aRandomPoint(1150, 1100);
pDocument->pClass->postMouseEvent(pDocument,
@@ -1078,7 +1078,7 @@ void DesktopLOKTest::testContextMenuImpress()
comphelper::LibreOfficeKit::setActive();
LibLODocument_Impl* pDocument = loadDoc("blank_presentation.odp", LOK_DOCTYPE_PRESENTATION);
pDocument->pClass->initializeForRendering(pDocument, nullptr);
- pDocument->pClass->registerCallback(pDocument, &DesktopLOKTest::callback, this);
+ pDocument->pClass->registerCallback(pDocument, &DesktopLOKTest::callback, this, /*callback latch*/ false);
Point aRandomPoint(1150, 1100);
pDocument->pClass->postMouseEvent(pDocument,
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index cb86a63d8ff6..93d7c5d160ad 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -392,10 +392,12 @@ static void doc_getDocumentSize(LibreOfficeKitDocument* pThis,
long* pHeight);
static void doc_initializeForRendering(LibreOfficeKitDocument* pThis,
const char* pArguments);
-
+static void doc_setCallbackLatch(LibreOfficeKitDocument* pThis,
+ bool bCallbackLatch);
static void doc_registerCallback(LibreOfficeKitDocument* pThis,
LibreOfficeKitCallback pCallback,
- void* pData);
+ void* pData,
+ bool bCallbackLatch = false);
static void doc_postKeyEvent(LibreOfficeKitDocument* pThis,
int nType,
int nCharCode,
@@ -468,6 +470,7 @@ LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XCompone
m_pDocumentClass->getTileMode = doc_getTileMode;
m_pDocumentClass->getDocumentSize = doc_getDocumentSize;
m_pDocumentClass->initializeForRendering = doc_initializeForRendering;
+ m_pDocumentClass->setCallbackLatch = doc_setCallbackLatch;
m_pDocumentClass->registerCallback = doc_registerCallback;
m_pDocumentClass->postKeyEvent = doc_postKeyEvent;
m_pDocumentClass->postMouseEvent = doc_postMouseEvent;
@@ -1558,9 +1561,22 @@ static void doc_initializeForRendering(LibreOfficeKitDocument* pThis,
}
}
+static void doc_setCallbackLatch(LibreOfficeKitDocument* pThis, bool bCallbackLatch)
+{
+ SolarMutexGuard aGuard;
+ LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis);
+
+ int nView = SfxLokHelper::getView();
+ if (nView < 0)
+ return;
+
+ if (pDocument->mpCallbackFlushHandlers[nView])
+ pDocument->mpCallbackFlushHandlers[nView]->setEventLatch(bCallbackLatch);
+}
+
static void doc_registerCallback(LibreOfficeKitDocument* pThis,
LibreOfficeKitCallback pCallback,
- void* pData)
+ void* pData, bool bCallbackLatch)
{
SolarMutexGuard aGuard;
LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis);
@@ -1596,6 +1612,8 @@ static void doc_registerCallback(LibreOfficeKitDocument* pThis,
if (pCallback != nullptr)
{
+ pDocument->mpCallbackFlushHandlers[nView]->setEventLatch(bCallbackLatch);
+
size_t nId = nView;
for (const auto& pair : pDocument->mpCallbackFlushHandlers)
{
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h
index 81d65c1ace38..e03163f399af 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -147,10 +147,15 @@ struct _LibreOfficeKitDocumentClass
void (*initializeForRendering) (LibreOfficeKitDocument* pThis,
const char* pArguments);
+ /// @see lok::Document::setCallbackLatch().
+ void (*setCallbackLatch) (LibreOfficeKitDocument* pThis,
+ bool bCallbackLatch);
+
/// @see lok::Document::registerCallback().
void (*registerCallback) (LibreOfficeKitDocument* pThis,
LibreOfficeKitCallback pCallback,
- void* pData);
+ void* pData,
+ bool bCallbackLatch);
/// @see lok::Document::postKeyEvent
void (*postKeyEvent) (LibreOfficeKitDocument* pThis,
diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx
index aae5f3806a64..346671dc1679 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ b/include/LibreOfficeKit/LibreOfficeKit.hxx
@@ -196,15 +196,27 @@ public:
}
/**
+ * 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);
+ }
+
+ /**
* Registers a callback. LOK will invoke this function when it wants to
* inform the client about events.
*
* @param pCallback the callback to invoke
* @param pData the user data, will be passed to the callback on invocation
+ * @param bCallbackLatch the event latch status to be set before the callback is registered
*/
- inline void registerCallback(LibreOfficeKitCallback pCallback, void* pData)
+ inline void registerCallback(LibreOfficeKitCallback pCallback, void* pData, bool bCallbackLatch = false)
{
- mpDoc->pClass->registerCallback(mpDoc, pCallback, pData);
+ mpDoc->pClass->registerCallback(mpDoc, pCallback, pData, bCallbackLatch);
}
/**
diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
index 1f7d33007117..5e43e5ea62b1 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -913,7 +913,7 @@ static gboolean postDocumentLoad(gpointer pData)
std::unique_lock<std::mutex> aGuard(g_aLOKMutex);
priv->m_pDocument->pClass->initializeForRendering(priv->m_pDocument, priv->m_aRenderingArguments.c_str());
priv->m_nViewId = priv->m_pDocument->pClass->getView(priv->m_pDocument);
- priv->m_pDocument->pClass->registerCallback(priv->m_pDocument, callbackWorker, pLOKDocView);
+ priv->m_pDocument->pClass->registerCallback(priv->m_pDocument, callbackWorker, pLOKDocView, /*callback latch*/ false);
priv->m_pDocument->pClass->getDocumentSize(priv->m_pDocument, &priv->m_nDocumentWidthTwips, &priv->m_nDocumentHeightTwips);
priv->m_nParts = priv->m_pDocument->pClass->getParts(priv->m_pDocument);
aGuard.unlock();
@@ -2510,7 +2510,7 @@ static void lok_doc_view_finalize (GObject* object)
ss << "lok::Document::setView(" << priv->m_nViewId << ")";
g_info("%s", ss.str().c_str());
priv->m_pDocument->pClass->setView(priv->m_pDocument, priv->m_nViewId);
- priv->m_pDocument->pClass->registerCallback(priv->m_pDocument, nullptr, nullptr);
+ priv->m_pDocument->pClass->registerCallback(priv->m_pDocument, nullptr, nullptr, /*callback latch*/ false);
aGuard.unlock();
if (priv->m_pDocument && priv->m_pDocument->pClass->getViews(priv->m_pDocument) > 1)