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

добавлен пересчет Vertex с флагом isDefinedName

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@61684 954022d7-b5bf-4e40-9824-e11837661b57
parent 37f57926
...@@ -562,7 +562,7 @@ DependencyGraph.prototype = { ...@@ -562,7 +562,7 @@ DependencyGraph.prototype = {
nodesSheetCell.removeAll(); nodesSheetCell.removeAll();
this.changeNodeEnd(); this.changeNodeEnd();
}, },
getNodeDependence:function ( aElems ) { getNodeDependence:function ( aElems, aDefinedNames ) {
var oRes = { oMasterNodes: {}, oMasterAreaNodes: {}, oMasterAreaNodesRestricted: {}, oWeightMap: {}, oNodeToArea: {}, nCounter: 0 }; var oRes = { oMasterNodes: {}, oMasterAreaNodes: {}, oMasterAreaNodesRestricted: {}, oWeightMap: {}, oNodeToArea: {}, nCounter: 0 };
var aWeightMapMasters = []; var aWeightMapMasters = [];
var aWeightMapMastersNodes = []; var aWeightMapMastersNodes = [];
...@@ -570,26 +570,42 @@ DependencyGraph.prototype = { ...@@ -570,26 +570,42 @@ DependencyGraph.prototype = {
var elem; var elem;
var oSheetRanges = {}; var oSheetRanges = {};
var oSheetWithArea = {};//все sheet на которых есть area для пересчета var oSheetWithArea = {};//все sheet на которых есть area для пересчета
while ( null != aElems ) { while ( null != aElems || null != aDefinedNames ) {
for ( var i in aElems ) { if(null != aElems){
elem = aElems[i]; for ( var i in aElems ) {
var sheetId = elem[0]; elem = aElems[i];
var cellId = elem[1]; var sheetId = elem[0];
//нужно обавлять в oSheetRanges даже несушествующие node, чтобы поддержать именении ячеек в SUM(A1:B2) var cellId = elem[1];
this._getNodeDependenceNodeToRange(sheetId, Asc.g_oRangeCache.getAscRange(cellId), oSheetRanges); //нужно обавлять в oSheetRanges даже несушествующие node, чтобы поддержать именении ячеек в SUM(A1:B2)
node = this.getNode(sheetId, cellId); this._getNodeDependenceNodeToRange(sheetId, Asc.g_oRangeCache.getAscRange(cellId), oSheetRanges);
if ( node && null == oRes.oWeightMap[node.nodeId] ) { node = this.getNode(sheetId, cellId);
//все node из aElems записываем в master if ( node && null == oRes.oWeightMap[node.nodeId] ) {
var oWeightMapElem = { id: oRes.nCounter++, cur: 0, max: 0, gray: false, bad: false, master: true, area: node.isArea }; //все node из aElems записываем в master
if (node.isArea) var oWeightMapElem = { id: oRes.nCounter++, cur: 0, max: 0, gray: false, bad: false, master: true, area: node.isArea };
oSheetWithArea[node.sheetId] = 1; if (node.isArea)
aWeightMapMasters.push( oWeightMapElem ); oSheetWithArea[node.sheetId] = 1;
aWeightMapMastersNodes.push( node ); aWeightMapMasters.push( oWeightMapElem );
oRes.oWeightMap[node.nodeId] = oWeightMapElem; aWeightMapMastersNodes.push( node );
this._getNodeDependence( oRes, oSheetRanges, node ); oRes.oWeightMap[node.nodeId] = oWeightMapElem;
} this._getNodeDependence( oRes, oSheetRanges, node );
} }
}
}
if(null != aDefinedNames){
for(var i = 0; i < aDefinedNames.length; ++i){
var node = aDefinedNames[i];
if ( node && null == oRes.oWeightMap[node.nodeId] ) {
//все node из aDefinedNames записываем в master
var oWeightMapElem = { id: oRes.nCounter++, cur: 0, max: 0, gray: false, bad: false, master: true, area: false };
aWeightMapMasters.push( oWeightMapElem );
aWeightMapMastersNodes.push( node );
oRes.oWeightMap[node.nodeId] = oWeightMapElem;
this._getNodeDependence( oRes, oSheetRanges, node );
}
}
}
aElems = null; aElems = null;
aDefinedNames = null;
//расширяем за счет area nodes //расширяем за счет area nodes
for ( var i in oSheetRanges ) { for ( var i in oSheetRanges ) {
var oSheetRange = oSheetRanges[i]; var oSheetRange = oSheetRanges[i];
...@@ -720,7 +736,10 @@ DependencyGraph.prototype = { ...@@ -720,7 +736,10 @@ DependencyGraph.prototype = {
var bStop = false; var bStop = false;
var oWeightMapElem = oRes.oWeightMap[node.nodeId]; var oWeightMapElem = oRes.oWeightMap[node.nodeId];
if ( null == oWeightMapElem ) { if ( null == oWeightMapElem ) {
oWeightMapElem = { id: oRes.nCounter++, cur: 0, max: 1, gray: false, bad: false, master: false, area: node.isArea }; if(node.isDefinedName)
oWeightMapElem = { id: oRes.nCounter++, cur: 0, max: 1, gray: false, bad: false, master: false, area: false };
else
oWeightMapElem = { id: oRes.nCounter++, cur: 0, max: 1, gray: false, bad: false, master: false, area: node.isArea };
oRes.oWeightMap[node.nodeId] = oWeightMapElem; oRes.oWeightMap[node.nodeId] = oWeightMapElem;
} }
else { else {
...@@ -740,7 +759,7 @@ DependencyGraph.prototype = { ...@@ -740,7 +759,7 @@ DependencyGraph.prototype = {
oWeightMapElem.max--; oWeightMapElem.max--;
} }
} }
if (!bStop && 1 == oWeightMapElem.max ) if (!bStop && 1 == oWeightMapElem.max && !node.isDefinedName )
this._getNodeDependenceNodeToRange( node.sheetId, node.getBBox(), oSheetRanges ); this._getNodeDependenceNodeToRange( node.sheetId, node.getBBox(), oSheetRanges );
if (!bStop && oWeightMapElem.max <= 1) { if (!bStop && oWeightMapElem.max <= 1) {
oWeightMapElem.gray = true; oWeightMapElem.gray = true;
...@@ -813,6 +832,8 @@ function Vertex(sheetId, cellId, wb){ ...@@ -813,6 +832,8 @@ function Vertex(sheetId, cellId, wb){
this.slaveEdges = null; this.slaveEdges = null;
this.refCount = 0; this.refCount = 0;
this.isDefinedName = false;
} }
Vertex.prototype = { Vertex.prototype = {
...@@ -1134,17 +1155,22 @@ function _sortDependency(wb, node, oNodeDependence, oNewMasterAreaNodes, bBad, o ...@@ -1134,17 +1155,22 @@ function _sortDependency(wb, node, oNodeDependence, oNewMasterAreaNodes, bBad, o
} }
} }
var bCurBad = oWeightMapElem.bad || bBad; var bCurBad = oWeightMapElem.bad || bBad;
//пересчитываем функцию if(node.isDefinedName){
var ws = wb.getWorksheetById( node.sheetId ); //todo
ws._RecalculatedFunctions(node.cellId, bCurBad, setCellFormat); }
//запоминаем области для удаления cache else{
var sheetArea = oCleanCellCacheArea[node.sheetId]; //пересчитываем функцию
if ( null == sheetArea ) { var ws = wb.getWorksheetById( node.sheetId );
sheetArea = {}; ws._RecalculatedFunctions(node.cellId, bCurBad, setCellFormat);
oCleanCellCacheArea[node.sheetId] = sheetArea; //запоминаем области для удаления cache
} var sheetArea = oCleanCellCacheArea[node.sheetId];
if(!node.isArea) if ( null == sheetArea ) {
sheetArea[node.cellId] = node.getBBox(); sheetArea = {};
oCleanCellCacheArea[node.sheetId] = sheetArea;
}
if(!node.isArea)
sheetArea[node.cellId] = node.getBBox();
}
//обрабатываем child //обрабатываем child
oWeightMapElem.gray = true; oWeightMapElem.gray = true;
var oSlaveNodes = node.getSlaveEdges(); var oSlaveNodes = node.getSlaveEdges();
......
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