[Libreoffice-commits] online.git: 2 commits - loleaflet/src loolwsd/LOOLKit.cpp
Pranav Kant
pranavk at collabora.co.uk
Mon Aug 15 15:46:06 UTC 2016
loleaflet/src/layer/tile/TileLayer.js | 48 ++++++++++++++++++++++++++++++++++
loolwsd/LOOLKit.cpp | 14 ++++-----
2 files changed, 55 insertions(+), 7 deletions(-)
New commits:
commit 6df1c4c6f7f445bed0e3ca2c777c73cab97654b6
Author: Pranav Kant <pranavk at collabora.co.uk>
Date: Mon Aug 15 21:12:03 2016 +0530
loolwsd: fix impress; get viewid after initializeForRendering()
For impress, call to initializeForRendering() *changes* the
viewid, so there's no point in remembering the viewid before call
to initializeForRendering().
diff --git a/loolwsd/LOOLKit.cpp b/loolwsd/LOOLKit.cpp
index 4777922..e4d33df 100644
--- a/loolwsd/LOOLKit.cpp
+++ b/loolwsd/LOOLKit.cpp
@@ -1013,11 +1013,7 @@ private:
if (_multiView)
{
Log::info("Loading view to document from URI: [" + uri + "] for session [" + sessionId + "].");
- viewId = _loKitDocument->createView();
-
- Log::info() << "Document [" << _url << "] view ["
- << viewId << "] loaded, leaving "
- << (_clientViews + 1) << " views." << Log::end;
+ _loKitDocument->createView();
}
}
@@ -1027,10 +1023,14 @@ private:
if (_multiView)
{
+ viewId = _loKitDocument->getView();
_viewIdToCallbackDescr.emplace(viewId,
- std::unique_ptr<CallbackDescriptor>(new CallbackDescriptor({ this, viewId })));
-
+ std::unique_ptr<CallbackDescriptor>(new CallbackDescriptor({ this, viewId })));
_loKitDocument->registerCallback(ViewCallback, _viewIdToCallbackDescr[viewId].get());
+
+ Log::info() << "Document [" << _url << "] view ["
+ << viewId << "] loaded, leaving "
+ << (_clientViews + 1) << " views." << Log::end;
}
else
{
commit 82e1769fe8322f695160411bd3c5d0dd88eacaad
Author: Pranav Kant <pranavk at collabora.co.uk>
Date: Thu Aug 11 13:03:07 2016 +0530
loleaflet: textviewcallback support; colored text selections
diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index 5e820ff..5fd01f2 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -136,6 +136,9 @@ L.TileLayer = L.GridLayer.extend({
this._getToolbarCommandsValues();
this._selections = new L.LayerGroup();
map.addLayer(this._selections);
+ this._viewSelectionsGroup = new L.LayerGroup();
+ map.addLayer(this._viewSelectionsGroup);
+ this._viewSelections = {};
this._searchResultsLayer = new L.LayerGroup();
map.addLayer(this._searchResultsLayer);
@@ -366,6 +369,9 @@ L.TileLayer = L.GridLayer.extend({
else if (textMsg.startsWith('remallviews:')) {
this._onRemAllViewMsg(textMsg);
}
+ else if (textMsg.startsWith('textviewselection:')) {
+ this._onTextViewSelectionMsg(textMsg);
+ }
},
_onCommandValuesMsg: function (textMsg) {
@@ -789,6 +795,48 @@ L.TileLayer = L.GridLayer.extend({
this._onUpdateTextSelection();
},
+ _onTextViewSelectionMsg: function (textMsg) {
+ textMsg = textMsg.substring('textviewselection:'.length + 1);
+ var obj = JSON.parse(textMsg);
+ var viewId = parseInt(obj.viewId);
+
+ // Ignore if viewid is same as ours
+ if (viewId === this._viewId) {
+ return;
+ }
+
+ var strTwips = obj.selection.match(/\d+/g);
+ if (this._viewSelections[viewId]) {
+ this._viewSelectionsGroup.removeLayer(this._viewSelections[viewId]);
+ }
+ if (strTwips != null) {
+ var rectangles = [];
+ var selectionCenter = new L.Point(0, 0);
+ for (var i = 0; i < strTwips.length; i += 4) {
+ var topLeftTwips = new L.Point(parseInt(strTwips[i]), parseInt(strTwips[i + 1]));
+ var offset = new L.Point(parseInt(strTwips[i + 2]), parseInt(strTwips[i + 3]));
+ var topRightTwips = topLeftTwips.add(new L.Point(offset.x, 0));
+ var bottomLeftTwips = topLeftTwips.add(new L.Point(0, offset.y));
+ var bottomRightTwips = topLeftTwips.add(offset);
+ rectangles.push([bottomLeftTwips, bottomRightTwips, topLeftTwips, topRightTwips]);
+ selectionCenter = selectionCenter.add(topLeftTwips);
+ selectionCenter = selectionCenter.add(offset.divideBy(2));
+ }
+
+ var polygons = L.PolyUtil.rectanglesToPolygons(rectangles, this);
+ for (i = 0; i < polygons.length; i++) {
+ var selection = new L.Polygon(polygons[i], {
+ pointerEvents: 'none',
+ fillColor: L.LOUtil.getViewIdHexColor(viewId),
+ fillOpacity: 0.25,
+ weight: 2,
+ opacity: 0.25});
+ this._viewSelections[viewId] = selection;
+ this._viewSelectionsGroup.addLayer(selection);
+ }
+ }
+ },
+
_onTextSelectionContentMsg: function (textMsg) {
this._selectionTextContent = textMsg.substr(22);
},
More information about the Libreoffice-commits
mailing list