Commit 27d0aea3 authored by Dmitry.Shahtanov's avatar Dmitry.Shahtanov Committed by Alexander.Trofimov

fix: Bug 30359 - [NamedRanges][CoEdit] Рассинхронизация адресов одноименных...

fix: Bug 30359 - [NamedRanges][CoEdit] Рассинхронизация адресов одноименных диапазонов с областью действия текущий лист при одновременном добавлении (http://bugzserver/show_bug.cgi?id=30359)

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@64723 954022d7-b5bf-4e40-9824-e11837661b57
parent 1d0c4b0c
...@@ -2870,6 +2870,15 @@ UndoRedoWorkbook.prototype = { ...@@ -2870,6 +2870,15 @@ UndoRedoWorkbook.prototype = {
this.wb.handlers.trigger("asc_onDelDefName") this.wb.handlers.trigger("asc_onDelDefName")
} }
else{ else{
if(this.wb.bCollaborativeChanges){
var name = Data.newName.Name, lsID = this.wb.getWorksheet(Data.newName.LocalSheetId);
lsID === null || lsID === undefined ? null : lsID = this.wb.getWorksheet(Data.newName.LocalSheetId).getId();
if( this.wb.isDefinedNamesExists(name,lsID) ){
var oConflictDefName = this.wb.getDefinesNames(name,lsID);
if(null != oConflictDefName)
oConflictDefName.renameDefNameToCollaborate(this.wb.getUniqueDefinedNameFrom(oConflictDefName, true));
}
}
this.wb.editDefinesNames( null, Data.newName, !bUndo ); this.wb.editDefinesNames( null, Data.newName, !bUndo );
this.wb.handlers.trigger("asc_onEditDefName", null, Data.newName); this.wb.handlers.trigger("asc_onEditDefName", null, Data.newName);
} }
......
...@@ -954,7 +954,7 @@ DependencyGraph.prototype = { ...@@ -954,7 +954,7 @@ DependencyGraph.prototype = {
var nodesList = this.defNameList, retRes = {}, defN, seUndoRedo = [], nSE, wsIndex, ws = this.wb.getWorksheetById(sheetId ), wsName = ws.getName(); var nodesList = this.defNameList, retRes = {}, defN, seUndoRedo = [], nSE, wsIndex, ws = this.wb.getWorksheetById(sheetId ), wsName = ws.getName();
for ( var id in nodesList ) { for ( var id in nodesList ) {
if ( nodesList[id].isTable && nodesList[id].Ref){ if ( nodesList[id].isTable && nodesList[id].Ref ){
var a = nodesList[id].Ref.split("!")[0]; var a = nodesList[id].Ref.split("!")[0];
if( a.localeCompare(parserHelp.getEscapeSheetName(wsName)) == 0 ) if( a.localeCompare(parserHelp.getEscapeSheetName(wsName)) == 0 )
nodesList[id].Ref = null; nodesList[id].Ref = null;
...@@ -1658,6 +1658,46 @@ DefNameVertex.prototype = { ...@@ -1658,6 +1658,46 @@ DefNameVertex.prototype = {
if( this.parsedRef.isParsed ){ if( this.parsedRef.isParsed ){
this.Ref = this.parsedRef.assemble(); this.Ref = this.parsedRef.assemble();
} }
},
renameDefNameToCollaborate:function(name){
var lastname = this.Name;
//из-за особенностей реализации формул, сначала делаем parse со старым именем, потом преименовываем, потом assemble
var aFormulas = [];
//переименование для отправки изменений
for(var i = 0, length = this.wb.aCollaborativeActions.length; i < length; ++i)
{
var aPointActions = this.wb.aCollaborativeActions[i];
for (var j = 0, length2 = aPointActions.length; j < length2; ++j) {
var action = aPointActions[j];
if (g_oUndoRedoWorkbook == action.oClass) {
if (historyitem_Workbook_DefinedNamesAdd == action.nActionType) {
if (lastname == action.oData.newName.Name)
action.oData.newName.Name = name;
}
}
else if (g_oUndoRedoCell == action.oClass) {
if (action.oData instanceof UndoRedoData_CellSimpleData) {
if (action.oData.oNewVal instanceof UndoRedoData_CellValueData) {
var oNewVal = action.oData.oNewVal;
if (null != oNewVal.formula && -1 != oNewVal.formula.indexOf(lastname)) {
var oParser = new parserFormula(oNewVal.formula, "A1", this.wb.getWorksheet(0));
oParser.parse();
aFormulas.push({ formula: oParser, value: oNewVal });
}
}
}
}
}
}
var clone = this.clone();
clone.Name = name;
this.wb.editDefinesNames( this.getAscCDefName(), clone.getAscCDefName() );
for(var i = 0, length = aFormulas.length; i < length; ++i)
{
var item = aFormulas[i];
item.value.formula = item.formula.assemble();
}
} }
}; };
...@@ -2442,25 +2482,10 @@ Workbook.prototype.checkDefName = function ( checkName, scope ) { ...@@ -2442,25 +2482,10 @@ Workbook.prototype.checkDefName = function ( checkName, scope ) {
}; };
Workbook.prototype.isDefinedNamesExists = function ( name, sheetId ) { Workbook.prototype.isDefinedNamesExists = function ( name, sheetId ) {
var n = name.toLowerCase(); var n = name.toLowerCase();
return !!this.dependencyFormulas.defNameList[getDefNameVertexId(sheetId, n)];
if ( null != sheetId ) {
var ws = this.getWorksheetById( sheetId );
if ( null != ws ) {
var bExist = false;
if ( ws.DefinedNames )
bExist = !!ws.DefinedNames[n];
if ( bExist )
return bExist;
}
}
if ( this.DefinedNames ) {
return !!this.DefinedNames[n];
}
return false;
}; };
Workbook.prototype.getDefinesNamesWB = function (defNameListId) { Workbook.prototype.getDefinedNamesWB = function (defNameListId) {
var names = [], name, thas = this, activeWS; var names = [], name, thas = this, activeWS;
/*c_oAscGetDefinedNamesList. /*c_oAscGetDefinedNamesList.
...@@ -2639,9 +2664,7 @@ Workbook.prototype.editDefinesNames = function ( oldName, newName, bUndo ) { ...@@ -2639,9 +2664,7 @@ Workbook.prototype.editDefinesNames = function ( oldName, newName, bUndo ) {
}; };
Workbook.prototype.findDefinesNames = function ( ref, sheetId ) { Workbook.prototype.findDefinesNames = function ( ref, sheetId ) {
return this.dependencyFormulas.getDefNameNodeByRef( ref, sheetId ); return this.dependencyFormulas.getDefNameNodeByRef( ref, sheetId );
}; };
Workbook.prototype.unlockDefName = function(){ Workbook.prototype.unlockDefName = function(){
this.dependencyFormulas.unlockDefName(); this.dependencyFormulas.unlockDefName();
...@@ -2649,6 +2672,46 @@ Workbook.prototype.unlockDefName = function(){ ...@@ -2649,6 +2672,46 @@ Workbook.prototype.unlockDefName = function(){
Workbook.prototype.checkDefNameLock = function(){ Workbook.prototype.checkDefNameLock = function(){
return this.dependencyFormulas.checkDefNameLock(); return this.dependencyFormulas.checkDefNameLock();
}; };
Workbook.prototype.getUniqueDefinedNameFrom=function(name, bCopy){
var nIndex = 1,
dnNewName = "",
fGetPostfix = null,
name = name.Name,
sheetId = name.sheetId;
if(bCopy)
{
var result = /^(.*)(\d)$/.exec(name);
if(result)
{
fGetPostfix = function(nIndex){return "" + nIndex;};
name = result[1];
}
else
{
fGetPostfix = function(nIndex){return "_" + nIndex;};
name = name;
}
}
else
{
fGetPostfix = function(nIndex){return nIndex.toString();};
}
while(nIndex < 10000)
{
var sPosfix = fGetPostfix(nIndex);
dnNewName = name + sPosfix;
var bUniqueName = false;
if(!this.isDefinedNamesExists( dnNewName, sheetId )){
bUniqueName = true;
break;
}
if(bUniqueName)
break;
nIndex++;
}
return dnNewName;
};
Workbook.prototype.buildDependency = function(){ Workbook.prototype.buildDependency = function(){
this.dependencyFormulas.clear(); this.dependencyFormulas.clear();
// this.dependencyFormulas = null; // this.dependencyFormulas = null;
...@@ -3271,7 +3334,7 @@ Woorksheet.prototype.setTabColor=function(color){ ...@@ -3271,7 +3334,7 @@ Woorksheet.prototype.setTabColor=function(color){
this.workbook.handlers.trigger("asc_onUpdateTabColor", this.getIndex()); this.workbook.handlers.trigger("asc_onUpdateTabColor", this.getIndex());
}; };
Woorksheet.prototype.renameWsToCollaborate=function(name){ Woorksheet.prototype.renameWsToCollaborate=function(name){
var lastname = this.getName(); var lastname = this.getName();
//из-за особенностей реализации формул, сначала делаем parse со старым именем, потом преименовываем, потом assemble //из-за особенностей реализации формул, сначала делаем parse со старым именем, потом преименовываем, потом assemble
var aFormulas = []; var aFormulas = [];
//переименование для отправки изменений //переименование для отправки изменений
......
...@@ -1952,7 +1952,7 @@ ...@@ -1952,7 +1952,7 @@
}; };
WorkbookView.prototype.getDefinedNames = function (defNameListId) { WorkbookView.prototype.getDefinedNames = function (defNameListId) {
return this.model.getDefinesNamesWB(defNameListId); return this.model.getDefinedNamesWB(defNameListId);
}; };
WorkbookView.prototype.setDefinedNames = function (defName) { WorkbookView.prototype.setDefinedNames = function (defName) {
......
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