Commit 746947f1 authored by Sergey.Konovalov's avatar Sergey.Konovalov Committed by Alexander.Trofimov

Правки для формул при вставке, удалении, перемещении, копировании sheet.

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@54173 954022d7-b5bf-4e40-9824-e11837661b57
parent d0c56133
...@@ -1888,25 +1888,6 @@ cArea3D.prototype.changeSheet = function ( lastName, newName ) { ...@@ -1888,25 +1888,6 @@ cArea3D.prototype.changeSheet = function ( lastName, newName ) {
this.wsTo = this._wb.getWorksheetByName( newName ).getId(); this.wsTo = this._wb.getWorksheetByName( newName ).getId();
} }
}; };
cArea3D.prototype.moveSheet = function ( tempW ) {
if ( this.wsFrom == this.wsTo ) {
return;
}
else if ( this.wsFrom == tempW.wFId ) {
var newWsFromIndex = this._wb.getWorksheetById( this.wsFrom ).getIndex(),
wsToIndex = this._wb.getWorksheetById( this.wsTo ).getIndex();
if ( newWsFromIndex > wsToIndex ) {
this.wsFrom = this._wb.getWorksheet( tempW.wFI ).getId();
}
}
else if ( this.wsTo == tempW.wFId ) {
var newWsToIndex = this._wb.getWorksheetById( this.wsTo ).getIndex(),
wsFromIndex = this._wb.getWorksheetById( this.wsFrom ).getIndex();
if ( newWsToIndex < wsFromIndex ) {
this.wsTo = this._wb.getWorksheet( tempW.wFI ).getId();
}
}
};
cArea3D.prototype.toString = function () { cArea3D.prototype.toString = function () {
var wsFrom = this._wb.getWorksheetById( this.wsFrom ).getName(); var wsFrom = this._wb.getWorksheetById( this.wsFrom ).getName();
var wsTo = this._wb.getWorksheetById( this.wsTo ).getName(); var wsTo = this._wb.getWorksheetById( this.wsTo ).getName();
...@@ -3187,15 +3168,92 @@ parserFormula.prototype = { ...@@ -3187,15 +3168,92 @@ parserFormula.prototype = {
} }
} }
}, },
insertSheet:function ( index ) {
moveSheet:function ( tempW ) { var bRes = false;
for ( var i = 0; i < this.outStack.length; i++ ) { for ( var i = 0; i < this.outStack.length; i++ ) {
if ( this.outStack[i] instanceof cArea3D ) { var elem = this.outStack[i];
this.outStack[i].moveSheet( tempW ); if ( elem instanceof cArea3D ) {
var wsTo = this.wb.getWorksheetById(elem.wsTo);
var wsToIndex = wsTo.getIndex();
var wsFrom = this.wb.getWorksheetById(elem.wsFrom);
var wsFromIndex = wsFrom.getIndex();
if(wsFromIndex <= index && index <= wsToIndex)
bRes = true;
} }
} }
return this; return bRes;
},
moveSheet:function ( tempW ) {
var nRes = 0;
for ( var i = 0; i < this.outStack.length; i++ ) {
var elem = this.outStack[i];
if ( elem instanceof cArea3D ) {
var wsTo = this.wb.getWorksheetById(elem.wsTo);
var wsToIndex = wsTo.getIndex();
var wsFrom = this.wb.getWorksheetById(elem.wsFrom);
var wsFromIndex = wsFrom.getIndex();
if(wsFromIndex <= tempW.wFI && tempW.wFI <= wsToIndex && 0 == nRes)
nRes = 1;
if(elem.wsFrom == tempW.wFId)
{
if(tempW.wTI > wsToIndex)
{
nRes = 2;
var wsNext = this.wb.getWorksheet(wsFromIndex + 1);
if(wsNext)
this.outStack[i].changeSheet( tempW.wFN, wsNext.getName() );
else
this.outStack[i] = new cError( cErrorType.bad_reference );
}
}
else if(elem.wsTo == tempW.wFId)
{
if(tempW.wTI <= wsFromIndex)
{
nRes = 2;
var wsPrev = this.wb.getWorksheet(wsToIndex - 1);
if(wsPrev)
this.outStack[i].changeSheet( tempW.wFN, wsPrev.getName() );
else
this.outStack[i] = new cError( cErrorType.bad_reference );
}
}
}
}
return nRes;
}, },
removeSheet:function(sheetId){
var bRes = false;
var ws = this.wb.getWorksheetById(sheetId);
if(ws)
{
var wsIndex = ws.getIndex();
var wsPrev = null;
if(wsIndex > 0)
wsPrev = this.wb.getWorksheet(wsIndex - 1);
var wsNext = null;
if(wsIndex < this.wb.getWorksheetCount() - 1)
wsNext = this.wb.getWorksheet(wsIndex + 1);
for ( var i = 0; i < this.outStack.length; i++ ) {
var elem = this.outStack[i];
if ( elem instanceof cArea3D )
{
bRes = true;
if(elem.wsFrom == sheetId)
{
if(elem.wsTo != sheetId && null != wsNext)
this.outStack[i].changeSheet( ws.getName(), wsNext.getName() );
else
this.outStack[i] = new cError( cErrorType.bad_reference );
}
else if(elem.wsTo == sheetId && null != wsPrev)
this.outStack[i].changeSheet( ws.getName(), wsPrev.getName() );
}
}
}
return bRes;
},
buildDependencies:function () { buildDependencies:function () {
......
...@@ -2980,12 +2980,13 @@ UndoRedoWoorksheet.prototype = { ...@@ -2980,12 +2980,13 @@ UndoRedoWoorksheet.prototype = {
if(bUndo) if(bUndo)
{ {
var sFormula = Data.sFormula var sFormula = Data.sFormula
var cell = ws._getCell(nRow, nCol); var cell = ws._getCellNoEmpty(nRow, nCol);
ws.workbook.dependencyFormulas.deleteMasterNodes(ws.getId(), cell.getName()); if(cell)
cell.setFormula(sFormula); {
addToArrRecalc(ws.workbook, ws.getId(), cell.getName()); var node = ws.workbook.dependencyFormulas.getNode(ws.getId(), cell.getName());
ws.workbook.needRecalc.nodes[ getVertexId(ws.getId(),cell.getName()) ] = [ ws.getId(),cell.getName() ]; if(node)
ws.workbook.needRecalc.length++; node.setFormula(Data.sFormula, false, true);
}
} }
} }
else if(historyitem_Worksheet_ColProp == Type) else if(historyitem_Worksheet_ColProp == Type)
......
...@@ -129,10 +129,6 @@ DependencyGraph.prototype = { ...@@ -129,10 +129,6 @@ DependencyGraph.prototype = {
var n = node.getSlaveEdges(); var n = node.getSlaveEdges();
if ( n ) { if ( n ) {
arr.push( node ); arr.push( node );
for ( var id2 in n ) {
n[id2].weightNode++;
// arr.push(n[id2]);
}
} }
} }
} }
...@@ -144,10 +140,6 @@ DependencyGraph.prototype = { ...@@ -144,10 +140,6 @@ DependencyGraph.prototype = {
var n = node.getSlaveEdges(); var n = node.getSlaveEdges();
if ( n ) { if ( n ) {
arr.push( node ); arr.push( node );
for ( var id2 in n ) {
n[id2].weightNode++;
// arr.push(n[id2]);
}
} }
} }
} }
...@@ -675,8 +667,6 @@ function Vertex(sheetId, cellId, wb){ ...@@ -675,8 +667,6 @@ function Vertex(sheetId, cellId, wb){
this.slaveEdges = null; this.slaveEdges = null;
this.refCount = 0; this.refCount = 0;
this.weightNode = 0;
} }
Vertex.prototype = { Vertex.prototype = {
...@@ -686,6 +676,19 @@ Vertex.prototype = { ...@@ -686,6 +676,19 @@ Vertex.prototype = {
{ {
return this.bbox; return this.bbox;
}, },
setFormula : function(sFormula, bAddToHistory, bAddNeedRecal)
{
var cell = this.returnCell();
if(null != sFormula)
cell.setFormula(sFormula, bAddToHistory);
this.wb.dependencyFormulas.deleteMasterNodes2( this.sheetId, this.cellId );
addToArrRecalc(this.sheetId, cell);
if(bAddNeedRecal)
{
this.wb.needRecalc.nodes[this.nodeId] = [this.sheetId, this.cellId ];
this.wb.needRecalc.length++;
}
},
setRefError : function(wsId, cellId) setRefError : function(wsId, cellId)
{ {
var cell = this.returnCell(); var cell = this.returnCell();
...@@ -1122,6 +1125,7 @@ Workbook.prototype.getWorksheetCount=function(){ ...@@ -1122,6 +1125,7 @@ Workbook.prototype.getWorksheetCount=function(){
return this.aWorksheets.length; return this.aWorksheets.length;
}; };
Workbook.prototype.createWorksheet=function(indexBefore, sName, sId){ Workbook.prototype.createWorksheet=function(indexBefore, sName, sId){
History.Create_NewPoint();
History.TurnOff(); History.TurnOff();
var oNewWorksheet = new Woorksheet(this, this.aWorksheets.length, true, sId); var oNewWorksheet = new Woorksheet(this, this.aWorksheets.length, true, sId);
if(null != sName) if(null != sName)
...@@ -1141,45 +1145,15 @@ Workbook.prototype.createWorksheet=function(indexBefore, sName, sId){ ...@@ -1141,45 +1145,15 @@ Workbook.prototype.createWorksheet=function(indexBefore, sName, sId){
this.aWorksheetsById[oNewWorksheet.getId()] = oNewWorksheet; this.aWorksheetsById[oNewWorksheet.getId()] = oNewWorksheet;
this._updateWorksheetIndexes(); this._updateWorksheetIndexes();
this.setActive(oNewWorksheet.index); this.setActive(oNewWorksheet.index);
if( indexBefore > 0 && indexBefore < this.aWorksheets.length-1 ){
var sheetStart = this.getWorksheet(indexBefore-1).getId(),
sheetStop = this.getWorksheet(indexBefore+1).getId(),
nodesSheetStart = this.dependencyFormulas.getNodeBySheetId(sheetStart),
nodesSheetStop = this.dependencyFormulas.getNodeBySheetId(sheetStop),
arr = {};
for( var i = 0; i < nodesSheetStart.length; i++ ){
var n = nodesSheetStart[i].getSlaveEdges();
for( var id in n ){
if( n[id].weightNode == 2 ){
arr[n[id].nodeId] = n[id];
}
n[id].weightNode = 0;
}
}
for( var i = 0; i < nodesSheetStop.length; i++ ){
var n = nodesSheetStop[i].getSlaveEdges();
for( var id in n ){
if( n[id].weightNode == 2 ){
arr[n[id].nodeId] = n[id];
}
n[id].weightNode = 0;
}
}
for( var id in arr ){
arr[id].cell.formulaParsed.buildDependencies();
}
}
History.TurnOn(); History.TurnOn();
History.Create_NewPoint(); this._insertWorksheetFormula(oNewWorksheet.index);
History.Add(g_oUndoRedoWorkbook, historyitem_Workbook_SheetAdd, null, null, new UndoRedoData_SheetAdd(indexBefore, oNewWorksheet.getName(), null, oNewWorksheet.getId())); History.Add(g_oUndoRedoWorkbook, historyitem_Workbook_SheetAdd, null, null, new UndoRedoData_SheetAdd(indexBefore, oNewWorksheet.getName(), null, oNewWorksheet.getId()));
return oNewWorksheet.index; return oNewWorksheet.index;
}; };
Workbook.prototype.copyWorksheet=function(index, insertBefore, sName, sId, bFromRedo){ Workbook.prototype.copyWorksheet=function(index, insertBefore, sName, sId, bFromRedo){
//insertBefore - optional //insertBefore - optional
if(index >= 0 && index < this.aWorksheets.length){ if(index >= 0 && index < this.aWorksheets.length){
History.Create_NewPoint();
History.TurnOff(); History.TurnOff();
var wsFrom = this.aWorksheets[index]; var wsFrom = this.aWorksheets[index];
var nameSheet = wsFrom.getName(); var nameSheet = wsFrom.getName();
...@@ -1201,19 +1175,22 @@ Workbook.prototype.copyWorksheet=function(index, insertBefore, sName, sId, bFrom ...@@ -1201,19 +1175,22 @@ Workbook.prototype.copyWorksheet=function(index, insertBefore, sName, sId, bFrom
} }
this.aWorksheetsById[newSheet.getId()] = newSheet; this.aWorksheetsById[newSheet.getId()] = newSheet;
this._updateWorksheetIndexes(); this._updateWorksheetIndexes();
History.TurnOn();
this._insertWorksheetFormula(insertBefore);
//для формул. создаем копию this.cwf[this.Id] для нового листа. //для формул. создаем копию this.cwf[this.Id] для нового листа.
if ( this.cwf[wsFrom.getId()] ){ if ( this.cwf[wsFrom.getId()] ){
this.cwf[newSheet.getId()] = { cells:{} }; var cwf = { cells:{} };
for( var id in this.cwf[wsFrom.getId()].cells ){ var newSheetId = newSheet.getId();
this.cwf[newSheet.getId()].cells[id] = this.cwf[wsFrom.getId()].cells[id]; var cwfFrom = this.cwf[wsFrom.getId()];
this.cwf[newSheetId] = cwf;
for( var id in cwfFrom.cells ){
cwf.cells[id] = cwfFrom.cells[id];
this.needRecalc.nodes[getVertexId(newSheetId, id)] = [newSheetId, id];
this.needRecalc.length++;
} }
newSheet._BuildDependencies(cwf.cells);
//очищаем и создаем новый граф зависимостей
this.buildDependency();
} }
History.TurnOn(); sortDependency(this);
History.Create_NewPoint();
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()));
if(!(bFromRedo === true)) if(!(bFromRedo === true))
{ {
...@@ -1232,68 +1209,82 @@ Workbook.prototype.insertWorksheet=function(index, sheet, cwf){ ...@@ -1232,68 +1209,82 @@ Workbook.prototype.insertWorksheet=function(index, sheet, cwf){
} }
this.aWorksheetsById[sheet.getId()] = sheet; this.aWorksheetsById[sheet.getId()] = sheet;
this._updateWorksheetIndexes(); this._updateWorksheetIndexes();
this._insertWorksheetFormula(index);
//восстанавливаем список ячеек с формулами для sheet //восстанавливаем список ячеек с формулами для sheet
this.cwf[sheet.getId()] = cwf; this.cwf[sheet.getId()] = cwf;
//очищаем и создаем новый граф зависимостей sheet._BuildDependencies(cwf.cells);
this.buildDependency(); sortDependency(this);
}
Workbook.prototype._insertWorksheetFormula=function(index){
if( index > 0 && index < this.aWorksheets.length - 1 ){
var oWsTo = this.aWorksheets[index - 1];
var nodesSheetTo = this.dependencyFormulas.getNodeBySheetId(oWsTo.getId());
for( var i = 0; i < nodesSheetTo.length; i++ ){
var se = nodesSheetTo[i].getSlaveEdges();
if(se)
{
for( var id in se ){
var slave = se[id];
var cell = slave.returnCell();
if( cell && cell.formulaParsed && cell.formulaParsed.is3D )
{
if(cell.formulaParsed.insertSheet(index))
slave.setFormula(null, false, true);
}
}
}
}
}
} }
Workbook.prototype.replaceWorksheet=function(indexFrom, indexTo){ Workbook.prototype.replaceWorksheet=function(indexFrom, indexTo){
if(indexFrom >= 0 && indexFrom < this.aWorksheets.length && if(indexFrom >= 0 && indexFrom < this.aWorksheets.length &&
indexTo >= 0 && indexTo < this.aWorksheets.length){ indexTo >= 0 && indexTo < this.aWorksheets.length){
History.Create_NewPoint();
History.TurnOff(); History.TurnOff();
var oWsFrom = this.aWorksheets[indexFrom];
var oWsTo = this.aWorksheets[indexTo]; var oWsTo = this.aWorksheets[indexTo];
var tempW = { var tempW = {
wFN: this.aWorksheets[indexFrom].getName(), wFN: oWsFrom.getName(),
wFI: indexFrom, wFI: indexFrom,
wFId: this.aWorksheets[indexFrom].getId(), wFId: oWsFrom.getId(),
wTN: oWsTo.getName(), wTN: oWsTo.getName(),
wTI: indexTo, wTI: indexTo,
wTId: oWsTo.getId() wTId: oWsTo.getId()
} }
//переводим обратно в индекс sheet перед которым надо вставить
var movedSheet = this.aWorksheets.splice(indexFrom,1); if(tempW.wFI < tempW.wTI)
this.aWorksheets.splice(indexTo,0,movedSheet[0]) tempW.wTI++;
this._updateWorksheetIndexes();
/* /*
Формулы: Формулы:
перестройка графа для трехмерных формул вида Sheet1:Sheet3!A1:A3, Sheet1:Sheet3!A1. перестройка графа для трехмерных формул вида Sheet1:Sheet3!A1:A3, Sheet1:Sheet3!A1.
пересчет трехмерных формул, перестройка формул при изменении положения листа: Sheet1, Sheet2, Sheet3, Sheet4 - Sheet1:Sheet4!A1 -> Sheet4, Sheet1, Sheet2, Sheet3 - Sheet1:Sheet3!A1; пересчет трехмерных формул, перестройка формул при изменении положения листа: Sheet1, Sheet2, Sheet3, Sheet4 - Sheet1:Sheet4!A1 -> Sheet4, Sheet1, Sheet2, Sheet3 - Sheet1:Sheet3!A1;
*/ */
lockDraw(this); lockDraw(this);
var a = this.dependencyFormulas.getNodeBySheetId(movedSheet[0].getId()); var a = this.dependencyFormulas.getNodeBySheetId(tempW.wFId);
for(var i=0;i<a.length;i++){ for(var i=0;i<a.length;i++){
var se = a[i].getSlaveEdges(); var se = a[i].getSlaveEdges();
if(se){ if(se){
for(var id in se){ for(var id in se){
var cID = se[id].cellId, _ws = this.getWorksheetById(se[id].sheetId), f = _ws.getCell2(cID).getCells()[0].sFormula; var slave = se[id];
if( f == null || f == undefined ){ var cell = slave.returnCell();
continue; if( cell && cell.formulaParsed && cell.formulaParsed.is3D )
} {
if( f.indexOf(tempW.wFN+":") > 0 || f.indexOf(":"+tempW.wFN) > 0 ){ var nMoveRes = cell.formulaParsed.moveSheet(tempW, true);
var _c = _ws.getCell2(cID).getCells()[0]; if(2 == nMoveRes)
_c.setFormula(_c.formulaParsed.moveSheet(tempW).assemble());//Перестраиваем трехмерные ссылки в формуле. slave.setFormula(cell.formulaParsed.assemble(), true, true);
this.dependencyFormulas.deleteMasterNodes(_ws.Id, cID); else if(1 == nMoveRes)
addToArrRecalc(_ws.getId(), _c); slave.setFormula(null, false, true);
// this.needRecalc[ getVertexId(_ws.getId(),cID) ] = [ _ws.getId(),cID ];
// if( this.needRecalc.length < 0) this.needRecalc.length = 0;
// this.needRecalc.length++;
}
else if( f.indexOf(_ws.getName()) < 0 ){
this.dependencyFormulas.deleteMasterNodes(_ws.Id, cID);
_ws._BuildDependencies({id:cID});
addToArrRecalc(_ws.getId(), _c);
// this.needRecalc[ getVertexId(_ws.getId(),cID) ] = [ _ws.getId(),cID ];
// if( this.needRecalc.length < 0) this.needRecalc.length = 0;
// this.needRecalc.length++;
} }
} }
} }
} }
History.TurnOn(); History.TurnOn();
History.Create_NewPoint(); var movedSheet = this.aWorksheets.splice(indexFrom, 1);
this.aWorksheets.splice(indexTo, 0, movedSheet[0])
this._updateWorksheetIndexes();
this._insertWorksheetFormula(tempW.wTI);
History.Add(g_oUndoRedoWorkbook, historyitem_Workbook_SheetMove, null, null, new UndoRedoData_FromTo(indexFrom, indexTo), true); History.Add(g_oUndoRedoWorkbook, historyitem_Workbook_SheetMove, null, null, new UndoRedoData_FromTo(indexFrom, indexTo), true);
buildRecalc(this); buildRecalc(this);
unLockDraw(this); unLockDraw(this);
...@@ -1314,32 +1305,39 @@ Workbook.prototype.removeWorksheet=function(nIndex, outputParams){ ...@@ -1314,32 +1305,39 @@ Workbook.prototype.removeWorksheet=function(nIndex, outputParams){
if(bEmpty) if(bEmpty)
return -1; return -1;
var nNewActive = this.nActive; var removedSheet = this.getWorksheet(nIndex);
var removedSheets = this.aWorksheets.splice(nIndex, 1); if(removedSheet)
if(removedSheets.length > 0)
{ {
var removedSheet = removedSheets[0]; History.Create_NewPoint();
var removedSheetId = removedSheet.getId(); var removedSheetId = removedSheet.getId();
History.TurnOff();
//по всем удаленным листам пробегаемся и удаляем из workbook.cwf (cwf - cells with forluma) элементы с названием соответствующего листа.
var _cwf = this.cwf[removedSheet.getId()];
delete this.cwf[removedSheet.getId()];
delete this.aWorksheetsById[removedSheet.getId()];
lockDraw(this); lockDraw(this);
var a = this.dependencyFormulas.getNodeBySheetId(removedSheet.getId()); var a = this.dependencyFormulas.getNodeBySheetId(removedSheetId);
for(var i=0;i<a.length;i++){ for(var i = 0; i < a.length; i++)
{
var node = a[i]; var node = a[i];
var se = node.getSlaveEdges(); var se = node.getSlaveEdges();
if(se){ if(se){
for(var id in se){ for(var id in se){
var slave = se[id]; var slave = se[id];
if( slave.sheetId != removedSheetId ) var cell = slave.returnCell();
slave.setRefError(removedSheetId, node.cellId); if( cell && cell.formulaParsed && cell.formulaParsed.is3D )
{
if(cell.formulaParsed.removeSheet(removedSheetId))
slave.setFormula(cell.formulaParsed.assemble(), true, true);
}
} }
} }
} }
this.dependencyFormulas.removeNodeBySheetId(removedSheet.getId()); this.dependencyFormulas.removeNodeBySheetId(removedSheetId);
History.TurnOff();
var nNewActive = this.nActive;
this.aWorksheets.splice(nIndex, 1);
//по всем удаленным листам пробегаемся и удаляем из workbook.cwf (cwf - cells with forluma) элементы с названием соответствующего листа.
var _cwf = this.cwf[removedSheetId];
delete this.cwf[removedSheetId];
delete this.aWorksheetsById[removedSheetId];
var bFind = false; var bFind = false;
if(nNewActive < this.aWorksheets.length) if(nNewActive < this.aWorksheets.length)
{ {
...@@ -1361,7 +1359,6 @@ Workbook.prototype.removeWorksheet=function(nIndex, outputParams){ ...@@ -1361,7 +1359,6 @@ Workbook.prototype.removeWorksheet=function(nIndex, outputParams){
} }
} }
History.TurnOn(); History.TurnOn();
History.Create_NewPoint();
History.Add(g_oUndoRedoWorkbook, historyitem_Workbook_SheetRemove, null, null, new UndoRedoData_SheetRemove(nIndex, removedSheetId, removedSheet, _cwf)); History.Add(g_oUndoRedoWorkbook, historyitem_Workbook_SheetRemove, null, null, new UndoRedoData_SheetRemove(nIndex, removedSheetId, removedSheet, _cwf));
if(null != outputParams) if(null != outputParams)
{ {
...@@ -1830,11 +1827,11 @@ Woorksheet.prototype.clone=function(sNewId, bFromRedo){ ...@@ -1830,11 +1827,11 @@ Woorksheet.prototype.clone=function(sNewId, bFromRedo){
if(this.AutoFilter) if(this.AutoFilter)
oNewWs.AutoFilter = this.AutoFilter.clone(); oNewWs.AutoFilter = this.AutoFilter.clone();
for(i in this.aCols) for(i in this.aCols)
oNewWs.aCols[i] = this.aCols[i].clone(); oNewWs.aCols[i] = this.aCols[i].clone(oNewWs);
if(null != this.oAllCol) if(null != this.oAllCol)
oNewWs.oAllCol = this.oAllCol.clone(); oNewWs.oAllCol = this.oAllCol.clone(oNewWs);
for(i in this.aGCells) for(i in this.aGCells)
oNewWs.aGCells[i] = this.aGCells[i].clone(); oNewWs.aGCells[i] = this.aGCells[i].clone(oNewWs);
var aMerged = this.mergeManager.getAll(); var aMerged = this.mergeManager.getAll();
for(i in aMerged) for(i in aMerged)
{ {
...@@ -3563,8 +3560,10 @@ Cell.prototype.compileXfs=function(){ ...@@ -3563,8 +3560,10 @@ Cell.prototype.compileXfs=function(){
} }
} }
}; };
Cell.prototype.clone=function(){ Cell.prototype.clone=function(oNewWs){
var oNewCell = new Cell(this.ws); if(!oNewWs)
oNewWs = this.ws;
var oNewCell = new Cell(oNewWs);
oNewCell.oId = new CellAddress(this.oId.getRow(), this.oId.getCol()); oNewCell.oId = new CellAddress(this.oId.getRow(), this.oId.getCol());
if(null != this.xfs) if(null != this.xfs)
oNewCell.xfs = this.xfs.clone(); oNewCell.xfs = this.xfs.clone();
......
...@@ -2131,9 +2131,11 @@ Col.prototype = ...@@ -2131,9 +2131,11 @@ Col.prototype =
{ {
this.ws._removeCol(this.index); this.ws._removeCol(this.index);
}, },
clone : function() clone : function(oNewWs)
{ {
var oNewCol = new Col(this.ws, this.index); if(!oNewWs)
oNewWs = this.ws;
var oNewCol = new Col(oNewWs, this.index);
if(null != this.BestFit) if(null != this.BestFit)
oNewCol.BestFit = this.BestFit; oNewCol.BestFit = this.BestFit;
if(null != this.hd) if(null != this.hd)
...@@ -2390,9 +2392,11 @@ Row.prototype = ...@@ -2390,9 +2392,11 @@ Row.prototype =
{ {
this.ws._removeRow(this.index); this.ws._removeRow(this.index);
}, },
clone : function() clone : function(oNewWs)
{ {
var oNewRow = new Row(this.ws); if(!oNewWs)
oNewWs = this.ws;
var oNewRow = new Row(oNewWs);
oNewRow.r = this.r; oNewRow.r = this.r;
if(null != this.xfs) if(null != this.xfs)
oNewRow.xfs = this.xfs.clone(); oNewRow.xfs = this.xfs.clone();
...@@ -2403,7 +2407,7 @@ Row.prototype = ...@@ -2403,7 +2407,7 @@ Row.prototype =
if(null != this.hd) if(null != this.hd)
oNewRow.hd = this.hd; oNewRow.hd = this.hd;
for(var i in this.c) for(var i in this.c)
oNewRow.c[i] = this.c[i].clone(); oNewRow.c[i] = this.c[i].clone(oNewWs);
return oNewRow; return oNewRow;
}, },
getDefaultXfs : function() getDefaultXfs : function()
...@@ -4573,4 +4577,4 @@ SortCondition.prototype.clone = function() { ...@@ -4573,4 +4577,4 @@ SortCondition.prototype.clone = function() {
if (this.dxf) if (this.dxf)
res.dxf = this.dxf.clone(); res.dxf = this.dxf.clone();
return res; return res;
}; };
\ No newline at end of file
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