Draw reference marks for formulas
(cherry picked from commit fd1b3b2a744388309fbbbcb73b2060183780109e) Change-Id: I3e361bd94cd6e0664e96494504064c2505c30774
This commit is contained in:
parent
9276ac2da1
commit
d712d97e3c
4 changed files with 88 additions and 2 deletions
|
@ -2111,7 +2111,8 @@ void ChildSession::rememberEventsForInactiveUser(const int type, const std::stri
|
|||
type == LOK_CALLBACK_GRAPHIC_SELECTION ||
|
||||
type == LOK_CALLBACK_DOCUMENT_SIZE_CHANGED ||
|
||||
type == LOK_CALLBACK_INVALIDATE_HEADER ||
|
||||
type == LOK_CALLBACK_CELL_ADDRESS)
|
||||
type == LOK_CALLBACK_CELL_ADDRESS ||
|
||||
type == LOK_CALLBACK_REFERENCE_MARKS)
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(getLock());
|
||||
_stateRecorder.recordEvent(type, payload);
|
||||
|
@ -2400,7 +2401,7 @@ void ChildSession::loKitCallback(const int type, const std::string& payload)
|
|||
sendTextFrame("tableselected: " + payload);
|
||||
break;
|
||||
case LOK_CALLBACK_REFERENCE_MARKS:
|
||||
// TODO
|
||||
sendTextFrame("referencemarks: " + payload);
|
||||
break;
|
||||
case LOK_CALLBACK_JSDIALOG:
|
||||
sendTextFrame("jsdialog: " + payload);
|
||||
|
|
|
@ -165,6 +165,7 @@ L.Control.Tabs = L.Control.extend({
|
|||
_setPart: function (e) {
|
||||
var part = e.target.id.match(/\d+/g)[0];
|
||||
if (part !== null) {
|
||||
this._map._docLayer._clearReferences();
|
||||
this._map.setPart(parseInt(part), /*external:*/ false, /*calledFromSetPartHandler:*/ true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ L.Map.include({
|
|||
}
|
||||
else if (typeof (part) === 'number' && part >= 0 && part < docLayer._parts) {
|
||||
docLayer._selectedPart = part;
|
||||
docLayer._updateReferenceMarks();
|
||||
}
|
||||
else {
|
||||
return;
|
||||
|
|
|
@ -25,6 +25,24 @@ function hex2string(inData)
|
|||
return hexified.join('');
|
||||
}
|
||||
|
||||
function marksAreEqual(mark1, mark2)
|
||||
{
|
||||
return mark1._bounds._northEast.lat == mark2._bounds._northEast.lat
|
||||
&& mark1._bounds._northEast.lng == mark2._bounds._northEast.lng
|
||||
&& mark1._bounds._southWest.lat == mark2._bounds._southWest.lat
|
||||
&& mark1._bounds._southWest.lng == mark2._bounds._southWest.lng;
|
||||
}
|
||||
|
||||
function hasMark(collection, mark)
|
||||
{
|
||||
for (var i = 0; i < collection.length; i++) {
|
||||
if (marksAreEqual(mark, collection[i])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
L.TileLayer = L.GridLayer.extend({
|
||||
|
||||
options: {
|
||||
|
@ -179,8 +197,10 @@ L.TileLayer = L.GridLayer.extend({
|
|||
this._initContainer();
|
||||
this._getToolbarCommandsValues();
|
||||
this._selections = new L.LayerGroup();
|
||||
this._references = new L.LayerGroup();
|
||||
if (this.options.permission !== 'readonly') {
|
||||
map.addLayer(this._selections);
|
||||
map.addLayer(this._references);
|
||||
}
|
||||
|
||||
// This layergroup contains all the layers corresponding to other's view
|
||||
|
@ -415,6 +435,12 @@ L.TileLayer = L.GridLayer.extend({
|
|||
else if (textMsg.startsWith('cellformula:')) {
|
||||
this._onCellFormulaMsg(textMsg);
|
||||
}
|
||||
else if (textMsg.startsWith('referencemarks:')) {
|
||||
this._onReferencesMsg(textMsg);
|
||||
}
|
||||
else if (textMsg.startsWith('referenceclear:')) {
|
||||
this._clearReferences();
|
||||
}
|
||||
else if (textMsg.startsWith('hyperlinkclicked:')) {
|
||||
this._onHyperlinkClickedMsg(textMsg);
|
||||
}
|
||||
|
@ -1348,6 +1374,59 @@ L.TileLayer = L.GridLayer.extend({
|
|||
this._onUpdateTextViewSelection(viewId);
|
||||
},
|
||||
|
||||
_updateReferenceMarks: function() {
|
||||
this._clearReferences();
|
||||
for (var i = 0; i < this._referencesAll.length; i++) {
|
||||
// Avoid doubed marks, add only marks for current sheet
|
||||
if ((this._references == null || !hasMark(this._references.getLayers(), this._referencesAll[i].mark))
|
||||
&& this._selectedPart === this._referencesAll[i].part) {
|
||||
this._references.addLayer(this._referencesAll[i].mark);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
_onReferencesMsg: function (textMsg) {
|
||||
textMsg = textMsg.substr(textMsg.indexOf(' ') + 1);
|
||||
var marks = JSON.parse(textMsg);
|
||||
marks = marks.marks;
|
||||
var references = [];
|
||||
this._referencesAll = [];
|
||||
|
||||
for (var mark = 0; mark < marks.length; mark++) {
|
||||
var strTwips = marks[mark].rectangle.match(/\d+/g);
|
||||
var strColor = marks[mark].color;
|
||||
var part = parseInt(marks[mark].part);
|
||||
|
||||
if (strTwips != null) {
|
||||
var rectangles = [];
|
||||
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]);
|
||||
}
|
||||
|
||||
var polygons = L.PolyUtil.rectanglesToPolygons(rectangles, this);
|
||||
var reference = new L.Polygon(polygons, {
|
||||
pointerEvents: 'none',
|
||||
fillColor: '#' + strColor,
|
||||
fillOpacity: 0.25,
|
||||
weight: 2,
|
||||
opacity: 0.25});
|
||||
|
||||
references.push({mark: reference, part: part});
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < references.length; i++) {
|
||||
this._referencesAll.push(references[i]);
|
||||
}
|
||||
|
||||
this._updateReferenceMarks();
|
||||
},
|
||||
|
||||
_onTextSelectionContentMsg: function (textMsg) {
|
||||
this._selectionTextContent = textMsg.substr(22);
|
||||
this._map._clipboardContainer.setValue(this._selectionTextContent);
|
||||
|
@ -1671,6 +1750,10 @@ L.TileLayer = L.GridLayer.extend({
|
|||
return ret;
|
||||
},
|
||||
|
||||
_clearReferences: function () {
|
||||
this._references.clearLayers();
|
||||
},
|
||||
|
||||
_postMouseEvent: function(type, x, y, count, buttons, modifier) {
|
||||
|
||||
this._sendClientZoom();
|
||||
|
|
Loading…
Reference in a new issue