From 46d7ed84f1418e472becc351265084ceb557d8bf Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Thu, 28 Jan 2021 21:56:57 +0300 Subject: [PATCH] [SSE] Draw preview when format is not set --- apps/common/main/lib/util/define.js | 3 +- .../main/app/view/FormatRulesEditDlg.js | 38 ++++++++++++------- .../main/app/view/FormatRulesManagerDlg.js | 3 +- 3 files changed, 28 insertions(+), 16 deletions(-) diff --git a/apps/common/main/lib/util/define.js b/apps/common/main/lib/util/define.js index 6abf9bbf3..1a70ed047 100644 --- a/apps/common/main/lib/util/define.js +++ b/apps/common/main/lib/util/define.js @@ -547,7 +547,8 @@ define(function(){ 'use strict'; textDataBar: 'Data bar', textIconSets: 'Icon sets', textFormula: 'Formula', - exampleText: 'AaBbCcYyZz' + exampleText: 'AaBbCcYyZz', + noFormatText: 'No format set' } })(), Common.define.conditionalData || {}); }); diff --git a/apps/spreadsheeteditor/main/app/view/FormatRulesEditDlg.js b/apps/spreadsheeteditor/main/app/view/FormatRulesEditDlg.js index 70e6be9d9..31321d759 100644 --- a/apps/spreadsheeteditor/main/app/view/FormatRulesEditDlg.js +++ b/apps/spreadsheeteditor/main/app/view/FormatRulesEditDlg.js @@ -1158,7 +1158,6 @@ define([ this.refreshRules(rec.get('index'), ruleType); } - this.xfsFormat = new AscCommonExcel.CellXfs(); if (props) { if (type == Asc.c_oAscCFType.containsText || type == Asc.c_oAscCFType.notContainsText || type == Asc.c_oAscCFType.beginsWith || type == Asc.c_oAscCFType.endsWith || type == Asc.c_oAscCFType.timePeriod || type == Asc.c_oAscCFType.aboveAverage || @@ -1166,8 +1165,8 @@ define([ this.xfsFormat = props.asc_getDxf(); } } - if (this.xfsFormat) { - var xfs = this.xfsFormat; + var xfs = this.xfsFormat ? this.xfsFormat : (new AscCommonExcel.CellXfs()); + if (xfs) { this.btnBold.toggle(xfs.asc_getFontBold() === true, true); this.btnItalic.toggle(xfs.asc_getFontItalic() === true, true); this.btnUnderline.toggle(xfs.asc_getFontUnderline() === true, true); @@ -1188,7 +1187,7 @@ define([ var val = xfs.asc_getNumFormatInfo(); val && this.cmbNumberFormat.setValue(val.asc_getType(), this.textCustom); } - this.api.asc_getPreviewCF('format-rules-edit-preview-format', this.xfsFormat, Common.define.conditionalData.exampleText); + this.previewFormat(); }, getSettings: function() { @@ -1202,7 +1201,7 @@ define([ if (type == Asc.c_oAscCFType.containsText || type == Asc.c_oAscCFType.containsBlanks || type == Asc.c_oAscCFType.duplicateValues || type == Asc.c_oAscCFType.timePeriod || type == Asc.c_oAscCFType.aboveAverage || type == Asc.c_oAscCFType.top10 || type == Asc.c_oAscCFType.cellIs || type == Asc.c_oAscCFType.expression) { - props.asc_setDxf(this.xfsFormat); + this.xfsFormat && props.asc_setDxf(this.xfsFormat); } switch (type) { @@ -1365,22 +1364,26 @@ define([ }, onBoldClick: function() { + !this.xfsFormat && (this.xfsFormat = new AscCommonExcel.CellXfs()); this.xfsFormat.asc_setFontBold(this.btnBold.isActive()); - this.api.asc_getPreviewCF('format-rules-edit-preview-format', this.xfsFormat, Common.define.conditionalData.exampleText); + this.previewFormat(); }, onItalicClick: function() { + !this.xfsFormat && (this.xfsFormat = new AscCommonExcel.CellXfs()); this.xfsFormat.asc_setFontItalic(this.btnItalic.isActive()); - this.api.asc_getPreviewCF('format-rules-edit-preview-format', this.xfsFormat, Common.define.conditionalData.exampleText); + this.previewFormat(); }, onUnderlineClick: function() { + !this.xfsFormat && (this.xfsFormat = new AscCommonExcel.CellXfs()); this.xfsFormat.asc_setFontUnderline(this.btnUnderline.isActive()); - this.api.asc_getPreviewCF('format-rules-edit-preview-format', this.xfsFormat, Common.define.conditionalData.exampleText); + this.previewFormat(); }, onStrikeoutClick: function() { + !this.xfsFormat && (this.xfsFormat = new AscCommonExcel.CellXfs()); this.xfsFormat.asc_setFontStrikeout(this.btnStrikeout.isActive()); - this.api.asc_getPreviewCF('format-rules-edit-preview-format', this.xfsFormat, Common.define.conditionalData.exampleText); + this.previewFormat(); }, onBordersWidth: function(menu, item, state) { @@ -1443,9 +1446,9 @@ define([ } else if (item.options.borderId != 'none') { new_borders[item.options.borderId] = new Asc.asc_CBorder(bordersWidth, bordersColor); } - this.xfsFormat.asc_setFontStrikeout(this.btnStrikeout.isActive()); + !this.xfsFormat && (this.xfsFormat = new AscCommonExcel.CellXfs()); this.xfsFormat.asc_setBorder(new_borders); - this.api.asc_getPreviewCF('format-rules-edit-preview-format', this.xfsFormat, Common.define.conditionalData.exampleText); + this.previewFormat(); } }, @@ -1455,8 +1458,9 @@ define([ $('.btn-color-value-line', this.btnTextColor.cmpEl).css('background-color', '#' + clr); picker.currentColor = color; + !this.xfsFormat && (this.xfsFormat = new AscCommonExcel.CellXfs()); this.xfsFormat.asc_setFontColor(Common.Utils.ThemeColor.getRgbColor(this.mnuTextColorPicker.currentColor)); - this.api.asc_getPreviewCF('format-rules-edit-preview-format', this.xfsFormat, Common.define.conditionalData.exampleText); + this.previewFormat(); }, onFormatTextColor: function(btn, e) { @@ -1469,8 +1473,9 @@ define([ $('.btn-color-value-line', this.btnFillColor.cmpEl).css('background-color', clr=='transparent' ? 'transparent' : '#' + clr); picker.currentColor = color; + !this.xfsFormat && (this.xfsFormat = new AscCommonExcel.CellXfs()); this.xfsFormat.asc_setFillColor(this.mnuFillColorPicker.currentColor == 'transparent' ? null : Common.Utils.ThemeColor.getRgbColor(this.mnuFillColorPicker.currentColor)); - this.api.asc_getPreviewCF('format-rules-edit-preview-format', this.xfsFormat, Common.define.conditionalData.exampleText); + this.previewFormat(); }, onFormatFillColor: function(picker, btn, e) { @@ -1478,8 +1483,13 @@ define([ }, onNumberFormatSelect: function(combo, record) { + !this.xfsFormat && (this.xfsFormat = new AscCommonExcel.CellXfs()); this.xfsFormat.asc_setNumFormatInfo(record.format); - this.api.asc_getPreviewCF('format-rules-edit-preview-format', this.xfsFormat, Common.define.conditionalData.exampleText); + this.previewFormat(); + }, + + previewFormat: function() { + this.api.asc_getPreviewCF('format-rules-edit-preview-format', this.xfsFormat, this.xfsFormat ? Common.define.conditionalData.exampleText : Common.define.conditionalData.noFormatText); }, updateThemeColors: function() { diff --git a/apps/spreadsheeteditor/main/app/view/FormatRulesManagerDlg.js b/apps/spreadsheeteditor/main/app/view/FormatRulesManagerDlg.js index 1de877309..18d1060a7 100644 --- a/apps/spreadsheeteditor/main/app/view/FormatRulesManagerDlg.js +++ b/apps/spreadsheeteditor/main/app/view/FormatRulesManagerDlg.js @@ -473,7 +473,8 @@ define([ 'text!spreadsheeteditor/main/app/template/FormatRulesManagerDlg.templa if (type == Asc.c_oAscCFType.containsText || type == Asc.c_oAscCFType.notContainsText || type == Asc.c_oAscCFType.beginsWith || type == Asc.c_oAscCFType.endsWith || type == Asc.c_oAscCFType.timePeriod || type == Asc.c_oAscCFType.aboveAverage || type == Asc.c_oAscCFType.top10 || type == Asc.c_oAscCFType.cellIs || type == Asc.c_oAscCFType.expression) { - this.api.asc_getPreviewCF(this.rules[rule.get('ruleIndex')].previewDiv, props.asc_getDxf(), Common.define.conditionalData.exampleText); + var dxf = props.asc_getDxf(); + this.api.asc_getPreviewCF(this.rules[rule.get('ruleIndex')].previewDiv, dxf, dxf ? Common.define.conditionalData.exampleText : Common.define.conditionalData.noFormatText); } },