[Libreoffice-commits] online.git: 2 commits - loleaflet/src loolwsd/LOKitHelper.hpp loolwsd/LOOLSession.cpp loolwsd/protocol.txt

Mihai Varga mihai.varga at collabora.com
Wed Jul 15 08:49:54 PDT 2015


 loleaflet/src/layer/tile/TileLayer.js |    9 ++++++---
 loolwsd/LOKitHelper.hpp               |   15 ++++++++++++---
 loolwsd/LOOLSession.cpp               |    1 -
 loolwsd/protocol.txt                  |    3 ++-
 4 files changed, 20 insertions(+), 8 deletions(-)

New commits:
commit 370109c6e4d80ffcf166836cfd4d4d87ed726f99
Author: Mihai Varga <mihai.varga at collabora.com>
Date:   Wed Jul 15 18:37:32 2015 +0300

    loleaflet: parse and send part names from the status cmd

diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index c991465..0554ed7 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -269,7 +269,7 @@ L.TileLayer = L.GridLayer.extend({
 			while (index < bytes.length && bytes[index] !== 10) {
 				index++;
 			}
-			textMsg = String.fromCharCode.apply(null, bytes.subarray(0, index + 1));
+			textMsg = String.fromCharCode.apply(null, bytes.subarray(0, index));
 		}
 
 		if (textMsg.startsWith('cursorvisible:')) {
@@ -397,10 +397,13 @@ L.TileLayer = L.GridLayer.extend({
 				this._documentInfo = textMsg;
 				this._parts = command.parts;
 				this._currentPart = command.currentPart;
+				var partNamesStr = bytes === undefined ? textMsg : String.fromCharCode.apply(null, bytes.subarray(index));
+				var partNames = partNamesStr.match(/[^\r\n]+/g);
 				this._map.fire('updateparts', {
 					currentPart: this._currentPart,
 					parts: this._parts,
-					docType: this._docType
+					docType: this._docType,
+					partNames: partNames
 				});
 				this._update();
 				if (!this._tilesPreFetcher) {
@@ -503,7 +506,7 @@ L.TileLayer = L.GridLayer.extend({
 			this._onUpdateTextSelection();
 		}
 		else if (textMsg.startsWith('textselectioncontent:')) {
-			textMsg += String.fromCharCode.apply(null, bytes.subarray(index + 1));
+			textMsg += String.fromCharCode.apply(null, bytes.subarray(index));
 			this._selectionTextContent = textMsg.substr(22);
 		}
 		else if (textMsg.startsWith('setpart:')) {
commit 675cfb8c4a424e0970540ab9c72053b1786f8d24
Author: Mihai Varga <mihai.varga at collabora.com>
Date:   Wed Jul 15 18:31:52 2015 +0300

    loolwsd: send part names with the status message
    
    Also disabled the status length assertion because part names
    are separated by new-line characters ('\n')

diff --git a/loolwsd/LOKitHelper.hpp b/loolwsd/LOKitHelper.hpp
index 7e793f8..a20590a 100644
--- a/loolwsd/LOKitHelper.hpp
+++ b/loolwsd/LOKitHelper.hpp
@@ -38,13 +38,22 @@ namespace LOKitHelper
     std::string documentStatus(LibreOfficeKitDocument *loKitDocument)
     {
         std::string typeString(documentTypeToString(static_cast<LibreOfficeKitDocumentType>(loKitDocument->pClass->getDocumentType(loKitDocument))));
-        long width, height;
+        long width, height, parts;
         loKitDocument->pClass->getDocumentSize(loKitDocument, &width, &height);
-        return ("type=" + typeString + " "
-                "parts=" + std::to_string(loKitDocument->pClass->getParts(loKitDocument)) + " "
+        parts = loKitDocument->pClass->getParts(loKitDocument);
+        std::string status =
+               ("type=" + typeString + " "
+                "parts=" + std::to_string(parts) + " "
                 "current=" + std::to_string(loKitDocument->pClass->getPart(loKitDocument)) + " "
                 "width=" + std::to_string(width) + " "
                 "height=" + std::to_string(height));
+        if (typeString == "spreadsheet" || typeString == "presentation") {
+            for (int i = 0; i < parts; i++) {
+                status += "\n";
+                status += loKitDocument->pClass->getPartName(loKitDocument, i);
+            }
+        }
+        return status;
     }
 };
 
diff --git a/loolwsd/LOOLSession.cpp b/loolwsd/LOOLSession.cpp
index 0e73bf6..448c08e 100644
--- a/loolwsd/LOOLSession.cpp
+++ b/loolwsd/LOOLSession.cpp
@@ -186,7 +186,6 @@ bool MasterProcessSession::handleInput(const char *buffer, int length)
             }
             else if (tokens[0] == "status:")
             {
-                assert(firstLine.size() == static_cast<std::string::size_type>(length));
                 peer->_tileCache->saveStatus(firstLine);
             }
             else if (tokens[0] == "invalidatetiles:")
diff --git a/loolwsd/protocol.txt b/loolwsd/protocol.txt
index 491dc9d..0db74e0 100644
--- a/loolwsd/protocol.txt
+++ b/loolwsd/protocol.txt
@@ -100,9 +100,10 @@ nextmessage: size=<byteSize>
     must be handled by clients that cannot (like those using Poco
     1.6.0, like the "loadtest" program in the loolwsd sources).
 
-status: type=<typeName> parts=<numberOfParts> current=<currentPartNumber> width=<width> height=<height>
+status: type=<typeName> parts=<numberOfParts> current=<currentPartNumber> width=<width> height=<height> [partNames]
 
     <typeName> is 'text, 'spreadsheet', 'presentation', 'drawing' or 'other. Others are numbers.
+    if the document has multiple parts and those have names, part names follow separated by '\n'
 
 textselectioncontent: <content>
 


More information about the Libreoffice-commits mailing list