From b5b0ac92512ead854066f7e5c908109c848e7327 Mon Sep 17 00:00:00 2001 From: Pranav Kant Date: Thu, 14 Dec 2017 13:11:00 +0530 Subject: lokdialog: Send close callback when dialog dissappears too Change-Id: I88bea3dc1ae938d31462e85ca1a8f48dd13e8e89 (cherry picked from commit 76de866e162502518acbc0ab020c257b80946c2d) Reviewed-on: https://gerrit.libreoffice.org/46439 Reviewed-by: Jan Holesovsky Tested-by: Jan Holesovsky --- sfx2/source/dialog/basedlgs.cxx | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/sfx2/source/dialog/basedlgs.cxx b/sfx2/source/dialog/basedlgs.cxx index 8bbf8bd3dee6..77486632c91d 100644 --- a/sfx2/source/dialog/basedlgs.cxx +++ b/sfx2/source/dialog/basedlgs.cxx @@ -167,10 +167,9 @@ void SfxModalDialog::dispose() SetDialogData_Impl(); delete pOutputSet; - SfxViewShell* pViewShell = SfxViewShell::Current(); - if (comphelper::LibreOfficeKit::isActive() && pViewShell) + if (comphelper::LibreOfficeKit::isActive() && GetLOKNotifier()) { - pViewShell->notifyWindow(GetLOKWindowId(), "close"); + SfxViewShell::Current()->notifyWindow(GetLOKWindowId(), "close"); ReleaseLOKNotifier(); } @@ -214,13 +213,13 @@ void SfxModalDialog::CreateOutputItemSet( const SfxItemSet& rSet ) void SfxModalDialog::StateChanged( StateChangedType nType ) { - if (comphelper::LibreOfficeKit::isActive() && nType == StateChangedType::InitShow) + if (comphelper::LibreOfficeKit::isActive()) { - // There are some dialogs, like Hyperlink dialog, which inherit from - // SfxModalDialog even though they are modeless, i.e., their Execute method - // isn't called. - if (!GetLOKNotifier()) + 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()); const Size aSize = GetOptimalSize(); std::vector aItems; @@ -228,6 +227,13 @@ void SfxModalDialog::StateChanged( StateChangedType nType ) aItems.emplace_back(std::make_pair("size", aSize.toString())); SfxViewShell::Current()->notifyWindow(GetLOKWindowId(), "created", aItems); } + else if (nType == StateChangedType::Visible && + !IsVisible() && + GetLOKNotifier()) + { + SfxViewShell::Current()->notifyWindow(GetLOKWindowId(), "close"); + ReleaseLOKNotifier(); + } } ModalDialog::StateChanged(nType); -- cgit v1.2.3