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