loleaflet/README                      |    2 +-
 loleaflet/dist/toolbar/toolbar.js     |    3 +--
 loleaflet/src/control/Parts.js        |    4 +++-
 loleaflet/src/control/Search.js       |   18 +++++++++++++++---
 loleaflet/src/layer/tile/TileLayer.js |    5 +++++
 5 files changed, 25 insertions(+), 7 deletions(-)

New commits:
commit 35e904ecf942eb379ec181a4edf6e18d45adb59c
Author: Pranav Kant <pran...@collabora.co.uk>
Date:   Fri Jan 13 20:32:10 2017 +0530

    loleaflet: Don't focus on map if search is going on
    
    ... and part is changed.
    
    Change-Id: Icebcfc9924a6891787d08476ba37a0174ae9b67d

diff --git a/loleaflet/src/control/Parts.js b/loleaflet/src/control/Parts.js
index cbca779..41f36e9 100644
--- a/loleaflet/src/control/Parts.js
+++ b/loleaflet/src/control/Parts.js
@@ -46,7 +46,9 @@ L.Map.include({
                        this._socket.sendMessage('commandvalues 
command=.uno:ViewRowColumnHeaders');
                }
                docLayer._drawSearchResults();
-               this.focus();
+               if (!this._searchRequested) {
+                       this.focus();
+               }
        },
 
        getPreview: function (id, index, maxWidth, maxHeight, options) {
diff --git a/loleaflet/src/control/Search.js b/loleaflet/src/control/Search.js
index 8bf8d15..f030a7b 100644
--- a/loleaflet/src/control/Search.js
+++ b/loleaflet/src/control/Search.js
@@ -50,6 +50,7 @@ L.Map.include({
                searchCmd['SearchItem.Command'] = {};
                searchCmd['SearchItem.Command'].type = 'long';
                searchCmd['SearchItem.Command'].value = all;
+               this._searchRequested = true;
                this._socket.sendMessage('uno .uno:ExecuteSearch ' + 
JSON.stringify(searchCmd));
        },
 
diff --git a/loleaflet/src/layer/tile/TileLayer.js 
b/loleaflet/src/layer/tile/TileLayer.js
index 4f34b8f..0e75eaa 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -885,11 +885,13 @@ L.TileLayer = L.GridLayer.extend({
 
        _onSearchNotFoundMsg: function (textMsg) {
                this._clearSearchResults();
+               this._searchRequested = false;
                var originalPhrase = textMsg.substring(16);
                this._map.fire('search', {originalPhrase: originalPhrase, 
count: 0});
        },
 
        _onSearchResultSelection: function (textMsg) {
+               this._searchRequested = false;
                textMsg = textMsg.substring(23);
                var obj = JSON.parse(textMsg);
                var originalPhrase = obj.searchString;
commit 64835bec909e797daa25947da876e779a3641134
Author: Pranav Kant <pran...@collabora.co.uk>
Date:   Fri Jan 13 19:59:28 2017 +0530

    loleaflet: Allow search expansion as you type
    
    Change-Id: I648721a0ed9e4d66db45956657398a4834ac45ce

diff --git a/loleaflet/dist/toolbar/toolbar.js 
b/loleaflet/dist/toolbar/toolbar.js
index 0385b26..02a89f0 100644
--- a/loleaflet/dist/toolbar/toolbar.js
+++ b/loleaflet/dist/toolbar/toolbar.js
@@ -736,10 +736,9 @@ function selectItem(item, func)
                item.current = index;
        }
 }
-
 function onSearch(e) {
        var toolbar = w2ui['toolbar-down'];
-       map.search(L.DomUtil.get('search-input').value);
+       map.search(L.DomUtil.get('search-input').value, false, 0, true /* 
expand search */);
        toolbar.enable('searchprev');
        toolbar.enable('searchnext');
        toolbar.show('cancelsearch');
diff --git a/loleaflet/src/control/Search.js b/loleaflet/src/control/Search.js
index 22bd3dd..8bf8d15 100644
--- a/loleaflet/src/control/Search.js
+++ b/loleaflet/src/control/Search.js
@@ -1,5 +1,5 @@
 L.Map.include({
-       search: function (text, backward, all) {
+       search: function (text, backward, all, expand) {
                if (backward === undefined) {
                        backward = false;
                }
@@ -28,14 +28,25 @@ L.Map.include({
                                Math.max(viewTopLeftpx.y, docBoundsTopLeft.y)));
                var topLeftTwips = this._docLayer._latLngToTwips(topLeft);
 
+               var searchStartPointX = topLeftTwips.x;
+               var searchStartPointY = topLeftTwips.y;
+               if (this._docLayer && this._docLayer._lastSearchResult && 
expand) {
+                       var strTwips = 
this._docLayer._lastSearchResult.twipsRectangles.match(/\d+/g);
+                       if (strTwips != null) {
+                               searchStartPointX = strTwips[0];
+                               searchStartPointY = strTwips[1];
+                       }
+                       this.resetSelection();
+               }
+
                searchCmd['SearchItem.SearchString'].value = text;
                searchCmd['SearchItem.Backward'].value = backward;
                searchCmd['SearchItem.SearchStartPointX'] = {};
                searchCmd['SearchItem.SearchStartPointX'].type = 'long';
-               searchCmd['SearchItem.SearchStartPointX'].value = 
topLeftTwips.x;
+               searchCmd['SearchItem.SearchStartPointX'].value = 
searchStartPointX;
                searchCmd['SearchItem.SearchStartPointY'] = {};
                searchCmd['SearchItem.SearchStartPointY'].type = 'long';
-               searchCmd['SearchItem.SearchStartPointY'].value = 
topLeftTwips.y;
+               searchCmd['SearchItem.SearchStartPointY'].value = 
searchStartPointY;
                searchCmd['SearchItem.Command'] = {};
                searchCmd['SearchItem.Command'].type = 'long';
                searchCmd['SearchItem.Command'].value = all;
diff --git a/loleaflet/src/layer/tile/TileLayer.js 
b/loleaflet/src/layer/tile/TileLayer.js
index b7fd4a0..4f34b8f 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -910,12 +910,15 @@ L.TileLayer = L.GridLayer.extend({
                        this._clearSearchResults();
                        this._searchResults = results;
                        this._map.setPart(results[0].part); // go to first 
result.
+               } else if (count === 1) {
+                       this._lastSearchResult = results[0];
                }
                this._searchTerm = originalPhrase;
                this._map.fire('search', {originalPhrase: originalPhrase, 
count: count, highlightAll: highlightAll, results: results});
        },
 
        _clearSearchResults: function() {
+               this._lastSearchResult = null;
                this._searchResults = null;
                this._searchTerm = null;
                this._searchResultsLayer.clearLayers();
commit 582bfbeb7fa2363b0fcd424b8d784675862be6a7
Author: Pranav Kant <pran...@collabora.co.uk>
Date:   Fri Jan 13 19:42:37 2017 +0530

    Update path
    
    Change-Id: Ic0654f64ee5ba9e4678cca42ceea4a5958a01c66

diff --git a/loleaflet/README b/loleaflet/README
index bfbadf5..714f7d5 100644
--- a/loleaflet/README
+++ b/loleaflet/README
@@ -130,7 +130,7 @@ API & events
 
 ######################################################################
 # See /loleaflet/reference.html for a better formated documentation. #
-# See /loolwsd/reference.txt for the HTTP API documentation.         #
+# See /wsd/reference.txt for the HTTP API documentation.         #
 ######################################################################
 
 Search:
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to