diff --git a/apps/spreadsheeteditor/mobile/locale/en.json b/apps/spreadsheeteditor/mobile/locale/en.json index 02681d4f8a..730a81fc13 100644 --- a/apps/spreadsheeteditor/mobile/locale/en.json +++ b/apps/spreadsheeteditor/mobile/locale/en.json @@ -318,6 +318,7 @@ "textThin": "Thin", "textMedium": "Medium", "textThick": "Thick", + "textFraction": "Fraction", "textGeneral": "General", "textNumber": "Number", "textInteger": "Integer", diff --git a/apps/spreadsheeteditor/mobile/src/controller/edit/EditCell.jsx b/apps/spreadsheeteditor/mobile/src/controller/edit/EditCell.jsx index b0d7bd9b7f..37fd07f146 100644 --- a/apps/spreadsheeteditor/mobile/src/controller/edit/EditCell.jsx +++ b/apps/spreadsheeteditor/mobile/src/controller/edit/EditCell.jsx @@ -1,12 +1,29 @@ import React, {Component} from 'react'; -import { f7 } from 'framework7-react'; -import {Device} from '../../../../../common/mobile/utils/device'; - import { EditCell } from '../../view/edit/EditCell'; class EditCellController extends Component { constructor (props) { super(props); + this.dateFormats = this.initFormats(Asc.c_oAscNumFormatType.Date, 38822); + this.timeFormats = this.initFormats(Asc.c_oAscNumFormatType.Time, 1.534); + } + + initFormats(type, exampleVal) { + const api = Common.EditorApi.get(); + let info = new Asc.asc_CFormatCellsInfo(); + + info.asc_setType(type); + info.asc_setDecimalPlaces(0); + info.asc_setSeparator(false); + + let formatsArr = api.asc_getFormatCells(info), + data = []; + + formatsArr.forEach(function(item) { + data.push({value: item, displayValue: api.asc_getLocaleExample(item, exampleVal)}); + }); + + return data; } toggleBold(value) { @@ -116,10 +133,23 @@ class EditCellController extends Component { api.asc_setCellAngle(angle); } - onCellFormat(value) { + onCellFormat(format) { const api = Common.EditorApi.get(); - let type = decodeURIComponent(atob(value)); - api.asc_setCellFormat(type); + api.asc_setCellFormat(format); + } + + onAccountingCellFormat(value) { + const api = Common.EditorApi.get(); + let info = new Asc.asc_CFormatCellsInfo(); + + info.asc_setType(Asc.c_oAscNumFormatType.Accounting); + info.asc_setSeparator(false); + info.asc_setSymbol(value); + + let format = api.asc_getFormatCells(info); + + if (format && format.length > 0) + api.asc_setCellFormat(format[0]); } onBorderStyle(type, borderInfo) { @@ -168,6 +198,9 @@ class EditCellController extends Component { onCellFormat={this.onCellFormat} onTextOrientationChange={this.onTextOrientationChange} onBorderStyle={this.onBorderStyle} + onAccountingCellFormat={this.onAccountingCellFormat} + dateFormats={this.dateFormats} + timeFormats={this.timeFormats} /> ) } diff --git a/apps/spreadsheeteditor/mobile/src/view/edit/EditCell.jsx b/apps/spreadsheeteditor/mobile/src/view/edit/EditCell.jsx index e66e490457..c2980ee4a4 100644 --- a/apps/spreadsheeteditor/mobile/src/view/edit/EditCell.jsx +++ b/apps/spreadsheeteditor/mobile/src/view/edit/EditCell.jsx @@ -88,7 +88,11 @@ const EditCell = props => { {!isAndroid ? : null @@ -757,20 +761,20 @@ const PageFormatCell = props => { } - props.onCellFormat('R2VuZXJhbA==')}> + props.onCellFormat('General')}> - props.onCellFormat('MC4wMA==')}> + props.onCellFormat('0.00')}> - props.onCellFormat('JTIzMA==')}> + props.onCellFormat('# ?/?')}> - props.onCellFormat('MC4wMEUlMkIwMA==')}> + props.onCellFormat('0.00E+00')}> @@ -780,19 +784,21 @@ const PageFormatCell = props => { - props.onCellFormat('MC4wMCUyNQ==')}> + props.onCellFormat('0.00%')}> - props.onCellFormat('JTQw')}> + props.onCellFormat('@')}> @@ -815,19 +821,19 @@ const PageAccountingFormatCell = props => { props.onCellFormat('XyglMjQqJTIwJTIzJTJDJTIzJTIzMC4wMF8pJTNCXyglMjQqJTIwKCUyMyUyQyUyMyUyMzAuMDApJTNCXyglMjQqJTIwJTIyLSUyMiUzRiUzRl8pJTNCXyglNDBfKQ==')}> + onClick={() => props.onAccountingCellFormat(1033)}> props.onCellFormat('XyglRTIlODIlQUMqJTIwJTIzJTJDJTIzJTIzMC4wMF8pJTNCXyglRTIlODIlQUMqJTIwKCUyMyUyQyUyMyUyMzAuMDApJTNCXyglRTIlODIlQUMqJTIwJTIyLSUyMiUzRiUzRl8pJTNCXyglNDBfKQ==')}> + onClick={() => props.onAccountingCellFormat(1031)}> props.onCellFormat('XyglQzIlQTMqJTIwJTIzJTJDJTIzJTIzMC4wMF8pJTNCXyglQzIlQTMqJTIwKCUyMyUyQyUyMyUyMzAuMDApJTNCXyglQzIlQTMqJTIwJTIyLSUyMiUzRiUzRl8pJTNCXyglNDBfKQ==')}> + onClick={() => props.onAccountingCellFormat(2057)}> props.onCellFormat('Xy0qJTIwJTIzJTJDJTIzJTIzMC4wMCU1QiUyNCVEMSU4MC4tNDE5JTVEXy0lM0ItKiUyMCUyMyUyQyUyMyUyMzAuMDAlNUIlMjQlRDElODAuLTQxOSU1RF8tJTNCXy0qJTIwJTIyLSUyMiUzRiUzRiU1QiUyNCVEMSU4MC4tNDE5JTVEXy0lM0JfLSU0MF8t')}> + onClick={() => props.onAccountingCellFormat(1049)}> props.onCellFormat('XyglQzIlQTUqJTIwJTIzJTJDJTIzJTIzMC4wMF8pJTNCXyglQzIlQTUqJTIwKCUyMyUyQyUyMyUyMzAuMDApJTNCXyglQzIlQTUqJTIwJTIyLSUyMiUzRiUzRl8pJTNCXyglNDBfKQ==')}> + onClick={() => props.onAccountingCellFormat(1041)}> @@ -840,7 +846,7 @@ const PageCurrencyFormatCell = props => { return ( - + {Device.phone && @@ -849,19 +855,19 @@ const PageCurrencyFormatCell = props => { props.onCellFormat('JTI0JTIzJTJDJTIzJTIzMC4wMA==')}> + onClick={() => props.onCellFormat('[$$-409]#,##0.00')}> props.onCellFormat('JUUyJTgyJUFDJTIzJTJDJTIzJTIzMC4wMA==')}> + onClick={() => props.onCellFormat('#,##0.00\ [$€-407]')}> props.onCellFormat('JUMyJUEzJTIzJTJDJTIzJTIzMC4wMA==')}> + onClick={() => props.onCellFormat('[$£-809]#,##0.00')}> props.onCellFormat('JTIzJTJDJTIzJTIzMC4wMCUyMiVEMSU4MC4lMjI=')}> + onClick={() => props.onCellFormat('#,##0.00\ [$₽-419]')}> props.onCellFormat('JUMyJUE1JTIzJTJDJTIzJTIzMC4wMA==')}> + onClick={() => props.onCellFormat('[$¥-411]#,##0.00')}> @@ -871,6 +877,7 @@ const PageCurrencyFormatCell = props => { const PageDateFormatCell = props => { const { t } = useTranslation(); const _t = t('View.Edit', {returnObjects: true}); + const dateFormats = props.dateFormats; return ( @@ -882,26 +889,12 @@ const PageDateFormatCell = props => { } - props.onCellFormat('TU0tZGQteXk=')}> - props.onCellFormat('TU0tZGQteXl5eQ==')}> - - props.onCellFormat('ZGQtTU0teXk=')}> - - props.onCellFormat('ZGQtTU0teXl5eQ==')}> - - props.onCellFormat('ZGQtTU1NLXl5eXk=')}> - - props.onCellFormat('ZGQtTU1N')}> - - props.onCellFormat('TU1NLXl5')}> - + {dateFormats.map((format, index) => { + return ( + props.onCellFormat(format.value)}> + ) + })} ) @@ -910,6 +903,7 @@ const PageDateFormatCell = props => { const PageTimeFormatCell = props => { const { t } = useTranslation(); const _t = t('View.Edit', {returnObjects: true}); + const timeFormats = props.timeFormats; return ( @@ -921,21 +915,12 @@ const PageTimeFormatCell = props => { } - props.onCellFormat('aCUzQW1tJTNCJTQw')}> - - props.onCellFormat('aCUzQW1tJTNBc3MlM0IlNDA=')}> - - props.onCellFormat('aCUzQW1tJTIwQU0lMkZQTSUzQiU0MA==')}> - - props.onCellFormat('aCUzQW1tJTNBc3MlMjBBTSUyRlBNJTNCJTQw')}> - - props.onCellFormat('JTVCaCU1RCUzQW1tJTNBc3MlM0IlNDA=')}> - + {timeFormats.map((format, index) => { + return ( + props.onCellFormat(format.value)}> + ) + })} )