Commit 6387817c authored by Alexander.Trofimov's avatar Alexander.Trofimov

start multiselect

parent aad333dc
/*
/*
* (c) Copyright Ascensio System SIA 2010-2016
*
* This program is a free software product. You can redistribute it and/or
......@@ -1986,7 +1986,8 @@ var editor;
if (window["NATIVE_EDITOR_ENJINE"]) {
if (this.wb.findCellText(options)) {
var ws = this.wb.getWorksheet();
return [ws.getCellLeftRelative(ws.activeRange.c1, 0), ws.getCellTopRelative(ws.activeRange.r1, 0)];
var range = ws.selectionRange.getLast();
return [ws.getCellLeftRelative(range.c1, 0), ws.getCellTopRelative(range.r1, 0)];
}
return null;
......
......@@ -116,8 +116,8 @@
* @returns {ApiRange}
*/
ApiWorksheet.prototype.GetActiveCell = function () {
var ar = this.worksheetView.activeRange;
return new ApiRange(this.worksheet.getCell3(ar.startRow, ar.startCol));
var cell = this.worksheetView.selectionRange.cell;
return new ApiRange(this.worksheet.getCell3(cell.row, cell.col));
};
/**
......
......@@ -262,6 +262,9 @@
Range.prototype.contains = function (c, r) {
return this.c1 <= c && c <= this.c2 && this.r1 <= r && r <= this.r2;
};
Range.prototype.contains2 = function (cell) {
return this.contains(cell.col, cell.row);
};
Range.prototype.containsRange = function (range) {
return this.contains(range.c1, range.r1) && this.contains(range.c2, range.r2);
......@@ -557,6 +560,110 @@
return new Range3D(ActiveRange.superclass.clone.apply(this, arguments), this.sheet, this.sheet2);
};
/**
* @constructor
*/
function SelectionRange() {
this.ranges = [new Range(0, 0, 0, 0)];
this.cell = new AscCommon.CellBase(0, 0); // Active cell
this.cellIndex = 0;
}
SelectionRange.prototype.clean = function () {
this.ranges = [new Range(0, 0, 0, 0)];
this.cell.clean();
this.cellIndex = 0;
};
SelectionRange.prototype.contains = function (c, r) {
return this.ranges.some(function (item) {
return item.contains(c, r);
});
};
SelectionRange.prototype.contains2 = function (cell) {
return this.contains(cell.col, cell.row);
};
SelectionRange.prototype.clone = function () {
var res = new SelectionRange();
res.ranges = this.ranges.map(function (range) {
return range.clone();
});
res.cell = this.cell.clone();
return res;
};
SelectionRange.prototype.isEqual = function (range) {
return false;
// todo return this.cell.isEqual(range.cell);
};
SelectionRange.prototype.offsetCell = function (dr, dc) {
var curRange;
var lastRow = this.cell.row;
var lastCol = this.cell.col;
this.cell.row += dr;
this.cell.col += dc;
while (true) {
curRange = this.ranges[this.cellIndex];
if (!curRange.contains2(this.cell)) {
if (dr) {
if (0 < dr) {
this.cell.row = curRange.r1;
this.cell.col += 1;
} else {
this.cell.row = curRange.r2;
this.cell.col -= 1;
}
} else {
if (0 < dc) {
this.cell.row += 1;
this.cell.col = curRange.c1;
} else {
this.cell.row -= 1;
this.cell.col = curRange.c2;
}
}
if (!curRange.contains2(this.cell)) {
if (0 < dc || 0 < dr) {
this.cellIndex += 1;
this.cellIndex = (this.ranges.length > this.cellIndex) ? this.cellIndex : 0;
curRange = this.ranges[this.cellIndex];
this.cell.row = curRange.r1;
this.cell.col = curRange.c1;
} else {
this.cellIndex -= 1;
this.cellIndex = (0 <= this.cellIndex) ? this.cellIndex : this.ranges.length - 1;
curRange = this.ranges[this.cellIndex];
this.cell.row = curRange.r2;
this.cell.col = curRange.c2;
}
}
}
// ToDo merge and hidden
break;
}
return (lastRow !== this.cell.row || lastCol !== this.cell.col)
};
SelectionRange.prototype.setCell = function (r, c) {
this.cell.row = r;
this.cell.col = c;
this.update();
};
SelectionRange.prototype.getLast = function () {
return this.ranges[this.ranges.length - 1];
};
SelectionRange.prototype.update = function () {
//меняем выделеную ячейку, если она не входит в диапазон
//возможно, в будующем придется пределать логику, пока нет примеров, когда это работает плохо
if (!this.contains2(this.cell)) {
var last = this.getLast();
this.cell.col = last.c1;
this.cell.row = last.r1;
}
};
/**
*
* @constructor
......@@ -1682,6 +1789,7 @@
window["AscCommonExcel"].CRangeOffset = CRangeOffset;
window["Asc"].Range = Range;
window["AscCommonExcel"].Range3D = Range3D;
window["AscCommonExcel"].SelectionRange = SelectionRange;
window["AscCommonExcel"].ActiveRange = ActiveRange;
window["AscCommonExcel"].FormulaRange = FormulaRange;
window["AscCommonExcel"].MultiplyRange = MultiplyRange;
......
......@@ -850,14 +850,8 @@
};
WorkbookView.prototype._onWSSelectionChanged = function(info) {
var ws = this.getWorksheet();
if (this.cellFormulaEnterWSOpen) {
ws = this.cellFormulaEnterWSOpen;
}
var ar = ws.activeRange;
this.lastSendInfoRange = ar.clone(true);
var ws = this.cellFormulaEnterWSOpen ? this.cellFormulaEnterWSOpen : this.getWorksheet();
this.lastSendInfoRange = ws.selectionRange.getLast().clone(true);
this.lastSendInfoRangeIsSelectOnShape = ws.getSelectionShape();
if (null === info) {
......@@ -945,9 +939,10 @@
}
};
WorkbookView.prototype._onChangeSelection = function(isStartPoint, dc, dr, isCoord, isSelectMode, callback) {
WorkbookView.prototype._onChangeSelection = function (isStartPoint, dc, dr, isCoord, isSelectMode, callback) {
var ws = this.getWorksheet();
var d = isStartPoint ? ws.changeSelectionStartPoint(dc, dr, isCoord, isSelectMode) : ws.changeSelectionEndPoint(dc, dr, isCoord, isSelectMode);
var d = isStartPoint ? ws.changeSelectionStartPoint(dc, dr, isCoord, isSelectMode) :
ws.changeSelectionEndPoint(dc, dr, isCoord, isSelectMode);
if (!isCoord && !isStartPoint && !isSelectMode) {
// Выделение с зажатым shift
this.canUpdateAfterShiftUp = true;
......@@ -964,7 +959,7 @@
ws.changeSelectionDone();
this._onSelectionNameChanged(ws.getSelectionName(/*bRangeText*/false));
// Проверим, нужно ли отсылать информацию о ячейке
var ar = ws.activeRange;
var ar = ws.selectionRange.getLast();
var isSelectOnShape = ws.getSelectionShape();
if (!this._isEqualRange(ar, isSelectOnShape)) {
this._onWSSelectionChanged(ws.getSelectionInfo());
......@@ -979,7 +974,7 @@
if (c_oTargetType.Hyperlink === ct.target) {
// Проверим замерженность
var isHyperlinkClick = false;
if ((ar.c1 === ar.c2 && ar.r1 === ar.r2) || isSelectOnShape) {
if (ar.isOneCell() || isSelectOnShape) {
isHyperlinkClick = true;
} else {
var mergedRange = ws.model.getMergedByCell(ar.r1, ar.c1);
......@@ -1204,7 +1199,7 @@
WorkbookView.prototype._onShowAutoComplete = function() {
var ws = this.getWorksheet();
var arrValues = ws.getCellAutoCompleteValues(ws.activeRange.startCol, ws.activeRange.startRow);
var arrValues = ws.getCellAutoCompleteValues(ws.selectionRange.cell);
this.handlers.trigger('asc_onEntriesListMenu', arrValues);
};
......@@ -1314,13 +1309,13 @@
var ws = t.getWorksheet();
var activeCellRange = ws.getActiveCell(0, 0, false);
var arn = ws.activeRange.clone(true);
var selectionRange = ws.selectionRange.clone();
var editFunction = function() {
t.setCellEditMode(true);
ws.setCellEditMode(true);
ws.openCellEditor(t.cellEditor, /*fragments*/undefined, /*cursorPos*/undefined, isFocus, isClearCell,
/*isHideCursor*/isHideCursor, /*isQuickInput*/isQuickInput, /*activeRange*/arn);
/*isHideCursor*/isHideCursor, /*isQuickInput*/isQuickInput, selectionRange);
t.input.disabled = false;
t.handlers.trigger("asc_onEditCell", c_oAscCellEditorState.editStart);
......@@ -1562,7 +1557,7 @@
if (c_oAscSelectionDialogType.Chart === this.selectionDialogType) {
// Когда идет выбор диапазона, то должны на закрываемом листе отменить выбор диапазона
tmpWorksheet = this.getWorksheet();
selectionRange = tmpWorksheet.activeRange.clone(true);
selectionRange = tmpWorksheet.selectionRange.getLast().clone(true);
tmpWorksheet.setSelectionDialogMode(c_oAscSelectionDialogType.None);
}
if (this.stateFormatPainter) {
......@@ -1970,7 +1965,7 @@
cursorPos = name.length - 1;
}
var arn = ws.activeRange.clone(true);
var selectionRange = ws.selectionRange.clone();
var openEditor = function(res) {
if (res) {
......@@ -1983,7 +1978,7 @@
t.skipHelpSelector = true;
}
// Открываем, с выставлением позиции курсора
if (!ws.openCellEditorWithText(t.cellEditor, name, cursorPos, /*isFocus*/false, /*activeRange*/arn)) {
if (!ws.openCellEditorWithText(t.cellEditor, name, cursorPos, /*isFocus*/false, selectionRange)) {
t.handlers.trigger("asc_onEditCell", c_oAscCellEditorState.editEnd);
t.setCellEditMode(false);
t.controller.setStrictClose(false);
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -40,6 +40,14 @@
//todo
//BinaryCommonWriter
function extendClass (Child, Parent) {
var F = function() { };
F.prototype = Parent.prototype;
Child.prototype = new F();
Child.prototype.constructor = Child;
Child.superclass = Parent.prototype;
}
var c_oSerConstants = {
ErrorFormat: -2,
ErrorUnknown: -1,
......@@ -761,6 +769,21 @@ function CellAddressUtils(){
};
}
var g_oCellAddressUtils = new CellAddressUtils();
function CellBase(r, c) {
this.row = r;
this.col = c;
}
CellBase.prototype.clean = function() {
this.row = 0;
this.col = 0;
};
CellBase.prototype.clone = function() {
return new CellBase(this.row, this.col);
};
CellBase.prototype.isEqual = function(cell) {
return this.row === cell.row && this.col === cell.col;
};
/**
* @constructor
*/
......@@ -798,6 +821,7 @@ function CellAddress(){
this._invalidId = true;
}
}
extendClass(CellAddress, CellBase);
CellAddress.prototype._isDigit=function(symbol){
return '0' <= symbol && symbol <= '9';
};
......@@ -1141,6 +1165,7 @@ function isRealObject(obj)
//----------------------------------------------------------export----------------------------------------------------
window['AscCommon'] = window['AscCommon'] || {};
window["AscCommon"].extendClass = extendClass;
window['AscCommon'].c_oSerConstants = c_oSerConstants;
window['AscCommon'].c_oSerPropLenType = c_oSerPropLenType;
window['AscCommon'].c_oSer_ColorType = c_oSer_ColorType;
......@@ -1159,6 +1184,7 @@ function isRealObject(obj)
window['AscCommon'].gc_nMaxRow0 = gc_nMaxRow0;
window['AscCommon'].gc_nMaxCol0 = gc_nMaxCol0;
window['AscCommon'].g_oCellAddressUtils = g_oCellAddressUtils;
window['AscCommon'].CellBase = CellBase;
window['AscCommon'].CellAddress = CellAddress;
window['AscCommon'].isRealObject = isRealObject;
window['AscCommon'].FileStream = FileStream;
......
......@@ -1779,14 +1779,6 @@ else if (AscBrowser.isOpera)
else
kCurFormatPainterWord = "url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAATCAYAAACdkl3yAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJxJREFUeNrslGEOwBAMhVtxM5yauxnColWJzt+9pFkl9vWlBeac4VINYG4h3vueFUeKIHLOjRTsp+pdKaX6QY2jufripobpzRoB0ro6qdW5I+q3qGxowXONI9LACcBBBMYhA/RuFJxA+WnXK1CBJJg0kKMD2cc8hNKe25P9gxSy01VY3pjdhHYgCCG0RYyR5Bphpk8kMofHjh4BBgA9UXIXw7elTAAAAABJRU5ErkJggg==') 2 11, pointer";
function extendClass (Child, Parent) {
var F = function() { };
F.prototype = Parent.prototype;
Child.prototype = new F();
Child.prototype.constructor = Child;
Child.superclass = Parent.prototype;
}
function asc_ajax (obj) {
var url = "", type = "GET",
async = true, data = null, dataType = "text/xml",
......@@ -2767,7 +2759,6 @@ window["SetDoctRendererParams"] = function(_params)
window["AscCommon"].CanDropFiles = CanDropFiles;
window["AscCommon"].getUrlType = getUrlType;
window["AscCommon"].prepareUrl = prepareUrl;
window["AscCommon"].extendClass = extendClass;
window["AscCommon"].getUserColorById = getUserColorById;
window["AscCommon"].isNullOrEmptyString = isNullOrEmptyString;
......
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