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 = {
var g_oUndoRedoData_SheetAddProperties = {
name: 0,
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.insertBefore= insertBefore;
this.name = name;
......@@ -1503,6 +1504,8 @@ function UndoRedoData_SheetAdd(insertBefore, name, sheetidfrom, sheetid){
//Эти поля заполняются после Undo/Redo
this.sheet = null;
this.cwf = null;
this.tableNames = tableNames;
}
UndoRedoData_SheetAdd.prototype = {
getType : function()
......@@ -1520,6 +1523,7 @@ UndoRedoData_SheetAdd.prototype = {
case this.Properties.name: return this.name;break;
case this.Properties.sheetidfrom: return this.sheetidfrom;break;
case this.Properties.sheetid: return this.sheetid;break;
case this.Properties.tableNames: return this.tableNames;break;
}
return null;
},
......@@ -1530,6 +1534,7 @@ UndoRedoData_SheetAdd.prototype = {
case this.Properties.name: this.name = value;break;
case this.Properties.sheetidfrom: this.sheetidfrom = value;break;
case this.Properties.sheetid: this.sheetid = value;break;
case this.Properties.tableNames: this.tableNames = value;break;
}
}
};
......@@ -2810,7 +2815,7 @@ UndoRedoWorkbook.prototype = {
{
var oCurWorksheet = this.wb.getWorksheetById(Data.sheetidfrom);
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 = {
// return false;
},
getNextTableName:function ( ws, Ref ) {
getNextTableName:function ( ws, Ref, tableName ) {
this.nTableNameMaxIndex++;
var sNewName = this.sTableNamePattern + this.nTableNameMaxIndex,
name = getDefNameVertexId( null, sNewName );
......@@ -1171,6 +1171,20 @@ DependencyGraph.prototype = {
sNewName = this.sTableNamePattern + this.nTableNameMaxIndex;
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 );
return sNewName;
},
......@@ -2055,14 +2069,14 @@ Workbook.prototype.createWorksheet=function(indexBefore, sName, sId){
History.SetSheetRedo(oNewWorksheet.getId());
return oNewWorksheet.index;
};
Workbook.prototype.copyWorksheet=function(index, insertBefore, sName, sId, bFromRedo){
Workbook.prototype.copyWorksheet=function(index, insertBefore, sName, sId, bFromRedo, tableNames){
//insertBefore - optional
if(index >= 0 && index < this.aWorksheets.length){
History.TurnOff();
var wsActive = this.getActiveWs();
var wsFrom = this.aWorksheets[index];
var newSheet = wsFrom.clone(sId, sName);
var newSheet = wsFrom.clone(sId, sName, tableNames);
newSheet.initPostOpen(this.wsHandlers);
if(null != insertBefore && insertBefore >= 0 && insertBefore < this.aWorksheets.length){
//помещаем новый sheet перед insertBefore
......@@ -2092,7 +2106,17 @@ Workbook.prototype.copyWorksheet=function(index, insertBefore, sName, sId, bFrom
}
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.SetSheetRedo(newSheet.getId());
if(!(bFromRedo === true))
......@@ -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 oNewWs = new Woorksheet(this.workbook, this.workbook.aWorksheets.length, sNewId);
oNewWs.sName = this.workbook.checkValidSheetName(sName) ? sName : this.workbook.getUniqueSheetNameFrom(this.sName, true);
......@@ -3323,7 +3347,14 @@ Woorksheet.prototype.clone=function(sNewId, sName){
oNewWs.nRowsCount = this.nRowsCount;
oNewWs.nColsCount = this.nColsCount;
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)
oNewWs.AutoFilter = this.AutoFilter.clone();
for (i in this.aCols) {
......
......@@ -4643,7 +4643,7 @@ function TablePart(handlers) {
this.result = null;
this.handlers = handlers;
}
TablePart.prototype.clone = function(ws) {
TablePart.prototype.clone = function(ws, tableName) {
var i, res = new TablePart(this.handlers);
res.Ref = this.Ref ? this.Ref.clone() : null;
res.HeaderRowCount = this.HeaderRowCount;
......@@ -4666,14 +4666,22 @@ TablePart.prototype.clone = function(ws) {
res.result.push(this.result[i].clone());
}
if(tableName)
{
res.DisplayName = tableName;
}
else
{
res.DisplayName = this.DisplayName;
}
if(ws !== null)
res.recalc(ws);
res.recalc(ws, tableName);
return res;
};
TablePart.prototype.recalc = function(ws) {
this.DisplayName = ws.workbook.dependencyFormulas.getNextTableName(ws, this.Ref);
TablePart.prototype.recalc = function(ws, tableName) {
this.DisplayName = ws.workbook.dependencyFormulas.getNextTableName(ws, this.Ref, tableName);
};
TablePart.prototype.moveRef = function(col, row) {
var ref = this.Ref.clone();
......
......@@ -261,6 +261,13 @@
return null;
};
CDocsCoApi.prototype.get_indexUser = function() {
if (this._CoAuthoringApi && this._onlineWork) {
return this._CoAuthoringApi.get_indexUser();
}
return null;
};
CDocsCoApi.prototype.releaseLocks = function(blockId) {
if (this._CoAuthoringApi && this._onlineWork) {
this._CoAuthoringApi.releaseLocks(blockId);
......
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