Commit 353121c3 authored by konovalovsergey's avatar konovalovsergey

table thisRow ValueError, shift undo error, remove DefinedNamesChange,...

table thisRow ValueError, shift undo error, remove DefinedNamesChange, listening name3D, af_setStyleAfterOpen move to model
parent fdef5c51
......@@ -1716,20 +1716,20 @@ cStrucTable.prototype._createArea = function ( val, opt_bbox ) {
this.colStartIndex = this.wb.getTableIndexColumnByName( this.tableName, this.colStart );
this.colEndIndex = this.wb.getTableIndexColumnByName( this.tableName, this.colEnd );
if( !this.colStartIndex && !this.colEndIndex ){
return this.area = new cError( cErrorType.bad_reference );
return this._createAreaError(paramObj);
}
} else {
paramObj.startCol = this.oneColumn = val['oneColumn'].replace(/'#/g,"#");
this.oneColumnIndex = this.wb.getTableIndexColumnByName( this.tableName, this.oneColumn );
if( !this.oneColumnIndex ){
return this.area = new cError( cErrorType.bad_reference );
return this._createAreaError(paramObj);
}
}
var tableData = this.wb.getTableRangeForFormula( this.tableName, paramObj );
if ( !tableData ) {
return this.area = new cError( cErrorType.bad_reference );
return this._createAreaError(paramObj);
}
if( tableData.range ){
this.area = tableData.range.isOneCell() ?
......@@ -1747,7 +1747,7 @@ cStrucTable.prototype._createArea = function ( val, opt_bbox ) {
tableData = this.wb.getTableRangeForFormula( this.tableName, paramObj );
if ( !tableData ) {
return this.area = new cError( cErrorType.bad_reference );
return this._createAreaError(paramObj);
}
if( tableData.range ){
this.area = tableData.range.isOneCell() ?
......@@ -1771,7 +1771,7 @@ cStrucTable.prototype._createArea = function ( val, opt_bbox ) {
data = this.wb.getTableRangeForFormula( this.tableName, paramObj );
if ( !data ) {
return this.area = new cError( cErrorType.bad_reference );
return this._createAreaError(paramObj);
}
if ( range ) {
......@@ -1789,7 +1789,7 @@ cStrucTable.prototype._createArea = function ( val, opt_bbox ) {
this.hdtcstartIndex = this.wb.getTableIndexColumnByName( this.tableName, this.hdtcstart );
if( !this.hdtcstartIndex ){
return this.area = new cError( cErrorType.bad_reference );
return this._createAreaError(paramObj);
}
if ( this.hdtcend ) {
......@@ -1798,7 +1798,7 @@ cStrucTable.prototype._createArea = function ( val, opt_bbox ) {
this.hdtcendIndex = this.wb.getTableIndexColumnByName( this.tableName, this.hdtcend );
if( !this.hdtcendIndex ){
return this.area = new cError( cErrorType.bad_reference );
return this._createAreaError(paramObj);
}
}
......@@ -1811,7 +1811,7 @@ cStrucTable.prototype._createArea = function ( val, opt_bbox ) {
data = this.wb.getTableRangeForFormula( this.tableName, paramObj );
if ( !data ) {
return this.area = new cError( cErrorType.bad_reference );
return this._createAreaError(paramObj);
}
range = data.range;
}
......@@ -1830,6 +1830,13 @@ cStrucTable.prototype._createArea = function ( val, opt_bbox ) {
!this.area ? this.area = new cError( cErrorType.bad_reference ) : null;
return this.area;
};
cStrucTable.prototype._createAreaError = function (paramObj) {
if(AscCommon.FormulaTablePartInfo.thisRow == paramObj.param){
return this.area = new cError( cErrorType.wrong_value_type );
} else {
return this.area = new cError( cErrorType.bad_reference );
}
};
cStrucTable.prototype._buildLocalTableString = function (reservedColumn,local) {
return parserHelp.getColumnNameByType(reservedColumn, local);
};
......@@ -4790,7 +4797,7 @@ parserFormula.prototype.calculate = function(opt_defName, opt_range) {
_cellsBbox = elem.getBBox0();
}
}
if (_cellsRange) {
if (_cellsRange || _cellsBbox) {
var isIntersect;
if (AscCommon.c_oNotifyType.Shift == notifyType) {
isIntersect = bbox.isIntersectForShift(_cellsBbox, offset);
......@@ -4802,7 +4809,7 @@ parserFormula.prototype.calculate = function(opt_defName, opt_range) {
if (isIntersect) {
var isNoDelete;
if (AscCommon.c_oNotifyType.Shift == notifyType) {
isNoDelete = _cellsBbox.forShift(bbox, offset);
isNoDelete = _cellsBbox.forShift(bbox, offset, this.wb.bUndoChanges);
} else if (AscCommon.c_oNotifyType.Move == notifyType) {
_cellsBbox.setOffset(offset);
isNoDelete = true;
......@@ -4811,18 +4818,20 @@ parserFormula.prototype.calculate = function(opt_defName, opt_range) {
isNoDelete = false;
} else {
isNoDelete = true;
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);
if (ltIn && rtIn && bbox.r1 != _cellsBbox.r1) {
_cellsBbox.setOffsetFirst({offsetCol: 0, offsetRow: bbox.r2 - _cellsBbox.r1 + 1});
} else if (rtIn && rbIn && bbox.c2 != _cellsBbox.c2) {
_cellsBbox.setOffsetLast({offsetCol: bbox.c1 - _cellsBbox.c2 - 1, offsetRow: 0});
} else if (rbIn && lbIn && bbox.r2 != _cellsBbox.r2) {
_cellsBbox.setOffsetLast({offsetCol: 0, offsetRow: bbox.r1 - _cellsBbox.r2 - 1});
} else if (lbIn && ltIn && bbox.c1 != _cellsBbox.c1) {
_cellsBbox.setOffsetFirst({offsetCol: bbox.c2 - _cellsBbox.c1 + 1, offsetRow: 0});
if (!this.wb.bUndoChanges) {
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);
if (ltIn && rtIn && bbox.r1 != _cellsBbox.r1) {
_cellsBbox.setOffsetFirst({offsetCol: 0, offsetRow: bbox.r2 - _cellsBbox.r1 + 1});
} else if (rtIn && rbIn && bbox.c2 != _cellsBbox.c2) {
_cellsBbox.setOffsetLast({offsetCol: bbox.c1 - _cellsBbox.c2 - 1, offsetRow: 0});
} else if (rbIn && lbIn && bbox.r2 != _cellsBbox.r2) {
_cellsBbox.setOffsetLast({offsetCol: 0, offsetRow: bbox.r1 - _cellsBbox.r2 - 1});
} else if (lbIn && ltIn && bbox.c1 != _cellsBbox.c1) {
_cellsBbox.setOffsetFirst({offsetCol: bbox.c2 - _cellsBbox.c1 + 1, offsetRow: 0});
}
}
}
}
......@@ -5074,8 +5083,10 @@ parserFormula.prototype.assembleLocale = function(locale, digitDelim) {
continue;
}
if (ref.type == cElementType.name || ref.type == cElementType.name3D) {
if (ref.type == cElementType.name) {
this.wb.dependencyFormulas.startListeningDefName(ref.value, this);
} else if (ref.type == cElementType.name3D) {
this.wb.dependencyFormulas.startListeningDefName(ref.value, this, ref.ws.getId());
} else if ((cElementType.cell === ref.type || cElementType.cell3D === ref.type ||
cElementType.cellsRange === ref.type) && ref.isValid()) {
this.wb.dependencyFormulas.startListeningRange(ref.getWsId(), ref.getRange().getBBox0(), this);
......@@ -5114,8 +5125,10 @@ parserFormula.prototype.assembleLocale = function(locale, digitDelim) {
continue;
}
if (ref.type == cElementType.name || ref.type == cElementType.name3D) {
if (ref.type == cElementType.name) {
this.wb.dependencyFormulas.endListeningDefName(ref.value, this);
} else if (ref.type == cElementType.name3D) {
this.wb.dependencyFormulas.endListeningDefName(ref.value, this, ref.ws.getId());
} else if ((cElementType.cell === ref.type || cElementType.cell3D === ref.type ||
cElementType.cellsRange === ref.type) && ref.isValid()) {
this.wb.dependencyFormulas.endListeningRange(ref.getWsId(), ref.getRange().getBBox0(), this);
......
......@@ -417,8 +417,6 @@ var UndoRedoDataTypes = new function() {
this.ColorFilter = 38;
this.DefinedName = 39;
this.DefinedNamesChange = 40;
this.SheetViewSettings = 43;
this.GlobalTableIdAdd = 44;
......@@ -521,8 +519,6 @@ var UndoRedoDataTypes = new function() {
case this.ParagraphParaItemAdd: return new UndoRedoData_historyitem_Paragraph_AddItem();
case this.DefinedName: return new UndoRedoData_DefinedNames();
case this.DefinedNamesChange: return new UndoRedoData_DefinedNamesChange();
}
return null;
};
......@@ -1640,19 +1636,17 @@ UndoRedoData_SheetPositions.prototype = {
};
var g_oUndoRedoData_DefinedNamesProperties = {
Name: 0,
Ref:1,
LocalSheetId:2,
slaveEdge:3,
name: 0,
ref:1,
sheetId:2,
isTable:4
};
function UndoRedoData_DefinedNames(name, ref, scope, isTable, slaveEdge){
function UndoRedoData_DefinedNames(name, ref, sheetId, isTable){
this.Properties = g_oUndoRedoData_DefinedNamesProperties;
this.Name = name;
this.Ref = ref;
this.LocalSheetId = scope;
this.name = name;
this.ref = ref;
this.sheetId = sheetId;
this.isTable = isTable;
this.slaveEdge = slaveEdge;
}
UndoRedoData_DefinedNames.prototype = {
getType : function()
......@@ -1667,11 +1661,10 @@ UndoRedoData_DefinedNames.prototype = {
{
switch(nType)
{
case this.Properties.Name: return this.Name;break;
case this.Properties.Ref: return this.Ref;break;
case this.Properties.LocalSheetId: return this.LocalSheetId;break;
case this.Properties.name: return this.name;break;
case this.Properties.ref: return this.ref;break;
case this.Properties.sheetId: return this.sheetId;break;
case this.Properties.isTable: return this.isTable;break;
case this.Properties.slaveEdge: return this.slaveEdge;break;
}
return null;
},
......@@ -1679,48 +1672,10 @@ UndoRedoData_DefinedNames.prototype = {
{
switch(nType)
{
case this.Properties.Name: this.Name = value;break;
case this.Properties.Ref: this.Ref = value;break;
case this.Properties.LocalSheetId: this.LocalSheetId = value;break;
case this.Properties.name: this.name = value;break;
case this.Properties.ref: this.ref = value;break;
case this.Properties.sheetId: this.sheetId = value;break;
case this.Properties.isTable: this.isTable = value;break;
case this.Properties.slaveEdge: this.slaveEdge = value;break;
}
}
};
var g_oUndoRedoData_DefinedNamesChangeProperties = {
oldName: 0,
newName:1
};
function UndoRedoData_DefinedNamesChange(oldName, newName){
this.Properties = g_oUndoRedoData_DefinedNamesChangeProperties;
this.oldName = oldName?new UndoRedoData_DefinedNames(oldName.Name, oldName.Ref, oldName.LocalSheetId, oldName.isTable, null):undefined;
this.newName = newName?new UndoRedoData_DefinedNames(newName.Name, newName.Ref, newName.LocalSheetId, newName.isTable, null):undefined;
}
UndoRedoData_DefinedNamesChange.prototype = {
getType : function()
{
return UndoRedoDataTypes.DefinedNamesChange;
},
getProperties : function()
{
return this.Properties;
},
getProperty : function(nType)
{
switch(nType)
{
case this.Properties.oldName: return this.oldName;break;
case this.Properties.newName: return this.newName;break;
}
return null;
},
setProperty : function(nType, value)
{
switch(nType)
{
case this.Properties.oldName: this.oldName = value;break;
case this.Properties.newName: this.newName = value;break;
}
}
};
......@@ -3013,21 +2968,21 @@ UndoRedoWorkbook.prototype = {
else if (AscCH.historyitem_Workbook_DefinedNamesChange === Type || AscCH.historyitem_Workbook_DefinedNamesChangeUndo === Type) {
var oldName, newName;
if (bUndo) {
oldName = Data.newName;
newName = Data.oldName;
oldName = Data.to;
newName = Data.from;
} else {
if (wb.bCollaborativeChanges) {
wb.handlers.trigger("asc_onLockDefNameManager", Asc.c_oAscDefinedNameReason.OK);
}
oldName = Data.oldName;
newName = Data.newName;
oldName = Data.from;
newName = Data.to;
}
if (bUndo || AscCH.historyitem_Workbook_DefinedNamesChangeUndo !== Type) {
if (null == newName) {
wb.delDefinesNames(oldName);
wb.delDefinesNamesUndoRedo(oldName);
wb.handlers.trigger("asc_onDelDefName")
} else {
wb.editDefinesNames(oldName, newName);
wb.editDefinesNamesUndoRedo(oldName, newName);
wb.handlers.trigger("asc_onEditDefName", oldName, newName);
}
}
......@@ -3926,7 +3881,6 @@ UndoRedoAutoFilters.prototype = {
window['AscCommonExcel'].UndoRedoData_SheetRemove = UndoRedoData_SheetRemove;
window['AscCommonExcel'].UndoRedoData_SheetPositions = UndoRedoData_SheetPositions;
window['AscCommonExcel'].UndoRedoData_DefinedNames = UndoRedoData_DefinedNames;
window['AscCommonExcel'].UndoRedoData_DefinedNamesChange = UndoRedoData_DefinedNamesChange;
window['AscCommonExcel'].UndoRedoData_ClrScheme = UndoRedoData_ClrScheme;
window['AscCommonExcel'].UndoRedoData_AutoFilter = UndoRedoData_AutoFilter;
window['AscCommonExcel'].UndoRedoData_SingleProperty = UndoRedoData_SingleProperty;
......
This diff is collapsed.
......@@ -5203,7 +5203,10 @@ TablePart.prototype.getTableRangeForFormula = function(objectParam)
}
case FormulaTablePartInfo.headers:
{
res = new Asc.Range(this.Ref.c1, this.Ref.r1, this.Ref.c2, this.Ref.r1);
if(this.HeaderRowCount === null)
{
res = new Asc.Range(this.Ref.c1, this.Ref.r1, this.Ref.c2, this.Ref.r1);
}
break;
}
case FormulaTablePartInfo.totals:
......
......@@ -340,7 +340,7 @@
}
};
Range.prototype.forShift = function(bbox, offset) {
Range.prototype.forShift = function(bbox, offset, bUndo) {
var isNoDelete = true;
var isHor = 0 != offset.offsetCol;
var toDelete = offset.offsetCol < 0 || offset.offsetRow < 0;
......@@ -355,14 +355,16 @@
}
} else if (this.c1 <= bbox.c2) {
if (this.c2 <= bbox.c2) {
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});
if(!bUndo){
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 {
this.setOffsetFirst({offsetCol: bbox.c1 - this.c1, offsetRow: 0});
......@@ -388,14 +390,16 @@
}
} else if (this.r1 <= bbox.r2) {
if (this.r2 <= bbox.r2) {
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});
if(!bUndo) {
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 {
this.setOffsetFirst({offsetCol: 0, offsetRow: bbox.r1 - this.r1});
......
......@@ -1171,7 +1171,7 @@
this._initWorksheetDefaultWidth();
this._initPane();
this._initCellsArea( true );
this.af_setStyleAfterOpen();
this.model.setTableStyleAfterOpen();
this._cleanCellsTextMetricsCache();
this._prepareCellTextMetricsCache();
......
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