[SSE] Fix bug 60105

This commit is contained in:
JuliaSvinareva 2022-12-19 18:50:32 +03:00
parent 645f8cd55b
commit 33663d2bbe
4 changed files with 74 additions and 23 deletions

View file

@ -91,11 +91,16 @@ define([
} }
}, this)); }, this));
this.printSettings.btnsSave.forEach(function (btn) { this.printSettings.btnsSave.forEach(function (btn) {
btn.on('click', _.bind(me.querySavePrintSettings, me, false)); btn.on('click', _.bind(me.querySavePrintSettings, me, 'save'));
}); });
this.printSettings.btnsPrint.forEach(function (btn) { this.printSettings.btnsPrint.forEach(function (btn) {
btn.on('click', _.bind(me.querySavePrintSettings, me, true)); btn.on('click', _.bind(me.querySavePrintSettings, me, 'print'));
}); });
if (this.mode.isDesktopApp) {
this.printSettings.btnsPrintPDF.forEach(function (btn) {
btn.on('click', _.bind(me.querySavePrintSettings, me, 'print-pdf'));
});
}
this.printSettings.btnPrevPage.on('click', _.bind(this.onChangePreviewPage, this, false)); this.printSettings.btnPrevPage.on('click', _.bind(this.onChangePreviewPage, this, false));
this.printSettings.btnNextPage.on('click', _.bind(this.onChangePreviewPage, this, true)); this.printSettings.btnNextPage.on('click', _.bind(this.onChangePreviewPage, this, true));
this.printSettings.txtNumberPage.on({ this.printSettings.txtNumberPage.on({
@ -442,34 +447,37 @@ define([
querySavePrintSettings: function(print) { querySavePrintSettings: function(print) {
if ( this.checkMargins(this.printSettings) ) { if ( this.checkMargins(this.printSettings) ) {
this.savePageOptions(this.printSettings); this.savePageOptions(this.printSettings);
this._isPrint = print; this._isPrint = print === 'print';
this.printSettings.applySettings(); this.printSettings.applySettings();
if (print) { var view = SSE.getController('Toolbar').getView('Toolbar');
var view = SSE.getController('Toolbar').getView('Toolbar'); var printType = this.printSettings.getRange();
var printType = this.printSettings.getRange(); this.adjPrintParams.asc_setPrintType(printType);
this.adjPrintParams.asc_setPrintType(printType); this.adjPrintParams.asc_setPageOptionsMap(this._changedProps);
this.adjPrintParams.asc_setPageOptionsMap(this._changedProps); this.adjPrintParams.asc_setIgnorePrintArea(this.printSettings.getIgnorePrintArea());
this.adjPrintParams.asc_setIgnorePrintArea(this.printSettings.getIgnorePrintArea()); this.adjPrintParams.asc_setActiveSheetsArray(printType === Asc.c_oAscPrintType.ActiveSheets ? SSE.getController('Statusbar').getSelectTabs() : null);
this.adjPrintParams.asc_setActiveSheetsArray(printType === Asc.c_oAscPrintType.ActiveSheets ? SSE.getController('Statusbar').getSelectTabs() : null); var pageFrom = this.printSettings.getPagesFrom(),
var pageFrom = this.printSettings.getPagesFrom(), pageTo = this.printSettings.getPagesTo();
pageTo = this.printSettings.getPagesTo(); if (pageFrom > pageTo) {
if (pageFrom > pageTo) { var t = pageFrom;
var t = pageFrom; pageFrom = pageTo;
pageFrom = pageTo; pageTo = t;
pageTo = t; }
} this.adjPrintParams.asc_setStartPageIndex(pageFrom > 0 ? pageFrom - 1 : null);
this.adjPrintParams.asc_setStartPageIndex(pageFrom > 0 ? pageFrom - 1 : null); this.adjPrintParams.asc_setEndPageIndex(pageTo > 0 ? pageTo - 1 : null);
this.adjPrintParams.asc_setEndPageIndex(pageTo > 0 ? pageTo - 1 : null); Common.localStorage.setItem("sse-print-settings-range", printType);
Common.localStorage.setItem("sse-print-settings-range", printType);
if (print === 'print') {
var opts = new Asc.asc_CDownloadOptions(null, Common.Utils.isChrome || Common.Utils.isOpera || Common.Utils.isGecko && Common.Utils.firefoxVersion>86); 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); opts.asc_setAdvancedOptions(this.adjPrintParams);
this.api.asc_Print(opts); this.api.asc_Print(opts);
Common.NotificationCenter.trigger('edit:complete', view);
this._isPrint = false; this._isPrint = false;
} else if (print === 'print-pdf') {
var opts = new Asc.asc_CDownloadOptions(Asc.c_oAscFileType.PDF);
opts.asc_setAdvancedOptions(this.adjPrintParams);
this.api.asc_DownloadAs(opts);
} }
Common.NotificationCenter.trigger('edit:complete', view);
} }
}, },

View file

@ -2735,6 +2735,26 @@ SSE.Views.FileMenuPanels.RecentFiles = Common.UI.BaseView.extend({
this.btnsSave = []; this.btnsSave = [];
this.btnsPrint = []; this.btnsPrint = [];
if (this.mode.isDesktopApp) {
this.btnsPrintPDF = [];
for (var i=0; i<2; i++) {
var table =
['<table>',
'<tr>',
'<td><button id="print-btn-print-<%= index %>" class="btn normal dlg-btn primary btn-text-default auto" result="print" data-hint="2" data-hint-direction="bottom" data-hint-offset="big"><%= scope.txtPrint %></button></td>',
'<td><button id="print-btn-print-pdf-<%= index %>" class="btn normal dlg-btn btn-text-default auto" result="save-pdf" data-hint="2" data-hint-direction="bottom" data-hint-offset="big"><%= scope.txtPrintToPDF %></button></td>',
'<td><button id="print-btn-save-<%= index %>" class="btn normal dlg-btn btn-text-default auto" result="save" data-hint="2" data-hint-direction="bottom" data-hint-offset="big"><%= scope.txtSave %></button></td>',
'</tr>', '</table>',
].join('');
var tableTemplate = _.template(table)({scope: this, index: i});
$($markup.find('.footer')[i]).html(tableTemplate);
this.btnsPrintPDF.push(new Common.UI.Button({
el: $markup.findById('#print-btn-print-pdf-'+i)
}));
}
$markup.find('.footer').addClass('footer-with-pdf');
}
for (var i=0; i<2; i++) { for (var i=0; i<2; i++) {
this.btnsSave.push(new Common.UI.Button({ this.btnsSave.push(new Common.UI.Button({
el: $markup.findById('#print-btn-save-'+i) el: $markup.findById('#print-btn-save-'+i)
@ -2744,6 +2764,13 @@ SSE.Views.FileMenuPanels.RecentFiles = Common.UI.BaseView.extend({
})); }));
} }
this.btnsSavePDF = [];
for (var i=0; i<2; i++) {
this.btnsSavePDF.push(new Common.UI.Button({
el: $markup.findById('#print-btn-save-pdf-'+i)
}));
}
this.btnPrevPage = new Common.UI.Button({ this.btnPrevPage = new Common.UI.Button({
parentEl: $markup.findById('#print-prev-page'), parentEl: $markup.findById('#print-prev-page'),
cls: 'btn-prev-page', cls: 'btn-prev-page',
@ -2950,6 +2977,7 @@ SSE.Views.FileMenuPanels.RecentFiles = Common.UI.BaseView.extend({
txtPrint: 'Print', txtPrint: 'Print',
txtSave: 'Save', txtSave: 'Save',
txtPrintToPDF: 'Print to PDF',
txtPrintRange: 'Print range', txtPrintRange: 'Print range',
txtCurrentSheet: 'Current sheet', txtCurrentSheet: 'Current sheet',
txtActiveSheets: 'Active sheets', txtActiveSheets: 'Active sheets',

View file

@ -3122,6 +3122,7 @@
"SSE.Views.PrintWithPreview.txtSettingsOfSheet": "Settings of sheet", "SSE.Views.PrintWithPreview.txtSettingsOfSheet": "Settings of sheet",
"SSE.Views.PrintWithPreview.txtSheet": "Sheet: {0}", "SSE.Views.PrintWithPreview.txtSheet": "Sheet: {0}",
"SSE.Views.PrintWithPreview.txtTop": "Top", "SSE.Views.PrintWithPreview.txtTop": "Top",
"SSE.Views.PrintWithPreview.txtPrintToPDF": "Print to PDF",
"SSE.Views.ProtectDialog.textExistName": "ERROR! Range with such a title already exists", "SSE.Views.ProtectDialog.textExistName": "ERROR! Range with such a title already exists",
"SSE.Views.ProtectDialog.textInvalidName": "The range title must begin with a letter and may only contain letters, numbers, and spaces.", "SSE.Views.ProtectDialog.textInvalidName": "The range title must begin with a letter and may only contain letters, numbers, and spaces.",
"SSE.Views.ProtectDialog.textInvalidRange": "ERROR! Invalid cells range", "SSE.Views.ProtectDialog.textInvalidRange": "ERROR! Invalid cells range",

View file

@ -693,7 +693,7 @@
font-weight: 700; font-weight: 700;
} }
.footer { .footer {
.btn.primary { .btn:not(:last-child) {
margin-right: 8px; margin-right: 8px;
} }
} }
@ -728,6 +728,20 @@
} }
} }
} }
.footer-with-pdf {
table {
width: 247px;
}
td:not(:last-child) {
padding-right: 5px;
}
.btn-text-default.auto {
padding-left: 3px;
padding-right: 3px;
min-width: 64px;
width: 100%;
}
}
} }
#print-navigation { #print-navigation {
height: 50px; height: 50px;