[SSE] Cell fill (gradient colors)

This commit is contained in:
Julia Svinareva 2019-08-20 12:55:55 +03:00
parent e3c106cec9
commit 961ff8d2fc

View file

@ -87,7 +87,7 @@ define([
this.BorderType = 1; this.BorderType = 1;
this.GradLinearDirectionType = 0; this.GradLinearDirectionType = 0;
this.GradRadialDirectionIdx = 0; this.GradRadialDirectionIdx = 0;
this.GradColors = ['000000','ffffff']; this.GradColors = [];
this.fillControls = []; this.fillControls = [];
@ -416,6 +416,8 @@ define([
this.CellColor = {Value: 0, Color: 'transparent'}; this.CellColor = {Value: 0, Color: 'transparent'};
this.FGColor = {Value: 1, Color: '000000'}; this.FGColor = {Value: 1, Color: '000000'};
this.BGColor = {Value: 1, Color: 'ffffff'}; this.BGColor = {Value: 1, Color: 'ffffff'};
this.GradColors[0] = {Value: 1, Color: '000000', Position: 0};
this.GradColors[1] = {Value: 1, Color: 'ffffff', Position: 1};
} else if (pattern !== null) { } else if (pattern !== null) {
if(pattern.asc_getType() === Asc.c_oAscPatternType.Solid) { if(pattern.asc_getType() === Asc.c_oAscPatternType.Solid) {
var color = pattern.asc_getFgColor(); var color = pattern.asc_getFgColor();
@ -425,8 +427,10 @@ define([
this.CellColor = {Value: 1, Color: Common.Utils.ThemeColor.getHexColor(color.getR(), color.getG(), color.getB())}; this.CellColor = {Value: 1, Color: Common.Utils.ThemeColor.getHexColor(color.getR(), color.getG(), color.getB())};
} }
this.OriginalFillType = Asc.c_oAscFill.FILL_TYPE_SOLID; this.OriginalFillType = Asc.c_oAscFill.FILL_TYPE_SOLID;
this.FGColor = this.GradColor1 = {Value: 1, Color: Common.Utils.ThemeColor.colorValue2EffectId(this.CellColor.Color)}; this.FGColor = {Value: 1, Color: Common.Utils.ThemeColor.colorValue2EffectId(this.CellColor.Color)};
this.BGColor = this.GradColor2 = {Value: 1, Color: 'ffffff'}; this.BGColor = {Value: 1, Color: 'ffffff'};
this.GradColors[0] = {Value: 1, Color: Common.Utils.ThemeColor.colorValue2EffectId(this.CellColor.Color), Position: 0};
this.GradColors[1] = {Value: 1, Color: 'ffffff', Position: 1};
} else { } else {
this.PatternFillType = pattern.asc_getType(); this.PatternFillType = pattern.asc_getType();
if (this._state.PatternFillType !== this.PatternFillType) { if (this._state.PatternFillType !== this.PatternFillType) {
@ -458,8 +462,8 @@ define([
} else } else
this.BGColor = {Value: 1, Color: 'ffffff'}; this.BGColor = {Value: 1, Color: 'ffffff'};
this.CellColor = {Value: 1, Color: Common.Utils.ThemeColor.colorValue2EffectId(this.FGColor.Color)}; this.CellColor = {Value: 1, Color: Common.Utils.ThemeColor.colorValue2EffectId(this.FGColor.Color)};
this.GradColor1 = this.FGColor; this.GradColors[0] = {Value: 1, Color: Common.Utils.ThemeColor.colorValue2EffectId(this.FGColor.Color), Position: 0};
this.GradColor2 = {Value: 1, Color: 'ffffff'}; this.GradColors[1] = {Value: 1, Color: 'ffffff', Position: 1};
this.OriginalFillType = Asc.c_oAscFill.FILL_TYPE_PATT; this.OriginalFillType = Asc.c_oAscFill.FILL_TYPE_PATT;
} }
} else if (gradient !== null) { } else if (gradient !== null) {
@ -490,25 +494,26 @@ define([
} }
} }
/* var gradientColors = []; var gradientStops;
this.GradColors = []; this.GradColors = [];
//gradientColors = gradient.asc_getGradientColors(); gradientStops = gradient.asc_getGradientStops();
for(var color in gradientColors) { for(var color of gradientStops) {
var clr = color.color, var clr = color.asc_getColor(),
position = color.asc_getPosition(),
itemColor; itemColor;
if (clr.getType() == Asc.c_oAscColor.COLOR_TYPE_SCHEME) { if (clr.getType() == Asc.c_oAscColor.COLOR_TYPE_SCHEME) {
itemColor = {Value: 1, Color: {color: Common.Utils.ThemeColor.getHexColor(clr.getR(), clr.getG(), clr.getB()), effectValue: clr.asc_getValue() }}; itemColor = {Value: 1, Color: {color: Common.Utils.ThemeColor.getHexColor(clr.getR(), clr.getG(), clr.getB()), effectValue: clr.asc_getValue() }, Position: position};
} else { } else {
itemColor = {Value: 1, Color: Common.Utils.ThemeColor.getHexColor(clr.getR(), clr.getG(), clr.getB())}; itemColor = {Value: 1, Color: Common.Utils.ThemeColor.getHexColor(clr.getR(), clr.getG(), clr.getB()), Position: position};
} }
this.GradColors.push(itemColor); this.GradColors.push(itemColor);
}*/ }
this.GradColors = _.sortBy(this.GradColors, 'Position');
this.OriginalFillType = Asc.c_oAscFill.FILL_TYPE_GRAD; this.OriginalFillType = Asc.c_oAscFill.FILL_TYPE_GRAD;
this.FGColor = {Value: 1, Color: 'ffffff'}; // this.GradColors[0] this.FGColor = {Value: 1, Color: Common.Utils.ThemeColor.colorValue2EffectId(this.GradColors[0].Color)};
this.BGColor = {Value: 1, Color: 'ffffff'}; this.BGColor = {Value: 1, Color: 'ffffff'};
this.CellColor = {Value: 1, Color: 'ffffff'}; // this.GradColors[0] this.CellColor = {Value: 1, Color: Common.Utils.ThemeColor.colorValue2EffectId(this.GradColors[0].Color)};
} }
if ( this._state.FillType !== this.OriginalFillType ) { if ( this._state.FillType !== this.OriginalFillType ) {
@ -592,53 +597,61 @@ define([
} }
// Gradient colors // Gradient colors
/*type1 = typeof(this.GradColors[0].Color); var gradColor1 = this.GradColors[0];
if (!gradColor1) {
gradColor1 = {Value: 1, Color: '000000'};
}
type1 = typeof(gradColor1.Color);
type2 = typeof(this._state.GradColor1); type2 = typeof(this._state.GradColor1);
if ( (type1 !== type2) || (type1=='object' && if ( (type1 !== type2) || (type1=='object' &&
(this.GradColors[0].Color.effectValue!==this._state.GradColor1.effectValue || this._state.GradColor1.color.indexOf(this.GradColors[0].Color.color)<0)) || (gradColor1.Color.effectValue!==this._state.GradColor1.effectValue || this._state.GradColor1.color.indexOf(gradColor1.Color.color)<0)) ||
(type1!='object' && this._state.GradColor1.indexOf(this.GradColors[0].Color)<0 )) { (type1!='object' && this._state.GradColor1.indexOf(gradColor1.Color)<0 )) {
this.btnGradColor1.setColor(this.GradColors[0].Color); this.btnGradColor1.setColor(gradColor1.Color);
if ( typeof(this.GradColors[0].Color) == 'object' ) { if ( typeof(gradColor1.Color) == 'object' ) {
var isselected = false; var isselected = false;
for (var i=0; i<10; i++) { for (var i=0; i<10; i++) {
if ( Common.Utils.ThemeColor.ThemeValues[i] == this.GradColors[0].Color.effectValue ) { if ( Common.Utils.ThemeColor.ThemeValues[i] == gradColor1.Color.effectValue ) {
this.colorsGrad1.select(this.GradColors[0].Color,true); this.colorsGrad1.select(gradColor1.Color,true);
isselected = true; isselected = true;
break; break;
} }
} }
if (!isselected) this.colorsGrad1.clearSelection(); if (!isselected) this.colorsGrad1.clearSelection();
} else } else
this.colorsGrad1.select(this.GradColors[0].Color,true); this.colorsGrad1.select(gradColor1.Color,true);
this._state.GradColor1 = this.GradColors[0].Color; this._state.GradColor1 = gradColor1.Color;
} }
type1 = typeof(this.GradColors[1].Color); var gradColor2 = this.GradColors[1];
if (!gradColor2) {
gradColor2 = {Value: 1, Color: 'ffffff'};
}
type1 = typeof(gradColor2.Color);
type2 = typeof(this._state.GradColor2); type2 = typeof(this._state.GradColor2);
if ( (type1 !== type2) || (type1=='object' && if ( (type1 !== type2) || (type1=='object' &&
(this.GradColors[1].Color.effectValue!==this._state.GradColor2.effectValue || this._state.GradColor2.color.indexOf(this.GradColors[1].Color.color)<0)) || (gradColor2.Color.effectValue!==this._state.GradColor2.effectValue || this._state.GradColor2.color.indexOf(gradColor2.Color.color)<0)) ||
(type1!='object' && this._state.GradColor2.indexOf(this.GradColors[1].Color)<0 )) { (type1!='object' && this._state.GradColor2.indexOf(gradColor2.Color)<0 )) {
this.btnGradColor1.setColor(this.GradColors[1].Color); this.btnGradColor2.setColor(gradColor2.Color);
if ( typeof(this.GradColors[1].Color) == 'object' ) { if ( typeof(gradColor2.Color) == 'object' ) {
var isselected = false; var isselected = false;
for (var i=0; i<10; i++) { for (var i=0; i<10; i++) {
if ( Common.Utils.ThemeColor.ThemeValues[i] == this.GradColors[1].Color.effectValue ) { if ( Common.Utils.ThemeColor.ThemeValues[i] == gradColor2.Color.effectValue ) {
this.colorsGrad2.select(this.GradColors[1].Color,true); this.colorsGrad2.select(gradColor2.Color,true);
isselected = true; isselected = true;
break; break;
} }
} }
if (!isselected) this.colorsGrad2.clearSelection(); if (!isselected) this.colorsGrad2.clearSelection();
} else } else
this.colorsGrad2.select(this.GradColors[1].Color,true); this.colorsGrad2.select(gradColor2.Color,true);
this._state.GradColor2 = this.GradColors[1].Color; this._state.GradColor2 = gradColor2.Color;
}*/ }
this._noApply = false; this._noApply = false;
} }