Related: tdf#125198 centralize notifyWindow:created to one place

Change-Id: I2729cb85f156ddafec69cc3280e9d8544f7c6182
Reviewed-on: https://gerrit.libreoffice.org/72117
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx
index c1921d2..7f7fc3a 100644
--- a/vcl/source/window/dialog.cxx
+++ b/vcl/source/window/dialog.cxx
@@ -752,23 +752,25 @@ void Dialog::StateChanged( StateChangedType nType )
{
    if (nType == StateChangedType::InitShow)
    {
        if (comphelper::LibreOfficeKit::isActive() && !GetLOKNotifier())
        DoInitialLayout();

        const bool bKitActive = comphelper::LibreOfficeKit::isActive();
        if (bKitActive)
        {
            vcl::ILibreOfficeKitNotifier* pViewShell = mpDialogImpl->m_aInstallLOKNotifierHdl.Call(nullptr);
            if (pViewShell)
            if (!GetLOKNotifier())
                SetLOKNotifier(mpDialogImpl->m_aInstallLOKNotifierHdl.Call(nullptr));

            if (const vcl::ILibreOfficeKitNotifier* pNotifier = 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);
                pNotifier->notifyWindow(GetLOKWindowId(), "created", aItems);
            }
        }

        DoInitialLayout();

        if ( !HasChildPathFocus() || HasFocus() )
            GrabFocusToFirstControl();
        if ( !(GetStyle() & WB_CLOSEABLE) )
@@ -889,12 +891,7 @@ bool Dialog::ImplStartExecute()
    if (bModal)
    {
        if (bKitActive && !GetLOKNotifier())
        {
            if (vcl::ILibreOfficeKitNotifier* pViewShell = mpDialogImpl->m_aInstallLOKNotifierHdl.Call(nullptr))
            {
                SetLOKNotifier(pViewShell);
            }
        }
            SetLOKNotifier(mpDialogImpl->m_aInstallLOKNotifierHdl.Call(nullptr));

        switch ( Application::GetDialogCancelMode() )
        {
@@ -925,19 +922,6 @@ bool Dialog::ImplStartExecute()
            std::abort();
        }

        if (bKitActive)
        {
            if(const vcl::ILibreOfficeKitNotifier* pNotifier = GetLOKNotifier())
            {
                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());
                pNotifier->notifyWindow(GetLOKWindowId(), "created", aItems);
            }
        }

#ifdef DBG_UTIL
        vcl::Window* pParent = GetParent();
        if ( pParent )