loleaflet/src/layer/tile/TileLayer.js | 72 ++++++++++- loolwsd/LOKitClient.cpp | 1 loolwsd/LOOLSession.cpp | 5 loolwsd/bundled/include/LibreOfficeKit/LibreOfficeKitEnums.h | 9 + 4 files changed, 84 insertions(+), 3 deletions(-)
New commits: commit 96965bec95370e595eb213ed76e8c10ea5c47556 Author: Andrzej Hunt <andrzej.h...@collabora.com> Date: Thu Nov 5 09:57:29 2015 +0100 loleaflet: update .uno:CellCursor parameter format This mirrors the parameter format for .uno:ViewRowColumnHeaders diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js index 60fadd9..3cdf098 100644 --- a/loleaflet/src/layer/tile/TileLayer.js +++ b/loleaflet/src/layer/tile/TileLayer.js @@ -943,11 +943,11 @@ L.TileLayer = L.GridLayer.extend({ // hence we need to request an updated cell cursor position for this level. _onCellCursorShift: function (bForce) { if (this._cellCursorMarker || bForce) { - L.Socket.sendMessage('commandvalues command=.uno:CellCursor:' - + '' + this._tileSize + ',' - + '' + this._tileSize + ',' - + '' + this._tileWidthTwips + ',' - + '' + this._tileHeightTwips ); + L.Socket.sendMessage('commandvalues command=.uno:CellCursor' + + '?outputHeight=' + this._tileSize + + '&outputWidth=' + this._tileSize + + '&tileHeight=' + this._tileWidthTwips + + '&tileWidth=' + this._tileHeightTwips ); } }, commit d9d0d47514fef09d0606abcf7dc48b6b977c8987 Author: Andrzej Hunt <andrzej.h...@collabora.com> Date: Wed Nov 4 15:44:29 2015 +0100 loleaflet: tdf#94605 Show cell cursor diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js index 6dc4d1f..60fadd9 100644 --- a/loleaflet/src/layer/tile/TileLayer.js +++ b/loleaflet/src/layer/tile/TileLayer.js @@ -66,6 +66,10 @@ L.TileLayer = L.GridLayer.extend({ this._graphicSelectionTwips = new L.bounds(new L.point(0, 0), new L.point(0, 0)); // Rectangle graphic selection this._graphicSelection = new L.LatLngBounds(new L.LatLng(0, 0), new L.LatLng(0, 0)); + // Original rectangle of cell cursor in twips + this._cellCursorTwips = new L.bounds(new L.point(0, 0), new L.point(0, 0)); + // Rectangle for cell cursor + this._cellCursor = new L.LatLngBounds(new L.LatLng(0, 0), new L.LatLng(0, 0)); // Position and size of the selection start (as if there would be a cursor caret there). this._lastValidPart = -1; @@ -110,10 +114,21 @@ L.TileLayer = L.GridLayer.extend({ map.on('paste', this._onPaste, this); map.on('zoomend', this._onUpdateCursor, this); map.on('zoomend', this._onUpdatePartPageRectangles, this); + map.on('zoomend', this._onCellCursorShift, this); map.on('dragstart', this._onDragStart, this); map.on('requestloksession', this._onRequestLOKSession, this); map.on('error', this._mapOnError, this); map.on('resize', this._fitDocumentHorizontally, this); + // Retrieve the initial cell cursor position (as LOK only sends us an + // updated cell cursor when the selected cell is changed and not the initial + // cell). + map.on('statusindicator', + function (e) { + if (e.statusType === 'alltilesloaded') { + this._onCellCursorShift(true); + } + }, + this); for (var key in this._selectionHandles) { this._selectionHandles[key].on('drag dragend', this._onSelectionHandleDrag, this); } @@ -204,6 +219,9 @@ L.TileLayer = L.GridLayer.extend({ else if (textMsg.startsWith('graphicselection:')) { this._onGraphicSelectionMsg(textMsg); } + else if (textMsg.startsWith('cellcursor:')) { + this._onCellCursorMsg(textMsg); + } else if (textMsg.startsWith('hyperlinkclicked:')) { this._onHyperlinkClickedMsg(textMsg); } @@ -264,7 +282,9 @@ L.TileLayer = L.GridLayer.extend({ _onCommandValuesMsg: function (textMsg) { var obj = JSON.parse(textMsg.substring(textMsg.indexOf('{'))); - if (this._map.unoToolbarCommands.indexOf(obj.commandName) !== -1) { + if (obj.commandName === ".uno:CellCursor") { + this._onCellCursorMsg(obj.commandValues); + } else if (this._map.unoToolbarCommands.indexOf(obj.commandName) !== -1) { this._toolbarCommandValues[obj.commandName] = obj.commandValues; this._map.fire('updatetoolbarcommandvalues', { commandName: obj.commandName, @@ -335,6 +355,25 @@ L.TileLayer = L.GridLayer.extend({ this._onUpdateGraphicSelection(); }, + _onCellCursorMsg: function (textMsg) { + if (textMsg.match('EMPTY')) { + this._cellCursorTwips = new L.bounds(new L.point(0, 0), new L.point(0, 0)); + this._cellCursor = new L.LatLngBounds(new L.LatLng(0, 0), new L.LatLng(0, 0)); + } + else { + var strTwips = textMsg.match(/\d+/g); + var topLeftTwips = new L.Point(parseInt(strTwips[0]), parseInt(strTwips[1])); + var offset = new L.Point(parseInt(strTwips[2]), parseInt(strTwips[3])); + var bottomRightTwips = topLeftTwips.add(offset); + this._cellCursorTwips = new L.bounds(topLeftTwips, bottomRightTwips); + this._cellCursor = new L.LatLngBounds( + this._twipsToLatLng(topLeftTwips, this._map.getZoom()), + this._twipsToLatLng(bottomRightTwips, this._map.getZoom())); + } + + this._onUpdateCellCursor(); + }, + _onHyperlinkClickedMsg: function (textMsg) { var link = textMsg.substring(18); window.open(link, '_blank'); @@ -579,6 +618,8 @@ L.TileLayer = L.GridLayer.extend({ // hide the graphic selection this._graphicSelection = null; this._onUpdateGraphicSelection(); + this._cellCursor = null; + this._onUpdateCellCursor(); }, _postMouseEvent: function(type, x, y, count, buttons, modifier) { @@ -735,6 +776,23 @@ L.TileLayer = L.GridLayer.extend({ } }, + _onUpdateCellCursor: function () { + if (this._cellCursor && !this._isEmptyRectangle(this._cellCursor)) { + if (this._cellCursorMarker) { + this._map.removeLayer(this._cellCursorMarker); + } + this._cellCursorMarker = L.rectangle(this._cellCursor, {fill: false, color: "#000000", weight: 2}); + if (!this._cellCursorMarker) { + this._map.fire('error', {msg: 'Cell Cursor marker initialization'}); + return; + } + this._map.addLayer(this._cellCursorMarker); + } + else if (this._cellCursor) { + this._map.removeLayer(this._cellCursorMarker); + } + }, + // Update text selection handlers. _onUpdateTextSelection: function () { var startMarker, endMarker; @@ -881,6 +939,18 @@ L.TileLayer = L.GridLayer.extend({ } }, + // Cells can change position during changes of zoom level in calc + // hence we need to request an updated cell cursor position for this level. + _onCellCursorShift: function (bForce) { + if (this._cellCursorMarker || bForce) { + L.Socket.sendMessage('commandvalues command=.uno:CellCursor:' + + '' + this._tileSize + ',' + + '' + this._tileSize + ',' + + '' + this._tileWidthTwips + ',' + + '' + this._tileHeightTwips ); + } + }, + _invalidatePreviews: function () { if (this._map._docPreviews && this._previewInvalidations.length > 0) { var toInvalidate = {}; commit ab5b41b74017fbea7b135ff41cec8175c8db7eb8 Author: Andrzej Hunt <andrzej.h...@collabora.com> Date: Wed Nov 4 13:38:32 2015 +0100 loolwsd: use length here too diff --git a/loolwsd/LOOLSession.cpp b/loolwsd/LOOLSession.cpp index d1d3d9e..8b6da93 100644 --- a/loolwsd/LOOLSession.cpp +++ b/loolwsd/LOOLSession.cpp @@ -234,7 +234,7 @@ bool MasterProcessSession::handleInput(const char *buffer, int length) } else if (tokens[0] == "commandvalues:") { - std::string stringMsg(buffer); + std::string stringMsg(buffer, length); std::string stringJSON = stringMsg.substr(stringMsg.find_first_of("{")); Parser parser; Var result = parser.parse(stringJSON); commit 09e823e750a98a5cd7d504c4558016f8ce1b935b Author: Andrzej Hunt <andrzej.h...@collabora.com> Date: Mon Nov 2 14:09:25 2015 +0100 loolwsd: tdf#94605 handle LOK_CALLBACK_CELL_CURSOR diff --git a/loolwsd/LOKitClient.cpp b/loolwsd/LOKitClient.cpp index 1e912af..481c3be 100644 --- a/loolwsd/LOKitClient.cpp +++ b/loolwsd/LOKitClient.cpp @@ -51,6 +51,7 @@ extern "C" CASE(TEXT_SELECTION_END); CASE(CURSOR_VISIBLE); CASE(GRAPHIC_SELECTION); + CASE(CELL_CURSOR); CASE(HYPERLINK_CLICKED); CASE(STATE_CHANGED); CASE(STATUS_INDICATOR_START); diff --git a/loolwsd/LOOLSession.cpp b/loolwsd/LOOLSession.cpp index 32b4b9f..d1d3d9e 100644 --- a/loolwsd/LOOLSession.cpp +++ b/loolwsd/LOOLSession.cpp @@ -868,6 +868,9 @@ extern "C" case LOK_CALLBACK_GRAPHIC_SELECTION: srv->sendTextFrame("graphicselection: " + std::string(pPayload)); break; + case LOK_CALLBACK_CELL_CURSOR: + srv->sendTextFrame("cellcursor: " + std::string(pPayload)); + break; case LOK_CALLBACK_HYPERLINK_CLICKED: srv->sendTextFrame("hyperlinkclicked: " + std::string(pPayload)); break; commit b46bc1bcf6200c1ce2df7cbadbddc6c28695a101 Author: Andrzej Hunt <andrzej.h...@collabora.com> Date: Mon Nov 2 14:05:29 2015 +0100 loolwsd: update the bundled headers diff --git a/loolwsd/bundled/include/LibreOfficeKit/LibreOfficeKitEnums.h b/loolwsd/bundled/include/LibreOfficeKit/LibreOfficeKitEnums.h index 86d9e6b..bf62675 100644 --- a/loolwsd/bundled/include/LibreOfficeKit/LibreOfficeKitEnums.h +++ b/loolwsd/bundled/include/LibreOfficeKit/LibreOfficeKitEnums.h @@ -195,7 +195,14 @@ typedef enum * // TODO "result": "..." // UNO Any converted to JSON (not implemented yet) * } */ - LOK_CALLBACK_UNO_COMMAND_RESULT + LOK_CALLBACK_UNO_COMMAND_RESULT, + + /** + * The size and/or the position of the cell cursor changed. + * + * Rectangle format is the same as LOK_CALLBACK_INVALIDATE_TILES. + */ + LOK_CALLBACK_CELL_CURSOR } LibreOfficeKitCallbackType; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits