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

update 'si' param check

parent d07d5a60
...@@ -3451,39 +3451,30 @@ Woorksheet.prototype.initPostOpen = function(handlers){ ...@@ -3451,39 +3451,30 @@ Woorksheet.prototype.initPostOpen = function(handlers){
var oCell = elem.cell; var oCell = elem.cell;
var sCellId = g_oCellAddressUtils.getCellId(oCell.nRow, oCell.nCol); var sCellId = g_oCellAddressUtils.getCellId(oCell.nRow, oCell.nCol);
var oFormulaExt = elem.ext; var oFormulaExt = elem.ext;
if (oFormulaExt.t == Asc.ECellFormulaType.cellformulatypeShared) { if (oFormulaExt.t === Asc.ECellFormulaType.cellformulatypeShared && null !== oFormulaExt.si) {
if(null != oFormulaExt.si){ if (null !== oFormulaExt.ref) {
if(null != oFormulaExt.ref){
if (oFormulaExt.v.length <= AscCommon.c_oAscMaxFormulaLength) { if (oFormulaExt.v.length <= AscCommon.c_oAscMaxFormulaLength) {
formulaShared[oFormulaExt.si] = { formulaShared[oFormulaExt.si] = {
fVal: new parserFormula(oFormulaExt.v, "", this), fRef: function(t) { fVal: new parserFormula(oFormulaExt.v, "", this),
var r = t.getRange2(oFormulaExt.ref); fRef: AscCommonExcel.g_oRangeCache.getAscRange(oFormulaExt.ref)
return {
c: r, first: r.first
};
}(this)
}; };
formulaShared[oFormulaExt.si].fVal.parse(); formulaShared[oFormulaExt.si].fVal.parse();
} }
} } else {
else{ var fs = formulaShared[oFormulaExt.si];
if( formulaShared[oFormulaExt.si] ){ if (fs && fs.fRef.contains(oCell.nCol, oCell.nRow)) {
var fr = formulaShared[oFormulaExt.si].fRef; if (false && fs.fVal.isParsed) {
if( fr.c.containCell2(oCell) ){ var off = oCell.getOffset3(fs.fRef.c1, fs.fRef.r1);
if( formulaShared[oFormulaExt.si].fVal.isParsed ){ fs.fVal.changeOffset(off);
var off = oCell.getOffset3(fr.first); oFormulaExt.v = fs.fVal.assemble();
formulaShared[oFormulaExt.si].fVal.changeOffset(off); off.offsetCol *= -1;
oFormulaExt.v = formulaShared[oFormulaExt.si].fVal.assemble(); off.offsetRow *= -1;
off.offsetCol *=-1; fs.fVal.changeOffset(off);
off.offsetRow *=-1;
formulaShared[oFormulaExt.si].fVal.changeOffset(off);
} }
cwf[sCellId] = sCellId; cwf[sCellId] = sCellId;
} }
} }
} }
}
}
if(oFormulaExt.v) { if(oFormulaExt.v) {
if (oFormulaExt.v.length <= AscCommon.c_oAscMaxFormulaLength) { if (oFormulaExt.v.length <= AscCommon.c_oAscMaxFormulaLength) {
oCell.setFormula(oFormulaExt.v); oCell.setFormula(oFormulaExt.v);
...@@ -3804,7 +3795,7 @@ Woorksheet.prototype.setName=function(name, bFromUndoRedo){ ...@@ -3804,7 +3795,7 @@ Woorksheet.prototype.setName=function(name, bFromUndoRedo){
//перестраиваем формулы, если у них были ссылки на лист со старым именем. //перестраиваем формулы, если у них были ссылки на лист со старым именем.
for(var id in this.workbook.cwf) { for(var id in this.workbook.cwf) {
this.workbook.getWorksheetById(id)._ReBuildFormulas(this.workbook.cwf[id],lastName,this.sName); this.workbook.getWorksheetById(id)._ReBuildFormulas(this.workbook.cwf[id]);
} }
this.workbook.dependencyFormulas.relinkDefNameByWorksheet(lastName, name); this.workbook.dependencyFormulas.relinkDefNameByWorksheet(lastName, name);
...@@ -6175,15 +6166,14 @@ Cell.prototype.moveVer=function(val){ ...@@ -6175,15 +6166,14 @@ Cell.prototype.moveVer=function(val){
this.nRow += val; this.nRow += val;
}; };
Cell.prototype.getOffset=function(cell){ Cell.prototype.getOffset=function(cell){
return {offsetCol:(this.nCol - cell.nCol), offsetRow:(this.nRow - cell.nRow)}; return this.getOffset3(cell.nCol - 1, cell.nRow - 1);
}; };
Cell.prototype.getOffset2=function(cellId){ Cell.prototype.getOffset2=function(cellId){
var cAddr2 = new CellAddress(cellId); var cAddr2 = new CellAddress(cellId);
return {offsetCol:(this.nCol - cAddr2.col + 1), offsetRow:(this.nRow - cAddr2.row + 1)}; return this.getOffset3(cAddr2.col, cAddr2.row);
}; };
Cell.prototype.getOffset3=function(cellAddr){ Cell.prototype.getOffset3=function(col, row){
var cAddr2 = cellAddr; return new AscCommonExcel.CRangeOffset((this.nCol - col + 1), (this.nRow - row + 1));
return {offsetCol:(this.nCol - cAddr2.col + 1), offsetRow:(this.nRow - cAddr2.row + 1)};
}; };
Cell.prototype.getValueData = function(){ Cell.prototype.getValueData = function(){
return new UndoRedoData_CellValueData(this.sFormula, this.oValue.clone()); return new UndoRedoData_CellValueData(this.sFormula, this.oValue.clone());
...@@ -8517,7 +8507,7 @@ Range.prototype._shiftUpDown = function (bUp, preDeleteAction, displayNameFormat ...@@ -8517,7 +8507,7 @@ Range.prototype._shiftUpDown = function (bUp, preDeleteAction, displayNameFormat
this.worksheet.workbook.buildRecalc(); this.worksheet.workbook.buildRecalc();
return true; return true;
}; };
Range.prototype.setOffset=function(offset){//offset = {offsetCol:intNumber, offsetRow:intNumber} Range.prototype.setOffset=function(offset){//offset = AscCommonExcel.CRangeOffset
this.bbox.c1 += offset.offsetCol; this.bbox.c1 += offset.offsetCol;
if( this.bbox.c1 < 0 ) if( this.bbox.c1 < 0 )
this.bbox.c1 = 0; this.bbox.c1 = 0;
......
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