[Libreoffice-commits] core.git: Branch 'feature/lok_dialog' - 10 commits - desktop/source include/LibreOfficeKit include/sfx2 include/tools include/vcl libreofficekit/qa sfx2/source sw/inc sw/source tools/source vcl/source

Pranav Kant pranavk at collabora.co.uk
Fri Nov 24 10:04:46 UTC 2017


Rebased ref, commits from common ancestor:
commit a60bd16596f95451ba22c9f261668c2bf7038938
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Fri Nov 24 02:27:49 2017 +0530

    lokdialog: Pull the plug; set headless mode to off
    
    Hope is that it only turns the DialogCancelMode to off and do not have
    any repurcussions on how LOK clients like Online behave.
    
    Change-Id: I378496b48dbf0dd2c7a3664c1d1c76dfb3a8b1cd

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 3d7ca4cf195d..c5b7bd342d6f 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -3573,11 +3573,6 @@ static int lo_initialize(LibreOfficeKit* pThis, const char* pAppPath, const char
             // Force headless -- this is only for bitmap rendering.
             rtl::Bootstrap::set("SAL_USE_VCLPLUGIN", "svp");
 
-            // We specifically need to make sure we have the "headless"
-            // command arg set (various code specifically checks via
-            // CommandLineArgs):
-            desktop::Desktop::GetCommandLineArgs().setHeadless();
-
 #ifdef IOS
             // mpDefInst need to be initialized, which only happens in InitVCL(),
             // there might be more elegant ways to get InitVCL() called, but
diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx
index 7a995adf107a..017a0015fee1 100644
--- a/vcl/source/window/dialog.cxx
+++ b/vcl/source/window/dialog.cxx
@@ -787,9 +787,6 @@ bool Dialog::ImplStartExecuteModal()
     case Application::DialogCancelMode::Off:
         break;
     case Application::DialogCancelMode::Silent:
-        if (ImplGetDialogText(this) == "Character")
-            break;
-
         SAL_INFO(
             "vcl",
             "Dialog \"" << ImplGetDialogText(this)
commit 1413a13fd3dc0c61710c1b7dd13439c869cb1852
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Fri Nov 24 02:27:09 2017 +0530

    lokdialog: Let all modal dialogs notify about creation, disposal
    
    Change-Id: I8ec0ad81abcf1adf628906b02f7f94ab74a550b5

diff --git a/include/sfx2/basedlgs.hxx b/include/sfx2/basedlgs.hxx
index cb403c78a075..6fdb41784ade 100644
--- a/include/sfx2/basedlgs.hxx
+++ b/include/sfx2/basedlgs.hxx
@@ -71,6 +71,8 @@ protected:
 public:
     virtual ~SfxModalDialog() override;
     virtual void dispose() override;
+
+    virtual short       Execute() override;
     const SfxItemSet*   GetOutputItemSet() const { return pOutputSet; }
     const SfxItemSet*   GetInputItemSet() const { return pInputSet; }
 };
diff --git a/sfx2/source/dialog/basedlgs.cxx b/sfx2/source/dialog/basedlgs.cxx
index 7877e878e129..73a110038d95 100644
--- a/sfx2/source/dialog/basedlgs.cxx
+++ b/sfx2/source/dialog/basedlgs.cxx
@@ -160,9 +160,33 @@ void SfxModalDialog::dispose()
 {
     SetDialogData_Impl();
     delete pOutputSet;
+
+    SfxViewShell* pViewShell = SfxViewShell::Current();
+    if (comphelper::LibreOfficeKit::isActive() && pViewShell)
+    {
+        pViewShell->notifyDialog(maID, "close");
+        pViewShell->UnregisterDlg(maID);
+    }
+
     ModalDialog::dispose();
 }
 
+short SfxModalDialog::Execute()
+{
+    SfxViewShell* pViewShell = SfxViewShell::Current();
+    if (comphelper::LibreOfficeKit::isActive() && pViewShell)
+    {
+        pViewShell->RegisterDlg(maID, this);
+        registerDialogNotifier(static_cast<vcl::IDialogNotifier*>(pViewShell));
+        const Size aSize = GetOptimalSize();
+        std::vector<vcl::LOKPayloadItem> aItems;
+        aItems.emplace_back(std::make_pair("size", aSize.toString()));
+        pViewShell->notifyDialog(maID, "created", aItems);
+    }
+
+    return ModalDialog::Execute();
+}
+
 void SfxModalDialog::CreateOutputItemSet( SfxItemPool& rPool )
 {
     DBG_ASSERT( !pOutputSet, "Double creation of OutputSet!" );
commit 79a9f8b2e5a6d3edabc7ba7fd2a691297d7fd11f
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Fri Nov 24 01:56:25 2017 +0530

    lokdialog: Notify to child helper method, not the main one
    
    Change-Id: I0698bfe578cb122dfabed566cb7a096f3cb56af5

diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx
index 92dcfa48cdcf..986a640d1625 100644
--- a/sfx2/source/view/viewsh.cxx
+++ b/sfx2/source/view/viewsh.cxx
@@ -1955,7 +1955,7 @@ void SfxViewShell::notifyDialog(const vcl::DialogID& rDialogId, const OUString&
 
 void SfxViewShell::notifyDialogChild(const vcl::DialogID& rDialogId, const OUString& rAction, const Point& rPos)
 {
-    SfxLokHelper::notifyDialog(rDialogId, rAction);
+    SfxLokHelper::notifyDialogChild(rDialogId, rAction, rPos);
 }
 
 void SfxViewShell::RegisterDlg(vcl::DialogID nDialogId, VclPtr<Dialog> pDlg)
commit 389d224fb0ef6fce608c63883746249fa8126853
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Fri Nov 24 01:49:21 2017 +0530

    lokdialog: Let modeless dialogs emit "created" callback too
    
    Change-Id: Ie81f8bd19696e6f0abceb86369545766918ae46a

diff --git a/sfx2/source/dialog/basedlgs.cxx b/sfx2/source/dialog/basedlgs.cxx
index 539f369534ac..7877e878e129 100644
--- a/sfx2/source/dialog/basedlgs.cxx
+++ b/sfx2/source/dialog/basedlgs.cxx
@@ -221,6 +221,19 @@ void SfxModelessDialog::StateChanged( StateChangedType nStateChange )
             }
         }
 
+        SfxViewShell* pViewShell = SfxViewShell::Current();
+        if (comphelper::LibreOfficeKit::isActive() && pViewShell)
+        {
+            pViewShell->RegisterDlg(maID, this);
+            registerDialogNotifier(static_cast<vcl::IDialogNotifier*>(pViewShell));
+            // Below method doesn't really give the exact dimensions,
+            // Check GetSizePixel() ?
+            const Size aOptimalSize = GetOptimalSize();
+            std::vector<vcl::LOKPayloadItem> aItems;
+            aItems.emplace_back(std::make_pair("size", aOptimalSize.toString()));
+            pViewShell->notifyDialog(maID, "created", aItems);
+        }
+
         pImpl->bConstructed = true;
     }
 
@@ -352,6 +365,14 @@ void SfxModelessDialog::dispose()
     if ( pImpl->pMgr->GetFrame().is() && pImpl->pMgr->GetFrame() == pBindings->GetActiveFrame() )
         pBindings->SetActiveFrame( nullptr );
     pImpl.reset();
+
+    SfxViewShell* pViewShell = SfxViewShell::Current();
+    if (comphelper::LibreOfficeKit::isActive() && pViewShell)
+    {
+        pViewShell->notifyDialog(maID, "close");
+        pViewShell->UnregisterDlg(maID);
+    }
+
     ModelessDialog::dispose();
 }
 
commit 5e8c4d90db79ba9cccc27f1b83528a43eda5a3b4
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Fri Nov 24 01:40:38 2017 +0530

    lokdialog: Notify dialog closure from sfx2/, instead of vcl/
    
    Change-Id: I49f5e0d5f6c7c0077a6d4390f8788c1691d47bd6

diff --git a/sfx2/source/dialog/tabdlg.cxx b/sfx2/source/dialog/tabdlg.cxx
index 3a4b64335139..17f64d51a063 100644
--- a/sfx2/source/dialog/tabdlg.cxx
+++ b/sfx2/source/dialog/tabdlg.cxx
@@ -21,12 +21,9 @@
 #include <limits.h>
 #include <stdlib.h>
 #include <algorithm>
-#include <vcl/builder.hxx>
-#include <vcl/msgbox.hxx>
-#include <vcl/IDialogRenderable.hxx>
-#include <unotools/viewoptions.hxx>
 
 #include <appdata.hxx>
+#include <comphelper/lok.hxx>
 #include <sfxtypes.hxx>
 #include <sfx2/tabdlg.hxx>
 #include <sfx2/viewfrm.hxx>
@@ -38,8 +35,11 @@
 #include <sfx2/sfxdlg.hxx>
 #include <sfx2/itemconnect.hxx>
 #include <sfx2/viewsh.hxx>
-
 #include <uitest/sfx_uiobject.hxx>
+#include <unotools/viewoptions.hxx>
+#include <vcl/builder.hxx>
+#include <vcl/msgbox.hxx>
+#include <vcl/IDialogRenderable.hxx>
 
 #include <sfx2/strings.hrc>
 #include <helpids.h>
@@ -403,6 +403,13 @@ void SfxTabDialog::dispose()
     m_pBaseFmtBtn.clear();
     m_pActionArea.clear();
 
+    SfxViewShell* pViewShell = SfxViewShell::Current();
+    if (comphelper::LibreOfficeKit::isActive() && pViewShell)
+    {
+        pViewShell->notifyDialog(maID, "close");
+        pViewShell->UnregisterDlg(maID);
+    }
+
     TabDialog::dispose();
 }
 
@@ -512,7 +519,7 @@ short SfxTabDialog::Execute()
     Start_Impl();
 
     SfxViewShell* pViewShell = SfxViewShell::Current();
-    if (pViewShell)
+    if (comphelper::LibreOfficeKit::isActive() && pViewShell)
     {
         pViewShell->RegisterDlg(maID, this);
         registerDialogNotifier(static_cast<vcl::IDialogNotifier*>(pViewShell));
diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx
index 5b08a53d298d..7a995adf107a 100644
--- a/vcl/source/window/dialog.cxx
+++ b/vcl/source/window/dialog.cxx
@@ -597,11 +597,6 @@ void Dialog::dispose()
     xEventBroadcaster->documentEventOccured(aObject);
     UITestLogger::getInstance().log("DialogClosed");
 
-    if (comphelper::LibreOfficeKit::isActive() && mpDialogNotifier)
-    {
-        mpDialogNotifier->notifyDialog(maID, "close");
-    }
-
     SystemWindow::dispose();
 }
 
commit 68d88bb35391bd6e020aa135b2133a4902144f55
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Fri Nov 24 01:40:13 2017 +0530

    gtv: Kill dialog selector combo box
    
    Change-Id: I2cd27dff95f2bc49a15ab395b8282b5496e1e229

diff --git a/libreofficekit/qa/gtktiledviewer/gtv-main-toolbar.cxx b/libreofficekit/qa/gtktiledviewer/gtv-main-toolbar.cxx
index 33e454808ed2..d973d32551d6 100644
--- a/libreofficekit/qa/gtktiledviewer/gtv-main-toolbar.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtv-main-toolbar.cxx
@@ -35,7 +35,6 @@ struct GtvMainToolbarPrivateImpl
     GtkWidget* m_pDeleteComment;
     GtkWidget* m_pPartSelector;
     GtkWidget* m_pPartModeSelector;
-    GtkWidget* m_pDialogSelector;
 
     /// Sensitivity (enabled or disabled) for each tool item, ignoring edit state
     std::map<GtkToolItem*, bool> m_aToolItemSensitivities;
@@ -50,8 +49,7 @@ struct GtvMainToolbarPrivateImpl
         m_pJustifypara(nullptr),
         m_pDeleteComment(nullptr),
         m_pPartSelector(nullptr),
-        m_pPartModeSelector(nullptr),
-        m_pDialogSelector(nullptr)
+        m_pPartModeSelector(nullptr)
         { }
 };
 
@@ -98,7 +96,6 @@ gtv_main_toolbar_init(GtvMainToolbar* toolbar)
     priv->m_pDeleteComment = GTK_WIDGET(gtk_builder_get_object(builder.get(), "btn_removeannotation"));
     priv->m_pPartSelector = GTK_WIDGET(gtk_builder_get_object(builder.get(), "combo_partselector"));
     priv->m_pPartModeSelector = GTK_WIDGET(gtk_builder_get_object(builder.get(), "combo_partsmodeselector"));
