Merge pull request #647 from ONLYOFFICE/fix/bugfix

Fix changing units of measurement.
This commit is contained in:
Julia Radzhabova 2021-01-11 18:33:40 +03:00 committed by GitHub
commit 0c443a3c56
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 49 additions and 4 deletions

View file

@ -185,6 +185,7 @@ define([
minValue: 0.1
});
this.lockedControls.push(this.spnWidth);
this.spinners.push(this.spnWidth);
this.spnWidth.on('change', this.onWidthChange.bind(this));
this.spnWidth.on('inputleave', function(){ me.fireEvent('editcomplete', me);});
@ -407,7 +408,7 @@ define([
formTextPr.put_MaxCharacters(this.spnMaxChars.getNumberValue() || 10);
if (this.spnWidth.getValue()) {
var value = this.spnWidth.getNumberValue();
formTextPr.put_Width(value<=0 ? 0 : parseInt(Common.Utils.Metric.fnRecalcToMM(value) * 72 * 20 / 25.4));
formTextPr.put_Width(value<=0 ? 0 : parseInt(Common.Utils.Metric.fnRecalcToMM(value) * 72 * 20 / 25.4 + 0.1));
} else
formTextPr.put_Width(0);
}
@ -423,7 +424,7 @@ define([
var formTextPr = this._originalTextFormProps || new AscCommon.CSdtTextFormPr();
if (this.spnWidth.getValue()) {
var value = this.spnWidth.getNumberValue();
formTextPr.put_Width(value<=0 ? 0 : parseInt(Common.Utils.Metric.fnRecalcToMM(value) * 72 * 20 / 25.4));
formTextPr.put_Width(value<=0 ? 0 : parseInt(Common.Utils.Metric.fnRecalcToMM(value) * 72 * 20 / 25.4 + 0.1));
} else
formTextPr.put_Width(0);
@ -783,8 +784,11 @@ define([
for (var i=0; i<this.spinners.length; i++) {
var spinner = this.spinners[i];
spinner.setDefaultUnit(Common.Utils.Metric.getCurrentMetricName());
spinner.setStep(Common.Utils.Metric.getCurrentMetric()==Common.Utils.Metric.c_MetricUnits.pt ? 1 : 0.01);
spinner.setStep(Common.Utils.Metric.getCurrentMetric()==Common.Utils.Metric.c_MetricUnits.pt ? 1 : 0.1);
}
var val = this._state.Width;
this.spnWidth && this.spnWidth.setMinValue(Common.Utils.Metric.fnRecalcFromMM(1));
this.spnWidth && this.spnWidth.setValue(val!==0 && val!==undefined ? Common.Utils.Metric.fnRecalcFromMM(val * 25.4 / 20 / 72.0) : -1, true);
}
},

View file

@ -214,6 +214,7 @@ define([
spinner.setDefaultUnit(Common.Utils.Metric.getCurrentMetricName());
spinner.setStep(Common.Utils.Metric.getCurrentMetric()==Common.Utils.Metric.c_MetricUnits.pt ? 1 : 0.01);
}
this.numPosition && this.numPosition.setValue(Common.Utils.Metric.fnRecalcFromMM(this._state.Position), true);
}
},

View file

@ -394,7 +394,13 @@ define([
if (this._state.LineRuleIdx !== null) {
this.numLineHeight.setDefaultUnit(this._arrLineRule[this._state.LineRuleIdx].defaultUnit);
this.numLineHeight.setStep(this._arrLineRule[this._state.LineRuleIdx].step);
this.numLineHeight && this.numLineHeight.setValue((this._state.LineHeight !== null) ? Common.Utils.Metric.fnRecalcFromMM(this._state.LineHeight) : '', true);
}
var val = this._state.LineSpacingBefore;
this.numSpacingBefore && this.numSpacingBefore.setValue((val !== null) ? ((val<0) ? val : Common.Utils.Metric.fnRecalcFromMM(val) ) : '', true);
val = this._state.LineSpacingAfter;
this.numSpacingAfter && this.numSpacingAfter.setValue((val !== null) ? ((val<0) ? val : Common.Utils.Metric.fnRecalcFromMM(val) ) : '', true);
},
createDelayedElements: function() {

View file

@ -577,6 +577,10 @@ define([
spinner.setDefaultUnit(Common.Utils.Metric.getCurrentMetricName());
spinner.setStep(Common.Utils.Metric.getCurrentMetric()==Common.Utils.Metric.c_MetricUnits.pt ? 1 : 0.1);
}
var val = this._state.Width;
this.numWidth && this.numWidth.setValue((val !== null && val !== undefined) ? Common.Utils.Metric.fnRecalcFromMM(val) : '', true);
val = this._state.Height;
this.numHeight && this.numHeight.setValue((val !== null && val !== undefined) ? Common.Utils.Metric.fnRecalcFromMM(val) : '', true);
}
},

View file

@ -193,6 +193,8 @@ define([
spinner.setDefaultUnit(Common.Utils.Metric.getCurrentMetricName());
spinner.setStep(Common.Utils.Metric.getCurrentMetric()==Common.Utils.Metric.c_MetricUnits.pt ? 1 : 0.1);
}
this.spnWidth && this.spnWidth.setValue((this._state.Width!==null) ? Common.Utils.Metric.fnRecalcFromMM(this._state.Width) : '', true);
this.spnHeight && this.spnHeight.setValue((this._state.Height!==null) ? Common.Utils.Metric.fnRecalcFromMM(this._state.Height) : '', true);
}
},

View file

@ -229,6 +229,10 @@ define([
spinner.setDefaultUnit(Common.Utils.Metric.getCurrentMetricName());
spinner.setStep(Common.Utils.Metric.getCurrentMetric()==Common.Utils.Metric.c_MetricUnits.pt ? 1 : 0.01);
}
var val = this._state.LineSpacingBefore;
this.numSpacingBefore && this.numSpacingBefore.setValue((val !== null) ? ((val<0) ? val : Common.Utils.Metric.fnRecalcFromMM(val) ) : '', true);
val = this._state.LineSpacingAfter;
this.numSpacingAfter && this.numSpacingAfter.setValue((val !== null) ? ((val<0) ? val : Common.Utils.Metric.fnRecalcFromMM(val) ) : '', true);
}
if (this.cmbLineRule) {
var rec = this.cmbLineRule.store.at(1);
@ -242,6 +246,7 @@ define([
if (!rec) rec = this.cmbLineRule.store.at(0);
this.numLineHeight.setDefaultUnit(rec.get('defaultUnit'));
this.numLineHeight.setStep(rec.get('step'));
this.numLineHeight && this.numLineHeight.setValue((this._state.LineHeight !== null) ? Common.Utils.Metric.fnRecalcFromMM(this._state.LineHeight) : '', true);
}
}
},

View file

@ -538,6 +538,10 @@ define([
spinner.setDefaultUnit(Common.Utils.Metric.getCurrentMetricName());
spinner.setStep(Common.Utils.Metric.getCurrentMetric()==Common.Utils.Metric.c_MetricUnits.pt ? 1 : 0.1);
}
var val = this._state.Width;
this.numWidth && this.numWidth.setValue((val !== null && val !== undefined) ? Common.Utils.Metric.fnRecalcFromMM(val) : '', true);
val = this._state.Height;
this.numHeight && this.numHeight.setValue((val !== null && val !== undefined) ? Common.Utils.Metric.fnRecalcFromMM(val) : '', true);
}
},

View file

@ -515,6 +515,8 @@ define([
spinner.setDefaultUnit(Common.Utils.Metric.getCurrentMetricName());
spinner.setStep(Common.Utils.Metric.getCurrentMetric()==Common.Utils.Metric.c_MetricUnits.pt ? 1 : 0.1);
}
this.spnWidth && this.spnWidth.setValue((this._state.Width!==null) ? Common.Utils.Metric.fnRecalcFromMM(this._state.Width) : '', true);
this.spnHeight && this.spnHeight.setValue((this._state.Height!==null) ? Common.Utils.Metric.fnRecalcFromMM(this._state.Height) : '', true);
}
},

