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