Merge pull request #158 from ONLYOFFICE/feature/paste-import

Feature/paste import
This commit is contained in:
Julia Radzhabova 2019-04-18 14:30:03 +03:00 committed by GitHub
commit 925af696f8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 244 additions and 101 deletions

View file

@ -106,6 +106,13 @@ Common.Utils = _.extend(new(function() {
Pivot : 10,
Cell : 11
},
importTextType = {
DRM: 0,
CSV: 1,
TXT: 2,
Paste: 3,
Columns: 4
},
isMobile = /android|avantgo|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od|ad)|iris|kindle|lge |maemo|midp|mmp|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(navigator.userAgent || navigator.vendor || window.opera),
me = this,
checkSize = function() {
@ -203,6 +210,7 @@ Common.Utils = _.extend(new(function() {
ipStrongRe: ipStrongRe,
hostnameStrongRe: hostnameStrongRe,
documentSettingsType: documentSettingsType,
importTextType: importTextType,
zoom: function() {return me.zoom;},
innerWidth: function() {return me.innerWidth;},
innerHeight: function() {return me.innerHeight;}

View file

@ -59,21 +59,20 @@ define([
width = 414;
height = 277;
} else {
width = (options.type !== Asc.c_oAscAdvancedOptionsID.DRM) ? 340 : (options.warning ? 370 : 262);
height = (options.type == Asc.c_oAscAdvancedOptionsID.CSV) ? 190 : (options.warning ? 187 : 147);
width = (options.type !== Common.Utils.importTextType.DRM) ? 340 : (options.warning ? 370 : 262);
height = (options.type == Common.Utils.importTextType.CSV || options.type == Common.Utils.importTextType.Paste || options.type == Common.Utils.importTextType.Columns) ? 190 : (options.warning ? 187 : 147);
}
_.extend(_options, {
mode : 1, // open settings
closable : (options.mode==2), // if save settings
closable : false, // true if save settings
preview : options.preview,
warning : options.warning,
codepages : options.codepages,
width : width,
height : height,
header : true,
cls : 'open-dlg',
contentTemplate : '',
title : (options.type == Asc.c_oAscAdvancedOptionsID.DRM) ? t.txtTitleProtected : t.txtTitle.replace('%1', (options.type == Asc.c_oAscAdvancedOptionsID.CSV) ? 'CSV' : 'TXT'),
toolcallback : _.bind(t.onToolClose, t),
closeFile : false
@ -82,7 +81,7 @@ define([
this.template = options.template || [
'<div class="box" style="height:' + (_options.height - 85) + 'px;">',
'<div class="content-panel" >',
'<% if (type == Asc.c_oAscAdvancedOptionsID.DRM) { %>',
'<% if (type == Common.Utils.importTextType.DRM) { %>',
'<% if (warning) { %>',
'<div>',
'<div class="icon img-commonctrl warn"/>',
@ -97,13 +96,15 @@ define([
'</div>',
'<% } %>',
'<% } else { %>',
'<div style="<% if (!!preview && type == Asc.c_oAscAdvancedOptionsID.CSV) { %>width: 230px;margin-right: 10px;display: inline-block;<% } else { %>width: 100%;<% } %>margin-bottom:15px;">',
'<% if (codepages && codepages.length>0) { %>',
'<div style="<% if (!!preview && (type == Common.Utils.importTextType.CSV || type == Common.Utils.importTextType.Paste || type == Common.Utils.importTextType.Columns)) { %>width: 230px;margin-right: 10px;display: inline-block;<% } else { %>width: 100%;<% } %>margin-bottom:15px;">',
'<label class="header">' + t.txtEncoding + '</label>',
'<div>',
'<div id="id-codepages-combo" class="input-group-nr" style="width: 100%; display: inline-block; vertical-align: middle;"></div>',
'</div>',
'</div>',
'<% if (type == Asc.c_oAscAdvancedOptionsID.CSV) { %>',
'<% } %>',
'<% if (type == Common.Utils.importTextType.CSV || type == Common.Utils.importTextType.Paste || type == Common.Utils.importTextType.Columns) { %>',
'<div style="display: inline-block; margin-bottom:15px;">',
'<label class="header">' + t.txtDelimiter + '</label>',
'<div>',
@ -143,6 +144,7 @@ define([
this.handler = _options.handler;
this.type = _options.type;
this.preview = _options.preview;
this.previewData = _options.previewData;
this.warning = _options.warning || false;
this.closable = _options.closable;
this.codepages = _options.codepages;
@ -168,7 +170,7 @@ define([
this.previewScrolled = this.$window.find('#id-preview');
this.previewInner = this.previewScrolled.find('div:first-child');
if (this.type == Asc.c_oAscAdvancedOptionsID.DRM) {
if (this.type == Common.Utils.importTextType.DRM) {
this.inputPwd = new Common.UI.InputField({
el: $('#id-password-txt'),
type: 'text',
@ -187,8 +189,9 @@ define([
});
} else {
this.initCodePages();
if (this.preview)
this.updatePreview();
if (this.preview) {
(this.previewData) ? this.previewCallback(this.previewData) : this.updatePreview();
}
}
this.onPrimary = function() {
me._handleInput('ok');
@ -200,7 +203,7 @@ define([
show: function() {
Common.UI.Window.prototype.show.apply(this, arguments);
if (this.type == Asc.c_oAscAdvancedOptionsID.DRM) {
if (this.type == Common.Utils.importTextType.DRM) {
var me = this;
setTimeout(function(){
me.inputPwd.cmpEl.find('input').focus();
@ -220,15 +223,15 @@ define([
_handleInput: function(state) {
if (this.handler) {
if (this.cmbEncoding) {
var encoding = (!this.cmbEncoding.isDisabled()) ? this.cmbEncoding.getValue() :
((this.settings && this.settings.asc_getCodePage()) ? this.settings.asc_getCodePage() : 0),
if (this.type == Common.Utils.importTextType.DRM) {
this.handler.call(this, state, this.inputPwd.getValue());
} else {
var encoding = (this.cmbEncoding && !this.cmbEncoding.isDisabled()) ? this.cmbEncoding.getValue() :
((this.settings && this.settings.asc_getCodePage()) ? this.settings.asc_getCodePage() : 0),
delimiter = this.cmbDelimiter ? this.cmbDelimiter.getValue() : null,
delimiterChar = (delimiter == -1) ? this.inputDelimiter.getValue() : null;
(delimiter == -1) && (delimiter = null);
this.handler.call(this, state, encoding, delimiter, delimiterChar);
} else {
this.handler.call(this, state, this.inputPwd.getValue());
}
}
@ -253,37 +256,37 @@ define([
}
length = encodedata.length;
for (i = 0; i < length; ++i) {
listItems.push({
value: encodedata[i][0],
displayValue: Common.Utils.String.htmlEncode(encodedata[i][1]),
lcid: encodedata[i][2] || ''
});
}
if (length) {
for (i = 0; i < length; ++i) {
listItems.push({
value: encodedata[i][0],
displayValue: Common.Utils.String.htmlEncode(encodedata[i][1]),
lcid: encodedata[i][2] || ''
});
}
var itemsTemplate =
_.template([
'<% _.each(items, function(item) { %>',
'<li id="<%= item.id %>" data-value="<%= item.value %>"><a tabindex="-1" type="menuitem">',
var itemsTemplate =
_.template([
'<% _.each(items, function(item) { %>',
'<li id="<%= item.id %>" data-value="<%= item.value %>"><a tabindex="-1" type="menuitem">',
'<div style="display: inline-block;"><%= item.displayValue %></div>',
'<label style="text-align: right;width:' + lcid_width + 'px;"><%= item.lcid %></label>',
'</a></li>',
'<% }); %>'
].join(''));
'</a></li>',
'<% }); %>'
].join(''));
this.cmbEncoding = new Common.UI.ComboBox({
el: $('#id-codepages-combo', this.$window),
style: 'width: 100%;',
menuStyle: 'min-width: 100%; max-height: 200px;',
cls: 'input-group-nr',
menuCls: 'scrollable-menu',
data: listItems,
editable: false,
disabled: true,
itemsTemplate: itemsTemplate
});
this.cmbEncoding = new Common.UI.ComboBox({
el: $('#id-codepages-combo', this.$window),
style: 'width: 100%;',
menuStyle: 'min-width: 100%; max-height: 200px;',
cls: 'input-group-nr',
menuCls: 'scrollable-menu',
data: listItems,
editable: false,
disabled: true,
itemsTemplate: itemsTemplate
});
if (length) {
this.cmbEncoding.setDisabled(false);
this.cmbEncoding.setValue((this.settings && this.settings.asc_getCodePage()) ? this.settings.asc_getCodePage() : encodedata[0][0]);
if (this.preview)
@ -295,7 +298,7 @@ define([
ul.find('li div').width(width);
}
if (this.type == Asc.c_oAscAdvancedOptionsID.CSV) {
if (this.type == Common.Utils.importTextType.CSV || this.type == Common.Utils.importTextType.Paste || this.type == Common.Utils.importTextType.Columns) {
this.cmbDelimiter = new Common.UI.ComboBox({
el: $('#id-delimiters-combo', this.$window),
style: 'width: 100px;',
@ -328,16 +331,23 @@ define([
},
updatePreview: function() {
var encoding = (!this.cmbEncoding.isDisabled()) ? this.cmbEncoding.getValue() :
var encoding = (this.cmbEncoding && !this.cmbEncoding.isDisabled()) ? this.cmbEncoding.getValue() :
((this.settings && this.settings.asc_getCodePage()) ? this.settings.asc_getCodePage() : 0);
var delimiter = this.cmbDelimiter ? this.cmbDelimiter.getValue() : null,
delimiterChar = (delimiter == -1) ? this.inputDelimiter.getValue() : null;
(delimiter == -1) && (delimiter = null);
if (this.type == Asc.c_oAscAdvancedOptionsID.CSV) {
var delimiter = this.cmbDelimiter ? this.cmbDelimiter.getValue() : null,
delimiterChar = (delimiter == -1) ? this.inputDelimiter.getValue() : null;
(delimiter == -1) && (delimiter = null);
this.api.asc_decodeBuffer(this.preview, new Asc.asc_CCSVAdvancedOptions(encoding, delimiter, delimiterChar), _.bind(this.previewCallback, this));
} else {
this.api.asc_decodeBuffer(this.preview, new Asc.asc_CTXTAdvancedOptions(encoding), _.bind(this.previewCallback, this));
switch (this.type) {
case Common.Utils.importTextType.CSV:
this.api.asc_decodeBuffer(this.preview, new Asc.asc_CCSVAdvancedOptions(encoding, delimiter, delimiterChar), _.bind(this.previewCallback, this));
break;
case Common.Utils.importTextType.TXT:
this.api.asc_decodeBuffer(this.preview, new Asc.asc_CTXTAdvancedOptions(encoding), _.bind(this.previewCallback, this));
break;
case Common.Utils.importTextType.Paste:
case Common.Utils.importTextType.Columns:
this.api.asc_TextImport(new Asc.asc_CCSVAdvancedOptions(encoding, delimiter, delimiterChar), _.bind(this.previewCallback, this), this.type == Common.Utils.importTextType.Paste);
break;
}
},
@ -379,7 +389,7 @@ define([
delete this.scrollerX;
}
if (this.type == Asc.c_oAscAdvancedOptionsID.CSV) {
if (this.type == Common.Utils.importTextType.CSV || this.type == Common.Utils.importTextType.Paste || this.type == Common.Utils.importTextType.Columns) {
var maxlength = 0;
for (var i=0; i<data.length; i++) {
if (data[i].length>maxlength)
@ -387,7 +397,7 @@ define([
}
var tpl = '<table>';
for (var i=0; i<data.length; i++) {
tpl += '<tr>';
tpl += '<tr style="vertical-align: top;">';
for (var j=0; j<data[i].length; j++) {
tpl += '<td>' + Common.Utils.String.htmlEncode(data[i][j]) + '</td>';
}
@ -400,7 +410,7 @@ define([
} else {
var tpl = '<table>';
for (var i=0; i<data.length; i++) {
tpl += '<tr><td>' + Common.Utils.String.htmlEncode(data[i]) + '</td></tr>';
tpl += '<tr style="vertical-align: top;"><td>' + Common.Utils.String.htmlEncode(data[i]) + '</td></tr>';
}
tpl += '</table>';
}

View file

@ -1947,8 +1947,9 @@ define([
me = this;
if (type == Asc.c_oAscAdvancedOptionsID.TXT) {
me._state.openDlg = new Common.Views.OpenDialog({
mode: mode,
type: type,
title: Common.Views.OpenDialog.prototype.txtTitle.replace('%1', 'TXT'),
closable: (mode==2), // if save settings
type: Common.Utils.importTextType.TXT,
preview: advOptions.asc_getOptions().asc_getData(),
codepages: advOptions.asc_getOptions().asc_getCodePages(),
settings: advOptions.asc_getOptions().asc_getRecommendedSettings(),
@ -1966,8 +1967,9 @@ define([
});
} else if (type == Asc.c_oAscAdvancedOptionsID.DRM) {
me._state.openDlg = new Common.Views.OpenDialog({
title: Common.Views.OpenDialog.prototype.txtTitleProtected,
closeFile: me.appOptions.canRequestClose,
type: type,
type: Common.Utils.importTextType.DRM,
warning: !(me.appOptions.isDesktopApp && me.appOptions.isOffline),
validatePwd: !!me._state.isDRM,
handler: function (result, value) {

View file

@ -1788,8 +1788,9 @@ define([
me = this;
if (type == Asc.c_oAscAdvancedOptionsID.DRM) {
me._state.openDlg = new Common.Views.OpenDialog({
title: Common.Views.OpenDialog.prototype.txtTitleProtected,
closeFile: me.appOptions.canRequestClose,
type: type,
type: Common.Utils.importTextType.DRM,
warning: !(me.appOptions.isDesktopApp && me.appOptions.isOffline),
validatePwd: !!me._state.isDRM,
handler: function (result, value) {

View file

@ -45,6 +45,7 @@ define([
'common/main/lib/util/utils',
'common/main/lib/util/Shortcuts',
'common/main/lib/view/CopyWarningDialog',
'common/main/lib/view/OpenDialog',
'spreadsheeteditor/main/app/view/DocumentHolder',
'spreadsheeteditor/main/app/view/HyperlinkSettingsDialog',
'spreadsheeteditor/main/app/view/ParagraphSettingsAdvanced',
@ -2135,23 +2136,25 @@ define([
// 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;
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.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.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];
pasteContainer = $('<div id="special-paste-container" style="position: absolute;"><div id="id-document-holder-btn-special-paste"></div></div>');
documentHolderView.cmpEl.append(pasteContainer);
@ -2170,28 +2173,78 @@ define([
menu.removeItem(menu.items[i]);
i--;
}
var groups = [];
for (var i = 0; i < 3; i++) {
groups[i] = [];
}
var group_prev = -1;
var importText;
_.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;
if (menuItem == Asc.c_oSpecialPasteProps.useTextImport) {
importText = new Common.UI.MenuItem({
caption: me._arrSpecialPaste[menuItem][0],
value: menuItem,
checkable: true,
toggleGroup : 'specialPasteGroup'
}).on('click', function(item, e) {
(new Common.Views.OpenDialog({
title: me.txtImportWizard,
closable: true,
type: Common.Utils.importTextType.Paste,
preview: true,
api: me.api,
handler: function (result, encoding, delimiter, delimiterChar) {
if (result == 'ok') {
if (me && me.api) {
var props = new Asc.SpecialPasteProps();
props.asc_setProps(Asc.c_oSpecialPasteProps.useTextImport);
props.asc_setAdvancedOptions(new Asc.asc_CCSVAdvancedOptions(encoding, delimiter, delimiterChar));
me.api.asc_SpecialPaste(props);
}
me._state.lastSpecPasteChecked = item;
} else {
item.setChecked(false, true);
me._state.lastSpecPasteChecked && me._state.lastSpecPasteChecked.setChecked(true, true);
}
}
})).show();
setTimeout(function(){menu.hide();}, 100);
});
} else {
var mnu = new Common.UI.MenuItem({
caption: me._arrSpecialPaste[menuItem][0],
value: menuItem,
checkable: true,
toggleGroup : 'specialPasteGroup'
}).on('click', function(item, e) {
me._state.lastSpecPasteChecked = item;
var mnu = new Common.UI.MenuItem({
caption: me._arrSpecialPaste[menuItem],
value: menuItem,
checkable: true,
toggleGroup : 'specialPasteGroup'
}).on('click', function(item, e) {
var props = new Asc.SpecialPasteProps();
props.asc_setProps(item.value);
me.api.asc_SpecialPaste(props);
setTimeout(function(){menu.hide();}, 100);
});
menu.addItem(mnu);
var props = new Asc.SpecialPasteProps();
props.asc_setProps(item.value);
me.api.asc_SpecialPaste(props);
setTimeout(function(){menu.hide();}, 100);
});
groups[me._arrSpecialPaste[menuItem][1]].push(mnu);
}
});
var newgroup = false;
for (var i = 0; i < 3; i++) {
if (newgroup && groups[i].length>0) {
menu.addItem(new Common.UI.MenuItem({ caption: '--' }));
newgroup = false;
}
_.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;
if (importText) {
menu.addItem(new Common.UI.MenuItem({ caption: '--' }));
menu.addItem(importText);
}
}
if ( coord[0].asc_getX()<0 || coord[0].asc_getY()<0) {
@ -3180,6 +3233,8 @@ define([
txtPasteLinkPicture: 'Linked Picture',
txtPasteSourceFormat: 'Source formatting',
txtPasteDestFormat: 'Destination formatting',
txtKeepTextOnly: 'Keep text only',
txtUseTextImport: 'Use text import wizard',
txtUndoExpansion: 'Undo table autoexpansion',
txtRedoExpansion: 'Redo table autoexpansion',
txtAnd: 'and',
@ -3206,7 +3261,8 @@ define([
txtEqualsToFontColor: 'Equals to font color',
txtAll: '(All)',
txtBlanks: '(Blanks)',
txtColumn: 'Column'
txtColumn: 'Column',
txtImportWizard: 'Text Import Wizard'
}, SSE.Controllers.DocumentHolder || {}));
});

View file

@ -1365,6 +1365,10 @@ define([
config.msg = this.errorEmailClient;
break;
case Asc.c_oAscError.ID.NoDataToParse:
config.msg = this.errorNoDataToParse;
break;
default:
config.msg = (typeof id == 'string') ? id : this.errorDefaultMessage.replace('%1', id);
break;
@ -1605,8 +1609,9 @@ define([
me = this;
if (type == Asc.c_oAscAdvancedOptionsID.CSV) {
me._state.openDlg = new Common.Views.OpenDialog({
mode: mode,
type: type,
title: Common.Views.OpenDialog.prototype.txtTitle.replace('%1', 'CSV'),
closable: (mode==2), // if save settings
type: Common.Utils.importTextType.CSV,
preview: advOptions.asc_getOptions().asc_getData(),
codepages: advOptions.asc_getOptions().asc_getCodePages(),
settings: advOptions.asc_getOptions().asc_getRecommendedSettings(),
@ -1624,8 +1629,9 @@ define([
});
} else if (type == Asc.c_oAscAdvancedOptionsID.DRM) {
me._state.openDlg = new Common.Views.OpenDialog({
title: Common.Views.OpenDialog.prototype.txtTitleProtected,
closeFile: me.appOptions.canRequestClose,
type: type,
type: Common.Utils.importTextType.DRM,
warning: !(me.appOptions.isDesktopApp && me.appOptions.isOffline),
validatePwd: !!me._state.isDRM,
handler: function (result, value) {
@ -2493,7 +2499,8 @@ define([
errorEmailClient: 'No email client could be found',
txtPrintArea: 'Print_Area',
txtTable: 'Table',
textCustomLoader: 'Please note that according to the terms of the license you are not entitled to change the loader.<br>Please contact our Sales Department to get a quote.'
textCustomLoader: 'Please note that according to the terms of the license you are not entitled to change the loader.<br>Please contact our Sales Department to get a quote.',
errorNoDataToParse: 'No data was selected to parse.'
}
})(), SSE.Controllers.Main || {}))
});

View file

@ -60,5 +60,15 @@
<div id="cell-spin-angle" style="display: inline-block;margin-left:5px;"></div>
</td>
</tr>
<tr>
<td class="padding-small" colspan=2>
<div class="separator horizontal"></div>
</td>
</tr>
<tr>
<td class="padding-small" colspan=2>
<button type="button" class="btn btn-text-default" id="cell-btn-text-to-column" style="width:100%;"><%= scope.textTextToColumn %></button>
</td>
</tr>
<tr class="finish-cell"></tr>
</table>

View file

@ -46,7 +46,8 @@ define([
'common/main/lib/component/Button',
'common/main/lib/component/ThemeColorPalette',
'common/main/lib/component/ColorButton',
'common/main/lib/component/ComboBorderSize'
'common/main/lib/component/ComboBorderSize',
'common/main/lib/view/OpenDialog'
], function (menuTemplate, $, _, Backbone) {
'use strict';
@ -70,11 +71,13 @@ define([
this._state = {
BackColor: undefined,
DisabledControls: true,
CellAngle: undefined
CellAngle: undefined,
CSVOptions: new Asc.asc_CCSVAdvancedOptions(0, 4, '')
};
this.lockedControls = [];
this._locked = true;
this.isEditCell = false;
this.isMultiSelect = false;
this.BorderType = 1;
this.render();
@ -138,6 +141,32 @@ define([
this.api && this.api.asc_setCellAngle(field.getNumberValue());
},
onTextToColumn: function() {
this.api.asc_TextImport(this._state.CSVOptions, _.bind(this.onTextToColumnCallback, this), false);
},
onTextToColumnCallback: function(data) {
if (!data || !data.length) return;
var me = this;
(new Common.Views.OpenDialog({
title: me.textWizard,
closable: true,
type: Common.Utils.importTextType.Columns,
preview: true,
previewData: data,
settings: this._state.CSVOptions,
api: me.api,
handler: function (result, encoding, delimiter, delimiterChar) {
if (result == 'ok') {
if (me && me.api) {
me.api.asc_TextToColumns(new Asc.asc_CCSVAdvancedOptions(encoding, delimiter, delimiterChar));
}
}
}
})).show();
},
render: function () {
var el = $(this.el);
el.html(this.template({
@ -149,6 +178,7 @@ define([
this.api = o;
if (o) {
this.api.asc_registerCallback('asc_onEditCell', this.onApiEditCell.bind(this));
this.api.asc_registerCallback('asc_onSelectionChanged', _.bind(this.onApiSelectionChanged, this));
}
return this;
},
@ -236,6 +266,12 @@ define([
});
this.lockedControls.push(this.spnAngle);
this.spnAngle.on('change', _.bind(this.onAngleChange, this));
this.btnTextToColumn = new Common.UI.Button({
el: $('#cell-btn-text-to-column')
});
this.btnTextToColumn.on('click', _.bind(this.onTextToColumn, this));
this.lockedControls.push(this.btnTextToColumn);
},
createDelayedElements: function() {
@ -333,6 +369,10 @@ define([
this.disableControls(this._locked);
},
onApiSelectionChanged: function(info) {
this.isMultiSelect = info.asc_getFlags().asc_getMultiselect() || info.asc_getSelectedColsCount()>1;
},
setLocked: function (locked) {
this._locked = locked;
},
@ -347,6 +387,7 @@ define([
item.setDisabled(disable);
});
}
this.btnTextToColumn.setDisabled(disable || this.isMultiSelect);
},
textBorders: 'Border\'s Style',
@ -367,7 +408,9 @@ define([
tipDiagU: 'Set Diagonal Up Border',
tipDiagD: 'Set Diagonal Down Border',
textOrientation: 'Text Orientation',
textAngle: 'Angle'
textAngle: 'Angle',
textTextToColumn: 'Text to Columns',
textWizard: 'Text to Columns Wizard'
}, SSE.Views.CellSettings || {}));
});

View file

@ -371,6 +371,9 @@
"SSE.Controllers.DocumentHolder.txtUndoExpansion": "Undo table autoexpansion",
"SSE.Controllers.DocumentHolder.txtUseTextImport": "Use text import wizard",
"SSE.Controllers.DocumentHolder.txtWidth": "Width",
"SSE.Controllers.DocumentHolder.txtKeepTextOnly": "Keep text only",
"SSE.Controllers.DocumentHolder.txtUseTextImport": "Use text import wizard",
"SSE.Controllers.DocumentHolder.txtImportWizard": "Text Import Wizard",
"SSE.Controllers.LeftMenu.newDocumentTitle": "Unnamed spreadsheet",
"SSE.Controllers.LeftMenu.textByColumns": "By columns",
"SSE.Controllers.LeftMenu.textByRows": "By rows",
@ -726,6 +729,7 @@
"SSE.Controllers.Main.warnNoLicense": "This version of ONLYOFFICE Editors has certain limitations for concurrent connections to the document server.<br>If you need more please consider purchasing a commercial license.",
"SSE.Controllers.Main.warnNoLicenseUsers": "This version of ONLYOFFICE Editors has certain limitations for concurrent users.<br>If you need more please consider purchasing a commercial license.",
"SSE.Controllers.Main.warnProcessRightsChange": "You have been denied the right to edit the file.",
"SSE.Controllers.Main.errorNoDataToParse": "No data was selected to parse.",
"SSE.Controllers.Print.strAllSheets": "All Sheets",
"SSE.Controllers.Print.textWarning": "Warning",
"SSE.Controllers.Print.txtCustom": "Custom",
@ -1148,6 +1152,8 @@
"SSE.Views.CellSettings.tipOuter": "Set outer border only",
"SSE.Views.CellSettings.tipRight": "Set outer right border only",
"SSE.Views.CellSettings.tipTop": "Set outer top border only",
"SSE.Views.CellSettings.textTextToColumn": "Text to Columns",
"SSE.Views.CellSettings.textWizard": "Text to Columns Wizard",
"SSE.Views.ChartSettings.strLineWeight": "Line Weight",
"SSE.Views.ChartSettings.strSparkColor": "Color",
"SSE.Views.ChartSettings.strTemplate": "Template",