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

update conditionalFormatting after change cell value

parent 5f5a28be
......@@ -15,50 +15,41 @@
* @memberOf Asc
*/
function CConditionalFormatting () {
if ( !(this instanceof CConditionalFormatting) ) {
return new CConditionalFormatting ();
}
this.Pivot = false;
this.SqRef = null;
this.pivot = false;
this.sqref = null;
this.aRules = [];
this.SqRefRange = null;
return this;
}
CConditionalFormatting.prototype.clone = function(ws) {
CConditionalFormatting.prototype.setSqref = function(sqref) {
this.sqref = AscCommonExcel.g_oRangeCache.getAscRange(sqref);
};
CConditionalFormatting.prototype.clone = function() {
var i, res = new CConditionalFormatting();
res.Pivot = this.Pivot;
res.SqRef = this.SqRef;
res.pivot = this.pivot;
res.sqref = this.sqref ? this.sqref.clone() : null;
for (i = 0; i < this.aRules.length; ++i)
res.aRules.push(this.aRules[i].clone());
res.recalc(ws);
return res;
};
CConditionalFormatting.prototype.recalc = function(ws) {
this.SqRefRange = ws.getRange2(this.SqRef);
};
function CConditionalFormattingRule () {
if ( !(this instanceof CConditionalFormattingRule) ) {
return new CConditionalFormattingRule ();
}
this.AboveAverage = true;
this.Bottom = false;
this.aboveAverage = true;
this.activePresent = false;
this.bottom = false;
this.dxf = null;
this.EqualAverage = false;
this.Operator = null;
this.Percent = false;
this.Priority = null;
this.Rank = null;
this.StdDev = null;
this.StopIfTrue = false;
this.Text = null;
this.TimePeriod = null;
this.Type = null;
this.equalAverage = false;
this.id = null;
this.operator = null;
this.percent = false;
this.priority = null;
this.rank = null;
this.stdDev = null;
this.stopIfTrue = false;
this.text = null;
this.timePeriod = null;
this.type = null;
this.aRuleElements = [];
......@@ -66,20 +57,20 @@
}
CConditionalFormattingRule.prototype.clone = function() {
var i, res = new CConditionalFormattingRule();
res.AboveAverage = this.AboveAverage;
res.Bottom = this.Bottom;
res.aboveAverage = this.aboveAverage;
res.bottom = this.bottom;
if (this.dxf)
res.dxf = this.dxf.clone();
res.EqualAverage = this.EqualAverage;
res.Operator = this.Operator;
res.Percent = this.Percent;
res.Priority = this.Priority;
res.Rank = this.Rank;
res.StdDev = this.StdDev;
res.StopIfTrue = this.StopIfTrue;
res.Text = this.Text;
res.TimePeriod = this.TimePeriod;
res.Type = this.Type;
res.equalAverage = this.equalAverage;
res.operator = this.operator;
res.percent = this.percent;
res.priority = this.priority;
res.rank = this.rank;
res.stdDev = this.stdDev;
res.stopIfTrue = this.stopIfTrue;
res.text = this.text;
res.timePeriod = this.timePeriod;
res.type = this.type;
for (i = 0; i < this.aRuleElements.length; ++i)
res.aRuleElements.push(this.aRuleElements[i].clone());
......@@ -87,10 +78,6 @@
};
function CColorScale () {
if ( !(this instanceof CColorScale) ) {
return new CColorScale ();
}
this.aCFVOs = [];
this.aColors = [];
......@@ -106,10 +93,6 @@
};
function CDataBar () {
if ( !(this instanceof CDataBar) ) {
return new CDataBar ();
}
this.MaxLength = 90;
this.MinLength = 10;
this.ShowValue = true;
......@@ -132,10 +115,6 @@
};
function CFormulaCF () {
if ( !(this instanceof CFormulaCF) ) {
return new CFormulaCF ();
}
this.Text = null;
return this;
......@@ -147,9 +126,6 @@
};
function CIconSet () {
if ( !(this instanceof CIconSet) ) {
return new CIconSet ();
}
this.IconSet = Asc.EIconSetType.Traffic3Lights1;
this.Percent = true;
this.Reverse = false;
......@@ -171,10 +147,6 @@
};
function CConditionalFormatValueObject () {
if ( !(this instanceof CConditionalFormatValueObject) ) {
return new CConditionalFormatValueObject ();
}
this.Gte = true;
this.Type = null;
this.Val = null;
......
......@@ -5575,7 +5575,6 @@
res = this.bcr.Read1(length, function (t, l) {
return oThis.ReadConditionalFormatting(t, l, oConditionalFormatting);
});
oConditionalFormatting.recalc(oWorksheet);
oWorksheet.aConditionalFormatting.push(oConditionalFormatting);
} else if (c_oSerWorksheetsTypes.SheetViews === type) {
res = this.bcr.Read1(length, function (t, l) {
......@@ -6297,9 +6296,9 @@
var oThis = this;
var oConditionalFormattingRule = null;
if (c_oSer_ConditionalFormatting.Pivot === type)
oConditionalFormatting.Pivot = this.stream.GetBool();
oConditionalFormatting.pivot = this.stream.GetBool();
else if (c_oSer_ConditionalFormatting.SqRef === type) {
oConditionalFormatting.SqRef = this.stream.GetString2LE(length);
oConditionalFormatting.setSqref(this.stream.GetString2LE(length));
}
else if (c_oSer_ConditionalFormatting.ConditionalFormattingRule === type) {
oConditionalFormattingRule = new AscCommonExcel.CConditionalFormattingRule();
......@@ -6318,34 +6317,34 @@
var oConditionalFormattingRuleElement = null;
if (c_oSer_ConditionalFormattingRule.AboveAverage === type)
oConditionalFormattingRule.AboveAverage = this.stream.GetBool();
oConditionalFormattingRule.aboveAverage = this.stream.GetBool();
else if (c_oSer_ConditionalFormattingRule.Bottom === type)
oConditionalFormattingRule.Bottom = this.stream.GetBool();
oConditionalFormattingRule.bottom = this.stream.GetBool();
else if (c_oSer_ConditionalFormattingRule.DxfId === type)
{
var DxfId = this.stream.GetULongLE();
oConditionalFormattingRule.dxf = this.Dxfs[DxfId];
}
else if (c_oSer_ConditionalFormattingRule.EqualAverage === type)
oConditionalFormattingRule.EqualAverage = this.stream.GetBool();
oConditionalFormattingRule.equalAverage = this.stream.GetBool();
else if (c_oSer_ConditionalFormattingRule.Operator === type)
oConditionalFormattingRule.Operator = this.stream.GetUChar();
oConditionalFormattingRule.operator = this.stream.GetUChar();
else if (c_oSer_ConditionalFormattingRule.Percent === type)
oConditionalFormattingRule.Percent = this.stream.GetBool();
oConditionalFormattingRule.percent = this.stream.GetBool();
else if (c_oSer_ConditionalFormattingRule.Priority === type)
oConditionalFormattingRule.Priority = this.stream.GetULongLE();
oConditionalFormattingRule.priority = this.stream.GetULongLE();
else if (c_oSer_ConditionalFormattingRule.Rank === type)
oConditionalFormattingRule.Rank = this.stream.GetULongLE();
oConditionalFormattingRule.rank = this.stream.GetULongLE();
else if (c_oSer_ConditionalFormattingRule.StdDev === type)
oConditionalFormattingRule.StdDev = this.stream.GetULongLE();
oConditionalFormattingRule.stdDev = this.stream.GetULongLE();
else if (c_oSer_ConditionalFormattingRule.StopIfTrue === type)
oConditionalFormattingRule.StopIfTrue = this.stream.GetBool();
oConditionalFormattingRule.stopIfTrue = this.stream.GetBool();
else if (c_oSer_ConditionalFormattingRule.Text === type)
oConditionalFormattingRule.Text = this.stream.GetString2LE(length);
oConditionalFormattingRule.text = this.stream.GetString2LE(length);
else if (c_oSer_ConditionalFormattingRule.TimePeriod === type)
oConditionalFormattingRule.TimePeriod = this.stream.GetString2LE(length);
oConditionalFormattingRule.timePeriod = this.stream.GetString2LE(length);
else if (c_oSer_ConditionalFormattingRule.Type === type)
oConditionalFormattingRule.Type = this.stream.GetUChar();
oConditionalFormattingRule.type = this.stream.GetUChar();
else if (c_oSer_ConditionalFormattingRule.ColorScale === type) {
oConditionalFormattingRuleElement = new AscCommonExcel.CColorScale();
res = this.bcr.Read1(length, function (t, l) {
......
......@@ -3350,7 +3350,7 @@ Woorksheet.prototype.clone=function(sNewId, sName){
oNewWs.sheetViews.push(this.sheetViews[i].clone());
}
for (i = 0; i < this.aConditionalFormatting.length; ++i) {
oNewWs.aConditionalFormatting.push(this.aConditionalFormatting[i].clone(oNewWs));
oNewWs.aConditionalFormatting.push(this.aConditionalFormatting[i].clone());
}
if (this.sheetPr)
oNewWs.sheetPr = this.sheetPr.clone();
......@@ -3480,20 +3480,21 @@ Woorksheet.prototype._updateConditionalFormatting = function(range) {
var min = Number.MAX_VALUE;
var max = -Number.MAX_VALUE;
var arrayCells = [];
var tmp, i, j, cell;
var tmp, i, j, cell, sqref;
for (i = 0; i < aCFs.length; ++i) {
// ToDo убрать null === aCFs[i].SqRefRange когда научимся мультиселект обрабатывать (\\192.168.5.2\source\DOCUMENTS\XLSX\Matematika Quantum Sedekah.xlsx)
if (null === aCFs[i].SqRefRange) {
sqref = aCFs[i].sqref;
// ToDo убрать null === sqref когда научимся мультиселект обрабатывать (\\192.168.5.2\source\DOCUMENTS\XLSX\Matematika Quantum Sedekah.xlsx)
if (null === sqref) {
continue;
}
if (!range || range.intersection(aCFs[i].SqRefRange)) {
if (!range || range.isIntersect(sqref)) {
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) {
switch (oRule.type) {
case Asc.ECfType.colorScale:
if (1 !== oRule.aRuleElements.length) {
break;
......@@ -3503,7 +3504,7 @@ Woorksheet.prototype._updateConditionalFormatting = function(range) {
break;
}
aCFs[i].SqRefRange._setPropertyNoEmpty(null, null, function(c) {
this.getRange3(sqref.r1, sqref.c1, sqref.r2, sqref.c2)._setPropertyNoEmpty(null, null, function(c) {
if (CellValueType.Number === c.getType() && false === c.isEmptyTextString()) {
tmp = parseFloat(c.getValueWithoutFormat());
if (isNaN(tmp)) {
......@@ -5369,6 +5370,7 @@ Woorksheet.prototype.createTablePart = function(){
};
Woorksheet.prototype.onUpdateRanges = function(ranges) {
this.workbook.updateSparklineCache(this.sName, ranges);
this._updateConditionalFormatting(new AscCommonExcel.MultiplyRange(ranges));
};
Woorksheet.prototype.updateSparklineCache = function(sheet, ranges) {
for (var i = 0; i < this.sparklineGroups.arrSparklineGroup.length; ++i) {
......
......@@ -699,6 +699,18 @@
return sRes;
};
function MultiplyRange(ranges) {
this.ranges = ranges;
}
MultiplyRange.prototype.isIntersect = function(range) {
for (var i = 0; i < this.ranges.length; ++i) {
if (range.isIntersect(this.ranges[i])) {
return true;
}
}
return false;
};
function VisibleRange(visibleRange, offsetX, offsetY) {
this.visibleRange = visibleRange;
this.offsetX = offsetX;
......@@ -1607,6 +1619,7 @@
window["AscCommonExcel"].Range3D = Range3D;
window["AscCommonExcel"].ActiveRange = ActiveRange;
window["AscCommonExcel"].FormulaRange = FormulaRange;
window["AscCommonExcel"].MultiplyRange = MultiplyRange;
window["AscCommonExcel"].VisibleRange = VisibleRange;
window["AscCommonExcel"].g_oRangeCache = g_oRangeCache;
......
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