summaryrefslogtreecommitdiff
path: root/vcl/jsdialog
diff options
context:
space:
mode:
authorSzymon Kłos <szymon.klos@collabora.com>2020-12-03 11:16:08 +0100
committerSzymon Kłos <szymon.klos@collabora.com>2020-12-08 11:22:31 +0100
commit913fa080fa8ed17228dc87fe885ec47df917ade6 (patch)
tree09f575cd673a98e3f761d1b538b011e5448ba7bf /vcl/jsdialog
parentf36433c10a4be39bd5e93621ee46766c587ad57c (diff)
jsdialog: send close on dialog response
Change-Id: I730d99cc9aa519f07d6b1c436d749f2c0b044bfd Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107151 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Szymon Kłos <szymon.klos@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107349 Tested-by: Szymon Kłos <szymon.klos@collabora.com>
Diffstat (limited to 'vcl/jsdialog')
-rw-r--r--vcl/jsdialog/jsdialogbuilder.cxx82
1 files changed, 57 insertions, 25 deletions
diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx
index 3c663bac10e0..08e66eedb6f5 100644
--- a/vcl/jsdialog/jsdialogbuilder.cxx
+++ b/vcl/jsdialog/jsdialogbuilder.cxx
@@ -40,7 +40,7 @@ JSDialogNotifyIdle::JSDialogNotifyIdle(VclPtr<vcl::Window> aNotifierWindow,
void JSDialogNotifyIdle::ForceUpdate() { m_bForce = true; }
-void JSDialogNotifyIdle::Invoke()
+void JSDialogNotifyIdle::send(std::unique_ptr<tools::JsonWriter> aJsonWriter)
{
if (!m_aNotifierWindow)
return;
@@ -48,39 +48,63 @@ void JSDialogNotifyIdle::Invoke()
const vcl::ILibreOfficeKitNotifier* pNotifier = m_aNotifierWindow->GetLOKNotifier();
if (pNotifier)
{
- tools::JsonWriter aJsonWriter;
- m_aContentWindow->DumpAsPropertyTree(aJsonWriter);
- aJsonWriter.put("id", m_aNotifierWindow->GetLOKWindowId());
- aJsonWriter.put("jsontype", m_sTypeOfJSON);
+ if (m_bForce || !aJsonWriter->isDataEquals(m_LastNotificationMessage))
+ {
+ m_bForce = false;
+ m_LastNotificationMessage = aJsonWriter->extractAsStdString();
+ pNotifier->libreOfficeKitViewCallback(LOK_CALLBACK_JSDIALOG,
+ m_LastNotificationMessage.c_str());
+ }
+ }
+}
+
+std::unique_ptr<tools::JsonWriter> JSDialogNotifyIdle::dumpStatus() const
+{
+ std::unique_ptr<tools::JsonWriter> aJsonWriter(new tools::JsonWriter());
+
+ if (!m_aContentWindow || !m_aNotifierWindow)
+ return aJsonWriter;
- if (m_sTypeOfJSON == "autofilter")
+ m_aContentWindow->DumpAsPropertyTree(*aJsonWriter);
+ aJsonWriter->put("id", m_aNotifierWindow->GetLOKWindowId());
+ aJsonWriter->put("jsontype", m_sTypeOfJSON);
+
+ if (m_sTypeOfJSON == "autofilter")
+ {
+ vcl::Window* pWindow = m_aContentWindow.get();
+ DockingWindow* pDockingWIndow = dynamic_cast<DockingWindow*>(pWindow);
+ while (pWindow && !pDockingWIndow)
{
- vcl::Window* pWindow = m_aContentWindow.get();
- DockingWindow* pDockingWIndow = dynamic_cast<DockingWindow*>(pWindow);
- while (pWindow && !pDockingWIndow)
- {
- pWindow = pWindow->GetParent();
- pDockingWIndow = dynamic_cast<DockingWindow*>(pWindow);
- }
-
- if (pDockingWIndow)
- {
- Point aPos = pDockingWIndow->GetFloatingPos();
- aJsonWriter.put("posx", aPos.getX());
- aJsonWriter.put("posy", aPos.getY());
- }
+ pWindow = pWindow->GetParent();
+ pDockingWIndow = dynamic_cast<DockingWindow*>(pWindow);
}
- if (m_bForce || !aJsonWriter.isDataEquals(m_LastNotificationMessage))
+ if (pDockingWIndow)
{
- m_bForce = false;
- m_LastNotificationMessage = aJsonWriter.extractAsStdString();
- pNotifier->libreOfficeKitViewCallback(LOK_CALLBACK_JSDIALOG,
- m_LastNotificationMessage.c_str());
+ Point aPos = pDockingWIndow->GetFloatingPos();
+ aJsonWriter->put("posx", aPos.getX());
+ aJsonWriter->put("posy", aPos.getY());
}
}
+
+ return aJsonWriter;
+}
+
+std::unique_ptr<tools::JsonWriter> JSDialogNotifyIdle::generateCloseMessage() const
+{
+ std::unique_ptr<tools::JsonWriter> aJsonWriter(new tools::JsonWriter());
+ if (m_aNotifierWindow)
+ aJsonWriter->put("id", m_aNotifierWindow->GetLOKWindowId());
+ aJsonWriter->put("jsontype", m_sTypeOfJSON);
+ aJsonWriter->put("action", "close");
+
+ return aJsonWriter;
}
+void JSDialogNotifyIdle::Invoke() { send(dumpStatus()); }
+
+void JSDialogNotifyIdle::sendClose() { send(generateCloseMessage()); }
+
void JSDialogSender::notifyDialogState(bool bForce)
{
if (bForce)
@@ -88,6 +112,8 @@ void JSDialogSender::notifyDialogState(bool bForce)
mpIdleNotify->Start();
}
+void JSDialogSender::sendClose() { mpIdleNotify->sendClose(); }
+
namespace
{
vcl::Window* extract_sal_widget(weld::Widget* pParent)
@@ -611,6 +637,12 @@ void JSDialog::undo_collapse()
notifyDialogState();
}
+void JSDialog::response(int response)
+{
+ sendClose();
+ SalInstanceDialog::response(response);
+}
+
JSLabel::JSLabel(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> aContentWindow,
FixedText* pLabel, SalInstanceBuilder* pBuilder, bool bTakeOwnership,
std::string sTypeOfJSON)