[PE][PE mobile] Get/set slide size in emu

This commit is contained in:
Julia Radzhabova 2021-02-15 20:10:46 +03:00
parent 6429ec6861
commit 36856e2e20
4 changed files with 96 additions and 60 deletions

View file

@ -110,11 +110,10 @@ define([
}; };
this._isAddingShape = false; this._isAddingShape = false;
this.slideSizeArr = [ this.slideSizeArr = [
[254, 190.5], [254, 143], [254, 158.7], [254, 190.5], [338.3, 253.7], [355.6, 266.7], { size: [9144000, 6858000], ratio: 9144000/6858000, type: Asc.c_oAscSlideSZType.SzScreen4x3},
[275, 190.5], [300.7, 225.5], [199.1, 149.3], [285.7, 190.5], [254, 190.5], [203.2, 25.4] { size: [12192000, 6858000], ratio: 12192000/6858000, type: Asc.c_oAscSlideSZType.SzCustom} ];
];
this.currentPageSize = { this.currentPageSize = {
type: -1, type: Asc.c_oAscSlideSZType.SzCustom,
width: 0, width: 0,
height: 0 height: 0
}; };
@ -621,24 +620,25 @@ define([
} }
}, },
onApiPageSize: function(width, height) { onApiPageSize: function(width, height, type) {
if (Math.abs(this.currentPageSize.width - width) > 0.001 || if (Math.abs(this.currentPageSize.width - width) > 0.001 ||
Math.abs(this.currentPageSize.height - height) > 0.001) { Math.abs(this.currentPageSize.height - height) > 0.001 ||
this.currentPageSize.type !== type) {
this.currentPageSize.width = width; this.currentPageSize.width = width;
this.currentPageSize.height = height; this.currentPageSize.height = height;
this.currentPageSize.type = -1; this.currentPageSize.type = type;
var portrait = (height>width); var ratio = (height>width) ? height/width : width/height;
var idx = -1;
for (var i = 0; i < this.slideSizeArr.length; i++) { for (var i = 0; i < this.slideSizeArr.length; i++) {
if (Math.abs(this.slideSizeArr[i][portrait ? 1 : 0] - this.currentPageSize.width) < 0.001 && if (Math.abs(this.slideSizeArr[i].ratio - ratio) < 0.001 ) {
Math.abs(this.slideSizeArr[i][portrait ? 0 : 1] - this.currentPageSize.height) < 0.001) { idx = i;
this.currentPageSize.type = i;
break; break;
} }
} }
this.toolbar.btnSlideSize.menu.items[0].setChecked(this.currentPageSize.type == 0); this.toolbar.btnSlideSize.menu.items[0].setChecked(idx == 0);
this.toolbar.btnSlideSize.menu.items[1].setChecked(this.currentPageSize.type == 1); this.toolbar.btnSlideSize.menu.items[1].setChecked(idx == 1);
} }
}, },
@ -1745,16 +1745,13 @@ define([
if (item.value !== 'advanced') { if (item.value !== 'advanced') {
var portrait = (this.currentPageSize.height > this.currentPageSize.width); var portrait = (this.currentPageSize.height > this.currentPageSize.width);
this.currentPageSize = { this.currentPageSize = {
type : item.value, type : this.slideSizeArr[item.value].type,
width : this.slideSizeArr[item.value][portrait ? 1 : 0], width : this.slideSizeArr[item.value].size[portrait ? 1 : 0],
height : this.slideSizeArr[item.value][portrait ? 0 : 1] height : this.slideSizeArr[item.value].size[portrait ? 0 : 1]
}; };
if (this.api) if (this.api)
this.api.changeSlideSize( this.api.changeSlideSize(this.currentPageSize.width, this.currentPageSize.height, this.currentPageSize.type);
this.slideSizeArr[item.value][portrait ? 1 : 0],
this.slideSizeArr[item.value][portrait ? 0 : 1]
);
Common.NotificationCenter.trigger('edit:complete', this.toolbar); Common.NotificationCenter.trigger('edit:complete', this.toolbar);
Common.component.Analytics.trackEvent('ToolBar', 'Slide Size'); Common.component.Analytics.trackEvent('ToolBar', 'Slide Size');
@ -1766,10 +1763,20 @@ define([
if (result == 'ok') { if (result == 'ok') {
props = dlg.getSettings(); props = dlg.getSettings();
me.currentPageSize = { type: props[0], width: props[1], height: props[2] }; me.currentPageSize = { type: props[0], width: props[1], height: props[2] };
me.toolbar.btnSlideSize.menu.items[0].setChecked(props[0] == 0); var portrait = (me.currentPageSize.height>me.currentPageSize.width),
me.toolbar.btnSlideSize.menu.items[1].setChecked(props[0] == 1); ratio = (portrait) ? me.currentPageSize.height/me.currentPageSize.width : me.currentPageSize.width/me.currentPageSize.height,
idx = -1;
for (var i = 0; i < me.slideSizeArr.length; i++) {
if (Math.abs(me.slideSizeArr[i].ratio - ratio) < 0.001 ) {
idx = i;
break;
}
}
me.toolbar.btnSlideSize.menu.items[0].setChecked(idx == 0);
me.toolbar.btnSlideSize.menu.items[1].setChecked(idx == 1);
if (me.api) if (me.api)
me.api.changeSlideSize(props[1], props[2]); me.api.changeSlideSize(props[1], props[2], props[0]);
} }
Common.NotificationCenter.trigger('edit:complete', me.toolbar); Common.NotificationCenter.trigger('edit:complete', me.toolbar);

View file

@ -99,37 +99,37 @@ define([
el: $('#slide-size-combo'), el: $('#slide-size-combo'),
cls: 'input-group-nr', cls: 'input-group-nr',
style: 'width: 100%;', style: 'width: 100%;',
menuStyle: 'min-width: 218px;', menuStyle: 'min-width: 218px;max-height: 185px;',
editable: false, editable: false,
takeFocusOnClose: true, takeFocusOnClose: true,
data: [ data: [
{value:0, displayValue: this.txtStandard , size: [254, 190.5]}, {value:Asc.c_oAscSlideSZType.SzScreen4x3, displayValue: this.txtStandard , size: [9144000, 6858000]},
{value:1, displayValue: this.txtWidescreen1 , size: [254, 143]}, {value:Asc.c_oAscSlideSZType.SzScreen16x9, displayValue: this.txtWidescreen + ' (16:9)', size: [9144000, 5143500]},
{value:2, displayValue: this.txtWidescreen2 , size: [254, 158.7]}, {value:Asc.c_oAscSlideSZType.SzScreen16x10, displayValue: this.txtWidescreen + ' (16:10)', size: [9144000, 5715000]},
{value:3, displayValue: this.txtLetter , size: [254, 190.5]}, {value:Asc.c_oAscSlideSZType.SzLetter, displayValue: this.txtLetter , size: [9144000, 6858000]},
{value:4, displayValue: this.txtLedger , size: [338.3, 253.7]}, {value:Asc.c_oAscSlideSZType.SzLedger, displayValue: this.txtLedger , size: [12179300, 9134475]},
{value:5, displayValue: this.txtA3 , size: [355.6, 266.7]}, {value:Asc.c_oAscSlideSZType.SzA3, displayValue: this.txtA3 , size: [12801600, 9601200]},
{value:6, displayValue: this.txtA4 , size: [275, 190.5]}, {value:Asc.c_oAscSlideSZType.SzA4, displayValue: this.txtA4 , size: [9906000, 6858000]},
{value:7, displayValue: this.txtB4 , size: [300.7, 225.5]}, {value:Asc.c_oAscSlideSZType.SzB4ISO, displayValue: this.txtB4 , size: [10826750, 8120063]},
{value:8, displayValue: this.txtB5 , size: [199.1, 149.3]}, {value:Asc.c_oAscSlideSZType.SzB5ISO, displayValue: this.txtB5 , size: [7169150, 5376863]},
{value:9, displayValue: this.txt35 , size: [285.7, 190.5]}, {value:Asc.c_oAscSlideSZType.Sz35mm, displayValue: this.txt35 , size: [10287000, 6858000]},
{value:10, displayValue: this.txtOverhead , size: [254, 190.5]}, {value:Asc.c_oAscSlideSZType.SzOverhead, displayValue: this.txtOverhead , size: [9144000, 6858000]},
{value:11, displayValue: this.txtBanner , size: [203.2, 25.4]}, {value:Asc.c_oAscSlideSZType.SzBanner, displayValue: this.txtBanner , size: [7315200, 914400]},
{value:-1, displayValue: this.txtCustom , size: []} {value:Asc.c_oAscSlideSZType.SzWidescreen, displayValue: this.txtWidescreen , size: [12192000, 6858000]},
{value:Asc.c_oAscSlideSZType.SzCustom, displayValue: this.txtCustom , size: [10058400, 7772400]}
] ]
}); });
this.cmbSlideSize.setValue(0); this.cmbSlideSize.setValue(Asc.c_oAscSlideSZType.SzScreen4x3);
this.cmbSlideSize.on('selected', _.bind(function(combo, record) { this.cmbSlideSize.on('selected', _.bind(function(combo, record) {
this._noApply = true; this._noApply = true;
if (record.value<0) { if (record.value<0) {
// set current slide size // set current slide size
} else { } else {
var w = record.size[0], var w = record.size[0]/36000,
h = record.size[1], h = record.size[1]/36000,
orient = this.cmbSlideOrientation.getValue(), orient = this.cmbSlideOrientation.getValue();
cond = orient==0 && w>h || orient==1 && h>w; this.spnWidth.setValue(Common.Utils.Metric.fnRecalcFromMM(orient ? w : h), true);
this.spnWidth.setValue(Common.Utils.Metric.fnRecalcFromMM(cond ? h : w), true); this.spnHeight.setValue(Common.Utils.Metric.fnRecalcFromMM(orient ? h : w), true);
this.spnHeight.setValue(Common.Utils.Metric.fnRecalcFromMM(cond ? w : h), true);
} }
this._noApply = false; this._noApply = false;
}, this)); }, this));
@ -146,8 +146,8 @@ define([
this.spinners.push(this.spnWidth); this.spinners.push(this.spnWidth);
this.spnWidth.on('change', _.bind(function(field, newValue, oldValue, eOpts){ this.spnWidth.on('change', _.bind(function(field, newValue, oldValue, eOpts){
if (!this._noApply) { if (!this._noApply) {
if (this.cmbSlideSize.getValue() >-1) if (this.cmbSlideSize.getValue() !== Asc.c_oAscSlideSZType.SzCustom)
this.cmbSlideSize.setValue(-1); this.cmbSlideSize.setValue(Asc.c_oAscSlideSZType.SzCustom);
var w = this.spnWidth.getNumberValue(), var w = this.spnWidth.getNumberValue(),
h = this.spnHeight.getNumberValue(); h = this.spnHeight.getNumberValue();
this.cmbSlideOrientation.setValue( h>w ? 0 : 1); this.cmbSlideOrientation.setValue( h>w ? 0 : 1);
@ -166,8 +166,8 @@ define([
this.spinners.push(this.spnHeight); this.spinners.push(this.spnHeight);
this.spnHeight.on('change', _.bind(function(field, newValue, oldValue, eOpts){ this.spnHeight.on('change', _.bind(function(field, newValue, oldValue, eOpts){
if (!this._noApply) { if (!this._noApply) {
if (this.cmbSlideSize.getValue() >-1) if (this.cmbSlideSize.getValue() !==Asc.c_oAscSlideSZType.SzCustom)
this.cmbSlideSize.setValue(-1); this.cmbSlideSize.setValue(Asc.c_oAscSlideSZType.SzCustom);
var w = this.spnWidth.getNumberValue(), var w = this.spnWidth.getNumberValue(),
h = this.spnHeight.getNumberValue(); h = this.spnHeight.getNumberValue();
this.cmbSlideOrientation.setValue( h>w ? 0 : 1); this.cmbSlideOrientation.setValue( h>w ? 0 : 1);
@ -230,16 +230,42 @@ define([
}, },
setSettings: function (type, pagewitdh, pageheight) { setSettings: function (type, pagewitdh, pageheight) {
this.spnWidth.setValue(Common.Utils.Metric.fnRecalcFromMM(pagewitdh), true); this.spnWidth.setValue(Common.Utils.Metric.fnRecalcFromMM(pagewitdh/36000), true);
this.spnHeight.setValue(Common.Utils.Metric.fnRecalcFromMM(pageheight), true); this.spnHeight.setValue(Common.Utils.Metric.fnRecalcFromMM(pageheight/36000), true);
this.cmbSlideSize.setValue(type);
this.cmbSlideOrientation.setValue((pageheight>pagewitdh) ? 0 : 1); this.cmbSlideOrientation.setValue((pageheight>pagewitdh) ? 0 : 1);
var portrait = pageheight>pagewitdh,
w = portrait ? pageheight : pagewitdh,
h = portrait ? pagewitdh : pageheight,
store = this.cmbSlideSize.store,
arr = [],
preset = Asc.c_oAscSlideSZType.SzCustom;
for (var i=0; i<store.length; i++) {
var item = store.at(i);
if (Math.abs(item.get('size')[0] - w) < 0.001 && Math.abs(item.get('size')[1] - h) < 0.001)
arr.push(item.get('value'));
}
if (arr.length>1) {
for (var i=0; i<arr.length; i++)
(arr[i]==type) && (preset = arr[i]);
} else if (arr.length>0)
preset = arr[0];
this.cmbSlideSize.setValue(preset);
}, },
getSettings: function() { getSettings: function() {
var props = [this.cmbSlideSize.getValue(), Common.Utils.Metric.fnRecalcToMM(this.spnWidth.getNumberValue()), Common.Utils.Metric.fnRecalcToMM(this.spnHeight.getNumberValue())]; var type = this.cmbSlideSize.getValue(),
return props; width, height;
if (type==Asc.c_oAscSlideSZType.SzCustom) {
width = Common.Utils.Metric.fnRecalcToMM(this.spnWidth.getNumberValue())*36000;
height = Common.Utils.Metric.fnRecalcToMM(this.spnHeight.getNumberValue())*36000;
} else {
var record = this.cmbSlideSize.getSelectedRecord(),
orient = this.cmbSlideOrientation.getValue();
width = record.size[orient ? 0 : 1];
height = record.size[orient ? 1 : 0];
}
return [type, width, height];
}, },
updateMetricUnit: function() { updateMetricUnit: function() {
@ -271,6 +297,7 @@ define([
txtCustom: 'Custom', txtCustom: 'Custom',
textSlideOrientation: 'Slide Orientation', textSlideOrientation: 'Slide Orientation',
strPortrait: 'Portrait', strPortrait: 'Portrait',
strLandscape: 'Landscape' strLandscape: 'Landscape',
txtWidescreen: 'Widescreen'
}, PE.Views.SlideSizeSettings || {})) }, PE.Views.SlideSizeSettings || {}))
}); });

View file

@ -1700,8 +1700,9 @@
"PE.Views.SlideSizeSettings.txtLetter": "Letter Paper (8.5x11 in)", "PE.Views.SlideSizeSettings.txtLetter": "Letter Paper (8.5x11 in)",
"PE.Views.SlideSizeSettings.txtOverhead": "Overhead", "PE.Views.SlideSizeSettings.txtOverhead": "Overhead",
"PE.Views.SlideSizeSettings.txtStandard": "Standard (4:3)", "PE.Views.SlideSizeSettings.txtStandard": "Standard (4:3)",
"PE.Views.SlideSizeSettings.txtWidescreen1": "Widescreen (16:9)", "PE.Views.SlideSizeSettings.txtWidescreen": "Widescreen",
"PE.Views.SlideSizeSettings.txtWidescreen2": "Widescreen (16:10)", "del_PE.Views.SlideSizeSettings.txtWidescreen1": "Widescreen (16:9)",
"del_PE.Views.SlideSizeSettings.txtWidescreen2": "Widescreen (16:10)",
"PE.Views.Statusbar.goToPageText": "Go to Slide", "PE.Views.Statusbar.goToPageText": "Go to Slide",
"PE.Views.Statusbar.pageIndexText": "Slide {0} of {1}", "PE.Views.Statusbar.pageIndexText": "Slide {0} of {1}",
"PE.Views.Statusbar.textShowBegin": "Show from Beginning", "PE.Views.Statusbar.textShowBegin": "Show from Beginning",

View file

@ -60,7 +60,7 @@ define([
_lang; _lang;
var _slideSizeArr = [ var _slideSizeArr = [
[254, 190.5], [254, 143] [9144000, 6858000, Asc.c_oAscSlideSZType.SzScreen4x3], [12192000, 6858000, Asc.c_oAscSlideSZType.SzCustom]
]; ];
return { return {
@ -332,8 +332,9 @@ define([
onApiPageSize: function(width, height) { onApiPageSize: function(width, height) {
var $input = $('#page-settings-view input[name="slide-size"]'); var $input = $('#page-settings-view input[name="slide-size"]');
if ($input.length > 0) { if ($input.length > 0) {
var ratio = (height>width) ? height/width : width/height;
for (var i = 0; i < _slideSizeArr.length; i++) { for (var i = 0; i < _slideSizeArr.length; i++) {
if (Math.abs(_slideSizeArr[i][0] - width) < 0.001 && Math.abs(_slideSizeArr[i][1] - height) < 0.001) { if (Math.abs(_slideSizeArr[i][0]/_slideSizeArr[i][1] - ratio) < 0.001 ) {
$input.val([i]); $input.val([i]);
break; break;
} }
@ -405,7 +406,7 @@ define([
var $target = $(e.currentTarget).find('input'); var $target = $(e.currentTarget).find('input');
if ($target && this.api) { if ($target && this.api) {
var value = parseFloat($target.prop('value')); var value = parseFloat($target.prop('value'));
this.api.changeSlideSize(_slideSizeArr[value][0], _slideSizeArr[value][1]); this.api.changeSlideSize(_slideSizeArr[value][0], _slideSizeArr[value][1], _slideSizeArr[value][2]);
} }
}, },