loleaflet/reference.html | 5 +++++ loleaflet/src/layer/tile/GridLayer.js | 15 +++++++++++++++ loleaflet/src/layer/tile/TileLayer.js | 19 ++++++++++++------- loolwsd/LOKitClient.cpp | 1 + loolwsd/LOOLSession.cpp | 3 +++ 5 files changed, 36 insertions(+), 7 deletions(-)
New commits: commit d8fa9d708b7d9138b6c3a8abc9a6bef981f6d27c Author: Mihai Varga <[email protected]> Date: Tue Oct 6 17:33:22 2015 +0300 handle LOK_CALLBACK_SEARCH_RESULT_SELECTION callback diff --git a/loleaflet/reference.html b/loleaflet/reference.html index d45f019..057c2d5 100644 --- a/loleaflet/reference.html +++ b/loleaflet/reference.html @@ -6823,6 +6823,11 @@ map.addControl(new MyControl()); <td><code>Number</code></td> <td>Number of search results</td> </tr> + <tr> + <td><code><b>results</b></code></td> + <td><code><a href="#bounds">Bounds[]</a></code></td> + <td>An array of bounds representing the selections of the search results in the document.</td> + </tr> </table> <h3 id="partpagerectangles-event">PartPageRectangles</h3> diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js index 5eaab4d..6be61de 100644 --- a/loleaflet/src/layer/tile/TileLayer.js +++ b/loleaflet/src/layer/tile/TileLayer.js @@ -214,8 +214,8 @@ L.TileLayer = L.GridLayer.extend({ else if (textMsg.startsWith('searchnotfound:')) { this._onSearchNotFoundMsg(textMsg); } - else if (textMsg.startsWith('searchresultcount:')) { - this._onSearchResultCount(textMsg); + else if (textMsg.startsWith('searchresultselection:')) { + this._onSearchResultSelection(textMsg); } else if (textMsg.startsWith('setpart:')) { this._onSetPartMsg(textMsg); @@ -336,11 +336,16 @@ L.TileLayer = L.GridLayer.extend({ this._map.fire('search', {originalPhrase: originalPhrase, count: 0}); }, - _onSearchResultCount: function (textMsg) { - textMsg = textMsg.substring(19); - var count = parseInt(textMsg.substring(0, textMsg.indexOf(';'))); - var originalPhrase = textMsg.substring(textMsg.indexOf(';') + 1); - this._map.fire('search', {originalPhrase: originalPhrase, count: count}); + _onSearchResultSelection: function (textMsg) { + textMsg = textMsg.substring(23); + var obj = JSON.parse(textMsg); + var originalPhrase = obj.searchString; + var count = obj.searchResultSelection.length; + var results = []; + for (var i = 0; i < obj.searchResultSelection.length; i++) { + results.push(this._twipsRectangleToPixelBounds(obj.searchResultSelection[i])); + } + this._map.fire('search', {originalPhrase: originalPhrase, count: count, results: results}); }, _onStateChangedMsg: function (textMsg) { diff --git a/loolwsd/LOKitClient.cpp b/loolwsd/LOKitClient.cpp index 57f0e03..8e3f546 100644 --- a/loolwsd/LOKitClient.cpp +++ b/loolwsd/LOKitClient.cpp @@ -58,6 +58,7 @@ extern "C" CASE(STATUS_INDICATOR_FINISH); CASE(SEARCH_NOT_FOUND); CASE(SEARCH_RESULT_COUNT); + CASE(SEARCH_RESULT_SELECTION); CASE(DOCUMENT_SIZE_CHANGED); CASE(SET_PART); #undef CASE diff --git a/loolwsd/LOOLSession.cpp b/loolwsd/LOOLSession.cpp index ef1f1d8..d8b7dd0 100644 --- a/loolwsd/LOOLSession.cpp +++ b/loolwsd/LOOLSession.cpp @@ -826,6 +826,9 @@ extern "C" case LOK_CALLBACK_SEARCH_NOT_FOUND: srv->sendTextFrame("searchnotfound: " + std::string(pPayload)); break; + case LOK_CALLBACK_SEARCH_RESULT_SELECTION: + srv->sendTextFrame("searchresultselection: " + std::string(pPayload)); + break; case LOK_CALLBACK_DOCUMENT_SIZE_CHANGED: srv->getStatus("", 0); srv->getPartPageRectangles("", 0); commit fd7d03a8c738401a84815e26b38310416009e454 Author: Mihai Varga <[email protected]> Date: Tue Oct 6 17:32:39 2015 +0300 loleaflet: twips rectangle to pixel bounds method diff --git a/loleaflet/src/layer/tile/GridLayer.js b/loleaflet/src/layer/tile/GridLayer.js index 9c89f7c..0e1fded 100644 --- a/loleaflet/src/layer/tile/GridLayer.js +++ b/loleaflet/src/layer/tile/GridLayer.js @@ -758,6 +758,21 @@ L.GridLayer = L.Layer.extend({ pixels.y * this._tileHeightTwips / this._tileSize); }, + _twipsRectangleToPixelBounds: function (strRectangle) { + // TODO use this more + // strRectangle = x, y, width, height + var strTwips = strRectangle.match(/\d+/g); + if (!strTwips) { + return null; + } + var topLeftTwips = new L.Point(parseInt(strTwips[0]), parseInt(strTwips[1])); + var offset = new L.Point(parseInt(strTwips[2]), parseInt(strTwips[3])); + var bottomRightTwips = topLeftTwips.add(offset); + return new L.Bounds( + this._twipsToPixels(topLeftTwips), + this._twipsToPixels(bottomRightTwips)); + }, + _noTilesToLoad: function () { for (var key in this._tiles) { if (!this._tiles[key].loaded) { return false; } _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
