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

update conditionalFormatting after change cell value

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