Commit 967d25c9 authored by Dmitry.Shahtanov's avatar Dmitry.Shahtanov Committed by Alexander.Trofimov

fix:

 Bug 29785 - [NamedRanges] Удаление листа или его копии, содержащего форматированную таблицу, не происходит и вызывает ошибку в консоли (http://bugzserver/show_bug.cgi?id=29785)
 Bug 29929 - [NamedRanges] Ошибка в консоли при удаление именованного диапазона со сдвигом, к элементам которого обращались (http://bugzserver/show_bug.cgi?id=29929)
 Bug 29944 - [NamedRanges][CoEdit] Ошибка в консоли при передаче именованного диапазона (http://bugzserver/show_bug.cgi?id=29944)
 Bug 29932 - [NamedRanges] Именованный диапазон форматированной таблицы содержит ее заголовок (http://bugzserver/show_bug.cgi?id=29932)

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@63943 954022d7-b5bf-4e40-9824-e11837661b57
parent 0b64fe44
......@@ -479,6 +479,10 @@ function cArea( val, ws ) {/*Area means "A1:E5" for example*/
this.wb = ws.workbook;
this._cells = val;
this.isAbsolute = false;
this.isAbsoluteCol1 = false;
this.isAbsoluteRow1 = false;
this.isAbsoluteCol2 = false;
this.isAbsoluteRow2 = false;
this.range = null;
// this._valid = this.range ? true : false;
}
......@@ -489,6 +493,10 @@ cArea.prototype.clone = function () {
// cBaseType.prototype.cloneTo.call( this, oRes );
this.constructor.prototype.cloneTo.call( this, oRes );
oRes.isAbsolute = this.isAbsolute;
oRes.isAbsoluteCol1 = this.isAbsoluteCol1;
oRes.isAbsoluteRow1 = this.isAbsoluteRow1;
oRes.isAbsoluteCol2 = this.isAbsoluteCol2;
oRes.isAbsoluteRow2 = this.isAbsoluteRow2;
return oRes;
};
cArea.prototype.getWsId = function () {
......@@ -684,6 +692,10 @@ function cArea3D( val, wsFrom, wsTo, wb ) {/*Area3D means "Sheat1!A1:E5" for exa
this._wb = wb;
this._cells = val;
this.isAbsolute = false;
this.isAbsoluteCol1 = false;
this.isAbsoluteRow1 = false;
this.isAbsoluteCol2 = false;
this.isAbsoluteRow2 = false;
this.wsFrom = this._wb.getWorksheetByName( wsFrom ).getId();
this.wsTo = this._wb.getWorksheetByName( wsTo ).getId();
}
......@@ -696,6 +708,10 @@ cArea3D.prototype.clone = function () {
// cBaseType.prototype.cloneTo.call( this, oRes );
this.constructor.prototype.cloneTo.call( this, oRes );
oRes.isAbsolute = this.isAbsolute;
oRes.isAbsoluteCol1 = this.isAbsoluteCol1;
oRes.isAbsoluteRow1 = this.isAbsoluteRow1;
oRes.isAbsoluteCol2 = this.isAbsoluteCol2;
oRes.isAbsoluteRow2 = this.isAbsoluteRow2;
return oRes;
};
cArea3D.prototype.wsRange = function () {
......@@ -1046,6 +1062,8 @@ function cRef( val, ws ) {/*Ref means A1 for example*/
this.ws = ws;
this.wb = this._wb = ws.workbook;
this.isAbsolute = false;
this.isAbsoluteCol1 = false;
this.isAbsoluteRow1 = false;
var ca = g_oCellAddressUtils.getCellAddress( val.replace( rx_space_g, "" ) );
this.range = null;
this._valid = ca.isValid();
......@@ -1063,6 +1081,8 @@ cRef.prototype.clone = function () {
// cBaseType.prototype.cloneTo.call( this, oRes );
this.constructor.prototype.cloneTo.call( this, oRes );
oRes.isAbsolute = this.isAbsolute;
oRes.isAbsoluteCol1 = this.isAbsoluteCol1;
oRes.isAbsoluteRow1 = this.isAbsoluteRow1;
return oRes;
};
cRef.prototype.getWsId = function () {
......@@ -1131,6 +1151,8 @@ function cRef3D( val, _wsFrom, wb ) {/*Ref means Sheat1!A1 for example*/
this.wb = this._wb = wb;
this._cells = val;
this.isAbsolute = false;
this.isAbsoluteCol1 = false;
this.isAbsoluteRow1 = false;
this.ws = this._wb.getWorksheetByName( _wsFrom );
this.range = null;
}
......@@ -1141,6 +1163,8 @@ cRef3D.prototype.clone = function () {
// cBaseType.prototype.cloneTo.call( this, oRes );
this.constructor.prototype.cloneTo.call( this, oRes );
oRes.isAbsolute = this.isAbsolute;
oRes.isAbsoluteCol1 = this.isAbsoluteCol1;
oRes.isAbsoluteRow1 = this.isAbsoluteRow1;
return oRes;
};
cRef3D.prototype.getWsId = function () {
......@@ -1256,9 +1280,8 @@ cName.prototype.toRef = function () {
return new cError( "#NAME?" );
}
var _3DRefTmp,
ref = this.defName.Ref,
_wsFrom, _wsTo;
var _3DRefTmp, ref = this.defName.Ref, _wsFrom, _wsTo;
if ( ref && (_3DRefTmp = parserHelp.is3DRef( ref, 0 ))[0] ) {
_wsFrom = _3DRefTmp[1];
_wsTo = ( (_3DRefTmp[2] !== null) && (_3DRefTmp[2] !== undefined) ) ? _3DRefTmp[2] : _wsFrom;
......@@ -1324,7 +1347,6 @@ cName.prototype.addDefinedNameNode = function ( nameReParse ) {
if ( (ref instanceof cRef || ref instanceof cRef3D || ref instanceof cArea) && ref.isValid() ) {
nTo = this.wb.dependencyFormulas.addNode( ref.getWsId(), ref._cells.replace( this.regSpace, "" ) );
this.wb.dependencyFormulas.addEdge2( node, nTo );
}
else if ( ref instanceof cArea3D && ref.isValid() ) {
......@@ -3194,6 +3216,63 @@ parserFormula.prototype = {
parse:function ( local, digitDelim ) {
function checkAbsRef(operand_str,found_operand){
var splitOpStr0 = operand_str.match(/\$/g) || [];
switch(splitOpStr0.length){
case 1:
if( operand_str.indexOf("$") > 0 ){
found_operand.isAbsoluteRow1 = true;
}
else{
found_operand.isAbsoluteCol1 = true;
}
break;
case 2:
found_operand.isAbsoluteCol1 = true;
found_operand.isAbsoluteRow1 = true;
break;
}
}
function checkAbsArea(operand_str,found_operand){
var splitOpStr = operand_str.split(":" ),
splitOpStr0 = splitOpStr[0].match(/\$/g) || [],
splitOpStr1 = splitOpStr[1].match(/\$/g) || [];
switch(splitOpStr0.length){
case 1:
if( splitOpStr[0].indexOf("$") > 0 ){
found_operand.isAbsoluteRow1 = true;
}
else{
found_operand.isAbsoluteCol1 = true;
}
break;
case 2:
found_operand.isAbsoluteCol1 = true;
found_operand.isAbsoluteRow1 = true;
break;
}
switch(splitOpStr1.length){
case 1:
if( splitOpStr[1].indexOf("$") > 0 ){
found_operand.isAbsoluteRow2 = true;
}
else{
found_operand.isAbsoluteCol2 = true;
}
break;
case 2:
found_operand.isAbsoluteCol2 = true;
found_operand.isAbsoluteRow2 = true;
break;
}
}
this.pCurrPos = 0;
if ( this.isParsed )
......@@ -3496,9 +3575,18 @@ parserFormula.prototype = {
if ( parserHelp.isArea.call( this, this.Formula, this.pCurrPos ) ) {
this.RefPos.push( {start:this.pCurrPos - this.operand_str.length, end:this.pCurrPos, index:this.outStack.length} );
found_operand = new cArea3D( this.operand_str.toUpperCase(), _wsFrom, _wsTo, this.wb );
if ( this.operand_str.indexOf( "$" ) > -1 ) {
checkAbsArea(this.operand_str,found_operand);
/*if ( this.operand_str.indexOf( "$" ) > -1 ) {
found_operand.isAbsolute = true;
}
if( this.operand_str.indexOf( "$" ) == 0 ){
found_operand.isAbsoluteCol = true;
}
if( this.operand_str.lastIndexOf( "$" ) > 0 ){
found_operand.isAbsoluteRow = true;
}
}*/
}
else if ( parserHelp.isRef.call( this, this.Formula, this.pCurrPos ) ) {
this.RefPos.push( {start:this.pCurrPos - this.operand_str.length, end:this.pCurrPos, index:this.outStack.length} );
......@@ -3509,7 +3597,16 @@ parserFormula.prototype = {
found_operand = new cRef3D( this.operand_str.toUpperCase(), _wsFrom, this.wb );
}
if ( this.operand_str.indexOf( "$" ) > -1 ) {
found_operand.isAbsolute = true;
checkAbsRef(this.operand_str,found_operand)
/*found_operand.isAbsolute = true;
if( this.operand_str.indexOf( "$" ) == 0 ){
found_operand.isAbsoluteCol = true;
}
if( this.operand_str.lastIndexOf( "$" ) > 0 ){
found_operand.isAbsoluteRow = true;
}*/
}
}
/*else if ( parserHelp.isName.call( this, this.Formula, this.pCurrPos ) ) {
......@@ -3523,7 +3620,18 @@ parserFormula.prototype = {
this.RefPos.push( {start:this.pCurrPos - this.operand_str.length, end:this.pCurrPos, index:this.outStack.length} );
found_operand = new cArea( this.operand_str.toUpperCase(), this.ws );
if ( this.operand_str.indexOf( "$" ) > -1 ) {
found_operand.isAbsolute = true;
checkAbsArea(this.operand_str,found_operand);
/* found_operand.isAbsolute = true;
if( this.operand_str.indexOf( "$" ) == 0 ){
found_operand.isAbsoluteCol = true;
}
if( this.operand_str.lastIndexOf( "$" ) > 0 ){
found_operand.isAbsoluteRow = true;
}*/
}
this.countRef++;
}
......@@ -3532,7 +3640,16 @@ parserFormula.prototype = {
this.RefPos.push( {start:this.pCurrPos - this.operand_str.length, end:this.pCurrPos, index:this.outStack.length} );
found_operand = new cRef( this.operand_str.toUpperCase(), this.ws );
if ( this.operand_str.indexOf( "$" ) > -1 ) {
found_operand.isAbsolute = true;
checkAbsRef(this.operand_str,found_operand)
/*found_operand.isAbsolute = true;
if( this.operand_str.indexOf( "$" ) == 0 ){
found_operand.isAbsoluteCol = true;
}
if( this.operand_str.lastIndexOf( "$" ) > 0 ){
found_operand.isAbsoluteRow = true;
}*/
}
this.countRef++;
}
......@@ -3803,23 +3920,30 @@ parserFormula.prototype = {
*/
shiftCells:function ( node, from, to ) {
//node.cellId содержит уже сдвинутое значение
var sFromName = from.getName();
var sFromName = from.getName(), elem;
for ( var i = 0; i < this.outStack.length; i++ ) {
var elem = this.outStack[i];
elem = this.outStack[i];
if ( elem instanceof cRef || elem instanceof cArea ) {
sFromName = from.getAbsName2(elem.isAbsoluteCol1, elem.isAbsoluteRow1, elem.isAbsoluteCol2, elem.isAbsoluteRow2);
if ( node.sheetId == elem.ws.getId() && sFromName == elem._cells ) {
elem.value = elem._cells = node.cellId;
elem.value = elem._cells = node.bbox.getAbsName2(elem.isAbsoluteCol1, elem.isAbsoluteRow1, elem.isAbsoluteCol2, elem.isAbsoluteRow2);
elem.range = elem.ws.getRange3( to.r1, to.c1, to.r2, to.c2 );
}
}
else if ( elem instanceof cRef3D ) {
sFromName = from.getAbsName2(elem.isAbsoluteCol1, elem.isAbsoluteRow1, elem.isAbsoluteCol2, elem.isAbsoluteRow2);
if ( node.sheetId == elem.ws.getId() && sFromName == elem._cells ) {
elem.value = elem._cells = node.cellId;
elem.value = elem._cells = node.bbox.getAbsName2(elem.isAbsoluteCol1, elem.isAbsoluteRow1, elem.isAbsoluteCol2, elem.isAbsoluteRow2);
}
}
else if ( elem instanceof cArea3D ) {
sFromName = from.getAbsName2(elem.isAbsoluteCol1, elem.isAbsoluteRow1, elem.isAbsoluteCol2, elem.isAbsoluteRow2);
if ( elem.wsFrom == elem.wsTo && node.sheetId == elem.wsFrom && sFromName == elem._cells ) {
elem.value = elem._cells = node.cellId;
elem.value = elem._cells = node.bbox.getAbsName2(elem.isAbsoluteCol1, elem.isAbsoluteRow1, elem.isAbsoluteCol2, elem.isAbsoluteRow2);
}
}
}
......@@ -3827,19 +3951,26 @@ parserFormula.prototype = {
stretchArea:function ( node, from, to ) {
//node.cellId содержит уже сдвинутое значение
var sFromName = from.getName();
var sFromName = from.getName(), elem;
for ( var i = 0; i < this.outStack.length; i++ ) {
var elem = this.outStack[i];
elem = this.outStack[i];
if ( elem instanceof cArea ) {
sFromName = from.getAbsName2(elem.isAbsoluteCol1, elem.isAbsoluteRow1, elem.isAbsoluteCol2, elem.isAbsoluteRow2);
if ( node.sheetId == elem.ws.getId() && sFromName == elem._cells ) {
elem.value = elem._cells = node.cellId;
elem.value = elem._cells = node.bbox.getAbsName2(elem.isAbsoluteCol1, elem.isAbsoluteRow1, elem.isAbsoluteCol2, elem.isAbsoluteRow2);
elem.range = elem.ws.getRange3( to.r1, to.c1, to.r2, to.c2 );
}
}
else if ( elem instanceof cArea3D ) {
sFromName = from.getAbsName2(elem.isAbsoluteCol1, elem.isAbsoluteRow1, elem.isAbsoluteCol2, elem.isAbsoluteRow2);
//node.cellId содержит уже сдвинутое значение
if ( elem.wsFrom == elem.wsTo && node.sheetId == elem.wsFrom && sFromName == elem._cells )
elem.value = elem._cells = node.cellId;
if ( elem.wsFrom == elem.wsTo && node.sheetId == elem.wsFrom && sFromName == elem._cells ){
elem.value = elem._cells = node.bbox.getAbsName2(elem.isAbsoluteCol1, elem.isAbsoluteRow1, elem.isAbsoluteCol2, elem.isAbsoluteRow2);
}
}
}
},
......@@ -4121,10 +4252,16 @@ parserFormula.prototype = {
return bRes;
},
buildDependencies:function ( nameReParse ) {
buildDependencies:function ( nameReParse, defName ) {
var node = this.wb.dependencyFormulas.addNode( this.ws.Id, this.cellId ),
ref, nTo, wsR;
var node, ref, nTo, wsR;
if( !defName ){
node = this.wb.dependencyFormulas.addNode( this.ws.Id, this.cellId )
}
else{
node = defName;
}
for ( var i = 0; i < this.outStack.length; i++ ) {
ref = this.outStack[i];
......@@ -4155,7 +4292,7 @@ parserFormula.prototype = {
else if ( ref instanceof cArea3D && ref.isValid() ) {
wsR = ref.wsRange();
for ( var j = 0; j < wsR.length; j++ ) {
this.wb.dependencyFormulas.addEdge( this.ws.Id, this.cellId.replace( this.regSpace, "" ), wsR[j].Id, ref._cells.replace( this.regSpace, "" ) );
this.wb.dependencyFormulas.addEdge2( node, this.wb.dependencyFormulas.addNode( wsR[j].Id, ref._cells.replace( this.regSpace, "" )) );
}
}
}
......
......@@ -1581,13 +1581,15 @@ var g_oUndoRedoData_DefinedNamesProperties = {
Name: 0,
Ref:1,
LocalSheetId:2,
slaveEdge:3
slaveEdge:3,
isTable:4
};
function UndoRedoData_DefinedNames(name, ref, scope, slaveEdge){
function UndoRedoData_DefinedNames(name, ref, scope, isTable, slaveEdge){
this.Properties = g_oUndoRedoData_DefinedNamesProperties;
this.Name = name;
this.Ref = ref;
this.LocalSheetId = scope;
this.isTable = isTable;
this.slaveEdge = slaveEdge;
}
UndoRedoData_DefinedNames.prototype = {
......@@ -1606,6 +1608,7 @@ UndoRedoData_DefinedNames.prototype = {
case this.Properties.Name: return this.Name;break;
case this.Properties.Ref: return this.Ref;break;
case this.Properties.LocalSheetId: return this.LocalSheetId;break;
case this.Properties.isTable: return this.isTable;break;
case this.Properties.slaveEdge: return this.slaveEdge;break;
}
return null;
......@@ -1617,6 +1620,7 @@ UndoRedoData_DefinedNames.prototype = {
case this.Properties.Name: this.Name = value;break;
case this.Properties.Ref: this.Ref = value;break;
case this.Properties.LocalSheetId: this.LocalSheetId = value;break;
case this.Properties.isTable: this.isTable = value;break;
case this.Properties.slaveEdge: this.slaveEdge = value;break;
}
}
......@@ -1628,8 +1632,8 @@ var g_oUndoRedoData_DefinedNamesChangeProperties = {
};
function UndoRedoData_DefinedNamesChange(oldName, newName){
this.Properties = g_oUndoRedoData_DefinedNamesChangeProperties;
this.oldName = oldName;
this.newName = newName;
this.oldName = oldName?new UndoRedoData_DefinedNames(oldName.Name, oldName.Ref, oldName.LocalSheetId, oldName.isTable, null):undefined;
this.newName = newName?new UndoRedoData_DefinedNames(newName.Name, newName.Ref, newName.LocalSheetId, newName.isTable, null):undefined;
}
UndoRedoData_DefinedNamesChange.prototype = {
getType : function()
......
......@@ -263,13 +263,17 @@ DependencyGraph.prototype = {
},
changeNodeProcessDelete: function (node, oFormulas, toDelete) {
//todo deleteAllSlaveEdges deleteMasterNodes
var oSlaves = node.deleteAllSlaveEdges();
var oSlaves = node.deleteAllSlaveEdges(), slave, formula;
if (this.bSetRefError) {
//выставляем #REF!
for (var i in oSlaves) {
var slave = oSlaves[i];
slave = oSlaves[i];
if( slave instanceof DefNameVertex ){
this.wb.delDefinesNames(slave.getAscCDefName())
continue;
}
if (null == toDelete || slave != toDelete[slave.nodeId]) {
var formula = slave.setRefError(node);
formula = slave.setRefError(node);
if (null != formula) {
if (oFormulas)
oFormulas[slave.nodeId] = { node: slave, formula: formula };
......@@ -896,10 +900,32 @@ DependencyGraph.prototype = {
}
// if ( oRes.isArea ) {
// var nodesSheetArea = this.nodesArea[node.sheetId];
// if ( null == nodesSheetArea ) {
// nodesSheetArea = new RangeDataManager(function(data, from, to){_this._changeNode(data, from, to);});
// this.nodesArea[oRes.sheetId] = nodesSheetArea;
// }
// nodesSheetArea.add( oBBoxNode, node );
// }
// else {
// var nodesSheetCell = this.nodesCell[node.sheetId];
// if ( null == nodesSheetCell ) {
// nodesSheetCell = new CellArea(function(data, from, to){_this._changeNode(data, from, to);});
// this.nodesCell[node.sheetId] = nodesSheetCell;
// }
// nodesSheetCell.add( oBBoxNode.r1, oBBoxNode.c1, node );
// }
/*поставить зависимость между ячейками и текущим ИД*/
if ( bUndo ) {
oRes.Ref = defRef;
}
oRes.parsedRef.buildDependencies(null,oRes);
return oRes;
},
......@@ -928,7 +954,7 @@ DependencyGraph.prototype = {
for( var id in nodesList ){
if( nodesList[id].parsedRef.removeSheet(sheetId) ){
if( !nodesList[id].isTable && nodesList[id].parsedRef.removeSheet(sheetId) ){
seUndoRedo = [];
defN = nodesList[id];
nSE = defN.getSlaveEdges();
......@@ -939,7 +965,7 @@ DependencyGraph.prototype = {
wsIndex = this.wb.getWorksheetById(defN.sheetId);
History.Add( g_oUndoRedoWorkbook, historyitem_Workbook_DefinedNamesDelete, null, null,
new UndoRedoData_DefinedNames( defN.Name, defN.Ref, wsIndex ? wsIndex.getIndex() : undefined, seUndoRedo ) );
new UndoRedoData_DefinedNames( defN.Name, defN.Ref, wsIndex ? wsIndex.getIndex() : undefined, defN.isTable, seUndoRedo ) );
if( defN.sheetId == sheetId ){
......@@ -1049,8 +1075,9 @@ DependencyGraph.prototype = {
return sNewName;
},
addTableName:function ( sName, ws, Ref ) {
var dfv = new DefNameVertex( null, sName, parserHelp.get3DRef( ws.getName(), Ref.getAbsName() ), this.wb, true ),
var refClone = Ref.clone(true);
refClone.r1++;
var dfv = new DefNameVertex( null, sName, parserHelp.get3DRef( ws.getName(), refClone.getAbsName() ), this.wb, true ),
defNameSheetsList = this.defNameSheets[dfv.sheetId];
this.defNameList[dfv.nodeId] = dfv;
if ( defNameSheetsList == null ) {
......@@ -1060,8 +1087,11 @@ DependencyGraph.prototype = {
defNameSheetsList[dfv.nodeId] = dfv;
},
changeTableName:function(tableName, ws, newRef){
var table = this.getDefNameNodeByName( tableName, ws );
table.Ref = parserHelp.getEscapeSheetName(ws.getName())+"!"+newRef.getAbsName();
var table = this.getDefNameNodeByName( tableName, ws ),
newRefClone = newRef.clone(true);
newRefClone.r1++;
table.Ref = table.Ref.split("!")[0]+"!"+newRefClone.getAbsName();
// table.Ref = parserHelp.getEscapeSheetName(ws.getName())+"!"+newRef.getAbsName();
},
delTableName:function(name,ws){
var table = this.getDefNameNodeByName( name, ws );
......@@ -1091,10 +1121,10 @@ function Vertex(sheetId, cellId, wb){
this.isBad = false;
//masterEdges содержит ячейки, от которых зависит текущая ячейка
this.masterEdges = null;
this.masterEdges = {};
//slaveEdges содержит ячейки, которые зависят от данной ячейки
this.slaveEdges = null;
this.slaveEdges = {};
this.refCount = 0;
......@@ -1160,10 +1190,22 @@ Vertex.prototype = {
},
moveOuter: function (from, to, oFormulas) {
if ((from.r1 == to.r1 && from.c1 == to.c1) || (from.r2 == to.r2 && from.c2 == to.c2)) {
var _sn = this.getSlaveEdges();
var _sn = this.getSlaveEdges(), slave, cell;
for (var _id in _sn) {
var slave = _sn[_id];
var cell = slave.returnCell();
slave = _sn[_id];
if( slave instanceof DefNameVertex ){
if ( false == this.wb.bUndoChanges && (false == this.wb.bRedoChanges || true == this.wb.bCollaborativeChanges )){
History.LocalChange = true;
var oN = slave.getAscCDefName(), nN;
slave.parsedRef.stretchArea(this, from, to);
nN = slave.getAscCDefName();
nN.Ref = slave.parsedRef.assemble();
this.wb.editDefinesNames( oN, nN );
History.LocalChange = false;
}
continue;
}
cell = slave.returnCell();
if (cell && cell.formulaParsed) {
cell.formulaParsed.stretchArea(this, from, to);
var formula = cell.formulaParsed.assemble();
......@@ -1188,10 +1230,27 @@ Vertex.prototype = {
addToArrRecalc(this.sheetId, cell);
}
}
var _sn = this.getSlaveEdges();
var _sn = this.getSlaveEdges(), slave, cell;
for (var _id in _sn) {
var slave = _sn[_id]
var cell = slave.returnCell();
slave = _sn[_id]
if( slave instanceof DefNameVertex ){
/*slave.parsedRef.shiftCells(this, from, to);
slave.relinkRef();*/
if ( false == this.wb.bUndoChanges && (false == this.wb.bRedoChanges || true == this.wb.bCollaborativeChanges )){
History.LocalChange = true;
var oN = slave.getAscCDefName(), nN;
slave.parsedRef.shiftCells(this, from, to);
nN = slave.getAscCDefName();
nN.Ref = slave.parsedRef.assemble();
this.wb.editDefinesNames( oN, nN );
History.LocalChange = false;
}
continue;
}
cell = slave.returnCell();
if (cell && cell.formulaParsed) {
cell.formulaParsed.shiftCells(this, from, to);
var formula = cell.formulaParsed.assemble();
......@@ -1250,24 +1309,16 @@ Vertex.prototype = {
//удаляем ребро между конкретной ведущей ячейки.
deleteMasterEdge: function (node) {
if (this.masterEdges) {
if(this.masterEdges[node.nodeId]){
this.masterEdges[node.nodeId] = null;
delete this.masterEdges[node.nodeId];
node.deleteSlaveEdge(this);
this.refCount--;
}
delete this.masterEdges[node.nodeId];
this.refCount--;
}
},
//удаляем ребро между конкретной зависимой(ведомой) ячейки.
deleteSlaveEdge: function (node) {
if (this.slaveEdges) {
if(this.slaveEdges[node.nodeId]){
this.slaveEdges[node.nodeId] = null;
delete this.slaveEdges[node.nodeId];
node.deleteMasterEdge(this);
this.refCount--;
}
delete this.slaveEdges[node.nodeId];
this.refCount--;
}
},
......@@ -1277,7 +1328,6 @@ Vertex.prototype = {
for( var id in this.masterEdges ){
var masterEdge = this.masterEdges[id];
masterEdge.deleteSlaveEdge(this);
this.masterEdges[id] = null;
delete this.masterEdges[id];
this.refCount--;
ret[id] = masterEdge;
......@@ -1292,7 +1342,6 @@ Vertex.prototype = {
for( var id in this.slaveEdges ){
var slaveEdge = this.slaveEdges[id];
slaveEdge.deleteMasterEdge(this);
this.slaveEdges[id] = null;
delete this.slaveEdges[id];
this.refCount--;
ret[id] = slaveEdge;
......@@ -1330,8 +1379,12 @@ function DefNameVertex( scope, defName, defRef, wb, isTable ) {
this.parsedRef = new parserFormula(this.Ref, "", this.wb.getWorksheet(0));
if( this.Ref ){
this.parsedRef.parse();
// this.parsedRef.buildDependencies();
}
}
else{
this.sheetTableId = wb.getActiveWs().getId();
}
//вершина которую мы прошли и поставили в очередь обхода
this.isBlack = false;
......@@ -1343,10 +1396,10 @@ function DefNameVertex( scope, defName, defRef, wb, isTable ) {
this.isBad = false;
//masterEdges содержит ячейки, от которых зависит текущая ячейка
this.masterEdges = null;
this.masterEdges = {};
//slaveEdges содержит ячейки, которые зависят от данной ячейки
this.slaveEdges = null;
this.slaveEdges = {};
this.refCount = 0;
......@@ -1490,24 +1543,24 @@ DefNameVertex.prototype = {
//удаляем ребро между конкретной ведущей ячейки.
deleteMasterEdge:function ( node ) {
if ( this.masterEdges ) {
if ( this.masterEdges[node.nodeId] ) {
this.masterEdges[node.nodeId] = null;
// if ( this.masterEdges[node.nodeId] ) {
// this.masterEdges[node.nodeId] = null;
delete this.masterEdges[node.nodeId];
node.deleteSlaveEdge( this );
// node.deleteSlaveEdge( this );
this.refCount--;
}
// }
}
},
//удаляем ребро между конкретной зависимой(ведомой) ячейки.
deleteSlaveEdge:function ( node ) {
if ( this.slaveEdges ) {
if ( this.slaveEdges[node.nodeId] ) {
this.slaveEdges[node.nodeId] = null;
// if ( this.slaveEdges[node.nodeId] ) {
// this.slaveEdges[node.nodeId] = null;
delete this.slaveEdges[node.nodeId];
node.deleteMasterEdge( this );
// node.deleteMasterEdge( this );
this.refCount--;
}
// }
}
},
......@@ -1708,7 +1761,6 @@ function _sortDependency(wb, node, oNodeDependence, oNewMasterAreaNodes, bBad, o
// var ws = wb.getWorksheetById( node.sheetId );
// ws._ReBuildFormulas
// ws._RecalculatedFunctions(node.cellId, bCurBad, setCellFormat);
// alert("node.isDefinedName")
}
else{
//пересчитываем функцию
......@@ -1844,7 +1896,9 @@ Workbook.prototype.init=function(bNoBuildDep){
var self = this;
this.wsHandlers = new asc.asc_CHandlersList(/*handlers*/{
"changeRefTablePart" : function (displayName, ref) {self.wsHandlers.trigger("asc_onChangeRefTablePart", displayName, ref);}
"changeRefTablePart" : function (displayName, ref) {
self.dependencyFormulas.changeTableName( displayName, null, ref );
}
});
//charts
......@@ -1862,6 +1916,7 @@ Workbook.prototype.init=function(bNoBuildDep){
this.buildDependency();
sortDependency(this);
}
};
Workbook.prototype.rebuildColors=function(){
g_oColorManager.rebuildColors();
......@@ -2444,7 +2499,7 @@ Workbook.prototype.delDefinesNames = function ( defName ) {
}
sortDependency( this );
History.Add( g_oUndoRedoWorkbook, historyitem_Workbook_DefinedNamesDelete, null, null, new UndoRedoData_DefinedNames( defName.Name, defName.Ref, defName.LocalSheetId, seUndoRedo ) );
History.Add( g_oUndoRedoWorkbook, historyitem_Workbook_DefinedNamesDelete, null, null, new UndoRedoData_DefinedNames( defName.Name, defName.Ref, defName.LocalSheetId, defName.isTable, seUndoRedo ) );
}
return retRes;
......@@ -2485,9 +2540,7 @@ Workbook.prototype.editDefinesNames = function ( oldName, newName, bUndo ) {
* */
if( !rename ){
retRes = this.dependencyFormulas.getDefNameNodeByName(newName.Name)
}
if(retRes){
......@@ -2503,7 +2556,6 @@ Workbook.prototype.editDefinesNames = function ( oldName, newName, bUndo ) {
se = se.returnCell();
if ( se ) {
se.setFormula( se.formulaParsed.assemble() );
if ( !rename ) {
......
......@@ -4349,7 +4349,7 @@ TablePart.prototype.clone = function(ws) {
TablePart.prototype.recalc = function(ws) {
this.DisplayName = ws.workbook.dependencyFormulas.getNextTableName(ws, this.Ref);
};
TablePart.prototype.moveRef = function(col, row, ws) {
TablePart.prototype.moveRef = function(col, row) {
var ref = this.Ref.clone();
ref.setOffset({offsetCol: col ? col : 0, offsetRow: row ? row : 0});
......
......@@ -1686,7 +1686,7 @@ var maxIndividualValues = 10000;
range = ref;
//move ref
findFilters[i].moveRef(diffCol, diffRow, ws);
findFilters[i].moveRef(diffCol, diffRow);
isUpdate = false;
if((findFilters[i].AutoFilter && findFilters[i].AutoFilter.FilterColumns && findFilters[i].AutoFilter.FilterColumns.length) || (findFilters[i].FilterColumns && findFilters[i].FilterColumns.length))
......
......@@ -380,6 +380,44 @@
return sRes;
},
getAbsName2 : function(absCol1,absRow1,absCol2,absRow2) {
var sRes = "";
if (0 == this.c1 && gc_nMaxCol0 == this.c2 && false == this.c1Abs && false == this.c2Abs) {
if (absRow1)
sRes += "$";
sRes += (this.r1 + 1) + ":";
if (absRow2)
sRes += "$";
sRes += (this.r2 + 1);
}
else if (0 == this.r1 && gc_nMaxRow0 == this.r2 && false == this.r1Abs && false == this.r2Abs) {
if (absCol1)
sRes += "$";
sRes += g_oCellAddressUtils.colnumToColstr(this.c1 + 1) + ":";
if (absCol2)
sRes += "$";
sRes += g_oCellAddressUtils.colnumToColstr(this.c2 + 1);
}
else {
if (absCol1)
sRes += "$";
sRes += g_oCellAddressUtils.colnumToColstr(this.c1 + 1);
if (absRow1)
sRes += "$";
sRes += (this.r1 + 1);
if (!this.isOneCell()) {
sRes += ":";
if (absCol2)
sRes += "$";
sRes += g_oCellAddressUtils.colnumToColstr(this.c2 + 1);
if (absRow2)
sRes += "$";
sRes += (this.r2 + 1);
}
}
return sRes;
},
getAllRange: function () {
var result;
if (c_oAscSelectionType.RangeMax === this.type)
......
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