Commit 3d323881 authored by Igor.Zotov's avatar Igor.Zotov Committed by Alexander.Trofimov

copy/paste для safari(mac)

копируем по событию oncopy

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@59446 954022d7-b5bf-4e40-9824-e11837661b57
parent 809ed210
......@@ -273,6 +273,39 @@
if(text == false)
return;
if(window.USER_AGENT_SAFARI_MACOS && !worksheet.isCellEditMode)
{
this._startCopyOrPaste();
this.element.appendChild(text);
History.TurnOff();
var sBase64 = this._getBinaryForCopy(worksheet);
if(isIntoShape)
sBase64 = null;
if(sBase64)
{
if(this.element.children && this.element.children.length == 1 && (window.USER_AGENT_WEBKIT || window.USER_AGENT_SAFARI_MACOS))
{
$(this.element.children[0]).css("font-weight", "normal");
$(this.element.children[0]).wrap(document.createElement("b"));
}
if(this.element.children[0])
$(this.element.children[0]).addClass("xslData;" + sBase64);
//for buttons copy/paste
this.lStorage = sBase64;
}
History.TurnOn();
this._endCopyOrPaste();
return sBase64;
}
else
{
this._startCopyOrPaste();
//исключения для opera в случае копирования пустой html
if($(text).find('td')[0] && $(text).find('td')[0].innerText == '' && AscBrowser.isOpera)
......@@ -306,6 +339,33 @@
this.lStorage.htmlInShape = text;
}
else
{
var sBase64 = this._getBinaryForCopy(worksheet);
if(this.element.children && this.element.children.length == 1 && (window.USER_AGENT_WEBKIT || window.USER_AGENT_SAFARI_MACOS))
{
$(this.element.children[0]).css("font-weight", "normal");
$(this.element.children[0]).wrap(document.createElement("b"));
}
if(this.element.children[0])
$(this.element.children[0]).addClass("xslData;" + sBase64);
//for buttons copy/paste
this.lStorage = sBase64;
}
}
History.TurnOn();
if(AscBrowser.isMozilla)
t._selectElement(t._getStylesSelect);
else
t._selectElement();
this._endCopyOrPaste();
}
},
_getBinaryForCopy: function(worksheet)
{
var fullUrl = this._getUseFullUrl();
window.global_pptx_content_writer.Start_UseFullUrl(fullUrl);
......@@ -329,29 +389,10 @@
var oBinaryFileWriter = new Asc.BinaryFileWriter(worksheet.model.workbook, cloneActiveRange);
var sBase64 = oBinaryFileWriter.Write();
if(this.element.children && this.element.children.length == 1 && (window.USER_AGENT_WEBKIT || window.USER_AGENT_SAFARI_MACOS))
{
$(this.element.children[0]).css("font-weight", "normal");
$(this.element.children[0]).wrap(document.createElement("b"));
}
if(this.element.children[0])
$(this.element.children[0]).addClass("xslData;" + sBase64);
//for buttons copy/paste
this.lStorage = sBase64;
window.global_pptx_content_writer.End_UseFullUrl()
}
};
window.global_pptx_content_writer.End_UseFullUrl();
History.TurnOn();
if(AscBrowser.isMozilla)
t._selectElement(t._getStylesSelect);
else
t._selectElement();
this._endCopyOrPaste();
return sBase64;
},
......@@ -817,6 +858,9 @@
},
_editorPaste: function (worksheet,callback) {
if(window.USER_AGENT_SAFARI_MACOS)
return;
var t = this;
window.GlobalPasteFlagCounter = 1;
isTruePaste = false;
......@@ -1096,7 +1140,7 @@
if(-1 != nIndex)
sHtml = sHtml.substring(0, nIndex + "</html>".length);
}
else if (is_chrome && fTest(e.clipboardData.types, "text/plain"))
else if (fTest(e.clipboardData.types, "text/plain"))
{
bExist = true;
var sText = e.clipboardData.getData('text/plain');
......@@ -5235,6 +5279,22 @@ function SafariIntervalFocus2()
}
}
function Editor_Copy_Event_Excel(e, ElemToSelect, isCut)
{
var api = window["Asc"]["editor"];
var wb = api.wb;
var ws = wb.getWorksheet();
var sBase64 = wb.clipboard.copyRange(ws.getSelectedRange(), ws, isCut, true);
if(isCut)
ws.emptySelection(c_oAscCleanOptions.All);
if(sBase64)
e.clipboardData.setData("text/x-custom", sBase64);
e.clipboardData.setData("text/html", ElemToSelect.innerHTML);
}
function Editor_CopyPaste_Create2(api)
{
var ElemToSelect = document.createElement("div");
......@@ -5261,43 +5321,69 @@ function Editor_CopyPaste_Create2(api)
ElemToSelect.style.lineHeight = "1px";
ElemToSelect["onpaste"] = function(e){
if (!window.GlobalPasteFlag)
ElemToSelect.oncopy = function(e){
var api = window["Asc"]["editor"];
if(api.controller.isCellEditMode)
return;
// тут onpaste не обрубаем, так как он в сафари под macos приходить должен
if (window.GlobalPasteFlagCounter == 1)
{
api.wb.clipboard._bodyPaste(api.wb.getWorksheet(), e);
if (window.GlobalPasteFlag)
window.GlobalPasteFlagCounter = 2;
Editor_Copy_Event_Excel(e, ElemToSelect);
e.preventDefault();
}
};
ElemToSelect["onbeforecopy"] = function(e){
var ws = api.wb.getWorksheet();
if(!ws.isCellEditMode)
api.wb.clipboard.copyRange(ws.getSelectedRange(), ws);
};
ElemToSelect.oncut = function(e){
var api = window["Asc"]["editor"];
if(api.controller.isCellEditMode)
return;
Editor_Copy_Event_Excel(e, ElemToSelect, true);
e.preventDefault();
}
ElemToSelect.onpaste = function(e){
var api = window["Asc"]["editor"];
var wb = api.wb;
var ws = wb.getWorksheet();
wb.clipboard._bodyPaste(ws,e);
e.preventDefault();
}
ElemToSelect["onbeforecut"] = function(e){
if(!api.isCellEdited)
{
var ws = api.wb.getWorksheet();
api.wb.clipboard.copyRange(ws.getSelectedRange(), ws);
if(isNeedEmptyAfterCut)
{
isNeedEmptyAfterCut = false;
ws.emptySelection(c_oAscCleanOptions.All);
var api = window["Asc"]["editor"];
if(api.controller.isCellEditMode)
return;
var selection = window.getSelection();
var rangeToSelect = document.createRange();
ElemToSelect.innerText = "&nbsp";
rangeToSelect.selectNodeContents (ElemToSelect);
selection.removeAllRanges ();
selection.addRange (rangeToSelect);
}
else
isNeedEmptyAfterCut = true;
ElemToSelect["onbeforecopy"] = function(e){
var api = window["Asc"]["editor"];
if(api.controller.isCellEditMode)
return;
var selection = window.getSelection();
var rangeToSelect = document.createRange();
ElemToSelect.innerText = "&nbsp";
rangeToSelect.selectNodeContents (ElemToSelect);
selection.removeAllRanges ();
selection.addRange (rangeToSelect);
}
};
document.body.appendChild( ElemToSelect );
//для редактора ячейки
//******для редактора ячейки
var elementText = document.createElement("textarea");
elementText.id = kElementTextId;
......
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