mirror of
https://github.com/LibreOffice/online.git
synced 2025-08-15 21:13:02 +00:00
Pass the locale settings from loleaflet to wsd/kit.
Change-Id: Ie530db73cfbdb62787f16eae0f4b07fbf8b8acb4
This commit is contained in:
@ -87,6 +87,7 @@ void Session::parseDocOptions(const std::vector<std::string>& tokens, int& part,
|
||||
|
||||
for (size_t i = offset; i < tokens.size(); ++i)
|
||||
{
|
||||
// FIXME use any kind of startsWith() instead of find(...) == 0
|
||||
if (tokens[i].find("url=") == 0)
|
||||
{
|
||||
_docURL = tokens[i].substr(strlen("url="));
|
||||
@ -120,6 +121,11 @@ void Session::parseDocOptions(const std::vector<std::string>& tokens, int& part,
|
||||
_haveDocPassword = true;
|
||||
++offset;
|
||||
}
|
||||
else if (tokens[i].find("lang=") == 0)
|
||||
{
|
||||
_lang = tokens[i].substr(strlen("lang="));
|
||||
++offset;
|
||||
}
|
||||
}
|
||||
|
||||
if (tokens.size() > offset)
|
||||
|
@ -116,19 +116,19 @@ private:
|
||||
std::mutex _mutex;
|
||||
|
||||
protected:
|
||||
// The actual URL, also in the child, even if the child never accesses that.
|
||||
/// The actual URL, also in the child, even if the child never accesses that.
|
||||
std::string _docURL;
|
||||
|
||||
// The Jailed document path.
|
||||
/// The Jailed document path.
|
||||
std::string _jailedFilePath;
|
||||
|
||||
// Password provided, if any, to open the document
|
||||
/// Password provided, if any, to open the document
|
||||
std::string _docPassword;
|
||||
|
||||
// If password is provided or not
|
||||
/// If password is provided or not
|
||||
bool _haveDocPassword;
|
||||
|
||||
// Whether document is password protected
|
||||
/// Whether document is password protected
|
||||
bool _isDocPasswordProtected;
|
||||
|
||||
/// Document options: a JSON string, containing options (rendering, also possibly load in the future).
|
||||
@ -139,6 +139,9 @@ protected:
|
||||
|
||||
/// Name of the user to whom the session belongs to
|
||||
std::string _userName;
|
||||
|
||||
/// Language for the document based on what the user has in the UI.
|
||||
std::string _lang;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -326,7 +326,7 @@ bool ChildSession::loadDocument(const char * /*buffer*/, int /*length*/, const s
|
||||
|
||||
std::unique_lock<std::recursive_mutex> lock(Mutex);
|
||||
|
||||
bool loaded = _docManager.onLoad(getId(), _jailedFilePath, _userName, _docPassword, renderOpts, _haveDocPassword);
|
||||
bool loaded = _docManager.onLoad(getId(), _jailedFilePath, _userName, _docPassword, renderOpts, _haveDocPassword, _lang);
|
||||
if (!loaded || _viewId < 0)
|
||||
{
|
||||
LOG_ERR("Failed to get LoKitDocument instance.");
|
||||
|
@ -35,7 +35,8 @@ public:
|
||||
const std::string& userName,
|
||||
const std::string& docPassword,
|
||||
const std::string& renderOpts,
|
||||
const bool haveDocPassword) = 0;
|
||||
const bool haveDocPassword,
|
||||
const std::string& lang) = 0;
|
||||
|
||||
/// Unload a client session, which unloads the document
|
||||
/// if it is the last and only.
|
||||
|
16
kit/Kit.cpp
16
kit/Kit.cpp
@ -907,7 +907,8 @@ private:
|
||||
const std::string& userName,
|
||||
const std::string& docPassword,
|
||||
const std::string& renderOpts,
|
||||
const bool haveDocPassword) override
|
||||
const bool haveDocPassword,
|
||||
const std::string& lang) override
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(_mutex);
|
||||
|
||||
@ -936,7 +937,7 @@ private:
|
||||
|
||||
try
|
||||
{
|
||||
if (!load(session, uri, userName, docPassword, renderOpts, haveDocPassword))
|
||||
if (!load(session, uri, userName, docPassword, renderOpts, haveDocPassword, lang))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -1126,7 +1127,8 @@ private:
|
||||
const std::string& userName,
|
||||
const std::string& docPassword,
|
||||
const std::string& renderOpts,
|
||||
const bool haveDocPassword)
|
||||
const bool haveDocPassword,
|
||||
const std::string& lang)
|
||||
{
|
||||
const std::string sessionId = session->getId();
|
||||
|
||||
@ -1151,9 +1153,13 @@ private:
|
||||
_jailedUrl = uri;
|
||||
_isDocPasswordProtected = false;
|
||||
|
||||
LOG_DBG("Calling lokit::documentLoad(" << uri << ").");
|
||||
std::string options;
|
||||
if (!lang.empty())
|
||||
options = "Language=" + lang;
|
||||
|
||||
LOG_DBG("Calling lokit::documentLoad(" << uri << ", \"" << options << "\").");
|
||||
Timestamp timestamp;
|
||||
_loKitDocument.reset(_loKit->documentLoad(uri.c_str()));
|
||||
_loKitDocument.reset(_loKit->documentLoad(uri.c_str(), options.c_str()));
|
||||
LOG_DBG("Returned lokit::documentLoad(" << uri << ") in " << (timestamp.elapsed() / 1000.) << "ms.");
|
||||
|
||||
if (!_loKitDocument || !_loKitDocument->get())
|
||||
|
@ -124,6 +124,9 @@ L.Socket = L.Class.extend({
|
||||
if (this._map._docPassword) {
|
||||
msg += ' password=' + this._map._docPassword;
|
||||
}
|
||||
if (String.locale) {
|
||||
msg += ' lang=' + String.locale;
|
||||
}
|
||||
if (this._map.options.renderingOptions) {
|
||||
var options = {
|
||||
'rendering': this._map.options.renderingOptions
|
||||
|
@ -310,7 +310,8 @@ public:
|
||||
const std::string& /*userName*/,
|
||||
const std::string& /*docPassword*/,
|
||||
const std::string& /*renderOpts*/,
|
||||
const bool /*haveDocPassword*/) override
|
||||
const bool /*haveDocPassword*/,
|
||||
const std::string& /*lang*/) override
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -268,6 +268,11 @@ bool ClientSession::loadDocument(const char* /*buffer*/, int /*length*/,
|
||||
oss << " password=" << _docPassword;
|
||||
}
|
||||
|
||||
if (!_lang.empty())
|
||||
{
|
||||
oss << " lang=" << _lang;
|
||||
}
|
||||
|
||||
if (!_docOptions.empty())
|
||||
{
|
||||
oss << " options=" << _docOptions;
|
||||
|
@ -65,13 +65,16 @@ load <pathname>
|
||||
|
||||
Deprecated.
|
||||
|
||||
load [part=<partNumber>] url=<url> [timestamp=<time>] [options=<options>]
|
||||
load [part=<partNumber>] url=<url> [timestamp=<time>] [lang=<locale>] [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.
|
||||
|
||||
lang specifies the locale to which we should switch before loading the
|
||||
document
|
||||
|
||||
options are the whole rest of the line, not URL-encoded, and must be valid JSON.
|
||||
|
||||
loolclient <major.minor[-patch]>
|
||||
|
Reference in New Issue
Block a user