[SSE] Cell fill

This commit is contained in:
Julia Svinareva 2019-09-11 11:40:24 +03:00
parent f8e78fc48f
commit 48ed19b119

View file

@ -409,19 +409,19 @@ define([
this.spnAngle.setValue((value !== null) ? value : '', true); this.spnAngle.setValue((value !== null) ? value : '', true);
this._state.CellAngle=value; this._state.CellAngle=value;
} }
var fill = props.asc_getFill2(), this.fill = props.asc_getFill2();
pattern = fill.asc_getPatternFill(), this.pattern = this.fill.asc_getPatternFill();
gradient = fill.asc_getGradientFill(); this.gradient = this.fill.asc_getGradientFill();
if (pattern === null && gradient === null) { if (this.pattern === null && this.gradient === null) {
this.OriginalFillType = Asc.c_oAscFill.FILL_TYPE_NOFILL; this.OriginalFillType = Asc.c_oAscFill.FILL_TYPE_NOFILL;
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[0] = {Value: 1, Color: '000000', Position: 0};
this.GradColors[1] = {Value: 1, Color: 'ffffff', Position: 1}; this.GradColors[1] = {Value: 1, Color: 'ffffff', Position: 1};
} else if (pattern !== null) { } else if (this.pattern !== null) {
if(pattern.asc_getType() === -1) { if(this.pattern.asc_getType() === -1) {
var color = pattern.asc_getFgColor(); var color = this.pattern.asc_getFgColor();
if (color.getType() == Asc.c_oAscColor.COLOR_TYPE_SCHEME) { if (color.getType() == Asc.c_oAscColor.COLOR_TYPE_SCHEME) {
this.CellColor = {Value: 1, Color: {color: Common.Utils.ThemeColor.getHexColor(color.getR(), color.getG(), color.getB()), effectValue: color.get_value() }}; this.CellColor = {Value: 1, Color: {color: Common.Utils.ThemeColor.getHexColor(color.getR(), color.getG(), color.getB()), effectValue: color.get_value() }};
} else { } else {
@ -433,7 +433,7 @@ define([
this.GradColors[0] = {Value: 1, Color: Common.Utils.ThemeColor.colorValue2EffectId(this.CellColor.Color), Position: 0}; this.GradColors[0] = {Value: 1, Color: Common.Utils.ThemeColor.colorValue2EffectId(this.CellColor.Color), Position: 0};
this.GradColors[1] = {Value: 1, Color: 'ffffff', Position: 1}; this.GradColors[1] = {Value: 1, Color: 'ffffff', Position: 1};
} else { } else {
this.PatternFillType = pattern.asc_getType(); this.PatternFillType = this.pattern.asc_getType();
if (this._state.PatternFillType !== this.PatternFillType) { if (this._state.PatternFillType !== this.PatternFillType) {
this.cmbPattern.suspendEvents(); this.cmbPattern.suspendEvents();
var rec = this.cmbPattern.menuPicker.store.findWhere({ var rec = this.cmbPattern.menuPicker.store.findWhere({
@ -443,7 +443,7 @@ define([
this.cmbPattern.resumeEvents(); this.cmbPattern.resumeEvents();
this._state.PatternFillType = this.PatternFillType; this._state.PatternFillType = this.PatternFillType;
} }
var color = pattern.asc_getFgColor(); var color = this.pattern.asc_getFgColor();
if (color) { if (color) {
if (color.getType() == Asc.c_oAscColor.COLOR_TYPE_SCHEME) { if (color.getType() == Asc.c_oAscColor.COLOR_TYPE_SCHEME) {
this.FGColor = {Value: 1, Color: {color: Common.Utils.ThemeColor.getHexColor(color.getR(), color.getG(), color.getB()), effectValue: color.asc_getValue() }}; this.FGColor = {Value: 1, Color: {color: Common.Utils.ThemeColor.getHexColor(color.getR(), color.getG(), color.getB()), effectValue: color.asc_getValue() }};
@ -453,7 +453,7 @@ define([
} else } else
this.FGColor = {Value: 1, Color: '000000'}; this.FGColor = {Value: 1, Color: '000000'};
color = pattern.asc_getBgColor(); color = this.pattern.asc_getBgColor();
if (color) { if (color) {
if (color.getType() == Asc.c_oAscColor.COLOR_TYPE_SCHEME) { if (color.getType() == Asc.c_oAscColor.COLOR_TYPE_SCHEME) {
this.BGColor = {Value: 1, Color: {color: Common.Utils.ThemeColor.getHexColor(color.getR(), color.getG(), color.getB()), effectValue: color.asc_getValue() }}; this.BGColor = {Value: 1, Color: {color: Common.Utils.ThemeColor.getHexColor(color.getR(), color.getG(), color.getB()), effectValue: color.asc_getValue() }};
@ -467,8 +467,8 @@ define([
this.GradColors[1] = {Value: 1, Color: 'ffffff', Position: 1}; 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 (this.gradient !== null) {
var gradFillType = gradient.asc_getType(); var gradFillType = this.gradient.asc_getType();
if (this._state.GradFillType !== gradFillType || this.GradFillType !== gradFillType) { if (this._state.GradFillType !== gradFillType || this.GradFillType !== gradFillType) {
this.GradFillType = gradFillType; this.GradFillType = gradFillType;
rec = undefined; rec = undefined;
@ -483,7 +483,7 @@ define([
this._state.GradFillType = this.GradFillType; this._state.GradFillType = this.GradFillType;
} }
if (this.GradFillType == Asc.c_oAscFillGradType.GRAD_LINEAR) { if (this.GradFillType == Asc.c_oAscFillGradType.GRAD_LINEAR) {
var value = gradient.asc_getDegree(); var value = this.gradient.asc_getDegree();
if (Math.abs(this.GradLinearDirectionType-value)>0.001) { if (Math.abs(this.GradLinearDirectionType-value)>0.001) {
this.GradLinearDirectionType=value; this.GradLinearDirectionType=value;
var record = this.mnuDirectionPicker.store.findWhere({type: value}); var record = this.mnuDirectionPicker.store.findWhere({type: value});
@ -496,8 +496,8 @@ define([
} }
var gradientStops; var gradientStops;
this.GradColors = []; this.GradColors.length = 0;
gradientStops = gradient.asc_getGradientStops(); gradientStops = this.gradient.asc_getGradientStops();
gradientStops.forEach(function (color) { gradientStops.forEach(function (color) {
var clr = color.asc_getColor(), var clr = color.asc_getColor(),
position = color.asc_getPosition(), position = color.asc_getPosition(),
@ -805,24 +805,28 @@ define([
}, },
onFillSrcSelect: function(combo, record) { onFillSrcSelect: function(combo, record) {
var me = this;
this.ShowHideElem(record.value); this.ShowHideElem(record.value);
switch (record.value){ switch (record.value){
case Asc.c_oAscFill.FILL_TYPE_SOLID: case Asc.c_oAscFill.FILL_TYPE_SOLID:
this._state.FillType = Asc.c_oAscFill.FILL_TYPE_SOLID; this._state.FillType = Asc.c_oAscFill.FILL_TYPE_SOLID;
if (!this._noApply) { if (!this._noApply) {
var pattern = new Asc.asc_CPatternFill(); if (this.pattern == null)
pattern.asc_setFgColor(Common.Utils.ThemeColor.getRgbColor((this.CellColor.Color=='transparent') ? {color: '4f81bd', effectId: 24} : this.CellColor.Color)); this.pattern = new Asc.asc_CPatternFill();
//this.propsFill.asc_putPatternFill(pattern); this.pattern.asc_setType(-1);
//this.api.asc_setGraphicObjectProps(this.propsFill); this.pattern.asc_setFgColor(Common.Utils.ThemeColor.getRgbColor((this.CellColor.Color=='transparent') ? {color: '4f81bd', effectId: 24} : this.CellColor.Color));
this.fill.asc_setPatternFill(this.pattern);
this.api.asc_setCellFill(this.fill);
} }
break; break;
case Asc.c_oAscFill.FILL_TYPE_GRAD: case Asc.c_oAscFill.FILL_TYPE_GRAD:
this._state.FillType = Asc.c_oAscFill.FILL_TYPE_GRAD; this._state.FillType = Asc.c_oAscFill.FILL_TYPE_GRAD;
if (!this._noApply) { if (!this._noApply) {
var gradient = new Asc.asc_CGradientFill(); if (this.gradient == null)
gradient.asc_setType(this.GradFillType); this.gradient = new Asc.asc_CGradientFill();
this.gradient.asc_setType(this.GradFillType);
if (this.GradFillType == Asc.c_oAscFillGradType.GRAD_LINEAR) { if (this.GradFillType == Asc.c_oAscFillGradType.GRAD_LINEAR) {
gradient.asc_setDegree(this.GradLinearDirectionType); this.gradient.asc_setDegree(this.GradLinearDirectionType);
} }
if (this.OriginalFillType !== Asc.c_oAscFill.FILL_TYPE_GRAD) { if (this.OriginalFillType !== Asc.c_oAscFill.FILL_TYPE_GRAD) {
var HexColor0 = Common.Utils.ThemeColor.getRgbColor(this.GradColors[0].Color).get_color().get_hex(), var HexColor0 = Common.Utils.ThemeColor.getRgbColor(this.GradColors[0].Color).get_color().get_hex(),
@ -836,18 +840,16 @@ define([
var gradientStop = new Asc.asc_CGradientStop(); var gradientStop = new Asc.asc_CGradientStop();
gradientStop.asc_setColor(Common.Utils.ThemeColor.getRgbColor(item.Color)); gradientStop.asc_setColor(Common.Utils.ThemeColor.getRgbColor(item.Color));
gradientStop.asc_setPosition(item.Position); gradientStop.asc_setPosition(item.Position);
gradient.asc_addGradientStop(gradientStop); me.gradient.asc_addGradientStop(gradientStop);
}); });
} }
//this.propsFill.asc_putGradientFill(gradient); this.fill.asc_setGradientFill(this.gradient);
//this.api.asc_setGraphicObjectProps(this.propsFill); this.api.asc_setCellFill(this.fill);
} }
break; break;
case Asc.c_oAscFill.FILL_TYPE_PATT: case Asc.c_oAscFill.FILL_TYPE_PATT:
this._state.FillType = Asc.c_oAscFill.FILL_TYPE_PATT; this._state.FillType = Asc.c_oAscFill.FILL_TYPE_PATT;
if (!this._noApply) { if (!this._noApply) {
var pattern = new Asc.asc_CPatternFill();
var fHexColor = Common.Utils.ThemeColor.getRgbColor(this.FGColor.Color).get_color().get_hex(); var fHexColor = Common.Utils.ThemeColor.getRgbColor(this.FGColor.Color).get_color().get_hex();
var bHexColor = Common.Utils.ThemeColor.getRgbColor(this.BGColor.Color).get_color().get_hex(); var bHexColor = Common.Utils.ThemeColor.getRgbColor(this.BGColor.Color).get_color().get_hex();
@ -856,18 +858,21 @@ define([
} else { } else {
fHexColor = this.FGColor.Color; fHexColor = this.FGColor.Color;
} }
pattern.asc_setFgColor(Common.Utils.ThemeColor.getRgbColor(fHexColor)); if (this.pattern == null)
pattern.asc_setBgColor(Common.Utils.ThemeColor.getRgbColor(this.BGColor.Color)); this.pattern = new Asc.asc_CPatternFill();
//this.propsFill.asc_putPatternFill(pattern); this.pattern.asc_setType(this.PatternFillType);
//this.api.asc_setGraphicObjectProps(this.propsFill); this.pattern.asc_setFgColor(Common.Utils.ThemeColor.getRgbColor(fHexColor));
this.pattern.asc_setBgColor(Common.Utils.ThemeColor.getRgbColor(this.BGColor.Color));
this.fill.asc_setPatternFill(this.pattern);
this.api.asc_setCellFill(this.fill);
} }
break; break;
case Asc.c_oAscFill.FILL_TYPE_NOFILL: case Asc.c_oAscFill.FILL_TYPE_NOFILL:
this._state.FillType = Asc.c_oAscFill.FILL_TYPE_NOFILL; this._state.FillType = Asc.c_oAscFill.FILL_TYPE_NOFILL;
if (!this._noApply) { if (!this._noApply) {
//this.propsFill.asc_putPatternFill(null); this.fill.asc_setPatternFill(null);
//this.propsFill.asc_putGradientFill(null); this.fill.asc_setGradientFill(null);
//this.api.asc_setGraphicObjectProps(this.propsFill); this.api.asc_setCellFill(this.fill);
} }
break; break;
} }
@ -905,19 +910,31 @@ define([
} }
if (this.api && !this._noApply) { if (this.api && !this._noApply) {
var gradient = new Asc.asc_CGradientFill(); if (this.gradient == null) {
this.gradient = new Asc.asc_CGradientFill();
if (this.GradFillType == Asc.c_oAscFillGradType.GRAD_LINEAR) { if (this.GradFillType == Asc.c_oAscFillGradType.GRAD_LINEAR) {
gradient.asc_setDegree(this.GradLinearDirectionType); this.gradient.asc_setDegree(this.GradLinearDirectionType);
} }
gradient.asc_setType(this.GradFillType); this.GradColors.forEach(function (item) {
//this.propsFill.asc_putGradientFill(gradient); var gradientStop = new Asc.asc_CGradientStop();
//this.api.asc_setGraphicObjectProps(this.propsFill); gradientStop.asc_setColor(Common.Utils.ThemeColor.getRgbColor(item.Color));
gradientStop.asc_setPosition(item.Position);
me.gradient.asc_addGradientStop(gradientStop);
});
}
if (this.GradFillType == Asc.c_oAscFillGradType.GRAD_LINEAR) {
this.gradient.asc_setDegree(this.GradLinearDirectionType);
}
this.gradient.asc_setType(this.GradFillType);
this.fill.asc_setGradientFill(this.gradient);
this.api.asc_setCellFill(this.fill);
} }
Common.NotificationCenter.trigger('edit:complete', this); Common.NotificationCenter.trigger('edit:complete', this);
}, },
onSelectGradient: function(btn, picker, itemView, record) { onSelectGradient: function(btn, picker, itemView, record) {
var me = this;
if (this._noApply) return; if (this._noApply) return;
var rawData = {}, var rawData = {},
@ -939,11 +956,19 @@ define([
if (this.api) { if (this.api) {
if (this.GradFillType == Asc.c_oAscFillGradType.GRAD_LINEAR) { if (this.GradFillType == Asc.c_oAscFillGradType.GRAD_LINEAR) {
var gradient = new Asc.asc_CGradientFill(); if (this.gradient == null) {
gradient.asc_setDegree(rawData.type); this.gradient = new Asc.asc_CGradientFill();
this.gradient.asc_setType(this.GradFillType);
//this.propsFill.asc_putGradientFill(gradient); this.GradColors.forEach(function (item) {
//this.api.asc_setGraphicObjectProps(this.propsFill); var gradientStop = new Asc.asc_CGradientStop();
gradientStop.asc_setColor(Common.Utils.ThemeColor.getRgbColor(item.Color));
gradientStop.asc_setPosition(item.Position);
me.gradient.asc_addGradientStop(gradientStop);
});
}
this.gradient.asc_setDegree(rawData.type);
this.fill.asc_setGradientFill(this.gradient);
this.api.asc_setCellFill(this.fill);
} }
} }
@ -951,7 +976,8 @@ define([
}, },
onColorsGradientSelect: function(picker, color) { onColorsGradientSelect: function(picker, color) {
var pickerId = picker.el.id; var me = this,
pickerId = picker.el.id;
if (pickerId === "cell-gradient-color1-menu") { if (pickerId === "cell-gradient-color1-menu") {
this.btnGradColor1.setColor(color); this.btnGradColor1.setColor(color);
this.GradColors[0].Color = color; this.GradColors[0].Color = color;
@ -961,22 +987,22 @@ define([
} }
if (this.api && !this._noApply) { if (this.api && !this._noApply) {
var gradient = new Asc.asc_CGradientFill(); if (this.gradient == null) {
if (this.OriginalFillType !== Asc.c_oAscFill.FILL_TYPE_GRAD) { this.gradient = new Asc.asc_CGradientFill();
gradient.asc_setType(this.GradFillType); this.gradient.asc_setType(this.GradFillType);
if (this.GradFillType == Asc.c_oAscFillGradType.GRAD_LINEAR) { if (this.GradFillType == Asc.c_oAscFillGradType.GRAD_LINEAR) {
gradient.asc_setDegree(this.GradLinearDirectionType); this.gradient.asc_setDegree(this.GradLinearDirectionType);
} }
} }
this.GradColors.forEach(function (item) { this.GradColors.forEach(function (item) {
var gradientStop = new Asc.asc_CGradientStop(); var gradientStop = new Asc.asc_CGradientStop();
gradientStop.asc_setColor(Common.Utils.ThemeColor.getRgbColor(item.Color)); gradientStop.asc_setColor(Common.Utils.ThemeColor.getRgbColor(item.Color));
gradientStop.asc_setPosition(item.Position); gradientStop.asc_setPosition(item.Position);
gradient.asc_addGradientStop(gradientStop); me.gradient.asc_addGradientStop(gradientStop);
}); });
//this.propsFill.asc_putGradientFill(gradient); this.fill.asc_setGradientFill(this.gradient);
//this.api.asc_setGraphicObjectProps(this.propsFill); this.api.asc_setCellFill(this.fill);
} }
Common.NotificationCenter.trigger('edit:complete', this); Common.NotificationCenter.trigger('edit:complete', this);
}, },
@ -984,14 +1010,14 @@ define([
onPatternSelect: function(combo, record) { onPatternSelect: function(combo, record) {
if (this.api && !this._noApply) { if (this.api && !this._noApply) {
this.PatternFillType = record.get('type'); this.PatternFillType = record.get('type');
var pattern = new Asc.asc_CPatternFill(); if (this.pattern == null) {
pattern.asc_setType(this.PatternFillType); this.pattern = new Asc.asc_CPatternFill();
if (this.OriginalFillType !== Asc.c_oAscFill.FILL_TYPE_PATT) { this.pattern.asc_setFgColor(Common.Utils.ThemeColor.getRgbColor(this.FGColor.Color));
pattern.asc_setFgColor(Common.Utils.ThemeColor.getRgbColor(this.FGColor.Color)); this.pattern.asc_setBgColor(Common.Utils.ThemeColor.getRgbColor(this.BGColor.Color));
pattern.asc_setBgColor(Common.Utils.ThemeColor.getRgbColor(this.BGColor.Color));
} }
//this.propsFill.asc_putPatternFill(pattern); this.pattern.asc_setType(this.PatternFillType);
//this.api.asc_setGraphicObjectProps(this.propsFill); this.fill.asc_setPatternFill(this.pattern);
this.api.asc_setCellFill(this.fill);
} }
Common.NotificationCenter.trigger('edit:complete', this); Common.NotificationCenter.trigger('edit:complete', this);
}, },
@ -1000,15 +1026,14 @@ define([
this.btnFGColor.setColor(color); this.btnFGColor.setColor(color);
this.FGColor = {Value: 1, Color: color}; this.FGColor = {Value: 1, Color: color};
if (this.api && !this._noApply) { if (this.api && !this._noApply) {
var pattern = new Asc.asc_CPatternFill(); if (this.pattern == null) {
pattern.asc_setType(Asc.c_oAscFill.FILL_TYPE_PATT); this.pattern = new Asc.asc_CPatternFill();
pattern.asc_setFgColor(Common.Utils.ThemeColor.getRgbColor(this.FGColor.Color)); this.pattern.asc_setType(this.PatternFillType);
if (this.OriginalFillType !== Asc.c_oAscFill.FILL_TYPE_PATT) { this.pattern.asc_setBgColor(Common.Utils.ThemeColor.getRgbColor(this.BGColor.Color));
pattern.asc_setType(this.PatternFillType);
pattern.asc_setBgColor(Common.Utils.ThemeColor.getRgbColor(this.BGColor.Color));
} }
//this.propsFill.asc_putPatternFill(pattern); this.pattern.asc_setFgColor(Common.Utils.ThemeColor.getRgbColor(this.FGColor.Color));
//this.api.asc_setGraphicObjectProps(this.propsFill); this.fill.asc_setPatternFill(this.pattern);
this.api.asc_setCellFill(this.fill);
} }
Common.NotificationCenter.trigger('edit:complete', this); Common.NotificationCenter.trigger('edit:complete', this);
}, },
@ -1017,15 +1042,14 @@ define([
this.btnBGColor.setColor(color); this.btnBGColor.setColor(color);
this.BGColor = {Value: 1, Color: color}; this.BGColor = {Value: 1, Color: color};
if (this.api && !this._noApply) { if (this.api && !this._noApply) {
var pattern = new Asc.asc_CPatternFill(); if (this.pattern == null) {
pattern.asc_setType(Asc.c_oAscFill.FILL_TYPE_PATT); this.pattern = new Asc.asc_CPatternFill();
pattern.asc_setBgColor(Common.Utils.ThemeColor.getRgbColor(this.BGColor.Color)); this.pattern.asc_setFgColor(Common.Utils.ThemeColor.getRgbColor(this.FGColor.Color));
if (this.OriginalFillType !== Asc.c_oAscFill.FILL_TYPE_PATT) { this.pattern.asc_setType(this.PatternFillType);
pattern.asc_setType(this.PatternFillType);
pattern.asc_setFgColor(Common.Utils.ThemeColor.getRgbColor(this.FGColor.Color));
} }
//this.propsFill.asc_putPatternFill(pattern); this.pattern.asc_setBgColor(Common.Utils.ThemeColor.getRgbColor(this.BGColor.Color));
//this.api.asc_setGraphicObjectProps(this.propsFill); this.fill.asc_setPatternFill(this.pattern);
this.api.asc_setCellFill(this.fill);
} }
Common.NotificationCenter.trigger('edit:complete', this); Common.NotificationCenter.trigger('edit:complete', this);
}, },