[Libreoffice-commits] online.git: loolwsd/ChildProcessSession.cpp loolwsd/ChildProcessSession.hpp loolwsd/LOOLKit.cpp
Ashod Nakashian
ashod.nakashian at collabora.co.uk
Fri Apr 29 01:05:04 UTC 2016
loolwsd/ChildProcessSession.cpp | 29 ++++++++++++++++-------------
loolwsd/ChildProcessSession.hpp | 4 ++--
loolwsd/LOOLKit.cpp | 19 +++++++++++++++----
3 files changed, 33 insertions(+), 19 deletions(-)
New commits:
commit 7ff5be1f701f44dbec70bbbaeac50b9ba654b074
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date: Wed Apr 27 20:42:45 2016 -0400
loolwsd: document rendering options should be set once
When loading a document first we set the rendering
options. Beyond that, the document is shared and
we shouldn't change the rendering options.
Change-Id: I0d2ac6fc43553b8395111ba2b8a3cc2796d2f0a4
Reviewed-on: https://gerrit.libreoffice.org/24470
Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
Tested-by: Ashod Nakashian <ashnakash at gmail.com>
diff --git a/loolwsd/ChildProcessSession.cpp b/loolwsd/ChildProcessSession.cpp
index 45ac69d..d727cfd 100644
--- a/loolwsd/ChildProcessSession.cpp
+++ b/loolwsd/ChildProcessSession.cpp
@@ -277,7 +277,7 @@ ChildProcessSession::ChildProcessSession(const std::string& id,
std::shared_ptr<WebSocket> ws,
LibreOfficeKitDocument * loKitDocument,
const std::string& jailId,
- std::function<LibreOfficeKitDocument*(const std::string&, const std::string&, const std::string&, bool)> onLoad,
+ std::function<LibreOfficeKitDocument*(const std::string&, const std::string&, const std::string&, const std::string&, bool)> onLoad,
std::function<void(const std::string&)> onUnload) :
LOOLSession(id, Kind::ToMaster, ws),
_loKitDocument(loKitDocument),
@@ -554,30 +554,33 @@ bool ChildProcessSession::loadDocument(const char * /*buffer*/, int /*length*/,
std::string timestamp;
parseDocOptions(tokens, part, timestamp);
+ std::string renderingOptions;
+ if (!_docOptions.empty())
+ {
+ Parser parser;
+ Poco::Dynamic::Var var = parser.parse(_docOptions);
+ Object::Ptr object = var.extract<Object::Ptr>();
+ renderingOptions = object->get("rendering").toString();
+ }
+
assert(!_docURL.empty());
assert(!_jailedFilePath.empty());
- _loKitDocument = _onLoad(getId(), _jailedFilePath, _docPassword, _isDocPasswordProvided);
-
+ _loKitDocument = _onLoad(getId(), _jailedFilePath, _docPassword, renderingOptions, _isDocPasswordProvided);
if (!_loKitDocument)
+ {
+ Log::error("Failed to get LoKitDocument instance.");
return false;
+ }
std::unique_lock<std::recursive_mutex> lock(Mutex);
if (_multiView)
- _viewId = _loKitDocument->pClass->getView(_loKitDocument);
-
- std::string renderingOptions;
- if (!_docOptions.empty())
{
- Parser parser;
- Poco::Dynamic::Var var = parser.parse(_docOptions);
- Object::Ptr object = var.extract<Object::Ptr>();
- renderingOptions = object->get("rendering").toString();
+ _viewId = _loKitDocument->pClass->getView(_loKitDocument);
+ _loKitDocument->pClass->initializeForRendering(_loKitDocument, (renderingOptions.empty() ? nullptr : renderingOptions.c_str()));
}
- _loKitDocument->pClass->initializeForRendering(_loKitDocument, (renderingOptions.empty() ? nullptr : renderingOptions.c_str()));
-
if (_docType != "text" && part != -1)
{
_loKitDocument->pClass->setPart(_loKitDocument, part);
diff --git a/loolwsd/ChildProcessSession.hpp b/loolwsd/ChildProcessSession.hpp
index 39b6d51..b614195 100644
--- a/loolwsd/ChildProcessSession.hpp
+++ b/loolwsd/ChildProcessSession.hpp
@@ -38,7 +38,7 @@ public:
std::shared_ptr<Poco::Net::WebSocket> ws,
LibreOfficeKitDocument * loKitDocument,
const std::string& jailId,
- std::function<LibreOfficeKitDocument*(const std::string&, const std::string&, const std::string&, bool)> onLoad,
+ std::function<LibreOfficeKitDocument*(const std::string&, const std::string&, const std::string&, const std::string&, bool)> onLoad,
std::function<void(const std::string&)> onUnload);
virtual ~ChildProcessSession();
@@ -100,7 +100,7 @@ private:
/// View ID, returned by createView() or 0 by default.
int _viewId;
std::map<int, std::string> _lastDocStates;
- std::function<LibreOfficeKitDocument*(const std::string&, const std::string&, const std::string&, bool)> _onLoad;
+ std::function<LibreOfficeKitDocument*(const std::string&, const std::string&, const std::string&, const std::string&, bool)> _onLoad;
std::function<void(const std::string&)> _onUnload;
std::unique_ptr<CallbackWorker> _callbackWorker;
diff --git a/loolwsd/LOOLKit.cpp b/loolwsd/LOOLKit.cpp
index 5af4248..624eb98 100644
--- a/loolwsd/LOOLKit.cpp
+++ b/loolwsd/LOOLKit.cpp
@@ -464,7 +464,8 @@ public:
ws->setReceiveTimeout(0);
auto session = std::make_shared<ChildProcessSession>(sessionId, ws, _loKitDocument, _jailId,
- [this](const std::string& id, const std::string& uri, const std::string& docPassword, bool isDocPasswordProvided) { return onLoad(id, uri, docPassword, isDocPasswordProvided); },
+ [this](const std::string& id, const std::string& uri, const std::string& docPassword,
+ const std::string& renderingOptions, bool isDocPasswordProvided) { return onLoad(id, uri, docPassword, renderingOptions, isDocPasswordProvided); },
[this](const std::string& id) { onUnload(id); });
auto thread = std::make_shared<Connection>(session, ws);
@@ -647,7 +648,11 @@ private:
}
/// Load a document (or view) and register callbacks.
- LibreOfficeKitDocument* onLoad(const std::string& sessionId, const std::string& uri, const std::string& docPassword, bool isDocPasswordProvided)
+ LibreOfficeKitDocument* onLoad(const std::string& sessionId,
+ const std::string& uri,
+ const std::string& docPassword,
+ const std::string& renderingOptions,
+ bool isDocPasswordProvided)
{
Log::info("Session " + sessionId + " is loading. " + std::to_string(_clientViews) + " views loaded.");
@@ -663,7 +668,7 @@ private:
try
{
- load(sessionId, uri, docPassword, isDocPasswordProvided);
+ load(sessionId, uri, docPassword, renderingOptions, isDocPasswordProvided);
}
catch (const std::exception& exc)
{
@@ -712,7 +717,11 @@ private:
private:
- LibreOfficeKitDocument* load(const std::string& sessionId, const std::string& uri, const std::string& docPassword, bool isDocPasswordProvided)
+ LibreOfficeKitDocument* load(const std::string& sessionId,
+ const std::string& uri,
+ const std::string& docPassword,
+ const std::string& renderingOptions,
+ bool isDocPasswordProvided)
{
const unsigned intSessionId = Util::decodeId(sessionId);
const auto it = _connections.find(intSessionId);
@@ -784,6 +793,8 @@ private:
{
_loKitDocument->pClass->registerCallback(_loKitDocument, DocumentCallback, this);
}
+
+ _loKitDocument->pClass->initializeForRendering(_loKitDocument, (renderingOptions.empty() ? nullptr : renderingOptions.c_str()));
}
else
{
More information about the Libreoffice-commits
mailing list