Commit 23b35366 authored by GoshaZotov's avatar GoshaZotov

fix bug 32949

parent fdace1b6
......@@ -485,9 +485,9 @@ var editor;
return AscCommon.g_clipboardBase.Button_Cut();
};
spreadsheet_api.prototype.asc_PasteData = function (_format, data1, data2) {
spreadsheet_api.prototype.asc_PasteData = function (_format, data1, data2, text_data) {
if (!this.getViewMode()) {
this.wb.pasteData(_format, data1, data2);
this.wb.pasteData(_format, data1, data2, text_data);
}
};
......
......@@ -142,7 +142,7 @@
}
},
pasteData: function(ws, _format, data1, data2)
pasteData: function(ws, _format, data1, data2, text_data)
{
var t = this;
t.pasteProcessor.clean();
......@@ -161,7 +161,14 @@
}
else
{
t.pasteProcessor.editorPasteExec(ws, data1);
if(text_data)
{
t.pasteProcessor.pasteTextOnSheet(ws, text_data);
}
else
{
t.pasteProcessor.editorPasteExec(ws, data1);
}
}
break;
......@@ -2237,10 +2244,7 @@
return;
}
//var aResult = this._getTableFromText(text);
var aResult = new excelPasteContent();
aResult = aResult.getDefaultPasteContent(worksheet, this.activeRange.r1, this.activeRange.c1, text);
var aResult = this._getTableFromText(worksheet, text);
if(aResult && !(aResult.onlyImages && window["Asc"]["editor"] && window["Asc"]["editor"].isChartEditor))
{
worksheet.setSelectionInfo('paste', aResult, this);
......@@ -2447,15 +2451,23 @@
return res;
},
_getTableFromText: function (sText)
_getTableFromText: function (worksheet, sText)
{
var activeRange = worksheet.model.selectionRange.getLast().clone(true);
var t = this;
var addTextIntoCell = function(row, col, text)
{
var cell = aResult.getCell(rowCounter, colCounter);
cell.content[0] = {text: text, format: {}};
return cell;
};
var aResult = new excelPasteContent();
var width = 0;
var colCounter = 0;
var rowCounter = 0;
var sCurPar = "";
var colCounter = activeRange.c1;
var rowCounter = activeRange.r1;
var sCurChar = "";
for ( var i = 0, length = sText.length; i < length; i++ )
{
......@@ -2463,44 +2475,27 @@
var Code = sText.charCodeAt(i);
var Item = null;
if(colCounter > width)
if(colCounter - activeRange.c1 > width)
{
width = colCounter;
width = colCounter - activeRange.c1;
}
if ( '\n' === Char )
{
if("" == sCurChar)
{
var cell = aResult.getCell(rowCounter, colCounter);
cell.content[0] = {text: "", format: {}};
colCounter = 0;
addTextIntoCell(rowCounter, colCounter, sCurChar);
colCounter = activeRange.c1;
rowCounter++;
//sHtml += "<tr><td style='font-family:Calibri'>&nbsp;</td></tr>";
}
else
{
var cell = aResult.getCell(rowCounter, colCounter);
cell.content[0] = {text: sCurChar, format: {}};
colCounter = 0;
rowCounter++;
addTextIntoCell(rowCounter, colCounter, sCurChar);
colCounter = activeRange.c1;
//sHtml += "<tr><td><span style='font-family:Calibri;font-size:11pt;white-space:nowrap'>" + sCurChar + "</span></td></tr>";
sCurChar = "";
}
/*else if(sCurPar != '')
{
var cell = aResult.getCell(rowCounter, colCounter);
cell.content[0] = {text: sCurChar, format: {}};
colCounter = 0;
rowCounter++;
//sCurPar += "<td><span style='font-family:Calibri;font-size:11pt;white-space:nowrap'>" + sCurChar + "</span></td>";
//sHtml += "<tr>" + sCurPar + "</tr>";
sCurChar = "";
sCurPar = "";
}*/
}
}
else if ( 13 === Code )
{
......@@ -2514,29 +2509,20 @@
}
else if ( 9 === Code )//tab
{
var cell = aResult.getCell(rowCounter, colCounter);
cell.content[0] = {text: sCurChar, format: {}};
addTextIntoCell(rowCounter, colCounter, sCurChar);
colCounter++;
/*sCurPar += "<td><span style='font-family:Calibri;font-size:11pt;white-space:nowrap'>" + sCurChar + "</span></td>";
if(i == length - 1)
{
sHtml += "<tr>" + sCurPar + "</tr>";
}*/
sCurChar = '';
sCurChar = "";
}
else
{
sCurChar += t._copyPasteCorrectString(Char);
if(i == length - 1)
{
var cell = aResult.getCell(rowCounter, colCounter);
cell.content[0] = {text: sCurChar, format: {}};
//sCurPar += "<td><span style='font-family:Calibri;font-size:11pt;white-space:nowrap'>" + sCurChar + "</span></td>";
//sHtml += "<tr>" + sCurPar + "</tr>";
}
}
if(i == length - 1)
{
addTextIntoCell(rowCounter, colCounter, sCurChar);
}
}
}
......
......@@ -2025,10 +2025,10 @@
t.clipboard.checkCopyToClipboard(ws, _clipboard, _formats);
};
WorkbookView.prototype.pasteData = function(_format, data1, data2) {
WorkbookView.prototype.pasteData = function(_format, data1, data2, text_data) {
var t = this, ws;
ws = t.getWorksheet();
t.clipboard.pasteData(ws, _format, data1, data2);
t.clipboard.pasteData(ws, _format, data1, data2, text_data);
};
WorkbookView.prototype.selectionCut = function() {
......
......@@ -273,7 +273,7 @@
}
sHtml += "</body></html>";
this.CommonIframe_PasteStart(sHtml, text_data);
this.CommonIframe_PasteStart(sHtml, _text_format);
return false;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment