[Libreoffice-commits] online.git: loolwsd/LOKitHelper.hpp loolwsd/LOOLSession.cpp loolwsd/LOOLWSD.cpp loolwsd/MessageQueue.cpp loolwsd/MessageQueue.hpp loolwsd/Png.hpp loolwsd/test

Miklos Vajna vmiklos at collabora.co.uk
Tue Nov 24 00:43:47 PST 2015


 loolwsd/LOKitHelper.hpp     |    6 ++++--
 loolwsd/LOOLSession.cpp     |   36 ++++++++++++++++++++++++------------
 loolwsd/LOOLWSD.cpp         |    6 ++++--
 loolwsd/MessageQueue.cpp    |    3 ++-
 loolwsd/MessageQueue.hpp    |    4 +++-
 loolwsd/Png.hpp             |   12 +++++++++---
 loolwsd/test/httpwstest.cpp |    6 +++---
 7 files changed, 49 insertions(+), 24 deletions(-)

New commits:
commit 2bb596a2568258e2e11a426f47e59dc4a9d0eba9
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Nov 24 09:41:59 2015 +0100

    loolwsd: coding style
    
    If README says "spaces, not tabs" and "braces go on separate lines",
    then be consistent about it before it gets normal to not respect those
    rules.

diff --git a/loolwsd/LOKitHelper.hpp b/loolwsd/LOKitHelper.hpp
index a20590a..33adeb8 100644
--- a/loolwsd/LOKitHelper.hpp
+++ b/loolwsd/LOKitHelper.hpp
@@ -47,8 +47,10 @@ namespace LOKitHelper
                 "current=" + std::to_string(loKitDocument->pClass->getPart(loKitDocument)) + " "
                 "width=" + std::to_string(width) + " "
                 "height=" + std::to_string(height));
