From b04cc196ad9baf631f013a1d137c1705c0b50a60 Mon Sep 17 00:00:00 2001 From: Julia Svinareva Date: Wed, 4 Sep 2019 15:09:04 +0300 Subject: [PATCH] [SSE] Fix Custom Scaling --- .../main/app/controller/Print.js | 81 ++++++++++--------- .../main/app/view/PrintSettings.js | 11 +-- apps/spreadsheeteditor/main/locale/en.json | 1 + 3 files changed, 48 insertions(+), 45 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/Print.js b/apps/spreadsheeteditor/main/app/controller/Print.js index a5fee5bba..a05707370 100644 --- a/apps/spreadsheeteditor/main/app/controller/Print.js +++ b/apps/spreadsheeteditor/main/app/controller/Print.js @@ -342,8 +342,7 @@ define([ registerControlEvents: function(panel) { panel.cmbPaperSize.on('selected', _.bind(this.propertyChange, this, panel)); panel.cmbPaperOrientation.on('selected', _.bind(this.propertyChange, this, panel)); - panel.cmbLayout.on('selected', _.bind(this.propertyChange, this, panel)); - panel.menuLayout && panel.menuLayout.on('item:click', _.bind(this.onCustomScale, this, panel)); + panel.cmbLayout.on('selected', _.bind(this.propertyChange, this, panel, 'scale')); panel.spnMarginTop.on('change', _.bind(this.propertyChange, this, panel)); panel.spnMarginBottom.on('change', _.bind(this.propertyChange, this, panel)); panel.spnMarginLeft.on('change', _.bind(this.propertyChange, this, panel)); @@ -352,9 +351,44 @@ define([ panel.chPrintRows.on('change', _.bind(this.propertyChange, this, panel)); }, - propertyChange: function(panel) { - if (this._changedProps) { - this._changedProps[panel.cmbSheet.getValue()] = this.getPageOptions(panel); + propertyChange: function(panel, scale, combo, record) { + if (scale === 'scale' && record.value === 4) { + var me = this; + var win = new SSE.Views.ScaleDialog({ + api: me.api, + handler: function(dlg, result) { + if (dlg == 'ok') { + if (me.api && result) { + me.fitWidth = result.width; + me.fitHeight = result.height; + me.fitScale = result.scale; + me.setScaling(panel, me.fitWidth, me.fitHeight, me.fitScale); + if (me._changedProps) { + me._changedProps[panel.cmbSheet.getValue()] = me.getPageOptions(panel); + } + } + } else { + var props; + if (me._changedProps.length > 0) { + props = me._changedProps[panel.cmbSheet.getValue()]; + } else { + props = new Asc.asc_CPageOptions(); + } + var opt = props.asc_getPageSetup(), + fitwidth = opt.asc_getFitToWidth(), + fitheight = opt.asc_getFitToHeight(), + fitscale = opt.asc_getScale(); + me.setScaling(panel, fitwidth, fitheight, fitscale); + } + Common.NotificationCenter.trigger('edit:complete'); + } + }); + win.show(); + Common.NotificationCenter.trigger('edit:complete', this.toolbar); + } else { + if (this._changedProps) { + this._changedProps[panel.cmbSheet.getValue()] = this.getPageOptions(panel); + } } }, @@ -362,39 +396,12 @@ define([ return this.adjPrintParams; }, - onCustomScale: function(panel) { - var me = this; - var win = new SSE.Views.ScaleDialog({ - api: me.api, - handler: function(dlg, result) { - if (dlg == 'ok') { - if (me.api && result) { - me.fitWidth = result.width; - me.fitHeight = result.height; - me.fitScale = result.scale; - me.setScaling(panel, me.fitWidth, me.fitHeight, me.fitScale); - me.propertyChange(panel); - } - } - Common.NotificationCenter.trigger('edit:complete'); - } - }); - win.show(); - Common.NotificationCenter.trigger('edit:complete', this.toolbar); - }, - setScaling: function (panel, width, height, scale) { - var me = this; - if (!width && !height && scale === 100) panel.cmbLayout.setValue(0); - else if (width === 1 && height === 1) panel.cmbLayout.setValue(1); - else if (width === 1 && !height) panel.cmbLayout.setValue(2); - else if (!width && height === 1) panel.cmbLayout.setValue(3); - else { - if (!panel.cmbLayout.store.findWhere({value: 4})) { - panel.cmbLayout.store.add({value: 4, displayValue: me.txtCustom}); - } - panel.cmbLayout.setValue(4); - } + if (!width && !height && scale === 100) panel.cmbLayout.setValue(0, true); + else if (width === 1 && height === 1) panel.cmbLayout.setValue(1, true); + else if (width === 1 && !height) panel.cmbLayout.setValue(2, true); + else if (!width && height === 1) panel.cmbLayout.setValue(3, true); + else panel.cmbLayout.setValue(4, true); }, warnCheckMargings: 'Margins are incorrect', diff --git a/apps/spreadsheeteditor/main/app/view/PrintSettings.js b/apps/spreadsheeteditor/main/app/view/PrintSettings.js index cb7026bfc..65d0109d5 100644 --- a/apps/spreadsheeteditor/main/app/view/PrintSettings.js +++ b/apps/spreadsheeteditor/main/app/view/PrintSettings.js @@ -213,15 +213,10 @@ define([ 'text!spreadsheeteditor/main/app/template/PrintSettings.template', { value: 0, displayValue: this.textActualSize }, { value: 1, displayValue: this.textFitPage }, { value: 2, displayValue: this.textFitCols }, - { value: 3, displayValue: this.textFitRows } + { value: 3, displayValue: this.textFitRows }, + { value: 4, displayValue: this.textCustomOptions} ] }); - this.menuLayout = new Common.UI.Menu({ - items: [ - { template: _.template('' + this.textCustom + '') } - ] - }); - this.menuLayout.render($('#printadv-dlg-combo-layout')); this.btnHide = new Common.UI.Button({ el: $('#printadv-dlg-btn-hide') @@ -329,7 +324,7 @@ define([ 'text!spreadsheeteditor/main/app/template/PrintSettings.template', btnDownload: 'Save & Download', textRange: 'Range', textIgnore: 'Ignore Print Area', - textCustom: 'Custom' + textCustomOptions: 'Custom Options' }, SSE.Views.PrintSettings || {})); }); \ No newline at end of file diff --git a/apps/spreadsheeteditor/main/locale/en.json b/apps/spreadsheeteditor/main/locale/en.json index 1c29ee8d6..0f08d6bc9 100644 --- a/apps/spreadsheeteditor/main/locale/en.json +++ b/apps/spreadsheeteditor/main/locale/en.json @@ -1938,6 +1938,7 @@ "SSE.Views.PrintSettings.textShowHeadings": "Show Rows and Columns Headings", "SSE.Views.PrintSettings.textTitle": "Print Settings", "SSE.Views.PrintSettings.textTitlePDF": "PDF Settings", + "SSE.Views.PrintSettings.textCustomOptions": "Custom Options", "SSE.Views.RightMenu.txtCellSettings": "Cell settings", "SSE.Views.RightMenu.txtChartSettings": "Chart settings", "SSE.Views.RightMenu.txtImageSettings": "Image settings",