Commit 902b1a3d authored by Alexander.Trofimov's avatar Alexander.Trofimov

fix bug 32901

add hot key F4
parent b569c549
......@@ -824,7 +824,7 @@
var isTitle = this._isAddNameColumn(mainAdjacentCells);
objOptions.asc_setIsTitle(isTitle);
var tmpRange = mainAdjacentCells.clone();
tmpRange.r1Abs = tmpRange.c1Abs = tmpRange.r2Abs = tmpRange.c2Abs = true;
tmpRange.setAbs(true, true, true, true);
objOptions.asc_setRange(tmpRange.getName());
return objOptions;
},
......
This diff is collapsed.
......@@ -465,43 +465,43 @@
CellEditor.prototype.canEnterCellRange = function () {
var fR = this._findRangeUnderCursor();
var isRange = (fR.range !== null && !fR.range.isName);
var prevChar = this.textRender.getChars( this.cursorPos - 1, 1 );
return isRange || this.rangeChars.indexOf( prevChar ) >= 0;
var prevChar = this.textRender.getChars(this.cursorPos - 1, 1);
return isRange || this.rangeChars.indexOf(prevChar) >= 0;
};
CellEditor.prototype.activateCellRange = function () {
var res = this._findRangeUnderCursor();
res.range ? this.handlers.trigger( "existedRange", res.range, res.wsName ) : this.handlers.trigger( "newRange" );
res.range ? this.handlers.trigger("existedRange", res.range, res.wsName) : this.handlers.trigger("newRange");
};
CellEditor.prototype.enterCellRange = function ( rangeStr ) {
CellEditor.prototype.enterCellRange = function (rangeStr) {
var res = this._findRangeUnderCursor();
if ( res.range ) {
this._moveCursor( kPosition, res.index );
this._selectChars( kPosition, res.index + res.length );
if (res.range) {
this._moveCursor(kPosition, res.index);
this._selectChars(kPosition, res.index + res.length);
}
var lastAction = this.undoList.length > 0 ? this.undoList[this.undoList.length - 1] : null;
while ( lastAction && lastAction.isRange ) {
while (lastAction && lastAction.isRange) {
this.undoList.pop();
lastAction = this.undoList.length > 0 ? this.undoList[this.undoList.length - 1] : null;
}
var tmp = this.skipTLUpdate;
this.skipTLUpdate = false;
this._addChars( rangeStr, undefined, /*isRange*/true );
this._addChars(rangeStr, undefined, /*isRange*/true);
this.skipTLUpdate = tmp;
};
CellEditor.prototype.changeCellRange = function ( range ) {
CellEditor.prototype.changeCellRange = function (range) {
var t = this;
t._moveCursor( kPosition, range.cursorePos/* -length */ );
t._selectChars( kPositionLength, range.formulaRangeLength );
t._addChars( range.getName(), undefined, /*isRange*/true );
t._moveCursor( kEndOfText );
t._moveCursor(kPosition, range.cursorePos/* -length */);
t._selectChars(kPositionLength, range.formulaRangeLength);
t._addChars(range.getName(), undefined, /*isRange*/true);
t._moveCursor(kEndOfText);
};
CellEditor.prototype.move = function ( l, t, r, b ) {
......@@ -799,8 +799,8 @@
this.skipKeyPress = false;
};
CellEditor.prototype._parseRangeStr = function ( s ) {
var range = AscCommonExcel.g_oRangeCache.getActiveRange( s );
CellEditor.prototype._parseRangeStr = function (s) {
var range = AscCommonExcel.g_oRangeCache.getActiveRange(s);
return range ? range.clone() : null;
};
......@@ -935,34 +935,31 @@
};
CellEditor.prototype._findRangeUnderCursor = function () {
var t = this,
s = t.textRender.getChars( 0, t.textRender.getCharsCount() ),
range,
arrFR = this.handlers.trigger( "getFormulaRanges" ),a;
var 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++ ) {
for (var id = 0; id < arrFR.length; id++) {
/*так как у нас уже есть некий массив с рейнджами, которые в формуле, то пробегаемся по ним и смотрим,
* находится ли курсор в позиции над этим диапазоном, дабы не парсить всю формулу заново
* необходимо чтобы парсить случаи когда используется что-то такое sumnas2:K2 - sumnas2 невалидная ссылка.
* */
a = arrFR[id];
if ( t.cursorPos >= a.cursorePos && t.cursorPos <= a.cursorePos + a.formulaRangeLength ) {
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 };
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( "getCellFormulaEnterWSOpen" ),
ws = wsOPEN ? wsOPEN.model : this.handlers.trigger( "getActiveWS" );
var r, offset, _e, _s, wsName = null, ret = false, refStr, isName = false, _sColorPos, wsOPEN = this.handlers.trigger(
"getCellFormulaEnterWSOpen"), ws = wsOPEN ? wsOPEN.model : this.handlers.trigger("getActiveWS");
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();
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;
r = this._formula.RefPos[index];
......@@ -970,18 +967,16 @@
_e = r.end;
_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();
}
refStr = r.oper.value;
ret = true;
break;
}
case cElementType.cell3D :
{
case cElementType.cell3D : {
refStr = r.oper.value;
ret = true;
wsName = r.oper.ws.getName();
......@@ -989,18 +984,16 @@
_sColorPos = _e - r.oper.toString().length;
break;
}
case cElementType.cellsRange :
{
if ( wsOPEN ) {
case cElementType.cellsRange : {
if (wsOPEN) {
wsName = wsOPEN.model.getName();
}
refStr = r.oper.value;
ret = true;
break;
}
case cElementType.cellsRange3D :
{
if ( !r.oper.isSingleSheet() ) {
case cElementType.cellsRange3D : {
if (!r.oper.isSingleSheet()) {
continue;
}
ret = true;
......@@ -1010,21 +1003,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();
......@@ -1039,10 +1031,10 @@
continue;
}
if ( ret && t.cursorPos > _s && t.cursorPos <= _s + r.oper.value.length ) {
range = t._parseRangeStr( r.oper.value );
if ( range ) {
if ( this.handlers.trigger( "getActiveWS" ) && this.handlers.trigger( "getActiveWS" ).getName() != wsName ) {
if (ret && t.cursorPos > _s && t.cursorPos <= _s + r.oper.value.length) {
range = t._parseRangeStr(r.oper.value);
if (range) {
if (this.handlers.trigger("getActiveWS") && this.handlers.trigger("getActiveWS").getName() != wsName) {
return {index: -1, length: 0, range: null};
}
range.isName = isName
......@@ -1052,10 +1044,8 @@
}
}
range ? range.isName = isName : null;
return !range ?
{index: -1, length: 0, range: null} :
return !range ? {index: -1, length: 0, range: null} :
{index: _s, length: r.oper.value.length, range: range, wsName: wsName};
};
CellEditor.prototype._updateFormulaEditMod = function ( bIsOpen ) {
......@@ -2493,6 +2483,17 @@
event.preventDefault();
}
return false;
case 115: // F4
var res = this._findRangeUnderCursor();
if (res.range) {
res.range.switchReference();
this.enterCellRange(res.range.getName());
}
event.stopPropagation();
event.preventDefault();
return false;
}
t.skipKeyPress = false;
......
......@@ -7271,10 +7271,10 @@
WorksheetView.prototype.getSelectionRangeValue = function () {
// ToDo проблема с выбором целого столбца/строки
var ar = this.activeRange.clone( true );
// ar.r1Abs = ar.c1Abs = ar.r2Abs = ar.c2Abs = true;
var ar = this.activeRange.clone(true);
var sName = ar.getAbsName();
return (c_oAscSelectionDialogType.FormatTable === this.selectionDialogType) ? sName : parserHelp.get3DRef( this.model.getName(), sName );
return (c_oAscSelectionDialogType.FormatTable === this.selectionDialogType) ? sName :
parserHelp.get3DRef(this.model.getName(), sName);
};
WorksheetView.prototype.getSelectionInfo = function ( bExt ) {
......@@ -8617,42 +8617,41 @@
return d;
};
WorksheetView.prototype.changeSelectionMoveResizeRangeHandle = function ( x, y, targetInfo, editor ) {
WorksheetView.prototype.changeSelectionMoveResizeRangeHandle = function (x, y, targetInfo, editor) {
// Возвращаемый результат
if ( !targetInfo ) {
if (!targetInfo) {
return null;
}
var indexFormulaRange = targetInfo.indexFormulaRange, d = {deltaY: 0, deltaX: 0}, newFormulaRange = null;
// Пересчитываем координаты
x *= asc_getcvt( 0/*px*/, 1/*pt*/, this._getPPIX() );
y *= asc_getcvt( 0/*px*/, 1/*pt*/, this._getPPIY() );
var ar = 0 == targetInfo.targetArr ? this.arrActiveFormulaRanges[indexFormulaRange].clone( true ) : this.arrActiveChartsRanges[indexFormulaRange].clone( true );
x *= asc_getcvt(0/*px*/, 1/*pt*/, this._getPPIX());
y *= asc_getcvt(0/*px*/, 1/*pt*/, this._getPPIY());
var ar = 0 == targetInfo.targetArr ? this.arrActiveFormulaRanges[indexFormulaRange].clone(true) :
this.arrActiveChartsRanges[indexFormulaRange].clone(true);
// Колонка по X и строка по Y
var colByX = this._findColUnderCursor( x, /*canReturnNull*/false, /*dX*/false ).col;
var rowByY = this._findRowUnderCursor( y, /*canReturnNull*/false, /*dY*/false ).row;
var colByX = this._findColUnderCursor(x, /*canReturnNull*/false, /*dX*/false).col;
var rowByY = this._findRowUnderCursor(y, /*canReturnNull*/false, /*dY*/false).row;
// Если мы только первый раз попали сюда, то копируем выделенную область
if ( null === this.startCellMoveResizeRange ) {
if ( (targetInfo.cursor == kCurNEResize || targetInfo.cursor == kCurSEResize) ) {
this.startCellMoveResizeRange = ar.clone( true );
this.startCellMoveResizeRange2 = new asc_Range( targetInfo.col, targetInfo.row, targetInfo.col, targetInfo.row, true );
}
else {
this.startCellMoveResizeRange = ar.clone( true );
if ( colByX < ar.c1 ) {
if (null === this.startCellMoveResizeRange) {
if ((targetInfo.cursor == kCurNEResize || targetInfo.cursor == kCurSEResize)) {
this.startCellMoveResizeRange = ar.clone(true);
this.startCellMoveResizeRange2 =
new asc_Range(targetInfo.col, targetInfo.row, targetInfo.col, targetInfo.row, true);
} else {
this.startCellMoveResizeRange = ar.clone(true);
if (colByX < ar.c1) {
colByX = ar.c1;
}
else if ( colByX > ar.c2 ) {
} else if (colByX > ar.c2) {
colByX = ar.c2;
}
if ( rowByY < ar.r1 ) {
if (rowByY < ar.r1) {
rowByY = ar.r1;
}
else if ( rowByY > ar.r2 ) {
} else if (rowByY > ar.r2) {
rowByY = ar.r2;
}
this.startCellMoveResizeRange2 = new asc_Range( colByX, rowByY, colByX, rowByY );
this.startCellMoveResizeRange2 = new asc_Range(colByX, rowByY, colByX, rowByY);
}
return null;
}
......@@ -8661,49 +8660,48 @@
// this.cleanSelection();
this.overlayCtx.clear();
if ( targetInfo.cursor == kCurNEResize || targetInfo.cursor == kCurSEResize ) {
if (targetInfo.cursor == kCurNEResize || targetInfo.cursor == kCurSEResize) {
if ( colByX < this.startCellMoveResizeRange2.c1 ) {
if (colByX < this.startCellMoveResizeRange2.c1) {
ar.c2 = this.startCellMoveResizeRange2.c1;
ar.c1 = colByX;
}
else if ( colByX > this.startCellMoveResizeRange2.c1 ) {
} else if (colByX > this.startCellMoveResizeRange2.c1) {
ar.c1 = this.startCellMoveResizeRange2.c1;
ar.c2 = colByX;
}
else {
} else {
ar.c1 = this.startCellMoveResizeRange2.c1;
ar.c2 = this.startCellMoveResizeRange2.c1
}
if ( rowByY < this.startCellMoveResizeRange2.r1 ) {
if (rowByY < this.startCellMoveResizeRange2.r1) {
ar.r2 = this.startCellMoveResizeRange2.r2;
ar.r1 = rowByY;
}
else if ( rowByY > this.startCellMoveResizeRange2.r1 ) {
} else if (rowByY > this.startCellMoveResizeRange2.r1) {
ar.r1 = this.startCellMoveResizeRange2.r1;
ar.r2 = rowByY;
}
else {
} else {
ar.r1 = this.startCellMoveResizeRange2.r1;
ar.r2 = this.startCellMoveResizeRange2.r1;
}
}
else {
} else {
this.startCellMoveResizeRange.normalize();
var colDelta = this.startCellMoveResizeRange.type != c_oAscSelectionType.RangeRow && this.startCellMoveResizeRange.type != c_oAscSelectionType.RangeMax ? colByX - this.startCellMoveResizeRange2.c1 : 0;
var rowDelta = this.startCellMoveResizeRange.type != c_oAscSelectionType.RangeCol && this.startCellMoveResizeRange.type != c_oAscSelectionType.RangeMax ? rowByY - this.startCellMoveResizeRange2.r1 : 0;
var colDelta = this.startCellMoveResizeRange.type != c_oAscSelectionType.RangeRow &&
this.startCellMoveResizeRange.type != c_oAscSelectionType.RangeMax ?
colByX - this.startCellMoveResizeRange2.c1 : 0;
var rowDelta = this.startCellMoveResizeRange.type != c_oAscSelectionType.RangeCol &&
this.startCellMoveResizeRange.type != c_oAscSelectionType.RangeMax ?
rowByY - this.startCellMoveResizeRange2.r1 : 0;
ar.c1 = this.startCellMoveResizeRange.c1 + colDelta;
if ( 0 > ar.c1 ) {
if (0 > ar.c1) {
colDelta -= ar.c1;
ar.c1 = 0;
}
ar.c2 = this.startCellMoveResizeRange.c2 + colDelta;
ar.r1 = this.startCellMoveResizeRange.r1 + rowDelta;
if ( 0 > ar.r1 ) {
if (0 > ar.r1) {
rowDelta -= ar.r1;
ar.r1 = 0;
}
......@@ -8711,46 +8709,41 @@
}
if ( y <= this.cellsTop + this.height_2px ) {
if (y <= this.cellsTop + this.height_2px) {
d.deltaY = -1;
}
else if ( y >= this.drawingCtx.getHeight() - this.height_2px ) {
} else if (y >= this.drawingCtx.getHeight() - this.height_2px) {
d.deltaY = 1;
}
if ( x <= this.cellsLeft + this.width_2px ) {
if (x <= this.cellsLeft + this.width_2px) {
d.deltaX = -1;
}
else if ( x >= this.drawingCtx.getWidth() - this.width_2px ) {
} else if (x >= this.drawingCtx.getWidth() - this.width_2px) {
d.deltaX = 1;
}
if ( this.startCellMoveResizeRange.type === c_oAscSelectionType.RangeRow ) {
if (this.startCellMoveResizeRange.type === c_oAscSelectionType.RangeRow) {
d.deltaX = 0;
}
else if ( this.startCellMoveResizeRange.type === c_oAscSelectionType.RangeCol ) {
} else if (this.startCellMoveResizeRange.type === c_oAscSelectionType.RangeCol) {
d.deltaY = 0;
}
else if ( this.startCellMoveResizeRange.type === c_oAscSelectionType.RangeMax ) {
} else if (this.startCellMoveResizeRange.type === c_oAscSelectionType.RangeMax) {
d.deltaX = 0;
d.deltaY = 0;
}
if ( 0 == targetInfo.targetArr ) {
if (0 == targetInfo.targetArr) {
var _p = this.arrActiveFormulaRanges[indexFormulaRange].cursorePos, _l = this.arrActiveFormulaRanges[indexFormulaRange].formulaRangeLength;
this.arrActiveFormulaRanges[indexFormulaRange] = ar.clone( true );
this.arrActiveFormulaRanges[indexFormulaRange] = ar.clone(true);
this.arrActiveFormulaRanges[indexFormulaRange].cursorePos = _p;
this.arrActiveFormulaRanges[indexFormulaRange].formulaRangeLength = _l;
newFormulaRange = this.arrActiveFormulaRanges[indexFormulaRange];
}
else {
this.arrActiveChartsRanges[indexFormulaRange] = ar.clone( true );
} else {
this.arrActiveChartsRanges[indexFormulaRange] = ar.clone(true);
this.moveRangeDrawingObjectTo = ar;
}
this._drawSelection();
if ( newFormulaRange ) {
editor.changeCellRange( newFormulaRange );
if (newFormulaRange) {
editor.changeCellRange(newFormulaRange);
}
return d;
......
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