[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-2-1' - 13 commits - loleaflet/dist loleaflet/main.js loleaflet/src wsd/DocumentBroker.cpp wsd/LOOLWSD.cpp

Henry Castro hcastro at collabora.com
Wed Sep 20 08:57:42 UTC 2017


 loleaflet/dist/menubar.css               |    2 -
 loleaflet/dist/toolbar/toolbar.js        |   53 ++++++++++++++++---------------
 loleaflet/main.js                        |    1 
 loleaflet/src/control/Control.Menubar.js |   14 +++++++-
 loleaflet/src/core/Socket.js             |   46 ++++++++++++++++----------
 loleaflet/src/map/Map.js                 |    8 +++-
 wsd/DocumentBroker.cpp                   |   14 ++------
 wsd/LOOLWSD.cpp                          |    4 ++
 8 files changed, 86 insertions(+), 56 deletions(-)

New commits:
commit 7f75603d15efc74d92e50996674338c6d98c2a34
Author: Henry Castro <hcastro at collabora.com>
Date:   Tue Sep 19 21:46:09 2017 -0400

    loleaflet: fix background color of the top level menu items
    
    Change-Id: I548c700a16664e8acfc6010c1be549e6176f2383

diff --git a/loleaflet/dist/menubar.css b/loleaflet/dist/menubar.css
index e74b4e21..1d8e5eec 100644
--- a/loleaflet/dist/menubar.css
+++ b/loleaflet/dist/menubar.css
@@ -40,7 +40,6 @@
 }
 
 .lo-menu a.disabled {
-    background: #efefef;
     cursor: default;
 }
 .lo-menu > li > a.has-submenu {
@@ -70,7 +69,7 @@
     background: #538ecd;
     color: #fff;
 }
