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