[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-3-0' - bundled/include kit/ChildSession.cpp kit/ChildSession.hpp kit/DummyLibreOfficeKit.cpp loleaflet/src wsd/ClientSession.cpp wsd/protocol.txt
Marco Cecchetti
marco.cecchetti at collabora.com
Thu Nov 30 16:30:34 UTC 2017
bundled/include/LibreOfficeKit/LibreOfficeKit.h | 3 ++
bundled/include/LibreOfficeKit/LibreOfficeKit.hxx | 13 ++++++++
kit/ChildSession.cpp | 33 ++++++++++++++++++++++
kit/ChildSession.hpp | 1
kit/DummyLibreOfficeKit.cpp | 11 +++++++
loleaflet/src/control/Control.Header.js | 16 ++++------
wsd/ClientSession.cpp | 1
wsd/protocol.txt | 6 ++++
8 files changed, 75 insertions(+), 9 deletions(-)
New commits:
commit b1366f39cd9d2bdc58a61bbeff0b79b1be7d5ce7
Author: Marco Cecchetti <marco.cecchetti at collabora.com>
Date: Wed Nov 29 00:07:05 2017 +0100
calc: set outline state
use a specific message from the client in order to set the visibility
state of a group instead of hijacking the update row/column header
message
Change-Id: I40cd44f61e91300519ea0eaf84617ff12e231025
Reviewed-on: https://gerrit.libreoffice.org/45506
Reviewed-by: Jan Holesovsky <kendy at collabora.com>
Tested-by: Jan Holesovsky <kendy at collabora.com>
diff --git a/bundled/include/LibreOfficeKit/LibreOfficeKit.h b/bundled/include/LibreOfficeKit/LibreOfficeKit.h
index 355c4457..af3355f9 100644
--- a/bundled/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/bundled/include/LibreOfficeKit/LibreOfficeKit.h
@@ -216,6 +216,9 @@ struct _LibreOfficeKitDocumentClass
/// @see lok::Document::setVisibleArea).
void (*setClientVisibleArea) (LibreOfficeKitDocument* pThis, int nX, int nY, int nWidth, int nHeight);
+ /// @see lok::Document::setOutlineState).
+ void (*setOutlineState) (LibreOfficeKitDocument* pThis, bool bColumn, int nLevel, int nIndex, bool bHidden);
+
/// @see lok::Document::createView().
int (*createView) (LibreOfficeKitDocument* pThis);
/// @see lok::Document::destroyView().
diff --git a/bundled/include/LibreOfficeKit/LibreOfficeKit.hxx b/bundled/include/LibreOfficeKit/LibreOfficeKit.hxx
index 08fbcf85..93c7e574 100644
--- a/bundled/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ b/bundled/include/LibreOfficeKit/LibreOfficeKit.hxx
@@ -447,6 +447,19 @@ public:
}
/**
+ * Show/Hide a single row/column header outline for Calc dosuments.
+ *
+ * @param bColumn - if we are dealing with a column or row group
+ * @param nLevel - the level to which the group belongs
+ * @param nIndex - the group entry index
+ * @param bHidden - the new group state (collapsed/expanded)
+ */
+ void setOutlineState(bool bColumn, int nLevel, int nIndex, bool bHidden)
+ {
+ mpDoc->pClass->setOutlineState(mpDoc, bColumn, nLevel, nIndex, bHidden);
+ }
+
+ /**
* Create a new view for an existing document.
* By default a loaded document has 1 view.
* @return the ID of the new view.
diff --git a/kit/ChildSession.cpp b/kit/ChildSession.cpp
index b540febe..ca4c855e 100644
--- a/kit/ChildSession.cpp
+++ b/kit/ChildSession.cpp
@@ -217,6 +217,7 @@ bool ChildSession::_handleInput(const char *buffer, int length)
assert(tokens[0] == "clientzoom" ||
tokens[0] == "clientvisiblearea" ||
+ tokens[0] == "outlinestate" ||
tokens[0] == "downloadas" ||
tokens[0] == "getchildid" ||
tokens[0] == "gettextselection" ||
@@ -243,6 +244,10 @@ bool ChildSession::_handleInput(const char *buffer, int length)
{
return clientVisibleArea(buffer, length, tokens);
}
+ else if (tokens[0] == "outlinestate")
+ {
+ return outlineState(buffer, length, tokens);
+ }
else if (tokens[0] == "downloadas")
{
return downloadAs(buffer, length, tokens);
@@ -592,6 +597,34 @@ bool ChildSession::clientVisibleArea(const char* /*buffer*/, int /*length*/, con
return true;
}
+bool ChildSession::outlineState(const char* /*buffer*/, int /*length*/, const std::vector<std::string>& tokens)
+{
+ std::string type, state;
+ int level, index;
+
+ if (tokens.size() != 5 ||
+ !getTokenString(tokens[1], "type", type) ||
+ (type != "column" && type != "row") ||
+ !getTokenInteger(tokens[2], "level", level) ||
+ !getTokenInteger(tokens[3], "index", index) ||
+ !getTokenString(tokens[4], "state", state) ||
+ (state != "visible" && state != "hidden"))
+ {
+ sendTextFrame("error: cmd=outlinestate kind=syntax");
+ return false;
+ }
+
+ bool column = type == "column";
+ bool hidden = state == "hidden";
+
+ std::unique_lock<std::mutex> lock(_docManager.getDocumentMutex());
+
+ getLOKitDocument()->setView(_viewId);
+
+ getLOKitDocument()->setOutlineState(column, level, index, hidden);
+ return true;
+}
+
bool ChildSession::downloadAs(const char* /*buffer*/, int /*length*/, const std::vector<std::string>& tokens)
{
std::string name, id, format, filterOptions;
diff --git a/kit/ChildSession.hpp b/kit/ChildSession.hpp
index b5b9209c..ad9486a2 100644
--- a/kit/ChildSession.hpp
+++ b/kit/ChildSession.hpp
@@ -182,6 +182,7 @@ private:
bool clientZoom(const char* buffer, int length, const std::vector<std::string>& tokens);
bool clientVisibleArea(const char* buffer, int length, const std::vector<std::string>& tokens);
+ bool outlineState(const char* buffer, int length, const std::vector<std::string>& tokens);
bool downloadAs(const char* buffer, int length, const std::vector<std::string>& tokens);
bool getChildId();
bool getTextSelection(const char* buffer, int length, const std::vector<std::string>& tokens);
diff --git a/kit/DummyLibreOfficeKit.cpp b/kit/DummyLibreOfficeKit.cpp
index 891ac6ed..55f4e0ce 100644
--- a/kit/DummyLibreOfficeKit.cpp
+++ b/kit/DummyLibreOfficeKit.cpp
@@ -106,6 +106,7 @@ static void doc_setClientZoom(LibreOfficeKitDocument* pThis,
int nTileTwipWidth,
int nTileTwipHeight);
static void doc_setClientVisibleArea(LibreOfficeKitDocument* pThis, int nX, int nY, int nWidth, int nHeight);
+static void doc_setOutlineState(LibreOfficeKitDocument* pThis, bool bColumn, int nLevel, int nIndex, bool bHidden);
static int doc_createView(LibreOfficeKitDocument* pThis);
static void doc_destroyView(LibreOfficeKitDocument* pThis, int nId);
static void doc_setView(LibreOfficeKitDocument* pThis, int nId);
@@ -153,6 +154,7 @@ LibLODocument_Impl::LibLODocument_Impl()
m_pDocumentClass->getCommandValues = doc_getCommandValues;
m_pDocumentClass->setClientZoom = doc_setClientZoom;
m_pDocumentClass->setClientVisibleArea = doc_setClientVisibleArea;
+ m_pDocumentClass->setOutlineState = doc_setOutlineState;
m_pDocumentClass->createView = doc_createView;
m_pDocumentClass->destroyView = doc_destroyView;
@@ -464,6 +466,15 @@ static void doc_setClientVisibleArea(LibreOfficeKitDocument* pThis, int nX, int
(void) nHeight;
}
+static void doc_setOutlineState(LibreOfficeKitDocument* pThis, bool bColumn, int nLevel, int nIndex, bool bHidden)
+{
+ (void) pThis;
+ (void) bColumn;
+ (void) nLevel;
+ (void) nIndex;
+ (void) bHidden;
+}
+
static int doc_createView(LibreOfficeKitDocument* /*pThis*/)
{
return 1;
diff --git a/loleaflet/src/control/Control.Header.js b/loleaflet/src/control/Control.Header.js
index 6dac7330..3da83248 100644
--- a/loleaflet/src/control/Control.Header.js
+++ b/loleaflet/src/control/Control.Header.js
@@ -382,15 +382,13 @@ L.Control.Header = L.Control.extend({
},
_updateOutlineState: function (column, group) {
- var e = {
- x: this._map._getTopLeftPoint().x,
- y: this._map._getTopLeftPoint().y,
- offset: {x: undefined, y: undefined},
- outline: {column: column, level: group.level, index: group.index, hidden: !group.hidden}
- };
- this._map.fire('updaterowcolumnheaders', e);
- // TODO do we need this ?
- //this._map._socket.sendMessage('commandvalues command=.uno:ViewAnnotationsPosition');
+ if (!group)
+ return;
+
+ var type = column ? 'column' : 'row';
+ var state = group.hidden ? 'visible' : 'hidden'; // we have to send the new state
+ var payload = 'outlinestate type='+ type + ' level=' + group.level + ' index=' + group.index + ' state=' + state;
+ this._map._socket.sendMessage(payload);
},
_onMouseDown: function (e) {
diff --git a/wsd/ClientSession.cpp b/wsd/ClientSession.cpp
index d7f6f1fc..663a55fc 100644
--- a/wsd/ClientSession.cpp
+++ b/wsd/ClientSession.cpp
@@ -126,6 +126,7 @@ bool ClientSession::_handleInput(const char *buffer, int length)
else if (tokens[0] != "canceltiles" &&
tokens[0] != "clientzoom" &&
tokens[0] != "clientvisiblearea" &&
+ tokens[0] != "outlinestate" &&
tokens[0] != "commandvalues" &&
tokens[0] != "closedocument" &&
tokens[0] != "downloadas" &&
diff --git a/wsd/protocol.txt b/wsd/protocol.txt
index 3af10f64..bb871d81 100644
--- a/wsd/protocol.txt
+++ b/wsd/protocol.txt
@@ -177,6 +177,12 @@ clientvisiblearea x=<x> y=<y> width=<width> height=<height>
Invokes lok::Document::setClientVisibleArea().
+outlinestate type=<type> level=<level> index=<index> state=<state>
+
+ <type> is 'column' or 'row', <level> and <index> are numbers, <state> is 'visible' or 'hidden'.
+
+ Invokes lok::Document::setOutlineState().
+
useractive
Sent when the user regains focus or clicks within the active area to
More information about the Libreoffice-commits
mailing list