Commit a3eb1ce7 authored by Dmitry.Shahtanov's avatar Dmitry.Shahtanov Committed by Alexander.Trofimov

Fixed issue #31882

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@68732 954022d7-b5bf-4e40-9824-e11837661b57
parent cbfbdeb9
...@@ -1653,11 +1653,12 @@ cStrucTable.prototype.createArea = function ( val, cell ) { ...@@ -1653,11 +1653,12 @@ cStrucTable.prototype.createArea = function ( val, cell ) {
this.area = new cError( cErrorType.bad_reference ); this.area = new cError( cErrorType.bad_reference );
return; return;
} }
if( this.tableData.range ){
this.area = this.tableData.range.isOneCell() ? this.area = this.tableData.range.isOneCell() ?
new cRef3D( this.tableData.range.getAbsName(), this.wb.getWorksheetById( this.tableData.wsID ).getName(), this.wb ): new cRef3D( this.tableData.range.getAbsName(), this.wb.getWorksheetById( this.tableData.wsID ).getName(), this.wb ):
new cArea3D( this.tableData.range.getAbsName(), this.wb.getWorksheetById( this.tableData.wsID ).getName(), this.wb.getWorksheetById( this.tableData.wsID ).getName(), this.wb ); new cArea3D( this.tableData.range.getAbsName(), this.wb.getWorksheetById( this.tableData.wsID ).getName(), this.wb.getWorksheetById( this.tableData.wsID ).getName(), this.wb );
} }
}
else if ( val['reservedColumn'] || !val['columnName'] ) { else if ( val['reservedColumn'] || !val['columnName'] ) {
this.reservedColumn = val['reservedColumn'] || ""; this.reservedColumn = val['reservedColumn'] || "";
this.reservedColumnIndex = paramObj.param = getColumnType( this.reservedColumn ); this.reservedColumnIndex = paramObj.param = getColumnType( this.reservedColumn );
...@@ -1667,11 +1668,12 @@ cStrucTable.prototype.createArea = function ( val, cell ) { ...@@ -1667,11 +1668,12 @@ cStrucTable.prototype.createArea = function ( val, cell ) {
this.area = new cError( cErrorType.bad_reference ); this.area = new cError( cErrorType.bad_reference );
return; return;
} }
if( this.tableData.range ){
this.area = this.tableData.range.isOneCell() ? this.area = this.tableData.range.isOneCell() ?
new cRef3D( this.tableData.range.getAbsName(), this.wb.getWorksheetById( this.tableData.wsID ).getName(), this.wb ): new cRef3D( this.tableData.range.getAbsName(), this.wb.getWorksheetById( this.tableData.wsID ).getName(), this.wb ):
new cArea3D( this.tableData.range.getAbsName(), this.wb.getWorksheetById( this.tableData.wsID ).getName(), this.wb.getWorksheetById( this.tableData.wsID ).getName(), this.wb ); new cArea3D( this.tableData.range.getAbsName(), this.wb.getWorksheetById( this.tableData.wsID ).getName(), this.wb.getWorksheetById( this.tableData.wsID ).getName(), this.wb );
} }
}
else if ( val['hdtcc'] ) { else if ( val['hdtcc'] ) {
this.hdt = val['hdt']; this.hdt = val['hdt'];
this.hdtIndexes = []; this.hdtIndexes = [];
...@@ -1736,11 +1738,12 @@ cStrucTable.prototype.createArea = function ( val, cell ) { ...@@ -1736,11 +1738,12 @@ cStrucTable.prototype.createArea = function ( val, cell ) {
this.tableData = data; this.tableData = data;
this.tableData.range = range; this.tableData.range = range;
if( range ){
this.area = range.isOneCell() ? this.area = range.isOneCell() ?
new cRef3D( range.getAbsName(), this.wb.getWorksheetById( this.tableData.wsID ).getName(), this.wb ): new cRef3D( range.getAbsName(), this.wb.getWorksheetById( this.tableData.wsID ).getName(), this.wb ):
new cArea3D( range.getAbsName(), this.wb.getWorksheetById( this.tableData.wsID ).getName(), this.wb.getWorksheetById( this.tableData.wsID ).getName(), this.wb ); new cArea3D( range.getAbsName(), this.wb.getWorksheetById( this.tableData.wsID ).getName(), this.wb.getWorksheetById( this.tableData.wsID ).getName(), this.wb );
} }
}
!this.area ? this.area = new cError( cErrorType.bad_reference ) : null; !this.area ? this.area = new cError( cErrorType.bad_reference ) : null;
return this.area; return this.area;
......
...@@ -4523,9 +4523,9 @@ TablePart.prototype.getTableRangeForFormula = function(objectParam) ...@@ -4523,9 +4523,9 @@ TablePart.prototype.getTableRangeForFormula = function(objectParam)
} }
case g_nFormulaTablePartInfo.thisRow: case g_nFormulaTablePartInfo.thisRow:
{ {
if( this.Ref.containsRange( objectParam.cell ) ){ // if( this.Ref.containsRange( objectParam.cell ) ){
res = new Asc.Range( this.Ref.c1, objectParam.cell.r1, this.Ref.c2, objectParam.cell.r1 ); res = new Asc.Range( this.Ref.c1, objectParam.cell.r1, this.Ref.c2, objectParam.cell.r1 );
} // }
break; break;
} }
case g_nFormulaTablePartInfo.columns: case g_nFormulaTablePartInfo.columns:
......
...@@ -813,20 +813,22 @@ ...@@ -813,20 +813,22 @@
// var __e__ = new Date().getTime(); // var __e__ = new Date().getTime();
// console.log("e-s "+ (__e__ - __s__)); // console.log("e-s "+ (__e__ - __s__));
this._formula = new parserFormula( s.substr( 1 ), "A1", ws ); this._formula = new parserFormula( s.substr( 1 ), this.options.cellName, ws );
this._formula.parse(); this._formula.parse();
var r, offset, _e, _s, wsName = null; var r, offset, _e, _s, wsName = null, refStr, isName = false;
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;
isName = false;
r = this._formula.RefPos[index]; r = this._formula.RefPos[index];
offset = r.end; offset = r.end;
_e = r.end; _e = r.end;
_s = r.start; _s = r.start;
switch ( r.oper.type ) { switch ( r.oper.type ) {
case cElementType.cell : case cElementType.cell :
{ {
...@@ -834,6 +836,7 @@ ...@@ -834,6 +836,7 @@
wsName = wsOPEN.model.getName(); wsName = wsOPEN.model.getName();
} }
ret = true; ret = true;
refStr = r.oper.value;
break; break;
} }
case cElementType.cell3D : case cElementType.cell3D :
...@@ -841,6 +844,7 @@ ...@@ -841,6 +844,7 @@
ret = true; ret = true;
wsName = r.oper.ws.getName(); wsName = r.oper.ws.getName();
_s = _e - r.oper.value.length; _s = _e - r.oper.value.length;
refStr = r.oper.value;
break; break;
} }
case cElementType.cellsRange : case cElementType.cellsRange :
...@@ -849,6 +853,7 @@ ...@@ -849,6 +853,7 @@
wsName = wsOPEN.model.getName(); wsName = wsOPEN.model.getName();
} }
ret = true; ret = true;
refStr = r.oper.value;
break; break;
} }
case cElementType.cellsRange3D : case cElementType.cellsRange3D :
...@@ -857,36 +862,46 @@ ...@@ -857,36 +862,46 @@
continue; continue;
} }
ret = true; ret = true;
refStr = r.oper.value;
wsName = r.oper.getWS().getName(); wsName = r.oper.getWS().getName();
_s = _e - r.oper.value.length; _s = _e - r.oper.value.length;
break; break;
} }
/*case cElementType.name :{ case cElementType.name :
{
continue; continue;
var nameRef = r.oper.toRef(); /*var nameRef = r.oper.toRef();
switch( nameRef.type ){ if( nameRef instanceof cError ) continue;
case cElementType.cellsRange :{ switch ( nameRef.type ) {
break;
}
case cElementType.cellsRange3D :{ case cElementType.cellsRange3D :{
break; if ( !r.oper.isSingleSheet() ) {
} continue;
case cElementType.cell3D :{
break;
} }
} }
case cElementType.cellsRange :
case cElementType.cell3D :
{
ret = true;
refStr = nameRef.value;
wsName = nameRef.getWS().getName(); wsName = nameRef.getWS().getName();
_s = _e - r.oper.value.length;
break; break;
}*/ }
}
isName = true;
break;*/
}
default : default :
continue; continue;
} }
if ( ret ) { if ( ret ) {
range = t._parseRangeStr( r.oper.value ); range = t._parseRangeStr( refStr );
if(!range) return false; if(!range) return false;
range.cursorePos = offset - (_e - _s) + 1; range.cursorePos = offset - (_e - _s) + 1;
range.formulaRangeLength = _e - _s; range.formulaRangeLength = _e - _s;
if(isName)range.isName = isName;
t.handlers.trigger( "newRange", range, wsName ); t.handlers.trigger( "newRange", range, wsName );
} }
} }
...@@ -898,14 +913,14 @@ ...@@ -898,14 +913,14 @@
var t = this, var t = this,
s = t.textRender.getChars( 0, t.textRender.getCharsCount() ), s = t.textRender.getChars( 0, t.textRender.getCharsCount() ),
range, range,
arrFR = this.handlers.trigger( "getFormulaRanges" ); 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 невалидная ссылка.
* */ * */
var 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 ) {
return {index: a.cursorePos, length: a.formulaRangeLength, range: a.clone( true )}; return {index: a.cursorePos, length: a.formulaRangeLength, range: a.clone( true )};
} }
...@@ -916,7 +931,7 @@ ...@@ -916,7 +931,7 @@
wsOPEN = this.handlers.trigger( "getCellFormulaEnterWSOpen" ), wsOPEN = this.handlers.trigger( "getCellFormulaEnterWSOpen" ),
ws = wsOPEN ? wsOPEN.model : this.handlers.trigger( "getActiveWS" ); ws = wsOPEN ? wsOPEN.model : this.handlers.trigger( "getActiveWS" );
this._formula = new parserFormula( s.substr( 1 ), "A1", ws ); this._formula = new 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 ) {
......
...@@ -3544,7 +3544,7 @@ ...@@ -3544,7 +3544,7 @@
} }
// Отрисовка квадратов для move/resize // Отрисовка квадратов для move/resize
if ( fillColor ) { if ( fillColor && !range.isName ) {
if ( drawLeftSide && drawTopSide ) { if ( drawLeftSide && drawTopSide ) {
ctx.fillRect( x1 - this.width_1px, y1 - this.height_1px, this.width_4px, this.height_4px ); ctx.fillRect( x1 - this.width_1px, y1 - this.height_1px, this.width_4px, this.height_4px );
} }
...@@ -4010,7 +4010,7 @@ ...@@ -4010,7 +4010,7 @@
var strokeColor, fillColor, colorIndex, uniqueColorIndex = 0, tmpColors = []; var strokeColor, fillColor, colorIndex, uniqueColorIndex = 0, tmpColors = [];
for ( i = 0; i < arrRanges.length; ++i ) { for ( i = 0; i < arrRanges.length; ++i ) {
var oFormulaRange = arrRanges[i].clone( true ); var oFormulaRange = arrRanges[i].clone( true );
if(arrRanges[i].isName)oFormulaRange.isName=true;
colorIndex = asc.getUniqueRangeColor( arrRanges, i, tmpColors ); colorIndex = asc.getUniqueRangeColor( arrRanges, i, tmpColors );
if ( null == colorIndex ) { if ( null == colorIndex ) {
colorIndex = uniqueColorIndex++; colorIndex = uniqueColorIndex++;
...@@ -6143,8 +6143,9 @@ ...@@ -6143,8 +6143,9 @@
var arrRanges = this.isFormulaEditMode ? this.arrActiveFormulaRanges : this.arrActiveChartsRanges, targetArr = this.isFormulaEditMode ? 0 : -1; var arrRanges = this.isFormulaEditMode ? this.arrActiveFormulaRanges : this.arrActiveChartsRanges, targetArr = this.isFormulaEditMode ? 0 : -1;
for ( i = 0, l = arrRanges.length; i < l; ++i ) { for ( i = 0, l = arrRanges.length; i < l; ++i ) {
oFormulaRange = arrRanges[i].clone( true ); oFormulaRange = arrRanges[i].clone( true );
oFormulaRange.isName = arrRanges[i].isName;
oFormulaRangeIn = oFormulaRange.intersectionSimple( vr ); oFormulaRangeIn = oFormulaRange.intersectionSimple( vr );
if ( oFormulaRangeIn ) { if ( oFormulaRangeIn && !oFormulaRange.isName ) {
xFormula1 = this.cols[oFormulaRangeIn.c1].left - offsetX; xFormula1 = this.cols[oFormulaRangeIn.c1].left - offsetX;
xFormula2 = this.cols[oFormulaRangeIn.c2].left + this.cols[oFormulaRangeIn.c2].width - offsetX; xFormula2 = this.cols[oFormulaRangeIn.c2].left + this.cols[oFormulaRangeIn.c2].width - offsetX;
yFormula1 = this.rows[oFormulaRangeIn.r1].top - offsetY; yFormula1 = this.rows[oFormulaRangeIn.r1].top - offsetY;
......
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