--- sc/source/ui/view/viewfun3.cxx.orig	2007-10-27 11:24:05.000000000 +0200
+++ sc/source/ui/view/viewfun3.cxx	2007-10-27 15:59:19.000000000 +0200
@@ -982,18 +982,32 @@
 		return FALSE;
 	}
 
-		//! Test auf Ueberlappung
-		//! nur wirkliche Schnittmenge testen !!!!!!!
-
-	//	pDoc->HasCommonAttr( StartCol,nStartRow, nUndoEndCol,nUndoEndRow, nStartTab,
-	//							pClipDoc, nClipStartX, nClipStartY );
+	ScDocFunc& rDocFunc = pDocSh->GetDocFunc(); 
+	if ( bRecord )
+	{
+		String aUndo = ScGlobal::GetRscString( pClipDoc->IsCutMode() ? STR_UNDO_MOVE : STR_UNDO_COPY );
+		pUndoMgr->EnterListAction( aUndo, aUndo );
+	}
 
 	if (bClipOver)
         if (lcl_SelHasAttrib( pDoc, nStartCol,nStartRow, nUndoEndCol,nUndoEndRow, rMark, HASATTR_OVERLAPPED ))
-        {        // "Cell merge not possible if cells already merged"
-			ErrorMessage(STR_MSSG_PASTEFROMCLIP_1);
-			delete pTransClip;
-			return FALSE;
+        {       // "Cell merge are possible if we unmerge cells before insertion"
+			ScRange destRange( nStartCol, nStartRow, nStartTab, nUndoEndCol, nUndoEndRow, nEndTab );
+		    rDocFunc.UnmergeCells(destRange, bRecord, TRUE);
+			for (SCCOL i = nStartCol; i <= nUndoEndCol; i++)
+				for (SCCOL j = nStartRow; j <= nUndoEndRow; j++) 
+					{
+						ScRange rrRange (i, j, nEndTab);
+						pDoc->ExtendOverlapped(rrRange);
+						pDoc->ExtendMerge(rrRange);
+						// we can have merged range in the selection, 
+						// so we take only those which are in the way
+						if (rrRange.aStart.Col() < nStartCol || rrRange.aEnd.Col() > nEndCol || 
+							rrRange.aStart.Row() < nStartRow || rrRange.aEnd.Row() > nEndRow) 
+						{
+							rDocFunc.UnmergeCells(rrRange, bRecord, TRUE);
+						}
+					}
 		}
 
 	if ( !bCutMode )
@@ -1085,7 +1099,7 @@
 
 	// skipped rows and merged cells don't mix
 	if ( !bIncludeFiltered && pClipDoc->HasClipFilteredRows() )
-		pDocSh->GetDocFunc().UnmergeCells( aUserRange, FALSE, TRUE );
+		rDocFunc.UnmergeCells( aUserRange, FALSE, TRUE );
 
     pDoc->ExtendMergeSel( nStartCol, nStartRow, nEndCol, nEndRow, rMark, TRUE );    // Refresh
 																					// und Bereich neu
@@ -1183,6 +1197,8 @@
 		}
 		else
 			pUndoMgr->AddUndoAction( pUndo );
+
+		pUndoMgr->LeaveListAction();
 	}
 
 	USHORT nPaint = PAINT_GRID;
@@ -1360,7 +1376,6 @@
         const BOOL bRecord( pDoc->IsUndoEnabled());
         ScDocument* pUndoDoc = NULL;
         ScDocument* pRedoDoc = NULL;
-        ScDocument* pRefUndoDoc = NULL;
         ScRefUndoData* pUndoData = NULL;
         SCTAB nTab = GetViewData()->GetTabNo();
         SCTAB nStartTab = nTab;
