From 24830cb70bf983f78d0a873f02c854574592a95c Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Tue, 15 Nov 2022 16:45:28 +0300 Subject: [PATCH] [DE] Send print settings to sdk. Enable print preview only for desktop. --- .../main/app/controller/Main.js | 2 +- .../main/app/controller/Print.js | 33 +++++++++---------- .../main/app/view/FileMenuPanels.js | 5 +-- 3 files changed, 19 insertions(+), 21 deletions(-) diff --git a/apps/documenteditor/main/app/controller/Main.js b/apps/documenteditor/main/app/controller/Main.js index 31b233d18..813a2089f 100644 --- a/apps/documenteditor/main/app/controller/Main.js +++ b/apps/documenteditor/main/app/controller/Main.js @@ -1494,7 +1494,7 @@ define([ } this.appOptions.canEditStyles = this.appOptions.canLicense && this.appOptions.canEdit; this.appOptions.canPrint = (this.permissions.print !== false); - this.appOptions.canPreviewPrint = this.appOptions.canPrint && !Common.Utils.isMac; + this.appOptions.canPreviewPrint = this.appOptions.canPrint && !Common.Utils.isMac && this.appOptions.isDesktopApp; this.appOptions.canRename = this.editorConfig.canRename; this.appOptions.buildVersion = params.asc_getBuildVersion(); this.appOptions.canForcesave = this.appOptions.isEdit && !this.appOptions.isOffline && (typeof (this.editorConfig.customization) == 'object' && !!this.editorConfig.customization.forcesave); diff --git a/apps/documenteditor/main/app/controller/Print.js b/apps/documenteditor/main/app/controller/Print.js index d92d4e893..8ae19b397 100644 --- a/apps/documenteditor/main/app/controller/Print.js +++ b/apps/documenteditor/main/app/controller/Print.js @@ -42,14 +42,10 @@ define([ ], initialize: function() { - var value = Common.localStorage.getItem("de-print-settings-range"); - value = (value!==null) ? parseInt(value) : Asc.c_oAscPrintType.ActiveSheets; - this.adjPrintParams = new Asc.asc_CAdjustPrint(); - this.adjPrintParams.asc_setPrintType(value); - this._state = { - lock_doc: false + lock_doc: false, + firstPrintPage: 0 }; this._navigationPreview = { @@ -119,6 +115,7 @@ define([ } if (res.length>0) { // me.adjPrintParams.asc_setPages(res); + me._state.firstPrintPage = res[0]; return true; } } @@ -135,8 +132,6 @@ define([ var eventname = (/Firefox/i.test(navigator.userAgent))? 'DOMMouseScroll' : 'mousewheel'; this.printSettings.$previewBox.on(eventname, _.bind(this.onPreviewWheel, this)); - - this.fillPrintOptions(); }, setMode: function (mode) { @@ -224,23 +219,14 @@ define([ } }, - fillPrintOptions: function(props) { - // fill page numbers, copies, collated - var panel = this.printSettings; - panel.cmbRange.setValue(this.adjPrintParams.asc_getPrintType()); - panel.inputPages.setValue(''); // pages numbers - }, - comboRangeChange: function(combo, record) { if (record.value === -1) { var me = this; setTimeout(function(){ me.printSettings.inputPages.focus(); }, 50); - // this.adjPrintParams.asc_setPrintType(record.value) } else { this.printSettings.inputPages.setValue(''); - this.adjPrintParams.asc_setPrintType(record.value) } this.printSettings.inputPages.showError(); }, @@ -501,8 +487,19 @@ define([ this.isInputFirstChange = true; return; } + if (this.printSettings.cmbRange.getValue()==='all') + this._state.firstPrintPage = 0; + else if (this.printSettings.cmbRange.getValue()==='current') + this._state.firstPrintPage = this._navigationPreview.currentPage; + this._isPrint = print; + this.adjPrintParams.asc_setNativeOptions({ + pages: this.printSettings.cmbRange.getValue()===-1 ? this.printSettings.inputPages.getValue() : this.printSettings.cmbRange.getValue(), + paperSize: this._state.pgsize, //this.api.asc_getPageSize(this._state.firstPrintPage), + paperOrientation: this._state.pgorient ? 'portrait' : 'landscape' // this.api.asc_getPageOrient(this._state.firstPrintPage) ? 'portrait' : 'landscape' + }); + if ( print ) { var opts = new Asc.asc_CDownloadOptions(null, Common.Utils.isChrome || Common.Utils.isOpera || Common.Utils.isGecko && Common.Utils.firefoxVersion>86); opts.asc_setAdvancedOptions(this.adjPrintParams); @@ -521,7 +518,7 @@ define([ this.isInputFirstChange = false; if (value.length<1) - this.printSettings.cmbRange.setValue(Asc.c_oAscPrintType.EntireWorkbook); + this.printSettings.cmbRange.setValue('all'); else if (this.printSettings.cmbRange.getValue()!==-1) this.printSettings.cmbRange.setValue(-1); }, diff --git a/apps/documenteditor/main/app/view/FileMenuPanels.js b/apps/documenteditor/main/app/view/FileMenuPanels.js index 881050d70..1365fa8f9 100644 --- a/apps/documenteditor/main/app/view/FileMenuPanels.js +++ b/apps/documenteditor/main/app/view/FileMenuPanels.js @@ -2399,14 +2399,15 @@ define([ takeFocusOnClose: true, cls: 'input-group-nr', data: [ - { value: Asc.c_oAscPrintType.EntireWorkbook, displayValue: this.txtAllPages }, - { value: Asc.c_oAscPrintType.ActiveSheets, displayValue: this.txtCurrentPage }, + { value: 'all', displayValue: this.txtAllPages }, + { value: 'current', displayValue: this.txtCurrentPage }, { value: -1, displayValue: this.txtCustomPages } ], dataHint: '2', dataHintDirection: 'bottom', dataHintOffset: 'big' }); + this.cmbRange.setValue('all'); this.inputPages = new Common.UI.InputField({ el: $markup.findById('#print-txt-pages'),