From e321dccbcd1cd63bb4a848e937ca53ac1633a5fc Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Wed, 5 Oct 2022 20:55:30 +0300 Subject: [PATCH] [DE] Fill format string from list settings --- .../main/app/view/ListSettingsDialog.js | 96 ++++++++++--------- 1 file changed, 52 insertions(+), 44 deletions(-) diff --git a/apps/documenteditor/main/app/view/ListSettingsDialog.js b/apps/documenteditor/main/app/view/ListSettingsDialog.js index a7afd5955..dc1cc8fca 100644 --- a/apps/documenteditor/main/app/view/ListSettingsDialog.js +++ b/apps/documenteditor/main/app/view/ListSettingsDialog.js @@ -153,6 +153,7 @@ define([ this.api = options.api; this.options.tpl = _.template(this.template)(this.options); this.levels = []; + this.formatStrings = []; Common.UI.Window.prototype.initialize.call(this, this.options); }, @@ -257,6 +258,7 @@ define([ store.add({ displayValue: me.txtSymbol + ': ', value: Asc.c_oAscNumberingFormat.Bullet, symbol: me.bulletProps.symbol, font: me.bulletProps.font }, {at: store.length-1}); combo.setData(store.models); combo.selectRecord(combo.store.findWhere({value: Asc.c_oAscNumberingFormat.Bullet, symbol: me.bulletProps.symbol, font: me.bulletProps.font})); + me.makeFormatStr(me._changedProps); } else combo.setValue(format || ''); }; @@ -272,7 +274,7 @@ define([ this._changedProps.put_Text([new Asc.CAscNumberingLvlText()]); this._changedProps.get_Text()[0].put_Value(this.bulletProps.symbol); - } else if (record.value == Asc.c_oAscNumberingFormat.None || oldformat == Asc.c_oAscNumberingFormat.Bullet) { + } else if (oldformat == Asc.c_oAscNumberingFormat.Bullet) { if (!this._changedProps.get_TextPr()) this._changedProps.put_TextPr(new AscCommonWord.CTextPr()); this._changedProps.get_TextPr().put_FontFamily(undefined); @@ -280,6 +282,7 @@ define([ this._changedProps.get_Text()[0].put_Type(Asc.c_oAscNumberingLvlTextType.Num); this._changedProps.get_Text()[0].put_Value(this.level); } + this.makeFormatStr(this._changedProps); } } if (this.api) { @@ -603,65 +606,70 @@ define([ } else if (this.type===2) { this.txtNumFormat.setDisabled(format == Asc.c_oAscNumberingFormat.Bullet); - this.cmbLevel.setDisabled(format == Asc.c_oAscNumberingFormat.Bullet); - this.cmbLevel.setDisabled(this.level===0); var arr = []; var me = this; for (var lvl=0; lvl0) ? record.value : undefined); + makeFormatStr: function(props) { + var formatStr = ''; + this.formatStrings[this.level] = []; + if (props) { + if (props.get_Format() !== Asc.c_oAscNumberingFormat.Bullet) { + var text = props.get_Text(); + var me = this; + var arr = this.formatStrings[this.level]; + text.forEach(function (item, index) { + if (item.get_Type() === Asc.c_oAscNumberingLvlTextType.Text) { + formatStr += item.get_Value().toString(); + } else if (item.get_Type() === Asc.c_oAscNumberingLvlTextType.Num) { + var num = item.get_Value(); + if (me.levels[num] === undefined) + me.levels[num] = me.props.get_Lvl(num); + arr[num] = {start: formatStr.length, index: index}; + var lvl = me.levels[num]; + formatStr += AscCommon.IntToNumberFormat(lvl.get_Start(), lvl.get_Format()); + arr[num].end = formatStr.length; + } + }); + } } + this.txtNumFormat.setValue(formatStr); }, onIncludeLevelSelected: function (combo, record) { - var $txt, end, start; var $txt = this.txtNumFormat.$el.find('input'), - start = $txt[0].selectionStart, - end = $txt[0].selectionEnd, - newVal = AscCommon.IntToNumberFormat(1, record.value); - $txt.val($txt.val().substring(0, start) + newVal + $txt.val().substring(end)); - this.selectionStart = this.selectionEnd = start + newVal.length; - - var text = this._changedProps.get_Text(); + selectionStart = $txt[0].selectionStart; if (this._changedProps) { - var arr = []; - 'перед'.split('').forEach(function (el) { - var t = new Asc.CAscNumberingLvlText(Asc.c_oAscNumberingLvlTextType.Text, el); - arr.push(t); - }); - arr.push(new Asc.CAscNumberingLvlText(Asc.c_oAscNumberingLvlTextType.Num, 0)); - 'после'.split('').forEach(function (el) { - var t = new Asc.CAscNumberingLvlText(Asc.c_oAscNumberingLvlTextType.Text, el); - arr.push(t); - }); - - // if (!this._changedProps.get_TextPr()) this._changedProps.put_TextPr(new AscCommonWord.CTextPr()); - // this._changedProps.get_TextPr().put_FontSize((record.value>0) ? record.value : undefined); + var text = this._changedProps.get_Text(), + arr = this.formatStrings[this.level]; + for (var i=0; i