bundled/include/LibreOfficeKit/LibreOfficeKitEnums.h |    8 ++++
 kit/ChildSession.cpp                                 |    6 +++
 kit/KitHelper.hpp                                    |    3 +
 loleaflet/dist/toolbar.css                           |    7 +++-
 loleaflet/dist/toolbar/toolbar.js                    |   31 +++++++++++++++++++
 loleaflet/src/layer/tile/TileLayer.js                |    8 ++++
 tools/KitClient.cpp                                  |    1 
 wsd/protocol.txt                                     |    5 +++
 8 files changed, 66 insertions(+), 3 deletions(-)

New commits:
commit 024e786e8591bbb75b6828ef3aad1a65574b7e97
Author: Marco Cecchetti <marco.cecche...@collabora.com>
Date:   Mon May 8 00:38:13 2017 +0200

    calc: added an address input field
    
    Change-Id: Ic030724e392693847a195b5e53866b40ebad7435
    Reviewed-on: https://gerrit.libreoffice.org/37359
    Reviewed-by: pranavk <pran...@collabora.co.uk>
    Tested-by: pranavk <pran...@collabora.co.uk>

diff --git a/bundled/include/LibreOfficeKit/LibreOfficeKitEnums.h 
b/bundled/include/LibreOfficeKit/LibreOfficeKitEnums.h
index dffc728e..0bf35024 100644
--- a/bundled/include/LibreOfficeKit/LibreOfficeKitEnums.h
+++ b/bundled/include/LibreOfficeKit/LibreOfficeKitEnums.h
@@ -500,7 +500,13 @@ typedef enum
      *
      * The payload says if we are invalidating a row or column header.
      */
-    LOK_CALLBACK_INVALIDATE_HEADER = 33
+    LOK_CALLBACK_INVALIDATE_HEADER = 33,
+
+    /**
+     * The text content of the address field in Calc.
+     */
+    LOK_CALLBACK_CELL_ADDRESS = 34
+
 }
 LibreOfficeKitCallbackType;
 
diff --git a/kit/ChildSession.cpp b/kit/ChildSession.cpp
index 295f261f..1fbc1944 100644
--- a/kit/ChildSession.cpp
+++ b/kit/ChildSession.cpp
@@ -1000,7 +1000,8 @@ void ChildSession::rememberEventsForInactiveUser(const 
int type, const std::stri
              type == LOK_CALLBACK_CELL_CURSOR ||
              type == LOK_CALLBACK_GRAPHIC_SELECTION ||
              type == LOK_CALLBACK_DOCUMENT_SIZE_CHANGED ||
-             type == LOK_CALLBACK_INVALIDATE_HEADER)
+             type == LOK_CALLBACK_INVALIDATE_HEADER ||
+             type == LOK_CALLBACK_CELL_ADDRESS)
     {
         auto lock(getLock());
         _stateRecorder.recordEvent(type, payload);
@@ -1230,6 +1231,9 @@ void ChildSession::loKitCallback(const int type, const 
std::string& payload)
     case LOK_CALLBACK_INVALIDATE_HEADER:
         sendTextFrame("invalidateheader: " + payload);
         break;
+    case LOK_CALLBACK_CELL_ADDRESS:
+        sendTextFrame("celladdress: " + payload);
+        break;
     default:
         LOG_ERR("Unknown callback event (" << type << "): " << payload);
     }
diff --git a/kit/KitHelper.hpp b/kit/KitHelper.hpp
index 63040a1e..efb0d5cb 100644
--- a/kit/KitHelper.hpp
+++ b/kit/KitHelper.hpp
@@ -111,6 +111,9 @@ namespace LOKitHelper
             return "COMMENT";
         case LOK_CALLBACK_INVALIDATE_HEADER:
             return "INVALIDATE_HEADER";
+        case LOK_CALLBACK_CELL_ADDRESS:
+            return "CELL_ADDRESS";
+
        }
 
         return std::to_string(type);
diff --git a/loleaflet/dist/toolbar.css b/loleaflet/dist/toolbar.css
index a2b5c31f..e8288c68 100644
--- a/loleaflet/dist/toolbar.css
+++ b/loleaflet/dist/toolbar.css
@@ -52,9 +52,14 @@
     padding-left: 125px;
 }
 
+#addressInput {
+    height: 29px;
+    width: 100px;
+}
+
 #formulaInput {
     height: 29px;
-    width: 800px;
+    width: 700px;
 }
 
 #tb_toolbar-up_item_close {