-    priv->m_pDialogSelector = GTK_WIDGET(gtk_builder_get_object(builder.get(), "combo_dialogselector"));
 
     toolbar->m_pAddressbar = GTK_WIDGET(gtk_builder_get_object(builder.get(), "addressbar_entry"));
     toolbar->m_pFormulabar = GTK_WIDGET(gtk_builder_get_object(builder.get(), "formulabar_entry"));
@@ -181,22 +178,6 @@ static void populatePartSelector(GtvMainToolbar* toolbar)
     gtv_application_window_set_part_broadcast(window, true);
 }
 
-static void populateDialogSelector(GtvMainToolbar* toolbar)
-{
-    GtvMainToolbarPrivate& priv = getPrivate(toolbar);
-
-    GtkComboBoxText* pSelector = GTK_COMBO_BOX_TEXT(priv->m_pDialogSelector);
-    gtk_combo_box_text_append_text( pSelector, ".uno:SearchDialog" );
-    gtk_combo_box_text_append_text( pSelector, ".uno:AcceptTrackedChanges" );
-    gtk_combo_box_text_append_text( pSelector, ".uno:SpellingAndGrammarDialog" );
-    gtk_combo_box_text_append_text( pSelector, ".uno:InsertField" );
-    gtk_combo_box_text_append_text( pSelector, ".uno:ImageMapDialog" );
-    gtk_combo_box_text_append_text( pSelector, ".uno:WordCountDialog" );
-    gtk_combo_box_text_append_text( pSelector, ".uno:HyperlinkDialog" );
-    gtk_combo_box_text_append_text( pSelector, ".uno:InsertIndexesEntry" );
-    gtk_combo_box_text_append_text( pSelector, ".uno:InsertAuthoritiesEntry");
-}
-
 void
 gtv_main_toolbar_doc_loaded(GtvMainToolbar* toolbar, LibreOfficeKitDocumentType eDocType, bool bEditMode)
 {
@@ -223,8 +204,6 @@ gtv_main_toolbar_doc_loaded(GtvMainToolbar* toolbar, LibreOfficeKitDocumentType
 
     // populate combo boxes
     populatePartSelector(toolbar);
-    // populate dialogs
-    populateDialogSelector(toolbar);
 }
 
 GtkContainer*
diff --git a/libreofficekit/qa/gtktiledviewer/gtv.ui b/libreofficekit/qa/gtktiledviewer/gtv.ui
index c8699b33cd5e..966c97e46967 100644
--- a/libreofficekit/qa/gtktiledviewer/gtv.ui
+++ b/libreofficekit/qa/gtktiledviewer/gtv.ui
@@ -445,22 +445,6 @@
       </packing>
     </child>
     <child>
-      <object class="GtkToolItem" id="dialogselectortoolitem">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <child>
-          <object class="GtkComboBoxText" id="combo_dialogselector">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-          </object>
-        </child>
-      </object>
-      <packing>
-        <property name="expand">False</property>
-        <property name="homogeneous">True</property>
-      </packing>
-    </child>
-    <child>
       <object class="GtkToggleToolButton" id="btn_editmode">
         <property name="visible">True</property>
         <property name="can_focus">False</property>
commit 39ec0327fa2fd0489c417b1e7ae4d2013935aae2
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Fri Nov 24 01:20:56 2017 +0530

    lokdialog: Make vcl::DialogID an integer
    
    This will help launching multiple instances of dialog from multiple
    views. The earlier approach of using the UNO command strings as dialog
    id would not have been useful for multi-view case.
    
    Change-Id: I01cfb3c8b204d5654df2417efdac6b50dc920f0e

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 42e78e8bec96..3d7ca4cf195d 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -543,7 +543,7 @@ static void doc_postKeyEvent(LibreOfficeKitDocument* pThis,
                              int nCharCode,
                              int nKeyCode);
 static void doc_postDialogKeyEvent(LibreOfficeKitDocument* pThis,
-                                   const char* pDialogId,
+                                   unsigned nDialogId,
                                    int nType,
                                    int nCharCode,
                                    int nKeyCode);
@@ -555,7 +555,7 @@ static void doc_postMouseEvent (LibreOfficeKitDocument* pThis,
                                 int nButtons,
                                 int nModifier);
 static void doc_postDialogMouseEvent (LibreOfficeKitDocument* pThis,
-                                      const char* pDialogId,
+                                      unsigned nDialogId,
                                       int nType,
                                       int nX,
                                       int nY,
@@ -563,7 +563,7 @@ static void doc_postDialogMouseEvent (LibreOfficeKitDocument* pThis,
                                       int nButtons,
                                       int nModifier);
 static void doc_postDialogChildMouseEvent (LibreOfficeKitDocument* pThis,
-                                           const char* pDialogId,
+                                           unsigned nDialogId,
                                            int nType,
                                            int nX,
                                            int nY,
@@ -610,14 +610,14 @@ static unsigned char* doc_renderFont(LibreOfficeKitDocument* pThis,
                           int* pFontHeight);
 static char* doc_getPartHash(LibreOfficeKitDocument* pThis, int nPart);
 
-static void doc_paintDialog(LibreOfficeKitDocument* pThis, const char* pDialogId, unsigned char* pBuffer,
+static void doc_paintDialog(LibreOfficeKitDocument* pThis, unsigned nDialogId, unsigned char* pBuffer,
                             const int nX, const int nY,
                             const int nWidth, const int nHeight);
 
-static void doc_getDialogInfo(LibreOfficeKitDocument* pThis, const char* pDialogId,
+static void doc_getDialogInfo(LibreOfficeKitDocument* pThis, unsigned nDialogId,
                               char** pDialogTitle, int* nWidth, int* nHeight);
 
-static void doc_paintActiveFloatingWindow(LibreOfficeKitDocument* pThis, const char* pDialogId, unsigned char* pBuffer, int* nWidth, int* nHeight);
+static void doc_paintActiveFloatingWindow(LibreOfficeKitDocument* pThis, unsigned nDialogId, unsigned char* pBuffer, int* nWidth, int* nHeight);
 
 LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XComponent> &xComponent)
     : mxComponent(xComponent)
@@ -1028,7 +1028,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 std::string aDialogId = aTree.get<std::string>("dialogId", "");
+                const unsigned nDialogId = aTree.get<unsigned>("dialogId", 0);
                 if (aTree.get<std::string>("action", "") == "invalidate")
                 {
                     std::string aRectStr = aTree.get<std::string>("rectangle", "");
@@ -1036,15 +1036,15 @@ void CallbackFlushHandler::queue(const int type, const char* data)
                     // remove all previous dialog part invalidations
                     if (aRectStr.empty())
                     {
-                        removeAll([&aDialogId] (const queue_type::value_type& elem) {
+                        removeAll([&nDialogId] (const queue_type::value_type& elem) {
                                 if (elem.first == LOK_CALLBACK_DIALOG)
                                 {
                                     boost::property_tree::ptree aOldTree;
                                     std::stringstream aOldStream(elem.second);
                                     boost::property_tree::read_json(aOldStream, aOldTree);
-                                    const std::string aOldDialogId = aOldTree.get<std::string>("dialogId", "");
+                                    const unsigned nOldDialogId = aOldTree.get<unsigned>("dialogId", 0);
                                     if (aOldTree.get<std::string>("action", "") == "invalidate" &&
-                                        aDialogId == aOldDialogId)
+                                        nDialogId == nOldDialogId)
                                     {
                                         return true;
                                     }
@@ -1057,7 +1057,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(),
-                                                       [&aDialogId] (const queue_type::value_type& elem)
+                                                       [&nDialogId] (const queue_type::value_type& elem)
                                                        {
                                                            if (elem.first != LOK_CALLBACK_DIALOG)
                                                                return false;
@@ -1065,9 +1065,9 @@ void CallbackFlushHandler::queue(const int type, const char* data)
                                                            boost::property_tree::ptree aOldTree;
                                                            std::stringstream aOldStream(elem.second);
                                                            boost::property_tree::read_json(aOldStream, aOldTree);
-                                                           const std::string aOldDialogId = aOldTree.get<std::string>("dialogId", "");
+                                                           const unsigned nOldDialogId = aOldTree.get<unsigned>("dialogId", 0);
                                                            if (aOldTree.get<std::string>("action", "") == "invalidate" &&
-                                                               aDialogId == aOldDialogId &&
+                                                               nDialogId == nOldDialogId &&
                                                                aOldTree.get<std::string>("rectangle", "").empty())
                                                            {
                                                                return true;
@@ -1088,7 +1088,7 @@ void CallbackFlushHandler::queue(const int type, const char* data)
                         aRectStream >> nLeft >> nComma >> nTop >> nComma >> nWidth >> nComma >> nHeight;
                         tools::Rectangle aNewRect = tools::Rectangle(nLeft, nTop, nLeft + nWidth, nTop + nHeight);
                         bool currentIsRedundant = false;
-                        removeAll([&aNewRect, &aDialogId, &currentIsRedundant] (const queue_type::value_type& elem) {
+                        removeAll([&aNewRect, &nDialogId, &currentIsRedundant] (const queue_type::value_type& elem) {
                                 if (elem.first != LOK_CALLBACK_DIALOG)
                                     return false;
 
@@ -1097,7 +1097,7 @@ void CallbackFlushHandler::queue(const int type, const char* data)
                                 boost::property_tree::read_json(aOldStream, aOldTree);
                                 if (aOldTree.get<std::string>("action", "") == "invalidate")
                                 {
-                                    const std::string aOldDialogId = aOldTree.get<std::string>("dialogId", "");
+                                    const unsigned nOldDialogId = aOldTree.get<unsigned>("dialogId", 0);
                                     std::string aOldRectStr = aOldTree.get<std::string>("rectangle", "");
                                     // not possible that we encounter an empty
                                     // rectangle here; we already handled this
@@ -1108,7 +1108,7 @@ void CallbackFlushHandler::queue(const int type, const char* data)
                                     aOldRectStream >> nOldLeft >> nOldComma >> nOldTop >> nOldComma >> nOldWidth >> nOldComma >> nOldHeight;
                                     tools::Rectangle aOldRect = tools::Rectangle(nOldLeft, nOldTop, nOldLeft + nOldWidth, nOldTop + nOldHeight);
 
-                                    if (aDialogId == aOldDialogId)
+                                    if (nDialogId == nOldDialogId)
                                     {
                                         // new one engulfs the old one?
                                         if (aNewRect.IsInside(aOldRect))
@@ -2256,7 +2256,7 @@ static void doc_postKeyEvent(LibreOfficeKitDocument* pThis, int nType, int nChar
     pDoc->postKeyEvent(nType, nCharCode, nKeyCode);
 }
 
-static void doc_postDialogKeyEvent(LibreOfficeKitDocument* pThis, const char* pDialogId, int nType, int nCharCode, int nKeyCode)
+static void doc_postDialogKeyEvent(LibreOfficeKitDocument* pThis, unsigned nDialogId, int nType, int nCharCode, int nKeyCode)
 {
     SolarMutexGuard aGuard;
 
@@ -2267,8 +2267,7 @@ static void doc_postDialogKeyEvent(LibreOfficeKitDocument* pThis, const char* pD
         return;
     }
 
-    vcl::DialogID aDialogID = OUString::createFromAscii(pDialogId);
-    pDoc->postDialogKeyEvent(aDialogID, nType, nCharCode, nKeyCode);
+    pDoc->postDialogKeyEvent(nDialogId, nType, nCharCode, nKeyCode);
 }
 
 /** Class to react on finishing of a dispatched command.
@@ -2422,7 +2421,7 @@ static void doc_postMouseEvent(LibreOfficeKitDocument* pThis, int nType, int nX,
     }
 }
 
-static void doc_postDialogMouseEvent(LibreOfficeKitDocument* pThis, const char* pDialogId, int nType, int nX, int nY, int nCount, int nButtons, int nModifier)
+static void doc_postDialogMouseEvent(LibreOfficeKitDocument* pThis, unsigned nDialogId, int nType, int nX, int nY, int nCount, int nButtons, int nModifier)
 {
     SolarMutexGuard aGuard;
 
@@ -2433,11 +2432,10 @@ static void doc_postDialogMouseEvent(LibreOfficeKitDocument* pThis, const char*
         return;
     }
 
-    vcl::DialogID aDialogID = OUString::createFromAscii(pDialogId);
-    pDoc->postDialogMouseEvent(aDialogID, nType, nX, nY, nCount, nButtons, nModifier);
+    pDoc->postDialogMouseEvent(nDialogId, nType, nX, nY, nCount, nButtons, nModifier);
 }
 
-static void doc_postDialogChildMouseEvent(LibreOfficeKitDocument* pThis, const char* pDialogId, int nType, int nX, int nY, int nCount, int nButtons, int nModifier)
+static void doc_postDialogChildMouseEvent(LibreOfficeKitDocument* pThis, unsigned nDialogId, int nType, int nX, int nY, int nCount, int nButtons, int nModifier)
 {
     SolarMutexGuard aGuard;
 
@@ -2448,8 +2446,7 @@ static void doc_postDialogChildMouseEvent(LibreOfficeKitDocument* pThis, const c
         return;
     }
 
-    vcl::DialogID aDialogID = OUString::createFromAscii(pDialogId);
-    pDoc->postDialogChildMouseEvent(aDialogID, nType, nX, nY, nCount, nButtons, nModifier);
+    pDoc->postDialogChildMouseEvent(nDialogId, nType, nX, nY, nCount, nButtons, nModifier);
 }
 
 static void doc_setTextSelection(LibreOfficeKitDocument* pThis, int nType, int nX, int nY)
@@ -3228,15 +3225,14 @@ unsigned char* doc_renderFont(SAL_UNUSED_PARAMETER LibreOfficeKitDocument* /*pTh
     return nullptr;
 }
 
-static void doc_getDialogInfo(LibreOfficeKitDocument* pThis, const char* pDialogId,
+static void doc_getDialogInfo(LibreOfficeKitDocument* pThis, unsigned nDialogId,
                               char** pDialogTitle, int* nWidth, int* nHeight)
 {
     SolarMutexGuard aGuard;
 
     IDialogRenderable* pDialogRenderable = getDialogRenderable(pThis);
-    vcl::DialogID aDialogID = OUString::createFromAscii(pDialogId);
     OUString aDialogTitle;
-    pDialogRenderable->getDialogInfo(aDialogID, aDialogTitle, *nWidth, *nHeight);
+    pDialogRenderable->getDialogInfo(nDialogId, aDialogTitle, *nWidth, *nHeight);
 
     // copy dialog title
     if (!aDialogTitle.isEmpty())
@@ -3247,7 +3243,7 @@ static void doc_getDialogInfo(LibreOfficeKitDocument* pThis, const char* pDialog
     }
 }
 
-static void doc_paintDialog(LibreOfficeKitDocument* pThis, const char* pDialogId,
+static void doc_paintDialog(LibreOfficeKitDocument* pThis, unsigned nDialogId,
                             unsigned char* pBuffer,
                             const int nX, const int nY,
                             const int nWidth, const int nHeight)
@@ -3261,18 +3257,16 @@ static void doc_paintDialog(LibreOfficeKitDocument* pThis, const char* pDialogId
 
     pDevice->SetOutputSizePixelScaleOffsetAndBuffer(Size(nWidth, nHeight), Fraction(1.0), Point(), pBuffer);
 
-    vcl::DialogID aDialogID = OUString::createFromAscii(pDialogId);
-
     MapMode aMapMode(pDevice->GetMapMode());
     aMapMode.SetOrigin(Point(-nX, -nY));
     pDevice->SetMapMode(aMapMode);
 
     comphelper::LibreOfficeKit::setDialogPainting(true);
-    pDialogRenderable->paintDialog(aDialogID, *pDevice.get());
+    pDialogRenderable->paintDialog(nDialogId, *pDevice.get());
     comphelper::LibreOfficeKit::setDialogPainting(false);
 }
 
-static void doc_paintActiveFloatingWindow(LibreOfficeKitDocument* pThis, const char* pDialogId, unsigned char* pBuffer, int* nWidth, int* nHeight)
+static void doc_paintActiveFloatingWindow(LibreOfficeKitDocument* pThis, unsigned nDialogId, unsigned char* pBuffer, int* nWidth, int* nHeight)
 {
     SolarMutexGuard aGuard;
 
@@ -3283,10 +3277,8 @@ static void doc_paintActiveFloatingWindow(LibreOfficeKitDocument* pThis, const c
 
     pDevice->SetOutputSizePixelScaleOffsetAndBuffer(Size(*nWidth, *nHeight), Fraction(1.0), Point(), pBuffer);
 
-    vcl::DialogID aDialogID = OUString::createFromAscii(pDialogId);
-
     comphelper::LibreOfficeKit::setDialogPainting(true);
-    pDialogRenderable->paintActiveFloatingWindow(aDialogID, *pDevice.get(), *nWidth, *nHeight);
+    pDialogRenderable->paintActiveFloatingWindow(nDialogId, *pDevice.get(), *nWidth, *nHeight);
     comphelper::LibreOfficeKit::setDialogPainting(false);
 }
 
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h
index 14824821cfd7..071da712703e 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -268,29 +268,29 @@ struct _LibreOfficeKitDocumentClass
 
     /// Paints dialog with given dialog id to the buffer
     /// @see lok::Document::paintDialog().
-    void (*paintDialog) (LibreOfficeKitDocument* pThis, const char* pDialogId,
+    void (*paintDialog) (LibreOfficeKitDocument* pThis, unsigned nDialogId,
                          unsigned char* pBuffer,
                          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, const char* pDialogId,
+    void (*getDialogInfo) (LibreOfficeKitDocument* pThis, unsigned nDialogId,
                            char** pDialogTitle, int* pWidth, int* pHeight);
 
     /// @see lok::Document::paintActiveFloatingWindow().
-    void (*paintActiveFloatingWindow) (LibreOfficeKitDocument* pThis, const char* pDialogId, unsigned char* pBuffer, int* nWidth, int* nHeight);
+    void (*paintActiveFloatingWindow) (LibreOfficeKitDocument* pThis, unsigned nDialogId, unsigned char* pBuffer, int* nWidth, int* nHeight);
 
     /// @see lok::Document::postDialogKeyEvent().
     void (*postDialogKeyEvent) (LibreOfficeKitDocument* pThis,
-                                const char* pDialogId,
+                                unsigned nDialogId,
                                 int nType,
                                 int nCharCode,
                                 int nKeyCode);
 
     /// @see lok::Document::postDialogMouseEvent().
     void (*postDialogMouseEvent) (LibreOfficeKitDocument* pThis,
-                                  const char* pDialogId,
+                                  unsigned nDialogId,
                                   int nType,
                                   int nX,
                                   int nY,
@@ -300,7 +300,7 @@ struct _LibreOfficeKitDocumentClass
 
     /// @see lok::Document::postDialogChildMouseEvent().
     void (*postDialogChildMouseEvent) (LibreOfficeKitDocument* pThis,
-                                       const char* pDialogId,
+                                       unsigned nDialogId,
                                        int nType,
                                        int nX,
                                        int nY,
diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx
index 19e121fe6573..c99b425daff6 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ b/include/LibreOfficeKit/LibreOfficeKit.hxx
@@ -160,38 +160,38 @@ public:
      *
      * Client must truncate pBuffer according to the nWidth and nHeight returned after the call.
      *
-     * @param pDialogId Unique dialog id to be painted
+     * @param nDialogId Unique dialog id to be painted
      * @param pBuffer Buffer with enough memory allocated to render any dialog
      * @param x x-coordinate from where the dialog should start painting
      * @param y y-coordinate from where the dialog should start painting
      * @param width The width of the dialog image to be painted
      * @param height The height of the dialog image to be painted
      */
-    void paintDialog(const char* pDialogId,
+    void paintDialog(unsigned nDialogId,
                      unsigned char* pBuffer,
                      const int x,
                      const int y,
                      const int width,
                      const int height)
     {
-        return mpDoc->pClass->paintDialog(mpDoc, pDialogId, pBuffer,
+        return mpDoc->pClass->paintDialog(mpDoc, nDialogId, pBuffer,
                                           x, y, width, height);
     }
 
     /* Get info about dialog with given dialog id
      *
-     * @param pDialogId Unique dialog id for which to get info about
+     * @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(const char* pDialogId,
+    void getDialogInfo(unsigned nDialogId,
                        char** pDialogTitle,
                        int& pWidth,
                        int& pHeight)
     {
-        return mpDoc->pClass->getDialogInfo(mpDoc, pDialogId, pDialogTitle, &pWidth, &pHeight);
+        return mpDoc->pClass->getDialogInfo(mpDoc, nDialogId, pDialogTitle, &pWidth, &pHeight);
 
     }
 
@@ -200,17 +200,17 @@ public:
      *
      * Client must truncate pBuffer according to the nWidth and nHeight returned after the call.
      *
-     * @param pDialogId Unique dialog id
+     * @param nDialogId Unique dialog id
      * @param pBuffer Buffer with enough memory allocated to render any dialog
      * @param nWidth output parameter returning the width of the rendered dialog.
      * @param nHeight output parameter returning the height of the rendered dialog
      */
-    void paintActiveFloatingWindow(const char* pDialogId,
+    void paintActiveFloatingWindow(unsigned nDialogId,
                                    unsigned char* pBuffer,
                                    int& nWidth,
                                    int& nHeight)
     {
-        return mpDoc->pClass->paintActiveFloatingWindow(mpDoc, pDialogId, pBuffer,
+        return mpDoc->pClass->paintActiveFloatingWindow(mpDoc, nDialogId, pBuffer,
                                                         &nWidth, &nHeight);
     }
 
@@ -282,14 +282,14 @@ public:
     /**
      * Posts a keyboard event to the dialog
      *
-     * @param pDialogId Dialog id on which key event should be posted
+     * @param nDialogId Dialog id on which key event should be posted
      * @param nType Event type, like press or release.
      * @param nCharCode contains the Unicode character generated by this event or 0
      * @param nKeyCode contains the integer code representing the key of the event (non-zero for control keys)
      */
-    void postDialogKeyEvent(const char* pDialogId, int nType, int nCharCode, int nKeyCode)
+    void postDialogKeyEvent(unsigned nDialogId, int nType, int nCharCode, int nKeyCode)
     {
-        mpDoc->pClass->postDialogKeyEvent(mpDoc, pDialogId, nType, nCharCode, nKeyCode);
+        mpDoc->pClass->postDialogKeyEvent(mpDoc, nDialogId, nType, nCharCode, nKeyCode);
     }
 
     /**
@@ -310,7 +310,7 @@ public:
     /**
      * Posts a mouse event to the dialog with given id.
      *
-     * @param pDialogId Dialog id where mouse event is to be posted
+     * @param nDialogId Dialog id where mouse event is to be posted
      * @param nType Event type, like down, move or up.
      * @param nX horizontal position in document coordinates
      * @param nY vertical position in document coordinates
@@ -318,15 +318,15 @@ public:
      * @param nButtons: which mouse buttons: 1 for left, 2 for middle, 4 right
      * @param nModifier: which keyboard modifier: (see include/vcl/vclenum.hxx for possible values)
      */
-    void postDialogMouseEvent(const char* pDialogId, int nType, int nX, int nY, int nCount, int nButtons, int nModifier)
+    void postDialogMouseEvent(unsigned nDialogId, int nType, int nX, int nY, int nCount, int nButtons, int nModifier)
     {
-        mpDoc->pClass->postDialogMouseEvent(mpDoc, pDialogId, nType, nX, nY, nCount, nButtons, nModifier);
+        mpDoc->pClass->postDialogMouseEvent(mpDoc, nDialogId, nType, nX, nY, nCount, nButtons, nModifier);
     }
 
     /**
      * Posts a mouse event to the child of a dialog with given id.
      *
-     * @param aDialogId Dialog id
+     * @param nDialogId Dialog id
      * @param nType Event type, like down, move or up.
      * @param nX horizontal position in document coordinates
      * @param nY vertical position in document coordinates
@@ -334,9 +334,9 @@ public:
      * @param nButtons: which mouse buttons: 1 for left, 2 for middle, 4 right
      * @param nModifier: which keyboard modifier: (see include/vcl/vclenum.hxx for possible values)
      */
-    void postDialogChildMouseEvent(const char* pDialogId, int nType, int nX, int nY, int nCount, int nButtons, int nModifier)
+    void postDialogChildMouseEvent(unsigned nDialogId, int nType, int nX, int nY, int nCount, int nButtons, int nModifier)
     {
-        mpDoc->pClass->postDialogChildMouseEvent(mpDoc, pDialogId, nType, nX, nY, nCount, nButtons, nModifier);
+        mpDoc->pClass->postDialogChildMouseEvent(mpDoc, nDialogId, nType, nX, nY, nCount, nButtons, nModifier);
     }
 
 
diff --git a/include/sfx2/lokhelper.hxx b/include/sfx2/lokhelper.hxx
index 93d61fc311fa..24e59d097393 100644
--- a/include/sfx2/lokhelper.hxx
+++ b/include/sfx2/lokhelper.hxx
@@ -42,11 +42,11 @@ public:
     /// Same as notifyOtherViews(), but works on a selected "other" view, not on all of them.
     static void notifyOtherView(SfxViewShell* pThisView, SfxViewShell const* pOtherView, int nType, const OString& rKey, const OString& rPayload);
     /// Emits a LOK_CALLBACK_DIALOG
-    static void notifyDialog(const OUString& rDialogId,
+    static void notifyDialog(vcl::DialogID nDialogId,
                              const OUString& rAction,
                              const std::vector<vcl::LOKPayloadItem>& rPayload = std::vector<vcl::LOKPayloadItem>());
     /// Emits a LOK_CALLBACK_DIALOG_CHILD
-    static void notifyDialogChild(const OUString& rDialogID, const OUString& rAction, const Point& rPos);
+    static void notifyDialogChild(vcl::DialogID nDialogId, const OUString& rAction, const Point& rPos);
     /// Emits a LOK_CALLBACK_INVALIDATE_TILES, but tweaks it according to setOptionalFeatures() if needed.
     static void notifyInvalidation(SfxViewShell const* pThisView, const OString& rPayload);
     /// A special value to signify 'infinity'.
diff --git a/include/sfx2/viewsh.hxx b/include/sfx2/viewsh.hxx
index de317e88910a..e91148e7b8fa 100644
--- a/include/sfx2/viewsh.hxx
+++ b/include/sfx2/viewsh.hxx
@@ -224,13 +224,13 @@ public:
     virtual       SfxShell*     GetFormShell()       { return nullptr; };
     virtual const SfxShell*     GetFormShell() const { return nullptr; };
 
-    void                        RegisterDlg(const vcl::DialogID& rDialogId, VclPtr<Dialog> pDlg);
-    VclPtr<Dialog>              GetOpenedDlg(const vcl::DialogID& rDialogId);
-    void                        UnregisterDlg(const vcl::DialogID& rDialogId);
+    void                        RegisterDlg(vcl::DialogID nDialogId, VclPtr<Dialog> pDlg);
+    VclPtr<Dialog>              GetOpenedDlg(vcl::DialogID nDialogId);
+    void                        UnregisterDlg(vcl::DialogID 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;
+    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;
 
     // Focus, KeyInput, Cursor
     virtual void                ShowCursor( bool bOn = true );
diff --git a/include/vcl/IDialogRenderable.hxx b/include/vcl/IDialogRenderable.hxx
index 9a63830566f0..f606782692e3 100644
--- a/include/vcl/IDialogRenderable.hxx
+++ b/include/vcl/IDialogRenderable.hxx
@@ -23,7 +23,7 @@ namespace vcl
 
 typedef std::pair<const OString, const OString> LOKPayloadItem;
 
-typedef OUString DialogID;
+typedef sal_uInt32 DialogID;
 
 class VCL_DLLPUBLIC IDialogRenderable
 {
diff --git a/include/vcl/dialog.hxx b/include/vcl/dialog.hxx
index 874828f92a0e..e4d9f88f6d83 100644
--- a/include/vcl/dialog.hxx
+++ b/include/vcl/dialog.hxx
@@ -59,6 +59,8 @@ private:
 
     vcl::IDialogNotifier*  mpDialogNotifier; // to emit LOK callbacks
 
+    static vcl::DialogID   mnLastDialogId;
+
     SAL_DLLPRIVATE void    ImplInitDialogData();
     SAL_DLLPRIVATE void    ImplInitSettings();
     SAL_DLLPRIVATE VclPtr<vcl::Window> AddBorderWindow(vcl::Window* pParent, WinBits nBits);
@@ -73,8 +75,8 @@ private:
 protected:
     using Window::ImplInit;
     SAL_DLLPRIVATE void    ImplInit( vcl::Window* pParent, WinBits nStyle, InitFlag eFlag = InitFlag::Default );
-    /// Dialog ID (UNO name) for this dialog
-    OUString               maID;
+    /// Dialog ID (used for LOK)
+    vcl::DialogID          maID;
     /// Necessary to register dialog notifier instance to emit LOK callbacks
     void                   registerDialogNotifier(vcl::IDialogNotifier* pDialogNotifier);
 
diff --git a/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx b/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx
index 176fa91fffaa..b5325cf853c0 100644
--- a/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx
@@ -48,7 +48,7 @@ struct GtvLokDialogPrivate
     guint32 m_nChildKeyModifier;
     guint32 m_nChildLastButtonPressed;
 
-    gchar* dialogid;
+    guint dialogid;
 };
 
 G_DEFINE_TYPE_WITH_PRIVATE(GtvLokDialog, gtv_lok_dialog, GTK_TYPE_DIALOG);
@@ -400,7 +400,7 @@ gtv_lok_dialog_set_property(GObject* object, guint propId, const GValue* value,
         priv->lokdocview = LOK_DOC_VIEW(g_value_get_object(value));
         break;
     case PROP_DIALOG_ID:
-        priv->dialogid = g_value_dup_string(value);
+        priv->dialogid = g_value_get_uint(value);
         break;
     case PROP_DIALOG_WIDTH:
         priv->m_nWidth = g_value_get_uint(value);
@@ -425,7 +425,7 @@ gtv_lok_dialog_get_property(GObject* object, guint propId, GValue* value, GParam
         g_value_set_object(value, priv->lokdocview);
         break;
     case PROP_DIALOG_ID:
-        g_value_set_string(value, priv->dialogid);
+        g_value_set_uint(value, priv->dialogid);
         break;
     case PROP_DIALOG_WIDTH:
         g_value_set_uint(value, priv->m_nWidth);
@@ -439,22 +439,10 @@ gtv_lok_dialog_get_property(GObject* object, guint propId, GValue* value, GParam
 }
 
 static void
-gtv_lok_dialog_finalize(GObject* object)
-{
-    GtvLokDialog* self = GTV_LOK_DIALOG(object);
-    GtvLokDialogPrivate* priv = getPrivate(self);
-
-    g_free(priv->dialogid);
-
-    G_OBJECT_CLASS(gtv_lok_dialog_parent_class)->finalize(object);
-}
-
-static void
 gtv_lok_dialog_class_init(GtvLokDialogClass* klass)
 {
     G_OBJECT_CLASS(klass)->get_property = gtv_lok_dialog_get_property;
     G_OBJECT_CLASS(klass)->set_property = gtv_lok_dialog_set_property;
-    G_OBJECT_CLASS(klass)->finalize = gtv_lok_dialog_finalize;
 
     properties[PROP_LOKDOCVIEW_CONTEXT] = g_param_spec_object("lokdocview",
                                                               "LOKDocView Context",
@@ -464,29 +452,29 @@ gtv_lok_dialog_class_init(GtvLokDialogClass* klass)
                                                                                        G_PARAM_CONSTRUCT_ONLY |
                                                                                        G_PARAM_STATIC_STRINGS));
 
-    properties[PROP_DIALOG_ID] = g_param_spec_string("dialogid",
-                                                     "Dialog identifier",
-                                                     "Unique dialog identifier; UNO command for now",
-                                                     nullptr,
-                                                     static_cast<GParamFlags>(G_PARAM_READWRITE |
-                                                                              G_PARAM_CONSTRUCT_ONLY |
-                                                                              G_PARAM_STATIC_STRINGS));
+    properties[PROP_DIALOG_ID] = g_param_spec_uint("dialogid",
+                                                   "Dialog identifier",
+                                                   "Unique dialog identifier",
+                                                   0, G_MAXUINT, 0,
+                                                   static_cast<GParamFlags>(G_PARAM_READWRITE |
+                                                                            G_PARAM_CONSTRUCT_ONLY |
+                                                                            G_PARAM_STATIC_STRINGS));
 
     properties[PROP_DIALOG_WIDTH] = g_param_spec_uint("width",
-                                                     "Dialog width",
-                                                     "Dialog width",
-                                                     0, 1024, 0,
-                                                     static_cast<GParamFlags>(G_PARAM_READWRITE |
-                                                                              G_PARAM_CONSTRUCT_ONLY |
-                                                                              G_PARAM_STATIC_STRINGS));
+                                                      "Dialog width",
+                                                      "Dialog width",
+                                                      0, 1024, 0,
+                                                      static_cast<GParamFlags>(G_PARAM_READWRITE |
+                                                                               G_PARAM_CONSTRUCT_ONLY |
+                                                                               G_PARAM_STATIC_STRINGS));
 
     properties[PROP_DIALOG_HEIGHT] = g_param_spec_uint("height",
                                                        "Dialog height",
-                                                      "Dialog height",
-                                                      0, 1024, 0,
-                                                     static_cast<GParamFlags>(G_PARAM_READWRITE |
-                                                                              G_PARAM_CONSTRUCT_ONLY |
-                                                                              G_PARAM_STATIC_STRINGS));
+                                                       "Dialog height",
+                                                       0, 1024, 0,
+                                                       static_cast<GParamFlags>(G_PARAM_READWRITE |
+                                                                                G_PARAM_CONSTRUCT_ONLY |
+                                                                                G_PARAM_STATIC_STRINGS));
 
     g_object_class_install_properties (G_OBJECT_CLASS(klass), PROP_LAST, properties);
 }
@@ -702,7 +690,7 @@ void gtv_lok_dialog_child_close(GtvLokDialog* dialog)
 
 
 GtkWidget*
-gtv_lok_dialog_new(LOKDocView* pDocView, const gchar* dialogId, guint width, guint height)
+gtv_lok_dialog_new(LOKDocView* pDocView, guint dialogId, guint width, guint height)
 {
     GtkWindow* pWindow = GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(pDocView)));
     return GTK_WIDGET(g_object_new(GTV_TYPE_LOK_DIALOG,
diff --git a/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.hxx b/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.hxx
index 8f2161ef5f27..0f7002c359d7 100644
--- a/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.hxx
+++ b/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.hxx
@@ -35,7 +35,7 @@ struct GtvLokDialogClass
 
 GType gtv_lok_dialog_get_type               (void) G_GNUC_CONST;
 
-GtkWidget* gtv_lok_dialog_new(LOKDocView* pDocView, const gchar* dialogId, guint width, guint height);
+GtkWidget* gtv_lok_dialog_new(LOKDocView* pDocView, guint dialogId, guint width, guint height);
 
 void gtv_lok_dialog_invalidate(GtvLokDialog* dialog, const GdkRectangle& aRectangle);
 
diff --git a/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx b/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx
index 03e54afd1d22..62f639957d2b 100644
--- a/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx
@@ -308,15 +308,15 @@ void LOKDocViewSigHandlers::dialog(LOKDocView* pDocView, gchar* pPayload, gpoint
     std::stringstream aStream(pPayload);
     boost::property_tree::ptree aRoot;
     boost::property_tree::read_json(aStream, aRoot);
-    const std::string aDialogId = aRoot.get<std::string>("dialogId");
+    const unsigned nDialogId = aRoot.get<unsigned>("dialogId");
     const std::string aAction = aRoot.get<std::string>("action");
 
     if (aAction == "created")
     {
         const std::string aSize = aRoot.get<std::string>("size");
         std::vector<int> aPoints = GtvHelpers::splitIntoIntegers(aSize, ", ", 2);
-        GtkWidget* pDialog = gtv_lok_dialog_new(pDocView, aDialogId.c_str(), aPoints[0], aPoints[1]);
-        g_info("created  dialog, for dialogid: %s with size: %s", aDialogId.c_str(), aSize.c_str());
+        GtkWidget* pDialog = gtv_lok_dialog_new(pDocView, nDialogId, aPoints[0], aPoints[1]);
+        g_info("created  dialog, for dialogid: %d with size: %s", nDialogId, aSize.c_str());
 
         gtv_application_window_register_child_window(window, GTK_WINDOW(pDialog));
         g_signal_connect(pDialog, "destroy", G_CALLBACK(destroyLokDialog), window);
@@ -333,9 +333,9 @@ void LOKDocViewSigHandlers::dialog(LOKDocView* pDocView, gchar* pPayload, gpoint
     GList* pIt = nullptr;
     for (pIt = pChildWins; pIt != nullptr; pIt = pIt->next)
     {
-        gchar* pChildDialogId = nullptr;
-        g_object_get(pIt->data, "dialogid", &pChildDialogId, nullptr);
-        if (g_strcmp0(pChildDialogId, aDialogId.c_str()) == 0)
+        guint nChildDialogId = 0;
+        g_object_get(pIt->data, "dialogid", &nChildDialogId, nullptr);
+        if (nDialogId == nChildDialogId)
         {
             if (aAction == "close")
                 gtk_widget_destroy(GTK_WIDGET(pIt->data));
@@ -355,7 +355,6 @@ void LOKDocViewSigHandlers::dialog(LOKDocView* pDocView, gchar* pPayload, gpoint
                 gtv_lok_dialog_invalidate(GTV_LOK_DIALOG(pIt->data), aGdkRectangle);
             }
         }
-        g_free(pChildDialogId);
     }
 }
 
@@ -366,9 +365,9 @@ void LOKDocViewSigHandlers::dialogChild(LOKDocView* pDocView, gchar* pPayload, g
     std::stringstream aStream(pPayload);
     boost::property_tree::ptree aRoot;
     boost::property_tree::read_json(aStream, aRoot);
-    std::string aDialogId = aRoot.get<std::string>("dialogId");
-    std::string aAction = aRoot.get<std::string>("action");
-    std::string aPos = aRoot.get<std::string>("position");
+    const unsigned nDialogId = aRoot.get<unsigned>("dialogId");
+    const std::string aAction = aRoot.get<std::string>("action");
+    const std::string aPos = aRoot.get<std::string>("position");
     gchar** ppCoordinates = g_strsplit(aPos.c_str(), ", ", 2);
     gchar** ppCoordinate = ppCoordinates;
     int nX = 0;
@@ -386,16 +385,15 @@ void LOKDocViewSigHandlers::dialogChild(LOKDocView* pDocView, gchar* pPayload, g
     GList* pIt = nullptr;
     for (pIt = pChildWins; pIt != nullptr; pIt = pIt->next)
     {
-        gchar* pChildDialogId = nullptr;
-        g_object_get(pIt->data, "dialogid", &pChildDialogId, nullptr);
-        if (g_strcmp0(pChildDialogId, aDialogId.c_str()) == 0)
+        guint nChildDialogId = 0;
+        g_object_get(pIt->data, "dialogid", &nChildDialogId, nullptr);
+        if (nDialogId == nChildDialogId)
         {
             if (aAction == "invalidate")
                 gtv_lok_dialog_child_invalidate(GTV_LOK_DIALOG(pIt->data), nX, nY);
             else if (aAction == "close")
                 gtv_lok_dialog_child_close(GTV_LOK_DIALOG(pIt->data));
         }
-        g_free(pChildDialogId);
     }
 }
 
diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx
index 33464711852f..9af028916b69 100644
--- a/sfx2/source/view/lokhelper.cxx
+++ b/sfx2/source/view/lokhelper.cxx
@@ -144,15 +144,15 @@ void SfxLokHelper::notifyOtherViews(SfxViewShell* pThisView, int nType, const OS
     }
 }
 
-void SfxLokHelper::notifyDialog(const OUString& rDialogID,
+void SfxLokHelper::notifyDialog(vcl::DialogID nDialogID,
                                 const OUString& rAction,
                                 const std::vector<vcl::LOKPayloadItem>& rPayload)
 {
-    if (SfxLokHelper::getViewsCount() <= 0 || rDialogID.isEmpty())
+    if (SfxLokHelper::getViewsCount() <= 0 || nDialogID == 0)
         return;
 
     SfxViewShell* pViewShell = SfxViewShell::GetFirst();
-    OString aPayload = OString("{ \"dialogId\": \"") + OUStringToOString(rDialogID, RTL_TEXTENCODING_UTF8).getStr() + OString("\"");
+    OString aPayload = OString("{ \"dialogId\": \"") + OString::number(nDialogID) + OString("\"");
     aPayload += OString(", \"action\": \"") + OUStringToOString(rAction, RTL_TEXTENCODING_UTF8).getStr() + OString("\"");
 
     for (const auto& rItem: rPayload)
@@ -172,13 +172,13 @@ void SfxLokHelper::notifyDialog(const OUString& rDialogID,
     }
 }
 
-void SfxLokHelper::notifyDialogChild(const OUString& rDialogID, const OUString& rAction, const Point& rPos)
+void SfxLokHelper::notifyDialogChild(vcl::DialogID nDialogID, const OUString& rAction, const Point& rPos)
 {
-    if (SfxLokHelper::getViewsCount() <= 0 || rDialogID.isEmpty())
+    if (SfxLokHelper::getViewsCount() <= 0 || nDialogID == 0)
         return;
 
     SfxViewShell* pViewShell = SfxViewShell::GetFirst();
-    const OString aPayload = OString("{ \"dialogId\": \"") + OUStringToOString(rDialogID, RTL_TEXTENCODING_UTF8).getStr() +
+    const OString aPayload = OString("{ \"dialogId\": \"") + OString::number(nDialogID) +
         OString("\", \"action\": \"") + OUStringToOString(rAction, RTL_TEXTENCODING_UTF8).getStr() +
         OString("\", \"position\": \"") + OString::number(rPos.getX()) + OString(", ") + OString::number(rPos.getY()) +
         + "\" }";
diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx
index 2d4d8af19a70..92dcfa48cdcf 100644
--- a/sfx2/source/view/viewsh.cxx
+++ b/sfx2/source/view/viewsh.cxx
@@ -1948,31 +1948,28 @@ Reference< view::XRenderable > SfxViewShell::GetRenderable()
     return xRender;
 }
 
-void SfxViewShell::notifyDialog(const vcl::DialogID& rDialogID, const OUString& rAction, const std::vector<vcl::LOKPayloadItem>& rPayload)
+void SfxViewShell::notifyDialog(const vcl::DialogID& rDialogId, const OUString& rAction, const std::vector<vcl::LOKPayloadItem>& rPayload)
 {
-    SfxLokHelper::notifyDialog(rDialogID, rAction, rPayload);
+    SfxLokHelper::notifyDialog(rDialogId, rAction, rPayload);
 }
 
-void SfxViewShell::notifyDialogChild(const vcl::DialogID& rDialogID, const OUString& rAction, const Point& rPos)
+void SfxViewShell::notifyDialogChild(const vcl::DialogID& rDialogId, const OUString& rAction, const Point& rPos)
 {
-    SfxLokHelper::notifyDialog(rDialogID, rAction);
+    SfxLokHelper::notifyDialog(rDialogId, rAction);
 }
 
-void SfxViewShell::RegisterDlg(const vcl::DialogID& rDialogId, VclPtr<Dialog> pDlg)
+void SfxViewShell::RegisterDlg(vcl::DialogID nDialogId, VclPtr<Dialog> pDlg)
 {
     if (pDlg)
-        maOpenedDialogs.push_back(std::make_pair(rName, pDlg));
+        maOpenedDialogs.push_back(std::make_pair(nDialogId, pDlg));
 }
 
-VclPtr<Dialog> SfxViewShell::GetOpenedDlg(const vcl::DialogID& rDialogId)
+VclPtr<Dialog> SfxViewShell::GetOpenedDlg(vcl::DialogID nDialogId)
 {
-    if (rName.startsWith(".uno:"))
-        rName = rName.replaceFirst(".uno:", "");
-
     const auto it = std::find_if(maOpenedDialogs.begin(),
                                  maOpenedDialogs.end(),
-                                 [&rDialogId](const std::pair<vcl::DialogID, VclPtr<Dialog>> aItem) {
-                                     return rDialogId == aItem.first;
+                                 [&nDialogId](const std::pair<vcl::DialogID, VclPtr<Dialog>> aItem) {
+                                     return nDialogId == aItem.first;
                                  });
 
     Dialog* ret = nullptr;
@@ -1983,12 +1980,12 @@ VclPtr<Dialog> SfxViewShell::GetOpenedDlg(const vcl::DialogID& rDialogId)
     return ret;
 }
 
-void SfxViewShell::UnregisterDlg(const OUString& rName)
+void SfxViewShell::UnregisterDlg(vcl::DialogID nDialogId)
 {
     maOpenedDialogs.erase(std::remove_if(maOpenedDialogs.begin(),
                                          maOpenedDialogs.end(),
-                                         [&rDialogId](const std::pair<vcl::DialogID, VclPtr<Dialog>> aItem) {
-                                             return aItem.first == rDialogId;
+                                         [&nDialogId](const std::pair<vcl::DialogID, VclPtr<Dialog>> aItem) {
+                                             return aItem.first == nDialogId;
                                          }));
 }
 
diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx
index 5b67193b9123..5b08a53d298d 100644
--- a/vcl/source/window/dialog.cxx
+++ b/vcl/source/window/dialog.cxx
@@ -346,6 +346,7 @@ struct DialogImpl
 
 void Dialog::ImplInitDialogData()
 {
+    maID                    = mnLastDialogId++;
     mpDialogNotifier        = nullptr;
     mpWindowImpl->mbDialog  = true;
     mpPrevExecuteDlg        = nullptr;
@@ -490,6 +491,8 @@ void Dialog::ImplInitSettings()
         SetBackground(GetSettings().GetStyleSettings().GetDialogColor());
 }
 
+vcl::DialogID Dialog::mnLastDialogId = 1;
+
 Dialog::Dialog( WindowType nType )
     : SystemWindow( nType )
     , mbForceBorderWindow(false)
@@ -957,7 +960,7 @@ void Dialog::LogicMouseMoveChild(const MouseEvent& rMouseEvent)
 
 void Dialog::InvalidateFloatingWindow(const Point& rPos)
 {
-    if (comphelper::LibreOfficeKit::isActive() && mpDialogNotifier && !maID.isEmpty())
+    if (comphelper::LibreOfficeKit::isActive() && mpDialogNotifier && maID != 0)
     {
         mpDialogNotifier->notifyDialogChild(maID, "invalidate", rPos);
     }
@@ -965,7 +968,7 @@ void Dialog::InvalidateFloatingWindow(const Point& rPos)
 
 void Dialog::CloseFloatingWindow()
 {
-    if (comphelper::LibreOfficeKit::isActive() && mpDialogNotifier && !maID.isEmpty())
+    if (comphelper::LibreOfficeKit::isActive() && mpDialogNotifier && maID != 0)
     {
         mpDialogNotifier->notifyDialogChild(maID, "close", Point(0, 0));
     }
@@ -973,7 +976,7 @@ void Dialog::CloseFloatingWindow()
 
 void Dialog::LogicInvalidate(const tools::Rectangle* pRectangle)
 {
-    if (!comphelper::LibreOfficeKit::isDialogPainting() && mpDialogNotifier && !maID.isEmpty())
+    if (!comphelper::LibreOfficeKit::isDialogPainting() && mpDialogNotifier && maID != 0)
     {
         std::vector<vcl::LOKPayloadItem> aPayload;
         if (pRectangle)
@@ -1025,7 +1028,7 @@ void Dialog::LOKCursor(const OUString& rAction, const std::vector<vcl::LOKPayloa
 {
     assert(comphelper::LibreOfficeKit::isActive());
 
-    if (!comphelper::LibreOfficeKit::isDialogPainting() && mpDialogNotifier && !maID.isEmpty())
+    if (!comphelper::LibreOfficeKit::isDialogPainting() && mpDialogNotifier && maID != 0)
     {
         mpDialogNotifier->notifyDialog(maID, rAction, rPayload);
     }
@@ -1346,7 +1349,7 @@ void Dialog::Resize()
     SystemWindow::Resize();
 
     // inform LOK clients
-    if (!comphelper::LibreOfficeKit::isDialogPainting() && mpDialogNotifier && !maID.isEmpty())
+    if (!comphelper::LibreOfficeKit::isDialogPainting() && mpDialogNotifier && maID != 0)
     {
         mpDialogNotifier->notifyDialog(maID, "invalidate");
     }
commit 80b20241e03839e3ffa66ca239552f524aa8ac3a
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Thu Nov 23 21:07:07 2017 +0530

    lokdialog: Create dialog when callback is received
    
    With this, we do away with initial approach of rendering the dialog on a
    large surface. We now create the cairo surface with dimensions of the
    dialog.
    
    Change-Id: Icb034693c7f1c656b7daae7f5c711b5bd4d8e880

diff --git a/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx b/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx
index dfdbc3bc6ca6..03e54afd1d22 100644
--- a/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx
@@ -22,6 +22,24 @@
 
 #include <iostream>
 
+static gboolean deleteLokDialog(GtkWidget* pWidget, GdkEvent* /*event*/, gpointer userdata)
+{
+    GtvApplicationWindow* window = GTV_APPLICATION_WINDOW(userdata);
+    g_info("deleteLokDialog");
+    gtv_application_window_unregister_child_window(window, GTK_WINDOW(pWidget));
+
+    return FALSE;
+}
+
+static gboolean destroyLokDialog(GtkWidget* pWidget, gpointer userdata)
+{
+    GtvApplicationWindow* window = GTV_APPLICATION_WINDOW(userdata);
+    g_info("destroyLokDialog");
+    gtv_application_window_unregister_child_window(window, GTK_WINDOW(pWidget));
+
+    return FALSE;
+}
+
 void LOKDocViewSigHandlers::editChanged(LOKDocView* pDocView, gboolean bWasEdit, gpointer)
 {
     GtvApplicationWindow* window = GTV_APPLICATION_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(pDocView)));
@@ -293,9 +311,23 @@ void LOKDocViewSigHandlers::dialog(LOKDocView* pDocView, gchar* pPayload, gpoint
     const std::string aDialogId = aRoot.get<std::string>("dialogId");
     const std::string aAction = aRoot.get<std::string>("action");
 
-    // we only understand 'invalidate' and 'close' as of now
-    if (aAction != "invalidate" && aAction != "close")
+    if (aAction == "created")
+    {
+        const std::string aSize = aRoot.get<std::string>("size");
+        std::vector<int> aPoints = GtvHelpers::splitIntoIntegers(aSize, ", ", 2);
+        GtkWidget* pDialog = gtv_lok_dialog_new(pDocView, aDialogId.c_str(), aPoints[0], aPoints[1]);
+        g_info("created  dialog, for dialogid: %s with size: %s", aDialogId.c_str(), aSize.c_str());
+
+        gtv_application_window_register_child_window(window, GTK_WINDOW(pDialog));
+        g_signal_connect(pDialog, "destroy", G_CALLBACK(destroyLokDialog), window);
+        g_signal_connect(pDialog, "delete-event", G_CALLBACK(deleteLokDialog), window);
+
+        gtk_window_set_resizable(GTK_WINDOW(pDialog), false);
+        gtk_widget_show_all(GTK_WIDGET(pDialog));
+        gtk_window_present(GTK_WINDOW(pDialog));
+
         return;
+    }
 
     GList* pChildWins = gtv_application_window_get_all_child_windows(window);
     GList* pIt = nullptr;
diff --git a/libreofficekit/qa/gtktiledviewer/gtv-main-toolbar.cxx b/libreofficekit/qa/gtktiledviewer/gtv-main-toolbar.cxx
index d18482447a7e..33e454808ed2 100644
--- a/libreofficekit/qa/gtktiledviewer/gtv-main-toolbar.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtv-main-toolbar.cxx
@@ -119,7 +119,6 @@ gtv_main_toolbar_init(GtvMainToolbar* toolbar)
     gtk_builder_add_callback_symbol(builder.get(), "documentRepair", G_CALLBACK(documentRepair));
     gtk_builder_add_callback_symbol(builder.get(), "signalAddressbar", G_CALLBACK(signalAddressbar));
     gtk_builder_add_callback_symbol(builder.get(), "signalFormulabar", G_CALLBACK(signalFormulabar));
-    gtk_builder_add_callback_symbol(builder.get(), "openLokDialog", G_CALLBACK(openLokDialog));
 
     // find toolbar
     // Note: These buttons are not the part of GtvMainToolbar
diff --git a/libreofficekit/qa/gtktiledviewer/gtv-signal-handlers.cxx b/libreofficekit/qa/gtktiledviewer/gtv-signal-handlers.cxx
index 521c49ea3eb2..fe7d33210ce1 100644
--- a/libreofficekit/qa/gtktiledviewer/gtv-signal-handlers.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtv-signal-handlers.cxx
@@ -290,42 +290,6 @@ void changePartMode( GtkWidget* pSelector, gpointer /* pItem */ )
     }
 }
 
-static gboolean deleteLokDialog(GtkWidget* pWidget, GdkEvent* /*event*/, gpointer userdata)
-{
-    GtvApplicationWindow* window = GTV_APPLICATION_WINDOW(userdata);
-    g_info("deleteLokDialog");
-    gtv_application_window_unregister_child_window(window, GTK_WINDOW(pWidget));
-
-    return FALSE;
-}
-
-static gboolean destroyLokDialog(GtkWidget* pWidget, gpointer userdata)
-{
-    GtvApplicationWindow* window = GTV_APPLICATION_WINDOW(userdata);
-    g_info("destroyLokDialog");
-    gtv_application_window_unregister_child_window(window, GTK_WINDOW(pWidget));
-
-    return FALSE;
-}
-
-void openLokDialog( GtkWidget* pSelector, gpointer /*pItem*/ )
-{
-    GtvApplicationWindow* window = GTV_APPLICATION_WINDOW(gtk_widget_get_toplevel(pSelector));
-    gchar* pDialogId = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(pSelector));
-    // Set the width, height of the dialog to something large enough to be able
-    // to render any dialog
-    GtkWidget* pDialog = gtv_lok_dialog_new(LOK_DOC_VIEW(window->lokdocview), pDialogId, 1024, 768);
-    gtv_application_window_register_child_window(window, GTK_WINDOW(pDialog));
-    g_signal_connect(pDialog, "destroy", G_CALLBACK(destroyLokDialog), window);
-    g_signal_connect(pDialog, "delete-event", G_CALLBACK(deleteLokDialog), window);
-    g_free(pDialogId);
-
-    g_info("openLokDialog");
-    gtk_window_set_resizable(GTK_WINDOW(pDialog), false);
-    gtk_widget_show_all(GTK_WIDGET(pDialog));
-    gtk_window_present(GTK_WINDOW(pDialog));
-}
-
 void changeZoom( GtkWidget* pButton, gpointer /* pItem */ )
 {
     static const float fZooms[] = { 0.25, 0.5, 0.75, 1.0, 1.5, 2.0, 3.0, 5.0 };
diff --git a/libreofficekit/qa/gtktiledviewer/gtv.ui b/libreofficekit/qa/gtktiledviewer/gtv.ui
index 7030ecaead5b..c8699b33cd5e 100644
--- a/libreofficekit/qa/gtktiledviewer/gtv.ui
+++ b/libreofficekit/qa/gtktiledviewer/gtv.ui
@@ -452,7 +452,6 @@
           <object class="GtkComboBoxText" id="combo_dialogselector">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
-            <signal name="changed" handler="openLokDialog" swapped="no"/>
           </object>
         </child>
       </object>
commit f17f2ebe2d4b69ff7c8dfed9f15c3f64b7fce38e
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Thu Nov 23 21:00:55 2017 +0530

    lokdialog: gtv: Add width and height props to Dialog GObject
    
    Change-Id: I488a94d9c6cefd37624f755c6308f0b75595df84

diff --git a/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx b/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx
index 001242ec6f52..176fa91fffaa 100644
--- a/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx
@@ -39,6 +39,8 @@ struct GtvLokDialogPrivate
     guint32 m_nLastButtonReleaseTime;
     guint32 m_nKeyModifier;
     guint32 m_nLastButtonPressed;
+    guint32 m_nWidth;
+    guint32 m_nHeight;
 
     // state for child floating windows
     guint32 m_nChildLastButtonPressTime;
@@ -56,6 +58,8 @@ enum
     PROP_0,
     PROP_LOKDOCVIEW_CONTEXT,
     PROP_DIALOG_ID,
+    PROP_DIALOG_WIDTH,
+    PROP_DIALOG_HEIGHT,
     PROP_LAST
 };
 
@@ -90,8 +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 = 1024;
-    int nHeight = 768;
+    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;
@@ -105,6 +110,7 @@ gtv_lok_dialog_draw(GtkWidget* pDialogDrawingArea, cairo_t* pCairo, gpointer)
     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);
@@ -396,6 +402,12 @@ gtv_lok_dialog_set_property(GObject* object, guint propId, const GValue* value,
     case PROP_DIALOG_ID:
         priv->dialogid = g_value_dup_string(value);
         break;
+    case PROP_DIALOG_WIDTH:
+        priv->m_nWidth = g_value_get_uint(value);
+        break;
+    case PROP_DIALOG_HEIGHT:
+        priv->m_nHeight = g_value_get_uint(value);
+        break;
     default:
         G_OBJECT_WARN_INVALID_PROPERTY_ID (object, propId, pspec);
     }
@@ -415,6 +427,12 @@ gtv_lok_dialog_get_property(GObject* object, guint propId, GValue* value, GParam
     case PROP_DIALOG_ID:
         g_value_set_string(value, priv->dialogid);
         break;
+    case PROP_DIALOG_WIDTH:
+        g_value_set_uint(value, priv->m_nWidth);
+        break;
+    case PROP_DIALOG_HEIGHT:
+        g_value_set_uint(value, priv->m_nHeight);
+        break;
     default:
         G_OBJECT_WARN_INVALID_PROPERTY_ID (object, propId, pspec);
     }
@@ -454,6 +472,22 @@ gtv_lok_dialog_class_init(GtvLokDialogClass* klass)
                                                                               G_PARAM_CONSTRUCT_ONLY |
                                                                               G_PARAM_STATIC_STRINGS));
 
+    properties[PROP_DIALOG_WIDTH] = g_param_spec_uint("width",
+                                                     "Dialog width",
+                                                     "Dialog width",
+                                                     0, 1024, 0,
+                                                     static_cast<GParamFlags>(G_PARAM_READWRITE |
+                                                                              G_PARAM_CONSTRUCT_ONLY |
+                                                                              G_PARAM_STATIC_STRINGS));
+
+    properties[PROP_DIALOG_HEIGHT] = g_param_spec_uint("height",
+                                                       "Dialog height",
+                                                      "Dialog height",
+                                                      0, 1024, 0,
+                                                     static_cast<GParamFlags>(G_PARAM_READWRITE |
+                                                                              G_PARAM_CONSTRUCT_ONLY |
+                                                                              G_PARAM_STATIC_STRINGS));
+
     g_object_class_install_properties (G_OBJECT_CLASS(klass), PROP_LAST, properties);
 }
 
@@ -668,12 +702,14 @@ void gtv_lok_dialog_child_close(GtvLokDialog* dialog)
 
 
 GtkWidget*
-gtv_lok_dialog_new(LOKDocView* pDocView, const gchar* dialogId)
+gtv_lok_dialog_new(LOKDocView* pDocView, const gchar* dialogId, guint width, guint height)
 {
     GtkWindow* pWindow = GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(pDocView)));
     return GTK_WIDGET(g_object_new(GTV_TYPE_LOK_DIALOG,
                                    "lokdocview", pDocView,
                                    "dialogid", dialogId,
+                                   "width", width,
+                                   "height", height,
                                    "title", "LOK Dialog",
                                    "modal", false,
                                    "transient-for", pWindow,
diff --git a/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.hxx b/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.hxx
index 619005635b60..8f2161ef5f27 100644
--- a/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.hxx
+++ b/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.hxx
@@ -35,7 +35,7 @@ struct GtvLokDialogClass
 
 GType gtv_lok_dialog_get_type               (void) G_GNUC_CONST;
 
-GtkWidget* gtv_lok_dialog_new(LOKDocView* pDocView, const gchar* dialogId);
+GtkWidget* gtv_lok_dialog_new(LOKDocView* pDocView, const gchar* dialogId, guint width, guint height);
 
 void gtv_lok_dialog_invalidate(GtvLokDialog* dialog, const GdkRectangle& aRectangle);
 
diff --git a/libreofficekit/qa/gtktiledviewer/gtv-signal-handlers.cxx b/libreofficekit/qa/gtktiledviewer/gtv-signal-handlers.cxx
index fee24c6a0f25..521c49ea3eb2 100644
--- a/libreofficekit/qa/gtktiledviewer/gtv-signal-handlers.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtv-signal-handlers.cxx
@@ -312,7 +312,9 @@ void openLokDialog( GtkWidget* pSelector, gpointer /*pItem*/ )
 {
     GtvApplicationWindow* window = GTV_APPLICATION_WINDOW(gtk_widget_get_toplevel(pSelector));
     gchar* pDialogId = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(pSelector));
-    GtkWidget* pDialog = gtv_lok_dialog_new(LOK_DOC_VIEW(window->lokdocview), pDialogId);
+    // Set the width, height of the dialog to something large enough to be able
+    // to render any dialog
+    GtkWidget* pDialog = gtv_lok_dialog_new(LOK_DOC_VIEW(window->lokdocview), pDialogId, 1024, 768);
     gtv_application_window_register_child_window(window, GTK_WINDOW(pDialog));
     g_signal_connect(pDialog, "destroy", G_CALLBACK(destroyLokDialog), window);
     g_signal_connect(pDialog, "delete-event", G_CALLBACK(deleteLokDialog), window);
commit 868654fbfd3ed79c9874572f9730b6fd1bd1b495
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Wed Nov 22 22:25:20 2017 +0530

    lokdialog: Changed dialog painting to allow for modal dialogs
    
    Split IDialogNotifier from IDialogRenderable and make SfxViewShell
    implement it.
    
    We now just send the dialog UNO command to the backend and wait for core
    to emit a 'created' dialog callback which signals dialog creation in the
    backend. The client is then supposed to send the paint commands for
    rendering the dialog.
    
    Change-Id: I1bfbce83c17955fa0212408376d6bcd1b2d2d1dd

diff --git a/include/sfx2/lokhelper.hxx b/include/sfx2/lokhelper.hxx
index e22017c8eccc..93d61fc311fa 100644
--- a/include/sfx2/lokhelper.hxx
+++ b/include/sfx2/lokhelper.hxx
@@ -44,7 +44,7 @@ public:
     /// Emits a LOK_CALLBACK_DIALOG
     static void notifyDialog(const OUString& rDialogId,
                              const OUString& rAction,
-                             const std::vector<vcl::LOKPayloadItem>& rPayload);
+                             const std::vector<vcl::LOKPayloadItem>& rPayload = std::vector<vcl::LOKPayloadItem>());
     /// Emits a LOK_CALLBACK_DIALOG_CHILD
     static void notifyDialogChild(const OUString& rDialogID, const OUString& rAction, const Point& rPos);
     /// Emits a LOK_CALLBACK_INVALIDATE_TILES, but tweaks it according to setOptionalFeatures() if needed.
diff --git a/include/sfx2/viewsh.hxx b/include/sfx2/viewsh.hxx
index 7c9929fbbe9e..de317e88910a 100644
--- a/include/sfx2/viewsh.hxx
+++ b/include/sfx2/viewsh.hxx
@@ -34,6 +34,8 @@
 #include <cppuhelper/interfacecontainer.hxx>
 #include <sfx2/shell.hxx>
 #include <tools/gen.hxx>
+#include <vcl/dialog.hxx>
+#include <vcl/IDialogRenderable.hxx>
 #include <vcl/errcode.hxx>
 #include <vcl/jobset.hxx>
 #include <o3tl/typed_flags_set.hxx>
@@ -140,7 +142,7 @@ template<class T> bool checkSfxViewShell(const SfxViewShell* pShell)
     return dynamic_cast<const T*>(pShell) != nullptr;
 }
 
-class SFX2_DLLPUBLIC SfxViewShell: public SfxShell, public SfxListener, public OutlinerViewShell
+class SFX2_DLLPUBLIC SfxViewShell: public SfxShell, public SfxListener, public OutlinerViewShell, public vcl::IDialogNotifier
 {
 #ifdef INCLUDED_SFX2_VIEWSH_HXX
 friend class SfxViewFrame;
@@ -153,6 +155,7 @@ friend class SfxPrinterController;
     VclPtr<vcl::Window>         pWindow;
     bool                        bNoNewWindow;
     bool                        mbPrinterSettingsModified;
+    std::vector<std::pair<vcl::DialogID, VclPtr<Dialog> > > maOpenedDialogs;
 
 protected:
     virtual void                Activate(bool IsMDIActivate) override;
@@ -221,6 +224,14 @@ public:
     virtual       SfxShell*     GetFormShell()       { return nullptr; };
     virtual const SfxShell*     GetFormShell() const { return nullptr; };
 
+    void                        RegisterDlg(const vcl::DialogID& rDialogId, VclPtr<Dialog> pDlg);
+    VclPtr<Dialog>              GetOpenedDlg(const vcl::DialogID& rDialogId);
+    void                        UnregisterDlg(const vcl::DialogID& rDialogId);
+
+    // 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;
+
     // Focus, KeyInput, Cursor
     virtual void                ShowCursor( bool bOn = true );
     virtual bool                KeyInput( const KeyEvent &rKeyEvent );
diff --git a/include/tools/gen.hxx b/include/tools/gen.hxx
index 079ada40e2e6..2db20125d499 100644
--- a/include/tools/gen.hxx
+++ b/include/tools/gen.hxx
@@ -48,6 +48,7 @@ public:
     long&               A() { return nA; }
     long&               B() { return nB; }
 
+    TOOLS_DLLPUBLIC rtl::OString        toString() const;
     TOOLS_DLLPUBLIC friend SvStream&    ReadPair( SvStream& rIStream, Pair& rPair );
     TOOLS_DLLPUBLIC friend SvStream&    WritePair( SvStream& rOStream, const Pair& rPair );
 
diff --git a/include/vcl/IDialogRenderable.hxx b/include/vcl/IDialogRenderable.hxx
index 4137e960edb9..9a63830566f0 100644
--- a/include/vcl/IDialogRenderable.hxx
+++ b/include/vcl/IDialogRenderable.hxx
@@ -45,6 +45,12 @@ public:
 
     virtual void postDialogChildMouseEvent(const DialogID& rDialogID, int nType, int nX, int nY,
                                            int nCount, int nButtons, int nModifier) = 0;
+};
+
+class VCL_DLLPUBLIC IDialogNotifier
+{
+public:
+    virtual ~IDialogNotifier() {}
 
     // Callbacks
     virtual void notifyDialog(const DialogID& rDialogID,
diff --git a/include/vcl/dialog.hxx b/include/vcl/dialog.hxx
index 8d84aab17606..874828f92a0e 100644
--- a/include/vcl/dialog.hxx
+++ b/include/vcl/dialog.hxx
@@ -57,7 +57,7 @@ private:
     VclPtr<VclButtonBox> mpActionArea;
     VclPtr<VclBox>       mpContentArea;
 
-    vcl::IDialogRenderable*   mpDialogRenderable; // to emit LOK callbacks
+    vcl::IDialogNotifier*  mpDialogNotifier; // to emit LOK callbacks
 
     SAL_DLLPRIVATE void    ImplInitDialogData();
     SAL_DLLPRIVATE void    ImplInitSettings();
@@ -73,8 +73,10 @@ private:
 protected:
     using Window::ImplInit;
     SAL_DLLPRIVATE void    ImplInit( vcl::Window* pParent, WinBits nStyle, InitFlag eFlag = InitFlag::Default );
-    OUString               maID; // Dialog ID (UNO name) for this dialog (set
-                                 // and used by LOK for now)
+    /// Dialog ID (UNO name) for this dialog
+    OUString               maID;
+    /// Necessary to register dialog notifier instance to emit LOK callbacks
+    void                   registerDialogNotifier(vcl::IDialogNotifier* pDialogNotifier);
 
 public:
     SAL_DLLPRIVATE bool    IsInClose() const { return mbInClose; }
@@ -84,8 +86,6 @@ public:
                    void    CloseFloatingWindow();
                    Size    PaintActiveFloatingWindow(VirtualDevice& rDevice) const;
 
-    /// Necessary to register dialog renderable instance to emit LOK callbacks
-    void registerDialogRenderable(vcl::IDialogRenderable* pDialogRenderable, const OUString& aDialogId);
     /// Paints the current dialog to the given virtual device
     void paintDialog(VirtualDevice& rDevice);
     void LogicMouseButtonDown(const MouseEvent& rMouseEvent);
diff --git a/sfx2/source/dialog/tabdlg.cxx b/sfx2/source/dialog/tabdlg.cxx
index ef7c8bdb039d..3a4b64335139 100644
--- a/sfx2/source/dialog/tabdlg.cxx
+++ b/sfx2/source/dialog/tabdlg.cxx
@@ -23,6 +23,7 @@
 #include <algorithm>
 #include <vcl/builder.hxx>
 #include <vcl/msgbox.hxx>
+#include <vcl/IDialogRenderable.hxx>
 #include <unotools/viewoptions.hxx>
 
 #include <appdata.hxx>
@@ -36,6 +37,7 @@
 #include <sfx2/bindings.hxx>
 #include <sfx2/sfxdlg.hxx>
 #include <sfx2/itemconnect.hxx>
+#include <sfx2/viewsh.hxx>
 
 #include <uitest/sfx_uiobject.hxx>
 
@@ -508,6 +510,18 @@ short SfxTabDialog::Execute()
     if ( !m_pTabCtrl->GetPageCount() )
         return RET_CANCEL;
     Start_Impl();
+
+    SfxViewShell* pViewShell = SfxViewShell::Current();
+    if (pViewShell)
+    {
+        pViewShell->RegisterDlg(maID, this);
+        registerDialogNotifier(static_cast<vcl::IDialogNotifier*>(pViewShell));
+        const Size aSize = GetOptimalSize();
+        std::vector<vcl::LOKPayloadItem> aItems;
+        aItems.emplace_back(std::make_pair("size", aSize.toString()));
+        pViewShell->notifyDialog(maID, "created", aItems);
+    }
+
     return TabDialog::Execute();
 }
 
diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx
index 1dfbd26db93c..2d4d8af19a70 100644
--- a/sfx2/source/view/viewsh.cxx
+++ b/sfx2/source/view/viewsh.cxx
@@ -1948,6 +1948,50 @@ Reference< view::XRenderable > SfxViewShell::GetRenderable()
     return xRender;
 }
 
+void SfxViewShell::notifyDialog(const vcl::DialogID& rDialogID, const OUString& rAction, const std::vector<vcl::LOKPayloadItem>& rPayload)
+{
+    SfxLokHelper::notifyDialog(rDialogID, rAction, rPayload);
+}
+
+void SfxViewShell::notifyDialogChild(const vcl::DialogID& rDialogID, const OUString& rAction, const Point& rPos)
+{
+    SfxLokHelper::notifyDialog(rDialogID, rAction);
+}
+
+void SfxViewShell::RegisterDlg(const vcl::DialogID& rDialogId, VclPtr<Dialog> pDlg)
+{
+    if (pDlg)
+        maOpenedDialogs.push_back(std::make_pair(rName, pDlg));
+}
+
+VclPtr<Dialog> SfxViewShell::GetOpenedDlg(const vcl::DialogID& rDialogId)
+{
+    if (rName.startsWith(".uno:"))
+        rName = rName.replaceFirst(".uno:", "");
+
+    const auto it = std::find_if(maOpenedDialogs.begin(),
+                                 maOpenedDialogs.end(),
+                                 [&rDialogId](const std::pair<vcl::DialogID, VclPtr<Dialog>> aItem) {
+                                     return rDialogId == aItem.first;
+                                 });
+
+    Dialog* ret = nullptr;
+    if (it != maOpenedDialogs.end())
+    {
+        ret = it->second;
+    }
+    return ret;
+}
+
+void SfxViewShell::UnregisterDlg(const OUString& rName)
+{
+    maOpenedDialogs.erase(std::remove_if(maOpenedDialogs.begin(),
+                                         maOpenedDialogs.end(),
+                                         [&rDialogId](const std::pair<vcl::DialogID, VclPtr<Dialog>> aItem) {
+                                             return aItem.first == rDialogId;
+                                         }));
+}
+
 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 e8a995ee3142..81b9165cfa15 100644
--- a/sw/inc/unotxdoc.hxx
+++ b/sw/inc/unotxdoc.hxx
@@ -443,12 +443,6 @@ public:
     void postDialogChildMouseEvent(const vcl::DialogID& rDialogID, int nType, int nX, int nY,
                                    int nCount, int nButtons, int nModifier) override;
 
-    void notifyDialog(const vcl::DialogID& rDialogID,
-                      const OUString& rAction,
-                      const std::vector<vcl::LOKPayloadItem>& rPayload = std::vector<vcl::LOKPayloadItem>()) override;
-
-    void notifyDialogChild(const vcl::DialogID& rDialogID, const OUString& rAction, const Point& rPos) override;
-
     // css::tiledrendering::XTiledRenderable
     virtual void SAL_CALL paintTile( const ::css::uno::Any& Parent, ::sal_Int32 nOutputWidth, ::sal_Int32 nOutputHeight, ::sal_Int32 nTilePosX, ::sal_Int32 nTilePosY, ::sal_Int32 nTileWidth, ::sal_Int32 nTileHeight ) override;
 
diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx
index 0d82750de8ce..be27093a9876 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -3641,70 +3641,33 @@ void SAL_CALL SwXTextDocument::paintTile( const ::css::uno::Any& Parent, ::sal_I
 
 void SwXTextDocument::paintDialog(const vcl::DialogID& rDialogID, VirtualDevice& rDevice)
 {
-    SfxViewFrame* pViewFrame = pDocShell->GetView()->GetViewFrame();
-    SfxSlotPool* pSlotPool = SW_MOD()->GetSlotPool();
-    const SfxSlot* pSlot = pSlotPool->GetUnoSlot(rDialogID);
-    if (!pSlot)
-    {
-        SAL_WARN("lok.dialog", "No slot found for " << rDialogID);
-        return;
-    }
-    SfxChildWindow* pChild = pViewFrame->GetChildWindow(pSlot->GetSlotId());
-    if (!pChild)
-    {
-        pViewFrame->ToggleChildWindow(pSlot->GetSlotId());
-        pChild = pViewFrame->GetChildWindow(pSlot->GetSlotId());
-        if (!pChild)
-        {
-            SAL_WARN("lok.dialog", "Dialog " << rDialogID << " is not supported");
-            return;
-        }
-    }
-
-    Dialog* pDlg = static_cast<Dialog*>(pChild->GetWindow());
-    // register the instance so that vcl::Dialog can emit LOK callbacks
-    pDlg->registerDialogRenderable(this, rDialogID);
-    pDlg->paintDialog(rDevice);
+    SfxViewShell* pViewShell = SfxViewShell::Current();
+    VclPtr<Dialog> pDlg = pViewShell->GetOpenedDlg(rDialogID);
+    if (pDlg)
+        pDlg->paintDialog(rDevice);
 }
 
 void SwXTextDocument::getDialogInfo(const vcl::DialogID& rDialogID, OUString& rDialogTitle, int& rWidth, int& rHeight)
 {
-    SfxViewFrame* pViewFrame = pDocShell->GetView()->GetViewFrame();
-    SfxSlotPool* pSlotPool = SW_MOD()->GetSlotPool();
-    const SfxSlot* pSlot = pSlotPool->GetUnoSlot(rDialogID);
-    if (!pSlot)
+    SfxViewShell* pViewShell = SfxViewShell::Current();
+    VclPtr<Dialog> pDlg = pViewShell->GetOpenedDlg(rDialogID);
+    if (pDlg)
     {
-        SAL_WARN("lok.dialog", "No slot found for " << rDialogID);
-        return;
+        rDialogTitle = pDlg->GetText();
+        const Size aSize = pDlg->GetOptimalSize();
+        rWidth = aSize.getWidth();
+        rHeight = aSize.getHeight();
     }
-    SfxChildWindow* pChild = pViewFrame->GetChildWindow(pSlot->GetSlotId());
-    if (!pChild)
-        return;
-
-    Dialog* pDlg = static_cast<Dialog*>(pChild->GetWindow());
-    rDialogTitle = pDlg->GetText();
-    const Size aSize = pDlg->GetOptimalSize();
-    rWidth = aSize.getWidth();
-    rHeight = aSize.getHeight();
 }
 
 void SwXTextDocument::postDialogKeyEvent(const vcl::DialogID& rDialogID, int nType, int nCharCode, int nKeyCode)
 {
     SolarMutexGuard aGuard;
 
-    // check if dialog is already open
-    SfxViewFrame* pViewFrame = pDocShell->GetView()->GetViewFrame();
-    SfxSlotPool* pSlotPool = SW_MOD()->GetSlotPool();
-    const SfxSlot* pSlot = pSlotPool->GetUnoSlot(rDialogID);
-    if (!pSlot)
-    {
-        SAL_WARN("lok.dialog", "No slot found for " << rDialogID);
-        return;
-    }
-    SfxChildWindow* pChild = pViewFrame->GetChildWindow(pSlot->GetSlotId());
-    if (pChild)
+    SfxViewShell* pViewShell = SfxViewShell::Current();
+    VclPtr<Dialog> pDialog = pViewShell->GetOpenedDlg(rDialogID);
+    if (pDialog)
     {
-        Dialog* pDialog = static_cast<Dialog*>(pChild->GetWindow());
         KeyEvent aEvent(nCharCode, nKeyCode, 0);
 
         switch (nType)
@@ -3727,19 +3690,10 @@ void SwXTextDocument::postDialogMouseEvent(const vcl::DialogID& rDialogID, int n
 {
     SolarMutexGuard aGuard;
 
-    // check if dialog is already open
-    SfxViewFrame* pViewFrame = pDocShell->GetView()->GetViewFrame();
-    SfxSlotPool* pSlotPool = SW_MOD()->GetSlotPool();
-    const SfxSlot* pSlot = pSlotPool->GetUnoSlot(rDialogID);
-    if (!pSlot)
+    SfxViewShell* pViewShell = SfxViewShell::Current();
+    VclPtr<Dialog> pDialog = pViewShell->GetOpenedDlg(rDialogID);
+    if (pDialog)
     {
-        SAL_WARN("lok.dialog", "No slot found for " << rDialogID);
-        return;
-    }
-    SfxChildWindow* pChild = pViewFrame->GetChildWindow(pSlot->GetSlotId());
-    if (pChild)
-    {
-        Dialog* pDialog = static_cast<Dialog*>(pChild->GetWindow());
         Point aPos(nX , nY);
         MouseEvent aEvent(aPos, nCount, MouseEventModifiers::SIMPLECLICK, nButtons, nModifier);
 
@@ -3767,19 +3721,10 @@ void SwXTextDocument::postDialogChildMouseEvent(const vcl::DialogID& rDialogID,
 {
     SolarMutexGuard aGuard;
 
-    // check if dialog is already open
-    SfxViewFrame* pViewFrame = pDocShell->GetView()->GetViewFrame();
-    SfxSlotPool* pSlotPool = SW_MOD()->GetSlotPool();
-    const SfxSlot* pSlot = pSlotPool->GetUnoSlot(rDialogID);
-    if (!pSlot)
-    {
-        SAL_WARN("lok.dialog", "No slot found for " << rDialogID);
-        return;
-    }
-    SfxChildWindow* pChild = pViewFrame->GetChildWindow(pSlot->GetSlotId());
-    if (pChild)
+    SfxViewShell* pViewShell = SfxViewShell::Current();
+    VclPtr<Dialog> pDialog = pViewShell->GetOpenedDlg(rDialogID);
+    if (pDialog)
     {
-        Dialog* pDialog = static_cast<Dialog*>(pChild->GetWindow());
         Point aPos(nX , nY);
         MouseEvent aEvent(aPos, nCount, MouseEventModifiers::SIMPLECLICK, nButtons, nModifier);
 
@@ -3801,36 +3746,16 @@ void SwXTextDocument::postDialogChildMouseEvent(const vcl::DialogID& rDialogID,
     }
 }
 
-void SwXTextDocument::notifyDialog(const vcl::DialogID& rDialogID,
-                                   const OUString& rAction,
-                                   const std::vector<vcl::LOKPayloadItem>& rPayload)
-{
-    SfxLokHelper::notifyDialog(rDialogID, rAction, rPayload);
-}
-
-void SwXTextDocument::notifyDialogChild(const vcl::DialogID& rDialogID, const OUString& rAction, const Point& rPos)
-{
-    SfxLokHelper::notifyDialogChild(rDialogID, rAction, rPos);
-}
-
 void SwXTextDocument::paintActiveFloatingWindow(const vcl::DialogID& rDialogID, VirtualDevice& rDevice, int& nWidth, int& nHeight)
 {
-    SfxViewFrame* pViewFrame = pDocShell->GetView()->GetViewFrame();
-    SfxSlotPool* pSlotPool = SW_MOD()->GetSlotPool();
-    const SfxSlot* pSlot = pSlotPool->GetUnoSlot(rDialogID);
-    if (!pSlot)
+    SfxViewShell* pViewShell = SfxViewShell::Current();
+    VclPtr<Dialog> pDialog = pViewShell->GetOpenedDlg(rDialogID);
+    if (pDialog)
     {
-        SAL_WARN("lok.dialog", "No slot found for " << rDialogID);
-        return;
+        const Size aSize = pDialog->PaintActiveFloatingWindow(rDevice);
+        nWidth = aSize.getWidth();
+        nHeight = aSize.getHeight();
     }
-    SfxChildWindow* pChild = pViewFrame->GetChildWindow(pSlot->GetSlotId());
-    if (!pChild)
-        return;
-
-    Dialog* pDlg = static_cast<Dialog*>(pChild->GetWindow());
-    const Size aSize = pDlg->PaintActiveFloatingWindow(rDevice);
-    nWidth = aSize.getWidth();
-    nHeight = aSize.getHeight();
 }
 
 void * SAL_CALL SwXTextDocument::operator new( size_t t) throw()
diff --git a/tools/source/generic/gen.cxx b/tools/source/generic/gen.cxx
index a3bf8d754aa4..2627d9202842 100644
--- a/tools/source/generic/gen.cxx
+++ b/tools/source/generic/gen.cxx
@@ -41,6 +41,16 @@ SvStream& WritePair( SvStream& rOStream, const Pair& rPair )
     return rOStream;
 }
 
+rtl::OString Pair::toString() const
+{
+    std::stringstream ss;
+    // Note that this is not just used for debugging output but the
+    // format is parsed by external code (passed in callbacks to
+    // LibreOfficeKit clients). So don't change.
+    ss << A() << ", " << B();
+    return ss.str().c_str();
+}
+
 void tools::Rectangle::SetSize( const Size& rSize )
 {
     if ( rSize.Width() < 0 )
diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx
index 4db7c9674a83..5b67193b9123 100644
--- a/vcl/source/window/dialog.cxx
+++ b/vcl/source/window/dialog.cxx
@@ -346,7 +346,7 @@ struct DialogImpl
 
 void Dialog::ImplInitDialogData()
 {
-    mpDialogRenderable = nullptr;
+    mpDialogNotifier        = nullptr;
     mpWindowImpl->mbDialog  = true;
     mpPrevExecuteDlg        = nullptr;
     mbInExecute             = false;
@@ -594,9 +594,9 @@ void Dialog::dispose()
     xEventBroadcaster->documentEventOccured(aObject);
     UITestLogger::getInstance().log("DialogClosed");
 
-    if (comphelper::LibreOfficeKit::isActive() && mpDialogRenderable)
+    if (comphelper::LibreOfficeKit::isActive() && mpDialogNotifier)
     {
-        mpDialogRenderable->notifyDialog(maID, "close");
+        mpDialogNotifier->notifyDialog(maID, "close");
     }
 
     SystemWindow::dispose();
@@ -789,6 +789,9 @@ bool Dialog::ImplStartExecuteModal()
     case Application::DialogCancelMode::Off:
         break;
     case Application::DialogCancelMode::Silent:
+        if (ImplGetDialogText(this) == "Character")
+            break;
+
         SAL_INFO(
             "vcl",
             "Dialog \"" << ImplGetDialogText(this)
@@ -874,12 +877,11 @@ bool Dialog::selectPageByUIXMLDescription(const OString& /*rUIXMLDescription*/)
     return true;
 }
 
-void Dialog::registerDialogRenderable(vcl::IDialogRenderable* pDialogRenderable, const OUString& aDialogId)
+void Dialog::registerDialogNotifier(vcl::IDialogNotifier* pDialogNotifier)
 {
-    if (pDialogRenderable && !mpDialogRenderable)
+    if (pDialogNotifier && !mpDialogNotifier)
     {
-        mpDialogRenderable = pDialogRenderable;
-        maID = aDialogId;
+        mpDialogNotifier = pDialogNotifier;
     }
 }
 
@@ -955,29 +957,29 @@ void Dialog::LogicMouseMoveChild(const MouseEvent& rMouseEvent)
 
 void Dialog::InvalidateFloatingWindow(const Point& rPos)
 {
-    if (comphelper::LibreOfficeKit::isActive() && mpDialogRenderable && !maID.isEmpty())
+    if (comphelper::LibreOfficeKit::isActive() && mpDialogNotifier && !maID.isEmpty())
     {
-        mpDialogRenderable->notifyDialogChild(maID, "invalidate", rPos);
+        mpDialogNotifier->notifyDialogChild(maID, "invalidate", rPos);
     }
 }
 
 void Dialog::CloseFloatingWindow()
 {
-    if (comphelper::LibreOfficeKit::isActive() && mpDialogRenderable && !maID.isEmpty())
+    if (comphelper::LibreOfficeKit::isActive() && mpDialogNotifier && !maID.isEmpty())
     {
-        mpDialogRenderable->notifyDialogChild(maID, "close", Point(0, 0));
+        mpDialogNotifier->notifyDialogChild(maID, "close", Point(0, 0));
     }
 }
 
 void Dialog::LogicInvalidate(const tools::Rectangle* pRectangle)
 {
-    if (!comphelper::LibreOfficeKit::isDialogPainting() && mpDialogRenderable && !maID.isEmpty())
+    if (!comphelper::LibreOfficeKit::isDialogPainting() && mpDialogNotifier && !maID.isEmpty())
     {
         std::vector<vcl::LOKPayloadItem> aPayload;
         if (pRectangle)
             aPayload.push_back(std::make_pair(OString("rectangle"), pRectangle->toString()));
 
-        mpDialogRenderable->notifyDialog(maID, "invalidate", aPayload);
+        mpDialogNotifier->notifyDialog(maID, "invalidate", aPayload);
     }
 }
 
@@ -1023,9 +1025,9 @@ void Dialog::LOKCursor(const OUString& rAction, const std::vector<vcl::LOKPayloa
 {
     assert(comphelper::LibreOfficeKit::isActive());
 
-    if (!comphelper::LibreOfficeKit::isDialogPainting() && mpDialogRenderable && !maID.isEmpty())
+    if (!comphelper::LibreOfficeKit::isDialogPainting() && mpDialogNotifier && !maID.isEmpty())
     {
-        mpDialogRenderable->notifyDialog(maID, rAction, rPayload);
+        mpDialogNotifier->notifyDialog(maID, rAction, rPayload);
     }
 }
 
@@ -1344,9 +1346,9 @@ void Dialog::Resize()
     SystemWindow::Resize();
 
     // inform LOK clients
-    if (!comphelper::LibreOfficeKit::isDialogPainting() && mpDialogRenderable && !maID.isEmpty())
+    if (!comphelper::LibreOfficeKit::isDialogPainting() && mpDialogNotifier && !maID.isEmpty())
     {
-        mpDialogRenderable->notifyDialog(maID, "invalidate");
+        mpDialogNotifier->notifyDialog(maID, "invalidate");
     }
 }
 


More information about the Libreoffice-commits mailing list