View file

@ -116,6 +116,8 @@ define([
spinner.setDefaultUnit(Common.Utils.Metric.getCurrentMetricName());
spinner.setStep(Common.Utils.Metric.getCurrentMetric()==Common.Utils.Metric.c_MetricUnits.pt ? 1 : 0.1);
}
this.spnWidth && this.spnWidth.setValue((this._state.Width!==null) ? Common.Utils.Metric.fnRecalcFromMM(this._state.Width) : '', true);
this.spnHeight && this.spnHeight.setValue((this._state.Height!==null) ? Common.Utils.Metric.fnRecalcFromMM(this._state.Height) : '', true);
}
},

View file

@ -232,6 +232,10 @@ define([
spinner.setDefaultUnit(Common.Utils.Metric.getCurrentMetricName());
spinner.setStep(Common.Utils.Metric.getCurrentMetric()==Common.Utils.Metric.c_MetricUnits.pt ? 1 : 0.01);
}
var val = this._state.LineSpacingBefore;
this.numSpacingBefore && this.numSpacingBefore.setValue((val !== null) ? ((val<0) ? val : Common.Utils.Metric.fnRecalcFromMM(val) ) : '', true);
val = this._state.LineSpacingAfter;
this.numSpacingAfter && this.numSpacingAfter.setValue((val !== null) ? ((val<0) ? val : Common.Utils.Metric.fnRecalcFromMM(val) ) : '', true);
}
if (this.cmbLineRule) {
var rec = this.cmbLineRule.store.at(1);
@ -245,7 +249,7 @@ define([
if (!rec) rec = this.cmbLineRule.store.at(0);
this.numLineHeight.setDefaultUnit(rec.get('defaultUnit'));
this.numLineHeight.setStep(rec.get('step'));
this.numLineHeight && this.numLineHeight.setValue((this._state.LineHeight !== null) ? Common.Utils.Metric.fnRecalcFromMM(this._state.LineHeight) : '', true);
}
}
},

