diff options
author | Henry Castro <hcastro@collabora.com> | 2020-12-17 11:34:46 -0400 |
---|---|---|
committer | Henry Castro <hcastro@collabora.com> | 2021-01-19 02:02:53 +0100 |
commit | e104272ac452d39a0f926f508051bd6af6613d24 (patch) | |
tree | bac5073c35a3636ef07b31593b3dc2674b8b4e4a /vcl/jsdialog/jsdialogbuilder.cxx | |
parent | 95f3f93d07f9a7459c610b8989d44f11a21dab0a (diff) |
jsdialog: use "WindowPaint" event to update
If the idle notifier is disabled instead it uses
the "WindowPaint" when the model has changed to
notify update status to client side.
Anyway the "WindowPaint" is supposed to be
asynchronous.
Change-Id: I0bb99526c72510a97e3906340c1e9269478da8cb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107916
Tested-by: Jenkins
Reviewed-by: Henry Castro <hcastro@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109143
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Diffstat (limited to 'vcl/jsdialog/jsdialogbuilder.cxx')
-rw-r--r-- | vcl/jsdialog/jsdialogbuilder.cxx | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx index 0d5f2c8f77ce..0cd9661b76ec 100644 --- a/vcl/jsdialog/jsdialogbuilder.cxx +++ b/vcl/jsdialog/jsdialogbuilder.cxx @@ -91,6 +91,40 @@ boost::property_tree::ptree JSDialogNotifyIdle::dumpStatus() const return aTree; } +void JSDialogNotifyIdle::updateStatus(VclPtr<vcl::Window> pWindow) +{ + if (!m_aNotifierWindow) + return; + + if (m_aNotifierWindow->IsReallyVisible()) + { + if (const vcl::ILibreOfficeKitNotifier* pNotifier = m_aNotifierWindow->GetLOKNotifier()) + { + boost::property_tree::ptree aTree; + + aTree.put("commandName", ".uno:jsdialog"); + aTree.put("success", "true"); + { + boost::property_tree::ptree aResult; + aResult.put("dialog_id", m_aNotifierWindow->GetLOKWindowId()); + aResult.put("control_id", pWindow->get_id()); + { + boost::property_tree::ptree aControl; + aControl = pWindow->DumpAsPropertyTree(); + aResult.add_child("control", aControl); + } + aTree.add_child("result", aResult); + } + + std::stringstream aStream; + boost::property_tree::write_json(aStream, aTree); + const std::string message = aStream.str(); + pNotifier->libreOfficeKitViewCallback(LOK_CALLBACK_UNO_COMMAND_RESULT, + message.c_str()); + } + } +} + boost::property_tree::ptree JSDialogNotifyIdle::generateCloseMessage() const { boost::property_tree::ptree aTree; @@ -120,6 +154,11 @@ void JSDialogSender::sendClose() { mpIdleNotify->sendClose(); } void JSDialogSender::dumpStatus() { mpIdleNotify->Invoke(); } +void JSDialogSender::sendUpdate(VclPtr<vcl::Window> pWindow) +{ + mpIdleNotify->updateStatus(pWindow); +} + // Drag and drop class JSDropTargetDropContext @@ -935,6 +974,8 @@ JSTreeView::JSTreeView(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> : JSWidget<SalInstanceTreeView, ::SvTabListBox>(aNotifierWindow, aContentWindow, pTreeView, pBuilder, bTakeOwnership, sTypeOfJSON) { + if (aNotifierWindow && aNotifierWindow->IsDisableIdleNotify()) + pTreeView->AddEventListener(LINK(this, JSTreeView, on_window_event)); } void JSTreeView::set_toggle(int pos, TriState eState, int col) @@ -1024,6 +1065,15 @@ void JSTreeView::set_text(const weld::TreeIter& rIter, const OUString& rStr, int notifyDialogState(); } +IMPL_LINK(JSTreeView, on_window_event, VclWindowEvent&, rEvent, void) +{ + if (rEvent.GetId() == VclEventId::WindowPaint && get_visible() && m_xTreeView->IsDirtyModel()) + { + sendUpdate(m_xTreeView); + m_xTreeView->SetDirtyModel(false); + } +} + JSExpander::JSExpander(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> aContentWindow, ::VclExpander* pExpander, SalInstanceBuilder* pBuilder, bool bTakeOwnership, std::string sTypeOfJSON) |