[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.3' - 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
Tue Nov 28 20:26:58 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                                   |   40 --
 include/vcl/dialog.hxx                                              |   20 -
 include/vcl/window.hxx                                              |   30 +
 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                                       |   27 +
 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                                      |    8 
 vcl/source/window/paint.cxx                                         |   16 
 vcl/source/window/window.cxx                                        |  172 ++++++++
 vcl/source/window/winproc.cxx                                       |    4 
 34 files changed, 618 insertions(+), 695 deletions(-)

New commits:
commit b97fa81cac972c729cd843a689fb76342b4ac19d
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 4810f9b59039..307418fcd55c 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -2267,7 +2267,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;
 
@@ -2445,7 +2445,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;
 
@@ -2476,7 +2476,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;
 
@@ -3283,7 +3283,7 @@ unsigned char* doc_renderFont(LibreOfficeKitDocument* /*pThis*/,
     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)
@@ -3311,7 +3311,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 880239709c1fcf24e96c4e7b3989e7b8b321c052
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 8d61d405f501..4810f9b59039 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -635,9 +635,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)
@@ -690,7 +687,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;
@@ -3287,35 +3283,6 @@ unsigned char* doc_renderFont(LibreOfficeKitDocument* /*pThis*/,
     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 4bd48c9b1756..355c44579933 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -262,11 +262,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 dc623261036a..08fbcf857abc 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ b/include/LibreOfficeKit/LibreOfficeKit.hxx
@@ -177,23 +177,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 d95e417d89c6..8d757b4dde45 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 904662bbf718..cb46e777d598 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 f2fad6dcc1404e8358e348a91a06f5c7e9369384
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 685cbe4a4a73..d39c3ac2cacb 100644
--- a/sfx2/source/view/lokhelper.cxx
+++ b/sfx2/source/view/lokhelper.cxx
@@ -139,7 +139,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("\"");
 
@@ -153,11 +153,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)
@@ -165,17 +162,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* pThisView, const OString& rPayload)
commit 5535ccc828e6159e5627ac016fc11b5588923264
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 bbc8972b00e2..bf975b465cbb 100644
--- a/vcl/source/window/dialog.cxx
+++ b/vcl/source/window/dialog.cxx
@@ -1235,9 +1235,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 OString &rValue)
commit 6c19b9710ad274369bf3793367b038de9edb1feb
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 116ec1406f7a..bbc8972b00e2 100644
--- a/vcl/source/window/dialog.cxx
+++ b/vcl/source/window/dialog.cxx
@@ -59,6 +59,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 2175822e925a8dba87f39dcf83b17348fba855f5
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 9e50f32cbe0f..116ec1406f7a 100644
--- a/vcl/source/window/dialog.cxx
+++ b/vcl/source/window/dialog.cxx
@@ -785,7 +785,7 @@ bool Dialog::ImplStartExecuteModal()
     case Application::DialogCancelMode::Off:
         break;
     case Application::DialogCancelMode::Silent:
-        if (ImplGetDialogText(this) == "Character")
+        if (GetLOKNotifier())
             break;
 
         SAL_INFO(
commit eba961f518774d467b03c5a77828a2a7c21b42ed
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 2770575a9e0d..8d61d405f501 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -1342,16 +1342,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 ...
@@ -2285,7 +2275,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.";
@@ -2463,7 +2453,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.";
@@ -2494,7 +2484,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.";
@@ -3305,7 +3295,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.";
@@ -3333,7 +3323,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.";
@@ -3358,7 +3348,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 e37c5137e381..5bfea3a81dcf 100644
--- a/include/sfx2/viewsh.hxx
+++ b/include/sfx2/viewsh.hxx
@@ -157,7 +157,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;
@@ -227,10 +226,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 b57ed35ae7e9..ae3ba9e76c3c 100644
--- a/include/vcl/ITiledRenderable.hxx
+++ b/include/vcl/ITiledRenderable.hxx
@@ -241,12 +241,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 f4e154816f3d..fa75822c563e 100644
--- a/include/vcl/window.hxx
+++ b/include/vcl/window.hxx
@@ -1209,6 +1209,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 6bc2c5da7ae8..917b211a82a1 100644
--- a/sc/inc/docuno.hxx
+++ b/sc/inc/docuno.hxx
@@ -432,9 +432,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 629c203399ad..473a8dcb17ac 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 ee1cb5687dd1..087fa521ca9e 100644
--- a/sd/source/ui/inc/unomodel.hxx
+++ b/sd/source/ui/inc/unomodel.hxx
@@ -268,9 +268,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 c902e2dc5104..6b852e2cb5bb 100644
--- a/sd/source/ui/unoidl/unomodel.cxx
+++ b/sd/source/ui/unoidl/unomodel.cxx
@@ -2705,12 +2705,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(mxForbidenCharacters);
diff --git a/sfx2/source/dialog/basedlgs.cxx b/sfx2/source/dialog/basedlgs.cxx
index e1afc854afd5..ce028f908472 100644
--- a/sfx2/source/dialog/basedlgs.cxx
+++ b/sfx2/source/dialog/basedlgs.cxx
@@ -171,7 +171,7 @@ void SfxModalDialog::dispose()
     if (comphelper::LibreOfficeKit::isActive() && pViewShell)
     {
         pViewShell->notifyWindow(GetLOKWindowId(), "close");
-        pViewShell->UnregisterDlg(GetLOKWindowId());
+        ReleaseLOKNotifier();
     }
 
     ModalDialog::dispose();
@@ -183,7 +183,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()));
@@ -255,7 +254,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();
@@ -398,7 +396,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 64bbc97727f9..23113c7836ea 100644
--- a/sfx2/source/dialog/tabdlg.cxx
+++ b/sfx2/source/dialog/tabdlg.cxx
@@ -409,7 +409,7 @@ void SfxTabDialog::dispose()
     if (comphelper::LibreOfficeKit::isActive() && pViewShell)
     {
         pViewShell->notifyWindow(GetLOKWindowId(), "close");
-        pViewShell->UnregisterDlg(GetLOKWindowId());
+        ReleaseLOKNotifier();
     }
 
     TabDialog::dispose();
@@ -524,7 +524,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 36229bd51ef4..78c43ed863f2 100644
--- a/sfx2/source/view/viewsh.cxx
+++ b/sfx2/source/view/viewsh.cxx
@@ -2046,37 +2046,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 f8865610db15..1de906c338b5 100644
--- a/sw/inc/unotxdoc.hxx
+++ b/sw/inc/unotxdoc.hxx
@@ -450,9 +450,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 ) throw (::css::uno::RuntimeException, std::exception) override;
 
diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx
index f92e720a34e8..4390c78a9111 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -3711,12 +3711,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 4f247162bcef..faf9e5162794 100644
--- a/vcl/inc/window.h
+++ b/vcl/inc/window.h
@@ -354,7 +354,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 b0d87fdef301..3a8444f80c59 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -85,6 +85,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 ))
 {
@@ -598,8 +604,6 @@ Window::~Window()
 
 } /* namespace vcl */
 
-vcl::LOKWindowId WindowImpl::mnLastWindowId = 1;
-
 WindowImpl::WindowImpl( WindowType nType )
 {
     maZoom                              = Fraction( 1, 1 );
@@ -3198,11 +3202,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 57c0ccf77627b485e8ed05cad295c4eef5eb16e4
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 73a68d657254..8f01f32cec3f 100644
--- a/include/vcl/dialog.hxx
+++ b/include/vcl/dialog.hxx
@@ -65,7 +65,6 @@ protected:
 public:
     SAL_DLLPRIVATE bool    IsInClose() const { return mbInClose; }
     virtual        void    doDeferredInit(WinBits nBits) override;
-    virtual        void    LogicInvalidate(const Rectangle* pRectangle) override;
                    void    InvalidateFloatingWindow(const Point& rPos);
                    void    CloseFloatingWindow();
 
diff --git a/include/vcl/window.hxx b/include/vcl/window.hxx
index d424f6fd14ab..f4e154816f3d 100644
--- a/include/vcl/window.hxx
+++ b/include/vcl/window.hxx
@@ -1066,6 +1066,7 @@ public:
     virtual void                        Invalidate( InvalidateFlags nFlags = InvalidateFlags::NONE );
     virtual void                        Invalidate( const Rectangle& rRect, InvalidateFlags nFlags = InvalidateFlags::NONE );
     virtual void                        Invalidate( const vcl::Region& rRegion, InvalidateFlags nFlags = InvalidateFlags::NONE );
+    virtual void                        LogicInvalidate(const 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 c1265b69e1b9..9e50f32cbe0f 100644
--- a/vcl/source/window/dialog.cxx
+++ b/vcl/source/window/dialog.cxx
@@ -896,21 +896,6 @@ void Dialog::CloseFloatingWindow()
         pNotifier->notifyWindowChild(GetLOKWindowId(), "close", Point(0, 0));
 }
 
-void Dialog::LogicInvalidate(const 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 7639a0ee8115..fcfbc4bf905c 100644
--- a/vcl/source/window/paint.cxx
+++ b/vcl/source/window/paint.cxx
@@ -1212,6 +1212,22 @@ void Window::Invalidate( const vcl::Region& rRegion, InvalidateFlags nFlags )
     }
 }
 
+void Window::LogicInvalidate(const 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 80d9696eb76e69101996c7a35ffec4c247e079d8
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 1596c7788ec8..2770575a9e0d 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -564,7 +564,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);
@@ -576,7 +576,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,
@@ -584,7 +584,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,
@@ -631,14 +631,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)
@@ -1049,7 +1049,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", "");
@@ -1057,7 +1057,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;
@@ -1065,7 +1065,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;
                                     }
@@ -1078,7 +1078,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;
@@ -1088,7 +1088,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;
@@ -1109,7 +1109,7 @@ void CallbackFlushHandler::queue(const int type, const char* data)
                         aRectStream >> nLeft >> nComma >> nTop >> nComma >> nWidth >> nComma >> nHeight;
                         Rectangle aNewRect = 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;
 
@@ -1129,7 +1129,7 @@ void CallbackFlushHandler::queue(const int type, const char* data)
                                     aOldRectStream >> nOldLeft >> nOldComma >> nOldTop >> nOldComma >> nOldWidth >> nOldComma >> nOldHeight;
                                     Rectangle aOldRect = Rectangle(nOldLeft, nOldTop, nOldLeft + nOldWidth, nOldTop + nOldHeight);
 
-                                    if (nDialogId == nOldDialogId)
+                                    if (nLOKWindowId == nOldDialogId)
                                     {
                                         // new one engulfs the old one?
                                         if (aNewRect.IsInside(aOldRect))
@@ -1342,10 +1342,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
@@ -2277,18 +2281,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.
@@ -2442,32 +2459,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)
@@ -3246,14 +3297,25 @@ unsigned char* doc_renderFont(LibreOfficeKitDocument* /*pThis*/,
     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())
@@ -3264,14 +3326,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)));
@@ -3283,15 +3350,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)));
@@ -3299,7 +3371,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 c199a5287b5c..810d537c1bed 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* 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* pThisView, const OString& rPayload);
     /// A special value to signify 'infinity'.
diff --git a/include/sfx2/viewsh.hxx b/include/sfx2/viewsh.hxx
index 7602da3f5d25..e37c5137e381 100644
--- a/include/sfx2/viewsh.hxx
+++ b/include/sfx2/viewsh.hxx
@@ -232,8 +232,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 db3831ccd5c6..281d04385aee 100644
--- a/include/vcl/IDialogRenderable.hxx
+++ b/include/vcl/IDialogRenderable.hxx
@@ -11,53 +11,31 @@
 #ifndef INCLUDED_VCL_IDIALOGRENDERABLE_HXX
 #define INCLUDED_VCL_IDIALOGRENDERABLE_HXX
 
-#include <tools/gen.hxx>
-#include <vcl/pointr.hxx>
-#include <vcl/virdev.hxx>
-#include <vcl/window.hxx>
+#include <vcl/dllapi.h>
 
-#include "IDialogRenderable.hxx"
+#include <tools/gen.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 ae3ba9e76c3c..b57ed35ae7e9 100644
--- a/include/vcl/ITiledRenderable.hxx
+++ b/include/vcl/ITiledRenderable.hxx
@@ -241,6 +241,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 76952b2f3cc5..73a68d657254 100644
--- a/include/vcl/dialog.hxx
+++ b/include/vcl/dialog.hxx
@@ -68,20 +68,9 @@ public:
     virtual        void    LogicInvalidate(const Rectangle* pRectangle) override;
                    void    InvalidateFloatingWindow(const Point& rPos);
                    void    CloseFloatingWindow();
-                   Size    PaintActiveFloatingWindow(VirtualDevice& rDevice);
 
     /// 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 08faef8e8519..d424f6fd14ab 100644
--- a/include/vcl/window.hxx
+++ b/include/vcl/window.hxx
@@ -34,6 +34,8 @@
 #include <vcl/region.hxx>
 #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>
@@ -485,8 +487,6 @@ public:
                                         Color* pPaintColor = nullptr);
 };
 
-typedef sal_uInt32 LOKWindowId;
-
 class VCL_DLLPUBLIC Window : public ::OutputDevice, public Resource
 {
     friend class ::vcl::Cursor;
@@ -1203,11 +1203,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 917b211a82a1..6bc2c5da7ae8 100644
--- a/sc/inc/docuno.hxx
+++ b/sc/inc/docuno.hxx
@@ -432,6 +432,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 473a8dcb17ac..629c203399ad 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 087fa521ca9e..ee1cb5687dd1 100644
--- a/sd/source/ui/inc/unomodel.hxx
+++ b/sd/source/ui/inc/unomodel.hxx
@@ -268,6 +268,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 6b852e2cb5bb..c902e2dc5104 100644
--- a/sd/source/ui/unoidl/unomodel.cxx
+++ b/sd/source/ui/unoidl/unomodel.cxx
@@ -2705,6 +2705,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(mxForbidenCharacters);
diff --git a/sfx2/source/dialog/basedlgs.cxx b/sfx2/source/dialog/basedlgs.cxx
index 8d2c789b9f0f..e1afc854afd5 100644
--- a/sfx2/source/dialog/basedlgs.cxx
+++ b/sfx2/source/dialog/basedlgs.cxx
@@ -170,7 +170,7 @@ void SfxModalDialog::dispose()
     SfxViewShell* pViewShell = SfxViewShell::Current();
     if (comphelper::LibreOfficeKit::isActive() && pViewShell)
     {
-        pViewShell->notifyDialog(GetLOKWindowId(), "close");
+        pViewShell->notifyWindow(GetLOKWindowId(), "close");
         pViewShell->UnregisterDlg(GetLOKWindowId());
     }
 
@@ -187,7 +187,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();
@@ -261,7 +261,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;
@@ -397,7 +397,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 0fc93ed11812..64bbc97727f9 100644
--- a/sfx2/source/dialog/tabdlg.cxx
+++ b/sfx2/source/dialog/tabdlg.cxx
@@ -408,7 +408,7 @@ void SfxTabDialog::dispose()
     SfxViewShell* pViewShell = SfxViewShell::Current();
     if (comphelper::LibreOfficeKit::isActive() && pViewShell)
     {
-        pViewShell->notifyDialog(GetLOKWindowId(), "close");
+        pViewShell->notifyWindow(GetLOKWindowId(), "close");
         pViewShell->UnregisterDlg(GetLOKWindowId());
     }
 
@@ -528,7 +528,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 da6cd4ac16ee..685cbe4a4a73 100644
--- a/sfx2/source/view/lokhelper.cxx
+++ b/sfx2/source/view/lokhelper.cxx
@@ -132,7 +132,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)
 {
@@ -160,7 +160,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 46412c9db379..36229bd51ef4 100644
--- a/sfx2/source/view/viewsh.cxx
+++ b/sfx2/source/view/viewsh.cxx
@@ -2036,14 +2036,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 e16dc50f43f4..f8865610db15 100644
--- a/sw/inc/unotxdoc.hxx
+++ b/sw/inc/unotxdoc.hxx
@@ -69,7 +69,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>
@@ -131,7 +130,6 @@ class SW_DLLPUBLIC SwXTextDocument : public SwXTextDocumentBaseClass,
     public SvxFmMSFactory,
     public SfxBaseModel,
     public vcl::ITiledRenderable,
-    public vcl::IDialogRenderable,
     public css::tiledrendering::XTiledRenderable
 {
 private:
@@ -452,17 +450,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 ) throw (::css::uno::RuntimeException, std::exception) override;
diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx
index be7df40f4619..f92e720a34e8 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -3711,123 +3711,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 701eb5c78abe..61e854a674b6 100644
--- a/vcl/Library_vcl.mk
+++ b/vcl/Library_vcl.mk
@@ -341,7 +341,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 6eab80b0c2f6..c1265b69e1b9 100644
--- a/vcl/source/window/dialog.cxx
+++ b/vcl/source/window/dialog.cxx
@@ -884,75 +884,16 @@ void Dialog::paintDialog(VirtualDevice& rDevice)
     PaintToDevice(&rDevice, Point(0, 0), Size());
 }
 
