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 @@ ...@@ -273,6 +273,39 @@
if(text == false) if(text == false)
return; 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(); this._startCopyOrPaste();
//исключения для opera в случае копирования пустой html //исключения для opera в случае копирования пустой html
if($(text).find('td')[0] && $(text).find('td')[0].innerText == '' && AscBrowser.isOpera) if($(text).find('td')[0] && $(text).find('td')[0].innerText == '' && AscBrowser.isOpera)
...@@ -306,6 +339,33 @@ ...@@ -306,6 +339,33 @@
this.lStorage.htmlInShape = text; this.lStorage.htmlInShape = text;
} }
else 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(); var fullUrl = this._getUseFullUrl();
window.global_pptx_content_writer.Start_UseFullUrl(fullUrl); window.global_pptx_content_writer.Start_UseFullUrl(fullUrl);
...@@ -329,29 +389,10 @@ ...@@ -329,29 +389,10 @@
var oBinaryFileWriter = new Asc.BinaryFileWriter(worksheet.model.workbook, cloneActiveRange); var oBinaryFileWriter = new Asc.BinaryFileWriter(worksheet.model.workbook, cloneActiveRange);
var sBase64 = oBinaryFileWriter.Write(); 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(); return sBase64;
if(AscBrowser.isMozilla)
t._selectElement(t._getStylesSelect);
else
t._selectElement();
this._endCopyOrPaste();
}, },
...@@ -817,6 +858,9 @@ ...@@ -817,6 +858,9 @@
}, },
_editorPaste: function (worksheet,callback) { _editorPaste: function (worksheet,callback) {
if(window.USER_AGENT_SAFARI_MACOS)
return;
var t = this; var t = this;
window.GlobalPasteFlagCounter = 1; window.GlobalPasteFlagCounter = 1;
isTruePaste = false; isTruePaste = false;
...@@ -1096,7 +1140,7 @@ ...@@ -1096,7 +1140,7 @@
if(-1 != nIndex) if(-1 != nIndex)
sHtml = sHtml.substring(0, nIndex + "</html>".length); 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; bExist = true;
var sText = e.clipboardData.getData('text/plain'); var sText = e.clipboardData.getData('text/plain');
...@@ -5235,6 +5279,22 @@ function SafariIntervalFocus2() ...@@ -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) function Editor_CopyPaste_Create2(api)
{ {
var ElemToSelect = document.createElement("div"); var ElemToSelect = document.createElement("div");
...@@ -5261,43 +5321,69 @@ function Editor_CopyPaste_Create2(api) ...@@ -5261,43 +5321,69 @@ function Editor_CopyPaste_Create2(api)
ElemToSelect.style.lineHeight = "1px"; ElemToSelect.style.lineHeight = "1px";
ElemToSelect["onpaste"] = function(e){ ElemToSelect.oncopy = function(e){
if (!window.GlobalPasteFlag) var api = window["Asc"]["editor"];
if(api.controller.isCellEditMode)
return; return;
// тут onpaste не обрубаем, так как он в сафари под macos приходить должен Editor_Copy_Event_Excel(e, ElemToSelect);
if (window.GlobalPasteFlagCounter == 1) e.preventDefault();
{
api.wb.clipboard._bodyPaste(api.wb.getWorksheet(), e);
if (window.GlobalPasteFlag)
window.GlobalPasteFlagCounter = 2;
} }
};
ElemToSelect["onbeforecopy"] = function(e){ ElemToSelect.oncut = function(e){
var ws = api.wb.getWorksheet(); var api = window["Asc"]["editor"];
if(!ws.isCellEditMode) if(api.controller.isCellEditMode)
api.wb.clipboard.copyRange(ws.getSelectedRange(), ws); 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){ ElemToSelect["onbeforecut"] = function(e){
if(!api.isCellEdited) var api = window["Asc"]["editor"];
{ if(api.controller.isCellEditMode)
var ws = api.wb.getWorksheet(); return;
api.wb.clipboard.copyRange(ws.getSelectedRange(), ws);
if(isNeedEmptyAfterCut) var selection = window.getSelection();
{ var rangeToSelect = document.createRange();
isNeedEmptyAfterCut = false;
ws.emptySelection(c_oAscCleanOptions.All); 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 ); document.body.appendChild( ElemToSelect );
//для редактора ячейки
//******для редактора ячейки
var elementText = document.createElement("textarea"); var elementText = document.createElement("textarea");
elementText.id = kElementTextId; 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