vcl/inc/jsdialog/jsdialogbuilder.hxx | 9 +++ vcl/jsdialog/jsdialogbuilder.cxx | 79 ++++++++++++++++++++++++----------- 2 files changed, 64 insertions(+), 24 deletions(-)
New commits: commit 393a3d5c586cc54c144922806abc05ce984f64ed Author: Szymon Kłos <szymon.k...@collabora.com> AuthorDate: Thu Dec 3 11:16:08 2020 +0100 Commit: Szymon Kłos <szymon.k...@collabora.com> CommitDate: Thu Dec 3 12:36:16 2020 +0100 jsdialog: send close on dialog response Change-Id: I730d99cc9aa519f07d6b1c436d749f2c0b044bfd Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107151 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Szymon Kłos <szymon.k...@collabora.com> diff --git a/vcl/inc/jsdialog/jsdialogbuilder.hxx b/vcl/inc/jsdialog/jsdialogbuilder.hxx index b6ee02c4ff04..fc0ffa6608eb 100644 --- a/vcl/inc/jsdialog/jsdialogbuilder.hxx +++ b/vcl/inc/jsdialog/jsdialogbuilder.hxx @@ -25,6 +25,7 @@ #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/datatransfer/dnd/XDropTarget.hpp> #include <cppuhelper/compbase.hxx> +#include <boost/property_tree/ptree_fwd.hpp> class ToolBox; class SfxViewShell; @@ -48,6 +49,12 @@ public: void Invoke() override; void ForceUpdate(); + void sendClose(); + +private: + void send(const boost::property_tree::ptree& rTree); + boost::property_tree::ptree dumpStatus() const; + boost::property_tree::ptree generateCloseMessage() const; }; class VCL_DLLPUBLIC JSDialogSender @@ -62,6 +69,7 @@ public: } void notifyDialogState(bool bForce = false); + void sendClose(); }; class JSDropTarget final @@ -229,6 +237,7 @@ public: virtual void collapse(weld::Widget* pEdit, weld::Widget* pButton) override; virtual void undo_collapse() override; + virtual void response(int response) override; }; class JSLabel : public JSWidget<SalInstanceLabel, FixedText> diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx index befb682849a7..85e578390485 100644 --- a/vcl/jsdialog/jsdialogbuilder.cxx +++ b/vcl/jsdialog/jsdialogbuilder.cxx @@ -34,7 +34,7 @@ JSDialogNotifyIdle::JSDialogNotifyIdle(VclPtr<vcl::Window> aNotifierWindow, void JSDialogNotifyIdle::ForceUpdate() { m_bForce = true; } -void JSDialogNotifyIdle::Invoke() +void JSDialogNotifyIdle::send(const boost::property_tree::ptree& rTree) { try { @@ -45,29 +45,7 @@ void JSDialogNotifyIdle::Invoke() if (pNotifier) { std::stringstream aStream; - boost::property_tree::ptree aTree = m_aContentWindow->DumpAsPropertyTree(); - aTree.put("id", m_aNotifierWindow->GetLOKWindowId()); - aTree.put("jsontype", m_sTypeOfJSON); - - if (m_sTypeOfJSON == "autofilter") - { - 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(); - aTree.put("posx", aPos.getX()); - aTree.put("posy", aPos.getY()); - } - } - - boost::property_tree::write_json(aStream, aTree); + boost::property_tree::write_json(aStream, rTree); const std::string message = aStream.str(); if (m_bForce || message != m_LastNotificationMessage) { @@ -83,6 +61,51 @@ void JSDialogNotifyIdle::Invoke() } } +boost::property_tree::ptree JSDialogNotifyIdle::dumpStatus() const +{ + if (!m_aContentWindow || !m_aNotifierWindow) + return boost::property_tree::ptree(); + + boost::property_tree::ptree aTree = m_aContentWindow->DumpAsPropertyTree(); + aTree.put("id", m_aNotifierWindow->GetLOKWindowId()); + aTree.put("jsontype", m_sTypeOfJSON); + + if (m_sTypeOfJSON == "autofilter") + { + 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(); + aTree.put("posx", aPos.getX()); + aTree.put("posy", aPos.getY()); + } + } + + return aTree; +} + +boost::property_tree::ptree JSDialogNotifyIdle::generateCloseMessage() const +{ + boost::property_tree::ptree aTree; + if (m_aNotifierWindow) + aTree.put("id", m_aNotifierWindow->GetLOKWindowId()); + aTree.put("jsontype", m_sTypeOfJSON); + aTree.put("action", "close"); + + return aTree; +} + +void JSDialogNotifyIdle::Invoke() { send(dumpStatus()); } + +void JSDialogNotifyIdle::sendClose() { send(generateCloseMessage()); } + void JSDialogSender::notifyDialogState(bool bForce) { if (bForce) @@ -90,6 +113,8 @@ void JSDialogSender::notifyDialogState(bool bForce) mpIdleNotify->Start(); } +void JSDialogSender::sendClose() { mpIdleNotify->sendClose(); } + // Drag and drop class JSDropTargetDropContext @@ -620,6 +645,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) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits