diff --git a/apps/common/main/resources/img/controls/toolbarbig.png b/apps/common/main/resources/img/controls/toolbarbig.png
index 5c300ef0d..aab375007 100644
Binary files a/apps/common/main/resources/img/controls/toolbarbig.png and b/apps/common/main/resources/img/controls/toolbarbig.png differ
diff --git a/apps/common/main/resources/img/controls/toolbarbig@2x.png b/apps/common/main/resources/img/controls/toolbarbig@2x.png
index bfc632e19..d767eea48 100644
Binary files a/apps/common/main/resources/img/controls/toolbarbig@2x.png and b/apps/common/main/resources/img/controls/toolbarbig@2x.png differ
diff --git a/apps/common/main/resources/less/dropdown-menu.less b/apps/common/main/resources/less/dropdown-menu.less
index 5aa203037..0f0c477cf 100644
--- a/apps/common/main/resources/less/dropdown-menu.less
+++ b/apps/common/main/resources/less/dropdown-menu.less
@@ -57,6 +57,9 @@
margin-left: -18px;
background-position: @menu-check-offset-x @menu-check-offset-y;
}
+ &.custom-scale:before {
+ margin-top: 3px;
+ }
}
.menu-item-icon {
diff --git a/apps/common/main/resources/less/toolbar.less b/apps/common/main/resources/less/toolbar.less
index 48138ef7b..4e64e2a59 100644
--- a/apps/common/main/resources/less/toolbar.less
+++ b/apps/common/main/resources/less/toolbar.less
@@ -531,6 +531,7 @@
.button-normal-icon(btn-more, 74, @toolbar-big-icon-size);
.button-normal-icon(btn-pagenum, 75, @toolbar-big-icon-size);
.button-normal-icon(btn-calculation, 80, @toolbar-big-icon-size);
+.button-normal-icon(btn-scale, 81, @toolbar-big-icon-size);
[applang=ru] {
.btn-toolbar {
diff --git a/apps/spreadsheeteditor/main/app/controller/Print.js b/apps/spreadsheeteditor/main/app/controller/Print.js
index edd5a8714..f207a1c1c 100644
--- a/apps/spreadsheeteditor/main/app/controller/Print.js
+++ b/apps/spreadsheeteditor/main/app/controller/Print.js
@@ -142,11 +142,9 @@ define([
parseFloat(Common.Utils.Metric.fnRecalcFromMM(h).toFixed(2)) + Common.Utils.Metric.getCurrentMetricName() + ')');
var fitwidth = opt.asc_getFitToWidth(),
- fitheight = opt.asc_getFitToHeight();
- if (!fitwidth && !fitheight) panel.cmbLayout.setValue(0);
- else if (fitwidth && fitheight) panel.cmbLayout.setValue(1);
- else if (fitwidth && !fitheight) panel.cmbLayout.setValue(2);
- else panel.cmbLayout.setValue(3);
+ fitheight = opt.asc_getFitToHeight(),
+ fitscale = opt.asc_getScale();
+ this.setScaling(panel, fitwidth, fitheight, fitscale);
item = panel.cmbPaperOrientation.store.findWhere({value: opt.asc_getOrientation()});
if (item) panel.cmbPaperOrientation.setValue(item.get('value'));
@@ -194,9 +192,17 @@ define([
opt.asc_setHeight(pageh? parseFloat(pageh[0]) : (this._originalPageSettings ? this._originalPageSettings.asc_getHeight() : undefined));
var value = panel.cmbLayout.getValue();
- opt.asc_setFitToWidth(value==1 || value==2);
- opt.asc_setFitToHeight(value==1 || value==3);
-
+ if (value !== 4) {
+ var fitToWidth = (value==1 || value==2) ? 1 : 0,
+ fitToHeight = (value==1 || value==3) ? 1 : 0;
+ opt.asc_setFitToWidth(fitToWidth);
+ opt.asc_setFitToHeight(fitToHeight);
+ !fitToWidth && !fitToHeight && opt.asc_setScale(100);
+ } else {
+ opt.asc_setFitToWidth(this.fitWidth);
+ opt.asc_setFitToHeight(this.fitHeight);
+ opt.asc_setScale(this.fitScale);
+ }
props.asc_setPageSetup(opt);
opt = new Asc.asc_CPageMargins();
@@ -339,7 +345,7 @@ define([
registerControlEvents: function(panel) {
panel.cmbPaperSize.on('selected', _.bind(this.propertyChange, this, panel));
panel.cmbPaperOrientation.on('selected', _.bind(this.propertyChange, this, panel));
- panel.cmbLayout.on('selected', _.bind(this.propertyChange, this, panel));
+ panel.cmbLayout.on('selected', _.bind(this.propertyChange, this, panel, 'scale'));
panel.spnMarginTop.on('change', _.bind(this.propertyChange, this, panel));
panel.spnMarginBottom.on('change', _.bind(this.propertyChange, this, panel));
panel.spnMarginLeft.on('change', _.bind(this.propertyChange, this, panel));
@@ -348,9 +354,40 @@ define([
panel.chPrintRows.on('change', _.bind(this.propertyChange, this, panel));
},
- propertyChange: function(panel) {
- if (this._changedProps) {
- this._changedProps[panel.cmbSheet.getValue()] = this.getPageOptions(panel);
+ propertyChange: function(panel, scale, combo, record) {
+ if (scale === 'scale' && record.value === 4) {
+ 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({
+ api: me.api,
+ props: props,
+ handler: function(dlg, result) {
+ if (dlg == 'ok') {
+ if (me.api && result) {
+ me.fitWidth = result.width;
+ me.fitHeight = result.height;
+ me.fitScale = result.scale;
+ me.setScaling(panel, me.fitWidth, me.fitHeight, me.fitScale);
+ if (me._changedProps) {
+ me._changedProps[panel.cmbSheet.getValue()] = me.getPageOptions(panel);
+ }
+ }
+ } else {
+ var opt = props.asc_getPageSetup(),
+ fitwidth = opt.asc_getFitToWidth(),
+ fitheight = opt.asc_getFitToHeight(),
+ fitscale = opt.asc_getScale();
+ me.setScaling(panel, fitwidth, fitheight, fitscale);
+ }
+ Common.NotificationCenter.trigger('edit:complete');
+ }
+ });
+ win.show();
+ Common.NotificationCenter.trigger('edit:complete', this.toolbar);
+ } else {
+ if (this._changedProps) {
+ this._changedProps[panel.cmbSheet.getValue()] = this.getPageOptions(panel);
+ }
}
},
@@ -358,6 +395,14 @@ define([
return this.adjPrintParams;
},
+ 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);
+ },
+
warnCheckMargings: 'Margins are incorrect',
strAllSheets: 'All Sheets',
textWarning: 'Warning',
diff --git a/apps/spreadsheeteditor/main/app/controller/Toolbar.js b/apps/spreadsheeteditor/main/app/controller/Toolbar.js
index 89f6338f3..656a4cf25 100644
--- a/apps/spreadsheeteditor/main/app/controller/Toolbar.js
+++ b/apps/spreadsheeteditor/main/app/controller/Toolbar.js
@@ -55,7 +55,8 @@ define([
'spreadsheeteditor/main/app/view/NameManagerDlg',
'spreadsheeteditor/main/app/view/FormatSettingsDialog',
'spreadsheeteditor/main/app/view/PageMarginsDialog',
- 'spreadsheeteditor/main/app/view/HeaderFooterDialog'
+ 'spreadsheeteditor/main/app/view/HeaderFooterDialog',
+ 'spreadsheeteditor/main/app/view/ScaleDialog'
], function () { 'use strict';
SSE.Controllers.Toolbar = Backbone.Controller.extend(_.extend({
@@ -70,7 +71,9 @@ define([
this.addListeners({
'Toolbar': {
- 'change:compact': this.onClickChangeCompact.bind(me)
+ 'change:compact': this.onClickChangeCompact.bind(me),
+ 'change:scalespn': this.onClickChangeScaleInMenu.bind(me),
+ 'click:customscale': this.onScaleClick.bind(me)
},
'FileMenu': {
'menu:hide': me.onFileMenu.bind(me, 'hide'),
@@ -357,6 +360,7 @@ 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.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));
@@ -1760,6 +1764,7 @@ define([
this.onApiPageOrient(opt.asc_getOrientation());
this.onApiPageSize(opt.asc_getWidth(), opt.asc_getHeight());
this.onApiPageMargins(props.asc_getPageMargins());
+ this.onChangeScaleSettings(opt.asc_getFitToWidth(),opt.asc_getFitToHeight(),opt.asc_getScale());
this.api.asc_isLayoutLocked(currentSheet) ? this.onApiLockDocumentProps(currentSheet) : this.onApiUnLockDocumentProps(currentSheet);
this.toolbar.lockToolbar(SSE.enumLock.printAreaLock, this.api.asc_isPrintAreaLocked(currentSheet), {array: [this.toolbar.btnPrintArea]});
@@ -1822,16 +1827,47 @@ 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;
+ } else {
+ this._state.scale = 5;
+ }
+ 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);
+ }
+ },
+
onApiLockDocumentProps: function(nIndex) {
if (this._state.lock_doc!==true && nIndex == this.api.asc_getActiveWorksheetIndex()) {
- this.toolbar.lockToolbar(SSE.enumLock.docPropsLock, true, {array: [this.toolbar.btnPageSize, this.toolbar.btnPageMargins, this.toolbar.btnPageOrient]});
+ this.toolbar.lockToolbar(SSE.enumLock.docPropsLock, true, {array: [this.toolbar.btnPageSize, this.toolbar.btnPageMargins, this.toolbar.btnPageOrient, this.toolbar.btnScale]});
this._state.lock_doc = true;
}
},
onApiUnLockDocumentProps: function(nIndex) {
if (this._state.lock_doc!==false && nIndex == this.api.asc_getActiveWorksheetIndex()) {
- this.toolbar.lockToolbar(SSE.enumLock.docPropsLock, false, {array: [this.toolbar.btnPageSize, this.toolbar.btnPageMargins, this.toolbar.btnPageOrient]});
+ this.toolbar.lockToolbar(SSE.enumLock.docPropsLock, false, {array: [this.toolbar.btnPageSize, this.toolbar.btnPageMargins, this.toolbar.btnPageOrient, this.toolbar.btnScale]});
this._state.lock_doc = false;
}
},
@@ -3360,6 +3396,82 @@ define([
Common.NotificationCenter.trigger('edit:complete', this.toolbar);
},
+ onClickChangeScaleInMenu: function(type, curScale) {
+ if (this.api) {
+ var scale;
+ if (type === 'up') {
+ if (curScale % 5 > 0.001) {
+ scale = Math.ceil(curScale / 5) * 5;
+ } else {
+ scale = curScale + 5;
+ }
+ } else {
+ if (curScale % 5 > 0.001) {
+ scale = Math.floor(curScale / 5) * 5;
+ } else {
+ scale = curScale - 5;
+ }
+ }
+ if (scale > 400) {
+ scale = 400;
+ } else if (scale < 10) {
+ scale = 10;
+ }
+ this.api.asc_SetPrintScale(0, 0, scale);
+ this.onChangeScaleSettings(0, 0, scale);
+ }
+ },
+
+ onScaleClick: function(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;
+ }
+ }
+ }
+
+ Common.NotificationCenter.trigger('edit:complete', this.toolbar);
+ },
+
textEmptyImgUrl : 'You need to specify image URL.',
warnMergeLostData : 'Operation can destroy data in the selected cells.
Continue?',
textWarning : 'Warning',
diff --git a/apps/spreadsheeteditor/main/app/template/Toolbar.template b/apps/spreadsheeteditor/main/app/template/Toolbar.template
index 0190dfd7c..9d812e6b3 100644
--- a/apps/spreadsheeteditor/main/app/template/Toolbar.template
+++ b/apps/spreadsheeteditor/main/app/template/Toolbar.template
@@ -151,6 +151,7 @@
+