[Libreoffice-commits] core.git: 22 commits - cui/source desktop/source include/LibreOfficeKit include/sfx2 include/tools include/vcl libreofficekit/qa sc/source sfx2/source sw/inc sw/source tools/source vcl/inc vcl/Library_vcl.mk vcl/source

Jan Holesovsky kendy at collabora.com
Wed Nov 29 09:18:42 UTC 2017


 cui/source/dialogs/iconcdlg.cxx                                     |    2 
 cui/source/inc/iconcdlg.hxx                                         |    3 
 desktop/source/lib/init.cxx                                         |  167 ++++----
 include/LibreOfficeKit/LibreOfficeKit.h                             |   15 
 include/LibreOfficeKit/LibreOfficeKit.hxx                           |   47 --
 include/sfx2/basedlgs.hxx                                           |    2 
 include/sfx2/lokhelper.hxx                                          |    6 
 include/sfx2/viewsh.hxx                                             |    8 
 include/tools/gen.hxx                                               |    1 
 include/vcl/IDialogRenderable.hxx                                   |   38 -
 include/vcl/dialog.hxx                                              |   20 -
 include/vcl/window.hxx                                              |   29 +
 libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx                 |   87 ++--
 libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.hxx                 |    2 
 libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx |   81 +++-
 libreofficekit/qa/gtktiledviewer/gtv-main-toolbar.cxx               |   24 -
 libreofficekit/qa/gtktiledviewer/gtv-signal-handlers.cxx            |   34 -
 libreofficekit/qa/gtktiledviewer/gtv.ui                             |   17 
 sc/source/ui/view/gridwin.cxx                                       |    1 
 sfx2/source/dialog/basedlgs.cxx                                     |   43 ++
 sfx2/source/dialog/tabdlg.cxx                                       |   28 +
 sfx2/source/view/lokhelper.cxx                                      |   26 -
 sfx2/source/view/viewsh.cxx                                         |   10 
 sw/inc/unotxdoc.hxx                                                 |   20 -
 sw/source/uibase/uno/unotxdoc.cxx                                   |  194 ----------
 tools/source/generic/gen.cxx                                        |   10 
 vcl/Library_vcl.mk                                                  |    1 
 vcl/inc/window.h                                                    |    3 
 vcl/source/app/IDialogRenderable.cxx                                |   22 -
 vcl/source/window/dialog.cxx                                        |  170 +-------
 vcl/source/window/floatwin.cxx                                      |    9 
 vcl/source/window/paint.cxx                                         |   16 
 vcl/source/window/window.cxx                                        |  172 ++++++++
 vcl/source/window/winproc.cxx                                       |    4 
 34 files changed, 617 insertions(+), 695 deletions(-)

New commits:
commit 33afa0f0bd49bd2984bb05b11b919e1050bac8f6
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Tue Nov 28 11:52:16 2017 +0100

    Fix 'unused parameter' warnings.
    
    Change-Id: I8478e907a66ca918eddc7a543cbcf23e17d9ee5a

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 0261040e4d35..95d4cda6ecd9 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -2247,7 +2247,7 @@ static void doc_postKeyEvent(LibreOfficeKitDocument* pThis, int nType, int nChar
     pDoc->postKeyEvent(nType, nCharCode, nKeyCode);
 }
 
-static void doc_postDialogKeyEvent(LibreOfficeKitDocument* pThis, unsigned nLOKWindowId, int nType, int nCharCode, int nKeyCode)
+static void doc_postDialogKeyEvent(LibreOfficeKitDocument* /*pThis*/, unsigned nLOKWindowId, int nType, int nCharCode, int nKeyCode)
 {
     SolarMutexGuard aGuard;
 
@@ -2425,7 +2425,7 @@ static void doc_postMouseEvent(LibreOfficeKitDocument* pThis, int nType, int nX,
     }
 }
 
-static void doc_postDialogMouseEvent(LibreOfficeKitDocument* pThis, unsigned nLOKWindowId, int nType, int nX, int nY, int nCount, int nButtons, int nModifier)
+static void doc_postDialogMouseEvent(LibreOfficeKitDocument* /*pThis*/, unsigned nLOKWindowId, int nType, int nX, int nY, int nCount, int nButtons, int nModifier)
 {
     SolarMutexGuard aGuard;
 
@@ -2456,7 +2456,7 @@ static void doc_postDialogMouseEvent(LibreOfficeKitDocument* pThis, unsigned nLO
     }
 }
 
