[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-2-0' - kit/ChildSession.cpp

2017-01-17 Thread Jan Holesovsky
 kit/ChildSession.cpp |   13 +++--
 1 file changed, 3 insertions(+), 10 deletions(-)

New commits:
commit 8b6e269faa60c2d4905bbb20d251da80cca5ac04
Author: Jan Holesovsky 
Date:   Tue Jan 17 19:15:56 2017 +0100

partpagerectangles is useless, and causes trouble for many documents.

When invoked too early after the document load, on slower servers it is
executed before the layout of the document is performed, leading to crashes.

It is useless for loleaflet, so let's disable it here, and remove it in
master for good.

Change-Id: Icf08d9df5efc8b0488c94048803e703b40f67e24

diff --git a/kit/ChildSession.cpp b/kit/ChildSession.cpp
index 13b32cd..da6e67b 100644
--- a/kit/ChildSession.cpp
+++ b/kit/ChildSession.cpp
@@ -530,16 +530,9 @@ bool ChildSession::getCommandValues(const char* 
/*buffer*/, int /*length*/, Stri
 
 bool ChildSession::getPartPageRectangles(const char* /*buffer*/, int 
/*length*/)
 {
-char* partPage = nullptr;
-{
-std::unique_lock lock(_docManager.getDocumentMutex());
-
-getLOKitDocument()->setView(_viewId);
-partPage = getLOKitDocument()->getPartPageRectangles();
-}
-
-sendTextFrame("partpagerectangles: " + std::string(partPage));
-std::free(partPage);
+// We don't support partpagerectangles any more, will be removed in the
+// next version
+sendTextFrame("partpagerectangles: ");
 return true;
 }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-2-0' - kit/ChildSession.cpp kit/ChildSession.hpp

2017-01-11 Thread Tomaž Vajngerl
 kit/ChildSession.cpp |  105 +++
 kit/ChildSession.hpp |   42 +++-
 2 files changed, 104 insertions(+), 43 deletions(-)

New commits:
commit 55769ae3eb7de33cc6afea4683e5b3f24c665278
Author: Tomaž Vajngerl 
Date:   Mon Jan 2 14:21:49 2017 +0100

Update cursor positions on active user - record events per view

When the user becomes inactive, we have to record events, that are
important to restore the user's document viewport when he becomes
active again.
We currently don't discriminate view events so events with different
view ID are considered as the same event and thus get overwritten.
The effect of this is that only the last cursor or selection of a
different view (different user working on a document) is updated
when the user becomes active again.
With this we discriminate view events and record them per view ID.
When the user becomes active again, we replay them for all views.

Change-Id: I0c6b9209f4d592d88fb23227c4de41084b8cd736
Reviewed-on: https://gerrit.libreoffice.org/32646
Reviewed-by: Jan Holesovsky 
Tested-by: Jan Holesovsky 

diff --git a/kit/ChildSession.cpp b/kit/ChildSession.cpp
index 3022344..13b32cd 100644
--- a/kit/ChildSession.cpp
+++ b/kit/ChildSession.cpp
@@ -115,20 +115,32 @@ bool ChildSession::_handleInput(const char *buffer, int 
length)
 sendTextFrame("setpart: part=" + std::to_string(curPart));
 }
 
-//TODO: Is the order of these important?
-for (const auto& pair : _lastDocEvents)
+for (const auto& viewPair : _stateRecorder._recordedViewEvents)
 {
-const auto typeName = 
LOKitHelper::kitCallbackTypeToString(pair.first);
-LOG_TRC("Replaying missed event: " << typeName << ": " << 
pair.second);
-loKitCallback(pair.first, pair.second);
+for (const auto& eventPair : viewPair.second)
+{
+const RecordedEvent& event = eventPair.second;
+LOG_TRC("Replaying missed view event: " <<  viewPair.first 
<< " " << LOKitHelper::kitCallbackTypeToString(event._type)
+<< ": " << 
event._payload);
+loKitCallback(event._type, event._payload);
+}
+}
+
+for (const auto& eventPair : _stateRecorder._recordedEvents)
+{
+const RecordedEvent& event = eventPair.second;
+LOG_TRC("Replaying missed event: " << 
LOKitHelper::kitCallbackTypeToString(event._type) << ": " << event._payload);
+loKitCallback(event._type, event._payload);
 }
 
-for (const auto& pair : _lastDocStates)
+for (const auto& pair : _stateRecorder._recordedStates)
 {
-LOG_TRC("Replaying missed state-change: STATE_CHANGED: " << 
pair.second);
+LOG_TRC("Replaying missed state-change: " << pair.second);
 loKitCallback(LOK_CALLBACK_STATE_CHANGED, pair.second);
 }
 
+_stateRecorder.clear();
+
 LOG_TRC("Finished replaying messages.");
 }
 
