[Libreoffice-commits] online.git: loleaflet/src loolwsd/bundled loolwsd/LOKitClient.cpp loolwsd/LOOLSession.cpp

Mihai Varga mihai.varga at collabora.com
Mon Oct 5 08:24:29 PDT 2015


 loleaflet/src/layer/tile/TileLayer.js                        |   10 ++++++++++
 loolwsd/LOKitClient.cpp                                      |    5 +++--
 loolwsd/LOOLSession.cpp                                      |    3 +++
 loolwsd/bundled/include/LibreOfficeKit/LibreOfficeKitEnums.h |    4 +++-
 4 files changed, 19 insertions(+), 3 deletions(-)

New commits:
commit 886cdc80df63636ee385a030ec30444573eafafa
Author: Mihai Varga <mihai.varga at collabora.com>
Date:   Mon Oct 5 16:44:40 2015 +0300

    search result count callback handler

diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index cfe686a..5eaab4d 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -214,6 +214,9 @@ 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('setpart:')) {
 			this._onSetPartMsg(textMsg);
 		}
@@ -333,6 +336,13 @@ 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});
+	},
+
 	_onStateChangedMsg: function (textMsg) {
 		var unoMsg = textMsg.substr(14).split('=');
 		var commandName = '',
diff --git a/loolwsd/LOKitClient.cpp b/loolwsd/LOKitClient.cpp
index 97d42da..57f0e03 100644
--- a/loolwsd/LOKitClient.cpp
+++ b/loolwsd/LOKitClient.cpp
@@ -57,6 +57,7 @@ extern "C"
             CASE(STATUS_INDICATOR_SET_VALUE);
             CASE(STATUS_INDICATOR_FINISH);
             CASE(SEARCH_NOT_FOUND);
+            CASE(SEARCH_RESULT_COUNT);
             CASE(DOCUMENT_SIZE_CHANGED);
             CASE(SET_PART);
 #undef CASE
@@ -117,7 +118,7 @@ protected:
 
             if (tokens[0] == "?" || tokens[0] == "help")
             {
-                std::cout << 
+                std::cout <<
                     "Commands mimic LOOL protocol but we talk directly to LOKit:" << std::endl <<
                     "    status" << std::endl <<
                     "        calls LibreOfficeKitDocument::getDocumentType, getParts, getPartName, getDocumentSize" << std::endl <<
@@ -152,7 +153,7 @@ protected:
                 int tilePosY(std::stoi(tokens[5]));
                 int tileWidth(std::stoi(tokens[6]));
                 int tileHeight(std::stoi(tokens[7]));
-                
+
                 std::vector<unsigned char> pixmap(canvasWidth*canvasHeight*4);
                 loKitDocument->pClass->setPart(loKitDocument, partNumber);
                 loKitDocument->pClass->paintTile(loKitDocument, pixmap.data(), canvasWidth, canvasHeight, tilePosX, tilePosY, tileWidth, tileHeight);
diff --git a/loolwsd/LOOLSession.cpp b/loolwsd/LOOLSession.cpp
index a293cde..ef1f1d8 100644
--- a/loolwsd/LOOLSession.cpp
+++ b/loolwsd/LOOLSession.cpp
@@ -808,6 +808,9 @@ extern "C"
         case LOK_CALLBACK_HYPERLINK_CLICKED:
             srv->sendTextFrame("hyperlinkclicked: " + std::string(pPayload));
             break;
+        case LOK_CALLBACK_SEARCH_RESULT_COUNT:
+            srv->sendTextFrame("searchresultcount: " + std::string(pPayload));
+            break;
         case LOK_CALLBACK_STATE_CHANGED:
             srv->sendTextFrame("statechanged: " + std::string(pPayload));
             break;
diff --git a/loolwsd/bundled/include/LibreOfficeKit/LibreOfficeKitEnums.h b/loolwsd/bundled/include/LibreOfficeKit/LibreOfficeKitEnums.h
index 7038e5f..dc3e0f9 100644
--- a/loolwsd/bundled/include/LibreOfficeKit/LibreOfficeKitEnums.h
+++ b/loolwsd/bundled/include/LibreOfficeKit/LibreOfficeKitEnums.h
@@ -155,7 +155,9 @@ typedef enum
      *
      * Payload is a single 0-based integer.
      */
-    LOK_CALLBACK_SET_PART
+    LOK_CALLBACK_SET_PART,
+    /// Number of search results, in case something is found.
+    LOK_CALLBACK_SEARCH_RESULT_COUNT
 }
 LibreOfficeKitCallbackType;
 


More information about the Libreoffice-commits mailing list