-static void doc_postDialogChildMouseEvent(LibreOfficeKitDocument* pThis, unsigned nLOKWindowId, int nType, int nX, int nY, int nCount, int nButtons, int nModifier)
+static void doc_postDialogChildMouseEvent(LibreOfficeKitDocument* /*pThis*/, unsigned nLOKWindowId, int nType, int nX, int nY, int nCount, int nButtons, int nModifier)
 {
     SolarMutexGuard aGuard;
 
@@ -3263,7 +3263,7 @@ unsigned char* doc_renderFont(SAL_UNUSED_PARAMETER LibreOfficeKitDocument* /*pTh
     return nullptr;
 }
 
-static void doc_paintDialog(LibreOfficeKitDocument* pThis, unsigned nLOKWindowId,
+static void doc_paintDialog(LibreOfficeKitDocument* /*pThis*/, unsigned nLOKWindowId,
                             unsigned char* pBuffer,
                             const int nX, const int nY,
                             const int nWidth, const int nHeight)
@@ -3291,7 +3291,7 @@ static void doc_paintDialog(LibreOfficeKitDocument* pThis, unsigned nLOKWindowId
     comphelper::LibreOfficeKit::setDialogPainting(false);
 }
 
-static void doc_paintActiveFloatingWindow(LibreOfficeKitDocument* pThis, unsigned nLOKWindowId, unsigned char* pBuffer, int* nWidth, int* nHeight)
+static void doc_paintActiveFloatingWindow(LibreOfficeKitDocument* /*pThis*/, unsigned nLOKWindowId, unsigned char* pBuffer, int* nWidth, int* nHeight)
 {
     SolarMutexGuard aGuard;
 
commit d0f0a3c289c269476e1724f5b6bb527210121c3d
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Tue Nov 28 02:53:48 2017 +0530

    lokdialog: Remove getDialogInfo + update gtktiledviewer accordingly.
    
    Change-Id: I6f810c97f2fadd3b1ea602a97e24c8b42f4a84b9

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index ece7600f178d..0261040e4d35 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -615,9 +615,6 @@ static void doc_paintDialog(LibreOfficeKitDocument* pThis, unsigned nLOKWindowId
                             const int nX, const int nY,
                             const int nWidth, const int nHeight);
 
-static void doc_getDialogInfo(LibreOfficeKitDocument* pThis, unsigned nLOKWindowId,
-                              char** pDialogTitle, int* nWidth, int* nHeight);
-
 static void doc_paintActiveFloatingWindow(LibreOfficeKitDocument* pThis, unsigned nLOKWindowId, unsigned char* pBuffer, int* nWidth, int* nHeight);
 
 LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XComponent> &xComponent)
@@ -670,7 +667,6 @@ LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XCompone
         m_pDocumentClass->getPartHash = doc_getPartHash;
 
         m_pDocumentClass->paintDialog = doc_paintDialog;
-        m_pDocumentClass->getDialogInfo = doc_getDialogInfo;
         m_pDocumentClass->paintActiveFloatingWindow = doc_paintActiveFloatingWindow;
 
         gDocumentClass = m_pDocumentClass;
@@ -3267,35 +3263,6 @@ unsigned char* doc_renderFont(SAL_UNUSED_PARAMETER LibreOfficeKitDocument* /*pTh
     return nullptr;
 }
 
-static void doc_getDialogInfo(LibreOfficeKitDocument* pThis, unsigned nLOKWindowId,
-                              char** pDialogTitle, int* nWidth, int* nHeight)
-{
-    // FIXME - I guess we should kill this one, and use only the callback
-    // "created"?
-
-    SolarMutexGuard aGuard;
-
-    VclPtr<Window> pWindow = vcl::Window::FindLOKWindow(nLOKWindowId);
-    if (!pWindow)
-    {
-        gImpl->maLastExceptionMsg = "Document doesn't support dialog rendering, or window not found.";
-        return;
-    }
-
-    OUString aDialogTitle(pWindow->GetText());
-    const Size aSize = pWindow->GetSizePixel();
-    *nWidth = aSize.getWidth();
-    *nHeight = aSize.getHeight();
-
-    // copy dialog title
-    if (!aDialogTitle.isEmpty())
-    {
-        OString aTitleString = OUStringToOString(aDialogTitle, RTL_TEXTENCODING_UTF8);
-        *pDialogTitle = static_cast<char*>(malloc(aTitleString.getLength() + 1));
-        strcpy(*pDialogTitle, aTitleString.getStr());
-    }
-}
-
 static void doc_paintDialog(LibreOfficeKitDocument* pThis, unsigned nLOKWindowId,
                             unsigned char* pBuffer,
                             const int nX, const int nY,
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h
index 071da712703e..e623ecb2508e 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -273,11 +273,6 @@ struct _LibreOfficeKitDocumentClass
                          const int x, const int y,
                          const int width, const int height);
 
-    /// Get info about dialog with given dialog id
-    /// @see lok::Document::getDialogInfo().
-    void (*getDialogInfo) (LibreOfficeKitDocument* pThis, unsigned nDialogId,
-                           char** pDialogTitle, int* pWidth, int* pHeight);
-
     /// @see lok::Document::paintActiveFloatingWindow().
     void (*paintActiveFloatingWindow) (LibreOfficeKitDocument* pThis, unsigned nDialogId, unsigned char* pBuffer, int* nWidth, int* nHeight);
 
diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx
index c99b425daff6..86ceab46c484 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ b/include/LibreOfficeKit/LibreOfficeKit.hxx
@@ -178,23 +178,6 @@ public:
                                           x, y, width, height);
     }
 
-    /* Get info about dialog with given dialog id
-     *
-     * @param nDialogId Unique dialog id for which to get info about
-     * @param pDialogTitle Pointer to pointer pointing to string containing the
-     * dialog title. Caller should the pointer to allocated string themselves.
-     * @param pWidth The width of the dialog
-     * @param pHeight The height of the dialog
-     */
-    void getDialogInfo(unsigned nDialogId,
-                       char** pDialogTitle,
-                       int& pWidth,
-                       int& pHeight)
-    {
-        return mpDoc->pClass->getDialogInfo(mpDoc, nDialogId, pDialogTitle, &pWidth, &pHeight);
-
-    }
-
     /**
      * Renders the active floating window of a dialog
      *
diff --git a/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx b/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx
index b5325cf853c0..74cb58e09d48 100644
--- a/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx
@@ -94,9 +94,9 @@ gtv_lok_dialog_draw(GtkWidget* pDialogDrawingArea, cairo_t* pCairo, gpointer)
     GdkRectangle aRect;
     gdk_cairo_get_clip_rectangle(pCairo, &aRect);
     g_info("Painting dialog region: %d, %d, %d, %d", aRect.x, aRect.y, aRect.width, aRect.height);
+
     int nWidth = priv->m_nWidth;
     int nHeight = priv->m_nHeight;
-    g_info("canvas width: %d and height %d", nWidth, nHeight);
     if (aRect.width != 0 && aRect.height != 0)
     {
         nWidth = aRect.width;
@@ -106,18 +106,9 @@ gtv_lok_dialog_draw(GtkWidget* pDialogDrawingArea, cairo_t* pCairo, gpointer)
     cairo_surface_t* pSurface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, nWidth, nHeight);
     unsigned char* pBuffer = cairo_image_surface_get_data(pSurface);
     LibreOfficeKitDocument* pDocument = lok_doc_view_get_document(LOK_DOC_VIEW(priv->lokdocview));
-    char* pDialogTitle = nullptr;
     pDocument->pClass->paintDialog(pDocument, priv->dialogid, pBuffer, aRect.x, aRect.y, nWidth, nHeight);
-    int outWidth = 0, outHeight = 0;
-    pDocument->pClass->getDialogInfo(pDocument, priv->dialogid, &pDialogTitle, &outWidth, &outHeight);
-    g_debug("getDialogInfo: width: %d, height: %d", outWidth, outHeight);
-    if (pDialogTitle)
-    {
-        gtk_window_set_title(GTK_WINDOW(pDialog), pDialogTitle);
-        free(pDialogTitle);
-    }
 
-    gtk_widget_set_size_request(GTK_WIDGET(pDialogDrawingArea), outWidth, outHeight);
+    gtk_widget_set_size_request(GTK_WIDGET(pDialogDrawingArea), priv->m_nWidth, priv->m_nHeight);
 
     cairo_surface_flush(pSurface);
     cairo_surface_mark_dirty(pSurface);
@@ -411,6 +402,9 @@ gtv_lok_dialog_set_property(GObject* object, guint propId, const GValue* value,
     default:
         G_OBJECT_WARN_INVALID_PROPERTY_ID (object, propId, pspec);
     }
+
+    //if (propId == PROP_DIALOG_WIDTH || propId == PROP_DIALOG_HEIGHT)
+    //  gtk_widget_set_size_request(GTK_WIDGET(priv->pDialogDrawingArea), priv->m_nWidth, priv->m_nHeight);
 }
 
 static void
@@ -692,6 +686,7 @@ void gtv_lok_dialog_child_close(GtvLokDialog* dialog)
 GtkWidget*
 gtv_lok_dialog_new(LOKDocView* pDocView, guint dialogId, guint width, guint height)
 {
+    g_debug("Dialog [ %d ] of size: %d x %d created", dialogId, width, height);
     GtkWindow* pWindow = GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(pDocView)));
     return GTK_WIDGET(g_object_new(GTV_TYPE_LOK_DIALOG,
                                    "lokdocview", pDocView,
diff --git a/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx b/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx
index 62f639957d2b..79839aeccad2 100644
--- a/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx
@@ -331,14 +331,35 @@ void LOKDocViewSigHandlers::dialog(LOKDocView* pDocView, gchar* pPayload, gpoint
 
     GList* pChildWins = gtv_application_window_get_all_child_windows(window);
     GList* pIt = nullptr;
-    for (pIt = pChildWins; pIt != nullptr; pIt = pIt->next)
+    bool found = false;
+    for (pIt = pChildWins; !found && pIt != nullptr; pIt = pIt->next)
     {
         guint nChildDialogId = 0;
         g_object_get(pIt->data, "dialogid", &nChildDialogId, nullptr);
         if (nDialogId == nChildDialogId)
         {
+            found = true;
+
             if (aAction == "close")
                 gtk_widget_destroy(GTK_WIDGET(pIt->data));
+            else if (aAction == "size_changed")
+            {
+                const std::string aSize = aRoot.get<std::string>("size");
+                std::vector<int> aSizePoints = GtvHelpers::splitIntoIntegers(aSize, ", ", 2);
+                if (aSizePoints.size() != 2)
+                {
+                    g_error("Malformed size_changed callback");
+                    break;
+                }
+
+                g_object_set(G_OBJECT(pIt->data),
+                             "width", aSizePoints[0],
+                             "height", aSizePoints[1],
+                             nullptr);
+
+                GdkRectangle aGdkRectangle = {0, 0, 0, 0};
+                gtv_lok_dialog_invalidate(GTV_LOK_DIALOG(pIt->data), aGdkRectangle);
+            }
             else if (aAction == "invalidate")
             {
                 GdkRectangle aGdkRectangle = {0, 0, 0, 0};
commit 3acfdecac9b2ced1ca0cdfb6bc69e6cbfea67e40
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Tue Nov 28 02:25:36 2017 +0530

    lokdialog: Notify the current view only
    
    Change-Id: I55e0dbf1677a24905d337c58184a4419c1020a87

diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx
index f9543e9d0471..d5d868010490 100644
--- a/sfx2/source/view/lokhelper.cxx
+++ b/sfx2/source/view/lokhelper.cxx
@@ -151,7 +151,7 @@ void SfxLokHelper::notifyWindow(vcl::LOKWindowId nLOKWindowId,
     if (SfxLokHelper::getViewsCount() <= 0 || nLOKWindowId == 0)
         return;
 
-    SfxViewShell* pViewShell = SfxViewShell::GetFirst();
+
     OString aPayload = OString("{ \"dialogId\": \"") + OString::number(nLOKWindowId) + OString("\"");
     aPayload += OString(", \"action\": \"") + OUStringToOString(rAction, RTL_TEXTENCODING_UTF8).getStr() + OString("\"");
 
@@ -165,11 +165,8 @@ void SfxLokHelper::notifyWindow(vcl::LOKWindowId nLOKWindowId,
     }
     aPayload += "}";
 
-    while (pViewShell)
-    {
+    if (SfxViewShell* pViewShell = SfxViewShell::Current())
         pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_DIALOG, aPayload.getStr());
-        pViewShell = SfxViewShell::GetNext(*pViewShell);
-    }
 }
 
 void SfxLokHelper::notifyWindowChild(vcl::LOKWindowId nLOKWindowId, const OUString& rAction, const Point& rPos)
@@ -177,17 +174,14 @@ void SfxLokHelper::notifyWindowChild(vcl::LOKWindowId nLOKWindowId, const OUStri
     if (SfxLokHelper::getViewsCount() <= 0 || nLOKWindowId == 0)
         return;
 
-    SfxViewShell* pViewShell = SfxViewShell::GetFirst();
+
     const OString aPayload = OString("{ \"dialogId\": \"") + OString::number(nLOKWindowId) +
         OString("\", \"action\": \"") + OUStringToOString(rAction, RTL_TEXTENCODING_UTF8).getStr() +
         OString("\", \"position\": \"") + OString::number(rPos.getX()) + OString(", ") + OString::number(rPos.getY()) +
         + "\" }";
 
-    while (pViewShell)
-    {
+    if (SfxViewShell* pViewShell = SfxViewShell::Current())
         pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_DIALOG_CHILD, aPayload.getStr());
-        pViewShell = SfxViewShell::GetNext(*pViewShell);
-    }
 }
 
 void SfxLokHelper::notifyInvalidation(SfxViewShell const* pThisView, const OString& rPayload)
commit 1dda69be37d8bb3ef29447e572a225e0028edaed
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Tue Nov 28 01:44:46 2017 +0530

    lokdialog: new callback size_changed with new size of the dialog
    
    Change-Id: Ibb864cb588ae7db92381c5578701d3ce09185f34

diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx
index 2ae4cf305530..e0bfc6cc1b06 100644
--- a/vcl/source/window/dialog.cxx
+++ b/vcl/source/window/dialog.cxx
@@ -1224,9 +1224,12 @@ void Dialog::Resize()
     if (comphelper::LibreOfficeKit::isDialogPainting())
         return;
 
-    // inform LOK clients
     if (const vcl::ILibreOfficeKitNotifier* pNotifier = GetLOKNotifier())
-        pNotifier->notifyWindow(GetLOKWindowId(), "invalidate");
+    {
+        std::vector<vcl::LOKPayloadItem> aItems;
+        aItems.emplace_back(std::make_pair("size", GetOptimalSize().toString()));
+        pNotifier->notifyWindow(GetLOKWindowId(), "size_changed", aItems);
+    }
 }
 
 bool Dialog::set_property(const OString &rKey, const OUString &rValue)
commit bc113a3bae176a7dac1392d0f45c3e425725f230
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Mon Nov 27 21:05:56 2017 +0530

    lokdialog: Emit callback when title is changed
    
    The plan is to remove the getDialogInfo from LOK API but one more step
    before doing that is to find out why the dialog size in 'created'
    dialog callback is less than what the actual dialog after painting is.
    
    Change-Id: I5176e175cbf7ed81c1465feeeea053c9a024fbd9

diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx
index 66cef2d575a5..2ae4cf305530 100644
--- a/vcl/source/window/dialog.cxx
+++ b/vcl/source/window/dialog.cxx
@@ -57,6 +57,7 @@
 #include <salframe.hxx>
 
 #include <iostream>
+#include <utility>
 
 static OString ImplGetDialogText( Dialog* pDialog )
 {
@@ -691,6 +692,15 @@ void Dialog::StateChanged( StateChangedType nType )
 
         ImplMouseAutoPos( this );
     }
+    else if (nType == StateChangedType::Text)
+    {
+        if (const vcl::ILibreOfficeKitNotifier* pNotifier = GetLOKNotifier())
+        {
+            std::vector<vcl::LOKPayloadItem> aPayload;
+            aPayload.push_back(std::make_pair(OString("title"), GetText().toUtf8()));
+            pNotifier->notifyWindow(GetLOKWindowId(), "title_changed", aPayload);
+        }
+    }
 
     SystemWindow::StateChanged( nType );
 
commit 094ec23874b9af221c5c45b914150cf12a44fae6
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Fri Nov 24 18:40:01 2017 +0530

    lokdialog: Launch dialogs which have a notifier registered
    
    Change-Id: I062fa291668b7dbfb8bc8e8d455a7933378ce7d9

diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx
index 2881754ff13e..66cef2d575a5 100644
--- a/vcl/source/window/dialog.cxx
+++ b/vcl/source/window/dialog.cxx
@@ -784,7 +784,7 @@ bool Dialog::ImplStartExecuteModal()
     case Application::DialogCancelMode::Off:
         break;
     case Application::DialogCancelMode::Silent:
-        if (ImplGetDialogText(this) == "Character")
+        if (GetLOKNotifier())
             break;
 
         SAL_INFO(
commit d516c5c9819dcd7dc6dded2f8f9d9e44061b23c0
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Mon Nov 27 19:23:22 2017 +0100

    lokdialog: Move the LOKWindowId <-> VclPtr<Window> mapping to Window.
    
    This allows registering & de-registering of non-sfx windows too, and makes the
    Calc autofilter popup to appear.
    
    Change-Id: I7cbbe94d208115aabcb6fa5f964646c7b7ce4c93

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index cf5827ecbebd..ece7600f178d 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -1322,16 +1322,6 @@ ITiledRenderable* getTiledRenderable(LibreOfficeKitDocument* pThis)
     return dynamic_cast<ITiledRenderable*>(pDocument->mxComponent.get());
 }
 
-VclPtr<Window> findWindow(LibreOfficeKitDocument* pThis, unsigned nLOKWindowId)
-{
-    ITiledRenderable* pRenderable = getTiledRenderable(pThis);
-
-    if (!pRenderable)
-        return VclPtr<Window>();
-
-    return pRenderable->findWindow(nLOKWindowId);
-}
-
 } // anonymous namespace
 
 // Wonder global state ...
@@ -2265,7 +2255,7 @@ static void doc_postDialogKeyEvent(LibreOfficeKitDocument* pThis, unsigned nLOKW
 {
     SolarMutexGuard aGuard;
 
-    VclPtr<Window> pWindow = findWindow(pThis, nLOKWindowId);
+    VclPtr<Window> pWindow = vcl::Window::FindLOKWindow(nLOKWindowId);
     if (!pWindow)
     {
         gImpl->maLastExceptionMsg = "Document doesn't support dialog rendering, or window not found.";
@@ -2443,7 +2433,7 @@ static void doc_postDialogMouseEvent(LibreOfficeKitDocument* pThis, unsigned nLO
 {
     SolarMutexGuard aGuard;
 
-    VclPtr<Window> pWindow = findWindow(pThis, nLOKWindowId);
+    VclPtr<Window> pWindow = vcl::Window::FindLOKWindow(nLOKWindowId);
     if (!pWindow)
     {
         gImpl->maLastExceptionMsg = "Document doesn't support dialog rendering, or window not found.";
@@ -2474,7 +2464,7 @@ static void doc_postDialogChildMouseEvent(LibreOfficeKitDocument* pThis, unsigne
 {
     SolarMutexGuard aGuard;
 
-    VclPtr<Window> pWindow = findWindow(pThis, nLOKWindowId);
+    VclPtr<Window> pWindow = vcl::Window::FindLOKWindow(nLOKWindowId);
     if (!pWindow)
     {
         gImpl->maLastExceptionMsg = "Document doesn't support dialog rendering, or window not found.";
@@ -3285,7 +3275,7 @@ static void doc_getDialogInfo(LibreOfficeKitDocument* pThis, unsigned nLOKWindow
 
     SolarMutexGuard aGuard;
 
-    VclPtr<Window> pWindow = findWindow(pThis, nLOKWindowId);
+    VclPtr<Window> pWindow = vcl::Window::FindLOKWindow(nLOKWindowId);
     if (!pWindow)
     {
         gImpl->maLastExceptionMsg = "Document doesn't support dialog rendering, or window not found.";
@@ -3313,7 +3303,7 @@ static void doc_paintDialog(LibreOfficeKitDocument* pThis, unsigned nLOKWindowId
 {
     SolarMutexGuard aGuard;
 
-    VclPtr<Window> pWindow = findWindow(pThis, nLOKWindowId);
+    VclPtr<Window> pWindow = vcl::Window::FindLOKWindow(nLOKWindowId);
     if (!pWindow)
     {
         gImpl->maLastExceptionMsg = "Document doesn't support dialog rendering, or window not found.";
@@ -3338,7 +3328,7 @@ static void doc_paintActiveFloatingWindow(LibreOfficeKitDocument* pThis, unsigne
 {
     SolarMutexGuard aGuard;
 
-    VclPtr<Window> pWindow = findWindow(pThis, nLOKWindowId);
+    VclPtr<Window> pWindow = vcl::Window::FindLOKWindow(nLOKWindowId);
     if (!pWindow)
     {
         gImpl->maLastExceptionMsg = "Document doesn't support dialog rendering, or window not found.";
diff --git a/include/sfx2/viewsh.hxx b/include/sfx2/viewsh.hxx
index d0d68b3b48ae..90ade4ba1463 100644
--- a/include/sfx2/viewsh.hxx
+++ b/include/sfx2/viewsh.hxx
@@ -153,7 +153,6 @@ friend class SfxPrinterController;
     VclPtr<vcl::Window>         pWindow;
     bool                        bNoNewWindow;
     bool                        mbPrinterSettingsModified;
-    std::vector<std::pair<vcl::LOKWindowId, VclPtr<Dialog> > > maOpenedDialogs;
 
 protected:
     virtual void                Activate(bool IsMDIActivate) override;
@@ -222,10 +221,6 @@ public:
     virtual       SfxShell*     GetFormShell()       { return nullptr; };
     virtual const SfxShell*     GetFormShell() const { return nullptr; };
 
-    void                        RegisterDlg(vcl::LOKWindowId nDialogId, VclPtr<Dialog> pDlg);
-    VclPtr<Dialog>              GetOpenedDlg(vcl::LOKWindowId nDialogId);
-    void                        UnregisterDlg(vcl::LOKWindowId nDialogId);
-
     // ILibreOfficeKitNotifier
     virtual void                notifyWindow(vcl::LOKWindowId nLOKWindowId, const OUString& rAction, const std::vector<vcl::LOKPayloadItem>& rPayload = std::vector<vcl::LOKPayloadItem>()) const override;
     virtual void                notifyWindowChild(vcl::LOKWindowId nLOKWindowId, const OUString& rAction, const Point& rPos) const override;
diff --git a/include/vcl/ITiledRenderable.hxx b/include/vcl/ITiledRenderable.hxx
index 016704bb09db..7b0720a429b7 100644
--- a/include/vcl/ITiledRenderable.hxx
+++ b/include/vcl/ITiledRenderable.hxx
@@ -228,12 +228,6 @@ public:
     {
         return OUString();
     }
-
-    /**
-     * Find the window/dialog with the right ID for tunneling of windows,
-     * dialogs or pop-ups.
-     */
-    virtual VclPtr<Window> findWindow(vcl::LOKWindowId nLOKWindowId) const = 0;
 };
 } // namespace vcl
 
diff --git a/include/vcl/window.hxx b/include/vcl/window.hxx
index f513ea8995eb..a638dfa88f94 100644
--- a/include/vcl/window.hxx
+++ b/include/vcl/window.hxx
@@ -1208,6 +1208,12 @@ public:
     const vcl::ILibreOfficeKitNotifier* GetLOKNotifier() const;
     vcl::LOKWindowId                    GetLOKWindowId() const;
 
+    /// Indicate that LOK is not going to use this dialog any more.
+    void                                ReleaseLOKNotifier();
+
+    /// Find an existing Window based on the LOKWindowId.
+    static VclPtr<Window>               FindLOKWindow(vcl::LOKWindowId nWindowId);
+
     /// Dialog / window tunneling related methods.
     virtual void paintDialog(VirtualDevice& rDevice);
     Size PaintActiveFloatingWindow(VirtualDevice& rDevice) const;
diff --git a/sc/inc/docuno.hxx b/sc/inc/docuno.hxx
index 01fc9d9be960..67ee07440884 100644
--- a/sc/inc/docuno.hxx
+++ b/sc/inc/docuno.hxx
@@ -363,9 +363,6 @@ public:
 
     /// @see vcl::ITiledRenderable::getPostItsPos().
     OUString getPostItsPos() override;
