kit/Kit.cpp | 72 ++++++++++++++++++++++++++++++++---------------------------- 1 file changed, 39 insertions(+), 33 deletions(-)
New commits: commit 9de86cc0aefde0637dea12e78498ae08708076e5 Author: Ashod Nakashian <[email protected]> Date: Sat Dec 24 12:47:29 2016 -0500 wsd: refactor render options handling Change-Id: I378ed6b76c236d9878c721a579c2b2296ff8144a Reviewed-on: https://gerrit.libreoffice.org/32608 Reviewed-by: Ashod Nakashian <[email protected]> Tested-by: Ashod Nakashian <[email protected]> diff --git a/kit/Kit.cpp b/kit/Kit.cpp index f654b34..c2c674e 100644 --- a/kit/Kit.cpp +++ b/kit/Kit.cpp @@ -1179,39 +1179,7 @@ private: LOG_TRC("View to url [" << uri << "] created."); } - Object::Ptr renderOptsObj; - - // Fill the object with renderoptions, if any - if (!_renderOpts.empty()) - { - Parser parser; - Poco::Dynamic::Var var = parser.parse(_renderOpts); - renderOptsObj = var.extract<Object::Ptr>(); - } - else if (!userName.empty()) - { - renderOptsObj = new Object(); - } - - // Append name of the user, if any, who opened the document to rendering options - if (!userName.empty()) - { - Object::Ptr authorObj = new Object(); - authorObj->set("type", "string"); - std::string decodedUserName; - URI::decode(userName, decodedUserName); - authorObj->set("value", decodedUserName); - renderOptsObj->set(".uno:Author", authorObj); - } - - std::string renderParams; - if (renderOptsObj) - { - std::ostringstream ossRenderOpts; - renderOptsObj->stringify(ossRenderOpts); - renderParams = ossRenderOpts.str(); - } - + const std::string renderParams = makeRenderParams(userName); LOG_INF("Initializing for rendering session [" << sessionId << "] on document url [" << _url << "] with: [" << renderParams << "]."); @@ -1295,6 +1263,44 @@ private: return false; } + std::string makeRenderParams(const std::string& userName) + { + Object::Ptr renderOptsObj; + + // Fill the object with renderoptions, if any + if (!_renderOpts.empty()) + { + Parser parser; + Poco::Dynamic::Var var = parser.parse(_renderOpts); + renderOptsObj = var.extract<Object::Ptr>(); + } + else if (!userName.empty()) + { + renderOptsObj = new Object(); + } + + // Append name of the user, if any, who opened the document to rendering options + if (!userName.empty()) + { + Object::Ptr authorObj = new Object(); + authorObj->set("type", "string"); + std::string decodedUserName; + URI::decode(userName, decodedUserName); + authorObj->set("value", decodedUserName); + renderOptsObj->set(".uno:Author", authorObj); + } + + std::string renderParams; + if (renderOptsObj) + { + std::ostringstream ossRenderOpts; + renderOptsObj->stringify(ossRenderOpts); + renderParams = ossRenderOpts.str(); + } + + return renderParams; + } + void run() override { Util::setThreadName("lok_handler"); _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
