[DE] Fill format string from list settings
This commit is contained in:
parent
23ad33a06f
commit
e321dccbcd
|
@ -153,6 +153,7 @@ define([
|
||||||
this.api = options.api;
|
this.api = options.api;
|
||||||
this.options.tpl = _.template(this.template)(this.options);
|
this.options.tpl = _.template(this.template)(this.options);
|
||||||
this.levels = [];
|
this.levels = [];
|
||||||
|
this.formatStrings = [];
|
||||||
|
|
||||||
Common.UI.Window.prototype.initialize.call(this, this.options);
|
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});
|
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.setData(store.models);
|
||||||
combo.selectRecord(combo.store.findWhere({value: Asc.c_oAscNumberingFormat.Bullet, symbol: me.bulletProps.symbol, font: me.bulletProps.font}));
|
combo.selectRecord(combo.store.findWhere({value: Asc.c_oAscNumberingFormat.Bullet, symbol: me.bulletProps.symbol, font: me.bulletProps.font}));
|
||||||
|
me.makeFormatStr(me._changedProps);
|
||||||
} else
|
} else
|
||||||
combo.setValue(format || '');
|
combo.setValue(format || '');
|
||||||
};
|
};
|
||||||
|
@ -272,7 +274,7 @@ define([
|
||||||
|
|
||||||
this._changedProps.put_Text([new Asc.CAscNumberingLvlText()]);
|
this._changedProps.put_Text([new Asc.CAscNumberingLvlText()]);
|
||||||
this._changedProps.get_Text()[0].put_Value(this.bulletProps.symbol);
|
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());
|
if (!this._changedProps.get_TextPr()) this._changedProps.put_TextPr(new AscCommonWord.CTextPr());
|
||||||
this._changedProps.get_TextPr().put_FontFamily(undefined);
|
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_Type(Asc.c_oAscNumberingLvlTextType.Num);
|
||||||
this._changedProps.get_Text()[0].put_Value(this.level);
|
this._changedProps.get_Text()[0].put_Value(this.level);
|
||||||
}
|
}
|
||||||
|
this.makeFormatStr(this._changedProps);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this.api) {
|
if (this.api) {
|
||||||
|
@ -603,65 +606,70 @@ define([
|
||||||
|
|
||||||
} else if (this.type===2) {
|
} else if (this.type===2) {
|
||||||
this.txtNumFormat.setDisabled(format == Asc.c_oAscNumberingFormat.Bullet);
|
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 arr = [];
|
||||||
var me = this;
|
var me = this;
|
||||||
for (var lvl=0; lvl<this.level; lvl++) {
|
for (var lvl=0; lvl<this.level; lvl++) {
|
||||||
var lvlprops = this.props.get_Lvl(lvl),
|
var frmt = this.props.get_Lvl(lvl).get_Format();
|
||||||
lvltext = lvlprops.get_Format();
|
if (frmt !== Asc.c_oAscNumberingFormat.None && frmt !== Asc.c_oAscNumberingFormat.Bullet) {
|
||||||
if (this.props.get_Lvl(lvl).get_Format() !== Asc.c_oAscNumberingFormat.None)
|
arr.push({ displayValue: me.textLevel + ' ' + (lvl+1), value: lvl });
|
||||||
arr.push({ displayValue: me.textLevel + ' ' + (lvl+1), value: this.props.get_Lvl(lvl).get_Format() });
|
}
|
||||||
}
|
}
|
||||||
this.cmbLevel.setData(arr);
|
this.cmbLevel.setData(arr);
|
||||||
this.cmbLevel.setValue('');
|
this.cmbLevel.setValue('');
|
||||||
|
this.cmbLevel.setDisabled(format == Asc.c_oAscNumberingFormat.Bullet || this.level===0 || arr.length<1);
|
||||||
|
this.makeFormatStr(levelProps);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
makeFormatStr: function() {
|
makeFormatStr: function(props) {
|
||||||
if (this._changedProps) {
|
var formatStr = '';
|
||||||
var text = this._changedProps.get_Text();
|
this.formatStrings[this.level] = [];
|
||||||
var arr = [];
|
if (props) {
|
||||||
'перед'.split('').forEach(function (el) {
|
if (props.get_Format() !== Asc.c_oAscNumberingFormat.Bullet) {
|
||||||
var t = new Asc.CAscNumberingLvlText(Asc.c_oAscNumberingLvlTextType.Text, el);
|
var text = props.get_Text();
|
||||||
arr.push(t);
|
var me = this;
|
||||||
});
|
var arr = this.formatStrings[this.level];
|
||||||
arr.push(new Asc.CAscNumberingLvlText(Asc.c_oAscNumberingLvlTextType.Num, 0));
|
text.forEach(function (item, index) {
|
||||||
'после'.split('').forEach(function (el) {
|
if (item.get_Type() === Asc.c_oAscNumberingLvlTextType.Text) {
|
||||||
var t = new Asc.CAscNumberingLvlText(Asc.c_oAscNumberingLvlTextType.Text, el);
|
formatStr += item.get_Value().toString();
|
||||||
arr.push(t);
|
} else if (item.get_Type() === Asc.c_oAscNumberingLvlTextType.Num) {
|
||||||
});
|
var num = item.get_Value();
|
||||||
|
if (me.levels[num] === undefined)
|
||||||
// if (!this._changedProps.get_TextPr()) this._changedProps.put_TextPr(new AscCommonWord.CTextPr());
|
me.levels[num] = me.props.get_Lvl(num);
|
||||||
// this._changedProps.get_TextPr().put_FontSize((record.value>0) ? record.value : undefined);
|
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) {
|
onIncludeLevelSelected: function (combo, record) {
|
||||||
var $txt, end, start;
|
|
||||||
var $txt = this.txtNumFormat.$el.find('input'),
|
var $txt = this.txtNumFormat.$el.find('input'),
|
||||||
start = $txt[0].selectionStart,
|
selectionStart = $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();
|
|
||||||
|
|
||||||
if (this._changedProps) {
|
if (this._changedProps) {
|
||||||
var arr = [];
|
var text = this._changedProps.get_Text(),
|
||||||
'перед'.split('').forEach(function (el) {
|
arr = this.formatStrings[this.level];
|
||||||
var t = new Asc.CAscNumberingLvlText(Asc.c_oAscNumberingLvlTextType.Text, el);
|
for (var i=0; i<arr.length; i++) {
|
||||||
arr.push(t);
|
if (arr[i]) {
|
||||||
});
|
var item = arr[i];
|
||||||
arr.push(new Asc.CAscNumberingLvlText(Asc.c_oAscNumberingLvlTextType.Num, 0));
|
if (i===record.value) {
|
||||||
'после'.split('').forEach(function (el) {
|
text.splice(item.index, 1);
|
||||||
var t = new Asc.CAscNumberingLvlText(Asc.c_oAscNumberingLvlTextType.Text, el);
|
if (item.end<selectionStart)
|
||||||
arr.push(t);
|
selectionStart -= (item.end - item.start);
|
||||||
});
|
} else {
|
||||||
|
if (item.end<selectionStart)
|
||||||
// if (!this._changedProps.get_TextPr()) this._changedProps.put_TextPr(new AscCommonWord.CTextPr());
|
selectionStart -= (item.end - item.start - 1);
|
||||||
// this._changedProps.get_TextPr().put_FontSize((record.value>0) ? record.value : undefined);
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
text.splice(selectionStart, 0, new Asc.CAscNumberingLvlText(Asc.c_oAscNumberingLvlTextType.Num, record.value));
|
||||||
|
this._changedProps.put_Text(text);
|
||||||
|
this.makeFormatStr(this._changedProps);
|
||||||
}
|
}
|
||||||
if (this.api) {
|
if (this.api) {
|
||||||
this.api.SetDrawImagePreviewBullet('bulleted-list-preview', this.props, this.level, this.type==2);
|
this.api.SetDrawImagePreviewBullet('bulleted-list-preview', this.props, this.level, this.type==2);
|
||||||
|
|
Loading…
Reference in a new issue