[Libreoffice-commits] online.git: loleaflet/src

Pranav Kant pranavk at collabora.com
Fri Mar 4 13:27:35 UTC 2016


 loleaflet/src/control/Control.Styles.js |   22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

New commits:
commit ea35385e18b6b24386c8509b0295cd0136facac1
Author: Pranav Kant <pranavk at collabora.com>
Date:   Tue Mar 1 19:41:54 2016 +0530

    loleaflet: Special handling for Impress docs on state change
    
    State changed event from LOK for impress documents is
    prefixed with the template name followed by the style name. Lets
    strip the template name for the time being till we support it in
    the UI.
    
    Also LOK emits some form of internal names in state change event
    which is different from the internal names supplied to us in
    intial .uno:StyleApply. For consistency, convert these names to
    our original form of internal names.
    
    Change-Id: I95d3d8aa29238fc326887cdfc9b22eb4e429d1bb
    Reviewed-on: https://gerrit.libreoffice.org/22814
    Reviewed-by: Andras Timar <andras.timar at collabora.com>
    Tested-by: Andras Timar <andras.timar at collabora.com>

diff --git a/loleaflet/src/control/Control.Styles.js b/loleaflet/src/control/Control.Styles.js
index 4f2d070..13671cb 100644
--- a/loleaflet/src/control/Control.Styles.js
+++ b/loleaflet/src/control/Control.Styles.js
@@ -129,12 +129,30 @@ L.Control.Styles = L.Control.extend({
 	},
 
 	_onStateChange: function (e) {
+		if (!e.state) {
+			return;
+		}
+		// For impress documents, LOK STATE_CHANGED callback return these internal names
+		// which are different from what is returned by initial .uno:StyleApply.
+		// Convert these names to our stored internal names before processing
+		var impressMapping = {	"Titel":"title","Untertitel":"subtitle",
+					"Gliederung 1":"outline1","Gliederung 2":"outline2","Gliederung 3":"outline3",
+					"Gliederung 4":"outline4","Gliederung 5":"outline5","Gliederung 6":"outline6",
+					"Gliederung 7":"outline7","Gliederung 8":"outline8","Gliederung 9":"outline9",
+					"Hintergrund":"background","Hintergrundobjekte":"backgroundobjects","Notizen":"notes"};
+
+		// For impress documents, template name is prefixed with style name.
+		// Strip the template name until we support it
+		if (this._map.getDocType() === 'presentation') {
+			e.state = e.state.split('~LT~')[1];
+			e.state = impressMapping[e.state];
+		}
 		if (e.commandName === '.uno:StyleApply') {
-			// 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()) {
+				if (value === e.state) {
 					this._container.value = value;
+					return;
 				}
 			}
 		}


More information about the Libreoffice-commits mailing list