[Libreoffice-commits] online.git: Branch 'distro/collabora/milestone-7' - 2 commits - loleaflet/src

Pranav Kant pranavk at collabora.com
Mon Mar 21 11:24:20 UTC 2016


 loleaflet/src/control/Control.Fonts.js  |    8 
 loleaflet/src/control/Control.Styles.js |  303 ++++++++++++++++++++++++++++++--
 2 files changed, 300 insertions(+), 11 deletions(-)

New commits:
commit 0df640a0b3702f456353ba1ad645c8e8e16c9d95
Author: Pranav Kant <pranavk at collabora.com>
Date:   Thu Mar 17 13:47:06 2016 +0530

    loleaflet: Fix command values and styles coming from server
    
    Change-Id: I34c30c0c0d519a96192e67a977fccdd6e5840b13

diff --git a/loleaflet/src/control/Control.Fonts.js b/loleaflet/src/control/Control.Fonts.js
index 755c4b0..390b715 100644
--- a/loleaflet/src/control/Control.Fonts.js
+++ b/loleaflet/src/control/Control.Fonts.js
@@ -35,6 +35,10 @@ L.Control.Fonts = L.Control.extend({
 			var first = L.DomUtil.create('option', '', container);
 			first.innerHTML = this.options.fontsInfo;
 			var fonts = e.commandValues;
+			if (!fonts) {
+				// in case of empty string, make sure `fonts' is not iterated
+				fonts = [];
+			}
 			for (var font in fonts) {
 				var item = L.DomUtil.create('option', '', container);
 				item.value = font;
@@ -110,6 +114,10 @@ L.Control.Fonts = L.Control.extend({
 	},
 
 	_onStateChange: function (e) {
+		if (!e.state) {
+			return;
+		}
+
 		if (e.commandName === '.uno:CharFontName') {
 			for (var i = 0; i < this._fontSelect.length; i++) {
 				var value = this._fontSelect[i].value;
diff --git a/loleaflet/src/control/Control.Styles.js b/loleaflet/src/control/Control.Styles.js
index 6d8ad1e..1e52351 100644
--- a/loleaflet/src/control/Control.Styles.js
+++ b/loleaflet/src/control/Control.Styles.js
@@ -400,7 +400,10 @@ L.Control.Styles = L.Control.extend({
 			// Fix 'Text Body' vs 'Text body'
 			for (var i = 0; i < this._container.length; i++) {
 				var value = this._container[i].value;
-				if (value && value.toLowerCase() === e.state.toLowerCase()) {
+				var innerHTML = this._container[i].innerHTML;
+				// For writer, we get UI names, but for others we seem to get internal names
+				// (likely to be fixed in core to keep it consistent)
+				if (value === e.state || innerHTML === e.state) {
 					this._container.value = value;
 				}
 			}
commit 23b841b2fb0fb8a8b80df24f19597631f6154349
Author: Pranav Kant <pranavk at collabora.com>
Date:   Thu Mar 17 12:20:45 2016 +0530

    loleaflet: Don't use l10n framework for style mappings
    
    Change-Id: I25c738b885f145e69a3516530c77d92a614f7053

diff --git a/loleaflet/src/control/Control.Styles.js b/loleaflet/src/control/Control.Styles.js
index 0691f4f..6d8ad1e 100644
--- a/loleaflet/src/control/Control.Styles.js
+++ b/loleaflet/src/control/Control.Styles.js
@@ -7,6 +7,281 @@ L.Control.Styles = L.Control.extend({
 		info: '- Styles -'
 	},
 
+	// Programming names -> UI names mapping
+	styleMappings: {
+		"Default":"Default",
+		"Result":"Result",
+		"Result2":"Result2",
+		"Heading":"Heading",
+		"Heading1":"Heading1",
+		"Default":"Default",
+		"Report":"Report",
+		"standard":"Default",
+		"objectwitharrow":"Object with arrow",
+		"objectwithshadow":"Object with shadow",
+		"objectwithoutfill":"Object without fill",
+		"Object with no fill and no line":"Object with no fill and no line",
+		"text":"Text",
+		"textbody":"Text body",
+		"textbodyjustfied":"Text body justified",
+		"textbodyindent":"First line indent",
+		"title":"Title",
+		"title1":"Title1",
+		"title2":"Title2",
+		"headline":"Heading",
+		"headline1":"Heading1",
+		"headline2":"Heading2",
+		"measure":"Dimension Line",
+		"Normal":"Normal",
+		"Heading 1":"Heading 1",
+		"Heading 2":"Heading 2",
+		"Heading 3":"Heading 3",
+		"Numbering Symbols":"Numbering Symbols",
+		"Bullets":"Bullets",
+		"Table Contents":"Table Contents",
+		"Quotations":"Quotations",
+		"Index":"Index",
+		"Caption":"Caption",
+		"List":"List",
+		"Text Body":"Text Body",
+		"default":"default",
+		"gray1":"gray1",
+		"gray2":"gray2",
+		"gray3":"gray3",
+		"bw1":"bw1",
+		"bw2":"bw2",
+		"bw3":"bw3",
+		"orange1":"orange1",
+		"orange2":"orange2",
+		"orange3":"orange3",
+		"turquoise1":"turquoise1",
+		"turquoise2":"turquoise2",
+		"turquoise3":"turquoise3",
+		"blue1":"blue1",
+		"blue2":"blue2",
+		"blue3":"blue3",
+		"sun1":"sun1",
+		"sun2":"sun2",
+		"sun3":"sun3",
+		"earth1":"earth1",
+		"earth2":"earth2",
+		"earth3":"earth3",
+		"green1":"green1",
+		"green2":"green2",
+		"green3":"green3",
+		"seetang1":"seetang1",
+		"seetang2":"seetang2",
+		"seetang3":"seetang3",
+		"lightblue1":"lightblue1",
+		"lightblue2":"lightblue2",
+		"lightblue3":"lightblue3",
+		"yellow1":"yellow1",
+		"yellow2":"yellow2",
+		"yellow3":"yellow3",
+		"default":"default",
+		"bw":"bw",
+		"orange":"orange",
+		"turquoise":"turquoise",
+		"blue":"blue",
+		"sun":"sun",
+		"earth":"earth",
+		"green":"green",
+		"seetang":"seetang",
+		"lightblue":"lightblue",
+		"yellow":"yellow",
+		"background":"Background",
+		"backgroundobjects":"Background objects",
+		"notes":"Notes",
+		"outline1":"Outline 1",
+		"outline2":"Outline 2",
+		"outline3":"Outline 3",
+		"outline4":"Outline 4",
+		"outline5":"Outline 5",
+		"outline6":"Outline 6",
+		"outline7":"Outline 7",
+		"outline8":"Outline 8",
+		"outline9":"Outline 9",
+		"subtitle":"Subtitle",
+		"title":"Title",
+		"Clear formatting":"Clear formatting",
+		"Default Style":"Default Style",
+		"Bullet Symbols":"Bullets",
+		"Numbering Symbols":"Numbering Symbols",
+		"Footnote Symbol":"Footnote Characters",
+		"Page Number":"Page Number",
+		"Caption characters":"Caption Characters",
+		"Drop Caps":"Drop Caps",
+		"Internet link":"Internet Link",
+		"Visited Internet Link":"Visited Internet Link",
+		"Placeholder":"Placeholder",
+		"Index Link":"Index Link",
+		"Endnote Symbol":"Endnote Characters",
+		"Line numbering":"Line Numbering",
+		"Main index entry":"Main Index Entry",
+		"Footnote anchor":"Footnote Anchor",
+		"Endnote anchor":"Endnote Anchor",
+		"Rubies":"Rubies",
+		"Vertical Numbering Symbols":"Vertical Numbering Symbols",
+		"Emphasis":"Emphasis",
+		"Citation":"Quotation",
+		"Strong Emphasis":"Strong Emphasis",
+		"Source Text":"Source Text",
+		"Example":"Example",
+		"User Entry":"User Entry",
+		"Variable":"Variable",
+		"Definition":"Definition",
+		"Teletype":"Teletype",
+		"Text body":"Text Body",
+		"Quotations":"Quotations",
+		"Title":"Title",
+		"Subtitle":"Subtitle",
+		"Heading 1":"Heading 1",
+		"Heading 2":"Heading 2",
+		"Heading 3":"Heading 3",
+		"Standard":"Default Style",
+		"Heading":"Heading",
+		"List":"List",
+		"Caption":"Caption",
+		"Index":"Index",
+		"Table Contents":"Table Contents",
+		"First line indent":"First Line Indent",
+		"Hanging indent":"Hanging Indent",
+		"Text body indent":"Text Body Indent",
+		"Salutation":"Complimentary Close",
+		"Signature":"Signature",
+		"List Indent":"List Indent",
+		"Marginalia":"Marginalia",
+		"Heading 4":"Heading 4",
+		"Heading 5":"Heading 5",
+		"Heading 6":"Heading 6",
+		"Heading 7":"Heading 7",
+		"Heading 8":"Heading 8",
+		"Heading 9":"Heading 9",
+		"Heading 10":"Heading 10",
+		"Numbering 1 Start":"Numbering 1 Start",
+		"Numbering 1":"Numbering 1",
+		"Numbering 1 End":"Numbering 1 End",
+		"Numbering 1 Cont.":"Numbering 1 Cont.",
+		"Numbering 2 Start":"Numbering 2 Start",
+		"Numbering 2":"Numbering 2",
+		"Numbering 2 End":"Numbering 2 End",
+		"Numbering 2 Cont.":"Numbering 2 Cont.",
+		"Numbering 3 Start":"Numbering 3 Start",
+		"Numbering 3":"Numbering 3",
+		"Numbering 3 End":"Numbering 3 End",
+		"Numbering 3 Cont.":"Numbering 3 Cont.",
+		"Numbering 4 Start":"Numbering 4 Start",
+		"Numbering 4":"Numbering 4",
+		"Numbering 4 End":"Numbering 4 End",
+		"Numbering 4 Cont.":"Numbering 4 Cont.",
+		"Numbering 5 Start":"Numbering 5 Start",
+		"Numbering 5":"Numbering 5",
+		"Numbering 5 End":"Numbering 5 End",
+		"Numbering 5 Cont.":"Numbering 5 Cont.",
+		"List 1 Start":"List 1 Start",
+		"List 1":"List 1",
+		"List 1 End":"List 1 End",
+		"List 1 Cont.":"List 1 Cont.",
+		"List 2 Start":"List 2 Start",
+		"List 2":"List 2",
+		"List 2 End":"List 2 End",
+		"List 2 Cont.":"List 2 Cont.",
+		"List 3 Start":"List 3 Start",
+		"List 3":"List 3",
+		"List 3 End":"List 3 End",
+		"List 3 Cont.":"List 3 Cont.",
+		"List 4 Start":"List 4 Start",
+		"List 4":"List 4",
+		"List 4 End":"List 4 End",
+		"List 4 Cont.":"List 4 Cont.",
+		"List 5 Start":"List 5 Start",
+		"List 5":"List 5",
+		"List 5 End":"List 5 End",
+		"List 5 Cont.":"List 5 Cont.",
+		"Index Heading":"Index Heading",
+		"Index 1":"Index 1",
+		"Index 2":"Index 2",
+		"Index 3":"Index 3",
+		"Index Separator":"Index Separator",
+		"Contents Heading":"Contents Heading",
+		"Contents 1":"Contents 1",
+		"Contents 2":"Contents 2",
+		"Contents 3":"Contents 3",
+		"Contents 4":"Contents 4",
+		"Contents 5":"Contents 5",
+		"User Index Heading":"User Index Heading",
+		"User Index 1":"User Index 1",
+		"User Index 2":"User Index 2",
+		"User Index 3":"User Index 3",
+		"User Index 4":"User Index 4",
+		"User Index 5":"User Index 5",
+		"Contents 6":"Contents 6",
+		"Contents 7":"Contents 7",
+		"Contents 8":"Contents 8",
+		"Contents 9":"Contents 9",
+		"Contents 10":"Contents 10",
+		"Illustration Index Heading":"Illustration Index Heading",
+		"Illustration Index 1":"Illustration Index 1",
+		"Object index heading":"Object Index Heading",
+		"Object index 1":"Object Index 1",
+		"Table index heading":"Table Index Heading",
+		"Table index 1":"Table Index 1",
+		"Bibliography Heading":"Bibliography Heading",
+		"Bibliography 1":"Bibliography 1",
+		"User Index 6":"User Index 6",
+		"User Index 7":"User Index 7",
+		"User Index 8":"User Index 8",
+		"User Index 9":"User Index 9",
+		"User Index 10":"User Index 10",
+		"Header":"Header",
+		"Header left":"Header Left",
+		"Header right":"Header Right",
+		"Footer":"Footer",
+		"Footer left":"Footer Left",
+		"Footer right":"Footer Right",
+		"Table Heading":"Table Heading",
+		"Illustration":"Illustration",
+		"Table":"Table",
+		"Text":"Text",
+		"Frame contents":"Frame Contents",
+		"Footnote":"Footnote",
+		"Addressee":"Addressee",
+		"Sender":"Sender",
+		"Endnote":"Endnote",
+		"Drawing":"Drawing",
+		"Preformatted Text":"Preformatted Text",
+		"Horizontal Line":"Horizontal Line",
+		"List Contents":"List Contents",
+		"List Heading":"List Heading",
+		"Standard":"Default Style",
+		"First Page":"First Page",
+		"Left Page":"Left Page",
+		"Right Page":"Right Page",
+		"Envelope":"Envelope",
+		"Index":"Index",
+		"HTML":"HTML",
+		"Footnote":"Footnote",
+		"Endnote":"Endnote",
+		"Landscape":"Landscape",
+		"Graphics":"Graphics",
+		"Frame":"Frame",
+		"OLE":"OLE",
+		"Formula":"Formula",
+		"Marginalia":"Marginalia",
+		"Watermark":"Watermark",
+		"Labels":"Labels",
+		"Numbering 1":"Numbering 1",
+		"Numbering 2":"Numbering 2",
+		"Numbering 3":"Numbering 3",
+		"Numbering 4":"Numbering 4",
+		"Numbering 5":"Numbering 5",
+		"List 1":"List 1",
+		"List 2":"List 2",
+		"List 3":"List 3",
+		"List 4":"List 4",
+		"List 5":"List 5"
+	},
+
 	onAdd: function (map) {
 		var stylesName = 'leaflet-control-styles';
 		this._container = L.DomUtil.create('select', stylesName + ' leaflet-bar');
@@ -59,8 +334,8 @@ L.Control.Styles = L.Control.extend({
 				commands.forEach(function (command) {
 					var item = L.DomUtil.create('option', '', container);
 					item.value = command.id;
-					item.innerHTML = command.text.toLocaleString();
-				});
+					item.innerHTML = this.styleMappings[command.text].toLocaleString();;
+				}, this);
 			}
 
 			if (topStyles.length > 0) {
@@ -69,8 +344,8 @@ L.Control.Styles = L.Control.extend({
 				topStyles.forEach(function (style) {
 					var item = L.DomUtil.create('option', '', container);
 					item.value = style;
-					item.innerHTML = style.toLocaleString();
-				});
+					item.innerHTML = this.styleMappings[style].toLocaleString();
+				}, this);
 			}
 
 			if (styles.length > 0) {
@@ -79,14 +354,17 @@ L.Control.Styles = L.Control.extend({
 				styles.forEach(function (style) {
 					var item = L.DomUtil.create('option', '', container);
 					item.value = style;
-
+					
+					var localeStyle;
 					if (style.startsWith('Outline')) {
 						var outlineLevel = style.split('Outline')[1];
-						var localeString = 'Outline'.toLocaleString() + outlineLevel;
-						item.innerHTML = localeString;
-					} else
-						item.innerHTML = style.toLocaleString();
-				});
+						localeStyle = 'Outline'.toLocaleString() + outlineLevel;
+					} else {
+						localeStyle = this.styleMappings[style].toLocaleString();
+					}
+
+					item.innerHTML = localeStyle;
+				}, this);
 			}
 		}
 	},


More information about the Libreoffice-commits mailing list