diff --git a/apps/spreadsheeteditor/main/app/controller/Print.js b/apps/spreadsheeteditor/main/app/controller/Print.js index 6a66e9270..532047783 100644 --- a/apps/spreadsheeteditor/main/app/controller/Print.js +++ b/apps/spreadsheeteditor/main/app/controller/Print.js @@ -198,6 +198,7 @@ define([ opt.asc_setFitToWidth(fitToWidth); opt.asc_setFitToHeight(fitToHeight); !fitToWidth && !fitToHeight && opt.asc_setScale(100); + this.setScaling(panel, fitToWidth, fitToHeight, 100); } else { opt.asc_setFitToWidth(this.fitWidth); opt.asc_setFitToHeight(this.fitHeight); @@ -355,7 +356,7 @@ define([ }, propertyChange: function(panel, scale, combo, record) { - if (scale === 'scale' && record.value === 4) { + if (scale === 'scale' && record.value === 'customoptions') { var me = this, props = (me._changedProps.length > 0 && me._changedProps[panel.cmbSheet.getValue()]) ? me._changedProps[panel.cmbSheet.getValue()] : me.api.asc_getPageOptions(panel.cmbSheet.getValue()); var win = new SSE.Views.ScaleDialog({ @@ -396,11 +397,14 @@ define([ }, setScaling: function (panel, width, height, scale) { - if (!width && !height && scale === 100) panel.cmbLayout.setValue(0, true); - else if (width === 1 && height === 1) panel.cmbLayout.setValue(1, true); - else if (width === 1 && !height) panel.cmbLayout.setValue(2, true); - else if (!width && height === 1) panel.cmbLayout.setValue(3, true); - else panel.cmbLayout.setValue(4, true); + var value; + if (!width && !height && scale === 100) value = 0; + else if (width === 1 && height === 1) value = 1; + else if (width === 1 && !height) value = 2; + else if (!width && height === 1) value = 3; + else value = 4; + panel.addCustomScale(value === 4); + panel.cmbLayout.setValue(value, true); }, warnCheckMargings: 'Margins are incorrect', diff --git a/apps/spreadsheeteditor/main/app/controller/Toolbar.js b/apps/spreadsheeteditor/main/app/controller/Toolbar.js index e886614c7..4e3147eae 100644 --- a/apps/spreadsheeteditor/main/app/controller/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/controller/Toolbar.js @@ -362,7 +362,9 @@ define([ toolbar.btnPageOrient.menu.on('item:click', _.bind(this.onPageOrientSelect, this)); toolbar.btnPageMargins.menu.on('item:click', _.bind(this.onPageMarginsSelect, this)); toolbar.mnuPageSize.on('item:click', _.bind(this.onPageSizeClick, this)); - toolbar.mnuScale.on('item:click', _.bind(this.onScaleClick, this)); + toolbar.mnuScale.on('item:click', _.bind(this.onScaleClick, this, 'scale')); + toolbar.menuWidthScale.on('item:click', _.bind(this.onScaleClick, this, 'width')); + toolbar.menuHeightScale.on('item:click', _.bind(this.onScaleClick, this, 'height')); toolbar.btnPrintArea.menu.on('item:click', _.bind(this.onPrintAreaClick, this)); toolbar.btnPrintArea.menu.on('show:after', _.bind(this.onPrintAreaMenuOpen, this)); toolbar.btnImgGroup.menu.on('item:click', _.bind(this.onImgGroupSelect, this)); @@ -1845,33 +1847,52 @@ define([ }, onChangeScaleSettings: function(width, height, scale) { - var me = this; if (this.toolbar.btnScale.menu) { - this.toolbar.btnScale.menu.clearAll(); if (width !== undefined) { - if ((width === 0 || width === null) && (height === 0 || height === null) && scale === 100) { - this._state.scale = 0; - } else if (width === 1 && height === 1) { - this._state.scale = 1; - } else if (width === 1 && (height === 0 || height === null)) { - this._state.scale = 2; - } else if ((width === 0 || width === null) && height === 1) { - this._state.scale = 3; - } else if ((width === 0 || width === null) && (height === 0 || height === null)) { - this._state.scale = 4; + var isWidth = false, + isHeight = false; + var width = width || 0, + height = height || 0; + if (scale !== undefined) { + this.toolbar.setValueCustomScale(scale); } else { - this._state.scale = 5; + this.toolbar.setValueCustomScale(this.api.asc_getPageOptions().asc_getPageSetup().asc_getScale()); + } + this.toolbar.menuWidthScale.clearAll(); + this.toolbar.menuWidthScale.items.forEach(function (item) { + if (item.value === width) { + item.setChecked(true); + isWidth = true; + return false; + } + }); + if (!isWidth) { + this.toolbar.menuWidthScale.items[11].setChecked(true); + } + this.toolbar.menuHeightScale.clearAll(); + this.toolbar.menuHeightScale.items.forEach(function (item) { + if (item.value === height) { + item.setChecked(true); + isHeight = true; + return false; + } + }); + if (!isHeight) { + this.toolbar.menuHeightScale.items[11].setChecked(true); + } + if (this.toolbar.btnCustomScaleUp && this.toolbar.btnCustomScaleDown) { + this.toolbar.btnCustomScaleUp.setDisabled(!(!width && !height)); + this.toolbar.btnCustomScaleDown.setDisabled(!(!width && !height)); + } + this._state.scaleWidth = width; + this._state.scaleHeight = height; + this._state.scale = scale; + } else { + if (this.toolbar.btnCustomScaleUp && this.toolbar.btnCustomScaleDown) { + this.toolbar.btnCustomScaleUp.setDisabled(!(!this._state.scaleWidth && !this._state.scaleHeight)); + this.toolbar.btnCustomScaleDown.setDisabled(!(!this._state.scaleWidth && !this._state.scaleHeight)); } - this.toolbar.setValueCustomScale(scale); - } else if (scale === undefined) { - this.toolbar.setValueCustomScale(this.api.asc_getPageOptions().asc_getPageSetup().asc_getScale()); } - _.each(this.toolbar.btnScale.menu.items, function(item){ - if (item.value === me._state.scale) { - item.setChecked(true); - return false; - } - }, this); } }, @@ -3390,50 +3411,40 @@ define([ } }, - onScaleClick: function(menu, item, event, scale) { + onScaleClick: function(type, menu, item, event, scale) { var me = this; if (me.api) { - if (scale !== undefined) { - me.api.asc_SetPrintScale(0, 0, scale); - me._state.scale = 4; - } else { - switch (item.value) { - case 0: - me.api.asc_SetPrintScale(0, 0, 100); - me._state.scale = 0; - break; - case 1: - me.api.asc_SetPrintScale(1, 1, 100); - me._state.scale = 1; - break; - case 2: - me.api.asc_SetPrintScale(1, 0, 100); - me._state.scale = 2; - break; - case 3: - me.api.asc_SetPrintScale(0, 1, 100); - me._state.scale = 3; - break; - case 5: - var win = new SSE.Views.ScaleDialog({ - api: me.api, - props: null, - handler: function (dlg, result) { - if (dlg == 'ok') { - if (me.api && result) { - me.api.asc_SetPrintScale(result.width, result.height, result.scale); - me.onChangeScaleSettings(result.width, result.height, result.scale); - } - me._state.scale = 5; - } else { - me.onChangeScaleSettings(); - } - Common.NotificationCenter.trigger('edit:complete'); - } - }); - win.show(); - break; + if (type === 'width' && item.value !== 'more') { + if (me._state.scaleHeight === undefined || me._state.scaleHeight === null) { + me._state.scaleHeight = 0; } + me.api.asc_SetPrintScale(item.value, me._state.scaleHeight, 100); + me.onChangeScaleSettings(item.value, me._state.scaleHeight, 100); + } else if (type === 'height' && item.value !== 'more') { + if (me._state.scaleWidth === undefined || me._state.scaleWidth === null) { + me._state.scaleWidth = 0; + } + me.api.asc_SetPrintScale(me._state.scaleWidth, item.value, 100); + me.onChangeScaleSettings(me._state.scaleWidth, item.value, 100); + } else if (type === 'scale' && scale !== undefined) { + me.api.asc_SetPrintScale(0, 0, scale); + } else if (item.value === 'custom' || item.value === 'more') { + var win = new SSE.Views.ScaleDialog({ + api: me.api, + props: null, + handler: function (dlg, result) { + if (dlg == 'ok') { + if (me.api && result) { + me.api.asc_SetPrintScale(result.width, result.height, result.scale); + me.onChangeScaleSettings(result.width, result.height, result.scale); + } + } else { + me.onChangeScaleSettings(me._state.scaleWidth, me._state.scaleHeight, me._state.scale); + } + Common.NotificationCenter.trigger('edit:complete'); + } + }); + win.show(); } } diff --git a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js index cbbed6958..bfadf0008 100644 --- a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js +++ b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js @@ -350,6 +350,14 @@ define([ ] }); + var itemsTemplate = + _.template([ + '<% _.each(items, function(item) { %>', + '
  • style="border-top: 1px solid #e5e5e5;margin-top: 5px;" <% } %> >', + '<%= scope.getDisplayValue(item) %>', + '
  • ', + '<% }); %>' + ].join('')); this.cmbLayout = new Common.UI.ComboBox({ el : $markup.findById('#advsettings-print-combo-layout'), style : 'width: 242px;', @@ -361,8 +369,9 @@ define([ { value: 1, displayValue: this.textFitPage }, { value: 2, displayValue: this.textFitCols }, { value: 3, displayValue: this.textFitRows }, - { value: 4, displayValue: this.textCustomOptions} - ] + { value: 'customoptions', displayValue: this.textCustomOptions } + ], + itemsTemplate: itemsTemplate }); this.chPrintGrid = new Common.UI.CheckBox({ @@ -438,6 +447,27 @@ define([ return this; }, + addCustomScale: function (add) { + if (add) { + this.cmbLayout.setData([ + { value: 0, displayValue: this.textActualSize }, + { value: 1, displayValue: this.textFitPage }, + { value: 2, displayValue: this.textFitCols }, + { value: 3, displayValue: this.textFitRows }, + { value: 4, displayValue: this.textCustom }, + { value: 'customoptions', displayValue: this.textCustomOptions } + ]); + } else { + this.cmbLayout.setData([ + { value: 0, displayValue: this.textActualSize }, + { value: 1, displayValue: this.textFitPage }, + { value: 2, displayValue: this.textFitCols }, + { value: 3, displayValue: this.textFitRows }, + { value: 'customoptions', displayValue: this.textCustomOptions } + ]); + } + }, + updateMetricUnit: function() { if (this.spinners) { for (var i=0; i', + '
  • style="border-top: 1px solid #e5e5e5;margin-top: 5px;" <% } %> >', + '<%= scope.getDisplayValue(item) %>', + '
  • ', + '<% }); %>' + ].join('')); this.cmbLayout = new Common.UI.ComboBox({ el : $('#printadv-dlg-combo-layout'), style : 'width: 242px;', @@ -215,8 +223,9 @@ define([ 'text!spreadsheeteditor/main/app/template/PrintSettings.template', { value: 1, displayValue: this.textFitPage }, { value: 2, displayValue: this.textFitCols }, { value: 3, displayValue: this.textFitRows }, - { value: 4, displayValue: this.textCustomOptions} - ] + { value: 'customoptions', displayValue: this.textCustomOptions } + ], + itemsTemplate: itemsTemplate }); this.btnHide = new Common.UI.Button({ @@ -233,6 +242,27 @@ define([ 'text!spreadsheeteditor/main/app/template/PrintSettings.template', this.handlerShowDetails(this.btnHide); }, + addCustomScale: function (add) { + if (add) { + this.cmbLayout.setData([ + { value: 0, displayValue: this.textActualSize }, + { value: 1, displayValue: this.textFitPage }, + { value: 2, displayValue: this.textFitCols }, + { value: 3, displayValue: this.textFitRows }, + { value: 4, displayValue: this.textCustom }, + { value: 'customoptions', displayValue: this.textCustomOptions } + ]); + } else { + this.cmbLayout.setData([ + { value: 0, displayValue: this.textActualSize }, + { value: 1, displayValue: this.textFitPage }, + { value: 2, displayValue: this.textFitCols }, + { value: 3, displayValue: this.textFitRows }, + { value: 'customoptions', displayValue: this.textCustomOptions } + ]); + } + }, + setRange: function(value) { this.cmbRange.setValue(value); }, @@ -324,7 +354,8 @@ define([ 'text!spreadsheeteditor/main/app/template/PrintSettings.template', btnDownload: 'Save & Download', textRange: 'Range', textIgnore: 'Ignore Print Area', - textCustomOptions: 'Custom Options' + textCustomOptions: 'Custom Options', + textCustom: 'Custom' }, SSE.Views.PrintSettings || {})); }); \ No newline at end of file diff --git a/apps/spreadsheeteditor/main/app/view/Toolbar.js b/apps/spreadsheeteditor/main/app/view/Toolbar.js index 14173f21d..b96eac788 100644 --- a/apps/spreadsheeteditor/main/app/view/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/view/Toolbar.js @@ -1345,8 +1345,6 @@ define([ '' ].join('')), stopPropagation: true, - toggleGroup: 'menuScale', - checkable: true, value: 4 }); @@ -1358,39 +1356,58 @@ define([ lock: [_set.docPropsLock, _set.lostConnect, _set.coAuth], menu: new Common.UI.Menu({ items: [ - { - caption: me.textActualSize, - checkable: true, - toggleGroup: 'menuScale', - value: 0 - }, - { - caption: me.textFitSheetOnOnePage, - checkable: true, - toggleGroup: 'menuScale', - value: 1 - }, - { - caption: me.textFitAllColumnsOnOnePage, - checkable: true, - toggleGroup: 'menuScale', - value: 2 - }, - { - caption: me.textFitAllRowsOnOnePage, - checkable: true, - toggleGroup: 'menuScale', - value: 3 - }, - me.mnuCustomScale, - {caption: '--'}, - { caption: me.textScaleCustom, - checkable: true, - toggleGroup: 'menuScale', - value: 5 - } ]}) }); + var menuWidthItem = new Common.UI.MenuItem({ + caption: me.textWidth, + menu: new Common.UI.Menu({ + menuAlign: 'tl-tr', + items: [ + {caption: this.textAuto, value: 0, checkable: true, toggleGroup : 'scaleWidth'}, + {caption: '1 ' + this.textOnePage, value: 1, checkable: true, toggleGroup : 'scaleWidth'}, + {caption: '2 ' + this.textFewPages, value: 2, checkable: true, toggleGroup : 'scaleWidth'}, + {caption: '3 ' + this.textFewPages, value: 3, checkable: true, toggleGroup : 'scaleWidth'}, + {caption: '4 ' + this.textFewPages, value: 4, checkable: true, toggleGroup : 'scaleWidth'}, + {caption: '5 ' + this.textManyPages, value: 5, checkable: true, toggleGroup : 'scaleWidth'}, + {caption: '6 ' + this.textManyPages, value: 6, checkable: true, toggleGroup : 'scaleWidth'}, + {caption: '7 ' + this.textManyPages, value: 7, checkable: true, toggleGroup : 'scaleWidth'}, + {caption: '8 ' + this.textManyPages, value: 8, checkable: true, toggleGroup : 'scaleWidth'}, + {caption: '9 ' + this.textManyPages, value: 9, checkable: true, toggleGroup : 'scaleWidth'}, + {caption: '--'}, + {caption: this.textMorePages, value: 'more', checkable: true, toggleGroup : 'scaleWidth'} + ] + }) + }); + var menuHeightItem = new Common.UI.MenuItem({ + caption: me.textHeight, + menu: new Common.UI.Menu({ + menuAlign: 'tl-tr', + items: [ + {caption: this.textAuto, value: 0, checkable: true, toggleGroup : 'scaleHeight'}, + {caption: '1 ' + this.textOnePage, value: 1, checkable: true, toggleGroup : 'scaleHeight'}, + {caption: '2 ' + this.textFewPages, value: 2, checkable: true, toggleGroup : 'scaleHeight'}, + {caption: '3 ' + this.textFewPages, value: 3, checkable: true, toggleGroup : 'scaleHeight'}, + {caption: '4 ' + this.textFewPages, value: 4, checkable: true, toggleGroup : 'scaleHeight'}, + {caption: '5 ' + this.textManyPages, value: 5, checkable: true, toggleGroup : 'scaleHeight'}, + {caption: '6 ' + this.textManyPages, value: 6, checkable: true, toggleGroup : 'scaleHeight'}, + {caption: '7 ' + this.textManyPages, value: 7, checkable: true, toggleGroup : 'scaleHeight'}, + {caption: '8 ' + this.textManyPages, value: 8, checkable: true, toggleGroup : 'scaleHeight'}, + {caption: '9 ' + this.textManyPages, value: 9, checkable: true, toggleGroup : 'scaleHeight'}, + {caption: '--'}, + {caption: this.textMorePages, value: 'more', checkable: true, toggleGroup : 'scaleHeight'} + ] + }) + }); + me.btnScale.menu.addItem(menuWidthItem); + me.btnScale.menu.addItem(menuHeightItem); + me.btnScale.menu.addItem(me.mnuCustomScale); + me.btnScale.menu.addItem({caption: '--'}); + me.btnScale.menu.addItem( + { caption: me.textScaleCustom, value: 'custom' + }); + me.menuWidthScale = me.btnScale.menu.items[0].menu; + me.menuHeightScale = me.btnScale.menu.items[1].menu; + me.mnuScale = me.btnScale.menu; me.mnuScale.on('show:after', _.bind(me.onAfterShowMenuScale, me)); @@ -1472,7 +1489,7 @@ define([ } if (!me.itemCustomScale) { me.itemCustomScale = $('.custom-scale', me.mnuCustomScale.$el).on('click', _.bind(function () { - me.fireEvent('click:customscale', [undefined, undefined, undefined, me.valueCustomScale], this); + me.fireEvent('click:customscale', ['scale', undefined, undefined, undefined, me.valueCustomScale], this); }, this)); } if (!me.btnCustomScaleUp) { @@ -1491,6 +1508,7 @@ define([ me.fireEvent('change:scalespn', ['down', me.valueCustomScale], this); }, this)); } + SSE.getController('Toolbar').onChangeScaleSettings(); }, setValueCustomScale: function(val) { @@ -2495,6 +2513,13 @@ define([ textFitAllColumnsOnOnePage: 'Fit All Columns on One Page', textFitAllRowsOnOnePage: 'Fit All Rows on One Page', textScaleCustom: 'Custom', - textScale: 'Scale' + textScale: 'Scale', + textAuto: 'Auto', + textOnePage: 'page', + textFewPages: 'pages', + textManyPages: 'pages', + textHeight: 'Height', + textWidth: 'Width', + textMorePages: 'More pages' }, SSE.Views.Toolbar || {})); }); \ No newline at end of file diff --git a/apps/spreadsheeteditor/main/locale/en.json b/apps/spreadsheeteditor/main/locale/en.json index bac17e95b..77ebe8dd2 100644 --- a/apps/spreadsheeteditor/main/locale/en.json +++ b/apps/spreadsheeteditor/main/locale/en.json @@ -1751,6 +1751,7 @@ "SSE.Views.MainSettingsPrint.textPrintHeadings": "Print Row and Column Headings", "SSE.Views.MainSettingsPrint.textSettings": "Settings for", "SSE.Views.MainSettingsPrint.textCustomOptions": "Custom Options", + "SSE.Views.MainSettingsPrint.textCustom": "Custom", "SSE.Views.NamedRangeEditDlg.errorCreateDefName": "The existing named ranges cannot be edited and the new ones cannot be created
    at the moment as some of them are being edited.", "SSE.Views.NamedRangeEditDlg.namePlaceholder": "Defined name", "SSE.Views.NamedRangeEditDlg.notcriticalErrorTitle": "Warning", @@ -1927,6 +1928,7 @@ "SSE.Views.PrintSettings.textTitle": "Print Settings", "SSE.Views.PrintSettings.textTitlePDF": "PDF Settings", "SSE.Views.PrintSettings.textCustomOptions": "Custom Options", + "SSE.Views.PrintSettings.textCustom": "Custom", "SSE.Views.RightMenu.txtCellSettings": "Cell settings", "SSE.Views.RightMenu.txtChartSettings": "Chart settings", "SSE.Views.RightMenu.txtImageSettings": "Image settings", @@ -2410,6 +2412,13 @@ "SSE.Views.Toolbar.txtYen": "¥ Yen", "SSE.Views.Toolbar.capBtnScale": "Scale to Fit", "SSE.Views.Toolbar.tipScale": "Scale to Fit", + "SSE.Views.Toolbar.textAuto": "Auto", + "SSE.Views.Toolbar.textOnePage": "page", + "SSE.Views.Toolbar.textFewPages": "pages", + "SSE.Views.Toolbar.textManyPages": "pages", + "SSE.Views.Toolbar.textHeight": "Height", + "SSE.Views.Toolbar.textWidth": "Width", + "SSE.Views.Toolbar.textMorePages": "More pages", "SSE.Views.Top10FilterDialog.textType": "Show", "SSE.Views.Top10FilterDialog.txtBottom": "Bottom", "SSE.Views.Top10FilterDialog.txtItems": "Item",