Merge pull request #2085 from ONLYOFFICE/fix/bug-49877-reserve

Bug 49877
This commit is contained in:
maxkadushkin 2022-11-25 16:45:34 +03:00 committed by GitHub
commit 775d9376be
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 845 additions and 798 deletions

View file

@ -102,12 +102,12 @@ define([
var txtPt = Common.Utils.Metric.getMetricName(Common.Utils.Metric.c_MetricUnits.pt), var txtPt = Common.Utils.Metric.getMetricName(Common.Utils.Metric.c_MetricUnits.pt),
data = [ data = [
{displayValue: '0.5 ' + txtPt, value: 0.5, pxValue: 0.5, offsety: 0}, {displayValue: '0.5 ' + txtPt, value: 0.5, pxValue: 0.5, offsety: 0},
{displayValue: '1 ' + txtPt, value: 1, pxValue: 1, offsety: 20}, {displayValue: '1 ' + txtPt, value: 1, pxValue: 1, offsety: 20}, //pxValue = 1.34px
{displayValue: '1.5 ' + txtPt, value: 1.5, pxValue: 2, offsety: 40}, {displayValue: '1.5 ' + txtPt, value: 1.5, pxValue: 2, offsety: 40},
{displayValue: '2.25 ' + txtPt, value: 2.25,pxValue: 3, offsety: 60}, {displayValue: '2.25 ' + txtPt, value: 2.25,pxValue: 3, offsety: 60},
{displayValue: '3 ' + txtPt, value: 3, pxValue: 4, offsety: 80}, {displayValue: '3 ' + txtPt, value: 3, pxValue: 4, offsety: 80},
{displayValue: '4.5 ' + txtPt, value: 4.5, pxValue: 5, offsety: 100}, {displayValue: '4.5 ' + txtPt, value: 4.5, pxValue: 6, offsety: 100},
{displayValue: '6 ' + txtPt, value: 6, pxValue: 6, offsety: 120} {displayValue: '6 ' + txtPt, value: 6, pxValue: 8, offsety: 120}
]; ];
if (options.allowNoBorders !== false) if (options.allowNoBorders !== false)
data.unshift({displayValue: this.txtNoBorders, value: 0, pxValue: 0 }); data.unshift({displayValue: this.txtNoBorders, value: 0, pxValue: 0 });
@ -209,8 +209,8 @@ define([
{displayValue: '1.5 ' + txtPt, value: 1.5, pxValue: 2, offsety: 40}, {displayValue: '1.5 ' + txtPt, value: 1.5, pxValue: 2, offsety: 40},
{displayValue: '2.25 ' + txtPt, value: 2.25,pxValue: 3, offsety: 60}, {displayValue: '2.25 ' + txtPt, value: 2.25,pxValue: 3, offsety: 60},
{displayValue: '3 ' + txtPt, value: 3, pxValue: 4, offsety: 80}, {displayValue: '3 ' + txtPt, value: 3, pxValue: 4, offsety: 80},
{displayValue: '4.5 ' + txtPt, value: 4.5, pxValue: 5, offsety: 100}, {displayValue: '4.5 ' + txtPt, value: 4.5, pxValue: 6, offsety: 100},
{displayValue: '6 ' + txtPt, value: 6, pxValue: 6, offsety: 120} {displayValue: '6 ' + txtPt, value: 6, pxValue: 8, offsety: 120}
]; ];
if (options.allowNoBorders !== false) if (options.allowNoBorders !== false)

File diff suppressed because it is too large Load diff

View file

@ -151,8 +151,8 @@ define([
{id: Common.UI.getId(), displayValue: '1.5 ' + txtPt, value: 1.5, pxValue: 2, offsety: 40}, {id: Common.UI.getId(), displayValue: '1.5 ' + txtPt, value: 1.5, pxValue: 2, offsety: 40},
{id: Common.UI.getId(), displayValue: '2.25 ' + txtPt, value: 2.25, pxValue: 3, offsety: 60}, {id: Common.UI.getId(), displayValue: '2.25 ' + txtPt, value: 2.25, pxValue: 3, offsety: 60},
{id: Common.UI.getId(), displayValue: '3 ' + txtPt, value: 3, pxValue: 4, offsety: 80}, {id: Common.UI.getId(), displayValue: '3 ' + txtPt, value: 3, pxValue: 4, offsety: 80},
{id: Common.UI.getId(), displayValue: '4.5 ' + txtPt, value: 4.5, pxValue: 5, offsety: 100}, {id: Common.UI.getId(), displayValue: '4.5 ' + txtPt, value: 4.5, pxValue: 6, offsety: 100},
{id: Common.UI.getId(), displayValue: '6 ' + txtPt, value: 6, pxValue: 6, offsety: 120} {id: Common.UI.getId(), displayValue: '6 ' + txtPt, value: 6, pxValue: 8, offsety: 120}
] ]
}).on('selected', _.bind(function(combo, record) { }).on('selected', _.bind(function(combo, record) {
this.BorderSize = {ptValue: record.value, pxValue: record.pxValue}; this.BorderSize = {ptValue: record.value, pxValue: record.pxValue};
@ -201,7 +201,8 @@ define([
} }
} }
var colorstr = (typeof(color) == 'object') ? color.color : color; var colorstr = (typeof(color) == 'object') ? color.color : color;
me.tableStyler.setCellsColor(colorstr); me.tableStyler.setTableColor(colorstr);
me.tableStyler.redrawTable();
}, this)); }, this));
this.colorsBack = this.btnBackColor.getPicker(); this.colorsBack = this.btnBackColor.getPicker();
@ -667,8 +668,7 @@ define([
}, },
afterRender: function() { afterRender: function() {
this.updateMetricUnit();
this.updateThemeColors();
if (!this.isFrame) { if (!this.isFrame) {
this.cmbFonts.fillFonts(this.fontStore); this.cmbFonts.fillFonts(this.fontStore);
@ -676,6 +676,13 @@ define([
this._setDefaults(this._originalProps); this._setDefaults(this._originalProps);
var colorstr = (typeof(this.paragraphShade) == 'object') ? this.paragraphShade.color : this.paragraphShade;
this.tableStyler.setTableColor(colorstr);
(colorstr!='transparent') && this.tableStyler.redrawTable();
this.updateMetricUnit();
this.updateThemeColors();
if (this.borderProps !== undefined) { if (this.borderProps !== undefined) {
this.btnBorderColor.setColor(this.borderProps.borderColor); this.btnBorderColor.setColor(this.borderProps.borderColor);
this.btnBorderColor.setAutoColor(this.borderProps.borderColor=='auto'); this.btnBorderColor.setAutoColor(this.borderProps.borderColor=='auto');
@ -692,16 +699,13 @@ define([
this.setTitle((this.isFrame) ? this.textTitleFrame : this.textTitle); this.setTitle((this.isFrame) ? this.textTitleFrame : this.textTitle);
for (var i=0; i<this.tableStyler.rows; i++) { this.tableStyler.on('borderclick:cellborder', function(ct, border, size, color){
for (var j=0; j<this.tableStyler.columns; j++) { if (this.ChangedBorders===undefined) {
this.tableStyler.getCell(j, i).on('borderclick', function(ct, border, size, color){ this.ChangedBorders = new Asc.asc_CParagraphBorders();
if (this.ChangedBorders===undefined) {
this.ChangedBorders = new Asc.asc_CParagraphBorders();
}
this._UpdateCellBordersStyle(ct, border, size, color, this.Borders);
}, this);
} }
} this._UpdateCellBordersStyle(ct, border, size, color, this.Borders);
}, this);
this.tableStyler.on('borderclick', function(ct, border, size, color){ this.tableStyler.on('borderclick', function(ct, border, size, color){
if (this.ChangedBorders===undefined) { if (this.ChangedBorders===undefined) {
this.ChangedBorders = new Asc.asc_CParagraphBorders(); this.ChangedBorders = new Asc.asc_CParagraphBorders();
@ -709,9 +713,6 @@ define([
this._UpdateTableBordersStyle(ct, border, size, color, this.Borders); this._UpdateTableBordersStyle(ct, border, size, color, this.Borders);
}, this); }, this);
var colorstr = (typeof(this.paragraphShade) == 'object') ? this.paragraphShade.color : this.paragraphShade;
this.tableStyler.setCellsColor(colorstr);
if (this.isFrame) if (this.isFrame)
this.setHeight(500); this.setHeight(500);
@ -1041,26 +1042,26 @@ define([
this._UpdateBorder(this.Borders.get_Bottom(), 'b'); this._UpdateBorder(this.Borders.get_Bottom(), 'b');
if (this.Borders.get_Between() !== null) { if (this.Borders.get_Between() !== null) {
for (var i=0; i<this.tableStyler.columns; i++) { for (var i=0; i<this.tableStyler.rows-1; i++) {
this._UpdateCellBorder(this.Borders.get_Between(), 'b', this.tableStyler.getCell(i, 0)); this._UpdateCellBorder(this.Borders.get_Between(), this.tableStyler.getCellBorder(i, -1));
this._UpdateCellBorder(this.Borders.get_Between(), 't', this.tableStyler.getCell(i, 1));
} }
} }
this.tableStyler.setVirtualBorderSize(oldSize.pxValue); this.tableStyler.setVirtualBorderSize(oldSize.pxValue);
this.tableStyler.setVirtualBorderColor((typeof(oldColor) == 'object') ? oldColor.color : oldColor); this.tableStyler.setVirtualBorderColor((typeof(oldColor) == 'object') ? oldColor.color : oldColor);
this.tableStyler.redrawTable();
}, },
_UpdateCellBorder: function(BorderParam, borderName, cell){ _UpdateCellBorder: function(BorderParam, cell){
if (null !== BorderParam && undefined !== BorderParam){ if (null !== BorderParam && undefined !== BorderParam){
if (null !== BorderParam.get_Value() && null !== BorderParam.get_Size() && null !== BorderParam.get_Color() && 1 == BorderParam.get_Value()){ if (null !== BorderParam.get_Value() && null !== BorderParam.get_Size() && null !== BorderParam.get_Color() && 1 == BorderParam.get_Value()){
cell.setBordersSize(borderName, this._BorderPt2Px(BorderParam.get_Size() * 72 / 25.4)); cell.setBordersSize(this._BorderPt2Px(BorderParam.get_Size() * 72 / 25.4));
cell.setBordersColor(borderName, 'rgb(' + BorderParam.get_Color().get_r() + ',' + BorderParam.get_Color().get_g() + ',' + BorderParam.get_Color().get_b() + ')'); cell.setBordersColor('rgb(' + BorderParam.get_Color().get_r() + ',' + BorderParam.get_Color().get_g() + ',' + BorderParam.get_Color().get_b() + ')');
} else } else
cell.setBordersSize(borderName, 0); cell.setBordersSize(0);
} }
else { else {
cell.setBordersSize(borderName, 0); cell.setBordersSize(0);
} }
}, },
@ -1084,8 +1085,8 @@ define([
if (value <=1.5) return 2; if (value <=1.5) return 2;
if (value <=2.25) return 3; if (value <=2.25) return 3;
if (value <=3) return 4; if (value <=3) return 4;
if (value <=4.5) return 5; if (value <=4.5) return 6;
return 6; return 8;
}, },
_ApplyBorderPreset: function(border) { _ApplyBorderPreset: function(border) {
@ -1126,42 +1127,11 @@ define([
_UpdateCellBordersStyle: function(ct, border, size, color, destination) { _UpdateCellBordersStyle: function(ct, border, size, color, destination) {
var updateBorders = destination; var updateBorders = destination;
updateBorders.put_Between(this._UpdateBorderStyle(updateBorders.get_Between(), (size>0)));
if ( ct.col==0 && border.indexOf('l') > -1 ) { if (this.ChangedBorders) {
updateBorders.put_Left(this._UpdateBorderStyle(updateBorders.get_Left(), (size>0))); this.ChangedBorders.put_Between(new Asc.asc_CTextBorder(updateBorders.get_Between()));
if (this.ChangedBorders) {
this.ChangedBorders.put_Left(new Asc.asc_CTextBorder(updateBorders.get_Left()));
}
} }
if ( ct.col== this.tableStylerColumns-1 && border.indexOf('r') > -1 ) {
updateBorders.put_Right(this._UpdateBorderStyle(updateBorders.get_Right(), (size>0)));
if (this.ChangedBorders) {
this.ChangedBorders.put_Right(new Asc.asc_CTextBorder(updateBorders.get_Right()));
}
}
if ( ct.row==0 && border.indexOf('t') > -1 ) {
updateBorders.put_Top(this._UpdateBorderStyle(updateBorders.get_Top(), (size>0)));
if (this.ChangedBorders) {
this.ChangedBorders.put_Top(new Asc.asc_CTextBorder(updateBorders.get_Top()));
}
}
if ( ct.row== this.tableStylerRows-1 && border.indexOf('b') > -1 ) {
updateBorders.put_Bottom(this._UpdateBorderStyle(updateBorders.get_Bottom(), (size>0)));
if (this.ChangedBorders) {
this.ChangedBorders.put_Bottom(new Asc.asc_CTextBorder(updateBorders.get_Bottom()));
}
}
if ( ct.row==0 && border.indexOf('b') > -1 ||
ct.row== this.tableStylerRows-1 && border.indexOf('t') > -1) {
updateBorders.put_Between(this._UpdateBorderStyle(updateBorders.get_Between(), (size>0)));
if (this.ChangedBorders) {
this.ChangedBorders.put_Between(new Asc.asc_CTextBorder(updateBorders.get_Between()));
}
}
}, },
_UpdateTableBordersStyle: function(ct, border, size, color, destination) { _UpdateTableBordersStyle: function(ct, border, size, color, destination) {

View file

@ -203,6 +203,7 @@ define([ 'text!documenteditor/main/app/template/ParagraphSettingsAdvanced.tem
allowAuto : true, allowAuto : true,
autoText : this.txtAutoText autoText : this.txtAutoText
}); });
this.numSpacingBefore.on('change', _.bind(function (field, newValue, oldValue, eOpts) { this.numSpacingBefore.on('change', _.bind(function (field, newValue, oldValue, eOpts) {
if (this.Spacing === null) { if (this.Spacing === null) {
var properties = (this._originalProps) ? this._originalProps : new Asc.asc_CParagraphProperty(); var properties = (this._originalProps) ? this._originalProps : new Asc.asc_CParagraphProperty();
@ -1006,11 +1007,13 @@ define([ 'text!documenteditor/main/app/template/ParagraphSettingsAdvanced.tem
}, },
afterRender: function() { afterRender: function() {
this.updateMetricUnit();
this.updateThemeColors();
this._setDefaults(this._originalProps); this._setDefaults(this._originalProps);
var colorstr = (typeof(this.paragraphShade) == 'object') ? this.paragraphShade.color : this.paragraphShade;
this.BordersImage.setTableColor(colorstr);
(colorstr!='transparent') &&this.BordersImage.redrawTable();
this.updateMetricUnit();
this.updateThemeColors();
if (this.borderProps !== undefined) { if (this.borderProps !== undefined) {
this.btnBorderColor.setColor(this.borderProps.borderColor); this.btnBorderColor.setColor(this.borderProps.borderColor);
this.btnBorderColor.setAutoColor(this.borderProps.borderColor=='auto'); this.btnBorderColor.setAutoColor(this.borderProps.borderColor=='auto');
@ -1027,16 +1030,13 @@ define([ 'text!documenteditor/main/app/template/ParagraphSettingsAdvanced.tem
this.onBorderSizeSelect(this.cmbBorderSize, rec); this.onBorderSizeSelect(this.cmbBorderSize, rec);
} }
for (var i=0; i<this.BordersImage.rows; i++) { this.BordersImage.on('borderclick:cellborder', function(ct, border, size, color){
for (var j=0; j<this.BordersImage.columns; j++) { if (this.ChangedBorders===undefined) {
this.BordersImage.getCell(j, i).on('borderclick', function(ct, border, size, color){ this.ChangedBorders = new Asc.asc_CParagraphBorders();
if (this.ChangedBorders===undefined) {
this.ChangedBorders = new Asc.asc_CParagraphBorders();
}
this._UpdateCellBordersStyle(ct, border, size, color, this.Borders);
}, this);
} }
} this._UpdateCellBordersStyle(ct, border, size, color, this.Borders);
}, this);
this.BordersImage.on('borderclick', function(ct, border, size, color){ this.BordersImage.on('borderclick', function(ct, border, size, color){
if (this.ChangedBorders===undefined) { if (this.ChangedBorders===undefined) {
this.ChangedBorders = new Asc.asc_CParagraphBorders(); this.ChangedBorders = new Asc.asc_CParagraphBorders();
@ -1044,9 +1044,6 @@ define([ 'text!documenteditor/main/app/template/ParagraphSettingsAdvanced.tem
this._UpdateTableBordersStyle(ct, border, size, color, this.Borders); this._UpdateTableBordersStyle(ct, border, size, color, this.Borders);
}, this); }, this);
var colorstr = (typeof(this.paragraphShade) == 'object') ? this.paragraphShade.color : this.paragraphShade;
this.BordersImage.setCellsColor(colorstr);
if (this.storageName) { if (this.storageName) {
var value = Common.localStorage.getItem(this.storageName); var value = Common.localStorage.getItem(this.storageName);
this.setActiveCategory((value!==null) ? parseInt(value) : 0); this.setActiveCategory((value!==null) ? parseInt(value) : 0);
@ -1197,7 +1194,8 @@ define([ 'text!documenteditor/main/app/template/ParagraphSettingsAdvanced.tem
} }
} }
var colorstr = (typeof(color) == 'object') ? color.color : color; var colorstr = (typeof(color) == 'object') ? color.color : color;
this.BordersImage.setCellsColor(colorstr); this.BordersImage.setTableColor(colorstr);
this.BordersImage.redrawTable();
}, },
@ -1240,41 +1238,9 @@ define([ 'text!documenteditor/main/app/template/ParagraphSettingsAdvanced.tem
_UpdateCellBordersStyle: function(ct, border, size, color, destination) { _UpdateCellBordersStyle: function(ct, border, size, color, destination) {
var updateBorders = destination; var updateBorders = destination;
updateBorders.put_Between(this._UpdateBorderStyle(updateBorders.get_Between(), (size>0)));
if ( ct.col==0 && border.indexOf('l') > -1 ) { if (this.ChangedBorders) {
updateBorders.put_Left(this._UpdateBorderStyle(updateBorders.get_Left(), (size>0))); this.ChangedBorders.put_Between(new Asc.asc_CTextBorder(updateBorders.get_Between()));
if (this.ChangedBorders) {
this.ChangedBorders.put_Left(new Asc.asc_CTextBorder(updateBorders.get_Left()));
}
}
if ( ct.col== this.tableStylerColumns-1 && border.indexOf('r') > -1 ) {
updateBorders.put_Right(this._UpdateBorderStyle(updateBorders.get_Right(), (size>0)));
if (this.ChangedBorders) {
this.ChangedBorders.put_Right(new Asc.asc_CTextBorder(updateBorders.get_Right()));
}
}
if ( ct.row==0 && border.indexOf('t') > -1 ) {
updateBorders.put_Top(this._UpdateBorderStyle(updateBorders.get_Top(), (size>0)));
if (this.ChangedBorders) {
this.ChangedBorders.put_Top(new Asc.asc_CTextBorder(updateBorders.get_Top()));
}
}
if ( ct.row== this.tableStylerRows-1 && border.indexOf('b') > -1 ) {
updateBorders.put_Bottom(this._UpdateBorderStyle(updateBorders.get_Bottom(), (size>0)));
if (this.ChangedBorders) {
this.ChangedBorders.put_Bottom(new Asc.asc_CTextBorder(updateBorders.get_Bottom()));
}
}
if ( ct.row==0 && border.indexOf('b') > -1 ||
ct.row== this.tableStylerRows-1 && border.indexOf('t') > -1) {
updateBorders.put_Between(this._UpdateBorderStyle(updateBorders.get_Between(), (size>0)));
if (this.ChangedBorders) {
this.ChangedBorders.put_Between(new Asc.asc_CTextBorder(updateBorders.get_Between()));
}
} }
}, },
@ -1317,26 +1283,25 @@ define([ 'text!documenteditor/main/app/template/ParagraphSettingsAdvanced.tem
this._UpdateBorder(this.Borders.get_Bottom(), 'b'); this._UpdateBorder(this.Borders.get_Bottom(), 'b');
if (this.Borders.get_Between() !== null) { if (this.Borders.get_Between() !== null) {
for (var i=0; i<this.BordersImage.columns; i++) { for (var i=0; i<this.BordersImage.rows-1; i++) {
this._UpdateCellBorder(this.Borders.get_Between(), 'b', this.BordersImage.getCell(i, 0)); this._UpdateCellBorder(this.Borders.get_Between(), this.BordersImage.getCellBorder(i, -1)); }
this._UpdateCellBorder(this.Borders.get_Between(), 't', this.BordersImage.getCell(i, 1));
}
} }
this.BordersImage.setVirtualBorderSize(oldSize.pxValue); this.BordersImage.setVirtualBorderSize(oldSize.pxValue);
this.BordersImage.setVirtualBorderColor((typeof(oldColor) == 'object') ? oldColor.color : oldColor); this.BordersImage.setVirtualBorderColor((typeof(oldColor) == 'object') ? oldColor.color : oldColor);
this.BordersImage.redrawTable();
}, },
_UpdateCellBorder: function(BorderParam, borderName, cell){ _UpdateCellBorder: function(BorderParam, betweenBorder){
if (null !== BorderParam && undefined !== BorderParam){ if (null !== BorderParam && undefined !== BorderParam){
if (null !== BorderParam.get_Value() && null !== BorderParam.get_Size() && null !== BorderParam.get_Color() && 1 == BorderParam.get_Value()){ if (null !== BorderParam.get_Value() && null !== BorderParam.get_Size() && null !== BorderParam.get_Color() && 1 == BorderParam.get_Value()){
cell.setBordersSize(borderName, this._BorderPt2Px(BorderParam.get_Size() * 72 / 25.4)); betweenBorder.setBordersSize( this._BorderPt2Px(BorderParam.get_Size() * 72 / 25.4));
cell.setBordersColor(borderName, 'rgb(' + BorderParam.get_Color().get_r() + ',' + BorderParam.get_Color().get_g() + ',' + BorderParam.get_Color().get_b() + ')'); betweenBorder.setBordersColor(new Common.Utils.RGBColor('rgb(' + BorderParam.get_Color().get_r() + ',' + BorderParam.get_Color().get_g() + ',' + BorderParam.get_Color().get_b() + ')'));
} else } else
cell.setBordersSize(borderName, 0); betweenBorder.setBordersSize( 0);
} }
else { else {
cell.setBordersSize(borderName, 0); betweenBorder.setBordersSize( 0);
} }
}, },
@ -1360,8 +1325,8 @@ define([ 'text!documenteditor/main/app/template/ParagraphSettingsAdvanced.tem
if (value <=1.5) return 2; if (value <=1.5) return 2;
if (value <=2.25) return 3; if (value <=2.25) return 3;
if (value <=3) return 4; if (value <=3) return 4;
if (value <=4.5) return 5; if (value <=4.5) return 6;
return 6; return 8;
}, },
addTab: function(btn, eOpts){ addTab: function(btn, eOpts){

View file

@ -1069,10 +1069,21 @@ define([ 'text!documenteditor/main/app/template/TableSettingsAdvanced.templat
}, },
afterRender: function() { afterRender: function() {
this.updateMetricUnit();
this.updateThemeColors();
this._setDefaults(this._originalProps); this._setDefaults(this._originalProps);
var cellcolorstr = (typeof(this.CellColor.Color) == 'object') ? this.CellColor.Color.color : this.CellColor.Color,
tablecolorstr = (typeof(this.TableColor.Color) == 'object') ? this.TableColor.Color.color : this.TableColor.Color;
this.tableBordersImageSpacing.setTableColor(tablecolorstr);
this.tableBordersImage.setTableColor(tablecolorstr);
this.tableBordersImageSpacing.setCellsColor(cellcolorstr);
this.tableBordersImage.setCellsColor((this._allTable) ? tablecolorstr : cellcolorstr);
if(colorstr!='transparent') {
this.tableBordersImage.redrawTable();
this.tableBordersImageSpacing.redrawTable();
}
this.updateMetricUnit();
this.updateThemeColors();
if (this.borderProps !== undefined) { if (this.borderProps !== undefined) {
this.btnBorderColor.setColor(this.borderProps.borderColor); this.btnBorderColor.setColor(this.borderProps.borderColor);
@ -1091,39 +1102,20 @@ define([ 'text!documenteditor/main/app/template/TableSettingsAdvanced.templat
this.onBorderSizeSelect(this.cmbBorderSize, rec); this.onBorderSizeSelect(this.cmbBorderSize, rec);
} }
for (var i=0; i<this.tableBordersImageSpacing.rows; i++) { this.tableBordersImageSpacing.on('borderclick:cellborder', function(ct, border, size, color){
for (var j=0; j<this.tableBordersImageSpacing.columns; j++) { if (this.ChangedCellBorders===undefined) {
this.tableBordersImageSpacing.getCell(j, i).on('borderclick', function(ct, border, size, color){ this.ChangedCellBorders = new Asc.CBorders();
if (this.ChangedCellBorders===undefined) {
this.ChangedCellBorders = new Asc.CBorders();
}
this._UpdateCellBordersStyle(ct, border, size, color, this.CellBorders, this.ChangedCellBorders);
}, this);
} }
} this._UpdateCellBordersStyle(ct, border, size, color, this.CellBorders, this.ChangedCellBorders);
}, this);
this.tableBordersImageSpacing.on('borderclick', function(ct, border, size, color){ this.tableBordersImageSpacing.on('borderclick', function(ct, border, size, color){
if (this.ChangedTableBorders===undefined) { if (this.ChangedTableBorders===undefined) {
this.ChangedTableBorders = new Asc.CBorders(); this.ChangedTableBorders = new Asc.CBorders();
} }
this._UpdateTableBordersStyle(ct, border, size, color, this.TableBorders, this.ChangedTableBorders); this._UpdateTableBordersStyle(ct, border, size, color, this.TableBorders, this.ChangedTableBorders);
}, this); }, this);
for (i=0; i<this.tableBordersImage.rows; i++) {
for (j=0; j<this.tableBordersImage.columns; j++) {
this.tableBordersImage.getCell(j, i).on('borderclick', function(ct, border, size, color){
if (this._allTable) {
if (this.ChangedTableBorders===undefined) {
this.ChangedTableBorders = new Asc.CBorders();
}
} else {
if (this.ChangedCellBorders===undefined) {
this.ChangedCellBorders = new Asc.CBorders();
}
}
this._UpdateCellBordersStyle(ct, border, size, color, (this._allTable) ? this.TableBorders : this.CellBorders, (this._allTable) ? this.ChangedTableBorders : this.ChangedCellBorders);
}, this);
}
}
this.tableBordersImage.on('borderclick', function(ct, border, size, color){ this.tableBordersImage.on('borderclick', function(ct, border, size, color){
if (this._allTable) { if (this._allTable) {
if (this.ChangedTableBorders===undefined) { if (this.ChangedTableBorders===undefined) {
@ -1135,14 +1127,22 @@ define([ 'text!documenteditor/main/app/template/TableSettingsAdvanced.templat
} }
} }
this._UpdateTableBordersStyle(ct, border, size, color, (this._allTable) ? this.TableBorders : this.CellBorders, (this._allTable) ? this.ChangedTableBorders : this.ChangedCellBorders); this._UpdateTableBordersStyle(ct, border, size, color, (this._allTable) ? this.TableBorders : this.CellBorders, (this._allTable) ? this.ChangedTableBorders : this.ChangedCellBorders);
}, this); }, this);
var cellcolorstr = (typeof(this.CellColor.Color) == 'object') ? this.CellColor.Color.color : this.CellColor.Color, this.tableBordersImage.on('borderclick:cellborder', function(ct, border, size, color){
tablecolorstr = (typeof(this.TableColor.Color) == 'object') ? this.TableColor.Color.color : this.TableColor.Color; if (this._allTable) {
this.tableBordersImageSpacing.setTableColor(tablecolorstr); if (this.ChangedTableBorders===undefined) {
this.tableBordersImage.setTableColor(tablecolorstr); this.ChangedTableBorders = new Asc.CBorders();
this.tableBordersImageSpacing.setCellsColor(cellcolorstr); }
this.tableBordersImage.setCellsColor((this._allTable) ? tablecolorstr : cellcolorstr); } else {
if (this.ChangedCellBorders===undefined) {
this.ChangedCellBorders = new Asc.CBorders();
}
}
this._UpdateCellBordersStyle(ct, border, size, color, (this._allTable) ? this.TableBorders : this.CellBorders, (this._allTable) ? this.ChangedTableBorders : this.ChangedCellBorders);
}, this);
if (this.storageName) { if (this.storageName) {
var value = Common.localStorage.getItem(this.storageName); var value = Common.localStorage.getItem(this.storageName);
@ -1748,8 +1748,11 @@ define([ 'text!documenteditor/main/app/template/TableSettingsAdvanced.templat
} }
var colorstr = (typeof(color) == 'object') ? color.color : color; var colorstr = (typeof(color) == 'object') ? color.color : color;
this.tableBordersImageSpacing.setCellsColor(colorstr); this.tableBordersImageSpacing.setCellsColor(colorstr);
if (!this._allTable) this.tableBordersImageSpacing.redrawTable()
if (!this._allTable) {
this.tableBordersImage.setCellsColor(colorstr); this.tableBordersImage.setCellsColor(colorstr);
this.tableBordersImage.redrawTable();
}
}, },
onColorsTableBackSelect: function(btn, color) { onColorsTableBackSelect: function(btn, color) {
@ -1774,6 +1777,8 @@ define([ 'text!documenteditor/main/app/template/TableSettingsAdvanced.templat
this.tableBordersImage.setTableColor(colorstr); this.tableBordersImage.setTableColor(colorstr);
if (this._allTable) if (this._allTable)
this.tableBordersImage.setCellsColor(colorstr); this.tableBordersImage.setCellsColor(colorstr);
this.tableBordersImage.redrawTable();
this.tableBordersImageSpacing.redrawTable();
}, },
_UpdateBordersSpacing_: function (){ _UpdateBordersSpacing_: function (){
@ -1789,28 +1794,19 @@ define([ 'text!documenteditor/main/app/template/TableSettingsAdvanced.templat
source = this.CellBorders; source = this.CellBorders;
for (var i=0; i<this.tableBordersImageSpacing.rows; i++) { this._UpdateCellBorderSpacing_(source.get_Top(), this.tableBordersImageSpacing.getCellBorder(0, -1,0));
this._UpdateCellBorderSpacing_(source.get_Left(), 'l', this.tableBordersImageSpacing.getCell(0, i)); this._UpdateCellBorderSpacing_(source.get_Left(), this.tableBordersImageSpacing.getCellBorder(-1, 0, 0));
} this._UpdateCellBorderSpacing_(source.get_Bottom(), this.tableBordersImageSpacing.getCellBorder(this.tableBordersImageSpacing.rows -1, -1,1));
this._UpdateCellBorderSpacing_(source.get_Right(), this.tableBordersImageSpacing.getCellBorder(-1, this.tableBordersImageSpacing.columns-1, 1));
for (i=0; i<this.tableBordersImageSpacing.rows; i++) {
this._UpdateCellBorderSpacing_(source.get_Right(), 'r', this.tableBordersImageSpacing.getCell(this.tableBordersImageSpacing.columns-1, i));
}
for (i=0; i<this.tableBordersImageSpacing.columns; i++) {
this._UpdateCellBorderSpacing_(source.get_Top(), 't', this.tableBordersImageSpacing.getCell(i, 0));
}
for (i=0; i<this.tableBordersImageSpacing.columns; i++) {
this._UpdateCellBorderSpacing_(source.get_Bottom(), 'b', this.tableBordersImageSpacing.getCell(i, this.tableBordersImageSpacing.rows-1));
}
if (this._allTable && source.get_InsideV() === null) { if (this._allTable && source.get_InsideV() === null) {
source.put_InsideV(new Asc.asc_CTextBorder()); source.put_InsideV(new Asc.asc_CTextBorder());
} }
if (source.get_InsideV() !== null) { if (source.get_InsideV() !== null) {
for (i=0; i<this.tableBordersImageSpacing.rows; i++) { for (var i=0; i<this.tableBordersImageSpacing.columns-1; i++) {
this._UpdateCellBorderSpacing_(source.get_InsideV(), 'r', this.tableBordersImageSpacing.getCell(0, i)); this._UpdateCellBorderSpacing_(source.get_InsideV(), this.tableBordersImageSpacing.getCellBorder(-1, i, 1));
this._UpdateCellBorderSpacing_(source.get_InsideV(), 'l', this.tableBordersImageSpacing.getCell(1, i)); this._UpdateCellBorderSpacing_(source.get_InsideV(), this.tableBordersImageSpacing.getCellBorder(-1, i+1, 0));
} }
} }
@ -1818,32 +1814,34 @@ define([ 'text!documenteditor/main/app/template/TableSettingsAdvanced.templat
source.put_InsideH(new Asc.asc_CTextBorder()); source.put_InsideH(new Asc.asc_CTextBorder());
} }
if (source.get_InsideH() !== null) { if (source.get_InsideH() !== null) {
for (i=0; i<this.tableBordersImageSpacing.columns; i++) { for (var i=0; i<this.tableBordersImageSpacing.rows-1; i++) {
this._UpdateCellBorderSpacing_(source.get_InsideH(), 'b', this.tableBordersImageSpacing.getCell(i, 0)); this._UpdateCellBorderSpacing_(source.get_InsideH(), this.tableBordersImageSpacing.getCellBorder(i, -1,1));
this._UpdateCellBorderSpacing_(source.get_InsideH(), 't', this.tableBordersImageSpacing.getCell(i, 1)); this._UpdateCellBorderSpacing_(source.get_InsideH(), this.tableBordersImageSpacing.getCellBorder(i+1, -1,0));
} }
} }
this.tableBordersImageSpacing.setVirtualBorderSize(oldSize.pxValue); this.tableBordersImageSpacing.setVirtualBorderSize(oldSize.pxValue);
this.tableBordersImageSpacing.setVirtualBorderColor((typeof(oldColor) == 'object') ? oldColor.color : oldColor); this.tableBordersImageSpacing.setVirtualBorderColor((typeof(oldColor) == 'object') ? oldColor.color : oldColor);
this.tableBordersImageSpacing.redrawTable();
}, },
_UpdateCellBorderSpacing_: function(BorderParam, borderName, cell){ _UpdateCellBorderSpacing_: function(BorderParam, cell){
if (null !== BorderParam && undefined !== BorderParam){ if (null !== BorderParam && undefined !== BorderParam){
if (null !== BorderParam.get_Value() && null !== BorderParam.get_Size() && null !== BorderParam.get_Color()){ if (null !== BorderParam.get_Value() && null !== BorderParam.get_Size() && null !== BorderParam.get_Color()){
if (1 == BorderParam.get_Value()) { if (1 == BorderParam.get_Value()) {
cell.setBordersSize(borderName, this._BorderPt2Px(BorderParam.get_Size() * 72 / 25.4)); cell.setBordersSize(this._BorderPt2Px(BorderParam.get_Size() * 72 / 25.4));
cell.setBordersColor(borderName, 'rgb(' + BorderParam.get_Color().get_r() + ',' + BorderParam.get_Color().get_g() + ',' + BorderParam.get_Color().get_b() + ')'); cell.setBordersColor('rgb(' + BorderParam.get_Color().get_r() + ',' + BorderParam.get_Color().get_g() + ',' + BorderParam.get_Color().get_b() + ')');
} else } else
cell.setBordersSize(borderName, 0); cell.setBordersSize(0);
} else { } else {
cell.setBordersSize(borderName, this.IndeterminateSize); cell.setBordersSize(this.IndeterminateSize);
cell.setBordersColor(borderName, this.IndeterminateColor); cell.setBordersColor(this.IndeterminateColor);
} }
} }
else { else {
cell.setBordersSize(borderName, this.IndeterminateSize); cell.setBordersSize(this.IndeterminateSize);
cell.setBordersColor(borderName, this.IndeterminateColor); cell.setBordersColor(this.IndeterminateColor);
} }
}, },
@ -1881,9 +1879,8 @@ define([ 'text!documenteditor/main/app/template/TableSettingsAdvanced.templat
source.put_InsideV(new Asc.asc_CTextBorder()); source.put_InsideV(new Asc.asc_CTextBorder());
} }
if (source.get_InsideV() !== null) { if (source.get_InsideV() !== null) {
for (var i=0; i<this.tableBordersImage.rows; i++) { for (var i=0; i < this.tableBordersImage.columns-1; i++) {
this._UpdateCellBorderNoSpacing_(source.get_InsideV(), 'r', this.tableBordersImage.getCell(0, i)); this._UpdateCellBorderNoSpacing_(source.get_InsideV(), this.tableBordersImage.getCellBorder(-1, i));
this._UpdateCellBorderNoSpacing_(source.get_InsideV(), 'l', this.tableBordersImage.getCell(1, i));
} }
} }
@ -1891,32 +1888,32 @@ define([ 'text!documenteditor/main/app/template/TableSettingsAdvanced.templat
source.put_InsideH(new Asc.asc_CTextBorder()); source.put_InsideH(new Asc.asc_CTextBorder());
} }
if (source.get_InsideH() !== null) { if (source.get_InsideH() !== null) {
for (i=0; i<this.tableBordersImage.columns; i++) { for (i=0; i<this.tableBordersImage.rows-1; i++) {
this._UpdateCellBorderNoSpacing_(source.get_InsideH(), 'b', this.tableBordersImage.getCell(i, 0)); this._UpdateCellBorderNoSpacing_(source.get_InsideH(), this.tableBordersImage.getCellBorder(i, -1));
this._UpdateCellBorderNoSpacing_(source.get_InsideH(), 't', this.tableBordersImage.getCell(i, 1));
} }
} }
this.tableBordersImage.setVirtualBorderSize(oldSize.pxValue); this.tableBordersImage.setVirtualBorderSize(oldSize.pxValue);
this.tableBordersImage.setVirtualBorderColor((typeof(oldColor) == 'object') ? oldColor.color : oldColor); this.tableBordersImage.setVirtualBorderColor((typeof(oldColor) == 'object') ? oldColor.color : oldColor);
}, },
_UpdateCellBorderNoSpacing_: function(BorderParam, borderName, cell){ _UpdateCellBorderNoSpacing_: function(BorderParam, cell){
if (null !== BorderParam && undefined !== BorderParam){ if (null !== BorderParam && undefined !== BorderParam){
if (null !== BorderParam.get_Value() && null !== BorderParam.get_Size() && null !== BorderParam.get_Color()){ if (null !== BorderParam.get_Value() && null !== BorderParam.get_Size() && null !== BorderParam.get_Color()){
if (1 == BorderParam.get_Value()) { if (1 == BorderParam.get_Value()) {
cell.setBordersSize(borderName, this._BorderPt2Px(BorderParam.get_Size() * 72 / 25.4)); cell.setBordersSize( this._BorderPt2Px(BorderParam.get_Size() * 72 / 25.4));
cell.setBordersColor(borderName, 'rgb(' + BorderParam.get_Color().get_r() + ',' + BorderParam.get_Color().get_g() + ',' + BorderParam.get_Color().get_b() + ')'); cell.setBordersColor( 'rgb(' + BorderParam.get_Color().get_r() + ',' + BorderParam.get_Color().get_g() + ',' + BorderParam.get_Color().get_b() + ')');
} else } else
cell.setBordersSize(borderName, 0); cell.setBordersSize( 0);
} else { } else {
cell.setBordersSize(borderName, this.IndeterminateSize); cell.setBordersSize( this.IndeterminateSize);
cell.setBordersColor(borderName, this.IndeterminateColor); cell.setBordersColor( this.IndeterminateColor);
} }
} }
else { else {
cell.setBordersSize(borderName, this.IndeterminateSize); cell.setBordersSize( this.IndeterminateSize);
cell.setBordersColor(borderName, this.IndeterminateColor); cell.setBordersColor( this.IndeterminateColor);
} }
}, },
@ -1946,8 +1943,8 @@ define([ 'text!documenteditor/main/app/template/TableSettingsAdvanced.templat
if (value <=1.5) return 2; if (value <=1.5) return 2;
if (value <=2.25) return 3; if (value <=2.25) return 3;
if (value <=3) return 4; if (value <=3) return 4;
if (value <=4.5) return 5; if (value <=4.5) return 6;
return 6; return 8;
}, },
_ApplyBorderPreset: function(btn) { _ApplyBorderPreset: function(btn) {
@ -1983,6 +1980,8 @@ define([ 'text!documenteditor/main/app/template/TableSettingsAdvanced.templat
this._UpdateBorderStyle(updateBorders.get_InsideV(), (cellborder.indexOf('c') > -1)); this._UpdateBorderStyle(updateBorders.get_InsideV(), (cellborder.indexOf('c') > -1));
this._UpdateBorderStyle(updateBorders.get_InsideH(), (cellborder.indexOf('m') > -1)); this._UpdateBorderStyle(updateBorders.get_InsideH(), (cellborder.indexOf('m') > -1));
} }
this.tableBordersImageSpacing.redrawTable();
this.tableBordersImage.redrawTable();
return; return;
} }
@ -2000,42 +1999,37 @@ define([ 'text!documenteditor/main/app/template/TableSettingsAdvanced.templat
_UpdateCellBordersStyle: function(ct, border, size, color, destination, changed_destination) { _UpdateCellBordersStyle: function(ct, border, size, color, destination, changed_destination) {
var updateBorders = destination; var updateBorders = destination;
if ( ct.col==0 && border.indexOf('l') > -1 ) { if(border.col == 0 && border.numInCell == 0){
this._UpdateBorderStyle(updateBorders.get_Left(), (size>0)); this._UpdateBorderStyle(updateBorders.get_Left(), (size>0));
if (changed_destination) { if (changed_destination) {
changed_destination.put_Left(new Asc.asc_CTextBorder(updateBorders.get_Left())); changed_destination.put_Left(new Asc.asc_CTextBorder(updateBorders.get_Left()));
} }
} }
else if(border.col == border.columns-1 && border.numInCell == 1){
if ( ct.col== this.tableStylerColumns-1 && border.indexOf('r') > -1 ) {
this._UpdateBorderStyle(updateBorders.get_Right(), (size>0)); this._UpdateBorderStyle(updateBorders.get_Right(), (size>0));
if (changed_destination) { if (changed_destination) {
changed_destination.put_Right(new Asc.asc_CTextBorder(updateBorders.get_Right())); changed_destination.put_Right(new Asc.asc_CTextBorder(updateBorders.get_Right()));
} }
} }
else if(border.row == 0 && border.numInCell == 0){
if ( ct.row==0 && border.indexOf('t') > -1 ) {
this._UpdateBorderStyle(updateBorders.get_Top(), (size>0)); this._UpdateBorderStyle(updateBorders.get_Top(), (size>0));
if (changed_destination) { if (changed_destination) {
changed_destination.put_Top(new Asc.asc_CTextBorder(updateBorders.get_Top())); changed_destination.put_Top(new Asc.asc_CTextBorder(updateBorders.get_Top()));
} }
} }
else if(border.row == border.rows-1 && border.numInCell == 1){
if ( ct.row== this.tableStylerRows-1 && border.indexOf('b') > -1 ) {
this._UpdateBorderStyle(updateBorders.get_Bottom(), (size>0)); this._UpdateBorderStyle(updateBorders.get_Bottom(), (size>0));
if (changed_destination) { if (changed_destination) {
changed_destination.put_Bottom(new Asc.asc_CTextBorder(updateBorders.get_Bottom())); changed_destination.put_Bottom(new Asc.asc_CTextBorder(updateBorders.get_Bottom()));
} }
} }
else if ( border.col > -1 ) {
if ( ct.col==0 && border.indexOf('r') > -1 || ct.col== this.tableStylerColumns-1 && border.indexOf('l') > -1) {
this._UpdateBorderStyle(updateBorders.get_InsideV(), (size>0)); this._UpdateBorderStyle(updateBorders.get_InsideV(), (size>0));
if (changed_destination) { if (changed_destination) {
changed_destination.put_InsideV(new Asc.asc_CTextBorder(updateBorders.get_InsideV())); changed_destination.put_InsideV(new Asc.asc_CTextBorder(updateBorders.get_InsideV()));
} }
} }
else if ( border.row > -1 ) {
if ( ct.row==0 && border.indexOf('b') > -1 || ct.row== this.tableStylerRows-1 && border.indexOf('t') > -1) {
this._UpdateBorderStyle(updateBorders.get_InsideH(), (size>0)); this._UpdateBorderStyle(updateBorders.get_InsideH(), (size>0));
if (changed_destination) { if (changed_destination) {
changed_destination.put_InsideH(new Asc.asc_CTextBorder(updateBorders.get_InsideH())); changed_destination.put_InsideH(new Asc.asc_CTextBorder(updateBorders.get_InsideH()));
@ -2051,20 +2045,17 @@ define([ 'text!documenteditor/main/app/template/TableSettingsAdvanced.templat
if (changed_destination) { if (changed_destination) {
changed_destination.put_Left(new Asc.asc_CTextBorder(updateBorders.get_Left())); changed_destination.put_Left(new Asc.asc_CTextBorder(updateBorders.get_Left()));
} }
} }else if (border.indexOf('t') > -1) {
if (border.indexOf('t') > -1) {
this._UpdateBorderStyle(updateBorders.get_Top(), (size>0)); this._UpdateBorderStyle(updateBorders.get_Top(), (size>0));
if (changed_destination) { if (changed_destination) {
changed_destination.put_Top(new Asc.asc_CTextBorder(updateBorders.get_Top())); changed_destination.put_Top(new Asc.asc_CTextBorder(updateBorders.get_Top()));
} }
} }else if (border.indexOf('r') > -1) {
if (border.indexOf('r') > -1) {
this._UpdateBorderStyle(updateBorders.get_Right(), (size>0)); this._UpdateBorderStyle(updateBorders.get_Right(), (size>0));
if (changed_destination) { if (changed_destination) {
changed_destination.put_Right(new Asc.asc_CTextBorder(updateBorders.get_Right())); changed_destination.put_Right(new Asc.asc_CTextBorder(updateBorders.get_Right()));
} }
} }else if (border.indexOf('b') > -1) {
if (border.indexOf('b') > -1) {
this._UpdateBorderStyle(updateBorders.get_Bottom(), (size>0)); this._UpdateBorderStyle(updateBorders.get_Bottom(), (size>0));
if (changed_destination) { if (changed_destination) {
changed_destination.put_Bottom(new Asc.asc_CTextBorder(updateBorders.get_Bottom())); changed_destination.put_Bottom(new Asc.asc_CTextBorder(updateBorders.get_Bottom()));