[Libreoffice-commits] core.git: Branch 'libreoffice-6-1' - sfx2/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Wed Oct 31 09:26:12 UTC 2018


 sfx2/source/dialog/basedlgs.cxx |   52 ++++++++++++++++++++--------------------
 1 file changed, 27 insertions(+), 25 deletions(-)

New commits:
commit 86d477d0d823e2aafdf6f54149a62bbf54741001
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Wed Oct 3 12:06:56 2018 +0100
Commit:     Miklos Vajna <vmiklos at collabora.co.uk>
CommitDate: Wed Oct 31 10:25:50 2018 +0100

    Related: tdf#120277 extract common piece of SfxModalDialog LOK notification
    
    Change-Id: Ie14cd80d5c33f58673823ee16fa8037efaa17773
    Reviewed-on: https://gerrit.libreoffice.org/61310
    Tested-by: Jenkins
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>

diff --git a/sfx2/source/dialog/basedlgs.cxx b/sfx2/source/dialog/basedlgs.cxx
index 9aa81f460a2a..8bda421974bf 100644
--- a/sfx2/source/dialog/basedlgs.cxx
+++ b/sfx2/source/dialog/basedlgs.cxx
@@ -153,24 +153,36 @@ void SfxModalDialog::CreateOutputItemSet( const SfxItemSet& rSet )
     }
 }
 
+namespace
+{
+    void InstallLOKNotifierCallback(Dialog& rDialog)
+    {
+        if (rDialog.GetLOKNotifier())
+            return;
+
+        SfxViewShell* pViewShell = SfxViewShell::Current();
+        if (!pViewShell)
+            return;
+
+        // There are some dialogs, like Hyperlink dialog, which inherit from
+        // SfxModalDialog even though they are modeless, i.e., their Execute method
+        // isn't called.
+        rDialog.SetLOKNotifier(pViewShell);
+        std::vector<vcl::LOKPayloadItem> aItems;
+        aItems.emplace_back("type", "dialog");
+        aItems.emplace_back("size", rDialog.GetSizePixel().toString());
+        if (!rDialog.GetText().isEmpty())
+            aItems.emplace_back("title", rDialog.GetText().toUtf8());
+        pViewShell->notifyWindow(rDialog.GetLOKWindowId(), "created", aItems);
+    }
+}
 
 void SfxModalDialog::StateChanged( StateChangedType nType )
 {
     if (comphelper::LibreOfficeKit::isActive())
     {
-        if (nType == StateChangedType::InitShow && !GetLOKNotifier())
-        {
-            // There are some dialogs, like Hyperlink dialog, which inherit from
-            // SfxModalDialog even though they are modeless, i.e., their Execute method
-            // isn't called.
-            SetLOKNotifier(SfxViewShell::Current());
-            std::vector<vcl::LOKPayloadItem> aItems;
-            aItems.emplace_back("type", "dialog");
-            aItems.emplace_back("size", GetSizePixel().toString());
-            if (!GetText().isEmpty())
-                aItems.emplace_back("title", GetText().toUtf8());
-            SfxViewShell::Current()->notifyWindow(GetLOKWindowId(), "created", aItems);
-        }
+        if (nType == StateChangedType::InitShow)
+            InstallLOKNotifierCallback(*this);
         else if (nType == StateChangedType::Visible &&
                  !IsVisible() &&
                  GetLOKNotifier())
@@ -183,7 +195,6 @@ void SfxModalDialog::StateChanged( StateChangedType nType )
     ModalDialog::StateChanged(nType);
 }
 
-
 void SfxModelessDialog::StateChanged( StateChangedType nStateChange )
 {
     if ( nStateChange == StateChangedType::InitShow )
@@ -223,17 +234,8 @@ void SfxModelessDialog::StateChanged( StateChangedType nStateChange )
             }
         }
 
-        SfxViewShell* pViewShell = SfxViewShell::Current();
-        if (comphelper::LibreOfficeKit::isActive() && pViewShell && !GetLOKNotifier())
-        {
-            SetLOKNotifier(pViewShell);
-            std::vector<vcl::LOKPayloadItem> aItems;
-            aItems.emplace_back("type", "dialog");
-            aItems.emplace_back("size", GetSizePixel().toString());
-            if (!GetText().isEmpty())
-                aItems.emplace_back("title", GetText().toUtf8());
-            pViewShell->notifyWindow(GetLOKWindowId(), "created", aItems);
-        }
+        if (comphelper::LibreOfficeKit::isActive())
+            InstallLOKNotifierCallback(*this);
 
         pImpl->bConstructed = true;
     }


More information about the Libreoffice-commits mailing list