diff --git a/common/Rectangle.hpp b/common/Rectangle.hpp index f020777b2c788..071556266f201 100644 --- a/common/Rectangle.hpp +++ b/common/Rectangle.hpp @@ -66,6 +66,9 @@ struct Rectangle } } + /// Ctor from comma separated values + Rectangle(const std::string &rectangle); + /// Ctor via top/left and bottom/right coordinates static Rectangle create(int x1, int y1, int x2, int y2) { diff --git a/common/Util.cpp b/common/Util.cpp index 2627896dbe96c..6fc08c8efd737 100644 --- a/common/Util.cpp +++ b/common/Util.cpp @@ -1001,6 +1001,22 @@ namespace Util return s; } + Rectangle::Rectangle(const std::string &rectangle) + { + StringVector tokens(StringVector::tokenize(rectangle, ',')); + if (tokens.size() == 4) + { + _x = std::stoi(tokens[0]); + _y = std::stoi(tokens[1]); + _width = std::stoi(tokens[2]); + _height = std::stoi(tokens[3]); + } + else + { + _x = _y = _width = _height = 0; + } + } + } // namespace Util namespace SigUtil { diff --git a/kit/ChildSession.cpp b/kit/ChildSession.cpp index 762c0c78703ad..0618e45e1b7f6 100644 --- a/kit/ChildSession.cpp +++ b/kit/ChildSession.cpp @@ -109,6 +109,7 @@ ChildSession::ChildSession(const std::shared_ptr& prot , _jailRoot(jailRoot) , _docManager(&docManager) , _viewId(-1) + , _currentPart(-1) , _isDocLoaded(false) , _copyToClipboard(false) , _canonicalViewId(-1) @@ -981,7 +982,10 @@ bool ChildSession::loadDocument(const StringVector& tokens) if (_docType != "text" && part != -1) { getLOKitDocument()->setPart(part); + _currentPart = part; } + else + _currentPart = getLOKitDocument()->getPart(); // Respond by the document status LOG_DBG("Sending status after loading view " << _viewId); @@ -2973,6 +2977,7 @@ bool ChildSession::setClientPart(const StringVector& tokens) if (getLOKitDocument()->getDocumentType() != LOK_DOCTYPE_TEXT && part != getLOKitDocument()->getPart()) { getLOKitDocument()->setPart(part); + _currentPart = part; } return true; @@ -3041,6 +3046,8 @@ bool ChildSession::moveSelectedClientParts(const StringVector& tokens) return true; // Non-fatal to fail. } + +/// Only used for writer bool ChildSession::setPage(const StringVector& tokens) { int page; @@ -3054,6 +3061,7 @@ bool ChildSession::setPage(const StringVector& tokens) getLOKitDocument()->setView(_viewId); getLOKitDocument()->setPart(page); + return true; } @@ -3412,6 +3420,7 @@ void ChildSession::loKitCallback(const int type, const std::string& payload) sendTextFrame("graphicinnertextarea: " + payload); break; case LOK_CALLBACK_CELL_CURSOR: + updateCursorPosition(payload); sendTextFrame("cellcursor: " + payload); break; case LOK_CALLBACK_CELL_FORMULA: @@ -3450,8 +3459,16 @@ void ChildSession::loKitCallback(const int type, const std::string& payload) getStatus(); break; case LOK_CALLBACK_SET_PART: + { + int part; + StringVector tokens(StringVector::tokenize(payload, ',')); + if (getTokenInteger(tokens[1], "part", part) && + getLOKitDocument()->getDocumentType() != LOK_DOCTYPE_TEXT) + _currentPart = part; + sendTextFrame("setpart: " + payload); break; + } case LOK_CALLBACK_UNO_COMMAND_RESULT: { Parser parser; diff --git a/kit/ChildSession.hpp b/kit/ChildSession.hpp index 1ef01596c72d5..5b0b001b4630b 100644 --- a/kit/ChildSession.hpp +++ b/kit/ChildSession.hpp @@ -261,6 +261,8 @@ class ChildSession final : public Session Session::dumpState(oss); oss << "\n\tviewId: " << _viewId + << "\n\tpart: " << _currentPart + << "\n\tcursor: " << _cursorPosition << "\n\tcanonicalViewId: " << _canonicalViewId << "\n\tisDocLoaded: " << _isDocLoaded << "\n\tdocType: " << _docType @@ -291,6 +293,12 @@ class ChildSession final : public Session /// View ID, returned by createView() or 0 by default. int _viewId; + /// Currently visible part + int _currentPart; + + /// Last known position of a cursor for prioritizing rendering + Util::Rectangle _cursorPosition; + /// Whether document has been opened successfully bool _isDocLoaded;