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 ) {
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 () {
var wsFrom = this._wb.getWorksheetById( this.wsFrom ).getName();
var wsTo = this._wb.getWorksheetById( this.wsTo ).getName();
......@@ -3187,14 +3168,91 @@ parserFormula.prototype = {
}
}
},
insertSheet:function ( index ) {
var bRes = false;
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 <= index && index <= wsToIndex)
bRes = true;
}
}
return bRes;
},
moveSheet:function ( tempW ) {
var nRes = 0;
for ( var i = 0; i < this.outStack.length; i++ ) {
if ( this.outStack[i] instanceof cArea3D ) {
this.outStack[i].moveSheet( tempW );
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 );
}
}
return this;
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 () {
......
......@@ -2980,12 +2980,13 @@ UndoRedoWoorksheet.prototype = {
if(bUndo)
{
var sFormula = Data.sFormula
var cell = ws._getCell(nRow, nCol);
ws.workbook.dependencyFormulas.deleteMasterNodes(ws.getId(), cell.getName());
cell.setFormula(sFormula);
addToArrRecalc(ws.workbook, ws.getId(), cell.getName());
ws.workbook.needRecalc.nodes[ getVertexId(ws.getId(),cell.getName()) ] = [ ws.getId(),cell.getName() ];
ws.workbook.needRecalc.length++;
var cell = ws._getCellNoEmpty(nRow, nCol);
if(cell)
{
var node = ws.workbook.dependencyFormulas.getNode(ws.getId(), cell.getName());
if(node)
node.setFormula(Data.sFormula, false, true);
}
}
}
else if(historyitem_Worksheet_ColProp == Type)
......
This diff is collapsed.
......@@ -2131,9 +2131,11 @@ Col.prototype =
{
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)
oNewCol.BestFit = this.BestFit;
if(null != this.hd)
......@@ -2390,9 +2392,11 @@ Row.prototype =
{
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;
if(null != this.xfs)
oNewRow.xfs = this.xfs.clone();
......@@ -2403,7 +2407,7 @@ Row.prototype =
if(null != this.hd)
oNewRow.hd = this.hd;
for(var i in this.c)
oNewRow.c[i] = this.c[i].clone();
oNewRow.c[i] = this.c[i].clone(oNewWs);
return oNewRow;
},
getDefaultXfs : function()
......
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