Commit 0e04bf2a authored by Alexander.Trofimov's avatar Alexander.Trofimov

support endsWith and beginsWith in conditional formatting

parent a6db9cd2
......@@ -939,7 +939,8 @@
notContainsText: 13,
timePeriod: 14,
top10: 15,
uniqueValues: 16
uniqueValues: 16,
endsWith: 17
};
/** @enum */
var EIconSetType =
......
......@@ -3496,7 +3496,7 @@ Woorksheet.prototype._updateConditionalFormatting = function(range) {
var aRules, oRule;
var oRuleElement = null;
var o;
var i, j, cell, sqref, values, tmp, min, max, dxf, condition;
var i, j, cell, sqref, values, tmp, min, max, dxf, compareFunction;
for (i = 0; i < aCFs.length; ++i) {
sqref = aCFs[i].sqref;
// ToDo убрать null === sqref когда научимся мультиселект обрабатывать (\\192.168.5.2\source\DOCUMENTS\XLSX\Matematika Quantum Sedekah.xlsx)
......@@ -3511,8 +3511,7 @@ Woorksheet.prototype._updateConditionalFormatting = function(range) {
// ToDo aboveAverage, beginsWith, cellIs, containsBlanks, containsErrors,
// ToDo dataBar, endsWith, expression, iconSet, notContainsBlanks,
// ToDo notContainsErrors, timePeriod, top10 (page 2679)
switch (oRule.type) {
case Asc.ECfType.colorScale:
if (Asc.ECfType.colorScale === oRule.type) {
if (1 !== oRule.aRuleElements.length) {
break;
}
......@@ -3548,28 +3547,59 @@ Woorksheet.prototype._updateConditionalFormatting = function(range) {
values.c[cell].setConditionalFormattingStyle(dxf);
}
}
break;
} else {
if (!oRule.dxf) {
continue;
}
values = this._getValuesForConditionalFormatting(sqref);
switch (oRule.type) {
case Asc.ECfType.duplicateValues:
case Asc.ECfType.uniqueValues:
if (oRule.dxf) {
condition = oRule.type === Asc.ECfType.uniqueValues;
values = this._getValuesForConditionalFormatting(sqref);
o = getUniqueKeys(values.v);
for (cell = 0; cell < values.c.length; ++cell) {
values.c[cell].setConditionalFormattingStyle((condition === o[values.v[cell]]) ? null : oRule.dxf);
}
}
compareFunction = (function(obj, condition){
return function(val) {
return condition === obj[val];
};
})(o, oRule.type === Asc.ECfType.duplicateValues);
break;
case Asc.ECfType.containsText:
compareFunction = (function(text){
return function(val) {
return -1 !== val.indexOf(text);
};
})(oRule.text);
break;
case Asc.ECfType.notContainsText:
if (oRule.dxf) {
condition = oRule.type === Asc.ECfType.containsText;
values = this._getValuesForConditionalFormatting(sqref);
for (cell = 0; cell < values.c.length; ++cell) {
values.c[cell].setConditionalFormattingStyle((condition === (-1 === values.v[cell].indexOf(oRule.text))) ? null : oRule.dxf);
compareFunction = (function(text){
return function(val) {
return -1 === val.indexOf(text);
};
})(oRule.text);
break;
case Asc.ECfType.beginsWith:
compareFunction = (function(text){
return function(val) {
return val.startsWith(text);
};
})(oRule.text);
break;
case Asc.ECfType.endsWith:
compareFunction = (function(text){
return function(val) {
return val.endsWith(text);
};
})(oRule.text);
break;
default:
continue;
break;
}
for (cell = 0; cell < values.c.length; ++cell) {
values.c[cell].setConditionalFormattingStyle(compareFunction(values.v[cell]) ? oRule.dxf : null);
}
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