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

дополнение для именованных диапзонов

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@62800 954022d7-b5bf-4e40-9824-e11837661b57
parent 2d0860dd
......@@ -223,9 +223,9 @@
/** @constructor */
function asc_CDefName(n, r, s) {
this.Name = n?n:null;
this.LocalSheetId = s?s:null;
this.Ref = r?r:null;
this.Name = n;
this.LocalSheetId = s;
this.Ref = r;
}
asc_CDefName.prototype = {
......
......@@ -5111,12 +5111,8 @@
});
if(null != oNewDefinedName.Name && null != oNewDefinedName.Ref)
{
LocalSheetId = oNewDefinedName.LocalSheetId;
if(LocalSheetId !== null ){
LocalSheetId = this.oWorkbook.aWorksheets[oNewDefinedName.LocalSheetId].getId();
}
this.oWorkbook.dependencyFormulas.addDefinedNameNode(oNewDefinedName.Name, LocalSheetId, oNewDefinedName.Ref);
this.oWorkbook.dependencyFormulas.addDefinedNameNode(oNewDefinedName.Name, oNewDefinedName.LocalSheetId, oNewDefinedName.Ref);
}
}
......
......@@ -860,14 +860,18 @@ DependencyGraph.prototype = {
return false;
},
addDefinedNameNode:function(defName, defScope, defRef, bUndo){
addDefinedNameNode:function(defName, sheetId, defRef, bUndo){
var ws = this.wb.getWorksheet(sheetId)
ws ? sheetId = ws.getId() : null;
var _this = this,
nodeId = getDefNameVertexId( defScope, defName ),
nodeId = getDefNameVertexId( sheetId, defName ),
oRes = this.defNameList[nodeId],
dfv, defNameSheetsList;
if( null == oRes ){
dfv = new DefNameVertex(defScope,defName,defRef,this.wb);
dfv = new DefNameVertex(sheetId,defName,defRef,this.wb);
oRes = (this.defNameList[dfv.nodeId] = dfv);
defNameSheetsList = this.defNameSheets[dfv.sheetId];
if( defNameSheetsList == null ){
......@@ -885,6 +889,10 @@ DependencyGraph.prototype = {
},
remoteDefName:function(sheetId, name){
var ws = this.wb.getWorksheet(sheetId)
ws ? sheetId = ws.getId() : null;
var nodeId = getDefNameVertexId( sheetId, name ),
oRes = this.defNameList[nodeId],
ret = null;
......@@ -898,12 +906,14 @@ DependencyGraph.prototype = {
},
changeDefName: function( oldDefName, newDefName ){
var oldN = this.getDefNameNodeByName( oldDefName.Name, oldDefName.Scope ),
var ws = this.wb.getWorksheet(oldDefName.LocalSheetId ), sheetId = null;
ws ? sheetId = ws.getId() : null;
var oldN = this.getDefNameNodeByName( oldDefName.Name, sheetId ),
res = null, sheetNodeList, nodeId,
sheetId = oldDefName.Scope,
name = oldDefName.Name;
sheetNodeList = this.defNameSheets[sheetId||"WB"];
nodeId = getDefNameVertexId( sheetId||"WB", name );
......@@ -926,11 +936,7 @@ DependencyGraph.prototype = {
defN = this.defNameList[id];
if( defN.isTable ){continue;}
if(defN.Ref != null){
defN = defN.getAscCDefName()
if(defN.LocalSheetId !== null){
defN.LocalSheetId = this.wb.aWorksheetsById[defN.LocalSheetId].index;
}
list.push(defN);
list.push(defN.getAscCDefName());
}
}
return list;
......@@ -1423,7 +1429,7 @@ DefNameVertex.prototype = {
},
getAscCDefName:function(){
return new Asc.asc_CDefName( this.Name, this.Ref, this.sheetId == "WB" ? null : this.sheetId );
return new Asc.asc_CDefName( this.Name, this.Ref, this.sheetId == "WB" ? null : this.wb.getWorksheetById(this.sheetId ).getIndex() );
},
changeDefName:function(newName){
......@@ -2172,7 +2178,7 @@ Workbook.prototype.getDefinesNames = function ( name, sheetId ) {
var res = this.dependencyFormulas.getDefNameNodeByName(name, sheetId);
return res;
};
Workbook.prototype.setDefinesNames = function ( defName ) {
/*Workbook.prototype.setDefinesNames = function ( defName ) {
var n = defName.Name.toLowerCase(),
retRes = null;
......@@ -2212,12 +2218,12 @@ Workbook.prototype.setDefinesNames = function ( defName ) {
History.Create_NewPoint();
History.Add(g_oUndoRedoWorkbook, historyitem_Workbook_DefinedNamesAdd, null, null, new UndoRedoData_DefinedNames(retRes.Name, retRes.Ref, retRes.Scope));
/*
*//*
TODO
добавить в граф зависимостей ноду с новым именованным диапазоном.
если функция содержит именованный диапазон с область видимости книга, а вводится диапазон с таким же именем,
но с областью видимости лист, то функция пересчитывается на диапазон с областью видимости лист
*/
*//*
......@@ -2225,7 +2231,7 @@ Workbook.prototype.setDefinesNames = function ( defName ) {
return retRes;
};
};*/
Workbook.prototype.delDefinesNames = function ( defName ) {
History.Create_NewPoint();
var retRes = false, res = null;
......@@ -2284,7 +2290,7 @@ Workbook.prototype.editDefinesNames = function ( oldName, newName, bUndo ) {
rename = true;
}
else{
retRes = this.dependencyFormulas.addDefinedNameNode(newName.Name, newName.Scope, newName.Ref, bUndo);
retRes = this.dependencyFormulas.addDefinedNameNode(newName.Name, newName.LocalSheetId, newName.Ref, bUndo);
}
if( retRes ){
......
......@@ -1966,6 +1966,15 @@
this.handlers.trigger("asc_onDelDefName", this.model.delDefinesNames(oldName));
};
WorkbookView.prototype.getDefaultDefinedName = function () {
//ToDo проверка defName.ref на знак "=" в начале ссылки. знака нет тогда это либо число либо строка, так делает Excel.
var ws = this.getWorksheet();
return new Asc.asc_CDefName( "", ws.getSelectionRangeValue(), null );
};
// Печать
......
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