diff --git a/apps/presentationeditor/main/app/view/ShapeSettings.js b/apps/presentationeditor/main/app/view/ShapeSettings.js index 46c1751fa..1149cacb0 100644 --- a/apps/presentationeditor/main/app/view/ShapeSettings.js +++ b/apps/presentationeditor/main/app/view/ShapeSettings.js @@ -175,6 +175,8 @@ define([ fill.get_fill().put_linear_scale(true); } if (this.OriginalFillType !== Asc.c_oAscFill.FILL_TYPE_GRAD) { + this.GradColor.values = [0, 100]; + this.GradColor.colors = [this.GradColor.colors[0], this.GradColor.colors[this.GradColor.colors.length - 1]]; var HexColor0 = Common.Utils.ThemeColor.getRgbColor(this.GradColor.colors[0]).get_color().get_hex(), HexColor1 = Common.Utils.ThemeColor.getRgbColor(this.GradColor.colors[1]).get_color().get_hex(); @@ -468,14 +470,22 @@ define([ fill.put_type(Asc.c_oAscFill.FILL_TYPE_GRAD); fill.put_fill( new Asc.asc_CFillGrad()); fill.get_fill().put_grad_type(this.GradFillType); - fill.get_fill().put_colors([Common.Utils.ThemeColor.getRgbColor(this.GradColor.colors[0]), Common.Utils.ThemeColor.getRgbColor(this.GradColor.colors[1])]); + var arr = []; + this.GradColor.colors.forEach(function(item){ + arr.push(Common.Utils.ThemeColor.getRgbColor(item)); + }); + fill.get_fill().put_colors(arr); if (this.OriginalFillType !== Asc.c_oAscFill.FILL_TYPE_GRAD) { if (this.GradFillType == Asc.c_oAscFillGradType.GRAD_LINEAR) { fill.get_fill().put_linear_angle(this.GradLinearDirectionType * 60000); fill.get_fill().put_linear_scale(true); } - fill.get_fill().put_positions([this.GradColor.values[0]*1000, this.GradColor.values[1]*1000]); + arr = []; + this.GradColor.values.forEach(function(item){ + arr.push(item*1000); + }); + fill.get_fill().put_positions(arr); } props.put_fill(fill); this.api.ShapeApply(props); @@ -512,14 +522,22 @@ define([ fill.put_type(Asc.c_oAscFill.FILL_TYPE_GRAD); fill.put_fill( new Asc.asc_CFillGrad()); fill.get_fill().put_grad_type(this.GradFillType); - fill.get_fill().put_positions([this.GradColor.values[0]*1000, this.GradColor.values[1]*1000]); + var arr = []; + this.GradColor.values.forEach(function(item){ + arr.push(item*1000); + }); + fill.get_fill().put_positions(arr); if (this.OriginalFillType !== Asc.c_oAscFill.FILL_TYPE_GRAD) { if (this.GradFillType == Asc.c_oAscFillGradType.GRAD_LINEAR) { fill.get_fill().put_linear_angle(this.GradLinearDirectionType * 60000); fill.get_fill().put_linear_scale(true); } - fill.get_fill().put_colors([Common.Utils.ThemeColor.getRgbColor(this.GradColor.colors[0]), Common.Utils.ThemeColor.getRgbColor(this.GradColor.colors[1])]); + arr = []; + this.GradColor.colors.forEach(function(item){ + arr.push(Common.Utils.ThemeColor.getRgbColor(item)); + }); + fill.get_fill().put_colors(arr); } props.put_fill(fill); this.api.ShapeApply(props); @@ -739,7 +757,7 @@ define([ this.FGColor = (this.ShapeColor.Color!=='transparent') ? {Value: 1, Color: Common.Utils.ThemeColor.colorValue2EffectId(this.ShapeColor.Color)} : {Value: 1, Color: '000000'}; this.BGColor = {Value: 1, Color: 'ffffff'}; this.GradColor.colors[0] = (this.ShapeColor.Color!=='transparent') ? Common.Utils.ThemeColor.colorValue2EffectId(this.ShapeColor.Color) : '000000'; - this.GradColor.colors[1] = 'ffffff'; + this.GradColor.colors[this.GradColor.colors.length-1] = 'ffffff'; } else if (fill_type==Asc.c_oAscFill.FILL_TYPE_BLIP) { fill = fill.get_fill(); this.BlipFillType = fill.get_type(); // null - не совпадают у нескольких фигур @@ -787,7 +805,7 @@ define([ this.OriginalFillType = Asc.c_oAscFill.FILL_TYPE_PATT; this.ShapeColor = {Value: 1, Color: Common.Utils.ThemeColor.colorValue2EffectId(this.FGColor.Color)}; this.GradColor.colors[0] = Common.Utils.ThemeColor.colorValue2EffectId(this.FGColor.Color); - this.GradColor.colors[1] = 'ffffff'; + this.GradColor.colors[this.GradColor.colors.length-1] = 'ffffff'; } else if (fill_type==Asc.c_oAscFill.FILL_TYPE_GRAD) { fill = fill.get_fill(); var gradfilltype = fill.get_grad_type(); // null - не совпадают у нескольких фигур @@ -818,49 +836,37 @@ define([ } } - var colors = fill.get_colors(); - if (colors && colors.length>0) { - color = colors[0]; + var me = this; + var colors = fill.get_colors(), + positions = fill.get_positions(), + length = colors.length; + this.sldrGradient.setThumbs(length); + if (this.GradColor.colors.length>length) { + this.GradColor.colors.splice(length, this.GradColor.colors.length - length); + this.GradColor.values.splice(length, this.GradColor.colors.length - length); + this.GradColor.currentIdx = 0; + } + colors && colors.forEach(function(color, index) { if (color) { if (color.get_type() == Asc.c_oAscColor.COLOR_TYPE_SCHEME) { - this.GradColor.colors[0] = {color: Common.Utils.ThemeColor.getHexColor(color.get_r(), color.get_g(), color.get_b()), effectValue: color.get_value()}; - Common.Utils.ThemeColor.colorValue2EffectId(this.GradColor.colors[0]); + me.GradColor.colors[index] = {color: Common.Utils.ThemeColor.getHexColor(color.get_r(), color.get_g(), color.get_b()), effectValue: color.get_value()}; + Common.Utils.ThemeColor.colorValue2EffectId(me.GradColor.colors[index]); } else { - this.GradColor.colors[0] = Common.Utils.ThemeColor.getHexColor(color.get_r(), color.get_g(), color.get_b()); + me.GradColor.colors[index] = Common.Utils.ThemeColor.getHexColor(color.get_r(), color.get_g(), color.get_b()); } } else - this.GradColor.colors[0] = '000000'; + me.GradColor.colors[index] = '000000'; - color = colors[1]; - if (color) { - if (color.get_type() == Asc.c_oAscColor.COLOR_TYPE_SCHEME) { - this.GradColor.colors[1] = {color: Common.Utils.ThemeColor.getHexColor(color.get_r(), color.get_g(), color.get_b()), effectValue: color.get_value()}; - Common.Utils.ThemeColor.colorValue2EffectId(this.GradColor.colors[1]); - } else { - this.GradColor.colors[1] = Common.Utils.ThemeColor.getHexColor(color.get_r(), color.get_g(), color.get_b()); - } - } else - this.GradColor.colors[1] = 'ffffff'; - - } - var positions = fill.get_positions(); - if (positions && positions.length>0) { - var position = positions[0]; + var position = positions[index]; if (position!==null) { position = position/1000; - this.GradColor.values[0] = position; - } - - position = positions[1]; - if (position!==null) { - position = position/1000; - this.GradColor.values[1] = position; + me.GradColor.values[index] = position; } + }); + for (var index=0; index0) { - color = colors[0]; + var me = this; + var colors = fill.get_colors(), + positions = fill.get_positions(), + length = colors.length; + this.sldrGradient.setThumbs(length); + if (this.GradColor.colors.length>length) { + this.GradColor.colors.splice(length, this.GradColor.colors.length - length); + this.GradColor.values.splice(length, this.GradColor.colors.length - length); + this.GradColor.currentIdx = 0; + } + colors && colors.forEach(function(color, index) { if (color) { if (color.get_type() == Asc.c_oAscColor.COLOR_TYPE_SCHEME) { - this.GradColor.colors[0] = {color: Common.Utils.ThemeColor.getHexColor(color.get_r(), color.get_g(), color.get_b()), effectValue: color.get_value()}; - Common.Utils.ThemeColor.colorValue2EffectId(this.GradColor.colors[0]); + me.GradColor.colors[index] = {color: Common.Utils.ThemeColor.getHexColor(color.get_r(), color.get_g(), color.get_b()), effectValue: color.get_value()}; + Common.Utils.ThemeColor.colorValue2EffectId(me.GradColor.colors[index]); } else { - this.GradColor.colors[0] = Common.Utils.ThemeColor.getHexColor(color.get_r(), color.get_g(), color.get_b()); + me.GradColor.colors[index] = Common.Utils.ThemeColor.getHexColor(color.get_r(), color.get_g(), color.get_b()); } } else - this.GradColor.colors[0] = '000000'; + me.GradColor.colors[index] = '000000'; - color = colors[1]; - if (color) { - if (color.get_type() == Asc.c_oAscColor.COLOR_TYPE_SCHEME) { - this.GradColor.colors[1] = {color: Common.Utils.ThemeColor.getHexColor(color.get_r(), color.get_g(), color.get_b()), effectValue: color.get_value()}; - Common.Utils.ThemeColor.colorValue2EffectId(this.GradColor.colors[1]); - } else { - this.GradColor.colors[1] = Common.Utils.ThemeColor.getHexColor(color.get_r(), color.get_g(), color.get_b()); - } - } else - this.GradColor.colors[1] = 'ffffff'; - - } - var positions = fill.get_positions(); - if (positions && positions.length>0) { - var position = positions[0]; + var position = positions[index]; if (position!==null) { position = position/1000; - this.GradColor.values[0] = position; - } - - position = positions[1]; - if (position!==null) { - position = position/1000; - this.GradColor.values[1] = position; + me.GradColor.values[index] = position; } + }); + for (var index=0; index0) { - color = colors[0]; + var me = this; + var colors = fill.get_colors(), + positions = fill.get_positions(), + length = colors.length; + this.sldrGradient.setThumbs(length); + if (this.GradColor.colors.length>length) { + this.GradColor.colors.splice(length, this.GradColor.colors.length - length); + this.GradColor.values.splice(length, this.GradColor.colors.length - length); + this.GradColor.currentIdx = 0; + } + colors && colors.forEach(function(color, index) { if (color) { if (color.get_type() == Asc.c_oAscColor.COLOR_TYPE_SCHEME) { - this.GradColor.colors[0] = {color: Common.Utils.ThemeColor.getHexColor(color.get_r(), color.get_g(), color.get_b()), effectValue: color.get_value()}; - Common.Utils.ThemeColor.colorValue2EffectId(this.GradColor.colors[0]); + me.GradColor.colors[index] = {color: Common.Utils.ThemeColor.getHexColor(color.get_r(), color.get_g(), color.get_b()), effectValue: color.get_value()}; + Common.Utils.ThemeColor.colorValue2EffectId(me.GradColor.colors[index]); } else { - this.GradColor.colors[0] = Common.Utils.ThemeColor.getHexColor(color.get_r(), color.get_g(), color.get_b()); + me.GradColor.colors[index] = Common.Utils.ThemeColor.getHexColor(color.get_r(), color.get_g(), color.get_b()); } } else - this.GradColor.colors[0] = '000000'; + me.GradColor.colors[index] = '000000'; - color = colors[1]; - if (color) { - if (color.get_type() == Asc.c_oAscColor.COLOR_TYPE_SCHEME) { - this.GradColor.colors[1] = {color: Common.Utils.ThemeColor.getHexColor(color.get_r(), color.get_g(), color.get_b()), effectValue: color.get_value()}; - Common.Utils.ThemeColor.colorValue2EffectId(this.GradColor.colors[1]); - } else { - this.GradColor.colors[1] = Common.Utils.ThemeColor.getHexColor(color.get_r(), color.get_g(), color.get_b()); - } - } else - this.GradColor.colors[1] = 'ffffff'; - - } - var positions = fill.get_positions(); - if (positions && positions.length>0) { - var position = positions[0]; + var position = positions[index]; if (position!==null) { position = position/1000; - this.GradColor.values[0] = position; - } - - position = positions[1]; - if (position!==null) { - position = position/1000; - this.GradColor.values[1] = position; + me.GradColor.values[index] = position; } + }); + for (var index=0; index0) { - color = colors[0]; + var me = this; + var colors = fill.asc_getColors(), + positions = fill.asc_getPositions(), + length = colors.length; + this.sldrGradient.setThumbs(length); + if (this.GradColor.colors.length>length) { + this.GradColor.colors.splice(length, this.GradColor.colors.length - length); + this.GradColor.values.splice(length, this.GradColor.colors.length - length); + this.GradColor.currentIdx = 0; + } + colors && colors.forEach(function(color, index) { if (color) { if (color.asc_getType() == Asc.c_oAscColor.COLOR_TYPE_SCHEME) { - this.GradColor.colors[0] = {color: Common.Utils.ThemeColor.getHexColor(color.asc_getR(), color.asc_getG(), color.asc_getB()), effectValue: color.asc_getValue()}; - Common.Utils.ThemeColor.colorValue2EffectId(this.GradColor.colors[0]); + me.GradColor.colors[index] = {color: Common.Utils.ThemeColor.getHexColor(color.asc_getR(), color.asc_getG(), color.asc_getB()), effectValue: color.asc_getValue()}; + Common.Utils.ThemeColor.colorValue2EffectId(me.GradColor.colors[index]); } else { - this.GradColor.colors[0] = Common.Utils.ThemeColor.getHexColor(color.asc_getR(), color.asc_getG(), color.asc_getB()); + me.GradColor.colors[index] = Common.Utils.ThemeColor.getHexColor(color.asc_getR(), color.asc_getG(), color.asc_getB()); } } else - this.GradColor.colors[0] = '000000'; + me.GradColor.colors[index] = '000000'; - color = colors[1]; - if (color) { - if (color.asc_getType() == Asc.c_oAscColor.COLOR_TYPE_SCHEME) { - this.GradColor.colors[1] = {color: Common.Utils.ThemeColor.getHexColor(color.asc_getR(), color.asc_getG(), color.asc_getB()), effectValue: color.asc_getValue()}; - Common.Utils.ThemeColor.colorValue2EffectId(this.GradColor.colors[1]); - } else { - this.GradColor.colors[1] = Common.Utils.ThemeColor.getHexColor(color.asc_getR(), color.asc_getG(), color.asc_getB()); - } - } else - this.GradColor.colors[1] = 'ffffff'; - - } - var positions = fill.asc_getPositions(); - if (positions && positions.length>0) { - var position = positions[0]; + var position = positions[index]; if (position!==null) { position = position/1000; - this.GradColor.values[0] = position; - } - - position = positions[1]; - if (position!==null) { - position = position/1000; - this.GradColor.values[1] = position; + me.GradColor.values[index] = position; } + }); + for (var index=0; index0) { - color = colors[0]; + var me = this; + var colors = fill.asc_getColors(), + positions = fill.asc_getPositions(), + length = colors.length; + this.sldrGradient.setThumbs(length); + if (this.GradColor.colors.length>length) { + this.GradColor.colors.splice(length, this.GradColor.colors.length - length); + this.GradColor.values.splice(length, this.GradColor.colors.length - length); + this.GradColor.currentIdx = 0; + } + colors && colors.forEach(function(color, index) { if (color) { if (color.asc_getType() == Asc.c_oAscColor.COLOR_TYPE_SCHEME) { - this.GradColor.colors[0] = {color: Common.Utils.ThemeColor.getHexColor(color.asc_getR(), color.asc_getG(), color.asc_getB()), effectValue: color.asc_getValue()}; - Common.Utils.ThemeColor.colorValue2EffectId(this.GradColor.colors[0]); + me.GradColor.colors[index] = {color: Common.Utils.ThemeColor.getHexColor(color.asc_getR(), color.asc_getG(), color.asc_getB()), effectValue: color.asc_getValue()}; + Common.Utils.ThemeColor.colorValue2EffectId(me.GradColor.colors[index]); } else { - this.GradColor.colors[0] = Common.Utils.ThemeColor.getHexColor(color.asc_getR(), color.asc_getG(), color.asc_getB()); + me.GradColor.colors[index] = Common.Utils.ThemeColor.getHexColor(color.asc_getR(), color.asc_getG(), color.asc_getB()); } } else - this.GradColor.colors[0] = '000000'; + me.GradColor.colors[index] = '000000'; - color = colors[1]; - if (color) { - if (color.asc_getType() == Asc.c_oAscColor.COLOR_TYPE_SCHEME) { - this.GradColor.colors[1] = {color: Common.Utils.ThemeColor.getHexColor(color.asc_getR(), color.asc_getG(), color.asc_getB()), effectValue: color.asc_getValue()}; - Common.Utils.ThemeColor.colorValue2EffectId(this.GradColor.colors[1]); - } else { - this.GradColor.colors[1] = Common.Utils.ThemeColor.getHexColor(color.asc_getR(), color.asc_getG(), color.asc_getB()); - } - } else - this.GradColor.colors[1] = 'ffffff'; - - } - var positions = fill.asc_getPositions(); - if (positions && positions.length>0) { - var position = positions[0]; + var position = positions[index]; if (position!==null) { position = position/1000; - this.GradColor.values[0] = position; - } - - position = positions[1]; - if (position!==null) { - position = position/1000; - this.GradColor.values[1] = position; + me.GradColor.values[index] = position; } + }); + for (var index=0; index