Commit 371cc33e authored by Alexander.Trofimov's avatar Alexander.Trofimov

bug 32535

validate name before create defined-name from menu toolbar
parent 97e54aa5
...@@ -1675,7 +1675,7 @@ var editor; ...@@ -1675,7 +1675,7 @@ var editor;
}; };
spreadsheet_api.prototype.asc_checkDefinedName = function(checkName, scope) { spreadsheet_api.prototype.asc_checkDefinedName = function(checkName, scope) {
return this.wb.checkDefName(checkName, scope); return this.wbModel.checkDefName(checkName, scope);
}; };
spreadsheet_api.prototype.asc_getDefaultDefinedName = function() { spreadsheet_api.prototype.asc_getDefaultDefinedName = function() {
......
...@@ -315,18 +315,17 @@ ...@@ -315,18 +315,17 @@
} }
}; };
/** @constructor */ /** @constructor */
function asc_CCheckDefName(s, r) { function asc_CCheckDefName(s, r) {
this.status = s; this.status = s;
this.reason = r; this.reason = r;
} }
asc_CCheckDefName.prototype = { asc_CCheckDefName.prototype.asc_getStatus = function () {
asc_getStatus: function() { return this.status;
return this.status; };
}, asc_getReason: function() { asc_CCheckDefName.prototype.asc_getReason = function () {
return this.reason; return this.reason;
} };
};
//----------------------------------------------------------export---------------------------------------------------- //----------------------------------------------------------export----------------------------------------------------
var prot; var prot;
......
...@@ -2482,42 +2482,38 @@ Workbook.prototype.recalcWB = function(isRecalcWB){ ...@@ -2482,42 +2482,38 @@ Workbook.prototype.recalcWB = function(isRecalcWB){
this.sortDependency(); this.sortDependency();
} }
}; };
Workbook.prototype.checkDefName = function ( checkName, scope ) { Workbook.prototype.checkDefName = function (checkName, scope) {
var res = new Asc.asc_CCheckDefName();
var rxTest = AscCommon.rx_defName.test( checkName ), res = new Asc.asc_CCheckDefName(); var range = AscCommonExcel.g_oRangeCache.getRange3D(checkName) ||
if ( !rxTest ) { AscCommonExcel.g_oRangeCache.getAscRange(checkName);
res.status = false; if (range || !AscCommon.rx_defName.test(checkName.toLowerCase())) {
res.reason = c_oAscDefinedNameReason.WrongName; res.status = false;
return res; res.reason = c_oAscDefinedNameReason.WrongName;
} return res;
}
if( scope !== null ){
scope = this.getWorksheet(scope).getId();
}
var defName = this.dependencyFormulas.getDefNameNode(getDefNameVertexId(scope, checkName));
if(defName){ if (scope !== null) {
defName = defName.getAscCDefName(); scope = this.getWorksheet(scope).getId();
res.status = false; }
if(defName.isLock){
res.reason = c_oAscDefinedNameReason.IsLocked;
}
else if( defName.Ref == null ){
res.reason = c_oAscDefinedNameReason.NameReserved;
}
else{
res.reason = c_oAscDefinedNameReason.Existed;
}
}
else{
res.status = true;
res.reason = c_oAscDefinedNameReason.OK;
}
return res; var defName = this.dependencyFormulas.getDefNameNode(getDefNameVertexId(scope, checkName));
if (defName) {
defName = defName.getAscCDefName();
res.status = false;
if (defName.isLock) {
res.reason = c_oAscDefinedNameReason.IsLocked;
} else if (defName.Ref == null) {
res.reason = c_oAscDefinedNameReason.NameReserved;
} else {
res.reason = c_oAscDefinedNameReason.Existed;
}
} else {
res.status = true;
res.reason = c_oAscDefinedNameReason.OK;
}
}; return res;
};
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)]; return !!this.dependencyFormulas.defNameList[getDefNameVertexId(sheetId, n)];
......
...@@ -2269,12 +2269,6 @@ ...@@ -2269,12 +2269,6 @@
}; };
WorkbookView.prototype.checkDefName = function(checkName, scope) {
return this.model.checkDefName(checkName, scope);
};
WorkbookView.prototype.editDefinedNames = function(oldName, newName) { WorkbookView.prototype.editDefinedNames = function(oldName, newName) {
//ToDo проверка defName.ref на знак "=" в начале ссылки. знака нет тогда это либо число либо строка, так делает Excel. //ToDo проверка defName.ref на знак "=" в начале ссылки. знака нет тогда это либо число либо строка, так делает Excel.
if (this.collaborativeEditing.getGlobalLock()) { if (this.collaborativeEditing.getGlobalLock()) {
......
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