Commit 9ed6855e authored by Alexander.Trofimov's avatar Alexander.Trofimov

remade opening files with Shared-formulas ('si' attribute).

now we parse on init this formulas on master cells and do clone + offset on subsequent cells (later we do parse*2 + 2*offset)
parent c536f7fe
...@@ -2733,9 +2733,6 @@ Workbook.prototype.getUniqueDefinedNameFrom=function(name, bCopy){ ...@@ -2733,9 +2733,6 @@ Workbook.prototype.getUniqueDefinedNameFrom=function(name, bCopy){
return dnNewName; return dnNewName;
}; };
Workbook.prototype.buildDependency = function(){ Workbook.prototype.buildDependency = function(){
this.dependencyFormulas.clear();
// this.dependencyFormulas = null;
// this.dependencyFormulas = new DependencyGraph(this);
for(var i in this.cwf){ for(var i in this.cwf){
this.getWorksheetById(i)._BuildDependencies(this.cwf[i]); this.getWorksheetById(i)._BuildDependencies(this.cwf[i]);
} }
...@@ -3442,43 +3439,45 @@ Woorksheet.prototype.copyDrawingObjects=function(oNewWs, wsFrom) ...@@ -3442,43 +3439,45 @@ Woorksheet.prototype.copyDrawingObjects=function(oNewWs, wsFrom)
drawingObjects.updateChartReferences2(parserHelp.getEscapeSheetName(wsFrom.sName), parserHelp.getEscapeSheetName(oNewWs.sName)); drawingObjects.updateChartReferences2(parserHelp.getEscapeSheetName(wsFrom.sName), parserHelp.getEscapeSheetName(oNewWs.sName));
} }
}; };
Woorksheet.prototype.initPostOpen = function(handlers){ Woorksheet.prototype.initPostOpen = function (handlers) {
var cwf = this.workbook.cwf[this.Id]={}; var cwf = this.workbook.cwf[this.Id] = {};
if(this.aFormulaExt){ if (this.aFormulaExt) {
var formulaShared = {}; var formulaShared = {};
for(var i = 0; i < this.aFormulaExt.length; ++i){ for (var i = 0; i < this.aFormulaExt.length; ++i) {
var elem = this.aFormulaExt[i]; var elem = this.aFormulaExt[i];
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 && null !== oFormulaExt.si) { var isShared = oFormulaExt.t === Asc.ECellFormulaType.cellformulatypeShared && null !== oFormulaExt.si;
if (isShared) {
if (null !== oFormulaExt.ref) { if (null !== oFormulaExt.ref) {
if (oFormulaExt.v.length <= AscCommon.c_oAscMaxFormulaLength) { if (oFormulaExt.v.length <= AscCommon.c_oAscMaxFormulaLength) {
oCell.formulaParsed = new parserFormula(oFormulaExt.v, sCellId, this);
oCell.formulaParsed.parse();
oCell.formulaParsed.buildDependencies();
formulaShared[oFormulaExt.si] = { formulaShared[oFormulaExt.si] = {
fVal: new parserFormula(oFormulaExt.v, "", this), fVal: oCell.formulaParsed,
fRef: AscCommonExcel.g_oRangeCache.getAscRange(oFormulaExt.ref) fRef: AscCommonExcel.g_oRangeCache.getAscRange(oFormulaExt.ref)
}; };
formulaShared[oFormulaExt.si].fVal.parse();
} }
} else { } else {
var fs = formulaShared[oFormulaExt.si]; var fs = formulaShared[oFormulaExt.si];
if (fs && fs.fRef.contains(oCell.nCol, oCell.nRow)) { if (fs && fs.fRef.contains(oCell.nCol, oCell.nRow)) {
if (fs.fVal.isParsed) { if (fs.fVal.isParsed) {
var off = oCell.getOffset3(fs.fRef.c1 + 1, fs.fRef.r1 + 1); var off = oCell.getOffset3(fs.fRef.c1 + 1, fs.fRef.r1 + 1);
fs.fVal.changeOffset(off);
oFormulaExt.v = fs.fVal.assemble(); oCell.formulaParsed = fs.fVal.clone(null, sCellId, this);
off.offsetCol *= -1; oCell.formulaParsed.changeOffset(off);
off.offsetRow *= -1; oCell.formulaParsed.buildDependencies();
fs.fVal.changeOffset(off); oFormulaExt.v = oCell.formulaParsed.assemble();
} }
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);
if(oFormulaExt.ca) { if (oFormulaExt.ca) {
oCell.sFormulaCA = true; oCell.sFormulaCA = true;
} }
} else { } else {
...@@ -3486,17 +3485,18 @@ Woorksheet.prototype.initPostOpen = function(handlers){ ...@@ -3486,17 +3485,18 @@ Woorksheet.prototype.initPostOpen = function(handlers){
} }
} }
/* // Если ячейка содержит в себе формулу, то добавляем ее в список ячеек с формулами. (Shared-формулу мы уже распарсили)
Если ячейка содержит в себе формулу, то добавляем ее в список ячеек с формулами. if (isShared) {
*/ cwf[sCellId] = null;
if(oCell.sFormula){ } else {
if (oCell.sFormula) {
cwf[sCellId] = sCellId; cwf[sCellId] = sCellId;
} }
/* }
Строится список ячеек, которые необходимо пересчитать при открытии. Это ячейки имеющие атрибут f.ca или значение в которых неопределено.
*/ // Строится список ячеек, которые необходимо пересчитать при открытии. Это ячейки имеющие атрибут f.ca или значение в которых неопределено.
if(oCell.sFormula && (oFormulaExt.ca || !oCell.oValue.getValueWithoutFormat()) ){ if (oCell.sFormula && (oFormulaExt.ca || !oCell.oValue.getValueWithoutFormat())) {
this.workbook.needRecalc.nodes[ getVertexId( this.Id, sCellId ) ] = [this.Id, sCellId]; this.workbook.needRecalc.nodes[getVertexId(this.Id, sCellId)] = [this.Id, sCellId];
this.workbook.needRecalc.length++; this.workbook.needRecalc.length++;
} }
} }
...@@ -3525,7 +3525,7 @@ Woorksheet.prototype.initPostOpen = function(handlers){ ...@@ -3525,7 +3525,7 @@ Woorksheet.prototype.initPostOpen = function(handlers){
this.handlers = handlers; this.handlers = handlers;
this._setHandlersTablePart(); this._setHandlersTablePart();
}; };
Woorksheet.prototype._getValuesForConditionalFormatting = function(sqref, withEmpty) { Woorksheet.prototype._getValuesForConditionalFormatting = function(sqref, withEmpty) {
var range = this.getRange3(sqref.r1, sqref.c1, sqref.r2, sqref.c2); var range = this.getRange3(sqref.r1, sqref.c1, sqref.r2, sqref.c2);
return range._getValues(withEmpty); return range._getValues(withEmpty);
...@@ -5205,6 +5205,11 @@ Woorksheet.prototype._BuildDependencies=function(cellRange){ ...@@ -5205,6 +5205,11 @@ Woorksheet.prototype._BuildDependencies=function(cellRange){
*/ */
var c, ca, oLengthCache = {}; var c, ca, oLengthCache = {};
for(var i in cellRange){ for(var i in cellRange){
if (null === cellRange[i]) {
cellRange[i] = i;
continue;
}
ca = g_oCellAddressUtils.getCellAddress(i); ca = g_oCellAddressUtils.getCellAddress(i);
c = this._getCellNoEmpty(ca.getRow0(),ca.getCol0()); c = this._getCellNoEmpty(ca.getRow0(),ca.getCol0());
......
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