-Size Dialog::PaintActiveFloatingWindow(VirtualDevice& rDevice)
-{
-    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 Rectangle* pRectangle)
@@ -966,59 +907,10 @@ void Dialog::LogicInvalidate(const 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
@@ -1350,7 +1242,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 OString &rValue)
diff --git a/vcl/source/window/floatwin.cxx b/vcl/source/window/floatwin.cxx
index 9ce9cd378b59..6a3385360ed7 100644
--- a/vcl/source/window/floatwin.cxx
+++ b/vcl/source/window/floatwin.cxx
@@ -734,7 +734,7 @@ void FloatingWindow::StartPopupMode( const Rectangle& rRect, FloatWinPopupFlags
     {
         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 7ba762908114..b0d87fdef301 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -65,6 +65,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>
 
@@ -3214,6 +3215,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 42777e61a4060b7b78795a5bb89e3155327a2555
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 8bd02f13ced5..8d2c789b9f0f 100644
--- a/sfx2/source/dialog/basedlgs.cxx
+++ b/sfx2/source/dialog/basedlgs.cxx
@@ -182,8 +182,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()));
@@ -254,8 +254,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 54a4088313c6..0fc93ed11812 100644
--- a/sfx2/source/dialog/tabdlg.cxx
+++ b/sfx2/source/dialog/tabdlg.cxx
@@ -523,8 +523,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 d3ad60417d87..7ba762908114 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -749,7 +749,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()
@@ -3192,6 +3192,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;
 }
 
@@ -3202,6 +3209,8 @@ const vcl::ILibreOfficeKitNotifier* Window::GetLOKNotifier() const
 
 vcl::LOKWindowId Window::GetLOKWindowId() const
 {
+    assert(mpWindowImpl->mnLOKWindowId > 0);
+
     return mpWindowImpl->mnLOKWindowId;
 }
 
commit 474e534738ae147eec450dfbca5e1ddbc86069cb
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 243e2ea62ea7..4a716cf536fb 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -681,6 +681,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 995183ebd5d0..9ce9cd378b59 100644
--- a/vcl/source/window/floatwin.cxx
+++ b/vcl/source/window/floatwin.cxx
@@ -729,6 +729,13 @@ void FloatingWindow::StartPopupMode( const Rectangle& rRect, FloatWinPopupFlags
         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 9df590be66324884e3e0e4eb9b255cd35103b06b
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 ce0a69b75e6f..c199a5287b5c 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* 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* pThisView, const OString& rPayload);
     /// A special value to signify 'infinity'.
diff --git a/include/sfx2/viewsh.hxx b/include/sfx2/viewsh.hxx
index 0db8fb3aec82..7602da3f5d25 100644
--- a/include/sfx2/viewsh.hxx
+++ b/include/sfx2/viewsh.hxx
@@ -143,7 +143,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
 {
 #ifdef INCLUDED_SFX2_VIEWSH_HXX
 friend class SfxViewFrame;
@@ -157,7 +157,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;
@@ -227,13 +227,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 ccb99cb0adb2..db3831ccd5c6 100644
--- a/include/vcl/IDialogRenderable.hxx
+++ b/include/vcl/IDialogRenderable.hxx
@@ -25,41 +25,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