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

fix bug 32901

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