diff --git a/apps/spreadsheeteditor/mobile/src/controller/Main.jsx b/apps/spreadsheeteditor/mobile/src/controller/Main.jsx index 1e166bd36..afd6c2524 100644 --- a/apps/spreadsheeteditor/mobile/src/controller/Main.jsx +++ b/apps/spreadsheeteditor/mobile/src/controller/Main.jsx @@ -187,6 +187,8 @@ class MainController extends Component { // 'translate': translate }); + Common.EditorApi = {get: () => this.api}; + this.appOptions = {}; this.bindEvents(); @@ -202,7 +204,6 @@ class MainController extends Component { Common.Gateway.appReady(); Common.Notifications.trigger('engineCreated', this.api); - Common.EditorApi = {get: () => this.api}; }, error => { console.log('promise failed ' + error); }); @@ -227,58 +228,21 @@ class MainController extends Component { // me.api.asc_registerCallback('asc_onDocumentName', _.bind(me.onDocumentName, me)); me.api.asc_registerCallback('asc_onEndAction', me._onLongActionEnd.bind(me)); - const storeSpreadsheetSettings = this.props.storeSpreadsheetSettings; - const storeFocusObjects = this.props.storeFocusObjects; - const storeCellSettings = this.props.storeCellSettings; - const storeTextSettings = this.props.storeTextSettings; - const storeChartSettings = this.props.storeChartSettings; - const styleSize = storeCellSettings.styleSize; - - this.api.asc_registerCallback('asc_onSelectionChanged', cellInfo => { - console.log(cellInfo); - - storeFocusObjects.resetCellInfo(cellInfo); - storeCellSettings.initCellSettings(cellInfo); - storeTextSettings.initTextSettings(cellInfo); + EditorUIController.initThemeColors && EditorUIController.initThemeColors(); - let selectedObjects = Common.EditorApi.get().asc_getGraphicObjectProps(); + EditorUIController.initCellInfo && EditorUIController.initCellInfo(this.props); - if(selectedObjects.length) { - storeFocusObjects.resetFocusObjects(selectedObjects); + EditorUIController.initEditorStyles && EditorUIController.initEditorStyles(this.props.storeCellSettings); - // Chart Settings - - if (storeFocusObjects.chartObject) { - storeChartSettings.updateChartStyles(this.api.asc_getChartPreviews(storeFocusObjects.chartObject.get_ChartProperties().getType())); - } - } - }); + EditorUIController.initFonts && EditorUIController.initFonts(this.props); + const styleSize = this.props.storeCellSettings.styleSize; this.api.asc_setThumbnailStylesSizes(styleSize.width, styleSize.height); - this.api.asc_registerCallback('asc_onInitEditorFonts', (fonts, select) => { - storeCellSettings.initEditorFonts(fonts, select); - storeTextSettings.initEditorFonts(fonts, select); - }); - - this.api.asc_registerCallback('asc_onEditorSelectionChanged', fontObj => { - console.log(fontObj) - storeCellSettings.initFontInfo(fontObj); - storeTextSettings.initFontInfo(fontObj); - }); - - this.api.asc_registerCallback('asc_onInitEditorStyles', styles => { - storeCellSettings.initCellStyles(styles); - }); - - this.api.asc_registerCallback('asc_onSendThemeColors', (colors, standart_colors) => { - Common.Utils.ThemeColor.setColors(colors, standart_colors); - }); - // Spreadsheet Settings this.api.asc_registerCallback('asc_onSendThemeColorSchemes', schemes => { - storeSpreadsheetSettings.addSchemes(schemes); + this.props.storeSpreadsheetSettings.addSchemes(schemes); }); // Downloaded Advanced Options diff --git a/apps/spreadsheeteditor/mobile/src/store/focusObjects.js b/apps/spreadsheeteditor/mobile/src/store/focusObjects.js index a5d710292..936293cb0 100644 --- a/apps/spreadsheeteditor/mobile/src/store/focusObjects.js +++ b/apps/spreadsheeteditor/mobile/src/store/focusObjects.js @@ -61,140 +61,19 @@ export class storeFocusObjects { } get selections () { - const _selections = []; - - let isCell, isRow, isCol, isAll, isChart, isImage, isTextShape, isShape, isTextChart, - selType = this._cellInfo.asc_getSelectionType(), - isObjLocked = false; - - switch (selType) { - case Asc.c_oAscSelectionType.RangeCells: isCell = true; break; - case Asc.c_oAscSelectionType.RangeRow: isRow = true; break; - case Asc.c_oAscSelectionType.RangeCol: isCol = true; break; - case Asc.c_oAscSelectionType.RangeMax: isAll = true; break; - case Asc.c_oAscSelectionType.RangeImage: isImage = true; break; - case Asc.c_oAscSelectionType.RangeShape: isShape = true; break; - case Asc.c_oAscSelectionType.RangeChart: isChart = true; break; - case Asc.c_oAscSelectionType.RangeChartText:isTextChart = true; break; - case Asc.c_oAscSelectionType.RangeShapeText: isTextShape = true; break; - } - - if (isImage || isShape || isChart) { - isImage = isShape = isChart = false; - let has_chartprops = false; - let selectedObjects = Common.EditorApi.get().asc_getGraphicObjectProps(); - - for (let i = 0; i < selectedObjects.length; i++) { - if (selectedObjects[i].asc_getObjectType() == Asc.c_oAscTypeSelectElement.Image) { - const elValue = selectedObjects[i].asc_getObjectValue(); - isObjLocked = isObjLocked || elValue.asc_getLocked(); - const shapeProps = elValue.asc_getShapeProperties(); - - if (shapeProps) { - if (shapeProps.asc_getFromChart()) { - isChart = true; - } else { - isShape = true; - - } - } else if (elValue.asc_getChartProperties()) { - isChart = true; - has_chartprops = true; - } else { - isImage = true; - } - } - } - } else if (isTextShape || isTextChart) { - const selectedObjects = Common.EditorApi.get().asc_getGraphicObjectProps(); - let isEquation = false; - - for (var i = 0; i < selectedObjects.length; i++) { - const elType = selectedObjects[i].asc_getObjectType(); - if (elType == Asc.c_oAscTypeSelectElement.Image) { - const value = selectedObjects[i].asc_getObjectValue(); - isObjLocked = isObjLocked || value.asc_getLocked(); - } else if (elType == Asc.c_oAscTypeSelectElement.Paragraph) { - } else if (elType == Asc.c_oAscTypeSelectElement.Math) { - isEquation = true; - } - } - } - if (isChart || isTextChart) { - _selections.push('chart'); - - if (isTextChart) { - _selections.push('text'); - } - } else if ((isShape || isTextShape) && !isImage) { - _selections.push('shape'); - - if (isTextShape) { - _selections.push('text'); - } - } else if (isImage) { - _selections.push('image'); - - if (isShape) { - _selections.push('shape'); - } - } else { - _selections.push('cell'); - - if (this._cellInfo.asc_getHyperlink()) { - _selections.push('hyperlink'); - } - } - return _selections; + return !!this.intf ? this.intf.getSelections() : null; } get shapeObject() { - const shapes = []; - for (let object of this._focusObjects) { - if (object.get_ObjectType() === Asc.c_oAscTypeSelectElement.Image) { - if (object.get_ObjectValue() && object.get_ObjectValue().get_ShapeProperties()) { - shapes.push(object); - } - } - } - if (shapes.length > 0) { - const object = shapes[shapes.length - 1]; // get top - return object.get_ObjectValue(); - } else { - return undefined; - } + return !!this.intf ? this.intf.getShapeObject() : null; } get imageObject() { - const images = []; - for (let object of this._focusObjects) { - if (object.get_ObjectType() === Asc.c_oAscTypeSelectElement.Image) { - images.push(object); - } - } - if (images.length > 0) { - const object = images[images.length - 1]; // get top - return object.get_ObjectValue(); - } else { - return undefined; - } + return !!this.intf ? this.intf.getImageObject() : null; } get chartObject() { - const charts = []; - for (let object of this._focusObjects) { - if (object.get_ObjectType() === Asc.c_oAscTypeSelectElement.Image) { - if (object.get_ObjectValue() && object.get_ObjectValue().get_ChartProperties()) { - charts.push(object); - } - } - } - if (charts.length > 0) { - const object = charts[charts.length - 1]; // get top - return object.get_ObjectValue(); - } else { - return undefined; - } + return !!this.intf ? this.intf.getChartObject() : null; } } \ No newline at end of file