Commit d6a63849 authored by Alexander.Trofimov's avatar Alexander.Trofimov

fix formula mode (in cell editor)

parent be4d574e
......@@ -211,6 +211,7 @@
this.r2 = r2;
this.refType1 = referenceType.R;
this.refType2 = referenceType.R;
this.type = c_oAscSelectionType.RangeCells;
return normalize ? this.normalize() : this;
}
......@@ -233,6 +234,7 @@
var oRes = new Range(this.c1, this.r1, this.c2, this.r2, normalize);
oRes.refType1 = this.refType1;
oRes.refType2 = this.refType2;
oRes.type = this.type;
return oRes;
};
......
......@@ -789,16 +789,17 @@
};
CellEditor.prototype._parseRangeStr = function (s) {
var range = AscCommonExcel.g_oRangeCache.getActiveRange(s);
//var range = AscCommonExcel.g_oRangeCache.getActiveRange(s);
var range = AscCommonExcel.g_oRangeCache.getAscRange(s);
return range ? range.clone() : null;
};
CellEditor.prototype._parseFormulaRanges = function () {
var s = this._getFragmentsText( this.options.fragments ), t = this, ret = false, range,
wsOPEN = this.handlers.trigger( "getCellFormulaEnterWSOpen" ),
ws = wsOPEN ? wsOPEN.model : this.handlers.trigger( "getActiveWS" );
var s = this._getFragmentsText(
this.options.fragments), t = this, ret = false, range, wsOPEN = this.handlers.trigger(
"getCellFormulaEnterWSOpen"), ws = wsOPEN ? wsOPEN.model : this.handlers.trigger("getActiveWS");
if ( s.length < 1 || s.charAt( 0 ) !== "=" || this.options.cellNumFormat == Asc.c_oAscNumFormatType.Text ) {
if (s.length < 1 || s.charAt(0) !== "=" || this.options.cellNumFormat == Asc.c_oAscNumFormatType.Text) {
return ret;
}
......@@ -822,14 +823,13 @@
// var __e__ = new Date().getTime();
// console.log("e-s "+ (__e__ - __s__));
this._formula = new AscCommonExcel.parserFormula( s.substr( 1 ), this.options.cellName, ws );
this._formula = new AscCommonExcel.parserFormula(s.substr(1), this.options.cellName, ws);
this._formula.parse();
var r, offset, _e, _s, wsName = null, refStr, isName = false,
_sColorPos;
var r, offset, _e, _s, wsName = null, refStr, isName = false, _sColorPos;
if ( this._formula.RefPos && this._formula.RefPos.length > 0 ) {
for ( var index = 0; index < this._formula.RefPos.length; index++ ) {
if (this._formula.RefPos && this._formula.RefPos.length > 0) {
for (var index = 0; index < this._formula.RefPos.length; index++) {
wsName = null;
isName = false;
r = this._formula.RefPos[index];
......@@ -839,18 +839,16 @@
_sColorPos = _s = r.start;
switch ( r.oper.type ) {
case cElementType.cell :
{
if ( wsOPEN ) {
switch (r.oper.type) {
case cElementType.cell : {
if (wsOPEN) {
wsName = wsOPEN.model.getName();
}
ret = true;
refStr = r.oper.value;
break;
}
case cElementType.cell3D :
{
case cElementType.cell3D : {
ret = true;
wsName = r.oper.ws.getName();
_s = _e - r.oper.value.length;
......@@ -858,18 +856,16 @@
refStr = r.oper.value;
break;
}
case cElementType.cellsRange :
{
if ( wsOPEN ) {
case cElementType.cellsRange : {
if (wsOPEN) {
wsName = wsOPEN.model.getName();
}
ret = true;
refStr = r.oper.value;
break;
}
case cElementType.cellsRange3D :
{
if ( !r.oper.isSingleSheet() ) {
case cElementType.cellsRange3D : {
if (!r.oper.isSingleSheet()) {
continue;
}
ret = true;
......@@ -880,20 +876,20 @@
break;
}
case cElementType.table :
case cElementType.name :
{
case cElementType.name : {
var nameRef = r.oper.toRef();
if( nameRef instanceof AscCommonExcel.cError ) continue;
switch ( nameRef.type ) {
if (nameRef instanceof AscCommonExcel.cError) {
continue;
}
switch (nameRef.type) {
case cElementType.cellsRange3D :{
if ( !nameRef.isSingleSheet() ) {
case cElementType.cellsRange3D : {
if (!nameRef.isSingleSheet()) {
continue;
}
}
case cElementType.cellsRange :
case cElementType.cell3D :
{
case cElementType.cell3D : {
ret = true;
refStr = nameRef.value;
wsName = nameRef.getWS().getName();
......@@ -908,15 +904,19 @@
continue;
}
if ( ret ) {
range = t._parseRangeStr( refStr );
if(!range) return false;
if (ret) {
range = t._parseRangeStr(refStr);
if (!range) {
return false;
}
range.cursorePos = offset - (_e - _s) + 1;
range.formulaRangeLength = _e - _s;
range.colorRangePos = offset - (_e - _sColorPos) + 1;
range.colorRangeLength = _e - _sColorPos;
if ( isName )range.isName = isName;
t.handlers.trigger( "newRange", range, wsName );
if (isName) {
range.isName = isName;
}
t.handlers.trigger("newRange", range, wsName);
}
}
}
......@@ -924,7 +924,7 @@
};
CellEditor.prototype._findRangeUnderCursor = function () {
var t = this, s = t.textRender.getChars(0, t.textRender.getCharsCount()), range, arrFR = this.handlers.trigger(
var ranges, t = this, s = t.textRender.getChars(0, t.textRender.getCharsCount()), range, arrFR = this.handlers.trigger(
"getFormulaRanges"), a;
for (var id = 0; id < arrFR.length; id++) {
......@@ -932,13 +932,16 @@
* находится ли курсор в позиции над этим диапазоном, дабы не парсить всю формулу заново
* необходимо чтобы парсить случаи когда используется что-то такое sumnas2:K2 - sumnas2 невалидная ссылка.
* */
a = arrFR[id];
ranges = arrFR[id].ranges;
for (var i = 0, l = ranges.length; i < l; ++i) {
a = ranges[i];
if (t.cursorPos >= a.cursorePos && t.cursorPos <= a.cursorePos + a.formulaRangeLength) {
range = a.clone(true);
range.isName = a.isName;
return {index: a.cursorePos, length: a.formulaRangeLength, range: range};
}
}
}
/*не нашли диапазонов под курсором, парсим формулу*/
var r, offset, _e, _s, wsName = null, ret = false, refStr, isName = false, _sColorPos, wsOPEN = this.handlers.trigger(
......@@ -1026,7 +1029,7 @@
if (this.handlers.trigger("getActiveWS") && this.handlers.trigger("getActiveWS").getName() != wsName) {
return {index: -1, length: 0, range: null};
}
range.isName = isName
range.isName = isName;
return {index: _s, length: r.oper.value.length, range: range, wsName: wsName};
}
}
......@@ -1070,33 +1073,36 @@
};
CellEditor.prototype._getRenderFragments = function () {
var opt = this.options, fragments = opt.fragments, i, j, first, last, val, lengthColors, tmpColors, colorIndex, uniqueColorIndex;
if ( this.isFormula() ) {
var arrRanges = this.handlers.trigger( "getFormulaRanges" );
if ( 0 < arrRanges.length ) {
var opt = this.options, fragments = opt.fragments, ranges, i, j, k, l, first, last, val, lengthColors, tmpColors, colorIndex, uniqueColorIndex;
if (this.isFormula()) {
var arrRanges = this.handlers.trigger("getFormulaRanges");
if (0 < arrRanges.length) {
fragments = [];
for ( i = 0; i < opt.fragments.length; ++i )
fragments.push( opt.fragments[i].clone() );
for (i = 0; i < opt.fragments.length; ++i) {
fragments.push(opt.fragments[i].clone());
}
lengthColors = AscCommonExcel.c_oAscFormulaRangeBorderColor.length;
tmpColors = [];
uniqueColorIndex = 0;
for ( i = 0; i < arrRanges.length; ++i ) {
val = arrRanges[i];
colorIndex = asc.getUniqueRangeColor( arrRanges, i, tmpColors );
if ( null == colorIndex ) {
for (i = 0; i < arrRanges.length; ++i) {
ranges = arrRanges[i].ranges;
for (j = 0, l = ranges.length; j < l; ++j) {
val = ranges[j];
colorIndex = asc.getUniqueRangeColor(ranges, j, tmpColors);
if (null == colorIndex) {
colorIndex = uniqueColorIndex++;
}
tmpColors.push( colorIndex );
this._extractFragments( val.colorRangePos, val.colorRangeLength, fragments );
tmpColors.push(colorIndex);
first = this._findFragment( val.cursorePos, fragments );
last = this._findFragment( val.cursorePos + val.formulaRangeLength - 1, fragments );
if ( first && last ) {
for ( j = first.index; j <= last.index; ++j )
fragments[j].format.c = AscCommonExcel.c_oAscFormulaRangeBorderColor[colorIndex % lengthColors];
this._extractFragments(val.colorRangePos, val.colorRangeLength, fragments);
first = this._findFragment(val.cursorePos, fragments);
last = this._findFragment(val.cursorePos + val.formulaRangeLength - 1, fragments);
if (first && last) {
for (k = first.index; k <= last.index; ++k) {
fragments[k].format.c = AscCommonExcel.c_oAscFormulaRangeBorderColor[colorIndex % lengthColors];
}
}
}
}
}
......@@ -1835,18 +1841,18 @@
}
};
CellEditor.prototype._findFragment = function ( pos, fragments ) {
CellEditor.prototype._findFragment = function (pos, fragments) {
var i, begin, end;
if ( !fragments ) {
if (!fragments) {
fragments = this.options.fragments;
}
for ( i = 0, begin = 0; i < fragments.length; ++i ) {
for (i = 0, begin = 0; i < fragments.length; ++i) {
end = begin + fragments[i].text.length;
if ( pos >= begin && pos < end ) {
if (pos >= begin && pos < end) {
return {index: i, begin: begin, end: end};
}
if ( i < fragments.length - 1 ) {
if (i < fragments.length - 1) {
begin = end;
}
}
......@@ -1917,20 +1923,20 @@
return res;
};
CellEditor.prototype._extractFragments = function ( startPos, length, fragments ) {
CellEditor.prototype._extractFragments = function (startPos, length, fragments) {
var fr;
fr = this._findFragment( startPos, fragments );
if ( !fr ) {
fr = this._findFragment(startPos, fragments);
if (!fr) {
throw "Can not extract fragment of text";
}
this._splitFragment( fr, startPos, fragments );
this._splitFragment(fr, startPos, fragments);
fr = this._findFragment( startPos + length, fragments );
if ( !fr ) {
fr = this._findFragment(startPos + length, fragments);
if (!fr) {
throw "Can not extract fragment of text";
}
this._splitFragment( fr, startPos + length, fragments );
this._splitFragment(fr, startPos + length, fragments);
};
CellEditor.prototype._addFragments = function ( f, pos ) {
......
......@@ -1263,6 +1263,11 @@
}
};
WorksheetView.prototype._getSelection = function () {
return (this.isFormulaEditMode) ? this.arrActiveFormulaRanges[this.arrActiveFormulaRangesPosition] :
this.model.selectionRange;
};
WorksheetView.prototype._fixVisibleRange = function ( range ) {
var tmp;
if ( null !== this.topLeftFrozenCell ) {
......@@ -3833,21 +3838,23 @@
};
WorksheetView.prototype._drawFormulaRanges = function (arrRanges) {
var i, length = AscCommonExcel.c_oAscFormulaRangeBorderColor.length;
var i, ranges, length = AscCommonExcel.c_oAscFormulaRangeBorderColor.length;
var strokeColor, colorIndex, uniqueColorIndex = 0, tmpColors = [];
for (i = 0; i < arrRanges.length; ++i) {
var oFormulaRange = arrRanges[i].clone(true);
colorIndex = asc.getUniqueRangeColor(arrRanges, i, tmpColors);
ranges = arrRanges[i].ranges;
for (var j = 0, l = ranges.length; j < l; ++j) {
colorIndex = asc.getUniqueRangeColor(ranges, j, tmpColors);
if (null == colorIndex) {
colorIndex = uniqueColorIndex++;
}
tmpColors.push(colorIndex);
strokeColor = AscCommonExcel.c_oAscFormulaRangeBorderColor[colorIndex % length];
this._drawElements(this._drawSelectionElement, oFormulaRange,
AscCommonExcel.selectionLineType.Selection | (arrRanges[i].isName ? AscCommonExcel.selectionLineType.None :
this._drawElements(this._drawSelectionElement, ranges[j],
AscCommonExcel.selectionLineType.Selection | (ranges[j].isName ? AscCommonExcel.selectionLineType.None :
AscCommonExcel.selectionLineType.Resize), strokeColor);
}
}
};
WorksheetView.prototype._drawSelectRange = function () {
......@@ -4042,28 +4049,24 @@
if (0 < this.arrActiveFormulaRanges.length) {
for (i = 0; i < this.arrActiveFormulaRanges.length; ++i) {
var activeFormula = this.arrActiveFormulaRanges[i].clone(true);
activeFormula = activeFormula.intersection(range);
if (null === activeFormula) {
// это ссылка из формулы на еще не добавленный рэндж
continue;
}
// Координаты для range формулы
_x1 = this.cols[activeFormula.c1].left - offsetX - this.width_3px;
_x2 = activeFormula.c2 > this.cols.length ? width :
this.cols[activeFormula.c2].left + this.cols[activeFormula.c2].width - offsetX + this.width_3px;
_y1 = this.rows[activeFormula.r1].top - offsetY - this.height_3px;
_y2 = activeFormula.r2 > this.rows.length ? height :
this.rows[activeFormula.r2].top + this.rows[activeFormula.r2].height - offsetY + this.height_3px;
this.arrActiveFormulaRanges[i].ranges.forEach(function (item) {
var arnIntersection = item.intersectionSimple(range);
if (arnIntersection) {
_x1 = t.cols[arnIntersection.c1].left - offsetX - t.width_3px;
_x2 = arnIntersection.c2 > t.cols.length ? width :
t.cols[arnIntersection.c2].left + t.cols[arnIntersection.c2].width - offsetX + t.width_1px +
t.width_2px;
_y1 = t.rows[arnIntersection.r1].top - offsetY - t.height_3px;
_y2 = arnIntersection.r2 > t.rows.length ? height : t.rows[arnIntersection.r2].top + t.rows[arnIntersection.r2].height - offsetY +
t.height_1px + t.height_2px;
// Выбираем наибольший range для очистки
x1 = Math.min(x1, _x1);
x2 = Math.max(x2, _x2);
y1 = Math.min(y1, _y1);
y2 = Math.max(y2, _y2);
}
});
}
// Вышли из редактора, очистим массив
//TODO: Нужно ли очищать массив ячеек из формулы в отрисовке???
......@@ -6044,8 +6047,7 @@
var targetArr = this.isFormulaEditMode ? 0 : -1;
for (i = 0, l = arrRanges.length; i < l; ++i) {
oFormulaRange = arrRanges[i].clone(true);
oFormulaRange.isName = arrRanges[i].isName;
oFormulaRange = arrRanges[i].getLast();
res = !oFormulaRange.isName &&
this._hitInRange(oFormulaRange, AscCommonExcel.selectionLineType.Resize, vr, x, y, offsetX, offsetY);
if (res) {
......@@ -6396,10 +6398,8 @@
};
WorksheetView.prototype._fixSelectionOfMergedCells = function (fixedRange) {
var ar = fixedRange ? fixedRange :
((this.isFormulaEditMode) ? this.arrActiveFormulaRanges[this.arrActiveFormulaRangesPosition] :
this.model.selectionRange.getLast());
var tmpSelection = this._getSelection();
var ar = fixedRange ? fixedRange : tmpSelection.getLast();
if (!ar) {
return;
}
......@@ -6420,7 +6420,9 @@
}
ar.r2 = ar.r1 === res.r1 ? res.r2 : res.r1;
ar.normalize();
this.model.selectionRange.update();
if (!fixedRange) {
tmpSelection.update();
}
};
WorksheetView.prototype._findVisibleCol = function (from, dc, flag) {
......@@ -6502,8 +6504,7 @@
WorksheetView.prototype._moveActiveCellToXY = function (x, y) {
var c, r;
var ar = (this.isFormulaEditMode) ? this.arrActiveFormulaRanges[this.arrActiveFormulaRangesPosition] :
this.model.selectionRange.getLast();
var ar = this._getSelection().getLast();
x *= asc_getcvt(0/*px*/, 1/*pt*/, this._getPPIX());
y *= asc_getcvt(0/*px*/, 1/*pt*/, this._getPPIY());
......@@ -6544,9 +6545,9 @@
};
WorksheetView.prototype._moveActiveCellToOffset = function (dc, dr) {
var ar = (this.isFormulaEditMode) ? this.arrActiveFormulaRanges[this.arrActiveFormulaRangesPosition] :
this.model.selectionRange.getLast();
var activeCell = this.model.selectionRange.activeCell;
var tmpSelection = this._getSelection();
var ar = tmpSelection.getLast();
var activeCell = tmpSelection.activeCell;
var mc = this.model.getMergedByCell(activeCell.row, activeCell.col);
var c = mc ? (dc < 0 ? mc.c1 : dc > 0 ? Math.min(mc.c2, this.nColsCount - 1 - dc) : activeCell.col) :
activeCell.col;
......@@ -6574,12 +6575,12 @@
};
WorksheetView.prototype._calcSelectionEndPointByXY = function (x, y) {
var ar = (this.isFormulaEditMode) ? this.arrActiveFormulaRanges[this.arrActiveFormulaRangesPosition] :
this.model.selectionRange.getLast();
var tmpSelection = this._getSelection();
var ar = tmpSelection.getLast();
x *= asc_getcvt(0/*px*/, 1/*pt*/, this._getPPIX());
y *= asc_getcvt(0/*px*/, 1/*pt*/, this._getPPIY());
var res = new asc_Range(this.model.selectionRange.activeCell.col, this.model.selectionRange.activeCell.row, this._findColUnderCursor(
var res = new asc_Range(tmpSelection.activeCell.col, tmpSelection.activeCell.row, this._findColUnderCursor(
x).col, this._findRowUnderCursor(y).row, true);
if (ar.type === c_oAscSelectionType.RangeCells) {
this._fixSelectionOfMergedCells(res);
......@@ -6588,14 +6589,13 @@
};
WorksheetView.prototype._calcSelectionEndPointByOffset = function (dc, dr) {
var ar = (this.isFormulaEditMode) ? this.arrActiveFormulaRanges[this.arrActiveFormulaRangesPosition] :
this.model.selectionRange.getLast();
var startCol = this.model.selectionRange.activeCell.col, startRow = this.model.selectionRange.activeCell.row;
var tmpSelection = this._getSelection();
var ar = tmpSelection.getLast();
var c1, r1, c2, r2, tmp;
tmp = asc.getEndValueRange(dc, startCol, ar.c1, ar.c2);
tmp = asc.getEndValueRange(dc, tmpSelection.activeCell.col, ar.c1, ar.c2);
c1 = tmp.x1;
c2 = tmp.x2;
tmp = asc.getEndValueRange(dr, startRow, ar.r1, ar.r2);
tmp = asc.getEndValueRange(dr, tmpSelection.activeCell.row, ar.r1, ar.r2);
r1 = tmp.x1;
r2 = tmp.x2;
......@@ -6631,8 +6631,7 @@
};
WorksheetView.prototype._calcActiveRangeOffsetIsCoord = function (x, y) {
var ar = (this.isFormulaEditMode) ? this.arrActiveFormulaRanges[this.arrActiveFormulaRangesPosition] :
this.model.selectionRange.getLast();
var ar = this._getSelection().getLast();
if (this.isFormulaEditMode) {
// Для формул нужно сделать ограничение по range (у нас хранится полный диапазон)
if (ar.c2 >= this.nColsCount || ar.r2 >= this.nRowsCount) {
......@@ -6673,8 +6672,7 @@
WorksheetView.prototype._calcActiveRangeOffset = function () {
var vr = this.visibleRange;
var ar = (this.isFormulaEditMode) ? this.arrActiveFormulaRanges[this.arrActiveFormulaRangesPosition] :
this.model.selectionRange.getLast();
var ar = this._getSelection().getLast();
if (this.isFormulaEditMode) {
// Для формул нужно сделать ограничение по range (у нас хранится полный диапазон)
if (ar.c2 >= this.nColsCount || ar.r2 >= this.nRowsCount) {
......@@ -7346,8 +7344,7 @@
this.model.selectionRange.clean();
}
}
var ar = ((this.isFormulaEditMode) ? this.arrActiveFormulaRanges[this.arrActiveFormulaRangesPosition] :
this.model.selectionRange.getLast()).clone();
var ar = this._getSelection().getLast().clone();
var ret = {};
var isChangeSelectionShape = false;
......@@ -7486,9 +7483,7 @@
if (isCoord) {
isChangeSelectionShape = this._checkSelectionShape();
}
var lastActiveRange = this.model.selectionRange.getLast();
var ar = (this.isFormulaEditMode) ? this.arrActiveFormulaRanges[this.arrActiveFormulaRangesPosition] :
lastActiveRange;
var ar = this._getSelection().getLast();
var newRange = isCoord ? this._calcSelectionEndPointByXY(x, y) : this._calcSelectionEndPointByOffset(x, y);
var isEqual = newRange.isEqual(ar);
......@@ -7519,8 +7514,8 @@
this.model.workbook.handlers.trigger("asc_onHideComment");
return isCoord ? this._calcActiveRangeOffsetIsCoord(x, y) : this._calcActiveRangeOffset(
this.getCellLeftRelative(x < 0 ? lastActiveRange.c1 : lastActiveRange.c2, /*pt*/0),
this.getCellTopRelative(y < 0 ? lastActiveRange.r1 : lastActiveRange.r2, /*pt*/0));
this.getCellLeftRelative(x < 0 ? ar.c1 : ar.c2, /*pt*/0),
this.getCellTopRelative(y < 0 ? ar.r1 : ar.r2, /*pt*/0));
};
// Окончание выделения
......@@ -11335,41 +11330,53 @@
this.draw( lockDraw );
};
WorksheetView.prototype.enterCellRange = function ( editor ) {
if ( !this.isFormulaEditMode ) {
WorksheetView.prototype.enterCellRange = function (editor) {
if (!this.isFormulaEditMode) {
return;
}
var currentRange = this.arrActiveFormulaRanges[this.arrActiveFormulaRangesPosition].clone();
var startCol = currentRange.startCol, startRow = currentRange.startRow;
var currentFormula = this.arrActiveFormulaRanges[this.arrActiveFormulaRangesPosition];
var currentRange = currentFormula.getLast().clone();
var activeCellId = currentFormula.activeCellId;
var activeCell = currentFormula.activeCell.clone();
// Замерженную ячейку должны отдать только левую верхнюю.
var mergedRange = this.model.getMergedByCell( currentRange.r1, currentRange.c1 );
if ( mergedRange && currentRange.isEqual( mergedRange ) ) {
var mergedRange = this.model.getMergedByCell(currentRange.r1, currentRange.c1);
if (mergedRange && currentRange.isEqual(mergedRange)) {
currentRange.r2 = currentRange.r1;
currentRange.c2 = currentRange.c1;
}
/* var defName = this.model.workbook.findDefinesNames(this.model.getName()+"!"+currentRange.getAbsName(),this.model.getId());
console.log("defName #2 " + defName);*/
var sheetName = "", cFEWSO = editor.handlers.trigger( "getCellFormulaEnterWSOpen" );
if( editor.formulaIsOperator() && cFEWSO && cFEWSO.model.getId() != this.model.getId() ){
sheetName = parserHelp.getEscapeSheetName(this.model.getName())+"!";
var sheetName = "", cFEWSO = editor.handlers.trigger("getCellFormulaEnterWSOpen");
if (editor.formulaIsOperator() && cFEWSO && cFEWSO.model.getId() != this.model.getId()) {
sheetName = parserHelp.getEscapeSheetName(this.model.getName()) + "!";
}
editor.enterCellRange( /*defName || */sheetName + currentRange.getAllRange().getName() );
editor.enterCellRange(/*defName || */sheetName + currentRange.getAllRange().getName());
for ( var tmpRange, i = 0; i < this.arrActiveFormulaRanges.length; ++i ) {
for (var tmpRange, i = 0; i < this.arrActiveFormulaRanges.length; ++i) {
tmpRange = this.arrActiveFormulaRanges[i];
if ( tmpRange.isEqual( currentRange ) ) {
tmpRange.startCol = startCol;
tmpRange.startRow = startRow;
if (tmpRange.getLast().isEqual(currentRange)) {
tmpRange.activeCellId = activeCellId;
tmpRange.activeCell.col = activeCell.col;
tmpRange.activeCell.row = activeCell.row;
break;
}
}
};
WorksheetView.prototype.addFormulaRange = function ( range ) {
var r = range !== undefined ? range : new asc_ActiveRange( this.activeRange.c1, this.activeRange.r1, this.activeRange.c2, this.activeRange.r2 );
this.arrActiveFormulaRanges.push( r );
WorksheetView.prototype.addFormulaRange = function (range) {
var r = this.model.selectionRange.clone();
if (range) {
r.assign2(range);
var lastSelection = r.getLast();
lastSelection.cursorePos = range.cursorePos;
lastSelection.formulaRangeLength = range.formulaRangeLength;
lastSelection.colorRangePos = range.colorRangePos;
lastSelection.colorRangeLength = range.colorRangeLength;
lastSelection.isName = range.isName;
}
this.arrActiveFormulaRanges.push(r);
this.arrActiveFormulaRangesPosition = this.arrActiveFormulaRanges.length - 1;
this._fixSelectionOfMergedCells();
};
......@@ -11377,7 +11384,7 @@
WorksheetView.prototype.activeFormulaRange = function (range) {
this.arrActiveFormulaRangesPosition = -1;
for (var i = 0; i < this.arrActiveFormulaRanges.length; ++i) {
if (this.arrActiveFormulaRanges[i].isEqual(range)) {
if (this.arrActiveFormulaRanges[i].getLast().isEqual(range)) {
this.arrActiveFormulaRangesPosition = i;
return;
}
......@@ -11386,7 +11393,7 @@
WorksheetView.prototype.removeFormulaRange = function (range) {
this.arrActiveFormulaRangesPosition = -1;
for (var i = 0; i < this.arrActiveFormulaRanges.length; ++i) {
if (this.arrActiveFormulaRanges[i].isEqual(range)) {
if (this.arrActiveFormulaRanges[i].getLast().isEqual(range)) {
this.arrActiveFormulaRanges.splice(i, 1);
return;
}
......
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