Commit a2f41d6d authored by Alexey.Musinov's avatar Alexey.Musinov

[mobile] select cells

parent edcaa667
...@@ -3180,7 +3180,7 @@ function OfflineEditor () { ...@@ -3180,7 +3180,7 @@ function OfflineEditor () {
AscCommonExcel.WorksheetView.prototype.__selection = function (c1, r1, c2, r2, isFrozen) { AscCommonExcel.WorksheetView.prototype.__selection = function (c1, r1, c2, r2, isFrozen) {
var native_selection = []; var selection = [];
var range = undefined; var range = undefined;
...@@ -3198,15 +3198,15 @@ function OfflineEditor () { ...@@ -3198,15 +3198,15 @@ function OfflineEditor () {
var activeCell = this.model.selectionRange.activeCell; var activeCell = this.model.selectionRange.activeCell;
native_selection.push(activeCell.col); selection.push(activeCell.col);
native_selection.push(activeCell.col); selection.push(activeCell.col);
native_selection.push(activeCell.row); selection.push(activeCell.row);
native_selection.push(activeCell.row); selection.push(activeCell.row);
native_selection.push(this.cols[activeCell.col].left - offsetX); selection.push(this.cols[activeCell.col].left - offsetX);
native_selection.push(this.rows[activeCell.row].top - offsetY); selection.push(this.rows[activeCell.row].top - offsetY);
native_selection.push(this.cols[activeCell.col].left + this.cols[activeCell.col].width - this.cols[activeCell.col].left); selection.push(this.cols[activeCell.col].left + this.cols[activeCell.col].width - this.cols[activeCell.col].left);
native_selection.push(this.rows[activeCell.row].top + this.rows[activeCell.row].height - this.rows[activeCell.row].top); selection.push(this.rows[activeCell.row].top + this.rows[activeCell.row].height - this.rows[activeCell.row].top);
var ranges = (this.isSelectionDialogMode ? this.copyActiveRange : this.model.selectionRange).ranges; var ranges = (this.isSelectionDialogMode ? this.copyActiveRange : this.model.selectionRange).ranges;
var range, selectionLineType; var range, selectionLineType;
...@@ -3221,79 +3221,83 @@ function OfflineEditor () { ...@@ -3221,79 +3221,83 @@ function OfflineEditor () {
range.c2 = this.cols.length - 1; range.c2 = this.cols.length - 1;
} }
native_selection.push(range.type); selection.push(range.type);
native_selection.push(range.c1); selection.push(range.c1);
native_selection.push(range.c2); selection.push(range.c2);
native_selection.push(range.r1); selection.push(range.r1);
native_selection.push(range.r2); selection.push(range.r2);
native_selection.push(this.cols[range.c1].left - offsetX); selection.push(this.cols[range.c1].left - offsetX);
native_selection.push(this.rows[range.r1].top - offsetY); selection.push(this.rows[range.r1].top - offsetY);
native_selection.push(this.cols[range.c2].left + this.cols[range.c2].width - this.cols[range.c1].left); selection.push(this.cols[range.c2].left + this.cols[range.c2].width - this.cols[range.c1].left);
native_selection.push(this.rows[range.r2].top + this.rows[range.r2].height - this.rows[range.r1].top); selection.push(this.rows[range.r2].top + this.rows[range.r2].height - this.rows[range.r1].top);
} }
var formulaRanges = []; var formularanges = [];
if (!isFrozen && this.isFormulaEditMode) { if (!isFrozen && this.isFormulaEditMode) {
if (this.arrActiveFormulaRanges.length) { if (this.arrActiveFormulaRanges.length) {
formulaRanges = this.__selectedCellRanges(this.arrActiveFormulaRanges, offsetX, offsetY); formularanges = this.__selectedCellRanges(this.arrActiveFormulaRanges, offsetX, offsetY);
} }
} }
return {'selection': native_selection, 'formulaRanges': formulaRanges}; return {'selection': selection, 'formularanges': formularanges};
}; };
AscCommonExcel.WorksheetView.prototype.__changeSelectionTopLeft = function (x, y, isCoord, isSelectMode, isTopLeft) { AscCommonExcel.WorksheetView.prototype.__changeSelectionPoint = function (x, y, isCoord, isSelectMode, isReverse) {
//var ar = (this.isFormulaEditMode) ? this.arrActiveFormulaRanges[this.arrActiveFormulaRanges.length - 1] : this.activeRange;
var isChangeSelectionShape = false;
if (isCoord) {
isChangeSelectionShape = this._checkSelectionShape();
}
var isMoveActiveCellToLeftTop = false; var isMoveActiveCellToLeftTop = false;
//var ar = this.activeRange; var selection = this._getSelection();
//var copy = this.activeRange.clone(); var lastRange = selection.getLast();
var ar = this.model.selectionRange.ranges[0]; var col = selection.activeCell.col;
var copy = this.model.selectionRange.ranges[0].clone(); var row = selection.activeCell.row;
var col = ar.startCol; if (isReverse) {
var row = ar.startRow; selection.activeCell.col = this.leftTopRange.c2;
selection.activeCell.row = this.leftTopRange.r2;
if (isTopLeft) {
this.model.selectionRange.ranges[0].startCol = this.leftTopRange.c2;
this.model.selectionRange.ranges[0].startRow = this.leftTopRange.r2;
} else { } else {
this.model.selectionRange.ranges[0].startCol = this.leftTopRange.c1; selection.activeCell.col = this.leftTopRange.c1;
this.model.selectionRange.ranges[0].startRow = this.leftTopRange.r1; selection.activeCell.row = this.leftTopRange.r1;
} }
var newRange = isCoord ? this._calcSelectionEndPointByXY(x, y) : this._calcSelectionEndPointByOffset(x, y); var ar = this._getSelection().getLast();
var newRange = isCoord ? this._calcSelectionEndPointByXY(x, y) :
this._calcSelectionEndPointByOffset(x, y);
var isEqual = newRange.isEqual(ar); var isEqual = newRange.isEqual(ar);
if (isEqual && !isCoord) {
if (!isEqual) { // При движении стрелками можем попасть на замерженную ячейку
}
if (newRange.c1 > col) { if (!isEqual || isChangeSelectionShape) {
if (newRange.c1 > col || newRange.c2 < col) {
col = newRange.c1; col = newRange.c1;
isMoveActiveCellToLeftTop = true; isMoveActiveCellToLeftTop = true;
} }
if (newRange.r1 > row) { if (newRange.r1 > row || newRange.r2 < row) {
row = newRange.r1; row = newRange.r1;
isMoveActiveCellToLeftTop = true; isMoveActiveCellToLeftTop = true;
} }
ar.assign2(newRange); ar.assign2(newRange);
this.model.selectionRange.ranges[0].startCol = col; selection.activeCell.col = col;
this.model.selectionRange.ranges[0].startRow = row; selection.activeCell.row = row;
if (isMoveActiveCellToLeftTop) { if (isMoveActiveCellToLeftTop) {
this.model.selectionRange.ranges[0].startCol = newRange.c1; selection.activeCell.col = newRange.c1;
this.model.selectionRange.ranges[0].startRow = newRange.r1; selection.activeCell.row = newRange.r1;
} }
//ToDo this.drawDepCells();
if (!this.isCellEditMode) { if (!this.isCellEditMode) {
if (!this.isSelectionDialogMode) { if (!this.isSelectionDialogMode) {
this.handlers.trigger("selectionNameChanged", this.getSelectionName(/*bRangeText*/true)); this.handlers.trigger("selectionNameChanged", this.getSelectionName(/*bRangeText*/true));
...@@ -3307,13 +3311,16 @@ function OfflineEditor () { ...@@ -3307,13 +3311,16 @@ function OfflineEditor () {
} }
} }
} else { } else {
this.model.selectionRange.ranges[0].startCol = col; selection.activeCell.col = col;
this.model.selectionRange.ranges[0].startRow = row; selection.activeCell.row = row;
} }
this.model.workbook.handlers.trigger("asc_onHideComment"); this.model.workbook.handlers.trigger("asc_onHideComment");
return this._calcActiveRangeOffset(x,y); return isCoord ? this._calcActiveRangeOffsetIsCoord(x, y) :
this._calcActiveRangeOffset(
this.getCellLeftRelative(x < 0 ? ar.c1 : ar.c2, /*pt*/0),
this.getCellTopRelative(y < 0 ? ar.r1 : ar.r2, /*pt*/0));
}; };
AscCommonExcel.WorksheetView.prototype.__chartsRanges = function(ranges) { AscCommonExcel.WorksheetView.prototype.__chartsRanges = function(ranges) {
...@@ -5232,7 +5239,12 @@ function offline_mouse_down(x, y, pin, isViewerMode, isFormulaEditMode, isRangeR ...@@ -5232,7 +5239,12 @@ function offline_mouse_down(x, y, pin, isViewerMode, isFormulaEditMode, isRangeR
} else { } else {
if (0 != _s.cellPin) { if (0 != _s.cellPin) {
ws.leftTopRange = ws.model.selectionRange.clone();
var selection = ws._getSelection();
var lastRange = selection.getLast();
ws.leftTopRange = lastRange.clone();
} else { } else {
var ret = false; var ret = false;
...@@ -5316,9 +5328,9 @@ function offline_mouse_move(x, y, isViewerMode, isRangeResize, isChartRange, ind ...@@ -5316,9 +5328,9 @@ function offline_mouse_move(x, y, isViewerMode, isRangeResize, isChartRange, ind
ws.enterCellRange(wb.cellEditor); ws.enterCellRange(wb.cellEditor);
} else { } else {
if (-1 == _s.cellPin) if (-1 == _s.cellPin)
ws.__changeSelectionTopLeft(x, y, true, true, true); ws.__changeSelectionPoint(x, y, true, true, true);
else if (1 === _s.cellPin) else if (1 === _s.cellPin)
ws.__changeSelectionTopLeft(x, y, true, true, false); ws.__changeSelectionPoint(x, y, true, true, false);
else { else {
ws.changeSelectionEndPoint(x, y, true, true); ws.changeSelectionEndPoint(x, y, true, true);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment