From 6b50bfd01cbd5021972649ec8037bd1005651674 Mon Sep 17 00:00:00 2001 From: nikita_bartoshuk Date: Tue, 3 Feb 2026 12:12:40 +0300 Subject: [PATCH] base sources --- .../main/app/controller/Toolbar.js | 170 ++++++++++++++++++ .../main/app/template/Toolbar.template | 1 + .../main/app/view/Toolbar.js | 16 +- apps/spreadsheeteditor/main/locale/en.json | 26 +++ 4 files changed, 212 insertions(+), 1 deletion(-) diff --git a/apps/spreadsheeteditor/main/app/controller/Toolbar.js b/apps/spreadsheeteditor/main/app/controller/Toolbar.js index c67af1422e..ea816275f3 100644 --- a/apps/spreadsheeteditor/main/app/controller/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/controller/Toolbar.js @@ -438,6 +438,7 @@ define([ toolbar.btnWrap.on('click', _.bind(this.onWrap, this)); toolbar.btnTextOrient.menu.on('item:click', _.bind(this.onTextOrientationMenu, this)); toolbar.btnInsertTable.on('click', _.bind(this.onBtnInsertTableClick, this)); + toolbar.btnPasteOptions.on('click', _.bind(this.onBtnPasteOptionsClick, this)); toolbar.btnInsertImage.menu.on('item:click', _.bind(this.onInsertImageMenu, this)); toolbar.btnInsertHyperlink.on('click', _.bind(this.onHyperlink, this)); toolbar.btnInsertText.on('click', _.bind(this.onBtnInsertTextClick, this)); @@ -1050,6 +1051,175 @@ define([ Common.component.Analytics.trackEvent('ToolBar', 'Table'); }, + onBtnPasteOptionsClick: function (btn, e) { + var me = this; + this.api.asc_getPasteOptions(function (options) { + me.handlePasteOptions(options) + }) + }, + + handlePasteOptions: function (options) { + var me = this; + var pasteItems = options.asc_getOptions(), + isTable = !!options.asc_getContainTables(); + console.log(options, 'OPTIONS') + if (!pasteItems) return; + + me._arrSpecialPaste = []; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.paste] = [me.txtPaste, 0]; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.pasteOnlyFormula] = [me.txtPasteFormulas, 0]; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.formulaNumberFormat] = [me.txtPasteFormulaNumFormat, 0]; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.formulaAllFormatting] = [me.txtPasteKeepSourceFormat, 0]; + 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.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]; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.destinationFormatting] = [me.txtPasteDestFormat, 2]; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.keepTextOnly] = [me.txtKeepTextOnly, 2]; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.useTextImport] = [me.txtUseTextImport, 3]; + + if (pasteItems.length>0) { + var menu = me.toolbar.btnPasteOptions.menu; + for (var i = 0; i < menu.items.length; i++) { + menu.removeItem(menu.items[i]); + i--; + } + + var groups = []; + for (var i = 0; i < 3; i++) { + groups[i] = []; + } + + var importText, pasteItem; + + _.each(pasteItems, function(menuItem, index) { + if (me._arrSpecialPaste[menuItem]) { + var mnu = new Common.UI.MenuItem({ + caption: me._arrSpecialPaste[menuItem][0], + value: menuItem, + checkable: true, + toggleGroup: 'specialPasteGroup' + }).on('click', _.bind(me.onSpecialPasteItemClick, me)); + + 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; + } + }); + var groupTitles = [me.txtFormula, me.txtValue, me.txtOther]; + + if (pasteItem) { + menu.addItem(pasteItem); + } + + for (var i = 0; i < 3; i++) { + 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); + }); + } + } + + (menu.items.length>0) && menu.items[0].setChecked(true, true); + me._state.lastSpecPasteChecked = (menu.items.length>0) ? menu.items[0] : null; + + if (importText) { + menu.addItem(new Common.UI.MenuItem({ caption: '--' })); + menu.addItem(importText); + } + console.log(options.asc_getShowPasteSpecial(), 'SPECIAL') + if (menu.items.length>0 && options.asc_getShowPasteSpecial()) { + menu.addItem(new Common.UI.MenuItem({ caption: '--' })); + var mnu = new Common.UI.MenuItem({ + caption: me.textPasteSpecial, + value: 'special' + }).on('click', function(item, e) { + (new SSE.Views.SpecialPasteDialog({ + props: pasteItems, + isTable: isTable, + handler: function (result, settings) { + if (result == 'ok') { + me._state.lastSpecPasteChecked && me._state.lastSpecPasteChecked.setChecked(false, true); + me._state.lastSpecPasteChecked = settings && me._arrSpecialPaste[settings.asc_getProps()] ? me._arrSpecialPaste[settings.asc_getProps()][2] : null; + me._state.lastSpecPasteChecked && me._state.lastSpecPasteChecked.setChecked(true, true); + if (me && me.api) { + me.api.asc_SpecialPaste(settings); + } + } + } + })).show(); + setTimeout(function(){menu.hide();}, 100); + }); + menu.addItem(mnu); + } + } + }, + + onSpecialPasteItemClick: function (item, e) { + var me = this, + menu = this.toolbar.btnPasteOptions.menu; + if (item.value == Asc.c_oSpecialPasteProps.useTextImport) { + (new Common.Views.OpenDialog({ + title: me.txtImportWizard, + closable: true, + type: Common.Utils.importTextType.Paste, + preview: true, + api: me.api, + handler: function (result, settings) { + if (result == 'ok') { + if (me && me.api) { + var props = new Asc.SpecialPasteProps(); + props.asc_setProps(Asc.c_oSpecialPasteProps.useTextImport); + props.asc_setAdvancedOptions(settings.textOptions); + me.api.asc_SpecialPaste(props); + } + me._state.lastSpecPasteChecked = item; + } else if (item.cmpEl) { + item.setChecked(false, true); + // me._state.lastSpecPasteChecked && me._state.lastSpecPasteChecked.setChecked(true, true); + } + } + })).show(); + setTimeout(function(){menu.hide();}, 100); + } else { + me._state.lastSpecPasteChecked = item; + var props = new Asc.SpecialPasteProps(); + props.asc_setProps(item.value); + me.api.asc_SpecialPaste(props); + setTimeout(function(){menu.hide();}, 100); + } + if (!item.cmpEl && me._state.lastSpecPasteChecked) { + for (var i = 0; i < menu.items.length; i++) { + menu.items[i].setChecked(menu.items[i].value===me._state.lastSpecPasteChecked.value, true); + if (menu.items[i].value===me._state.lastSpecPasteChecked.value) + me._state.lastSpecPasteChecked = menu.items[i]; + } + } + return false; + }, + onInsertImageMenu: function(menu, item, e) { var me = this; if (item.value === 'file') { diff --git a/apps/spreadsheeteditor/main/app/template/Toolbar.template b/apps/spreadsheeteditor/main/app/template/Toolbar.template index 3a552dab98..0666c340f9 100644 --- a/apps/spreadsheeteditor/main/app/template/Toolbar.template +++ b/apps/spreadsheeteditor/main/app/template/Toolbar.template @@ -144,6 +144,7 @@
+
diff --git a/apps/spreadsheeteditor/main/app/view/Toolbar.js b/apps/spreadsheeteditor/main/app/view/Toolbar.js index 7076bc0f17..958b2d9010 100644 --- a/apps/spreadsheeteditor/main/app/view/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/view/Toolbar.js @@ -1554,6 +1554,18 @@ define([ dataHintOffset: 'small' }); + me.btnPasteOptions = new Common.UI.Button({ + id : 'tlbtn-inserttable', + cls : 'btn-toolbar x-huge icon-top', + iconCls : 'toolbar__icon btn-freeze-panes', + caption : me.capPasteOptions, + lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth, _set.ruleFilter, _set.multiselect, _set.cantModifyFilter, _set.ruleMerge, _set.editPivot, _set.wsLock, _set.userProtected], + menu : new Common.UI.Menu({items: []}), + dataHint: '1', + dataHintDirection: 'bottom', + dataHintOffset: 'small' + }); + me.listStyles = new Common.UI.ComboDataView({ cls : 'combo-cell-styles', enableKeyEvents : true, @@ -2453,7 +2465,7 @@ define([ me.cmbFontName, me.cmbFontSize, me.btnIncFontSize, me.btnDecFontSize, me.btnChangeCase, me.btnBold, me.btnItalic, me.btnUnderline, me.btnStrikeout, me.btnSubscript, me.btnTextColor, me.btnAlignLeft, me.btnAlignCenter,me.btnAlignRight,me.btnAlignJust, me.btnAlignTop, - me.btnAlignMiddle, me.btnAlignBottom, me.btnWrap, me.btnTextOrient, me.btnBackColor, me.btnInsertTable, + me.btnAlignMiddle, me.btnAlignBottom, me.btnWrap, me.btnTextOrient, me.btnBackColor, me.btnInsertTable, me.btnPasteOptions, me.btnMerge, me.btnTextDir, me.btnInsertFormula, me.btnNamedRange, me.btnFillNumbers, me.btnIncDecimal, me.btnInsertShape, me.btnInsertSmartArt, me.btnInsertEquation, me.btnInsertSymbol, me.btnInsertSlicer, me.btnInsertText, me.btnInsertTextArt, me.btnSortUp, me.btnSortDown, me.btnSetAutofilter, me.btnClearAutofilter, me.btnTableTemplate, me.btnCellStyle, me.btnPercentStyle, me.btnCommaStyle, me.btnCurrencyStyle, me.btnDecDecimal, me.btnAddCell, me.btnDeleteCell, me.btnFormatCell, me.btnCondFormat, @@ -2623,6 +2635,7 @@ define([ _injectComponent('#slot-btn-text-orient', this.btnTextOrient); _injectComponent('#slot-btn-insimage', this.btnInsertImage); _injectComponent('#slot-btn-instable', this.btnInsertTable); + _injectComponent('#slot-btn-paste-options', this.btnPasteOptions); _injectComponent('#slot-btn-inshyperlink', this.btnInsertHyperlink); _injectComponent('#slot-btn-insshape', this.btnInsertShape); _injectComponent('#slot-btn-instext', this.btnInsertText); @@ -2711,6 +2724,7 @@ define([ _updateHint(this.btnWrap, this.tipWrap); _updateHint(this.btnTextOrient, this.tipTextOrientation); _updateHint(this.btnInsertTable, this.tipInsertTable); + _updateHint(this.btnPasteOptions, this.tipPasteOptions); _updateHint(this.btnInsertImage, this.tipInsertImage); _updateHint(this.btnInsertChart, this.tipInsertChartSpark); _updateHint(this.btnInsertChartRecommend, this.tipInsertChartRecommend); diff --git a/apps/spreadsheeteditor/main/locale/en.json b/apps/spreadsheeteditor/main/locale/en.json index fd2c65bc39..3bb8377c6d 100644 --- a/apps/spreadsheeteditor/main/locale/en.json +++ b/apps/spreadsheeteditor/main/locale/en.json @@ -2416,6 +2416,30 @@ "SSE.Controllers.Toolbar.warnLongOperation": "The operation you are about to perform might take rather much time to complete.
Are you sure you want to continue?", "SSE.Controllers.Toolbar.warnMergeLostData": "Only the data from the upper-left cell will remain in the merged cell.
Are you sure you want to continue?", "SSE.Controllers.Toolbar.warnNoRecommended": "To create a chart, select the cells that contain the data you'd like to use.
If you have names for the rows and columns and you'd like use them as labels, include them in your selection.", + "SSE.Controllers.Toolbar.txtKeepTextOnly": "Keep text only", + "SSE.Controllers.Toolbar.txtUseTextImport": "Use text import", + "SSE.Controllers.Toolbar.txtPaste": "Paste", + "SSE.Controllers.Toolbar.txtPasteBorders": "Formula without borders", + "SSE.Controllers.Toolbar.txtPasteColWidths": "Formula + column width", + "SSE.Controllers.Toolbar.txtPasteDestFormat": "Destination formatting", + "SSE.Controllers.Toolbar.txtPasteFormat": "Paste only formatting", + "SSE.Controllers.Toolbar.txtPasteFormulaNumFormat": "Formula + number format", + "SSE.Controllers.Toolbar.txtPasteFormulas": "Paste only formula", + "SSE.Controllers.Toolbar.txtPasteKeepSourceFormat": "Formula + all formatting", + "SSE.Controllers.Toolbar.txtPasteLink": "Paste link", + "SSE.Controllers.Toolbar.txtPasteLinkPicture": "Linked picture", + "SSE.Controllers.Toolbar.txtPasteMerge": "Merge conditional formatting", + "SSE.Controllers.Toolbar.txtPastePicture": "Picture", + "SSE.Controllers.Toolbar.txtPasteSourceFormat": "Source formatting", + "SSE.Controllers.Toolbar.txtPasteTranspose": "Transpose", + "SSE.Controllers.Toolbar.txtPasteValFormat": "Value + all formatting", + "SSE.Controllers.Toolbar.txtPasteValNumFormat": "Value + number format", + "SSE.Controllers.Toolbar.txtPasteValues": "Paste only value", + "SSE.Controllers.Toolbar.txtOther": "Other", + "SSE.Controllers.Toolbar.txtFormula": "Formula", + "SSE.Controllers.Toolbar.txtValue": "Value", + "SSE.Controllers.Toolbar.textPasteSpecial": "Paste special", + "SSE.Controllers.Toolbar.txtImportWizard": "Text Import", "SSE.Controllers.Viewport.textFreezePanes": "Freeze panes", "SSE.Controllers.Viewport.textFreezePanesShadow": "Show Frozen Panes Shadow", "SSE.Controllers.Viewport.textHideFBar": "Hide Formula Bar", @@ -4778,6 +4802,7 @@ "SSE.Views.Toolbar.capInsertShape": "Shape", "SSE.Views.Toolbar.capInsertSpark": "Sparkline", "SSE.Views.Toolbar.capInsertTable": "Table", + "SSE.Views.Toolbar.capPasteOptions": "Paste Options", "SSE.Views.Toolbar.capInsertText": "Text Box", "SSE.Views.Toolbar.capInsertTextart": "Text Art", "SSE.Views.Toolbar.capShapesMerge": "Merge Shapes", @@ -5005,6 +5030,7 @@ "SSE.Views.Toolbar.tipInsertSpark": "Insert sparkline", "SSE.Views.Toolbar.tipInsertSymbol": "Insert symbol", "SSE.Views.Toolbar.tipInsertTable": "Insert table", + "SSE.Views.Toolbar.tipPasteOptions": "Paste options", "SSE.Views.Toolbar.tipInsertText": "Insert text box", "SSE.Views.Toolbar.tipInsertTextart": "Insert Text Art", "SSE.Views.Toolbar.tipInsertVerticalText": "Insert vertical text box",