View file

@ -122,6 +122,14 @@ define([
spinner.setDefaultUnit(Common.Utils.Metric.getCurrentMetricName());
spinner.setStep(Common.Utils.Metric.getCurrentMetric()==Common.Utils.Metric.c_MetricUnits.pt ? 1 : 0.1);
}
this.spnWidth && this.spnWidth.setValue((this._state.Width!==null) ? Common.Utils.Metric.fnRecalcFromMM(this._state.Width) : '', true);
this.spnHeight && this.spnHeight.setValue((this._state.Height!==null) ? Common.Utils.Metric.fnRecalcFromMM(this._state.Height) : '', true);
this.spnColWidth && this.spnColWidth.setValue((this._state.ColWidth!==null) ? Common.Utils.Metric.fnRecalcFromMM(this._state.ColWidth) : '', true);
this.spnColHeight && this.spnColHeight.setValue((this._state.ColHeight!==null) ? Common.Utils.Metric.fnRecalcFromMM(this._state.ColHeight) : '', true);
var val = this._state.PosHor;
this.spnHor && this.spnHor.setValue((val !== null && val !== undefined) ? Common.Utils.Metric.fnRecalcFromMM(val) : '', true);
val = this._state.PosVert;
this.spnVert && this.spnVert.setValue((val !== null && val !== undefined) ? Common.Utils.Metric.fnRecalcFromMM(val) : '', true);
}
},
@ -436,9 +444,12 @@ define([
var Position = {X: value.get_X(), Y: value.get_Y()};
this.spnHor.setValue((Position.X !== null && Position.X !== undefined) ? Common.Utils.Metric.fnRecalcFromMM(Position.X) : '', true);
this.spnVert.setValue((Position.Y !== null && Position.Y !== undefined) ? Common.Utils.Metric.fnRecalcFromMM(Position.Y) : '', true);
this._state.PosHor = Position.X;
this._state.PosVert = Position.Y;
} else {
this.spnHor.setValue('', true);
this.spnVert.setValue('', true);
this._state.PosHor = this._state.PosVert = null;
}
var slicerprops = props.asc_getSlicerProperties();