loolwsd/LOOLSession.cpp |   43 ++++++++++++++++++++++++++++++++++---------
 1 file changed, 34 insertions(+), 9 deletions(-)

New commits:
commit 57199a36cdc2ad802f8d7e944e6fc4ae830fab26
Author: Miklos Vajna <vmik...@collabora.co.uk>
Date:   Thu Nov 19 10:08:48 2015 +0100

    loolwsd: route rendering options to initializeForRendering()

diff --git a/loolwsd/LOOLSession.cpp b/loolwsd/LOOLSession.cpp
index a8d814e..efe4cf4 100644
--- a/loolwsd/LOOLSession.cpp
+++ b/loolwsd/LOOLSession.cpp
@@ -1026,7 +1026,16 @@ bool ChildProcessSession::loadDocument(const char 
*buffer, int length, StringTok
         return false;
     }
 
-    _loKitDocument->pClass->initializeForRendering(_loKitDocument, nullptr);
+    std::string renderingOptions;
+    if (!_docOptions.empty())
+    {
+        Poco::JSON::Parser parser;
+        Poco::Dynamic::Var var = parser.parse(_docOptions);
+        Poco::JSON::Object::Ptr object = 
var.extract<Poco::JSON::Object::Ptr>();
+        renderingOptions = object->get("rendering").toString();
+    }
+
+    _loKitDocument->pClass->initializeForRendering(_loKitDocument, 
(renderingOptions.empty() ? nullptr : renderingOptions.c_str()));
 
     if ( _docType != "text" && part != -1)
     {
commit 93c0d29c5c41453652055fb793711c743d6ebec7
Author: Miklos Vajna <vmik...@collabora.co.uk>
Date:   Thu Nov 19 09:29:58 2015 +0100

    loolwsd: accept load options in ChildProcessSession::loadDocument()

diff --git a/loolwsd/LOOLSession.cpp b/loolwsd/LOOLSession.cpp
index 41b89f3..a8d814e 100644
--- a/loolwsd/LOOLSession.cpp
+++ b/loolwsd/LOOLSession.cpp
@@ -682,7 +682,7 @@ void MasterProcessSession::dispatchChild()
     _peer = childSession;
     childSession->_peer = shared_from_this();
 
-    std::string loadRequest = "load" + (_loadPart >= 0 ?  " part=" + 
std::to_string(_loadPart) : "") + " url=" + _docURL;
+    std::string loadRequest = "load" + (_loadPart >= 0 ?  " part=" + 
std::to_string(_loadPart) : "") + " url=" + _docURL + (!_docOptions.empty() ? " 
options=" + _docOptions : "");
     forwardToPeer(loadRequest.c_str(), loadRequest.size());
 }
 
@@ -961,21 +961,37 @@ extern "C"
 bool ChildProcessSession::loadDocument(const char *buffer, int length, 
StringTokenizer& tokens)
 {
     int part = -1;
-    if (tokens.count() < 2 || tokens.count() > 4)
+    if (tokens.count() < 2)
     {
         sendTextFrame("error: cmd=load kind=syntax");
         return false;
     }
 
-    if (tokens.count() > 2 && tokens[2].find("url=") == 0)
+    // First token is the "load" command itself.
+    size_t offset = 1;
+    if (tokens.count() > 2 && tokens[1].find("part=") == 0)
     {
         getTokenInteger(tokens[1], "part", part);
-        _docURL = tokens[2].substr(strlen("url="));
+        ++offset;
+    }
+
+    for (size_t i = offset; i < tokens.count(); ++i)
+    {
+        if (tokens[i].find("url=") == 0)
+        {
+            _docURL = tokens[i].substr(strlen("url="));
+            ++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());
+        }
     }
-    else if (tokens[1].find("url=") == 0)
-        _docURL = tokens[1].substr(strlen("url="));
-    else
-        _docURL = tokens[1];
 
     URI aUri;
     try
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to