loleaflet/src/control/Control.JSDialogBuilder.js |   52 +++++++++++++++++++++--
 1 file changed, 49 insertions(+), 3 deletions(-)

New commits:
commit f96461558d094caf53f2215187117bfaa9170996
Author:     Szymon Kłos <szymon.k...@collabora.com>
AuthorDate: Thu Nov 14 13:55:53 2019 +0100
Commit:     Szymon Kłos <szymon.k...@collabora.com>
CommitDate: Thu Nov 14 13:56:59 2019 +0100

    jsdialog: add uno listener for checkboxes
    
    Change-Id: I207456330503c8900524f746411e0005434beb11

diff --git a/loleaflet/src/control/Control.JSDialogBuilder.js 
b/loleaflet/src/control/Control.JSDialogBuilder.js
index af13ab70a..fca8f9f14 100644
--- a/loleaflet/src/control/Control.JSDialogBuilder.js
+++ b/loleaflet/src/control/Control.JSDialogBuilder.js
@@ -395,13 +395,35 @@ L.Control.JSDialogBuilder = L.Control.extend({
                if (data.enabled == 'false')
                        $(checkbox).attr('disabled', 'disabled');
 
-               if (data.checked == 'true')
-                       $(checkbox).attr('checked', 'checked');
-
                checkbox.addEventListener('change', function() {
                        builder.callback('checkbox', 'change', checkbox, 
this.checked, builder);
                });
 
+               var customCommand = builder._mapWindowIdToUnoCommand(data.id);
+
+               var updateFunction = function() {
+                       var state = builder._getUnoStateForItemId(data.id, 
builder);
+
+                       if (!state) {
+                               var items = builder.map['stateChangeHandler'];
+                               state = items.getItemValue(data.command);
+                       }
+                       if (!state)
+                               state = data.checked;
+
+                       if (state && state === 'true' || state === 1 || state 
=== '1')
+                               $(checkbox).attr('checked', 'checked');
+                       else if (state)
+                               $(checkbox).removeAttr('checked', 'checked');
+               }
+
+               updateFunction();
+
+               builder.map.on('commandstatechanged', function(e) {
+                       if (e.commandName === customCommand ? customCommand : 
data.command)
+                               updateFunction();
+               }, this);
+
                if (data.hidden)
                        $(checkbox).hide();
 
@@ -448,6 +470,12 @@ L.Control.JSDialogBuilder = L.Control.extend({
                case 'leadingzeros':
                        return '.uno:NumberFormat';
 
+               case 'negativenumbersred':
+                       return '.uno:NumberFormat';
+
+               case 'thousandseparator':
+                       return '.uno:NumberFormat';
+
                case 'linetransparency':
                        return '.uno:LineTransparence';
 
@@ -527,6 +555,24 @@ L.Control.JSDialogBuilder = L.Control.extend({
                        }
                        break;
 
+               case 'negativenumbersred':
+                       state = items.getItemValue('.uno:NumberFormat');
+                       if (state) {
+                               state = state.split(',');
+                               if (state.length > 1)
+                                       return state[1];
+                       }
+                       return;
+
+               case 'thousandseparator':
+                       state = items.getItemValue('.uno:NumberFormat');
+                       if (state) {
+                               state = state.split(',');
+                               if (state.length > 0)
+                                       return state[0];
+                       }
+                       return;
+
                case 'linetransparency':
                        state = items.getItemValue('.uno:LineTransparence');
                        if (state) {
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to