From e232acc272c2f88b024691b586f1c36a3f7bee6e Mon Sep 17 00:00:00 2001 From: JuliaSvinareva Date: Wed, 20 Oct 2021 17:56:06 +0300 Subject: [PATCH] [SSE] Add handlers for print range and header/footer settings in file menu --- .../main/app/controller/Print.js | 37 +++++++++---------- .../main/app/view/FileMenuPanels.js | 28 ++++++++++++++ 2 files changed, 46 insertions(+), 19 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/Print.js b/apps/spreadsheeteditor/main/app/controller/Print.js index 8bdb5e4bf..e4f654201 100644 --- a/apps/spreadsheeteditor/main/app/controller/Print.js +++ b/apps/spreadsheeteditor/main/app/controller/Print.js @@ -60,10 +60,11 @@ define([ },*/ 'PrintWithPreview': { 'show': _.bind(this.onShowMainSettingsPrint, this), - 'render:after': _.bind(this.onAfterRender, this) + 'render:after': _.bind(this.onAfterRender, this), + 'changerange': _.bind(this.onChangeRange, this, false) }, 'PrintSettings': { - 'changerange': _.bind(this.onChangeRange,this) + 'changerange': _.bind(this.onChangeRange, this, true) } }); Common.NotificationCenter.on('print', _.bind(this.openPrintSettings, this, 'print')); @@ -193,22 +194,24 @@ define([ panel.btnPresetsLeft.menu.items[panel.btnPresetsLeft.menu.items[0].value == 'frozen' ? 0 : 1].setDisabled(!this.api.asc_getPrintTitlesRange(Asc.c_oAscPrintTitlesRangeType.frozen, true, sheet)); }, - fillPrintOptions: function(props) { - this.printSettingsDlg.setRange(props.asc_getPrintType()); - this.printSettingsDlg.setIgnorePrintArea(!!props.asc_getIgnorePrintArea()); - this.onChangeRange(); + fillPrintOptions: function(props, isDlg) { + var menu = isDlg ? this.printSettingsDlg : this.printSettings; + menu.setRange(props.asc_getPrintType()); + menu.setIgnorePrintArea(!!props.asc_getIgnorePrintArea()); + this.onChangeRange(isDlg); }, - onChangeRange: function() { - var printtype = this.printSettingsDlg.getRange(), - store = this.printSettingsDlg.cmbSheet.store, + onChangeRange: function(isDlg) { + var menu = isDlg ? this.printSettingsDlg : this.printSettings; + var printtype = menu.getRange(), + store = menu.cmbSheet.store, item = (printtype !== Asc.c_oAscPrintType.EntireWorkbook) ? store.findWhere({value: this.api.asc_getActiveWorksheetIndex()}) : store.at(0); if (item) { - this.printSettingsDlg.cmbSheet.setValue(item.get('value')); - this.comboSheetsChange(this.printSettingsDlg, this.printSettingsDlg.cmbSheet, item.toJSON()); + menu.cmbSheet.setValue(item.get('value')); + this.comboSheetsChange(menu, menu.cmbSheet, item.toJSON()); } - this.printSettingsDlg.cmbSheet.setDisabled(printtype !== Asc.c_oAscPrintType.EntireWorkbook); - this.printSettingsDlg.chIgnorePrintArea.setDisabled(printtype == Asc.c_oAscPrintType.Selection); + menu.cmbSheet.setDisabled(printtype !== Asc.c_oAscPrintType.EntireWorkbook); + menu.chIgnorePrintArea.setDisabled(printtype == Asc.c_oAscPrintType.Selection); }, getPageOptions: function(panel) { @@ -270,11 +273,7 @@ define([ this.updateSettings(this.printSettings); } - var item = this.printSettings.cmbSheet.store.findWhere({value: this.api.asc_getActiveWorksheetIndex()}); - if (item) { - this.printSettings.cmbSheet.setValue(item.get('value')); - this.comboSheetsChange(this.printSettings, this.printSettings.cmbSheet, item.toJSON()); - } + this.fillPrintOptions(this.adjPrintParams, false); }, openPrintSettings: function(type, cmp, format, asUrl) { @@ -295,7 +294,7 @@ define([ this.updateSettings(this.printSettingsDlg); this.printSettingsDlg.cmbSheet.on('selected', _.bind(this.comboSheetsChange, this, this.printSettingsDlg)); this.fillComponents(this.printSettingsDlg, true); - this.fillPrintOptions(this.adjPrintParams); + this.fillPrintOptions(this.adjPrintParams, true); this.registerControlEvents(this.printSettingsDlg); },this) })); diff --git a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js index 0754efbe4..a462092b5 100644 --- a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js +++ b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js @@ -2793,6 +2793,7 @@ define([ { value: Asc.c_oAscPrintType.Selection, displayValue: this.txtSelection } ] }); + this.cmbRange.on('selected', _.bind(this.comboRangeChange, this)); this.chIgnorePrintArea = new Common.UI.CheckBox({ el: $markup.findById('#print-chb-ignore'), @@ -2964,6 +2965,9 @@ define([ this.$el = $(node).html($markup); + this.$el.on('click', '#print-header-footer-settings', _.bind(this.openHeaderSettings, this)); + this.$headerSettings = $('#print-header-footer-settings'); + if (_.isUndefined(this.scroller)) { this.scroller = new Common.UI.Scroller({ el: this.pnlSettings, @@ -3067,6 +3071,30 @@ define([ return (this.$el || $(this.el)).is(":visible"); }, + setRange: function(value) { + this.cmbRange.setValue(value); + }, + + getRange: function() { + return this.cmbRange.getValue(); + }, + + setIgnorePrintArea: function(value) { + this.chIgnorePrintArea.setValue(value); + }, + + getIgnorePrintArea: function() { + return (this.chIgnorePrintArea.getValue()=='checked'); + }, + + comboRangeChange: function(combo, record) { + this.fireEvent('changerange', this); + }, + + openHeaderSettings: function() { + SSE.getController('Toolbar').onEditHeaderClick(); + }, + txtPrint: 'Print', txtSave: 'Save', txtPrintRange: 'Print range',