From 08f9439cdf32d668b04af0912fa2cff18dda6a0c Mon Sep 17 00:00:00 2001 From: Ashod Nakashian Date: Sat, 29 Jun 2019 10:52:11 -0400 Subject: leaflet: fire Doc_ModifiedStatus with modified state of the document When .uno:ModifiedStatus is received, now Doc_ModifiedStatus is fired to inform the client of the modified state of the document. This is useful in case the integration needs to prompt the user to save before closing the document (which they can catch with the onunload or onbeforeunload events in the browser, as well as with our UI_Close when the default handler is disabled). Includes working sample and documentation. Change-Id: Ief30483e2f078b0aa9f3c006a1ecb4093375174c Reviewed-on: https://gerrit.libreoffice.org/74891 Reviewed-by: Jan Holesovsky Tested-by: Jan Holesovsky --- loleaflet/html/framed.doc.html | 24 +++++++++++++++++++++++- loleaflet/reference.html | 15 +++++++++++++++ loleaflet/src/map/Map.js | 6 +++++- test/data/empty.odt | Bin 8131 -> 7405 bytes 4 files changed, 43 insertions(+), 2 deletions(-) diff --git a/loleaflet/html/framed.doc.html b/loleaflet/html/framed.doc.html index d89a1a98f..80f842c40 100644 --- a/loleaflet/html/framed.doc.html +++ b/loleaflet/html/framed.doc.html @@ -87,12 +87,30 @@ function receiveMessage(event) { console.log('==== framed.doc.html receiveMessage: ' + event.data); var msg = JSON.parse(event.data); - if (msg && msg.MessageId == 'App_LoadingStatus') { + if (!msg) { + return; + } + if (msg.MessageId == 'App_LoadingStatus') { if (msg.Values) { if (msg.Values.Status == 'Document_Loaded') { window.frames[0].postMessage(JSON.stringify({'MessageId': 'Host_PostmessageReady'}), '*'); } } + } else if (msg.MessageId == 'Doc_ModifiedStatus') { + if (msg.Values) { + if (msg.Values.Modified == true) { + document.getElementById("ModifiedStatus").innerHTML = "Modified"; + } + else { + document.getElementById("ModifiedStatus").innerHTML = "Saved"; + } + } + } else if (msg.MessageId == 'Action_Save_Resp') { + if (msg.Values) { + if (msg.Values.success == true) { + document.getElementById("ModifiedStatus").innerHTML = "Saved"; + } + } } } @@ -125,6 +143,10 @@

+

Modified Status: + Saved +

+