From 41a907f48d5f0acd933caf69d5b4d6c3f624f7a6 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Tue, 16 Feb 2021 17:05:47 +0300 Subject: [PATCH] [PE][PE mobile] Bug 46911 --- .../main/app/controller/Toolbar.js | 15 +++++++-------- .../mobile/app/controller/Settings.js | 17 ++++++++++++----- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/apps/presentationeditor/main/app/controller/Toolbar.js b/apps/presentationeditor/main/app/controller/Toolbar.js index 5054569d9..4257ca6d0 100644 --- a/apps/presentationeditor/main/app/controller/Toolbar.js +++ b/apps/presentationeditor/main/app/controller/Toolbar.js @@ -110,8 +110,8 @@ define([ }; this._isAddingShape = false; this.slideSizeArr = [ - { size: [9144000, 6858000], ratio: 9144000/6858000, type: Asc.c_oAscSlideSZType.SzScreen4x3}, - { size: [12192000, 6858000], ratio: 12192000/6858000, type: Asc.c_oAscSlideSZType.SzCustom} ]; + { size: [9144000, 6858000], ratio: 6858000/9144000, type: Asc.c_oAscSlideSZType.SzScreen4x3}, + { size: [12192000, 6858000], ratio: 6858000/12192000, type: Asc.c_oAscSlideSZType.SzCustom} ]; this.currentPageSize = { type: Asc.c_oAscSlideSZType.SzCustom, width: 0, @@ -628,7 +628,7 @@ define([ this.currentPageSize.height = height; this.currentPageSize.type = type; - var ratio = (height>width) ? height/width : width/height; + var ratio = height/width; var idx = -1; for (var i = 0; i < this.slideSizeArr.length; i++) { if (Math.abs(this.slideSizeArr[i].ratio - ratio) < 0.001 ) { @@ -1743,11 +1743,11 @@ define([ onSlideSize: function(menu, item) { if (item.value !== 'advanced') { - var portrait = (this.currentPageSize.height > this.currentPageSize.width); + var newwidth = (this.currentPageSize.height / this.slideSizeArr[item.value].ratio); this.currentPageSize = { type : this.slideSizeArr[item.value].type, - width : this.slideSizeArr[item.value].size[portrait ? 1 : 0], - height : this.slideSizeArr[item.value].size[portrait ? 0 : 1] + width : newwidth, + height : this.currentPageSize.height }; if (this.api) @@ -1763,8 +1763,7 @@ define([ if (result == 'ok') { props = dlg.getSettings(); me.currentPageSize = { type: props[0], width: props[1], height: props[2] }; - var portrait = (me.currentPageSize.height>me.currentPageSize.width), - ratio = (portrait) ? me.currentPageSize.height/me.currentPageSize.width : me.currentPageSize.width/me.currentPageSize.height, + var ratio = me.currentPageSize.height/me.currentPageSize.width, idx = -1; for (var i = 0; i < me.slideSizeArr.length; i++) { if (Math.abs(me.slideSizeArr[i].ratio - ratio) < 0.001 ) { diff --git a/apps/presentationeditor/mobile/app/controller/Settings.js b/apps/presentationeditor/mobile/app/controller/Settings.js index 68d5ca13b..f79b3057c 100644 --- a/apps/presentationeditor/mobile/app/controller/Settings.js +++ b/apps/presentationeditor/mobile/app/controller/Settings.js @@ -57,7 +57,8 @@ define([ infoObj, modalView, _licInfo, - _lang; + _lang, + _currentPageSize; var _slideSizeArr = [ [9144000, 6858000, Asc.c_oAscSlideSZType.SzScreen4x3], [12192000, 6858000, Asc.c_oAscSlideSZType.SzCustom] @@ -330,11 +331,12 @@ define([ // API handlers onApiPageSize: function(width, height) { + _currentPageSize = {width: width, height: height}; var $input = $('#page-settings-view input[name="slide-size"]'); if ($input.length > 0) { - var ratio = (height>width) ? height/width : width/height; + var ratio = height/width; 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]); break; } @@ -405,8 +407,13 @@ define([ _onSlideSize: function(e) { var $target = $(e.currentTarget).find('input'); if ($target && this.api) { - var value = parseFloat($target.prop('value')); - this.api.changeSlideSize(_slideSizeArr[value][0], _slideSizeArr[value][1], _slideSizeArr[value][2]); + var value = parseFloat($target.prop('value')), + 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]); } },