diff --git a/apps/api/documents/api.js b/apps/api/documents/api.js index f3cc1fc2a..710aee5bb 100644 --- a/apps/api/documents/api.js +++ b/apps/api/documents/api.js @@ -131,7 +131,8 @@ toolbarHideFileName: false, reviewDisplay: 'original', spellcheck: true, - compatibleFeatures: false + compatibleFeatures: false, + unit: 'cm' // cm, pt, inch }, plugins: { autostart: ['asc.{FFE1F462-1EA2-4391-990D-4CC84940B754}'], diff --git a/apps/documenteditor/main/app/controller/Main.js b/apps/documenteditor/main/app/controller/Main.js index 747664e63..45873fd59 100644 --- a/apps/documenteditor/main/app/controller/Main.js +++ b/apps/documenteditor/main/app/controller/Main.js @@ -1316,7 +1316,8 @@ define([ } var value = Common.localStorage.getItem('de-settings-unit'); - value = (value!==null) ? parseInt(value) : Common.Utils.Metric.getDefaultMetric(); + value = (value!==null) ? parseInt(value) : (this.appOptions.customization && this.appOptions.customization.unit ? Common.Utils.Metric.c_MetricUnits[this.appOptions.customization.unit.toLocaleLowerCase()] : Common.Utils.Metric.getDefaultMetric()); + (value===undefined) && (value = Common.Utils.Metric.getDefaultMetric()); Common.Utils.Metric.setCurrentMetric(value); Common.Utils.InternalSettings.set("de-settings-unit", value); me.api.asc_SetDocumentUnits((value==Common.Utils.Metric.c_MetricUnits.inch) ? Asc.c_oAscDocumentUnits.Inch : ((value==Common.Utils.Metric.c_MetricUnits.pt) ? Asc.c_oAscDocumentUnits.Point : Asc.c_oAscDocumentUnits.Millimeter)); diff --git a/apps/documenteditor/mobile/app/controller/Main.js b/apps/documenteditor/mobile/app/controller/Main.js index 6c430dc27..835009461 100644 --- a/apps/documenteditor/mobile/app/controller/Main.js +++ b/apps/documenteditor/mobile/app/controller/Main.js @@ -798,8 +798,9 @@ define([ if (this.appOptions.isEdit) { var me = this; - var value = Common.localStorage.getItem('de-mobile-settings-unit'); - value = (value!==null) ? parseInt(value) : Common.Utils.Metric.getDefaultMetric(); + var value = Common.localStorage.getItem('de-mobile-settings-unit'); + value = (value!==null) ? parseInt(value) : (this.appOptions.customization && this.appOptions.customization.unit ? Common.Utils.Metric.c_MetricUnits[this.appOptions.customization.unit.toLocaleLowerCase()] : Common.Utils.Metric.getDefaultMetric()); + (value===undefined) && (value = Common.Utils.Metric.getDefaultMetric()); Common.Utils.Metric.setCurrentMetric(value); me.api.asc_SetDocumentUnits((value==Common.Utils.Metric.c_MetricUnits.inch) ? Asc.c_oAscDocumentUnits.Inch : ((value==Common.Utils.Metric.c_MetricUnits.pt) ? Asc.c_oAscDocumentUnits.Point : Asc.c_oAscDocumentUnits.Millimeter)); diff --git a/apps/documenteditor/mobile/app/controller/Settings.js b/apps/documenteditor/mobile/app/controller/Settings.js index ae3df00a3..cd817049f 100644 --- a/apps/documenteditor/mobile/app/controller/Settings.js +++ b/apps/documenteditor/mobile/app/controller/Settings.js @@ -376,8 +376,7 @@ define([ var me = this, $unitMeasurement = $('.page[data-page=settings-advanced-view] input:radio[name=unit-of-measurement]'); $unitMeasurement.single('change', _.bind(me.unitMeasurementChange, me)); - var value = Common.localStorage.getItem('de-mobile-settings-unit'); - value = (value!==null) ? parseInt(value) : Common.Utils.Metric.getDefaultMetric(); + var value = Common.Utils.Metric.getCurrentMetric(); $unitMeasurement.val([value]); var _stateDisplayMode = DE.getController('Common.Controllers.Collaboration').getDisplayMode(); if(_stateDisplayMode == "final" || _stateDisplayMode == "original") { @@ -642,7 +641,6 @@ define([ Common.Utils.Metric.setCurrentMetric(value); Common.localStorage.setItem("de-mobile-settings-unit", value); this.api.asc_SetDocumentUnits((value==Common.Utils.Metric.c_MetricUnits.inch) ? Asc.c_oAscDocumentUnits.Inch : ((value==Common.Utils.Metric.c_MetricUnits.pt) ? Asc.c_oAscDocumentUnits.Point : Asc.c_oAscDocumentUnits.Millimeter)); - }, onPageMarginsChange: function (align, e) { diff --git a/apps/presentationeditor/main/app/controller/Main.js b/apps/presentationeditor/main/app/controller/Main.js index 418aa44e0..7487b620a 100644 --- a/apps/presentationeditor/main/app/controller/Main.js +++ b/apps/presentationeditor/main/app/controller/Main.js @@ -1021,7 +1021,8 @@ define([ } var value = Common.localStorage.getItem('pe-settings-unit'); - value = (value!==null) ? parseInt(value) : Common.Utils.Metric.getDefaultMetric(); + value = (value!==null) ? parseInt(value) : (me.appOptions.customization && me.appOptions.customization.unit ? Common.Utils.Metric.c_MetricUnits[me.appOptions.customization.unit.toLocaleLowerCase()] : Common.Utils.Metric.getDefaultMetric()); + (value===undefined) && (value = Common.Utils.Metric.getDefaultMetric()); Common.Utils.Metric.setCurrentMetric(value); Common.Utils.InternalSettings.set("pe-settings-unit", value); me.api.asc_SetDocumentUnits((value==Common.Utils.Metric.c_MetricUnits.inch) ? Asc.c_oAscDocumentUnits.Inch : ((value==Common.Utils.Metric.c_MetricUnits.pt) ? Asc.c_oAscDocumentUnits.Point : Asc.c_oAscDocumentUnits.Millimeter)); diff --git a/apps/presentationeditor/mobile/app/controller/Main.js b/apps/presentationeditor/mobile/app/controller/Main.js index 16e51eacc..22f2ded06 100644 --- a/apps/presentationeditor/mobile/app/controller/Main.js +++ b/apps/presentationeditor/mobile/app/controller/Main.js @@ -725,10 +725,11 @@ define([ var me = this, value; - // var value = Common.localStorage.getItem('pe-settings-unit'); - // value = (value!==null) ? parseInt(value) : Common.Utils.Metric.getDefaultMetric(); - // Common.Utils.Metric.setCurrentMetric(value); - // me.api.asc_SetDocumentUnits((value==Common.Utils.Metric.c_MetricUnits.inch) ? Asc.c_oAscDocumentUnits.Inch : ((value==Common.Utils.Metric.c_MetricUnits.pt) ? Asc.c_oAscDocumentUnits.Point : Asc.c_oAscDocumentUnits.Millimeter)); + value = Common.localStorage.getItem('pe-mobile-settings-unit'); + value = (value!==null) ? parseInt(value) : (me.appOptions.customization && me.appOptions.customization.unit ? Common.Utils.Metric.c_MetricUnits[me.appOptions.customization.unit.toLocaleLowerCase()] : Common.Utils.Metric.getDefaultMetric()); + (value===undefined) && (value = Common.Utils.Metric.getDefaultMetric()); + Common.Utils.Metric.setCurrentMetric(value); + me.api.asc_SetDocumentUnits((value==Common.Utils.Metric.c_MetricUnits.inch) ? Asc.c_oAscDocumentUnits.Inch : ((value==Common.Utils.Metric.c_MetricUnits.pt) ? Asc.c_oAscDocumentUnits.Point : Asc.c_oAscDocumentUnits.Millimeter)); // value = Common.localStorage.getItem('pe-hidden-rulers'); // if (me.api.asc_SetViewRulers) me.api.asc_SetViewRulers(value===null || parseInt(value) === 0); diff --git a/apps/presentationeditor/mobile/app/controller/Settings.js b/apps/presentationeditor/mobile/app/controller/Settings.js index e034693f2..46a66abd0 100644 --- a/apps/presentationeditor/mobile/app/controller/Settings.js +++ b/apps/presentationeditor/mobile/app/controller/Settings.js @@ -271,8 +271,7 @@ define([ var me = this, $unitMeasurement = $('.page[data-page=settings-application-view] input:radio[name=unit-of-measurement]'); $unitMeasurement.single('change', _.bind(me.unitMeasurementChange, me)); - var value = Common.localStorage.getItem('pe-mobile-settings-unit'); - value = (value!==null) ? parseInt(value) : Common.Utils.Metric.getDefaultMetric(); + var value = Common.Utils.Metric.getCurrentMetric(); $unitMeasurement.val([value]); }, diff --git a/apps/spreadsheeteditor/main/app/controller/Main.js b/apps/spreadsheeteditor/main/app/controller/Main.js index 1b7cb600f..773560c63 100644 --- a/apps/spreadsheeteditor/main/app/controller/Main.js +++ b/apps/spreadsheeteditor/main/app/controller/Main.js @@ -1106,7 +1106,8 @@ define([ this.toolbarView = toolbarController.getView('Toolbar'); var value = Common.localStorage.getItem('sse-settings-unit'); - value = (value!==null) ? parseInt(value) : Common.Utils.Metric.getDefaultMetric(); + value = (value!==null) ? parseInt(value) : (me.appOptions.customization && me.appOptions.customization.unit ? Common.Utils.Metric.c_MetricUnits[me.appOptions.customization.unit.toLocaleLowerCase()] : Common.Utils.Metric.getDefaultMetric()); + (value===undefined) && (value = Common.Utils.Metric.getDefaultMetric()); Common.Utils.Metric.setCurrentMetric(value); Common.Utils.InternalSettings.set("sse-settings-unit", value); diff --git a/apps/spreadsheeteditor/mobile/app/controller/Main.js b/apps/spreadsheeteditor/mobile/app/controller/Main.js index dec9af8ff..324d0ad13 100644 --- a/apps/spreadsheeteditor/mobile/app/controller/Main.js +++ b/apps/spreadsheeteditor/mobile/app/controller/Main.js @@ -752,8 +752,10 @@ define([ if (this.appOptions.isEdit) { var me = this; - var value = Common.localStorage.getItem('sse-settings-unit'); - Common.Utils.Metric.setCurrentMetric((value!==null) ? parseInt(value) : Common.Utils.Metric.getDefaultMetric()); + var value = Common.localStorage.getItem('se-mobile-settings-unit'); + value = (value!==null) ? parseInt(value) : (me.appOptions.customization && me.appOptions.customization.unit ? Common.Utils.Metric.c_MetricUnits[me.appOptions.customization.unit.toLocaleLowerCase()] : Common.Utils.Metric.getDefaultMetric()); + (value===undefined) && (value = Common.Utils.Metric.getDefaultMetric()); + Common.Utils.Metric.setCurrentMetric(value); me.api.asc_registerCallback('asc_onDocumentModifiedChanged', _.bind(me.onDocumentModifiedChanged, me)); me.api.asc_registerCallback('asc_onDocumentCanSaveChanged', _.bind(me.onDocumentCanSaveChanged, me)); diff --git a/apps/spreadsheeteditor/mobile/app/controller/Settings.js b/apps/spreadsheeteditor/mobile/app/controller/Settings.js index b8a176d08..196bd9996 100644 --- a/apps/spreadsheeteditor/mobile/app/controller/Settings.js +++ b/apps/spreadsheeteditor/mobile/app/controller/Settings.js @@ -371,10 +371,6 @@ define([ this.changeCurrentPageSize(opt.asc_getWidth(), opt.asc_getHeight()); $pageSize.find('.item-title').text(_pageSizes[_pageSizesIndex]['caption']); - var valueUnit = Common.localStorage.getItem('se-mobile-settings-unit'); - valueUnit = (valueUnit!==null) ? parseInt(valueUnit) : Common.Utils.Metric.getDefaultMetric(); - Common.Utils.Metric.setCurrentMetric(valueUnit); - var curMetricName = Common.Utils.Metric.getMetricName(Common.Utils.Metric.getCurrentMetric()), sizeW = parseFloat(Common.Utils.Metric.fnRecalcFromMM(_pageSizes[_pageSizesIndex]['value'][0]).toFixed(2)), sizeH = parseFloat(Common.Utils.Metric.fnRecalcFromMM(_pageSizes[_pageSizesIndex]['value'][1]).toFixed(2)); @@ -569,8 +565,7 @@ define([ var me = this, $unitMeasurement = $('.page[data-page=settings-application-view] input:radio[name=unit-of-measurement]'); $unitMeasurement.single('change', _.bind(me.unitMeasurementChange, me)); - var value = Common.localStorage.getItem('se-mobile-settings-unit'); - value = (value!==null) ? parseInt(value) : Common.Utils.Metric.getDefaultMetric(); + var value = Common.Utils.Metric.getCurrentMetric(); $unitMeasurement.val([value]); //init formula language