From 1311957fee4ee276734eaec45ee84eb0df3327b1 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Thu, 29 Oct 2020 13:03:01 +0300 Subject: [PATCH] [DE mobile][PE mobile] Fix Bug 47163 [DE][PE] Fix spacing settings --- .../app/view/ParagraphSettingsAdvanced.js | 12 ++++-- .../app/controller/edit/EditParagraph.js | 4 +- .../app/view/ParagraphSettingsAdvanced.js | 12 ++++-- .../mobile/app/controller/edit/EditText.js | 41 +++++++++++++++---- 4 files changed, 50 insertions(+), 19 deletions(-) diff --git a/apps/documenteditor/main/app/view/ParagraphSettingsAdvanced.js b/apps/documenteditor/main/app/view/ParagraphSettingsAdvanced.js index 5cddca362..21c6794b0 100644 --- a/apps/documenteditor/main/app/view/ParagraphSettingsAdvanced.js +++ b/apps/documenteditor/main/app/view/ParagraphSettingsAdvanced.js @@ -207,7 +207,8 @@ define([ 'text!documenteditor/main/app/template/ParagraphSettingsAdvanced.tem var properties = (this._originalProps) ? this._originalProps : new Asc.asc_CParagraphProperty(); this.Spacing = properties.get_Spacing(); } - this.Spacing.put_Before(Common.Utils.Metric.fnRecalcToMM(field.getNumberValue())); + var value = field.getNumberValue(); + this.Spacing.put_Before(value<0 ? -1 : Common.Utils.Metric.fnRecalcToMM(value)); }, this)); this.spinners.push(this.numSpacingBefore); @@ -227,7 +228,8 @@ define([ 'text!documenteditor/main/app/template/ParagraphSettingsAdvanced.tem var properties = (this._originalProps) ? this._originalProps : new Asc.asc_CParagraphProperty(); this.Spacing = properties.get_Spacing(); } - this.Spacing.put_After(Common.Utils.Metric.fnRecalcToMM(field.getNumberValue())); + var value = field.getNumberValue(); + this.Spacing.put_After(value<0 ? -1 : Common.Utils.Metric.fnRecalcToMM(value)); }, this)); this.spinners.push(this.numSpacingAfter); @@ -756,8 +758,10 @@ define([ 'text!documenteditor/main/app/template/ParagraphSettingsAdvanced.tem this.numIndentsLeft.setValue(this.LeftIndent!==null ? Common.Utils.Metric.fnRecalcFromMM(this.LeftIndent) : '', true); this.numIndentsRight.setValue((props.get_Ind() !== null && props.get_Ind().get_Right() !== null) ? Common.Utils.Metric.fnRecalcFromMM(props.get_Ind().get_Right()) : '', true); - this.numSpacingBefore.setValue((props.get_Spacing() !== null && props.get_Spacing().get_Before() !== null) ? Common.Utils.Metric.fnRecalcFromMM(props.get_Spacing().get_Before()) : '', true); - this.numSpacingAfter.setValue((props.get_Spacing() !== null && props.get_Spacing().get_After() !== null) ? Common.Utils.Metric.fnRecalcFromMM(props.get_Spacing().get_After()) : '', true); + var value = props.get_Spacing() ? props.get_Spacing().get_Before() : null; + this.numSpacingBefore.setValue((value !== null) ? (value<0 ? value : Common.Utils.Metric.fnRecalcFromMM(value)) : '', true); + value = props.get_Spacing() ? props.get_Spacing().get_After() : null; + this.numSpacingAfter.setValue((value !== null) ? (value<0 ? value : Common.Utils.Metric.fnRecalcFromMM(value)) : '', true); var linerule = props.get_Spacing().get_LineRule(); this.cmbLineRule.setValue((linerule !== null) ? linerule : '', true); diff --git a/apps/documenteditor/mobile/app/controller/edit/EditParagraph.js b/apps/documenteditor/mobile/app/controller/edit/EditParagraph.js index 6175d77c8..b0ac19f25 100644 --- a/apps/documenteditor/mobile/app/controller/edit/EditParagraph.js +++ b/apps/documenteditor/mobile/app/controller/edit/EditParagraph.js @@ -244,7 +244,7 @@ define([ if ($button.hasClass('decrement')) { distance = Math.max(-1, distance - step); } else { - distance = Math.min(maxValue, distance + step); + distance = (distance<0) ? 0 : Math.min(maxValue, distance + step); } var distanceFix = parseFloat(distance.toFixed(2)); @@ -273,7 +273,7 @@ define([ if ($button.hasClass('decrement')) { distance = Math.max(-1, distance - step); } else { - distance = Math.min(maxValue, distance + step); + distance = (distance<0) ? 0 : Math.min(maxValue, distance + step); } var distanceFix = parseFloat(distance.toFixed(2)); diff --git a/apps/presentationeditor/main/app/view/ParagraphSettingsAdvanced.js b/apps/presentationeditor/main/app/view/ParagraphSettingsAdvanced.js index 21d23d1a8..d461ab3c4 100644 --- a/apps/presentationeditor/main/app/view/ParagraphSettingsAdvanced.js +++ b/apps/presentationeditor/main/app/view/ParagraphSettingsAdvanced.js @@ -210,7 +210,8 @@ define([ 'text!presentationeditor/main/app/template/ParagraphSettingsAdvanced var properties = (this._originalProps) ? this._originalProps : new Asc.asc_CParagraphProperty(); this.Spacing = properties.get_Spacing(); } - this.Spacing.put_Before(Common.Utils.Metric.fnRecalcToMM(field.getNumberValue())); + var value = field.getNumberValue(); + this.Spacing.put_Before(value<0 ? -1 : Common.Utils.Metric.fnRecalcToMM(value)); }, this)); this.spinners.push(this.numSpacingBefore); @@ -230,7 +231,8 @@ define([ 'text!presentationeditor/main/app/template/ParagraphSettingsAdvanced var properties = (this._originalProps) ? this._originalProps : new Asc.asc_CParagraphProperty(); this.Spacing = properties.get_Spacing(); } - this.Spacing.put_After(Common.Utils.Metric.fnRecalcToMM(field.getNumberValue())); + var value = field.getNumberValue(); + this.Spacing.put_After(value<0 ? -1 : Common.Utils.Metric.fnRecalcToMM(value)); }, this)); this.spinners.push(this.numSpacingAfter); @@ -434,8 +436,10 @@ define([ 'text!presentationeditor/main/app/template/ParagraphSettingsAdvanced this.cmbSpecial.setValue(this.CurSpecial); this.numSpecialBy.setValue(this.FirstLine!== null ? Math.abs(Common.Utils.Metric.fnRecalcFromMM(this.FirstLine)) : '', true); - this.numSpacingBefore.setValue((props.get_Spacing() !== null && props.get_Spacing().get_Before() !== null) ? Common.Utils.Metric.fnRecalcFromMM(props.get_Spacing().get_Before()) : '', true); - this.numSpacingAfter.setValue((props.get_Spacing() !== null && props.get_Spacing().get_After() !== null) ? Common.Utils.Metric.fnRecalcFromMM(props.get_Spacing().get_After()) : '', true); + var value = props.get_Spacing() ? props.get_Spacing().get_Before() : null; + this.numSpacingBefore.setValue((value !== null) ? (value<0 ? value : Common.Utils.Metric.fnRecalcFromMM(value)) : '', true); + value = props.get_Spacing() ? props.get_Spacing().get_After() : null; + this.numSpacingAfter.setValue((value !== null) ? (value<0 ? value : Common.Utils.Metric.fnRecalcFromMM(value)) : '', true); var linerule = props.get_Spacing().get_LineRule(); this.cmbLineRule.setValue((linerule !== null) ? linerule : '', true); diff --git a/apps/presentationeditor/mobile/app/controller/edit/EditText.js b/apps/presentationeditor/mobile/app/controller/edit/EditText.js index 2ad5ce9b1..9f66c7b0b 100644 --- a/apps/presentationeditor/mobile/app/controller/edit/EditText.js +++ b/apps/presentationeditor/mobile/app/controller/edit/EditText.js @@ -415,35 +415,58 @@ define([ onDistanceBefore: function (e) { var $button = $(e.currentTarget), - distance = _paragraphInfo.spaceBefore; + distance = _paragraphInfo.spaceBefore, + step, + maxValue; + + if (Common.Utils.Metric.getCurrentMetric() == Common.Utils.Metric.c_MetricUnits.pt) { + step = 1; + } else { + step = 0.01; + } + + maxValue = Common.Utils.Metric.fnRecalcFromMM(558.8); if ($button.hasClass('decrement')) { - distance = Math.max(-1, --distance); + distance = Math.max(-1, distance - step); } else { - distance = Math.min(100, ++distance); + distance = (distance<0) ? 0 : Math.min(maxValue, distance + step); } + var distanceFix = parseFloat(distance.toFixed(2)); + _paragraphInfo.spaceBefore = distance; - $('#paragraph-distance-before .item-after label').text(_paragraphInfo.spaceBefore < 0 ? 'Auto' : (_paragraphInfo.spaceBefore) + ' ' + metricText); + $('#paragraph-distance-before .item-after label').text(_paragraphInfo.spaceBefore < 0 ? 'Auto' : distanceFix + ' ' + metricText); this.api.put_LineSpacingBeforeAfter(0, (_paragraphInfo.spaceBefore < 0) ? -1 : Common.Utils.Metric.fnRecalcToMM(_paragraphInfo.spaceBefore)); }, onDistanceAfter: function (e) { var $button = $(e.currentTarget), - distance = _paragraphInfo.spaceAfter; + distance = _paragraphInfo.spaceAfter, + step, + maxValue; + + if (Common.Utils.Metric.getCurrentMetric() == Common.Utils.Metric.c_MetricUnits.pt) { + step = 1; + } else { + step = 0.01; + } + + maxValue = Common.Utils.Metric.fnRecalcFromMM(558.8); if ($button.hasClass('decrement')) { - distance = Math.max(-1, --distance); + distance = Math.max(-1, distance - step); } else { - distance = Math.min(100, ++distance); + distance = (distance<0) ? 0 : Math.min(maxValue, distance + step); } + var distanceFix = parseFloat(distance.toFixed(2)); + _paragraphInfo.spaceAfter = distance; - $('#paragraph-distance-after .item-after label').text(_paragraphInfo.spaceAfter < 0 ? 'Auto' : (_paragraphInfo.spaceAfter) + ' ' + metricText); - + $('#paragraph-distance-after .item-after label').text(_paragraphInfo.spaceAfter < 0 ? 'Auto' : distanceFix + ' ' + metricText); this.api.put_LineSpacingBeforeAfter(1, (_paragraphInfo.spaceAfter < 0) ? -1 : Common.Utils.Metric.fnRecalcToMM(_paragraphInfo.spaceAfter)); },