From 681d032adbed4159ce6e258e8693bad259b5c3b2 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Tue, 17 Jan 2017 15:58:20 +0300 Subject: [PATCH] [SSE] Number format in the toolbar depends on regional settings. --- .../main/app/controller/Toolbar.js | 22 ++- .../main/app/view/FileMenuPanels.js | 4 +- .../main/app/view/Toolbar.js | 176 +----------------- 3 files changed, 22 insertions(+), 180 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/Toolbar.js b/apps/spreadsheeteditor/main/app/controller/Toolbar.js index ece2432b9..ea4fc6506 100644 --- a/apps/spreadsheeteditor/main/app/controller/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/controller/Toolbar.js @@ -103,7 +103,8 @@ define([ fontsize: undefined, multiselect: false, sparklines_disabled: false, - numformattype: undefined + numformattype: undefined, + langId: undefined }; var checkInsertAutoshape = function(e, action) { @@ -910,8 +911,23 @@ define([ onNumberFormatOpenBefore: function(combo) { if (this.api) { - var me = this, - info = me.api.asc_getCellInfo(); + var me = this; + + var value = Common.localStorage.getItem("sse-settings-reg-settings"); + value = (value!==null) ? parseInt(value) : ((this.toolbar.mode.lang) ? parseInt(Common.util.LanguageInfo.getLocalLanguageCode(this.toolbar.mode.lang)) : 0x0409); + + if (this._state.langId !== value) { + this._state.langId = value; + + var info = new Asc.asc_CFormatCellsInfo(); + info.asc_setType(Asc.c_oAscNumFormatType.None); + info.asc_setSymbol(this._state.langId); + var arr = this.api.asc_getFormatCells(info); // all formats + me.toolbar.numFormatData.forEach( function(item, index) { + me.toolbar.numFormatData[index].format = arr[index]; + }); + } + me.toolbar.numFormatData.forEach( function(item, index) { item.exampleval = me.api.asc_getLocaleExample(item.format); }); diff --git a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js index a9610142c..fb0e8a247 100644 --- a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js +++ b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js @@ -760,8 +760,8 @@ define([ info.asc_setType(Asc.c_oAscNumFormatType.None); info.asc_setSymbol(landId); var arr = this.api.asc_getFormatCells(info); // all formats - text = this.api.asc_getLocaleExample(arr[2], 1000.01, landId); - text = text + ' ' + this.api.asc_getLocaleExample(arr[4], (new Date()).getExcelDateWithTime(), landId); + text = this.api.asc_getLocaleExample(arr[4], 1000.01, landId); + text = text + ' ' + this.api.asc_getLocaleExample(arr[5], (new Date()).getExcelDateWithTime(), landId); text = text + ' ' + this.api.asc_getLocaleExample(arr[6], (new Date()).getExcelDateWithTime(), landId); } $('#fms-lbl-reg-settings').text(_.isEmpty(text) ? '' : this.strRegSettingsEx + text); diff --git a/apps/spreadsheeteditor/main/app/view/Toolbar.js b/apps/spreadsheeteditor/main/app/view/Toolbar.js index 353981382..ded621618 100644 --- a/apps/spreadsheeteditor/main/app/view/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/view/Toolbar.js @@ -692,7 +692,7 @@ define([ items : [ { caption : me.txtDollar, - value : me.ascFormatOptions.Accounting + value : '_($* #,##0.00_);_($* (#,##0.00);_($* "-"??_);_(@_)' }, { caption : me.txtEuro, @@ -1531,180 +1531,6 @@ define([ }); } - // var formatTemplate = _.template('<%= caption %><%= options.tplval ? options.tplval : options.value %>'); - // this.btnNumberFormat.setMenu( new Common.UI.Menu({ - // style: 'margin-left: -1px;', - // items: [ - // { - // caption : this.txtGeneral, - // value : this.ascFormatOptions.General - // }, - // { - // caption : this.txtNumber, - // value : this.ascFormatOptions.Number - // }, - // { - // caption : this.txtInteger, - // value : '#0' - // }, - // { - // caption : this.txtScientific, - // value : this.ascFormatOptions.Scientific - // }, - // { - // caption : this.txtAccounting, - // menu : new Common.UI.Menu({ - // style: 'min-width: 120px;', - // menuAlign: 'tl-tr', - // items : [ - // { - // caption : this.txtDollar, - // value : this.ascFormatOptions.Accounting - // }, - // { - // caption : this.txtEuro, - // value : '_(€* #,##0.00_);_(€* (#,##0.00);_(€* "-"??_);_(@_)' - // }, - // { - // caption : this.txtPound, - // value : '_(£* #,##0.00_);_(£* (#,##0.00);_(£* "-"??_);_(@_)' - // }, - // { - // caption : this.txtRouble, - // value : '_-* #,##0.00[$р.-419]_-;-* #,##0.00[$р.-419]_-;_-* "-"??[$р.-419]_-;_-@_-' - // }, - // { - // caption : this.txtYen, - // value : '_(¥* #,##0.00_);_(¥* (#,##0.00);_(¥* "-"??_);_(@_)' - // } - // ] - // }) - // }, - // { - // caption : this.txtCurrency, - // menu : new Common.UI.Menu({ - // style: 'min-width: 120px;', - // menuAlign: 'tl-tr', - // items : [ - // { - // caption : this.txtDollar, - // value : this.ascFormatOptions.Currency - // }, - // { - // caption : this.txtEuro, - // value : '€#,##0.00' - // }, - // { - // caption : this.txtPound, - // value : '£#,##0.00' - // }, - // { - // caption : this.txtRouble, - // value : '#,##0.00"р."' - // }, - // { - // caption : this.txtYen, - // value : '¥#,##0.00' - // } - // ] - // }) - // }, - // { - // caption : this.txtDate, - // menu : new Common.UI.Menu({ - // style: 'min-width: 200px;', - // menuAlign: 'tl-tr', - // items: [ - // { - // caption : '07-24-88', - // value : 'MM-dd-yy', - // template: formatTemplate - // }, - // { - // caption : '07-24-1988', - // value : 'MM-dd-yyyy', - // template: formatTemplate - // }, - // { - // caption : '24-07-88', - // value : 'dd-MM-yy', - // template: formatTemplate - // }, - // { - // caption : '24-07-1988', - // value : 'dd-MM-yyyy', - // template: formatTemplate - // }, - // { - // caption : '24-Jul-1988', - // value : 'dd-MMM-yyyy', - // template: formatTemplate - // }, - // { - // caption : '24-Jul', - // value : 'dd-MMM', - // template: formatTemplate - // }, - // { - // caption : 'Jul-88', - // value : 'MMM-yy', - // template: formatTemplate - // } - // ] - // }) - // }, - // { - // caption : this.txtTime, - // menu : new Common.UI.Menu({ - // style: 'min-width: 200px;', - // menuAlign: 'tl-tr', - // showSeparator : false, - // items: [ - // { - // caption : '10:56', - // value : 'HH:mm', - // template: formatTemplate - // }, - // { - // caption : '21:56:00', - // value : 'HH:MM:ss', - // template: formatTemplate - // }, - // { - // caption : '05:56 AM', - // tplval : 'hh:mm tt', - // value : 'hh:mm AM/PM', - // template: formatTemplate - // }, - // { - // caption : '05:56:00 AM', - // tplval : 'hh:mm:ss tt', - // value : 'hh:mm:ss AM/PM', - // template: formatTemplate - // }, - // { - // caption : '38:56:00', - // value : '[h]:mm:ss', - // template: formatTemplate - // } - // ] - // }) - // }, - // { - // caption : this.txtPercentage, - // value : this.ascFormatOptions.Percentage - // }, - // { - // caption : this.txtFraction, - // value : this.ascFormatOptions.Fraction - // }, - // { - // caption : this.txtText, - // value : this.ascFormatOptions.Text - // } - // ] - // })); - this.mnuInsertChartPicker = new Common.UI.DataView({ el: $('#id-toolbar-menu-insertchart'), parentMenu: this.btnInsertChart.menu,