@@ -969,6 +981,50 @@ bool ChildSession::setPage(const char* /*buffer*/, int 
/*length*/, StringTokeniz
 return true;
 }
 
+/* If the user is inactive we have to remember important events so that when
+ * the user becomes active again, we can replay the events.
+ */
+void ChildSession::rememberEventsForInactiveUser(const int nType, const 
std::string& rPayload)
+{
+if (nType == LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR ||
+nType == LOK_CALLBACK_CURSOR_VISIBLE ||
+nType == LOK_CALLBACK_TEXT_SELECTION ||
+nType == LOK_CALLBACK_TEXT_SELECTION_START ||
+nType == LOK_CALLBACK_TEXT_SELECTION_END ||
+nType == LOK_CALLBACK_CELL_FORMULA ||
+nType == LOK_CALLBACK_CELL_CURSOR ||
+nType == LOK_CALLBACK_GRAPHIC_SELECTION ||
+nType == LOK_CALLBACK_DOCUMENT_SIZE_CHANGED)
+{
+auto lock(getLock());
+_stateRecorder.recordEvent(nType, rPayload);
+}
+else if (nType == LOK_CALLBACK_INVALIDATE_VIEW_CURSOR ||
+nType == LOK_CALLBACK_TEXT_VIEW_SELECTION ||
+nType == LOK_CALLBACK_CELL_VIEW_CURSOR ||
+nType == LOK_CALLBACK_GRAPHIC_VIEW_SELECTION ||
+nType == LOK_CALLBACK_VIEW_CURSOR_VISIBLE ||
+nType == LOK_CALLBACK_VIEW_LOCK)
+{
+auto lock(getLock());
+Poco::JSON::Parser parser;
+
+auto root = parser.parse(rPayload).extract();
+int viewId = root->getValue("viewId");
+_stateRecorder.recordViewEvent(viewId, nType, rPayload);
+}
+else if (nType == LOK_CALLBACK_STATE_CHANGED)
+{
+std::string name;
+std::string value;
+if (LOOLProtocol::parseNameValuePair(rPayload, name, value, '='))
+{
+auto lock(getLock());
+_stateRecorder.recordState(name, value);
+}
+}

[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-2-0' - kit/ChildSession.cpp

2016-12-01 Thread Henry Castro
 kit/ChildSession.cpp |   18 +-
 1 file changed, 13 insertions(+), 5 deletions(-)

New commits:
commit 800bc6befe96596471941ce9be35ce0ea6a76a2f
Author: Henry Castro 
Date:   Tue Nov 29 20:22:23 2016 -0400

kit: render font failure if and only if fails encode PNG

Change-Id: Ia082b28ed70c33b6febd0b3acd62508b7b7c5549
Reviewed-on: https://gerrit.libreoffice.org/31455
Reviewed-by: Jan Holesovsky 
Tested-by: Jan Holesovsky 

diff --git a/kit/ChildSession.cpp b/kit/ChildSession.cpp
index 4e65d3a..dc825cd 100644
--- a/kit/ChildSession.cpp
+++ b/kit/ChildSession.cpp
@@ -362,6 +362,7 @@ bool ChildSession::loadDocument(const char * /*buffer*/, 
int /*length*/, StringT
 bool ChildSession::sendFontRendering(const char* /*buffer*/, int /*length*/, 
StringTokenizer& tokens)
 {
 std::string font, text, decodedFont, decodedChar;
+bool bSuccess;
 
 if (tokens.count() < 3 ||
 !getTokenString(tokens[1], "font", font))
@@ -404,15 +405,22 @@ bool ChildSession::sendFontRendering(const char* 
/*buffer*/, int /*length*/, Str
 
 LOG_TRC("renderFont [" << font << "] rendered in " << 
(timestamp.elapsed()/1000.) << "ms");
 
-if (!ptrFont ||
-!png::encodeBufferToPNG(ptrFont, width, height, output, 
LOK_TILEMODE_RGBA))
+if (!ptrFont)
 {
-std::free(ptrFont);
-return sendTextFrame("error: cmd=renderfont kind=failure");
+return sendTextFrame(output.data(), output.size());
+}
+
+if (png::encodeBufferToPNG(ptrFont, width, height, output, 
LOK_TILEMODE_RGBA))
+{
+bSuccess = sendTextFrame(output.data(), output.size());
+}
+else
+{
+bSuccess = sendTextFrame("error: cmd=renderfont kind=failure");
 }
 
 std::free(ptrFont);
-return sendTextFrame(output.data(), output.size());
+return bSuccess;
 }
 
 bool ChildSession::getStatus(const char* /*buffer*/, int /*length*/)
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-2-0' - kit/ChildSession.cpp

2016-12-01 Thread Jan Holesovsky
 kit/ChildSession.cpp |7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

New commits:
commit 6b2e21129a0de2a1fe36f36da522738d051a0950
Author: Jan Holesovsky 
Date:   Thu Dec 1 12:25:16 2016 +0100

Don't send setpart: to text documents, it will always jump to the 1st page.

Change-Id: I809f2ba493329174a33f99d63eec2c60b38acb05
Reviewed-on: https://gerrit.libreoffice.org/31480
Reviewed-by: Andras Timar 
Tested-by: Andras Timar 

diff --git a/kit/ChildSession.cpp b/kit/ChildSession.cpp
index e12f5e3..4e65d3a 100644
--- a/kit/ChildSession.cpp
+++ b/kit/ChildSession.cpp
@@ -109,8 +109,11 @@ bool ChildSession::_handleInput(const char *buffer, int 
length)
 // Notify all views about updated view info
 _docManager.notifyViewInfo(viewIds);
 
-sendTextFrame("curpart: part=" + std::to_string(curPart));
-sendTextFrame("setpart: part=" + std::to_string(curPart));
+if (getLOKitDocument()->getDocumentType() != LOK_DOCTYPE_TEXT)
+{
+sendTextFrame("curpart: part=" + std::to_string(curPart));
+sendTextFrame("setpart: part=" + std::to_string(curPart));
+}
 
 //TODO: Is the order of these important?
 for (const auto& pair : _lastDocEvents)
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-2-0' - kit/ChildSession.cpp

2016-11-29 Thread Ashod Nakashian
 kit/ChildSession.cpp |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 64a8e7532124cb17a47bfa204fab5b0113737ac9
Author: Ashod Nakashian 
Date:   Tue Nov 29 23:13:24 2016 -0500

loolwsd: missing else

Change-Id: I37458f0a8f13764fdd4010dfd38616dd6c15eac0

diff --git a/kit/ChildSession.cpp b/kit/ChildSession.cpp
index 755e593..e12f5e3 100644
--- a/kit/ChildSession.cpp
+++ b/kit/ChildSession.cpp
@@ -1053,7 +1053,7 @@ void ChildSession::loKitCallback(const int nType, const 
std::string& rPayload)
   " width=" + std::to_string(width) +
   " height=" + std::to_string(height));
 }
-if (tokens.count() == 2 && tokens[0] == "EMPTY")
+else if (tokens.count() == 2 && tokens[0] == "EMPTY")
 {
 const std::string part = (_docType != "text" ? 
tokens[1].c_str() : "0"); // Writer renders everything as part 0.
 sendTextFrame("invalidatetiles: EMPTY, " + part);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-2-0' - kit/ChildSession.cpp

2016-11-29 Thread Ashod Nakashian
 kit/ChildSession.cpp |5 +
 1 file changed, 5 insertions(+)

New commits:
commit 12d6db8a3dcc83cfdddb20893f2ca165a448
Author: Ashod Nakashian 
Date:   Tue Nov 29 22:59:47 2016 -0500

loolwsd: Writer doesn't have parts

Fixup the part for EMPTY invalidation as well.

N.B. Should replace 'EMPTY' with '0,0,INT_MAX,INT_MAX'
to be consistent. Since both are expected, no compat
issues should be expected.

Change-Id: I066981622b1de71e9e849530df0583291b74b804
Reviewed-on: https://gerrit.libreoffice.org/31392
Reviewed-by: Ashod Nakashian 
Tested-by: Ashod Nakashian 

diff --git a/kit/ChildSession.cpp b/kit/ChildSession.cpp
index 65868cf..755e593 100644
--- a/kit/ChildSession.cpp
+++ b/kit/ChildSession.cpp
@@ -1053,6 +1053,11 @@ void ChildSession::loKitCallback(const int nType, const 
std::string& rPayload)
   " width=" + std::to_string(width) +
   " height=" + std::to_string(height));
 }
+if (tokens.count() == 2 && tokens[0] == "EMPTY")
+{
+const std::string part = (_docType != "text" ? 
tokens[1].c_str() : "0"); // Writer renders everything as part 0.
+sendTextFrame("invalidatetiles: EMPTY, " + part);
+}
 else
 {
 sendTextFrame("invalidatetiles: " + rPayload);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits