[Libreoffice-commits] online.git: Branch 'distro/cib/libreoffice-6-2' - 7 commits - configure.ac loleaflet/html loleaflet/js loleaflet/reference.html loleaflet/src wsd/ClientSession.cpp
Samuel Mehrbrodt (via logerrit)
logerrit at kemper.freedesktop.org
Mon Jul 15 11:45:06 UTC 2019
configure.ac | 2
loleaflet/html/framed.doc.html | 114 ++++++++++++++++++++++++------
loleaflet/js/toolbar.js | 5 +
loleaflet/reference.html | 64 ++++++++++++++++
loleaflet/src/control/Control.Menubar.js | 9 +-
loleaflet/src/map/Map.js | 7 +
loleaflet/src/map/handler/Map.Keyboard.js | 7 +
loleaflet/src/map/handler/Map.WOPI.js | 14 +++
wsd/ClientSession.cpp | 4 -
9 files changed, 196 insertions(+), 30 deletions(-)
New commits:
commit e80ea97d88b4d32d51a8014bd56135d9a2bcbfff
Author: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
AuthorDate: Mon Jul 15 13:44:27 2019 +0200
Commit: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
CommitDate: Mon Jul 15 13:44:27 2019 +0200
Release 6.2.5
diff --git a/configure.ac b/configure.ac
index 7d70a3635..6e4fb5755 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3,7 +3,7 @@
AC_PREREQ([2.63])
-AC_INIT([loolwsd], [6.2.4.0], [libreoffice at lists.freedesktop.org])
+AC_INIT([loolwsd], [6.2.5.0], [libreoffice at lists.freedesktop.org])
LT_INIT([shared, disable-static, dlopen])
AM_INIT_AUTOMAKE([1.10 subdir-objects tar-pax -Wno-portability])
commit 308866c9e9719fef21cfbb0af74f134e454de1a4
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
AuthorDate: Sat Jun 29 10:52:11 2019 -0400
Commit: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
CommitDate: Mon Jul 15 12:34:47 2019 +0200
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 <kendy at collabora.com>
Tested-by: Jan Holesovsky <kendy at collabora.com>
(cherry picked from commit 08f9439cdf32d668b04af0912fa2cff18dda6a0c)
diff --git a/loleaflet/html/framed.doc.html b/loleaflet/html/framed.doc.html
index bd62fddeb..435c26e6d 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 @@
<button onclick="disable_default_uiaction('UI_Save', false); return false;">Enable default save action</button></br></br>
</form>
+ <p>Modified Status:
+ <span id="ModifiedStatus">Saved</span>
+ </p>
+
<!-- The hostname and pathnames below are obviously specific to my
personal environment and need to be changed appropriately. Also
the hex string needs to be changed of course, to the right one as
diff --git a/loleaflet/reference.html b/loleaflet/reference.html
index 3a5837f2a..f087c7464 100644
--- a/loleaflet/reference.html
+++ b/loleaflet/reference.html
@@ -3237,6 +3237,21 @@ Editor to WOPI host
Response to this query is sent via <code>Action_SaveAs</code> message.
</td>
</tr>
+ <tr>
+ <td><code><b>Doc_ModifiedStatus</b></code></td>
+ <td></td>
+ <td>
+ Notification to update the modified status of the document.
+ Values.Modified will be true, if the document has been modified
+ since the last save, otherwise, it will be false if the document
+ has been saved.
+
+ Note that this notification may be published without a change
+ from the prior value, so care must be taken to check the Values.Modified
+ value and not assume the notifiaction itself implies the
+ modified state of the document on its own.
+ </td>
+ </tr>
</table>
<h3 id='loleaflet-postmessage-python'>Calling Python scripts</h3>
diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js
index 2cca1a086..cf5240d6b 100644
--- a/loleaflet/src/map/Map.js
+++ b/loleaflet/src/map/Map.js
@@ -177,8 +177,12 @@ L.Map = L.Evented.extend({
this._docLoaded = false;
this.on('commandstatechanged', function(e) {
- if (e.commandName === '.uno:ModifiedStatus')
+ if (e.commandName === '.uno:ModifiedStatus') {
this._everModified = this._everModified || (e.state === 'true');
+
+ // Fire an event to let the client know whether the document needs saving or not.
+ this.fire('postMessage', {msgId: 'Doc_ModifiedStatus', args: { Modified: e.state === 'true' }});
+ }
}, this);
this.on('docloaded', function(e) {
diff --git a/test/data/empty.odt b/test/data/empty.odt
index 208d2f874..6b0747507 100644
Binary files a/test/data/empty.odt and b/test/data/empty.odt differ
commit 971cf5ff17fc7b99c7c085b6fffb514e4c7fd180
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
AuthorDate: Sun Jun 16 13:16:20 2019 -0400
Commit: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
CommitDate: Mon Jul 15 12:34:41 2019 +0200
leaflet: support disabling default action
Clients often need to handle certain commands themselves.
This is especially true for Action_Save and Action_Close.
A new postMessage command, Disable_Default_UIAction, is
now available to support disabling/enabling the default
action for certain commands (as of this patch, only
Action_Save and Action_Close are supported).
The actions in question issue a notification and,
when the default handler is disabled, the client
is expected to handle the notification for which
they disabled the default handler and act as necessary.
See reference.html for more details.
Change-Id: Ia6ce4e2d7578f79cc2069097e0b968e6c4aeabd1
Reviewed-on: https://gerrit.libreoffice.org/74136
Reviewed-by: Andras Timar <andras.timar at collabora.com>
Tested-by: Andras Timar <andras.timar at collabora.com>
(cherry picked from commit 04064878fc24d910435ca0162c2f37b68b493d58)
diff --git a/loleaflet/html/framed.doc.html b/loleaflet/html/framed.doc.html
index 28fb465c8..bd62fddeb 100644
--- a/loleaflet/html/framed.doc.html
+++ b/loleaflet/html/framed.doc.html
@@ -76,6 +76,12 @@
});
}
+ function disable_default_uiaction(action, disable) {
+ post({'MessageId': 'Disable_Default_UIAction',
+ 'Values': { 'action': action, 'disable': disable }
+ });
+ }
+
// This function is invoked when the iframe posts a message back.
function receiveMessage(event) {
@@ -115,6 +121,8 @@
<button onclick="show_commands('save'); return false;">Show Save Commands</button></br>
<button onclick="hide_commands('print'); return false;">Hide Print Commands</button>
<button onclick="show_commands('print'); return false;">Show Print Commands</button></br></br>
+ <button onclick="disable_default_uiaction('UI_Save', true); return false;">Disable default save action</button></br>
+ <button onclick="disable_default_uiaction('UI_Save', false); return false;">Enable default save action</button></br></br>
</form>
<!-- The hostname and pathnames below are obviously specific to my
diff --git a/loleaflet/js/toolbar.js b/loleaflet/js/toolbar.js
index 8320107ee..2090b00fa 100644
--- a/loleaflet/js/toolbar.js
+++ b/loleaflet/js/toolbar.js
@@ -105,7 +105,10 @@ function onClick(e, id, item, subItem) {
}
}
else if (id === 'save') {
- map.save(false /* An explicit save should terminate cell edit */, false /* An explicit save should save it again */);
+ map.fire('postMessage', {msgId: 'UI_Save'});
+ if (!map._disableDefaultAction['UI_Save']) {
+ map.save(false /* An explicit save should terminate cell edit */, false /* An explicit save should save it again */);
+ }
}
else if (id === 'repair') {
map._socket.sendMessage('commandvalues command=.uno:DocumentRepair');
diff --git a/loleaflet/reference.html b/loleaflet/reference.html
index da6961d59..3a5837f2a 100644
--- a/loleaflet/reference.html
+++ b/loleaflet/reference.html
@@ -3158,6 +3158,47 @@ WOPI host to editor
Shows the horizontal document ruler (Writer only)
</td>
</tr>
+ <tr>
+ <td><code><b>Disable_Default_UIAction</b></code></td>
+ <td>
+ <code><nobr>action: <string></nobr></code>
+ <code><nobr>disable: <Boolean></nobr></code>
+ </td>
+ <td>
+ Disable the default handler and action for a UI command.<br/>
+
+ <code>action</code> is the action name to enable/disable the
+ default action for.<br/>
+
+ <code>disable</code> controls whether to disable (true) or
+ enable (false) the default action.<br/>
+
+ When set to true, the given UI command will only issue a postMessage
+ without invoking the default action, leaving it up to the client
+ to intercept the postMessage event and handle as necessary.
+ Notice that some actions do not have any default handler to
+ begin with (such as UI_SaveAs and UI_Share) and therefore this
+ will have no effect on them; they only issue postMessage notification
+ anyway without taking any action beyond that.<br/>
+
+ For example, UI_Save will be issued for invoking the save
+ command (from the menu, toolbar, or keyboard shortcut) and no
+ action will take place if 'UI_Save' is disabled via
+ the Disable_Default_UIAction command. Clients who disable
+ UI_Save should then issue Action_Save themselves, when and
+ if they desire to save the document.
+ Similarly, when disabling UI_Close, the document will not
+ close upon invoking the UI_Close action, instead a postMessage
+ notification will be issued and it will be up to the client
+ to issue Action_Close when they desire.<br/>
+
+ Clients must be careful not to issue duplicate actions when
+ the default handler is enabled, instead, they should only
+ issue actions themselves when the default is disabled.
+
+ Note: currently only UI_Save and UI_Close are supported.<br/>
+ </td>
+ </tr>
</table>
<h5><a name="toolbar-button-ids">Finding toolbar button IDs</a></h5>
diff --git a/loleaflet/src/control/Control.Menubar.js b/loleaflet/src/control/Control.Menubar.js
index 28fa62156..9a9b2398d 100644
--- a/loleaflet/src/control/Control.Menubar.js
+++ b/loleaflet/src/control/Control.Menubar.js
@@ -685,7 +685,10 @@ L.Control.Menubar = L.Control.extend({
_executeAction: function(item) {
var id = $(item).data('id');
if (id === 'save') {
- this._map.save(true, true);
+ this._map.fire('postMessage', {msgId: 'UI_Save'});
+ if (!this._map._disableDefaultAction['UI_Save']) {
+ this._map.save(true, true);
+ }
} else if (id === 'saveas') {
this._map.fire('postMessage', {msgId: 'UI_SaveAs'});
} else if (id === 'shareas') {
@@ -748,7 +751,9 @@ L.Control.Menubar = L.Control.extend({
this._map.fire('postMessage', {msgId: 'close', args: {EverModified: this._map._everModified, Deprecated: true}});
this._map.fire('postMessage', {msgId: 'UI_Close', args: {EverModified: this._map._everModified}});
}
- this._map.remove();
+ if (!this._map._disableDefaultAction['UI_Close']) {
+ this._map.remove();
+ }
} else if (id === 'repair') {
this._map._socket.sendMessage('commandvalues command=.uno:DocumentRepair');
}
diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js
index 6427f06ad..2cca1a086 100644
--- a/loleaflet/src/map/Map.js
+++ b/loleaflet/src/map/Map.js
@@ -95,6 +95,7 @@ L.Map = L.Evented.extend({
this._debugAlwaysActive = false; // disables the dimming / document inactivity when true
this._serverRecycling = false;
this._documentIdle = false;
+ this._disableDefaultAction = {}; // The events for which the default handler is disabled and only issues postMessage.
vex.dialogID = -1;
diff --git a/loleaflet/src/map/handler/Map.Keyboard.js b/loleaflet/src/map/handler/Map.Keyboard.js
index 77adf34b7..0e4473092 100644
--- a/loleaflet/src/map/handler/Map.Keyboard.js
+++ b/loleaflet/src/map/handler/Map.Keyboard.js
@@ -529,8 +529,11 @@ L.Map.Keyboard = L.Handler.extend({
this._map.print();
return true;
case 83: // s
- this._map.save(false /* An explicit save should terminate cell edit */,
- false /* An explicit save should save it again */);
+ this._map.fire('postMessage', {msgId: 'UI_Save'});
+ if (!this._map._disableDefaultAction['UI_Save']) {
+ this._map.save(false /* An explicit save should terminate cell edit */,
+ false /* An explicit save should save it again */);
+ }
return true;
case 86: // v
case 118: // v (Safari)
diff --git a/loleaflet/src/map/handler/Map.WOPI.js b/loleaflet/src/map/handler/Map.WOPI.js
index 418106462..b67cf9a9d 100644
--- a/loleaflet/src/map/handler/Map.WOPI.js
+++ b/loleaflet/src/map/handler/Map.WOPI.js
@@ -325,6 +325,17 @@ L.Map.WOPI = L.Handler.extend({
this._map.CallPythonScriptSource = e.source;
this._map.sendUnoCommand('vnd.sun.star.script:' + msg.ScriptFile + '$' + msg.Function + '?language=Python&location=share', msg.Values);
}
+ else if (msg.MessageId === 'Disable_Default_UIAction') {
+ // Disable the default handler and action for a UI command.
+ // When set to true, the given UI command will issue a postmessage
+ // only. For example, UI_Save will be issued for invoking the save
+ // command (from the menu, toolbar, or keyboard shortcut) and no
+ // action will take place if 'UI_Save' is disabled via
+ // the Disable_Default_UIAction command.
+ if (msg.Values && msg.Values.action && msg.Values.disable !== undefined) {
+ this._map._disableDefaultAction[msg.Values.action] = msg.Values.disable;
+ }
+ }
},
_postMessage: function(e) {
diff --git a/test/data/empty.odt b/test/data/empty.odt
index 6b0747507..208d2f874 100644
Binary files a/test/data/empty.odt and b/test/data/empty.odt differ
commit bacbfff24e4f70edfe917881973318056f53ad47
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
AuthorDate: Sun Jun 16 14:05:33 2019 -0400
Commit: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
CommitDate: Mon Jul 1 17:40:47 2019 +0200
wsd: don't use DocBrokers marked to be destroyed
There are cases when we do get client-requests
while we are about to unload and destroy
the DocBroker. This protects against the use
of partially-destroyed DocBroker (specifically,
when TileCache is already destroyed).
Change-Id: I963f2239fd62280e70b1938d3c6f653e8af91b1e
Reviewed-on: https://gerrit.libreoffice.org/74132
Reviewed-by: Andras Timar <andras.timar at collabora.com>
Tested-by: Andras Timar <andras.timar at collabora.com>
(cherry picked from commit cba106de61771a2da86689f990ff616c99fcefa6)
diff --git a/wsd/ClientSession.cpp b/wsd/ClientSession.cpp
index a1e6c9319..8f6186a5e 100644
--- a/wsd/ClientSession.cpp
+++ b/wsd/ClientSession.cpp
@@ -81,9 +81,9 @@ bool ClientSession::_handleInput(const char *buffer, int length)
const std::vector<std::string> tokens = LOOLProtocol::tokenize(firstLine.data(), firstLine.size());
std::shared_ptr<DocumentBroker> docBroker = getDocumentBroker();
- if (!docBroker)
+ if (!docBroker || docBroker->isMarkedToDestroy())
{
- LOG_ERR("No DocBroker found. Terminating session " << getName());
+ LOG_ERR("No DocBroker found, or DocBroker marked to be destroyed. Terminating session " << getName());
return false;
}
commit 6fc67e4b69e9de590f25c806ceb8ead3979ede5f
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
AuthorDate: Sat Jun 15 20:58:49 2019 -0400
Commit: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
CommitDate: Mon Jul 1 17:40:41 2019 +0200
leaflet: support Action_Close
This allows for clients to issue a document
close programmatically, which is useful when they
have custom buttons or commands, or external
events/triggers, that might result in cleanly
closing the document.
A demo of how to use it is included in framed.doc.html.
Change-Id: Ib889bb01bbcaaa91fd0f341c989aeb1a6fceec28
Reviewed-on: https://gerrit.libreoffice.org/74131
Reviewed-by: Andras Timar <andras.timar at collabora.com>
Tested-by: Andras Timar <andras.timar at collabora.com>
(cherry picked from commit 08d72efe37f36aad64eccff807972e49c9b13911)
diff --git a/loleaflet/html/framed.doc.html b/loleaflet/html/framed.doc.html
index 2b1cf3374..28fb465c8 100644
--- a/loleaflet/html/framed.doc.html
+++ b/loleaflet/html/framed.doc.html
@@ -52,6 +52,12 @@
});
}
+ function closeDocument() {
+ post({'MessageId': 'Action_Close',
+ 'Values': null
+ });
+ }
+
function hide_commands(id) {
post({'MessageId': 'Hide_Menu_Item',
'Values': { 'id': id, }
@@ -103,7 +109,8 @@
<form id="insert-text-form">
Click <button onclick="capitalize(); return false;">here</button> to capitalize selected text in the document.</br></br>
- <button onclick="save(); return false;">Save</button></br></br>
+ <button onclick="save(); return false;">Save</button>
+ <button onclick="closeDocument(); return false;">Close</button></br></br>
<button onclick="hide_commands('save'); return false;">Hide Save Commands</button>
<button onclick="show_commands('save'); return false;">Show Save Commands</button></br>
<button onclick="hide_commands('print'); return false;">Hide Print Commands</button>
diff --git a/loleaflet/reference.html b/loleaflet/reference.html
index 31eb23610..da6961d59 100644
--- a/loleaflet/reference.html
+++ b/loleaflet/reference.html
@@ -2925,6 +2925,14 @@ WOPI host to editor
</td>
</tr>
<tr>
+ <td><code><b>Action_Close</b></code></td>
+ <td><code>
+ </code></td>
+ <td>
+ Closes the document.
+ </td>
+ </tr>
+ <tr>
<td><code><b>Action_Print</b></code></td>
<td><code>
</code></td>
diff --git a/loleaflet/src/map/handler/Map.WOPI.js b/loleaflet/src/map/handler/Map.WOPI.js
index a0bcfff74..418106462 100644
--- a/loleaflet/src/map/handler/Map.WOPI.js
+++ b/loleaflet/src/map/handler/Map.WOPI.js
@@ -267,6 +267,9 @@ L.Map.WOPI = L.Handler.extend({
this._map.save(dontTerminateEdit, dontSaveIfUnmodified);
}
+ else if (msg.MessageId === 'Action_Close') {
+ this._map.remove();
+ }
else if (msg.MessageId === 'Action_Print') {
this._map.print();
}
commit 08fd7ef485b82deeeacf5d719df60217d6887635
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
AuthorDate: Sat Jun 15 20:56:28 2019 -0400
Commit: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
CommitDate: Mon Jul 1 17:39:03 2019 +0200
leaflet: show/hide commands demo
This demonstrates the use of show and hide
functionality via Show/Hide_Button and
Show/Hide_Menu_Item postMessage events.
Save and Print buttons and menu items are
controlled in the demo.
Change-Id: I81dfea816765da50a1c20699b460765ae35f60a6
Reviewed-on: https://gerrit.libreoffice.org/74130
Reviewed-by: Andras Timar <andras.timar at collabora.com>
Tested-by: Andras Timar <andras.timar at collabora.com>
(cherry picked from commit 439eb0b98bbedaf8ea2cf016bd2c3bae5c56a2cd)
diff --git a/loleaflet/html/framed.doc.html b/loleaflet/html/framed.doc.html
index 894bc1c8f..2b1cf3374 100644
--- a/loleaflet/html/framed.doc.html
+++ b/loleaflet/html/framed.doc.html
@@ -46,6 +46,30 @@
});
}
+ function save() {
+ post({'MessageId': 'Action_Save',
+ 'Values': { 'Notify': true, }
+ });
+ }
+
+ function hide_commands(id) {
+ post({'MessageId': 'Hide_Menu_Item',
+ 'Values': { 'id': id, }
+ });
+ post({'MessageId': 'Hide_Button',
+ 'Values': { 'id': id, }
+ });
+ }
+
+ function show_commands(id) {
+ post({'MessageId': 'Show_Menu_Item',
+ 'Values': { 'id': id, }
+ });
+ post({'MessageId': 'Show_Button',
+ 'Values': { 'id': id, }
+ });
+ }
+
// This function is invoked when the iframe posts a message back.
function receiveMessage(event) {
@@ -78,7 +102,12 @@
</form>
<form id="insert-text-form">
- Click <button onclick="capitalize(); return false;">here</button> to capitalize selected text in the document:
+ Click <button onclick="capitalize(); return false;">here</button> to capitalize selected text in the document.</br></br>
+ <button onclick="save(); return false;">Save</button></br></br>
+ <button onclick="hide_commands('save'); return false;">Hide Save Commands</button>
+ <button onclick="show_commands('save'); return false;">Show Save Commands</button></br>
+ <button onclick="hide_commands('print'); return false;">Hide Print Commands</button>
+ <button onclick="show_commands('print'); return false;">Show Print Commands</button></br></br>
</form>
<!-- The hostname and pathnames below are obviously specific to my
commit a55f704b2177590d649bda68a7ac770ffbb7f74e
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
AuthorDate: Sun Jun 16 13:28:58 2019 -0400
Commit: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
CommitDate: Mon Jul 1 17:38:49 2019 +0200
Cleanup framed.doc.html sample
Now Host_PostmessageReady is automatically issued
upon loading and the postMessage calls are more modular,
allowing for expansion with more functionality.
Change-Id: I22b50f7228e0fd32c4cb880f4981c1a455038d48
Reviewed-on: https://gerrit.libreoffice.org/74129
Reviewed-by: Andras Timar <andras.timar at collabora.com>
Tested-by: Andras Timar <andras.timar at collabora.com>
(cherry picked from commit 0b7cc06e602d8c45fc667d96b1c66ad17fee44bd)
diff --git a/loleaflet/html/framed.doc.html b/loleaflet/html/framed.doc.html
index 8fa875db4..894bc1c8f 100644
--- a/loleaflet/html/framed.doc.html
+++ b/loleaflet/html/framed.doc.html
@@ -10,9 +10,9 @@
To test this, do 'make run', and then in your browser open the
equivalent of
- http://snorken.local:9980/loleaflet/3304e9093/framed.html if the
+ http://snorken.local:9980/loleaflet/3304e9093/framed.doc.html if the
browser is running on a different machine, or
- http://localhost:9980/loleaflet/3304e9093/framed.html if running
+ http://localhost:9980/loleaflet/3304e9093/framed.doc.html if running
on the same machine.
-->
@@ -24,34 +24,40 @@
<script>
+ function post(msg) {
+ window.frames[0].postMessage(JSON.stringify(msg), '*');
+ }
+
function insertText(text) {
- window.frames[0].postMessage(JSON.stringify({'MessageId': 'Host_PostmessageReady'}), '*');
- window.frames[0].postMessage(JSON.stringify({'MessageId': 'CallPythonScript',
- 'SendTime': Date.now(),
- 'ScriptFile': 'InsertText.py',
- 'Function': 'InsertText',
- 'Values': { 'text': {'type': 'string', 'value': text}}
- }),
- '*');
+ post({'MessageId': 'CallPythonScript',
+ 'SendTime': Date.now(),
+ 'ScriptFile': 'InsertText.py',
+ 'Function': 'InsertText',
+ 'Values': { 'text': {'type': 'string', 'value': text}}
+ });
}
function capitalize() {
- window.frames[0].postMessage(JSON.stringify({'MessageId': 'Host_PostmessageReady'}), '*');
- window.frames[0].postMessage(JSON.stringify({'MessageId': 'CallPythonScript',
- 'SendTime': Date.now(),
- 'ScriptFile': 'Capitalise.py',
- 'Function': 'capitalisePython',
- 'Values': null
- }),
- '*');
+ post({'MessageId': 'CallPythonScript',
+ 'SendTime': Date.now(),
+ 'ScriptFile': 'Capitalise.py',
+ 'Function': 'capitalisePython',
+ 'Values': null
+ });
}
// This function is invoked when the iframe posts a message back.
function receiveMessage(event) {
+ console.log('==== framed.doc.html receiveMessage: ' + event.data);
var msg = JSON.parse(event.data);
- console.log('==== framed.html receiveMessage: ' + event.data);
- console.log(' ' + msg);
+ if (msg && msg.MessageId == 'App_LoadingStatus') {
+ if (msg.Values) {
+ if (msg.Values.Status == 'Document_Loaded') {
+ window.frames[0].postMessage(JSON.stringify({'MessageId': 'Host_PostmessageReady'}), '*');
+ }
+ }
+ }
}
// 'main' code of this <script> block, run when page is being
More information about the Libreoffice-commits
mailing list