loleaflet/src/control/Control.Toolbar.js |   35 +++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

New commits:
commit a43c8c304dc7580982f374d7360ea0c408333bcf
Author:     Dennis Francis <dennis.fran...@collabora.com>
AuthorDate: Thu Feb 6 14:36:57 2020 +0530
Commit:     Jan Holesovsky <ke...@collabora.com>
CommitDate: Mon Feb 10 12:07:13 2020 +0100

    Use the correct align statechange messages...
    
    from core to control the state of toolbar's align
    buttons (based on the current selection type).
    
    Change-Id: I1c4c4ce1776091c05196d7c8257ea59f8248284a
    Reviewed-on: https://gerrit.libreoffice.org/c/online/+/88160
    Tested-by: Jan Holesovsky <ke...@collabora.com>
    Reviewed-by: Jan Holesovsky <ke...@collabora.com>

diff --git a/loleaflet/src/control/Control.Toolbar.js 
b/loleaflet/src/control/Control.Toolbar.js
index 6c718af9b..536c9c09c 100644
--- a/loleaflet/src/control/Control.Toolbar.js
+++ b/loleaflet/src/control/Control.Toolbar.js
@@ -1279,6 +1279,11 @@ function updateToolbarItem(toolbar, id, html) {
 function unoCmdToToolbarId(commandname)
 {
        var id = commandname.toLowerCase().substr(5);
+       var selectionType = 'text';
+
+       if (map._clip && map._clip._selectionType)
+               selectionType = map._clip._selectionType;
+
        if (map.getDocType() === 'spreadsheet') {
                switch (id) {
                case 'alignleft':
@@ -1292,6 +1297,32 @@ function unoCmdToToolbarId(commandname)
                        break;
                }
        }
+       else if (selectionType == 'complex') {
+
+               // ignore the text align state messages.
+               if (id === 'leftpara' || id === 'rightpara' ||
+                       id === 'centerpara') {
+                       id = '';
+               }
+
+               // convert the object align statemessages to align button ids.
+               switch (id) {
+               case 'objectalignleft':
+                       id = 'leftpara';
+                       break;
+               case 'aligncenter':
+                       id = 'centerpara';
+                       break;
+               case 'objectalignright':
+                       id = 'rightpara';
+                       break;
+               }
+       }
+       else if (id === 'objectalignleft' || id === 'aligncenter' ||
+               id === 'objectalignright') {
+               // selectionType is 'text', so ignore object align state 
messages.
+               id = '';
+       }
        return id;
 }
 
@@ -1979,6 +2010,10 @@ function onCommandStateChanged(e) {
        }
 
        var id = unoCmdToToolbarId(commandName);
+       // id is set to '' by unoCmdToToolbarId() if the statechange message 
should be ignored.
+       if (id === '')
+               return;
+
        if (state === 'true') {
                if (map._permission === 'edit') {
                        toolbar.enable(id);
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to