Commit 929f0aab authored by konovalovsergey's avatar konovalovsergey

bugfix

parent 36ababec
...@@ -407,6 +407,7 @@ var editor; ...@@ -407,6 +407,7 @@ var editor;
AscCommonExcel.g_oUndoRedoRow = new AscCommonExcel.UndoRedoRowCol(wbModel, true); AscCommonExcel.g_oUndoRedoRow = new AscCommonExcel.UndoRedoRowCol(wbModel, true);
AscCommonExcel.g_oUndoRedoComment = new AscCommonExcel.UndoRedoComment(wbModel); AscCommonExcel.g_oUndoRedoComment = new AscCommonExcel.UndoRedoComment(wbModel);
AscCommonExcel.g_oUndoRedoAutoFilters = new AscCommonExcel.UndoRedoAutoFilters(wbModel); AscCommonExcel.g_oUndoRedoAutoFilters = new AscCommonExcel.UndoRedoAutoFilters(wbModel);
AscCommonExcel.g_DefNameWorksheet = new AscCommonExcel.Woorksheet(wbModel, -1);
}; };
spreadsheet_api.prototype.asc_DownloadAs = function(typeFile, bIsDownloadEvent) {//передаем число соответствующее своему формату. например c_oAscFileType.XLSX spreadsheet_api.prototype.asc_DownloadAs = function(typeFile, bIsDownloadEvent) {//передаем число соответствующее своему формату. например c_oAscFileType.XLSX
......
...@@ -3584,6 +3584,13 @@ function parserFormula( formula, parent, _ws ) { ...@@ -3584,6 +3584,13 @@ function parserFormula( formula, parent, _ws ) {
this.isDirty = isDirty; this.isDirty = isDirty;
}; };
parserFormula.prototype.notify = function(data) { parserFormula.prototype.notify = function(data) {
var eventData = {notifyData: data, assembleType: AscCommon.c_oNotifyParentAssemble.Normal, isRebuild: false};
if (this.parent && this.parent.onFormulaEvent) {
var checkCanDo = this.parent.onFormulaEvent(AscCommon.c_oNotifyParentType.CanDo, eventData);
if(!checkCanDo){
return;
}
}
if (AscCommon.c_oNotifyType.Dirty === data.type) { if (AscCommon.c_oNotifyType.Dirty === data.type) {
if (!this.isDirty) { if (!this.isDirty) {
this.isDirty = true; this.isDirty = true;
...@@ -3600,10 +3607,19 @@ function parserFormula( formula, parent, _ws ) { ...@@ -3600,10 +3607,19 @@ function parserFormula( formula, parent, _ws ) {
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.shiftCells(data.type, data.sheetId, data.bbox, data.offset); this.shiftCells(data.type, data.sheetId, data.bbox, data.offset);
eventData.assembleType = AscCommon.c_oNotifyParentAssemble.Flag;
} else if (AscCommon.c_oNotifyType.ChangeDefName === data.type) { } else if (AscCommon.c_oNotifyType.ChangeDefName === data.type) {
this.changeDefName(data.from, data.to); if (!data.to) {
this.removeTableName(data.from);
} else if (data.from.Name != data.to.Name) {
this.changeDefName(data.from, data.to);
} else if (data.from.isTable) {
eventData.assembleType = AscCommon.c_oNotifyParentAssemble.Current;
eventData.isRebuild = true;
}
} else if (AscCommon.c_oNotifyType.Rebuild === data.type) { } else if (AscCommon.c_oNotifyType.Rebuild === data.type) {
; eventData.assembleType = AscCommon.c_oNotifyParentAssemble.Assemble;
eventData.isRebuild = true;
} else if (AscCommon.c_oNotifyType.ChangeSheet === data.type) { } else if (AscCommon.c_oNotifyType.ChangeSheet === data.type) {
if (this.is3D) { if (this.is3D) {
var changeData = data.data; var changeData = data.data;
...@@ -3619,7 +3635,7 @@ function parserFormula( formula, parent, _ws ) { ...@@ -3619,7 +3635,7 @@ function parserFormula( formula, parent, _ws ) {
} }
} }
if (this.parent && this.parent.onFormulaEvent) { if (this.parent && this.parent.onFormulaEvent) {
this.parent.onFormulaEvent(AscCommon.c_oNotifyParentType.ChangeFormula); this.parent.onFormulaEvent(AscCommon.c_oNotifyParentType.ChangeFormula, eventData);
} }
} }
}; };
...@@ -4400,14 +4416,20 @@ parserFormula.prototype.getRef = function() { ...@@ -4400,14 +4416,20 @@ parserFormula.prototype.getRef = function() {
} }
} }
}; };
parserFormula.prototype.shiftCells = function(notifyType, sheetId, bbox, offset) { parserFormula.prototype.removeTableName = function(defName) {
var isHor = 0 != offset.offsetCol; var i, elem, LocalSheetId;
var oShiftGetBBox; for (i = 0; i < this.outStack.length; i++) {
if (AscCommon.c_oNotifyType.Shift == notifyType) { elem = this.outStack[i];
oShiftGetBBox = AscCommonExcel.shiftGetBBox(bbox, isHor); if (elem.type == cElementType.table) {
} else { LocalSheetId = elem.ws ? elem.ws.getIndex() : null;
oShiftGetBBox = bbox; if (elem.tableName == defName.Name && (null == defName.LocalSheetId || LocalSheetId == defName.LocalSheetId )) {
this.outStack[i] = elem.toRef();
}
}
} }
};
parserFormula.prototype.shiftCells = function(notifyType, sheetId, bbox, offset) {
var isHor = offset && 0 != offset.offsetCol;
var elem; var elem;
for (var i = 0; i < this.outStack.length; i++) { for (var i = 0; i < this.outStack.length; i++) {
elem = this.outStack[i]; elem = this.outStack[i];
...@@ -4429,9 +4451,12 @@ parserFormula.prototype.getRef = function() { ...@@ -4429,9 +4451,12 @@ parserFormula.prototype.getRef = function() {
var _cellsBbox = AscCommonExcel.g_oRangeCache.getAscRange(_cells.replace(this.regSpace, "")); var _cellsBbox = AscCommonExcel.g_oRangeCache.getAscRange(_cells.replace(this.regSpace, ""));
var isIntersect; var isIntersect;
if (AscCommon.c_oNotifyType.Shift == notifyType) { if (AscCommon.c_oNotifyType.Shift == notifyType) {
isIntersect = oShiftGetBBox.isIntersectForShift(_cellsBbox, isHor); isIntersect = bbox.isIntersectForShift(_cellsBbox, offset);
} else { } else if (AscCommon.c_oNotifyType.Move == notifyType) {
isIntersect = oShiftGetBBox.containsRange(_cellsBbox); isIntersect = bbox.containsRange(_cellsBbox);
} else if (AscCommon.c_oNotifyType.Delete == notifyType) {
//isIntersect = bbox.isIntersect(_cellsBbox);
isIntersect = bbox.containsRange(_cellsBbox);
} }
if (isIntersect) { if (isIntersect) {
var isNoDelete; var isNoDelete;
...@@ -4439,9 +4464,32 @@ parserFormula.prototype.getRef = function() { ...@@ -4439,9 +4464,32 @@ parserFormula.prototype.getRef = function() {
_cellsBbox = _cellsBbox.clone(); _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) {
_cellsBbox = _cellsBbox.clone();
_cellsBbox.setOffset(offset);
isNoDelete = true; isNoDelete = true;
} else if (AscCommon.c_oNotifyType.Delete == notifyType) { } else if (AscCommon.c_oNotifyType.Delete == notifyType) {
isNoDelete = false; isNoDelete = false;
// if (bbox.containsRange(_cellsBbox)) {
// isNoDelete = false;
// } else {
// isNoDelete = true;
// if (!_cellsBbox.containsRange(bbox)) {
// var ltIn = bbox.contains(_cellsBbox.c1, _cellsBbox.r1);
// var rtIn = bbox.contains(_cellsBbox.c2, _cellsBbox.r1);
// var lbIn = bbox.contains(_cellsBbox.c1, _cellsBbox.r2);
// var rbIn = bbox.contains(_cellsBbox.c2, _cellsBbox.r2);
// _cellsBbox = _cellsBbox.clone();
// if (ltIn && rtIn) {
// _cellsBbox.setOffsetFirst({offsetCol: 0, offsetRow: bbox.r2 - _cellsBbox.r1 + 1});
// } else if (rtIn && rbIn) {
// _cellsBbox.setOffsetLast({offsetCol: bbox.c1 - _cellsBbox.c2 - 1, offsetRow: 0});
// } else if (rbIn && lbIn) {
// _cellsBbox.setOffsetLast({offsetCol: 0, offsetRow: bbox.r1 - _cellsBbox.r2 - 1});
// } else if (lbIn && ltIn) {
// _cellsBbox.setOffsetFirst({offsetCol: bbox.c2 - _cellsBbox.c1 + 1, offsetRow: 0});
// }
// }
// }
} }
if (isNoDelete) { if (isNoDelete) {
elem.value = elem._cells = elem.value = elem._cells =
......
This diff is collapsed.
...@@ -305,11 +305,38 @@ ...@@ -305,11 +305,38 @@
return bRes; return bRes;
}, },
isIntersectForShift: function(range, isHor) { isIntersectForShift: function(range, offset) {
var isHor = offset && 0 != offset.offsetCol;
var toDelete = offset && (offset.offsetCol < 0 || offset.offsetRow < 0);
if (isHor) { if (isHor) {
return this.r1 <= range.r1 && range.r2 <= this.r2 && this.c1 <= range.c2; if (this.r1 <= range.r1 && range.r2 <= this.r2 && this.c1 <= range.c2) {
return true;
} else if (toDelete && this.c1 <= range.c1 && range.c2 <= this.c2) {
var topIn = this.r1 <= range.r1 && range.r1 <= this.r2;
var bottomIn = this.r1 <= range.r2 && range.r2 <= this.r2;
return topIn || bottomIn;
} else {
return false;
}
} else { } else {
return this.c1 <= range.c1 && range.c2 <= this.c2 && this.r1 <= range.r2; if (this.c1 <= range.c1 && range.c2 <= this.c2 && this.r1 <= range.r2) {
return true;
} else if (toDelete && this.r1 <= range.r1 && range.r2 <= this.r2) {
var leftIn = this.c1 <= range.c1 && range.c1 <= this.c2;
var rightIn = this.c1 <= range.c2 && range.c2 <= this.c2;
return leftIn || rightIn;
} else {
return false;
}
}
},
isIntersectForShiftCell: function(col, row, offset) {
var isHor = offset && 0 != offset.offsetCol;
if (isHor) {
return this.r1 <= row && row <= this.r2 && this.c1 <= col;
} else {
return this.c1 <= col && col <= this.c2 && this.r1 <= row;
} }
}, },
...@@ -328,9 +355,18 @@ ...@@ -328,9 +355,18 @@
} }
} else if (this.c1 <= bbox.c2) { } else if (this.c1 <= bbox.c2) {
if (this.c2 <= bbox.c2) { if (this.c2 <= bbox.c2) {
isNoDelete = false; var topIn = bbox.r1 <= this.r1 && this.r1 <= bbox.r2;
var bottomIn = bbox.r1 <= this.r2 && this.r2 <= bbox.r2;
if (topIn && bottomIn) {
isNoDelete = false;
} else if (topIn) {
this.setOffsetFirst({offsetCol: 0, offsetRow: bbox.r2 - this.r1 + 1});
} else if (bottomIn) {
this.setOffsetLast({offsetCol: 0, offsetRow: bbox.r1 - this.r2 - 1});
}
} else { } else {
this.setOffsetFirst({offsetCol: bbox.c2 - this.c1 + 1, offsetRow: 0}); this.setOffsetFirst({offsetCol: bbox.c1 - this.c1, offsetRow: 0});
this.setOffsetLast(offset);
} }
} else { } else {
this.setOffset(offset); this.setOffset(offset);
...@@ -352,9 +388,18 @@ ...@@ -352,9 +388,18 @@
} }
} else if (this.r1 <= bbox.r2) { } else if (this.r1 <= bbox.r2) {
if (this.r2 <= bbox.r2) { if (this.r2 <= bbox.r2) {
isNoDelete = false; var leftIn = bbox.c1 <= this.c1 && this.c1 <= bbox.c2;
var rightIn = bbox.c1 <= this.c2 && this.c2 <= bbox.c2;
if (leftIn && rightIn) {
isNoDelete = false;
} else if (leftIn) {
this.setOffsetFirst({offsetCol: bbox.c2 - this.c1 + 1, offsetRow: 0});
} else if (rightIn) {
this.setOffsetLast({offsetCol: bbox.c1 - this.c2 - 1, offsetRow: 0});
}
} else { } else {
this.setOffsetFirst({offsetCol: 0, offsetRow: bbox.r2 - this.r1 + 1}); this.setOffsetFirst({offsetCol: 0, offsetRow: bbox.r1 - this.r1});
this.setOffsetLast(offset);
} }
} else { } else {
this.setOffset(offset); this.setOffset(offset);
......
...@@ -823,9 +823,16 @@ var c_oAscPrintDefaultSettings = { ...@@ -823,9 +823,16 @@ var c_oAscPrintDefaultSettings = {
}; };
var c_oNotifyParentType = { var c_oNotifyParentType = {
Change: 0, CanDo: 0,
ChangeFormula: 1, Change: 1,
EndCalculate: 2 ChangeFormula: 2,
EndCalculate: 3
};
var c_oNotifyParentAssemble = {
Normal: 0,
Flag: 1,
Current: 2
}; };
var c_oDashType = { var c_oDashType = {
...@@ -1480,6 +1487,8 @@ window['Asc']['c_oAscMaxCellOrCommentLength'] = window['Asc'].c_oAscMaxCellOrCom ...@@ -1480,6 +1487,8 @@ window['Asc']['c_oAscMaxCellOrCommentLength'] = window['Asc'].c_oAscMaxCellOrCom
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_oNotifyParentType = c_oNotifyParentType;
window["AscCommon"].c_oNotifyParentAssemble = c_oNotifyParentAssemble;
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;
......
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