From 0f883b3c4ea6a613b4db847cf2818eae2fcd0a03 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Thu, 12 May 2022 22:06:23 +0300 Subject: [PATCH] [SSE] Draw custom bullents in context menu --- .../main/app/controller/Toolbar.js | 3 +- .../main/app/controller/DocumentHolder.js | 71 +++++++++++++++++-- .../main/app/view/DocumentHolder.js | 40 +++++++---- 3 files changed, 90 insertions(+), 24 deletions(-) diff --git a/apps/presentationeditor/main/app/controller/Toolbar.js b/apps/presentationeditor/main/app/controller/Toolbar.js index b97d66568..b59c6d254 100644 --- a/apps/presentationeditor/main/app/controller/Toolbar.js +++ b/apps/presentationeditor/main/app/controller/Toolbar.js @@ -519,8 +519,7 @@ define([ if (this._state.bullets.subtype!==0x1000) idx = this._state.bullets.subtype; else { // custom - var me = this, - bullet = v.asc_getListCustom(); + var bullet = v.asc_getListCustom(); if (bullet) { var type = bullet.asc_getType(); if (type == Asc.asc_PreviewBulletType.char) { diff --git a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js index e64eca38d..ff5dd4956 100644 --- a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js +++ b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js @@ -233,7 +233,7 @@ define([ view.menuParagraphVAlign.menu.on('item:click', _.bind(me.onParagraphVAlign, me)); view.menuParagraphDirection.menu.on('item:click', _.bind(me.onParagraphDirection, me)); view.menuParagraphBullets.menu.on('item:click', _.bind(me.onSelectBulletMenu, me)); - view.menuParagraphBullets.menu.on('render:after', _.bind(me.onBulletMenuShowAfter, me)); + // view.menuParagraphBullets.menu.on('render:after', _.bind(me.onBulletMenuShowAfter, me)); view.menuParagraphBullets.menu.on('show:after', _.bind(me.onBulletMenuShowAfter, me)); view.menuAddHyperlinkShape.on('click', _.bind(me.onInsHyperlink, me)); view.menuEditHyperlinkShape.on('click', _.bind(me.onInsHyperlink, me)); @@ -947,7 +947,25 @@ define([ rawData = record; } - if (this.api) + if (rawData.type===0 && rawData.subtype===0x1000) {// custom bullet + var bullet = new Asc.asc_CBullet(); + if (rawData.drawdata.type===Asc.asc_PreviewBulletType.char) { + bullet.asc_putSymbol(rawData.drawdata.char); + bullet.asc_putFont(rawData.drawdata.specialFont); + } else if (rawData.drawdata.type===Asc.asc_PreviewBulletType.image) + bullet.asc_fillBulletImage(rawData.drawdata.imageId); + + var props; + var selectedObjects = this.api.asc_getGraphicObjectProps(); + for (var i = 0; i < selectedObjects.length; i++) { + if (selectedObjects[i].asc_getObjectType() == Asc.c_oAscTypeSelectElement.Paragraph) { + props = selectedObjects[i].asc_getObjectValue(); + props.asc_putBullet(bullet); + this.api.asc_setGraphicObjectProps(props); + break; + } + } + } else this.api.asc_setListType(rawData.type, rawData.subtype); if (e.type !== 'click') @@ -2107,9 +2125,45 @@ define([ documentHolder.menuParagraphDirect270.setChecked(direct == Asc.c_oAscVertDrawingText.vert270); documentHolder.menuParagraphBulletNone.setChecked(listtype.get_ListType() == -1); - // documentHolder.mnuListSettings.setDisabled(listtype.get_ListType() == -1); - var rec = documentHolder.paraBulletsPicker.store.findWhere({ type: listtype.get_ListType(), subtype: listtype.get_ListSubType() }); + var type = listtype.get_ListType(), + subtype = listtype.get_ListSubType(), + rec, + defrec = documentHolder.paraBulletsPicker.store.at(7), + drawDefBullet = (defrec.get('subtype')===0x1000) && (type===1 || subtype!==0x1000); + if (type===1 || subtype!==0x1000) { + rec = documentHolder.paraBulletsPicker.store.findWhere({ type: type, subtype: subtype }); + } else { + var bullet = listtype.asc_getListCustom(); + if (bullet) { + var bullettype = bullet.asc_getType(); + if (bullettype === Asc.asc_PreviewBulletType.char) { + var symbol = bullet.asc_getChar(); + if (symbol) { + rec = defrec; + rec.set('subtype', 0x1000); + rec.set('tip', ''); + rec.set('drawdata', {type: bullettype, char: symbol, specialFont: bullet.asc_getSpecialFont()}); + drawDefBullet = false; + + } + } else if (bullettype === Asc.asc_PreviewBulletType.image) { + var id = bullet.asc_getImageId(); + if (id) { + rec = defrec; + rec.set('subtype', 0x1000); + rec.set('tip', ''); + rec.set('drawdata', {type: bullettype, imageId: id}); + drawDefBullet = false; + } + } + } + } documentHolder.paraBulletsPicker.selectRecord(rec, true); + if (drawDefBullet) { + defrec.set('subtype', 8); + defrec.set('tip', documentHolder.tipMarkersDash); + defrec.set('drawdata', documentHolder._markersArr[7]); + } } else if (elType == Asc.c_oAscTypeSelectElement.Paragraph) { documentHolder.pmiTextAdvanced.textInfo = selectedObjects[i].asc_getObjectValue(); isObjLocked = isObjLocked || documentHolder.pmiTextAdvanced.textInfo.asc_getLocked(); @@ -3759,11 +3813,14 @@ define([ var store = this.documentHolder.paraBulletsPicker.store; var arrNum = [], arrMarker = []; store.each(function(item){ - if (item.get('group')=='menu-list-bullet-group') - arrMarker.push(item.get('id')); + var data = item.get('drawdata'); + data['divId'] = item.get('id'); + if (item.get('group')==='menu-list-bullet-group') + arrMarker.push(data); else - arrNum.push(item.get('id')); + arrNum.push(data); }); + if (this.api && this.api.SetDrawImagePreviewBulletForMenu) { this.api.SetDrawImagePreviewBulletForMenu(arrMarker, 0); this.api.SetDrawImagePreviewBulletForMenu(arrNum, 1); diff --git a/apps/spreadsheeteditor/main/app/view/DocumentHolder.js b/apps/spreadsheeteditor/main/app/view/DocumentHolder.js index 159f2d452..bcf77715e 100644 --- a/apps/spreadsheeteditor/main/app/view/DocumentHolder.js +++ b/apps/spreadsheeteditor/main/app/view/DocumentHolder.js @@ -966,25 +966,35 @@ define([ }) }); + me._markersArr = [ + {type: Asc.asc_PreviewBulletType.char, char: String.fromCharCode(0x00B7), specialFont: 'Symbol'}, + {type: Asc.asc_PreviewBulletType.char, char: 'o', specialFont: 'Courier New'}, + {type: Asc.asc_PreviewBulletType.char, char: String.fromCharCode(0x00A7), specialFont: 'Wingdings'}, + {type: Asc.asc_PreviewBulletType.char, char: String.fromCharCode(0x0076), specialFont: 'Wingdings'}, + {type: Asc.asc_PreviewBulletType.char, char: String.fromCharCode(0x00D8), specialFont: 'Wingdings'}, + {type: Asc.asc_PreviewBulletType.char, char: String.fromCharCode(0x00FC), specialFont: 'Wingdings'}, + {type: Asc.asc_PreviewBulletType.char, char: String.fromCharCode(0x00A8), specialFont: 'Symbol'}, + {type: Asc.asc_PreviewBulletType.char, char: String.fromCharCode(0x2013), specialFont: 'Arial'} + ]; me.paraBulletsPicker = { conf: {rec: null}, delayRenderTips: true, store : new Common.UI.DataViewStore([ - {group: 'menu-list-bullet-group', id: 'id-markers-' + Common.UI.getId(), type: 0, subtype: 1, skipRenderOnChange: true, tip: this.tipMarkersFRound}, - {group: 'menu-list-bullet-group', id: 'id-markers-' + Common.UI.getId(), type: 0, subtype: 2, skipRenderOnChange: true, tip: this.tipMarkersHRound}, - {group: 'menu-list-bullet-group', id: 'id-markers-' + Common.UI.getId(), type: 0, subtype: 3, skipRenderOnChange: true, tip: this.tipMarkersFSquare}, - {group: 'menu-list-bullet-group', id: 'id-markers-' + Common.UI.getId(), type: 0, subtype: 4, skipRenderOnChange: true, tip: this.tipMarkersStar}, - {group: 'menu-list-bullet-group', id: 'id-markers-' + Common.UI.getId(), type: 0, subtype: 5, skipRenderOnChange: true, tip: this.tipMarkersArrow}, - {group: 'menu-list-bullet-group', id: 'id-markers-' + Common.UI.getId(), type: 0, subtype: 6, skipRenderOnChange: true, tip: this.tipMarkersCheckmark}, - {group: 'menu-list-bullet-group', id: 'id-markers-' + Common.UI.getId(), type: 0, subtype: 7, skipRenderOnChange: true, tip: this.tipMarkersFRhombus}, - {group: 'menu-list-bullet-group', id: 'id-markers-' + Common.UI.getId(), type: 0, subtype: 8, skipRenderOnChange: true, tip: this.tipMarkersDash}, - {group: 'menu-list-number-group', id: 'id-numbers-' + Common.UI.getId(), type: 1, subtype: 4, skipRenderOnChange: true, tip: this.tipNumCapitalLetters}, - {group: 'menu-list-number-group', id: 'id-numbers-' + Common.UI.getId(), type: 1, subtype: 5, skipRenderOnChange: true, tip: this.tipNumLettersParentheses}, - {group: 'menu-list-number-group', id: 'id-numbers-' + Common.UI.getId(), type: 1, subtype: 6, skipRenderOnChange: true, tip: this.tipNumLettersPoints}, - {group: 'menu-list-number-group', id: 'id-numbers-' + Common.UI.getId(), type: 1, subtype: 1, skipRenderOnChange: true, tip: this.tipNumNumbersPoint}, - {group: 'menu-list-number-group', id: 'id-numbers-' + Common.UI.getId(), type: 1, subtype: 2, skipRenderOnChange: true, tip: this.tipNumNumbersParentheses}, - {group: 'menu-list-number-group', id: 'id-numbers-' + Common.UI.getId(), type: 1, subtype: 3, skipRenderOnChange: true, tip: this.tipNumRoman}, - {group: 'menu-list-number-group', id: 'id-numbers-' + Common.UI.getId(), type: 1, subtype: 7, skipRenderOnChange: true, tip: this.tipNumRomanSmall} + {group: 'menu-list-bullet-group', id: 'id-markers-' + Common.UI.getId(), type: 0, subtype: 1, drawdata: me._markersArr[0], skipRenderOnChange: true, tip: this.tipMarkersFRound}, + {group: 'menu-list-bullet-group', id: 'id-markers-' + Common.UI.getId(), type: 0, subtype: 2, drawdata: me._markersArr[1], skipRenderOnChange: true, tip: this.tipMarkersHRound}, + {group: 'menu-list-bullet-group', id: 'id-markers-' + Common.UI.getId(), type: 0, subtype: 3, drawdata: me._markersArr[2], skipRenderOnChange: true, tip: this.tipMarkersFSquare}, + {group: 'menu-list-bullet-group', id: 'id-markers-' + Common.UI.getId(), type: 0, subtype: 4, drawdata: me._markersArr[3], skipRenderOnChange: true, tip: this.tipMarkersStar}, + {group: 'menu-list-bullet-group', id: 'id-markers-' + Common.UI.getId(), type: 0, subtype: 5, drawdata: me._markersArr[4], skipRenderOnChange: true, tip: this.tipMarkersArrow}, + {group: 'menu-list-bullet-group', id: 'id-markers-' + Common.UI.getId(), type: 0, subtype: 6, drawdata: me._markersArr[5], skipRenderOnChange: true, tip: this.tipMarkersCheckmark}, + {group: 'menu-list-bullet-group', id: 'id-markers-' + Common.UI.getId(), type: 0, subtype: 7, drawdata: me._markersArr[6], skipRenderOnChange: true, tip: this.tipMarkersFRhombus}, + {group: 'menu-list-bullet-group', id: 'id-markers-' + Common.UI.getId(), type: 0, subtype: 8, drawdata: me._markersArr[7], skipRenderOnChange: true, tip: this.tipMarkersDash}, + {group: 'menu-list-number-group', id: 'id-numbers-' + Common.UI.getId(), type: 1, subtype: 4, drawdata: {type: Asc.asc_PreviewBulletType.number, numberingType: Asc.asc_oAscNumberingLevel.UpperLetterDot_Left}, skipRenderOnChange: true, tip: this.tipNumCapitalLetters}, + {group: 'menu-list-number-group', id: 'id-numbers-' + Common.UI.getId(), type: 1, subtype: 5, drawdata: {type: Asc.asc_PreviewBulletType.number, numberingType: Asc.asc_oAscNumberingLevel.LowerLetterBracket_Left}, skipRenderOnChange: true, tip: this.tipNumLettersParentheses}, + {group: 'menu-list-number-group', id: 'id-numbers-' + Common.UI.getId(), type: 1, subtype: 6, drawdata: {type: Asc.asc_PreviewBulletType.number, numberingType: Asc.asc_oAscNumberingLevel.LowerLetterDot_Left}, skipRenderOnChange: true, tip: this.tipNumLettersPoints}, + {group: 'menu-list-number-group', id: 'id-numbers-' + Common.UI.getId(), type: 1, subtype: 1, drawdata: {type: Asc.asc_PreviewBulletType.number, numberingType: Asc.asc_oAscNumberingLevel.DecimalDot_Right}, skipRenderOnChange: true, tip: this.tipNumNumbersPoint}, + {group: 'menu-list-number-group', id: 'id-numbers-' + Common.UI.getId(), type: 1, subtype: 2, drawdata: {type: Asc.asc_PreviewBulletType.number, numberingType: Asc.asc_oAscNumberingLevel.DecimalBracket_Right}, skipRenderOnChange: true, tip: this.tipNumNumbersParentheses}, + {group: 'menu-list-number-group', id: 'id-numbers-' + Common.UI.getId(), type: 1, subtype: 3, drawdata: {type: Asc.asc_PreviewBulletType.number, numberingType: Asc.asc_oAscNumberingLevel.UpperRomanDot_Right}, skipRenderOnChange: true, tip: this.tipNumRoman}, + {group: 'menu-list-number-group', id: 'id-numbers-' + Common.UI.getId(), type: 1, subtype: 7, drawdata: {type: Asc.asc_PreviewBulletType.number, numberingType: Asc.asc_oAscNumberingLevel.LowerRomanDot_Right}, skipRenderOnChange: true, tip: this.tipNumRomanSmall} ]), groups: new Common.UI.DataViewGroupStore([ {id: 'menu-list-bullet-group', caption: this.textBullets},