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,90 +3439,93 @@ Woorksheet.prototype.copyDrawingObjects=function(oNewWs, wsFrom) ...@@ -3442,90 +3439,93 @@ 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 (null !== oFormulaExt.ref) { if (isShared) {
if (null !== oFormulaExt.ref) {
if (oFormulaExt.v.length <= AscCommon.c_oAscMaxFormulaLength) {
oCell.formulaParsed = new parserFormula(oFormulaExt.v, sCellId, this);
oCell.formulaParsed.parse();
oCell.formulaParsed.buildDependencies();
formulaShared[oFormulaExt.si] = {
fVal: oCell.formulaParsed,
fRef: AscCommonExcel.g_oRangeCache.getAscRange(oFormulaExt.ref)
};
}
} else {
var fs = formulaShared[oFormulaExt.si];
if (fs && fs.fRef.contains(oCell.nCol, oCell.nRow)) {
if (fs.fVal.isParsed) {
var off = oCell.getOffset3(fs.fRef.c1 + 1, fs.fRef.r1 + 1);
oCell.formulaParsed = fs.fVal.clone(null, sCellId, this);
oCell.formulaParsed.changeOffset(off);
oCell.formulaParsed.buildDependencies();
oFormulaExt.v = oCell.formulaParsed.assemble();
}
}
}
}
if (oFormulaExt.v) {
if (oFormulaExt.v.length <= AscCommon.c_oAscMaxFormulaLength) { if (oFormulaExt.v.length <= AscCommon.c_oAscMaxFormulaLength) {
formulaShared[oFormulaExt.si] = { oCell.setFormula(oFormulaExt.v);
fVal: new parserFormula(oFormulaExt.v, "", this), if (oFormulaExt.ca) {
fRef: AscCommonExcel.g_oRangeCache.getAscRange(oFormulaExt.ref) oCell.sFormulaCA = true;
}; }
formulaShared[oFormulaExt.si].fVal.parse(); } else {
this.workbook.openErrors.push(oCell.getName());
} }
}
// Если ячейка содержит в себе формулу, то добавляем ее в список ячеек с формулами. (Shared-формулу мы уже распарсили)
if (isShared) {
cwf[sCellId] = null;
} else { } else {
var fs = formulaShared[oFormulaExt.si]; if (oCell.sFormula) {
if (fs && fs.fRef.contains(oCell.nCol, oCell.nRow)) {
if (fs.fVal.isParsed) {
var off = oCell.getOffset3(fs.fRef.c1 + 1, fs.fRef.r1 + 1);
fs.fVal.changeOffset(off);
oFormulaExt.v = fs.fVal.assemble();
off.offsetCol *= -1;
off.offsetRow *= -1;
fs.fVal.changeOffset(off);
}
cwf[sCellId] = sCellId; cwf[sCellId] = sCellId;
} }
} }
// Строится список ячеек, которые необходимо пересчитать при открытии. Это ячейки имеющие атрибут f.ca или значение в которых неопределено.
if (oCell.sFormula && (oFormulaExt.ca || !oCell.oValue.getValueWithoutFormat())) {
this.workbook.needRecalc.nodes[getVertexId(this.Id, sCellId)] = [this.Id, sCellId];
this.workbook.needRecalc.length++;
}
} }
if(oFormulaExt.v) { this.aFormulaExt = null;
if (oFormulaExt.v.length <= AscCommon.c_oAscMaxFormulaLength) {
oCell.setFormula(oFormulaExt.v);
if(oFormulaExt.ca) {
oCell.sFormulaCA = true;
}
} else {
this.workbook.openErrors.push(oCell.getName());
}
}
/*
Если ячейка содержит в себе формулу, то добавляем ее в список ячеек с формулами.
*/
if(oCell.sFormula){
cwf[sCellId] = sCellId;
}
/*
Строится список ячеек, которые необходимо пересчитать при открытии. Это ячейки имеющие атрибут f.ca или значение в которых неопределено.
*/
if(oCell.sFormula && (oFormulaExt.ca || !oCell.oValue.getValueWithoutFormat()) ){
this.workbook.needRecalc.nodes[ getVertexId( this.Id, sCellId ) ] = [this.Id, sCellId];
this.workbook.needRecalc.length++;
}
} }
this.aFormulaExt = null;
}
if (!this.PagePrintOptions) {
// Даже если не было, создадим
this.PagePrintOptions = new Asc.asc_CPageOptions();
}
this.PagePrintOptions.init();
// Sheet Views if (!this.PagePrintOptions) {
if (0 === this.sheetViews.length) { // Даже если не было, создадим
// Даже если не было, создадим this.PagePrintOptions = new Asc.asc_CPageOptions();
this.sheetViews.push(new AscCommonExcel.asc_CSheetViewSettings()); }
} this.PagePrintOptions.init();
if (window['IS_NATIVE_EDITOR']) { // Sheet Views
for (var j = this.sheetViews.length - 1; j >= 0; --j) { if (0 === this.sheetViews.length) {
this.sheetViews[j].pane = null; // Даже если не было, создадим
} this.sheetViews.push(new AscCommonExcel.asc_CSheetViewSettings());
} }
this._updateConditionalFormatting(null); if (window['IS_NATIVE_EDITOR']) {
for (var j = this.sheetViews.length - 1; j >= 0; --j) {
this.handlers = handlers; this.sheetViews[j].pane = null;
this._setHandlersTablePart(); }
}; }
this._updateConditionalFormatting(null);
this.handlers = handlers;
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