-        if (typeString == "spreadsheet" || typeString == "presentation") {
-            for (int i = 0; i < parts; i++) {
+        if (typeString == "spreadsheet" || typeString == "presentation")
+        {
+            for (int i = 0; i < parts; i++)
+            {
                 status += "\n";
                 status += loKitDocument->pClass->getPartName(loKitDocument, i);
             }
diff --git a/loolwsd/LOOLSession.cpp b/loolwsd/LOOLSession.cpp
index ff15806..c518ab5 100644
--- a/loolwsd/LOOLSession.cpp
+++ b/loolwsd/LOOLSession.cpp
@@ -92,13 +92,16 @@ LOOLSession::LOOLSession(std::shared_ptr<WebSocket> ws, Kind kind) :
     _docURL("")
 {
     std::cout << Util::logPrefix() << "LOOLSession ctor this=" << this << " " << _kind << " ws=" << _ws.get() << std::endl;
-    if (kind == Kind::ToClient) {
+    if (kind == Kind::ToClient)
+    {
         _kindString = "ToClient";
     }
-    else if (kind == Kind::ToMaster) {
+    else if (kind == Kind::ToMaster)
+    {
         _kindString = "ToMaster";
     }
-    else if (kind == Kind::ToPrisoner) {
+    else if (kind == Kind::ToPrisoner)
+    {
         _kindString = "ToPrisoner";
     }
 }
@@ -279,7 +282,8 @@ bool MasterProcessSession::handleInput(const char *buffer, int length)
             {
                 peer->_tileCache->saveTextFile(std::string(buffer, length), "partpagerectangles.txt");
             }
-            else if (tokens[0] == "invalidatecursor:") {
+            else if (tokens[0] == "invalidatecursor:")
+            {
                 peer->_tileCache->setEditing(true);
             }
             else if (tokens[0] == "invalidatetiles:")
@@ -418,7 +422,8 @@ bool MasterProcessSession::handleInput(const char *buffer, int length)
             forwardToPeer(buffer, length);
         }
 
-        if ((tokens.count() > 1 && tokens[0] == "uno" && tokens[1] == ".uno:Save")) {
+        if ((tokens.count() > 1 && tokens[0] == "uno" && tokens[1] == ".uno:Save"))
+        {
            _tileCache->documentSaved();
         }
     }
@@ -895,7 +900,8 @@ extern "C"
                                        " width=" + std::to_string(width) +
                                        " height=" + std::to_string(height));
                 }
-                else {
+                else
+                {
                     srv->sendTextFrame("invalidatetiles: " + std::string(pPayload));
                 }
             }
@@ -1100,7 +1106,8 @@ void ChildProcessSession::sendTile(const char* /*buffer*/, int /*length*/, Strin
     std::memcpy(output.data(), response.data(), response.size());
 
     unsigned char *pixmap = new unsigned char[4 * width * height];
-    if (_docType != "text" && part != _loKitDocument->pClass->getPart(_loKitDocument)) {
+    if (_docType != "text" && part != _loKitDocument->pClass->getPart(_loKitDocument))
+    {
         _loKitDocument->pClass->setPart(_loKitDocument, part);
     }
 
@@ -1151,8 +1158,10 @@ bool ChildProcessSession::downloadAs(const char* /*buffer*/, int /*length*/, Str
 
     getTokenString(tokens[3], "format", format);
 
-    if (getTokenString(tokens[4], "options", filterOptions)) {
-        if (tokens.count() > 5) {
+    if (getTokenString(tokens[4], "options", filterOptions))
+    {
+        if (tokens.count() > 5)
+        {
             filterOptions += Poco::cat(std::string(" "), tokens.begin() + 5, tokens.end());
         }
     }
@@ -1233,7 +1242,8 @@ bool ChildProcessSession::insertFile(const char* /*buffer*/, int /*length*/, Str
         return false;
     }
 
-    if (type == "graphic") {
+    if (type == "graphic")
+    {
         std::string fileName = "file://" + jailDocumentURL + "/insertfile/" + name;
         std::string command = ".uno:InsertGraphic";
         std::string arguments = "{"
@@ -1384,8 +1394,10 @@ bool ChildProcessSession::saveAs(const char* /*buffer*/, int /*length*/, StringT
 
     getTokenString(tokens[2], "format", format);
 
-    if (getTokenString(tokens[3], "options", filterOptions)) {
-        if (tokens.count() > 4) {
+    if (getTokenString(tokens[3], "options", filterOptions))
+    {
+        if (tokens.count() > 4)
+        {
             filterOptions += Poco::cat(std::string(" "), tokens.begin() + 4, tokens.end());
         }
     }
diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp
index 2954842..2caec30 100644
--- a/loolwsd/LOOLWSD.cpp
+++ b/loolwsd/LOOLWSD.cpp
@@ -845,7 +845,8 @@ namespace
             // The program is setuid root. Not normal on Linux where we use setcap, but if this
             // needs to run on non-Linux Unixes, setuid root is what it will bneed to be to be able
             // to do chroot().
-            if (setuid(getuid()) != 0) {
+            if (setuid(getuid()) != 0)
+            {
                 Application::instance().logger().error(std::string("setuid() failed: ") + strerror(errno));
             }
         }
@@ -868,7 +869,8 @@ namespace
                 else
                     LOOLWSD::uid = 65534;
             }
-            if (setuid(LOOLWSD::uid) != 0) {
+            if (setuid(LOOLWSD::uid) != 0)
+            {
                 Application::instance().logger().error(std::string("setuid() failed: ") + strerror(errno));
             }
         }
diff --git a/loolwsd/MessageQueue.cpp b/loolwsd/MessageQueue.cpp
index f37c5b8..65fd0e5 100644
--- a/loolwsd/MessageQueue.cpp
+++ b/loolwsd/MessageQueue.cpp
@@ -65,7 +65,8 @@ void BasicTileQueue::put_impl(const std::string& value)
     {
         // remove all the existing tiles from the queue
         _queue.erase(std::remove_if(_queue.begin(), _queue.end(),
-                    [](const std::string& v) {
+                    [](const std::string& v)
+                    {
                         // must not remove the tiles with 'id=', they are special, used
                         // eg. for previews etc.
                         return (v.compare(0, 5, "tile ") == 0) && (v.find("id=") == std::string::npos);
diff --git a/loolwsd/MessageQueue.hpp b/loolwsd/MessageQueue.hpp
index f1b8996..26a1d51 100644
--- a/loolwsd/MessageQueue.hpp
+++ b/loolwsd/MessageQueue.hpp
@@ -21,7 +21,9 @@
 class MessageQueue
 {
 public:
-    MessageQueue() {}
+    MessageQueue()
+    {
+    }
     virtual ~MessageQueue();
 
     MessageQueue(const MessageQueue&) = delete;
diff --git a/loolwsd/Png.hpp b/loolwsd/Png.hpp
index a2d27eb..23d86d4 100644
--- a/loolwsd/Png.hpp
+++ b/loolwsd/Png.hpp
@@ -42,16 +42,20 @@ unpremultiply_data (png_structp /*png*/, png_row_infop row_info, png_bytep data)
 {
     unsigned int i;
 
-    for (i = 0; i < row_info->rowbytes; i += 4) {
+    for (i = 0; i < row_info->rowbytes; i += 4)
+    {
         uint8_t *b = &data[i];
         uint32_t pixel;
         uint8_t  alpha;
 
         memcpy (&pixel, b, sizeof (uint32_t));
         alpha = (pixel & 0xff000000) >> 24;
-        if (alpha == 0) {
+        if (alpha == 0)
+        {
             b[0] = b[1] = b[2] = b[3] = 0;
-        } else {
+        }
+        else
+        {
             b[0] = (((pixel & 0xff0000) >> 16) * 255 + alpha / 2) / alpha;
             b[1] = (((pixel & 0x00ff00) >>  8) * 255 + alpha / 2) / alpha;
             b[2] = (((pixel & 0x0000ff) >>  0) * 255 + alpha / 2) / alpha;
@@ -59,3 +63,5 @@ unpremultiply_data (png_structp /*png*/, png_row_infop row_info, png_bytep data)
         }
     }
 }
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/loolwsd/test/httpwstest.cpp b/loolwsd/test/httpwstest.cpp
index c967fff..415b4d9 100644
--- a/loolwsd/test/httpwstest.cpp
+++ b/loolwsd/test/httpwstest.cpp
@@ -39,9 +39,9 @@ class HTTPWSTest : public CPPUNIT_NS::TestFixture
 public:
     HTTPWSTest()
         : _uri("http://127.0.0.1:" + std::to_string(LOOLWSD::DEFAULT_CLIENT_PORT_NUMBER)),
-        _session(_uri.getHost(), _uri.getPort()),
-        _request(Poco::Net::HTTPRequest::HTTP_POST, "/ws"),
-        _socket(_session, _request, _response)
+          _session(_uri.getHost(), _uri.getPort()),
+          _request(Poco::Net::HTTPRequest::HTTP_POST, "/ws"),
+          _socket(_session, _request, _response)
     {
     }
 };


More information about the Libreoffice-commits mailing list