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

Miklos Vajna vmiklos at collabora.co.uk
Wed Nov 18 09:15:52 PST 2015


 loleaflet/debug/document/document_simple_example.html |    8 +++++
 loleaflet/src/core/Socket.js                          |    6 ++++
 loolwsd/LOOLSession.cpp                               |   26 +++++++++++++++---
 loolwsd/LOOLSession.hpp                               |    3 ++
 loolwsd/protocol.txt                                  |    4 ++
 5 files changed, 43 insertions(+), 4 deletions(-)

New commits:
commit 084e4702573c7bb3be1e203eac9b6ff1fbe72404
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Wed Nov 18 18:10:00 2015 +0100

    loleaflet: send rendering options on load

diff --git a/loleaflet/debug/document/document_simple_example.html b/loleaflet/debug/document/document_simple_example.html
index fdadd98..bf3a26c 100644
--- a/loleaflet/debug/document/document_simple_example.html
+++ b/loleaflet/debug/document/document_simple_example.html
@@ -57,8 +57,16 @@
         vex.dialog.alert('Wrong host, usage: host=ws://localhost:9980');
     }
 
+    var renderingOptions = {
+        ".uno:HideWhitespace": {
+            "type": "boolean",
+            "value": "false"
+        }
+    };
+
     var globalMap = L.map('map', {
             doc: filePath,
+            renderingOptions: renderingOptions,
             server: host,
             edit: edit,
             timestamp: timestamp,
diff --git a/loleaflet/src/core/Socket.js b/loleaflet/src/core/Socket.js
index ad240ba..fe47c65 100644
--- a/loleaflet/src/core/Socket.js
+++ b/loleaflet/src/core/Socket.js
@@ -53,6 +53,12 @@ L.Socket = {
 		if (this._map.options.timestamp) {
 			msg += ' timestamp=' + this._map.options.timestamp;
 		}
+		if (this._map.options.renderingOptions) {
+			var options = {
+				'rendering': this._map.options.renderingOptions
+			};
+			msg += ' options=' + JSON.stringify(options);
+		}
 		this.socket.send(msg);
 		this.socket.send('status');
 		this.socket.send('partpagerectangles');
commit e6f0abf763f699d5f191eefa9c693548143a5313
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Wed Nov 18 18:09:13 2015 +0100

    loolwsd: support getting load options
    
    This is a single json that contains both load and rendering options.
    Currently only the rendering ones are added to it by the client.
    
    Also, just accept the options string for now, a later commit will have
    to actually pass the rendering part to
    lok::Document::initializeForRendering().

diff --git a/loolwsd/LOOLSession.cpp b/loolwsd/LOOLSession.cpp
index b6abe34..112eb08 100644
--- a/loolwsd/LOOLSession.cpp
+++ b/loolwsd/LOOLSession.cpp
@@ -427,22 +427,42 @@ bool MasterProcessSession::invalidateTiles(const char* /*buffer*/, int /*length*
 
 bool MasterProcessSession::loadDocument(const char* /*buffer*/, int /*length*/, StringTokenizer& tokens)
 {
-    if (tokens.count() < 2 || tokens.count() > 4)
+    if (tokens.count() < 2)
     {
         sendTextFrame("error: cmd=load kind=syntax");
         return false;
     }
 
-    if (tokens.count() > 2 )
+    // First token is the "load" command itself.
+    size_t offset = 1;
+    if (tokens.count() > 2 && tokens[1].find("part=") == 0)
+    {
         getTokenInteger(tokens[1], "part", _loadPart);
+        ++offset;
+    }
 
     std::string timestamp;
-    for (size_t i = 1; i < tokens.count(); ++i)
+    for (size_t i = offset; i < tokens.count(); ++i)
     {
         if (tokens[i].find("url=") == 0)
+        {
             _docURL = tokens[i].substr(strlen("url="));
+            ++offset;
+        }
         else if (tokens[i].find("timestamp=") == 0)
+        {
             timestamp = tokens[i].substr(strlen("timestamp="));
+            ++offset;
+        }
+    }
+
+    if (tokens.count() > offset)
+    {
+        if (getTokenString(tokens[offset], "options", _docOptions))
+        {
+            if (tokens.count() > offset + 1)
+                _docOptions += Poco::cat(std::string(" "), tokens.begin() + offset + 1, tokens.end());
+        }
     }
 
     try
diff --git a/loolwsd/LOOLSession.hpp b/loolwsd/LOOLSession.hpp
index c8598b7..4dbb1cf 100644
--- a/loolwsd/LOOLSession.hpp
+++ b/loolwsd/LOOLSession.hpp
@@ -77,6 +77,9 @@ protected:
     // The actual URL, also in the child, even if the child never accesses that.
     std::string _docURL;
 
+    /// Document options: a JSON string, containing options (rendering, also possibly load in the future).
+    std::string _docOptions;
+
 private:
     std::mutex _mutex;
 };
diff --git a/loolwsd/protocol.txt b/loolwsd/protocol.txt
index 25c6111..2f98f31 100644
--- a/loolwsd/protocol.txt
+++ b/loolwsd/protocol.txt
@@ -52,13 +52,15 @@ load <pathname>
 
     Deprecated.
 
-load [part=<partNumber>] url=<url> [timestamp=<time>]
+load [part=<partNumber>] url=<url> [timestamp=<time>] [options=<options>]
 
     part is an optional parameter. <partNumber> is a number.
 
     timestamp is an optional parameter.  <time> is provided in microseconds
     since the Unix epoch - midnight, January 1, 1970.
 
+    options are the whole rest of the line, not URL-encoded
+
 mouse type=<type> x=<x> y=<y> count=<count>
 
     <type> is 'buttondown', 'buttonup' or 'move', others are numbers.


More information about the Libreoffice-commits mailing list