From dc93c8878be17e9b3399c2400c37d8130164632b Mon Sep 17 00:00:00 2001 From: Dmitry-Ilyushechkin Date: Fri, 14 Feb 2025 13:30:04 +0300 Subject: [PATCH 1/3] fix bug 59516 --- apps/common/main/lib/component/MenuItem.js | 12 ++++--- apps/common/main/resources/less/toolbar.less | 5 +++ .../main/app/controller/DocumentHolderExt.js | 34 ++++++++++++++----- apps/spreadsheeteditor/main/locale/en.json | 3 ++ 4 files changed, 42 insertions(+), 12 deletions(-) diff --git a/apps/common/main/lib/component/MenuItem.js b/apps/common/main/lib/component/MenuItem.js index e60fff8d29..224a1f6fab 100644 --- a/apps/common/main/lib/component/MenuItem.js +++ b/apps/common/main/lib/component/MenuItem.js @@ -106,20 +106,22 @@ define([ dataHintDirection: '', dataHintOffset: '', dataHintTitle: '', - scaling: true + scaling: true, + header : '' }, tagName : 'li', template: _.template([ - ' data-no-icon <% } %> style="<%= style %>" <% if(options.canFocused) { %> tabindex="-1" type="menuitem" <% }; if(!_.isUndefined(options.stopPropagation)) { %> data-stopPropagation="true" <% }; if(!_.isUndefined(options.dataHint)) { %> data-hint="<%= options.dataHint %>" <% }; if(!_.isUndefined(options.dataHintDirection)) { %> data-hint-direction="<%= options.dataHintDirection %>" <% }; if(!_.isUndefined(options.dataHintOffset)) { %> data-hint-offset="<%= options.dataHintOffset %>" <% }; if(options.dataHintTitle) { %> data-hint-title="<%= options.dataHintTitle %>" <% }; %> >', + '<% if (header) { %> <%- header %> <% } %> <% if (caption) { %> data-no-icon <% } %> style="<%= style %>" <% if(options.canFocused) { %> tabindex="-1" type="menuitem" <% }; if(!_.isUndefined(options.stopPropagation)) { %> data-stopPropagation="true" <% }; if(!_.isUndefined(options.dataHint)) { %> data-hint="<%= options.dataHint %>" <% }; if(!_.isUndefined(options.dataHintDirection)) { %> data-hint-direction="<%= options.dataHintDirection %>" <% }; if(!_.isUndefined(options.dataHintOffset)) { %> data-hint-offset="<%= options.dataHintOffset %>" <% }; if(options.dataHintTitle) { %> data-hint-title="<%= options.dataHintTitle %>" <% }; %> >', '<% if (!_.isEmpty(iconCls)) { %>', '', '<% } else if (!_.isEmpty(iconImg)) { %>', '', '<% } %>', '<%- caption %>', - '' + '', + '<% } %>' ].join('')), initialize : function(options) { @@ -144,6 +146,7 @@ define([ this.iconImg = me.options.iconImg; this.hint = me.options.hint; this.rendered = false; + this.header = me.options.header; if (this.menu !== null && !(this.menu instanceof Common.UI.Menu) && !(this.menu instanceof Common.UI.MenuSimple)) { this.menu = new Common.UI.Menu(_.extend({}, me.options.menu)); @@ -173,7 +176,8 @@ define([ iconCls : me.iconCls, iconImg : me.iconImg, style : me.style, - options : me.options + options : me.options, + header : me.header })); if (me.menu) { diff --git a/apps/common/main/resources/less/toolbar.less b/apps/common/main/resources/less/toolbar.less index ece052d16c..5f3397c3ce 100644 --- a/apps/common/main/resources/less/toolbar.less +++ b/apps/common/main/resources/less/toolbar.less @@ -1146,6 +1146,11 @@ section .field-styles { align-items: center; } } + .menu-header { + font-weight: bold; + cursor: default; + padding: 5px 20px; + } } .background-plugins { diff --git a/apps/spreadsheeteditor/main/app/controller/DocumentHolderExt.js b/apps/spreadsheeteditor/main/app/controller/DocumentHolderExt.js index 0c274147f4..4db5368d33 100644 --- a/apps/spreadsheeteditor/main/app/controller/DocumentHolderExt.js +++ b/apps/spreadsheeteditor/main/app/controller/DocumentHolderExt.js @@ -3346,7 +3346,12 @@ define([], function () { } var importText; + _.each(pasteItems, function(menuItem, index) { + if (menuItem === Asc.c_oSpecialPasteProps.paste) { + return; + } + if (menuItem == Asc.c_oSpecialPasteProps.useTextImport) { importText = new Common.UI.MenuItem({ caption: me._arrSpecialPaste[menuItem][0] + (me.hkSpecPaste[menuItem] ? ' (' + me.hkSpecPaste[menuItem] + ')' : ''), @@ -3366,16 +3371,29 @@ define([], function () { me._arrSpecialPaste[menuItem][2] = mnu; } }); - var newgroup = false; + var groupTitles = [me.txtFormula, me.txtValue, me.txtOther]; + + menu.addItem(new Common.UI.MenuItem({ + caption: me.txtPaste + ' (P)', + value: 'paste', + checkable: true, + toggleGroup: 'specialPasteGroup' + }).on('click', _.bind(me.onSpecialPasteItemClick, me))); + for (var i = 0; i < 3; i++) { - if (newgroup && groups[i].length>0) { - menu.addItem(new Common.UI.MenuItem({ caption: '--' })); - newgroup = false; + if (groups[i].length > 0) { + if (menu.items.length > 0) { + menu.addItem(new Common.UI.MenuItem({ caption: '--' })); + } + menu.addItem(new Common.UI.MenuItem({ + header: groupTitles[i], + disabled: true, + cls: 'menu-header' + })); + _.each(groups[i], function (menuItem, index) { + menu.addItem(menuItem); + }); } - _.each(groups[i], function(menuItem, index) { - menu.addItem(menuItem); - newgroup = true; - }); } (menu.items.length>0) && menu.items[0].setChecked(true, true); me._state.lastSpecPasteChecked = (menu.items.length>0) ? menu.items[0] : null; diff --git a/apps/spreadsheeteditor/main/locale/en.json b/apps/spreadsheeteditor/main/locale/en.json index d264b054e2..27f76cc93a 100644 --- a/apps/spreadsheeteditor/main/locale/en.json +++ b/apps/spreadsheeteditor/main/locale/en.json @@ -962,6 +962,9 @@ "SSE.Controllers.DocumentHolder.txtWarnUrl": "Clicking this link can be harmful to your device and data.
Are you sure you want to continue?", "SSE.Controllers.DocumentHolder.txtWidth": "Width", "SSE.Controllers.DocumentHolder.warnFilterError": "You need at least one field in the Values area in order to apply a value filter.", + "SSE.Controllers.DocumentHolder.txtFormula": "Formula", + "SSE.Controllers.DocumentHolder.txtValue": "Value", + "SSE.Controllers.DocumentHolder.txtOther": "Other", "SSE.Controllers.FormulaDialog.sCategoryAll": "All", "SSE.Controllers.FormulaDialog.sCategoryCube": "Cube", "SSE.Controllers.FormulaDialog.sCategoryCustom": "Custom", From b193ce8adf92c396e5f99376dc67ee61401d7de6 Mon Sep 17 00:00:00 2001 From: Dmitry-Ilyushechkin Date: Mon, 24 Feb 2025 17:06:35 +0300 Subject: [PATCH 2/3] fix special paste --- .../main/app/controller/DocumentHolderExt.js | 31 ++++++++++--------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/DocumentHolderExt.js b/apps/spreadsheeteditor/main/app/controller/DocumentHolderExt.js index 4db5368d33..7793fdd3df 100644 --- a/apps/spreadsheeteditor/main/app/controller/DocumentHolderExt.js +++ b/apps/spreadsheeteditor/main/app/controller/DocumentHolderExt.js @@ -3308,12 +3308,12 @@ define([], function () { me._arrSpecialPaste[Asc.c_oSpecialPasteProps.formulaWithoutBorders] = [me.txtPasteBorders, 0]; me._arrSpecialPaste[Asc.c_oSpecialPasteProps.formulaColumnWidth] = [me.txtPasteColWidths, 0]; me._arrSpecialPaste[Asc.c_oSpecialPasteProps.mergeConditionalFormating] = [me.txtPasteMerge, 0]; - me._arrSpecialPaste[Asc.c_oSpecialPasteProps.transpose] = [me.txtPasteTranspose, 0]; me._arrSpecialPaste[Asc.c_oSpecialPasteProps.pasteOnlyValues] = [me.txtPasteValues, 1]; me._arrSpecialPaste[Asc.c_oSpecialPasteProps.valueNumberFormat] = [me.txtPasteValNumFormat, 1]; me._arrSpecialPaste[Asc.c_oSpecialPasteProps.valueAllFormating] = [me.txtPasteValFormat, 1]; me._arrSpecialPaste[Asc.c_oSpecialPasteProps.pasteOnlyFormating] = [me.txtPasteFormat, 2]; me._arrSpecialPaste[Asc.c_oSpecialPasteProps.link] = [me.txtPasteLink, 2]; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.transpose] = [me.txtPasteTranspose, 2]; me._arrSpecialPaste[Asc.c_oSpecialPasteProps.picture] = [me.txtPastePicture, 2]; me._arrSpecialPaste[Asc.c_oSpecialPasteProps.linkedPicture] = [me.txtPasteLinkPicture, 2]; me._arrSpecialPaste[Asc.c_oSpecialPasteProps.sourceformatting] = [me.txtPasteSourceFormat, 2]; @@ -3345,14 +3345,18 @@ define([], function () { groups[i] = []; } - var importText; + var importText, pasteItem; _.each(pasteItems, function(menuItem, index) { - if (menuItem === Asc.c_oSpecialPasteProps.paste) { - return; - } - - if (menuItem == Asc.c_oSpecialPasteProps.useTextImport) { + if (menuItem == Asc.c_oSpecialPasteProps.paste) { + pasteItem = new Common.UI.MenuItem({ + caption: me._arrSpecialPaste[menuItem][0] + (me.hkSpecPaste[menuItem] ? ' (' + me.hkSpecPaste[menuItem] + ')' : ''), + value: menuItem, + checkable: true, + toggleGroup: 'specialPasteGroup' + }).on('click', _.bind(me.onSpecialPasteItemClick, me)); + me._arrSpecialPaste[menuItem][2] = pasteItem; + } else if (menuItem == Asc.c_oSpecialPasteProps.useTextImport) { importText = new Common.UI.MenuItem({ caption: me._arrSpecialPaste[menuItem][0] + (me.hkSpecPaste[menuItem] ? ' (' + me.hkSpecPaste[menuItem] + ')' : ''), value: menuItem, @@ -3372,14 +3376,11 @@ define([], function () { } }); var groupTitles = [me.txtFormula, me.txtValue, me.txtOther]; - - menu.addItem(new Common.UI.MenuItem({ - caption: me.txtPaste + ' (P)', - value: 'paste', - checkable: true, - toggleGroup: 'specialPasteGroup' - }).on('click', _.bind(me.onSpecialPasteItemClick, me))); - + + if (pasteItem) { + menu.addItem(pasteItem); + } + for (var i = 0; i < 3; i++) { if (groups[i].length > 0) { if (menu.items.length > 0) { From 1e70b335f09df9520c87d26d4f9c498c2dfc98eb Mon Sep 17 00:00:00 2001 From: Dmitry-Ilyushechkin Date: Mon, 24 Feb 2025 18:35:18 +0300 Subject: [PATCH 3/3] code reduction --- .../main/app/controller/DocumentHolderExt.js | 30 +++++++------------ 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/DocumentHolderExt.js b/apps/spreadsheeteditor/main/app/controller/DocumentHolderExt.js index 7793fdd3df..1afc2c2d10 100644 --- a/apps/spreadsheeteditor/main/app/controller/DocumentHolderExt.js +++ b/apps/spreadsheeteditor/main/app/controller/DocumentHolderExt.js @@ -3348,30 +3348,22 @@ define([], function () { var importText, pasteItem; _.each(pasteItems, function(menuItem, index) { - if (menuItem == Asc.c_oSpecialPasteProps.paste) { - pasteItem = new Common.UI.MenuItem({ + if (me._arrSpecialPaste[menuItem]) { + var mnu = new Common.UI.MenuItem({ caption: me._arrSpecialPaste[menuItem][0] + (me.hkSpecPaste[menuItem] ? ' (' + me.hkSpecPaste[menuItem] + ')' : ''), value: menuItem, checkable: true, toggleGroup: 'specialPasteGroup' }).on('click', _.bind(me.onSpecialPasteItemClick, me)); - me._arrSpecialPaste[menuItem][2] = pasteItem; - } else if (menuItem == Asc.c_oSpecialPasteProps.useTextImport) { - importText = new Common.UI.MenuItem({ - caption: me._arrSpecialPaste[menuItem][0] + (me.hkSpecPaste[menuItem] ? ' (' + me.hkSpecPaste[menuItem] + ')' : ''), - value: menuItem, - checkable: true, - toggleGroup : 'specialPasteGroup' - }).on('click', _.bind(me.onSpecialPasteItemClick, me)); - me._arrSpecialPaste[menuItem][2] = importText; - } else if (me._arrSpecialPaste[menuItem]) { - var mnu = new Common.UI.MenuItem({ - caption: me._arrSpecialPaste[menuItem][0] + (me.hkSpecPaste[menuItem] ? ' (' + me.hkSpecPaste[menuItem] + ')' : ''), - value: menuItem, - checkable: true, - toggleGroup : 'specialPasteGroup' - }).on('click', _.bind(me.onSpecialPasteItemClick, me)); - groups[me._arrSpecialPaste[menuItem][1]].push(mnu); + + if (menuItem == Asc.c_oSpecialPasteProps.paste) { + pasteItem = mnu; + } else if (menuItem == Asc.c_oSpecialPasteProps.useTextImport) { + importText = mnu; + } else { + groups[me._arrSpecialPaste[menuItem][1]].push(mnu); + } + me._arrSpecialPaste[menuItem][2] = mnu; } });