[SSE] Add menu for special paste.

This commit is contained in:
Julia Radzhabova 2017-02-09 15:40:16 +03:00
parent d80f5ed598
commit 67f3751268
3 changed files with 118 additions and 1 deletions

View file

@ -253,6 +253,8 @@ define([
this.api.asc_registerCallback('asc_onSelectionChanged', _.bind(this.onSelectionChanged, this)); 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_onEntriesListMenu', _.bind(this.onEntriesListMenu, this)); // Alt + Down
this.api.asc_registerCallback('asc_onFormulaCompleteMenu', _.bind(this.onFormulaCompleteMenu, this)); 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; 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 = $('<div id="special-paste-container" style="position: absolute; z-index: 10000;"><div id="id-document-holder-btn-special-paste"></div></div>');
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) { onCellsRange: function(status) {
this.rangeSelectionMode = (status != Asc.c_oAscSelectionDialogType.None); 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?', 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', txtExpand: 'Expand and sort',
txtSorting: 'Sorting', 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 || {})); }, SSE.Controllers.DocumentHolder || {}));
}); });

View file

@ -198,6 +198,23 @@
"SSE.Controllers.DocumentHolder.txtTop": "Top", "SSE.Controllers.DocumentHolder.txtTop": "Top",
"SSE.Controllers.DocumentHolder.txtUnderbar": "Bar under text", "SSE.Controllers.DocumentHolder.txtUnderbar": "Bar under text",
"SSE.Controllers.DocumentHolder.txtWidth": "Width", "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.newDocumentTitle": "Unnamed spreadsheet",
"SSE.Controllers.LeftMenu.textByColumns": "By columns", "SSE.Controllers.LeftMenu.textByColumns": "By columns",
"SSE.Controllers.LeftMenu.textByRows": "By rows", "SSE.Controllers.LeftMenu.textByRows": "By rows",

View file

@ -258,3 +258,10 @@
border: 1px solid @gray; border: 1px solid @gray;
.background-ximage('@{app-image-path}/toolbar/math.png', '@{app-image-path}/toolbar/math@2x.png', 1500px); .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;
}