From 8e1c4264629be56ff857abbd52ead5fb583c0157 Mon Sep 17 00:00:00 2001
From: "Igor.Zotov" <Igor.Zotov@OnlyOffice.com>
Date: Fri, 2 Aug 2013 10:03:09 +0000
Subject: [PATCH] =?UTF-8?q?copy/paste/cut=20=D0=B4=D0=BB=D1=8F=20safari=20?=
 =?UTF-8?q?MAC?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@48460 954022d7-b5bf-4e40-9824-e11837661b57
---
 Excel/model/clipboard.js   | 33 ++++++++++++++++++++++++---------
 Excel/view/WorkbookView.js |  4 ++--
 2 files changed, 26 insertions(+), 11 deletions(-)

diff --git a/Excel/model/clipboard.js b/Excel/model/clipboard.js
index 366c0b1a7..88aa29300 100644
--- a/Excel/model/clipboard.js
+++ b/Excel/model/clipboard.js
@@ -2556,6 +2556,7 @@ var COPY_ELEMENT_ID = "clipboard-helper";
 var PASTE_ELEMENT_ID = "wrd_pastebin";
 var ELEMENT_DISPAY_STYLE = "none";
 var kElementTextId = "clipboard-helper-text";
+var isNeedEmptyAfterCut = false;
 
 if (window.USER_AGENT_SAFARI_MACOS)
 {
@@ -2577,7 +2578,7 @@ function SafariIntervalFocus()
 		}	
 		else if (pastebin && api.IsFocus)
             pastebin.focus();
-        else
+        else if(!pastebin || !pastebinText)
         {
             // create
             Editor_CopyPaste_Create(api);
@@ -2614,9 +2615,16 @@ function Editor_CopyPaste_Create(api)
 		api.wb.clipboard.copyRange(api.wb.getWorksheet().getSelectedRange(), api.wb.getWorksheet());
     };
 	
-	/*ElemToSelect["onbeforecut"] = function(e){
+	ElemToSelect["onbeforecut"] = function(e){
 		api.wb.clipboard.copyRange(api.wb.getWorksheet().getSelectedRange(), api.wb.getWorksheet());
-    };*/
+		if(isNeedEmptyAfterCut)
+		{
+			isNeedEmptyAfterCut = false;
+			api.wb.getWorksheet().setSelectionInfo("empty", c_oAscCleanOptions.All);
+		}
+		else
+			isNeedEmptyAfterCut = true;		
+    };
 
     document.body.appendChild( ElemToSelect );
 	
@@ -2643,13 +2651,20 @@ function Editor_CopyPaste_Create(api)
 		}	
     };
 	
-	/*elementText["onbeforecut"] = function(e){
-		if((api.wb && api.wb.getWorksheet() && api.wb.getWorksheet().isCellEditMode))
+	elementText["onbeforecut"] = function(e){
+		api.wb.clipboard.copyRange(api.wb.getWorksheet().getSelectedRange(), api.wb.getWorksheet());
+		if(isNeedEmptyAfterCut == true)
 		{
-			v = api.wb.cellEditor.copySelection();
-			if (v) {api.wb.clipboard.copyCellValue(v, api.wb.cellEditor.hasBackground ? api.wb.cellEditor.background : null);}
-		}	
-    };*/
+			isNeedEmptyAfterCut = false;
+			if((api.wb && api.wb.getWorksheet() && api.wb.getWorksheet().isCellEditMode))
+			{
+				v = api.wb.cellEditor.cutSelection();
+				if (v) {api.wb.clipboard.copyCellValue(v, api.wb.cellEditor.hasBackground ? api.wb.cellEditor.background : null);}
+			}	
+		}
+		else
+			isNeedEmptyAfterCut = true;		
+    };
 	
 	/*elementText["onpaste"] = function(e){
 		api.wb.clipboard.pasteAsText();
diff --git a/Excel/view/WorkbookView.js b/Excel/view/WorkbookView.js
index fc45348d3..7bfcd7ee9 100644
--- a/Excel/view/WorkbookView.js
+++ b/Excel/view/WorkbookView.js
@@ -1232,11 +1232,11 @@
 
 			cutToClipboard: function () {
 				var t = this, ws, v;
-				if (!t.controller.isCellEditMode) {
+				if (!t.controller.isCellEditMode && !window.USER_AGENT_SAFARI_MACOS) {
 					ws = t.getWorksheet();
 					t.clipboard.copyRange(ws.getSelectedRange(), ws);
 					ws.setSelectionInfo("empty", c_oAscCleanOptions.All);
-				} else {
+				} else if(!window.USER_AGENT_SAFARI_MACOS){
 					v = t.cellEditor.cutSelection();
 					if (v) {t.clipboard.copyCellValue(v, t.cellEditor.hasBackground ? t.cellEditor.background : null);}
 				}
-- 
2.30.9