[DE] Send print settings to sdk. Enable print preview only for desktop.

This commit is contained in:
Julia Radzhabova 2022-11-15 16:45:28 +03:00
parent 50bf470a63
commit 24830cb70b
3 changed files with 19 additions and 21 deletions

View file

@ -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);

View file

@ -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);
},

View file

@ -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'),