[PE][PE mobile] Bug 46911

This commit is contained in:
Julia Radzhabova 2021-02-16 17:05:47 +03:00
parent 7bca00ebc5
commit 41a907f48d
2 changed files with 19 additions and 13 deletions

View file

@ -110,8 +110,8 @@ define([
}; };
this._isAddingShape = false; this._isAddingShape = false;
this.slideSizeArr = [ this.slideSizeArr = [
{ size: [9144000, 6858000], ratio: 9144000/6858000, type: Asc.c_oAscSlideSZType.SzScreen4x3}, { size: [9144000, 6858000], ratio: 6858000/9144000, type: Asc.c_oAscSlideSZType.SzScreen4x3},
{ size: [12192000, 6858000], ratio: 12192000/6858000, type: Asc.c_oAscSlideSZType.SzCustom} ]; { size: [12192000, 6858000], ratio: 6858000/12192000, type: Asc.c_oAscSlideSZType.SzCustom} ];
this.currentPageSize = { this.currentPageSize = {
type: Asc.c_oAscSlideSZType.SzCustom, type: Asc.c_oAscSlideSZType.SzCustom,
width: 0, width: 0,
@ -628,7 +628,7 @@ define([
this.currentPageSize.height = height; this.currentPageSize.height = height;
this.currentPageSize.type = type; this.currentPageSize.type = type;
var ratio = (height>width) ? height/width : width/height; var ratio = height/width;
var idx = -1; 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].ratio - ratio) < 0.001 ) { if (Math.abs(this.slideSizeArr[i].ratio - ratio) < 0.001 ) {
@ -1743,11 +1743,11 @@ define([
onSlideSize: function(menu, item) { onSlideSize: function(menu, item) {
if (item.value !== 'advanced') { if (item.value !== 'advanced') {
var portrait = (this.currentPageSize.height > this.currentPageSize.width); var newwidth = (this.currentPageSize.height / this.slideSizeArr[item.value].ratio);
this.currentPageSize = { this.currentPageSize = {
type : this.slideSizeArr[item.value].type, type : this.slideSizeArr[item.value].type,
width : this.slideSizeArr[item.value].size[portrait ? 1 : 0], width : newwidth,
height : this.slideSizeArr[item.value].size[portrait ? 0 : 1] height : this.currentPageSize.height
}; };
if (this.api) if (this.api)
@ -1763,8 +1763,7 @@ 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] };
var portrait = (me.currentPageSize.height>me.currentPageSize.width), var ratio = me.currentPageSize.height/me.currentPageSize.width,
ratio = (portrait) ? me.currentPageSize.height/me.currentPageSize.width : me.currentPageSize.width/me.currentPageSize.height,
idx = -1; idx = -1;
for (var i = 0; i < me.slideSizeArr.length; i++) { for (var i = 0; i < me.slideSizeArr.length; i++) {
if (Math.abs(me.slideSizeArr[i].ratio - ratio) < 0.001 ) { if (Math.abs(me.slideSizeArr[i].ratio - ratio) < 0.001 ) {

View file

@ -57,7 +57,8 @@ define([
infoObj, infoObj,
modalView, modalView,
_licInfo, _licInfo,
_lang; _lang,
_currentPageSize;
var _slideSizeArr = [ var _slideSizeArr = [
[9144000, 6858000, Asc.c_oAscSlideSZType.SzScreen4x3], [12192000, 6858000, Asc.c_oAscSlideSZType.SzCustom] [9144000, 6858000, Asc.c_oAscSlideSZType.SzScreen4x3], [12192000, 6858000, Asc.c_oAscSlideSZType.SzCustom]
@ -330,11 +331,12 @@ define([
// API handlers // API handlers
onApiPageSize: function(width, height) { onApiPageSize: function(width, height) {
_currentPageSize = {width: width, height: 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; var ratio = height/width;
for (var i = 0; i < _slideSizeArr.length; i++) { for (var i = 0; i < _slideSizeArr.length; i++) {
if (Math.abs(_slideSizeArr[i][0]/_slideSizeArr[i][1] - ratio) < 0.001 ) { if (Math.abs(_slideSizeArr[i][1]/_slideSizeArr[i][0] - ratio) < 0.001 ) {
$input.val([i]); $input.val([i]);
break; break;
} }
@ -405,8 +407,13 @@ define([
_onSlideSize: function(e) { _onSlideSize: function(e) {
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], _slideSizeArr[value][2]); ratio = _slideSizeArr[value][1] / _slideSizeArr[value][0];
_currentPageSize = {
width : ((_currentPageSize.height || _slideSizeArr[value][1]) / ratio),
height : _currentPageSize.height
};
this.api.changeSlideSize(_currentPageSize.width, _currentPageSize.height, _slideSizeArr[value][2]);
} }
}, },