[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-3-0' - loleaflet/src loleaflet/unocommands.js

Henry Castro hcastro at collabora.com
Fri Jan 12 21:00:44 UTC 2018


 loleaflet/src/control/Control.Menubar.js |   27 +++++++++++++++++++++++++--
 loleaflet/unocommands.js                 |    3 +++
 2 files changed, 28 insertions(+), 2 deletions(-)

New commits:
commit 703861538ff2bddb157a4836c995154390df31aa
Author: Henry Castro <hcastro at collabora.com>
Date:   Fri Jan 12 21:45:45 2018 +0100

    loleaflet: add Header/Footer menu
    
    Change-Id: Iabbb3e2a8eadadae2446b572f0e411491af9db4f
    Reviewed-on: https://gerrit.libreoffice.org/47829
    Reviewed-by: Henry Castro <hcastro at collabora.com>
    Tested-by: Henry Castro <hcastro at collabora.com>

diff --git a/loleaflet/src/control/Control.Menubar.js b/loleaflet/src/control/Control.Menubar.js
index c863eeec..ba9b9b30 100644
--- a/loleaflet/src/control/Control.Menubar.js
+++ b/loleaflet/src/control/Control.Menubar.js
@@ -63,6 +63,9 @@ L.Control.Menubar = L.Control.extend({
 				{name: _UNO('.uno:InsertGraphic', 'text'), id: 'insertgraphic', type: 'action'},
 				{name: _UNO('.uno:InsertAnnotation', 'text'), id: 'insertcomment', type: 'action'},
 				{type: 'separator'},
+				{name: _UNO('.uno:InsertHeaderFooterMenu', 'text'), type: 'menu', menu: [
+					{uno: '.uno:InsertPageHeader'},
+					{uno: '.uno:InsertPageFooter'}]},
 				{uno: '.uno:InsertFootnote'},
 				{uno: '.uno:InsertEndnote'},
 				{type: 'separator'},
@@ -683,6 +686,27 @@ L.Control.Menubar = L.Control.extend({
 		}
 	},
 
+	_sendCommand: function (item) {
+		var unoCommand = $(item).data('uno');
+		if (unoCommand == '.uno:InsertPageHeader' || unoCommand == '.uno:InsertPageFooter') {
+			if (map['stateChangeHandler'].getItemValue(unoCommand) === 'true') {
+				vex.dialog.confirm({
+					message: (unoCommand.endsWith('Header') ? _('Are you sure you want to delete the header?') :
+						_('Are you sure you want to delete the footer?')),
+					callback: function(value) {
+						if (value) {
+							map.sendUnoCommand(unoCommand + '?On:bool=false');
+						}
+					}
+				});
+			} else {
+				map.sendUnoCommand(unoCommand + '?On:bool=true');
+			}
+		} else {
+			map.sendUnoCommand(unoCommand);
+		}
+	},
+
 	_onDeleteSlide: function(e) {
 		if (e) {
 			map.deletePage();
@@ -693,8 +717,7 @@ L.Control.Menubar = L.Control.extend({
 		var self = e.data.self;
 		var type = $(item).data('type');
 		if (type === 'unocommand') {
-			var unoCommand = $(item).data('uno');
-			map.sendUnoCommand(unoCommand);
+			self._sendCommand(item);
 		} else if (type === 'action') {
 			self._executeAction(item);
 		}
diff --git a/loleaflet/unocommands.js b/loleaflet/unocommands.js
index fade3dc0..706c7c6a 100644
--- a/loleaflet/unocommands.js
+++ b/loleaflet/unocommands.js
@@ -89,11 +89,14 @@ var unoCommandsArray = {
 	InsertFootnote:{text:{menu:_('~Footnote'),},},
 	InsertGraphic:{global:{context:_('Insert Image'),menu:_('~Image...'),},},
 	InsertHardHyphen:{global:{menu:_('Non-br~eaking hyphen'),},},
+	InsertHeaderFooterMenu:{text:{menu:_('He~ader and Footer'),},},
 	InsertIndexesEntry:{text:{menu:_('~Index Entry...'),},},
 	InsertLRM:{global:{menu:_('~Left-to-right mark'),},},
 	InsertMenu:{global:{menu:_('~Insert'),},},
 	InsertNeutralParagraph:{text:{menu:_('Insert Unnumbered Entry'),},},
 	InsertNonBreakingSpace:{global:{menu:_('~Non-breaking space'),},},
+	InsertPageFooter:{text:{menu:_('Foote~r'),},},
+	InsertPageHeader:{text:{menu:_('He~ader'),},},
 	InsertPagebreak:{text:{menu:_('~Page Break'),},},
 	InsertRLM:{global:{menu:_('~Right-to-left mark'),},},
 	InsertRows:{presentation:{menu:_('Insert Row'),},spreadsheet:{menu:_('Rows ~Above'),},text:{menu:_('Insert Row'),},},


More information about the Libreoffice-commits mailing list