diff --git a/loleaflet/dist/toolbar/toolbar.js 
b/loleaflet/dist/toolbar/toolbar.js
index 793bd910..bbd4b81e 100644
--- a/loleaflet/dist/toolbar/toolbar.js
+++ b/loleaflet/dist/toolbar/toolbar.js
@@ -614,6 +614,8 @@ $(function () {
                name: 'formulabar',
                items: [
                        {type: 'html',  id: 'left'},
+                       {type: 'html', id: 'address', html: '<input 
id="addressInput" type="text">'},
+                       {type: 'break'},
                        {type: 'button',  id: 'sum',  img: 'autosum', hint: 
_('Sum')},
                        {type: 'button',  id: 'function',  img: 'equal', hint: 
_('Function')},
                        {type: 'button', hidden: true, id: 'cancelformula',  
img: 'cancel', hint: _('Cancel')},
@@ -624,6 +626,7 @@ $(function () {
                        onClick(e.target);
                },
                onRefresh: function(e) {
+                       $('#addressInput').off('keyup', 
onAddressInput).on('keyup', onAddressInput);
                        $('#formulaInput').off('keyup', 
onFormulaInput).on('keyup', onFormulaInput);
                        $('#formulaInput').off('blur', 
onFormulaBarBlur).on('blur', onFormulaBarBlur);
                        $('#formulaInput').off('focus', 
onFormulaBarFocus).on('focus', onFormulaBarFocus);
@@ -868,6 +871,25 @@ function onInsertFile() {
        return false;
 }
 
+function onAddressInput(e) {
+       if (e.keyCode === 13) {
+               // address control should not have focus anymore
+               map.focus();
+               var value = L.DomUtil.get('addressInput').value;
+               var command = {
+                       ToPoint : {
+                               type: 'string',
+                               value: value
+                       }
+
+               };
+               map.sendUnoCommand('.uno:GoToCell', command);
+       } else if (e.keyCode === 27) { // 27 = esc key
+               map.sendUnoCommand('.uno:Cancel');
+               map.focus();
+       }
+}
+
 function onFormulaInput(e) {
        // keycode = 13 is 'enter'
        if (e.keyCode === 13) {
@@ -1407,6 +1429,13 @@ map.on('commandresult', function (e) {
        }
 });
 
+map.on('celladdress', function (e) {
+       if (document.activeElement !== L.DomUtil.get('addressInput')) {
+               // if the user is not editing the address field
+               L.DomUtil.get('addressInput').value = e.address;
+       }
+});
+
 map.on('cellformula', function (e) {
        if (document.activeElement !== L.DomUtil.get('formulaInput')) {
                // if the user is not editing the formula bar
@@ -1456,6 +1485,7 @@ map.on('updatepermission', function (e) {
                $('.fontsizes-select').prop('disabled', false);
 
                // Enable formula bar
+               $('#addressInput').prop('disabled', false);
                $('#formulaInput').prop('disabled', false);
                toolbar = w2ui.formulabar;
                formulaBarButtons.forEach(function(id) {
@@ -1485,6 +1515,7 @@ map.on('updatepermission', function (e) {
                $('.fontsizes-select').prop('disabled', true);
 
                // Disable formula bar
+               $('#addressInput').prop('disabled', true);
                $('#formulaInput').prop('disabled', true);
 
                toolbar = w2ui.formulabar;
diff --git a/loleaflet/src/layer/tile/TileLayer.js 
b/loleaflet/src/layer/tile/TileLayer.js
index 0d2bb93a..8611d3d6 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -364,6 +364,9 @@ L.TileLayer = L.GridLayer.extend({
                else if (textMsg.startsWith('cellcursor:')) {
                        this._onCellCursorMsg(textMsg);
                }
+               else if (textMsg.startsWith('celladdress:')) {
+                       this._onCellAddressMsg(textMsg);
+               }
                else if (textMsg.startsWith('cellformula:')) {
                        this._onCellFormulaMsg(textMsg);
                }
@@ -499,6 +502,11 @@ L.TileLayer = L.GridLayer.extend({
                }
        },
 
+       _onCellAddressMsg: function (textMsg) {
+               var address = textMsg.substring(13);
+               this._map.fire('celladdress', {address: address});
+       },
+
        _onCellFormulaMsg: function (textMsg) {
                var formula = textMsg.substring(13);
                this._selectionTextContent = formula;
diff --git a/tools/KitClient.cpp b/tools/KitClient.cpp
index 95597b35..8aa38e73 100644
--- a/tools/KitClient.cpp
+++ b/tools/KitClient.cpp
@@ -77,6 +77,7 @@ extern "C"
             CASE(REDLINE_TABLE_ENTRY_MODIFIED);
             CASE(COMMENT);
             CASE(INVALIDATE_HEADER);
+            CASE(CELL_ADDRESS);
 #undef CASE
         }
         std::cout << " payload: " << payload << std::endl;
diff --git a/wsd/protocol.txt b/wsd/protocol.txt
index b2404a70..1d136eb7 100644
--- a/wsd/protocol.txt
+++ b/wsd/protocol.txt
@@ -375,6 +375,11 @@ comment:
     Signals that comment has either been added, removed or modified. See
     LOK_CALLBACK_COMMENT for JSON structure.
 
+celladdress: <payload>
+
+    Message is sent anytime the content of the address input box should be 
updated.
+    The <payload> is a string representing the new content.
+
 stats: <key> <value>
 
     Contains statistical data. Eg: 'stats: wopiloadduration 5' means that
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to