Commit feb835f9 authored by Alexander.Trofimov's avatar Alexander.Trofimov

update code formatting Workbook.js

parent 6ae175a7
...@@ -3057,144 +3057,148 @@ Workbook.prototype.getTableNameColumnByIndex = function(tableName, columnIndex){ ...@@ -3057,144 +3057,148 @@ Workbook.prototype.getTableNameColumnByIndex = function(tableName, columnIndex){
} }
return res; return res;
}; };
Workbook.prototype.updateSparklineCache = function(sheet, ranges) { Workbook.prototype.updateSparklineCache = function (sheet, ranges) {
for (var i = 0; i < this.aWorksheets.length; ++i) { for (var i = 0; i < this.aWorksheets.length; ++i) {
this.aWorksheets[i].updateSparklineCache(sheet, ranges); this.aWorksheets[i].updateSparklineCache(sheet, ranges);
} }
}; };
Workbook.prototype.lockDraw = function() { Workbook.prototype.lockDraw = function () {
++this.lockCounter; ++this.lockCounter;
}; };
Workbook.prototype.unLockDraw = function() { Workbook.prototype.unLockDraw = function () {
if (0 < this.lockCounter) { if (0 < this.lockCounter) {
--this.lockCounter; --this.lockCounter;
} }
}; };
Workbook.prototype.buildRecalc = function(notrec, bForce) { Workbook.prototype.buildRecalc = function (notrec, bForce) {
var ws; var ws;
if (this.lockCounter > 0 && !bForce) { if (this.lockCounter > 0 && !bForce) {
return; return;
} }
if (!bForce) { if (!bForce) {
for (var id in arrDefNameRecalc) { for (var id in arrDefNameRecalc) {
arrDefNameRecalc[id].rebuild(); arrDefNameRecalc[id].rebuild();
} }
arrDefNameRecalc = {}; arrDefNameRecalc = {};
} }
for (var id in arrRecalc) { for (var id in arrRecalc) {
ws = this.getWorksheetById(id); ws = this.getWorksheetById(id);
if (ws) { if (ws) {
var temp = arrRecalc[id]; var temp = arrRecalc[id];
var _rec = {}; var _rec = {};
for (var i = 0, length = temp.length; i < length; ++i) { for (var i = 0, length = temp.length; i < length; ++i) {
var cell = temp[i]; var cell = temp[i];
var cellId = g_oCellAddressUtils.getCellId(cell.nRow, cell.nCol); var cellId = g_oCellAddressUtils.getCellId(cell.nRow, cell.nCol);
_rec[cellId] = cellId; _rec[cellId] = cellId;
this.needRecalc.nodes[getVertexId(id, cellId)] = [id, cellId]; this.needRecalc.nodes[getVertexId(id, cellId)] = [id, cellId];
this.needRecalc.length++; this.needRecalc.length++;
} }
ws._BuildDependencies(_rec); ws._BuildDependencies(_rec);
} }
} }
arrRecalc = {}; arrRecalc = {};
if (!notrec) { if (!notrec) {
this.sortDependency(); this.sortDependency();
} }
}; };
Workbook.prototype.sortDependency = function(setCellFormat) { Workbook.prototype.sortDependency = function (setCellFormat) {
this.buildRecalc(true); this.buildRecalc(true);
var i; var i;
var nR = this.needRecalc; var nR = this.needRecalc;
if (nR && (nR.length > 0)) { if (nR && (nR.length > 0)) {
var oCleanCellCacheArea = {}; var oCleanCellCacheArea = {};
var oNodeDependence = this.dependencyFormulas.getNodeDependence(nR.nodes); var oNodeDependence = this.dependencyFormulas.getNodeDependence(nR.nodes);
for (i in oNodeDependence.oMasterNodes) for (i in oNodeDependence.oMasterNodes) {
this._sortDependency(oNodeDependence.oMasterNodes[i], oNodeDependence, oNodeDependence.oMasterAreaNodes, false, this._sortDependency(oNodeDependence.oMasterNodes[i], oNodeDependence, oNodeDependence.oMasterAreaNodes, false,
oCleanCellCacheArea, setCellFormat); oCleanCellCacheArea, setCellFormat);
//те AreaNodes }
var oCurMasterAreaNodes = oNodeDependence.oMasterAreaNodes; //те AreaNodes
while (true) { var oCurMasterAreaNodes = oNodeDependence.oMasterAreaNodes;
var bEmpty = true; while (true) {
var oNewMasterAreaNodes = {}; var bEmpty = true;
for (i in oCurMasterAreaNodes) { var oNewMasterAreaNodes = {};
bEmpty = false; for (i in oCurMasterAreaNodes) {
this._sortDependency(oCurMasterAreaNodes[i], oNodeDependence, oNewMasterAreaNodes, false, oCleanCellCacheArea, bEmpty = false;
setCellFormat); this._sortDependency(oCurMasterAreaNodes[i], oNodeDependence, oNewMasterAreaNodes, false, oCleanCellCacheArea,
} setCellFormat);
oCurMasterAreaNodes = oNewMasterAreaNodes; }
if (bEmpty) { oCurMasterAreaNodes = oNewMasterAreaNodes;
//все оставшиеся считаем как bad if (bEmpty) {
//todo сделать как в Excel, которой определяет циклические ссылки на момент подсчета(пример A1=VLOOKUP(1,B1:D2,2),B2 = 1, D1=A1 - это не циклическая ссылка) //все оставшиеся считаем как bad
for (i in oNodeDependence.oMasterAreaNodesRestricted) { //todo сделать как в Excel, которой определяет циклические ссылки на момент подсчета(пример A1=VLOOKUP(1,B1:D2,2),B2 = 1, D1=A1 - это не циклическая ссылка)
this._sortDependency(oNodeDependence.oMasterAreaNodesRestricted[i].node, oNodeDependence, null, true, for (i in oNodeDependence.oMasterAreaNodesRestricted) {
oCleanCellCacheArea, setCellFormat); this._sortDependency(oNodeDependence.oMasterAreaNodesRestricted[i].node, oNodeDependence, null, true,
} oCleanCellCacheArea, setCellFormat);
break; }
} break;
} }
for (i in oCleanCellCacheArea) }
this.handlers.trigger("cleanCellCache", i, oCleanCellCacheArea[i], AscCommonExcel.c_oAscCanChangeColWidth.none); for (i in oCleanCellCacheArea) {
this.handlers.trigger("cleanCellCache", i, oCleanCellCacheArea[i], AscCommonExcel.c_oAscCanChangeColWidth.none);
}
AscCommonExcel.g_oVLOOKUPCache.clean(); AscCommonExcel.g_oVLOOKUPCache.clean();
AscCommonExcel.g_oHLOOKUPCache.clean(); AscCommonExcel.g_oHLOOKUPCache.clean();
} }
this.needRecalc = {nodes: {}, length: 0}; this.needRecalc = {nodes: {}, length: 0};
}; };
Workbook.prototype._sortDependency = function(node, oNodeDependence, oNewMasterAreaNodes, bBad, oCleanCellCacheArea, setCellFormat) { Workbook.prototype._sortDependency =
if (node) { function (node, oNodeDependence, oNewMasterAreaNodes, bBad, oCleanCellCacheArea, setCellFormat) {
var oWeightMapElem = oNodeDependence.oWeightMap[node.nodeId]; if (node) {
if (oWeightMapElem) { var oWeightMapElem = oNodeDependence.oWeightMap[node.nodeId];
oWeightMapElem.cur++; if (oWeightMapElem) {
if (oWeightMapElem.cur == oWeightMapElem.max && !oWeightMapElem.gray) { oWeightMapElem.cur++;
if (null != oNewMasterAreaNodes) { if (oWeightMapElem.cur == oWeightMapElem.max && !oWeightMapElem.gray) {
var oNodeToAreaElement = oNodeDependence.oNodeToArea[node.nodeId]; if (null != oNewMasterAreaNodes) {
if (oNodeToAreaElement) { var oNodeToAreaElement = oNodeDependence.oNodeToArea[node.nodeId];
for (var i = 0, length = oNodeToAreaElement.length; i < length; ++i) { if (oNodeToAreaElement) {
var elem = oNodeToAreaElement[i]; for (var i = 0, length = oNodeToAreaElement.length; i < length; ++i) {
elem.cur++; var elem = oNodeToAreaElement[i];
if (elem.cur == elem.max) { elem.cur++;
oNewMasterAreaNodes[elem.node.nodeId] = elem.node; if (elem.cur == elem.max) {
delete oNodeDependence.oMasterAreaNodesRestricted[elem.node.nodeId]; oNewMasterAreaNodes[elem.node.nodeId] = elem.node;
} delete oNodeDependence.oMasterAreaNodesRestricted[elem.node.nodeId];
} }
} }
} }
var bCurBad = oWeightMapElem.bad || bBad; }
if (node.isDefinedName) { var bCurBad = oWeightMapElem.bad || bBad;
//todo if (node.isDefinedName) {
//Обрабатываем тут все, что было сделано с именованной ссылкой: переименована; //todo
//перемещен диапазон; сдвиг/удаление ячеек, приведшие к сдвигу ячеек; удаление именованного диапазона. //Обрабатываем тут все, что было сделано с именованной ссылкой: переименована;
// //перемещен диапазон; сдвиг/удаление ячеек, приведшие к сдвигу ячеек; удаление именованного диапазона.
// var ws = this.getWorksheetById( node.sheetId ); //
// ws._ReBuildFormulas // var ws = this.getWorksheetById( node.sheetId );
// ws._RecalculatedFunctions(node.cellId, bCurBad, setCellFormat); // ws._ReBuildFormulas
} else { // ws._RecalculatedFunctions(node.cellId, bCurBad, setCellFormat);
//пересчитываем функцию } else {
var ws = this.getWorksheetById(node.sheetId); //пересчитываем функцию
ws._RecalculatedFunctions(node.cellId, bCurBad, setCellFormat); var ws = this.getWorksheetById(node.sheetId);
//запоминаем области для удаления cache ws._RecalculatedFunctions(node.cellId, bCurBad, setCellFormat);
var sheetArea = oCleanCellCacheArea[node.sheetId]; //запоминаем области для удаления cache
if (null == sheetArea) { var sheetArea = oCleanCellCacheArea[node.sheetId];
sheetArea = {}; if (null == sheetArea) {
oCleanCellCacheArea[node.sheetId] = sheetArea; sheetArea = {};
} oCleanCellCacheArea[node.sheetId] = sheetArea;
if (!node.isArea) { }
sheetArea[node.cellId] = node.getBBox(); if (!node.isArea) {
} sheetArea[node.cellId] = node.getBBox();
} }
//обрабатываем child }
oWeightMapElem.gray = true; //обрабатываем child
var oSlaveNodes = node.getSlaveEdges(); oWeightMapElem.gray = true;
if (oSlaveNodes) { var oSlaveNodes = node.getSlaveEdges();
for (var i in oSlaveNodes) if (oSlaveNodes) {
this._sortDependency(oSlaveNodes[i], oNodeDependence, oNewMasterAreaNodes, bBad, oCleanCellCacheArea); for (var i in oSlaveNodes) {
} this._sortDependency(oSlaveNodes[i], oNodeDependence, oNewMasterAreaNodes, bBad, oCleanCellCacheArea);
oWeightMapElem.gray = false; }
} }
} oWeightMapElem.gray = false;
} }
}; }
}
};
//------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------
/** /**
* @constructor * @constructor
......
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