diff -uNr old/sc/source/ui/view/viewfun3.cxx new/sc/source/ui/view/viewfun3.cxx --- old/sc/source/ui/view/viewfun3.cxx 2008-11-19 15:48:00.000000000 +0800 +++ new/sc/source/ui/view/viewfun3.cxx 2009-02-19 16:59:56.000000000 +0800 @@ -185,6 +185,9 @@ #include #include +#include "attrib.hxx" +#include "patattr.hxx" +#include "dociter.hxx" #include "viewfunc.hxx" #include "tabvwsh.hxx" #include "docsh.hxx" @@ -1058,11 +1061,35 @@ // 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, aFilteredMark, HASATTR_OVERLAPPED )) { // "Cell merge not possible if cells already merged" - ErrorMessage(STR_MSSG_PASTEFROMCLIP_1); - return FALSE; + ScDocAttrIterator aIter( pDoc, nStartTab, nStartCol, nStartRow, nUndoEndCol, nUndoEndRow ); + const ScPatternAttr* pPattern = NULL; + const ScMergeAttr* pMergeFlag = NULL; + const ScMergeFlagAttr* pMergeFlagAttr = NULL; + SCCOL nCol = -1; + SCROW nRow1 = -1; + SCROW nRow2 = -1; + while ( ( pPattern = aIter.GetNext( nCol, nRow1, nRow2 ) ) != NULL ) + { + pMergeFlag = (const ScMergeAttr*) &pPattern->GetItem(ATTR_MERGE); + pMergeFlagAttr = (const ScMergeFlagAttr*) &pPattern->GetItem(ATTR_MERGE_FLAG); + if( ( pMergeFlag && pMergeFlag->IsMerged() ) || ( pMergeFlagAttr && pMergeFlagAttr->IsOverlapped() ) ) + { + ScRange aRange(nCol, nRow1, nStartTab); + pDoc->ExtendOverlapped(aRange); + pDoc->ExtendMerge(aRange, TRUE, TRUE); + rDocFunc.UnmergeCells(aRange, bRecord, TRUE); + } + } } if ( !bCutMode ) @@ -1156,7 +1183,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, aFilteredMark, TRUE ); // Refresh // und Bereich neu @@ -1254,6 +1281,7 @@ } else pUndoMgr->AddUndoAction( pUndo ); + pUndoMgr->LeaveListAction(); } USHORT nPaint = PAINT_GRID;