Commit 48b8edcd authored by konovalovsergey's avatar konovalovsergey

fix errors

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