[Libreoffice-commits] online.git: Branch 'feature/latency' - wsd/ClientSession.cpp wsd/ClientSession.hpp

Tamás Zolnai tamas.zolnai at collabora.com
Tue Jun 19 14:19:37 UTC 2018


 wsd/ClientSession.cpp |   58 ++++++++++++++++++++++++++------------------------
 wsd/ClientSession.hpp |    1 
 2 files changed, 32 insertions(+), 27 deletions(-)

New commits:
commit 3daf7893dff625dab59ecaec1d9af360350fd517
Author: Tamás Zolnai <tamas.zolnai at collabora.com>
Date:   Tue Jun 19 16:15:37 2018 +0200

    Handle part number a bit more robust in case of Writer
    
    Change-Id: I7390f1c5f4289be67deacf3540068c040b230584

diff --git a/wsd/ClientSession.cpp b/wsd/ClientSession.cpp
index 46bdfe775..85f740bea 100644
--- a/wsd/ClientSession.cpp
+++ b/wsd/ClientSession.cpp
@@ -48,7 +48,8 @@ ClientSession::ClientSession(const std::string& id,
     _tileWidthPixel(0),
     _tileHeightPixel(0),
     _tileWidthTwips(0),
-    _tileHeightTwips(0)
+    _tileHeightTwips(0),
+    _isTextDocument(false)
 {
     const size_t curConnections = ++LOOLWSD::NumConnections;
     LOG_INF("ClientSession ctor [" << getName() << "], current number of connections: " << curConnections);
@@ -291,17 +292,20 @@ bool ClientSession::_handleInput(const char *buffer, int length)
     }
     else if (tokens[0] == "setclientpart")
     {
-        int temp;
-        if (tokens.size() != 2 ||
-            !getTokenInteger(tokens[1], "part", temp))
+        if(!_isTextDocument)
         {
-            sendTextFrame("error: cmd=setclientpart kind=syntax");
-            return false;
-        }
-        else
-        {
-            _clientSelectedPart = temp;
-            return forwardToChild(std::string(buffer, length), docBroker);
+            int temp;
+            if (tokens.size() != 2 ||
+                !getTokenInteger(tokens[1], "part", temp))
+            {
+                sendTextFrame("error: cmd=setclientpart kind=syntax");
+                return false;
+            }
+            else
+            {
+                _clientSelectedPart = temp;
+                return forwardToChild(std::string(buffer, length), docBroker);
+            }
         }
     }
     else if (tokens[0] == "clientzoom")
@@ -724,17 +728,20 @@ bool ClientSession::handleKitToClientMessage(const char* buffer, const int lengt
     }
     else if (tokens[0] == "setpart:" && tokens.size() == 2)
     {
-        int setPart;
-        if(getTokenInteger(tokens[1], "part", setPart))
-        {
-            _clientSelectedPart = setPart;
-        }
-        else if (stringToInteger(tokens[1], setPart))
+        if(!_isTextDocument)
         {
+            int setPart;
+            if(getTokenInteger(tokens[1], "part", setPart))
+            {
             _clientSelectedPart = setPart;
-        }
-        else
-            return false;
+            }
+            else if (stringToInteger(tokens[1], setPart))
+            {
+                _clientSelectedPart = setPart;
+            }
+            else
+                return false;
+         }
     }
     else if (tokens.size() == 3 && tokens[0] == "saveas:")
     {
@@ -865,7 +872,7 @@ bool ClientSession::handleKitToClientMessage(const char* buffer, const int lengt
                 std::string docType;
                 if(getTokenString(token, "type", docType))
                 {
-                    _docType = docType;
+                    _isTextDocument = docType.find("text") != std::string::npos;
                 }
             }
 
@@ -1102,7 +1109,7 @@ void ClientSession::handleTileInvalidation(const std::string& message,
     if(!_clientVisibleArea.hasSurface() ||
        _tileWidthPixel == 0 || _tileHeightPixel == 0 ||
        _tileWidthTwips == 0 || _tileHeightTwips == 0 ||
-       _clientSelectedPart == -1)
+       (_clientSelectedPart == -1 && !_isTextDocument))
     {
         return;
     }
@@ -1111,14 +1118,11 @@ void ClientSession::handleTileInvalidation(const std::string& message,
     int part = result.first;
     Util::Rectangle& invalidateRect = result.second;
 
-    if(_docType.find("text") != std::string::npos) // For Writer we don't have separate parts
-        part = 0;
-
-    if(part == -1) // If no part is specifed we use the part used by the client
+    if( part == -1 ) // If no part is specifed we use the part used by the client
         part = _clientSelectedPart;
 
     std::vector<TileDesc> invalidTiles;
-    if(part == _clientSelectedPart)
+    if(part == _clientSelectedPart || _isTextDocument)
     {
         Util::Rectangle intersection;
         intersection._x1 = std::max(invalidateRect._x1, _clientVisibleArea._x1);
diff --git a/wsd/ClientSession.hpp b/wsd/ClientSession.hpp
index ed8266bbc..decc6c227 100644
--- a/wsd/ClientSession.hpp
+++ b/wsd/ClientSession.hpp
@@ -196,6 +196,7 @@ private:
 
     // Type of the docuemnt, extracter from status message
     std::string _docType;
+    bool _isTextDocument;
 
     std::vector<std::string> _tilesOnFly;
     boost::optional<std::chrono::time_point<std::chrono::steady_clock>> _tileCounterStartTime;


More information about the Libreoffice-commits mailing list