Commit 519109c2 authored by alexey.musinov's avatar alexey.musinov

[mobile] copy/paste/cut for cell editor

parent 295ae633
...@@ -5948,50 +5948,56 @@ function offline_insertFormula(functionName, autoComplete, isDefName) { ...@@ -5948,50 +5948,56 @@ function offline_insertFormula(functionName, autoComplete, isDefName) {
function offline_copy() { function offline_copy() {
var worksheet = _api.wb.getWorksheet(); var worksheet = _api.wb.getWorksheet();
var sBase64 = {}; var sBase64 = {};
var dataBuffer = {};
if (_api.wb.cellEditor.isOpened) { if (_api.wb.cellEditor.isOpened) {
var v = _api.wb.cellEditor.copySelection(); var v = _api.wb.cellEditor.copySelection();
if (v) { if (v) {
sBase64.text = _api.wb.cellEditor._getFragmentsText(v); dataBuffer.text = _api.wb.cellEditor._getFragmentsText(v);
sBase64.sBase64 = '';
sBase64.drawingUrls = null;
} }
} else {
var clipboard = {};
clipboard.pushData = function(type, data) {
if (AscCommon.c_oAscClipboardDataFormat.Text === type) {
dataBuffer.text = data;
} else if (AscCommon.c_oAscClipboardDataFormat.Internal === type) {
if (null != data.drawingUrls && data.drawingUrls.length > 0) {
dataBuffer.drawingUrls = data.drawingUrls[0];
}
dataBuffer.sBase64 = data.sBase64;
}
}
_api.asc_CheckCopy(clipboard, AscCommon.c_oAscClipboardDataFormat.Internal|AscCommon.c_oAscClipboardDataFormat.Text);
} }
else {
sBase64 = _api.wb.clipboard.getSelectedBinary(false);
}
var _stream = global_memory_stream_menu; var _stream = global_memory_stream_menu;
_stream["ClearNoAttack"](); _stream["ClearNoAttack"]();
// TODO: для картинок и текста if (dataBuffer.text) {
if (!sBase64) _stream["WriteByte"](0);
{ _stream["WriteString2"](dataBuffer.text);
_stream["WriteByte"](255);
return _stream;
} }
_stream["WriteByte"](0); if (dataBuffer.drawingUrls) {
_stream["WriteString2"](sBase64.text);
// image
if (null != sBase64.drawingUrls && sBase64.drawingUrls.length > 0)
{
_stream["WriteByte"](1); _stream["WriteByte"](1);
_stream["WriteStringA"](sBase64.drawingUrls[0]); _stream["WriteStringA"](dataBuffer.drawingUrls);
} }
// else
//{ if (dataBuffer.sBase64) {
// owner format _stream["WriteByte"](2);
_stream["WriteByte"](2); _stream["WriteStringA"](dataBuffer.sBase64);
_stream["WriteStringA"](sBase64.sBase64); }
// }
// _stream["WriteByte"](3);
// _stream["WriteString2"](sBase64.html);
_stream["WriteByte"](255); _stream["WriteByte"](255);
return _stream; return _stream;
} }
function offline_paste(params) { function offline_paste(params) {
...@@ -6000,7 +6006,7 @@ function offline_paste(params) { ...@@ -6000,7 +6006,7 @@ function offline_paste(params) {
if (0 == type) if (0 == type)
{ {
_api.wb.clipboard._pasteTextOnSheet(params[1],worksheet); _api.asc_PasteData(AscCommon.c_oAscClipboardDataFormat.Text, params[1]);
} }
else if (1 == type) else if (1 == type)
{ {
...@@ -6008,54 +6014,65 @@ function offline_paste(params) { ...@@ -6008,54 +6014,65 @@ function offline_paste(params) {
} }
else if (2 == type) else if (2 == type)
{ {
_api.wb.clipboard._pasteFromBinaryExcel(worksheet, params[1], null, true); _api.asc_PasteData(AscCommon.c_oAscClipboardDataFormat.Internal, params[1]);
} }
} }
function offline_cut() { function offline_cut() {
var worksheet = _api.wb.getWorksheet(); var worksheet = _api.wb.getWorksheet();
var sBase64 = {};
var dataBuffer = {};
if (_api.wb.cellEditor.isOpened) { if (_api.wb.cellEditor.isOpened) {
var v = _api.wb.cellEditor.copySelection(); var v = _api.wb.cellEditor.copySelection();
if (v) { if (v) {
sBase64.text = _api.wb.cellEditor._getFragmentsText(v); dataBuffer.text = _api.wb.cellEditor._getFragmentsText(v);
sBase64.sBase64 = '';
sBase64.drawingUrls = null;
_api.wb.cellEditor.cutSelection(); _api.wb.cellEditor.cutSelection();
} }
}
else { } else {
sBase64 = _api.wb.clipboard.getSelectedBinary(true);
var clipboard = {};
clipboard.pushData = function(type, data) {
if (AscCommon.c_oAscClipboardDataFormat.Text === type) {
dataBuffer.text = data;
} else if (AscCommon.c_oAscClipboardDataFormat.Internal === type) {
if (null != data.drawingUrls && data.drawingUrls.length > 0) {
dataBuffer.drawingUrls = data.drawingUrls[0];
}
dataBuffer.sBase64 = data.sBase64;
}
}
_api.asc_CheckCopy(clipboard, AscCommon.c_oAscClipboardDataFormat.Internal|AscCommon.c_oAscClipboardDataFormat.Text);
worksheet.emptySelection(Asc.c_oAscCleanOptions.All); worksheet.emptySelection(Asc.c_oAscCleanOptions.All);
} }
var _stream = global_memory_stream_menu; var _stream = global_memory_stream_menu;
_stream["ClearNoAttack"](); _stream["ClearNoAttack"]();
// TODO: для картинок и текста if (dataBuffer.text) {
if (!sBase64) _stream["WriteByte"](0);
{ _stream["WriteString2"](dataBuffer.text);
_stream["WriteByte"](255);
return _stream;
} }
// text format if (dataBuffer.drawingUrls) {
_stream["WriteByte"](0);
_stream["WriteString2"](sBase64.text);
// image
if (null != sBase64.drawingUrls && sBase64.drawingUrls.length > 0)
{
_stream["WriteByte"](1); _stream["WriteByte"](1);
_stream["WriteStringA"](sBase64.drawingUrls[0]); _stream["WriteStringA"](dataBuffer.drawingUrls);
} }
_stream["WriteByte"](2); if (dataBuffer.sBase64) {
_stream["WriteStringA"](sBase64.sBase64); _stream["WriteByte"](2);
_stream["WriteStringA"](dataBuffer.sBase64);
}
_stream["WriteByte"](255); _stream["WriteByte"](255);
return _stream; return _stream;
} }
function offline_delete() { function offline_delete() {
......
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