wsd: set the language when creating a new view

This uses the new createViewWithOptions API to
set the language of the user at the point of
creating a new view.

Change-Id: Ibf3e0af1b0cc300126388c1217692d8d969be0f3
Reviewed-on: https://gerrit.libreoffice.org/67501
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
This commit is contained in:
Ashod Nakashian 2019-01-24 06:53:37 -05:00 committed by Ashod Nakashian
parent ca1a83f96b
commit 83a73e24e0
3 changed files with 16 additions and 9 deletions

View file

@ -375,6 +375,9 @@ struct _LibreOfficeKitDocumentClass
int nY,
int nOffset);
/// @see lok::Document::createViewWithOptions().
int (*createViewWithOptions) (LibreOfficeKitDocument* pThis, const char* pOptions);
#endif // defined LOK_USE_UNSTABLE_API || defined LIBO_INTERNAL_ONLY
};

View file

@ -440,13 +440,17 @@ public:
}
/**
* Create a new view for an existing document.
* Create a new view for an existing document with
* options similar to documentLoadWithOptions.
* By default a loaded document has 1 view.
* @return the ID of the new view.
*/
int createView()
int createView(const char* pOptions = nullptr)
{
return mpDoc->pClass->createView(mpDoc);
if (LIBREOFFICEKIT_DOCUMENT_HAS(mpDoc, createViewWithOptions))
return mpDoc->pClass->createViewWithOptions(mpDoc, pOptions);
else
return mpDoc->pClass->createView(mpDoc);
}
/**

View file

@ -1571,6 +1571,10 @@ private:
{
const std::string sessionId = session->getId();
std::string options;
if (!lang.empty())
options = "Language=" + lang;
std::unique_lock<std::mutex> lock(_documentMutex);
if (!_loKitDocument)
@ -1594,10 +1598,6 @@ private:
_jailedUrl = uri;
_isDocPasswordProtected = false;
std::string options;
if (!lang.empty())
options = "Language=" + lang;
LOG_DBG("Calling lokit::documentLoad(" << uriAnonym << ", \"" << options << "\").");
Timestamp timestamp;
_loKitDocument.reset(_loKit->documentLoad(uri.c_str(), options.c_str()));
@ -1666,8 +1666,8 @@ private:
}
}
LOG_INF("Creating view to url [" << uriAnonym << "] for session [" << sessionId << "].");
_loKitDocument->createView();
LOG_INF("Creating view to url [" << uriAnonym << "] for session [" << sessionId << "] with " << options << '.');
_loKitDocument->createView(options.c_str());
LOG_TRC("View to url [" << uriAnonym << "] created.");
}