Commit ca9eb521 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@68277 954022d7-b5bf-4e40-9824-e11837661b57
parent 457be833
...@@ -3273,10 +3273,72 @@ Woorksheet.prototype.initPostOpen = function(handlers){ ...@@ -3273,10 +3273,72 @@ Woorksheet.prototype.initPostOpen = function(handlers){
this.sheetViews[j].pane = null; this.sheetViews[j].pane = null;
} }
} }
this._initConditionalFormatting();
this.handlers = handlers; this.handlers = handlers;
this._setHandlersTablePart(); this._setHandlersTablePart();
}; };
Woorksheet.prototype._initConditionalFormatting = function() {
var oGradient = null;
var aCFs = this.aConditionalFormatting;
var aRules, oRule;
var oRuleElement = null;
var min = Number.MAX_VALUE;
var max = -Number.MAX_VALUE;
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;
}
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.length = 0;
min = Number.MAX_VALUE;
max = -Number.MAX_VALUE;
break;
}
}
}
};
Woorksheet.prototype._forEachCell=function(fAction){ Woorksheet.prototype._forEachCell=function(fAction){
for(var rowInd in this.aGCells){ for(var rowInd in this.aGCells){
var row = this.aGCells[rowInd]; var row = this.aGCells[rowInd];
......
...@@ -1124,7 +1124,6 @@ ...@@ -1124,7 +1124,6 @@
this._initPane(); this._initPane();
this._initCellsArea( true ); this._initCellsArea( true );
this.autoFilters.addFiltersAfterOpen(); this.autoFilters.addFiltersAfterOpen();
this._initConditionalFormatting();
this._cleanCellsTextMetricsCache(); this._cleanCellsTextMetricsCache();
this._prepareCellTextMetricsCache(); this._prepareCellTextMetricsCache();
...@@ -1132,69 +1131,6 @@ ...@@ -1132,69 +1131,6 @@
this.handlers.trigger( "initialized" ); this.handlers.trigger( "initialized" );
}; };
WorksheetView.prototype._initConditionalFormatting = function () {
var oGradient = null;
var aCFs = this.model.aConditionalFormatting;
var aRules, oRule;
var oRuleElement = null;
var min = Number.MAX_VALUE;
var max = -Number.MAX_VALUE;
var tmp;
var arrayCells = [];
for ( var i in aCFs ) {
aRules = aCFs[i].aRules;
if ( 0 >= aRules.length ) {
continue;
}
for ( var j in aRules ) {
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;
}
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 ( var cell in arrayCells ) {
var dxf = new CellXfs();
dxf.fill = new Fill( {bg: oGradient.calculateColor( arrayCells[cell].val )} );
arrayCells[cell].cell.setConditionalFormattingStyle( dxf );
}
}
arrayCells.splice( 0, arrayCells.length );
min = Number.MAX_VALUE;
max = -Number.MAX_VALUE;
break;
}
}
}
};
WorksheetView.prototype._prepareComments = function () { WorksheetView.prototype._prepareComments = function () {
// Теперь получение всех комментариев через asc_getWorkbookComments // Теперь получение всех комментариев через asc_getWorkbookComments
var commentList = this.cellCommentator.prepareComments( this.model.aComments ); var commentList = this.cellCommentator.prepareComments( this.model.aComments );
......
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