[Libreoffice-commits] online.git: kit/KitHelper.hpp loleaflet/src

Ashod Nakashian (via logerrit) logerrit at kemper.freedesktop.org
Sat Aug 17 02:31:03 UTC 2019


 kit/KitHelper.hpp              |   51 ++++++++++++++++++++++++-----------------
 loleaflet/src/control/Parts.js |    1 
 loleaflet/src/core/Socket.js   |    7 +++++
 3 files changed, 38 insertions(+), 21 deletions(-)

New commits:
commit 7d03d68e1ac9a483a48bc01ad00aa1af79561736
Author:     Ashod Nakashian <ashod.nakashian at collabora.co.uk>
AuthorDate: Sun Sep 16 17:32:56 2018 -0400
Commit:     Ashod Nakashian <ashnakash at gmail.com>
CommitDate: Sat Aug 17 04:30:42 2019 +0200

    wsd: leaflet: status now includes selected parts
    
    Change-Id: I3eeb2fbc52d28047dd0ab7e4318fa44d5c5c0a98
    Reviewed-on: https://gerrit.libreoffice.org/69632
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>
    Reviewed-on: https://gerrit.libreoffice.org/71096

diff --git a/kit/KitHelper.hpp b/kit/KitHelper.hpp
index b0962276a..0c449262c 100644
--- a/kit/KitHelper.hpp
+++ b/kit/KitHelper.hpp
@@ -64,32 +64,41 @@ namespace LOKitHelper
 
         if (type == LOK_DOCTYPE_SPREADSHEET || type == LOK_DOCTYPE_PRESENTATION)
         {
-            if (type == LOK_DOCTYPE_SPREADSHEET)
+            std::ostringstream hposs;
+            std::ostringstream sposs;
+            for (int i = 0; i < parts; ++i)
             {
-                std::ostringstream hposs;
-                for (int i = 0; i < parts; ++i)
+                ptrValue = loKitDocument->pClass->getPartInfo(loKitDocument, i);
+                const std::string partinfo(ptrValue);
+                std::free(ptrValue);
+                for (const auto& prop : Util::JsonToMap(partinfo))
                 {
-
-                    ptrValue = loKitDocument->pClass->getPartInfo(loKitDocument, i);
-                    std::string partinfo(ptrValue);
-                    std::free(ptrValue);
-                    const auto aPartInfo = Util::JsonToMap(partinfo);
-                    for (const auto& prop: aPartInfo)
+                    const std::string& name = prop.first;
+                    if (name == "visible")
                     {
-                        const std::string& name = prop.first;
-                        if (name == "visible")
-                        {
-                            if (prop.second == "0")
-                                hposs << i << ",";
-                        }
+                        if (prop.second == "0")
+                            hposs << i << ',';
+                    }
+                    else if (name == "selected")
+                    {
+                        if (prop.second == "1")
+                            sposs << i << ',';
                     }
                 }
-                std::string hiddenparts = hposs.str();
-                if (!hiddenparts.empty())
-                {
-                    hiddenparts.pop_back();
-                    oss << " hiddenparts=" << hiddenparts;
-                }
+            }
+
+            std::string hiddenparts = hposs.str();
+            if (!hiddenparts.empty())
+            {
+                hiddenparts.pop_back(); // Remove last ','
+                oss << " hiddenparts=" << hiddenparts;
+            }
+
+            std::string selectedparts = sposs.str();
+            if (!selectedparts.empty())
+            {
+                selectedparts.pop_back(); // Remove last ','
+                oss << " selectedparts=" << selectedparts;
             }
 
             for (int i = 0; i < parts; ++i)
diff --git a/loleaflet/src/control/Parts.js b/loleaflet/src/control/Parts.js
index 49a8de3ec..24e57ba55 100644
--- a/loleaflet/src/control/Parts.js
+++ b/loleaflet/src/control/Parts.js
@@ -57,6 +57,7 @@ L.Map.include({
 	// part is the part index/id
 	// how is 0 to deselect, 1 to select, and 2 to toggle selection
 	selectPart: function (part, how, external) {
+		//TODO: Update/track selected parts.
 		var docLayer = this._docLayer;
 		if (typeof (part) === 'number' && part >= 0 && part < docLayer._parts) {
 			var selectedPart = part;
diff --git a/loleaflet/src/core/Socket.js b/loleaflet/src/core/Socket.js
index e676b724a..5488697c9 100644
--- a/loleaflet/src/core/Socket.js
+++ b/loleaflet/src/core/Socket.js
@@ -976,6 +976,13 @@ L.Socket = L.Class.extend({
 					command.hiddenparts.push(parseInt(item));
 				});
 			}
+			else if (tokens[i].startsWith('selectedparts=')) {
+				var selectedparts = tokens[i].substring(14).split(',');
+				command.selectedparts = [];
+				selectedparts.forEach(function (item) {
+					command.selectedparts.push(parseInt(item));
+				});
+			}
 		}
 		if (command.tileWidth && command.tileHeight && this._map._docLayer) {
 			var defaultZoom = this._map.options.zoom;


More information about the Libreoffice-commits mailing list