-
-    /// @see vcl::ITiledRenderable::findWindow().
-    VclPtr<vcl::Window> findWindow(vcl::LOKWindowId nLOKWindowId) const override;
 };
 
 class ScDrawPagesObj : public cppu::WeakImplHelper<
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index 9144363f5f0c..ca287c11b398 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -1130,12 +1130,6 @@ OUString ScModelObj::getPostItsPos()
     return OUString::fromUtf8(aStream.str().c_str());
 }
 
-VclPtr<vcl::Window> ScModelObj::findWindow(vcl::LOKWindowId nLOKWindowId) const
-{
-    SfxViewShell* pViewShell = SfxViewShell::Current();
-    return pViewShell->GetOpenedDlg(nLOKWindowId);
-}
-
 void ScModelObj::initializeForTiledRendering(const css::uno::Sequence<css::beans::PropertyValue>& /*rArguments*/)
 {
     SolarMutexGuard aGuard;
diff --git a/sd/source/ui/inc/unomodel.hxx b/sd/source/ui/inc/unomodel.hxx
index d93ccdd89da9..404c34c49b72 100644
--- a/sd/source/ui/inc/unomodel.hxx
+++ b/sd/source/ui/inc/unomodel.hxx
@@ -265,9 +265,6 @@ public:
     /// @see vcl::ITiledRenderable::getPostIts().
     virtual OUString getPostIts() override;
 
-    /// @see vcl::ITiledRenderable::findWindow().
-    VclPtr<vcl::Window> findWindow(vcl::LOKWindowId nLOKWindowId) const override;
-
     // XComponent
 
     /** This dispose implementation releases the resources held by the
diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx
index 8af06f170e54..2699b62bb97f 100644
--- a/sd/source/ui/unoidl/unomodel.cxx
+++ b/sd/source/ui/unoidl/unomodel.cxx
@@ -2669,12 +2669,6 @@ Pointer SdXImpressDocument::getPointer()
     return pWindow->GetPointer();
 }
 
-VclPtr<vcl::Window> SdXImpressDocument::findWindow(vcl::LOKWindowId nLOKWindowId) const
-{
-    SfxViewShell* pViewShell = SfxViewShell::Current();
-    return pViewShell->GetOpenedDlg(nLOKWindowId);
-}
-
 uno::Reference< i18n::XForbiddenCharacters > SdXImpressDocument::getForbiddenCharsTable()
 {
     uno::Reference< i18n::XForbiddenCharacters > xForb(mxForbiddenCharacters);
diff --git a/sfx2/source/dialog/basedlgs.cxx b/sfx2/source/dialog/basedlgs.cxx
index fba79fdcc1b0..e9cadef82db0 100644
--- a/sfx2/source/dialog/basedlgs.cxx
+++ b/sfx2/source/dialog/basedlgs.cxx
@@ -165,7 +165,7 @@ void SfxModalDialog::dispose()
     if (comphelper::LibreOfficeKit::isActive() && pViewShell)
     {
         pViewShell->notifyWindow(GetLOKWindowId(), "close");
-        pViewShell->UnregisterDlg(GetLOKWindowId());
+        ReleaseLOKNotifier();
     }
 
     ModalDialog::dispose();
@@ -177,7 +177,6 @@ short SfxModalDialog::Execute()
     if (comphelper::LibreOfficeKit::isActive() && pViewShell)
     {
         SetLOKNotifier(pViewShell);
-        pViewShell->RegisterDlg(GetLOKWindowId(), this);
         const Size aSize = GetOptimalSize();
         std::vector<vcl::LOKPayloadItem> aItems;
         aItems.emplace_back(std::make_pair("size", aSize.toString()));
@@ -249,7 +248,6 @@ void SfxModelessDialog::StateChanged( StateChangedType nStateChange )
         if (comphelper::LibreOfficeKit::isActive() && pViewShell)
         {
             SetLOKNotifier(pViewShell);
-            pViewShell->RegisterDlg(GetLOKWindowId(), this);
             // Below method doesn't really give the exact dimensions,
             // Check GetSizePixel() ?
             const Size aOptimalSize = GetOptimalSize();
@@ -394,7 +392,7 @@ void SfxModelessDialog::dispose()
     if (comphelper::LibreOfficeKit::isActive() && pViewShell)
     {
         pViewShell->notifyWindow(GetLOKWindowId(), "close");
-        pViewShell->UnregisterDlg(GetLOKWindowId());
+        ReleaseLOKNotifier();
     }
 
     ModelessDialog::dispose();
diff --git a/sfx2/source/dialog/tabdlg.cxx b/sfx2/source/dialog/tabdlg.cxx
index 10cacfb0eee2..ce9e1a753984 100644
--- a/sfx2/source/dialog/tabdlg.cxx
+++ b/sfx2/source/dialog/tabdlg.cxx
@@ -407,7 +407,7 @@ void SfxTabDialog::dispose()
     if (comphelper::LibreOfficeKit::isActive() && pViewShell)
     {
         pViewShell->notifyWindow(GetLOKWindowId(), "close");
-        pViewShell->UnregisterDlg(GetLOKWindowId());
+        ReleaseLOKNotifier();
     }
 
     TabDialog::dispose();
@@ -522,7 +522,6 @@ short SfxTabDialog::Execute()
     if (comphelper::LibreOfficeKit::isActive() && pViewShell)
     {
         SetLOKNotifier(pViewShell);
-        pViewShell->RegisterDlg(GetLOKWindowId(), this);
         const Size aSize = GetOptimalSize();
         std::vector<vcl::LOKPayloadItem> aItems;
         aItems.emplace_back(std::make_pair("size", aSize.toString()));
diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx
index c286992d168e..4f08ef2298d6 100644
--- a/sfx2/source/view/viewsh.cxx
+++ b/sfx2/source/view/viewsh.cxx
@@ -1958,37 +1958,6 @@ void SfxViewShell::notifyWindowChild(vcl::LOKWindowId nDialogId, const OUString&
     SfxLokHelper::notifyWindowChild(nDialogId, rAction, rPos);
 }
 
-void SfxViewShell::RegisterDlg(vcl::LOKWindowId nDialogId, VclPtr<Dialog> pDlg)
-{
-    if (pDlg)
-        maOpenedDialogs.push_back(std::make_pair(nDialogId, pDlg));
-}
-
-VclPtr<Dialog> SfxViewShell::GetOpenedDlg(vcl::LOKWindowId nDialogId)
-{
-    const auto it = std::find_if(maOpenedDialogs.begin(),
-                                 maOpenedDialogs.end(),
-                                 [&nDialogId](const std::pair<vcl::LOKWindowId, VclPtr<Dialog>> aItem) {
-                                     return nDialogId == aItem.first;
-                                 });
-
-    Dialog* ret = nullptr;
-    if (it != maOpenedDialogs.end())
-    {
-        ret = it->second;
-    }
-    return ret;
-}
-
-void SfxViewShell::UnregisterDlg(vcl::LOKWindowId nDialogId)
-{
-    maOpenedDialogs.erase(std::remove_if(maOpenedDialogs.begin(),
-                                         maOpenedDialogs.end(),
-                                         [&nDialogId](const std::pair<vcl::LOKWindowId, VclPtr<Dialog>> aItem) {
-                                             return aItem.first == nDialogId;
-                                         }));
-}
-
 uno::Reference< datatransfer::clipboard::XClipboardNotifier > SfxViewShell::GetClipboardNotifier()
 {
     uno::Reference< datatransfer::clipboard::XClipboardNotifier > xClipboardNotifier;
diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx
index 288f32fa3df7..3f202c88ae54 100644
--- a/sw/inc/unotxdoc.hxx
+++ b/sw/inc/unotxdoc.hxx
@@ -429,9 +429,6 @@ public:
     /// @see vcl::ITiledRenderable::getPostIts().
     OUString getPostIts() override;
 
-    /// @see vcl::ITiledRenderable::findWindow().
-    VclPtr<vcl::Window> findWindow(vcl::LOKWindowId nLOKWindowId) const override;
-
     // css::tiledrendering::XTiledRenderable
     virtual void SAL_CALL paintTile( const ::css::uno::Any& Parent, ::sal_Int32 nOutputWidth, ::sal_Int32 nOutputHeight, ::sal_Int32 nTilePosX, ::sal_Int32 nTilePosY, ::sal_Int32 nTileWidth, ::sal_Int32 nTileHeight ) override;
 
diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx
index cae647d2948b..a6431a67975f 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -3639,12 +3639,6 @@ void SAL_CALL SwXTextDocument::paintTile( const ::css::uno::Any& Parent, ::sal_I
     #endif
 }
 
-VclPtr<vcl::Window> SwXTextDocument::findWindow(vcl::LOKWindowId nLOKWindowId) const
-{
-    SfxViewShell* pViewShell = SfxViewShell::Current();
-    return pViewShell->GetOpenedDlg(nLOKWindowId);
-}
-
 void * SAL_CALL SwXTextDocument::operator new( size_t t) throw()
 {
     return SwXTextDocumentBaseClass::operator new(t);
diff --git a/vcl/inc/window.h b/vcl/inc/window.h
index 7b2222b3718b..dec452861bb1 100644
--- a/vcl/inc/window.h
+++ b/vcl/inc/window.h
@@ -378,7 +378,6 @@ public:
     css::uno::Reference< css::uno::XInterface > mxDNDListenerContainer;
 
     const vcl::ILibreOfficeKitNotifier* mpLOKNotifier; ///< To emit the LOK callbacks eg. for dialog tunneling.
-    static vcl::LOKWindowId mnLastWindowId; ///< To be able to have an unique ID for each dealog / window we tunnel.
     vcl::LOKWindowId mnLOKWindowId; ///< ID of this specific window.
 };
 
diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx
index 852dae458f35..26a63eea7870 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -84,6 +84,12 @@ using namespace ::com::sun::star::datatransfer::dnd;
 
 namespace vcl {
 
+/// Counter to be able to have unique id's for each window.
+static vcl::LOKWindowId sLastLOKWindowId = 1;
+
+/// Map to remember the LOKWindowId <-> Window binding.
+static std::map<vcl::LOKWindowId, VclPtr<vcl::Window>> sLOKWindows;
+
 Window::Window( WindowType nType ) :
     mpWindowImpl(new WindowImpl( nType ))
 {
@@ -592,8 +598,6 @@ Window::~Window()
 
 } /* namespace vcl */
 
-vcl::LOKWindowId WindowImpl::mnLastWindowId = 1;
-
 WindowImpl::WindowImpl( WindowType nType )
 {
     maZoom                              = Fraction( 1, 1 );
@@ -3161,11 +3165,32 @@ void Window::SetLOKNotifier(const vcl::ILibreOfficeKitNotifier* pNotifier)
     assert(pNotifier);
 
     // assign the LOK window id
-    mpWindowImpl->mnLOKWindowId = WindowImpl::mnLastWindowId++;
+    assert(mpWindowImpl->mnLOKWindowId == 0);
+    mpWindowImpl->mnLOKWindowId = sLastLOKWindowId++;
+    sLOKWindows.insert(std::map<vcl::LOKWindowId, VclPtr<vcl::Window>>::value_type(mpWindowImpl->mnLOKWindowId, this));
 
     mpWindowImpl->mpLOKNotifier = pNotifier;
 }
 
+VclPtr<Window> Window::FindLOKWindow(vcl::LOKWindowId nWindowId)
+{
+    const auto it = sLOKWindows.find(nWindowId);
+    if (it != sLOKWindows.end())
+        return it->second;
+
+    return VclPtr<Window>();
+}
+
+void Window::ReleaseLOKNotifier()
+{
+    // unregister the LOK window binding
+    if (mpWindowImpl->mnLOKWindowId > 0)
+        sLOKWindows.erase(mpWindowImpl->mnLOKWindowId);
+
+    mpWindowImpl->mpLOKNotifier = nullptr;
+    mpWindowImpl->mnLOKWindowId = 0;
+}
+
 const vcl::ILibreOfficeKitNotifier* Window::GetLOKNotifier() const
 {
     return mpWindowImpl->mpLOKNotifier;
commit b4487b0fd22ce1fc595851f63a3f7bba36681f2c
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Mon Nov 27 15:03:19 2017 +0100

    lokdialog: Move the LogicInvalidate from Dialog down to Window.
    
    Another step towards the autofilter popup working...
    
    Change-Id: I4907a23fcd0fc64da0c7f51e2f36b1657a17638c

diff --git a/include/vcl/dialog.hxx b/include/vcl/dialog.hxx
index 30fae84afa9a..acc1ceef2701 100644
--- a/include/vcl/dialog.hxx
+++ b/include/vcl/dialog.hxx
@@ -75,7 +75,6 @@ protected:
 public:
     SAL_DLLPRIVATE bool    IsInClose() const { return mbInClose; }
     virtual        void    doDeferredInit(WinBits nBits) override;
-    virtual        void    LogicInvalidate(const tools::Rectangle* pRectangle) override;
                    void    InvalidateFloatingWindow(const Point& rPos);
                    void    CloseFloatingWindow();
 
diff --git a/include/vcl/window.hxx b/include/vcl/window.hxx
index b0ae9d319d49..f513ea8995eb 100644
--- a/include/vcl/window.hxx
+++ b/include/vcl/window.hxx
@@ -1065,6 +1065,7 @@ public:
     virtual void                        Invalidate( InvalidateFlags nFlags = InvalidateFlags::NONE );
     virtual void                        Invalidate( const tools::Rectangle& rRect, InvalidateFlags nFlags = InvalidateFlags::NONE );
     virtual void                        Invalidate( const vcl::Region& rRegion, InvalidateFlags nFlags = InvalidateFlags::NONE );
+    virtual void                        LogicInvalidate(const tools::Rectangle* pRectangle) override;
     void                                Validate();
     bool                                HasPaintEvent() const;
     void                                Update();
diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx
index 702575f53d65..2881754ff13e 100644
--- a/vcl/source/window/dialog.cxx
+++ b/vcl/source/window/dialog.cxx
@@ -895,21 +895,6 @@ void Dialog::CloseFloatingWindow()
         pNotifier->notifyWindowChild(GetLOKWindowId(), "close", Point(0, 0));
 }
 
-void Dialog::LogicInvalidate(const tools::Rectangle* pRectangle)
-{
-    if (comphelper::LibreOfficeKit::isDialogPainting())
-        return;
-
-    if (const vcl::ILibreOfficeKitNotifier* pNotifier = GetLOKNotifier())
-    {
-        std::vector<vcl::LOKPayloadItem> aPayload;
-        if (pRectangle)
-            aPayload.push_back(std::make_pair(OString("rectangle"), pRectangle->toString()));
-
-        pNotifier->notifyWindow(GetLOKWindowId(), "invalidate", aPayload);
-    }
-}
-
 void Dialog::ensureRepaint()
 {
     // ensure repaint
diff --git a/vcl/source/window/paint.cxx b/vcl/source/window/paint.cxx
index a77e09db9f13..3aa954b90536 100644
--- a/vcl/source/window/paint.cxx
+++ b/vcl/source/window/paint.cxx
@@ -1189,6 +1189,22 @@ void Window::Invalidate( const vcl::Region& rRegion, InvalidateFlags nFlags )
     }
 }
 
