Blob Blame History Raw
From 2dd20703103d2510fa47958743ced3ae203f613d Mon Sep 17 00:00:00 2001
From: Miklos Vajna <vmiklos@collabora.co.uk>
Date: Thu, 17 Sep 2015 15:39:19 +0200
Subject: [PATCH 150/398] lok::Document: register callback in the view, if
 requested

With this, a postKeyEvent() in one view properly results in one
LOK_CALLBACK_INVALIDATE_TILES per view, at least in Writer.

Change-Id: Ia0a9a00ea5a98c38f3d399208b9ef028f3036f79
(cherry picked from commit b8a54763f4f66538f13b6c0e13045e5cb3167ca4)
---
 desktop/source/lib/init.cxx | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 52a78e228a32..64a6c00ffba6 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -54,6 +54,8 @@
 #include <sfx2/msgpool.hxx>
 #include <sfx2/dispatch.hxx>
 #include <sfx2/lokhelper.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/viewsh.hxx>
 #include <svx/svxids.hrc>
 #include <vcl/svapp.hxx>
 #include <vcl/svpforlokit.hxx>
@@ -816,14 +818,22 @@ static void doc_registerCallback(LibreOfficeKitDocument* pThis,
                                 LibreOfficeKitCallback pCallback,
                                 void* pData)
 {
-    ITiledRenderable* pDoc = getTiledRenderable(pThis);
-    if (!pDoc)
+    if (comphelper::LibreOfficeKit::isViewCallback())
     {
-        gImpl->maLastExceptionMsg = "Document doesn't support tiled rendering";
-        return;
+        if (SfxViewShell* pViewShell = SfxViewFrame::Current()->GetViewShell())
+            pViewShell->registerLibreOfficeKitViewCallback(pCallback, pData);
     }
+    else
+    {
+        ITiledRenderable* pDoc = getTiledRenderable(pThis);
+        if (!pDoc)
+        {
+            gImpl->maLastExceptionMsg = "Document doesn't support tiled rendering";
+            return;
+        }
 
-    pDoc->registerCallback(pCallback, pData);
+        pDoc->registerCallback(pCallback, pData);
+    }
 }
 
 static void doc_postKeyEvent(LibreOfficeKitDocument* pThis, int nType, int nCharCode, int nKeyCode)
-- 
2.12.0