[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-1-9' - 37 commits - loleaflet/dist loleaflet/main.js loleaflet/src loolwsd/Admin.hpp loolwsd/AdminModel.cpp loolwsd/AdminModel.hpp loolwsd/Auth.hpp loolwsd/ChildSession.cpp loolwsd/ChildSession.hpp loolwsd/ClientSession.cpp loolwsd/ClientSession.hpp loolwsd/DocumentBroker.cpp loolwsd/DocumentBroker.hpp loolwsd/Exceptions.hpp loolwsd/FileServer.hpp loolwsd/IoUtil.hpp loolwsd/Log.cpp loolwsd/Log.hpp loolwsd/LOKitHelper.hpp loolwsd/LOOLForKit.cpp loolwsd/LOOLKit.cpp loolwsd/LOOLKit.hpp loolwsd/LOOLProtocol.hpp loolwsd/LOOLSession.cpp loolwsd/LOOLSession.hpp loolwsd/LOOLWSD.cpp loolwsd/LOOLWSD.hpp loolwsd/MessageQueue.hpp loolwsd/Png.hpp loolwsd/PrisonerSession.hpp loolwsd/QueueHandler.hpp loolwsd/Storage.cpp loolwsd/Storage.hpp loolwsd/test loolwsd/TileCache.cpp loolwsd/TileCache.hpp loolwsd/TileDesc.hpp loolwsd/Unit.hpp loolwsd/UnitHTTP.hpp loolwsd/Util.hpp

Marco Cecchetti marco.cecchetti at collabora.com
Mon Oct 31 16:53:48 UTC 2016


 loleaflet/dist/loleaflet.html                 |   13 +
 loleaflet/dist/spreadsheet.css                |    9 
 loleaflet/dist/toolbar/toolbar.js             |   13 +
 loleaflet/main.js                             |   10 
 loleaflet/src/control/Control.ColumnHeader.js |   11 +
 loleaflet/src/control/Control.Header.js       |   56 +++++
 loleaflet/src/control/Control.Menubar.js      |  118 ++++++++--
 loleaflet/src/control/Control.RowHeader.js    |   11 +
 loleaflet/src/core/Socket.js                  |   38 ++-
 loleaflet/src/layer/tile/CalcTileLayer.js     |   19 +
 loleaflet/src/layer/tile/TileLayer.js         |    8 
 loleaflet/src/map/Map.js                      |   51 ++++
 loleaflet/src/map/handler/Map.Print.js        |    2 
 loolwsd/Admin.hpp                             |    5 
 loolwsd/AdminModel.cpp                        |   68 ++----
 loolwsd/AdminModel.hpp                        |    1 
 loolwsd/Auth.hpp                              |    3 
 loolwsd/ChildSession.cpp                      |    6 
 loolwsd/ChildSession.hpp                      |   82 +++----
 loolwsd/ClientSession.cpp                     |    6 
 loolwsd/ClientSession.hpp                     |   19 -
 loolwsd/DocumentBroker.cpp                    |  103 +++++----
 loolwsd/DocumentBroker.hpp                    |   15 -
 loolwsd/Exceptions.hpp                        |    3 
 loolwsd/FileServer.hpp                        |    2 
 loolwsd/IoUtil.hpp                            |    7 
 loolwsd/LOKitHelper.hpp                       |   16 -
 loolwsd/LOOLForKit.cpp                        |    6 
 loolwsd/LOOLKit.cpp                           |   29 +-
 loolwsd/LOOLKit.hpp                           |   12 +
 loolwsd/LOOLProtocol.hpp                      |    5 
 loolwsd/LOOLSession.cpp                       |    6 
 loolwsd/LOOLSession.hpp                       |   34 +--
 loolwsd/LOOLWSD.cpp                           |  284 ++++++++++++--------------
 loolwsd/LOOLWSD.hpp                           |   31 +-
 loolwsd/Log.cpp                               |   20 +
 loolwsd/Log.hpp                               |  126 +++++++----
 loolwsd/MessageQueue.hpp                      |    4 
 loolwsd/Png.hpp                               |    2 
 loolwsd/PrisonerSession.hpp                   |    4 
 loolwsd/QueueHandler.hpp                      |    6 
 loolwsd/Storage.cpp                           |   45 ++--
 loolwsd/Storage.hpp                           |   95 +++++---
 loolwsd/TileCache.cpp                         |    8 
 loolwsd/TileCache.hpp                         |   10 
 loolwsd/TileDesc.hpp                          |   28 --
 loolwsd/Unit.hpp                              |  102 +++++----
 loolwsd/UnitHTTP.hpp                          |   84 +++++--
 loolwsd/Util.hpp                              |   25 --
 loolwsd/test/WhiteBoxTests.cpp                |    2 
 loolwsd/test/countloolkits.hpp                |    6 
 loolwsd/test/data/calc_render.xls             |binary
 loolwsd/test/helpers.hpp                      |    6 
 loolwsd/test/httpwstest.cpp                   |   18 +
 54 files changed, 1053 insertions(+), 640 deletions(-)

New commits:
commit 957e8922754d2fb62cbe9169dbe693d437f54581
Author: Marco Cecchetti <marco.cecchetti at collabora.com>
Date:   Mon Oct 31 17:43:01 2016 +0100

    loleaflet: print dialog: it seems that this magic hack is no more needed
    
    Change-Id: I5dc3af5d8c70b381638f82de14ea47b1627237b9
    (cherry picked from commit 8c522c44d101c0c5e3e1c51b59249266cef4e9d3)

diff --git a/loleaflet/src/map/handler/Map.Print.js b/loleaflet/src/map/handler/Map.Print.js
index d121c7e..9a9743f 100644
--- a/loleaflet/src/map/handler/Map.Print.js
+++ b/loleaflet/src/map/handler/Map.Print.js
@@ -49,8 +49,6 @@ L.Map.Print = L.Handler.extend({
 	_onIframeLoaded: function () {
 		this._printIframe.contentWindow.focus(); // Required for IE
 		this._printIframe.contentWindow.print();
-		// couldn't find another way to remove it
-		setTimeout(L.bind(this._closePrintDialog, this), 1000);
 	},
 
 	_closePrintDialog: function () {
commit d7bd8d97b8f350cc9312dd6928d46cd6bff0d8bf
Author: Andras Timar <andras.timar at collabora.com>
Date:   Mon Oct 31 17:24:12 2016 +0100

    loleaflet: add link to git hash
    
    (cherry picked from commit cbff58346284a0dfd1e231f75396b016fd5b222e)

diff --git a/loleaflet/src/core/Socket.js b/loleaflet/src/core/Socket.js
index 6182142..afc04f0 100644
--- a/loleaflet/src/core/Socket.js
+++ b/loleaflet/src/core/Socket.js
@@ -140,8 +140,14 @@ L.Socket = L.Class.extend({
 		if (textMsg.startsWith('loolserver ')) {
 			// This must be the first message, unless we reconnect.
 			var loolwsdVersionObj = JSON.parse(textMsg.substring(textMsg.indexOf('{')));
-			$('#loolwsd-version').text(loolwsdVersionObj.Version +
-			                           ' (git hash: ' + loolwsdVersionObj.Hash + ')');
+			var h = loolwsdVersionObj.Hash;
+			if (parseInt(h,16).toString(16) === h.toLowerCase()) {
+				h = '<a target="_blank" href="https://gerrit.libreoffice.org/gitweb?p=online.git;a=commit;h=' + h + '">' + h + '</a>';
+				$('#loolwsd-version').html(loolwsdVersionObj.Version + ' (git hash: ' + h + ')');
+			}
+			else {
+				$('#loolwsd-version').text(loolwsdVersionObj.Version);
+			}
 
 			// TODO: For now we expect perfect match in protocol versions
 			if (loolwsdVersionObj.Protocol !== this.ProtocolVersionNumber) {
@@ -150,9 +156,13 @@ L.Socket = L.Class.extend({
 		}
 		else if (textMsg.startsWith('lokitversion ')) {
 			var lokitVersionObj = JSON.parse(textMsg.substring(textMsg.indexOf('{')));
-			$('#lokit-version').text(lokitVersionObj.ProductName + ' ' +
+			var h = lokitVersionObj.BuildId.substring(0, 7);
+			if (parseInt(h,16).toString(16) === h.toLowerCase()) {
+				h = '<a target="_blank" href="https://gerrit.libreoffice.org/gitweb?p=core.git;a=commit;h=' + h + '">' + h + '</a>';
+			}
+			$('#lokit-version').html(lokitVersionObj.ProductName + ' ' +
 			                         lokitVersionObj.ProductVersion + lokitVersionObj.ProductExtension.replace('.10.','-') +
-			                         ' (git hash: ' + lokitVersionObj.BuildId.substring(0, 7) + ')');
+			                         ' (git hash: ' + h + ')');
 		}
 		else if (textMsg.startsWith('perm:')) {
 			var perm = textMsg.substring('perm:'.length);
commit 9ac4627196a7f99e88985a4ee8a26661c9fe6e66
Author: Tor Lillqvist <tml at collabora.com>
Date:   Mon Oct 31 17:45:14 2016 +0200

    Assertion failures are for developers to read
    
    '_sessions.empty()' does not need a verbal explanation. We don't do
    those in other assertions in the same file anyway.
    
    (Also, I dislike the use of exclamation marks, especially in contexts
    that by themselves already are alerts, like in assertion failure
    messages. Exposure to LibreOffice source code with its style (in some
    neighbourhoods) of multiple exclamation marks, even, in comments,
    makes you like that. Exclamation marks makes your comments or messages
    look like check-out tabloid headlines.)
    
    (cherry picked from commit be22779c21fad4502b7b2ee5d624478a7ff3b66b)

diff --git a/loolwsd/DocumentBroker.cpp b/loolwsd/DocumentBroker.cpp
index 7516cc5..eda6eeb 100644
--- a/loolwsd/DocumentBroker.cpp
+++ b/loolwsd/DocumentBroker.cpp
@@ -171,7 +171,7 @@ DocumentBroker::~DocumentBroker()
                 << "] destroyed with " << _sessions.size()
                 << " sessions left." << Log::end;
 
-    assert(_sessions.empty() && "DocumentBroker still has unremoved sessions!");
+    assert(_sessions.empty());
 }
 
 bool DocumentBroker::load(const std::string& sessionId, const std::string& jailId)
commit c464f4c47eda78f2bc473273fd7398c4c5d55523
Author: Andras Timar <andras.timar at collabora.com>
Date:   Mon Oct 31 14:45:04 2016 +0100

    disable zoom for Calc
    
    (cherry picked from commit d589618bc1c6c73b5fa1711504ca6dcadb0cbe6b)

diff --git a/loleaflet/dist/toolbar/toolbar.js b/loleaflet/dist/toolbar/toolbar.js
index f1bda05..fcbc4e7 100644
--- a/loleaflet/dist/toolbar/toolbar.js
+++ b/loleaflet/dist/toolbar/toolbar.js
@@ -738,6 +738,9 @@ map.on('doclayerinit', function () {
 	var statusbar = w2ui['toolbar-down'];
 	switch (docType) {
 	case 'spreadsheet':
+		statusbar.disable('zoomreset');
+		statusbar.disable('zoomout');
+		statusbar.disable('zoomin');
 		statusbar.insert('left', [
 			{type: 'break', id:'break1'},
 			{type: 'html',  id: 'StatusDocPos',
diff --git a/loleaflet/src/control/Control.Menubar.js b/loleaflet/src/control/Control.Menubar.js
index ed3fb85..c44f6cd 100644
--- a/loleaflet/src/control/Control.Menubar.js
+++ b/loleaflet/src/control/Control.Menubar.js
@@ -208,12 +208,7 @@ L.Control.Menubar = L.Control.extend({
 												{type: 'separator'},
 												{name: _('Select all'), type: 'unocommand', uno: '.uno:SelectAll'}]
 			},
-			{name: _('View'), type: 'menu', menu: [{name: _('Full screen'), id: 'fullscreen', type: 'action'},
-												{type: 'separator'},
-												{name: _('Zoom in'), id: 'zoomin', type: 'action'},
-												{name: _('Zoom out'), id: 'zoomout', type: 'action'},
-												{name: _('Reset zoom'), id: 'zoomreset', type: 'action'}]
-			},
+			{name: _('View'), type: 'menu', menu: [{name: _('Full screen'), id: 'fullscreen', type: 'action'}]},
 			{name: _('Insert'), type: 'menu', menu: [{name: _('Image'), id: 'insertgraphic', type: 'action'},
 												  {name: _('Comment'), type: 'unocommand', uno: '.uno:InsertAnnotation'},
 												  {type: 'separator'},
commit 2ee513bd3d3035fbb139342319a8aa4d266f4098
Author: Andras Timar <andras.timar at collabora.com>
Date:   Mon Oct 31 13:26:50 2016 +0100

    loleaflet: add Format - Page size to Writer menu
    
    (cherry picked from commit 513d963b570cef35d64c4acf5641afce5d337a77)

diff --git a/loleaflet/src/control/Control.Menubar.js b/loleaflet/src/control/Control.Menubar.js
index eff476d..ed3fb85 100644
--- a/loleaflet/src/control/Control.Menubar.js
+++ b/loleaflet/src/control/Control.Menubar.js
@@ -118,7 +118,12 @@ L.Control.Menubar = L.Control.extend({
 						{name: _('To next paragraph in level'), type: 'unocommand', uno: '.uno:JumpDownThisLevel'},
 						{name: _('To previous paragraph in level'), type: 'unocommand', uno: '.uno:JumpUpThisLevel'},
 						{name: _('Continue previous numbering'), type: 'unocommand', uno: '.uno:ContinueNumbering'}]},
-				{name: _('Clear direct formatting'), type: 'unocommand', uno: '.uno:ResetAttributes'}
+				{name: _('Clear direct formatting'), type: 'unocommand', uno: '.uno:ResetAttributes'},
+				{name: _('Page'), type: 'menu', menu: [
+						{name: 'A4', type: 'unocommand', uno: '.uno:AttributePageSize {"AttributePageSize.Width":{"type":"long", "value": "21000"},"AttributePageSize.Height":{"type":"long", "value": "29700"}}'},
+						{name: 'A5', type: 'unocommand', uno: '.uno:AttributePageSize {"AttributePageSize.Width":{"type":"long", "value": "14800"},"AttributePageSize.Height":{"type":"long", "value": "21000"}}'},
+						{name: 'Letter', type: 'unocommand', uno: '.uno:AttributePageSize {"AttributePageSize.Width":{"type":"long", "value": "21590"},"AttributePageSize.Height":{"type":"long", "value": "27940"}}'},
+						{name: 'Legal', type: 'unocommand', uno: '.uno:AttributePageSize {"AttributePageSize.Width":{"type":"long", "value": "21590"},"AttributePageSize.Height":{"type":"long", "value": "35560"}}'}]}
 			]},
 			{name: _('Tables'), type: 'menu', menu: [{name: _('Insert'), type: 'menu', menu: [{name: _('Rows before'), type: 'unocommand', uno: '.uno:InsertRowsBefore'},
 																						{name: _('Rows after'), type: 'unocommand', uno: '.uno:InsertRowsAfter'},
commit 966cff73cb9db7c5a3497630569d19b83d2666bd
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Mon Oct 31 01:28:40 2016 -0400

    loolwsd: explicitly scope DocumentBroker mutex
    
    Change-Id: I64629774ec745f47e7376231a3ca569bcbfffaac
    Reviewed-on: https://gerrit.libreoffice.org/30424
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>
    (cherry picked from commit 4ba5bedf6adfdc92a4ef2624ef2d6c255fd17d37)

diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp
index 59f8322..3956e29 100644
--- a/loolwsd/LOOLWSD.cpp
+++ b/loolwsd/LOOLWSD.cpp
@@ -713,49 +713,48 @@ private:
         const auto docKey = DocumentBroker::getDocKey(uriPublic);
         std::shared_ptr<DocumentBroker> docBroker;
 
-        // scope the DocBrokersLock
-        {
-            std::unique_lock<std::mutex> DocBrokersLock(DocBrokersMutex);
+        std::unique_lock<std::mutex> docBrokersLock(DocBrokersMutex);
 
-            if (TerminationFlag)
-            {
-                Log::error("Termination flag set. No loading new session [" + id + "]");
-                return;
-            }
+        if (TerminationFlag)
+        {
+            Log::error("Termination flag set. No loading new session [" + id + "]");
+            return;
+        }
 
-            cleanupDocBrokers();
+        cleanupDocBrokers();
 
-            // Lookup this document.
-            auto it = DocBrokers.find(docKey);
-            if (it != DocBrokers.end())
+        // Lookup this document.
+        auto it = DocBrokers.find(docKey);
+        if (it != DocBrokers.end())
+        {
+            // Get the DocumentBroker from the Cache.
+            Log::debug("Found DocumentBroker for docKey [" + docKey + "].");
+            docBroker = it->second;
+            assert(docBroker);
+        }
+        else
+        {
+            // New Document.
+#if MAX_DOCUMENTS > 0
+            if (DocBrokers.size() + 1 > MAX_DOCUMENTS)
             {
-                // Get the DocumentBroker from the Cache.
-                Log::debug("Found DocumentBroker for docKey [" + docKey + "].");
-                docBroker = it->second;
-                assert(docBroker);
+                Log::error() << "Limit on maximum number of open documents of "
+                             << MAX_DOCUMENTS << " reached." << Log::end;
+                shutdownLimitReached(*ws);
+                return;
             }
-            else
-            {
-                // New Document.
-#if MAX_DOCUMENTS > 0
-                if (DocBrokers.size() + 1 > MAX_DOCUMENTS)
-                {
-                    Log::error() << "Limit on maximum number of open documents of "
-                                 << MAX_DOCUMENTS << " reached." << Log::end;
-                    shutdownLimitReached(*ws);
-                    return;
-                }
 #endif
 
-                // Store a dummy (marked to destroy) document broker until we
-                // have the real one, so that the other requests block
-                Log::debug("Inserting a dummy DocumentBroker for docKey [" + docKey + "] temporarily.");
+            // Store a dummy (marked to destroy) document broker until we
+            // have the real one, so that the other requests block
+            Log::debug("Inserting a dummy DocumentBroker for docKey [" + docKey + "] temporarily.");
 
-                std::shared_ptr<DocumentBroker> tempBroker = std::make_shared<DocumentBroker>();
-                DocBrokers.emplace(docKey, tempBroker);
-            }
+            std::shared_ptr<DocumentBroker> tempBroker = std::make_shared<DocumentBroker>();
+            DocBrokers.emplace(docKey, tempBroker);
         }
 
+        docBrokersLock.unlock();
+
         if (docBroker && docBroker->isMarkedToDestroy())
         {
             // If this document is going out, wait.
@@ -767,7 +766,7 @@ private:
                 std::this_thread::sleep_for(std::chrono::milliseconds(POLL_TIMEOUT_MS));
 
                 std::unique_lock<std::mutex> lock(DocBrokersMutex);
-                auto it = DocBrokers.find(docKey);
+                it = DocBrokers.find(docKey);
                 if (it == DocBrokers.end())
                 {
                     // went away successfully
commit 45cb9798e4beeab039157ab969b0a4d754922f9a
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Mon Oct 31 01:27:46 2016 -0400

    loolwsd: some logs converted to new form
    
    Change-Id: I7d478ff2fc5715c3f612bf57f98aa2ce454ed4ed
    Reviewed-on: https://gerrit.libreoffice.org/30423
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>
    (cherry picked from commit 4186149f5b546fde96b6d5f9f14854836102676a)

diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp
index 119e7b3..59f8322 100644
--- a/loolwsd/LOOLWSD.cpp
+++ b/loolwsd/LOOLWSD.cpp
@@ -702,11 +702,11 @@ private:
     /// Handle GET requests.
     static void handleGetRequest(const std::string& uri, std::shared_ptr<WebSocket>& ws, const std::string& id)
     {
-        Log::info("Starting GET request handler for session [" + id + "].");
+        LOG_INF("Starting GET request handler for session [" << id << "].");
 
         // indicator to the client that document broker is searching
         std::string status("statusindicator: find");
-        Log::trace("Sending to Client [" + status + "].");
+        LOG_TRC("Sending to Client [" << status << "].");
         ws->sendFrame(status.data(), status.size());
 
         const auto uriPublic = DocumentBroker::sanitizeURI(uri);
@@ -867,12 +867,12 @@ private:
         {
             // indicator to a client that is waiting to connect to lokit process
             status = "statusindicator: connect";
-            Log::trace("Sending to Client [" + status + "].");
+            LOG_TRC("Sending to Client [" << status << "].");
             ws->sendFrame(status.data(), status.size());
 
             // Now the bridge beetween the client and kit process is connected
             status = "statusindicator: ready";
-            Log::trace("Sending to Client [" + status + "].");
+            LOG_TRC("Sending to Client [" + status + "].");
             ws->sendFrame(status.data(), status.size());
 
             Util::checkDiskSpaceOnRegisteredFileSystems();
@@ -1039,8 +1039,8 @@ public:
         if (++LOOLWSD::NumConnections > MAX_CONNECTIONS)
         {
             --LOOLWSD::NumConnections;
-            Log::error() << "Limit on maximum number of connections of "
-                         << MAX_CONNECTIONS << " reached." << Log::end;
+            LOG_ERR("Limit on maximum number of connections of "
+                    << MAX_CONNECTIONS << " reached.");
             // accept hand shake
             WebSocket ws(request, response);
             shutdownLimitReached(ws);
@@ -1147,24 +1147,23 @@ public:
         }
         catch (const Exception& exc)
         {
-            Log::error() << "ClientRequestHandler::handleClientRequest: " << exc.displayText()
-                         << (exc.nested() ? " (" + exc.nested()->displayText() + ")" : "")
-                         << Log::end;
+            LOG_ERR("ClientRequestHandler::handleClientRequest: " << exc.displayText()
+                    << (exc.nested() ? " (" + exc.nested()->displayText() + ")" : ""));
             response.setStatusAndReason(HTTPResponse::HTTP_SERVICE_UNAVAILABLE);
         }
         catch (const UnauthorizedRequestException& exc)
         {
-            Log::error("ClientRequestHandler::handleClientRequest: UnauthorizedException: " + exc.toString());
+            LOG_ERR("ClientRequestHandler::handleClientRequest: UnauthorizedException: " << exc.toString());
             response.setStatusAndReason(HTTPResponse::HTTP_UNAUTHORIZED);
         }
         catch (const BadRequestException& exc)
         {
-            Log::error("ClientRequestHandler::handleClientRequest: BadRequestException: " + exc.toString());
+            LOG_ERR("ClientRequestHandler::handleClientRequest: BadRequestException: " << exc.toString());
             response.setStatusAndReason(HTTPResponse::HTTP_BAD_REQUEST);
         }
         catch (const std::exception& exc)
         {
-            Log::error("ClientRequestHandler::handleClientRequest: Exception: " + std::string(exc.what()));
+            LOG_ERR("ClientRequestHandler::handleClientRequest: Exception: " << exc.what());
             response.setStatusAndReason(HTTPResponse::HTTP_SERVICE_UNAVAILABLE);
         }
 
commit 8f9947316823145f66e27ae48446163349426f4c
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Mon Oct 31 02:00:50 2016 -0400

    loolwsd: new logging macros with lower overhead
    
    Change-Id: I6889af4dd18692877469e8b24671aaf4649055e5
    Reviewed-on: https://gerrit.libreoffice.org/30422
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>
    (cherry picked from commit 8be8311eaafd01ea2cd012910589b04f66a8b694)

diff --git a/loolwsd/Log.hpp b/loolwsd/Log.hpp
index 799fd77..7fe521d 100644
--- a/loolwsd/Log.hpp
+++ b/loolwsd/Log.hpp
@@ -170,6 +170,13 @@ namespace Log
     }
 }
 
+#define LOG_TRC(X) if (Log::traceEnabled()) { std::ostringstream oss; oss << Log::prefix("TRC") << X; Log::logger().trace(oss.str()); }
+#define LOG_DBG(X) if (Log::debugEnabled()) { std::ostringstream oss; oss << Log::prefix("DBG") << X; Log::logger().debug(oss.str()); }
+#define LOG_INF(X) if (Log::infoEnabled()) { std::ostringstream oss; oss << Log::prefix("INF") << X; Log::logger().information(oss.str()); }
+#define LOG_WRN(X) if (Log::warnEnabled()) { std::ostringstream oss; oss << Log::prefix("WRN") << X; Log::logger().warning(oss.str()); }
+#define LOG_ERR(X) if (Log::errorEnabled()) { std::ostringstream oss; oss << Log::prefix("ERR") << X; Log::logger().error(oss.str()); }
+#define LOG_FTL(X) if (Log::fatalEnabled()) { std::ostringstream oss; oss << Log::prefix("FTL") << X; Log::logger().fatal(oss.str()); }
+
 #endif
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit da5f65a332f4148a30e8b4d0589771893ec5fbc3
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Sun Oct 30 19:16:57 2016 -0400

    loolwsd: more efficient stream logging
    
    Change-Id: I6596f87be4d36d2857c40b88864099c6cb5ab5b0
    Reviewed-on: https://gerrit.libreoffice.org/30421
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>
    (cherry picked from commit 90c60d99318de07f5e421e822882e691cdd6f287)

diff --git a/loolwsd/Log.hpp b/loolwsd/Log.hpp
index ea3d6ee..799fd77 100644
--- a/loolwsd/Log.hpp
+++ b/loolwsd/Log.hpp
@@ -24,7 +24,7 @@ namespace Log
                     const bool logToFile = false,
                     std::map<std::string, std::string> config = {});
     Poco::Logger& logger();
-    std::string prefix();
+    std::string prefix(const char* level);
 
     void trace(const std::string& msg);
     void debug(const std::string& msg);
@@ -35,7 +35,12 @@ namespace Log
     void fatal(const std::string& msg);
     void sysfatal(const std::string& msg);
 
-    inline bool traceEnabled() { return logger().getLevel() > Poco::Message::PRIO_TRACE; }
+    inline bool traceEnabled() { return logger().getLevel() >= Poco::Message::PRIO_TRACE; }
+    inline bool debugEnabled() { return logger().getLevel() >= Poco::Message::PRIO_DEBUG; }
+    inline bool infoEnabled() { return logger().getLevel() >= Poco::Message::PRIO_INFORMATION; }
+    inline bool warnEnabled() { return logger().getLevel() >= Poco::Message::PRIO_WARNING; }
+    inline bool errorEnabled() { return logger().getLevel() >= Poco::Message::PRIO_ERROR; }
+    inline bool fatalEnabled() { return logger().getLevel() >= Poco::Message::PRIO_FATAL; }
 
     /// Signal safe prefix logging
     void signalLogPrefix();
@@ -63,10 +68,11 @@ namespace Log
         {
         }
 
-        StreamLogger(std::function<void(const std::string&)> func)
+        StreamLogger(std::function<void(const std::string&)> func, const char* level)
           : _func(std::move(func)),
             _enabled(true)
         {
+            _stream << prefix(level);
         }
 
         StreamLogger(StreamLogger&& sl) noexcept
@@ -96,33 +102,43 @@ namespace Log
     inline StreamLogger trace()
     {
         return traceEnabled()
-             ? StreamLogger([](const std::string& msg) { trace(msg); })
+             ? StreamLogger([](const std::string& msg) { logger().trace(msg); }, "TRC")
              : StreamLogger();
     }
 
     inline StreamLogger debug()
     {
-        return StreamLogger([](const std::string& msg) { debug(msg); });
+        return debugEnabled()
+             ? StreamLogger([](const std::string& msg) { logger().debug(msg); }, "DBG")
+             : StreamLogger();
     }
 
     inline StreamLogger info()
     {
-        return StreamLogger([](const std::string& msg) { info(msg); });
+        return infoEnabled()
+             ? StreamLogger([](const std::string& msg) { logger().information(msg); }, "INF")
+             : StreamLogger();
     }
 
     inline StreamLogger warn()
     {
-        return StreamLogger([](const std::string& msg) { warn(msg); });
+        return warnEnabled()
+             ? StreamLogger([](const std::string& msg) { logger().warning(msg); }, "WRN")
+             : StreamLogger();
     }
 
     inline StreamLogger error()
     {
-        return StreamLogger([](const std::string& msg) { error(msg); });
+        return errorEnabled()
+             ? StreamLogger([](const std::string& msg) { logger().error(msg); }, "ERR")
+             : StreamLogger();
     }
 
     inline StreamLogger fatal()
     {
-        return StreamLogger([](const std::string& msg) { fatal(msg); });
+        return fatalEnabled()
+             ? StreamLogger([](const std::string& msg) { logger().fatal(msg); }, "FTL")
+             : StreamLogger();
     }
 
     template <typename U>
commit c6aa4ef4583a9e1a1c3730c0627ecad1db739e37
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Sun Oct 30 19:07:41 2016 -0400

    loolwsd: logging cleanup
    
    Streaming to string can now be disabled when
    the not needed to reduce overhead.
    
    Change-Id: I95e5a700776bd9f05b0d969703fc471401dfea3b
    Reviewed-on: https://gerrit.libreoffice.org/30420
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>
    (cherry picked from commit b14961ffaf8488f2d64503120f5d074c8aaa09a3)

diff --git a/loolwsd/Log.cpp b/loolwsd/Log.cpp
index e9b9576..c263975 100644
--- a/loolwsd/Log.cpp
+++ b/loolwsd/Log.cpp
@@ -36,8 +36,10 @@ namespace Log
     using namespace Poco;
 
     static const Poco::Int64 epochStart = Poco::Timestamp().epochMicroseconds();
+
     /// Helper to avoid destruction ordering issues.
-    struct StaticNames {
+    struct StaticNames
+    {
         std::atomic<bool> inited;
         std::string name;
         std::string id;
@@ -56,9 +58,10 @@ namespace Log
     //   $ man 7 signal
     void signalLog(const char *message)
     {
-        while (true) {
-            int length = strlen(message);
-            int written = write (STDERR_FILENO, message, length);
+        while (true)
+        {
+            const int length = strlen(message);
+            const int written = write (STDERR_FILENO, message, length);
             if (written < 0)
             {
                 if (errno == EINTR)
@@ -66,6 +69,7 @@ namespace Log
                 else
                     break;
             }
+
             message += written;
             if (message[0] == '\0')
                 break;
@@ -81,17 +85,19 @@ namespace Log
 
         const Poco::Int64 one_s = 1000000;
         const Poco::Int64 hours = usec / (one_s*60*60);
-        usec %= (one_s*60*60);
+        usec %= (one_s * 60 * 60);
         const Poco::Int64 minutes = usec / (one_s*60);
-        usec %= (one_s*60);
+        usec %= (one_s * 60);
         const Poco::Int64 seconds = usec / (one_s);
         usec %= (one_s);
 
         char procName[32]; // we really need only 16
         if (prctl(PR_GET_NAME, reinterpret_cast<unsigned long>(procName), 0, 0, 0) != 0)
+        {
             strncpy(procName, "<noid>", sizeof(procName) - 1);
+        }
 
-        const char *appName = (Source.inited ? Source.id.c_str() : "<shutdown>");
+        const char* appName = (Source.inited ? Source.id.c_str() : "<shutdown>");
         assert(strlen(appName) + 32 + 28 < 1024 - 1);
 
         snprintf(buffer, 4095, "%s-%.04lu %d:%.2d:%.2d.%.6d [ %s ] %s  ", appName,
diff --git a/loolwsd/Log.hpp b/loolwsd/Log.hpp
index 6bded5e..ea3d6ee 100644
--- a/loolwsd/Log.hpp
+++ b/loolwsd/Log.hpp
@@ -35,6 +35,8 @@ namespace Log
     void fatal(const std::string& msg);
     void sysfatal(const std::string& msg);
 
+    inline bool traceEnabled() { return logger().getLevel() > Poco::Message::PRIO_TRACE; }
+
     /// Signal safe prefix logging
     void signalLogPrefix();
     /// Signal safe logging
@@ -55,31 +57,47 @@ namespace Log
     class StreamLogger
     {
     public:
+        /// No-op instance.
+        StreamLogger()
+          : _enabled(false)
+        {
+        }
+
         StreamLogger(std::function<void(const std::string&)> func)
-            : _func(std::move(func))
+          : _func(std::move(func)),
+            _enabled(true)
         {
         }
 
         StreamLogger(StreamLogger&& sl) noexcept
-            : _stream(sl._stream.str()),
-              _func(std::move(sl._func))
+          : _stream(sl._stream.str()),
+            _func(std::move(sl._func)),
+            _enabled(sl._enabled)
         {
         }
 
+        bool enabled() const { return _enabled; }
+
         void flush() const
         {
-            _func(_stream.str());
+            if (_enabled)
+            {
+                _func(_stream.str());
+            }
         }
 
         std::ostringstream _stream;
 
     private:
         std::function<void(const std::string&)> _func;
+        const bool _enabled;
     };
 
     inline StreamLogger trace()
     {
-        return StreamLogger([](const std::string& msg) { trace(msg); });
+        return traceEnabled()
+             ? StreamLogger([](const std::string& msg) { trace(msg); })
+             : StreamLogger();
     }
 
     inline StreamLogger debug()
@@ -110,14 +128,22 @@ namespace Log
     template <typename U>
     StreamLogger& operator<<(StreamLogger& lhs, const U& rhs)
     {
-        lhs._stream << rhs;
+        if (lhs.enabled())
+        {
+            lhs._stream << rhs;
+        }
+
         return lhs;
     }
 
     template <typename U>
     StreamLogger& operator<<(StreamLogger&& lhs, U&& rhs)
     {
-        lhs._stream << rhs;
+        if (lhs.enabled())
+        {
+            lhs._stream << rhs;
+        }
+
         return lhs;
     }
 
commit 8a603defac2f7933164dc89916215bbcc3f67494
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Sun Oct 30 15:24:27 2016 -0400

    loolwsd: cleanup tile response handling
    
    Change-Id: I34b76b463c05e3479d1fd1516906c9a75282c753
    Reviewed-on: https://gerrit.libreoffice.org/30419
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>
    (cherry picked from commit c8eb2ba6127f9d3da56811c25860c89ce085f588)

diff --git a/loolwsd/DocumentBroker.cpp b/loolwsd/DocumentBroker.cpp
index 185d610..7516cc5 100644
--- a/loolwsd/DocumentBroker.cpp
+++ b/loolwsd/DocumentBroker.cpp
@@ -740,29 +740,27 @@ void DocumentBroker::cancelTileRequests(const std::shared_ptr<ClientSession>& se
 void DocumentBroker::handleTileResponse(const std::vector<char>& payload)
 {
     const std::string firstLine = getFirstLine(payload);
+    Log::debug("Handling tile combined: " + firstLine);
+
     try
     {
-        auto tile = TileDesc::parse(firstLine);
-        const auto buffer = payload.data();
         const auto length = payload.size();
-
         if (firstLine.size() < static_cast<std::string::size_type>(length) - 1)
         {
+            const auto tile = TileDesc::parse(firstLine);
+            const auto buffer = payload.data();
             const auto offset = firstLine.size() + 1;
             tileCache().saveTileAndNotify(tile, buffer + offset, length - offset);
         }
         else
         {
             Log::debug() << "Render request declined for " << firstLine << Log::end;
-            std::unique_lock<std::mutex> tileBeingRenderedLock(tileCache().getTilesBeingRenderedLock());
-            tileCache().forgetTileBeingRendered(tile);
+            // They will get re-issued if we don't forget them.
         }
     }
     catch (const std::exception& exc)
     {
         Log::error("Failed to process tile response [" + firstLine + "]: " + exc.what() + ".");
-        //FIXME: Return error.
-        //sendTextFrame("error: cmd=tile kind=syntax");
     }
 }
 
@@ -773,13 +771,12 @@ void DocumentBroker::handleTileCombinedResponse(const std::vector<char>& payload
 
     try
     {
-        auto tileCombined = TileCombined::parse(firstLine);
-        const auto buffer = payload.data();
         const auto length = payload.size();
-        auto offset = firstLine.size() + 1;
-
         if (firstLine.size() < static_cast<std::string::size_type>(length) - 1)
         {
+            const auto tileCombined = TileCombined::parse(firstLine);
+            const auto buffer = payload.data();
+            auto offset = firstLine.size() + 1;
             for (const auto& tile : tileCombined.getTiles())
             {
                 tileCache().saveTileAndNotify(tile, buffer + offset, tile.getImgSize());
@@ -788,19 +785,13 @@ void DocumentBroker::handleTileCombinedResponse(const std::vector<char>& payload
         }
         else
         {
-            Log::error() << "Render request failed for " << firstLine << Log::end;
-            std::unique_lock<std::mutex> tileBeingRenderedLock(tileCache().getTilesBeingRenderedLock());
-            for (const auto& tile : tileCombined.getTiles())
-            {
-                tileCache().forgetTileBeingRendered(tile);
-            }
+            Log::error() << "Render request declined for " << firstLine << Log::end;
+            // They will get re-issued if we don't forget them.
         }
     }
     catch (const std::exception& exc)
     {
         Log::error("Failed to process tile response [" + firstLine + "]: " + exc.what() + ".");
-        //FIXME: Return error.
-        //sendTextFrame("error: cmd=tile kind=syntax");
     }
 }
 
diff --git a/loolwsd/TileCache.cpp b/loolwsd/TileCache.cpp
index e8ebdd1..d26db3b 100644
--- a/loolwsd/TileCache.cpp
+++ b/loolwsd/TileCache.cpp
@@ -444,14 +444,14 @@ void TileCache::subscribeToTileRendering(const TileDesc& tile, const std::shared
 {
     assert(subscriber->getKind() == LOOLSession::Kind::ToClient);
 
-    std::unique_lock<std::mutex> lock(_tilesBeingRenderedMutex);
-
-    std::shared_ptr<TileBeingRendered> tileBeingRendered = findTileBeingRendered(tile);
-
     std::ostringstream oss;
     oss << '(' << tile.getPart() << ',' << tile.getTilePosX() << ',' << tile.getTilePosY() << ')';
     const auto name = oss.str();
 
+    std::unique_lock<std::mutex> lock(_tilesBeingRenderedMutex);
+
+    std::shared_ptr<TileBeingRendered> tileBeingRendered = findTileBeingRendered(tile);
+
     if (tileBeingRendered)
     {
         for (const auto &s : tileBeingRendered->_subscribers)
commit 5fac340d8adbb438e5ed4840c9a674eb73dee101
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Sun Oct 30 14:31:34 2016 -0400

    loolwsd: expect no sessions when destroying DocumentBroker
    
    Change-Id: Ib8244cd8ae6449a07eb010fba4b26ec5bad09162
    Reviewed-on: https://gerrit.libreoffice.org/30418
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>
    (cherry picked from commit c96c13f01432cc9d2586021fd0f96e446e6fa3f1)

diff --git a/loolwsd/DocumentBroker.cpp b/loolwsd/DocumentBroker.cpp
index 10aef26..185d610 100644
--- a/loolwsd/DocumentBroker.cpp
+++ b/loolwsd/DocumentBroker.cpp
@@ -170,6 +170,8 @@ DocumentBroker::~DocumentBroker()
     Log::info() << "~DocumentBroker [" << _uriPublic.toString()
                 << "] destroyed with " << _sessions.size()
                 << " sessions left." << Log::end;
+
+    assert(_sessions.empty() && "DocumentBroker still has unremoved sessions!");
 }
 
 bool DocumentBroker::load(const std::string& sessionId, const std::string& jailId)
commit 507a93d463a04f5d86befbc83540a4d454445b22
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Sat Oct 29 21:32:56 2016 -0400

    loolwsd: convert int to string before adding to literal
    
    Change-Id: Ia3352589aa894b38892f98fedc93926f063dce72
    Reviewed-on: https://gerrit.libreoffice.org/30417
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>
    (cherry picked from commit ce785b643213406ed802ef630fb9ef75d01dfa59)

diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp
index 26a726e..119e7b3 100644
--- a/loolwsd/LOOLWSD.cpp
+++ b/loolwsd/LOOLWSD.cpp
@@ -1335,14 +1335,14 @@ static inline ServerSocket* getServerSocket(int nClientPortNumber)
 
 static inline ServerSocket* findFreeServerPort(int& nClientPortNumber)
 {
-    ServerSocket *socket = NULL;
+    ServerSocket* socket = nullptr;
     while (!socket)
     {
         socket = getServerSocket(nClientPortNumber);
         if (!socket)
         {
             nClientPortNumber++;
-            Log::info("client port busy - trying " + nClientPortNumber);
+            Log::info("client port busy - trying " + std::to_string(nClientPortNumber));
         }
     }
     return socket;
@@ -1365,14 +1365,14 @@ static inline ServerSocket* getMasterSocket(int nMasterPortNumber)
 static inline
 ServerSocket* findFreeMasterPort(int &nMasterPortNumber)
 {
-    ServerSocket *socket = NULL;
+    ServerSocket* socket = nullptr;
     while (!socket)
     {
         socket = getServerSocket(nMasterPortNumber);
         if (!socket)
         {
             nMasterPortNumber++;
-            Log::info("master port busy - trying " + nMasterPortNumber);
+            Log::info("master port busy - trying " + std::to_string(nMasterPortNumber));
         }
     }
     return socket;
commit 792159672fe8d11c3696bd3d5bf2ff8645347475
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Sat Oct 29 21:15:00 2016 -0400

    loolwsd: consistent formatting
    
    With the help of clang-format.
    For reference, the following command was used,
    but not all changes were commited:
    
    clang-format-3.9 -style='{BasedOnStyle: WebKit,
     AlignAfterOpenBracket: Align,
     AlwaysBreakAfterReturnType: None,
     BreakBeforeBraces: Allman,
     DerivePointerAlignment: 'true',
     ExperimentalAutoDetectBinPacking: 'true',
     IndentWrappedFunctionNames: 'true',
     UseTab: Never}'
    
    Change-Id: I0f7490c7ee38aeefeefcf9d5d4c3dab380cd63b8
    Reviewed-on: https://gerrit.libreoffice.org/30416
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>
    (cherry picked from commit 773c15f7103e85cbe33b897316050841a269c526)

diff --git a/loolwsd/Admin.hpp b/loolwsd/Admin.hpp
index 699b2e2..e82775d 100644
--- a/loolwsd/Admin.hpp
+++ b/loolwsd/Admin.hpp
@@ -27,7 +27,7 @@
 class Admin;
 
 /// Admin requests over HTTP(S) handler.
-class AdminRequestHandler: public Poco::Net::HTTPRequestHandler
+class AdminRequestHandler : public Poco::Net::HTTPRequestHandler
 {
 public:
     AdminRequestHandler(Admin* adminManager);
@@ -87,8 +87,7 @@ public:
 
     void rescheduleCpuTimer(unsigned interval);
 
-    static
-    AdminRequestHandler* createRequestHandler()
+    static AdminRequestHandler* createRequestHandler()
     {
         return new AdminRequestHandler(&instance());
     }
diff --git a/loolwsd/AdminModel.hpp b/loolwsd/AdminModel.hpp
index 1fff82c..61286b7 100644
--- a/loolwsd/AdminModel.hpp
+++ b/loolwsd/AdminModel.hpp
@@ -170,7 +170,6 @@ public:
     void removeDocument(const std::string& docKey);
 
 private:
-
     std::string getMemStats();
 
     std::string getCpuStats();
diff --git a/loolwsd/Auth.hpp b/loolwsd/Auth.hpp
index 664cfc1..87aa54b 100644
--- a/loolwsd/Auth.hpp
+++ b/loolwsd/Auth.hpp
@@ -20,7 +20,6 @@
 class AuthBase
 {
 public:
-
     /// Called to acquire an access token.
     virtual const std::string getAccessToken() = 0;
 
@@ -29,7 +28,7 @@ public:
 };
 
 /// JWT Authorization.
-class JWTAuth: public AuthBase
+class JWTAuth : public AuthBase
 {
 public:
     JWTAuth(const std::string& keyPath, const std::string& name, const std::string& sub, const std::string& aud)
diff --git a/loolwsd/ChildSession.hpp b/loolwsd/ChildSession.hpp
index 7b0a3ca..4730f72 100644
--- a/loolwsd/ChildSession.hpp
+++ b/loolwsd/ChildSession.hpp
@@ -12,8 +12,8 @@
 
 #include <mutex>
 
-#include <Poco/Thread.h>
 #include <Poco/NotificationQueue.h>
+#include <Poco/Thread.h>
 
 #include "Common.hpp"
 #include "LOOLKit.hpp"
@@ -28,32 +28,26 @@ class IDocumentManager
 {
 public:
     /// Reqest loading a document, or a new view, if one exists.
-    virtual
-    std::shared_ptr<lok::Document> onLoad(const std::string& sessionId,
-                                          const std::string& jailedFilePath,
-                                          const std::string& userName,
-                                          const std::string& docPassword,
-                                          const std::string& renderOpts,
-                                          const bool haveDocPassword) = 0;
+    virtual std::shared_ptr<lok::Document> onLoad(const std::string& sessionId,
+                                                  const std::string& jailedFilePath,
+                                                  const std::string& userName,
+                                                  const std::string& docPassword,
+                                                  const std::string& renderOpts,
+                                                  const bool haveDocPassword)
+        = 0;
 
     /// Unload a client session, which unloads the document
     /// if it is the last and only.
-    virtual
-    void onUnload(const ChildSession& session) = 0;
+    virtual void onUnload(const ChildSession& session) = 0;
 
     /// Send updated view info to all active sessions
-    virtual
-    void notifyViewInfo(const std::vector<int>& viewIds) = 0;
+    virtual void notifyViewInfo(const std::vector<int>& viewIds) = 0;
     /// Get a view ID <-> UserInfo map.
-    virtual
-    std::map<int, UserInfo> getViewInfo() = 0;
-    virtual
-    std::mutex& getMutex() = 0;
-    virtual
-    std::shared_ptr<TileQueue>& getTileQueue() = 0;
-
-    virtual
-    bool sendTextFrame(const std::string& message) = 0;
+    virtual std::map<int, UserInfo> getViewInfo() = 0;
+    virtual std::mutex& getMutex() = 0;
+    virtual std::shared_ptr<TileQueue>& getTileQueue() = 0;
+
+    virtual bool sendTextFrame(const std::string& message) = 0;
 };
 
 /// Represents a session to the WSD process, in a Kit process. Note that this is not a singleton.
@@ -72,8 +66,8 @@ public:
                  IDocumentManager& docManager);
     virtual ~ChildSession();
 
-    bool getStatus(const char *buffer, int length);
-    bool getPartPageRectangles(const char *buffer, int length);
+    bool getStatus(const char* buffer, int length);
+    bool getPartPageRectangles(const char* buffer, int length);
     int getViewId() const { return _viewId; }
     void setViewId(const int viewId) { _viewId = viewId; }
     const std::string& getViewUserId() const { return _userId; }
@@ -96,30 +90,30 @@ public:
     }
 
 private:
-    bool loadDocument(const char *buffer, int length, Poco::StringTokenizer& tokens);
+    bool loadDocument(const char* buffer, int length, Poco::StringTokenizer& tokens);
 
-    bool sendFontRendering(const char *buffer, int length, Poco::StringTokenizer& tokens);
-    bool getCommandValues(const char *buffer, int length, Poco::StringTokenizer& tokens);
+    bool sendFontRendering(const char* buffer, int length, Poco::StringTokenizer& tokens);
+    bool getCommandValues(const char* buffer, int length, Poco::StringTokenizer& tokens);
 
-    bool clientZoom(const char *buffer, int length, Poco::StringTokenizer& tokens);
-    bool clientVisibleArea(const char *buffer, int length, Poco::StringTokenizer& tokens);
-    bool downloadAs(const char *buffer, int length, Poco::StringTokenizer& tokens);
+    bool clientZoom(const char* buffer, int length, Poco::StringTokenizer& tokens);
+    bool clientVisibleArea(const char* buffer, int length, Poco::StringTokenizer& tokens);
+    bool downloadAs(const char* buffer, int length, Poco::StringTokenizer& tokens);
     bool getChildId();
-    bool getTextSelection(const char *buffer, int length, Poco::StringTokenizer& tokens);
-    bool paste(const char *buffer, int length, Poco::StringTokenizer& tokens);
-    bool insertFile(const char *buffer, int length, Poco::StringTokenizer& tokens);
-    bool keyEvent(const char *buffer, int length, Poco::StringTokenizer& tokens);
-    bool mouseEvent(const char *buffer, int length, Poco::StringTokenizer& tokens);
-    bool unoCommand(const char *buffer, int length, Poco::StringTokenizer& tokens);
-    bool selectText(const char *buffer, int length, Poco::StringTokenizer& tokens);
-    bool selectGraphic(const char *buffer, int length, Poco::StringTokenizer& tokens);
-    bool resetSelection(const char *buffer, int length, Poco::StringTokenizer& tokens);
-    bool saveAs(const char *buffer, int length, Poco::StringTokenizer& tokens);
-    bool setClientPart(const char *buffer, int length, Poco::StringTokenizer& tokens);
-    bool setPage(const char *buffer, int length, Poco::StringTokenizer& tokens);
+    bool getTextSelection(const char* buffer, int length, Poco::StringTokenizer& tokens);
+    bool paste(const char* buffer, int length, Poco::StringTokenizer& tokens);
+    bool insertFile(const char* buffer, int length, Poco::StringTokenizer& tokens);
+    bool keyEvent(const char* buffer, int length, Poco::StringTokenizer& tokens);
+    bool mouseEvent(const char* buffer, int length, Poco::StringTokenizer& tokens);
+    bool unoCommand(const char* buffer, int length, Poco::StringTokenizer& tokens);
+    bool selectText(const char* buffer, int length, Poco::StringTokenizer& tokens);
+    bool selectGraphic(const char* buffer, int length, Poco::StringTokenizer& tokens);
+    bool resetSelection(const char* buffer, int length, Poco::StringTokenizer& tokens);
+    bool saveAs(const char* buffer, int length, Poco::StringTokenizer& tokens);
+    bool setClientPart(const char* buffer, int length, Poco::StringTokenizer& tokens);
+    bool setPage(const char* buffer, int length, Poco::StringTokenizer& tokens);
 
     virtual void disconnect() override;
-    virtual bool _handleInput(const char *buffer, int length) override;
+    virtual bool _handleInput(const char* buffer, int length) override;
 
 private:
     const std::string _jailId;
diff --git a/loolwsd/ClientSession.hpp b/loolwsd/ClientSession.hpp
index 8136b00..8713026 100644
--- a/loolwsd/ClientSession.hpp
+++ b/loolwsd/ClientSession.hpp
@@ -62,32 +62,30 @@ public:
     const Poco::URI& getPublicUri() const { return _uriPublic; }
 
 private:
+    virtual bool _handleInput(const char* buffer, int length) override;
 
-    virtual bool _handleInput(const char *buffer, int length) override;
-
-    bool loadDocument(const char *buffer, int length, Poco::StringTokenizer& tokens,
+    bool loadDocument(const char* buffer, int length, Poco::StringTokenizer& tokens,
                       const std::shared_ptr<DocumentBroker>& docBroker);
 
-    bool getStatus(const char *buffer, int length,
+    bool getStatus(const char* buffer, int length,
                    const std::shared_ptr<DocumentBroker>& docBroker);
-    bool getCommandValues(const char *buffer, int length, Poco::StringTokenizer& tokens,
+    bool getCommandValues(const char* buffer, int length, Poco::StringTokenizer& tokens,
                           const std::shared_ptr<DocumentBroker>& docBroker);
-    bool getPartPageRectangles(const char *buffer, int length,
+    bool getPartPageRectangles(const char* buffer, int length,
                                const std::shared_ptr<DocumentBroker>& docBroker);
 
-    bool sendTile(const char *buffer, int length, Poco::StringTokenizer& tokens,
+    bool sendTile(const char* buffer, int length, Poco::StringTokenizer& tokens,
                   const std::shared_ptr<DocumentBroker>& docBroker);
-    bool sendCombinedTiles(const char *buffer, int length, Poco::StringTokenizer& tokens,
+    bool sendCombinedTiles(const char* buffer, int length, Poco::StringTokenizer& tokens,
                            const std::shared_ptr<DocumentBroker>& docBroker);
 
-    bool sendFontRendering(const char *buffer, int length, Poco::StringTokenizer& tokens,
+    bool sendFontRendering(const char* buffer, int length, Poco::StringTokenizer& tokens,
                            const std::shared_ptr<DocumentBroker>& docBroker);
 
     bool forwardToChild(const std::string& message,
                         const std::shared_ptr<DocumentBroker>& docBroker);
 
 private:
-
     std::weak_ptr<DocumentBroker> _docBroker;
 
     /// URI with which client made request to us
diff --git a/loolwsd/DocumentBroker.cpp b/loolwsd/DocumentBroker.cpp
index 2e24c72..10aef26 100644
--- a/loolwsd/DocumentBroker.cpp
+++ b/loolwsd/DocumentBroker.cpp
@@ -77,10 +77,9 @@ std::string getCachePath(const std::string& uri)
 
     digestEngine.update(uri.c_str(), uri.size());
 
-    return (LOOLWSD::Cache + "/" +
+    return (LOOLWSD::Cache + '/' +
             Poco::DigestEngine::digestToHex(digestEngine.digest()).insert(3, "/").insert(2, "/").insert(1, "/"));
 }
-
 }
 
 Poco::URI DocumentBroker::sanitizeURI(const std::string& uri)
@@ -169,7 +168,7 @@ DocumentBroker::~DocumentBroker()
     Admin::instance().rmDoc(_docKey);
 
     Log::info() << "~DocumentBroker [" << _uriPublic.toString()
-                << "] destroyed with " << getSessionsCount()
+                << "] destroyed with " << _sessions.size()
                 << " sessions left." << Log::end;
 }
 
@@ -374,7 +373,7 @@ bool DocumentBroker::autoSave(const bool force, const size_t waitTimeoutMs)
     {
         // Find the most recent activity.
         double inactivityTimeMs = std::numeric_limits<double>::max();
-        for (auto& sessionIt: _sessions)
+        for (auto& sessionIt : _sessions)
         {
             inactivityTimeMs = std::min(sessionIt.second->getInactivityMS(), inactivityTimeMs);
         }
@@ -413,7 +412,7 @@ bool DocumentBroker::sendUnoSave(const bool dontSaveIfUnmodified)
     Util::assertIsLocked(_mutex);
 
     // Save using session holding the edit-lock (or first if multview).
-    for (auto& sessionIt: _sessions)
+    for (auto& sessionIt : _sessions)
     {
         // Invalidate the timestamp to force persisting.
         _lastFileModifiedTime.fromEpochTime(0);
@@ -565,7 +564,7 @@ void DocumentBroker::alertAllUsersOfDocument(const std::string& cmd, const std::
 
     std::stringstream ss;
     ss << "error: cmd=" << cmd << " kind=" << kind;
-    for (auto& it: _sessions)
+    for (auto& it : _sessions)
     {
         it.second->sendTextFrame(ss.str());
     }
@@ -585,7 +584,7 @@ bool DocumentBroker::handleInput(const std::vector<char>& payload)
     }
     else if (command == "tilecombine:")
     {
-       handleTileCombinedResponse(payload);
+        handleTileCombinedResponse(payload);
     }
     else if (LOOLProtocol::getFirstToken(command, '-') == "client")
     {
@@ -658,7 +657,8 @@ void DocumentBroker::handleTileRequest(TileDesc& tile,
     tileCache().subscribeToTileRendering(tile, session);
 
     // Forward to child to render.
-    Log::debug() << "Sending render request for tile (" << tile.getPart() << ',' << tile.getTilePosX() << ',' << tile.getTilePosY() << ")." << Log::end;
+    Log::debug() << "Sending render request for tile (" << tile.getPart() << ','
+                 << tile.getTilePosX() << ',' << tile.getTilePosY() << ")." << Log::end;
     const std::string request = "tile " + tile.serialize();
     _childProcess->sendTextFrame(request);
     _debugRenderedTileCount++;
@@ -746,9 +746,8 @@ void DocumentBroker::handleTileResponse(const std::vector<char>& payload)
 
         if (firstLine.size() < static_cast<std::string::size_type>(length) - 1)
         {
-            tileCache().saveTileAndNotify(
-                tile, buffer + firstLine.size() + 1,
-                length - firstLine.size() - 1);
+            const auto offset = firstLine.size() + 1;
+            tileCache().saveTileAndNotify(tile, buffer + offset, length - offset);
         }
         else
         {
@@ -814,7 +813,7 @@ bool DocumentBroker::startDestroy(const std::string& id)
     _lastEditableSession = !currentSession->second->isReadOnly();
     if (_lastEditableSession && !_sessions.empty())
     {
-        for (const auto& it: _sessions)
+        for (const auto& it : _sessions)
         {
             if (it.second->getId() != id &&
                 !it.second->isReadOnly())
diff --git a/loolwsd/DocumentBroker.hpp b/loolwsd/DocumentBroker.hpp
index 39bc19a..f538fc3 100644
--- a/loolwsd/DocumentBroker.hpp
+++ b/loolwsd/DocumentBroker.hpp
@@ -21,8 +21,8 @@
 #include <string>
 #include <thread>
 
-#include <Poco/URI.h>
 #include <Poco/Net/WebSocket.h>
+#include <Poco/URI.h>
 
 #include "IoUtil.hpp"
 #include "Log.hpp"
@@ -92,7 +92,7 @@ public:
                     Log::syserror("Cannot terminate lokit [" + std::to_string(_pid) + "]. Abandoning.");
                 }
 
-               _pid = -1;
+                _pid = -1;
             }
         }
         catch (const std::exception& ex)
@@ -161,13 +161,11 @@ class ClientSession;
 class DocumentBroker : public std::enable_shared_from_this<DocumentBroker>
 {
 public:
-
     static Poco::URI sanitizeURI(const std::string& uri);
 
     /// Returns a document-specific key based
     /// on the URI of the document.
-    static
-    std::string getDocKey(const Poco::URI& uri);
+    static std::string getDocKey(const Poco::URI& uri);
 
     /// Dummy document broker that is marked to destroy.
     DocumentBroker();
@@ -265,13 +263,16 @@ public:
     /// Currently, only makes sense in case storage is WOPI
     const std::chrono::duration<double> getStorageLoadDuration() const;
 
+    /// Called by the ChildProcess object to notify
+    /// that it has terminated on its own.
+    /// This happens either when the child exists
+    /// or upon failing to process an incoming message.
     void childSocketTerminated();
 
     /// Get the PID of the associated child process
     Poco::Process::PID getPid() const { return _childProcess->getPid(); }
 
 private:
-
     /// Sends the .uno:Save command to LoKit.
     bool sendUnoSave(const bool dontSaveIfUnmodified);
 
@@ -292,7 +293,7 @@ private:
     std::string _filename;
     std::chrono::steady_clock::time_point _lastSaveTime;
     Poco::Timestamp _lastFileModifiedTime;
-    std::map<std::string, std::shared_ptr<ClientSession>> _sessions;
+    std::map<std::string, std::shared_ptr<ClientSession> > _sessions;
     std::unique_ptr<StorageBase> _storage;
     std::unique_ptr<TileCache> _tileCache;
     std::atomic<bool> _markToDestroy;
diff --git a/loolwsd/Exceptions.hpp b/loolwsd/Exceptions.hpp
index fee8d8b..ae2d1a6 100644
--- a/loolwsd/Exceptions.hpp
+++ b/loolwsd/Exceptions.hpp
@@ -12,8 +12,8 @@
 #ifndef INCLUDED_EXCEPTIONS_HPP
 #define INCLUDED_EXCEPTIONS_HPP
 
-#include <stdexcept>
 #include <exception>
+#include <stdexcept>
 
 // Generic LOOL errors and base for others.
 class LoolException : public std::runtime_error
@@ -67,7 +67,6 @@ public:
     using LoolException::LoolException;
 };
 
-
 #endif
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/loolwsd/FileServer.hpp b/loolwsd/FileServer.hpp
index 04bf7f1..20a9c8f 100644
--- a/loolwsd/FileServer.hpp
+++ b/loolwsd/FileServer.hpp
@@ -25,7 +25,7 @@
 #include "Log.hpp"
 
 /// Handles file requests over HTTP(S).
-class FileServerRequestHandler: public Poco::Net::HTTPRequestHandler
+class FileServerRequestHandler : public Poco::Net::HTTPRequestHandler
 {
     std::string getRequestPathname(const Poco::Net::HTTPServerRequest& request);
 
diff --git a/loolwsd/IoUtil.hpp b/loolwsd/IoUtil.hpp
index 69819c2..564cef5 100644
--- a/loolwsd/IoUtil.hpp
+++ b/loolwsd/IoUtil.hpp
@@ -11,13 +11,13 @@
 #define INCLUDED_IOUTIL_HPP
 
 #include <functional>
-#include <string>
 #include <memory>
+#include <string>
 
 #include <sys/poll.h>
 
-#include <Poco/Net/WebSocket.h>
 #include <Poco/Logger.h>
+#include <Poco/Net/WebSocket.h>
 
 namespace IoUtil
 {
@@ -37,8 +37,7 @@ namespace IoUtil
     void shutdownWebSocket(const std::shared_ptr<Poco::Net::WebSocket>& ws);
 
     ssize_t writeToPipe(int pipe, const char* buffer, ssize_t size);
-    inline
-    ssize_t writeToPipe(int pipe, const std::string& message)
+    inline ssize_t writeToPipe(int pipe, const std::string& message)
     {
         return writeToPipe(pipe, message.c_str(), message.size());
     }
diff --git a/loolwsd/LOKitHelper.hpp b/loolwsd/LOKitHelper.hpp
index 2986dc3..f029450 100644
--- a/loolwsd/LOKitHelper.hpp
+++ b/loolwsd/LOKitHelper.hpp
@@ -10,8 +10,8 @@
 #ifndef INCLUDED_LOKITHELPER_HPP
 #define INCLUDED_LOKITHELPER_HPP
 
-#include <string>
 #include <sstream>
+#include <string>
 
 #define LOK_USE_UNSTABLE_API
 #include <LibreOfficeKit/LibreOfficeKit.h>
@@ -19,8 +19,7 @@
 
 namespace LOKitHelper
 {
-    inline
-    std::string documentTypeToString(LibreOfficeKitDocumentType type)
+    inline std::string documentTypeToString(LibreOfficeKitDocumentType type)
     {
         switch (type)
         {
@@ -37,16 +36,14 @@ namespace LOKitHelper
         }
     }
 
-    inline
-    std::string getDocumentTypeAsString(LibreOfficeKitDocument *loKitDocument)
+    inline std::string getDocumentTypeAsString(LibreOfficeKitDocument *loKitDocument)
     {
         assert(loKitDocument && "null loKitDocument");
         const auto type = static_cast<LibreOfficeKitDocumentType>(loKitDocument->pClass->getDocumentType(loKitDocument));
         return documentTypeToString(type);
     }
 
-    inline
-    std::string kitCallbackTypeToString(const int nType)
+    inline std::string kitCallbackTypeToString(const int nType)
     {
         // Keep in the same order as in LibreOfficeKitEnums.h
         switch (nType)
@@ -116,10 +113,9 @@ namespace LOKitHelper
         return std::to_string(nType);
     }
 
-    inline
-    std::string documentStatus(LibreOfficeKitDocument *loKitDocument)
+    inline std::string documentStatus(LibreOfficeKitDocument *loKitDocument)
     {
-        char* ptrValue;
+        char *ptrValue;
         assert(loKitDocument && "null loKitDocument");
         const auto type = static_cast<LibreOfficeKitDocumentType>(loKitDocument->pClass->getDocumentType(loKitDocument));
 
diff --git a/loolwsd/LOOLKit.hpp b/loolwsd/LOOLKit.hpp
index 61196fa..b60ebe2 100644
--- a/loolwsd/LOOLKit.hpp
+++ b/loolwsd/LOOLKit.hpp
@@ -17,7 +17,7 @@ void lokit_main(const std::string& childRoot,
                 bool queryVersionInfo,
                 bool displayVersion);
 
-bool globalPreinit(const std::string &loTemplate);
+bool globalPreinit(const std::string& loTemplate);
 /// Wrapper around private Document::ViewCallback().
 void documentViewCallback(const int nType, const char* pPayload, void* pData);
 
@@ -40,7 +40,6 @@ struct UserInfo
     std::string username;
 };
 
-
 #endif
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/loolwsd/LOOLProtocol.hpp b/loolwsd/LOOLProtocol.hpp
index f8204cc..855ca94 100644
--- a/loolwsd/LOOLProtocol.hpp
+++ b/loolwsd/LOOLProtocol.hpp
@@ -29,11 +29,10 @@ namespace LOOLProtocol
     constexpr unsigned ProtocolMajorVersionNumber = 0;
     constexpr unsigned ProtocolMinorVersionNumber = 1;
 
-    inline
-    std::string GetProtocolVersion()
+    inline std::string GetProtocolVersion()
     {
         return std::to_string(ProtocolMajorVersionNumber) + '.'
-             + std::to_string(ProtocolMinorVersionNumber);
+            + std::to_string(ProtocolMinorVersionNumber);
     }
 
     // Parse a string into a version tuple.
diff --git a/loolwsd/LOOLSession.hpp b/loolwsd/LOOLSession.hpp
index 3c14f2d..b875e1d 100644
--- a/loolwsd/LOOLSession.hpp
+++ b/loolwsd/LOOLSession.hpp
@@ -16,17 +16,17 @@
 #include <mutex>
 #include <ostream>
 
-#include <Poco/Net/WebSocket.h>
 #include <Poco/Buffer.h>
+#include <Poco/Net/WebSocket.h>
 #include <Poco/Path.h>
 #include <Poco/Process.h>
 #include <Poco/StringTokenizer.h>
 #include <Poco/Types.h>
 
-#include "MessageQueue.hpp"
 #include "LOOLProtocol.hpp"
-#include "TileCache.hpp"
 #include "Log.hpp"
+#include "MessageQueue.hpp"
+#include "TileCache.hpp"
 
 /// Base class of a WebSocket session.
 class LOOLSession
@@ -36,22 +36,25 @@ public:
     /// 1) Between the master loolwsd server to the end-user LOOL client
     /// 2) Between the master loolwsd server and a jailed child process, in the master process
     /// 3) Ditto, in the jailed process
-    enum class Kind { ToClient, ToPrisoner, ToMaster };
+    enum class Kind
+    {
+        ToClient,
+        ToPrisoner,
+        ToMaster
+    };
 
     const std::string& getId() const { return _id; }
     const std::string& getName() const { return _name; }
     bool isDisconnected() const { return _disconnected; }
 
-    virtual
-    bool sendBinaryFrame(const char *buffer, int length);
-    virtual
-    bool sendTextFrame(const char* buffer, const int length);
+    virtual bool sendBinaryFrame(const char* buffer, int length);
+    virtual bool sendTextFrame(const char* buffer, const int length);
     bool sendTextFrame(const std::string& text)
     {
         return sendTextFrame(text.data(), text.size());
     }
 
-    bool handleInput(const char *buffer, int length);
+    bool handleInput(const char* buffer, int length);
 
     /// Invoked when we want to disconnect a session.
     virtual void disconnect();
@@ -92,7 +95,7 @@ protected:
     }
 
     template <typename T>
-    bool forwardToPeer(T& p, const char *buffer, int length, const bool binary)
+    bool forwardToPeer(T& p, const char* buffer, int length, const bool binary)
     {
         const auto message = LOOLProtocol::getAbbreviatedMessage(buffer, length);
 
@@ -126,11 +129,9 @@ protected:
     }
 
 private:
-
-    virtual bool _handleInput(const char *buffer, int length) = 0;
+    virtual bool _handleInput(const char* buffer, int length) = 0;
 
 private:
-
     /// A session ID specific to an end-to-end connection (from user to lokit).
     const std::string _id;
 
@@ -185,8 +186,8 @@ protected:
     std::string _userName;
 };
 
-template<typename charT, typename traits>
-inline std::basic_ostream<charT, traits> & operator <<(std::basic_ostream<charT, traits> & stream, LOOLSession::Kind kind)
+template <typename charT, typename traits>
+inline std::basic_ostream<charT, traits>& operator<<(std::basic_ostream<charT, traits>& stream, LOOLSession::Kind kind)
 {
     switch (kind)
     {
diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp
index 235c2b5..26a726e 100644
--- a/loolwsd/LOOLWSD.cpp
+++ b/loolwsd/LOOLWSD.cpp
@@ -25,8 +25,8 @@
 
 #include <unistd.h>
 
-#include <sys/types.h>
 #include <sys/stat.h>
+#include <sys/types.h>
 #include <sys/wait.h>
 
 #include <cassert>
@@ -175,7 +175,8 @@ static std::mutex DocBrokersMutex;
 static int careerSpanSeconds = 0;
 #endif
 
-namespace {
+namespace
+{
 
 static inline
 void shutdownLimitReached(WebSocket& ws)
@@ -275,7 +276,7 @@ static bool cleanupChildren()
         if (!NewChildren[i]->isAlive())
         {
             Log::warn() << "Removing unused dead child [" << NewChildren[i]->getPid()
-                         << "]." << Log::end;
+                        << "]." << Log::end;
             NewChildren.erase(NewChildren.begin() + i);
             removed = true;
         }
@@ -344,8 +345,8 @@ static size_t addNewChild(const std::shared_ptr<ChildProcess>& child)
     NewChildren.emplace_back(child);
     const auto count = NewChildren.size();
     Log::info() << "Have " << count << " "
-                << (count == 1 ? "child" : "children")
-                << "." << Log::end;
+                << (count == 1 ? "child." : "children.")
+                << Log::end;
 
     NewChildrenCV.notify_one();
     return count;
@@ -378,7 +379,7 @@ static std::shared_ptr<ChildProcess> getNewChild()
         forkChildren(balance);
 
         const auto timeout = chrono::milliseconds(CHILD_TIMEOUT_MS);
-        if (NewChildrenCV.wait_for(lock, timeout, [](){ return !NewChildren.empty(); }))
+        if (NewChildrenCV.wait_for(lock, timeout, []() { return !NewChildren.empty(); }))
         {
             auto child = NewChildren.back();
             NewChildren.pop_back();
@@ -441,7 +442,7 @@ public:
 };
 
 /// Handle a public connection from a client.
-class ClientRequestHandler: public HTTPRequestHandler
+class ClientRequestHandler : public HTTPRequestHandler
 {
 private:
     static std::string getContentType(const std::string& fileName)
@@ -507,7 +508,7 @@ private:
 
                     cleanupDocBrokers();
 
-                    //FIXME: What if the same document is already open? Need a fake dockey here?
+                    // FIXME: What if the same document is already open? Need a fake dockey here?
                     Log::debug("New DocumentBroker for docKey [" + docKey + "].");
                     DocBrokers.emplace(docKey, docBroker);
 
@@ -525,7 +526,7 @@ private:
                     const std::string load = "load url=" + encodedFrom;
                     session->handleInput(load.data(), load.size());
 
-                    //FIXME: Check for security violations.
+                    // FIXME: Check for security violations.
                     Path toPath(docBroker->getPublicUri().getPath());
                     toPath.setExtension(format);
                     const std::string toJailURL = "file://" + std::string(JAILED_DOCUMENT_ROOT) + toPath.getFileName();
@@ -584,7 +585,7 @@ private:
 
             if (!sent)
             {
-                //TODO: We should differentiate between bad request and failed conversion.
+                // TODO: We should differentiate between bad request and failed conversion.
                 throw BadRequestException("Failed to convert and send file.");
             }
 
@@ -636,7 +637,7 @@ private:
         else if (tokens.count() >= 6)
         {
             Log::info("File download request.");
-            //TODO: Check that the user in question has access to this file!
+            // TODO: Check that the user in question has access to this file!
 
             // 1. Validate the dockey
             std::string decodedUri;
@@ -706,7 +707,7 @@ private:
         // indicator to the client that document broker is searching
         std::string status("statusindicator: find");
         Log::trace("Sending to Client [" + status + "].");
-        ws->sendFrame(status.data(), (int) status.size());
+        ws->sendFrame(status.data(), status.size());
 
         const auto uriPublic = DocumentBroker::sanitizeURI(uri);
         const auto docKey = DocumentBroker::getDocKey(uriPublic);
@@ -760,11 +761,10 @@ private:
             // If this document is going out, wait.
             Log::debug("Document [" + docKey + "] is marked to destroy, waiting to reload.");
 
-            const auto timeout = POLL_TIMEOUT_MS;
             bool timedOut = true;
-            for (size_t i = 0; i < COMMAND_TIMEOUT_MS / timeout; ++i)
+            for (size_t i = 0; i < COMMAND_TIMEOUT_MS / POLL_TIMEOUT_MS; ++i)
             {
-                std::this_thread::sleep_for(std::chrono::milliseconds(timeout));
+                std::this_thread::sleep_for(std::chrono::milliseconds(POLL_TIMEOUT_MS));
 
                 std::unique_lock<std::mutex> lock(DocBrokersMutex);
                 auto it = DocBrokers.find(docKey);
@@ -790,7 +790,7 @@ private:
 
                 if (TerminationFlag)
                 {
-                    Log::error("Termination flag set. No loading new session [" + id + "]");
+                    Log::error("Termination flag set. Not loading new session [" + id + "]");
                     return;
                 }
             }
@@ -849,7 +849,7 @@ private:
 
         // Check if readonly session is required
         bool isReadOnly = false;
-        for (const auto& param: uriPublic.getQueryParameters())
+        for (const auto& param : uriPublic.getQueryParameters())
         {
             Log::debug("Query param: " + param.first + ", value: " + param.second);
             if (param.first == "permission")
@@ -868,12 +868,12 @@ private:
             // indicator to a client that is waiting to connect to lokit process
             status = "statusindicator: connect";
             Log::trace("Sending to Client [" + status + "].");
-            ws->sendFrame(status.data(), (int) status.size());
+            ws->sendFrame(status.data(), status.size());
 
             // Now the bridge beetween the client and kit process is connected
             status = "statusindicator: ready";
             Log::trace("Sending to Client [" + status + "].");
-            ws->sendFrame(status.data(), (int) status.size());
+            ws->sendFrame(status.data(), status.size());
 
             Util::checkDiskSpaceOnRegisteredFileSystems();
 
@@ -951,7 +951,7 @@ private:
             Log::error("Error in client request handler: " + exc.toString());
             status = "error: cmd=internal kind=unauthorized";
             Log::trace("Sending to Client [" + status + "].");
-            ws->sendFrame(status.data(), (int) status.size());
+            ws->sendFrame(status.data(), status.size());
         }
         catch (const std::exception& exc)
         {
@@ -1048,7 +1048,7 @@ public:
         }
 #endif
 
-        handleClientRequest(request,response);
+        handleClientRequest(request, response);
 
 #if MAX_CONNECTIONS > 0
         --LOOLWSD::NumConnections;
@@ -1071,7 +1071,9 @@ public:
         bool responded = false;
         try
         {
-            if ((request.getMethod() == HTTPRequest::HTTP_GET || request.getMethod() == HTTPRequest::HTTP_HEAD) && request.getURI() == "/")
+            if ((request.getMethod() == HTTPRequest::HTTP_GET ||
+                 request.getMethod() == HTTPRequest::HTTP_HEAD) &&
+                request.getURI() == "/")
             {
                 std::string mimeType = "text/plain";
                 std::string responseString = "OK";
@@ -1185,7 +1187,7 @@ public:
 };
 
 /// Handle requests from prisoners (internal).
-class PrisonerRequestHandler: public HTTPRequestHandler
+class PrisonerRequestHandler : public HTTPRequestHandler
 {
 public:
 
@@ -1236,7 +1238,7 @@ public:
 
 /// External (client) connection handler factory.
 /// Creates handler objects.
-class ClientRequestHandlerFactory: public HTTPRequestHandlerFactory
+class ClientRequestHandlerFactory : public HTTPRequestHandlerFactory
 {
 public:
     ClientRequestHandlerFactory()
@@ -1287,7 +1289,7 @@ public:
 
 /// Internal (prisoner) connection handler factory.
 /// Creates handler objects.
-class PrisonerRequestHandlerFactory: public HTTPRequestHandlerFactory
+class PrisonerRequestHandlerFactory : public HTTPRequestHandlerFactory
 {
 public:
     HTTPRequestHandler* createRequestHandler(const HTTPServerRequest& request) override
@@ -1309,18 +1311,18 @@ public:
     }
 };
 
-namespace {
+namespace
+{
 
-static inline
-ServerSocket* getServerSocket(int nClientPortNumber)
+static inline ServerSocket* getServerSocket(int nClientPortNumber)
 {
     try
     {
-        ServerSocket *socket = LOOLWSD::isSSLEnabled() ? new SecureServerSocket()
-            : new ServerSocket();
+        ServerSocket* socket = LOOLWSD::isSSLEnabled() ? new SecureServerSocket() : new ServerSocket();
         socket->bind(nClientPortNumber, false);
-        // 64 is the default value for the backlog parameter in Poco when creating a ServerSocket,
-        // so use it here, too.
+
+        // 64 is the default value for the backlog parameter in Poco
+        // when creating a ServerSocket, so use it here, too.
         socket->listen(64);
         return socket;
     }
@@ -1331,8 +1333,7 @@ ServerSocket* getServerSocket(int nClientPortNumber)
     }
 }
 
-static inline
-ServerSocket* findFreeServerPort(int &nClientPortNumber)
+static inline ServerSocket* findFreeServerPort(int& nClientPortNumber)
 {
     ServerSocket *socket = NULL;
     while (!socket)
@@ -1347,8 +1348,7 @@ ServerSocket* findFreeServerPort(int &nClientPortNumber)
     return socket;
 }
 
-static inline
-ServerSocket* getMasterSocket(int nMasterPortNumber)
+static inline ServerSocket* getMasterSocket(int nMasterPortNumber)
 {
     try
     {
@@ -1378,8 +1378,7 @@ ServerSocket* findFreeMasterPort(int &nMasterPortNumber)
     return socket;
 }
 
-static inline
-std::string getLaunchURI()
+static inline std::string getLaunchURI()
 {
     std::string aAbsTopSrcDir = Poco::Path(Application::instance().commandPath()).parent().toString();
     aAbsTopSrcDir = Poco::Path(aAbsTopSrcDir).absolute().toString();
@@ -1445,8 +1444,7 @@ void LOOLWSD::initialize(Application& self)
         throw std::runtime_error("Do not run as root. Please run as lool user.");
     }
 
-    if (!UnitWSD::init(UnitWSD::UnitType::TYPE_WSD,
-                       UnitTestLibrary))
+    if (!UnitWSD::init(UnitWSD::UnitType::TYPE_WSD, UnitTestLibrary))
     {
         throw std::runtime_error("Failed to load wsd unit test library.");
     }
@@ -1454,41 +1452,40 @@ void LOOLWSD::initialize(Application& self)
     auto& conf = config();
 
     // Add default values of new entries here.
-    static const std::map<std::string, std::string> DefAppConfig = {
-        { "tile_cache_path", LOOLWSD_CACHEDIR },
-        { "sys_template_path", "systemplate" },
-        { "lo_template_path", "/opt/collaboraoffice5.1" },
-        { "child_root_path", "jails" },
-        { "lo_jail_subpath", "lo" },
-        { "server_name", "" },
-        { "file_server_root_path", "../loleaflet/../" },
-        { "num_prespawn_children", "1" },
-        { "per_document.max_concurrency", "4" },
-        { "loleaflet_html", "loleaflet.html" },
-        { "logging.color", "true" },
-        { "logging.level", "trace" },
-        { "ssl.enable", "true" },
-        { "ssl.termination", "true" },
-        { "ssl.cert_file_path", LOOLWSD_CONFIGDIR "/cert.pem" },
-        { "ssl.key_file_path", LOOLWSD_CONFIGDIR "/key.pem" },
-        { "ssl.ca_file_path", LOOLWSD_CONFIGDIR "/ca-chain.cert.pem" },
-        { "storage.filesystem[@allow]", "false" },
-        { "storage.wopi[@allow]", "true" },
-        { "storage.wopi.host[0][@allow]", "true" },
-        { "storage.wopi.host[0]", "localhost" },
-        { "storage.wopi.max_file_size", "0" },
-        { "storage.webdav[@allow]", "false" },
-        { "logging.file[@enable]", "false" },
-        { "logging.file.property[0][@name]", "path" },
-        { "logging.file.property[0]", "loolwsd.log" },
-        { "logging.file.property[1][@name]", "rotation" },
-        { "logging.file.property[1]", "never" },
-        { "logging.file.property[2][@name]", "compress" },
-        { "logging.file.property[2]", "true" },
-        { "logging.file.property[3][@name]", "flush" },
-        { "logging.file.property[3]", "false" },
-        { "trace[@enable]", "false" }
-    };
+    static const std::map<std::string, std::string> DefAppConfig
+        = { { "tile_cache_path", LOOLWSD_CACHEDIR },
+            { "sys_template_path", "systemplate" },
+            { "lo_template_path", "/opt/collaboraoffice5.1" },
+            { "child_root_path", "jails" },
+            { "lo_jail_subpath", "lo" },
+            { "server_name", "" },
+            { "file_server_root_path", "../loleaflet/../" },
+            { "num_prespawn_children", "1" },
+            { "per_document.max_concurrency", "4" },
+            { "loleaflet_html", "loleaflet.html" },
+            { "logging.color", "true" },
+            { "logging.level", "trace" },
+            { "ssl.enable", "true" },
+            { "ssl.termination", "true" },
+            { "ssl.cert_file_path", LOOLWSD_CONFIGDIR "/cert.pem" },
+            { "ssl.key_file_path", LOOLWSD_CONFIGDIR "/key.pem" },
+            { "ssl.ca_file_path", LOOLWSD_CONFIGDIR "/ca-chain.cert.pem" },
+            { "storage.filesystem[@allow]", "false" },
+            { "storage.wopi[@allow]", "true" },
+            { "storage.wopi.host[0][@allow]", "true" },
+            { "storage.wopi.host[0]", "localhost" },
+            { "storage.wopi.max_file_size", "0" },
+            { "storage.webdav[@allow]", "false" },
+            { "logging.file[@enable]", "false" },
+            { "logging.file.property[0][@name]", "path" },
+            { "logging.file.property[0]", "loolwsd.log" },
+            { "logging.file.property[1][@name]", "rotation" },
+            { "logging.file.property[1]", "never" },
+            { "logging.file.property[2][@name]", "compress" },
+            { "logging.file.property[2]", "true" },
+            { "logging.file.property[3][@name]", "flush" },
+            { "logging.file.property[3]", "false" },
+            { "trace[@enable]", "false" } };
 
     // Set default values, in case they are missing from the config file.
     AutoPtr<AppConfigMap> pDefConfig(new AppConfigMap(DefAppConfig));
@@ -1586,17 +1583,17 @@ void LOOLWSD::initialize(Application& self)
     }
 
     // Otherwise we profile the soft-device at jail creation time.
-    setenv ("SAL_DISABLE_OPENCL", "true", 1);
+    setenv("SAL_DISABLE_OPENCL", "true", 1);
 
     // In Trial Versions we might want to set some limits.
     LOOLWSD::NumConnections = 0;
-    Log::info() << "Open Documents Limit: " << (MAX_DOCUMENTS > 0 ?
-                                                std::to_string(MAX_DOCUMENTS) :
-                                                std::string("unlimited")) << Log::end;
+    Log::info() << "Open Documents Limit: "
+                << (MAX_DOCUMENTS ? std::to_string(MAX_DOCUMENTS) : std::string("unlimited"))
+                << Log::end;
 
-    Log::info() << "Client Connections Limit: " << (MAX_CONNECTIONS > 0 ?
-                                                    std::to_string(MAX_CONNECTIONS) :
-                                                    std::string("unlimited")) << Log::end;
+    Log::info() << "Client Connections Limit: "
+                << (MAX_CONNECTIONS ? std::to_string(MAX_CONNECTIONS) : std::string("unlimited"))
+                << Log::end;
 
     // Command Tracing.
     if (getConfigValue<bool>(conf, "trace[@enable]", false))
@@ -1628,8 +1625,8 @@ void LOOLWSD::initialize(Application& self)
     ServerApplication::initialize(self);
 
 #if ENABLE_DEBUG
-            std::cerr << "\nLaunch this in your browser:\n\n" <<
-                getLaunchURI() << "\n" << std::endl;
+    std::cerr << "\nLaunch this in your browser:\n\n"
+              << getLaunchURI() << '\n' << std::endl;
 #endif
 }
 
@@ -1824,7 +1821,7 @@ Process::PID LOOLWSD::createForKit()
         args.push_back("--nocaps");
     }
 
-    Log::info("Launching forkit process: " + forKitPath + " " +
+    Log::info("Launching forkit process: " + forKitPath + ' ' +
               Poco::cat(std::string(" "), args.begin(), args.end()));
 
     LastForkRequestTime = std::chrono::steady_clock::now();
@@ -1854,7 +1851,7 @@ int LOOLWSD::main(const std::vector<std::string>& /*args*/)
 
     initializeSSL();
 
-    char *locale = setlocale(LC_ALL, nullptr);
+    char* locale = setlocale(LC_ALL, nullptr);
     if (locale == nullptr || std::strcmp(locale, "C") == 0)
         setlocale(LC_ALL, "en_US.utf8");
 
@@ -1918,7 +1915,7 @@ int LOOLWSD::main(const std::vector<std::string>& /*args*/)
     if (!psvs)
         return Application::EXIT_SOFTWARE;
 
-    ThreadPool threadPool(NumPreSpawnedChildren*6, MAX_SESSIONS * 2);
+    ThreadPool threadPool(NumPreSpawnedChildren * 6, MAX_SESSIONS * 2);
     HTTPServer srv(new ClientRequestHandlerFactory(), threadPool, *psvs, params1);
     Log::info("Starting master server listening on " + std::to_string(ClientPortNumber));
     srv.start();
@@ -1988,8 +1985,7 @@ int LOOLWSD::main(const std::vector<std::string>& /*args*/)
                 else if (WIFSTOPPED(status) == true)
                 {
                     Log::info() << "Child process [" << pid << "] stopped with "
-                                << Util::signalName(WSTOPSIG(status))
-                                << Log::end;
+                                << Util::signalName(WSTOPSIG(status)) << Log::end;
                 }
                 else if (WIFCONTINUED(status) == true)
                 {
@@ -2027,9 +2023,9 @@ int LOOLWSD::main(const std::vector<std::string>& /*args*/)
                 {
                     std::unique_lock<std::mutex> DocBrokersLock(DocBrokersMutex);
                     cleanupDocBrokers();
-                    for (auto& brokerIt : DocBrokers)
+                    for (auto& pair : DocBrokers)
                     {
-                        brokerIt.second->autoSave(false, 0);
+                        pair.second->autoSave(false, 0);
                     }
                 }
                 catch (const std::exception& exc)
diff --git a/loolwsd/LOOLWSD.hpp b/loolwsd/LOOLWSD.hpp
index d1c0301..f1577d9 100644
--- a/loolwsd/LOOLWSD.hpp
+++ b/loolwsd/LOOLWSD.hpp
@@ -29,7 +29,7 @@ class TraceFileWriter;
 
 /// The Server class which is responsible for all
 /// external interactions.
-class LOOLWSD: public Poco::Util::ServerApplication
+class LOOLWSD : public Poco::Util::ServerApplication
 {
 public:
     LOOLWSD();
@@ -51,32 +51,26 @@ public:
     static std::atomic<unsigned> NumConnections;
     static std::unique_ptr<TraceFileWriter> TraceDumper;
 
-    static
-    std::string GenSessionId()
+    static std::string GenSessionId()
     {
         return Util::encodeId(++NextSessionId, 4);
     }
 
-    static
-    bool isSSLEnabled()
+    static bool isSSLEnabled()
     {
         return LOOLWSD::SSLEnabled.get();
     }
 
-    static
-    bool isSSLTermination()
+    static bool isSSLTermination()
     {
         return LOOLWSD::SSLTermination.get();
     }
 
-    static
-    void dumpEventTrace(const std::string& pId, const std::string& sessionId, const std::string& data);
+    static void dumpEventTrace(const std::string& pId, const std::string& sessionId, const std::string& data);
 
-    static
-    void dumpIncomingTrace(const std::string& pId, const std::string& sessionId, const std::string& data);
+    static void dumpIncomingTrace(const std::string& pId, const std::string& sessionId, const std::string& data);
 
-    static
-    void dumpOutgoingTrace(const std::string& pId, const std::string& sessionId, const std::string& data);
+    static void dumpOutgoingTrace(const std::string& pId, const std::string& sessionId, const std::string& data);
 
 protected:
     void initialize(Poco::Util::Application& self) override;
@@ -93,7 +87,6 @@ private:
     void displayHelp();
     Poco::Process::PID createForKit();
 
-
     class ConfigValueGetter
     {
         Poco::Util::LayeredConfiguration& _config;
@@ -104,17 +97,17 @@ private:
                           const std::string& name)
             : _config(config)
             , _name(name)
-        {}
+        {
+        }
 
         void operator()(unsigned int& value) { value = _config.getUInt(_name); }
         void operator()(bool& value) { value = _config.getBool(_name); }
         void operator()(std::string& value) { value = _config.getString(_name); }
     };
 
-    template<typename T>
-    static
-    bool getSafeConfig(Poco::Util::LayeredConfiguration& config,
-                       const std::string& name, T& value)
+    template <typename T>
+    static bool getSafeConfig(Poco::Util::LayeredConfiguration& config,
+                              const std::string& name, T& value)
     {
         try
         {
diff --git a/loolwsd/Log.hpp b/loolwsd/Log.hpp
index 93724a2..6bded5e 100644
--- a/loolwsd/Log.hpp
+++ b/loolwsd/Log.hpp
@@ -10,9 +10,9 @@
 #ifndef INCLUDED_LOG_HPP
 #define INCLUDED_LOG_HPP
 
-#include <string>
-#include <sstream>
 #include <functional>
+#include <sstream>
+#include <string>
 
 #include <Poco/Logger.h>
 
@@ -38,7 +38,7 @@ namespace Log
     /// Signal safe prefix logging
     void signalLogPrefix();
     /// Signal safe logging
-    void signalLog(const char *message);
+    void signalLog(const char* message);
 
     /// The following is to write streaming logs.
     /// Log::info() << "Value: 0x" << std::hex << value
@@ -54,81 +54,74 @@ namespace Log
     /// operator for logging.
     class StreamLogger
     {
-        public:
-            StreamLogger(std::function<void(const std::string&)> func)
-              : _func(std::move(func))
-            {
-            }
-
-            StreamLogger(StreamLogger&& sl) noexcept
-              : _stream(sl._stream.str())
-              , _func(std::move(sl._func))
-            {
-            }
-
-            void flush() const
-            {
-                _func(_stream.str());
-            }
-
-            std::ostringstream _stream;
-
-        private:
-            std::function<void(const std::string&)> _func;
+    public:
+        StreamLogger(std::function<void(const std::string&)> func)
+            : _func(std::move(func))
+        {
+        }
+
+        StreamLogger(StreamLogger&& sl) noexcept
+            : _stream(sl._stream.str()),
+              _func(std::move(sl._func))
+        {
+        }
+
+        void flush() const
+        {
+            _func(_stream.str());
+        }
+
+        std::ostringstream _stream;
+
+    private:
+        std::function<void(const std::string&)> _func;
     };
 
-    inline
-    StreamLogger trace()
+    inline StreamLogger trace()
     {
-        return StreamLogger([](const std::string& msg) { trace(msg);});
+        return StreamLogger([](const std::string& msg) { trace(msg); });
     }
 
-    inline
-    StreamLogger debug()
+    inline StreamLogger debug()
     {
-        return StreamLogger([](const std::string& msg) { debug(msg);});
+        return StreamLogger([](const std::string& msg) { debug(msg); });
     }
 
-    inline
-    StreamLogger info()
+    inline StreamLogger info()
     {
-        return StreamLogger([](const std::string& msg) { info(msg);});
+        return StreamLogger([](const std::string& msg) { info(msg); });
     }
 
-    inline
-    StreamLogger warn()
+    inline StreamLogger warn()
     {
-        return StreamLogger([](const std::string& msg) { warn(msg);});
+        return StreamLogger([](const std::string& msg) { warn(msg); });
     }
 
-    inline
-    StreamLogger error()
+    inline StreamLogger error()
     {
-        return StreamLogger([](const std::string& msg) { error(msg);});
+        return StreamLogger([](const std::string& msg) { error(msg); });
     }
 
-    inline
-    StreamLogger fatal()
+    inline StreamLogger fatal()
     {
-        return StreamLogger([](const std::string& msg) { fatal(msg);});
+        return StreamLogger([](const std::string& msg) { fatal(msg); });
     }
 
     template <typename U>
-    StreamLogger& operator <<(StreamLogger& lhs, const U& rhs)
+    StreamLogger& operator<<(StreamLogger& lhs, const U& rhs)
     {
         lhs._stream << rhs;
         return lhs;
     }
 
     template <typename U>
-    StreamLogger& operator <<(StreamLogger&& lhs, U&& rhs)
+    StreamLogger& operator<<(StreamLogger&& lhs, U&& rhs)
     {
         lhs._stream << rhs;
         return lhs;
     }
 
-    inline
-    void operator <<(StreamLogger& lhs, const _end_marker&)
+    inline void operator<<(StreamLogger& lhs, const _end_marker&)
     {
         (void)end;
         lhs.flush();
diff --git a/loolwsd/MessageQueue.hpp b/loolwsd/MessageQueue.hpp
index 95a5654..26fd650 100644
--- a/loolwsd/MessageQueue.hpp
+++ b/loolwsd/MessageQueue.hpp
@@ -75,7 +75,6 @@ class TileQueue : public MessageQueue
     friend class TileQueueTests;
 
 private:
-
     class CursorPosition
     {
     public:
@@ -87,10 +86,9 @@ private:
     };
 
 public:
-
     void updateCursorPosition(int viewId, int part, int x, int y, int width, int height)
     {
-        auto cursorPosition = CursorPosition({part, x, y, width, height});
+        auto cursorPosition = CursorPosition({ part, x, y, width, height });
         auto it = _cursorPositions.find(viewId);
         if (it != _cursorPositions.end())
         {
diff --git a/loolwsd/Png.hpp b/loolwsd/Png.hpp
index 6796adf..cb05654 100644
--- a/loolwsd/Png.hpp
+++ b/loolwsd/Png.hpp
@@ -62,7 +62,7 @@ extern "C"
 
     static void user_write_fn(png_structp png_ptr, png_bytep data, png_size_t length)
     {
-        std::vector<char> *outputp = (std::vector<char> *) png_get_io_ptr(png_ptr);
+        std::vector<char>* outputp = (std::vector<char>*)png_get_io_ptr(png_ptr);
         const size_t oldsize = outputp->size();
         outputp->resize(oldsize + length);
         std::memcpy(outputp->data() + oldsize, data, length);
diff --git a/loolwsd/PrisonerSession.hpp b/loolwsd/PrisonerSession.hpp
index 3d6ac6c..87cba16 100644
--- a/loolwsd/PrisonerSession.hpp
+++ b/loolwsd/PrisonerSession.hpp
@@ -28,11 +28,9 @@ public:
     bool shutdownPeer(Poco::UInt16 statusCode);
 
 private:
-
-    virtual bool _handleInput(const char *buffer, int length) override;
+    virtual bool _handleInput(const char* buffer, int length) override;
 
 private:
-
     std::shared_ptr<DocumentBroker> _docBroker;
     std::weak_ptr<ClientSession> _peer;
     int _curPart;
diff --git a/loolwsd/QueueHandler.hpp b/loolwsd/QueueHandler.hpp
index 8c6cca3..3f330e6 100644
--- a/loolwsd/QueueHandler.hpp
+++ b/loolwsd/QueueHandler.hpp
@@ -9,13 +9,13 @@
 
 #include <Poco/Runnable.h>
 
-#include "MessageQueue.hpp"
-#include "LOOLSession.hpp"
 #include "LOOLProtocol.hpp"
+#include "LOOLSession.hpp"
+#include "MessageQueue.hpp"
 #include "Util.hpp"
 
 /// This thread handles incoming messages on a given kit instance.
-class QueueHandler: public Poco::Runnable
+class QueueHandler : public Poco::Runnable
 {
 public:
     QueueHandler(std::shared_ptr<MessageQueue> queue,
diff --git a/loolwsd/Storage.hpp b/loolwsd/Storage.hpp
index b21b19e..a60d42b 100644
--- a/loolwsd/Storage.hpp
+++ b/loolwsd/Storage.hpp
@@ -11,11 +11,11 @@
 #ifndef INCLUDED_STORAGE_HPP
 #define INCLUDED_STORAGE_HPP
 
-#include <string>
 #include <set>
+#include <string>
 
-#include <Poco/Util/Application.h>
 #include <Poco/URI.h>
+#include <Poco/Util/Application.h>
 
 #include "Auth.hpp"
 #include "Log.hpp"
@@ -25,7 +25,6 @@
 class StorageBase
 {
 public:
-
     /// Represents basic file's attributes.
     /// Used for local and network files.
     class FileInfo
@@ -80,8 +79,7 @@ public:
     /// Writes the contents of the file back to the source.
     virtual bool saveLocalFileToStorage(const Poco::URI& uriPublic) = 0;
 
-    static
-    size_t getFileSize(const std::string& filename);
+    static size_t getFileSize(const std::string& filename);
 
     /// Must be called at startup to configure.
     static void initialize();
@@ -161,7 +159,8 @@ public:
                   "], jailPath: [" + jailPath + "], uri: [" + uri.toString() + "].");
     }
 
-    class WOPIFileInfo {
+    class WOPIFileInfo
+    {
     public:
         WOPIFileInfo(const std::string& userid,
                      const std::string& username,
diff --git a/loolwsd/TileCache.hpp b/loolwsd/TileCache.hpp
index fd44cd0..b9b2f60 100644
--- a/loolwsd/TileCache.hpp
+++ b/loolwsd/TileCache.hpp
@@ -40,14 +40,14 @@ public:
 
     /// Subscribes if no subscription exists and returns the version number.
     /// Otherwise returns 0 to signify a subscription exists.
-    void subscribeToTileRendering(const TileDesc& tile, const std::shared_ptr<ClientSession> &subscriber);
+    void subscribeToTileRendering(const TileDesc& tile, const std::shared_ptr<ClientSession>& subscriber);
 
     /// Cancels all tile requests by the given subscriber.
-    std::string cancelTiles(const std::shared_ptr<ClientSession> &subscriber);
+    std::string cancelTiles(const std::shared_ptr<ClientSession>& subscriber);
 
     std::unique_ptr<std::fstream> lookupTile(const TileDesc& tile);
 
-    void saveTileAndNotify(const TileDesc& tile, const char *data, const size_t size);
+    void saveTileAndNotify(const TileDesc& tile, const char* data, const size_t size);
 
     std::string getTextFile(const std::string& fileName);
 
@@ -59,7 +59,7 @@ public:
 
     // Saves a font / style / etc rendering
     // The dir parameter should be the type of rendering, like "font", "style", etc
-    void saveRendering(const std::string& name, const std::string& dir, const char *data, size_t size);
+    void saveRendering(const std::string& name, const std::string& dir, const char* data, size_t size);
 
     std::unique_ptr<std::fstream> lookupCachedFile(const std::string& name, const std::string& dir);
 
@@ -96,7 +96,7 @@ private:
 
     mutable std::mutex _tilesBeingRenderedMutex;
 
-    std::map<std::string, std::shared_ptr<TileBeingRendered>> _tilesBeingRendered;
+    std::map<std::string, std::shared_ptr<TileBeingRendered> > _tilesBeingRendered;
 };
 
 #endif
diff --git a/loolwsd/TileDesc.hpp b/loolwsd/TileDesc.hpp
index 9356c2d..8ba44bd 100644
--- a/loolwsd/TileDesc.hpp
+++ b/loolwsd/TileDesc.hpp
@@ -135,8 +135,7 @@ public:
     }
 
     /// Deserialize a TileDesc from a tokenized string.
-    static
-    TileDesc parse(const Poco::StringTokenizer& tokens)
+    static TileDesc parse(const Poco::StringTokenizer& tokens)
     {
         // We don't expect undocumented fields and
         // assume all values to be int.
@@ -165,12 +164,10 @@ public:
     }
 
     /// Deserialize a TileDesc from a string format.
-    static
-    TileDesc parse(const std::string& message)
+    static TileDesc parse(const std::string& message)
     {
         Poco::StringTokenizer tokens(message, " ",
-                                     Poco::StringTokenizer::TOK_IGNORE_EMPTY |
-                                     Poco::StringTokenizer::TOK_TRIM);
+                                     Poco::StringTokenizer::TOK_IGNORE_EMPTY | Poco::StringTokenizer::TOK_TRIM);
         return parse(tokens);
     }
 
@@ -182,8 +179,8 @@ private:
     int _tilePosY;
     int _tileWidth;
     int _tileHeight;
-    int _ver;       //< Versioning support.
-    int _imgSize;   //< Used for responses.
+    int _ver; //< Versioning support.
+    int _imgSize; //< Used for responses.
     int _id;
 };
 
@@ -251,7 +248,6 @@ private:
     }
 
 public:
-
     int getPart() const { return _part; }
     int getWidth() const { return _width; }
     int getHeight() const { return _height; }
@@ -312,8 +308,7 @@ public:
     }
 
     /// Deserialize a TileDesc from a tokenized string.
-    static
-    TileCombined parse(const Poco::StringTokenizer& tokens)
+    static TileCombined parse(const Poco::StringTokenizer& tokens)
     {
         // We don't expect undocumented fields and
         // assume all values to be int.
@@ -363,17 +358,14 @@ public:
     }
 
     /// Deserialize a TileDesc from a string format.
-    static
-    TileCombined parse(const std::string& message)
+    static TileCombined parse(const std::string& message)
     {
         Poco::StringTokenizer tokens(message, " ",
-                                     Poco::StringTokenizer::TOK_IGNORE_EMPTY |
-                                     Poco::StringTokenizer::TOK_TRIM);
+                                     Poco::StringTokenizer::TOK_IGNORE_EMPTY | Poco::StringTokenizer::TOK_TRIM);
         return parse(tokens);
     }
 
-    static
-    TileCombined create(const std::vector<TileDesc>& tiles)
+    static TileCombined create(const std::vector<TileDesc>& tiles)
     {
         assert(!tiles.empty());
 
@@ -399,7 +391,7 @@ private:
     int _height;
     int _tileWidth;
     int _tileHeight;
-    int _ver;       //< Versioning support.
+    int _ver; //< Versioning support.
     int _id;
 };
 
diff --git a/loolwsd/Unit.hpp b/loolwsd/Unit.hpp
index fb6a850..97b7103 100644
--- a/loolwsd/Unit.hpp
+++ b/loolwsd/Unit.hpp
@@ -9,10 +9,10 @@
 #ifndef INCLUDED_UNIT_HPP
 #define INCLUDED_UNIT_HPP
 
-#include <string>
-#include <memory>
 #include <atomic>
 #include <cassert>
+#include <memory>
+#include <string>
 
 #include <Poco/Net/WebSocket.h>
 
@@ -24,13 +24,16 @@ class UnitHTTPServerRequest;
 class UnitHTTPServerResponse;
 
 // Forward declaration to avoid pulling the world here.
-namespace Poco {
-    namespace Net {
+namespace Poco
+{
+    namespace Net
+    {
         class HTTPServerRequest;
         class HTTPServerResponse;
     }
 
-    namespace Util {
+    namespace Util
+    {
         class LayeredConfiguration;
     }
 }
@@ -50,7 +53,6 @@ class UnitBase
     friend UnitKit;
 
 protected:
-
     // ---------------- Helper API ----------------
     /// After this time we invoke 'timeout' default 30 seconds
     void setTimeout(int timeoutMilliSeconds);
@@ -58,33 +60,42 @@ protected:
     /// If the test times out this gets invoked, the default just exits.
     virtual void timeout();
 
-    enum TestResult { TEST_FAILED, TEST_OK, TEST_TIMED_OUT };
+    enum TestResult
+    {
+        TEST_FAILED,
+        TEST_OK,
+        TEST_TIMED_OUT
+    };
 
     /// Encourages the process to exit with this value (unless hooked)
     void exitTest(TestResult result);
 
-             UnitBase();
+    UnitBase();
     virtual ~UnitBase();
 
 public:
-    enum UnitType { TYPE_WSD, TYPE_KIT };
+    enum UnitType
+    {
+        TYPE_WSD,
+        TYPE_KIT
+    };
     /// Load unit test hook shared library from this path
-    static bool init(UnitType type, const std::string &unitLibPath);
+    static bool init(UnitType type, const std::string& unitLibPath);
 
     /// Do we have a unit test library hooking things & loaded
     static bool isUnitTesting();
 
     /// Tweak the return value from the process.
-	virtual void returnValue(int & /* retValue */);
+    virtual void returnValue(int& /* retValue */);
 
 private:
     void setHandle(void *dlHandle) { _dlHandle = dlHandle; }
-    static UnitBase *linkAndCreateUnit(UnitType type, const std::string &unitLibPath);
+    static UnitBase *linkAndCreateUnit(UnitType type, const std::string& unitLibPath);
 
     void *_dlHandle;
     bool _setRetValue;
-    int  _retValue;
-    int  _timeoutMilliSeconds;
+    int _retValue;
+    int _timeoutMilliSeconds;
     std::atomic<bool> _timeoutShutdown;
     static UnitBase *Global;
     UnitType _type;
@@ -94,17 +105,22 @@ private:
 class UnitWSD : public UnitBase
 {
     bool _hasKitHooks;
+
 public:
-             UnitWSD();
+    UnitWSD();
     virtual ~UnitWSD();
 
-	static UnitWSD &get()
+    static UnitWSD& get()
     {
-        assert (Global && Global->_type == UnitType::TYPE_WSD);
+        assert(Global && Global->_type == UnitType::TYPE_WSD);
         return *static_cast<UnitWSD *>(Global);
     }
 
-    enum TestRequest { TEST_REQ_CLIENT, TEST_REQ_PRISONER };
+    enum TestRequest
+    {
+        TEST_REQ_CLIENT,
+        TEST_REQ_PRISONER
+    };
     /// Simulate an incoming request
     void testHandleRequest(TestRequest type,
                            UnitHTTPServerRequest& request,
@@ -117,29 +133,35 @@ public:
     // ---------------- WSD hooks ----------------
 
     /// Manipulate and modify the configuration before any usage.
-    virtual void configure(Poco::Util::LayeredConfiguration & /* config */);
+    virtual void configure(Poco::Util::LayeredConfiguration& /* config */);
     /// Main-loop reached, time for testing
     virtual void invokeTest() {}
     /// Tweak the count of pre-spawned kits.
-    virtual void preSpawnCount(int & /* numPrefork */) {}
+    virtual void preSpawnCount(int& /* numPrefork */) {}
     /// When a new child kit process reports
-    virtual void newChild(const std::shared_ptr<Poco::Net::WebSocket> & /* socket */) {}
+    virtual void newChild(const std::shared_ptr<Poco::Net::WebSocket>& /* socket */) {}
     /// Intercept createStorage
     virtual bool createStorage(const Poco::URI& /* uri */,
                                const std::string& /* jailRoot */,
                                const std::string& /* jailPath */,
-                               std::unique_ptr<StorageBase> & /*rStorage */)
-        { return false; }
+                               std::unique_ptr<StorageBase>& /*rStorage */)
+    {
+        return false;
+    }
     /// Intercept incoming requests, so unit tests can silently communicate
     virtual bool filterHandleRequest(
-                     TestRequest /* type */,
-                     Poco::Net::HTTPServerRequest& /* request */,
-                     Poco::Net::HTTPServerResponse& /* response */)
-        { return false; }
+        TestRequest /* type */,
+        Poco::Net::HTTPServerRequest& /* request */,
+        Poco::Net::HTTPServerResponse& /* response */)
+    {
+        return false;
+    }
 
     /// Child sent a message
     virtual bool filterChildMessage(const std::vector<char>& /* payload */)
-        { return false; }
+    {
+        return false;
+    }
 
     // ---------------- TileCache hooks ----------------
     /// Called before the lookupTile call returns. Should always be called to fire events.
@@ -147,9 +169,9 @@ public:
                             int tileWidth, int tileHeight, std::unique_ptr<std::fstream>& cacheFile);
 
     // ---------------- DocumentBroker hooks ----------------
-    virtual bool filterLoad(const std::string &/* sessionId */,
-                            const std::string &/* jailId */,
-                            bool &/* result */)
+    virtual bool filterLoad(const std::string& /* sessionId */,
+                            const std::string& /* jailId */,
+                            bool& /* result */)
     {
         return false;
     }
@@ -177,11 +199,11 @@ public:
 class UnitKit : public UnitBase
 {
 public:
-             UnitKit();
+    UnitKit();
     virtual ~UnitKit();
-	static UnitKit &get()
+    static UnitKit& get()
     {
-        assert (Global && Global->_type == UnitType::TYPE_KIT);
+        assert(Global && Global->_type == UnitType::TYPE_KIT);
         return *static_cast<UnitKit *>(Global);
     }
 
@@ -199,14 +221,18 @@ public:
     virtual void postFork() {}
 
     /// Kit got a message
-    virtual bool filterKitMessage(const std::shared_ptr<Poco::Net::WebSocket> & /* ws */,
-                                  std::string &/* message */)
-        { return false; }
+    virtual bool filterKitMessage(const std::shared_ptr<Poco::Net::WebSocket>& /* ws */,
+                                  std::string& /* message */)
+    {
+        return false;
+    }
 
     /// Allow a custom LibreOfficeKit wrapper
     virtual LibreOfficeKit *lok_init(const char * /* instdir */,
                                      const char * /* userdir */)
-        { return NULL; }
+    {
+        return NULL;
+    }
 };
 
 #endif
diff --git a/loolwsd/UnitHTTP.hpp b/loolwsd/UnitHTTP.hpp

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list