Commit 2a3d0d45 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@62981 954022d7-b5bf-4e40-9824-e11837661b57
parent 1fcf9e8d
......@@ -2119,8 +2119,8 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
return this.wbModel.getWorksheet(index).getHidden();
};
spreadsheet_api.prototype.asc_getDefinedNames = function () {
return this.wb.getDefinedNames();
spreadsheet_api.prototype.asc_getDefinedNames = function (defNameListId) {
return this.wb.getDefinedNames(defNameListId);
};
spreadsheet_api.prototype.asc_setDefinedNames = function (defName) {
......
......@@ -321,3 +321,9 @@ var c_oAscFormulaRangeBorderColor = [
var c_oAscLockNameFrozenPane = "frozenPane";
var c_oAscLockNameTabColor = "tabColor";
var c_oAscGetDefinedNamesList = {
Worksheet : 0,
WorksheetWorkbook : 1,
All : 2
}
\ No newline at end of file
......@@ -874,7 +874,7 @@ DependencyGraph.prototype = {
oRes = this.defNameList[nodeId],
dfv, defNameSheetsList;
if ( null == oRes ) {
if ( null == oRes || null == oRes.Ref ) {
dfv = new DefNameVertex( sheetId, defName, defRef, this.wb );
oRes = (this.defNameList[dfv.nodeId] = dfv);
defNameSheetsList = this.defNameSheets[dfv.sheetId];
......@@ -934,6 +934,33 @@ DependencyGraph.prototype = {
return oldN;
},
copyDefNameByWorksheet:function( oldSheetId, newSheetId ){
var obj = {}, oldS = this.defNameSheets[oldSheetId], defNamNode,
oldWS = this.wb.getWorksheetById(oldSheetId ),
newWS = this.wb.getWorksheetById(newSheetId);
for( var id in oldS ){
defNamNode = oldS[id].clone();
defNamNode.changeScope(newSheetId);
defNamNode.changeRefToNewSheet(oldWS.getName(),newWS.getName());
obj[defNamNode.nodeId] = defNamNode;
this.defNameList[defNamNode.nodeId] = defNamNode;
}
this.defNameSheets[newSheetId] = obj;
},
relinkDefNameByWorksheet:function (){
var oldS = this.defNameList;
for( var id in oldS ){
oldS[id].relinkRef();
}
},
saveDefName:function () {
var list = [], defN;
for ( var id in this.defNameList ) {
......@@ -1224,11 +1251,16 @@ function DefNameVertex( scope, defName, defRef, wb, isTable ) {
// this.sheetId = scope || "WB";
this.cellId = defName.toLowerCase();
this.Ref = defRef;
this.Name = defName
this.Name = defName;
this.isTable = isTable;
this.nodeId = getDefNameVertexId( this.sheetId, defName );
this.wb = wb;
this.parsedRef = new parserFormula(this.Ref, "", this.wb.getWorksheet(0))
if( this.Ref ){
this.parsedRef.parse();
}
//вершина которую мы прошли и поставили в очередь обхода
this.isBlack = false;
......@@ -1252,6 +1284,22 @@ DefNameVertex.prototype = {
constructor:Vertex,
clone:function(){
return new DefNameVertex( this.sheetId, this.cellId, this.Ref , this.wb, this.isTable );
},
changeScope:function( newScope ){
this.sheetId = newScope === null || newScope === undefined ? "WB" : newScope;
this.nodeId = getDefNameVertexId( this.sheetId, this.Name );
},
changeRefToNewSheet:function( lastName, newName ){
if( this.parsedRef.isParsed ){
this.parsedRef = this.parsedRef.changeSheet( lastName, newName );
this.Ref = this.parsedRef.assemble();
}
},
moveInner:function ( bboxTo ) {
//удаляем старые ссылки slave и master
for ( var i in this.slaveEdges ) {
......@@ -1440,6 +1488,12 @@ DefNameVertex.prototype = {
this.Ref = newName.Ref;
this.Name = newName.Name;
this.nodeId = getDefNameVertexId( this.sheetId, newName.Name );
},
relinkRef:function(){
if( this.parsedRef.isParsed ){
this.Ref = this.parsedRef.assemble();
}
}
};
......@@ -1829,6 +1883,9 @@ Workbook.prototype.copyWorksheet=function(index, insertBefore, sName, sId, bFrom
this._updateWorksheetIndexes(wsActive);
History.TurnOn();
this._insertWorksheetFormula(insertBefore);
this.dependencyFormulas.copyDefNameByWorksheet( wsFrom.getId(), newSheet.getId() );
//для формул. создаем копию this.cwf[this.Id] для нового листа.
if ( this.cwf[wsFrom.getId()] ){
var cwf = { cells:{} };
......@@ -1842,6 +1899,7 @@ Workbook.prototype.copyWorksheet=function(index, insertBefore, sName, sId, bFrom
}
newSheet._BuildDependencies(cwf.cells);
}
sortDependency(this);
History.Add(g_oUndoRedoWorkbook, historyitem_Workbook_SheetAdd, null, null, new UndoRedoData_SheetAdd(insertBefore, newSheet.getName(), wsFrom.getId(), newSheet.getId()));
History.SetSheetUndo(wsActive.getId());
......@@ -2181,16 +2239,47 @@ Workbook.prototype.isDefinedNamesExists = function ( name, sheetId ) {
}
return false;
};
Workbook.prototype.getDefinesNamesWB = function () {
var names = [], name;
Workbook.prototype.getDefinesNamesWB = function (defNameListId) {
var names = [], name, thas = this;
/*c_oAscGetDefinedNamesList.
Worksheet : 0,
WorksheetWorkbook : 1,
All*/
for ( var id in this.dependencyFormulas.defNameList ) {
name = this.dependencyFormulas.defNameList[id].getAscCDefName()
if ( name.Ref ) {
names.push( name );
function getNames(id,arr){
var listDN = thas.dependencyFormulas.defNameSheets[id], name;
for ( var id in listDN ) {
name = listDN[id].getAscCDefName();
if ( name.Ref ) {
arr.push( name );
}
}
}
var activeWS, listDN
switch(defNameListId){
case c_oAscGetDefinedNamesList.Worksheet:
case c_oAscGetDefinedNamesList.WorksheetWorkbook:
activeWS = this.getActiveWs();
getNames(activeWS.getId(),names);
if( c_oAscGetDefinedNamesList.WorksheetWorkbook ){
getNames("WB",names);
}
break;
case c_oAscGetDefinedNamesList.All:
default:
for ( var id in this.dependencyFormulas.defNameList ) {
name = this.dependencyFormulas.defNameList[id].getAscCDefName()
if ( name.Ref ) {
names.push( name );
}
}
break;
}
return names;
}
Workbook.prototype.getDefinesNames = function ( name, sheetId ) {
......@@ -2820,6 +2909,7 @@ Woorksheet.prototype.clone=function(sNewId){
}
if (this.sheetPr)
oNewWs.sheetPr = this.sheetPr.clone();
return oNewWs;
};
Woorksheet.prototype.copyDrawingObjects=function(oNewWs, wsFrom)
......@@ -2990,6 +3080,8 @@ Woorksheet.prototype.setName=function(name, bFromUndoRedo){
this.workbook.getWorksheetById(id)._ReBuildFormulas(this.workbook.cwf[id].cells,lastName,this.sName);
}
this.workbook.dependencyFormulas.relinkDefNameByWorksheet(this.Id);
if(!bFromUndoRedo)
{
var _lastName = parserHelp.getEscapeSheetName(lastName);
......
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