From 2ee40024e7f5ea00c6cdfeac6cca5743b01021ac Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Mon, 16 Dec 2019 14:02:22 +0300 Subject: [PATCH 1/2] Fix Bug 42788: add customization->units parameter to api --- apps/api/documents/api.js | 3 ++- apps/documenteditor/main/app/controller/Main.js | 3 ++- apps/documenteditor/mobile/app/controller/Main.js | 5 +++-- apps/documenteditor/mobile/app/controller/Settings.js | 4 +--- apps/presentationeditor/main/app/controller/Main.js | 3 ++- apps/presentationeditor/mobile/app/controller/Main.js | 9 +++++---- .../presentationeditor/mobile/app/controller/Settings.js | 3 +-- apps/spreadsheeteditor/main/app/controller/Main.js | 3 ++- apps/spreadsheeteditor/mobile/app/controller/Main.js | 6 ++++-- apps/spreadsheeteditor/mobile/app/controller/Settings.js | 7 +------ 10 files changed, 23 insertions(+), 23 deletions(-) diff --git a/apps/api/documents/api.js b/apps/api/documents/api.js index f3cc1fc2a..347890b05 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, + units: '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..b292f37da 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.units ? Common.Utils.Metric.c_MetricUnits[this.appOptions.customization.units.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..21d5f0693 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.units ? Common.Utils.Metric.c_MetricUnits[this.appOptions.customization.units.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..b420dda34 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.units ? Common.Utils.Metric.c_MetricUnits[me.appOptions.customization.units.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..9e5e4ea3c 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.units ? Common.Utils.Metric.c_MetricUnits[me.appOptions.customization.units.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..3954d4e93 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.units ? Common.Utils.Metric.c_MetricUnits[me.appOptions.customization.units.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..3124deb3b 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.units ? Common.Utils.Metric.c_MetricUnits[me.appOptions.customization.units.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 From add6f62dbd6ed07542ab50260c2507cc863a8b53 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Mon, 16 Dec 2019 15:01:09 +0300 Subject: [PATCH 2/2] Bug 42788: rename customization->units to customization->unit --- apps/api/documents/api.js | 2 +- apps/documenteditor/main/app/controller/Main.js | 2 +- apps/documenteditor/mobile/app/controller/Main.js | 2 +- apps/presentationeditor/main/app/controller/Main.js | 2 +- apps/presentationeditor/mobile/app/controller/Main.js | 2 +- apps/spreadsheeteditor/main/app/controller/Main.js | 2 +- apps/spreadsheeteditor/mobile/app/controller/Main.js | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/apps/api/documents/api.js b/apps/api/documents/api.js index 347890b05..710aee5bb 100644 --- a/apps/api/documents/api.js +++ b/apps/api/documents/api.js @@ -132,7 +132,7 @@ reviewDisplay: 'original', spellcheck: true, compatibleFeatures: false, - units: 'cm' // cm, pt, inch + 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 b292f37da..45873fd59 100644 --- a/apps/documenteditor/main/app/controller/Main.js +++ b/apps/documenteditor/main/app/controller/Main.js @@ -1316,7 +1316,7 @@ define([ } var value = Common.localStorage.getItem('de-settings-unit'); - value = (value!==null) ? parseInt(value) : (this.appOptions.customization && this.appOptions.customization.units ? Common.Utils.Metric.c_MetricUnits[this.appOptions.customization.units.toLocaleLowerCase()] : 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); diff --git a/apps/documenteditor/mobile/app/controller/Main.js b/apps/documenteditor/mobile/app/controller/Main.js index 21d5f0693..835009461 100644 --- a/apps/documenteditor/mobile/app/controller/Main.js +++ b/apps/documenteditor/mobile/app/controller/Main.js @@ -799,7 +799,7 @@ define([ var me = this; var value = Common.localStorage.getItem('de-mobile-settings-unit'); - value = (value!==null) ? parseInt(value) : (this.appOptions.customization && this.appOptions.customization.units ? Common.Utils.Metric.c_MetricUnits[this.appOptions.customization.units.toLocaleLowerCase()] : 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); 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/main/app/controller/Main.js b/apps/presentationeditor/main/app/controller/Main.js index b420dda34..7487b620a 100644 --- a/apps/presentationeditor/main/app/controller/Main.js +++ b/apps/presentationeditor/main/app/controller/Main.js @@ -1021,7 +1021,7 @@ define([ } var value = Common.localStorage.getItem('pe-settings-unit'); - value = (value!==null) ? parseInt(value) : (me.appOptions.customization && me.appOptions.customization.units ? Common.Utils.Metric.c_MetricUnits[me.appOptions.customization.units.toLocaleLowerCase()] : 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); diff --git a/apps/presentationeditor/mobile/app/controller/Main.js b/apps/presentationeditor/mobile/app/controller/Main.js index 9e5e4ea3c..22f2ded06 100644 --- a/apps/presentationeditor/mobile/app/controller/Main.js +++ b/apps/presentationeditor/mobile/app/controller/Main.js @@ -726,7 +726,7 @@ define([ value; value = Common.localStorage.getItem('pe-mobile-settings-unit'); - value = (value!==null) ? parseInt(value) : (me.appOptions.customization && me.appOptions.customization.units ? Common.Utils.Metric.c_MetricUnits[me.appOptions.customization.units.toLocaleLowerCase()] : 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); 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/spreadsheeteditor/main/app/controller/Main.js b/apps/spreadsheeteditor/main/app/controller/Main.js index 3954d4e93..773560c63 100644 --- a/apps/spreadsheeteditor/main/app/controller/Main.js +++ b/apps/spreadsheeteditor/main/app/controller/Main.js @@ -1106,7 +1106,7 @@ define([ this.toolbarView = toolbarController.getView('Toolbar'); var value = Common.localStorage.getItem('sse-settings-unit'); - value = (value!==null) ? parseInt(value) : (me.appOptions.customization && me.appOptions.customization.units ? Common.Utils.Metric.c_MetricUnits[me.appOptions.customization.units.toLocaleLowerCase()] : 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 3124deb3b..324d0ad13 100644 --- a/apps/spreadsheeteditor/mobile/app/controller/Main.js +++ b/apps/spreadsheeteditor/mobile/app/controller/Main.js @@ -753,7 +753,7 @@ define([ var me = this; var value = Common.localStorage.getItem('se-mobile-settings-unit'); - value = (value!==null) ? parseInt(value) : (me.appOptions.customization && me.appOptions.customization.units ? Common.Utils.Metric.c_MetricUnits[me.appOptions.customization.units.toLocaleLowerCase()] : 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);