Commit 147ee916 authored by Alexander.Trofimov's avatar Alexander.Trofimov Committed by Alexander.Trofimov

Реализовал возможность обновлять условное форматирование.

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@68281 954022d7-b5bf-4e40-9824-e11837661b57
parent ca9eb521
......@@ -200,10 +200,6 @@
};
function CGradient (c1, c2) {
if ( !(this instanceof CGradient) ) {
return new CGradient (c1, c2);
}
this.MaxColorIndex = 512;
this.base_shift = 8;
......
......@@ -3274,12 +3274,12 @@ Woorksheet.prototype.initPostOpen = function(handlers){
}
}
this._initConditionalFormatting();
this._updateConditionalFormatting(null);
this.handlers = handlers;
this._setHandlersTablePart();
};
Woorksheet.prototype._initConditionalFormatting = function() {
Woorksheet.prototype._updateConditionalFormatting = function(range) {
var oGradient = null;
var aCFs = this.aConditionalFormatting;
var aRules, oRule;
......@@ -3289,52 +3289,57 @@ Woorksheet.prototype._initConditionalFormatting = function() {
var arrayCells = [];
var tmp, i, j, cell;
for (i = 0; i < aCFs.length; ++i) {
aRules = aCFs[i].aRules;
for (j = 0; j < aRules.length; ++j) {
oRule = aRules[j];
// ToDo aboveAverage, beginsWith, cellIs, containsBlanks, containsErrors,
// ToDo containsText, dataBar, duplicateValues, endsWith, expression, iconSet, notContainsBlanks,
// ToDo notContainsErrors, notContainsText, timePeriod, top10, uniqueValues (page 2679)
switch (oRule.Type) {
case Asc.ECfType.colorScale:
if (1 !== oRule.aRuleElements.length) {
break;
}
oRuleElement = oRule.aRuleElements[0];
// ToDo убрать null === aCFs[i].SqRefRange когда научимся мультиселект обрабатывать (\\192.168.5.2\source\DOCUMENTS\XLSX\Matematika Quantum Sedekah.xlsx)
if (!(oRuleElement instanceof Asc.CColorScale) || null === aCFs[i].SqRefRange) {
break;
}
// ToDo убрать null === aCFs[i].SqRefRange когда научимся мультиселект обрабатывать (\\192.168.5.2\source\DOCUMENTS\XLSX\Matematika Quantum Sedekah.xlsx)
if (null === aCFs[i].SqRefRange) {
continue;
}
if (!range || range.intersection(aCFs[i].SqRefRange)) {
aRules = aCFs[i].aRules;
for (j = 0; j < aRules.length; ++j) {
oRule = aRules[j];
// ToDo aboveAverage, beginsWith, cellIs, containsBlanks, containsErrors,
// ToDo containsText, dataBar, duplicateValues, endsWith, expression, iconSet, notContainsBlanks,
// ToDo notContainsErrors, notContainsText, timePeriod, top10, uniqueValues (page 2679)
switch (oRule.Type) {
case Asc.ECfType.colorScale:
if (1 !== oRule.aRuleElements.length) {
break;
}
oRuleElement = oRule.aRuleElements[0];
if (!(oRuleElement instanceof Asc.CColorScale)) {
break;
}
aCFs[i].SqRefRange._setPropertyNoEmpty(null, null, function(c) {
if (CellValueType.Number === c.getType() && false === c.isEmptyTextString()) {
tmp = parseFloat(c.getValueWithoutFormat());
if (isNaN(tmp)) {
return;
aCFs[i].SqRefRange._setPropertyNoEmpty(null, null, function(c) {
if (CellValueType.Number === c.getType() && false === c.isEmptyTextString()) {
tmp = parseFloat(c.getValueWithoutFormat());
if (isNaN(tmp)) {
return;
}
arrayCells.push({cell: c, val: tmp});
min = Math.min(min, tmp);
max = Math.max(max, tmp);
}
});
// ToDo CFVO Type (formula, max, min, num, percent, percentile) (page 2681)
// ToDo support 3 colors in rule
if (0 < arrayCells.length && 2 === oRuleElement.aColors.length) {
oGradient = new Asc.CGradient(oRuleElement.aColors[0], oRuleElement.aColors[1]);
oGradient.init(min, max);
for (cell = 0; cell < arrayCells.length; ++cell) {
var dxf = new CellXfs();
dxf.fill = new Fill({bg: oGradient.calculateColor(arrayCells[cell].val)});
arrayCells[cell].cell.setConditionalFormattingStyle(dxf);
}
arrayCells.push({cell: c, val: tmp});
min = Math.min(min, tmp);
max = Math.max(max, tmp);
}
});
// ToDo CFVO Type (formula, max, min, num, percent, percentile) (page 2681)
// ToDo support 3 colors in rule
if (0 < arrayCells.length && 2 === oRuleElement.aColors.length) {
oGradient = new Asc.CGradient(oRuleElement.aColors[0], oRuleElement.aColors[1]);
oGradient.init(min, max);
for (cell = 0; cell < arrayCells.length; ++cell) {
var dxf = new CellXfs();
dxf.fill = new Fill({bg: oGradient.calculateColor(arrayCells[cell].val)});
arrayCells[cell].cell.setConditionalFormattingStyle(dxf);
}
}
arrayCells.length = 0;
min = Number.MAX_VALUE;
max = -Number.MAX_VALUE;
break;
arrayCells.length = 0;
min = Number.MAX_VALUE;
max = -Number.MAX_VALUE;
break;
}
}
}
}
......
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