+void Window::LogicInvalidate(const tools::Rectangle* pRectangle)
+{
+    if (comphelper::LibreOfficeKit::isDialogPainting())
+        return;
+
+    if (const vcl::ILibreOfficeKitNotifier* pNotifier = GetLOKNotifier())
+    {
+        // In case we are routing the window, notify the client
+        std::vector<vcl::LOKPayloadItem> aPayload;
+        if (pRectangle)
+            aPayload.push_back(std::make_pair(OString("rectangle"), pRectangle->toString()));
+
+        pNotifier->notifyWindow(GetLOKWindowId(), "invalidate", aPayload);
+    }
+}
+
 void Window::Validate()
 {
     if ( !comphelper::LibreOfficeKit::isActive() && (!IsDeviceOutputNecessary() || !mnOutWidth || !mnOutHeight) )
commit e2ae221f6164ba240da7d6470fd52c1982fa07d2
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Fri Nov 24 18:50:05 2017 +0100

    lokdialog: Move the painting down to Window, and enable Calc and Impress.
    
    Tested with .uno:FormatCellDialog in Calc, Impress not tested.
    
    Change-Id: I6d911c29616988db0625be9e2a63cf2172c69ee8

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index b40ff1a609e4..cf5827ecbebd 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -544,7 +544,7 @@ static void doc_postKeyEvent(LibreOfficeKitDocument* pThis,
                              int nCharCode,
                              int nKeyCode);
 static void doc_postDialogKeyEvent(LibreOfficeKitDocument* pThis,
-                                   unsigned nDialogId,
+                                   unsigned nLOKWindowId,
                                    int nType,
                                    int nCharCode,
                                    int nKeyCode);
@@ -556,7 +556,7 @@ static void doc_postMouseEvent (LibreOfficeKitDocument* pThis,
                                 int nButtons,
                                 int nModifier);
 static void doc_postDialogMouseEvent (LibreOfficeKitDocument* pThis,
-                                      unsigned nDialogId,
+                                      unsigned nLOKWindowId,
                                       int nType,
                                       int nX,
                                       int nY,
@@ -564,7 +564,7 @@ static void doc_postDialogMouseEvent (LibreOfficeKitDocument* pThis,
                                       int nButtons,
                                       int nModifier);
 static void doc_postDialogChildMouseEvent (LibreOfficeKitDocument* pThis,
-                                           unsigned nDialogId,
+                                           unsigned nLOKWindowId,
                                            int nType,
                                            int nX,
                                            int nY,
@@ -611,14 +611,14 @@ static unsigned char* doc_renderFont(LibreOfficeKitDocument* pThis,
                           int* pFontHeight);
 static char* doc_getPartHash(LibreOfficeKitDocument* pThis, int nPart);
 
-static void doc_paintDialog(LibreOfficeKitDocument* pThis, unsigned nDialogId, unsigned char* pBuffer,
+static void doc_paintDialog(LibreOfficeKitDocument* pThis, unsigned nLOKWindowId, unsigned char* pBuffer,
                             const int nX, const int nY,
                             const int nWidth, const int nHeight);
 
-static void doc_getDialogInfo(LibreOfficeKitDocument* pThis, unsigned nDialogId,
+static void doc_getDialogInfo(LibreOfficeKitDocument* pThis, unsigned nLOKWindowId,
                               char** pDialogTitle, int* nWidth, int* nHeight);
 
-static void doc_paintActiveFloatingWindow(LibreOfficeKitDocument* pThis, unsigned nDialogId, unsigned char* pBuffer, int* nWidth, int* nHeight);
+static void doc_paintActiveFloatingWindow(LibreOfficeKitDocument* pThis, unsigned nLOKWindowId, unsigned char* pBuffer, int* nWidth, int* nHeight);
 
 LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XComponent> &xComponent)
     : mxComponent(xComponent)
@@ -1029,7 +1029,7 @@ void CallbackFlushHandler::queue(const int type, const char* data)
                 boost::property_tree::ptree aTree;
                 std::stringstream aStream(payload);
                 boost::property_tree::read_json(aStream, aTree);
-                const unsigned nDialogId = aTree.get<unsigned>("dialogId", 0);
+                const unsigned nLOKWindowId = aTree.get<unsigned>("dialogId", 0);
                 if (aTree.get<std::string>("action", "") == "invalidate")
                 {
                     std::string aRectStr = aTree.get<std::string>("rectangle", "");
@@ -1037,7 +1037,7 @@ void CallbackFlushHandler::queue(const int type, const char* data)
                     // remove all previous dialog part invalidations
                     if (aRectStr.empty())
                     {
-                        removeAll([&nDialogId] (const queue_type::value_type& elem) {
+                        removeAll([&nLOKWindowId] (const queue_type::value_type& elem) {
                                 if (elem.first == LOK_CALLBACK_DIALOG)
                                 {
                                     boost::property_tree::ptree aOldTree;
@@ -1045,7 +1045,7 @@ void CallbackFlushHandler::queue(const int type, const char* data)
                                     boost::property_tree::read_json(aOldStream, aOldTree);
                                     const unsigned nOldDialogId = aOldTree.get<unsigned>("dialogId", 0);
                                     if (aOldTree.get<std::string>("action", "") == "invalidate" &&
-                                        nDialogId == nOldDialogId)
+                                        nLOKWindowId == nOldDialogId)
                                     {
                                         return true;
                                     }
@@ -1058,7 +1058,7 @@ void CallbackFlushHandler::queue(const int type, const char* data)
                         // if we have to invalidate all of the dialog, ignore
                         // any part invalidation message
                         const auto& pos = std::find_if(m_queue.rbegin(), m_queue.rend(),
-                                                       [&nDialogId] (const queue_type::value_type& elem)
+                                                       [&nLOKWindowId] (const queue_type::value_type& elem)
                                                        {
                                                            if (elem.first != LOK_CALLBACK_DIALOG)
                                                                return false;
@@ -1068,7 +1068,7 @@ void CallbackFlushHandler::queue(const int type, const char* data)
                                                            boost::property_tree::read_json(aOldStream, aOldTree);
                                                            const unsigned nOldDialogId = aOldTree.get<unsigned>("dialogId", 0);
                                                            if (aOldTree.get<std::string>("action", "") == "invalidate" &&
-                                                               nDialogId == nOldDialogId &&
+                                                               nLOKWindowId == nOldDialogId &&
                                                                aOldTree.get<std::string>("rectangle", "").empty())
                                                            {
                                                                return true;
@@ -1089,7 +1089,7 @@ void CallbackFlushHandler::queue(const int type, const char* data)
                         aRectStream >> nLeft >> nComma >> nTop >> nComma >> nWidth >> nComma >> nHeight;
                         tools::Rectangle aNewRect = tools::Rectangle(nLeft, nTop, nLeft + nWidth, nTop + nHeight);
                         bool currentIsRedundant = false;
-                        removeAll([&aNewRect, &nDialogId, &currentIsRedundant] (const queue_type::value_type& elem) {
+                        removeAll([&aNewRect, &nLOKWindowId, &currentIsRedundant] (const queue_type::value_type& elem) {
                                 if (elem.first != LOK_CALLBACK_DIALOG)
                                     return false;
 
@@ -1109,7 +1109,7 @@ void CallbackFlushHandler::queue(const int type, const char* data)
                                     aOldRectStream >> nOldLeft >> nOldComma >> nOldTop >> nOldComma >> nOldWidth >> nOldComma >> nOldHeight;
                                     tools::Rectangle aOldRect = tools::Rectangle(nOldLeft, nOldTop, nOldLeft + nOldWidth, nOldTop + nOldHeight);
 
-                                    if (nDialogId == nOldDialogId)
+                                    if (nLOKWindowId == nOldDialogId)
                                     {
                                         // new one engulfs the old one?
                                         if (aNewRect.IsInside(aOldRect))
@@ -1322,10 +1322,14 @@ ITiledRenderable* getTiledRenderable(LibreOfficeKitDocument* pThis)
     return dynamic_cast<ITiledRenderable*>(pDocument->mxComponent.get());
 }
 
-IDialogRenderable* getDialogRenderable(LibreOfficeKitDocument* pThis)
+VclPtr<Window> findWindow(LibreOfficeKitDocument* pThis, unsigned nLOKWindowId)
 {
-    LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis);
-    return dynamic_cast<IDialogRenderable*>(pDocument->mxComponent.get());
+    ITiledRenderable* pRenderable = getTiledRenderable(pThis);
+
+    if (!pRenderable)
+        return VclPtr<Window>();
+
+    return pRenderable->findWindow(nLOKWindowId);
 }
 
 } // anonymous namespace
@@ -2257,18 +2261,31 @@ static void doc_postKeyEvent(LibreOfficeKitDocument* pThis, int nType, int nChar
     pDoc->postKeyEvent(nType, nCharCode, nKeyCode);
 }
 
-static void doc_postDialogKeyEvent(LibreOfficeKitDocument* pThis, unsigned nDialogId, int nType, int nCharCode, int nKeyCode)
+static void doc_postDialogKeyEvent(LibreOfficeKitDocument* pThis, unsigned nLOKWindowId, int nType, int nCharCode, int nKeyCode)
 {
     SolarMutexGuard aGuard;
 
-    IDialogRenderable* pDoc = getDialogRenderable(pThis);
-    if (!pDoc)
+    VclPtr<Window> pWindow = findWindow(pThis, nLOKWindowId);
+    if (!pWindow)
     {
-        gImpl->maLastExceptionMsg = "Document doesn't support dialog rendering";
+        gImpl->maLastExceptionMsg = "Document doesn't support dialog rendering, or window not found.";
         return;
     }
 
-    pDoc->postDialogKeyEvent(nDialogId, nType, nCharCode, nKeyCode);
+    KeyEvent aEvent(nCharCode, nKeyCode, 0);
+
+    switch (nType)
+    {
+        case LOK_KEYEVENT_KEYINPUT:
+            pWindow->LOKKeyInput(aEvent);
+            break;
+        case LOK_KEYEVENT_KEYUP:
+            pWindow->LOKKeyUp(aEvent);
+            break;
+        default:
+            assert(false);
+            break;
+    }
 }
 
 /** Class to react on finishing of a dispatched command.
@@ -2422,32 +2439,66 @@ static void doc_postMouseEvent(LibreOfficeKitDocument* pThis, int nType, int nX,
     }
 }
 
-static void doc_postDialogMouseEvent(LibreOfficeKitDocument* pThis, unsigned nDialogId, int nType, int nX, int nY, int nCount, int nButtons, int nModifier)
+static void doc_postDialogMouseEvent(LibreOfficeKitDocument* pThis, unsigned nLOKWindowId, int nType, int nX, int nY, int nCount, int nButtons, int nModifier)
 {
     SolarMutexGuard aGuard;
 
-    IDialogRenderable* pDoc = getDialogRenderable(pThis);
-    if (!pDoc)
+    VclPtr<Window> pWindow = findWindow(pThis, nLOKWindowId);
+    if (!pWindow)
     {
-        gImpl->maLastExceptionMsg = "Document doesn't support dialog rendering";
+        gImpl->maLastExceptionMsg = "Document doesn't support dialog rendering, or window not found.";
         return;
     }
 
-    pDoc->postDialogMouseEvent(nDialogId, nType, nX, nY, nCount, nButtons, nModifier);
+    Point aPos(nX, nY);
+    MouseEvent aEvent(aPos, nCount, MouseEventModifiers::SIMPLECLICK, nButtons, nModifier);
+
+    switch (nType)
+    {
+        case LOK_MOUSEEVENT_MOUSEBUTTONDOWN:
+            pWindow->LogicMouseButtonDown(aEvent);
+            break;
+        case LOK_MOUSEEVENT_MOUSEBUTTONUP:
+            pWindow->LogicMouseButtonUp(aEvent);
+            break;
+        case LOK_MOUSEEVENT_MOUSEMOVE:
+            pWindow->LogicMouseMove(aEvent);
+            break;
+        default:
+            assert(false);
+            break;
+    }
 }
 
-static void doc_postDialogChildMouseEvent(LibreOfficeKitDocument* pThis, unsigned nDialogId, int nType, int nX, int nY, int nCount, int nButtons, int nModifier)
+static void doc_postDialogChildMouseEvent(LibreOfficeKitDocument* pThis, unsigned nLOKWindowId, int nType, int nX, int nY, int nCount, int nButtons, int nModifier)
 {
     SolarMutexGuard aGuard;
 
-    IDialogRenderable* pDoc = getDialogRenderable(pThis);
-    if (!pDoc)
+    VclPtr<Window> pWindow = findWindow(pThis, nLOKWindowId);
+    if (!pWindow)
     {
-        gImpl->maLastExceptionMsg = "Document doesn't support dialog rendering";
+        gImpl->maLastExceptionMsg = "Document doesn't support dialog rendering, or window not found.";
         return;
     }
 
-    pDoc->postDialogChildMouseEvent(nDialogId, nType, nX, nY, nCount, nButtons, nModifier);
+    Point aPos(nX, nY);
+    MouseEvent aEvent(aPos, nCount, MouseEventModifiers::SIMPLECLICK, nButtons, nModifier);
+
+    switch (nType)
+    {
+        case LOK_MOUSEEVENT_MOUSEBUTTONDOWN:
+            pWindow->LogicMouseButtonDownChild(aEvent);
+            break;
+        case LOK_MOUSEEVENT_MOUSEBUTTONUP:
+            pWindow->LogicMouseButtonUpChild(aEvent);
+            break;
+        case LOK_MOUSEEVENT_MOUSEMOVE:
+            pWindow->LogicMouseMoveChild(aEvent);
+            break;
+        default:
+            assert(false);
+            break;
+    }
 }
 
 static void doc_setTextSelection(LibreOfficeKitDocument* pThis, int nType, int nX, int nY)
@@ -3226,14 +3277,25 @@ unsigned char* doc_renderFont(SAL_UNUSED_PARAMETER LibreOfficeKitDocument* /*pTh
     return nullptr;
 }
 
-static void doc_getDialogInfo(LibreOfficeKitDocument* pThis, unsigned nDialogId,
+static void doc_getDialogInfo(LibreOfficeKitDocument* pThis, unsigned nLOKWindowId,
                               char** pDialogTitle, int* nWidth, int* nHeight)
 {
+    // FIXME - I guess we should kill this one, and use only the callback
+    // "created"?
+
     SolarMutexGuard aGuard;
 
-    IDialogRenderable* pDialogRenderable = getDialogRenderable(pThis);
-    OUString aDialogTitle;
-    pDialogRenderable->getDialogInfo(nDialogId, aDialogTitle, *nWidth, *nHeight);
+    VclPtr<Window> pWindow = findWindow(pThis, nLOKWindowId);
+    if (!pWindow)
+    {
+        gImpl->maLastExceptionMsg = "Document doesn't support dialog rendering, or window not found.";
+        return;
+    }
+
+    OUString aDialogTitle(pWindow->GetText());
+    const Size aSize = pWindow->GetSizePixel();
+    *nWidth = aSize.getWidth();
+    *nHeight = aSize.getHeight();
 
     // copy dialog title
     if (!aDialogTitle.isEmpty())
@@ -3244,14 +3306,19 @@ static void doc_getDialogInfo(LibreOfficeKitDocument* pThis, unsigned nDialogId,
     }
 }
 
-static void doc_paintDialog(LibreOfficeKitDocument* pThis, unsigned nDialogId,
+static void doc_paintDialog(LibreOfficeKitDocument* pThis, unsigned nLOKWindowId,
                             unsigned char* pBuffer,
                             const int nX, const int nY,
                             const int nWidth, const int nHeight)
 {
     SolarMutexGuard aGuard;
 
-    IDialogRenderable* pDialogRenderable = getDialogRenderable(pThis);
+    VclPtr<Window> pWindow = findWindow(pThis, nLOKWindowId);
+    if (!pWindow)
+    {
+        gImpl->maLastExceptionMsg = "Document doesn't support dialog rendering, or window not found.";
+        return;
+    }
 
     ScopedVclPtrInstance<VirtualDevice> pDevice(nullptr, Size(1, 1), DeviceFormat::DEFAULT);
     pDevice->SetBackground(Wallpaper(Color(COL_TRANSPARENT)));
@@ -3263,15 +3330,20 @@ static void doc_paintDialog(LibreOfficeKitDocument* pThis, unsigned nDialogId,
     pDevice->SetMapMode(aMapMode);
 
     comphelper::LibreOfficeKit::setDialogPainting(true);
-    pDialogRenderable->paintDialog(nDialogId, *pDevice.get());
+    pWindow->paintDialog(*pDevice.get());
     comphelper::LibreOfficeKit::setDialogPainting(false);
 }
 
-static void doc_paintActiveFloatingWindow(LibreOfficeKitDocument* pThis, unsigned nDialogId, unsigned char* pBuffer, int* nWidth, int* nHeight)
+static void doc_paintActiveFloatingWindow(LibreOfficeKitDocument* pThis, unsigned nLOKWindowId, unsigned char* pBuffer, int* nWidth, int* nHeight)
 {
     SolarMutexGuard aGuard;
 
-    IDialogRenderable* pDialogRenderable = getDialogRenderable(pThis);
+    VclPtr<Window> pWindow = findWindow(pThis, nLOKWindowId);
+    if (!pWindow)
+    {
+        gImpl->maLastExceptionMsg = "Document doesn't support dialog rendering, or window not found.";
+        return;
+    }
 
     ScopedVclPtrInstance<VirtualDevice> pDevice(nullptr, Size(1, 1), DeviceFormat::DEFAULT);
     pDevice->SetBackground(Wallpaper(Color(COL_TRANSPARENT)));
@@ -3279,7 +3351,9 @@ static void doc_paintActiveFloatingWindow(LibreOfficeKitDocument* pThis, unsigne
     pDevice->SetOutputSizePixelScaleOffsetAndBuffer(Size(*nWidth, *nHeight), Fraction(1.0), Point(), pBuffer);
 
     comphelper::LibreOfficeKit::setDialogPainting(true);
-    pDialogRenderable->paintActiveFloatingWindow(nDialogId, *pDevice.get(), *nWidth, *nHeight);
+    const Size aSize = pWindow->PaintActiveFloatingWindow(*pDevice.get());
+    *nWidth = aSize.getWidth();
+    *nHeight = aSize.getHeight();
     comphelper::LibreOfficeKit::setDialogPainting(false);
 }
 
diff --git a/include/sfx2/lokhelper.hxx b/include/sfx2/lokhelper.hxx
index 170d65a794d0..00288d04faac 100644
--- a/include/sfx2/lokhelper.hxx
+++ b/include/sfx2/lokhelper.hxx
@@ -42,11 +42,11 @@ public:
     /// Same as notifyOtherViews(), but works on a selected "other" view, not on all of them.
     static void notifyOtherView(SfxViewShell* pThisView, SfxViewShell const* pOtherView, int nType, const OString& rKey, const OString& rPayload);
     /// Emits a LOK_CALLBACK_DIALOG
-    static void notifyDialog(vcl::LOKWindowId nDialogId,
+    static void notifyWindow(vcl::LOKWindowId nDialogId,
                              const OUString& rAction,
                              const std::vector<vcl::LOKPayloadItem>& rPayload = std::vector<vcl::LOKPayloadItem>());
     /// Emits a LOK_CALLBACK_DIALOG_CHILD
-    static void notifyDialogChild(vcl::LOKWindowId nDialogId, const OUString& rAction, const Point& rPos);
+    static void notifyWindowChild(vcl::LOKWindowId nDialogId, const OUString& rAction, const Point& rPos);
     /// Emits a LOK_CALLBACK_INVALIDATE_TILES, but tweaks it according to setOptionalFeatures() if needed.
     static void notifyInvalidation(SfxViewShell const* pThisView, const OString& rPayload);
     /// A special value to signify 'infinity'.
diff --git a/include/sfx2/viewsh.hxx b/include/sfx2/viewsh.hxx
index 2fcf7283399a..d0d68b3b48ae 100644
--- a/include/sfx2/viewsh.hxx
+++ b/include/sfx2/viewsh.hxx
@@ -227,8 +227,8 @@ public:
     void                        UnregisterDlg(vcl::LOKWindowId nDialogId);
 
     // ILibreOfficeKitNotifier
-    virtual void                notifyDialog(const vcl::LOKWindowId& rDialogId, const OUString& rAction, const std::vector<vcl::LOKPayloadItem>& rPayload = std::vector<vcl::LOKPayloadItem>()) const override;
-    virtual void                notifyDialogChild(const vcl::LOKWindowId& rDialogId, const OUString& rAction, const Point& rPos) const override;
+    virtual void                notifyWindow(vcl::LOKWindowId nLOKWindowId, const OUString& rAction, const std::vector<vcl::LOKPayloadItem>& rPayload = std::vector<vcl::LOKPayloadItem>()) const override;
+    virtual void                notifyWindowChild(vcl::LOKWindowId nLOKWindowId, const OUString& rAction, const Point& rPos) const override;
 
     // Focus, KeyInput, Cursor
     virtual void                ShowCursor( bool bOn = true );
diff --git a/include/vcl/IDialogRenderable.hxx b/include/vcl/IDialogRenderable.hxx
index 20515c86d2a6..281d04385aee 100644
--- a/include/vcl/IDialogRenderable.hxx
+++ b/include/vcl/IDialogRenderable.hxx
@@ -11,51 +11,31 @@
 #ifndef INCLUDED_VCL_IDIALOGRENDERABLE_HXX
 #define INCLUDED_VCL_IDIALOGRENDERABLE_HXX
 
+#include <vcl/dllapi.h>
+
 #include <tools/gen.hxx>
-#include <vcl/pointr.hxx>
-#include <vcl/virdev.hxx>
-#include <vcl/window.hxx>
+#include <rtl/ustring.hxx>
 
-#include <map>
+#include <vector>
 
 namespace vcl
 {
 
 typedef std::pair<const OString, const OString> LOKPayloadItem;
 
-class VCL_DLLPUBLIC IDialogRenderable
-{
-public:
-    virtual ~IDialogRenderable();
-
-    virtual void paintDialog(const LOKWindowId& rLOKWindowId, VirtualDevice &rDevice) = 0;
-
-    virtual void getDialogInfo(const LOKWindowId& rLOKWindowId, OUString& rDialogTitle, int& rWidth, int& rHeight) = 0;
-
-    virtual void paintActiveFloatingWindow(const LOKWindowId& rLOKWindowId, VirtualDevice &rDevice,
-                                           int& nOutputWidth, int& nOutputHeight) = 0;
-
-    virtual void postDialogKeyEvent(const LOKWindowId& rLOKWindowId, int nType,
-                                    int nCharCode, int nKeyCode) = 0;
-
-    virtual void postDialogMouseEvent(const LOKWindowId& rLOKWindowId, int nType, int nX, int nY,
-                                      int nCount, int nButtons, int nModifier) = 0;
-
-    virtual void postDialogChildMouseEvent(const LOKWindowId& rLOKWindowId, int nType, int nX, int nY,
-                                           int nCount, int nButtons, int nModifier) = 0;
-};
+typedef sal_uInt32 LOKWindowId;
 
 class VCL_DLLPUBLIC ILibreOfficeKitNotifier
 {
 public:
     virtual ~ILibreOfficeKitNotifier() {}
 
-    // Callbacks
-    virtual void notifyDialog(const LOKWindowId& rLOKWindowId,
+    /// Callbacks
+    virtual void notifyWindow(vcl::LOKWindowId nLOKWindowId,
                               const OUString& rAction,
                               const std::vector<LOKPayloadItem>& rPayload = std::vector<LOKPayloadItem>()) const = 0;
 
-    virtual void notifyDialogChild(const LOKWindowId& rLOKWindowId, const OUString& rAction, const Point& rPos) const = 0;
+    virtual void notifyWindowChild(vcl::LOKWindowId nLOKWindowId, const OUString& rAction, const Point& rPos) const = 0;
 };
 
 } // namespace vcl
diff --git a/include/vcl/ITiledRenderable.hxx b/include/vcl/ITiledRenderable.hxx
index 7b0720a429b7..016704bb09db 100644
--- a/include/vcl/ITiledRenderable.hxx
+++ b/include/vcl/ITiledRenderable.hxx
@@ -228,6 +228,12 @@ public:
     {
         return OUString();
     }
+
+    /**
+     * Find the window/dialog with the right ID for tunneling of windows,
+     * dialogs or pop-ups.
+     */
+    virtual VclPtr<Window> findWindow(vcl::LOKWindowId nLOKWindowId) const = 0;
 };
 } // namespace vcl
 
diff --git a/include/vcl/dialog.hxx b/include/vcl/dialog.hxx
index 4347917b7675..30fae84afa9a 100644
--- a/include/vcl/dialog.hxx
+++ b/include/vcl/dialog.hxx
@@ -78,20 +78,9 @@ public:
     virtual        void    LogicInvalidate(const tools::Rectangle* pRectangle) override;
                    void    InvalidateFloatingWindow(const Point& rPos);
                    void    CloseFloatingWindow();
-                   Size    PaintActiveFloatingWindow(VirtualDevice& rDevice) const;
 
     /// Paints the current dialog to the given virtual device
-    void paintDialog(VirtualDevice& rDevice);
-    void LogicMouseButtonDown(const MouseEvent& rMouseEvent);
-    void LogicMouseButtonUp(const MouseEvent& rMouseEvent);
-    void LogicMouseMove(const MouseEvent& rMouseEvent);
-    void LogicMouseButtonDownChild(const MouseEvent& rMouseEvent);
-    void LogicMouseButtonUpChild(const MouseEvent& rMouseEvent);
-    void LogicMouseMoveChild(const MouseEvent& rMouseEvent);
-
-    void LOKKeyInput(const KeyEvent& rKeyEvent);
-    void LOKKeyUp(const KeyEvent& rKeyEvent);
-    void LOKCursor(const OUString& rAction, const std::vector<vcl::LOKPayloadItem>& rPayload);
+    void paintDialog(VirtualDevice& rDevice) override;
 
 protected:
     explicit        Dialog( WindowType nType );
diff --git a/include/vcl/window.hxx b/include/vcl/window.hxx
index be9d88d48adc..b0ae9d319d49 100644
--- a/include/vcl/window.hxx
+++ b/include/vcl/window.hxx
@@ -34,6 +34,7 @@
 #include <vcl/salnativewidgets.hxx>
 #include <vcl/uitest/factory.hxx>
 #include <vcl/vclevent.hxx>
+#include <vcl/IDialogRenderable.hxx>
 #include <rtl/ustring.hxx>
 #include <rtl/ref.hxx>
 #include <cppuhelper/weakref.hxx>
@@ -489,8 +490,6 @@ public:
                                         Color const * pPaintColor = nullptr);
 };
 
-typedef sal_uInt32 LOKWindowId;
-
 class VCL_DLLPUBLIC Window : public ::OutputDevice
 {
     friend class ::vcl::Cursor;
@@ -1203,11 +1202,26 @@ public:
 
     void                        SetComponentInterface( css::uno::Reference< css::awt::XWindowPeer > const & xIFace );
 
-    /// Interface to register for dialog tunneling.
+    /// Interface to register for dialog / window tunneling.
     void                                SetLOKNotifier(const vcl::ILibreOfficeKitNotifier* pNotifier);
     const vcl::ILibreOfficeKitNotifier* GetLOKNotifier() const;
     vcl::LOKWindowId                    GetLOKWindowId() const;
 
+    /// Dialog / window tunneling related methods.
+    virtual void paintDialog(VirtualDevice& rDevice);
+    Size PaintActiveFloatingWindow(VirtualDevice& rDevice) const;
+
+    void LogicMouseButtonDown(const MouseEvent& rMouseEvent);
+    void LogicMouseButtonUp(const MouseEvent& rMouseEvent);
+    void LogicMouseMove(const MouseEvent& rMouseEvent);
+    void LogicMouseButtonDownChild(const MouseEvent& rMouseEvent);
+    void LogicMouseButtonUpChild(const MouseEvent& rMouseEvent);
+    void LogicMouseMoveChild(const MouseEvent& rMouseEvent);
+
+    void LOKKeyInput(const KeyEvent& rKeyEvent);
+    void LOKKeyUp(const KeyEvent& rKeyEvent);
+    void LOKCursor(const OUString& rAction, const std::vector<vcl::LOKPayloadItem>& rPayload);
+
     /** @name Accessibility
      */
     ///@{
diff --git a/sc/inc/docuno.hxx b/sc/inc/docuno.hxx
index 67ee07440884..01fc9d9be960 100644
--- a/sc/inc/docuno.hxx
+++ b/sc/inc/docuno.hxx
@@ -363,6 +363,9 @@ public:
 
     /// @see vcl::ITiledRenderable::getPostItsPos().
     OUString getPostItsPos() override;
+
+    /// @see vcl::ITiledRenderable::findWindow().
+    VclPtr<vcl::Window> findWindow(vcl::LOKWindowId nLOKWindowId) const override;
 };
 
 class ScDrawPagesObj : public cppu::WeakImplHelper<
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index ca287c11b398..9144363f5f0c 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -1130,6 +1130,12 @@ OUString ScModelObj::getPostItsPos()
     return OUString::fromUtf8(aStream.str().c_str());
 }
 
+VclPtr<vcl::Window> ScModelObj::findWindow(vcl::LOKWindowId nLOKWindowId) const
+{
+    SfxViewShell* pViewShell = SfxViewShell::Current();
+    return pViewShell->GetOpenedDlg(nLOKWindowId);
+}
+
 void ScModelObj::initializeForTiledRendering(const css::uno::Sequence<css::beans::PropertyValue>& /*rArguments*/)
 {
     SolarMutexGuard aGuard;
diff --git a/sd/source/ui/inc/unomodel.hxx b/sd/source/ui/inc/unomodel.hxx
index 404c34c49b72..d93ccdd89da9 100644
--- a/sd/source/ui/inc/unomodel.hxx
+++ b/sd/source/ui/inc/unomodel.hxx
@@ -265,6 +265,9 @@ public:
     /// @see vcl::ITiledRenderable::getPostIts().
     virtual OUString getPostIts() override;
 
+    /// @see vcl::ITiledRenderable::findWindow().
+    VclPtr<vcl::Window> findWindow(vcl::LOKWindowId nLOKWindowId) const override;
+
     // XComponent
 
     /** This dispose implementation releases the resources held by the
diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx
index 2699b62bb97f..8af06f170e54 100644
--- a/sd/source/ui/unoidl/unomodel.cxx
+++ b/sd/source/ui/unoidl/unomodel.cxx
@@ -2669,6 +2669,12 @@ Pointer SdXImpressDocument::getPointer()
     return pWindow->GetPointer();
 }
 
+VclPtr<vcl::Window> SdXImpressDocument::findWindow(vcl::LOKWindowId nLOKWindowId) const
+{
+    SfxViewShell* pViewShell = SfxViewShell::Current();
+    return pViewShell->GetOpenedDlg(nLOKWindowId);
+}
+
 uno::Reference< i18n::XForbiddenCharacters > SdXImpressDocument::getForbiddenCharsTable()
 {
     uno::Reference< i18n::XForbiddenCharacters > xForb(mxForbiddenCharacters);
diff --git a/sfx2/source/dialog/basedlgs.cxx b/sfx2/source/dialog/basedlgs.cxx
index 18d2a395631d..fba79fdcc1b0 100644
--- a/sfx2/source/dialog/basedlgs.cxx
+++ b/sfx2/source/dialog/basedlgs.cxx
@@ -164,7 +164,7 @@ void SfxModalDialog::dispose()
     SfxViewShell* pViewShell = SfxViewShell::Current();
     if (comphelper::LibreOfficeKit::isActive() && pViewShell)
     {
-        pViewShell->notifyDialog(GetLOKWindowId(), "close");
+        pViewShell->notifyWindow(GetLOKWindowId(), "close");
         pViewShell->UnregisterDlg(GetLOKWindowId());
     }
 
@@ -181,7 +181,7 @@ short SfxModalDialog::Execute()
         const Size aSize = GetOptimalSize();
         std::vector<vcl::LOKPayloadItem> aItems;
         aItems.emplace_back(std::make_pair("size", aSize.toString()));
-        pViewShell->notifyDialog(GetLOKWindowId(), "created", aItems);
+        pViewShell->notifyWindow(GetLOKWindowId(), "created", aItems);
     }
 
     return ModalDialog::Execute();
@@ -255,7 +255,7 @@ void SfxModelessDialog::StateChanged( StateChangedType nStateChange )
             const Size aOptimalSize = GetOptimalSize();
             std::vector<vcl::LOKPayloadItem> aItems;
             aItems.emplace_back(std::make_pair("size", aOptimalSize.toString()));
-            pViewShell->notifyDialog(GetLOKWindowId(), "created", aItems);
+            pViewShell->notifyWindow(GetLOKWindowId(), "created", aItems);
         }
 
         pImpl->bConstructed = true;
@@ -393,7 +393,7 @@ void SfxModelessDialog::dispose()
     SfxViewShell* pViewShell = SfxViewShell::Current();
     if (comphelper::LibreOfficeKit::isActive() && pViewShell)
     {
-        pViewShell->notifyDialog(GetLOKWindowId(), "close");
+        pViewShell->notifyWindow(GetLOKWindowId(), "close");
         pViewShell->UnregisterDlg(GetLOKWindowId());
     }
 
diff --git a/sfx2/source/dialog/tabdlg.cxx b/sfx2/source/dialog/tabdlg.cxx
index 7b53bbc32ff3..10cacfb0eee2 100644
--- a/sfx2/source/dialog/tabdlg.cxx
+++ b/sfx2/source/dialog/tabdlg.cxx
@@ -406,7 +406,7 @@ void SfxTabDialog::dispose()
     SfxViewShell* pViewShell = SfxViewShell::Current();
     if (comphelper::LibreOfficeKit::isActive() && pViewShell)
     {
-        pViewShell->notifyDialog(GetLOKWindowId(), "close");
+        pViewShell->notifyWindow(GetLOKWindowId(), "close");
         pViewShell->UnregisterDlg(GetLOKWindowId());
     }
 
@@ -526,7 +526,7 @@ short SfxTabDialog::Execute()
         const Size aSize = GetOptimalSize();
         std::vector<vcl::LOKPayloadItem> aItems;
         aItems.emplace_back(std::make_pair("size", aSize.toString()));
-        pViewShell->notifyDialog(GetLOKWindowId(), "created", aItems);
+        pViewShell->notifyWindow(GetLOKWindowId(), "created", aItems);
     }
 
     return TabDialog::Execute();
diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx
index cfd9041ab421..f9543e9d0471 100644
--- a/sfx2/source/view/lokhelper.cxx
+++ b/sfx2/source/view/lokhelper.cxx
@@ -144,7 +144,7 @@ void SfxLokHelper::notifyOtherViews(SfxViewShell* pThisView, int nType, const OS
     }
 }
 
-void SfxLokHelper::notifyDialog(vcl::LOKWindowId nLOKWindowId,
+void SfxLokHelper::notifyWindow(vcl::LOKWindowId nLOKWindowId,
                                 const OUString& rAction,
                                 const std::vector<vcl::LOKPayloadItem>& rPayload)
 {
@@ -172,7 +172,7 @@ void SfxLokHelper::notifyDialog(vcl::LOKWindowId nLOKWindowId,
     }
 }
 
-void SfxLokHelper::notifyDialogChild(vcl::LOKWindowId nLOKWindowId, const OUString& rAction, const Point& rPos)
+void SfxLokHelper::notifyWindowChild(vcl::LOKWindowId nLOKWindowId, const OUString& rAction, const Point& rPos)
 {
     if (SfxLokHelper::getViewsCount() <= 0 || nLOKWindowId == 0)
         return;
diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx
index 778a9d9f68b7..c286992d168e 100644
--- a/sfx2/source/view/viewsh.cxx
+++ b/sfx2/source/view/viewsh.cxx
@@ -1948,14 +1948,14 @@ Reference< view::XRenderable > SfxViewShell::GetRenderable()
     return xRender;
 }
 
-void SfxViewShell::notifyDialog(const vcl::LOKWindowId& rDialogId, const OUString& rAction, const std::vector<vcl::LOKPayloadItem>& rPayload) const
+void SfxViewShell::notifyWindow(vcl::LOKWindowId nDialogId, const OUString& rAction, const std::vector<vcl::LOKPayloadItem>& rPayload) const
 {
-    SfxLokHelper::notifyDialog(rDialogId, rAction, rPayload);
+    SfxLokHelper::notifyWindow(nDialogId, rAction, rPayload);
 }
 
-void SfxViewShell::notifyDialogChild(const vcl::LOKWindowId& rDialogId, const OUString& rAction, const Point& rPos) const
+void SfxViewShell::notifyWindowChild(vcl::LOKWindowId nDialogId, const OUString& rAction, const Point& rPos) const
 {
-    SfxLokHelper::notifyDialogChild(rDialogId, rAction, rPos);
+    SfxLokHelper::notifyWindowChild(nDialogId, rAction, rPos);
 }
 
 void SfxViewShell::RegisterDlg(vcl::LOKWindowId nDialogId, VclPtr<Dialog> pDlg)
diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx
index 85c1d4a4ead6..288f32fa3df7 100644
--- a/sw/inc/unotxdoc.hxx
+++ b/sw/inc/unotxdoc.hxx
@@ -70,7 +70,6 @@
 #include <cppuhelper/implbase.hxx>
 #include <vcl/event.hxx>
 #include <vcl/ITiledRenderable.hxx>
-#include <vcl/IDialogRenderable.hxx>
 #include <com/sun/star/tiledrendering/XTiledRenderable.hpp>
 
 #include "unobaseclass.hxx"
@@ -132,7 +131,6 @@ class SW_DLLPUBLIC SwXTextDocument : public SwXTextDocumentBaseClass,
     public SvxFmMSFactory,
     public SfxBaseModel,
     public vcl::ITiledRenderable,
-    public vcl::IDialogRenderable,
     public css::tiledrendering::XTiledRenderable
 {
 private:
@@ -431,17 +429,8 @@ public:
     /// @see vcl::ITiledRenderable::getPostIts().
     OUString getPostIts() override;
 
-    void paintDialog(const vcl::LOKWindowId& rLOKWindowId, VirtualDevice& rDevice) override;
-    void getDialogInfo(const vcl::LOKWindowId& rLOKWindowId, OUString& rDialogTitle, int& rWidth, int& rHeight) override;
-    void paintActiveFloatingWindow(const vcl::LOKWindowId& rLOKWindowId, VirtualDevice& rDevice, int& nWidth, int& nHeight) override;
-    void postDialogKeyEvent(const vcl::LOKWindowId& rLOKWindowId, int nType,
-                            int nCharCode, int nKeyCode) override;
-
-    void postDialogMouseEvent(const vcl::LOKWindowId& rLOKWindowId, int nType, int nX, int nY,
-                              int nCount, int nButtons, int nModifier) override;
-
-    void postDialogChildMouseEvent(const vcl::LOKWindowId& rLOKWindowId, int nType, int nX, int nY,
-                                   int nCount, int nButtons, int nModifier) override;
+    /// @see vcl::ITiledRenderable::findWindow().
+    VclPtr<vcl::Window> findWindow(vcl::LOKWindowId nLOKWindowId) const override;
 
     // css::tiledrendering::XTiledRenderable
     virtual void SAL_CALL paintTile( const ::css::uno::Any& Parent, ::sal_Int32 nOutputWidth, ::sal_Int32 nOutputHeight, ::sal_Int32 nTilePosX, ::sal_Int32 nTilePosY, ::sal_Int32 nTileWidth, ::sal_Int32 nTileHeight ) override;
diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx
index fc7c7a6a2b59..cae647d2948b 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -3639,123 +3639,10 @@ void SAL_CALL SwXTextDocument::paintTile( const ::css::uno::Any& Parent, ::sal_I
     #endif
 }
 
-void SwXTextDocument::paintDialog(const vcl::LOKWindowId& rLOKWindowId, VirtualDevice& rDevice)
+VclPtr<vcl::Window> SwXTextDocument::findWindow(vcl::LOKWindowId nLOKWindowId) const
 {
     SfxViewShell* pViewShell = SfxViewShell::Current();
-    VclPtr<Dialog> pDlg = pViewShell->GetOpenedDlg(rLOKWindowId);
-    if (pDlg)
-        pDlg->paintDialog(rDevice);
-}
-
-void SwXTextDocument::getDialogInfo(const vcl::LOKWindowId& rLOKWindowId, OUString& rDialogTitle, int& rWidth, int& rHeight)
-{
-    SfxViewShell* pViewShell = SfxViewShell::Current();
-    VclPtr<Dialog> pDlg = pViewShell->GetOpenedDlg(rLOKWindowId);
-    if (pDlg)
-    {
-        rDialogTitle = pDlg->GetText();
-        const Size aSize = pDlg->GetOptimalSize();
-        rWidth = aSize.getWidth();
-        rHeight = aSize.getHeight();
-    }
-}
-
-void SwXTextDocument::postDialogKeyEvent(const vcl::LOKWindowId& rLOKWindowId, int nType, int nCharCode, int nKeyCode)
-{
-    SolarMutexGuard aGuard;
-
-    SfxViewShell* pViewShell = SfxViewShell::Current();
-    VclPtr<Dialog> pDialog = pViewShell->GetOpenedDlg(rLOKWindowId);
-    if (pDialog)
-    {
-        KeyEvent aEvent(nCharCode, nKeyCode, 0);
-
-        switch (nType)
-        {
-        case LOK_KEYEVENT_KEYINPUT:
-            pDialog->LOKKeyInput(aEvent);
-            break;
-        case LOK_KEYEVENT_KEYUP:
-            pDialog->LOKKeyUp(aEvent);
-            break;
-        default:
-            assert(false);
-            break;
-        }
-    }
-}
-
-void SwXTextDocument::postDialogMouseEvent(const vcl::LOKWindowId& rLOKWindowId, int nType, int nX, int nY,
-                                           int nCount, int nButtons, int nModifier)
-{
-    SolarMutexGuard aGuard;
-
-    SfxViewShell* pViewShell = SfxViewShell::Current();
-    VclPtr<Dialog> pDialog = pViewShell->GetOpenedDlg(rLOKWindowId);
-    if (pDialog)
-    {
-        Point aPos(nX , nY);
-        MouseEvent aEvent(aPos, nCount, MouseEventModifiers::SIMPLECLICK, nButtons, nModifier);
-
-        switch (nType)
-        {
-        case LOK_MOUSEEVENT_MOUSEBUTTONDOWN:
-            pDialog->LogicMouseButtonDown(aEvent);
-            break;
-        case LOK_MOUSEEVENT_MOUSEBUTTONUP:
-            pDialog->LogicMouseButtonUp(aEvent);
-            break;
-        case LOK_MOUSEEVENT_MOUSEMOVE:
-            pDialog->LogicMouseMove(aEvent);
-            break;
-        default:
-            assert(false);
-            break;
-        }
-    }
-}
-
-
-void SwXTextDocument::postDialogChildMouseEvent(const vcl::LOKWindowId& rLOKWindowId, int nType, int nX, int nY,
-                                                int nCount, int nButtons, int nModifier)
-{
-    SolarMutexGuard aGuard;
-
-    SfxViewShell* pViewShell = SfxViewShell::Current();
-    VclPtr<Dialog> pDialog = pViewShell->GetOpenedDlg(rLOKWindowId);
-    if (pDialog)
-    {
-        Point aPos(nX , nY);
-        MouseEvent aEvent(aPos, nCount, MouseEventModifiers::SIMPLECLICK, nButtons, nModifier);
-
-        switch (nType)
-        {
-        case LOK_MOUSEEVENT_MOUSEBUTTONDOWN:
-            pDialog->LogicMouseButtonDownChild(aEvent);
-            break;
-        case LOK_MOUSEEVENT_MOUSEBUTTONUP:
-            pDialog->LogicMouseButtonUpChild(aEvent);
-            break;
-        case LOK_MOUSEEVENT_MOUSEMOVE:
-            pDialog->LogicMouseMoveChild(aEvent);
-            break;
-        default:
-            assert(false);
-            break;
-        }
-    }
-}
-
-void SwXTextDocument::paintActiveFloatingWindow(const vcl::LOKWindowId& rLOKWindowId, VirtualDevice& rDevice, int& nWidth, int& nHeight)
-{
-    SfxViewShell* pViewShell = SfxViewShell::Current();
-    VclPtr<Dialog> pDialog = pViewShell->GetOpenedDlg(rLOKWindowId);
-    if (pDialog)
-    {
-        const Size aSize = pDialog->PaintActiveFloatingWindow(rDevice);
-        nWidth = aSize.getWidth();
-        nHeight = aSize.getHeight();
-    }
+    return pViewShell->GetOpenedDlg(nLOKWindowId);
 }
 
 void * SAL_CALL SwXTextDocument::operator new( size_t t) throw()
diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk
index 699d6abd67f5..c1f3cc5324e7 100644
--- a/vcl/Library_vcl.mk
+++ b/vcl/Library_vcl.mk
@@ -331,7 +331,6 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
     vcl/source/app/IconThemeScanner \
     vcl/source/app/IconThemeSelector \
     vcl/source/app/ITiledRenderable \
-    vcl/source/app/IDialogRenderable \
     vcl/source/app/sound \
     vcl/source/app/stdtext \
     vcl/source/app/svapp \
diff --git a/vcl/source/app/IDialogRenderable.cxx b/vcl/source/app/IDialogRenderable.cxx
deleted file mode 100644
index 58ec05265101..000000000000
--- a/vcl/source/app/IDialogRenderable.cxx
+++ /dev/null
@@ -1,22 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- */
-
-#include <vcl/IDialogRenderable.hxx>
-
-namespace vcl
-{
-
-IDialogRenderable::~IDialogRenderable()
-{
-}
-
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx
index 68232e872e5d..702575f53d65 100644
--- a/vcl/source/window/dialog.cxx
+++ b/vcl/source/window/dialog.cxx
@@ -883,75 +883,16 @@ void Dialog::paintDialog(VirtualDevice& rDevice)
     PaintToDevice(&rDevice, Point(0, 0), Size());
 }
 
-Size Dialog::PaintActiveFloatingWindow(VirtualDevice& rDevice) const
-{
-    Size aRet;
-    ImplSVData* pSVData = ImplGetSVData();
-    FloatingWindow* pFirstFloat = pSVData->maWinData.mpFirstFloat;
-    if (pFirstFloat)
-    {
-        // TODO:: run a while loop here and check all the active floating
-        // windows ( chained together, cf. pFirstFloat->mpNextFloat )
-        // For now just assume that the active floating window is the one we
-        // want to render
-        if (pFirstFloat->GetParentDialog() == this)
-        {
-            pFirstFloat->PaintToDevice(&rDevice, Point(0, 0), Size());
-            aRet = ::isLayoutEnabled(pFirstFloat) ? pFirstFloat->get_preferred_size() : pFirstFloat->GetSizePixel();
-        }
-
-        pFirstFloat = nullptr;
-    }
-
-    return aRet;
-}
-
-void Dialog::LogicMouseButtonDownChild(const MouseEvent& rMouseEvent)
-{
-    assert(comphelper::LibreOfficeKit::isActive());
-
-    ImplSVData* pSVData = ImplGetSVData();
-    FloatingWindow* pFirstFloat = pSVData->maWinData.mpFirstFloat;
-    if (pFirstFloat && pFirstFloat->GetParentDialog() == this)
-    {
-        ImplWindowFrameProc(pFirstFloat->ImplGetBorderWindow(), SalEvent::ExternalMouseButtonDown, &rMouseEvent);
-    }
-}
-
-void Dialog::LogicMouseButtonUpChild(const MouseEvent& rMouseEvent)
-{
-    assert(comphelper::LibreOfficeKit::isActive());
-
-    ImplSVData* pSVData = ImplGetSVData();
-    FloatingWindow* pFirstFloat = pSVData->maWinData.mpFirstFloat;
-    if (pFirstFloat && pFirstFloat->GetParentDialog() == this)
-    {
-        ImplWindowFrameProc(pFirstFloat->ImplGetBorderWindow(), SalEvent::ExternalMouseButtonUp, &rMouseEvent);
-    }
-}
-
-void Dialog::LogicMouseMoveChild(const MouseEvent& rMouseEvent)
-{
-    assert(comphelper::LibreOfficeKit::isActive());
-
-    ImplSVData* pSVData = ImplGetSVData();
-    FloatingWindow* pFirstFloat = pSVData->maWinData.mpFirstFloat;
-    if (pFirstFloat && pFirstFloat->GetParentDialog() == this)
-    {
-        ImplWindowFrameProc(pFirstFloat->ImplGetBorderWindow(), SalEvent::ExternalMouseMove, &rMouseEvent);
-    }
-}
-
 void Dialog::InvalidateFloatingWindow(const Point& rPos)
 {
     if (const vcl::ILibreOfficeKitNotifier* pNotifier = GetLOKNotifier())
-        pNotifier->notifyDialogChild(GetLOKWindowId(), "invalidate", rPos);
+        pNotifier->notifyWindowChild(GetLOKWindowId(), "invalidate", rPos);
 }
 
 void Dialog::CloseFloatingWindow()
 {
     if (const vcl::ILibreOfficeKitNotifier* pNotifier = GetLOKNotifier())
-        pNotifier->notifyDialogChild(GetLOKWindowId(), "close", Point(0, 0));
+        pNotifier->notifyWindowChild(GetLOKWindowId(), "close", Point(0, 0));
 }
 
 void Dialog::LogicInvalidate(const tools::Rectangle* pRectangle)
@@ -965,59 +906,10 @@ void Dialog::LogicInvalidate(const tools::Rectangle* pRectangle)
         if (pRectangle)
             aPayload.push_back(std::make_pair(OString("rectangle"), pRectangle->toString()));
 
-        pNotifier->notifyDialog(GetLOKWindowId(), "invalidate", aPayload);
+        pNotifier->notifyWindow(GetLOKWindowId(), "invalidate", aPayload);
     }
 }
 
-void Dialog::LogicMouseButtonDown(const MouseEvent& rMouseEvent)
-{
-    // When we're not doing tiled rendering, then positions must be passed as pixels.
-    assert(comphelper::LibreOfficeKit::isActive());
-
-    ImplWindowFrameProc(this, SalEvent::ExternalMouseButtonDown, &rMouseEvent);
-}
-
-void Dialog::LogicMouseButtonUp(const MouseEvent& rMouseEvent)
-{
-    // When we're not doing tiled rendering, then positions must be passed as pixels.
-    assert(comphelper::LibreOfficeKit::isActive());
-
-    ImplWindowFrameProc(this, SalEvent::ExternalMouseButtonUp, &rMouseEvent);
-}
-
-void Dialog::LogicMouseMove(const MouseEvent& rMouseEvent)
-{
-    // When we're not doing tiled rendering, then positions must be passed as pixels.
-    assert(comphelper::LibreOfficeKit::isActive());
-
-    ImplWindowFrameProc(this, SalEvent::ExternalMouseMove, &rMouseEvent);
-}
-
-void Dialog::LOKKeyInput(const KeyEvent& rKeyEvent)
-{
-    assert(comphelper::LibreOfficeKit::isActive());
-
-    ImplWindowFrameProc(this, SalEvent::ExternalKeyInput, &rKeyEvent);
-}
-
-void Dialog::LOKKeyUp(const KeyEvent& rKeyEvent)
-{
-    assert(comphelper::LibreOfficeKit::isActive());
-
-    ImplWindowFrameProc(this, SalEvent::ExternalKeyUp, &rKeyEvent);
-}
-
-void Dialog::LOKCursor(const OUString& rAction, const std::vector<vcl::LOKPayloadItem>& rPayload)
-{
-    assert(comphelper::LibreOfficeKit::isActive());
-
-    if (comphelper::LibreOfficeKit::isDialogPainting())
-        return;
-
-    if (const vcl::ILibreOfficeKitNotifier* pNotifier = GetLOKNotifier())
-        pNotifier->notifyDialog(GetLOKWindowId(), rAction, rPayload);
-}
-
 void Dialog::ensureRepaint()
 {
     // ensure repaint
@@ -1339,7 +1231,7 @@ void Dialog::Resize()
 
     // inform LOK clients
     if (const vcl::ILibreOfficeKitNotifier* pNotifier = GetLOKNotifier())
-        pNotifier->notifyDialog(GetLOKWindowId(), "invalidate");
+        pNotifier->notifyWindow(GetLOKWindowId(), "invalidate");
 }
 
 bool Dialog::set_property(const OString &rKey, const OUString &rValue)
diff --git a/vcl/source/window/floatwin.cxx b/vcl/source/window/floatwin.cxx
index b00da3a18a77..f5d9927a2482 100644
--- a/vcl/source/window/floatwin.cxx
+++ b/vcl/source/window/floatwin.cxx
@@ -725,7 +725,7 @@ void FloatingWindow::StartPopupMode( const tools::Rectangle& rRect, FloatWinPopu
     {
         std::vector<vcl::LOKPayloadItem> aItems;
         aItems.emplace_back(std::make_pair("size", rRect.GetSize().toString()));
-        pNotifier->notifyDialog(GetLOKWindowId(), "created", aItems);
+        pNotifier->notifyWindow(GetLOKWindowId(), "created", aItems);
     }
 }
 
diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx
index ba61ea70a3b3..852dae458f35 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -64,6 +64,7 @@
 #include <com/sun/star/datatransfer/clipboard/SystemClipboard.hpp>
 #include <com/sun/star/rendering/CanvasFactory.hpp>
 #include <com/sun/star/rendering/XSpriteCanvas.hpp>
+#include <comphelper/lok.hxx>
 #include <comphelper/processfactory.hxx>
 #include <unotools/configmgr.hxx>
 
@@ -3177,6 +3178,123 @@ vcl::LOKWindowId Window::GetLOKWindowId() const
     return mpWindowImpl->mnLOKWindowId;
 }
 
+void Window::paintDialog(VirtualDevice& rDevice)
+{
+    // FIXME are these two necessary?
+    Show();
+    ToTop();
+
+    PaintToDevice(&rDevice, Point(0, 0), Size());
+}
+
+Size Window::PaintActiveFloatingWindow(VirtualDevice& rDevice) const
+{
+    Size aRet;
+    ImplSVData* pSVData = ImplGetSVData();
+    FloatingWindow* pFirstFloat = pSVData->maWinData.mpFirstFloat;
+    if (pFirstFloat)
+    {
+        // TODO:: run a while loop here and check all the active floating
+        // windows ( chained together, cf. pFirstFloat->mpNextFloat )
+        // For now just assume that the active floating window is the one we
+        // want to render
+        if (pFirstFloat->GetParentDialog() == this)
+        {
+            pFirstFloat->PaintToDevice(&rDevice, Point(0, 0), Size());
+            aRet = pFirstFloat->GetSizePixel();
+        }
+
+        pFirstFloat = nullptr;
+    }
+
+    return aRet;
+}
+
+void Window::LogicMouseButtonDown(const MouseEvent& rMouseEvent)
+{
+    // When we're not doing tiled rendering, then positions must be passed as pixels.
+    assert(comphelper::LibreOfficeKit::isActive());
+
+    ImplWindowFrameProc(this, SalEvent::ExternalMouseButtonDown, &rMouseEvent);
+}
+
+void Window::LogicMouseButtonUp(const MouseEvent& rMouseEvent)
+{
+    // When we're not doing tiled rendering, then positions must be passed as pixels.
+    assert(comphelper::LibreOfficeKit::isActive());
+
+    ImplWindowFrameProc(this, SalEvent::ExternalMouseButtonUp, &rMouseEvent);
+}
+
+void Window::LogicMouseMove(const MouseEvent& rMouseEvent)
+{
+    // When we're not doing tiled rendering, then positions must be passed as pixels.
+    assert(comphelper::LibreOfficeKit::isActive());
+
+    ImplWindowFrameProc(this, SalEvent::ExternalMouseMove, &rMouseEvent);
+}
+
+void Window::LogicMouseButtonDownChild(const MouseEvent& rMouseEvent)
+{
+    assert(comphelper::LibreOfficeKit::isActive());
+
+    ImplSVData* pSVData = ImplGetSVData();
+    FloatingWindow* pFirstFloat = pSVData->maWinData.mpFirstFloat;
+    if (pFirstFloat && pFirstFloat->GetParentDialog() == this)
+    {
+        ImplWindowFrameProc(pFirstFloat->ImplGetBorderWindow(), SalEvent::ExternalMouseButtonDown, &rMouseEvent);
+    }
+}
+
+void Window::LogicMouseButtonUpChild(const MouseEvent& rMouseEvent)
+{
+    assert(comphelper::LibreOfficeKit::isActive());
+
+    ImplSVData* pSVData = ImplGetSVData();
+    FloatingWindow* pFirstFloat = pSVData->maWinData.mpFirstFloat;
+    if (pFirstFloat && pFirstFloat->GetParentDialog() == this)
+    {
+        ImplWindowFrameProc(pFirstFloat->ImplGetBorderWindow(), SalEvent::ExternalMouseButtonUp, &rMouseEvent);
+    }
+}
+
+void Window::LogicMouseMoveChild(const MouseEvent& rMouseEvent)
+{
+    assert(comphelper::LibreOfficeKit::isActive());
+
+    ImplSVData* pSVData = ImplGetSVData();
+    FloatingWindow* pFirstFloat = pSVData->maWinData.mpFirstFloat;
+    if (pFirstFloat && pFirstFloat->GetParentDialog() == this)
+    {
+        ImplWindowFrameProc(pFirstFloat->ImplGetBorderWindow(), SalEvent::ExternalMouseMove, &rMouseEvent);
+    }
+}
+
+void Window::LOKKeyInput(const KeyEvent& rKeyEvent)
+{
+    assert(comphelper::LibreOfficeKit::isActive());
+
+    ImplWindowFrameProc(this, SalEvent::ExternalKeyInput, &rKeyEvent);
+}
+
+void Window::LOKKeyUp(const KeyEvent& rKeyEvent)
+{
+    assert(comphelper::LibreOfficeKit::isActive());
+
+    ImplWindowFrameProc(this, SalEvent::ExternalKeyUp, &rKeyEvent);
+}
+
+void Window::LOKCursor(const OUString& rAction, const std::vector<vcl::LOKPayloadItem>& rPayload)
+{
+    assert(comphelper::LibreOfficeKit::isActive());
+
+    if (comphelper::LibreOfficeKit::isDialogPainting())
+        return;
+
+    if (const vcl::ILibreOfficeKitNotifier* pNotifier = GetLOKNotifier())
+        pNotifier->notifyWindow(GetLOKWindowId(), rAction, rPayload);
+}
+
 void Window::ImplCallDeactivateListeners( vcl::Window *pNew )
 {
     // no deactivation if the newly activated window is my child
commit 5de24bea47e7ae971a53b51ee7d1b85d134bbe52
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Fri Nov 24 12:06:42 2017 +0100

    lokdialogs: Assign the LOK window id only when necessary.
    
    Change-Id: Id48957a8c2bde068f30bb26e66df81972fe38e0f

diff --git a/sfx2/source/dialog/basedlgs.cxx b/sfx2/source/dialog/basedlgs.cxx
index 9d30c8596e33..18d2a395631d 100644
--- a/sfx2/source/dialog/basedlgs.cxx
+++ b/sfx2/source/dialog/basedlgs.cxx
@@ -176,8 +176,8 @@ short SfxModalDialog::Execute()
     SfxViewShell* pViewShell = SfxViewShell::Current();
     if (comphelper::LibreOfficeKit::isActive() && pViewShell)
     {
-        pViewShell->RegisterDlg(GetLOKWindowId(), this);
         SetLOKNotifier(pViewShell);
+        pViewShell->RegisterDlg(GetLOKWindowId(), this);
         const Size aSize = GetOptimalSize();
         std::vector<vcl::LOKPayloadItem> aItems;
         aItems.emplace_back(std::make_pair("size", aSize.toString()));
@@ -248,8 +248,8 @@ void SfxModelessDialog::StateChanged( StateChangedType nStateChange )
         SfxViewShell* pViewShell = SfxViewShell::Current();
         if (comphelper::LibreOfficeKit::isActive() && pViewShell)
         {
-            pViewShell->RegisterDlg(GetLOKWindowId(), this);
             SetLOKNotifier(pViewShell);
+            pViewShell->RegisterDlg(GetLOKWindowId(), this);
             // Below method doesn't really give the exact dimensions,
             // Check GetSizePixel() ?
             const Size aOptimalSize = GetOptimalSize();
diff --git a/sfx2/source/dialog/tabdlg.cxx b/sfx2/source/dialog/tabdlg.cxx
index a12d76a14ae1..7b53bbc32ff3 100644
--- a/sfx2/source/dialog/tabdlg.cxx
+++ b/sfx2/source/dialog/tabdlg.cxx
@@ -521,8 +521,8 @@ short SfxTabDialog::Execute()
     SfxViewShell* pViewShell = SfxViewShell::Current();
     if (comphelper::LibreOfficeKit::isActive() && pViewShell)
     {
-        pViewShell->RegisterDlg(GetLOKWindowId(), this);
         SetLOKNotifier(pViewShell);
+        pViewShell->RegisterDlg(GetLOKWindowId(), this);
         const Size aSize = GetOptimalSize();
         std::vector<vcl::LOKPayloadItem> aItems;
         aItems.emplace_back(std::make_pair("size", aSize.toString()));
diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx
index 3604276839b8..ba61ea70a3b3 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -740,7 +740,7 @@ WindowImpl::WindowImpl( WindowType nType )
     static bool bDoubleBuffer = getenv("VCL_DOUBLEBUFFERING_FORCE_ENABLE");
     mbDoubleBufferingRequested = bDoubleBuffer; // when we are not sure, assume it cannot do double-buffering via RenderContext
     mpLOKNotifier                       = nullptr;
-    mnLOKWindowId                       = mnLastWindowId++;
+    mnLOKWindowId                       = 0;
 }
 
 WindowImpl::~WindowImpl()
@@ -3155,6 +3155,13 @@ void Window::SetComponentInterface( Reference< css::awt::XWindowPeer > const & x
 
 void Window::SetLOKNotifier(const vcl::ILibreOfficeKitNotifier* pNotifier)
 {
+    // don't allow setting this twice
+    assert(mpWindowImpl->mpLOKNotifier == nullptr);
+    assert(pNotifier);
+
+    // assign the LOK window id
+    mpWindowImpl->mnLOKWindowId = WindowImpl::mnLastWindowId++;
+
     mpWindowImpl->mpLOKNotifier = pNotifier;
 }
 
@@ -3165,6 +3172,8 @@ const vcl::ILibreOfficeKitNotifier* Window::GetLOKNotifier() const
 
 vcl::LOKWindowId Window::GetLOKWindowId() const
 {
+    assert(mpWindowImpl->mnLOKWindowId > 0);
+
     return mpWindowImpl->mnLOKWindowId;
 }
 
commit 6bc22c34fb3742dc991ec35dc6660d162a39ccf5
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Fri Nov 24 11:21:13 2017 +0100

    lokdialog: Make the Autofilter popup notify about its creation.
    
    Change-Id: Ib4062fa887b44eb1368205a414f4ac162f648c5c

diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index 3db50f96447b..21b320c5b91a 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -627,6 +627,7 @@ void ScGridWindow::LaunchAutoFilterMenu(SCCOL nCol, SCROW nRow)
 
     mpAutoFilterPopup.disposeAndClear();
     mpAutoFilterPopup.reset(VclPtr<ScCheckListMenuWindow>::Create(this, pDoc));
+    mpAutoFilterPopup->SetLOKNotifier(SfxViewShell::Current());
     mpAutoFilterPopup->setOKAction(new AutoFilterAction(this, Normal));
     mpAutoFilterPopup->setPopupEndAction(
         new AutoFilterPopupEndAction(this, ScAddress(nCol, nRow, nTab)));
diff --git a/vcl/source/window/floatwin.cxx b/vcl/source/window/floatwin.cxx
index 936f55d401e3..b00da3a18a77 100644
--- a/vcl/source/window/floatwin.cxx
+++ b/vcl/source/window/floatwin.cxx
@@ -720,6 +720,13 @@ void FloatingWindow::StartPopupMode( const tools::Rectangle& rRect, FloatWinPopu
         GrabFocus();
     }
     Show( true, ShowFlags::NoActivate );
+
+    if (const vcl::ILibreOfficeKitNotifier* pNotifier = GetLOKNotifier())
+    {
+        std::vector<vcl::LOKPayloadItem> aItems;
+        aItems.emplace_back(std::make_pair("size", rRect.GetSize().toString()));
+        pNotifier->notifyDialog(GetLOKWindowId(), "created", aItems);
+    }
 }
 
 void FloatingWindow::StartPopupMode( ToolBox* pBox, FloatWinPopupFlags nFlags )
commit ba8154d857aa815ba3c5b52987dc17be6eba7f48
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Fri Nov 24 10:20:47 2017 +0100

    lokdialog: Move the Notifier down to vcl::Window.
    
    We need to tunnel more than just dialogs, so this is the 1st step to get the
    Autofilter popup rendered.
    
    Change-Id: I6523a39ddc7a6eb2a204e48ab364130a5822f548

diff --git a/include/sfx2/lokhelper.hxx b/include/sfx2/lokhelper.hxx
index 24e59d097393..170d65a794d0 100644
--- a/include/sfx2/lokhelper.hxx
+++ b/include/sfx2/lokhelper.hxx
@@ -42,11 +42,11 @@ public:
     /// Same as notifyOtherViews(), but works on a selected "other" view, not on all of them.
     static void notifyOtherView(SfxViewShell* pThisView, SfxViewShell const* pOtherView, int nType, const OString& rKey, const OString& rPayload);
     /// Emits a LOK_CALLBACK_DIALOG
-    static void notifyDialog(vcl::DialogID nDialogId,
+    static void notifyDialog(vcl::LOKWindowId nDialogId,
                              const OUString& rAction,
                              const std::vector<vcl::LOKPayloadItem>& rPayload = std::vector<vcl::LOKPayloadItem>());
     /// Emits a LOK_CALLBACK_DIALOG_CHILD
-    static void notifyDialogChild(vcl::DialogID nDialogId, const OUString& rAction, const Point& rPos);
+    static void notifyDialogChild(vcl::LOKWindowId nDialogId, const OUString& rAction, const Point& rPos);
     /// Emits a LOK_CALLBACK_INVALIDATE_TILES, but tweaks it according to setOptionalFeatures() if needed.
     static void notifyInvalidation(SfxViewShell const* pThisView, const OString& rPayload);
     /// A special value to signify 'infinity'.
diff --git a/include/sfx2/viewsh.hxx b/include/sfx2/viewsh.hxx
index e6687ff7d5a7..2fcf7283399a 100644
--- a/include/sfx2/viewsh.hxx
+++ b/include/sfx2/viewsh.hxx
@@ -142,7 +142,7 @@ template<class T> bool checkSfxViewShell(const SfxViewShell* pShell)
     return dynamic_cast<const T*>(pShell) != nullptr;
 }
 
-class SFX2_DLLPUBLIC SfxViewShell: public SfxShell, public SfxListener, public OutlinerViewShell, public vcl::IDialogNotifier
+class SFX2_DLLPUBLIC SfxViewShell: public SfxShell, public SfxListener, public OutlinerViewShell, public vcl::ILibreOfficeKitNotifier
 {
 friend class SfxViewFrame;
 friend class SfxBaseController;
@@ -153,7 +153,7 @@ friend class SfxPrinterController;
     VclPtr<vcl::Window>         pWindow;
     bool                        bNoNewWindow;
     bool                        mbPrinterSettingsModified;
-    std::vector<std::pair<vcl::DialogID, VclPtr<Dialog> > > maOpenedDialogs;
+    std::vector<std::pair<vcl::LOKWindowId, VclPtr<Dialog> > > maOpenedDialogs;
 
 protected:
     virtual void                Activate(bool IsMDIActivate) override;
@@ -222,13 +222,13 @@ public:
     virtual       SfxShell*     GetFormShell()       { return nullptr; };
     virtual const SfxShell*     GetFormShell() const { return nullptr; };
 
-    void                        RegisterDlg(vcl::DialogID nDialogId, VclPtr<Dialog> pDlg);
-    VclPtr<Dialog>              GetOpenedDlg(vcl::DialogID nDialogId);
-    void                        UnregisterDlg(vcl::DialogID nDialogId);
+    void                        RegisterDlg(vcl::LOKWindowId nDialogId, VclPtr<Dialog> pDlg);
+    VclPtr<Dialog>              GetOpenedDlg(vcl::LOKWindowId nDialogId);
+    void                        UnregisterDlg(vcl::LOKWindowId nDialogId);
 
-    // IDialogNotifier
-    virtual void                notifyDialog(const vcl::DialogID& rDialogId, const OUString& rAction, const std::vector<vcl::LOKPayloadItem>& rPayload = std::vector<vcl::LOKPayloadItem>()) override;
-    virtual void                notifyDialogChild(const vcl::DialogID& rDialogId, const OUString& rAction, const Point& rPos) override;
+    // ILibreOfficeKitNotifier
+    virtual void                notifyDialog(const vcl::LOKWindowId& rDialogId, const OUString& rAction, const std::vector<vcl::LOKPayloadItem>& rPayload = std::vector<vcl::LOKPayloadItem>()) const override;
+    virtual void                notifyDialogChild(const vcl::LOKWindowId& rDialogId, const OUString& rAction, const Point& rPos) const override;
 
     // Focus, KeyInput, Cursor
     virtual void                ShowCursor( bool bOn = true );
diff --git a/include/vcl/IDialogRenderable.hxx b/include/vcl/IDialogRenderable.hxx
index f606782692e3..20515c86d2a6 100644
--- a/include/vcl/IDialogRenderable.hxx
+++ b/include/vcl/IDialogRenderable.hxx
@@ -23,41 +23,39 @@ namespace vcl
 
 typedef std::pair<const OString, const OString> LOKPayloadItem;
 
-typedef sal_uInt32 DialogID;
-
 class VCL_DLLPUBLIC IDialogRenderable
 {
 public:
     virtual ~IDialogRenderable();
 
-    virtual void paintDialog(const DialogID& rDialogID, VirtualDevice &rDevice) = 0;
+    virtual void paintDialog(const LOKWindowId& rLOKWindowId, VirtualDevice &rDevice) = 0;
 
-    virtual void getDialogInfo(const DialogID& rDialogID, OUString& rDialogTitle, int& rWidth, int& rHeight) = 0;
+    virtual void getDialogInfo(const LOKWindowId& rLOKWindowId, OUString& rDialogTitle, int& rWidth, int& rHeight) = 0;
 
-    virtual void paintActiveFloatingWindow(const DialogID& rDialogID, VirtualDevice &rDevice,
+    virtual void paintActiveFloatingWindow(const LOKWindowId& rLOKWindowId, VirtualDevice &rDevice,
                                            int& nOutputWidth, int& nOutputHeight) = 0;
 
-    virtual void postDialogKeyEvent(const DialogID& rDialogID, int nType,
+    virtual void postDialogKeyEvent(const LOKWindowId& rLOKWindowId, int nType,
                                     int nCharCode, int nKeyCode) = 0;
 
-    virtual void postDialogMouseEvent(const DialogID& rDialogID, int nType, int nX, int nY,
+    virtual void postDialogMouseEvent(const LOKWindowId& rLOKWindowId, int nType, int nX, int nY,
                                       int nCount, int nButtons, int nModifier) = 0;
 
-    virtual void postDialogChildMouseEvent(const DialogID& rDialogID, int nType, int nX, int nY,

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list