diff --git a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js index c589e4ce1..d1488a6df 100644 --- a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js +++ b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js @@ -253,6 +253,8 @@ define([ this.api.asc_registerCallback('asc_onSelectionChanged', _.bind(this.onSelectionChanged, this)); this.api.asc_registerCallback('asc_onEntriesListMenu', _.bind(this.onEntriesListMenu, this)); // Alt + Down this.api.asc_registerCallback('asc_onFormulaCompleteMenu', _.bind(this.onFormulaCompleteMenu, this)); + this.api.asc_registerCallback('asc_onShowSpecialPasteOptions', _.bind(this.onShowSpecialPasteOptions, this)); + this.api.asc_registerCallback('asc_onHideSpecialPasteOptions', _.bind(this.onHideSpecialPasteOptions, this)); return this; }, @@ -1594,6 +1596,80 @@ define([ } }, + onShowSpecialPasteOptions: function(specialPasteShowOptions) { + var me = this, + documentHolderView = me.documentHolder, + coord = specialPasteShowOptions.asc_getCellCoord(), + showPoint = [coord.asc_getX() + coord.asc_getWidth() + 3, coord.asc_getY() + coord.asc_getHeight() + 3], + pasteContainer = documentHolderView.cmpEl.find('#special-paste-container'), + pasteItems = specialPasteShowOptions.asc_getOptions(); + + // Prepare menu container + if (pasteContainer.length < 1) { + me._arrSpecialPaste = []; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.paste] = me.txtPaste; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.pasteOnlyFormula] = me.txtPasteFormulas; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.formulaNumberFormat] = me.txtPasteFormulaNumFormat; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.formulaAllFormatting] = me.txtPasteKeepSourceFormat; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.formulaWithoutBorders] = me.txtPasteBorders; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.formulaColumnWidth] = me.txtPasteColWidths; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.mergeConditionalFormating] = me.txtPasteMerge; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.pasteOnlyValues] = me.txtPasteValues; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.valueNumberFormat] = me.txtPasteValNumFormat; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.valueAllFormating] = me.txtPasteValFormat; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.pasteOnlyFormating] = me.txtPasteFormat; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.transpose] = me.txtPasteTranspose; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.link] = me.txtPasteLink; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.picture] = me.txtPastePicture; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.linkedPicture] = me.txtPasteLinkPicture; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.sourceformatting] = me.txtPasteSourceFormat; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.destinationFormatting] = me.txtPasteDestFormat; + + pasteContainer = $('
'); + documentHolderView.cmpEl.append(pasteContainer); + + me.btnSpecialPaste = new Common.UI.Button({ + cls : 'btn-toolbar', + iconCls : 'btn-paste', + menu : new Common.UI.Menu({items: []}) + }); + me.btnSpecialPaste.render($('#id-document-holder-btn-special-paste')) ; + } + + var menu = me.btnSpecialPaste.menu; + for (var i = 0; i < menu.items.length; i++) { + menu.removeItem(menu.items[i]); + i--; + } + + var group_prev = -1; + _.each(pasteItems, function(menuItem, index) { + var group = (menuItem<7) ? 0 : (menuItem>9 ? 2 : 1); + if (group_prev !== group && group_prev>=0) + menu.addItem(new Common.UI.MenuItem({ caption: '--' })); + group_prev = group; + + var mnu = new Common.UI.MenuItem({ + caption: me._arrSpecialPaste[menuItem], + value: menuItem + }).on('click', function(item, e) { + var props = new Asc.SpecialPasteProps(); + props.asc_setProps(item.value); + me.api.asc_SpecialPaste(props); + }); + menu.addItem(mnu); + }); + + Common.UI.Menu.Manager.hideAll(); + + pasteContainer.css({left: showPoint[0], top : showPoint[1]}); + pasteContainer.show(); + }, + + onHideSpecialPasteOptions: function() { + this.documentHolder.cmpEl.find('#special-paste-container').hide(); + }, + onCellsRange: function(status) { this.rangeSelectionMode = (status != Asc.c_oAscSelectionDialogType.None); }, @@ -2323,7 +2399,24 @@ define([ txtExpandSort: 'The data next to the selection will not be sorted. Do you want to expand the selection to include the adjacent data or continue with sorting the currently selected cells only?', txtExpand: 'Expand and sort', txtSorting: 'Sorting', - txtSortSelected: 'Sort selected' + txtSortSelected: 'Sort selected', + txtPaste: 'Paste', + txtPasteFormulas: 'Paste only formula', + txtPasteFormulaNumFormat: 'Formula + number format', + txtPasteKeepSourceFormat: 'Formula + all formatting', + txtPasteBorders: 'Formula without borders', + txtPasteColWidths: 'Formula + column width', + txtPasteMerge: 'Merge conditional formatting', + txtPasteTranspose: 'Transpose', + txtPasteValues: 'Paste only value', + txtPasteValNumFormat: 'Value + number format', + txtPasteValFormat: 'Value + all formatting', + txtPasteFormat: 'Paste only formatting', + txtPasteLink: 'Paste Link', + txtPastePicture: 'Picture', + txtPasteLinkPicture: 'Linked Picture', + txtPasteSourceFormat: 'Source formatting', + txtPasteDestFormat: 'Destination formatting' }, SSE.Controllers.DocumentHolder || {})); }); \ No newline at end of file diff --git a/apps/spreadsheeteditor/main/locale/en.json b/apps/spreadsheeteditor/main/locale/en.json index 9701c4566..9c22330f7 100644 --- a/apps/spreadsheeteditor/main/locale/en.json +++ b/apps/spreadsheeteditor/main/locale/en.json @@ -198,6 +198,23 @@ "SSE.Controllers.DocumentHolder.txtTop": "Top", "SSE.Controllers.DocumentHolder.txtUnderbar": "Bar under text", "SSE.Controllers.DocumentHolder.txtWidth": "Width", + "SSE.Controllers.DocumentHolder.txtPaste": "Paste", + "SSE.Controllers.DocumentHolder.txtPasteFormulas": "Paste only formula", + "SSE.Controllers.DocumentHolder.txtPasteFormulaNumFormat": "Formula + number format", + "SSE.Controllers.DocumentHolder.txtPasteKeepSourceFormat": "Formula + all formatting", + "SSE.Controllers.DocumentHolder.txtPasteBorders": "Formula without borders", + "SSE.Controllers.DocumentHolder.txtPasteColWidths": "Formula + column width", + "SSE.Controllers.DocumentHolder.txtPasteMerge": "Merge conditional formatting", + "SSE.Controllers.DocumentHolder.txtPasteTranspose": "Transpose", + "SSE.Controllers.DocumentHolder.txtPasteValues": "Paste only value", + "SSE.Controllers.DocumentHolder.txtPasteValNumFormat": "Value + number format", + "SSE.Controllers.DocumentHolder.txtPasteValFormat": "Value + all formatting", + "SSE.Controllers.DocumentHolder.txtPasteFormat": "Paste only formatting", + "SSE.Controllers.DocumentHolder.txtPasteLink": "Paste link", + "SSE.Controllers.DocumentHolder.txtPastePicture": "Picture", + "SSE.Controllers.DocumentHolder.txtPasteLinkPicture": "Linked picture", + "SSE.Controllers.DocumentHolder.txtPasteSourceFormat": "Source formatting", + "SSE.Controllers.DocumentHolder.txtPasteDestFormat": "Destination formatting", "SSE.Controllers.LeftMenu.newDocumentTitle": "Unnamed spreadsheet", "SSE.Controllers.LeftMenu.textByColumns": "By columns", "SSE.Controllers.LeftMenu.textByRows": "By rows", diff --git a/apps/spreadsheeteditor/main/resources/less/toolbar.less b/apps/spreadsheeteditor/main/resources/less/toolbar.less index 9beb5159d..53bbacd00 100644 --- a/apps/spreadsheeteditor/main/resources/less/toolbar.less +++ b/apps/spreadsheeteditor/main/resources/less/toolbar.less @@ -258,3 +258,10 @@ border: 1px solid @gray; .background-ximage('@{app-image-path}/toolbar/math.png', '@{app-image-path}/toolbar/math@2x.png', 1500px); } + +#special-paste-container { + position: absolute; + z-index: 10000; + background-color: @gray-light; + border: 1px solid @gray; +} \ No newline at end of file