Merge pull request #2117 from ONLYOFFICE/feature/print-options

Feature/print options
This commit is contained in:
JuliaSvinareva 2022-12-07 14:39:44 +03:00 committed by GitHub
commit 3ddbc065e9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 181 additions and 17 deletions

View file

@ -148,20 +148,29 @@ define([
}
},
updateSettings: function(panel) {
resetSheets: function (panel) {
var wc = this.api.asc_getWorksheetsCount(), i = -1;
var items = [];
var rangeRecord = panel.cmbRange.getSelectedRecord(),
rangeValue = rangeRecord && rangeRecord.value,
selectedTabs = SSE.getController('Statusbar').getSelectTabs();
while (++i < wc) {
if (!this.api.asc_isWorksheetHidden(i)) {
items.push({
displayValue:this.api.asc_getWorksheetName(i),
value: i
});
if ((rangeRecord && rangeValue !== Asc.c_oAscPrintType.ActiveSheets) || selectedTabs.indexOf(i) !== -1) {
items.push({
displayValue: this.api.asc_getWorksheetName(i),
value: i
});
}
}
}
panel.cmbSheet.store.reset(items);
},
updateSettings: function(panel) {
this.resetSheets(panel);
var item = panel.cmbSheet.store.findWhere({value: panel.cmbSheet.getValue()}) ||
panel.cmbSheet.store.findWhere({value: this.api.asc_getActiveWorksheetIndex()});
if (item) {
@ -256,15 +265,16 @@ define([
},
onChangeRange: function(isDlg) {
var menu = isDlg ? this.printSettingsDlg : this.printSettings;
var printtype = menu.getRange(),
store = menu.cmbSheet.store,
var menu = isDlg ? this.printSettingsDlg : this.printSettings,
printtype = menu.getRange();
this.resetSheets(menu);
var store = menu.cmbSheet.store,
item = (printtype !== Asc.c_oAscPrintType.EntireWorkbook) ? store.findWhere({value: this.api.asc_getActiveWorksheetIndex()}) : store.at(0);
if (item) {
menu.cmbSheet.setValue(item.get('value'));
this.comboSheetsChange(menu, menu.cmbSheet, item.toJSON());
}
menu.cmbSheet.setDisabled(printtype !== Asc.c_oAscPrintType.EntireWorkbook);
menu.cmbSheet.setDisabled(printtype === Asc.c_oAscPrintType.Selection || printtype === Asc.c_oAscPrintType.ActiveSheets && menu.cmbSheet.store.length < 2);
menu.chIgnorePrintArea.setDisabled(printtype == Asc.c_oAscPrintType.Selection);
if (!isDlg) {
@ -335,6 +345,8 @@ define([
if (!this.isFillSheets) {
this.isFillSheets = true;
this.updateSettings(this.printSettings);
} else {
this.resetSheets(this.printSettings);
}
this.printSettings.cmbSheet.store.each(function (item) {
var sheetIndex = item.get('value');
@ -394,6 +406,16 @@ define([
this.adjPrintParams.asc_setPrintType(printtype);
this.adjPrintParams.asc_setPageOptionsMap(this._changedProps);
this.adjPrintParams.asc_setIgnorePrintArea(this.printSettingsDlg.getIgnorePrintArea());
this.adjPrintParams.asc_setActiveSheetsArray(printtype === Asc.c_oAscPrintType.ActiveSheets ? SSE.getController('Statusbar').getSelectTabs() : null);
var pageFrom = this.printSettingsDlg.getPagesFrom(),
pageTo = this.printSettingsDlg.getPagesTo();
if (pageFrom > pageTo) {
var t = pageFrom;
pageFrom = pageTo;
pageTo = t;
}
this.adjPrintParams.asc_setStartPageIndex(pageFrom > 0 ? pageFrom - 1 : null);
this.adjPrintParams.asc_setEndPageIndex(pageTo > 0 ? pageTo - 1 : null);
Common.localStorage.setItem("sse-print-settings-range", printtype);
if ( this.printSettingsDlg.type=='print' ) {
@ -429,6 +451,16 @@ define([
this.adjPrintParams.asc_setPrintType(printType);
this.adjPrintParams.asc_setPageOptionsMap(this._changedProps);
this.adjPrintParams.asc_setIgnorePrintArea(this.printSettings.getIgnorePrintArea());
this.adjPrintParams.asc_setActiveSheetsArray(printType === Asc.c_oAscPrintType.ActiveSheets ? SSE.getController('Statusbar').getSelectTabs() : null);
var pageFrom = this.printSettings.getPagesFrom(),
pageTo = this.printSettings.getPagesTo();
if (pageFrom > pageTo) {
var t = pageFrom;
pageFrom = pageTo;
pageTo = t;
}
this.adjPrintParams.asc_setStartPageIndex(pageFrom > 0 ? pageFrom - 1 : null);
this.adjPrintParams.asc_setEndPageIndex(pageTo > 0 ? pageTo - 1 : null);
Common.localStorage.setItem("sse-print-settings-range", printType);
var opts = new Asc.asc_CDownloadOptions(null, Common.Utils.isChrome || Common.Utils.isOpera || Common.Utils.isGecko && Common.Utils.firefoxVersion>86);
@ -737,6 +769,16 @@ define([
adjPrintParams.asc_setPrintType(printType);
adjPrintParams.asc_setPageOptionsMap(this._changedProps);
adjPrintParams.asc_setIgnorePrintArea(this.printSettings.getIgnorePrintArea());
adjPrintParams.asc_setActiveSheetsArray(printType === Asc.c_oAscPrintType.ActiveSheets ? SSE.getController('Statusbar').getSelectTabs() : null);
var pageFrom = this.printSettings.getPagesFrom(),
pageTo = this.printSettings.getPagesTo();
if (pageFrom > pageTo) {
var t = pageFrom;
pageFrom = pageTo;
pageTo = t;
}
adjPrintParams.asc_setStartPageIndex(pageFrom > 0 ? pageFrom - 1 : null);
adjPrintParams.asc_setEndPageIndex(pageTo > 0 ? pageTo - 1 : null);
var opts = new Asc.asc_CDownloadOptions(null, Common.Utils.isChrome || Common.Utils.isOpera || Common.Utils.isGecko && Common.Utils.firefoxVersion>86);
opts.asc_setAdvancedOptions(adjPrintParams);

View file

@ -840,6 +840,15 @@ define([
this.disconnectTip = null;
},
getSelectTabs: function () {
var selectTabs = this.statusbar.tabbar.selectTabs,
tabIndArr = [];
selectTabs.forEach(function (item) {
tabIndArr.push(item.sheetindex);
});
return tabIndArr;
},
zoomText : 'Zoom {0}%',
errorLastSheet : 'Workbook must have at least one visible worksheet.',
errorRemoveSheet: 'Can\'t delete the worksheet.',

View file

@ -2,8 +2,13 @@
<div class="padding-large inner-content" >
<div id="printadv-dlg-combo-range" class="input-group-nr"></div>
<div id="printadv-dlg-chb-ignore" style="margin-top: 5px;"></div>
<div id="printadv-dlg-pages">
<label><%= scope.textPages %></label>
<div id="printadv-dlg-spin-pages-from"></div>
<label><%= scope.textTo %></label>
<div id="printadv-dlg-spin-pages-to"></div>
</div>
</div>
<div class="padding-small"></div>
<div class="padding-large inner-content" >
<div id="printadv-dlg-combo-sheets" class="input-group-nr"></div>
</div>

View file

@ -2367,6 +2367,14 @@ SSE.Views.FileMenuPanels.RecentFiles = Common.UI.BaseView.extend({
'<tr><td><label class="header"><%= scope.txtPrintRange %></label></td></tr>',
'<tr><td class="padding-small"><div id="print-combo-range" style="width: 248px;"></div></td></tr>',
'<tr><td class="padding-large"><div id="print-chb-ignore" style="width: 248px;"></div></td></tr>',
'<tr><td class="padding-large">',
'<div class="pages">',
'<label><%= scope.txtPages %></label>',
'<div id="print-spin-pages-from"></div>',
'<label><%= scope.txtTo %></label>',
'<div id="print-spin-pages-to"></div>',
'</div>',
'</td></tr>',
'<tr><td><label class="header"><%= scope.txtSettingsOfSheet %></label></td></tr>',
'<tr><td class="padding-large"><div id="print-combo-sheets" style="width: 248px;"></div></td></tr>',
'<tr><td><label class="header"><%= scope.txtPageSize %></label></td></tr>',
@ -2475,7 +2483,7 @@ SSE.Views.FileMenuPanels.RecentFiles = Common.UI.BaseView.extend({
takeFocusOnClose: true,
cls: 'input-group-nr',
data: [
{ value: Asc.c_oAscPrintType.ActiveSheets, displayValue: this.txtCurrentSheet },
{ value: Asc.c_oAscPrintType.ActiveSheets, displayValue: this.txtActiveSheets },
{ value: Asc.c_oAscPrintType.EntireWorkbook, displayValue: this.txtAllSheets },
{ value: Asc.c_oAscPrintType.Selection, displayValue: this.txtSelection }
],
@ -2493,6 +2501,32 @@ SSE.Views.FileMenuPanels.RecentFiles = Common.UI.BaseView.extend({
dataHintOffset: 'small'
});
this.spnPagesFrom = new Common.UI.MetricSpinner({
el: $markup.findById('#print-spin-pages-from'),
step: 1,
width: 60,
defaultUnit : '',
value: '',
maxValue: 1000000,
minValue: 1,
dataHint: '2',
dataHintDirection: 'bottom',
dataHintOffset: 'big'
});
this.spnPagesTo = new Common.UI.MetricSpinner({
el: $markup.findById('#print-spin-pages-to'),
step: 1,
width: 60,
defaultUnit : '',
value: '',
maxValue: 1000000,
minValue: 1,
dataHint: '2',
dataHintDirection: 'bottom',
dataHintOffset: 'big'
});
this.cmbSheet = new Common.UI.ComboBox({
el: $markup.findById('#print-combo-sheets'),
menuStyle: 'min-width: 248px;max-height: 280px;',
@ -2876,6 +2910,14 @@ SSE.Views.FileMenuPanels.RecentFiles = Common.UI.BaseView.extend({
return (this.chIgnorePrintArea.getValue()=='checked');
},
getPagesFrom: function () {
return this.spnPagesFrom.getValue();
},
getPagesTo: function () {
return this.spnPagesTo.getValue();
},
comboRangeChange: function(combo, record) {
this.fireEvent('changerange', this);
},
@ -2905,6 +2947,9 @@ SSE.Views.FileMenuPanels.RecentFiles = Common.UI.BaseView.extend({
txtSave: 'Save',
txtPrintRange: 'Print range',
txtCurrentSheet: 'Current sheet',
txtActiveSheets: 'Active sheets',
txtPages: 'Pages:',
txtTo: 'to',
txtAllSheets: 'All sheets',
txtSelection: 'Selection',
txtSettingsOfSheet: 'Settings of sheet',

View file

@ -62,7 +62,7 @@ define([ 'text!spreadsheeteditor/main/app/template/PrintSettings.template',
template: [
'<div class="box" style="height:' + (this.options.height-85) + 'px;">',
'<div class="menu-panel" style="overflow: hidden;">',
'<div style="height: 54px; line-height: 42px;" class="div-category">' + ((this.type == 'print') ? this.textPrintRange : this.textRange)+ '</div>',
'<div style="height: 84px; line-height: 42px;" class="div-category">' + ((this.type == 'print') ? this.textPrintRange : this.textRange)+ '</div>',
'<div style="height: 52px; line-height: 66px;" class="div-category">' + this.textSettings + '</div>',
'<div style="height: 38px; line-height: 38px;" class="div-category">' + this.textPageSize + '</div>',
'<div style="height: 38px; line-height: 38px;" class="div-category">' + this.textPageOrientation + '</div>',
@ -96,7 +96,7 @@ define([ 'text!spreadsheeteditor/main/app/template/PrintSettings.template',
takeFocusOnClose: true,
cls : 'input-group-nr',
data : [
{ value: Asc.c_oAscPrintType.ActiveSheets, displayValue: this.textCurrentSheet },
{ value: Asc.c_oAscPrintType.ActiveSheets, displayValue: this.textActiveSheets },
{ value: Asc.c_oAscPrintType.EntireWorkbook, displayValue: this.textAllSheets },
{ value: Asc.c_oAscPrintType.Selection, displayValue: this.textSelection }
]
@ -108,6 +108,32 @@ define([ 'text!spreadsheeteditor/main/app/template/PrintSettings.template',
labelText: this.textIgnore
});
this.spnPagesFrom = new Common.UI.MetricSpinner({
el: $('#printadv-dlg-spin-pages-from'),
step: 1,
width: 60,
defaultUnit : '',
value: '',
maxValue: 1000000,
minValue: 1,
dataHint: '2',
dataHintDirection: 'bottom',
dataHintOffset: 'big'
});
this.spnPagesTo = new Common.UI.MetricSpinner({
el: $('#printadv-dlg-spin-pages-to'),
step: 1,
width: 60,
defaultUnit : '',
value: '',
maxValue: 1000000,
minValue: 1,
dataHint: '2',
dataHintDirection: 'bottom',
dataHintOffset: 'big'
});
this.cmbSheet = new Common.UI.ComboBox({
el : $('#printadv-dlg-combo-sheets'),
style : 'width: 242px;',
@ -326,6 +352,14 @@ define([ 'text!spreadsheeteditor/main/app/template/PrintSettings.template',
return (this.chIgnorePrintArea.getValue()=='checked');
},
getPagesFrom: function () {
return this.spnPagesFrom.getValue();
},
getPagesTo: function () {
return this.spnPagesTo.getValue();
},
comboRangeChange: function(combo, record) {
this.fireEvent('changerange', this);
},
@ -355,13 +389,13 @@ define([ 'text!spreadsheeteditor/main/app/template/PrintSettings.template',
if (!this.extended) {
this.extended = true;
this.panelDetails.css({'display': 'none'});
this.setHeight(314);
this.setHeight(344);
btn.setCaption(this.textShowDetails);
Common.localStorage.setItem("sse-hide-print-settings", 1);
} else {
this.extended = false;
this.panelDetails.css({'display': 'block'});
this.setHeight(585);
this.setHeight(615);
btn.setCaption(this.textHideDetails);
Common.localStorage.setItem("sse-hide-print-settings", 0);
}
@ -384,6 +418,7 @@ define([ 'text!spreadsheeteditor/main/app/template/PrintSettings.template',
textPrintRange: 'Print Range',
textLayout: 'Layout',
textCurrentSheet: 'Current Sheet',
textActiveSheets: 'Active Sheets',
textAllSheets: 'All Sheets',
textSelection: 'Selection',
textActualSize: 'Actual Size',
@ -406,7 +441,9 @@ define([ 'text!spreadsheeteditor/main/app/template/PrintSettings.template',
strPrintTitles: 'Print Titles',
textRepeatTop: 'Repeat rows at top',
textRepeatLeft: 'Repeat columns at left',
textRepeat: 'Repeat...'
textRepeat: 'Repeat...',
textPages: 'Pages:',
textTo: 'to'
}, SSE.Views.PrintSettings || {}));
});

View file

@ -3042,6 +3042,7 @@
"SSE.Views.PrintSettings.textActualSize": "Actual size",
"SSE.Views.PrintSettings.textAllSheets": "All sheets",
"SSE.Views.PrintSettings.textCurrentSheet": "Current sheet",
"SSE.Views.PrintSettings.textActiveSheets": "Active sheets",
"SSE.Views.PrintSettings.textCustom": "Custom",
"SSE.Views.PrintSettings.textCustomOptions": "Custom options",
"SSE.Views.PrintSettings.textFitCols": "Fit all columns on one page",
@ -3067,6 +3068,8 @@
"SSE.Views.PrintSettings.textShowHeadings": "Show rows and columns headings",
"SSE.Views.PrintSettings.textTitle": "Print settings",
"SSE.Views.PrintSettings.textTitlePDF": "PDF settings",
"SSE.Views.PrintSettings.textPages": "Pages:",
"SSE.Views.PrintSettings.textTo": "to",
"SSE.Views.PrintTitlesDialog.textFirstCol": "First column",
"SSE.Views.PrintTitlesDialog.textFirstRow": "First row",
"SSE.Views.PrintTitlesDialog.textFrozenCols": "Frozen columns",
@ -3083,6 +3086,9 @@
"SSE.Views.PrintWithPreview.txtApplyToAllSheets": "Apply to all sheets",
"SSE.Views.PrintWithPreview.txtBottom": "Bottom",
"SSE.Views.PrintWithPreview.txtCurrentSheet": "Current sheet",
"SSE.Views.PrintWithPreview.txtActiveSheets": "Active sheets",
"SSE.Views.PrintWithPreview.txtPages": "Pages:",
"SSE.Views.PrintWithPreview.txtTo": "to",
"SSE.Views.PrintWithPreview.txtCustom": "Custom",
"SSE.Views.PrintWithPreview.txtCustomOptions": "Custom Options",
"SSE.Views.PrintWithPreview.txtEmptyTable": "There is nothing to print because the table is empty",

View file

@ -85,3 +85,15 @@
border: @scaled-one-px-value-ie solid @border-regular-control-ie;
border: @scaled-one-px-value solid @border-regular-control;
}
#printadv-dlg-pages {
margin-top: 16px;
label, #printadv-dlg-spin-pages-from {
margin-right: 6px;
}
label, div {
display: inline-block;
}
}

View file

@ -681,6 +681,14 @@
flex-direction: column;
border-right: @scaled-one-px-value-ie solid @border-toolbar-ie;
border-right: @scaled-one-px-value solid @border-toolbar;
.pages {
label, #print-spin-pages-from {
margin-right: 6px;
}
label, div {
display: inline-block;
}
}
label.header {
font-weight: 700;
}