[DE] Apply line numbering

This commit is contained in:
Julia Radzhabova 2020-09-28 23:49:46 +03:00
parent b76e5ce940
commit 21cb4c0994
3 changed files with 75 additions and 54 deletions

View file

@ -102,7 +102,8 @@ define([
pgmargins: undefined, pgmargins: undefined,
fontsize: undefined, fontsize: undefined,
in_equation: false, in_equation: false,
in_chart: false in_chart: false,
linenum_apply: Asc.c_oAscSectionApplyType.All
}; };
this.flg = {}; this.flg = {};
this.diagramEditor = null; this.diagramEditor = null;
@ -1683,54 +1684,55 @@ define([
switch (item.value) { switch (item.value) {
case 0: case 0:
this.api.asc_SetLineNumbersProps(this._state.linenum_apply, null);
break;
case 1: case 1:
case 2: case 2:
case 3: case 3:
this._state.linenum = undefined; this._state.linenum = undefined;
if (this.api && item.checked) { if (this.api && item.checked) {
var props = new Asc.CSectionLnNumType();
props.put_Restart(item.value==1 ? Asc.c_oAscLineNumberRestartType.Continuous : (item.value==2 ? Asc.c_oAscLineNumberRestartType.NewPage : Asc.c_oAscLineNumberRestartType.NewSection));
this.api.asc_SetLineNumbersProps(this._state.linenum_apply, props);
} }
break; break;
case 4: case 4:
this.api && this.api.put_ParagraphSuppressLineNumbers(item.checked); this.api && this.api.asc_SetParagraphSuppressLineNumbers(item.checked);
break; break;
case 5: case 5:
var win, var win,
me = this; me = this;
win = new DE.Views.LineNumbersDialog({ win = new DE.Views.LineNumbersDialog({
applyTo: me._state.linenum_apply,
handler: function(dlg, result) { handler: function(dlg, result) {
if (result == 'ok') { if (result == 'ok') {
// var props = dlg.getSettings(); var settings = dlg.getSettings();
// me.api.asc_SetLineNumbersProps(props); me.api.asc_SetLineNumbersProps(settings.type, settings.props);
me._state.linenum_apply = settings.type;
Common.NotificationCenter.trigger('edit:complete', me.toolbar); Common.NotificationCenter.trigger('edit:complete', me.toolbar);
} }
} }
}); });
win.show(); win.show();
// win.setSettings(me.api.asc_GetLineNumbersProps()); win.setSettings(me.api.asc_GetLineNumbersProps());
break; break;
} }
Common.NotificationCenter.trigger('edit:complete', this.toolbar);
}, },
onLineNumbersProps: function(props) { onLineNumbersProps: function(props) {
var index = 0;
if (props) { if (props) {
// var type = props.asc_getType(); switch (props.get_Restart()) {
var index = -1; case Asc.c_oAscLineNumberRestartType.Continuous: index = 1; break;
// switch (type) { case Asc.c_oAscLineNumberRestartType.NewPage: index = 2; break;
// case Asc.None: index = 0; break; case Asc.c_oAscLineNumberRestartType.NewSection: index = 3; break;
// case Asc.Continuous: index = 1; break; }
// case Asc.Page: index = 2; break;
// case Asc.Section: index = 3; break;
// }
if (this._state.linenum === index)
return;
if (index < 0)
this.toolbar.btnLineNumbers.menu.clearAll();
else
this.toolbar.btnLineNumbers.menu.items[index].setChecked(true);
this._state.linenum = index;
} }
if (this._state.linenum === index)
return;
this.toolbar.btnLineNumbers.menu.items[index].setChecked(true);
this._state.linenum = index;
}, },
onColorSchemaClick: function(menu, item) { onColorSchemaClick: function(menu, item) {

View file

@ -47,7 +47,7 @@ define([
DE.Views.LineNumbersDialog = Common.UI.Window.extend(_.extend({ DE.Views.LineNumbersDialog = Common.UI.Window.extend(_.extend({
options: { options: {
width: 290, width: 290,
height: 273, height: 308,
header: true, header: true,
style: 'min-width: 290px;', style: 'min-width: 290px;',
cls: 'modal-dlg', cls: 'modal-dlg',
@ -70,7 +70,10 @@ define([
'<div style="margin-bottom: 8px;"><label>' + this.textNumbering + '</label></div>', '<div style="margin-bottom: 8px;"><label>' + this.textNumbering + '</label></div>',
'<div id="line-numbers-restart-each-page" style="margin-bottom: 8px;"></div>', '<div id="line-numbers-restart-each-page" style="margin-bottom: 8px;"></div>',
'<div id="line-numbers-restart-each-section" style="margin-bottom: 8px;"></div>', '<div id="line-numbers-restart-each-section" style="margin-bottom: 8px;"></div>',
'<div id="line-numbers-continuous" style="margin-bottom: 5px;"></div>', '<div id="line-numbers-continuous" style="margin-bottom: 15px;"></div>',
'<div style="margin-bottom: 5px;">',
'<label style="margin-top: 4px;">' + this.textApplyTo + '</label><div id="line-numbers-combo-apply" class="input-group-nr" style="display: inline-block; width:125px;float:right;"></div>',
'</div>',
'</div>' '</div>'
].join(''); ].join('');
@ -155,6 +158,18 @@ define([
disabled: true disabled: true
}); });
this.cmbApply = new Common.UI.ComboBox({
el: $('#line-numbers-combo-apply'),
cls: 'input-group-nr',
menuStyle: 'min-width: 125px;',
editable: false,
data: [
{ displayValue: this.textSection, value: Asc.c_oAscSectionApplyType.Current },
{ displayValue: this.textForward, value: Asc.c_oAscSectionApplyType.ToEnd },
{ displayValue: this.textDocument, value: Asc.c_oAscSectionApplyType.All }
]
});
this.cmbApply.setValue(this.options.applyTo);
this.getChild().find('.dlg-btn').on('click', _.bind(this.onBtnClick, this)); this.getChild().find('.dlg-btn').on('click', _.bind(this.onBtnClick, this));
@ -166,17 +181,18 @@ define([
setSettings: function (props) { setSettings: function (props) {
if (props) { if (props) {
// var type = props.asc_getType(); var type = props.get_Restart();
// this.chAddLineNumbering.setValue(type !== case Asc.None); this.chAddLineNumbering.setValue(true);
// switch (type) { switch (type) {
// case Asc.Continuous: this.rbContinuous.setValue(true, true); break; case Asc.c_oAscLineNumberRestartType.Continuous: this.rbContinuous.setValue(true, true); break;
// case Asc.Page: this.rbRestartEachPage.setValue(true, true); break; case Asc.c_oAscLineNumberRestartType.NewPage: this.rbRestartEachPage.setValue(true, true); break;
// case Asc.Section: this.rbRestartEachSection.setValue(true, true); break; case Asc.c_oAscLineNumberRestartType.NewSection: this.rbRestartEachSection.setValue(true, true); break;
// } }
// this.spnStartAt.setValue(props.get_StartAt()!==null ? props.get_StartAt() : '', true); this.spnStartAt.setValue(props.get_Start()!==null && props.get_Start()!==undefined ? props.get_Start() : '', true);
// this.spnFromText.setValue(props.get_FromText()!==null ? (props.get_FromText()<0 ? -1 : Common.Utils.Metric.fnRecalcFromMM(props.get_FromText())) : '', true); this.spnFromText.setValue(props.get_Distance()!==null && props.get_Distance()!==undefined ? Common.Utils.Metric.fnRecalcFromMM(props.get_Distance() * 25.4 / 20 / 72.0) : -1, true);
// this.spnCountBy.setValue(props.get_Count()!==null ? props.get_Count() : '', true); this.spnCountBy.setValue(props.get_CountBy()!==null && props.get_CountBy()!==undefined ? props.get_CountBy() : '', true);
} } else
this.chAddLineNumbering.setValue(false);
}, },
_handleInput: function(state) { _handleInput: function(state) {
@ -197,22 +213,21 @@ define([
}, },
getSettings: function() { getSettings: function() {
// var props = new Asc.CDocumentLineNumberProps(); var props;
// if (this.chAddLineNumbering.getValue()!=='checked') { if (this.chAddLineNumbering.getValue()==='checked') {
// props.put_Type(Asc.None); props = new Asc.CSectionLnNumType();
// } else { if (this.rbContinuous.getValue())
// if (this.rbContinuous.getValue()) props.put_Restart(Asc.c_oAscLineNumberRestartType.Continuous);
// props.put_Type(Asc.Continuous); else if (this.rbRestartEachPage.getValue())
// else if (this.rbRestartEachPage.getValue()) props.put_Restart(Asc.c_oAscLineNumberRestartType.NewPage);
// props.put_Type(Asc.Page); else if (this.rbRestartEachSection.getValue())
// else if (this.rbRestartEachSection.getValue()) props.put_Restart(Asc.c_oAscLineNumberRestartType.NewSection);
// props.put_Type(Asc.Section); props.put_Start(this.spnStartAt.getValue()!=='' ? this.spnStartAt.getNumberValue() : undefined);
// props.put_StartAt(this.spnStartAt.getNumberValue()); var value = this.spnFromText.getNumberValue();
// var value = this.spnFromText.getNumberValue(); props.put_Distance(value<0 ? null : parseInt(Common.Utils.Metric.fnRecalcToMM(value) * 72 * 20 / 25.4));
// props.put_FromText(value<0 ? -1 : Common.Utils.Metric.fnRecalcToMM()); props.put_CountBy(this.spnCountBy.getValue()!=='' ? this.spnCountBy.getNumberValue() : undefined);
// props.put_Count(this.spnCountBy.getNumberValue()); }
// } return {props: props, type: this.cmbApply.getValue()};
// return props;
}, },
updateMetricUnit: function() { updateMetricUnit: function() {
@ -234,6 +249,10 @@ define([
textNumbering: 'Numbering', textNumbering: 'Numbering',
textRestartEachPage: 'Restart Each Page', textRestartEachPage: 'Restart Each Page',
textRestartEachSection: 'Restart Each Section', textRestartEachSection: 'Restart Each Section',
textContinuous: 'Continuous' textContinuous: 'Continuous',
textApplyTo: 'Apply changes to',
textDocument: 'Whole document',
textSection: 'Current section',
textForward: 'This point forward'
}, DE.Views.LineNumbersDialog || {})) }, DE.Views.LineNumbersDialog || {}))
}); });

View file

@ -352,7 +352,7 @@ define([ 'text!documenteditor/main/app/template/ParagraphSettingsAdvanced.tem
}); });
this.chLineNumbers.on('change', _.bind(function(field, newValue, oldValue, eOpts){ this.chLineNumbers.on('change', _.bind(function(field, newValue, oldValue, eOpts){
if (this._changedProps) { if (this._changedProps) {
// this._changedProps.put_SuppressLineNumbers(field.getValue()=='checked'); this._changedProps.put_SuppressLineNumbers(field.getValue()=='checked');
} }
}, this)); }, this));
@ -784,7 +784,7 @@ define([ 'text!documenteditor/main/app/template/ParagraphSettingsAdvanced.tem
this.chKeepNext.setValue((props.get_KeepNext() !== null && props.get_KeepNext() !== undefined) ? props.get_KeepNext() : 'indeterminate', true); this.chKeepNext.setValue((props.get_KeepNext() !== null && props.get_KeepNext() !== undefined) ? props.get_KeepNext() : 'indeterminate', true);
this.chOrphan.setValue((props.get_WidowControl() !== null && props.get_WidowControl() !== undefined) ? props.get_WidowControl() : 'indeterminate', true); this.chOrphan.setValue((props.get_WidowControl() !== null && props.get_WidowControl() !== undefined) ? props.get_WidowControl() : 'indeterminate', true);
// this.chLineNumbers.setValue((props.get_SuppressLineNumbers() !== null && props.get_SuppressLineNumbers() !== undefined) ? props.get_SuppressLineNumbers() : 'indeterminate', true); this.chLineNumbers.setValue((props.get_SuppressLineNumbers() !== null && props.get_SuppressLineNumbers() !== undefined) ? props.get_SuppressLineNumbers() : 'indeterminate', true);
this.Borders = new Asc.asc_CParagraphBorders(props.get_Borders()); this.Borders = new Asc.asc_CParagraphBorders(props.get_Borders());