Commit 1c46a06a authored by konovalovsergey's avatar konovalovsergey

bugfix

parent 929f0aab
...@@ -1418,7 +1418,8 @@ function cStrucTable( val, wb, ws ) { ...@@ -1418,7 +1418,8 @@ function cStrucTable( val, wb, ws ) {
this.isDynamic = false;//#This row this.isDynamic = false;//#This row
this.area = null; this.area = null;
this.val = val; this.val = val;
this._createArea( val, null ); var ret = this._createArea( val, null );
return (ret && ret.type != cElementType.error) ? this : ret;
} }
cStrucTable.prototype = Object.create( cBaseType.prototype ); cStrucTable.prototype = Object.create( cBaseType.prototype );
...@@ -3609,16 +3610,14 @@ function parserFormula( formula, parent, _ws ) { ...@@ -3609,16 +3610,14 @@ function parserFormula( formula, parent, _ws ) {
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; eventData.assembleType = AscCommon.c_oNotifyParentAssemble.Flag;
} else if (AscCommon.c_oNotifyType.ChangeDefName === data.type) { } else if (AscCommon.c_oNotifyType.ChangeDefName === data.type) {
if (!data.to) { if (data.from.Name != data.to.Name) {
this.removeTableName(data.from);
} else if (data.from.Name != data.to.Name) {
this.changeDefName(data.from, data.to); this.changeDefName(data.from, data.to);
} else if (data.from.isTable) { } else if (data.from.isTable) {
eventData.assembleType = AscCommon.c_oNotifyParentAssemble.Current; eventData.assembleType = AscCommon.c_oNotifyParentAssemble.Current;
eventData.isRebuild = true; 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.assembleType = AscCommon.c_oNotifyParentAssemble.Normal;
eventData.isRebuild = true; 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) {
......
...@@ -3926,7 +3926,7 @@ ...@@ -3926,7 +3926,7 @@
return oThis.ReadTable(t,l, oNewTable); return oThis.ReadTable(t,l, oNewTable);
}); });
if(null != oNewTable.Ref && null != oNewTable.DisplayName) if(null != oNewTable.Ref && null != oNewTable.DisplayName)
this.ws.workbook.dependencyFormulas.addTableName(oNewTable.DisplayName, this.ws, oNewTable.Ref, oNewTable); this.ws.workbook.dependencyFormulas.addTableName(this.ws, oNewTable);
aTables.push(oNewTable); aTables.push(oNewTable);
} }
else else
......
...@@ -663,54 +663,42 @@ function getRangeType(oBBox){ ...@@ -663,54 +663,42 @@ function getRangeType(oBBox){
}); });
}, },
//defined name table //defined name table
getNextTableName: function(ws, Ref, opt_tableName, opt_table) { getNextTableName: function() {
var sNewName; var sNewName;
if (opt_tableName) { var collaborativeIndexUser = "";
sNewName = opt_tableName; if (this.wb.oApi.collaborativeEditing.getCollaborativeEditing()) {
} else { collaborativeIndexUser = "_" + this.wb.oApi.CoAuthoringApi.get_indexUser();
var collaborativeIndexUser = ""; }
if (this.wb.oApi.collaborativeEditing.getCollaborativeEditing()) { do {
collaborativeIndexUser = "_" + this.wb.oApi.CoAuthoringApi.get_indexUser(); this.tableNameIndex++;
} sNewName = this.tableNamePattern + this.tableNameIndex + collaborativeIndexUser;
do { } while (this.isListeningDefName(sNewName));
this.tableNameIndex++;
sNewName = this.tableNamePattern + this.tableNameIndex + collaborativeIndexUser;
} while (this.isListeningDefName(sNewName));
}
this.addTableName(sNewName, ws, Ref, opt_table);
return sNewName; return sNewName;
}, },
addTableName: function(sName, ws, Ref, table) { addTableName: function(ws, table) {
var refClone; var ref = table.getRangeWithoutHeaderFooter();
if (table) {
refClone = table.getRangeWithoutHeaderFooter();
} else {
//todo
refClone = Ref.clone(true);
refClone.r1++;
}
var defName = this.getDefNameByName(sName, null); var defNameRef = parserHelp.get3DRef(ws.getName(), ref.getAbsName());
var defName = this.getDefNameByName(table.DisplayName, null);
if (!defName) { if (!defName) {
var defNameRef = parserHelp.get3DRef(ws.getName(), refClone.getAbsName()); this.addDefNameOpen(table.DisplayName, defNameRef, null, null, true);
this.addDefNameOpen(sName, defNameRef, null, null, true);
} else { } else {
defName.ref = defNameRef; defName.setRef(defNameRef);
} }
}, },
changeTableRef: function(tableName, newRef) { changeTableRef: function(tableName, newRef) {
History.TurnOff();
var defName = this.getDefNameByName(tableName, null); var defName = this.getDefNameByName(tableName, null);
if (defName) { if (defName) {
this.buildDependency();
var oldAscName = defName.getAscCDefName(); var oldAscName = defName.getAscCDefName();
var newAscName = defName.getAscCDefName(); var newAscName = defName.getAscCDefName();
newAscName.Ref = defName.ref.split('!')[0] + '!' + newRef.getAbsName(); newAscName.Ref = defName.ref.split('!')[0] + '!' + newRef.getAbsName();
History.TurnOff();
this.editDefinesNames(oldAscName, newAscName); this.editDefinesNames(oldAscName, newAscName);
var notifyData = {type: AscCommon.c_oNotifyType.ChangeDefName, from: oldAscName, to: newAscName}; var notifyData = {type: AscCommon.c_oNotifyType.ChangeDefName, from: oldAscName, to: newAscName};
this._broadcastDefName(defName.name, notifyData); this._broadcastDefName(defName.name, notifyData);
History.TurnOn();
} }
History.TurnOn();
}, },
changeTableName: function(tableName, newName) { changeTableName: function(tableName, newName) {
var defName = this.getDefNameByName(tableName, null); var defName = this.getDefNameByName(tableName, null);
...@@ -724,7 +712,8 @@ function getRangeType(oBBox){ ...@@ -724,7 +712,8 @@ function getRangeType(oBBox){
} }
}, },
delTableName: function(tableName) { delTableName: function(tableName) {
this._delDefName(tableName, null); var defName = this._delDefName(tableName, null);
this.addToChangedDefName(defName);
//todo make ref //todo make ref
// var notifyData = {type: AscCommon.c_oNotifyType.ChangeDefName, from: defName.getAscCDefName(), to: null}; // var notifyData = {type: AscCommon.c_oNotifyType.ChangeDefName, from: defName.getAscCDefName(), to: null};
// this._broadcastDefName(tableName, notifyData); // this._broadcastDefName(tableName, notifyData);
...@@ -736,6 +725,7 @@ function getRangeType(oBBox){ ...@@ -736,6 +725,7 @@ function getRangeType(oBBox){
var notifyData = {type: AscCommon.c_oNotifyType.Rebuild}; var notifyData = {type: AscCommon.c_oNotifyType.Rebuild};
this._broadcastDefName(defName.name, notifyData); this._broadcastDefName(defName.name, notifyData);
} }
this.calcTree();
}, },
//set dirty //set dirty
addToChangedCell: function(cell) { addToChangedCell: function(cell) {
...@@ -1121,7 +1111,7 @@ function getRangeType(oBBox){ ...@@ -1121,7 +1111,7 @@ function getRangeType(oBBox){
} }
} }
var bottom = this.yTree.getElem(bbox.r2); var bottom = this.yTree.getElem(bbox.r2);
if (bottom.storedValue.vals[data.id]) { if (bottom && bottom.storedValue.vals[data.id]) {
delete bottom.storedValue.vals[data.id]; delete bottom.storedValue.vals[data.id];
bottom.storedValue.count--; bottom.storedValue.count--;
if (bottom.storedValue.count <= 0) { if (bottom.storedValue.count <= 0) {
...@@ -1456,8 +1446,7 @@ Workbook.prototype._insertTablePartsName = function (sheet) { ...@@ -1456,8 +1446,7 @@ Workbook.prototype._insertTablePartsName = function (sheet) {
{ {
for(var i = 0; i < sheet.TableParts.length; i++) for(var i = 0; i < sheet.TableParts.length; i++)
{ {
var oNewTable = sheet.TableParts[i]; this.dependencyFormulas.addTableName(sheet, sheet.TableParts[i]);
this.dependencyFormulas.addTableName(oNewTable.DisplayName, sheet, oNewTable.Ref, oNewTable);
} }
} }
}; };
...@@ -2813,7 +2802,7 @@ Woorksheet.prototype.insertRowsBefore=function(index, count){ ...@@ -2813,7 +2802,7 @@ Woorksheet.prototype.insertRowsBefore=function(index, count){
}; };
Woorksheet.prototype._insertRowsBefore=function(index, count){ Woorksheet.prototype._insertRowsBefore=function(index, count){
this.workbook.dependencyFormulas.lockRecal(); this.workbook.dependencyFormulas.lockRecal();
var oActualRange = {r1: index, c1: 0, r2: index + count - 1, c2: gc_nMaxCol0}; var oActualRange = new Asc.Range(0, index, gc_nMaxCol0, index + count - 1);
History.Create_NewPoint(); History.Create_NewPoint();
//index 0 based //index 0 based
var aIndexes = []; var aIndexes = [];
...@@ -2885,7 +2874,7 @@ Woorksheet.prototype._removeCols=function(start, stop){ ...@@ -2885,7 +2874,7 @@ Woorksheet.prototype._removeCols=function(start, stop){
History.Create_NewPoint(); History.Create_NewPoint();
//start, stop 0 based //start, stop 0 based
var nDif = -(stop - start + 1), i, j, length, nIndex; var nDif = -(stop - start + 1), i, j, length, nIndex;
var oActualRange = { r1: 0, c1: start, r2: gc_nMaxRow0, c2: stop }; var oActualRange = new Asc.Range(start, 0, stop, gc_nMaxRow0);
for(i in this.aGCells) for(i in this.aGCells)
{ {
var nRowIndex = i - 0; var nRowIndex = i - 0;
...@@ -2948,7 +2937,7 @@ Woorksheet.prototype.insertColsBefore=function(index, count){ ...@@ -2948,7 +2937,7 @@ Woorksheet.prototype.insertColsBefore=function(index, count){
}; };
Woorksheet.prototype._insertColsBefore=function(index, count){ Woorksheet.prototype._insertColsBefore=function(index, count){
this.workbook.dependencyFormulas.lockRecal(); this.workbook.dependencyFormulas.lockRecal();
var oActualRange = {r1: 0, c1: index, r2: gc_nMaxRow0, c2: index + count - 1}; var oActualRange = new Asc.Range(index, 0, index + count - 1, gc_nMaxRow0);
History.Create_NewPoint(); History.Create_NewPoint();
//index 0 based //index 0 based
for(var i in this.aGCells) for(var i in this.aGCells)
...@@ -4350,6 +4339,23 @@ Cell.prototype.setValue2=function(array){ ...@@ -4350,6 +4339,23 @@ Cell.prototype.setValue2=function(array){
cell.removeHyperlink(); cell.removeHyperlink();
} }
}; };
Cell.prototype.setFormula = function(formula) {
var DataOld = null;
var DataNew = null;
if (History.Is_On())
DataOld = this.getValueData();
this.removeDependencies();
this.oValue.clean();
this.formulaParsed = new parserFormula(formula, this, this.ws);
this.ws.workbook.dependencyFormulas.addToBuildDependencyCell(this);
if (History.Is_On()) {
DataNew = this.getValueData();
if (false == DataOld.isEqual(DataNew))
History.Add(AscCommonExcel.g_oUndoRedoCell, AscCH.historyitem_Cell_ChangeValue, this.ws.getId(), new Asc.Range(this.nCol, this.nRow, this.nCol, this.nRow), new UndoRedoData_CellSimpleData(this.nRow, this.nCol, DataOld, DataNew));
}
};
Cell.prototype.removeDependencies = function() { Cell.prototype.removeDependencies = function() {
//удаляем сторое значение //удаляем сторое значение
if (this.formulaParsed) { if (this.formulaParsed) {
...@@ -4701,7 +4707,7 @@ Cell.prototype.getValueData = function(){ ...@@ -4701,7 +4707,7 @@ Cell.prototype.getValueData = function(){
Cell.prototype.setValueData = function(Val){ Cell.prototype.setValueData = function(Val){
//значения устанавляваются через setValue, чтобы пересчитались формулы //значения устанавляваются через setValue, чтобы пересчитались формулы
if(null != Val.formula) if(null != Val.formula)
this.setValue("=" + Val.formula); this.setFormula(Val.formula);
else if(null != Val.value) else if(null != Val.value)
{ {
var DataOld = null; var DataOld = null;
...@@ -4779,7 +4785,7 @@ Cell.prototype.setValueData = function(Val){ ...@@ -4779,7 +4785,7 @@ Cell.prototype.setValueData = function(Val){
break; break;
} }
if (eventData.isRebuild) { if (eventData.isRebuild) {
this.setValue('=' + assemb); this.setFormula(assemb);
} else { } else {
this.formulaParsed.Formula = assemb; this.formulaParsed.Formula = assemb;
this.formulaParsed.buildDependencies(); this.formulaParsed.buildDependencies();
...@@ -7652,7 +7658,7 @@ Range.prototype._sortByArray=function(oBBox, aSortData, bUndo){ ...@@ -7652,7 +7658,7 @@ Range.prototype._sortByArray=function(oBBox, aSortData, bUndo){
History.TurnOff(); History.TurnOff();
var _p_ = oCurCell.formulaParsed.clone(null, oCurCell, this); var _p_ = oCurCell.formulaParsed.clone(null, oCurCell, this);
var assemb = _p_.changeOffset({offsetCol: 0, offsetRow: shift}).assemble(); var assemb = _p_.changeOffset({offsetCol: 0, offsetRow: shift}).assemble();
oCurCell.setValue("=" + assemb); oCurCell.setFormula(assemb);
History.TurnOn(); History.TurnOn();
} }
} }
...@@ -7923,11 +7929,7 @@ Range.prototype.promote=function(bCtrl, bVertical, nIndex){ ...@@ -7923,11 +7929,7 @@ Range.prototype.promote=function(bCtrl, bVertical, nIndex){
} }
History.SetSelectionRedo(oSelectionRedo); History.SetSelectionRedo(oSelectionRedo);
} }
oFormulaLocaleInfo.Parse = false;
oFormulaLocaleInfo.DigitSep = false;
_promoteFromTo(oBBox, this.worksheet, oPromoteAscRange, this.worksheet, true, oCanPromote, bCtrl, bVertical, nIndex); _promoteFromTo(oBBox, this.worksheet, oPromoteAscRange, this.worksheet, true, oCanPromote, bCtrl, bVertical, nIndex);
oFormulaLocaleInfo.Parse = true;
oFormulaLocaleInfo.DigitSep = true;
return true; return true;
}; };
function _promoteFromTo(from, wsFrom, to, wsTo, bIsPromote, oCanPromote, bCtrl, bVertical, nIndex) { function _promoteFromTo(from, wsFrom, to, wsTo, bIsPromote, oCanPromote, bCtrl, bVertical, nIndex) {
...@@ -8196,7 +8198,7 @@ function _promoteFromTo(from, wsFrom, to, wsTo, bIsPromote, oCanPromote, bCtrl, ...@@ -8196,7 +8198,7 @@ function _promoteFromTo(from, wsFrom, to, wsTo, bIsPromote, oCanPromote, bCtrl,
} else { } else {
var _p_ = oFromCell.formulaParsed.clone(null, oFromCell, this); var _p_ = oFromCell.formulaParsed.clone(null, oFromCell, this);
var assemb = _p_.changeOffset(oCopyCell.getOffset2(oFromCell.getName())).assemble(); var assemb = _p_.changeOffset(oCopyCell.getOffset2(oFromCell.getName())).assemble();
oCopyCell.setValue("=" + assemb); oCopyCell.setFormula(assemb);
} }
} }
} }
......
...@@ -4726,7 +4726,8 @@ TablePart.prototype.clone = function(ws, tableName) { ...@@ -4726,7 +4726,8 @@ TablePart.prototype.clone = function(ws, tableName) {
return res; return res;
}; };
TablePart.prototype.recalc = function(ws, tableName) { TablePart.prototype.recalc = function(ws, tableName) {
this.DisplayName = ws.workbook.dependencyFormulas.getNextTableName(ws, this.Ref, tableName, this); this.DisplayName = ws.workbook.dependencyFormulas.getNextTableName();
ws.workbook.dependencyFormulas.addTableName(ws, this);
}; };
TablePart.prototype.moveRef = function(col, row) { TablePart.prototype.moveRef = function(col, row) {
var ref = this.Ref.clone(); var ref = this.Ref.clone();
...@@ -4791,7 +4792,7 @@ TablePart.prototype.changeRefOnRange = function(range, autoFilters, generateNewT ...@@ -4791,7 +4792,7 @@ TablePart.prototype.changeRefOnRange = function(range, autoFilters, generateNewT
this.TableColumns = newTableColumns; this.TableColumns = newTableColumns;
} }
} }
this.Ref = Asc.Range(range.c1, range.r1, range.c2, range.r2);
//event //event
this.handlers.trigger("changeRefTablePart", this.DisplayName, this.getRangeWithoutHeaderFooter()); this.handlers.trigger("changeRefTablePart", this.DisplayName, this.getRangeWithoutHeaderFooter());
......
...@@ -921,7 +921,7 @@ ...@@ -921,7 +921,7 @@
if(!worksheet.TableParts) if(!worksheet.TableParts)
worksheet.TableParts = []; worksheet.TableParts = [];
worksheet.TableParts[worksheet.TableParts.length] = cloneData; worksheet.TableParts[worksheet.TableParts.length] = cloneData;
worksheet.workbook.dependencyFormulas.addTableName(cloneData.DisplayName, worksheet, cloneData.Ref, cloneData); worksheet.workbook.dependencyFormulas.addTableName(worksheet, cloneData);
this._setColorStyleTable(cloneData.Ref, cloneData, null, true); this._setColorStyleTable(cloneData.Ref, cloneData, null, true);
} }
else else
...@@ -1045,7 +1045,7 @@ ...@@ -1045,7 +1045,7 @@
if(!worksheet.TableParts) if(!worksheet.TableParts)
worksheet.TableParts = []; worksheet.TableParts = [];
worksheet.TableParts[worksheet.TableParts.length] = cloneData; worksheet.TableParts[worksheet.TableParts.length] = cloneData;
worksheet.workbook.dependencyFormulas.addTableName(cloneData.DisplayName, worksheet, cloneData.Ref, cloneData); worksheet.workbook.dependencyFormulas.addTableName(worksheet, cloneData);
this._setColorStyleTable(cloneData.Ref, cloneData, null, true); this._setColorStyleTable(cloneData.Ref, cloneData, null, true);
} }
else else
...@@ -3475,14 +3475,8 @@ ...@@ -3475,14 +3475,8 @@
newFilter.TableColumns = tableColumns; newFilter.TableColumns = tableColumns;
newFilter.DisplayName = tablePartDisplayName ? tablePartDisplayName : worksheet.workbook.dependencyFormulas.getNextTableName();
if(tablePartDisplayName) worksheet.workbook.dependencyFormulas.addTableName(worksheet, newFilter);
{
newFilter.DisplayName = tablePartDisplayName;
worksheet.workbook.dependencyFormulas.addTableName(tablePartDisplayName, worksheet, ref, newFilter);
}
else
newFilter.DisplayName = worksheet.workbook.dependencyFormulas.getNextTableName(worksheet, ref, null, newFilter);
worksheet.TableParts[worksheet.TableParts.length] = newFilter; worksheet.TableParts[worksheet.TableParts.length] = newFilter;
......
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