summaryrefslogtreecommitdiff
path: root/sfx2/source
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2018-10-03 12:06:56 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2018-10-31 10:25:50 +0100
commit86d477d0d823e2aafdf6f54149a62bbf54741001 (patch)
tree0b6c3389ad3692d7730e68d74fb5352ecbbc4d01 /sfx2/source
parent4947deeaee3c94b022930fbf69ac839121133c09 (diff)
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@collabora.co.uk>
Diffstat (limited to 'sfx2/source')
-rw-r--r--sfx2/source/dialog/basedlgs.cxx52
1 files changed, 27 insertions, 25 deletions
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;
}