Commit 48b8edcd authored by konovalovsergey's avatar konovalovsergey

fix errors

parent 082674b0
......@@ -315,7 +315,7 @@
};
CFormulaCF.prototype.init = function(ws) {
if (!this._f) {
this._f = new AscCommonExcel.parserFormula(this.Text, '', ws);
this._f = new AscCommonExcel.parserFormula(this.Text, null, ws);
this._f.parse();
}
};
......
......@@ -3584,23 +3584,28 @@ function parserFormula( formula, parent, _ws ) {
return this.isDirty;
};
parserFormula.prototype.setIsDirty = function(isDirty) {
if(isDirty && !this.isDirty){
this.wb.dependencyFormulas.addToFormulaTrack(this.parent);
}
this.isDirty = isDirty;
};
parserFormula.prototype.notify = function(data) {
if (AscCommon.c_oNotifyType.Dirty === data.type) {
this.setIsDirty(true);
if (this.parent && this.parent.onDirty) {
this.parent.onDirty();
if (!this.isDirty) {
this.isDirty = true;
if (this.parent && this.parent.onFormulaEvent) {
this.parent.onFormulaEvent(AscCommon.c_oNotifyParentType.Change);
}
}
} else if (AscCommon.c_oNotifyType.Changed === data.type) {
if (this.parent && this.parent.onFormulaEvent) {
this.parent.onFormulaEvent(AscCommon.c_oNotifyParentType.Change);
}
} else {
var oldFormula = this.Formula;
if (AscCommon.c_oNotifyType.Shift === data.type || AscCommon.c_oNotifyType.Move === data.type ||
AscCommon.c_oNotifyType.Delete === data.type) {
this.shiftCells2(data.type, data.sheetId, data.bbox, data.offset);
this.wb.dependencyFormulas.addToChangedElem(this.parent);
if (this.parent && this.parent.onFormulaEvent) {
this.parent.onFormulaEvent(AscCommon.c_oNotifyParentType.Change);
}
} else if (AscCommon.c_oNotifyType.ChangeDefName === data.type) {
this.changeDefName(data.from, data.to);
} else if (AscCommon.c_oNotifyType.Rebuild === data.type) {
......@@ -3618,8 +3623,8 @@ function parserFormula( formula, parent, _ws ) {
}
}
}
if (this.parent && this.parent.onChangeFormula && oldFormula !== this.Formula) {
this.parent.onChangeFormula(oldFormula, this.Formula);
if (this.parent && this.parent.onFormulaEvent && oldFormula !== this.Formula) {
this.parent.onFormulaEvent(AscCommon.c_oNotifyParentType.ChangeFormula, {from: oldFormula, to: this.Formula});
}
}
};
......@@ -4225,19 +4230,15 @@ parserFormula.prototype.parse = function(local, digitDelim) {
};
parserFormula.prototype.calculate = function(opt_defName, opt_range) {
this.isDirty = false;
if (this.isCalculate) {
this.value = new cError(cErrorType.bad_reference);
this._updateCellValue();
this.isCalculate = false;
this._endCalculate();
return this.value;
}
this.isCalculate = true;
if (this.outStack.length < 1) {
this.value = new cError(cErrorType.wrong_name);
this._updateCellValue();
this.isCalculate = false;
this._endCalculate();
return this.value;
}
var rangeCell = null;
......@@ -4262,8 +4263,7 @@ parserFormula.prototype.calculate = function(opt_defName, opt_range) {
if (elemArr.length < currentElement.getArguments()) {
elemArr = [];
this.value = new cError(cErrorType.unsupported_function);
this._updateCellValue();
this.isCalculate = false;
this._endCalculate();
return this.value;
} else {
var arg = [];
......@@ -4289,67 +4289,16 @@ parserFormula.prototype.calculate = function(opt_defName, opt_range) {
this.value = elemArr.pop();
this.value.numFormat = numFormat;
this._updateCellValue();
this.isCalculate = false;
this._endCalculate();
return this.value;
};
parserFormula.prototype._calculateRefType = function(cell) {
var val = this.value;
if (val.type == cElementType.cell || val.type == cElementType.cell3D) {
var nF = val.numFormat;
val = val.getValue();
val.numFormat = nF;
}
else if (val.type == cElementType.array) {
var nF = val.numFormat;
val = val.getElement(0);
val.numFormat = nF;
}
else if (val.type == cElementType.cellsRange || val.type == cElementType.cellsRange3D) {
var nF = val.numFormat;
val = val.cross(new CellAddress(cell.nRow, cell.nCol), cell.ws.getId());
// val = val.getElementByCell(new CellAddress(cell));
val.numFormat = nF;
}
this.value = val;
}
parserFormula.prototype._updateCellValue = function() {
var __cell = this.parent;
if (!(__cell instanceof AscCommonExcel.Cell)) {
return;
}
this._calculateRefType(__cell);
var res = this.value;
if (__cell && res) {
__cell.oValue.clean();
switch (res.type) {
case cElementType.number:
__cell.oValue.type = CellValueType.Number;
__cell.oValue.number = res.getValue();
break;
case cElementType.bool:
__cell.oValue.type = CellValueType.Bool;
__cell.oValue.number = res.value ? 1 : 0;
break;
case cElementType.error:
__cell.oValue.type = CellValueType.Error;
__cell.oValue.text = res.getValue().toString();
break;
case cElementType.name:
__cell.oValue.type = CellValueType.Error;
__cell.oValue.text = res.getValue().toString();
break;
default:
__cell.oValue.type = CellValueType.String;
__cell.oValue.text = res.getValue().toString();
}
this.wb.dependencyFormulas.addToCleanCellCache(__cell.ws.getId(), __cell.nRow, __cell.nCol);
AscCommonExcel.g_oVLOOKUPCache.remove(__cell);
AscCommonExcel.g_oHLOOKUPCache.remove(__cell);
//todo
this.ca = res.ca;
}
parserFormula.prototype._endCalculate = function() {
if (this.parent && this.parent.onFormulaEvent) {
this.parent.onFormulaEvent(AscCommon.c_oNotifyParentType.EndCalculate);
}
this.isCalculate = false;
this.isDirty = false;
};
/* Метод возвращает все ссылки на ячейки которые участвуют в формуле*/
parserFormula.prototype.getRef = function() {
......@@ -4495,6 +4444,7 @@ parserFormula.prototype.getRef = function() {
if (isIntersect) {
var isNoDelete;
if (AscCommon.c_oNotifyType.Shift == notifyType) {
_cellsBbox = _cellsBbox.clone();
isNoDelete = _cellsBbox.forShift(bbox, offset);
} else if (AscCommon.c_oNotifyType.Move == notifyType) {
isNoDelete = true;
......@@ -4503,7 +4453,7 @@ parserFormula.prototype.getRef = function() {
}
if (isNoDelete) {
elem.value = elem._cells =
_cellsBbox.getAbsName2(elem.isAbsoluteCol1, elem.sisAbsoluteRow1, elem.isAbsoluteCol2,
_cellsBbox.getAbsName2(elem.isAbsoluteCol1, elem.isAbsoluteRow1, elem.isAbsoluteCol2,
elem.isAbsoluteRow2);
if (elem instanceof cRef || elem instanceof cArea) {
elem.range = elem.ws.getRange3(_cellsBbox.r1, _cellsBbox.c1, _cellsBbox.r2, _cellsBbox.c2);
......
......@@ -1535,7 +1535,6 @@ function UndoRedoData_SheetAdd(insertBefore, name, sheetidfrom, sheetid, tableNa
this.sheetid = sheetid;
//Эти поля заполняются после Undo/Redo
this.sheet = null;
this.cwf = null;
this.tableNames = tableNames;
}
......@@ -1574,12 +1573,11 @@ var g_oUndoRedoData_SheetRemoveProperties = {
sheetId: 0,
sheet: 1
};
function UndoRedoData_SheetRemove(index, sheetId, sheet, cwf){
function UndoRedoData_SheetRemove(index, sheetId, sheet){
this.Properties = g_oUndoRedoData_SheetRemoveProperties;
this.index = index;
this.sheetId = sheetId;
this.sheet = sheet;
this.cwf = cwf;
}
UndoRedoData_SheetRemove.prototype = {
getType : function()
......@@ -2813,19 +2811,18 @@ UndoRedoWorkbook.prototype = {
Data.insertBefore = 0;
if(bUndo)
{
var outputParams = {sheet: null, cwf: null};
var outputParams = {sheet: null};
this.wb.removeWorksheet(Data.insertBefore, outputParams);
//сохраняем тот sheet который удалили, иначе может возникнуть ошибка, если какой-то обьект запоминал ссылку на sheet(например):
//Добавляем лист -> Добавляем ссылку -> undo -> undo -> redo -> redo
Data.sheet = outputParams.sheet;
Data.cwf = outputParams.cwf;
}
else
{
if(null != Data.sheet)
{
//сюда заходим только если до этого было сделано Undo
this.wb.insertWorksheet(Data.insertBefore, Data.sheet, Data.cwf);
this.wb.insertWorksheet(Data.insertBefore, Data.sheet);
}
else
{
......@@ -2857,7 +2854,7 @@ UndoRedoWorkbook.prototype = {
{
if(bUndo)
{
this.wb.insertWorksheet(Data.index, Data.sheet, Data.cwf);
this.wb.insertWorksheet(Data.index, Data.sheet);
}
else
{
......@@ -3157,6 +3154,7 @@ UndoRedoWoorksheet.prototype = {
nCol = Data.nCol;
if(bUndo)
{
//todo
var oCellAddres = new CellAddress(nRow, nCol, 0);
var node = ws.workbook.dependencyFormulas.addNode(ws.getId(), oCellAddres.getID());
if (node)
......@@ -3512,7 +3510,6 @@ UndoRedoWoorksheet.prototype = {
if(null != oConflictWs)
oConflictWs.renameWsToCollaborate(this.wb.getUniqueSheetNameFrom(oConflictWs.getName(), true));
}
AscCommonExcel.buildDefNameAfterRenameWorksheet(ws);
}
ws.setName(name, true);
}
......
This diff is collapsed.
......@@ -336,10 +336,10 @@
this.setOffset(offset);
}
} else {
if (this.c1 > bbox.c1) {
this.setOffset(offset);
} else {
if (this.c1 < bbox.c1) {
this.setOffsetLast(offset);
} else {
this.setOffset(offset);
}
}
} else {
......@@ -360,10 +360,10 @@
this.setOffset(offset);
}
} else {
if (this.r1 > bbox.r1) {
this.setOffset(offset);
} else {
if (this.r1 < bbox.r1) {
this.setOffsetLast(offset);
} else {
this.setOffset(offset);
}
}
}
......
......@@ -9578,7 +9578,7 @@
var nameFormat = false;
//}
if ( currentObj[0].cellFrom ) {
var offset = range.getCells()[0].getOffset2( currentObj[0].cellFrom ), assemb, _p_ = new AscCommonExcel.parserFormula( currentObj[0].text.substring( 1 ), "", range.worksheet );
var offset = range.getCells()[0].getOffset2( currentObj[0].cellFrom ), assemb, _p_ = new AscCommonExcel.parserFormula( currentObj[0].text.substring( 1 ), null, range.worksheet );
if ( _p_.parse() ) {
assemb = _p_.changeOffset( offset ).assemble();
......@@ -9952,7 +9952,7 @@
//formula
if ( newVal.getFormula() && !isOneMerge ) {
var offset = range.getCells()[numFormula].getOffset2( value2[numFormula].sId ), assemb,
_p_ = new AscCommonExcel.parserFormula( value2[numFormula].sFormula, firstRange.getName() ? firstRange.getName() : "", range.worksheet );
_p_ = new AscCommonExcel.parserFormula( value2[numFormula].sFormula, null, range.worksheet );
if ( _p_.parse() ) {
assemb = _p_.changeOffset( offset ).assemble();
......
......@@ -816,9 +816,16 @@ var c_oAscPrintDefaultSettings = {
Shift: 1,
Move: 2,
Delete: 3,
ChangeDefName: 4,
Rebuild: 5,
ChangeSheet: 6
Rebuild: 4,
Changed: 5,
ChangeDefName: 6,
ChangeSheet: 7
};
var c_oNotifyParentType = {
Change: 0,
ChangeFormula: 1,
EndCalculate: 2
};
var c_oDashType = {
......@@ -1472,6 +1479,7 @@ window['Asc']['c_oAscMaxCellOrCommentLength'] = window['Asc'].c_oAscMaxCellOrCom
window["AscCommon"].c_oAscPrintDefaultSettings = c_oAscPrintDefaultSettings;
window["AscCommon"].c_oZoomType = c_oZoomType;
window["AscCommon"].c_oNotifyType = c_oNotifyType;
window["AscCommon"].c_oNotifyParentType = c_oNotifyParentType;
window["AscCommon"].c_oAscEncodings = c_oAscEncodings;
window["AscCommon"].c_oAscEncodingsMap = c_oAscEncodingsMap;
window["AscCommon"].c_oAscCodePageUtf8 = c_oAscCodePageUtf8;
......
......@@ -3417,7 +3417,6 @@ PasteProcessor.prototype =
_convertTableFromExcel: function(aContentExcel)
{
var worksheet = aContentExcel.workbook.aWorksheets[0];
var pasteRange = AscCommonExcel.g_oRangeCache.getAscRange(aContentExcel.activeRange);
var rows = worksheet._getRows(), range;
var tempActiveRef = aContentExcel.activeRange;
var activeRange = AscCommonExcel.g_oRangeCache.getAscRange(tempActiveRef);
......
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