From 225c669dd00d37140834598fac675531b093579d Mon Sep 17 00:00:00 2001 From: JuliaSvinareva Date: Mon, 18 Oct 2021 11:21:30 +0300 Subject: [PATCH 01/19] [SSE] Make print with preview in file menu --- .../main/app/template/FileMenu.template | 2 + .../main/app/view/FileMenu.js | 16 ++ .../main/app/view/FileMenuPanels.js | 216 ++++++++++++++++++ .../main/resources/less/leftmenu.less | 4 + 4 files changed, 238 insertions(+) diff --git a/apps/spreadsheeteditor/main/app/template/FileMenu.template b/apps/spreadsheeteditor/main/app/template/FileMenu.template index 8bb022a44..a2e4c5f83 100644 --- a/apps/spreadsheeteditor/main/app/template/FileMenu.template +++ b/apps/spreadsheeteditor/main/app/template/FileMenu.template @@ -8,6 +8,7 @@
  • +
  • @@ -34,4 +35,5 @@
    +
    \ No newline at end of file diff --git a/apps/spreadsheeteditor/main/app/view/FileMenu.js b/apps/spreadsheeteditor/main/app/view/FileMenu.js index 89f3ce5af..3352738ae 100644 --- a/apps/spreadsheeteditor/main/app/view/FileMenu.js +++ b/apps/spreadsheeteditor/main/app/view/FileMenu.js @@ -139,6 +139,16 @@ define([ dataHintOffset: [2, 14] }); + this.miPrintWithPreview = new Common.UI.MenuItem({ + el : $markup.elementById('#fm-btn-print-with-preview'), + action : 'print-with-preview', + caption : this.btnPrintCaption, + canFocused: false, + dataHint: 1, + dataHintDirection: 'left-top', + dataHintOffset: [2, 14] + }); + this.miRename = new Common.UI.MenuItem({ el : $markup.elementById('#fm-btn-rename'), action : 'rename', @@ -244,6 +254,7 @@ define([ this.miSaveCopyAs, this.miSaveAs, this.miPrint, + this.miPrintWithPreview, this.miRename, this.miProtect, this.miRecent, @@ -343,6 +354,7 @@ define([ this.miSave[this.mode.isEdit?'show':'hide'](); this.miEdit[!this.mode.isEdit && this.mode.canEdit && this.mode.canRequestEditRights ?'show':'hide'](); this.miPrint[this.mode.canPrint?'show':'hide'](); + this.miPrintWithPreview[this.mode.canPrint?'show':'hide'](); this.miRename[(this.mode.canRename && !this.mode.isDesktopApp) ?'show':'hide'](); this.miProtect[this.mode.canProtect ?'show':'hide'](); var isVisible = this.mode.canDownload || this.mode.isEdit || this.mode.canPrint || this.mode.canProtect || @@ -406,6 +418,10 @@ define([ this.panels['opts'].SetDisabled(this.mode.disableEditing); delete this.mode.disableEditing; } + + if (this.mode.canPrint) { + this.panels['print-with-preview'] = ((new SSE.Views.FileMenuPanels.PrintWithPreview({menu:this})).render(this.$el.find('#panel-print'))); + } }, setMode: function(mode, delay) { diff --git a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js index 1367681ec..30112b9e7 100644 --- a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js +++ b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js @@ -2678,4 +2678,220 @@ define([ }, SSE.Views.FileMenuPanels.ProtectDoc || {})); + SSE.Views.FileMenuPanels.PrintWithPreview = Common.UI.BaseView.extend(_.extend({ + el: '#panel-print', + menu: undefined, + + template: _.template([ + '
    ', + '
    ', + '', + '', + '
    ', + '
    ', + + '
    ', + '
    ' + ].join('')), + + initialize: function(options) { + Common.UI.BaseView.prototype.initialize.call(this,arguments); + + this.menu = options.menu; + }, + + render: function(node) { + var $markup = $(this.template({scope: this})); + + this.cmbRange = new Common.UI.ComboBox({ + el: $markup.findById('#print-combo-range'), + menuStyle: 'min-width: 132px;max-height: 280px;', + editable: false, + takeFocusOnClose: true, + cls: 'input-group-nr', + data: [ + { value: Asc.c_oAscPrintType.ActiveSheets, displayValue: this.txtCurrentSheet }, + { value: Asc.c_oAscPrintType.EntireWorkbook, displayValue: this.txtAllSheets }, + { value: Asc.c_oAscPrintType.Selection, displayValue: this.txtSelection } + ] + }); + this.cmbRange.on('selected', _.bind(this.onChangeComboRange, this)); + + this.cmbSheet = new Common.UI.ComboBox({ + el: $markup.findById('#print-combo-sheets'), + menuStyle: 'min-width: 242px;max-height: 280px;', + editable: false, + cls: 'input-group-nr', + data: [], + takeFocusOnClose: true + }); + + this.cmbPaperSize = new Common.UI.ComboBox({ + el: $markup.findById('#print-combo-pages'), + menuStyle: 'max-height: 280px; min-width: 242px;', + editable: false, + takeFocusOnClose: true, + cls: 'input-group-nr', + data: [ + {value:'215.9|279.4', displayValue:'US Letter (21,59cm x 27,94cm)', caption: 'US Letter'}, + {value:'215.9|355.6', displayValue:'US Legal (21,59cm x 35,56cm)', caption: 'US Legal'}, + {value:'210|297', displayValue:'A4 (21cm x 29,7cm)', caption: 'A4'}, + {value:'148|210', displayValue:'A5 (14,8cm x 21cm)', caption: 'A5'}, + {value:'176|250', displayValue:'B5 (17,6cm x 25cm)', caption: 'B5'}, + {value:'104.8|241.3', displayValue:'Envelope #10 (10,48cm x 24,13cm)', caption: 'Envelope #10'}, + {value:'110|220', displayValue:'Envelope DL (11cm x 22cm)', caption: 'Envelope DL'}, + {value:'279.4|431.8', displayValue:'Tabloid (27,94cm x 43,18cm)', caption: 'Tabloid'}, + {value:'297|420', displayValue:'A3 (29,7cm x 42cm)', caption: 'A3'}, + {value:'304.8|457.1', displayValue:'Tabloid Oversize (30,48cm x 45,71cm)', caption: 'Tabloid Oversize'}, + {value:'196.8|273', displayValue:'ROC 16K (19,68cm x 27,3cm)', caption: 'ROC 16K'}, + {value:'119.9|234.9', displayValue:'Envelope Choukei 3 (11,99cm x 23,49cm)', caption: 'Envelope Choukei 3'}, + {value:'330.2|482.5', displayValue:'Super B/A3 (33,02cm x 48,25cm)', caption: 'Super B/A3'} + ] + }); + + this.cmbPaperOrientation = new Common.UI.ComboBox({ + el : $markup.findById('#print-combo-orient'), + menuStyle : 'min-width: 132px;', + editable : false, + takeFocusOnClose: true, + cls : 'input-group-nr', + data : [ + { value: Asc.c_oAscPageOrientation.PagePortrait, displayValue: this.txtPortrait }, + { value: Asc.c_oAscPageOrientation.PageLandscape, displayValue: this.txtLandscape } + ] + }); + + var itemsTemplate = + _.template([ + '<% _.each(items, function(item) { %>', + '
  • class="border-top" style="margin-top: 5px;" <% } %> >', + '<%= scope.getDisplayValue(item) %>', + '
  • ', + '<% }); %>' + ].join('')); + this.cmbLayout = new Common.UI.ComboBox({ + el : $markup.findById('#print-combo-layout'), + menuStyle : 'min-width: 242px;', + editable : false, + takeFocusOnClose: true, + cls : 'input-group-nr', + data : [ + { value: 0, displayValue: this.txtActualSize }, + { value: 1, displayValue: this.txtFitPage }, + { value: 2, displayValue: this.txtFitCols }, + { value: 3, displayValue: this.txtFitRows }, + { value: 'customoptions', displayValue: this.txtCustomOptions } + ], + itemsTemplate: itemsTemplate + }); + + this.txtRangeTop = new Common.UI.InputFieldBtn({ + el: $markup.findById('#print-txt-top'), + allowBlank: true, + validateOnChange: true + }); + + this.btnPresetsTop = new Common.UI.Button({ + parentEl: $markup.findById('#print-presets-top'), + cls: 'btn-text-menu-default', + caption: this.txtRepeat, + menu: true + }); + + this.txtRangeLeft = new Common.UI.InputFieldBtn({ + el: $markup.findById('#print-txt-left'), + allowBlank: true, + validateOnChange: true + }); + + this.btnPresetsLeft = new Common.UI.Button({ + parentEl: $markup.findById('#print-presets-left'), + cls: 'btn-text-menu-default', + caption: this.txtRepeat, + menu: true + }); + + this.$el = $(node).html($markup); + return this; + }, + + show: function() { + Common.UI.BaseView.prototype.show.call(this,arguments); + this.scroller && this.scroller.update(); + }, + + setMode: function(mode) { + this.mode = mode; + }, + + setApi: function(api) { + + }, + + onChangeComboRange: function () { + + }, + + txtPrint: 'Print', + txtSave: 'Save', + txtPrintRange: 'Print range', + txtCurrentSheet: 'Current sheet', + txtAllSheets: 'All sheets', + txtSelection: 'Selection', + txtSettingsOfSheet: 'Settings of sheet', + txtPageSize: 'Page size', + txtPageOrientation: 'Page orientation', + txtPortrait: 'Portrait', + txtLandscape: 'Landscape', + txtScaling: 'Scaling', + txtActualSize: 'Actual Size', + txtFitPage: 'Fit Sheet on One Page', + txtFitCols: 'Fit All Columns on One Page', + txtFitRows: 'Fit All Rows on One Pag', + txtCustomOptions: 'Custom Options', + txtPrintTitles: 'Print titles', + txtRepeatRowsAtTop: 'Repeat rows at top', + txtRepeatColumnsAtLeft: 'Repeat columns at left', + txtRepeat: 'Repeat...' + }, SSE.Views.FileMenuPanels.PrintWithPreview || {})); + }); diff --git a/apps/spreadsheeteditor/main/resources/less/leftmenu.less b/apps/spreadsheeteditor/main/resources/less/leftmenu.less index d8b073b21..05028a1ae 100644 --- a/apps/spreadsheeteditor/main/resources/less/leftmenu.less +++ b/apps/spreadsheeteditor/main/resources/less/leftmenu.less @@ -521,6 +521,10 @@ } } } + + #panel-print { + padding: 0; + } } } From 095c0d624d6e0e584c4d5667ed2a6fa62a1ae304 Mon Sep 17 00:00:00 2001 From: JuliaSvinareva Date: Mon, 18 Oct 2021 19:35:23 +0300 Subject: [PATCH 02/19] [SSE] Make print with preview in file menu --- .../main/app/view/FileMenuPanels.js | 232 +++++++++++++++--- .../main/resources/less/leftmenu.less | 60 +++++ 2 files changed, 252 insertions(+), 40 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js index 30112b9e7..a82071b93 100644 --- a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js +++ b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js @@ -2684,51 +2684,85 @@ define([ template: _.template([ '
    ', - '
    ', - '', - '', '
    ', - '
    ', - + '', '
    ' ].join('')), @@ -2737,14 +2771,18 @@ define([ Common.UI.BaseView.prototype.initialize.call(this,arguments); this.menu = options.menu; + + this.spinners = []; }, render: function(node) { + var me = this; + var $markup = $(this.template({scope: this})); this.cmbRange = new Common.UI.ComboBox({ el: $markup.findById('#print-combo-range'), - menuStyle: 'min-width: 132px;max-height: 280px;', + menuStyle: 'min-width: 248px;max-height: 280px;', editable: false, takeFocusOnClose: true, cls: 'input-group-nr', @@ -2756,9 +2794,14 @@ define([ }); this.cmbRange.on('selected', _.bind(this.onChangeComboRange, this)); + this.chIgnorePrintArea = new Common.UI.CheckBox({ + el: $markup.findById('#print-chb-ignore'), + labelText: this.txtIgnore + }); + this.cmbSheet = new Common.UI.ComboBox({ el: $markup.findById('#print-combo-sheets'), - menuStyle: 'min-width: 242px;max-height: 280px;', + menuStyle: 'min-width: 248px;max-height: 280px;', editable: false, cls: 'input-group-nr', data: [], @@ -2767,7 +2810,7 @@ define([ this.cmbPaperSize = new Common.UI.ComboBox({ el: $markup.findById('#print-combo-pages'), - menuStyle: 'max-height: 280px; min-width: 242px;', + menuStyle: 'max-height: 280px; min-width: 248px;', editable: false, takeFocusOnClose: true, cls: 'input-group-nr', @@ -2790,7 +2833,7 @@ define([ this.cmbPaperOrientation = new Common.UI.ComboBox({ el : $markup.findById('#print-combo-orient'), - menuStyle : 'min-width: 132px;', + menuStyle : 'min-width: 134px;', editable : false, takeFocusOnClose: true, cls : 'input-group-nr', @@ -2810,7 +2853,7 @@ define([ ].join('')); this.cmbLayout = new Common.UI.ComboBox({ el : $markup.findById('#print-combo-layout'), - menuStyle : 'min-width: 242px;', + menuStyle : 'min-width: 248px;', editable : false, takeFocusOnClose: true, cls : 'input-group-nr', @@ -2834,6 +2877,7 @@ define([ parentEl: $markup.findById('#print-presets-top'), cls: 'btn-text-menu-default', caption: this.txtRepeat, + style: 'width: 77px;', menu: true }); @@ -2847,16 +2891,109 @@ define([ parentEl: $markup.findById('#print-presets-left'), cls: 'btn-text-menu-default', caption: this.txtRepeat, + style: 'width: 77px;', menu: true }); + this.spnMarginTop = new Common.UI.MetricSpinner({ + el: $markup.findById('#print-spin-margin-top'), + step: .1, + width: 120, + defaultUnit : "cm", + value: '0 cm', + maxValue: 48.25, + minValue: 0 + }); + this.spinners.push(this.spnMarginTop); + + this.spnMarginBottom = new Common.UI.MetricSpinner({ + el: $markup.findById('#print-spin-margin-bottom'), + step: .1, + width: 120, + defaultUnit : "cm", + value: '0 cm', + maxValue: 48.25, + minValue: 0 + }); + this.spinners.push(this.spnMarginBottom); + + this.spnMarginLeft = new Common.UI.MetricSpinner({ + el: $markup.findById('#print-spin-margin-left'), + step: .1, + width: 120, + defaultUnit : "cm", + value: '0.19 cm', + maxValue: 48.25, + minValue: 0 + }); + this.spinners.push(this.spnMarginLeft); + + this.spnMarginRight = new Common.UI.MetricSpinner({ + el: $markup.findById('#print-spin-margin-right'), + step: .1, + width: 120, + defaultUnit : "cm", + value: '0.19 cm', + maxValue: 48.25, + minValue: 0 + }); + this.spinners.push(this.spnMarginRight); + + this.chPrintGrid = new Common.UI.CheckBox({ + el: $markup.findById('#print-chb-grid'), + labelText: this.txtPrintGrid + }); + + this.chPrintRows = new Common.UI.CheckBox({ + el: $markup.findById('#print-chb-rows'), + labelText: this.txtPrintHeadings + }); + + this.btnApplyAll = new Common.UI.Button({ + el: $markup.findById('#print-apply-all') + }); + this.btnApplyAll.on('click', _.bind(this.onApplyToAll, this)); + + this.pnlSettings = $markup.find('.flex-settings').addBack().filter('.flex-settings'); + this.pnlApply = $markup.find('.fms-flex-apply').addBack().filter('.fms-flex-apply'); + this.pnlTable = $(this.pnlSettings.find('table')[0]); + this.trApply = $markup.find('.fms-btn-apply'); + this.$el = $(node).html($markup); + + if (_.isUndefined(this.scroller)) { + this.scroller = new Common.UI.Scroller({ + el: this.pnlSettings, + suppressScrollX: true, + alwaysVisibleY: true + }); + } + + Common.NotificationCenter.on({ + 'window:resize': function() { + me.isVisible() && me.updateScroller(); + } + }); + return this; }, show: function() { Common.UI.BaseView.prototype.show.call(this,arguments); - this.scroller && this.scroller.update(); + + this.updateScroller(); + }, + + updateScroller: function() { + if (this.scroller) { + Common.UI.Menu.Manager.hideAll(); + var scrolled = this.$el.height()< this.pnlTable.height() + 25 + this.pnlApply.height(); + this.pnlApply.toggleClass('hidden', !scrolled); + this.trApply.toggleClass('hidden', scrolled); + this.pnlSettings.css('overflow', scrolled ? 'hidden' : 'visible'); + this.scroller.update(); + this.pnlSettings.toggleClass('bordered', this.scroller.isVisible()); + } }, setMode: function(mode) { @@ -2871,6 +3008,10 @@ define([ }, + onApplyToAll: function () { + + }, + txtPrint: 'Print', txtSave: 'Save', txtPrintRange: 'Print range', @@ -2891,7 +3032,18 @@ define([ txtPrintTitles: 'Print titles', txtRepeatRowsAtTop: 'Repeat rows at top', txtRepeatColumnsAtLeft: 'Repeat columns at left', - txtRepeat: 'Repeat...' + txtRepeat: 'Repeat...', + txtMargins: 'Margins', + txtTop: 'Top', + txtBottom: 'Bottom', + txtLeft: 'Left', + txtRight: 'Right', + txtGridlinesAndHeadings: 'Gridlines and headings', + txtPrintGrid: 'Print gridlines', + txtPrintHeadings: 'Print row and columns headings', + txtHeaderFooterSettings: 'Header/footer settings', + txtApplyToAllSheets: 'Apply to all sheets', + txtIgnore: 'Ignore print area' }, SSE.Views.FileMenuPanels.PrintWithPreview || {})); }); diff --git a/apps/spreadsheeteditor/main/resources/less/leftmenu.less b/apps/spreadsheeteditor/main/resources/less/leftmenu.less index 05028a1ae..554d84cb9 100644 --- a/apps/spreadsheeteditor/main/resources/less/leftmenu.less +++ b/apps/spreadsheeteditor/main/resources/less/leftmenu.less @@ -524,6 +524,66 @@ #panel-print { padding: 0; + #id-print-settings { + position: absolute; + width:280px; + top: 0; + bottom: 0; + } + .print-settings { + width: 100%; + height: 100%; + overflow: hidden; + display: flex; + flex-direction: column; + border-right: @scaled-one-px-value-ie solid @border-toolbar-ie; + border-right: @scaled-one-px-value solid @border-toolbar; + label.header { + font-weight: 700; + } + .footer { + .btn.primary { + margin-right: 8px; + } + } + .settings-container { + width: 100%; + height: 100%; + overflow: hidden; + padding: 12px 16px; + .padding-small { + padding-bottom: 8px; + } + .padding-large { + padding-bottom: 16px; + } + + #print-apply-all { + margin-top: 5px; + } + .link { + margin-top: 9px; + } + .footer { + margin-top: 24px; + } + } + .fms-flex-apply { + padding-left: 16px; + .footer { + .btn { + margin-top: 16px; + margin-bottom: 16px; + } + } + } + } + #print-navigation { + height: 50px; + } + #print-preview { + height: calc(100% - 50px); + } } } } From 02a400d75c4aef962113479ce345bb12a0bf5899 Mon Sep 17 00:00:00 2001 From: JuliaSvinareva Date: Tue, 19 Oct 2021 19:03:31 +0300 Subject: [PATCH 03/19] [SSE] Make print with preview in file menu --- .../main/app/controller/Main.js | 3 +- .../main/app/controller/Print.js | 14 +++- .../main/app/view/FileMenu.js | 4 +- .../main/app/view/FileMenuPanels.js | 80 ++++++++++++++++--- 4 files changed, 83 insertions(+), 18 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/Main.js b/apps/spreadsheeteditor/main/app/controller/Main.js index 717d5a325..b72806304 100644 --- a/apps/spreadsheeteditor/main/app/controller/Main.js +++ b/apps/spreadsheeteditor/main/app/controller/Main.js @@ -2509,7 +2509,8 @@ define([ this.getApplication().getController('RightMenu').updateMetricUnit(); this.getApplication().getController('Toolbar').getView('Toolbar').updateMetricUnit(); } - this.getApplication().getController('Print').getView('MainSettingsPrint').updateMetricUnit(); + //this.getApplication().getController('Print').getView('MainSettingsPrint').updateMetricUnit(); + this.getApplication().getController('Print').getView('PrintWithPreview').updateMetricUnit(); }, _compareActionStrong: function(obj1, obj2){ diff --git a/apps/spreadsheeteditor/main/app/controller/Print.js b/apps/spreadsheeteditor/main/app/controller/Print.js index 6f22a4959..8bdb5e4bf 100644 --- a/apps/spreadsheeteditor/main/app/controller/Print.js +++ b/apps/spreadsheeteditor/main/app/controller/Print.js @@ -39,7 +39,8 @@ define([ SSE.Controllers.Print = Backbone.Controller.extend(_.extend({ views: [ - 'MainSettingsPrint' + 'MainSettingsPrint', + 'PrintWithPreview' ], initialize: function() { @@ -53,7 +54,11 @@ define([ this._originalPageSettings = null; this.addListeners({ - 'MainSettingsPrint': { + /*'MainSettingsPrint': { + 'show': _.bind(this.onShowMainSettingsPrint, this), + 'render:after': _.bind(this.onAfterRender, this) + },*/ + 'PrintWithPreview': { 'show': _.bind(this.onShowMainSettingsPrint, this), 'render:after': _.bind(this.onAfterRender, this) }, @@ -66,12 +71,13 @@ define([ }, onLaunch: function() { - this.printSettings = this.createView('MainSettingsPrint'); + //this.printSettings = this.createView('MainSettingsPrint'); + this.printSettings = this.createView('PrintWithPreview'); }, onAfterRender: function(view) { this.printSettings.cmbSheet.on('selected', _.bind(this.comboSheetsChange, this, this.printSettings)); - this.printSettings.btnOk.on('click', _.bind(this.querySavePrintSettings, this)); + this.printSettings.btnSave.on('click', _.bind(this.querySavePrintSettings, this)); this.fillComponents(this.printSettings); this.registerControlEvents(this.printSettings); }, diff --git a/apps/spreadsheeteditor/main/app/view/FileMenu.js b/apps/spreadsheeteditor/main/app/view/FileMenu.js index 3352738ae..8e5b5f6d8 100644 --- a/apps/spreadsheeteditor/main/app/view/FileMenu.js +++ b/apps/spreadsheeteditor/main/app/view/FileMenu.js @@ -420,7 +420,9 @@ define([ } if (this.mode.canPrint) { - this.panels['print-with-preview'] = ((new SSE.Views.FileMenuPanels.PrintWithPreview({menu:this})).render(this.$el.find('#panel-print'))); + var printPanel = SSE.getController('Print').getView('PrintWithPreview'); + printPanel.menu = this; + this.panels['print-with-preview'] = printPanel.render(this.$el.find('#panel-print')); } }, diff --git a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js index a82071b93..0754efbe4 100644 --- a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js +++ b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js @@ -210,9 +210,9 @@ define([ this.generalSettings.options = {alias:'MainSettingsGeneral'}; this.generalSettings.render($markup.findById('#panel-settings-general')); - this.printSettings = SSE.getController('Print').getView('MainSettingsPrint'); - this.printSettings.menu = this.menu; - this.printSettings.render($markup.findById('#panel-settings-print')); + //this.printSettings = SSE.getController('Print').getView('MainSettingsPrint'); + //this.printSettings.menu = this.menu; + //this.printSettings.render($markup.findById('#panel-settings-print')); this.spellcheckSettings = new SSE.Views.FileMenuPanels.MainSpellCheckSettings({menu: this.menu}); this.spellcheckSettings.render($markup.findById('#panel-settings-spellcheck')); @@ -221,7 +221,7 @@ define([ el: $markup.findById('#id-settings-menu'), store: new Common.UI.DataViewStore([ {name: this.txtGeneral, panel: this.generalSettings, iconCls:'toolbar__icon btn-settings', contentTarget: 'panel-settings-general', selected: true}, - {name: this.txtPageSettings, panel: this.printSettings, iconCls:'toolbar__icon btn-print', contentTarget: 'panel-settings-print'}, + //{name: this.txtPageSettings, panel: this.printSettings, iconCls:'toolbar__icon btn-print', contentTarget: 'panel-settings-print'}, {name: this.txtSpellChecking, panel: this.spellcheckSettings, iconCls:'toolbar__icon btn-ic-docspell', contentTarget: 'panel-settings-spellcheck'} ]), itemTemplate: _.template([ @@ -2678,7 +2678,7 @@ define([ }, SSE.Views.FileMenuPanels.ProtectDoc || {})); - SSE.Views.FileMenuPanels.PrintWithPreview = Common.UI.BaseView.extend(_.extend({ + SSE.Views.PrintWithPreview = Common.UI.BaseView.extend(_.extend({ el: '#panel-print', menu: undefined, @@ -2746,7 +2746,7 @@ define([ '', '', '', '', @@ -2755,7 +2755,7 @@ define([ '', '
    ', @@ -2773,6 +2773,7 @@ define([ this.menu = options.menu; this.spinners = []; + this._initSettings = true; }, render: function(node) { @@ -2792,7 +2793,6 @@ define([ { value: Asc.c_oAscPrintType.Selection, displayValue: this.txtSelection } ] }); - this.cmbRange.on('selected', _.bind(this.onChangeComboRange, this)); this.chIgnorePrintArea = new Common.UI.CheckBox({ el: $markup.findById('#print-chb-ignore'), @@ -2952,13 +2952,16 @@ define([ this.btnApplyAll = new Common.UI.Button({ el: $markup.findById('#print-apply-all') }); - this.btnApplyAll.on('click', _.bind(this.onApplyToAll, this)); this.pnlSettings = $markup.find('.flex-settings').addBack().filter('.flex-settings'); this.pnlApply = $markup.find('.fms-flex-apply').addBack().filter('.fms-flex-apply'); this.pnlTable = $(this.pnlSettings.find('table')[0]); this.trApply = $markup.find('.fms-btn-apply'); + this.btnSave = new Common.UI.Button({ + el: $markup.findById('#print-button-save') + }); + this.$el = $(node).html($markup); if (_.isUndefined(this.scroller)) { @@ -2975,13 +2978,21 @@ define([ } }); + this.updateMetricUnit(); + + this.fireEvent('render:after', this); + return this; }, show: function() { Common.UI.BaseView.prototype.show.call(this,arguments); - + if (this._initSettings) { + this.updateMetricUnit(); + this._initSettings = false; + } this.updateScroller(); + this.fireEvent('show', this); }, updateScroller: function() { @@ -3004,12 +3015,56 @@ define([ }, - onChangeComboRange: function () { + updateMetricUnit: function() { + if (this.spinners) { + for (var i=0; i Date: Wed, 20 Oct 2021 17:56:06 +0300 Subject: [PATCH 04/19] [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', From 8e9d5dcea0327ec5865e0f6f6ff18910f66e22af Mon Sep 17 00:00:00 2001 From: JuliaSvinareva Date: Thu, 21 Oct 2021 15:20:32 +0300 Subject: [PATCH 05/19] [SSE] Add handler for print button in print preview menu --- .../main/app/controller/Print.js | 19 +++++++++++++++++-- .../main/app/view/FileMenuPanels.js | 18 +++++++++++------- 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/Print.js b/apps/spreadsheeteditor/main/app/controller/Print.js index e4f654201..9e71204ef 100644 --- a/apps/spreadsheeteditor/main/app/controller/Print.js +++ b/apps/spreadsheeteditor/main/app/controller/Print.js @@ -78,7 +78,9 @@ define([ onAfterRender: function(view) { this.printSettings.cmbSheet.on('selected', _.bind(this.comboSheetsChange, this, this.printSettings)); - this.printSettings.btnSave.on('click', _.bind(this.querySavePrintSettings, this)); + this.printSettings.btnSave.on('click', _.bind(this.querySavePrintSettings, this, false)); + this.printSettings.btnPrint.on('click', _.bind(this.querySavePrintSettings, this, true)); + this.fillComponents(this.printSettings); this.registerControlEvents(this.printSettings); }, @@ -335,10 +337,23 @@ define([ this.printSettingsDlg = null; }, - querySavePrintSettings: function() { + querySavePrintSettings: function(print) { if ( this.checkMargins(this.printSettings) ) { this.savePageOptions(this.printSettings); this.printSettings.applySettings(); + + if (print) { + var printType = this.printSettings.getRange(); + this.adjPrintParams.asc_setPrintType(printType); + this.adjPrintParams.asc_setPageOptionsMap(this._changedProps); + this.adjPrintParams.asc_setIgnorePrintArea(this.printSettings.getIgnorePrintArea()); + Common.localStorage.setItem("sse-print-settings-range", printType); + + var opts = new Asc.asc_CDownloadOptions(null, Common.Utils.isChrome || Common.Utils.isSafari || Common.Utils.isOpera || Common.Utils.isGecko && Common.Utils.firefoxVersion>86); + opts.asc_setAdvancedOptions(this.adjPrintParams); + this.api.asc_Print(opts); + Common.NotificationCenter.trigger('edit:complete', view); + } } }, diff --git a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js index a462092b5..091f655ef 100644 --- a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js +++ b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js @@ -2745,8 +2745,8 @@ define([ '', '', '', '', '', @@ -2754,8 +2754,8 @@ define([ '', '', '', @@ -2868,7 +2868,7 @@ define([ itemsTemplate: itemsTemplate }); - this.txtRangeTop = new Common.UI.InputFieldBtn({ + this.txtRangeTop = new Common.UI.InputField({ el: $markup.findById('#print-txt-top'), allowBlank: true, validateOnChange: true @@ -2882,7 +2882,7 @@ define([ menu: true }); - this.txtRangeLeft = new Common.UI.InputFieldBtn({ + this.txtRangeLeft = new Common.UI.InputField({ el: $markup.findById('#print-txt-left'), allowBlank: true, validateOnChange: true @@ -2960,7 +2960,11 @@ define([ this.trApply = $markup.find('.fms-btn-apply'); this.btnSave = new Common.UI.Button({ - el: $markup.findById('#print-button-save') + el: $markup.findById('#print-btn-save') + }); + + this.btnPrint = new Common.UI.Button({ + el: $markup.findById('#print-btn-print') }); this.$el = $(node).html($markup); From 79bf7d21bb3df0bb78439234cd28b71ef28ea7ec Mon Sep 17 00:00:00 2001 From: JuliaSvinareva Date: Thu, 21 Oct 2021 16:01:30 +0300 Subject: [PATCH 06/19] [SSE] Open print with preview from toolbar, remove unused code --- .../main/app/controller/LeftMenu.js | 5 +++++ .../main/app/controller/Main.js | 2 +- .../main/app/template/FileMenu.template | 1 - apps/spreadsheeteditor/main/app/view/FileMenu.js | 16 ++-------------- 4 files changed, 8 insertions(+), 16 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/LeftMenu.js b/apps/spreadsheeteditor/main/app/controller/LeftMenu.js index ec0ca3b6e..c1c70fa06 100644 --- a/apps/spreadsheeteditor/main/app/controller/LeftMenu.js +++ b/apps/spreadsheeteditor/main/app/controller/LeftMenu.js @@ -107,6 +107,7 @@ define([ if ( !this.leftMenu.panelHistory.isVisible() ) this.clickMenuFileItem(null, 'history'); }, this)); + Common.NotificationCenter.on('file:print', _.bind(this.clickToolbarPrint, this)); }, onLaunch: function() { @@ -534,6 +535,10 @@ define([ this.leftMenu.menuFile.hide(); }, + clickToolbarPrint: function () { + this.leftMenu.showMenu('file:printpreview'); + }, + changeToolbarSaveState: function (state) { var btnSave = this.leftMenu.menuFile.getButton('save'); btnSave && btnSave.setDisabled(state); diff --git a/apps/spreadsheeteditor/main/app/controller/Main.js b/apps/spreadsheeteditor/main/app/controller/Main.js index b72806304..639ebe996 100644 --- a/apps/spreadsheeteditor/main/app/controller/Main.js +++ b/apps/spreadsheeteditor/main/app/controller/Main.js @@ -2639,7 +2639,7 @@ define([ onPrint: function() { if (!this.appOptions.canPrint || Common.Utils.ModalWindow.isVisible()) return; - Common.NotificationCenter.trigger('print', this); + Common.NotificationCenter.trigger('file:print', this); }, onPrintUrl: function(url) { diff --git a/apps/spreadsheeteditor/main/app/template/FileMenu.template b/apps/spreadsheeteditor/main/app/template/FileMenu.template index a2e4c5f83..01ba748b1 100644 --- a/apps/spreadsheeteditor/main/app/template/FileMenu.template +++ b/apps/spreadsheeteditor/main/app/template/FileMenu.template @@ -7,7 +7,6 @@
  • -
  • diff --git a/apps/spreadsheeteditor/main/app/view/FileMenu.js b/apps/spreadsheeteditor/main/app/view/FileMenu.js index 8e5b5f6d8..6511ad4c1 100644 --- a/apps/spreadsheeteditor/main/app/view/FileMenu.js +++ b/apps/spreadsheeteditor/main/app/view/FileMenu.js @@ -129,19 +129,9 @@ define([ dataHintOffset: [2, 14] }); - this.miPrint = new Common.UI.MenuItem({ - el : $markup.elementById('#fm-btn-print'), - action : 'print', - caption : this.btnPrintCaption, - canFocused: false, - dataHint: 1, - dataHintDirection: 'left-top', - dataHintOffset: [2, 14] - }); - this.miPrintWithPreview = new Common.UI.MenuItem({ el : $markup.elementById('#fm-btn-print-with-preview'), - action : 'print-with-preview', + action : 'printpreview', caption : this.btnPrintCaption, canFocused: false, dataHint: 1, @@ -253,7 +243,6 @@ define([ this.miDownload, this.miSaveCopyAs, this.miSaveAs, - this.miPrint, this.miPrintWithPreview, this.miRename, this.miProtect, @@ -353,7 +342,6 @@ define([ this.miSaveAs[(this.mode.canDownload && this.mode.isDesktopApp && this.mode.isOffline)?'show':'hide'](); this.miSave[this.mode.isEdit?'show':'hide'](); this.miEdit[!this.mode.isEdit && this.mode.canEdit && this.mode.canRequestEditRights ?'show':'hide'](); - this.miPrint[this.mode.canPrint?'show':'hide'](); this.miPrintWithPreview[this.mode.canPrint?'show':'hide'](); this.miRename[(this.mode.canRename && !this.mode.isDesktopApp) ?'show':'hide'](); this.miProtect[this.mode.canProtect ?'show':'hide'](); @@ -422,7 +410,7 @@ define([ if (this.mode.canPrint) { var printPanel = SSE.getController('Print').getView('PrintWithPreview'); printPanel.menu = this; - this.panels['print-with-preview'] = printPanel.render(this.$el.find('#panel-print')); + this.panels['printpreview'] = printPanel.render(this.$el.find('#panel-print')); } }, From bd079d420909626c1e6aee16e6092b6b2ca8ff52 Mon Sep 17 00:00:00 2001 From: JuliaSvinareva Date: Thu, 21 Oct 2021 19:52:17 +0300 Subject: [PATCH 07/19] [SSE] Add print gridlines and print headings in toolbar --- .../main/app/controller/Toolbar.js | 12 +++++++++ .../main/app/template/Toolbar.template | 9 +++++++ .../main/app/view/Toolbar.js | 27 ++++++++++++++++--- 3 files changed, 45 insertions(+), 3 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/Toolbar.js b/apps/spreadsheeteditor/main/app/controller/Toolbar.js index 9b29a6259..3afddf524 100644 --- a/apps/spreadsheeteditor/main/app/controller/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/controller/Toolbar.js @@ -396,6 +396,8 @@ define([ button.on('click', _.bind(me.onEditHeaderClick, me)); }); toolbar.btnPrintTitles.on('click', _.bind(this.onPrintTitlesClick, this)); + toolbar.chPrintGridlines.on('change', _.bind(this.onPrintGridlinesChange, this)); + toolbar.chPrintHeadings.on('change', _.bind(this.onPrintHeadingsChange, this)); if (toolbar.btnCondFormat.rendered) { toolbar.btnCondFormat.menu.on('show:before', _.bind(this.onShowBeforeCondFormat, this, this.toolbar, 'toolbar')); } @@ -4063,6 +4065,16 @@ define([ } }, + onPrintGridlinesChange: function (field, value) { // To Do + console.log(value); + Common.NotificationCenter.trigger('edit:complete', this.toolbar); + }, + + onPrintHeadingsChange: function (field, value) { // To Do + console.log(value); + Common.NotificationCenter.trigger('edit:complete', this.toolbar); + }, + textEmptyImgUrl : 'You need to specify image URL.', warnMergeLostData : 'Operation can destroy data in the selected cells.
    Continue?', textWarning : 'Warning', diff --git a/apps/spreadsheeteditor/main/app/template/Toolbar.template b/apps/spreadsheeteditor/main/app/template/Toolbar.template index c76a111d3..3429bb547 100644 --- a/apps/spreadsheeteditor/main/app/template/Toolbar.template +++ b/apps/spreadsheeteditor/main/app/template/Toolbar.template @@ -162,6 +162,15 @@
    +
    +
    + +
    +
    + +
    +
    +
    diff --git a/apps/spreadsheeteditor/main/app/view/Toolbar.js b/apps/spreadsheeteditor/main/app/view/Toolbar.js index 97c8f6dac..06c2d4f95 100644 --- a/apps/spreadsheeteditor/main/app/view/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/view/Toolbar.js @@ -1567,6 +1567,22 @@ define([ dataHintOffset: 'small' }); + me.chPrintGridlines = new Common.UI.CheckBox({ + labelText: this.textPrintGridlines, + lock: [_set.selRange, _set.selRangeEdit, _set.lostConnect, _set.coAuth, _set.coAuthText, _set["Objects"]], + dataHint: '1', + dataHintDirection: 'left', + dataHintOffset: 'small' + }); + + me.chPrintHeadings = new Common.UI.CheckBox({ + labelText: this.textPrintHeadings, + lock: [_set.selRange, _set.selRangeEdit, _set.lostConnect, _set.coAuth, _set.coAuthText, _set["Objects"]], + dataHint: '1', + dataHintDirection: 'left', + dataHintOffset: 'small' + }); + me.btnImgAlign = new Common.UI.Button({ cls: 'btn-toolbar x-huge icon-top', iconCls: 'toolbar__icon btn-img-align', @@ -1634,7 +1650,8 @@ define([ me.btnInsertChart, me.btnColorSchemas, me.btnInsertSparkline, me.btnCopy, me.btnPaste, me.listStyles, me.btnPrint, /*me.btnSave,*/ me.btnClearStyle, me.btnCopyStyle, - me.btnPageMargins, me.btnPageSize, me.btnPageOrient, me.btnPrintArea, me.btnPrintTitles, me.btnImgAlign, me.btnImgBackward, me.btnImgForward, me.btnImgGroup, me.btnScale + me.btnPageMargins, me.btnPageSize, me.btnPageOrient, me.btnPrintArea, me.btnPrintTitles, me.btnImgAlign, me.btnImgBackward, me.btnImgForward, me.btnImgGroup, me.btnScale, + me.chPrintGridlines, me.chPrintHeadings ]; _.each(me.lockControls.concat([me.btnSave]), function(cmp) { @@ -1840,7 +1857,9 @@ define([ _injectComponent('#slot-btn-pagemargins', this.btnPageMargins); _injectComponent('#slot-btn-pagesize', this.btnPageSize); _injectComponent('#slot-btn-printarea', this.btnPrintArea); - _injectComponent('#slot-btn-printtitles', this.btnPrintTitles); + _injectComponent('#slot-btn-printtitles', this.btnPrintTitles); + _injectComponent('#slot-chk-print-gridlines', this.chPrintGridlines); + _injectComponent('#slot-chk-print-headings', this.chPrintHeadings); _injectComponent('#slot-img-align', this.btnImgAlign); _injectComponent('#slot-img-group', this.btnImgGroup); _injectComponent('#slot-img-movefrwd', this.btnImgForward); @@ -2850,6 +2869,8 @@ define([ textItems: 'Items', tipInsertSpark: 'Insert sparkline', capInsertSpark: 'Sparklines', - txtScheme22: 'New Office' + txtScheme22: 'New Office', + textPrintGridlines: 'Print gridlines', + textPrintHeadings: 'Print headings' }, SSE.Views.Toolbar || {})); }); \ No newline at end of file From a9d80439968d4ed2ce49e200ce4a34201aa18a5f Mon Sep 17 00:00:00 2001 From: JuliaSvinareva Date: Fri, 22 Oct 2021 21:17:45 +0300 Subject: [PATCH 08/19] [SSE] Add alt-key hints, make preview navigation buttons in print settings --- .../main/app/view/FileMenuPanels.js | 115 ++++++++++++++---- .../main/resources/less/leftmenu.less | 36 ++++++ 2 files changed, 127 insertions(+), 24 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js index 091f655ef..2d1a0e042 100644 --- a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js +++ b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js @@ -2742,11 +2742,11 @@ define([ '', '', '', - '', + //'', '', '', '', '', @@ -2754,15 +2754,18 @@ define([ '
    ', '', '', '', '', '' ].join('')), @@ -2791,13 +2794,19 @@ define([ { value: Asc.c_oAscPrintType.ActiveSheets, displayValue: this.txtCurrentSheet }, { value: Asc.c_oAscPrintType.EntireWorkbook, displayValue: this.txtAllSheets }, { value: Asc.c_oAscPrintType.Selection, displayValue: this.txtSelection } - ] + ], + dataHint: '2', + dataHintDirection: 'bottom', + dataHintOffset: 'big' }); this.cmbRange.on('selected', _.bind(this.comboRangeChange, this)); this.chIgnorePrintArea = new Common.UI.CheckBox({ el: $markup.findById('#print-chb-ignore'), - labelText: this.txtIgnore + labelText: this.txtIgnore, + dataHint: '2', + dataHintDirection: 'left', + dataHintOffset: 'small' }); this.cmbSheet = new Common.UI.ComboBox({ @@ -2806,7 +2815,10 @@ define([ editable: false, cls: 'input-group-nr', data: [], - takeFocusOnClose: true + takeFocusOnClose: true, + dataHint: '2', + dataHintDirection: 'bottom', + dataHintOffset: 'big' }); this.cmbPaperSize = new Common.UI.ComboBox({ @@ -2829,7 +2841,10 @@ define([ {value:'196.8|273', displayValue:'ROC 16K (19,68cm x 27,3cm)', caption: 'ROC 16K'}, {value:'119.9|234.9', displayValue:'Envelope Choukei 3 (11,99cm x 23,49cm)', caption: 'Envelope Choukei 3'}, {value:'330.2|482.5', displayValue:'Super B/A3 (33,02cm x 48,25cm)', caption: 'Super B/A3'} - ] + ], + dataHint: '2', + dataHintDirection: 'bottom', + dataHintOffset: 'big' }); this.cmbPaperOrientation = new Common.UI.ComboBox({ @@ -2841,7 +2856,10 @@ define([ data : [ { value: Asc.c_oAscPageOrientation.PagePortrait, displayValue: this.txtPortrait }, { value: Asc.c_oAscPageOrientation.PageLandscape, displayValue: this.txtLandscape } - ] + ], + dataHint: '2', + dataHintDirection: 'bottom', + dataHintOffset: 'big' }); var itemsTemplate = @@ -2865,13 +2883,19 @@ define([ { value: 3, displayValue: this.txtFitRows }, { value: 'customoptions', displayValue: this.txtCustomOptions } ], - itemsTemplate: itemsTemplate + itemsTemplate: itemsTemplate, + dataHint: '2', + dataHintDirection: 'bottom', + dataHintOffset: 'big' }); this.txtRangeTop = new Common.UI.InputField({ el: $markup.findById('#print-txt-top'), allowBlank: true, - validateOnChange: true + validateOnChange: true, + dataHint: '2', + dataHintDirection: 'left', + dataHintOffset: 'small' }); this.btnPresetsTop = new Common.UI.Button({ @@ -2879,13 +2903,19 @@ define([ cls: 'btn-text-menu-default', caption: this.txtRepeat, style: 'width: 77px;', - menu: true + menu: true, + dataHint: '2', + dataHintDirection: 'bottom', + dataHintOffset: 'big' }); this.txtRangeLeft = new Common.UI.InputField({ el: $markup.findById('#print-txt-left'), allowBlank: true, - validateOnChange: true + validateOnChange: true, + dataHint: '2', + dataHintDirection: 'left', + dataHintOffset: 'small' }); this.btnPresetsLeft = new Common.UI.Button({ @@ -2893,7 +2923,10 @@ define([ cls: 'btn-text-menu-default', caption: this.txtRepeat, style: 'width: 77px;', - menu: true + menu: true, + dataHint: '2', + dataHintDirection: 'bottom', + dataHintOffset: 'big' }); this.spnMarginTop = new Common.UI.MetricSpinner({ @@ -2903,7 +2936,10 @@ define([ defaultUnit : "cm", value: '0 cm', maxValue: 48.25, - minValue: 0 + minValue: 0, + dataHint: '2', + dataHintDirection: 'bottom', + dataHintOffset: 'big' }); this.spinners.push(this.spnMarginTop); @@ -2914,7 +2950,10 @@ define([ defaultUnit : "cm", value: '0 cm', maxValue: 48.25, - minValue: 0 + minValue: 0, + dataHint: '2', + dataHintDirection: 'bottom', + dataHintOffset: 'big' }); this.spinners.push(this.spnMarginBottom); @@ -2925,7 +2964,10 @@ define([ defaultUnit : "cm", value: '0.19 cm', maxValue: 48.25, - minValue: 0 + minValue: 0, + dataHint: '2', + dataHintDirection: 'bottom', + dataHintOffset: 'big' }); this.spinners.push(this.spnMarginLeft); @@ -2936,23 +2978,32 @@ define([ defaultUnit : "cm", value: '0.19 cm', maxValue: 48.25, - minValue: 0 + minValue: 0, + dataHint: '2', + dataHintDirection: 'bottom', + dataHintOffset: 'big' }); this.spinners.push(this.spnMarginRight); this.chPrintGrid = new Common.UI.CheckBox({ el: $markup.findById('#print-chb-grid'), - labelText: this.txtPrintGrid + labelText: this.txtPrintGrid, + dataHint: '2', + dataHintDirection: 'left', + dataHintOffset: 'small' }); this.chPrintRows = new Common.UI.CheckBox({ el: $markup.findById('#print-chb-rows'), - labelText: this.txtPrintHeadings + labelText: this.txtPrintHeadings, + dataHint: '2', + dataHintDirection: 'left', + dataHintOffset: 'small' }); - this.btnApplyAll = new Common.UI.Button({ + /*this.btnApplyAll = new Common.UI.Button({ el: $markup.findById('#print-apply-all') - }); + });*/ this.pnlSettings = $markup.find('.flex-settings').addBack().filter('.flex-settings'); this.pnlApply = $markup.find('.fms-flex-apply').addBack().filter('.fms-flex-apply'); @@ -2967,6 +3018,22 @@ define([ el: $markup.findById('#print-btn-print') }); + this.btnPrevPage = new Common.UI.Button({ + parentEl: $markup.findById('#print-prev-page'), + cls: 'btn-prev-page', + iconCls: 'arrow', + dataHint: '2', + dataHintDirection: 'top' + }); + + this.btnNextPage = new Common.UI.Button({ + parentEl: $markup.findById('#print-next-page'), + cls: 'btn-next-page', + iconCls: 'arrow', + dataHint: '2', + dataHintDirection: 'top' + }); + this.$el = $(node).html($markup); this.$el.on('click', '#print-header-footer-settings', _.bind(this.openHeaderSettings, this)); diff --git a/apps/spreadsheeteditor/main/resources/less/leftmenu.less b/apps/spreadsheeteditor/main/resources/less/leftmenu.less index 554d84cb9..774376152 100644 --- a/apps/spreadsheeteditor/main/resources/less/leftmenu.less +++ b/apps/spreadsheeteditor/main/resources/less/leftmenu.less @@ -580,6 +580,42 @@ } #print-navigation { height: 50px; + padding-left: 20px; + padding-top: 10px; + .btn-prev-page, .btn-next-page { + background-color: transparent; + padding: 0; + height: 20px; + width: 20px; + i.arrow { + display: inline-block; + width: 10px; + height: 10px; + + border: solid @scaled-one-px-value-ie @icon-normal-ie; + border: solid @scaled-one-px-value @icon-normal; + border-bottom: none; + border-right: none; + } + &.disabled { + opacity: @component-disabled-opacity; + } + + &:hover:not(:disabled):not(.disabled) { + background-color: @highlight-button-hover-ie; + background-color: @highlight-button-hover; + } + } + .btn-prev-page { + i { + transform: rotate(-45deg) translate(-1px, 3px); + } + } + .btn-next-page { + i { + transform: rotate(135deg) translate(4px, 0px); + } + } } #print-preview { height: calc(100% - 50px); From 2f5805d3ace6f0ca8839e86845ef31b551c90dfe Mon Sep 17 00:00:00 2001 From: JuliaSvinareva Date: Mon, 25 Oct 2021 11:37:28 +0300 Subject: [PATCH 09/19] [SSE] Add number page and name of active sheet in print settings in file menu --- .../main/app/view/FileMenuPanels.js | 37 ++++++++++++++++++- .../main/resources/less/leftmenu.less | 18 +++++++++ 2 files changed, 54 insertions(+), 1 deletion(-) diff --git a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js index 2d1a0e042..f0a60e4c6 100644 --- a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js +++ b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js @@ -2765,6 +2765,12 @@ define([ '', '', '' @@ -3034,6 +3040,20 @@ define([ dataHintDirection: 'top' }); + this.countOfPages = $markup.findById('#print-count-page'); + + this.txtNumberPage = new Common.UI.InputField({ + el: $markup.findById('#print-number-page'), + allowBlank: true, + validateOnChange: true, + style: 'width: 32px;', + dataHint: '2', + dataHintDirection: 'left', + dataHintOffset: 'small' + }); + + this.txtActiveSheet = $markup.findById('#print-active-sheet'); + this.$el = $(node).html($markup); this.$el.on('click', '#print-header-footer-settings', _.bind(this.openHeaderSettings, this)); @@ -3166,6 +3186,18 @@ define([ SSE.getController('Toolbar').onEditHeaderClick(); }, + updateCountOfPages: function (count) { + this.countOfPages.text( + Common.Utils.String.format(this.txtOf, count) + ); + }, + + updateActiveSheet: function (name) { + this.txtActiveSheet.text( + Common.Utils.String.format(this.txtSheet, name) + ); + }, + txtPrint: 'Print', txtSave: 'Save', txtPrintRange: 'Print range', @@ -3198,7 +3230,10 @@ define([ txtPrintHeadings: 'Print row and columns headings', txtHeaderFooterSettings: 'Header/footer settings', txtApplyToAllSheets: 'Apply to all sheets', - txtIgnore: 'Ignore print area' + txtIgnore: 'Ignore print area', + txtPage: 'Page', + txtOf: 'of {0}', + txtSheet: 'Sheet: {0}' }, SSE.Views.FileMenuPanels.PrintWithPreview || {})); }); diff --git a/apps/spreadsheeteditor/main/resources/less/leftmenu.less b/apps/spreadsheeteditor/main/resources/less/leftmenu.less index 774376152..75838bdaa 100644 --- a/apps/spreadsheeteditor/main/resources/less/leftmenu.less +++ b/apps/spreadsheeteditor/main/resources/less/leftmenu.less @@ -582,6 +582,7 @@ height: 50px; padding-left: 20px; padding-top: 10px; + display: flex; .btn-prev-page, .btn-next-page { background-color: transparent; padding: 0; @@ -616,6 +617,23 @@ transform: rotate(135deg) translate(4px, 0px); } } + .page-number { + display: flex; + align-items: center; + height: 20px; + margin-left: 10px; + label { + font-weight: bold; + } + #print-count-page, #print-number-page { + margin-left: 4px; + } + } + #print-active-sheet { + margin-left: 12px; + height: 20px; + line-height: 20px; + } } #print-preview { height: calc(100% - 50px); From 7cc2f854e8d5e1356903553ba0625a1551055351 Mon Sep 17 00:00:00 2001 From: JuliaSvinareva Date: Tue, 26 Oct 2021 20:21:24 +0300 Subject: [PATCH 10/19] [SSE] Add init and close print preview methods --- apps/spreadsheeteditor/main/app/controller/Print.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/apps/spreadsheeteditor/main/app/controller/Print.js b/apps/spreadsheeteditor/main/app/controller/Print.js index 9e71204ef..c21b0e894 100644 --- a/apps/spreadsheeteditor/main/app/controller/Print.js +++ b/apps/spreadsheeteditor/main/app/controller/Print.js @@ -77,6 +77,7 @@ define([ }, onAfterRender: function(view) { + this.printSettings.menu.on('menu:hide', _.bind(this.onHidePrintMenu, this)); this.printSettings.cmbSheet.on('selected', _.bind(this.comboSheetsChange, this, this.printSettings)); this.printSettings.btnSave.on('click', _.bind(this.querySavePrintSettings, this, false)); this.printSettings.btnPrint.on('click', _.bind(this.querySavePrintSettings, this, true)); @@ -276,6 +277,8 @@ define([ } this.fillPrintOptions(this.adjPrintParams, false); + + this._pagePreviewCount = this.api.asc_initPrintPreview('print-preview'); }, openPrintSettings: function(type, cmp, format, asUrl) { @@ -340,6 +343,7 @@ define([ querySavePrintSettings: function(print) { if ( this.checkMargins(this.printSettings) ) { this.savePageOptions(this.printSettings); + this._isPrint = print; this.printSettings.applySettings(); if (print) { @@ -353,6 +357,8 @@ define([ opts.asc_setAdvancedOptions(this.adjPrintParams); this.api.asc_Print(opts); Common.NotificationCenter.trigger('edit:complete', view); + + this._isPrint = false; } } }, @@ -573,6 +579,10 @@ define([ } }, + onHidePrintMenu: function () { + this.api.asc_closePrintPreview(this._isPrint); + }, + warnCheckMargings: 'Margins are incorrect', strAllSheets: 'All Sheets', textWarning: 'Warning', From ac93b3b4f25fab16ef00c7603af24145c4b8f1c8 Mon Sep 17 00:00:00 2001 From: JuliaSvinareva Date: Wed, 27 Oct 2021 14:11:23 +0300 Subject: [PATCH 11/19] [SSE] Add api methods for gridlines and headings --- .../main/app/controller/Toolbar.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/Toolbar.js b/apps/spreadsheeteditor/main/app/controller/Toolbar.js index 3afddf524..9b883dc91 100644 --- a/apps/spreadsheeteditor/main/app/controller/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/controller/Toolbar.js @@ -2252,6 +2252,8 @@ define([ this.onApiPageSize(opt.asc_getWidth(), opt.asc_getHeight()); this.onApiPageMargins(props.asc_getPageMargins()); this.onChangeScaleSettings(opt.asc_getFitToWidth(),opt.asc_getFitToHeight(),opt.asc_getScale()); + this.onApiGridLines(props.asc_getGridLines()); + this.onApiHeadings(props.asc_getHeadings()); this.api.asc_isLayoutLocked(currentSheet) ? this.onApiLockDocumentProps(currentSheet) : this.onApiUnLockDocumentProps(currentSheet); this.toolbar.lockToolbar(SSE.enumLock.printAreaLock, this.api.asc_isPrintAreaLocked(currentSheet), {array: [this.toolbar.btnPrintArea]}); @@ -2262,6 +2264,14 @@ define([ this.onApiSheetChanged(); }, + onApiGridLines: function (checked) { + this.toolbar.chPrintGridlines.setValue(checked, true); + }, + + onApiHeadings: function (checked) { + this.toolbar.chPrintHeadings.setValue(checked, true); + }, + onApiPageSize: function(w, h) { if (this._state.pgorient===undefined) return; @@ -4065,13 +4075,13 @@ define([ } }, - onPrintGridlinesChange: function (field, value) { // To Do - console.log(value); + onPrintGridlinesChange: function (field, value) { + this.api.asc_SetPrintGridlines(value === 'checked'); Common.NotificationCenter.trigger('edit:complete', this.toolbar); }, - onPrintHeadingsChange: function (field, value) { // To Do - console.log(value); + onPrintHeadingsChange: function (field, value) { + this.api.asc_SetPrintHeadings(value === 'checked'); Common.NotificationCenter.trigger('edit:complete', this.toolbar); }, From eb08feee37b1785c25eb75dd1ddaf046a662ef95 Mon Sep 17 00:00:00 2001 From: JuliaSvinareva Date: Wed, 27 Oct 2021 20:22:23 +0300 Subject: [PATCH 12/19] [SSE] Add methods for navigation in print preview --- .../main/app/controller/Print.js | 57 ++++++++++++++++++- .../main/app/view/FileMenuPanels.js | 20 ++++++- 2 files changed, 74 insertions(+), 3 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/Print.js b/apps/spreadsheeteditor/main/app/controller/Print.js index c21b0e894..d283166b5 100644 --- a/apps/spreadsheeteditor/main/app/controller/Print.js +++ b/apps/spreadsheeteditor/main/app/controller/Print.js @@ -53,6 +53,11 @@ define([ this._changedProps = null; this._originalPageSettings = null; + this._navigationPreview = { + pageCount: false, + currentPage: 0 + }; + this.addListeners({ /*'MainSettingsPrint': { 'show': _.bind(this.onShowMainSettingsPrint, this), @@ -81,6 +86,12 @@ define([ this.printSettings.cmbSheet.on('selected', _.bind(this.comboSheetsChange, this, this.printSettings)); this.printSettings.btnSave.on('click', _.bind(this.querySavePrintSettings, this, false)); this.printSettings.btnPrint.on('click', _.bind(this.querySavePrintSettings, this, true)); + this.printSettings.btnPrevPage.on('click', _.bind(this.onChangePreviewPage, this, false)); + this.printSettings.btnNextPage.on('click', _.bind(this.onChangePreviewPage, this, true)); + this.printSettings.txtNumberPage.on({ + 'keypress:after': _.bind(this.onKeypressPageNumber, this), + 'keyup:after': _.bind(this.onKeyupPageNumber, this) + }); this.fillComponents(this.printSettings); this.registerControlEvents(this.printSettings); @@ -278,7 +289,9 @@ define([ this.fillPrintOptions(this.adjPrintParams, false); - this._pagePreviewCount = this.api.asc_initPrintPreview('print-preview'); + this._navigationPreview.pageCount = this.api.asc_initPrintPreview('print-preview'); + this.printSettings.updateCountOfPages(this._navigationPreview.pageCount); + this.printSettings.updateCurrentPage(0); }, openPrintSettings: function(type, cmp, format, asUrl) { @@ -583,6 +596,48 @@ define([ this.api.asc_closePrintPreview(this._isPrint); }, + onChangePreviewPage: function (next) { + var index = this._navigationPreview.currentPage; + if (next) { + index++; + index = Math.min(index, this._navigationPreview.pageCount - 1); + } else { + index--; + index = Math.max(index, 0); + } + this.api.asc_drawPrintPreview(index); + + this.printSettings.updateCurrentPage(index); + this._navigationPreview.currentPage = index; + }, + + onKeypressPageNumber: function (input, e) { + if (e.keyCode === Common.UI.Keys.RETURN) { + var box = this.$el.find('#print-number-page'), + edit = box.find('input[type=text]'), page = parseInt(edit.val()); + if (!page || page-- > this._navigationPreview.pageCount || page < 0) { + edit.select(); + return false; + } + + box.focus(); // for IE + + this.api.asc_drawPrintPreview(page-1); + this.api.asc_enableKeyEvents(true); + + return false; + } + }, + + onKeyupPageNumber: function (input, e) { + if (e.keyCode === Common.UI.Keys.ESC) { + var box = this.$el.find('#print-number-page'); + box.focus(); // for IE + this.api.asc_enableKeyEvents(true); + return false; + } + }, + warnCheckMargings: 'Margins are incorrect', strAllSheets: 'All Sheets', textWarning: 'Warning', diff --git a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js index f0a60e4c6..dc4d4b4ea 100644 --- a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js +++ b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js @@ -3046,7 +3046,17 @@ define([ el: $markup.findById('#print-number-page'), allowBlank: true, validateOnChange: true, - style: 'width: 32px;', + style: 'width: 50px;', + maskExp: /[0-9]/, + validation: function(value) { + if (/(^[0-9]+$)/.test(value)) { + value = parseInt(value); + if (undefined !== value && value > 0 && value <= me.pageCount) + return true; + } + + return me.txtPageNumInvalid; + }, dataHint: '2', dataHintDirection: 'left', dataHintOffset: 'small' @@ -3190,6 +3200,7 @@ define([ this.countOfPages.text( Common.Utils.String.format(this.txtOf, count) ); + this.pageCount = count; }, updateActiveSheet: function (name) { @@ -3198,6 +3209,10 @@ define([ ); }, + updateCurrentPage: function (index) { + this.txtNumberPage.setValue(index + 1); + }, + txtPrint: 'Print', txtSave: 'Save', txtPrintRange: 'Print range', @@ -3233,7 +3248,8 @@ define([ txtIgnore: 'Ignore print area', txtPage: 'Page', txtOf: 'of {0}', - txtSheet: 'Sheet: {0}' + txtSheet: 'Sheet: {0}', + txtPageNumInvalid: 'Page number invalid' }, SSE.Views.FileMenuPanels.PrintWithPreview || {})); }); From ead08997a1352927820f5306e071ab62b5ec0b30 Mon Sep 17 00:00:00 2001 From: JuliaSvinareva Date: Thu, 28 Oct 2021 14:27:51 +0300 Subject: [PATCH 13/19] [SSE] Add update preview method --- .../main/app/controller/Print.js | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/apps/spreadsheeteditor/main/app/controller/Print.js b/apps/spreadsheeteditor/main/app/controller/Print.js index d283166b5..196470537 100644 --- a/apps/spreadsheeteditor/main/app/controller/Print.js +++ b/apps/spreadsheeteditor/main/app/controller/Print.js @@ -58,6 +58,8 @@ define([ currentPage: 0 }; + this._isPreviewVisible = false; + this.addListeners({ /*'MainSettingsPrint': { 'show': _.bind(this.onShowMainSettingsPrint, this), @@ -92,6 +94,7 @@ define([ 'keypress:after': _.bind(this.onKeypressPageNumber, this), 'keyup:after': _.bind(this.onKeyupPageNumber, this) }); + this.printSettings.chIgnorePrintArea.on('change', _.bind(this.updatePreview, this)); this.fillComponents(this.printSettings); this.registerControlEvents(this.printSettings); @@ -226,6 +229,10 @@ define([ } menu.cmbSheet.setDisabled(printtype !== Asc.c_oAscPrintType.EntireWorkbook); menu.chIgnorePrintArea.setDisabled(printtype == Asc.c_oAscPrintType.Selection); + + if (!isDlg) { + this.updatePreview(); + } }, getPageOptions: function(panel) { @@ -292,6 +299,8 @@ define([ this._navigationPreview.pageCount = this.api.asc_initPrintPreview('print-preview'); this.printSettings.updateCountOfPages(this._navigationPreview.pageCount); this.printSettings.updateCurrentPage(0); + + this._isPreviewVisible = true; }, openPrintSettings: function(type, cmp, format, asUrl) { @@ -452,6 +461,7 @@ define([ me.setScaling(panel, me.fitWidth, me.fitHeight, me.fitScale); if (me._changedProps) { me._changedProps[panel.cmbSheet.getValue()] = me.getPageOptions(panel); + me.updatePreview(); } } } else { @@ -469,6 +479,7 @@ define([ } else { if (this._changedProps) { this._changedProps[panel.cmbSheet.getValue()] = this.getPageOptions(panel); + this.updatePreview(); } } }, @@ -593,7 +604,10 @@ define([ }, onHidePrintMenu: function () { - this.api.asc_closePrintPreview(this._isPrint); + if (this._isPreviewVisible) { + this.api.asc_closePrintPreview(this._isPrint); + this._isPreviewVisible = false; + } }, onChangePreviewPage: function (next) { @@ -638,6 +652,20 @@ define([ } }, + updatePreview: function () { + if (this._isPreviewVisible) { + var adjPrintParams = new Asc.asc_CAdjustPrint(); + adjPrintParams.asc_setPrintType(this.printSettings.getRange()); + adjPrintParams.asc_setPageOptionsMap(this._changedProps); + adjPrintParams.asc_setIgnorePrintArea(this.printSettings.getIgnorePrintArea()); + + var opts = new Asc.asc_CDownloadOptions(null, Common.Utils.isChrome || Common.Utils.isSafari || Common.Utils.isOpera || Common.Utils.isGecko && Common.Utils.firefoxVersion>86); + opts.asc_setAdvancedOptions(adjPrintParams); + this._navigationPreview.pageCount = this.api.asc_updatePrintPreview(opts); + this.printSettings.updateCountOfPages(this._navigationPreview.pageCount); + } + }, + warnCheckMargings: 'Margins are incorrect', strAllSheets: 'All Sheets', textWarning: 'Warning', From 14e367d6a90a620d52f4ea0a55ee5929bd9335db Mon Sep 17 00:00:00 2001 From: JuliaSvinareva Date: Thu, 11 Nov 2021 13:32:26 +0300 Subject: [PATCH 14/19] [SSE] Fix input of page number for print menu --- apps/spreadsheeteditor/main/app/controller/Print.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/Print.js b/apps/spreadsheeteditor/main/app/controller/Print.js index 196470537..de3123c36 100644 --- a/apps/spreadsheeteditor/main/app/controller/Print.js +++ b/apps/spreadsheeteditor/main/app/controller/Print.js @@ -627,9 +627,9 @@ define([ onKeypressPageNumber: function (input, e) { if (e.keyCode === Common.UI.Keys.RETURN) { - var box = this.$el.find('#print-number-page'), + var box = this.printSettings.$el.find('#print-number-page'), edit = box.find('input[type=text]'), page = parseInt(edit.val()); - if (!page || page-- > this._navigationPreview.pageCount || page < 0) { + if (!page || page > this._navigationPreview.pageCount || page < 0) { edit.select(); return false; } @@ -645,7 +645,7 @@ define([ onKeyupPageNumber: function (input, e) { if (e.keyCode === Common.UI.Keys.ESC) { - var box = this.$el.find('#print-number-page'); + var box = this.printSettings.$el.find('#print-number-page'); box.focus(); // for IE this.api.asc_enableKeyEvents(true); return false; From 6438d216029e1cf3b2489682d41ed5367c32d4e1 Mon Sep 17 00:00:00 2001 From: JuliaSvinareva Date: Thu, 11 Nov 2021 14:41:44 +0300 Subject: [PATCH 15/19] [SSE] Add redrawing of preview when print settings are changed --- .../main/app/controller/Print.js | 27 ++++++++++++++++--- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/Print.js b/apps/spreadsheeteditor/main/app/controller/Print.js index de3123c36..46e08a8d2 100644 --- a/apps/spreadsheeteditor/main/app/controller/Print.js +++ b/apps/spreadsheeteditor/main/app/controller/Print.js @@ -46,6 +46,7 @@ define([ initialize: function() { var value = Common.localStorage.getItem("sse-print-settings-range"); value = (value!==null) ? parseInt(value) : Asc.c_oAscPrintType.ActiveSheets; + this._currentPrintType = value; this.adjPrintParams = new Asc.asc_CAdjustPrint(); this.adjPrintParams.asc_setPrintType(value); @@ -654,15 +655,33 @@ define([ updatePreview: function () { if (this._isPreviewVisible) { - var adjPrintParams = new Asc.asc_CAdjustPrint(); - adjPrintParams.asc_setPrintType(this.printSettings.getRange()); + var adjPrintParams = new Asc.asc_CAdjustPrint(), + printType = this.printSettings.getRange(); + adjPrintParams.asc_setPrintType(printType); adjPrintParams.asc_setPageOptionsMap(this._changedProps); adjPrintParams.asc_setIgnorePrintArea(this.printSettings.getIgnorePrintArea()); var opts = new Asc.asc_CDownloadOptions(null, Common.Utils.isChrome || Common.Utils.isSafari || Common.Utils.isOpera || Common.Utils.isGecko && Common.Utils.firefoxVersion>86); opts.asc_setAdvancedOptions(adjPrintParams); - this._navigationPreview.pageCount = this.api.asc_updatePrintPreview(opts); - this.printSettings.updateCountOfPages(this._navigationPreview.pageCount); + + var pageCount = this.api.asc_updatePrintPreview(opts); + + var newPage; + if (this._currentPrintType !== printType) { + newPage = 0; + this._currentPrintType = printType; + } else if (this._navigationPreview.pageCount > pageCount) { + newPage = pageCount - 1; + } else { + newPage = this._navigationPreview.currentPage; + } + + this.api.asc_drawPrintPreview(newPage); + + this._navigationPreview.currentPage = newPage; + this.printSettings.updateCurrentPage(newPage); + this._navigationPreview.pageCount = pageCount; + this.printSettings.updateCountOfPages(pageCount); } }, From b0a69a7f1d0358076972f70efeb14eca4eb3b0f5 Mon Sep 17 00:00:00 2001 From: JuliaSvinareva Date: Thu, 25 Nov 2021 18:59:48 +0300 Subject: [PATCH 16/19] [SSE] Print preview: add update name of preview sheet --- apps/spreadsheeteditor/main/app/controller/Print.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/apps/spreadsheeteditor/main/app/controller/Print.js b/apps/spreadsheeteditor/main/app/controller/Print.js index 46e08a8d2..3b7184e14 100644 --- a/apps/spreadsheeteditor/main/app/controller/Print.js +++ b/apps/spreadsheeteditor/main/app/controller/Print.js @@ -104,6 +104,7 @@ define([ setApi: function(o) { this.api = o; this.api.asc_registerCallback('asc_onSheetsChanged', _.bind(this.updateSheetsInfo, this)); + this.api.asc_registerCallback('asc_onPrintPreviewSheetChanged', _.bind(this.onApiChangePreviewSheet, this)); }, updateSheetsInfo: function() { @@ -685,6 +686,16 @@ define([ } }, + onApiChangePreviewSheet: function (index) { + var item = this.printSettings.cmbSheet.store.findWhere({value: index}); + if (item) { + this.printSettings.cmbSheet.setValue(item.get('value')); + this.comboSheetsChange(this.printSettings, this.printSettings.cmbSheet, item.toJSON()); + var sheetName = this.api.asc_getWorksheetName(index); + this.printSettings.updateActiveSheet(sheetName); + } + }, + warnCheckMargings: 'Margins are incorrect', strAllSheets: 'All Sheets', textWarning: 'Warning', From 20e9ad355ad3f926b9d60cefc1d0b29d1cb8432b Mon Sep 17 00:00:00 2001 From: JuliaSvinareva Date: Thu, 25 Nov 2021 19:41:19 +0300 Subject: [PATCH 17/19] [SSE] Print preview: add resize --- apps/spreadsheeteditor/main/app/controller/Print.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/apps/spreadsheeteditor/main/app/controller/Print.js b/apps/spreadsheeteditor/main/app/controller/Print.js index 3b7184e14..b83a6e185 100644 --- a/apps/spreadsheeteditor/main/app/controller/Print.js +++ b/apps/spreadsheeteditor/main/app/controller/Print.js @@ -99,6 +99,12 @@ define([ this.fillComponents(this.printSettings); this.registerControlEvents(this.printSettings); + + Common.NotificationCenter.on('window:resize', _.bind(function () { + if (this._isPreviewVisible) { + this.api.asc_drawPrintPreview(this._navigationPreview.currentPage); + } + }, this)); }, setApi: function(o) { From 81dcc267ef689b6456c1b862213350f46f322c56 Mon Sep 17 00:00:00 2001 From: JuliaSvinareva Date: Thu, 25 Nov 2021 20:40:41 +0300 Subject: [PATCH 18/19] [SSE] Print preview: fix page navigation --- apps/spreadsheeteditor/main/app/controller/Print.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/spreadsheeteditor/main/app/controller/Print.js b/apps/spreadsheeteditor/main/app/controller/Print.js index b83a6e185..0ba2720e7 100644 --- a/apps/spreadsheeteditor/main/app/controller/Print.js +++ b/apps/spreadsheeteditor/main/app/controller/Print.js @@ -677,7 +677,7 @@ define([ if (this._currentPrintType !== printType) { newPage = 0; this._currentPrintType = printType; - } else if (this._navigationPreview.pageCount > pageCount) { + } else if (this._navigationPreview.currentPage > pageCount - 1) { newPage = pageCount - 1; } else { newPage = this._navigationPreview.currentPage; From 267bb39e987f7703c739948746d8f26fecd6820d Mon Sep 17 00:00:00 2001 From: JuliaSvinareva Date: Fri, 26 Nov 2021 10:28:27 +0300 Subject: [PATCH 19/19] [SSE] Print preview: fix print and save buttons --- .../main/app/controller/Print.js | 9 +++++-- .../main/app/view/FileMenuPanels.js | 25 +++++++++++-------- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/Print.js b/apps/spreadsheeteditor/main/app/controller/Print.js index 0ba2720e7..d5cccda67 100644 --- a/apps/spreadsheeteditor/main/app/controller/Print.js +++ b/apps/spreadsheeteditor/main/app/controller/Print.js @@ -85,10 +85,15 @@ define([ }, onAfterRender: function(view) { + var me = this; this.printSettings.menu.on('menu:hide', _.bind(this.onHidePrintMenu, this)); this.printSettings.cmbSheet.on('selected', _.bind(this.comboSheetsChange, this, this.printSettings)); - this.printSettings.btnSave.on('click', _.bind(this.querySavePrintSettings, this, false)); - this.printSettings.btnPrint.on('click', _.bind(this.querySavePrintSettings, this, true)); + this.printSettings.btnsSave.forEach(function (btn) { + btn.on('click', _.bind(me.querySavePrintSettings, me, false)); + }); + this.printSettings.btnsPrint.forEach(function (btn) { + btn.on('click', _.bind(me.querySavePrintSettings, me, true)); + }); this.printSettings.btnPrevPage.on('click', _.bind(this.onChangePreviewPage, this, false)); this.printSettings.btnNextPage.on('click', _.bind(this.onChangePreviewPage, this, true)); this.printSettings.txtNumberPage.on({ diff --git a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js index dc4d4b4ea..a8e4d4cb7 100644 --- a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js +++ b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js @@ -2745,8 +2745,8 @@ define([ //'', '', '', '', '', @@ -2754,8 +2754,8 @@ define([ '', '', '', @@ -3016,13 +3016,16 @@ define([ this.pnlTable = $(this.pnlSettings.find('table')[0]); this.trApply = $markup.find('.fms-btn-apply'); - this.btnSave = new Common.UI.Button({ - el: $markup.findById('#print-btn-save') - }); - - this.btnPrint = new Common.UI.Button({ - el: $markup.findById('#print-btn-print') - }); + this.btnsSave = []; + this.btnsPrint = []; + for (var i=0; i<2; i++) { + this.btnsSave.push(new Common.UI.Button({ + el: $markup.findById('#print-btn-save-'+i) + })); + this.btnsPrint.push(new Common.UI.Button({ + el: $markup.findById('#print-btn-print-'+i) + })); + } this.btnPrevPage = new Common.UI.Button({ parentEl: $markup.findById('#print-prev-page'),