diff --git a/apps/common/main/lib/util/utils.js b/apps/common/main/lib/util/utils.js index ec6f0c975..776933b1f 100644 --- a/apps/common/main/lib/util/utils.js +++ b/apps/common/main/lib/util/utils.js @@ -379,10 +379,12 @@ var metrics = new(function() { return me.defaultMetric; }, - fnRecalcToMM: function(value) { + fnRecalcToMM: function(value, unit) { // value in pt/cm/inch. need to convert to mm + if(unit==undefined) + unrt=me.currentMetric if (value!==null && value!==undefined) { - switch (me.currentMetric) { + switch (unit) { case me.c_MetricUnits.cm: return value * 10; case me.c_MetricUnits.pt: @@ -394,9 +396,11 @@ var metrics = new(function() { return value; }, - fnRecalcFromMM: function(value) { + fnRecalcFromMM: function(value, unit) { // value in mm. need to convert to pt/cm/inch - switch (me.currentMetric) { + if(unit==undefined) + unrt=me.currentMetric + switch (unit) { case me.c_MetricUnits.cm: return parseFloat((value/10.).toFixed(4)); case me.c_MetricUnits.pt: diff --git a/apps/documenteditor/main/app/view/ParagraphSettings.js b/apps/documenteditor/main/app/view/ParagraphSettings.js index 3a2df1009..399d47419 100644 --- a/apps/documenteditor/main/app/view/ParagraphSettings.js +++ b/apps/documenteditor/main/app/view/ParagraphSettings.js @@ -89,9 +89,9 @@ define([ this.isChart = false; this._arrLineRule = [ - {displayValue: this.textAtLeast,defaultValue: 4.24, value: c_paragraphLinerule.LINERULE_LEAST, minValue: 0.03, step: 0.01, defaultUnit: 'pt'}, - {displayValue: this.textAuto, defaultValue: 1.08, value: c_paragraphLinerule.LINERULE_AUTO, minValue: 0.5, step: 0.01, defaultUnit: ''}, - {displayValue: this.textExact, defaultValue: 4.24, value: c_paragraphLinerule.LINERULE_EXACT, minValue: 0.03, step: 0.01, defaultUnit: 'pt'} + {displayValue: this.textAtLeast,defaultValue: 4.24, value: c_paragraphLinerule.LINERULE_LEAST, minValue: 0.03, step: 1, defaultUnit: 'pt'}, + {displayValue: this.textAuto, defaultValue: 1, value: c_paragraphLinerule.LINERULE_AUTO, minValue: 0.5, step: 0.01, defaultUnit: ''}, + {displayValue: this.textExact, defaultValue: 4.24, value: c_paragraphLinerule.LINERULE_EXACT, minValue: 0.03, step: 1, defaultUnit: 'pt'} ]; this._arrSpecial = [ @@ -136,11 +136,11 @@ define([ this.numSpacingBefore = new Common.UI.MetricSpinner({ el: $markup.findById('#paragraph-spin-spacing-before'), - step: .1, + step: 1, width: 85, value: '', - defaultUnit : "cm", - maxValue: 55.88, + defaultUnit : "pt", + maxValue: 1584, minValue: 0, allowAuto : true, autoText : this.txtAutoText, @@ -151,11 +151,11 @@ define([ this.numSpacingAfter = new Common.UI.MetricSpinner({ el: $markup.findById('#paragraph-spin-spacing-after'), - step: .1, + step: 1, width: 85, value: '', - defaultUnit : "cm", - maxValue: 55.88, + defaultUnit : "pt", + maxValue: 1584, minValue: 0, allowAuto : true, autoText : this.txtAutoText, @@ -275,14 +275,14 @@ define([ return; var type = c_paragraphLinerule.LINERULE_AUTO; if (this.api) - this.api.put_PrLineSpacing(this.cmbLineRule.getValue(), (this.cmbLineRule.getValue()==c_paragraphLinerule.LINERULE_AUTO) ? field.getNumberValue() : field.getNumberValue()* 25.4 / 72.0); - // this.api.put_PrLineSpacing(this.cmbLineRule.getValue(), (this.cmbLineRule.getValue()==c_paragraphLinerule.LINERULE_AUTO) ? field.getNumberValue() : Common.Utils.Metric.fnRecalcToMM(field.getNumberValue())); + // this.api.put_PrLineSpacing(this.cmbLineRule.getValue(), (this.cmbLineRule.getValue()==c_paragraphLinerule.LINERULE_AUTO) ? field.getNumberValue() : field.getNumberValue()* 25.4 / 72.0); + this.api.put_PrLineSpacing(this.cmbLineRule.getValue(), (this.cmbLineRule.getValue()==c_paragraphLinerule.LINERULE_AUTO) ? field.getNumberValue() : Common.Utils.Metric.fnRecalcToMM(field.getNumberValue(),Common.Utils.Metric.c_MetricUnits.pt)); }, onNumSpacingBeforeChange: function(field, newValue, oldValue, eOpts){ if (this.api) { var num = field.getNumberValue(); - this._state.LineSpacingBefore = (num<0) ? -1 : Common.Utils.Metric.fnRecalcToMM(num); + this._state.LineSpacingBefore = (num<0) ? -1 : Common.Utils.Metric.fnRecalcToMM(num,Common.Utils.Metric.c_MetricUnits.pt); this.api.put_LineSpacingBeforeAfter(0, this._state.LineSpacingBefore); } }, @@ -290,7 +290,7 @@ define([ onNumSpacingAfterChange: function(field, newValue, oldValue, eOpts){ if (this.api){ var num = field.getNumberValue(); - this._state.LineSpacingAfter = (num<0) ? -1 : Common.Utils.Metric.fnRecalcToMM(num); + this._state.LineSpacingAfter = (num<0) ? -1 : Common.Utils.Metric.fnRecalcToMM(num,Common.Utils.Metric.c_MetricUnits.pt); this.api.put_LineSpacingBeforeAfter(1, this._state.LineSpacingAfter); } }, @@ -329,8 +329,8 @@ define([ if ( linerule == c_paragraphLinerule.LINERULE_AUTO ) { val = line; } else if (linerule !== null && line !== null ) { - //val = Common.Utils.Metric.fnRecalcFromMM(line); - val=parseFloat((line * 72.0 / 25.4).toFixed(3)); + val = Common.Utils.Metric.fnRecalcFromMM(line, Common.Utils.Metric.c_MetricUnits.pt); + //val=parseFloat((line * 72.0 / 25.4).toFixed(3)); } this.numLineHeight.setValue((val !== null) ? val : '', true); @@ -453,7 +453,7 @@ define([ if ( Spacing.LineRule == c_paragraphLinerule.LINERULE_AUTO ) { val = Spacing.Line; } else if (Spacing.LineRule !== null && Spacing.Line !== null ) { - val = Common.Utils.Metric.fnRecalcFromMM(Spacing.Line); + val = Common.Utils.Metric.fnRecalcFromMM(Spacing.Line, Common.Utils.Metric.c_MetricUnits.pt); } this.numLineHeight.setValue((val !== null) ? val : '', true); @@ -463,14 +463,14 @@ define([ if ( Math.abs(this._state.LineSpacingBefore-Spacing.Before)>0.001 || (this._state.LineSpacingBefore===null || Spacing.Before===null)&&(this._state.LineSpacingBefore!==Spacing.Before)) { - this.numSpacingBefore.setValue((Spacing.Before !== null) ? ((Spacing.Before<0) ? Spacing.Before : Common.Utils.Metric.fnRecalcFromMM(Spacing.Before) ) : '', true); + this.numSpacingBefore.setValue((Spacing.Before !== null) ? ((Spacing.Before<0) ? Spacing.Before : Common.Utils.Metric.fnRecalcFromMM(Spacing.Before, Common.Utils.Metric.c_MetricUnits.pt) ) : '', true); this._state.LineSpacingBefore=Spacing.Before; } if ( Math.abs(this._state.LineSpacingAfter-Spacing.After)>0.001 || (this._state.LineSpacingAfter===null || Spacing.After===null)&&(this._state.LineSpacingAfter!==Spacing.After)) { - this.numSpacingAfter.setValue((Spacing.After !== null) ? ((Spacing.After<0) ? Spacing.After : Common.Utils.Metric.fnRecalcFromMM(Spacing.After) ) : '', true); + this.numSpacingAfter.setValue((Spacing.After !== null) ? ((Spacing.After<0) ? Spacing.After : Common.Utils.Metric.fnRecalcFromMM(Spacing.After, Common.Utils.Metric.c_MetricUnits.pt) ) : '', true); this._state.LineSpacingAfter=Spacing.After; } @@ -554,18 +554,17 @@ define([ for (var i=0; i