diff options
author | Caolán McNamara <caolanm@redhat.com> | 2018-10-03 12:06:56 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-10-03 21:02:53 +0200 |
commit | 19ec881034dbabbdc72779eb9382d0deb17ac569 (patch) | |
tree | a58e6fafc59a4c284f8fcb88e8b149be3e78c008 /sfx2 | |
parent | f6390539a271e287a96419a8d13d16800aa756b0 (diff) |
Related: tdf#120277 extract common piece of SfxModalDialog LOK notification
Change-Id: Ie14cd80d5c33f58673823ee16fa8037efaa17773
Reviewed-on: https://gerrit.libreoffice.org/61303
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/dialog/basedlgs.cxx | 52 |
1 files changed, 27 insertions, 25 deletions
diff --git a/sfx2/source/dialog/basedlgs.cxx b/sfx2/source/dialog/basedlgs.cxx index bb944a05e89b..f40dbc910efe 100644 --- a/sfx2/source/dialog/basedlgs.cxx +++ b/sfx2/source/dialog/basedlgs.cxx @@ -152,30 +152,41 @@ 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); } ModalDialog::StateChanged(nType); } - void SfxModelessDialog::StateChanged( StateChangedType nStateChange ) { if ( nStateChange == StateChangedType::InitShow ) @@ -215,17 +226,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; } |