-.lo-menu > li {
+.lo-menu > li, .lo-menu > li > a.disabled {
     background: #efefef; /* top-level menus remain greyish */
 }
 .lo-menu > li > a:hover, .lo-menu > li > a:focus, .lo-menu > li > a:active, .lo-menu > li > a.highlighted {
commit 5b11d06b849265ec317e2597bbd80f39dfe504d0
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Mon Sep 18 23:00:19 2017 +0530

    Broadcast closing documents in same thread
    
    ... instead of handing it over the Document broker polling thread which
    can lead to race conditions, and hence not giving desired behavior when
    document is changed externally.
    
    Change-Id: Ib0821d4ae931c357bc4d4c526865eefc090ddc23

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index cb258737..6c76f9dc 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -515,16 +515,12 @@ bool DocumentBroker::load(const std::shared_ptr<ClientSession>& session, const s
                          << "Actual: " << fileInfo._modifiedTime << Log::end;
 
             _documentChangedInStorage = true;
+            std::string message = "close: documentconflict";
             if (_isModified)
-            {
-                const std::string errorMsg = "error: cmd=storage kind=documentconflict";
-                session->sendTextFrame(errorMsg);
-                broadcastMessage(errorMsg);
-            }
-            else
-            {
-                closeDocument("documentconflict");
-            }
+                message = "error: cmd=storage kind=documentconflict";
+
+            session->sendTextFrame(message);
+            broadcastMessage(message);
         }
     }
 
commit c5633e724ad107324c396576b72df16e0768823c
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Mon Sep 18 21:35:34 2017 +0530

    Don't forget reconnecting the socket in these cases
    
    This regressed with 7c1e1120c63661d84a5696c5b10a961477228e19
    
    Calling .initialize() on socket object is not enough anymore after above
    mentioned commit; it doesn't re-establish the socket connection as
    was the intent earlier in following cases.
    
    Change-Id: Icd0a87a875eb275ed3c914474cdc502b460e2d16
    Reviewed-on: https://gerrit.libreoffice.org/42431
    Reviewed-by: Henry Castro <hcastro at collabora.com>
    Tested-by: Henry Castro <hcastro at collabora.com>

diff --git a/loleaflet/src/core/Socket.js b/loleaflet/src/core/Socket.js
index 576f8d7d..8e7ff652 100644
--- a/loleaflet/src/core/Socket.js
+++ b/loleaflet/src/core/Socket.js
@@ -88,7 +88,7 @@ L.Socket = L.Class.extend({
 
 		var socketState = this.socket.readyState;
 		if (socketState === 2 || socketState === 3) {
-			this.initialize(this._map);
+			this._map.loadDocument();
 		}
 
 		if (socketState === 1) {
@@ -290,7 +290,7 @@ L.Socket = L.Class.extend({
 					}
 
 					try {
-						socket.initialize(map);
+						map.loadDocument(map);
 					} catch (error) {
 					}
 				}, timeoutMs);
@@ -504,10 +504,10 @@ L.Socket = L.Class.extend({
 					callback: L.bind(function(data) {
 						if (data) {
 							this._map._docPassword = data.password;
-							this.initialize(this._map);
+							this._map.loadDocument();
 						} else if (passwordType === 'to-modify') {
 							this._map._docPassword = '';
-							this.initialize(this._map);
+							this._map.loadDocument();
 						} else {
 							this._map.hideBusy();
 						}
diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js
index a0b94da0..d1d04d62 100644
--- a/loleaflet/src/map/Map.js
+++ b/loleaflet/src/map/Map.js
@@ -826,7 +826,7 @@ L.Map = L.Evented.extend({
 					return vex.close(id);
 				}
 			} else {
-				this._socket.initialize(this);
+				this.loadDocument();
 			}
 		}
 
commit e40ed9dce77d04a980e4ebf463e9980f84df4f57
Author: Henry Castro <hcastro at collabora.com>
Date:   Sun Sep 17 11:09:02 2017 -0400

    loleaflet: show error when the document is disconnected
    
    Change-Id: I43f8d48002ccb2fc3b6ac9807b72ba6b618d72d2

diff --git a/loleaflet/src/core/Socket.js b/loleaflet/src/core/Socket.js
index b11bbe4c..576f8d7d 100644
--- a/loleaflet/src/core/Socket.js
+++ b/loleaflet/src/core/Socket.js
@@ -260,6 +260,10 @@ L.Socket = L.Class.extend({
 			else if (textMsg === 'shuttingdown') {
 				msg = _('Server is shutting down for maintenance (auto-saving)');
 			}
+			else if (textMsg === 'docdisconnected') {
+				msg = _('Oops, there is a problem connecting the document');
+				postMsgData['Reason'] = 'DocumentDisconnected';
+			}
 			else if (textMsg === 'recycling') {
 				msg = _('Server is recycling and will be available shortly');
 
commit 75acbe02a665c85a765da22d2d0c58bbc7e68894
Author: Henry Castro <hcastro at collabora.com>
Date:   Sun Sep 17 10:45:59 2017 -0400

    loleaflet: clean up the socket connection
    
    Change-Id: I29861d74ba5e0aa789eec41fb353aca1dad6cce4

diff --git a/loleaflet/src/core/Socket.js b/loleaflet/src/core/Socket.js
index 74cc65f4..b11bbe4c 100644
--- a/loleaflet/src/core/Socket.js
+++ b/loleaflet/src/core/Socket.js
@@ -23,25 +23,27 @@ L.Socket = L.Class.extend({
 
 	connect: function() {
 		var map = this._map;
+		if (map.options.permission) {
+			map.options.docParams['permission'] = map.options.permission;
+		}
+		var wopiSrc = '';
+		if (map.options.wopiSrc != '') {
+			wopiSrc = '?WOPISrc=' + map.options.wopiSrc + '&compat=/ws';
+		}
+
 		try {
-			if (map.options.permission) {
-				map.options.docParams['permission'] = map.options.permission;
-			}
-			var wopiSrc = '';
-			if (map.options.wopiSrc != '') {
-				wopiSrc = '?WOPISrc=' + map.options.wopiSrc + '&compat=/ws';
-			}
 			this.socket = new WebSocket(map.options.server + '/lool/' + encodeURIComponent(map.options.doc + '?' + $.param(map.options.docParams)) + '/ws' + wopiSrc);
-			this.socket.onerror = L.bind(this._onSocketError, this);
-			this.socket.onclose = L.bind(this._onSocketClose, this);
-			this.socket.onopen = L.bind(this._onSocketOpen, this);
-			this.socket.onmessage = L.bind(this._onMessage, this);
-			this.socket.binaryType = 'arraybuffer';
 		} catch (e) {
 			this._map.fire('error', {msg: _('Oops, there is a problem connecting to LibreOffice Online : ' + e), cmd: 'socket', kind: 'failed', id: 3});
-			return null;
+			return;
 		}
 
+		this.socket.onerror = L.bind(this._onSocketError, this);
+		this.socket.onclose = L.bind(this._onSocketClose, this);
+		this.socket.onopen = L.bind(this._onSocketOpen, this);
+		this.socket.onmessage = L.bind(this._onMessage, this);
+		this.socket.binaryType = 'arraybuffer';
+
 		if (map.options.docParams.access_token && parseInt(map.options.docParams.access_token_ttl)) {
 			var tokenExpiryWarning = 900 * 1000; // Warn when 15 minutes remain
 			clearTimeout(this._accessTokenExpireTimeout);
commit 604d53098ce825fd6caecebc553f84448044bce1
Author: Henry Castro <hcastro at collabora.com>
Date:   Sun Sep 17 10:33:06 2017 -0400

    wsd: notify when the document is disconnected
    
    Change-Id: I36e6df3c576ff0f02d3b059c2f1db4226d527b49

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 80ff392b..0ae2ee4e 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -1424,6 +1424,7 @@ private:
         {
             auto lock = docBroker->getLock();
             docBroker->assertCorrectThread();
+            docBroker->setCloseReason("docdisconnected");
             docBroker->stop();
         }
     }
commit 91ec2c990d41f37a22c85e66c13fcaaaf3c43dd3
Author: Henry Castro <hcastro at collabora.com>
Date:   Thu Sep 14 17:36:45 2017 -0400

    loleaflet: ignore events before the document is loaded
    
    Change-Id: Icd28854f4430786e1383a7fe6a694f3c7ce9a188

diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js
index bf30788d..a0b94da0 100644
--- a/loleaflet/src/map/Map.js
+++ b/loleaflet/src/map/Map.js
@@ -1012,7 +1012,7 @@ L.Map = L.Evented.extend({
 	},
 
 	_handleDOMEvent: function (e) {
-		if (!this._loaded || !this._enabled || L.DomEvent._skipped(e)) { return; }
+		if (!this._docLayer || !this._loaded || !this._enabled || L.DomEvent._skipped(e)) { return; }
 
 		this.lastActiveTime = Date.now();
 
commit f171e65fd235fe3c8e719621e4474ab185f91f9f
Author: Henry Castro <hcastro at collabora.com>
Date:   Wed Sep 13 17:02:26 2017 -0400

    wsd: debug: log when the wsd is ready to accept connections
    
    Change-Id: I56ea17af47bc85f30e74f5e93b94e0f3f3d95be4

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index cb74fda3..80ff392b 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -2576,6 +2576,9 @@ int LOOLWSD::innerMain()
 
     /// The main-poll does next to nothing:
     SocketPoll mainWait("main");
+#if ENABLE_DEBUG
+    std::cerr << "Ready to accept connections.\n" << std::endl;
+#endif
 
     const auto startStamp = std::chrono::steady_clock::now();
 
commit 37646b9230e239103c00fc30915b4c94b7b97e84
Author: Henry Castro <hcastro at collabora.com>
Date:   Wed Sep 13 12:37:10 2017 -0400

    loleaflet: fix background color of the menu item in disabled state
    
    Change-Id: Idbe08dcd1fd1bb885f77478e3ad314be392a140d

diff --git a/loleaflet/dist/menubar.css b/loleaflet/dist/menubar.css
index d3a35fce..e74b4e21 100644
--- a/loleaflet/dist/menubar.css
+++ b/loleaflet/dist/menubar.css
@@ -40,6 +40,7 @@
 }
 
 .lo-menu a.disabled {
+    background: #efefef;
     cursor: default;
 }
 .lo-menu > li > a.has-submenu {
commit a31d578f88331e4f07dfae41ae75f8a9f3ec1698
Author: Henry Castro <hcastro at collabora.com>
Date:   Wed Sep 13 11:09:56 2017 -0400

    loleaflet: ensure initialize map components before the document is loaded
    
    Change-Id: I3b6219926f0f9d0306ef25bc5f9a9145410bac74

diff --git a/loleaflet/main.js b/loleaflet/main.js
index ece21653..5d8aaed0 100644
--- a/loleaflet/main.js
+++ b/loleaflet/main.js
@@ -132,6 +132,7 @@ map.addControl(L.control.columnHeader());
 map.addControl(L.control.rowHeader());
 map.addControl(L.control.contextMenu());
 map.addControl(L.control.menubar());
+map.loadDocument();
 
 window.addEventListener('beforeunload', function () {
 	if (global.map && global.map._socket) {
diff --git a/loleaflet/src/core/Socket.js b/loleaflet/src/core/Socket.js
index c67d5311..74cc65f4 100644
--- a/loleaflet/src/core/Socket.js
+++ b/loleaflet/src/core/Socket.js
@@ -18,6 +18,11 @@ L.Socket = L.Class.extend({
 	initialize: function (map) {
 		console.debug('socket.initialize:');
 		this._map = map;
+		this._msgQueue = [];
+	},
+
+	connect: function() {
+		var map = this._map;
 		try {
 			if (map.options.permission) {
 				map.options.docParams['permission'] = map.options.permission;
@@ -43,7 +48,6 @@ L.Socket = L.Class.extend({
 			this._accessTokenExpireTimeout = setTimeout(L.bind(this._sessionExpiredWarning, this),
 			                                            parseInt(map.options.docParams.access_token_ttl) - Date.now() - tokenExpiryWarning);
 		}
-		this._msgQueue = [];
 	},
 
 	_sessionExpiredWarning: function() {
diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js
index 6027e26a..bf30788d 100644
--- a/loleaflet/src/map/Map.js
+++ b/loleaflet/src/map/Map.js
@@ -150,6 +150,10 @@ L.Map = L.Evented.extend({
 		}, this);
 	},
 
+	loadDocument: function() {
+		this._socket.connect();
+	},
+
 	// public methods that modify map state
 
 	getViewId: function (username) {
commit 9636b13e0b1f337679bf0c395c9f2b6644b6bd97
Author: Henry Castro <hcastro at collabora.com>
Date:   Mon Sep 4 19:16:07 2017 -0400

    loleaflet: log when w2ui toolbar is not created
    
    Change-Id: I9f8f50b628028f9f5541aa97f8c2f0ff2e72924d

diff --git a/loleaflet/dist/toolbar/toolbar.js b/loleaflet/dist/toolbar/toolbar.js
index a0cd7d42..f54127ba 100644
--- a/loleaflet/dist/toolbar/toolbar.js
+++ b/loleaflet/dist/toolbar/toolbar.js
@@ -684,6 +684,9 @@ $(function () {
 			$('#search-input').off('keypress', onSearchKeyPress).on('keypress', onSearchKeyPress);
 		}
 	});
+	if ($('#toolbar-up').children().length === 0) {
+		console.log('w2ui toolbar is not created');
+	}
 });
 
 var userJoinedPopupMessage = '<div>' + _('%user has joined') + '</div>';
commit be2e129ee299e8ca92b2a8a06ba38c337bf9f0d7
Author: Henry Castro <hcastro at collabora.com>
Date:   Mon Sep 4 16:52:30 2017 -0400

    loleaflet: disable toolbar buttons before the document is loaded
    
    Change-Id: Ia6679414f8eab54366a48b1c431ce9384d2dc8ca

diff --git a/loleaflet/dist/toolbar/toolbar.js b/loleaflet/dist/toolbar/toolbar.js
index b48487b8..a0cd7d42 100644
--- a/loleaflet/dist/toolbar/toolbar.js
+++ b/loleaflet/dist/toolbar/toolbar.js
@@ -455,47 +455,47 @@ $(function () {
 			{type: 'html', id: 'left'},
 			{type: 'button',  id: 'save', img: 'save', hint: _('Save')},
 			{type: 'break', id: 'savebreak'},
-			{type: 'button',  id: 'undo',  img: 'undo', hint: _('Undo'), uno: 'Undo'},
-			{type: 'button',  id: 'redo',  img: 'redo', hint: _('Redo'), uno: 'Redo'},
-			{type: 'button',  id: 'repair', img: 'repair', hint: _('Document repair')},
+			{type: 'button',  id: 'undo',  img: 'undo', hint: _('Undo'), uno: 'Undo', disabled: true},
+			{type: 'button',  id: 'redo',  img: 'redo', hint: _('Redo'), uno: 'Redo', disabled: true},
+			{type: 'button',  id: 'repair', img: 'repair', hint: _('Document repair'), disabled: true},
 			{type: 'break'},
 			{type: 'html',   id: 'styles', html: '<select class="styles-select"></select>'},
 			{type: 'html',   id: 'fonts', html: '<select class="fonts-select"></select>'},
 			{type: 'html',   id: 'fontsizes', html: '<select class="fontsizes-select"></select>'},
 			{type: 'break'},
-			{type: 'button',  id: 'bold',  img: 'bold', hint: _('Bold'), uno: 'Bold'},
-			{type: 'button',  id: 'italic', img: 'italic', hint: _('Italic'), uno: 'Italic'},
-			{type: 'button',  id: 'underline',  img: 'underline', hint: _('Underline'), uno: 'Underline'},
-			{type: 'button',  id: 'strikeout', img: 'strikeout', hint: _('Strikeout'), uno: 'Strikeout'},
+			{type: 'button',  id: 'bold',  img: 'bold', hint: _('Bold'), uno: 'Bold', disabled: true},
+			{type: 'button',  id: 'italic', img: 'italic', hint: _('Italic'), uno: 'Italic', disabled: true},
+			{type: 'button',  id: 'underline',  img: 'underline', hint: _('Underline'), uno: 'Underline', disabled: true},
+			{type: 'button',  id: 'strikeout', img: 'strikeout', hint: _('Strikeout'), uno: 'Strikeout', disabled: true},
 			{type: 'break', id: 'formatbreak'},
 			{type: 'html',  id: 'fontcolor-html', html: '<div id="fontcolor-wrapper"><input id="fontColorPicker" style="display:none;"></div>'},
 			{type: 'button',  id: 'fontcolor', img: 'color', hint: _('Font color')},
 			{type: 'html',  id: 'backcolor-html', html: '<div id="backcolor-wrapper"><input id="backColorPicker" style="display:none;"></div>'},
 			{type: 'button',  id: 'backcolor', img: 'backcolor', hint: _('Highlighting')},
 			{type: 'break'},
-			{type: 'button',  id: 'leftpara',  img: 'alignleft', hint: _('Align left'), uno: 'LeftPara', unosheet: 'AlignLeft'},
-			{type: 'button',  id: 'centerpara',  img: 'alignhorizontal', hint: _('Center horizontally'), uno: 'CenterPara', unosheet: 'AlignHorizontalCenter'},
-			{type: 'button',  id: 'rightpara',  img: 'alignright', hint: _('Align right'), uno: 'RightPara', unosheet: 'AlignRight'},
-			{type: 'button',  id: 'justifypara',  img: 'alignblock', hint: _('Justified'), uno: 'JustifyPara', unosheet: ''},
+			{type: 'button',  id: 'leftpara',  img: 'alignleft', hint: _('Align left'), uno: 'LeftPara', unosheet: 'AlignLeft', disabled: true},
+			{type: 'button',  id: 'centerpara',  img: 'alignhorizontal', hint: _('Center horizontally'), uno: 'CenterPara', unosheet: 'AlignHorizontalCenter', disabled: true},
+			{type: 'button',  id: 'rightpara',  img: 'alignright', hint: _('Align right'), uno: 'RightPara', unosheet: 'AlignRight', disabled: true},
+			{type: 'button',  id: 'justifypara',  img: 'alignblock', hint: _('Justified'), uno: 'JustifyPara', unosheet: '', disabled: true},
 			{type: 'break',  id: 'wraptextseparator'},
-			{type: 'button',  id: 'wraptext',  img: 'wraptext', hint: _('Wrap Text'), uno: 'WrapText'},
-			{type: 'button',  id: 'togglemergecells',  img: 'togglemergecells', hint: _('Merge and Center Cells'), uno: 'ToggleMergeCells'},
+			{type: 'button',  id: 'wraptext',  img: 'wraptext', hint: _('Wrap Text'), uno: 'WrapText', disabled: true},
+			{type: 'button',  id: 'togglemergecells',  img: 'togglemergecells', hint: _('Merge and Center Cells'), uno: 'ToggleMergeCells', disabled: true},
 			{type: 'break',   id: 'break-toggle'},
-			{type: 'button',  id: 'numberformatcurrency',  img: 'numberformatcurrency', hint: _('Format as Currency'), uno: 'NumberFormatCurrency'},
-			{type: 'button',  id: 'numberformatpercent',  img: 'numberformatpercent', hint: _('Format as Percent'), uno: 'NumberFormatPercent'},
-			{type: 'button',  id: 'numberformatdecimal',  img: 'numberformatdecimal', hint: _('Format as Number'), uno: 'NumberFormatDecimal'},
-			{type: 'button',  id: 'numberformatdate',  img: 'numberformatdate', hint: _('Format as Date'), uno: 'NumberFormatDate'},
-			{type: 'button',  id: 'numberformatincdecimals',  img: 'numberformatincdecimals', hint: _('Add Decimal Place'), uno: 'NumberFormatIncDecimals'},
-			{type: 'button',  id: 'numberformatdecdecimals',  img: 'numberformatdecdecimals', hint: _('Delete Decimal Place'), uno: 'NumberFormatDecDecimals'},
+			{type: 'button',  id: 'numberformatcurrency',  img: 'numberformatcurrency', hint: _('Format as Currency'), uno: 'NumberFormatCurrency', disabled: true},
+			{type: 'button',  id: 'numberformatpercent',  img: 'numberformatpercent', hint: _('Format as Percent'), uno: 'NumberFormatPercent', disabled: true},
+			{type: 'button',  id: 'numberformatdecimal',  img: 'numberformatdecimal', hint: _('Format as Number'), uno: 'NumberFormatDecimal', disabled: true},
+			{type: 'button',  id: 'numberformatdate',  img: 'numberformatdate', hint: _('Format as Date'), uno: 'NumberFormatDate', disabled: true},
+			{type: 'button',  id: 'numberformatincdecimals',  img: 'numberformatincdecimals', hint: _('Add Decimal Place'), uno: 'NumberFormatIncDecimals', disabled: true},
+			{type: 'button',  id: 'numberformatdecdecimals',  img: 'numberformatdecdecimals', hint: _('Delete Decimal Place'), uno: 'NumberFormatDecDecimals', disabled: true},
 			{type: 'break',   id: 'break-number'},
-			{type: 'button',  id: 'sortascending',  img: 'sortascending', hint: _('Sort Ascending'), uno: 'SortAscending'},
-			{type: 'button',  id: 'sortdescending',  img: 'sortdescending', hint: _('Sort Descending'), uno: 'SortDescending'},
+			{type: 'button',  id: 'sortascending',  img: 'sortascending', hint: _('Sort Ascending'), uno: 'SortAscending', disabled: true},
+			{type: 'button',  id: 'sortdescending',  img: 'sortdescending', hint: _('Sort Descending'), uno: 'SortDescending', disabled: true},
 			{type: 'break',   id: 'break-align'},
-			{type: 'button',  id: 'defaultbullet',  img: 'bullet', hint: _('Bullets on/off'), uno: 'DefaultBullet'},
-			{type: 'button',  id: 'defaultnumbering',  img: 'numbering', hint: _('Numbering on/off'), uno: 'DefaultNumbering'},
+			{type: 'button',  id: 'defaultbullet',  img: 'bullet', hint: _('Bullets on/off'), uno: 'DefaultBullet', disabled: true},
+			{type: 'button',  id: 'defaultnumbering',  img: 'numbering', hint: _('Numbering on/off'), uno: 'DefaultNumbering', disabled: true},
 			{type: 'break',   id: 'break-numbering'},
-			{type: 'button',  id: 'incrementindent',  img: 'incrementindent', hint: _('Increase indent'), uno: 'IncrementIndent'},
-			{type: 'button',  id: 'decrementindent',  img: 'decrementindent', hint: _('Decrease indent'), uno: 'DecrementIndent'},
+			{type: 'button',  id: 'incrementindent',  img: 'incrementindent', hint: _('Increase indent'), uno: 'IncrementIndent', disabled: true},
+			{type: 'button',  id: 'decrementindent',  img: 'decrementindent', hint: _('Decrease indent'), uno: 'DecrementIndent', disabled: true},
 			{type: 'break', id: 'incdecindent'},
 			{type: 'html',  id: 'inserttable-html', html: '<div id="inserttable-wrapper"><div id="inserttable-popup" class="inserttable-pop ui-widget ui-widget-content ui-corner-all" style="position: absolute; display: none;"><div class="inserttable-grid"></div><div id="inserttable-status" class="loleaflet-font" style="padding: 5px;"><br/></div></div>'},
 			{type: 'button',  id: 'inserttable',  img: 'inserttable', hint: _('Insert table')},
commit ef8ed1fc4e633492da17a442a328de1a05da044d
Author: Henry Castro <hcastro at collabora.com>
Date:   Mon Sep 4 16:32:24 2017 -0400

    loleaflet: add initial menu bar before the document is loaded
    
    Change-Id: I9ab7f87e0ad3f4c9ff11670b8a2675d895a9c812

diff --git a/loleaflet/src/control/Control.Menubar.js b/loleaflet/src/control/Control.Menubar.js
index 62fc9789..4a3671f2 100644
--- a/loleaflet/src/control/Control.Menubar.js
+++ b/loleaflet/src/control/Control.Menubar.js
@@ -6,6 +6,12 @@
 L.Control.Menubar = L.Control.extend({
 	// TODO: Some mechanism to stop the need to copy duplicate menus (eg. Help)
 	options: {
+		initial: [
+			{name: _('File'), disabled: true},
+			{name: _('Edit'), disabled: true},
+			{name: _('View'), disabled: true},
+			{name: _('Insert'), disabled: true}
+		],
 		text:  [
 			{name: _('File'), id: 'file', type: 'menu', menu: [
 				{name: _('Save'), id: 'save', type: 'action'},
@@ -306,6 +312,7 @@ L.Control.Menubar = L.Control.extend({
 	onAdd: function (map) {
 		this._initialized = false;
 		this._menubarCont = L.DomUtil.get('main-menu');
+		this._initializeMenu(this.options.initial);
 
 		map.on('doclayerinit', this._onDocLayerInit, this);
 		map.on('addmenu', this._addMenu, this);
@@ -330,6 +337,11 @@ L.Control.Menubar = L.Control.extend({
 	},
 
 	_onDocLayerInit: function() {
+		// clear initial menu
+		while (this._menubarCont.hasChildNodes()) {
+			this._menubarCont.removeChild(this._menubarCont.firstChild);
+		}
+
 		// Add document specific menu
 		var docType = this._map.getDocType();
 		if (docType === 'text') {
@@ -751,7 +763,7 @@ L.Control.Menubar = L.Control.extend({
 					L.DomUtil.addClass(liItem, 'readonly');
 				}
 			}
-			var aItem = L.DomUtil.create('a', '', liItem);
+			var aItem = L.DomUtil.create('a', menu[i].disabled ? 'disabled' : '', liItem);
 			aItem.innerHTML = menu[i].name;
 
 			if (menu[i].type === 'menu') {


More information about the Libreoffice-commits mailing list