[Libreoffice-commits] online.git: 2 commits - loleaflet/README loleaflet/reference.html loleaflet/src

Mihai Varga mihai.varga at collabora.com
Mon Oct 19 00:46:48 PDT 2015


 loleaflet/README                      |    2 ++
 loleaflet/reference.html              |   32 ++++++++++++++++++++++++++++++--
 loleaflet/src/control/Search.js       |   12 +++++++++++-
 loleaflet/src/layer/tile/GridLayer.js |   13 +++++++++++++
 loleaflet/src/layer/tile/TileLayer.js |    5 ++++-
 5 files changed, 60 insertions(+), 4 deletions(-)

New commits:
commit ed35ac63f6cf468b3ed143eb33611c5d4634be8d
Author: Mihai Varga <mihai.varga at collabora.com>
Date:   Mon Oct 19 10:44:54 2015 +0300

    loleaflet: searchAll method

diff --git a/loleaflet/README b/loleaflet/README
index 24123a7..3158cf2 100644
--- a/loleaflet/README
+++ b/loleaflet/README
@@ -62,10 +62,12 @@ API & events
 Search:
     - API:
         map.search(text, [backward])
+        map.searchAll(text, [backward])
     - events:
         map.on('search', function (e) {}) (currently only fired when no search result is found) where:
             + e.originalPhrase = the phrase that has been searched for
             + e.count = number of results
+            + e.results = [SearchResult], where SearchResult = {part: part, rectangles: [Bounds]}
 
 Zoom:
     - API:
diff --git a/loleaflet/reference.html b/loleaflet/reference.html
index 2d79223..9c4a2e2 100644
--- a/loleaflet/reference.html
+++ b/loleaflet/reference.html
@@ -1405,6 +1405,14 @@ var map = L.map('map', {
         Or backwards if specified.</td>
 	</tr>
 	<tr>
+		<td><code><b>searchAll</b>(
+			<nobr><String> <i>phrase</i>,</nobr>
+			<nobr><Boolean> <i>backward?</i> )</nobr>
+		</code></td>
+		<td><code>undefined</code></td>
+		<td>Searches for all occurences of the given phrase.</td>
+	</tr>
+	<tr>
 		<td><code><b>setPermission</b>(
 			<nobr><<a href="#documentpermission-values">DocumentPermissionValues</a>> <i>documenPermission</i>)</nobr>
 		</code></td>
@@ -1667,8 +1675,28 @@ var map = L.map('map', {
 	</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>
+		<td><code><a href="#search-result">SearchResult[]</a></code></td>
+		<td>An array representing the selections of the search results in the document.</td>
+	</tr>
+</table>
+
+<h3 id="search-result">SearchResult</h3>
+
+<table data-id='values'>
+	<tr>
+		<th class="width100">property</th>
+		<th class="width100">type</th>
+		<th>description</th>
+	</tr>
+	<tr>
+		<td><code><b>part</b></code></td>
+		<td><code>Number</code></td>
+        <td>The part in which the selection lies.</td>
+	</tr>
+	<tr>
+		<td><code><b>rectangles</b></code></td>
+        <td><code><a href="#bounds">Bounds[]</a></code></td>
+        <td>Selection bounds in pixels.</td>
 	</tr>
 </table>
 
diff --git a/loleaflet/src/control/Search.js b/loleaflet/src/control/Search.js
index e9413e4..e08d1c4 100644
--- a/loleaflet/src/control/Search.js
+++ b/loleaflet/src/control/Search.js
@@ -1,8 +1,11 @@
 L.Map.include({
-	search: function (text, backward) {
+	search: function (text, backward, all) {
 		if (backward === undefined) {
 			backward = false;
 		}
+		if (all === undefined) {
+			all = 0;
+		}
 
 		var searchCmd = {
 			'SearchItem.SearchString': {
@@ -29,9 +32,16 @@ L.Map.include({
 		searchCmd['SearchItem.SearchStartPointY'] = {};
 		searchCmd['SearchItem.SearchStartPointY'].type = 'long';
 		searchCmd['SearchItem.SearchStartPointY'].value = topLeftTwips.y;
+		searchCmd['SearchItem.Command'] = {};
+		searchCmd['SearchItem.Command'].type = 'long';
+		searchCmd['SearchItem.Command'].value = all;
 		L.Socket.sendMessage('uno .uno:ExecuteSearch ' + JSON.stringify(searchCmd));
 	},
 
+	searchAll: function (text, backward) {
+		this.search(text, backward, 1);
+	},
+
 	resetSelection: function () {
 		L.Socket.sendMessage('resetselection');
 	}
diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index b16429f..551e25b 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -373,7 +373,10 @@ L.TileLayer = L.GridLayer.extend({
 		var count = obj.searchResultSelection.length;
 		var results = [];
 		for (var i = 0; i < obj.searchResultSelection.length; i++) {
-			results.push(this._twipsRectangleToPixelBounds(obj.searchResultSelection[i]));
+			results.push({
+				part: obj.searchResultSelection[i].part,
+				rectangles: this._twipsRectanglesToPixelBounds(obj.searchResultSelection[i].rectangles)
+			});
 		}
 		this._map.fire('search', {originalPhrase: originalPhrase, count: count, results: results});
 	},
commit a666eb248f7143f3894fbd264df830f022deca66
Author: Mihai Varga <mihai.varga at collabora.com>
Date:   Mon Oct 19 10:29:53 2015 +0300

    loleaflet: [more] rectangles to pixel bounds method

diff --git a/loleaflet/src/layer/tile/GridLayer.js b/loleaflet/src/layer/tile/GridLayer.js
index 0e1fded..b11a51a 100644
--- a/loleaflet/src/layer/tile/GridLayer.js
+++ b/loleaflet/src/layer/tile/GridLayer.js
@@ -773,6 +773,19 @@ L.GridLayer = L.Layer.extend({
 				this._twipsToPixels(bottomRightTwips));
 	},
 
+	_twipsRectanglesToPixelBounds: function (strRectangles) {
+		// used when we have more rectangles
+		strRectangles = strRectangles.split(';');
+		var boundsList = [];
+		for (var i = 0; i < strRectangles.length; i++) {
+			var bounds = this._twipsRectangleToPixelBounds(strRectangles[i]);
+			if (bounds) {
+				boundsList.push(bounds);
+			}
+		}
+		return boundsList;
+	},
+
 	_noTilesToLoad: function () {
 		for (var key in this._tiles) {
 			if (!this._tiles[key].loaded) { return false; }


More information about the Libreoffice-commits mailing list