Replace _textSelectionStart and _textSelectionEnd with SimpleRectangle(s).
Also move them into their sections. Signed-off-by: Gökay Şatır <gokaysatir@collabora.com> Change-Id: I677a100c859ac8986f5609d9caa5187ef81818ddpull/9012/head
parent
b9e7d071a2
commit
ecdcc369d6
|
@ -3509,17 +3509,16 @@ L.CanvasTileLayer = L.Layer.extend({
|
||||||
if (rectangles.length) {
|
if (rectangles.length) {
|
||||||
var topLeftTwips = rectangles[0].getTopLeft();
|
var topLeftTwips = rectangles[0].getTopLeft();
|
||||||
var bottomRightTwips = rectangles[0].getBottomRight();
|
var bottomRightTwips = rectangles[0].getBottomRight();
|
||||||
var oldSelection = this._textSelectionEnd;
|
var oldSelection = this._selectionHandles.end.rectangle ? this._selectionHandles.end.rectangle.clone(): null;
|
||||||
this._textSelectionEnd = new L.LatLngBounds(
|
|
||||||
this._twipsToLatLng(topLeftTwips, this._map.getZoom()),
|
|
||||||
this._twipsToLatLng(bottomRightTwips, this._map.getZoom()));
|
|
||||||
|
|
||||||
this._updateScrollOnCellSelection(oldSelection, this._textSelectionEnd);
|
this._selectionHandles.end.rectangle = new app.definitions.simpleRectangle(topLeftTwips.x, topLeftTwips.y, (bottomRightTwips.x - topLeftTwips.x), (bottomRightTwips.y - topLeftTwips.y));
|
||||||
|
|
||||||
|
this._updateScrollOnCellSelection(oldSelection, this._selectionHandles.end.rectangle);
|
||||||
this._selectionHandles.end.setShowSection(true);
|
this._selectionHandles.end.setShowSection(true);
|
||||||
this._updateMarkers();
|
this._updateMarkers();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this._textSelectionEnd = null;
|
this._selectionHandles.end.rectangle = null;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -3529,21 +3528,19 @@ L.CanvasTileLayer = L.Layer.extend({
|
||||||
if (rectangles.length) {
|
if (rectangles.length) {
|
||||||
var topLeftTwips = rectangles[0].getTopLeft();
|
var topLeftTwips = rectangles[0].getTopLeft();
|
||||||
var bottomRightTwips = rectangles[0].getBottomRight();
|
var bottomRightTwips = rectangles[0].getBottomRight();
|
||||||
var oldSelection = this._textSelectionStart;
|
let oldSelection = this._selectionHandles.start.rectangle ? this._selectionHandles.start.rectangle.clone(): null;
|
||||||
//FIXME: The selection is really not two points, as they can be
|
//FIXME: The selection is really not two points, as they can be
|
||||||
//FIXME: on top of each other, but on separate lines. We should
|
//FIXME: on top of each other, but on separate lines. We should
|
||||||
//FIXME: capture the whole area in _onTextSelectionMsg.
|
//FIXME: capture the whole area in _onTextSelectionMsg.
|
||||||
this._textSelectionStart = new L.LatLngBounds(
|
this._selectionHandles.start.rectangle = new app.definitions.simpleRectangle(topLeftTwips.x, topLeftTwips.y, (bottomRightTwips.x - topLeftTwips.x), (bottomRightTwips.y - topLeftTwips.y));
|
||||||
this._twipsToLatLng(topLeftTwips, this._map.getZoom()),
|
|
||||||
this._twipsToLatLng(bottomRightTwips, this._map.getZoom()));
|
|
||||||
|
|
||||||
this._updateScrollOnCellSelection(oldSelection, this._textSelectionStart);
|
this._updateScrollOnCellSelection(oldSelection, this._selectionHandles.start.rectangle);
|
||||||
|
|
||||||
this._selectionHandles.start.setShowSection(true);
|
this._selectionHandles.start.setShowSection(true);
|
||||||
this._selectionHandles.active = true;
|
this._selectionHandles.active = true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this._textSelectionStart = null;
|
this._selectionHandles.start.rectangle = null;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -4788,8 +4785,8 @@ L.CanvasTileLayer = L.Layer.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
_removeSelection: function() {
|
_removeSelection: function() {
|
||||||
this._textSelectionStart = null;
|
this._selectionHandles.start.rectangle = null;
|
||||||
this._textSelectionEnd = null;
|
this._selectionHandles.end.rectangle = null;
|
||||||
this._selectedTextContent = '';
|
this._selectedTextContent = '';
|
||||||
|
|
||||||
this._selectionHandles.start.setShowSection(false);
|
this._selectionHandles.start.setShowSection(false);
|
||||||
|
@ -4800,14 +4797,14 @@ L.CanvasTileLayer = L.Layer.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
_updateMarkers: function() {
|
_updateMarkers: function() {
|
||||||
if (!app.file.textCursor.visible || !this._textSelectionStart)
|
if (!app.file.textCursor.visible || !this._selectionHandles.start.rectangle)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!this._selectionHandles.start.isSectionShown() || !this._selectionHandles.end.isSectionShown())
|
if (!this._selectionHandles.start.isSectionShown() || !this._selectionHandles.end.isSectionShown())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var startPos = this._map._docLayer._latLngToCorePixels(this._textSelectionStart.getSouthWest());
|
var startPos = { x: this._selectionHandles.start.rectangle.pX1, y: this._selectionHandles.start.rectangle.pY2 };
|
||||||
var endPos = this._map._docLayer._latLngToCorePixels(this._textSelectionEnd.getSouthWest());
|
var endPos = { x: this._selectionHandles.end.rectangle.pX1, y: this._selectionHandles.end.rectangle.pY2 };
|
||||||
|
|
||||||
if (app.map._docLayer.isCalcRTL()) {
|
if (app.map._docLayer.isCalcRTL()) {
|
||||||
// Mirror position from right to left.
|
// Mirror position from right to left.
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class TextSelectionHandle extends HTMLObjectSection {
|
class TextSelectionHandle extends HTMLObjectSection {
|
||||||
|
public rectangle: cool.SimpleRectangle = null; // This is the rectangle sent from the core side.
|
||||||
|
|
||||||
constructor (sectionName: string, objectWidth: number, objectHeight: number, documentPosition: cool.SimplePoint, extraClass: string = "", visible: boolean = true) {
|
constructor (sectionName: string, objectWidth: number, objectHeight: number, documentPosition: cool.SimplePoint, extraClass: string = "", visible: boolean = true) {
|
||||||
super(sectionName, objectWidth, objectHeight, documentPosition, extraClass, visible);
|
super(sectionName, objectWidth, objectHeight, documentPosition, extraClass, visible);
|
||||||
|
|
|
@ -278,10 +278,13 @@ L.Map.TouchGesture = L.Handler.extend({
|
||||||
if (app.calc.cellCursorVisible)
|
if (app.calc.cellCursorVisible)
|
||||||
bContainsSel = docLayer.containsSelection(latlng);
|
bContainsSel = docLayer.containsSelection(latlng);
|
||||||
var textSelection;
|
var textSelection;
|
||||||
if (docLayer._textSelectionStart && docLayer._textSelectionEnd)
|
if (docLayer._selectionHandles.start.rectangle && docLayer._selectionHandles.end.rectangle) {
|
||||||
textSelection = new L.LatLngBounds(docLayer._textSelectionStart.getSouthWest(), docLayer._textSelectionEnd.getNorthEast());
|
// Oversimplication. See "inBand" function.
|
||||||
|
textSelection = new app.definitions.simpleRectangle(0, docLayer._selectionHandles.end.rectangle.y1, app.file.size.twips[0], 0);
|
||||||
|
textSelection.height = docLayer._selectionHandles.end.rectangle.y2 - docLayer._selectionHandles.start.rectangle.y1;
|
||||||
|
}
|
||||||
|
|
||||||
if ((textSelection && textSelection.inBand(latlng))
|
if ((textSelection && textSelection.pContainsPoint(posInTwips.toArray()))
|
||||||
|| (graphicSelection && graphicSelection.contains(latlng))
|
|| (graphicSelection && graphicSelection.contains(latlng))
|
||||||
|| (app.calc.cellCursorVisible && app.calc.cellCursorRectangle.containsPoint(posInTwips.toArray())) || bContainsSel) {
|
|| (app.calc.cellCursorVisible && app.calc.cellCursorRectangle.containsPoint(posInTwips.toArray())) || bContainsSel) {
|
||||||
// long touched an already selected object
|
// long touched an already selected object
|
||||||
|
|
Loading…
Reference in New Issue