Commit 9f4b78c0 authored by GoshaZotov's avatar GoshaZotov

fix bug 32319 - [NamedRanges][CoEdit] Рассинхронизация при копировании листа...

fix bug 32319  - [NamedRanges][CoEdit] Рассинхронизация при копировании листа с форматированной таблицей одним пользователем и одновременном создании её другим (edit)
parent a20a47bb
...@@ -1492,9 +1492,10 @@ UndoRedoDataParaPr.prototype = { ...@@ -1492,9 +1492,10 @@ UndoRedoDataParaPr.prototype = {
var g_oUndoRedoData_SheetAddProperties = { var g_oUndoRedoData_SheetAddProperties = {
name: 0, name: 0,
sheetidfrom: 1, sheetidfrom: 1,
sheetid: 2 sheetid: 2,
tableNames: 3
}; };
function UndoRedoData_SheetAdd(insertBefore, name, sheetidfrom, sheetid){ function UndoRedoData_SheetAdd(insertBefore, name, sheetidfrom, sheetid, tableNames){
this.Properties = g_oUndoRedoData_SheetAddProperties; this.Properties = g_oUndoRedoData_SheetAddProperties;
this.insertBefore= insertBefore; this.insertBefore= insertBefore;
this.name = name; this.name = name;
...@@ -1503,6 +1504,8 @@ function UndoRedoData_SheetAdd(insertBefore, name, sheetidfrom, sheetid){ ...@@ -1503,6 +1504,8 @@ function UndoRedoData_SheetAdd(insertBefore, name, sheetidfrom, sheetid){
//Эти поля заполняются после Undo/Redo //Эти поля заполняются после Undo/Redo
this.sheet = null; this.sheet = null;
this.cwf = null; this.cwf = null;
this.tableNames = tableNames;
} }
UndoRedoData_SheetAdd.prototype = { UndoRedoData_SheetAdd.prototype = {
getType : function() getType : function()
...@@ -1520,6 +1523,7 @@ UndoRedoData_SheetAdd.prototype = { ...@@ -1520,6 +1523,7 @@ UndoRedoData_SheetAdd.prototype = {
case this.Properties.name: return this.name;break; case this.Properties.name: return this.name;break;
case this.Properties.sheetidfrom: return this.sheetidfrom;break; case this.Properties.sheetidfrom: return this.sheetidfrom;break;
case this.Properties.sheetid: return this.sheetid;break; case this.Properties.sheetid: return this.sheetid;break;
case this.Properties.tableNames: return this.tableNames;break;
} }
return null; return null;
}, },
...@@ -1530,6 +1534,7 @@ UndoRedoData_SheetAdd.prototype = { ...@@ -1530,6 +1534,7 @@ UndoRedoData_SheetAdd.prototype = {
case this.Properties.name: this.name = value;break; case this.Properties.name: this.name = value;break;
case this.Properties.sheetidfrom: this.sheetidfrom = value;break; case this.Properties.sheetidfrom: this.sheetidfrom = value;break;
case this.Properties.sheetid: this.sheetid = value;break; case this.Properties.sheetid: this.sheetid = value;break;
case this.Properties.tableNames: this.tableNames = value;break;
} }
} }
}; };
...@@ -2810,7 +2815,7 @@ UndoRedoWorkbook.prototype = { ...@@ -2810,7 +2815,7 @@ UndoRedoWorkbook.prototype = {
{ {
var oCurWorksheet = this.wb.getWorksheetById(Data.sheetidfrom); var oCurWorksheet = this.wb.getWorksheetById(Data.sheetidfrom);
var nIndex = oCurWorksheet.getIndex(); var nIndex = oCurWorksheet.getIndex();
this.wb.copyWorksheet(nIndex, Data.insertBefore, Data.name, Data.sheetid, true); this.wb.copyWorksheet(nIndex, Data.insertBefore, Data.name, Data.sheetid, true, Data.tableNames);
} }
} }
} }
......
...@@ -1162,7 +1162,7 @@ DependencyGraph.prototype = { ...@@ -1162,7 +1162,7 @@ DependencyGraph.prototype = {
// return false; // return false;
}, },
getNextTableName:function ( ws, Ref ) { getNextTableName:function ( ws, Ref, tableName ) {
this.nTableNameMaxIndex++; this.nTableNameMaxIndex++;
var sNewName = this.sTableNamePattern + this.nTableNameMaxIndex, var sNewName = this.sTableNamePattern + this.nTableNameMaxIndex,
name = getDefNameVertexId( null, sNewName ); name = getDefNameVertexId( null, sNewName );
...@@ -1171,6 +1171,20 @@ DependencyGraph.prototype = { ...@@ -1171,6 +1171,20 @@ DependencyGraph.prototype = {
sNewName = this.sTableNamePattern + this.nTableNameMaxIndex; sNewName = this.sTableNamePattern + this.nTableNameMaxIndex;
name = getDefNameVertexId( null, sNewName ); name = getDefNameVertexId( null, sNewName );
} }
if(tableName)
{
sNewName = tableName;
}
else if(ws.workbook.oApi.collaborativeEditing.getCollaborativeEditing())
{
var indexUser = ws.workbook.oApi.CoAuthoringApi.get_indexUser();
if(null !== indexUser)
{
sNewName += "_" + indexUser;
}
}
this.addTableName( sNewName, ws, Ref ); this.addTableName( sNewName, ws, Ref );
return sNewName; return sNewName;
}, },
...@@ -2055,14 +2069,14 @@ Workbook.prototype.createWorksheet=function(indexBefore, sName, sId){ ...@@ -2055,14 +2069,14 @@ Workbook.prototype.createWorksheet=function(indexBefore, sName, sId){
History.SetSheetRedo(oNewWorksheet.getId()); History.SetSheetRedo(oNewWorksheet.getId());
return oNewWorksheet.index; return oNewWorksheet.index;
}; };
Workbook.prototype.copyWorksheet=function(index, insertBefore, sName, sId, bFromRedo){ Workbook.prototype.copyWorksheet=function(index, insertBefore, sName, sId, bFromRedo, tableNames){
//insertBefore - optional //insertBefore - optional
if(index >= 0 && index < this.aWorksheets.length){ if(index >= 0 && index < this.aWorksheets.length){
History.TurnOff(); History.TurnOff();
var wsActive = this.getActiveWs(); var wsActive = this.getActiveWs();
var wsFrom = this.aWorksheets[index]; var wsFrom = this.aWorksheets[index];
var newSheet = wsFrom.clone(sId, sName); var newSheet = wsFrom.clone(sId, sName, tableNames);
newSheet.initPostOpen(this.wsHandlers); newSheet.initPostOpen(this.wsHandlers);
if(null != insertBefore && insertBefore >= 0 && insertBefore < this.aWorksheets.length){ if(null != insertBefore && insertBefore >= 0 && insertBefore < this.aWorksheets.length){
//помещаем новый sheet перед insertBefore //помещаем новый sheet перед insertBefore
...@@ -2092,7 +2106,17 @@ Workbook.prototype.copyWorksheet=function(index, insertBefore, sName, sId, bFrom ...@@ -2092,7 +2106,17 @@ Workbook.prototype.copyWorksheet=function(index, insertBefore, sName, sId, bFrom
} }
newSheet._BuildDependencies(cwf.cells); newSheet._BuildDependencies(cwf.cells);
} }
History.Add(AscCommonExcel.g_oUndoRedoWorkbook, AscCH.historyitem_Workbook_SheetAdd, null, null, new UndoRedoData_SheetAdd(insertBefore, newSheet.getName(), wsFrom.getId(), newSheet.getId()));
if(!tableNames && newSheet.TableParts && newSheet.TableParts.length)
{
tableNames = [];
for(var i = 0; i < newSheet.TableParts.length; i++)
{
tableNames.push(newSheet.TableParts[i].DisplayName);
}
}
History.Add(AscCommonExcel.g_oUndoRedoWorkbook, AscCH.historyitem_Workbook_SheetAdd, null, null, new UndoRedoData_SheetAdd(insertBefore, newSheet.getName(), wsFrom.getId(), newSheet.getId(), tableNames));
History.SetSheetUndo(wsActive.getId()); History.SetSheetUndo(wsActive.getId());
History.SetSheetRedo(newSheet.getId()); History.SetSheetRedo(newSheet.getId());
if(!(bFromRedo === true)) if(!(bFromRedo === true))
...@@ -3313,7 +3337,7 @@ Woorksheet.prototype.generateFontMap=function(oFontMap){ ...@@ -3313,7 +3337,7 @@ Woorksheet.prototype.generateFontMap=function(oFontMap){
} }
} }
}; };
Woorksheet.prototype.clone=function(sNewId, sName){ Woorksheet.prototype.clone=function(sNewId, sName, tableNames){
var i, elem, range; var i, elem, range;
var oNewWs = new Woorksheet(this.workbook, this.workbook.aWorksheets.length, sNewId); var oNewWs = new Woorksheet(this.workbook, this.workbook.aWorksheets.length, sNewId);
oNewWs.sName = this.workbook.checkValidSheetName(sName) ? sName : this.workbook.getUniqueSheetNameFrom(this.sName, true); oNewWs.sName = this.workbook.checkValidSheetName(sName) ? sName : this.workbook.getUniqueSheetNameFrom(this.sName, true);
...@@ -3323,7 +3347,14 @@ Woorksheet.prototype.clone=function(sNewId, sName){ ...@@ -3323,7 +3347,14 @@ Woorksheet.prototype.clone=function(sNewId, sName){
oNewWs.nRowsCount = this.nRowsCount; oNewWs.nRowsCount = this.nRowsCount;
oNewWs.nColsCount = this.nColsCount; oNewWs.nColsCount = this.nColsCount;
for (i = 0; i < this.TableParts.length; ++i) for (i = 0; i < this.TableParts.length; ++i)
oNewWs.TableParts.push(this.TableParts[i].clone(oNewWs)); {
var tableName = null;
if(tableNames && tableNames.length)
{
tableName = tableNames[i];
}
oNewWs.TableParts.push(this.TableParts[i].clone(oNewWs, tableName));
}
if(this.AutoFilter) if(this.AutoFilter)
oNewWs.AutoFilter = this.AutoFilter.clone(); oNewWs.AutoFilter = this.AutoFilter.clone();
for (i in this.aCols) { for (i in this.aCols) {
......
...@@ -4643,7 +4643,7 @@ function TablePart(handlers) { ...@@ -4643,7 +4643,7 @@ function TablePart(handlers) {
this.result = null; this.result = null;
this.handlers = handlers; this.handlers = handlers;
} }
TablePart.prototype.clone = function(ws) { TablePart.prototype.clone = function(ws, tableName) {
var i, res = new TablePart(this.handlers); var i, res = new TablePart(this.handlers);
res.Ref = this.Ref ? this.Ref.clone() : null; res.Ref = this.Ref ? this.Ref.clone() : null;
res.HeaderRowCount = this.HeaderRowCount; res.HeaderRowCount = this.HeaderRowCount;
...@@ -4666,14 +4666,22 @@ TablePart.prototype.clone = function(ws) { ...@@ -4666,14 +4666,22 @@ TablePart.prototype.clone = function(ws) {
res.result.push(this.result[i].clone()); res.result.push(this.result[i].clone());
} }
res.DisplayName = this.DisplayName; if(tableName)
{
res.DisplayName = tableName;
}
else
{
res.DisplayName = this.DisplayName;
}
if(ws !== null) if(ws !== null)
res.recalc(ws); res.recalc(ws, tableName);
return res; return res;
}; };
TablePart.prototype.recalc = function(ws) { TablePart.prototype.recalc = function(ws, tableName) {
this.DisplayName = ws.workbook.dependencyFormulas.getNextTableName(ws, this.Ref); this.DisplayName = ws.workbook.dependencyFormulas.getNextTableName(ws, this.Ref, tableName);
}; };
TablePart.prototype.moveRef = function(col, row) { TablePart.prototype.moveRef = function(col, row) {
var ref = this.Ref.clone(); var ref = this.Ref.clone();
......
...@@ -260,6 +260,13 @@ ...@@ -260,6 +260,13 @@
} }
return null; return null;
}; };
CDocsCoApi.prototype.get_indexUser = function() {
if (this._CoAuthoringApi && this._onlineWork) {
return this._CoAuthoringApi.get_indexUser();
}
return null;
};
CDocsCoApi.prototype.releaseLocks = function(blockId) { CDocsCoApi.prototype.releaseLocks = function(blockId) {
if (this._CoAuthoringApi && this._onlineWork) { if (this._CoAuthoringApi && this._onlineWork) {
......
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