[SSE] Draw custom bullents in context menu

This commit is contained in:
Julia Radzhabova 2022-05-12 22:06:23 +03:00
parent affb23683a
commit 0f883b3c4e
3 changed files with 90 additions and 24 deletions

View file

@ -519,8 +519,7 @@ define([
if (this._state.bullets.subtype!==0x1000) if (this._state.bullets.subtype!==0x1000)
idx = this._state.bullets.subtype; idx = this._state.bullets.subtype;
else { // custom else { // custom
var me = this, var bullet = v.asc_getListCustom();
bullet = v.asc_getListCustom();
if (bullet) { if (bullet) {
var type = bullet.asc_getType(); var type = bullet.asc_getType();
if (type == Asc.asc_PreviewBulletType.char) { if (type == Asc.asc_PreviewBulletType.char) {

View file

@ -233,7 +233,7 @@ define([
view.menuParagraphVAlign.menu.on('item:click', _.bind(me.onParagraphVAlign, me)); view.menuParagraphVAlign.menu.on('item:click', _.bind(me.onParagraphVAlign, me));
view.menuParagraphDirection.menu.on('item:click', _.bind(me.onParagraphDirection, 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('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.menuParagraphBullets.menu.on('show:after', _.bind(me.onBulletMenuShowAfter, me));
view.menuAddHyperlinkShape.on('click', _.bind(me.onInsHyperlink, me)); view.menuAddHyperlinkShape.on('click', _.bind(me.onInsHyperlink, me));
view.menuEditHyperlinkShape.on('click', _.bind(me.onInsHyperlink, me)); view.menuEditHyperlinkShape.on('click', _.bind(me.onInsHyperlink, me));
@ -947,7 +947,25 @@ define([
rawData = record; 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); this.api.asc_setListType(rawData.type, rawData.subtype);
if (e.type !== 'click') if (e.type !== 'click')
@ -2107,9 +2125,45 @@ define([
documentHolder.menuParagraphDirect270.setChecked(direct == Asc.c_oAscVertDrawingText.vert270); documentHolder.menuParagraphDirect270.setChecked(direct == Asc.c_oAscVertDrawingText.vert270);
documentHolder.menuParagraphBulletNone.setChecked(listtype.get_ListType() == -1); documentHolder.menuParagraphBulletNone.setChecked(listtype.get_ListType() == -1);
// documentHolder.mnuListSettings.setDisabled(listtype.get_ListType() == -1); var type = listtype.get_ListType(),
var rec = documentHolder.paraBulletsPicker.store.findWhere({ type: listtype.get_ListType(), subtype: listtype.get_ListSubType() }); 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); 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) { } else if (elType == Asc.c_oAscTypeSelectElement.Paragraph) {
documentHolder.pmiTextAdvanced.textInfo = selectedObjects[i].asc_getObjectValue(); documentHolder.pmiTextAdvanced.textInfo = selectedObjects[i].asc_getObjectValue();
isObjLocked = isObjLocked || documentHolder.pmiTextAdvanced.textInfo.asc_getLocked(); isObjLocked = isObjLocked || documentHolder.pmiTextAdvanced.textInfo.asc_getLocked();
@ -3759,11 +3813,14 @@ define([
var store = this.documentHolder.paraBulletsPicker.store; var store = this.documentHolder.paraBulletsPicker.store;
var arrNum = [], arrMarker = []; var arrNum = [], arrMarker = [];
store.each(function(item){ store.each(function(item){
if (item.get('group')=='menu-list-bullet-group') var data = item.get('drawdata');
arrMarker.push(item.get('id')); data['divId'] = item.get('id');
if (item.get('group')==='menu-list-bullet-group')
arrMarker.push(data);
else else
arrNum.push(item.get('id')); arrNum.push(data);
}); });
if (this.api && this.api.SetDrawImagePreviewBulletForMenu) { if (this.api && this.api.SetDrawImagePreviewBulletForMenu) {
this.api.SetDrawImagePreviewBulletForMenu(arrMarker, 0); this.api.SetDrawImagePreviewBulletForMenu(arrMarker, 0);
this.api.SetDrawImagePreviewBulletForMenu(arrNum, 1); this.api.SetDrawImagePreviewBulletForMenu(arrNum, 1);

View file

@ -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 = { me.paraBulletsPicker = {
conf: {rec: null}, conf: {rec: null},
delayRenderTips: true, delayRenderTips: true,
store : new Common.UI.DataViewStore([ 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: 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, skipRenderOnChange: true, tip: this.tipMarkersHRound}, {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, skipRenderOnChange: true, tip: this.tipMarkersFSquare}, {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, skipRenderOnChange: true, tip: this.tipMarkersStar}, {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, skipRenderOnChange: true, tip: this.tipMarkersArrow}, {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, skipRenderOnChange: true, tip: this.tipMarkersCheckmark}, {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, skipRenderOnChange: true, tip: this.tipMarkersFRhombus}, {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, skipRenderOnChange: true, tip: this.tipMarkersDash}, {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, skipRenderOnChange: true, tip: this.tipNumCapitalLetters}, {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, skipRenderOnChange: true, tip: this.tipNumLettersParentheses}, {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, skipRenderOnChange: true, tip: this.tipNumLettersPoints}, {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, skipRenderOnChange: true, tip: this.tipNumNumbersPoint}, {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, skipRenderOnChange: true, tip: this.tipNumNumbersParentheses}, {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, skipRenderOnChange: true, tip: this.tipNumRoman}, {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, skipRenderOnChange: true, tip: this.tipNumRomanSmall} {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([ groups: new Common.UI.DataViewGroupStore([
{id: 'menu-list-bullet-group', caption: this.textBullets}, {id: 'menu-list-bullet-group', caption: this.textBullets},